chem-generic-ui 2.1.1 → 2.2.0-rc1

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.
@@ -0,0 +1,17 @@
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".react-flow__selection{background:#0059dc14;border:1px dotted rgba(0,89,220,.8)}.react-flow__edge.selected .react-flow__edge-path{stroke:#555}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-path{stroke:#b1b1b7;stroke-width:1}.react-flow__edge-text{font-size:10px}.react-flow__edge-textbg{fill:#fff}.react-flow__connection-path{stroke:#b1b1b7;stroke-width:1}.react-flow__node{cursor:grab}.react-flow__node-default,.react-flow__node-input,.react-flow__node-output{padding:10px;border-radius:3px;width:150px;font-size:12px;color:#222;text-align:center;border-width:1px;border-style:solid}.react-flow__node-default.selectable:hover,.react-flow__node-input.selectable:hover,.react-flow__node-output.selectable:hover{box-shadow:0 1px 4px 1px #00000014}.react-flow__node-input{background:#fff;border-color:#0041d0}.react-flow__node-input.selected,.react-flow__node-input.selected:hover{box-shadow:0 0 0 .5px #0041d0}.react-flow__node-input .react-flow__handle{background:#0041d0}.react-flow__node-default{background:#fff;border-color:#1a192b}.react-flow__node-default.selected,.react-flow__node-default.selected:hover{box-shadow:0 0 0 .5px #1a192b}.react-flow__node-default .react-flow__handle{background:#1a192b}.react-flow__node-output{background:#fff;border-color:#ff0072}.react-flow__node-output.selected,.react-flow__node-output.selected:hover{box-shadow:0 0 0 .5px #ff0072}.react-flow__node-output .react-flow__handle{background:#ff0072}.react-flow__nodesselection-rect{background:#0059dc14;border:1px dotted rgba(0,89,220,.8)}.react-flow__handle{position:absolute;width:6px;height:6px;background:#555;border:1px solid white;border-radius:100%}.react-flow__handle.connectable{cursor:crosshair}.react-flow__minimap{background-color:#fff}.react-flow__controls{box-shadow:0 0 2px 1px #00000014}.react-flow__controls-button{background:#fefefe;border-bottom:1px solid #eee;box-sizing:content-box;display:flex;justify-content:center;align-items:center;width:16px;height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding:5px}.react-flow__controls-button svg{max-width:12px;max-height:12px}.react-flow__controls-button:hover{background:#f4f4f4}.gu_flow_default_element .add{position:absolute;top:0;right:2px;color:#337ab7}.gu_flow_default_element .chk{position:absolute;top:0;right:2px;color:green}.gu_flow_default_element .border_line{border-width:0px 0px 1px 0px;border-style:solid;border-color:#000}.gu_flow_default_element .border_line.invalid{border-color:#f08080}.overview-example__add{display:none}.react-flow__node a{font-weight:700;color:#111}.react-flow__node.dark-node{background:#0041d0;color:#f8f8f8}.react-flow__node.dark{background:#557;color:#f8f8f8}.react-flow__node-selectorNode{font-size:12px;background:#f0f2f3;border:1px solid 555;border-radius:5px;text-align:center}.react-flow__node-selectorNode .react-flow__handle{border-color:#f0f2f3}@media screen and (min-width:768px){.overview-example__add{display:block}}.dndflow{flex-direction:column;display:flex;flex-grow:1;height:100%}.dndflow aside>*{margin-bottom:10px;cursor:grab}.dndflow aside{background:#eee;border-right:1px solid #777;flex-grow:1;font-size:12px;overflow:auto;padding:15px 10px;max-width:190px}.dndflow aside .description{margin-bottom:10px}.dndflow .dndnode{height:20px;padding:4px;border:1px solid #1a192b;border-radius:2px;margin-bottom:10px;display:flex;justify-content:center;align-items:center}.dndflow .dndnode:hover{box-shadow:0 0 2.6px #0dcaf0;border-color:#5bc0de}.dndflow .reactflow-wrapper{flex-grow:1;height:100%}.dndflow .selectall{margin-top:10px}@media screen and (min-width:768px){.dndflow{flex-direction:row}.dndflow aside{width:20%;max-width:190px}}.providerflow{flex-direction:column;display:flex;height:100%}.providerflow aside{border-right:1px solid #eee;padding:15px 10px;font-size:12px;background:#fcfcfc}.providerflow aside .description{margin-bottom:10px}.providerflow aside .title{font-weight:700;margin-bottom:5px}.providerflow aside .transform{margin-bottom:20px}.providerflow .reactflow-wrapper{flex-grow:1;height:100%}.providerflow .selectall{margin-top:10px}@media screen and (min-width:768px){.providerflow{flex-direction:row}.providerflow aside{width:20%;max-width:250px}}.save__controls{position:absolute;right:10px;top:10px;z-index:4;font-size:12px}.save__controls button{margin-left:5px}.gu-full-modal{width:90vw;height:90vh;max-width:none;margin-left:auto;margin-right:auto}.gu-full-modal .modal-content{height:100%}.gu-full-modal .modal-content .modal-body{height:92%}.gu-full-modal ::-webkit-scrollbar{background:transparent;overflow:visible;width:17px}.gu-full-modal ::-webkit-scrollbar-thumb{background-color:#0003;border:solid #fff}.gu-full-modal ::-webkit-scrollbar-thumb:hover{background:#000c}.gu-full-modal ::-webkit-scrollbar-thumb:horizontal{border-width:4px 6px;min-width:40px}.gu-full-modal ::-webkit-scrollbar-thumb:vertical{border-width:6px 4px;min-height:40px}.gu-full-modal ::-webkit-scrollbar-track-piece{background-color:#fff}.gu-full-modal ::-webkit-scrollbar-corner{background:transparent}.gu-full-modal ::-webkit-scrollbar-thumb{background-color:#adadad;-webkit-box-shadow:inset 1px 1px 0 rgba(0,0,0,.1),inset 0 -1px 0 rgba(0,0,0,.07)}.gu-full-modal ::-webkit-scrollbar-thumb:hover{background-color:#999}.gu_modal-68w{width:68%!important;max-width:none!important}.gu-full-width-panel{white-space:normal;width:100%;padding:5px;border:2px solid red;border-style:ridge;box-sizing:border-box;background-color:#9994;font-family:inherit}.gu-full-width-center{border:1px solid grey;padding:2px;box-sizing:border-box;font-family:cursive;background-color:#9994;font-family:inherit}.element-select-modal{z-index:9999!important}.element-select-modal .modal-backdrop{z-index:9998!important}:root{--gu-ml-0: 0;--gu-mr-0: 0;--gu-mb-0: 0;--gu-ml-1: .25rem;--gu-mr-1: .25rem;--gu-mb-1: .25rem;--gu-ml-2: .5rem;--gu-mr-2: .5rem;--gu-mb-2: .5rem;--gu-ml-3: 1rem;--gu-mr-3: 1rem;--gu-mb-3: 1rem;--gu-ml-4: 1.5rem;--gu-mr-4: 1.5rem;--gu-mb-4: 1.5rem;--gu-ml-5: 3rem;--gu-mr-5: 3rem;--gu-mb-5: 3rem}::placeholder{color:#adb5bd!important}::-webkit-input-placeholder{color:#adb5bd!important}:-moz-placeholder{color:#adb5bd!important}::-moz-placeholder{color:#adb5bd!important}:-ms-input-placeholder{color:#adb5bd!important}.Select-placeholder,[class$=-placeholder],.react-select__placeholder{color:#adb5bd!important}.gu-ml-0{margin-left:0}.gu-ml-1{margin-left:.25rem}.gu-ml-2{margin-left:.5rem}.gu-ml-3{margin-left:1rem}.gu-ml-4{margin-left:1.5rem}.gu-mr-0{margin-right:0}.gu-mr-1{margin-right:.25rem}.gu-mr-2{margin-right:.5rem}.gu-mr-3{margin-right:1rem}.gu-mr-4{margin-right:1.5rem}.gu-mr-auto{margin-right:auto}.gu-mb-0{margin-bottom:0}.gu-mb-1{margin-bottom:.25rem}.gu-mb-2{margin-bottom:.5rem}.gu-mb-3{margin-bottom:1rem}.gu-mb-4{margin-bottom:1.5rem}.btn-gxs,.btn-group-gxs>.btn{padding:1px 5px;font-size:12px;line-height:1.5;border-radius:3px}.gu-no-pointer{cursor:default;-webkit-text-decoration:none;text-decoration:none}.gu-no-pointer:hover{-webkit-text-decoration:none;text-decoration:none}.gu-ont-display{margin-left:.5rem;background-color:green!important;color:#fff!important;border:green solid 1px}.gu-ont-display:hover{border-color:green!important}.gu-menu-item-del{color:red!important}.gu-menu-item-del:hover,.gu-menu-item-del:focus,.gu-menu-item-del:active{color:#fff!important;background-color:red!important}.gu-menu-item-cond{color:#fe9600!important}.gu-menu-item-cond:hover,.gu-menu-item-cond:focus,.gu-menu-item-cond:active{color:#fff!important;background-color:#fe9600!important}.gu-square-corners{border-radius:0!important}.accordion .accordion-item .accordion-header.custom-accordion-header .accordion-button{padding:0rem 1rem!important;background-color:inherit!important}.gu-bg-light{background-color:#eef1f2!important}.gu-bg-white{background-color:#fff!important}.gu-datepicker .react-datepicker{display:flex!important}.gu-datepicker .react-datepicker__header{padding-top:.8rem!important}.gu-datepicker .react-datepicker-wrapper{width:auto!important;width:initial!important}.ug-no-caret .dropdown-toggle:after{display:none!important}.ug-input-group .ug-no-caret .dropdown-toggle:after{display:none!important}.panel_generic_properties.accordion-item:focus,.panel_generic_properties.accordion-item:active,.panel_generic_properties.accordion-item.show{border:none;box-shadow:none}.panel_generic_properties.accordion-item .accordion-button:focus,.panel_generic_properties.accordion-item .accordion-button:active{border:none;box-shadow:none}.panel_generic_properties.accordion-item .accordion-button:not(.collapsed){box-shadow:none;background-color:transparent;color:inherit}.panel_generic_properties.accordion-item .accordion-button:after{display:none!important}.panel_generic_properties.accordion-item:hover{border:none;box-shadow:none}.lu-bg-light{background-color:#eef1f2!important}.lu-bg-white{background-color:#fff!important}.lu-ds-element-accordion-header .accordion-button:after{display:none!important}.lu-ds-element-accordion-header .accordion-button{box-shadow:none!important;height:2.7rem!important;border:none!important;background-color:transparent!important;color:#000!important;padding:0rem 1rem!important}.lu-ds-element-accordion-header .accordion-button:not(.collapsed){background-color:transparent!important;color:#000!important}.lu_dot-progress-container{display:flex;gap:2px;align-items:center}.lu_dot{width:8px;height:8px;border:1px solid transparent;transition:all .2s ease}.lu_dot.shape-dot{border-radius:50%}.lu_dot.shape-square{border-radius:20%;width:9px;height:9px}.lu_dot.filled{border-color:transparent}.lu_dot.filled.variant-success{background-color:green}.lu_dot.filled.variant-warning{background-color:#f0ad4e}.lu_dot.filled.variant-danger{background-color:red}.lu_dot.filled.variant-primary{background-color:#337ab7}.lu_dot.filled.variant-info{background-color:#5bc0de}.lu_dot.empty{background-color:transparent}.lu_dot.empty.variant-success{border-color:#00800066}.lu_dot.empty.variant-warning{border-color:#f0ad4e66}.lu_dot.empty.variant-danger{border-color:#f006}.lu_dot.empty.variant-primary{border-color:#337ab766}.lu_dot.empty.variant-info{border-color:#5bc0de66}.gu_can-drop,.generic_grid_dnd.can-drop{border:2px dashed lightgrey!important;color:#d3d3d3!important;opacity:1!important;cursor:copy}.gu_is-over,.generic_grid_dnd.is-over{border:2px dashed #31708f!important;color:#31708f!important;opacity:1!important}.gu_is-dragging,.generic_grid_dnd.is-dragging{opacity:.2;cursor:not-allowed}.gu_btn_text_success{color:green}.gu_btn_text_danger{color:red}.gu_flow_dnd_sidebar{border-width:0px 0px 1px 0px;border-color:#000;border-style:solid}.gu_sp_form{display:flex;align-items:center;flex-wrap:wrap;margin-bottom:5px}.gu_sp_form .gu_sp_label{width:100%;margin:0 5px;text-align:left;font-weight:700}.gu_sp_form .gu_sp_column{width:100%;margin-top:0;margin-bottom:0}.gu_button_right{float:right;right:0;z-index:0;margin-left:2px}.bg-bs-primary{background-color:#337ab7!important}.bg-bs-warning{background-color:#f0ad4e!important}.lbg-outline-default{background-color:transparent!important;background-color:initial!important;color:#9a6700!important;border:#9a6700 solid 1px}.lbg-outline-primary{background-color:transparent!important;background-color:initial!important;color:#337ab7!important;border:#337ab7 solid 1px}.lbg-outline-warning{background-color:transparent!important;background-color:initial!important;color:#fe9600!important;border:#fe9600 solid 1px}.icon_generic_nav{font-family:FontAwesome,Helvetica,Arial,sans-serif!important}.field_required{background-color:#ffffe0}.template_panel_heading{display:flex;justify-content:space-between;align-items:center;padding:5px 10px!important;width:100%}.template_panel_heading_reset{padding:0;border-bottom:0;border-bottom:initial;border-top-left-radius:0;border-top-left-radius:initial;border-top-right-radius:0;border-top-right-radius:initial}.panel_generic_properties{border-left:0!important;border-left:initial!important;border-right:0!important;border-right:initial!important;border-bottom:0!important;border-bottom:initial!important;line-height:26px!important;box-shadow:none!important;box-shadow:initial!important;margin-bottom:0!important;margin-bottom:initial!important;font-size:inherit!important}.panel_generic_properties .panel-title{font-weight:700}.panel_generic_properties .default_style{font-size:14px;line-height:normal}.panel_generic_properties_body{padding-left:0!important;padding-left:initial!important;padding-right:0!important;padding-right:initial!important}.panel_generic_heading_slim{padding:5px 0!important}.panel_generic_heading{font-weight:700;padding:0!important;padding:initial!important}.panel_generic_heading_bu{font-weight:700;padding:0!important;padding:initial!important;-webkit-text-decoration:underline;text-decoration:underline}.panel_generic_heading_bui{font-weight:700;padding:0!important;padding:initial!important;-webkit-text-decoration:underline;text-decoration:underline;font-style:italic}.props_text .dummy{background-color:transparent!important;background-color:initial!important;border:medium none currentcolor!important;border:initial!important;box-shadow:none!important;box-shadow:initial!important}.props_text .editable{background-color:#fff}.props_text .readonly{background-color:#f2f2f2}.props_text .required{background-color:#ffffe0}.props_text input:invalid{border:1px solid lightcoral}.props_text .form-control.readonly{background-color:#f2f2f2!important}.select_generic_properties_editable .Select-control{background-color:#fff}.select_generic_properties_readonly .Select-control{background-color:#f2f2f2}.select_generic_properties_required .Select-control{background-color:#ffffe0}.drop_generic_properties{display:flex;align-items:center}.drop_generic_properties .target{height:100%;width:100%;margin:0 10px;display:inline-block}.drop_generic_properties .target .indicator{font-size:x-large}.drop_generic_properties .target .s-img{display:flex}.drop_generic_properties .target .s-img img{height:4vh;width:4vw}.drop_generic_properties .target .data{font-size:medium;line-height:normal!important;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;align-self:center;width:100%}.drop_generic_properties .target.can-drop .indicator,.drop_generic_properties .target.can-drop .data{border:2px dashed lightgrey;color:#d3d3d3}.drop_generic_properties .target.is-over .indicator,.drop_generic_properties .target.is-over .data{border:2px dashed #31708f;color:#31708f}.drop_generic_properties .btn_del{float:right;align-self:center}.drop_generic_properties .sample_radios{font-size:xx-small;line-height:2;display:inline-flex;padding-right:5px}.generic_criteria_modal{display:block;padding-left:0;top:45%!important;width:75vw!important}.search_criteria_mof .modal_body{max-height:70vh;height:70vh;overflow:auto}.search_criteria_mof .btn_footer{margin-top:10px}.input-form .input-group-addon{font-weight:700}.input-form .help{font-size:80%;font-style:italic;margin-left:.5rem!important;margin-left:var(--gu-ml-2)!important;margin-right:.5rem!important;margin-right:var(--gu-mr-2)!important}.g-ds-note{color:#000!important;float:left!important;text-align:left!important;font-weight:lighter!important}.g-ds-note .g-ds-title{-webkit-text-decoration:underline;text-decoration:underline;font-weight:700;line-height:1.5}.g_input_group{padding:6px!important}.g_input_group_label{background-color:#d3d3d3!important;width:auto!important;width:initial!important;white-space:nowrap!important;padding:6px!important}.g_col_w{width:20%!important}.generic_grid{display:block}.generic_grid>div{display:flex;flex-wrap:nowrap}.generic_grid_header{width:100%;margin:6px 0 6px 6px;text-align:center;line-height:15px;align-self:center;font-weight:bolder;font-family:Franklin Gothic Medium,Arial Narrow,Arial,sans-serif}.generic_grid_row{width:100%;margin:6px 0 6px 6px;text-align:center;line-height:15px;align-self:center}.generic_grid_row_left{text-align:left}.generic_version{background-color:#777;display:inline-block;padding:.35em .65em;font-size:.75em;text-align:center;vertical-align:baseline;white-space:nowrap;border-radius:.5rem;color:#fff;background-color:transparent;background-color:initial;color:#00f}.generic_version_draft{background-color:#777;display:inline-block;padding:.35em .65em;font-size:.75em;text-align:center;vertical-align:baseline;white-space:nowrap;border-radius:.5rem;color:#fff;background-color:transparent;background-color:initial;color:#000}.generic_panel_none{border-color:#ddd!important}.generic_panel_none>.panel-heading{background-color:#fff!important}.generic_attr_chks{display:inline-flex;align-items:center}.generic_attr_chks>input{margin-top:0}.generic_attr_chks>label{padding-left:4px}.generic_btn_default{background-color:#777!important;color:#fff!important}.drop_generic_table_wrap .target .s-img{position:relative;border:1px solid transparent}.drop_generic_table_wrap .target .s-img img{height:4vw;width:4vw}.drop_generic_table_wrap .target .s-img .del_btn{position:absolute;top:0%;left:0%}.drop_generic_table_wrap .target .s-img .link_btn{position:absolute;bottom:0%;left:0%}.drop_generic_table_wrap .target .s-img:hover{border:1px solid #0dcaf0}.drop_generic_table_wrap .target .data{font-size:inherit;white-space:inherit;text-align:left}.drop_generic_table_wrap .target.can-drop .s-img{border:2px dashed lightgrey;color:#d3d3d3}.drop_generic_table_wrap .target.is-over .s-img{border:2px dashed #31708f;color:#31708f}.generic_grid_img{border:hsl(0,0%,95%) solid thin}.generic_sam_options{display:flex;flex-direction:column;text-align:left;font-size:x-small}.generic_sam_options .radio{margin-top:0;margin-top:initial;margin-bottom:0;margin-bottom:initial}.generic_files{padding:0 5px!important}.generic_files>div>div>div{text-align:left;align-self:center}.generic_files>div>div>div .form-group{margin-bottom:0}.generic_files .file_text{overflow:hidden;text-overflow:ellipsis}.grid-btn-none{font-size:large;color:#fff}.generic_grid_dnd>div{width:100%}.generic_grid_dnd>div>div{vertical-align:middle}.generic_grid_dnd .dnd{cursor:move}.generic_grid_dnd .dnd-btn{font-size:large}.generic_grid_dnd .dnd-btn span{cursor:move}.dnd-btn{font-size:large}.dnd-btn span{cursor:move}.generic_layer_modal>.layer_header{background-color:#fff;color:#337ab7;font-size:20px}.generic_layer_column{width:100%;text-align:center;line-height:15px;align-self:center;border:1px solid #337ab7;background-color:#fff;margin:5px;padding:10px;color:#337ab7;border-radius:4px}.generic_layer_column>div:first-child{display:flex}.generic_layer_column>div:first-child>button{float:right;border-radius:50%}.generic_layer_column>div:first-child>div{width:100%}.generic_wf_modal{max-height:100%;overflow:auto}.generic_wf_modal>div:first-child{height:100vh;width:100%}.flow_view_draggable{z-index:100;width:50vw;top:12%;left:10%}.flow_view_draggable .panel-body{padding:5px}.flow_view_draggable .panel-body>.body_bg{max-height:100%;overflow:auto}.flow_view_draggable .panel-body>.body_bg>.body_canvas{resize:both;overflow:auto;height:70vh;width:40vw;min-height:250px;min-width:900px;max-width:1600px;max-height:840px}.gu_date_picker{margin-right:2px}.gu_date_picker input{border-radius:4px;box-shadow:inset 0 2px 2px #e9e9e9;border:1px solid #ccc;padding:4px 12px;width:100%}.gu_date_picker-clear:after{background-color:#000!important}.gu_date_picker_layer{display:inline-flex;line-height:normal;float:right}.gu_datetime_range{display:flex;flex-wrap:nowrap}.gu_datetime_range div{width:100%}.gu_btn_broup_layer{display:table}.gu_btn_broup_layer>div{display:table-cell;vertical-align:middle;line-height:normal;line-height:initial}.gu_btn_broup_layer .form-group{margin-bottom:0;margin-bottom:initial;float:left}.pre_line_tooltip .tooltip-inner{white-space:pre-wrap!important}.drag-layer-preview{pointer-events:none;position:fixed;top:0;left:0;z-index:9999;transform:translate(-50%,-50%);display:flex;align-items:center;justify-content:center}.drag-item-content{background-color:#fff;border:1px solid #cccccc;padding:8px 12px;border-radius:4px;box-shadow:0 4px 12px #00000026;font-weight:500;color:#333;white-space:nowrap}.gu-btn-outline-secondary:hover{color:#fff!important;background-color:#6c757d!important;border-color:#6c757d!important}.gu-btn-outline-primary:hover{color:#fff!important;background-color:#0d6efd!important;border-color:#0d6efd!important}.prog-overview-dashboard{background-image:radial-gradient(#aaa 1px,transparent 0);background-size:16px 16px;background-color:#f8f9fa;padding:15px;border-radius:8px;border:1px solid #eee}.lu_square-progress,.lu_square-progress .progress-bar{border-radius:0!important}.lu_details-marked{background-color:#337ab70d;border-radius:4px;padding-right:8px!important;font-weight:600}.lu_details-marked:hover{background-color:#337ab71a}@keyframes lu-border-flash{0%{box-shadow:0 0 #fffbdd00}15%{box-shadow:0 0 0 6px #ffe733e6,0 0 25px 8px #fffbdd40}to{box-shadow:0 0 #fffbdd00}}.lu_jump-highlight{position:relative;z-index:10;border-radius:4px;animation:lu-border-flash 4s cubic-bezier(.19,1,.22,1)}.gu-form-group{align-items:center;display:inline-flex;width:100%}.gu-form-group>div[class^=col-]{padding-right:0}.gu-form-group .gu-form-group-label{float:right;font-weight:700}.gu-ontology-select-code-prefix{border-radius:.375rem;float:right;background-color:#337ab7!important}.gu-ontology-select-code-short{border-radius:.375rem;float:right;background-color:#5bc0de!important}.gu-ontology-text-link a{font-size:inherit;line-height:inherit;padding:0;padding:initial}.gu-xsmall-input-group.gu-xsmall-input-group>input,.gu-xsmall-input-group.gu-xsmall-input-group>span{min-height:calc(1.5em + .5rem + var(--bs-border-width) * 2);font-size:.875rem;height:2.2rem;padding:.25rem .5rem}.lu-drop-zone{border:3px dashed lightgrey;color:gray;text-align:center;width:100%}.gu-editable{background-color:#fff!important}.gu-readonly{background-color:#f2f2f2!important}.gu-required{background-color:#ffffe0!important}.gu-designer-template-bar{margin:20px 0 0;display:inline-flex;width:100%;align-items:stretch}.gu-designer-template-bar button:nth-child(2){margin-left:5px}.gu-designer-template-bar>span{display:flex;flex:1;align-items:center;margin-left:10px;padding:0 10px;border-radius:5px}.gu-designer-template-bar>span>span{width:99%}.lu-link{color:#0d6efd!important;-webkit-text-decoration:none;text-decoration:none;cursor:pointer}.lu-link:hover{color:#0a58ca!important;-webkit-text-decoration:underline;text-decoration:underline}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("reactflow/dist/style.css");require("ag-grid-community/styles/ag-grid.css");require("ag-grid-community/styles/ag-theme-alpine.css");require("ag-grid-community/styles/ag-theme-balham.css");require("ag-grid-community/styles/ag-theme-quartz.css");const m=require("generic-ui-core"),e=require("react/jsx-runtime"),g=require("react"),c=require("react-bootstrap"),X=require("lodash/cloneDeep"),ce=require("lodash/sortBy"),l=require("prop-types"),Vl=require("lodash"),Ds=require("@fortawesome/react-fontawesome"),W=require("@fortawesome/free-solid-svg-icons"),Oe=require("@fortawesome/free-regular-svg-icons"),ie=require("uuid"),Se=require("ag-grid-react"),he=require("react-bootstrap/Col"),_e=require("react-bootstrap/Row"),Jt=require("react-bootstrap/Badge"),Ne=require("react-bootstrap/Button"),be=require("react-dnd"),zl=require("react-dnd-html5-backend"),Ie=require("lodash/findIndex"),Yl=require("react-bootstrap/Accordion");require("react-datepicker/dist/react-datepicker.css");const Os=require("react-dropzone"),Ue=require("react-select"),it=require("moment"),Hl=require("lodash/round");require("moment-precise-range-plugin");const Wl=require("numeral"),Kl=require("copy-to-clipboard"),Xl=require("react-svg-file-zoom-pan"),Zl=require("react-datepicker"),Ps=require("lodash/filter"),Ql=require("mathjs"),js=require("react-bootstrap/ButtonGroup"),Jl=require("react-bootstrap/OverlayTrigger"),ea=require("react-bootstrap/Tooltip"),re=require("reactflow"),hr=require("lodash/orderBy"),ta=require("react-select/async"),mr=require("lodash/isArray"),sa=require("lodash/mergeWith"),Vr=require("ajv"),na=require("lodash/findKey"),ra=require("react-bootstrap/Form"),zr=require("jsondiffpatch"),ia=require("diff"),yr=require("react-bootstrap/ButtonToolbar"),la=require("react-draggable"),aa=require("lodash/isEmpty"),de=({children:s,className:t,...n})=>e.jsx(c.Form.Group,{className:`mb-3 ${t||""}`,...n,children:s});de.propTypes={children:l.node.isRequired,className:l.string};de.defaultProps={className:""};const Gs=g.forwardRef(({element:s,editable:t},n)=>{const r=g.useRef(),i=g.useRef(),a=g.useRef(),o=g.useRef(),d=g.useRef();return g.useImperativeHandle(n,()=>({k_name:r.current,k_prefix:i.current,k_label:a.current,k_iconname:o.current,k_desc:d.current})),e.jsxs(c.Form,{className:"row input-form",children:[e.jsxs(de,{controlId:"formControlKlass",children:[e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Element"}),e.jsx(c.Form.Control,{type:"text",defaultValue:s.name,ref:r,disabled:!t})]}),e.jsxs("div",{className:"help",children:["Element must be at least 3 characters long and can not be longer than 10 characters",e.jsx("br",{}),"Element is only lowercase letters allowed",e.jsx("br",{}),"Element should not contain special characters like $, !, %, etc."]})]}),e.jsxs(de,{controlId:"formControlPrefix",children:[e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Prefix"}),e.jsx(c.Form.Control,{type:"text",defaultValue:s.klass_prefix,ref:i})]}),e.jsxs("div",{className:"help",children:["Prefix is used to define the prefix of Element label",e.jsx("br",{}),"Prefix should not contain special characters like $, !, %, etc."]})]}),e.jsx(de,{controlId:"formControlLabel",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Element Label"}),e.jsx(c.Form.Control,{type:"text",defaultValue:s.label,ref:a})]})}),e.jsxs(de,{controlId:"formControlIcon",children:[e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Icon"}),s.icon_name?e.jsx(c.InputGroup.Text,{children:e.jsx("i",{className:s.icon_name})}):null,e.jsx(c.Form.Control,{type:"text",defaultValue:s.icon_name,ref:o})]}),e.jsxs("div",{className:"help",children:["Icon is used to represent a particular element. Please use the icon code from",e.jsx(c.Button,{variant:"link",size:"sm",href:"https://fontawesome.com/v4.7/icons/",target:"_blank",children:"Font Awesome 4"}),". The icon code format is like ‘ fa fa-abc ’."]})]}),e.jsx(de,{controlId:"formControlDescription",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Description"}),e.jsx(c.Form.Control,{type:"text",defaultValue:s.desc,ref:d})]})})]})});Gs.displayName="KlassAttrForm";Gs.propTypes={element:l.object.isRequired,editable:l.bool.isRequired};const Yr=g.createContext(),oa=({children:s,value:t})=>e.jsx(Yr.Provider,{value:t,children:s}),Ms=()=>{const s=g.useContext(Yr);if(s===void 0)throw new Error("useDesignerContext must be used within a DesignerProvider");return s},$s=g.forwardRef(({element:s,editable:t},n)=>{const{klasses:r}=Ms(),i=g.useRef(),a=g.useRef(),o=g.useRef();g.useImperativeHandle(n,()=>({k_label:i.current,k_desc:a.current,k_klass:o.current}));const d=r?.filter(f=>f.is_active!==!1),p=Vl.sortBy(d,["label"])?.map(f=>e.jsx("option",{value:f.id,children:f.label},f.id));return e.jsxs(c.Form,{className:"row input-form",children:[e.jsx(de,{controlId:"formControlLabel",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Segment Label"}),e.jsx(c.Form.Control,{type:"text",defaultValue:s.label,ref:i})]})}),e.jsx(de,{controlId:"formControlDescription",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Description"}),e.jsx(c.Form.Control,{type:"text",defaultValue:s.desc,ref:a})]})}),e.jsx(de,{controlId:"formControlAssignKlass",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Assign to Element"}),e.jsx(c.Form.Control,{as:"select",defaultValue:s?.element_klass?.id,ref:o,disabled:!t,readOnly:!t,children:p},s?.element_klass?.id)]})})]})});$s.displayName="SegmentAttrForm";$s.propTypes={element:l.object.isRequired,editable:l.bool.isRequired};const Ft=(s,t="toString")=>Object.freeze(s.reduce((n,r)=>(n[r.toUpperCase()]=r[t](),n),{})),gr=s=>{const t=Number(s||"");return Number.isNaN(t)?0:t},Hr=s=>{if(s){const t=Number(s);return Number.isNaN(t)?null:parseInt(Number(s),10)}return null},es=s=>{const t=String(s).toLowerCase();return!(!t||t==="false"||t==="0")},ge=(s,t="-")=>s.join(t),da=s=>/^https?:\/\//i.test(s)?s:`https://${s}`,ca=s=>{if(!s)return[{type:"text",content:""}];const t=String(s),n=/\b((https?:\/\/)?(www\.)?((localhost)|([\p{L}\p{N}-]+\.)+[\p{L}]{2,}|(\d{1,3}\.){3}\d{1,3})(:\d+)?([\/?#][^\s]*)?)\b/giu,r=[];let i=0;for(const a of t.matchAll(n)){const o=a[0],d=a.index,u=d+o.length;d>i&&r.push({type:"text",content:t.slice(i,d)});const p=da(o);r.push({type:"link",content:o,href:p}),i=u}return i<t.length&&r.push({type:"text",content:t.slice(i)}),r},We=(s,t)=>s!==void 0?s:t!==void 0?t:!0,Be=(s,t)=>{let n=s?"readonly":"editable";return n=t&&!s?"required":n,n},ua=s=>{if(!s)return null;const{element_type:t}=s;return t?t==="Container"?"Dataset":"Segment":"Element"},Wr=(s,t,n)=>s?.find(a=>a.key===t)?.fields?.find(a=>a.field===n)?.label||n,Kr=(s,t)=>s?.find(r=>r.key===t)?.label||t,Xr=(s,t,n=[])=>s.layer==="SRC-EL"?{layerTitle:"Source (Source)",fieldTitle:"TYPE",valueTitle:n.find(i=>i.name===s.value)?.label||s.value}:{layerTitle:`${Kr(t,s.layer)} (${s.layer})`,fieldTitle:Wr(t,s.layer,s.field),valueTitle:typeof s.value=="boolean"?String(s.value):s.value},w=Object.freeze({BTN_AI_LINK:"link",BTN_AI_UNLINK:"unlink",IMG_NOT_AVAILABLE_SVG:"@assets/images/no_image.svg",NODE_TYPES:Ft(["Input","Output","Default"],"toLowerCase"),GENERIC_TYPES:Ft(["Element","Segment","Dataset","Layer","Vocabulary"]),GENERIC_KLASS_TYPES:Ft(["ElementKlass","SegmentKlass","DatasetKlass"]),GRID_THEME:{ALPINE:{VALUE:"ag-theme-alpine",PAGE_SIZE:6},BALHAM:{VALUE:"ag-theme-balham",PAGE_SIZE:10},QUARTZ:{VALUE:"ag-theme-quartz",PAGE_SIZE:6}},MODEL_TYPES:Ft(["GenericEl","Segment","Container"]),SYS_REACTION:"REACTION-",OLS_EBI:{BASE:"https://www.ebi.ac.uk/ols4/api/select",PARAM:["rows=20","collection=efo","obsoletes=false","local=false","fieldList=id,iri,label,short_form,obo_id,ontology_name,ontology_prefix,description,type"].join("&")},OLS_TIB:{BASE:"https://service.tib.eu/ts4tib/api/select",PARAM:["rows=20","collection=nfdi4chem","obsoletes=false","local=false","fieldList=id,iri,label,short_form,obo_id,ontology_name,ontology_prefix,description,type"].join("&")},MYDB:"mydb",PERMIT_TARGET:{DEVICE_DESCRIPTION:"device_description",ELEMENT:"element",REACTION:"reaction",RESEARCH_PLAN:"research_plan",SCREEN:"screen",WELLPLATE:"wellplate",GENERIC_GRID:"generic_grid",MOLECULE:"molecule",SAMPLE:"sample"},PROPS_RELEASE:"properties_release",SEPARATOR_TAG:"@@"}),Zr=g.forwardRef((s,t)=>{switch(s.content){case w.GENERIC_TYPES.SEGMENT:return e.jsx($s,{ref:t,element:s.element,editable:s.editable});case w.GENERIC_TYPES.ELEMENT:return e.jsx(Gs,{ref:t,element:s.element,editable:s.editable});default:return e.jsx("div",{children:"No content"})}});Zr.displayName="Content";const pa="chem-generic-ui",fa="2.2.0-rc1";class ee{constructor(t,n){this.notify=t,n&&typeof n=="object"&&!Array.isArray(n)?(this.element=X(n),this.element.pkg=Object.assign({},this.element.pkg,{name:pa,version:fa})):this.element=n}}const ha="success",ma="error",te=(s="Operation error.",t="Error")=>({msg:s,title:t,lvl:ma,isSuccess:!1}),se=(s="Operation successfully. Remember to save once you've finished editing.",t="Success")=>({msg:s,title:t,lvl:ha,isSuccess:!0}),ya=(s=!0,t="add dummy field successfully",n="Add dummy field")=>s?se(t,n):te(t,n),Ke=(s=!0,t="add new field successfully",n="Add new field")=>s?se(t,n):te(t,n),Nt=(s={type:null,layerKey:null},t="update layer successfully",n="Update layer")=>{const{type:r,layerKey:i}=s;switch(r){case"checkWorkflow":return te(["Cannot change the attribute 'used in Workflow?'",`because this layer [${i}] is currently used in workflow.`].join(" "),n);case"checkRestriction":return te(["Cannot be used in Workflow",`because the Layer Restriction of this layer [${i}] has been set.`].join(" "),n);case"checkGroup":return te(["Cannot be used in Workflow",`because this layer [${i}] is part of a group.`].join(" "),n);default:return se(t,n)}},ga=s=>/\b[a-z]{3,10}\b/.test(s),xa=s=>/^[a-zA-Z0-9_]*$/.test(s),ba=s=>s===null||s.trim().length===0?Ke(!1,"please input field name first!"):xa(s)?Ke():Ke(!1,"only can be alphanumeric (a-z, A-Z, 0-9 and underscores)."),Ot=s=>ga(s.name)?s.klass_prefix===""?te("Invalid Prefix.",`Element [${s.name}]`):s.label===""?te("Invalid Element Label.",`Element [${s.name}]`):s.icon_name===""?te("Invalid Icon.",`Element [${s.name}]`):se():te("Invalid Element Name.",`Element [${s.name}]`),Pt=s=>s.label===""?te("Invalid Segment Label.",`Segment [${s.label}]`):s.klass_element===""?te("Invalid Element Assignment.",`Segment [${s.label}]`):se(),_a=(s,t)=>m.isLayerInWF(s,t)?te(`This layer [${t}] can not be removed because it is currently used in workflow.`,`Layer [${t}]`):se(["Operation successfully.","Remember to save once you've finished editing."].join(" ")),qs=(s,t="new")=>s.key===""?te("Please input Name.",`Layer [${s.key}]`):t==="new"&&!/^[a-z][a-z_]+[a-z]$/g.test(s.key)?te("This Name is invalid, please try a different one.",`Layer [${s.key}]`):parseInt(s.cols||1,10)<1?te("The minimum number of columns per row is 1. Please enter a different value.",`Layer [${s.key}]`):se(),ja=(s,t)=>{const{key:n,wf:r}=t;if(m.isLayerInWF(s,n)&&!r)return Nt({type:"checkWorkflow",layerKey:n});const{layers:i}=s.properties_template;if(r&&i[n]&&(i[n].cond_fields||[]).length>0)return Nt({type:"checkRestriction",layerKey:n});const{metadata:a={}}=s,o=a.groups?.find(d=>d.layers?.includes(n));return r&&o?Nt({type:"checkGroup",layerKey:n}):Nt()},va=(s,t)=>{const n=t;return n===""?te("Please input Name.",`Select List [${n}]`):/^[a-z][a-z_]+[a-z]$/g.test(n)?s?.properties_template?.select_options?.[`${n}`]?te("This name of Select List is already in use. Please choose another one.",`Select List [${n}]`):se():te("This Name is invalid, please try a different one.",`Select List [${n}]`)},Ea=(s,t)=>s==null||s.trim().length===0?te("Please input option name first!","Add new option"):t.filter(n=>n.key===s).length>1?te(`This option key [${s}] is already in use. Please choose a different option key.`,"Add new option"):se(),xt=s=>{const{actions:t,data:n,editable:r,genericType:i,showProps:a}=s,{show:o,setShow:d}=a,u=g.useRef(),p=C=>{switch(i){case w.GENERIC_TYPES.SEGMENT:{const T={label:u.current.k_label.value.trim(),desc:u.current.k_desc.value.trim(),element_klass:u.current.k_klass.value},S=Pt(T);C(new ee(S,T)),S.isSuccess&&d(!1);break}case w.GENERIC_TYPES.ELEMENT:{const T={name:u.current.k_name.value.trim(),label:u.current.k_label.value.trim(),klass_prefix:u.current.k_prefix.value.trim(),icon_name:u.current.k_iconname.value.trim(),desc:u.current.k_desc.value.trim()},S=Ot(T);C(new ee(S,T)),S.isSuccess&&d(!1);break}default:console.log(`Warning: ${i} is not supported.`)}},f=C=>{switch(i){case w.GENERIC_TYPES.SEGMENT:{const T={label:u.current.k_label.value.trim(),desc:u.current.k_desc.value.trim(),element_klass:u.current.k_klass.value},S={...n,...T},v=Pt(S);C(new ee(v,S)),v.isSuccess&&d(!1);break}case w.GENERIC_TYPES.ELEMENT:{const T={name:u.current.k_name.value.trim(),label:u.current.k_label.value.trim(),klass_prefix:u.current.k_prefix.value.trim(),icon_name:u.current.k_iconname.value.trim(),desc:u.current.k_desc.value.trim()},S={...n,...T},v=Ot(S);C(new ee(v,S)),v.isSuccess&&d(!1);break}default:console.log(`Warning: ${i} is not supported.`)}},h=C=>{C(n),d(!1)},y=C=>{switch(i){case w.GENERIC_TYPES.SEGMENT:{const T={label:u.current.k_label.value.trim(),desc:u.current.k_desc.value.trim()},S={...n,...T},v=Pt(S);C(new ee(v,S)),v.isSuccess&&d(!1);break}case w.GENERIC_TYPES.ELEMENT:{const T={label:u.current.k_label.value.trim(),klass_prefix:u.current.k_prefix.value.trim(),icon_name:u.current.k_iconname.value.trim(),desc:u.current.k_desc.value.trim()},S={...n,...T},v=Ot(S);C(new ee(v,S)),v.isSuccess&&d(!1);break}default:console.log(`Warning: ${i} is not supported.`)}},b=(C,T)=>{let S=null;switch(C){case"c":S=e.jsx(c.Button,{variant:"warning",onClick:T?()=>p(T):()=>{},children:"Create"},`_attr_modal_btn_${C}`);break;case"cc":S=e.jsx(c.Button,{variant:"warning",onClick:T?()=>f(T):()=>{},children:"Copy"},`_attr_modal_btn_${C}`);break;case"u":S=e.jsx(c.Button,{variant:"warning",onClick:T?()=>y(T):()=>{},children:"Update"},`_attr_modal_btn_${C}`);break;case"d":S=e.jsx(c.Button,{variant:"danger",onClick:T?()=>h(T):()=>{},children:"Delete"},`_attr_modal_btn_${C}`);break;default:S=null}return S},x=()=>{const C=[];return t.forEach(T=>{C.push(b(T.action,T.fnAction)),C.push(e.jsx("span",{children:" "},`_attr_modal_span_${T.action}`))}),C},j=()=>{const C=[],T={c:"New",cc:"Copy",u:"Edit",d:"Delete"};return t.map(S=>C.push(T[S.action])),C.join("/").concat(" ").concat(i)};return e.jsx(e.Fragment,{children:e.jsxs(c.Modal,{centered:!0,size:"lg",backdrop:"static",show:o,onHide:()=>d(!1),children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:j()})}),e.jsx(c.Modal.Body,{style:{overflow:"auto"},children:e.jsxs("div",{className:"col-md-12",children:[e.jsx(Zr,{ref:u,content:i,element:n,editable:r}),e.jsx(c.Form,{className:"row mb-3",children:e.jsxs(c.Form.Group,{children:[x(),e.jsx(c.ButtonGroup,{children:e.jsx(c.Button,{variant:"primary",onClick:()=>d(!1),children:"Close"})})]})})]})})]})})};xt.propTypes={actions:l.arrayOf(l.shape({action:l.oneOf(["c","cc","u","d"]),fnAction:l.func})).isRequired,data:l.object,editable:l.bool,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired};xt.defaultProps={data:{},editable:!0};const Ta={faAnglesDown:W.faAnglesDown,faAnglesUp:W.faAnglesUp,faArrowsAlt:W.faArrowsAlt,faArrowCircleDown:W.faArrowCircleDown,faArrowDown:W.faArrowDown,faArrowRight:W.faArrowRight,faArrowRightToBracket:W.faArrowRightToBracket,faArrowsRotate:W.faArrowsRotate,faArrowUp:W.faArrowUp,faArrowUpRightFromSquare:W.faArrowUpRightFromSquare,faArrowsLeftRight:W.faArrowsLeftRight,faArrowsUpDownLeftRight:W.faArrowsUpDownLeftRight,faBan:W.faBan,faBars:W.faBars,faBarsProgress:W.faBarsProgress,faBookOpen:W.faBookOpen,faCaretDown:W.faCaretDown,faCaretLeft:W.faCaretLeft,faCaretRight:W.faCaretRight,faCaretUp:W.faCaretUp,faChartDiagram:W.faChartDiagram,faChartBar:Oe.faChartBar,faCheck:W.faCheck,faChevronDown:W.faChevronDown,faChevronUp:W.faChevronUp,faClock:Oe.faClock,faClockRotateLeft:W.faClockRotateLeft,faCircleArrowRight:W.faCircleArrowRight,faCircleCheck:W.faCircleCheck,faCircleInfo:W.faCircleInfo,faCirclePlus:W.faCirclePlus,faCircleQuestion:Oe.faCircleQuestion,faClone:Oe.faClone,faDiagramProject:W.faDiagramProject,faDownLeftAndUpRightToCenter:W.faDownLeftAndUpRightToCenter,faDownload:W.faDownload,faEllipsis:W.faEllipsis,faEllipsisVertical:W.faEllipsisVertical,faExclamationCircle:W.faExclamationCircle,faEye:W.faEye,faFlask:W.faFlask,faFileExport:W.faFileExport,faFileImport:W.faFileImport,faFileLines:W.faFileLines,faFileWord:W.faFileWord,faFloppyDisk:Oe.faFloppyDisk,faGears:W.faGears,faGlobe:W.faGlobe,faGripLinesVertical:W.faGripLinesVertical,faLayerGroup:W.faLayerGroup,faLink:W.faLink,faList:W.faList,faMagnifyingGlass:W.faMagnifyingGlass,faMinus:W.faMinus,faObjectGroup:W.faObjectGroup,faPaintbrush:W.faPaintbrush,faPaperclip:W.faPaperclip,faPaperPlane:W.faPaperPlane,faPaste:Oe.faPaste,faPencil:W.faPencil,faPlus:W.faPlus,faReply:W.faReply,faRotate:W.faRotate,faSpellCheck:W.faSpellCheck,faSquare:W.faSquare,faSquareCaretDown:Oe.faSquareCaretDown,faT:W.faT,faTag:W.faTag,faTableCells:W.faTableCells,faTableCellsLarge:W.faTableCellsLarge,faTimes:W.faTimes,faExpandArrowsAlt:W.faExpandArrowsAlt,faCompressArrowsAlt:W.faCompressArrowsAlt,faTrashCan:Oe.faTrashCan,faTriangleExclamation:W.faTriangleExclamation,faUpRightAndDownLeftFromCenter:W.faUpRightAndDownLeftFromCenter},Ca={faSpinner:W.faSpinner},Sa=Object.freeze(Object.fromEntries(Object.entries(Ta).map(([s,t])=>[s,e.jsx(Ds.FontAwesomeIcon,{icon:t})]))),wa=Object.freeze(Object.fromEntries(Object.entries(Ca).map(([s,t])=>[s,e.jsx(Ds.FontAwesomeIcon,{icon:t,spin:!0})]))),I={...Sa,...wa},Gt=Object.freeze({se00:"Operation error.",se01:"Response is missing expected code.",se02:"Cannot connect to LabIMotion Template Hub.",se03:"Unauthorized action.",se04:"Invalid data.",set00:"The template upload has failed due to mismatched data.",set01:"The template upload has failed due to validation errors.",set02:"The template upload has failed due to incorrect format.",si00:"If you need assistance, please contact us at chemotion-labimotion@lists.kit.edu.",ss00:"Operation successfully.",ss01:"Save data successfully.",ss02:"Connect to LabIMotion Template Hub successfully.",ss03:"Update Template successfully."}),ms=s=>typeof s!="string"?"":s.replace(/^[a-z]/,t=>t.toUpperCase()),xr=(s,t)=>{const n={data:"data"};return s<=1?t:n[t]?n[t]:t.endsWith("s")?t:`${t}s`},Xe=(s,t="")=>{if(!Gt[s])return te();const n=/s/.test(s[1]),r=t?`${Gt[s]} ${t}`:Gt[s];return n?se(r):te(r)},br=(s,t="")=>`${Gt[s]||""} ${t}`.trim(),Ve=(s="default")=>{switch(s){case"default":return"lu-bg-light";case"none":return"lu-bg-white";default:return`bg-${s}`}},Ce=Object.freeze({adjust_calculation:"Adjust the calculation",add_entry:"Add an entry",add_layer:"Add a layer",arrange_field:"Arrange fields order",arrange_layer:"Arrange layers order",arrange_group_layer:"Arrange groups & layers order",associate_direct:"Associate with this sample",associate_duplicate:"Duplicate the sample first and then associate with it",associate_split:"Split from the sample first and then associate with it",change_position:"Change position via drag and drop",chmo_changed:e.jsxs(e.Fragment,{children:["Type (Chemical Methods Ontology) has been changed.",e.jsx("br",{}),"Please review this dataset content."]}),clipboard:"Copy to clipboard",clipboard_copied:"Copied!",close:"Close window",copy:s=>`Copy ${ms(s)} to ...`,copy_to_duration:e.jsxs(e.Fragment,{children:["use this duration",e.jsx("br",{}),"(rounded to precision 1)"]}),create:s=>`Create a new ${ms(s)}`,create_element:"Create a new Element",create_segment:"Create a new Segment",create_dataset:"Create a new Dataset",design_flow:"Design a workflow",design_template:"Click to design the template",docs:"Documentation",draw_flow:"Draw a custom workflow",dtl_expand:"Expand details",dtl_collapse:"Collapse details",edit_attr:s=>`Edit ${ms(s)} attributes`,edit_layer_attr:s=>`Edit layer [${s}] attributes`,export_docx:"Export as docx file",export_tbl_xlsx:"Export table as xlsx file",fl_defined:"A workflow is defined",fl_view:"View the predefined workflow",fld_add:"Add a new field",fld_dum_add:"Add a dummy field",grid_large:"Enlarge grid size",grid_small:"Shrink grid size",group_layer:"Group layers and set conditions",link_element:"Select an element to link it to this record",imp_element_n_temp:"Import a element and its template",imp_segment_n_temp:"Import a segment and its template",imp_dataset_n_temp:"Import a dataset and its template",imp_temp_to_area:"Import a Template into the Work Area",link_term:s=>e.jsxs(e.Fragment,{children:[s," ",e.jsx("br",{})," What is this?"]}),lyr_add2std:"Add this layer to Standard Layer",lyr_add2tpl:"Add this layer to the template",lyr_view:"View this Layer",more_func:"More functions",mv_up:"Move Up",mv_down:"Move Down",no_unit_conversion:["Units like 'Electrical potential' (V vs. CE, V vs. RE)","and","'Specific current' (mA/g, mA/cm²) won’t be converted."].join(" "),preview_or_versions:"Click to preview or view version history",sel_add:"Add a new selection list",sel_lyr2tpl:e.jsxs(e.Fragment,{children:["Select from the Standard Layer and",e.jsx("br",{}),"apply it in the template"]}),sel_voc2tpl:e.jsxs(e.Fragment,{children:["Select from the LabIMotion Vocabulary (Lab-Vocab) and",e.jsx("br",{}),"apply it in the template"]}),sel_opt_add:"Add an option",scn_full:"Full screen",scn_full_exit:"Exit full screen",tpl_act:"Activate this template (currently inactive)",tpl_de_act:"De-activate this template (currently active)",tpl_edit:"Edit this template",tpl_fetch:"Fetch this template from Template Hub",tpl_ver_info:"View version information",tpl_view_hub:"View all templates in Template Hub",tpl_save_rel_major:e.jsxs(e.Fragment,{children:["Save and Release template as major version",e.jsx("br",{}),"(version number X.Y, X is the major version)"]}),tpl_save_rel_minor:e.jsxs(e.Fragment,{children:["Save and Release template as minor version",e.jsx("br",{}),"(version number X.Y, Y is the minor version)"]}),tpl_save_draft:"Save as Draft",record_time:"Record the time",reload_temp:"Click to reload the template",remove:"Remove",remove_molecule:"Remove this molecule",restriction_setting:"Restriction Setting",restric_not_on_required:"This required field cannot have restrictions.",return_to_list:"Back to list",ver_download:"Download this version",ver_retrieve:"Retrieve this version",ver_view:"View this version",voc_add:"Add this into LabIMotion Vocabulary (Lab-Vocab)",voc_add2tpl:"Add this LabIMotion Vocabulary (Lab-Vocab) to the template"}),Q=({idf:s,children:t,placement:n})=>{const r=s.split("."),[i]=g.useState(`ltt_${r[0]}_${ie.v4()}`),a=typeof Ce[r[0]]=="function"?Ce[r[0]](r[1]):Ce[r[0]]||"No message",d=g.isValidElement(t)&&t.props&&t.props.disabled?e.jsx("span",{className:"d-inline-flex",style:{pointerEvents:"auto",cursor:"not-allowed"},tabIndex:0,children:t}):t;return e.jsx(c.OverlayTrigger,{delayShow:1e3,placement:n||"top",overlay:e.jsx(c.Tooltip,{id:i,children:a||"No message"}),children:d})};Q.propTypes={idf:l.string,children:l.node.isRequired,placement:l.oneOf(["top","right","bottom","left"])};Q.defaultProps={idf:"ltt",placement:"top"};function Bs(s){const{fnCreate:t,genericType:n}=s,[r,i]=g.useState(!1);return n===w.GENERIC_TYPES.DATASET?null:e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:`create.${n.toLowerCase()}`,children:e.jsxs(c.Button,{onClick:()=>i(!0),variant:"outline-secondary",className:"gu-btn-outline-secondary",children:[I.faPlus," New"]})}),e.jsx(xt,{actions:[{action:"c",fnAction:t}],genericType:n,showProps:{show:r,setShow:i}})]})}Bs.propTypes={fnCreate:l.func.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired};Bs.defaultProps={};const Us=({btnNew:s,btnUpload:t,fnClickLarge:n,fnClickSmall:r,children:i})=>e.jsxs(c.ButtonGroup,{className:"ms-2",children:[t,s,e.jsx(Q,{idf:"grid_large",children:e.jsx(c.Button,{onClick:n,variant:"outline-secondary",className:"gu-btn-outline-secondary",children:I.faTableCellsLarge})}),e.jsx(Q,{idf:"grid_small",children:e.jsx(c.Button,{onClick:r,variant:"outline-secondary",className:"gu-btn-outline-secondary",children:I.faTableCells})}),i]});Us.propTypes={btnNew:l.element,btnUpload:l.element,fnClickLarge:l.func.isRequired,fnClickSmall:l.func.isRequired};Us.defaultProps={btnNew:null,btnUpload:null};function Vs(s){const{data:t,fnSelect:n,fnDelete:r,fnEdit:i,genericType:a}=s,[o,d]=g.useState(!1),u=()=>{n(),d(!0)};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:`edit_attr.${a.toLowerCase()}`,children:e.jsx(c.Button,{variant:"light",size:"sm",onClick:u,children:I.faPencil})}),e.jsx(xt,{actions:[{action:"u",fnAction:i},{action:"d",fnAction:r}],data:t,editable:!1,fnAction:i,genericType:a,showProps:{show:o,setShow:d}})]})}Vs.propTypes={data:l.object,fnDelete:l.func.isRequired,fnEdit:l.func.isRequired,fnSelect:l.func.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired};Vs.defaultProps={};function zs(s){const{data:t,fnCopy:n,fnSelect:r,genericType:i}=s,[a,o]=g.useState(!1),d=()=>{r(),o(!0)};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:`copy.${i.toLowerCase()}`,children:e.jsx(c.Button,{variant:"light",size:"sm",onClick:d,children:I.faClone})}),e.jsx(xt,{actions:[{action:"cc",fnAction:n}],data:t,editable:!0,fnAction:n,genericType:i,showProps:{show:a,setShow:o}})]})}zs.propTypes={data:l.object,fnCopy:l.func.isRequired,fnSelect:l.func.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired};zs.defaultProps={};const Mt={show:1e3,hide:0},Qr="top",Jr=["hover","focus"],Ra=s=>typeof s=="number"?{show:s,hide:0}:s&&typeof s=="object"?{show:s.show??Mt.show,hide:s.hide??Mt.hide}:Mt,Fa=(s,t)=>{if(s!=null)return s;if(!t)return null;const[n,r]=t.split("."),i=Ce[n];return typeof i=="function"?i(r):i??null},ct=g.forwardRef(({tooltip:s,tooltipId:t,placement:n,delay:r,trigger:i,overlayClassName:a,overlayProps:o,wrapperClassName:d,wrapperStyle:u,children:p,...f},h)=>{const[y]=g.useState(()=>`tooltip-button-${ie.v4()}`),b=g.useMemo(()=>Fa(s,t),[s,t]),x=g.useMemo(()=>Ra(r),[r]),j=n||Qr,C=i||Jr,T={...f,ref:h},S=e.jsx(c.Button,{...T,children:p});if(!b)return S;const E=!!T.disabled?e.jsx("span",{className:["tooltip-button-wrapper","d-inline-flex",d].filter(Boolean).join(" "),style:{pointerEvents:"auto",cursor:"not-allowed",...u},tabIndex:0,children:S}):S;return e.jsx(c.OverlayTrigger,{delay:x,placement:j,trigger:C,overlay:e.jsx(c.Tooltip,{id:y,className:a,...o,children:b}),children:E})});ct.displayName="TooltipButton";ct.propTypes={tooltip:l.node,tooltipId:l.string,placement:l.oneOf(["top","right","bottom","left"]),delay:l.oneOfType([l.number,l.shape({show:l.number,hide:l.number})]),trigger:l.oneOfType([l.string,l.arrayOf(l.string)]),overlayClassName:l.string,overlayProps:l.object,wrapperClassName:l.string,wrapperStyle:l.object,children:l.node.isRequired};ct.defaultProps={tooltip:void 0,tooltipId:void 0,placement:Qr,delay:Mt,trigger:Jr,overlayClassName:void 0,overlayProps:void 0,wrapperClassName:void 0,wrapperStyle:void 0};const ei=s=>{const{data:t,fnCopy:n,fnDelete:r,fnEdit:i,fnDownload:a,node:o,genericType:d}=s,u=()=>{o.setSelected(!0,!0)},p=f=>{o.setSelected(!0,!0),a(f)};return e.jsxs("span",{className:"d-inline-flex gap-1",children:[e.jsx(zs,{data:t,fnSelect:u,fnCopy:n,genericType:d}),e.jsx(Vs,{data:t,fnSelect:u,fnDelete:r,fnEdit:i,genericType:d}),e.jsx(ct,{tooltip:`Export ${d} and its template`,placement:"top",delay:1e3,overlayClassName:"pre_line_tooltip",size:"sm",variant:"light",onClick:()=>p(t),children:I.faFileExport})]})},ue=g.memo(s=>{const{idf:t,bs:n,size:r,fnClick:i,element:a,place:o,fa:d,disabled:u,txt:p,btnCls:f,as:h}=s,y=p?e.jsxs("span",{children:[p," "]}):"",b=e.jsxs(c.Dropdown.Item,{eventKey:`${t}_menu_item`,onClick:()=>i(a),children:[I[d],"  ",Ce[t]]});return h==="menu"?b:e.jsxs(ct,{tooltipId:t,placement:o,variant:n||void 0,size:r||void 0,className:f,disabled:u,onClick:x=>{x.stopPropagation(),i(a)},children:[y===""&&I[d],y!==""&&e.jsxs(e.Fragment,{children:[I[d]," ",y]})]})});ue.propTypes={idf:l.string,element:l.oneOfType([l.object,l.bool]),fnClick:l.func.isRequired,bs:l.string,size:l.string,place:l.string,fa:l.string,disabled:l.bool,txt:l.string,btnCls:l.string,as:l.string};ue.defaultProps={idf:"ltt",bs:"light",size:void 0,place:"top",fa:"faPencil",disabled:!1,txt:null,element:{},btnCls:"",as:"button"};const kt={true:{tip:"tpl_de_act",fa:"faCheck",bs:"light",cls:"gu_btn_text_success"},false:{tip:"tpl_act",fa:"faBan",bs:"light",cls:"gu_btn_text_danger"}},Ys=s=>{const{data:t,fnDeActivate:n,node:r,value:i}=s,a=o=>{r.setSelected(!0,!0),n(o)};return e.jsx(ue,{idf:kt[i].tip,fnClick:a,element:t,fa:kt[i].fa,size:"sm",btnCls:kt[i].cls,bs:kt[i].bs})},Hs=({data:s,node:t,genericType:n})=>{const[r,i]=g.useState(!1),a=()=>{i(!0)},o=()=>{i(!1)},d=()=>n===w.GENERIC_TYPES.DATASET?{label:"Term ID:",value:s?.ols_term_id||"N/A",column:"left"}:{label:"Description:",value:s?.desc||"N/A",column:"left"},u=[{label:`${n}:`,value:s?.label||"N/A",column:"left"},d(),{label:"Version:",value:s?.version||"N/A",column:"left"},{label:"UUID:",value:s?.uuid||"N/A",column:"left",isCode:!0},{label:"Released At:",value:s?.released_at||"N/A",column:"right"},{label:"Updated At:",value:s?.updated_at||"N/A",column:"right"},{label:"Sync Time:",value:s?.sync_time||"N/A",column:"right"},{label:"Identifier:",value:s?.identifier||"N/A",column:"right",isCode:!0}],p=u.filter(y=>y.column==="left"),f=u.filter(y=>y.column==="right"),h=(y,b)=>e.jsxs("div",{className:"mb-3",children:[e.jsx("strong",{className:"text-muted",children:y.label}),e.jsx("div",{className:"mt-1",children:y.isCode?e.jsx("code",{className:"small",children:y.value}):y.value})]},b);return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"d-inline-flex align-items-center gap-1",children:e.jsx(ue,{idf:"tpl_ver_info",fa:"faTag",fnClick:()=>a(),size:"sm",bs:"light",txt:s?.version||"",forceClose:r})}),e.jsxs(c.Modal,{show:r,backdrop:"static",keyboard:!1,centered:!0,size:"xl",onHide:o,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:`${n} Information`})}),e.jsx(c.Modal.Body,{className:"p-4",children:s?e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-md-6",children:p.map(h)}),e.jsx("div",{className:"col-md-6",children:f.map(h)})]}):e.jsx("div",{className:"text-center text-muted",children:e.jsx("p",{children:"No detailed information available."})})}),e.jsx(c.Modal.Footer,{className:"justify-content-start",children:e.jsx(c.Button,{variant:"secondary",onClick:o,children:"Close"})})]})]})},Ze=({title:s,children:t})=>e.jsxs("span",{children:[e.jsxs("span",{className:"h5 d-inline",children:[s,": "]}),t]});Ze.propTypes={title:l.string.isRequired,children:l.node.isRequired};const De=({wf:s=!1})=>s?e.jsx("span",{children:I.faChartDiagram}):null;De.propTypes={wf:l.bool};De.defaultProps={wf:!1};const Na=({data:s})=>!s||!s.flow&&!s.flowObject?null:e.jsx(De,{wf:!0}),Ws=s=>{const{data:t,fnShow:n,node:r}=s,i=a=>{r.setSelected(!0,!0),n(a)};return e.jsxs("span",{className:"d-inline-flex align-items-center gap-1",children:[e.jsx(ue,{idf:"tpl_edit",fa:"faFileLines",element:t,fnClick:i,size:"sm",bs:"light"}),e.jsx(Na,{data:t.properties_template})]})},ka={minWidth:50,width:150,filter:!1,sortable:!0},bt=({columnDefs:s,gridData:t,pageSize:n,theme:r,rowSelected:i,filterText:a,onSetAutoHeight:o,onClearSelection:d})=>{const[u]=g.useState(s),p=g.useRef(),f=g.useMemo(()=>({height:"80vh",width:"100%"}),[]),[h,y]=g.useState(t||[]),b=g.useRef(null),x=g.useCallback(()=>{if(!p?.current?.api)return;const S=p.current.api.getSelectedNodes();if(S.length>0){const v=S[0];p.current.api.ensureNodeVisible(v,"top")}},[]),j=g.useCallback(()=>{p?.current?.api&&setTimeout(()=>{document.querySelector("#guiDesignerGrid").style.height="80vh"},100)},[]);g.useEffect(()=>{o&&o(j)},[o,j]);const C=g.useCallback(()=>{p?.current?.api&&(p.current.api.deselectAll(),b.current=null)},[]);g.useEffect(()=>{d&&d(C)},[d,C]);const T=g.useCallback(()=>{p?.current?.api&&setTimeout(()=>{document.querySelector("#guiDesignerGrid").style.height="16vh",x()},100)},[]);return g.useEffect(()=>{i?T():j()},[i,j,T]),g.useEffect(()=>{const S=p?.current?.api?.getSelectedRows()?.[0];S?.id?b.current=S.id:b.current=null,y(t),requestAnimationFrame(()=>{b.current&&p?.current?.api&&p.current.api.forEachNode(v=>{v.data.id===b.current&&v.setSelected(!0)})})},[t]),g.useEffect(()=>{p?.current?.api&&p.current.api.setGridOption("quickFilterText",a||"")},[a]),e.jsx(e.Fragment,{children:e.jsx("div",{id:"guiDesignerGrid",style:f,className:r,children:e.jsx(Se.AgGridReact,{ref:p,columnDefs:u,defaultColDef:ka,rowSelection:{mode:"singleRow",checkboxes:!1,enableClickSelection:!1},rowData:h})})})};bt.propTypes={columnDefs:l.array.isRequired,gridData:l.array.isRequired,pageSize:l.number,theme:l.string,rowSelected:l.bool,filterText:l.string,onSetAutoHeight:l.func,onClearSelection:l.func};bt.defaultProps={pageSize:w.GRID_THEME.BALHAM.PAGE_SIZE,theme:w.GRID_THEME.BALHAM.VALUE,rowSelected:!1};const _r=w.GENERIC_TYPES.ELEMENT,La=s=>{const{value:t,iconStyle:n}=s;return e.jsx("i",{className:t,"aria-hidden":"true",style:n||{color:"black"}})},Ks=s=>{const{gridData:t,pageSize:n,theme:r,fnCopyKlass:i,fnDeleteKlass:a,fnEditKlass:o,fnDeActivateKlass:d,fnDownloadKlass:u,fnShowProp:p,rowSelected:f,filterText:h,onSetAutoHeight:y,onClearSelection:b}=s,x=g.useMemo(()=>[{hide:!0,headerName:"#",valueFormatter:j=>`${parseInt(j.node.id,10)+1}`,sortable:!1},{headerName:"Action",cellRenderer:ei,cellRendererParams:{fnCopy:i,fnDelete:a,fnEdit:o,fnDownload:u,genericType:_r},sortable:!1},{headerName:"Active",field:"is_active",width:100,cellRenderer:Ys,cellRendererParams:{fnDeActivate:d}},{field:"name"},{headerName:"Prefix",field:"klass_prefix",width:100},{headerName:"Element label",field:"label",flex:1},{headerName:"Icon",field:"icon_name",width:100,sortable:!1,cellRenderer:La},{headerName:"Description",field:"desc",flex:1},{headerName:"Template",cellRenderer:Ws,width:100,cellRendererParams:{fnShow:p},sortable:!1},{headerName:"Ver. Info",cellRenderer:Hs,width:100,cellRendererParams:{genericType:_r},sortable:!1}],[i,a,o,u,d,p]);return e.jsx(bt,{columnDefs:x,gridData:t,pageSize:n,theme:r,rowSelected:f,filterText:h,onSetAutoHeight:y,onClearSelection:b})};Ks.propTypes={gridData:l.array.isRequired,fnCopyKlass:l.func.isRequired,fnDeActivateKlass:l.func.isRequired,fnDownloadKlass:l.func.isRequired,fnDeleteKlass:l.func.isRequired,fnEditKlass:l.func.isRequired,fnShowProp:l.func.isRequired,pageSize:l.number,theme:l.string,filterText:l.string,rowSelected:l.bool,onSetAutoHeight:l.func,onClearSelection:l.func};Ks.defaultProps={pageSize:10,theme:w.GRID_THEME.QUARTZ.VALUE};const jr=w.GENERIC_TYPES.SEGMENT,Aa=s=>{const{data:t}=s;return e.jsxs(e.Fragment,{children:[t.element_klass?.label," ",e.jsx("i",{className:t.element_klass?.icon_name,"aria-hidden":"true"})]})},Xs=s=>{const{gridData:t,pageSize:n,theme:r,fnCopyKlass:i,fnDeleteKlass:a,fnEditKlass:o,fnDeActivateKlass:d,fnDownloadKlass:u,fnShowProp:p,rowSelected:f,filterText:h,onSetAutoHeight:y,onClearSelection:b}=s,x=g.useMemo(()=>[{hide:!0,headerName:"#",valueFormatter:j=>`${parseInt(j.node.id,10)+1}`,sortable:!1},{headerName:"Action",cellRenderer:ei,cellRendererParams:{fnCopy:i,fnDelete:a,fnEdit:o,fnDownload:u,genericType:jr},sortable:!1},{headerName:"Active",field:"is_active",width:100,cellRenderer:Ys,cellRendererParams:{fnDeActivate:d}},{headerName:"Segment label",field:"label",flex:1},{headerName:"Description",field:"desc",flex:1},{headerName:"Belongs to",field:"element_klass.name",width:100,cellRenderer:Aa},{headerName:"Template",cellRenderer:Ws,width:100,cellRendererParams:{fnShow:p},sortable:!1},{headerName:"Ver. Info.",cellRenderer:Hs,width:100,cellRendererParams:{genericType:jr},sortable:!1}],[i,a,o,u,d,p]);return e.jsx(bt,{columnDefs:x,gridData:t,pageSize:n,theme:r,rowSelected:f,filterText:h,onSetAutoHeight:y,onClearSelection:b})};Xs.propTypes={gridData:l.array.isRequired,fnCopyKlass:l.func.isRequired,fnDeActivateKlass:l.func.isRequired,fnDownloadKlass:l.func.isRequired,fnDeleteKlass:l.func.isRequired,fnEditKlass:l.func.isRequired,fnShowProp:l.func.isRequired,pageSize:l.number,theme:l.string,filterText:l.string,rowSelected:l.bool,onSetAutoHeight:l.func,onClearSelection:l.func};Xs.defaultProps={pageSize:10,theme:w.GRID_THEME.QUARTZ.VALUE};const Ia=w.GENERIC_TYPES.DATASET,Zs=s=>{const{gridData:t,pageSize:n,theme:r,fnDeActivateKlass:i,fnShowProp:a,rowSelected:o,filterText:d,onSetAutoHeight:u,onClearSelection:p}=s,f=g.useMemo(()=>[{hide:!0,headerName:"#",valueFormatter:h=>`${parseInt(h.node.id,10)+1}`,sortable:!1},{headerName:"Active",field:"is_active",width:100,cellRenderer:Ys,cellRendererParams:{fnDeActivate:i}},{headerName:"Chemical Methods Ontology",field:"label",flex:1},{headerName:"Template",cellRenderer:Ws,width:100,cellRendererParams:{fnShow:a},sortable:!1},{headerName:"Ver. Info.",cellRenderer:Hs,width:100,cellRendererParams:{genericType:Ia},sortable:!1}],[i,a]);return e.jsx(bt,{columnDefs:f,gridData:t,pageSize:n,theme:r,rowSelected:o,filterText:d,onSetAutoHeight:u,onClearSelection:p})};Zs.propTypes={gridData:l.array.isRequired,fnDeActivateKlass:l.func.isRequired,fnShowProp:l.func.isRequired,pageSize:l.number,theme:l.string,filterText:l.string,rowSelected:l.bool,onSetAutoHeight:l.func,onClearSelection:l.func};Zs.defaultProps={pageSize:10,theme:w.GRID_THEME.QUARTZ.VALUE};const ys=s=>Object.values(w.GRID_THEME).find(n=>n.VALUE===s)?.PAGE_SIZE||6,mt=Object.freeze({DOC_SITE:"https://www.chemotion.net/docs/labimotion"}),Qs=s=>{const{notify:t,active:n,fnSwitch:r}=s,[i,a]=g.useState(!1);g.useEffect(()=>{a(t!==null&&Object.keys(t||{}).length>0)},[t]);const o=d=>{d.stopPropagation(),a(!1)};return e.jsxs("span",{className:"gu-designer-template-bar",children:[e.jsxs(c.ButtonGroup,{children:[e.jsx(Q,{idf:"design_template",children:e.jsx(c.Button,{className:n==="w"?"border-secondary":"",variant:n==="w"?"secondary":"light",onClick:()=>r("w"),active:n==="w",children:"Work Area"})}),e.jsx(Q,{idf:"preview_or_versions",children:e.jsx(c.Button,{className:n==="p"?"border-secondary":"",variant:n==="p"?"secondary":"light",onClick:()=>r("p"),active:n==="p",children:"Preview, Revisions & Share"})})]}),e.jsx(c.OverlayTrigger,{delayShow:1e3,placement:"top",overlay:e.jsx(c.Tooltip,{id:"_designer_doc_tooltip",children:"Learn more"}),children:e.jsx(c.Button,{variant:"link",href:[mt.DOC_SITE,"designer","template-features"].join("/"),target:"_blank",onClick:d=>d.stopPropagation(),children:I.faCircleQuestion})}),i&&t!==null&&e.jsxs("span",{className:`alert ${t.isSuccess?"alert-success":"alert-danger"} mb-0 ml-2`,children:[e.jsxs("span",{children:[e.jsx("b",{children:t.title}),`: ${t.msg}`]}),e.jsx(c.Button,{size:"sm",onClick:o,variant:"light",children:I.faTimes})]})]})};Qs.propTypes={notify:l.object,active:l.string,fnSwitch:l.func.isRequired};Qs.defaultProps={notify:null,active:"w"};const ze="d-flex justify-content-between align-items-center";class ve{constructor(t){Object.assign(this,t),this.id||(this.id=ve.buildID())}static buildID(){return ie.v4()}}class Da extends ve{constructor(t){super({default:"",field:"",label:"",position:0,required:!1,sub_fields:[],text_sub_fields:[],...t})}}class Bt{constructor(t){this.ai=[],this.color="none",this.cols=1,this.label="",this.position=0,this.style="panel_generic_heading",this.wf=!1,this.wf_position=0,Object.assign(this,t),this.key||(this.key=t.sys?`${t.sys}-${Bt.buildID()}`:Bt.buildID()),this.fields=[]}static buildID(){return Date.now().toString()}addField(t){const n=new Da(t);this.fields.push(n)}}const et=(s,t)=>{const n=t.groups||[],r={...s},i=new Set;n.forEach(f=>{f.layers?.forEach(h=>i.add(h))});const a=Object.values(r).filter(f=>!i.has(f.key)),o=[...n.map(f=>({type:"group",data:f,position:f.position||0})),...a.map(f=>({type:"layer",data:f,position:f.position||0}))],d=ce(o,"position"),u=[...n],p={...r};return d.forEach((f,h)=>{if(f.type==="group"){const y=u.findIndex(b=>b.id===f.data.id);y!==-1&&(u[y]={...u[y],position:h},u[y].layers?.forEach(b=>{p[b]&&(p[b]={...p[b],position:h})}))}else if(f.type==="layer"){const y=f.data.key;p[y]&&(p[y]={...p[y],position:h})}}),{layers:p,metadata:u.length>0?{...t,groups:u}:{}}},Oa=s=>{const t=s;Object.keys(t.properties_template.layers).forEach(r=>{let a=t.properties_template.layers[r]?.fields||[];(a||[]).forEach((o,d)=>{const u=o;return u.position=d+1,u.type===m.FieldTypes.F_SYSTEM_DEFINED&&(u.option_layers=m.reUnit(u.option_layers)),u.required=[m.FieldTypes.F_INTEGER,m.FieldTypes.F_TEXT].includes(u.type)?u.required:!1,u.sub_fields=[m.FieldTypes.F_INPUT_GROUP,m.FieldTypes.F_TABLE,m.FieldTypes.F_SELECT_MULTI,m.FieldTypes.F_DATETIME_RANGE].includes(u.type)?u.sub_fields:[],u.type!==m.FieldTypes.F_TEXT_FORMULA&&(u.text_sub_fields=[]),u}),a=ce(a,o=>o.position),t.properties_template.layers[r].wf_position=0,t.properties_template.layers[r].fields=a});const n=et(t.properties_template.layers,t.metadata||{});return t.metadata=n.metadata,t.properties_template.layers=n.layers,t},Js=s=>{const t=new Set;return s.forEach(n=>{n.layers&&Array.isArray(n.layers)&&n.layers.forEach(r=>t.add(r))}),t},Pa=(s,t)=>!s||!Array.isArray(s)||!t?null:s.find(n=>n.layers&&Array.isArray(n.layers)&&n.layers.includes(t))||null,Ga=(s,t)=>{if(!s||!t)return null;const n=s.groups||[],r=s.restrict||{},i=Pa(n,t);return i?{group:i,restrict:r[i.id]||null}:null},Ma=(s,t,n)=>{if(!s||!Array.isArray(s)||s.length===0)return{isValid:!1,error:"No layers provided"};const r=s.filter(o=>!t[o]);if(r.length>0)return{isValid:!1,error:`Layers not found in klass.json: ${r.join(", ")}`};const i=Js(n),a=s.filter(o=>i.has(o));return a.length>0?{isValid:!1,error:`Layers already assigned to another group: ${a.join(", ")}`}:{isValid:!0}},$a=(s,t,n)=>{if(!t||typeof t!="object")return{success:!1,error:"Invalid group object"};if(!t.id)return{success:!1,error:"Group must have an id"};if(!t.label)return{success:!1,error:"Group must have a label"};if(s.some(i=>i.id===t.id))return{success:!1,error:`Group with id '${t.id}' already exists`};if(n){const i=Ma(t.layers,n,s);if(!i.isValid)return{success:!1,error:i.error}}if(!t.layers||!Array.isArray(t.layers))return{success:!1,error:"Group must have a layers array"};const r={id:t.id,label:t.label,layers:[...t.layers]};return t.position!==void 0&&t.position!==null&&(r.position=t.position),s.push(r),{success:!0,message:`Group '${t.label}' added successfully with ${t.layers.length} layer(s)`}},vr=(s,t)=>{const n=s.findIndex(r=>r.id===t);return n!==-1?{success:!0,message:`Group '${s.splice(n,1)[0].label}' removed successfully`}:{success:!1,error:`Group with id '${t}' not found`}},Er=(s,t,n,r)=>{if(r&&!r[n])return{success:!1,error:`Layer '${n}' not found`};const i=s.find(o=>o.id===t);return i?i.layers&&i.layers.includes(n)?{success:!1,error:`Layer '${n}' already in this group`}:Js(s).has(n)?{success:!1,error:`Layer '${n}' is already assigned to another group`}:(i.layers||(i.layers=[]),i.layers.push(n),{success:!0,message:`Layer '${n}' added to group '${i.label}' successfully`}):{success:!1,error:`Group with id '${t}' not found`}},qa=(s,t,n)=>{const r=s.find(i=>i.id===t);return r?!r.layers||!r.layers.includes(n)?{success:!1,error:`Layer '${n}' not found in this group`}:(r.layers=r.layers.filter(i=>i!==n),{success:!0,message:`Layer '${n}' removed from group '${r.label}' successfully`,isEmpty:r.layers.length===0}):{success:!1,error:`Group with id '${t}' not found`}},tt=(s,t=[])=>{if(!s||typeof s!="object")return[];const n=Js(t),r=[];return t.forEach(i=>{if(!i.layers||!Array.isArray(i.layers))return;const a=i.layers.filter(o=>s[o]).map(o=>({key:o,position:s[o].position||0,data:s[o]}));a.length>0&&r.push({type:"group",id:i.id,label:i.label,position:i.position||0,layers:a})}),Object.keys(s).forEach(i=>{n.has(i)||r.push({type:"layer",key:i,position:s[i].position||0,data:s[i]})}),r.sort((i,a)=>i.position-a.position),r},Ba=(s,t,n)=>{const[r,i,a]=[s,t,n],{metadata:o={}}=r,{layers:d}=r.properties,u=ce(d,["position","wf_position"]),p=u.findIndex(f=>f.key===i.key);if(p!==-1){const f=new Bt({sys:a});f.addField({type:m.FieldTypes.F_SYS_REACTION,field:"reaction",hasOwnRow:!0}),u.splice(p+1,0,f);const h=o.groups?.find(x=>x.layers?.includes(i.key));h?(h.layers.splice(h.layers.indexOf(i.key)+1,0,f.key),f.position=h.position+.5):f.position=i.position+.5;const y=m.orgLayerObject(u),b=et(y,o);r.properties.layers=b.layers,r.metadata=b.metadata,r.changed=!0}},Ua=(s,t,n)=>{const[r,i,a]=[s,t,n];r.properties.layers[a]?.fields?.length>0&&(r.properties.layers[a].fields[0]=i,r.changed=!0)},ti=(s,t,n=[])=>{if(!s||typeof s!="object"||!t)return!1;const r=tt(s,n);if(r.length===0)return!1;const i=r[0];return i.type==="layer"?i.key===t:i.type==="group"?i.layers?.[0]?.key===t:!1},gs="1",xs="accordion_design_props_",Va=`py-1 ${ze} rounded`,en=({dnd:s,eventKey:t,callback:n,extClass:r,children:i,isSys:a})=>{const o=c.useAccordionButton(t,()=>n&&n(t));return e.jsxs("div",{className:`${Va} ${r||"lu-bg-light"}`,children:[e.jsx("div",{className:`flex-grow-1 ${ze}`,onClick:a?void 0:o,style:{cursor:a?"default":"pointer"},"aria-label":"Toggle Accordion",role:"button",children:i}),s]})};en.propTypes={dnd:l.node,eventKey:l.string.isRequired,callback:l.func,extClass:l.string,children:l.node.isRequired,isSys:l.bool.isRequired};en.defaultProps={dnd:void 0,callback:void 0,extClass:""};const _t=({dnd:s=void 0,extClass:t="",layerKey:n,propHeader:r,layers:i,expandAll:a,groups:o,children:d})=>{const[u,p]=g.useState(!0),f=n.startsWith(w.SYS_REACTION),h=ti(i,n,o),[y,b]=g.useState(()=>a??!!(u&&h));g.useEffect(()=>{a!=null&&(b(a),p(!1))},[a]);const x=()=>{f||(b(!y),p(!1))};let j=y;return f&&(j=!0),e.jsx(c.Accordion,{id:`_${xs}${n}`,activeKey:j?gs:void 0,children:e.jsxs(c.Accordion.Item,{className:"panel_generic_properties pb-3",eventKey:gs,children:[e.jsx(en,{dnd:s,eventKey:gs,callback:x,extClass:t,isSys:f,children:r}),e.jsx(c.Accordion.Body,{className:"py-0 px-3",children:d})]},`_${xs}item_${n}`)},`${xs}${n}`)};_t.propTypes={dnd:l.node,extClass:l.string,layerKey:l.string.isRequired,propHeader:l.node.isRequired,layers:l.object,expandAll:l.bool,groups:l.array,children:l.node.isRequired};_t.defaultProps={dnd:void 0,extClass:"",layers:{},expandAll:void 0,groups:[]};function Le({variant:s,color:t,text:n,children:r,className:i}){const a=r||n;if(!a&&a!==0)return null;const o=["ms-1"];i&&o.push(i),s==="outline"&&o.push(`lbg-outline-${t}`);const d=o.join(" ");return s==="solid"?e.jsx(c.Badge,{pill:!0,className:d,bg:t,children:a}):e.jsx(c.Badge,{pill:!0,className:d,children:a})}Le.propTypes={variant:l.oneOf(["solid","outline"]),color:l.string.isRequired,text:l.oneOfType([l.string,l.number]),children:l.node,className:l.string};Le.defaultProps={variant:"solid",text:"",children:null,className:""};function tn({layer:s,groupInfo:t}){const n=s?.fields?.length||0,r=s?.cond_fields?.length>0,i=t?.restrict?.cond?.length>0;return e.jsxs("span",{className:"flex-grow-1",children:[t&&e.jsxs(Le,{variant:"solid",color:"primary",children:["Group: ",t.group.label,i&&e.jsxs(e.Fragment,{children:[" ",I.faGears," "]})]}),t&&" ",e.jsx("span",{className:"fw-bold",children:s.label}),e.jsx(Le,{variant:"solid",color:"dark",text:s.key}),r&&e.jsx(Le,{variant:"solid",color:"warning",children:I.faGears}),e.jsx(Le,{variant:"outline",color:"primary",text:`${s.cols} ${xr(s.cols,"col")}/row, ${n} ${xr(n,"field")}`}),s?.wf&&e.jsx(Le,{variant:"outline",color:"warning",text:"workflow"})]})}tn.propTypes={layer:l.shape({key:l.string.isRequired,label:l.string.isRequired,cols:l.number,fields:l.array,wf:l.bool}).isRequired,groupInfo:l.shape({group:l.shape({id:l.string.isRequired,label:l.string.isRequired,layers:l.array.isRequired,position:l.number}).isRequired,restrict:l.object})};tn.defaultProps={groupInfo:null};const sn=s=>s.length>1?e.jsx("span",{children:`Repetition ${s[1]}`}):null,nn=s=>{const t="Reaction:";if(!s||!s.length)return t;const{value:n={}}=s[0];return n.el_label?`${t} ${n.el_label}`:t},Ut=e.jsx("h1",{children:"No layers to arrange"}),za=e.jsx("h1",{children:"No fields to arrange"}),Ya=(s,t,n,r,i=null)=>{const o=n.startsWith(w.SYS_REACTION)?nn(r):`${t}(${n})`,d=n.split(".");return e.jsxs("span",{className:`${ze} ${s}`,children:[o,sn(d),i&&e.jsx(De,{wf:i})]})};function si({className:s,label:t,keyProp:n,fields:r,wf:i=null,children:a}){const d=n.startsWith(w.SYS_REACTION)?nn(r):`${t}(${n})`,u=n.split(".");return e.jsxs("span",{className:`w-100 d-flex align-items-center ${s}`,children:[e.jsxs("span",{children:[d,sn(u),i&&e.jsx(De,{wf:i})]}),a]})}si.propTypes={className:l.string,label:l.string.isRequired,keyProp:l.string.isRequired,fields:l.array,wf:l.bool,children:l.node};const Ha=(s,t,n)=>{const i=n==="dummy"?"(dummy field)":`${s}(${t})`;return e.jsx("span",{className:`fw-bold ${ze}`,children:i})};function rn({scrollableContainerRef:s}){const t=g.useRef(null),{item:n,isDragging:r,currentOffset:i}=be.useDragLayer(p=>({item:p.getItem(),isDragging:p.isDragging(),currentOffset:p.getClientOffset()}));if(g.useEffect(()=>{if(!r||!i||!s?.current){t.current&&(clearTimeout(t.current),t.current=null);return}const p=s.current,f=p.getBoundingClientRect(),{y:h}=i;if(!(i.x>=f.left&&i.x<=f.right)){t.current&&(clearTimeout(t.current),t.current=null);return}const b=60,x=8;let j=!1,C=null;if(h<f.top+b&&p.scrollTop>0)j=!0,C="up";else if(h>f.bottom-b){const T=p.scrollHeight-p.clientHeight;p.scrollTop<T&&(j=!0,C="down")}if(j&&!t.current){const T=()=>{if(r){if(C==="up")p.scrollTop=Math.max(0,p.scrollTop-x);else if(C==="down"){const S=p.scrollHeight-p.clientHeight;p.scrollTop=Math.min(S,p.scrollTop+x)}t.current=setTimeout(T,50)}};t.current=setTimeout(T,100)}else!j&&t.current&&(clearTimeout(t.current),t.current=null);return()=>{t.current&&(clearTimeout(t.current),t.current=null)}},[r,i,s]),!r||!i||!n)return null;const{x:a,y:o}=i,u=(()=>{const p=n.layer||{};if(p.field!==void 0){const{label:f,field:h,type:y}=p;return m.FieldTypes.F_DUMMY===y?"(dummy field)":`${f}(${h})`}if(p.key!==void 0){const{label:f,key:h,fields:y}=p,x=h&&h.startsWith(w.SYS_REACTION)?nn(y):`${f}(${h})`,j=h?h.split("."):[],C=sn(j);return C?`${x} - ${C.props.children}`:x}return p.label||n.label||"Item"})();return e.jsx("div",{className:"drag-layer-preview",style:{position:"fixed",pointerEvents:"none",top:o,left:a,zIndex:1e4,transform:"translate(-50%, -50%)",opacity:.9},children:e.jsx("div",{className:"w-100 drag-item-content",style:{backgroundColor:"#ffffff",border:"2px solid #007bff",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 8px 32px rgba(0,0,0,0.15), 0 4px 16px rgba(0,123,255,0.2)",fontWeight:500,color:"#333333",whiteSpace:"nowrap",fontSize:"14px",minWidth:"120px",textAlign:"center"},children:u})})}const Ae=s=>{const{canDrag:t,type:n,layer:r,field:i,handleMove:a,children:o}=s,d=g.useRef(null),[{isDraggingSource:u},p,f]=be.useDrag({type:n,item:{type:n,layer:r,field:i,label:r?.label||o.props?.label},canDrag:()=>t,collect:C=>({isDraggingSource:C.isDragging()})});g.useEffect(()=>{f(zl.getEmptyImage(),{captureDraggingState:!0})},[f]);const[{isOver:h,isOverValidTarget:y},b]=be.useDrop({accept:n,canDrop:C=>!r.wf||!C.layer.wf,drop:(C,T)=>{i===C.field&&r.key!==C.layer.key&&a(C.layer.key,r.key)},collect:C=>({isOver:C.isOver(),isOverValidTarget:C.canDrop()})});let x="generic_grid_dnd";h&&(x+=" is-over"),y&&(x+=" can-drop");const j={opacity:u?0:1,position:"relative",zIndex:u?9e3:1,transition:"all 0.2s ease",...h&&y&&{backgroundColor:"rgba(0, 123, 255, 0.1)",borderColor:"#007bff",transform:"scale(1.02)"}};return e.jsx("div",{ref:C=>{p(C),b(C),d.current=C?.parentElement},className:`w-100 p-2 m-2 ${x}`,style:j,children:e.jsx("div",{className:"dnd",children:o})})};Ae.propTypes={canDrag:l.bool,type:l.string.isRequired,layer:l.object.isRequired,field:l.string.isRequired,handleMove:l.func.isRequired,children:l.node.isRequired};Ae.defaultProps={canDrag:!0};function Vt({conditions:s,layers:t}){const{cond_fields:n=[],cond_operator:r=1}=s;if(!n.length)return null;const i=t?Object.keys(t).map(o=>({key:o,label:t[o].label,fields:t[o].fields||[]})):[];if(!i.length)return null;const a=m.getCondOperator[r];return e.jsxs(e.Fragment,{children:[e.jsxs("small",{className:"text-muted d-block mb-2",children:[I.faGears," Existing Conditions: ",a]}),n.map(o=>e.jsx("div",{className:"d-flex align-items-center gap-2 mb-2 p-2 border rounded bg-white",children:e.jsxs("small",{className:"flex-grow-1",children:[e.jsx("strong",{children:Kr(i,o.layer)})," →"," ",Wr(i,o.layer,o.field),' = "',typeof o.value=="boolean"?String(o.value):o.value,'"']})},o.id))]})}Vt.propTypes={conditions:l.shape({cond_fields:l.arrayOf(l.shape({id:l.string,layer:l.string,field:l.string,value:l.oneOfType([l.string,l.bool])})),cond_operator:l.number}).isRequired,layers:l.objectOf(l.shape({label:l.string.isRequired,fields:l.arrayOf(l.shape({field:l.string.isRequired,label:l.string.isRequired}))})).isRequired};const ni=g.forwardRef(({element:s},t)=>{const n=s?.properties_template?.layers||{},r=s?.metadata||{groups:[],restrict:{}},[i,a]=g.useState(n),[o,d]=g.useState(r),u=g.useRef(null),[p,f]=g.useState(new Set);if(g.useEffect(()=>{const _=et(n,r);a(_.layers),d(_.metadata)},[]),g.useImperativeHandle(t,()=>({getUpdates:()=>({layers:i,metadata:o})})),!s?.properties_template?.layers||Object.values(n).length===0)return Ut;const y=(_,R)=>{const F=R.groups||[],D=Object.values(_),L=new Set;F.forEach(U=>{U.layers?.forEach(N=>L.add(N))});const P=D.filter(U=>!L.has(U.key)),G=[...F.map(U=>({type:"group",data:U,position:U.position||0})),...P.map(U=>({type:"layer",data:U,position:U.position||0}))];return{items:ce(G,"position"),allLayers:_}},b=y(n,r),x=y(i,o),j=(_,R,F)=>{const D=[...o.groups||[]],L=D.findIndex(q=>q.id===F);if(L===-1)return;const P=D[L],G=P.layers||[],k=G.indexOf(_),U=G.indexOf(R);if(k===-1||U===-1)return;const N=[...G],[A]=N.splice(k,1);N.splice(U,0,A),D[L]={...P,layers:N},d({...o,groups:D})},C=(_,R)=>{const F=x.items.findIndex(U=>U.type==="group"&&U.data.id===_||U.type==="layer"&&U.data.key===_),D=x.items.findIndex(U=>U.type==="group"&&U.data.id===R||U.type==="layer"&&U.data.key===R);if(F===-1||D===-1)return;const L=[...x.items],[P]=L.splice(F,1);L.splice(D,0,P);const G=[...o.groups||[]],k={...i};L.forEach((U,N)=>{if(U.type==="group"){const A=G.findIndex(q=>q.id===U.data.id);A!==-1&&(G[A]={...G[A],position:N},G[A].layers?.forEach(q=>{k[q]&&(k[q]={...k[q],position:N})}))}else if(U.type==="layer"){const A=U.data.key;k[A]&&(k[A]={...k[A],position:N})}}),d({...o,groups:G}),a(k)},T=(_,R=!1,F=null)=>{const{label:D,color:L,style:P="panel_generic_heading",key:G,fields:k}=_,U=`p-3 rounded border border-${R?"primary":"secondary"}`,N=_.cond_fields&&_.cond_fields.length>0,A=p.has(G),q=B=>{B.stopPropagation();const M=new Set(p);A?M.delete(G):M.add(G),f(M)},Y=e.jsxs("div",{className:`${Ve()} ${U}`,children:[e.jsx("div",{className:"d-flex align-items-center",children:e.jsx(si,{className:P,label:D,keyProp:G,fields:k,wf:_.wf,children:e.jsx("span",{className:"ms-auto",children:N&&e.jsxs(Ne,{variant:"outline-secondary",size:"xsm",onClick:q,children:[I.faGears," ",A?"Hide":"Show"," Restrictions"]})})})}),N&&A&&e.jsx("div",{className:"mt-2",children:e.jsx(Vt,{conditions:_,layers:n})})]});return R?F?e.jsx(Ae,{type:`layer-in-group-${F}`,layer:_,field:"position",handleMove:(B,M)=>j(B,M,F),canDrag:!0,children:Y},`layer-${G}-new`):e.jsx(Ae,{type:"top-level-item",layer:{type:"layer",key:G,label:D,position:_.position},field:"position",handleMove:(B,M)=>C(B,M),canDrag:!0,children:Y},`layer-${G}-new`):F?e.jsx("div",{className:"w-100 p-2 m-2",children:Y},`layer-${G}-current`):Y},S=(_,R=!1)=>{const D=_.layers?.map(q=>(R?x:b).allLayers[q]).filter(Boolean)||[],P=(R?o:r)?.restrict?.[_.id],G=P&&P.cond&&P.cond.length>0,k=p.has(`group-${_.id}`),U=q=>{q.stopPropagation();const Y=new Set(p),B=`group-${_.id}`;k?Y.delete(B):Y.add(B),f(Y)},N=G?{cond_fields:P.cond.map(q=>({...q})),cond_operator:P.op}:null,A=e.jsxs("div",{className:`border border-2 ${R?"border-info":"border-secondary"} rounded p-2 mb-2`,children:[e.jsxs("div",{className:"d-flex align-items-center mb-2",children:[e.jsx(Jt,{bg:R?"info":"secondary",className:"me-2",children:I.faLayerGroup}),e.jsx("strong",{className:R?"text-info":"",children:_.label}),G&&e.jsxs(Ne,{variant:"outline-secondary",size:"xsm",onClick:U,className:"ms-2",children:[I.faGears," ",k?"Hide":"Show"," Restrictions"]})]}),G&&k&&N&&e.jsx("div",{className:"mb-2",children:e.jsx(Vt,{conditions:N,layers:n})}),e.jsxs("div",{children:[D.map(q=>T(q,R,_.id)),D.length===0&&e.jsx("div",{className:"text-muted fst-italic",children:"No layers in this group"})]})]});return R?e.jsx(Ae,{type:"top-level-item",layer:{type:"group",id:_.id,label:_.label,key:_.id,position:_.position},field:"position",handleMove:(q,Y)=>C(q,Y),canDrag:!0,children:A},`group-${_.id}-new`):e.jsx("div",{className:"w-100 p-2 m-2",children:A},`group-${_.id}-current`)},v=()=>{const{items:_}=b;return e.jsx(e.Fragment,{children:_.map(R=>R.type==="group"?S(R.data,!1):e.jsx("div",{className:"w-100 p-2 m-2",children:T(R.data,!1,null)},`layer-${R.data.key}-current`))})},E=()=>{const{items:_}=x;return e.jsx(e.Fragment,{children:_.map(R=>R.type==="group"?S(R.data,!0):T(R.data,!0,null))})};return e.jsxs("div",{className:"d-flex flex-column h-100",children:[e.jsxs(_e,{className:"mx-0 p-3",children:[e.jsx(he,{md:6,children:e.jsx(Ze,{title:"Current Arrangement",children:"The existing arrangement of groups and layers"})}),e.jsx(he,{md:6,className:"text-primary",children:e.jsxs(Ze,{title:"New Arrangement",children:["Drag (",I.faArrowsUpDownLeftRight,") groups and layers to reorder. Layers within groups can only be reordered within their group."]})})]}),e.jsx("div",{ref:u,className:"flex-grow-1",style:{overflowY:"auto",overflowX:"hidden",minHeight:0,position:"relative"},children:e.jsxs(_e,{className:"mx-0 h-100",children:[e.jsx(he,{md:6,style:{position:"relative"},children:v()}),e.jsx(he,{md:6,style:{position:"relative"},children:E()})]})}),e.jsx(rn,{scrollableContainerRef:u})]})});ni.displayName="GroupLayerOrderContent";function ts({onSave:s,showProps:t,children:n}){const{show:r,setShow:i}=t;if(!r)return null;const a=()=>{const o=n.ref?.current?.getUpdates();o&&(s(o),i(!1))};return e.jsxs(c.Modal,{centered:!0,show:r,onHide:()=>i(!1),fullscreen:!0,backdrop:"static",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Arrange the order"})}),e.jsx(c.Modal.Body,{className:"d-flex flex-column p-0",style:{overflow:"hidden"},children:n}),e.jsxs(c.Modal.Footer,{className:"justify-content-start",children:[e.jsx(c.Button,{variant:"secondary",onClick:()=>i(!1),children:"Cancel"}),e.jsx(c.Button,{variant:"success",onClick:a,children:"Save"})]})]})}ts.propTypes={onSave:l.func.isRequired,showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired,children:l.node.isRequired};function ln({generic:s={},genericType:t,fnSave:n=()=>{}}){const[r,i]=g.useState(!1),a=g.useRef(null);if(Object.keys(s.properties_template).length===0)return null;const o=d=>{const u=X(s);u.properties_template.layers=d.layers;const p=d.metadata?.groups||[];p.length===0?u.metadata={}:u.metadata={groups:p,restrict:d.metadata?.restrict||{}},u.changed=!0,n(new ee(se(),u))};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"arrange_group_layer",children:e.jsxs(c.Button,{className:"fw-medium",size:"sm",variant:"primary",onClick:()=>i(!0),children:[I.faBars," Arrange Groups & Layers"]})}),e.jsx(ts,{genericType:t,showProps:{show:r,setShow:i},onSave:o,children:e.jsx(ni,{ref:a,element:X(s||{})})})]})}ln.propTypes={generic:l.object,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnSave:l.func};ln.defaultProps={generic:{},fnSave:()=>{}};const an=[{value:m.FieldTypes.F_INTEGER,name:m.FieldTypes.F_INTEGER,label:"Integer"},{value:m.FieldTypes.F_DATETIME,name:m.FieldTypes.F_DATETIME,label:"Date-Time Picker"},{value:m.FieldTypes.F_DATETIME_RANGE,name:m.FieldTypes.F_DATETIME_RANGE,label:"Datetime range"},{value:m.FieldTypes.F_DRAG_ELEMENT,name:m.FieldTypes.F_DRAG_ELEMENT,label:"Link Element"},{value:m.FieldTypes.F_TEXT,name:m.FieldTypes.F_TEXT,label:"Text"},{value:m.FieldTypes.F_TEXTAREA,name:m.FieldTypes.F_TEXTAREA,label:"Text area"},{value:m.FieldTypes.F_SELECT,name:m.FieldTypes.F_SELECT,label:"Select"},{value:m.FieldTypes.F_SELECT_MULTI,name:m.FieldTypes.F_SELECT_MULTI,label:"Select (Multiple)"},{value:m.FieldTypes.F_CHECKBOX,name:m.FieldTypes.F_CHECKBOX,label:"Checkbox"},{value:m.FieldTypes.F_SYSTEM_DEFINED,name:m.FieldTypes.F_SYSTEM_DEFINED,label:"System-Defined"},{value:m.FieldTypes.F_FORMULA_FIELD,name:m.FieldTypes.F_FORMULA_FIELD,label:"Formula-Field"}],ri=[{value:m.FieldTypes.F_DRAG_MOLECULE,name:m.FieldTypes.F_DRAG_MOLECULE,label:"Link Molecule"},{value:m.FieldTypes.F_DRAG_SAMPLE,name:m.FieldTypes.F_DRAG_SAMPLE,label:"Link Sample"},{value:m.FieldTypes.F_INPUT_GROUP,name:m.FieldTypes.F_INPUT_GROUP,label:"Input Group"},{value:m.FieldTypes.F_TEXT_FORMULA,name:m.FieldTypes.F_TEXT_FORMULA,label:"Text-Formula"},{value:m.FieldTypes.F_TABLE,name:m.FieldTypes.F_TABLE,label:"Table"},{value:m.FieldTypes.F_UPLOAD,name:m.FieldTypes.F_UPLOAD,label:"Upload"}],Wa=ri,Ka=[{value:m.FieldTypes.F_DUMMY,name:m.FieldTypes.F_DUMMY,label:"Dummy"},{value:m.FieldTypes.F_FORMULA_FIELD,name:m.FieldTypes.F_FORMULA_FIELD,label:"Formula-Field"},{value:m.FieldTypes.F_TABLE,name:m.FieldTypes.F_TABLE,label:"Table"},{value:m.FieldTypes.F_TEXT_FORMULA,name:m.FieldTypes.F_TEXT_FORMULA,label:"Text-Formula"}],ii=an,on=an.concat(ri),li=an.concat(Wa),ai=Ka,vs=s=>{const t=on.find(n=>n.value===s);return t?t.label:s};function lt({fieldObj:s,prop:t}){const n=s[t],i={field:{text:n||"",variant:"solid",color:"dark"},type:{text:s.type===m.FieldTypes.F_SELECT?`${vs(s.type)}: ${s?.option_layers}`:vs(s.type),variant:"outline",color:"x"},cols:{text:n?`column width division: ${n}`:"",variant:"outline",color:"default"}}[t]||{text:n||"",variant:"outline",color:"default"};return e.jsx(Le,{variant:i.variant,color:i.color,text:i.text})}lt.propTypes={prop:l.oneOf(["field","type","cols"]).isRequired,fieldObj:l.object.isRequired};const Lt=[{value:"none",label:"None",bg:"white",text:"dark"},{value:"warning",label:"Amber",bg:"warning",text:"white"},{value:"primary",label:"Blue (Ocean Blue)",bg:"primary",text:"white"},{value:"info",label:"Blue (Sky Blue)",bg:"info",text:"white"},{value:"danger",label:"Crimson",bg:"danger",text:"white"},{value:"success",label:"Fresh Green",bg:"success",text:"white"},{value:"default",label:"Grey",bg:"secondary",text:"dark"}],ss=g.forwardRef(({layer:s,isAttrOnWF:t,isCreateMode:n},r)=>{const i=g.useRef(),a=g.useRef(),o=g.useRef(),d=g.useRef(),u=g.useRef(),p=g.useRef(),[f,h]=g.useState(s.color||"none"),[y,b]=g.useState(!1),[x,j]=g.useState(s.label_fields||[]),[,C]=g.useState(s.label||""),T=[m.FieldTypes.F_SELECT,m.FieldTypes.F_TEXT],v=s.fields?s.fields.filter(L=>T.includes(L.type)):[],E=()=>v.filter(L=>!x.includes(L.field)),_=L=>{j([...x,L])},R=L=>{j(x.filter(P=>P!==L))},F=L=>{if(L===0)return;const P=[...x];[P[L-1],P[L]]=[P[L],P[L-1]],j(P)},D=L=>{if(L===x.length-1)return;const P=[...x];[P[L],P[L+1]]=[P[L+1],P[L]],j(P)};return g.useImperativeHandle(r,()=>({attLayerKey:i.current,attLabel:a.current,attCols:o.current,attColor:d.current,attStyle:u.current,attWf:p.current,labelFields:x})),e.jsxs(c.Form,{className:"row input-form",children:[e.jsxs(de,{controlId:"formControlLayerKey",children:[e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Name"}),e.jsx(c.Form.Control,{type:"text",defaultValue:s.key,ref:i,readOnly:!!s.key,className:s.key?"bg-light text-muted":""})]}),e.jsxs("div",{className:"help",children:["Layer name is unique in the template, at least 3 characters",e.jsx("br",{}),"Layer name must contain only lowercase letters and underscores, underscores can not be the first/last one character",e.jsx("br",{}),"Layer name should not contain special characters like $, !, %, etc."]})]}),e.jsx(de,{controlId:"formControlLayerLabel",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Display name"}),e.jsx(c.Form.Control,{type:"text",defaultValue:s.label,ref:a,onChange:L=>C(L.target.value)})]})}),e.jsx(de,{controlId:"formControlLayerCols",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Columns per row"}),e.jsx(c.Form.Select,{defaultValue:s.cols||1,ref:o,children:[1,2,3,4,5,6].map(L=>e.jsx("option",{value:L,children:L},L))})]})}),e.jsx(de,{controlId:"formControlLayerColor",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Header color"}),e.jsx(c.Form.Select,{defaultValue:s.color,ref:d,onChange:L=>h(L.target.value),children:Lt.map(L=>e.jsx("option",{value:L.value,children:L.label},L.value))}),e.jsx(c.InputGroup.Text,{className:"bg-white",children:e.jsx(c.Badge,{bg:Lt.find(L=>L.value===f)?.bg||"light",text:Lt.find(L=>L.value===f)?.text||"dark",className:f==="default"?"lu-bg-light":"",children:Lt.find(L=>L.value===f)?.label||"None"})})]})}),e.jsx(de,{controlId:"formCtlHeaderStyle",children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Text Style"}),e.jsxs(c.Form.Select,{defaultValue:s.style,ref:u,children:[e.jsx("option",{value:"panel_generic_heading",children:"bold"}),e.jsx("option",{value:"panel_generic_heading_bu",children:"bold + underline"}),e.jsx("option",{value:"panel_generic_heading_bui",children:"bold + underline + italic"})]})]})}),e.jsx(de,{controlId:"formCtlWF",hidden:!t,children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Used in Workflow?"}),e.jsxs(c.Form.Select,{defaultValue:s?.wf,ref:p,children:[e.jsx("option",{value:!1,children:"No"}),e.jsx("option",{value:!0,children:"Yes"})]})]})}),!n&&e.jsxs(de,{controlId:"formCtlDynamicLabel",children:[e.jsxs(c.Button,{variant:"link",onClick:()=>b(!y),"aria-controls":"dynamic-label-collapse","aria-expanded":y,className:"text-decoration-none p-0 mb-2",children:[y?"▼":"▶"," Advanced Display Name Setting",x.length>0&&e.jsxs(c.Badge,{bg:"info",className:"ms-2",children:[x.length," field",x.length>1?"s":""," ","selected"]})]}),e.jsx(c.Collapse,{in:y,children:e.jsx("div",{id:"dynamic-label-collapse",children:e.jsxs("div",{className:"border rounded p-3 bg-light",children:[e.jsxs("p",{className:"text-muted small mb-3",children:["Select fields to include in the layer display name. Only select and text field types are supported. The display name will be:"," ",e.jsx("strong",{children:"Display Name - Field1 Value - Field2 Value"})]}),x.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("strong",{className:"d-block mb-2",children:"Selected Fields (in order):"}),e.jsx(c.ListGroup,{children:x.map((L,P)=>{const G=v.find(k=>k.field===L);return G?e.jsxs(c.ListGroup.Item,{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("span",{children:[e.jsx("strong",{children:G.label||""}),e.jsx(lt,{fieldObj:G,prop:"field"})]}),e.jsxs("div",{children:[e.jsx(c.Button,{size:"xsm",variant:"outline-secondary",onClick:()=>F(P),disabled:P===0,className:"me-1",title:"Move up",children:"↑"}),e.jsx(c.Button,{size:"xsm",variant:"outline-secondary",onClick:()=>D(P),disabled:P===x.length-1,className:"me-1",title:"Move down",children:"↓"}),e.jsx(c.Button,{size:"xsm",variant:"outline-danger",onClick:()=>R(L),title:"Remove",children:"×"})]})]},L):null})})]}),E().length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("strong",{className:"d-block mb-2",children:"Available Fields:"}),e.jsx(c.ListGroup,{children:E().map(L=>e.jsxs(c.ListGroup.Item,{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("span",{children:[e.jsx("strong",{children:L.label||L.field}),e.jsx(lt,{fieldObj:L,prop:"field"})]}),e.jsx(c.Button,{size:"xsm",variant:"outline-primary",onClick:()=>_(L.field),children:"Select"})]},L.field))})]}),v.length===0&&e.jsx("div",{className:"alert alert-info mb-0",children:"No text or select fields available in this layer."})]})})})]})]})});ss.propTypes={layer:l.object.isRequired,isAttrOnWF:l.bool.isRequired,isCreateMode:l.bool};ss.defaultProps={isCreateMode:!1};ss.displayName="LayerAttrForm";function ns(s){const{actions:t,isAttrOnWF:n,layer:r,showProps:i}=s,{show:a,setShow:o}=i,d=g.useRef(),u=b=>{const x={key:d.current.attLayerKey.value.trim(),label:d.current.attLabel.value.trim(),color:d.current.attColor.value.trim(),style:d.current.attStyle.value.trim(),cols:parseInt(d.current.attCols.value.trim()||1,10),position:-1,wf:d.current.attWf.value==="true"||d.current.attWf.value===!0||!1,label_fields:d.current.labelFields||[]};b(x),o(!1)},p=b=>{const x={key:d.current.attLayerKey.value.trim(),label:d.current.attLabel.value.trim(),color:d.current.attColor.value.trim(),style:d.current.attStyle.value.trim(),cols:parseInt(d.current.attCols.value.trim()||1,10),position:r.position,wf:d.current.attWf.value==="true"||d.current.attWf.value===!0||!1,label_fields:d.current.labelFields||[]};b(r.key,x),o(!1)},f=(b,x)=>{let j=null;switch(b){case"c":j=e.jsx(c.Button,{variant:"warning",onClick:x?()=>u(x):()=>{},children:"Create"},`_layer_attr_modal_btn_${b}`);break;case"u":j=e.jsx(c.Button,{variant:"warning",onClick:x?()=>p(x):()=>{},children:"Update"},`_layer_attr_modal_btn_${b}`);break;default:j=null}return j},h=()=>{const b=[];return t.forEach(x=>{b.push(f(x.action,x.fnAction))}),b},y=()=>{const b=[],x={c:"New Layer",u:"Edit Layer attributes"};return t.map(j=>b.push(x[j.action])),b.join("/")};return e.jsxs(c.Modal,{centered:!0,size:"lg",backdrop:"static",show:a,onHide:()=>o(!1),children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:y()})}),e.jsx(c.Modal.Body,{style:{maxHeight:"70vh",overflow:"auto"},children:e.jsx("div",{className:"col-md-12",children:e.jsx(ss,{ref:d,layer:r,isAttrOnWF:n,isCreateMode:t.some(b=>b.action==="c")})})}),e.jsxs(c.Modal.Footer,{className:"justify-content-start",children:[e.jsx(c.Button,{variant:"secondary",onClick:()=>o(!1),children:"Cancel"}),h()]})]})}ns.propTypes={actions:l.arrayOf(l.shape({action:l.oneOf(["c","u"]),fnAction:l.func})).isRequired,isAttrOnWF:l.bool,layer:l.object,showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired};ns.defaultProps={isAttrOnWF:!1,layer:{}};const dn=s=>{const{fnUpdate:t,isAttrOnWF:n,layer:r,as:i}=s,[a,o]=g.useState(!1),d=p=>{const f=p.split(".");return typeof Ce[f[0]]=="function"?Ce[f[0]](f[1]):Ce[f[0]]||"No message"},u=e.jsxs(c.Dropdown.Item,{eventKey:`edit_layer_attr.${r.label}`,onClick:()=>o(!0),children:[I.faPencil,"  ",d(`edit_layer_attr.${r.label}`)]});return e.jsxs(e.Fragment,{children:[i==="menu"?u:e.jsx(Q,{idf:`edit_layer_attr.${r.label}`,children:e.jsx(c.Button,{size:"sm",onClick:()=>o(!0),children:I.faPencil})}),e.jsx(ns,{actions:[{action:"u",fnAction:t}],isAttrOnWF:n,layer:r,showProps:{show:a,setShow:o}})]})};dn.propTypes={fnUpdate:l.func.isRequired,isAttrOnWF:l.bool,layer:l.object.isRequired,as:l.string};dn.defaultProps={isAttrOnWF:!1,as:"menu"};const cn=s=>{const{fnCreate:t,isAttrOnWF:n}=s,[r,i]=g.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"add_layer",children:e.jsxs(c.Button,{className:"fw-medium",size:"sm",variant:"primary",onClick:()=>i(!0),children:[I.faPlus," Add new layer"]})}),e.jsx(ns,{actions:[{action:"c",fnAction:t}],isAttrOnWF:n,showProps:{show:r,setShow:i}})]})};cn.propTypes={fnCreate:l.func.isRequired,isAttrOnWF:l.bool};cn.defaultProps={isAttrOnWF:!1};const ut="/api/v1",Es={credentials:"same-origin",headers:{Accept:"application/json"}},Tr=s=>({...Es,method:s}),Cr=(s,t)=>({...Es,method:t,headers:{...Es.headers,"Content-Type":"application/json"},body:JSON.stringify(s)}),Sr=async s=>{if(!s.ok){const n=await s.json();throw new Error(n.error||s.statusText)}const t=await s.json();return"mc"in t?t:{mc:"se01"}},At=s=>({mc:"se00",msg:s instanceof Error?s.message:s});class xe{static buildUrl=(t,n={})=>{const i=new URLSearchParams(n).toString();return`${ut}/${t}${i?`?${i}`:""}`};static getHeaders=()=>({Accept:"application/json","Content-Type":"application/json"});static execApi=async(t,n="GET",r={})=>{const a=new URLSearchParams(r).toString(),o=`${ut}/${t}${a?`?${a}`:""}`;try{const d=await fetch(o,Tr(n));return await Sr(d)}catch(d){return At(d)}};static execApiData=async(t,n,r="POST")=>{try{const i=await fetch(`${ut}/${n}`,Cr(t,r));return await Sr(i)}catch(i){return At(i)}};static execApiDepr=async(t,n="GET",r={})=>{const a=new URLSearchParams(r||{}).toString(),o=`${ut}/${t}${a?`?${a}`:""}`;try{return await(await fetch(o,Tr(n))).json()}catch(d){return At(d)}};static execApiDataDepr=async(t,n,r="POST")=>{try{return await(await fetch(`${ut}/${n}`,Cr(t,r))).json()}catch(i){return At(i)}};static execApiRaw=async(t,n="GET",r={})=>{const i=xe.buildUrl(t,r);try{const a=await fetch(i,{method:n,headers:xe.getHeaders(),credentials:"same-origin"});if(!a.ok)throw new Error(`HTTP error ${a.status}`);return a}catch(a){throw console.error(`API error for ${i}:`,a),a}};static execApiDataRaw=async(t,n)=>{const r=xe.buildUrl(n);try{const i=await fetch(r,{method:"POST",headers:xe.getHeaders(),credentials:"same-origin",body:JSON.stringify(t)});if(!i.ok)throw new Error(`HTTP error ${i.status}`);return i}catch(i){throw console.error(`API data error for ${r}:`,i),i}}}const Xa="layers";class Me{static#e=async(t,n="GET",r=null)=>{const i=`${Xa}/${t}`,a=r?await xe.execApiData(r,i):await xe.execApi(i,n);return new ee(Xe(a.mc,a.msg||""),{data:a.data})};static saveStandardLayer=(t={})=>Me.#e("save_standard_layer","POST",t);static deleteStandardLayer=t=>Me.#e(`delete_standard_layer/${t}`,"DELETE");static getStandardLayer=t=>Me.#e(`get_standard_layer/${t}`);static getAllLayers=()=>Me.#e("get_all_layers")}const un=({idf:s,content:t,trigger:n,placement:r,children:i})=>{const a=s.split("."),[o]=g.useState(`lpo_${a[0]}_${ie.v4()}`),d=e.jsx(c.Popover,{id:o,children:t});return e.jsx(c.OverlayTrigger,{animation:!0,placement:r||"top",trigger:n,overlay:d,children:i})};un.propTypes={idf:l.string,content:l.node.isRequired,trigger:l.arrayOf(l.string).isRequired,placement:l.string,children:l.node.isRequired};un.defaultProps={idf:"lpo",placement:"top"};function Qe(s){const{msg:t,cls:n,fnClick:r,size:i,fnParams:a,place:o,fa:d,disabled:u}=s,p=h=>{r(a),h.stopPropagation()},f=e.jsxs("div",{className:"bg-white border rounded shadow-sm p-3",style:{maxWidth:"400px"},children:[e.jsx("h6",{className:"mb-2",children:"Confirm Action"}),e.jsxs("p",{className:"mb-3",children:[I.faTriangleExclamation," ",t||"Confirm"]}),e.jsxs("div",{className:"d-flex justify-content-end gap-2",children:[e.jsx(c.Button,{size:"sm",variant:"secondary",onClick:h=>h.stopPropagation(),"data-testid":"confirm-btn-no",children:"No"}),e.jsx(c.Button,{size:"sm",variant:"danger",onClick:p,"data-testid":"confirm-btn-yes",children:"Yes"})]})]});return e.jsx(un,{content:f,trigger:["focus"],placement:o,children:e.jsx(c.Button,{size:i||void 0,className:n,disabled:u,"data-testid":"confirm-btn",variant:"light",onClick:h=>h.stopPropagation(),type:"button",children:I[d]})})}Qe.propTypes={msg:l.string.isRequired,fnParams:l.object.isRequired,fnClick:l.func.isRequired,cls:l.string,size:l.string,place:l.string,fa:l.string,disabled:l.bool};Qe.defaultProps={cls:"btn-none",size:void 0,place:"top",fa:"faTrashCan",disabled:!1};const Za=({onLayerSelect:s,onLayerDelete:t,onLayerView:n})=>{const[r,i]=g.useState([]);g.useEffect(()=>{(async()=>{const d=await Me.getAllLayers();d.notify.isSuccess&&i(d.element.data||[])})()},[]);const a=[{headerName:"Action",cellRenderer:o=>e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"lyr_add2tpl",children:e.jsx(c.Button,{size:"sm",onClick:()=>s(o),children:"Add"})}),e.jsx(Q,{idf:"lyr_view",children:e.jsx(c.Button,{className:"gu-ml-1",size:"sm",onClick:()=>n(o),children:"View"})}),e.jsx(Qe,{cls:"gu-ml-1",msg:"Delete this Standard Layer permanently?",fnClick:t,fnParams:o})]}),sortable:!1,filter:!1,width:160},{field:"id",headerName:"ID",sortable:!1,filter:!1,width:70},{field:"name",headerName:"Name",sortable:!0,filter:!0,width:200},{field:"label",headerName:"Display Name",sortable:!0,filter:!0,flex:1},{field:"description",headerName:"Description",sortable:!0,filter:!1,cellStyle:{whiteSpace:"pre-wrap",lineHeight:"20px"},cellRenderer:o=>o.value?e.jsx("pre",{style:{margin:0,fontFamily:"inherit",backgroundColor:"unset",border:"unset"},children:o.value}):"",autoHeight:!0,flex:1}];return e.jsx("div",{className:w.GRID_THEME.QUARTZ.VALUE,style:{height:"600px",width:"100%",overflow:"auto"},children:e.jsx(Se.AgGridReact,{columnDefs:a,rowData:r,suppressAutoSize:!0})})},Qa=s=>{const{show:t,title:n,fnHide:r}=s;return e.jsxs(c.Modal,{centered:!0,show:t,size:"sm",onHide:r,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:n})}),e.jsx(c.Modal.Body,{children:"No Data"})]})},oi=s=>{const{show:t,generic:n,layer:r,fnHide:i,fnLink:a}=s;if(!t)return null;const{name:o,container:d,properties:u}=n,p=u&&u.layers&&u.layers[r],f=p.label||"(no label)";let h=d&&d.children&&d.children[0].children||[];if(h=h.filter(j=>!j.is_new),h.length<1||!f)return e.jsx(Qa,{show:t,title:`Analyses, select to link to Layer ${f}`,fnHide:i});const y=p.ai||[],b=j=>e.jsxs("div",{children:[e.jsx("div",{className:"generic_grid_row generic_grid_row_left",children:j.name}),e.jsxs("div",{className:"generic_grid_row generic_grid_row_left",children:[e.jsx(c.Button,{size:"sm",variant:"success",className:"gu_button_right",onClick:()=>a(j.id,r,w.BTN_AI_LINK),disabled:y.includes(j.id),children:w.BTN_AI_LINK}),e.jsx(c.Button,{size:"sm",variant:"danger",className:"gu_button_right",onClick:()=>a(j.id,r,w.BTN_AI_UNLINK),disabled:!y.includes(j.id),children:w.BTN_AI_UNLINK})]})]},`_row_linked_analysis_${j.id}_${r}`),x=[];return h.forEach(j=>{x.push(b(j))}),e.jsxs(c.Modal,{centered:!0,size:"lg",show:t,onHide:i,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsxs(c.Modal.Title,{children:[e.jsx("b",{children:o})," Analyses",e.jsx("br",{}),"select to link/unlink to Layer ",e.jsx("b",{children:f})]})}),e.jsx(c.Modal.Body,{children:e.jsx("div",{style:{maxHeight:"80vh",overflow:"auto"},children:e.jsx("div",{className:"generic_grid",children:x})})})]})};oi.propTypes={show:l.bool.isRequired,generic:l.object.isRequired,layer:l.string.isRequired,fnHide:l.func.isRequired,fnLink:l.func.isRequired};const Ja=["timeStart","timeStop","durationCalc","duration"],eo={d:"days",h:"hours",min:"minutes",s:"seconds"},to={d:"day(s)",h:"hour(s)",min:"min(s)",s:"sec(s)"},di=s=>{const{layer:t,opt:n,onInputChange:r,editMode:i}=s,a="DD/MM/YYYY hh:mm:ss";let o=n.f_obj.sub_fields||[];o.length<1&&(o=Ja.map(j=>j==="duration"?new ve({type:m.FieldTypes.F_TEXT,value:"",col_name:j,option_layers:"duration",value_system:"d"}):new ve({type:m.FieldTypes.F_TEXT,value:"",col_name:j})));const d=o.find(j=>j.col_name==="timeStart")||"",u=o.find(j=>j.col_name==="timeStop")||"",p=o.find(j=>j.col_name==="duration")||"",f=(j,C,T=!1)=>{if(j&&C){const S=it(j,"DD-MM-YYYY HH:mm:ss"),v=it(C,"DD-MM-YYYY HH:mm:ss");if(S<v)return T?it.preciseDiff(S,v):it.duration(v.diff(S))}return""},h=(j,C=1)=>j.asDays()>=C?"d":j.asHours()>=C?"h":j.asMinutes()>=C?"min":j.asSeconds()>=C?"s":"h",y=j=>{const{field:C,event:T}=j;if(T==="setCurrent"){const S=new Date().toLocaleString("en-GB").split(", ").join(" ");o.find(v=>v.col_name===C).value=S}else if(T==="changeUnit"){const S=o.find(_=>_.col_name===C),v=m.genUnits("duration");let E=v.findIndex(_=>_.key===S.value_system);E<v.length-1?E+=1:E=0,S.value_system=v.length>0?v[E].key:"",S.value=m.unitConversion("duration",S.value_system,S.value)}else if(T==="copyTo"){const S=f(d.value,u.value);if(S){const v=h(S),E=o.find(_=>_.col_name===C);E.value_system=v,E.value=Hl(S.as(eo[v]),1)}}else{const{value:S}=T.target;o.find(v=>v.col_name===C).value=S}r({field:n.f_obj.field,layer:t.key,subFields:o,type:n.f_obj.type})},b=f(d.value,u.value,!0),x=We(i,!(d.readonly??!1));return e.jsxs(c.Row,{children:[e.jsx(c.Col,{sm:12,md:3,lg:3,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:"Start"}),e.jsxs(c.InputGroup,{children:[e.jsx(c.Form.Control,{type:"text",value:d.value,placeholder:a,onChange:j=>y({field:"timeStart",event:j}),readOnly:!x}),e.jsx(c.Button,{variant:"light",style:{padding:"6px"},onClick:()=>y({field:"timeStart",event:"setCurrent"}),disabled:!x,children:I.faClock})]})]})}),e.jsx(c.Col,{sm:12,md:3,lg:3,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:"Stop"}),e.jsxs(c.InputGroup,{children:[e.jsx(c.Form.Control,{type:"text",value:u.value,placeholder:a,onChange:j=>y({field:"timeStop",event:j}),readOnly:!x}),e.jsx(c.Button,{variant:"light",style:{padding:"6px"},onClick:()=>y({field:"timeStop",event:"setCurrent"}),disabled:!x,children:I.faClock})]})]})}),e.jsx(c.Col,{sm:12,md:3,lg:3,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:"Duration"}),e.jsxs(c.InputGroup,{children:[e.jsx(c.Form.Control,{type:"text",value:b,disabled:!0,placeholder:"Duration",readOnly:!x}),e.jsx(Q,{idf:"clipboard",children:e.jsx(c.Button,{variant:"light",onClick:()=>{navigator.clipboard.writeText(b)},disabled:!x,children:I.faPaste})}),e.jsx(Q,{idf:"copy_to_duration",children:e.jsx(c.Button,{variant:"light",className:"clipboardBtn",onClick:()=>y({field:"duration",event:"copyTo"}),disabled:!x,children:I.faArrowRight})})]})]})}),e.jsx(c.Col,{sm:12,md:3,lg:3,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:" "}),e.jsxs(c.InputGroup,{children:[e.jsx(c.Form.Control,{type:"text",value:p.value||"",placeholder:"Input Duration...",onChange:j=>y({field:"duration",event:j}),readOnly:!x}),e.jsx(c.Button,{variant:"success",onClick:()=>y({field:"duration",event:"changeUnit"}),disabled:!x,children:to[m.genUnit("duration",p.value_system).key]||""})]})]})})]})};di.propTypes={opt:l.object.isRequired,layer:l.object.isRequired,onInputChange:l.func.isRequired,editMode:l.bool.isRequired};function zt(s,t=""){const n=m.buildTS(s);if(!n)return null;const{label:r}=s;return e.jsx(Q,{idf:`link_term.${r}`,children:e.jsx(c.Button,{className:"p-0",variant:"link",href:n,target:"_blank",onClick:i=>i.stopPropagation(),children:t||I.faCircleQuestion})})}const ht=s=>{const{label:t,desc:n,isSpCall:r,ontology:i}=s,a=r?"gu_sp_label fw-bold d-inline-block mt-2 mb-1":"gu_sp_label_none fw-bold d-inline-block mt-2 mb-1";return n&&n!==""&&!r?e.jsxs(e.Fragment,{children:[e.jsx(c.OverlayTrigger,{placement:"top",overlay:e.jsx(c.Tooltip,{id:ie.v4(),children:n}),children:e.jsx("span",{className:a,children:t})}),zt(i)]}):e.jsxs("span",{className:a,children:[t," ",zt(i)]})};ht.propTypes={label:l.string.isRequired,desc:l.string,isSpCall:l.bool,ontology:l.object};ht.defaultProps={desc:"",isSpCall:!1,ontology:null};const pe=s=>{const{label:t,description:n,isSpCall:r,f_obj:i}=s;return t===void 0?null:t===""?e.jsx(ht,{label:" "}):t!==""&&!i?e.jsx(ht,{label:t}):e.jsx(ht,{label:t,desc:n,isSpCall:r,ontology:i.ontology})};class Yt{constructor(t){Object.assign(this,t),this.id||(this.id=Yt.buildID())}static buildID(){return ie.v4()}static fromFile(t){return new Yt({file:t,name:t.name,filename:t.name,identifier:t.id,is_deleted:!1})}get isNew(){return this.is_new===!0}serialize(){return super.serialize({filename:this.filename,identifier:this.identifier,file:this.file,thumb:this.thumb,content_type:this.content_type,is_deleted:this.is_deleted,id:this.id,is_new:this.isNew||!1})}}function ci({link:s}){return s?e.jsx(c.OverlayTrigger,{delayShow:1e3,placement:"top",overlay:e.jsx(c.Tooltip,{id:"_field_doc_tooltip",children:"Learn more"}),children:e.jsx(c.Button,{style:{padding:"0"},variant:"link",href:s,target:"_blank",onClick:t=>t.stopPropagation(),children:I.faCircleQuestion})}):null}ci.propTypes={link:l.string.isRequired};const Ts=(s,t)=>e.jsx("span",{className:s,style:t}),so=(s,t,n,r)=>{const i=[],o=(s.layers[`${r}`].fields.find(d=>d.field===n)||{}).value||{};switch(t.action){case"l":{const d=Ie(o.files||[],p=>p.uid===t.uid),u=t&&t.val&&t.val.target&&t.val.target.value;o.files[d]&&u&&(o.files[d].label=u);break}case"f":{(t.val||[]).forEach(d=>{const u=ie.v4();(typeof o.files>"u"||o.files===null)&&(o.files=[]),o.files.push({uid:u,filename:d.name}),i.push({uid:u,filename:d.name,file:Yt.fromFile(d)})});break}case"d":{const d=Ie(o.files||[],u=>u.uid===t.uid);return d>=0&&o.files&&o.files.length>0&&o.files.splice(d,1),[o,i,t.uid]}default:console.log(t)}return[o,i]};class no{constructor(){this.type=m.FieldTypes.F_DUMMY,this.field=ie.v4(),this.position=100,this.label="",this.default="",this.required=!1}}const st=s=>{if(typeof s>"u"||s===null||s==="")return"";const n=s.match(/<\s*(\w+\b)(?:(?!<\s*\/\s*\1\b)[\s\S])*<\s*\/\s*\1\s*>|[^<]+/g).map(r=>{const i=r.match(/<sup[^>]*>([^<]+)<\/sup>/);if(i)return e.jsx("sup",{children:i[1]},ie.v4());const a=r.match(/<sub[^>]*>([^<]+)<\/sub>/);return a?e.jsx("sub",{children:a[1]},ie.v4()):r});return e.jsx("span",{children:n})},ui=[{label:"InChiKey",value:"inchikey"},{label:"SMILES",value:"smiles"},{label:"IUPAC",value:"iupac"},{label:"Mass",value:"molecular_weight"}],pi=[{label:"Name",value:"name"},{label:"Ext. Label",value:"external_label"},{label:"Mass",value:"molecular_weight"}],ke=(s=!1)=>[s?"gu_sp_form":"gu_sp_form_none",s?"gu_sp_column":"gu_sp_column_none"],ro=(s,t="")=>{const n=[mt.DOC_SITE,...s].join("/");return t?`${n}#${t}`:n},io=["designer","components"],ye=ro([...io,"fields"]),It={cols:{label:"Column Width Division",doc:[ye,"#column-width-division"].join("")},description:{label:"Hover Info",doc:[ye,"#hover-info"].join("")},field:{label:"Field Name",doc:[ye,"#field-name"].join("")},hasOwnRow:{label:"Has its own line",doc:[ye,"#has-its-own-line"].join("")},label:{label:"Display Name",doc:[ye,"#display-name"].join("")},placeholder:{label:"Placeholder",doc:[ye,"/types","/text","#placeholder"].join("")},type:{label:"Type",doc:[ye,"/types"].join("")},canAdjust:{label:"Can adjust?",doc:[ye,"/types","/formula-field","#can-adjust"].join("")},decimal:{label:"Decimal",doc:[ye,"/types","/formula-field","#decimal"].join("")},formula:{label:"Formula",doc:[ye,"/types","/formula-field","#formula"].join("")},options:{label:"Options",doc:[ye,"/types","/select","#options"].join("")},readonly:{label:"Readonly",doc:[ye,"/types","/text","#read-only"].join("")},required:{label:"Required",doc:[ye,"/types","/text","#required"].join("")},si:{label:"Measured Parameter",doc:[ye,"/types","/system-defined","#system-units"].join("")},supportedUnits:{label:"Set Default Unit",doc:[ye,"/types","/system-defined","#supported-units"].join("")},designer:{label:"LabIMotion Designer",doc:[mt.DOC_SITE,"designer"].join("/")},restrictionSetting:{label:"Restriction Setting",doc:[ye,"layers","restriction-setting"].join("")},templateFeatures:{label:"Template Features",doc:[mt.DOC_SITE,"designer","template-features"].join("/")}},me=s=>It[s]?{label:It[s].label,fieldTooltip:e.jsx(ci,{tooltip:It[s].tooltip,link:It[s].doc})}:{},Ye={menuPortal:s=>({...s,zIndex:9999}),menu:s=>({...s,zIndex:9999}),control:s=>({...s,minHeight:"31px",height:"31px",border:"1px solid #ced4da",boxShadow:"none","&:hover":{borderColor:"#80bdff"}}),valueContainer:s=>({...s,padding:"0 8px",height:"29px"}),singleValue:s=>({...s,marginTop:"0",lineHeight:"29px"}),multiValue:s=>({...s,lineHeight:"normal"}),input:s=>({...s,margin:"0",padding:"0"}),indicatorsContainer:s=>({...s,height:"29px"}),dropdownIndicator:s=>({...s,padding:"4px"})},lo=s=>Array.isArray(s)?s.length===0?[]:s.every(t=>t&&typeof t=="object"&&"value"in t)?Array.from(new Map(s.filter(t=>t.value).map(t=>[t.value,t])).values()).map(t=>({value:t.value})):[]:[],ao=(s,t)=>t.element?.id===s?!1:!!(t.reaction_id||t.wellplate_id||t.element),fi=Object.values(w.PERMIT_TARGET),oo=w.PERMIT_TARGET.ELEMENT,hi=[w.PERMIT_TARGET.SAMPLE,w.PERMIT_TARGET.MOLECULE],co=hi.concat([w.PERMIT_TARGET.GRID]),mi=s=>hi.includes(s[0])?s:fi.filter(t=>!co.includes(t)),Cs=s=>{const t=s||{},n=t.id;if(!n)return{id:"",name:"",email:""};const r=`${t?.first_name} ${t?.last_name}`||"",i=t?.email||"";return{id:n,name:r,email:i}},wr=s=>{const n=m.getUnitSystem().filter(r=>r.field===s)[0];return!n||Object.keys(n).length===0?null:n?.units[0]},bs=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),yi=(s,t,n)=>`${s}${n}${t}`,uo=(s,t)=>{const n=Object.prototype.hasOwnProperty.call(s,w.PROPS_RELEASE);return{icon_name:s.element_klass?.icon_name||"",el_tip:n?yi(s.label,s.name,t):s.short_label||s.name||s.label||"",el_klass:n?s.element_klass?.name:s.type}},po=(s,t,n,r)=>{const i=t?.tag?.taggable_data||{},a=ao(n,i),o=w.SEPARATOR_TAG,d={el_id:t.id,el_type:s,el_label:t.short_label,el_name:t.name||"",el_tip:t.short_label||t.name||t.label||""},u={[w.PERMIT_TARGET.MOLECULE]:{el_id:t.molecule?.id,el_label:t.molecule_name_label,el_tip:yi(t.molecule?.inchikey,t.molecule?.cano_smiles,o)},[w.PERMIT_TARGET.SAMPLE]:{is_new:!0,cr_opt:r&&a?1:0,isAssoc:a,el_decoupled:t.decoupled||!1,el_klass:w.PERMIT_TARGET.SAMPLE},[w.PERMIT_TARGET.ELEMENT]:uo(t,o)};return{...d,...u[s]||{}}},fo={cell_line:"icon-cell_line",device_description:"icon-device_description",reaction:"icon-reaction",research_plan:"icon-research_plan",sample:"icon-sample",screen:"icon-screen",wellplate:"icon-wellplate"},ho=(s,t,n)=>{if(s.value?.el_id){const r=s.value?.el_label||s.value?.el_name;let i=s.value.el_svg;s.value.el_type===w.PERMIT_TARGET.SAMPLE&&i&&!i.endsWith(".svg")&&s.value.el_decoupled&&(i=w.IMG_NOT_AVAILABLE_SVG),i&&!i.endsWith(".svg")&&(i=w.IMG_NOT_AVAILABLE_SVG);const a=s.value.el_tip&&s.value.el_tip.split(w.SEPARATOR_TAG),o=a&&a.length>=1&&a[0]||"",d=a&&a.length>=2&&a[1]||"",u=e.jsxs("div",{children:[o,e.jsx("br",{}),d]}),p=e.jsx(c.Popover,{id:"popover-svg",title:u,style:{maxWidth:"none",maxHeight:"none"},children:e.jsx("img",{src:i,style:{height:"26vh",width:"26vh"},alt:""})});let f=r;const h=b=>b===w.IMG_NOT_AVAILABLE_SVG?null:e.jsx(c.OverlayTrigger,{delayShow:1e3,trigger:["hover","focus"],placement:"top",rootClose:!0,onHide:null,overlay:p,children:e.jsx("img",{className:"generic_grid_img",src:b,alt:""})}),y=(b,x,j)=>b&&b!==""?e.jsxs("div",{className:"s-img",children:[h(b),e.jsx("span",{className:"data",children:j})]}):e.jsx(c.OverlayTrigger,{placement:"top",overlay:e.jsxs(c.Tooltip,{id:ie.v4(),children:[o,e.jsx("br",{}),d]}),children:e.jsx("div",{className:"data",children:j})});if(s.value.el_type===w.PERMIT_TARGET.SAMPLE&&s.value.is_new!==!0&&(f=e.jsx("a",{role:"link",onClick:()=>n(s.value.el_type,s.value.el_id),className:"lu-link",children:e.jsx("span",{className:"reaction-material-link",children:r})})),s.value.el_type===w.PERMIT_TARGET.ELEMENT){const b=fo[s.value.el_klass]||s.value.icon_name;f=e.jsxs("a",{role:"link",onClick:()=>n(s.value.el_klass,s.value.el_id),className:"lu-link",children:[e.jsx("i",{className:b})," ",e.jsx("span",{className:"reaction-material-link",children:r})]})}return y(i,s.value.el_tip,f)}return t===w.PERMIT_TARGET.ELEMENT?e.jsx("span",{className:"indicator",children:I.faLink}):Ts(`icon-${t} indicator`,{width:"4vw"})},mo=(s,t,n,r)=>po(s,t,n,r),gi=s=>{const{opt:t,onDrop:n,readOnly:r}=s,{onNavi:i}=t,[{isOver:a,isOverValidTarget:o},d]=be.useDrop({accept:mi(t.dndItems),canDrop:f=>!r,drop:f=>{const h=f.element,y=mo(t.type.split("_")[1],h,t.id,t.classStr);n(y)},collect:f=>({isOver:f.isOver(),isOverValidTarget:f.canDrop()})}),u=t.dndItems&&t.dndItems[0]===w.PERMIT_TARGET.MOLECULE?w.PERMIT_TARGET.SAMPLE:t.dndItems[0],p=`target${a?" is-over":""}${o?" can-drop":""}`;return e.jsx("div",{ref:d,className:p,children:ho(t,u,i)})};gi.propTypes={opt:l.object.isRequired,onDrop:l.func.isRequired,readOnly:l.bool};const xi=({field:s,rowValue:t,handleMove:n,isEditable:r})=>{const[{isDraggingSource:i},a]=be.useDrag({type:"GRID",item:{fid:s,rId:t.id,type:"GRID"},canDrag:()=>r,collect:f=>({isDraggingSource:f.isDragging()})}),[{isOver:o,isOverValidTarget:d},u]=be.useDrop({accept:"GRID",canDrop:()=>r,drop:f=>{const h={fid:s,rId:t.id},y=f;h.fid===y.fid&&h.rId!==y.rId&&n(y.rId,h.rId)},collect:f=>({isOver:f.isOver(),isOverValidTarget:f.canDrop()})}),p=`generic_grid_dnd${o?" is-over":""}${d?" can-drop":""}${i?" is-dragging":""}`;return e.jsx("div",{ref:u,children:e.jsx("div",{ref:a,className:p,children:e.jsx("div",{className:"dnd-btn",children:e.jsx("span",{className:"text-primary",children:I.faArrowsUpDownLeftRight})})})})};xi.propTypes={field:l.string.isRequired,rowValue:l.object.isRequired,handleMove:l.func.isRequired};const Fe={FN_DRAG_EL_CHEMOTION:"FN_DRAG_EL_CHEMOTION",FN_CONTRIBUTE_TEMPLATE:"FN_CONTRIBUTE_TEMPLATE",FN_DIFF:"FN_DIFF",FN_TABLE_EXPORT:"FN_TABLE_EXPORT",FN_SIZE_GRID:"FN_SIZE_GRID"},yo={[Fe.FN_DRAG_EL_CHEMOTION]:!0,[Fe.FN_CONTRIBUTE_TEMPLATE]:!0,[Fe.FN_DIFF]:!1,[Fe.FN_TABLE_EXPORT]:!0,[Fe.FN_SIZE_GRID]:!0},go=s=>yo[s]??!0;function jt(s){const t=s.fnId;return n=>t?go(t)===!1?null:e.jsx(s,{...n}):e.jsx(s,{...n})}const vt=({addRow:s,isEditable:t=!0})=>e.jsx(Q,{idf:"add_entry",children:e.jsx(c.Button,{onClick:()=>s(),size:"xsm",variant:"primary",disabled:!t,children:I.faPlus})});vt.propTypes={addRow:l.func.isRequired};const Et=({delRow:s,node:t,isEditable:n=!0})=>{const{data:r}=t;return e.jsx(Q,{idf:"remove",children:e.jsx(c.Button,{variant:"light",onClick:()=>s(r),size:"xsm",disabled:!n,children:I.faMinus})})};Et.propTypes={delRow:l.func.isRequired,node:l.object.isRequired};const Rr=()=>e.jsx("div",{className:"grid-btn-none",children:I.faArrowsUpDownLeftRight}),bi=({moveRow:s,field:t,type:n,isEditable:r,node:i})=>e.jsx(xi,{field:t,type:n,rowValue:i.data,handleMove:s,isEditable:r});bi.propTypes={moveRow:l.func.isRequired,field:l.string.isRequired,type:l.string.isRequired,node:l.object.isRequired};const pn=({download:s,opt:t,loading:n=!1})=>{const{isEditable:r}=t;return e.jsx(Q,{idf:"export_tbl_xlsx",children:e.jsx(c.Button,{variant:"success",onClick:s,size:"xsm",disabled:!r||n,children:n?I.faSpinner:I.faDownload})})};pn.fnId=Fe.FN_TABLE_EXPORT;pn.propTypes={download:l.func.isRequired,opt:l.object.isRequired,loading:l.bool.isRequired};const xo=jt(pn),_i=s=>{const{opt:t}=s,{id:n,genericType:r}=t||{};return typeof n!="number"||![w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT].includes(r)?e.jsx(Rr,{}):e.jsx(xo,{...s})||e.jsx(Rr,{})};_i.propTypes={download:l.func,opt:l.object.isRequired,loading:l.bool.isRequired};const bo=(s,t)=>{const{type:n,field:r,onCellChange:i,cellRenderer:a,cellParams:o}=s;switch(n){case m.FieldTypes.F_TEXT:return e.jsx(c.Form.Control,{type:"text",value:t[r]||"",onChange:d=>i({e:d,columnDef:s,rowValue:t})});case m.FieldTypes.F_SYSTEM_DEFINED:return e.jsxs(c.InputGroup,{children:[e.jsx(c.Form.Control,{type:"number",value:t[r].value||"",onChange:d=>i({e:d,columnDef:s,rowValue:t})}),a({...o,node:{data:t}})]});case m.FieldTypes.F_SELECT:case m.FieldTypes.F_DRAG_MOLECULE:case m.FieldTypes.F_DRAG_SAMPLE:case"dnd":return a({...o,node:{data:t}});default:return e.jsx("span",{})}},_o=s=>{const t=s,n=[],r=(i,a)=>{const{width:o,headerName:d,headerComponent:u,headerParams:p}=i,f={};return o&&Object.assign(f,{width:o,minWidth:o}),e.jsxs("div",{className:"generic_grid_header",style:f,children:[u?u(p):null,e.jsx("div",{style:f,children:d})]},`column_header_${i.colId||i.field}_${a}`)};return t.forEach((i,a)=>n.push(r(i,a))),e.jsx("div",{className:"generic_grid",style:{borderBottom:"1px solid #ccc"},children:e.jsx("div",{children:n})})},jo=(s,t)=>{const n=s,r=t,i=[],a=(o,d,u)=>{const{field:p,width:f,cellParams:h,cellRenderer:y,type:b}=o,x={};f&&Object.assign(x,{width:f,minWidth:f});const j=b===m.FieldTypes.F_SELECT?"generic_grid_row generic_grid_row_left":"generic_grid_row";return e.jsx("div",{className:j,style:x,children:p?bo(o,d)||"":y({...h,node:{data:d}})||""},`column_row_${d.id}_${o.colId||o.field}_${u}`)};return n.forEach((o,d)=>i.push(a(o,r,d))),e.jsx("div",{className:"generic_grid",children:e.jsx("div",{children:i})},`column_row_${r.id}`)},vo=s=>{const t=s;return t&&t.length>0?null:e.jsx("div",{className:"generic_grid",children:e.jsx("div",{children:e.jsx("div",{className:"generic_grid_row",style:{width:"100%"},children:"(No data)"})})})},ji=s=>{const{sField:t,onChange:n,node:r}=s;if(t.type!==m.FieldTypes.F_SYSTEM_DEFINED)return null;const{data:i}=r;return e.jsx(c.Button,{onClick:()=>n(t,r),variant:"success",size:"sm",children:st(m.genUnit(t.option_layers,i[t.id].value_system).label)||""},`ucr_${i.id}`)};ji.propTypes={sField:l.object.isRequired,onChange:l.func.isRequired,node:l.object.isRequired};const Eo=(s,t,n,r)=>{const{molecule:i,tag:a}=t,o=a?.taggable_data||{};let d=!1;r!=="Segment"&&(o?.element?.id===n?d=!1:d=!!(o.reaction_id||o.wellplate_id||o.element));const u=r!=="Segment"?1:0;switch(s){case w.PERMIT_TARGET.MOLECULE:return{el_id:i.id,el_type:w.PERMIT_TARGET.MOLECULE,el_label:i.cano_smiles||t.molecule_formula||t.molecule_name_label,el_inchikey:i.inchikey,el_smiles:i.cano_smiles,el_iupac:i.iupac_name,el_molecular_weight:i.molecular_weight,el_svg:`/images/molecules/${i.molecule_svg_file}`};case w.PERMIT_TARGET.SAMPLE:return{el_id:t.id,is_new:!0,cr_opt:u,isAssoc:d,el_type:w.PERMIT_TARGET.SAMPLE,el_label:t.short_label,el_short_label:t.short_label,el_name:t.name,el_external_label:t.external_label,el_molecular_weight:t.molecule_molecular_weight,el_smiles:t.molecule_cano_smiles,el_svg:t.sample_svg_file?`/images/samples/${t.sample_svg_file}`:`/images/molecules/${i.molecule_svg_file}`,el_decoupled:t.decoupled||!1};default:return{el_id:t.id,is_new:!0,cr_opt:0,el_type:t.type,el_label:t.short_label,el_name:t.name||""}}},Fr=(s,t,n=()=>{},r={})=>{if(s.value&&s.value.el_id){const i=s.value.el_label;let a=s.value.el_svg;s.value.el_type==="sample"&&a&&!a.endsWith(".svg")&&s.value.el_decoupled&&(a=w.IMG_NOT_AVAILABLE_SVG),a&&!a.endsWith(".svg")&&(a=w.IMG_NOT_AVAILABLE_SVG);const o=e.jsx(c.Popover,{id:"popover-svg",title:i,style:{maxWidth:"none",maxHeight:"none"},children:e.jsx("img",{src:a,style:{height:"26vh",width:"26vh"},alt:""})}),d=p=>p===w.IMG_NOT_AVAILABLE_SVG?Ts(`icon-${t}`,{width:"4vw",fontSize:"x-large"}):e.jsx(c.OverlayTrigger,{delayShow:1e3,trigger:["hover","focus"],placement:"top",rootClose:!0,onHide:null,overlay:o,children:e.jsx("img",{className:"generic_grid_img",src:p,alt:""})});return((p,f)=>p&&p!==""?e.jsxs("div",{className:"s-img",children:[d(p),e.jsx("div",{className:"del_btn",children:e.jsx(Q,{idf:"remove_molecule",children:e.jsx(c.Button,{variant:"danger",size:"xsm",className:"btn_del",onClick:()=>n({},r),children:I.faTrashCan})})})]}):e.jsx("div",{className:"data",style:{width:"4vw"},children:f}))(a,i)}return Ts(`icon-${t} indicator`,{width:"4vw",fontSize:"x-large"})},To=(s,t,n)=>{if(s.type===m.FieldTypes.F_TABLE){const r=s.sField||{},i=s.data[r.id],{data:a}=s;return Fr(i,t,n,{sField:r,data:a})}return Fr(s,t)},fn=s=>{const{opt:t,onDrop:n,genericType:r}=s,[{isOver:i,isOverValidTarget:a},o]=be.useDrop({accept:mi(t.dndItems),drop:(u,p)=>{const f=p.getItem().element,h=t.sField.type.split("_")[1],{id:y}=t,b=Eo(h,f,y,r);n(b,t)},collect:u=>({isOver:u.isOver(),isOverValidTarget:u.canDrop()})}),d=`target${i?" is-over":""}${a?" can-drop":""}`;return e.jsx("div",{className:d,ref:o,style:{display:"inline-flex",justifyContent:"center"},children:To(t,"sample",n)})};fn.propTypes={opt:l.object.isRequired,onDrop:l.func};fn.defaultProps={onDrop:()=>{}};const Ss=s=>{const{opt:t,sField:n,onChange:r,node:i,genericType:a}=s;if(![m.FieldTypes.F_DRAG_MOLECULE,m.FieldTypes.F_DRAG_SAMPLE].includes(n.type))return null;const{data:o}=i;t.dndItems=[n.type.split("_")[1]],t.sField=n,t.data=o;const d=X(t);return e.jsx("div",{className:"drop_generic_properties drop_generic_table_wrap",children:e.jsx(fn,{opt:d,onDrop:r,genericType:a})})};Ss.propTypes={sField:l.object.isRequired,opt:l.object.isRequired,onChange:l.func.isRequired,node:l.object.isRequired};const ws=s=>{const{attr:t,sField:n,node:r}=s;let i=((r.data[n.id]||{}).value||{})[`el_${t.value}`]||"";i=t.value==="molecular_weight"&&i!==""?i.toFixed(6):i;const a=()=>{Kl(i)};return e.jsx(Q,{idf:"clipboard",children:e.jsx("div",{role:"button",tabIndex:0,className:"clipboardBtn",onClick:a,onKeyDown:o=>o.key==="Enter"&&a(),style:{wordBreak:"break-all",cursor:"copy"},children:i})})};ws.propTypes={attr:l.object.isRequired,sField:l.object.isRequired,node:l.object.isRequired};const hn=s=>{const{sField:t,node:n,onNavi:r}=s,i=((n.data[t.id]||{}).value||{}).el_id||"",a=((n.data[t.id]||{}).value||{}).el_short_label||" ";return i===""?e.jsx("div",{}):e.jsx("a",{role:"link",onClick:()=>r("sample",i),className:"lu-link",children:e.jsx("span",{className:"reaction-material-link",children:a})})};hn.propTypes={sField:l.object.isRequired,node:l.object.isRequired,onNavi:l.func};hn.defaultProps={onNavi:()=>{}};const vi=s=>{const{sField:t,node:n,onChange:r,genericType:i}=s,{data:a}=n,o=a[t.id]&&a[t.id].value||{};if(!o.is_new)return e.jsx("div",{});const d=ie.v4();return i==="Segment"?e.jsx("div",{className:"generic_sam_options",children:e.jsx(Q,{idf:"associate_direct",placement:"right",children:e.jsx(c.Form.Check,{type:"radio",name:`dropS_${d}`,disabled:o.isAssoc,checked:o.cr_opt===0,onChange:()=>r({node:n,subField:t,crOpt:0}),label:"Current"})})}):e.jsxs("div",{className:"generic_sam_options",children:[e.jsx(Q,{idf:"associate_direct",placement:"right",children:e.jsx(c.Form.Check,{type:"radio",name:`dropS_${d}`,disabled:o.isAssoc,checked:o.cr_opt===0,onChange:()=>r({node:n,subField:t,crOpt:0}),label:"Current"})}),e.jsx(Q,{idf:"associate_split",placement:"right",children:e.jsx(c.Form.Check,{type:"radio",name:`dropS_${d}`,checked:o.cr_opt===1,onChange:()=>r({node:n,subField:t,crOpt:1}),label:"Split"})}),e.jsx(Q,{idf:"associate_duplicate",placement:"right",children:e.jsx(c.Form.Check,{type:"radio",name:`dropS_${d}`,checked:o.cr_opt===2,onChange:()=>r({node:n,subField:t,crOpt:2}),label:"Copy"})})]})};vi.propTypes={sField:l.object.isRequired,node:l.object.isRequired,onChange:l.func.isRequired};const Ei=s=>{const{sField:t,onChange:n,sOptions:r,node:i}=s;if(t.type!==m.FieldTypes.F_SELECT||r.length<1)return null;const{data:a}=i,o=r.find(d=>d.value===a[t.id].value)||null;return e.jsx(Ue,{styles:Ye,isClearable:!0,menuContainerStyle:{position:"absolute"},multi:!1,options:r,value:o,onChange:d=>n(d,t,i),menuPlacement:"auto",menuPortalTarget:document.body})};Ei.propTypes={sField:l.object.isRequired,onChange:l.func.isRequired,node:l.object.isRequired,sOptions:l.arrayOf(l.object).isRequired};const Co=(s,t)=>{const n=window.URL.createObjectURL(s),r=document.createElement("a");r.href=n,r.setAttribute("download",t),document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r)},So=(s,t="download")=>{try{const n=s.headers.get("Content-Disposition");if(n&&n.indexOf("attachment")!==-1){const a=/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(n);if(a!=null&&a[1])return a[1].replace(/['"]/g,"");const d=/filename\*=UTF-8''([^;]*)/i.exec(n);if(d&&d[1])return decodeURIComponent(d[1])}const r=s.url;if(r){const i=r.split("/"),a=i[i.length-1];if(a&&a.includes(".")&&!a.includes("?")&&a.length<100)return a.split("?")[0]}return t}catch(n){return console.error("Error extracting filename from response:",n),t}},Ti=async(s,t="download")=>{try{const n=await s.clone().blob(),r=So(s,t);Co(n,r)}catch(n){throw console.error("Error downloading file from response:",n),n}};class Ht{static exec=async(t,n="GET",r=null,i={})=>{const a=t,o=r?await xe.execApiDataDepr(r,a,n):await xe.execApiDepr(a,n,i);return o.error?new ee(Xe("se00",o.error||""),{data:o}):new ee(Xe("ss00",o.msg||""),{data:o})};static execRaw=async(t,n="GET",r=null,i={})=>{const a=t;return r?await xe.execApiDataRaw(r,a):await xe.execApiRaw(a,n,i)}}class mn{static#e=Ht.execRaw;static exportTable=(t,n)=>mn.#e(`exporter/table_xlsx/${t}`,"GET",null,n)}class Ci extends g.Component{constructor(t){super(t),this.state={dlLoading:!1},this.delRow=this.delRow.bind(this),this.download=this.download.bind(this),this.addRow=this.addRow.bind(this),this.moveRow=this.moveRow.bind(this),this.onCellChange=this.onCellChange.bind(this),this.onSelectClick=this.onSelectClick.bind(this),this.onUnitClick=this.onUnitClick.bind(this),this.onDrop=this.onDrop.bind(this),this.onChk=this.onChk.bind(this),this.getColumns=this.getColumns.bind(this)}onCellChange(t){const{e:n,columnDef:r,rowValue:i}=t,a=n.target.value;if(i[r.field].value===a)return;if(r.type===m.FieldTypes.F_TEXT&&(i[r.field]=a),r.type===m.FieldTypes.F_SYSTEM_DEFINED){if(isNaN(a))return;i[r.field].value=Wl(a).value()}const{opt:d}=this.props,u=d.f_obj.sub_values||[],p=u.findIndex(f=>f.id===i.id);u.splice(p,1,i),d.f_obj.sub_values=u,d.onSubChange(0,0,d.f_obj,!0)}onSelectClick(t,n,r){const{data:i}=r,{opt:a}=this.props,o=a.f_obj.sub_values||[],d=o.find(p=>p.id===i.id);d[n.id]={value:t?t.value:""};const u=o.findIndex(p=>p.id===i.id);o.splice(u,1,d),a.f_obj.sub_values=o,a.onSubChange(n,n.id,a.f_obj,!0)}onUnitClick(t,n){const{data:r}=n,{opt:i}=this.props,a=i.f_obj.sub_values||[],o=a.find(y=>y.id===r.id),d=m.genUnits(t.option_layers);let u=d.findIndex(y=>y.key===o[t.id].value_system);u<d.length-1?u+=1:u=0;const p=d.length>0?d[u].key:"",f=m.unitConversion(t.option_layers,p,o[t.id].value);o[t.id]={value:f,value_system:p};const h=a.findIndex(y=>y.id===r.id);a.splice(h,1,o),i.f_obj.sub_values=a,i.onSubChange(t,t.id,i.f_obj,!0)}onDrop(t,n){const{opt:r}=this.props,i=n.sField,a=r.f_obj.sub_values||[],o=a.find(u=>u.id===n.data.id);o[i.id]={value:t};const d=a.findIndex(u=>u.id===n.data.id);a.splice(d,1,o),r.f_obj.sub_values=a,r.onSubChange(i,i.id,r.f_obj,!0)}onChk(t){const{node:n,subField:r,crOpt:i}=t,{opt:a}=this.props,o=a.f_obj.sub_values||[],d=o.find(p=>p.id===n.data.id);n.data[r.id].value.cr_opt=i,d[r.id]={value:n.data[r.id].value};const u=o.findIndex(p=>p.id===n.data.id);o.splice(u,1,d),a.f_obj.sub_values=o,a.onSubChange(r,r.id,a.f_obj,!0)}getColumns(){const{opt:t}=this.props,{selectOptions:n,onNavi:r,isEditable:i}=t,a=t.f_obj.sub_values||[];let o=[];(t.f_obj.sub_fields||[]).forEach(f=>{let h={type:f.type,headerName:f.col_name,field:f.id};const y=[];if(f.type===m.FieldTypes.F_TEXT&&(h={...h,editable:!0,onCellChange:this.onCellChange}),f.type===m.FieldTypes.F_SELECT){let b=n[f.option_layers]&&n[f.option_layers].options||[];b=b.map(j=>({value:j.key,name:j.key,label:j.label}));const x={sField:f,onChange:this.onSelectClick,sOptions:b};h={...h,cellRenderer:Ei,cellParams:x,onCellChange:this.onCellChange}}if(f.type===m.FieldTypes.F_SYSTEM_DEFINED){const b={sField:f,onChange:this.onUnitClick};h={...h,cellRenderer:ji,cellParams:b,onCellChange:this.onCellChange}}if(f.type===m.FieldTypes.F_DRAG_MOLECULE){const b={sField:f,opt:t,onChange:this.onDrop,genericType:t.genericType};h={...h,cellRenderer:Ss,cellParams:b,onCellChange:this.onCellChange,width:"5vw"},((f.value||"").split(";")||[]).forEach(j=>{const C=ui.find(T=>T.value===j);if(C){const T={colId:j,editable:!1,type:m.FieldTypes.F_TEXT,headerName:C.label,cellRenderer:ws,cellParams:{attr:C,sField:f}};y.push(T)}})}if(f.type===m.FieldTypes.F_DRAG_SAMPLE){const b=a.filter(S=>S[f.id]&&S[f.id].value&&S[f.id].value.is_new),x={sField:f,opt:t,onChange:this.onDrop,genericType:t.genericType};h={...h,cellRenderer:Ss,cellParams:x,onCellChange:this.onCellChange,width:"5vw"};const j={colId:"sam_option",editable:!1,type:m.FieldTypes.F_TEXT,headerName:"",cellRenderer:vi,cellParams:{sField:f,onChange:this.onChk,genericType:t.genericType},width:"3vw"};b.length>0&&t.genericType!=="Segment"&&y.push(j);const C={colId:"sam_link",editable:!1,type:m.FieldTypes.F_TEXT,headerName:"Short label",cellRenderer:hn,cellParams:{sField:f,onNavi:r},width:"10vw"};y.push(C),((f.value||"").split(";")||[]).forEach(S=>{const v=pi.find(E=>E.value===S);if(v){const E={colId:S,editable:!1,type:m.FieldTypes.F_TEXT,headerName:v.label,cellRenderer:ws,cellParams:{attr:v,sField:f}};y.push(E)}})}o.push(h),y.length>0&&(o=o.concat(y))});const d={type:"button",headerName:"",colId:t.f_obj.field,headerComponent:vt,headerParams:{addRow:this.addRow,isEditable:i},cellRenderer:Et,cellParams:{delRow:this.delRow,isEditable:i},width:"unset"};o.splice(0,0,d);const u=`${w.PERMIT_TARGET.GENERIC_GRID}_${t.layer.key}_${t.f_obj.field}`,p={type:"dnd",field:t.f_obj.field,headerName:"",colId:`${t.f_obj.field}_dnd`,headerComponent:_i,headerParams:{download:this.download,opt:t,loading:this.state.dlLoading},cellRenderer:bi,cellParams:{moveRow:this.moveRow,field:t.f_obj.field,type:u,isEditable:i},width:"unset"};return o.splice(0,0,p),o}moveRow(t,n){const{opt:r}=this.props,i=r.f_obj.sub_values,a=i.findIndex(u=>u.id===t),o=i.findIndex(u=>u.id===n),d=i[a];i[a]=i[o],i[o]=d,r.onSubChange(0,0,r.f_obj,!0)}delRow(t){const{opt:n}=this.props;n.f_obj.sub_values=n.f_obj.sub_values.filter(r=>r.id!==t.id),n.onSubChange(0,0,n.f_obj,!0)}addRow(){const{opt:t}=this.props,n=t.f_obj.sub_fields||[],r=new ve;n.map(i=>i.type===m.FieldTypes.F_TEXT?Object.assign(r,{[i.id]:""}):Object.assign(r,{[i.id]:{value:"",value_system:i.value_system}})),t.f_obj.sub_values=t.f_obj.sub_values||[],t.f_obj.sub_values.push(r),t.onSubChange(0,0,t.f_obj,!0)}async download(){try{this.setState({dlLoading:!0});const{opt:t}=this.props,n=await mn.exportTable(t.id,{klass:t.genericType,layer_id:t.layer.key,field_id:t.field});await Ti(n)}catch(t){console.error("Error exporting file:",t)}finally{this.setState({dlLoading:!1})}}render(){const{opt:t}=this.props;if(t.isSearch)return e.jsx("div",{children:"(This is a table)"});if((t.f_obj.sub_fields||[]).length<1)return null;const n=this.getColumns();return e.jsxs("div",{children:[_o(n),e.jsx("div",{children:vo(t.f_obj.sub_values)}),e.jsx("div",{children:(t.f_obj.sub_values||[]).map(r=>jo(n,r))})]})}}Ci.propTypes={opt:l.object.isRequired};const yn=({opt:s,attachment:t})=>{const[n,r]=g.useState(""),[i,a]=g.useState("50%");g.useEffect(()=>{const p=new URLSearchParams({identifier:t.uid,annotated:!1});fetch(`/api/v1/attachments/image/-1?${p}`,{credentials:"same-origin",method:"GET"}).then(f=>f.blob()).then(f=>{f?.type.startsWith("image")&&r(URL.createObjectURL(f))}).catch(f=>{console.log(f)})},[t.uid]);const o=p=>{let f=parseFloat(p.target.value);Number.isNaN(f)?f=50:f<0?f=0:f>100&&(f=100),a(`${f}%`)},d=e.jsx(c.Button,{size:"sm",id:t.uid,className:"button-right",onClick:()=>s.onChange({...s.value,action:"d",uid:t.uid}),children:I.faTimes}),u=t.aid?e.jsx(e.Fragment,{children:e.jsx("a",{onClick:()=>m.downloadFile({contents:`/api/v1/attachments/${t.aid}`,name:t.filename}),style:{cursor:"pointer"},title:t.filename,children:t.filename})}):t.filename;return e.jsxs("div",{className:"generic_grid",children:[e.jsxs("div",{children:[e.jsx("div",{children:d}),e.jsx("div",{className:"generic_grid_row file_text",children:u}),e.jsx("div",{className:"generic_grid_row",children:e.jsx(c.Form.Group,{size:"sm",children:e.jsx(c.Form.Control,{type:"text",value:t.label||"",onChange:p=>s.onChange({...s.value,action:"l",uid:t.uid,val:p})})})})]}),e.jsx("div",{style:{flexDirection:"column",alignItems:"center"},children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{alignSelf:"flex-end",display:"inline-flex"},children:[e.jsxs(c.InputGroup,{size:"sm",className:"gu-xsmall-input-group",children:[e.jsx(c.Form.Control,{type:"number",step:"any",value:parseFloat(i),onChange:o}),e.jsx(c.InputGroup.Text,{children:"%"})]}),e.jsx(c.Button,{size:"sm",onClick:()=>window.open(n,"_blank"),children:"Original"})]}),e.jsx("img",{src:n,alt:t.filename,style:{width:i,height:"auto",maxWidth:"100%"}})]})})]})};yn.propTypes={attachment:l.shape({aid:l.number,filename:l.string,label:l.string,uid:l.string}),opt:l.shape({onChange:l.func,value:l.object})};yn.defaultProps={attachment:{},opt:{}};const Si=({children:s,type:t,field:n,rowValue:r,fnCb:i})=>{const[{isOver:a,isOverValidTarget:o},d]=be.useDrop({accept:t,canDrop:p=>p.element.type==="reaction"&&r.key===m.FieldTypes.F_SYS_REACTION,drop:p=>i({source:p,target:n,rid:r}),collect:p=>({isOver:!!p.isOver(),isOverValidTarget:!!p.canDrop(),item:p.getItem(),itemType:p.getItemType()})}),u=[a&&"gu_is-over",o&&"gu_can-drop"].filter(Boolean).join(" ");return e.jsx("div",{ref:d,className:u,children:s})};Si.propTypes={children:l.oneOfType([l.arrayOf(l.node),l.node]).isRequired,type:l.array.isRequired,fnCb:l.func.isRequired,field:l.object.isRequired,rowValue:l.object.isRequired};const wi=s=>{const{field:t,onNavi:n,onChange:r,isEditable:i}=s,{value:a={}}=t,{el_id:o,el_label:d,el_svg:u,el_tip:p,el_type:f}=a,h=u?`/images/reactions/${u}`:w.IMG_NOT_AVAILABLE_SVG,y=h.endsWith(".svg")?e.jsx("div",{style:{width:"100%",height:"auto"},children:e.jsx(Xl,{svgPath:h,duration:300,resize:!0})}):e.jsx("img",{src:h,style:{height:"26vh"},alt:""}),b=e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"red"},children:I.faBan}),"  Reaction is not accessible."]}),x=T=>{const{source:S,target:v}=T,{element:E}=S;v.value={el_id:E.id,el_label:E.short_label,el_svg:E.reaction_svg_file,el_type:E.type},r({target:v})},j=e.jsxs("div",{className:"lu-drop-zone",style:{alignContent:"center",height:68},children:["Drop Reaction ",I.faFlask," Here"]}),C=()=>{if(!i&&!o)return null;if(!o)return j;const T=e.jsx(c.Button,{variant:"link",style:{border:"1px solid #003366",borderRadius:"4px",padding:"0px 5px"},onClick:()=>n(f,o),children:d}),S=p==="ERROR"?b:y;return e.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"100%"},children:[e.jsx("div",{style:{position:"absolute",top:0,left:0},children:T}),S]})};return i?e.jsx(Si,{type:["reaction"],field:t,rowValue:{key:t.type},fnCb:x,children:C()}):C()};wi.propTypes={field:l.object.isRequired,onNavi:l.func.isRequired,onChange:l.func.isRequired};const wo=({handleChange:s,val:t,readOnly:n})=>{const r=t?new Date(t):null;return e.jsx(c.Form.Group,{onClick:i=>i.stopPropagation(),children:e.jsx("div",{className:"gu-datepicker",children:e.jsx(Zl,{isClearable:!n,clearButtonClassName:"gu_date_picker-clear",showTimeSelect:!0,timeFormat:"HH:mm",timeIntervals:15,timeCaption:"Time",dateFormat:"dd/MM/yyyy HH:mm",selected:r,onSelect:s,onChange:s,placeholderText:"DD/MM/YYYY hh:mm",readOnly:n,className:n?"gu-readonly":""})})})},Ro=({onChange:s,val:t,readOnly:n})=>{const[r,i]=g.useState(!1),a=o=>{s(o),i(!1)};return t||r?e.jsx(wo,{handleChange:a,val:t,readOnly:n}):e.jsx(Q,{idf:"record_time",children:e.jsx(c.Button,{variant:"light",size:"sm",onClick:o=>{o.stopPropagation(),i(!r)},disabled:n,children:I.faClock})})},gn=({opt:s,value:t})=>{const n=ca(t);return e.jsxs(c.Form.Group,{className:"props_text",children:[pe(s),e.jsx("div",{children:n.map((r,i)=>r.type==="link"?e.jsxs("a",{href:r.href,target:"_blank",rel:"noopener noreferrer",style:{wordBreak:"break-word"},children:[r.content," ",I.faArrowUpRightFromSquare]},i):e.jsx("span",{children:r.content},i))})]})};gn.propTypes={opt:l.object,value:l.string};gn.defaultProps={opt:{},value:""};const Fo=s=>s.isSpCall?e.jsxs(c.Form.Group,{className:"props_text gu_sp_form",children:[pe(s),e.jsx(c.Form.Check,{type:"checkbox",name:s.field,checked:s.value,onChange:s.onChange,disabled:s.readOnly,className:"gu_sp_column"})]}):e.jsxs(c.Form.Group,{children:[pe({label:"",description:""}),e.jsxs(c.Form.Check,{type:"checkbox",id:s.field,checked:s.value,onChange:s.onChange,disabled:s.readOnly,children:[e.jsx(c.Form.Check.Input,{type:"checkbox",name:s.field,checked:s.value,onChange:s.onChange,disabled:s.readOnly}),e.jsx(c.Form.Check.Label,{children:pe(s)})]})]}),Ri=s=>{const t=ke(s.isSpCall),n=s.isAtLayer?"gu_date_picker gu_date_picker_layer":"gu_date_picker",r=s.value&&new Date(it(s.value,"DD/MM/YYYY HH:mm:ss").toISOString());return e.jsxs(c.Form.Group,{className:t[0],children:[pe(s),e.jsx("div",{className:n,children:e.jsx(Ro,{onChange:s.onChange,val:r,readOnly:s.readOnly})})]})},No=s=>{const t=s.isRequired?"drop_generic_properties field_required":"drop_generic_properties";let n=null;s.value?.is_new===!0&&s.classStr&&(n=e.jsxs("div",{className:"sample_radios",children:[e.jsx(Q,{idf:"associate_direct",children:e.jsx(c.Form.Check,{type:"radio",name:`dropS_${s.value.el_id}`,disabled:s.value.isAssoc===!0,checked:s.value.cr_opt===0,onChange:()=>s.onChange({...s.value,cr_opt:0}),inline:!0,label:"Current"})}),e.jsx(Q,{idf:"associate_split",children:e.jsx(c.Form.Check,{type:"radio",name:`dropS_${s.value.el_id}`,checked:s.value.cr_opt===1,onChange:()=>s.onChange({...s.value,cr_opt:1}),inline:!0,label:"Split"})}),e.jsx(Q,{idf:"associate_duplicate",children:e.jsx(c.Form.Check,{type:"radio",name:`dropS_${s.value.el_id}`,checked:s.value.cr_opt===2,onChange:()=>s.onChange({...s.value,cr_opt:2}),inline:!0,label:"Copy"})})]}));const r=s.type===m.FieldTypes.F_DRAG_ELEMENT?e.jsx("span",{className:"indicator",children:I.faLink}):e.jsx("span",{className:"icon-sample indicator"}),i=s.isPreview===!0?e.jsx("div",{className:"target",children:r}):e.jsx(gi,{opt:s,onDrop:s.onChange,readOnly:s.readOnly});return e.jsxs(c.Form.Group,{children:[pe(s),e.jsx("div",{style:{paddingBottom:"0px"},children:e.jsxs("div",{className:t,children:[i,n,s.isEditable&&e.jsx("div",{style:{zIndex:"3"},children:e.jsx(Q,{idf:"remove",children:e.jsx(c.Button,{size:"sm",className:"btn_del",variant:"danger",onClick:()=>s.onChange({}),disabled:!s.isEditable,children:I.faTrashCan})})})]})})]})},ko=()=>e.jsx(c.Form.Group,{className:"props_text",children:e.jsx(c.Form.Control,{type:"text",className:"dummy",readOnly:!0})}),Lo=s=>e.jsx(wi,{field:s.f_obj,onNavi:s.onNavi,onChange:s.onChange,isEditable:s.isEditable}),Ao=s=>{const{f_obj:t,isSpCall:n,onSubChange:r,readOnly:i}=s,a=g.useCallback((u,p)=>{r(u,p,t)},[r,t]),o=ke(n),d=t?.sub_fields?.map(u=>u.type===m.FieldTypes.F_LABEL?e.jsx(c.InputGroup.Text,{children:u.value},`_label_${u.id}`):u.type===m.FieldTypes.F_SYSTEM_DEFINED?e.jsxs(g.Fragment,{children:[e.jsx(c.Form.Control,{type:"number",name:u.id,value:u.value,className:`gu-${Be(i,!1)}`,onChange:p=>a(p,u.id,t),min:1,readOnly:i}),e.jsx(c.Button,{onClick:()=>a(u,u.id,t),variant:"success",disabled:i,children:st(m.genUnit(u.option_layers,u.value_system).label)||""})]},`_fra_${u.id}`):e.jsx(c.Form.Control,{type:u.type,name:u.id,value:u.value||"",className:`gu-${Be(i,!1)}`,onChange:p=>a(p,u.id,t),readOnly:i},u.id));return e.jsxs(c.Form.Group,{className:o[0],children:[pe(s),e.jsx(c.InputGroup,{children:d})]})},Io=s=>{const t=Be(s.readOnly,s.isRequired),n=ke(s.isSpCall);return e.jsxs(c.Form.Group,{className:n[0],children:[pe(s),e.jsx(c.Form.Control,{type:"number",value:s.value,onChange:s.onChange,className:t,readOnly:s.readOnly,required:s.isRequired,placeholder:s.placeholder,min:1})]})},Do=s=>{const t=s.options.map(o=>({value:o.key,name:o.key,label:o.label}));let n=Be(s.readOnly,s.isRequired);n=`select_generic_properties_${n}`;const r=t.find(o=>o.value===s.value)||null,i=ke(s.isSpCall),a={menuPortal:o=>({...o,zIndex:9999}),menu:o=>({...o,zIndex:9999})};return e.jsxs(c.Form.Group,{className:i[0],children:[pe(s),e.jsx("span",{className:i[1],children:e.jsx(Ue,{isClearable:!0,name:s.field,multi:!1,options:t,value:r,onChange:s.onChange,className:n,isDisabled:s.readOnly,menuPlacement:"auto",menuPortalTarget:document.body,styles:{...Ye,...a}})})]})},Oo=s=>{const t=Be(s.readOnly,s.isRequired),n=ke(s.isSpCall),r=!!m.genUnit(s.option_layers,s.value_system).unit_type;return e.jsxs(c.Form.Group,{className:n[0],children:[pe(s),e.jsxs(c.InputGroup,{className:n[1],children:[e.jsx(c.Form.Control,{type:"number",value:s.f_obj.value!==void 0&&s.f_obj.value!==null?s.f_obj.value:"",onChange:s.onChange,className:`gu-${t} ${n[1]}`,readOnly:s.readOnly,required:s.isRequired,placeholder:s.placeholder}),e.jsx(c.Button,{size:"sm",disabled:s.readOnly,onClick:s.onClick,variant:"success",title:r?Ce.no_unit_conversion:void 0,children:st(m.genUnit(s.option_layers,s.value_system).label)||""})]})]})},Po=s=>e.jsxs(c.Form.Group,{children:[pe(s),e.jsx(Ci,{opt:s},`grid_${s.f_obj.field}`)]}),Go=s=>{const[t]=g.useState(ie.v4()),{f_obj:n}=s,r=s.value;if(n?.readonly)return e.jsx(gn,{opt:s,value:n.placeholder});const i=ke(s.isSpCall);let a=Be(s.readOnly,s.isRequired),o=s.readOnly||!1;return o&&(a="readonly"),e.jsxs(c.Form.Group,{className:`props_text ${i[0]}`,children:[pe(s),e.jsx(c.Form.Control,{id:t,type:"text",value:r,onChange:s.onChange,className:`${a} ${i[1]}`,readOnly:o,required:s.isRequired,placeholder:s.placeholder})]})},Mo=s=>{const[t]=g.useState(ie.v4()),n=Be(s.readOnly,s.isRequired),r=ke(s.isSpCall);return e.jsxs(c.Form.Group,{className:`props_text ${r[0]}`,children:[pe(s),e.jsx(c.Form.Control,{id:t,as:"textarea",value:s.value,onChange:s.onChange,className:n,readOnly:s.readOnly,required:s.isRequired,placeholder:s.placeholder})]})},$o=s=>{const[t]=g.useState(ie.v4()),{layers:n}=s,r=[];(s.f_obj?.text_sub_fields||[]).map(a=>{const{layer:o,field:d,separator:u}=a;if(d&&d!=="")if(d.includes(`[${w.SEPARATOR_TAG}]`)){const p=d.split(`[${w.SEPARATOR_TAG}]`);if(p&&p.length===2){const f=((n[o]||{}).fields||[]).find(h=>h.field===p[0]&&h.type===m.FieldTypes.F_TABLE);(f&&f.sub_values||[]).forEach(h=>{h&&h[p[1]]&&h[p[1]]!==""&&(r.push(h[p[1]]),r.push(u))})}}else{const p=((n[o]||{}).fields||[]).find(f=>f.field===d);p&&p.value&&p.value!==""&&(r.push(p.value),r.push(u))}return!0});const i=ke(s.isSpCall);return e.jsxs(c.Form.Group,{className:`props_text ${i[0]}`,children:[pe(s),e.jsx(c.Form.Control,{id:t,type:"text",value:r.join(""),className:`readonly ${i[1]}`,readOnly:!0,required:!1})]})},qo=s=>{const t=s.value&&s.value.files||[];return s.isSearch?e.jsx("div",{children:"(This is an upload)"}):e.jsxs(c.Form.Group,{className:"props_text",children:[pe(s),s.readOnly?null:e.jsx("div",{style:{paddingBottom:"0px",paddingTop:"0px"},children:e.jsx(Os,{id:"dropzone",onDrop:n=>s.onChange({...s.value,action:"f",val:n}),className:"lu-drop-zone",style:{height:34},children:e.jsx("div",{style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap"},children:"Drop File, or Click to Select."})})}),e.jsx(c.ListGroup,{children:t.map(n=>e.jsx(c.ListGroupItem,{className:"generic_files",children:e.jsx(yn,{opt:s,attachment:n})},n.uid))})]})},Bo=s=>{const t=(s.f_obj.wf_options||[]).map(i=>{const a=i.label.match(/(.*)\(.*\)/);return{value:i.key,name:i.key,label:a[1]===""?a[0]:a[1]}});let n=Be(s.readOnly,s.isRequired);n=`select_generic_properties_${n}`;const r=t.find(i=>i.value===s.value)||null;return e.jsxs(c.Form.Group,{children:[pe(s),e.jsx(Ue,{menuContainerStyle:{position:"absolute"},name:s.field,multi:!1,options:t,value:r,onChange:s.onChange,className:n,disabled:s.readOnly,styles:Ye})]})},Uo=s=>{const{f_obj:t,formula:n,isSpCall:r,layer:i,onChange:a,placeholder:o,type:d,value:u,isEditable:p}=s;let{canAdjust:f=!1,decimal:h=5}=t;f=es(f),h=Hr(h)||5;const y=i?.fields||[];let b=0,x=null;const j=Ps(y,_=>[m.FieldTypes.F_INTEGER,m.FieldTypes.F_SYSTEM_DEFINED].includes(_.type)),C=/[a-zA-Z0-9_]+/gm,T=n&&n.match(C)?n.match(C).sort((_,R)=>R.length-_.length):[];let S=n?.replace(/\*\*/g,"^");if(T.forEach(_=>{if(!isNaN(_))return;const R=j.find(F=>F.field===_);typeof R>"u"||R==null?S=S?.replace(_,0):S=S?.replace(_,parseFloat(R.value||0))}),d===m.FieldTypes.F_FORMULA_FIELD)try{b=Ql.evaluate(S),x=isNaN(b)?0:parseFloat(b.toFixed(h))}catch(_){x=_.message}const v=e.jsx(c.Form.Control,{type:"text",value:x,className:"readonly",readOnly:!0,disabled:!p,required:!1,placeholder:o,min:0}),E=ke(r);return e.jsxs(c.Form.Group,{className:E[0],children:[pe(s),f?e.jsxs(c.InputGroup,{className:E[1],children:[v,e.jsx(Q,{idf:"adjust_calculation",children:e.jsx(c.Button,{variant:"light",className:"clipboardBtn",onClick:()=>a(x),disabled:!p,children:I.faArrowRight})}),e.jsx(c.Form.Control,{type:"text",value:u,onChange:a,required:!1,placeholder:o,min:0,readOnly:!p})]}):v]})},Pe="generic_elements",Vo="segments",zo="generic_dataset",Nr="generic_klass";class fe{static#e=async(t,n,r="GET",i=null)=>{const a=`${t}/${n}`,o=r==="GET"?null:i,d=r==="GET"?i||{}:{};return Ht.exec(a,r,o,d)};static klassRevisions=(t={})=>fe.#e(Pe,"klass_revisions.json","GET",t);static revisions=({type:t,id:n}={})=>fe.#e(Pe,`${t}_revisions.json`,"GET",{id:n});static deleteKlassRevision=t=>fe.#e(Pe,"delete_klass_revision","POST",t);static deleteRevision=t=>fe.#e(Pe,"delete_revision","POST",t);static listELKlass=(t={})=>fe.#e(Pe,"list_element_klass.json","GET",t);static listSGKlass=(t={})=>fe.#e(Vo,"list_segment_klass.json","GET",t);static listDSKlass=(t={})=>fe.#e(zo,"list_klass.json","GET",t);static deActivateKlass=(t={})=>fe.#e(Nr,"de_activate","POST",t);static fetchKlass=(t={})=>fe.#e(Nr,"fetch","GET",t);static updateTemplate=(t={})=>fe.#e(Pe,"update_template","POST",t);static listELby=(t={})=>fe.#e(Pe,"search_by_like","GET",t);static listBasicELby=(t={})=>fe.#e(Pe,"search_basic_by_like","GET",t);static dispatchListELby=(t={})=>{const{name:n,short_label:r,selected_klass:i,limit:a}=t;return i.klass.is_generic?fe.listELby({name:n,short_label:r,klass_id:i.klass.id,limit:a}):fe.listBasicELby({name:n,short_label:r,klass_name:i.klass.name,limit:a})}}const Yo=Object.values(w.PERMIT_TARGET),Fi=({show:s,onHide:t,onSelect:n})=>{const[r,i]=g.useState([]),[a,o]=g.useState([]),[d,u]=g.useState(!1),[p,f]=g.useState(null),[h,y]=g.useState(""),[b,x]=g.useState(""),[j,C]=g.useState(20),[T,S]=g.useState({}),v=g.useRef();g.useEffect(()=>{s&&E()},[s]);const E=async()=>{u(!0);try{const k=await fe.listELKlass({is_active:!0});if(k.notify?.isSuccess){const U=ce((k.element?.data?.klass||[]).filter(N=>N.is_generic||Yo.includes(N.name)),"label");i(U)}else console.error("Failed to fetch elements:",k.error),i([])}catch(k){console.error("Error fetching elements:",k),i([])}finally{u(!1)}},_=g.useMemo(()=>r.map(k=>({value:k.name,label:k.label,klass:k})),[r]),R=g.useCallback(async()=>{const k={};if(p||(k.element="Element selection is required"),b.trim()&&b.trim().length<3&&(k.shortLabel="Short Label must be at least 3 characters"),h.trim()&&h.trim().length<3&&(k.name="Name must be at least 3 characters"),p?.value==="research_plan"?h.trim()||(k.name="Name is required for research plans"):!h.trim()&&!b.trim()&&(k.search="At least one of Name or Short Label is required"),S(k),!(Object.keys(k).length>0))try{const U=await fe.dispatchListELby({name:h,short_label:b,selected_klass:p,limit:20});U.notify?.isSuccess?o(U.element?.data?.elements||[]):(console.error("Failed to search elements:",U.error),o([]))}catch(U){console.error("Error searching elements:",U),o([])}},[p,b,h,r]),F=()=>{f(null),x(""),y(""),o([]),S({})},D=g.useCallback(k=>{if(k.node.isSelected()){const U=k.data;n(U),L()}},[n]),L=g.useCallback(()=>{F(),t()},[t,F]),P=g.useMemo(()=>[{headerName:"Element",field:"klass_label",sortable:!1,flex:1},{headerName:"Name",field:"name",sortable:!0,flex:2},{headerName:"Short Label",field:"short_label",sortable:!0,flex:1},{headerName:"Action",field:"id",sortable:!1,width:120,cellRenderer:k=>e.jsx(c.Button,{variant:"primary",size:"xsm",onClick:()=>{n(k.data),L()},children:"Select"})}],[n,L]),G=g.useMemo(()=>({minWidth:100,filter:!1,sortable:!0,resizable:!0}),[]);return s&&e.jsx(e.Fragment,{children:e.jsx("div",{className:"modal-backdrop fade show",style:{zIndex:1055},children:e.jsxs(c.Modal,{show:s,onHide:L,size:"xl",centered:!0,backdrop:"static",enforceFocus:!0,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Link Element"})}),e.jsxs(c.Modal.Body,{children:[Object.keys(T).length>0&&e.jsxs(c.Alert,{variant:"danger",className:"mb-3",children:[T.element&&e.jsx("div",{children:T.element}),T.search&&e.jsx("div",{children:T.search}),T.shortLabel&&e.jsx("div",{children:T.shortLabel}),T.name&&e.jsx("div",{children:T.name})]}),e.jsxs(c.Row,{className:"mb-3 align-items-end",children:[e.jsx(c.Col,{md:3,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:"Element"}),e.jsx(Ue,{styles:Ye,isClearable:!0,options:_,value:p,onChange:f,placeholder:"select from element...",menuPortalTarget:document.body,menuPosition:"fixed"})]})}),e.jsx(c.Col,{md:3,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:"Name"}),e.jsx(c.Form.Control,{type:"text",size:"sm",placeholder:"(case-insensitive like search)",value:h,onChange:k=>y(k.target.value)})]})}),e.jsx(c.Col,{md:3,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:"Short Label"}),e.jsx(c.Form.Control,{type:"text",size:"sm",placeholder:"(case-insensitive like search)",value:b,onChange:k=>x(k.target.value)})]})}),e.jsx(c.Col,{md:1,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:"Results"}),e.jsx(c.Form.Control,{disabled:!0,type:"text",size:"sm",placeholder:"20",value:j,onChange:k=>C(k.target.value)})]})}),e.jsx(c.Col,{md:2,children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Button,{variant:"primary",onClick:R,className:"me-2",size:"sm",children:"Search"}),e.jsx(c.Button,{variant:"secondary",onClick:F,size:"sm",children:"Reset"})]})})]}),e.jsx("div",{className:w.GRID_THEME.BALHAM.VALUE,style:{height:"400px",width:"100%",overflow:"auto"},children:e.jsx(Se.AgGridReact,{ref:v,rowData:a,columnDefs:P,defaultColDef:G,loading:d,rowSelection:{mode:"singleRow",checkboxes:!1,enableClickSelection:!1},onRowClicked:D,suppressAutoSize:!1})})]}),e.jsx(c.Modal.Footer,{className:"justify-content-start",children:e.jsx(c.Button,{variant:"secondary",onClick:L,children:"Close"})})]})})})};Fi.propTypes={show:l.bool.isRequired,onHide:l.func.isRequired,onSelect:l.func.isRequired};const xn=({onSelect:s,label:t,variant:n,size:r,className:i,disabled:a})=>{const[o,d]=g.useState(!1),u=p=>{s(p),d(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(c.Button,{variant:n,size:r,className:i,disabled:a,onClick:()=>d(!0),children:t}),e.jsx(Fi,{show:o,onHide:()=>d(!1),onSelect:u})]})};xn.propTypes={onSelect:l.func.isRequired,label:l.string,variant:l.string,size:l.string,className:l.string,disabled:l.bool};xn.defaultProps={label:"Link Element",variant:"success",size:"xsm",className:"",disabled:!1};const Ho=e.jsx(c.Button,{variant:"success",size:"xsm",disabled:!0,children:"Link Element"});function bn({elId:s,elTip:t,iconName:n,elLabel:r,elKlass:i,onNavi:a,onChange:o,isEditable:d}){if(!s)return e.jsx("span",{});const[,u]=(t||"").split(w.SEPARATOR_TAG);return e.jsxs("span",{className:"d-flex align-items-center gap-3",children:[e.jsxs("a",{role:"link",onClick:()=>a(i,s),className:"lu-link",children:[e.jsx("i",{className:n})," ",e.jsx("span",{className:"reaction-material-link",children:r||u})," ",I.faArrowUpRightFromSquare]}),e.jsx(c.Button,{size:"sm",variant:"danger",onClick:()=>o({}),disabled:!d,children:I.faTrashCan})]})}bn.propTypes={elId:l.string,elTip:l.string,iconName:l.string,elLabel:l.string,elKlass:l.string,onNavi:l.func.isRequired,onChange:l.func.isRequired,isEditable:l.bool};bn.defaultProps={elId:null,elTip:"",iconName:"",elLabel:"",elKlass:"",isEditable:!1};function Ni(s){const{onChange:t,isEditable:n,isPreview:r,onNavi:i,value:a}=s,{el_id:o,el_label:d,el_klass:u,icon_name:p,el_tip:f}=a||{},h=y=>{if(!y||!y.id)return;const b={el_id:y.id,el_type:w.PERMIT_TARGET.ELEMENT,icon_name:y.klass_icon||"",el_klass:y.klass_name,el_label:y.short_label,el_name:y.name||"",el_tip:`${y.klass_label}${w.SEPARATOR_TAG}${y.name}`};t(b)};return r?e.jsxs(c.Form.Group,{children:[pe(s),e.jsx("div",{children:Ho})]}):e.jsxs(c.Form.Group,{children:[pe(s),e.jsx("div",{children:o?e.jsx(bn,{elId:o,elTip:f,iconName:p,elLabel:d,elKlass:u,onNavi:i,onChange:t,isEditable:n}):e.jsx(xn,{onSelect:h})})]})}Ni.fnId=Fe.FN_DRAG_EL_CHEMOTION;const Wo=jt(Ni);function ki(s){const{genericType:t}=s;return t===w.GENERIC_TYPES.DATASET?e.jsx(Wo,{...s}):e.jsx(No,{...s})}ki.propTypes={genericType:l.string.isRequired};const Ko=s=>{const{field:t,f_obj:n,options:r,onChange:i,isRequired:a,isEditable:o,isSpCall:d,readOnly:u}=s,p=ke(d),f=r.map(b=>({value:b.key,name:b.key,label:b.label}));let h=o?"select_generic_properties_editable":"select_generic_properties_readonly";h=a&&o?"select_generic_properties_required":h;const y=(n?.sub_fields||[]).map(b=>{const x=f.find(j=>j.value===b.value);return x||null}).filter(Boolean);return e.jsxs(c.Form.Group,{className:p[0],children:[pe(s),e.jsx("span",{className:p[1],children:e.jsx(Ue,{className:h,isClearable:!0,isMulti:!0,isDisabled:u,menuPlacement:"auto",menuPortalTarget:document.body,name:t,options:f,onChange:i,styles:Ye,value:y})})]})},kr="is_voc",He={R:{value:"read",op:7},S:{value:"skip"},W:{value:"write"}},Xo=s=>typeof s!="object"||s===null||Array.isArray(s),Zo=s=>typeof s=="object"&&s!==null&&!Array.isArray(s)&&Object.keys(s).length===0,Qo=s=>Xo(s)||Zo(s)||!(kr in s)?He.S.value:s[kr]===!0&&s?.opid>=He.R.op?He.R.value:He.W.value,Lr=(s,t)=>Qo(s)===He.R.value?!0:t,Li=s=>{const t={...s,dndItems:[],readOnly:Lr(s.f_obj,s.readOnly),isEditable:!Lr(s.f_obj,!s.isEditable)};let[n,r]=t.type.split("_");switch(s.isSearch&&n===m.FieldTypes.F_DRAG&&(n=m.FieldTypes.F_TEXT),n){case m.FieldTypes.F_CHECKBOX:return Fo(t);case m.FieldTypes.F_DATETIME:return Ri(t);case m.FieldTypes.F_FORMULA_FIELD:return Uo(t);case m.FieldTypes.F_SELECT:return Do(t);case m.FieldTypes.F_SELECT_MULTI:return Ko(t);case m.FieldTypes.F_DRAG:return t.dndItems=[...t.dndItems,r],ki(t);case m.FieldTypes.F_INTEGER:return Io(t);case m.FieldTypes.F_SYSTEM_DEFINED:return Oo(t);case m.FieldTypes.F_INPUT_GROUP:return Ao(t);case m.FieldTypes.F_TEXTAREA:return Mo(t);case m.FieldTypes.F_UPLOAD:return qo(t);case m.FieldTypes.F_DUMMY:return ko();case m.FieldTypes.F_SYS_REACTION:return Lo(t);case m.FieldTypes.F_TABLE:return Po(t);case m.FieldTypes.F_TEXT_FORMULA:return $o(t);case m.FieldTypes.F_WF_NEXT:return Bo(t);default:return Go(t)}},Ar={canDrag(s){return!s.layer.wf},beginDrag(s){return s}},Jo=s=>{const{type:t,layer:n,field:r,handleMove:i,id:a,handleChange:o,onAttrChange:d,hasAi:u,editMode:p,grouped:f}=s,[{isDraggingSource:h},y]=be.useDrag(()=>({type:t,canDrag:()=>Ar.canDrag(s),item:()=>Ar.beginDrag(s),collect:N=>({isDraggingSource:N.isDragging()})})),[{isOver:b,isOverValidTarget:x},j]=be.useDrop(()=>({accept:t,canDrop:N=>!n.wf||!N.layer.wf,drop:N=>{r===N.field&&n.key!==N.layer.key&&i(N.layer.key,n.key)},collect:N=>({isOver:N.isOver(),isOverValidTarget:N.canDrop()})})),{style:C,label:T,wf:S=!1,key:v,timeRecord:E}=n,_=v.startsWith(w.SYS_REACTION),R=(N,A,q,Y)=>e.jsx(Jl,{delayShow:1e3,placement:"top",overlay:e.jsx(ea,{id:`tooltip-${n.key}-${q}`,children:A}),children:e.jsx(Ne,{variant:"light",size:"sm",onClick:Y,children:N},`btn-${n.key}-${q}`)},`${n.key}-${q}`),F=u?R(I.faPaperclip,"link analysis","_tooltip_link_ana",N=>o(N,a,n,"ana-modal")):null,D=R(I.faFlask,"Add reaction","_tooltip_layer_add_reaction",N=>o(N,a,n,"layer-add-reaction")),L=R(I.faPlus,"Add layer","_tooltip_add_layer",N=>o(N,a,n,"layer-modal")),P=R(I.faMinus,_?"Remove this reaction":"Remove layer","_tooltip_remove_layer",N=>o(N,a,n,"layer-remove")),G=()=>{const N=v.split(".");return N.length>1?e.jsx("span",{children:`Repetition ${N[1]}`}):null},k=()=>{const N=e.jsx(js,{children:Ri({isSpCall:!1,isAtLayer:!0,label:void 0,value:E||"",onChange:d,readOnly:!p})},`${n.key}-group1`);if(!p)return N;const A=!S&&(/\.\d+$/.test(v)||_);return e.jsxs(e.Fragment,{children:[_?null:N,e.jsxs(js,{className:"me-2",children:[D,F,_?null:L,A?P:null]},`${n.key}-group2`)]})},U=e.jsxs("div",{className:ze,children:[e.jsx(De,{wf:S}),G(),k()]});return e.jsx("div",{children:U})},Je=(s,t,n,r=new Set,i=null)=>{const a=`${t.key}.${s.field}`;if(r.has(a))return[!1,s.label];r.add(a);const[o,d]=m.showProperties(s,n,i);if(!o)return[!1,d];if(s.cond_fields&&s.cond_fields.length>0)for(const u of s.cond_fields){const p=n[u.layer];if(p){const f=(p.fields||[]).find(h=>h.field===u.field);if(f){const[h]=Je(f,p,n,r,i);if(!h)return[!1,d]}}}return[!0,d]},qe=(s,t,n=null)=>{let r=s;s.cond&&!s.cond_fields&&(r={cond_fields:s.cond.map(o=>({...o,value:o.eq||o.value})),cond_operator:s.op});const[i,a]=m.showProperties(r,t,n);if(!i)return[!1,a];if(r.cond_fields)for(const o of r.cond_fields){const d=t[o.layer];if(d){const u=(d.fields||[]).find(p=>p.field===o.field);if(u){const[p]=Je(u,d,t,new Set,n);if(!p)return[!1,a]}}}return[!0,a]},ed=(s,t)=>{if(!Array.isArray(s)||!Array.isArray(t))return[];const n=t.filter(r=>r.type==="select"?!0:r.type==="text"?r.readonly!==!0:!1).map(r=>r.field);return s.filter(r=>n.includes(r))},Rs=(s,t)=>Array.isArray(s)?s.filter(n=>n!==t):[],td=(s,t,n,r=null,i={},a=null)=>{if(!s)return"";if(!Array.isArray(t)||t.length===0)return s;const o=n?.fields||[],d=ed(t,o);if(d.length===0)return s;const u=d.map(p=>{const f=o.find(h=>h.field===p);if(!f)return null;if(r){const[h]=Je(f,n,r,new Set,a);if(!h)return null}return i[p]?i[p]:f.value||f.default||""}).filter(p=>p&&p.toString().trim()!=="");return u.length===0?s:`${s} - ${u.join(" - ")}`},_n=g.createContext(),sd=({children:s,value:t})=>e.jsx(_n.Provider,{value:t,children:s}),Tt=()=>{const s=g.useContext(_n);return s===void 0?{refSource:{}}:s};class ot extends g.Component{static contextType=_n;constructor(t){super(t),this.handleChange=this.handleChange.bind(this),this.handleSubChange=this.handleSubChange.bind(this),this.handleDTRChange=this.handleDTRChange.bind(this),this.moveLayer=this.moveLayer.bind(this)}handleChange(t,n,r,i){const{onChange:a}=this.props;a(t,n,r,i)}handleSubChange(t,n,r,i=!1){const{onSubChange:a}=this.props,o=r.sub_fields.find(p=>p.id===n);if(!i)if(t.type===m.FieldTypes.F_SYSTEM_DEFINED){const p=m.genUnits(t.option_layers);let f=p.findIndex(h=>h.key===t.value_system);f<p.length-1?f+=1:f=0,o.value_system=p.length>0?p[f].key:"",o.value=m.unitConversion(t.option_layers,o.value_system,t.value)}else o.value=t.target.value;const{layer:d}=this.props,u={f:r,sub:o};a(d.key,u,i)}handleDTRChange(t){const{field:n,layer:r,subFields:i,type:a}=t;this.handleChange(i,n,r,a)}handleClick(t,n,r){const{onClick:i}=this.props,a=m.genUnits(n.option_layers);let o=a.findIndex(u=>u.key===r);o<a.length-1?o+=1:o=0;const d=n;d.value_system=a.length>0?a[o].key:"",i(t,d)}views(){const{layer:t,selectOptions:n,id:r,layers:i,classStr:a,isPreview:o,isSearch:d,onNavi:u,isSpCall:p,editMode:f,genericType:h}=this.props,{fields:y,key:b,sp:x}=t;let{cols:j}=t;p&&x&&(j=1);let C=j||1,T=Math.floor(12/C);const S=[];let v=[],E=12,_=0;const{refSource:R}=this.context;return(y||[]).forEach((F,D)=>{const[L,P]=Je(F,t,i,new Set,R?.element);if(L){let G;if(F.type===m.FieldTypes.F_DATETIME_RANGE){v.length>0&&(S.push(e.jsx(_e,{children:v},`${b}_${S.length}`)),v=[],E=12),S.push(e.jsx(di,{layer:t,opt:{f_obj:F},onInputChange:this.handleDTRChange,editMode:f},`${b}_${S.length}`)),_=0;return}F.hasOwnRow?(v.length>0&&(S.push(e.jsx(_e,{children:v},`${b}_${S.length}`)),v=[],E=12),G=12,_=0):F.type===m.FieldTypes.F_TABLE?(G=12/(F.cols||1),_=0):(C=F.cols||C,T=Math.floor(12/C),G=T),(C===5&&_>=5||E<G)&&(S.push(e.jsx(_e,{children:v},`${b}_${S.length}`)),v=[],E=12,_=0);const k=m.genUnits(F.option_layers)[0]||{},U=C===5&&![m.FieldTypes.F_TABLE,m.FieldTypes.F_DATETIME_RANGE].includes(F.type)&&!F.hasOwnRow?"g_col_w":"";v.push(e.jsx(he,{md:G,lg:G,className:U,children:e.jsx(Li,{layers:i,id:r,layer:t,classStr:a||"",f_obj:F,label:P||F.label,value:F.value||"",description:F.description||"",type:F.type||m.FieldTypes.F_TEXT,field:F.field||"field",formula:F.formula||"",options:n&&n[F.option_layers]&&n[F.option_layers].options||[],onChange:N=>this.handleChange(N,F.field,b,F.type),onSubChange:this.handleSubChange,isEditable:We(f,!(F.readonly??!1)),isPreview:o,isSearch:d,readOnly:!We(f,!(F.readonly??!1)),isRequired:F.required||!1,placeholder:F.placeholder||"",option_layers:F.option_layers,value_system:F.value_system||k.key,onClick:()=>this.handleClick(b,F,F.value_system||k.key),selectOptions:n||{},onNavi:u,isSpCall:p,genericType:h},`${r}_${t}_${F.field}_GenPropertiesLayer`)},`prop_${b}_${F.priority}_${F.field}`)),E-=G,_+=1,(G===12||D===y.length-1||C===5&&_>=5)&&(S.push(e.jsx(_e,{children:v},`${b}_${S.length}`)),v=[],E=12,_=0)}}),v.length>0&&S.push(e.jsx(_e,{children:v},`${b}_${S.length}`)),S}moveLayer(t,n){this.handleChange(null,t,n,"drop-layer")}render(){const{id:t,layer:n,layers:r,activeWF:i,hasAi:a,aiComp:o,expandAll:d,editMode:u,grouped:p,groups:f}=this.props,{color:h="default",style:y,label:b}=n,{refSource:x}=this.context,j=td(b,n.label_fields||[],n,r,{},x?.element),C=Ve(h);let T=y||"panel_generic_heading";T=["lu-bg-light","lu-bg-white"].includes(C)?`${T} text-dark`:`${T} text-white`;const S=e.jsx(Jo,{type:"gen_panel",layer:n,field:"layer",rowValue:{id:n.key},handleMove:this.moveLayer,id:t,handleChange:this.handleChange,onAttrChange:_=>this.handleChange(_,"timeRecord",n,"layer-data-change"),hasAi:a,editMode:u,grouped:p}),v=e.jsx(Yl.Header,{as:"div",className:`custom-accordion-header ${C} flex-grow-1`,children:j===""?e.jsx("span",{className:T,children:" "}):e.jsx("span",{className:T,children:j})});return e.jsxs(_t,{dnd:i?S:void 0,layerKey:n.key,propHeader:v,extClass:C,layers:r,expandAll:d,groups:f,children:[this.views(),o&&o[n.key]]},`_usr_prop_content_${n.key}`)}}ot.propTypes={id:l.oneOfType([l.string,l.number]),layer:l.object,selectOptions:l.object,onChange:l.func.isRequired,onSubChange:l.func.isRequired,onClick:l.func,classStr:l.string,layers:l.object.isRequired,isPreview:l.bool,isSearch:l.bool,activeWF:l.bool,isSpCall:l.bool,onNavi:l.func,hasAi:l.bool,aiComp:l.any,expandAll:l.bool,editMode:l.bool.isRequired,genericType:l.string.isRequired,grouped:l.bool.isRequired,groups:l.array};ot.defaultProps={id:0,selectOptions:{},onClick:()=>{},isPreview:!1,classStr:"",isSearch:!1,activeWF:!1,isSpCall:!1,onNavi:()=>{},hasAi:!1,aiComp:null,expandAll:void 0,groups:[]};function jn({groupId:s,groupLabel:t,groupLayers:n,restriction:r,allLayers:i,id:a,classStr:o,onChange:d,onSubChange:u,selectOptions:p,onClick:f,isPreview:h,isSearch:y,activeWF:b,onNavi:x,isSpCall:j,hasAi:C,aiComp:T,expandAll:S,editMode:v,genericType:E,groups:_}){const{refSource:R}=Tt(),[F,D]=g.useState(!0),[L,P]=g.useState(()=>S??(n||[]).some(M=>ti(i,M.key,_))),[G,k]=g.useState(!1),U=r&&r.cond&&r.cond.length>0,N=U?{cond_fields:r.cond.map(B=>({...B,value:B.eq||B.value})),cond_operator:r.op}:null,A=n||[];let q=S;q===void 0&&(F||(q=!1));const Y=A.map((B,M)=>{const O=`${s}_${B.key}_${M}`;if(typeof B.cond_fields>"u"||B.cond_fields==null||B.cond_fields.length===0)return e.jsx(ot,{id:a,layer:B,classStr:o||"",onChange:d,onSubChange:u,selectOptions:p,onClick:f,layers:i,isPreview:h,isSearch:y,activeWF:b,onNavi:x,isSpCall:j,hasAi:C,aiComp:T,expandAll:q,editMode:v,genericType:E,grouped:!0,groups:_},O);const[V]=qe(B,i,R?.element);return V?e.jsx(ot,{id:a,layer:B,classStr:o||"",onChange:d,onSubChange:u,selectOptions:p,onClick:f,layers:i,isPreview:h,isSearch:y,activeWF:b,onNavi:x,isSpCall:j,hasAi:C,aiComp:T,expandAll:q,editMode:v,genericType:E,grouped:!0,groups:_},O):null}).filter(Boolean);return e.jsxs(c.Card,{className:"mb-3 border-2 border-info",id:`group-anchor-${s}`,children:[e.jsxs(c.Card.Header,{className:"d-flex align-items-center justify-content-between cursor-pointer",onClick:()=>{P(!L),D(!1)},style:{cursor:"pointer"},children:[e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx(c.Badge,{bg:"info",className:"me-2",children:I.faLayerGroup}),e.jsx("strong",{className:"text-info",children:t}),e.jsxs("span",{className:"ms-2 text-muted small",children:["(",n.length," layer",n.length!==1?"s":"",")"]})]}),e.jsxs("div",{className:"d-flex align-items-center",children:[U&&e.jsxs(c.Badge,{bg:"secondary",className:"me-2 cursor-pointer",onClick:B=>{B.stopPropagation(),k(!G)},style:{cursor:"pointer"},children:[I.faGears," ",G?"Hide":"Show"," Restrictions"]}),e.jsx("span",{className:"text-muted",children:L?I.faChevronUp:I.faChevronDown})]})]}),G&&U&&N&&e.jsx(c.Card.Body,{className:"border-bottom bg-light py-2",children:e.jsx(Vt,{conditions:N,layers:i})}),e.jsx(c.Collapse,{in:L,unmountOnExit:!0,children:e.jsx(c.Card.Body,{className:"p-2",children:Y.length>0?Y:e.jsx("div",{className:"text-muted text-center py-3",children:"No layers to display in this group"})})})]})}jn.propTypes={groupId:l.string.isRequired,groupLabel:l.string.isRequired,groupLayers:l.array.isRequired,restriction:l.object,allLayers:l.object.isRequired,id:l.oneOfType([l.string,l.number]),classStr:l.string,onChange:l.func.isRequired,onSubChange:l.func.isRequired,selectOptions:l.object,onClick:l.func,isPreview:l.bool,isSearch:l.bool,activeWF:l.bool,onNavi:l.func,isSpCall:l.bool,hasAi:l.bool,aiComp:l.object,expandAll:l.bool,editMode:l.bool,genericType:l.string,groups:l.array};jn.defaultProps={groups:[]};const nd=s=>{const{generic:t,funcChange:n,funcSubChange:r,funcClick:i,extLys:a,id:o,isPreview:d,activeWF:u,isSearch:p,fnNavi:f,isSpCall:h,hasAi:y,aiComp:b,expandAll:x,editMode:j,genericType:C}=s,{refSource:T}=Tt(),S=t.properties?.layers||{},v=t.properties_release?.select_options||{},E=t?.short_label||"",_=t.metadata||{},R=_.groups||[],F=_.restrict||{},D=h?[]:a.map(k=>e.jsx(Li,{field:k.field,label:"Name",classStr:E||"",description:k.generic.description||"",value:k.generic[k.field]||"",type:k.type,isEditable:We(j,!0),readOnly:!We(j,!0),isRequired:k.isRequired||!1,onChange:U=>n(U,k.field,"",k.type),genericType:C},`${k.generic.id}_${k.field}_elementalPropertiesExt`)),L=[].concat(e.jsx("div",{className:"pb-3",children:D},"ext-layers")),P=tt(S,R),G={id:o,classStr:E||"",onChange:n,onSubChange:r,selectOptions:v,onClick:i,layers:S,isPreview:d,isSearch:p,activeWF:u,onNavi:f,isSpCall:h,hasAi:y,aiComp:b,expandAll:x,editMode:We(j,!0),genericType:C,groups:R};return P.forEach((k,U)=>{if(k.type==="group"){const N=k.layers.map(B=>B.data);if(h&&N.every(B=>!B.sp))return;const A=h?N.filter(B=>B.sp):N;if(A.length===0)return;const q=F[k.id];if(q&&q.cond&&q.cond.length>0){const B={cond_fields:q.cond.map(O=>({...O,value:O.eq||O.value})),cond_operator:q.op},[M]=qe(B,S,T?.element);if(!M)return}const Y=e.jsx(jn,{groupId:k.id,groupLabel:k.label,groupLayers:A,restriction:F[k.id],allLayers:S,...G},`group-${k.id}-${U}`);L.push(Y)}else{const N=k.data;if(h&&!N.sp)return;const A=`${N.key}_${U}`;if(typeof N.cond_fields>"u"||N.cond_fields==null||N.cond_fields.length===0){const q=e.jsx(ot,{layer:N,grouped:!1,...G},A);L.push(q)}else if(N?.cond_fields?.length>0){const[q]=qe(N,S,T?.element);if(q){const Y=e.jsx(ot,{layer:N,grouped:!1,...G},A);L.push(Y)}}}}),L},Ai=g.createContext(),Ii=({children:s,initialShowOverview:t=!0})=>{const[n,r]=g.useState(t),a={showOverview:n,setShowOverview:r,toggleOverview:()=>r(o=>!o),isProviderPresent:!0};return e.jsx(Ai.Provider,{value:a,children:s})};Ii.propTypes={children:l.node.isRequired,initialShowOverview:l.bool};const Di=()=>{const s=g.useContext(Ai);return s||{showOverview:!0,setShowOverview:()=>console.warn("useGenUIContext must be used within a GenUIProvider"),toggleOverview:()=>console.warn("useGenUIContext must be used within a GenUIProvider"),isProviderPresent:!1}},Oi=({now:s,maxDots:t=10,variant:n="primary",shape:r="dot",className:i=""})=>{const a=Math.round(s/100*t),o=Array.from({length:t}),d=u=>`lu_dot ${u<a?"filled":"empty"} variant-${n} shape-${r}`;return e.jsx("div",{className:`lu_dot-progress-container ${i}`,children:o.map((u,p)=>e.jsx("div",{className:d(p)},p))})};Oi.propTypes={now:l.number.isRequired,maxDots:l.number,variant:l.string,shape:l.oneOf(["dot","square"]),className:l.string};const Re=s=>s!==""&&s!==null&&s!==void 0,rd={[m.FieldTypes.F_CHECKBOX]:()=>!0,[m.FieldTypes.F_TEXT_FORMULA]:()=>!0,[m.FieldTypes.F_TEXT]:s=>s.readonly===!0||Re(s.value),[m.FieldTypes.F_TABLE]:s=>Array.isArray(s.sub_values)&&s.sub_values.length>0&&typeof s.sub_values[0]=="object"&&s.sub_values[0]!==null,[m.FieldTypes.F_DATETIME_RANGE]:({sub_fields:s})=>Array.isArray(s)&&s.length>=4&&Re(s[0]?.value)&&Re(s[1]?.value)&&Re(s[3]?.value),[m.FieldTypes.F_INPUT_GROUP]:({sub_fields:s})=>Array.isArray(s)&&s.length>0&&s.every(t=>t.type===m.FieldTypes.F_LABEL||Re(t.value)),[m.FieldTypes.F_SELECT_MULTI]:({sub_fields:s})=>Array.isArray(s)&&s.some(t=>Re(t.value)),[m.FieldTypes.F_DRAG_ELEMENT]:({value:s})=>s&&typeof s=="object"&&Re(s.el_id),[m.FieldTypes.F_DRAG_MOLECULE]:({value:s})=>s&&typeof s=="object"&&Re(s.el_id),[m.FieldTypes.F_DRAG_SAMPLE]:({value:s})=>s&&typeof s=="object"&&Re(s.el_id),[m.FieldTypes.F_UPLOAD]:({value:s})=>s&&typeof s=="object"&&Array.isArray(s.files)&&s.files.length>0},id=s=>{const t=rd[s.type];return t?t(s):Re(s.value)},Pi=(s,t,n=null)=>{const r=s.fields||[];if(r.length===0)return 100;const i=r.filter(d=>{const[u]=Je(d,s,t,new Set,n);return u}),a=i.length;if(a===0)return 100;const o=i.filter(id).length;return Math.round(o/a*100)},ld=(s,t,n=null)=>{if(s.length===0)return 0;const r=s.reduce((i,a)=>i+Pi(a,t,n),0);return Math.round(r/s.length)},Gi=({generic:s,onNodeJump:t,refElement:n})=>{const{properties:r,metadata:i={}}=s,a=r?.layers||{},o=i.groups||[],d=i.restrict||{},[u,p]=g.useState(new Set),f=x=>{p(j=>{const C=new Set(j);return C.has(x)?C.delete(x):C.add(x),C})},y=tt(a,o).filter(x=>{const C=x.type==="group"?d[x.id]||{}:x.data,[T]=qe(C,a,n);return T}),b=(x,j=!1)=>{const C=x.type==="group",T=C?ld(x.layers.map(E=>E.data),a,n):Pi(x.data,a,n),S=u.has(x.id),v=T===100?"success":T>50?"warning":"danger";return e.jsx(c.Card,{className:`mb-2 shadow-sm ${j?"ms-3 border-start-0 bg-light":""}`,style:{fontSize:"0.85rem",borderColor:C?"#5bc0de":"#dee2e6",borderLeftWidth:C?"4px":"1px"},children:e.jsxs(c.Card.Body,{className:"p-2",children:[e.jsxs("div",{className:"d-flex justify-content-between align-items-center mb-1",children:[e.jsxs("div",{className:"d-flex align-items-center text-truncate pe-2",children:[C&&e.jsx("span",{className:"me-2 text-info",style:{fontSize:"0.9rem",minWidth:"16px"},children:I.faLayerGroup}),e.jsx("span",{className:`fw-bold text-truncate ${C?"":"ps-1"}`,title:C?x.label:x.data.label||x.key,children:C?x.label:x.data.label||x.key})]}),e.jsxs("div",{className:"d-flex align-items-center flex-shrink-0",children:[e.jsx(c.Button,{variant:"primary",size:"sm",className:"p-0 px-1 me-1",title:"Go to section",onClick:()=>t(C?x.id:x.key,C),children:I.faArrowDown}),C&&e.jsx(c.Button,{variant:"primary",size:"sm",className:"p-0 px-1",title:S?"Collapse":"Expand",onClick:()=>f(x.id),children:S?I.faMinus:I.faPlus})]})]}),e.jsxs("div",{className:"px-1",children:[e.jsx("div",{className:"small text-muted mb-1",style:{fontSize:"0.7rem"},children:"Completion"}),e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx(Oi,{now:T,variant:v,className:"me-2",shape:"square"}),e.jsxs("span",{className:"small text-muted fw-bold",style:{minWidth:"35px",textAlign:"right",fontSize:"0.75rem"},children:[T,"%"]})]})]}),C&&S&&e.jsx("div",{className:"mt-2 border-top pt-2",children:x.layers.filter(E=>{const[_]=qe(E.data,a,n);return _}).map(E=>b({...E,type:"layer"},!0))})]})},C?`group-${x.id}`:`layer-${x.key}`)};return e.jsxs("div",{className:"prog-overview-dashboard",children:[e.jsxs("div",{className:"d-flex align-items-center mb-3 bg-white",style:{lineHeight:1},children:[e.jsx("span",{className:"me-2 d-flex align-items-center",style:{fontSize:"1.1rem",transform:"translateY(-1px)"},children:I.faChartBar}),e.jsx("div",{className:"fw-bold uppercase tracking-wider",style:{fontSize:"0.85rem",letterSpacing:"0.05rem"},children:"OVERVIEW MAP"})]}),e.jsx(c.Row,{xs:1,md:2,lg:3,xl:4,className:"g-2",children:y.map(x=>e.jsx(c.Col,{children:b(x)},x.type==="group"?`col-group-${x.id}`:`col-layer-${x.key}`))})]})};Gi.propTypes={generic:l.object.isRequired,onNodeJump:l.func.isRequired,refElement:l.object};const Mi=({generic:s,refElement:t})=>{const{showOverview:n}=Di(),r=(a,o)=>{const d=f=>{const h=document.getElementById(f);return h?(h.scrollIntoView({behavior:"smooth",block:"start"}),h.classList.add("lu_jump-highlight"),setTimeout(()=>{h.classList.remove("lu_jump-highlight")},4e3),!0):!1},u=`_accordion_design_props_${a}`,p=`group-anchor-${a}`;if(o)d(p);else if(document.getElementById(u))d(u);else{const y=(s.metadata?.groups||[]).find(b=>(b.layers||[]).includes(a));if(y){const b=document.querySelector(`#group-anchor-${y.id} .card-header`);b&&(b.click(),setTimeout(()=>{d(u)},100))}else d(u)}};return Object.keys(s.properties?.layers||{}).length>0?e.jsx(e.Fragment,{children:n&&e.jsx("div",{className:"mb-4",children:e.jsx(Gi,{generic:s,onNodeJump:r,refElement:t})})}):null};Mi.propTypes={generic:l.object.isRequired,refElement:l.object};const Ir=(s,t,n)=>e.jsx(c.Card,{className:"shadow-sm",style:{width:"100%"},children:e.jsxs(c.Card.Body,{className:"d-flex justify-content-between align-items-center p-3",children:[e.jsx("div",{children:e.jsxs(c.Card.Title,{className:"h6 mb-0",children:[s.label,e.jsxs("span",{className:"text-muted small me-2 fw-normal",children:[" ","(",s.key,")"]})]})}),e.jsx("span",{title:n?"Add this layer":"This layer cannot be added",style:{cursor:n?"pointer":"not-allowed"},children:e.jsxs(c.Button,{size:"sm",variant:n?"primary":"secondary",onClick:r=>t(r,s),disabled:!n,children:[I.faPlus," Add"]})})]})},s.key);function $i(s){const{show:t,generic:n,fnClose:r,fnAdd:i,selectedLayerKey:a}=s;if(!t)return null;const o=n.properties_release?.layers||{},d=n.metadata||{};if(Object.values(o).length<1)return null;const f=((x,j)=>{const C=j.groups||[],T=Object.values(x),S=new Set;C.forEach(R=>{R.layers?.forEach(F=>S.add(F))});const v=T.filter(R=>!S.has(R.key)),E=[...C.map(R=>({type:"group",data:R,position:R.position||0})),...v.map(R=>({type:"layer",data:R,position:R.position||0}))];return{items:ce(E,"position"),allLayers:x}})(o,d),h=(d.groups||[]).some(x=>x.layers?.includes(a));let y=null;h&&(y=(d.groups||[]).find(x=>x.layers?.includes(a))?.id);const b=[];return f.items.forEach(x=>{if(x.type==="group"){const j=x.data.layers?.map(C=>f.allLayers[C]).filter(Boolean)||[];b.push(e.jsxs("div",{className:"p-3 pt-2 border rounded bg-light",children:[e.jsx("h5",{children:x.data.label}),e.jsx("div",{className:"d-flex flex-wrap gap-3",children:j.map(C=>{let T=!1;return h?T=x.data.id===y:T=!1,Ir(C,i,T)})})]},`group-${x.data.id}`))}else{let j=!1;h?j=!1:j=!0,b.push(Ir(x.data,i,j))}}),e.jsxs(c.Modal,{size:"lg",centered:!0,show:t,onHide:r,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Choose Layer"})}),e.jsx(c.Modal.Body,{style:{maxHeight:"70vh",overflowY:"auto"},children:e.jsx("div",{className:"d-flex flex-column gap-3",children:b})})]})}$i.propTypes={show:l.bool.isRequired,selectedLayerKey:l.string.isRequired,generic:l.object.isRequired,fnClose:l.func.isRequired,fnAdd:l.func.isRequired};const qi={id:"1",type:"input",data:{label:"Start"},position:{x:250,y:15},width:150,height:39},Bi={id:"2",type:"output",data:{label:"End"},position:{x:250,y:255},width:150,height:39},ad=[qi,Bi],od={x:0,y:0,zoom:1},vn=s=>{const t=X(s||{}),n=t?.elements||[];if(n.length<1)return{nodes:ad,edges:[],viewport:od};const r=n.filter(o=>!o.source),i=n.filter(o=>o.source&&o.source!==o.target).map(o=>({...o,markerEnd:{type:re.MarkerType.ArrowClosed}})),a={x:t?.position[0],y:t?.position[1],zoom:t?.zoom};return{nodes:r,edges:i,viewport:a}},dd=(s,t)=>s.nodes?.filter(n=>n.id===t)[0],cd=(s,t,n,r)=>{const{nodes:i,edges:a}=s,o=i?.filter(y=>y.id===t);if(o.length<1)return null;const{layer:d}=o[0].data,u=a||[],p=i?.filter(y=>y.type==="default"&&y.data)||[],f=u.filter(y=>y.source===t).map(y=>y.target)||[],h=p.filter(y=>f.includes(y.id))?.map(y=>({key:y.id,label:`${y.data.layer.label}(${y.data.layer.key})`}))||[];if(h.length>0){const y=(d.fields||[]).length+1;d.fields.push({type:m.FieldTypes.F_WF_NEXT,default:"",field:"_wf_next",label:"Next",required:!1,sub_fields:[],text_sub_fields:[],position:y,wf_options:h})}return d.wf_info={node_id:t,source_layer:n},d.wf_position=r+1,d},Ui=(s,t)=>{const n=s;return n.fields.map(r=>{const i=r;let a=i.cond_fields;return!a||a.length<1||a.filter(o=>!o.field||o.field==="").length===a.length?i:(a=a.filter(o=>o.layer===t),a.length<1?(delete i.cond_fields,i):(a=a.map(o=>{const d=o;return d.layer=n.key,d}),i.cond_fields=a,i))}),n.fields},ud=(s,t,n)=>{const r={},i=Object.keys(s);return Object.keys(s).forEach(a=>{if(Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a],a===t)){const o=r[a].position,d=i.filter(u=>u===n.key||u.startsWith(`${n.key}.`)).length;if(d===0)r[n.key]=n,r[n.key].position=o;else{const u=n.key;r[`${n.key}.${d}`]=n,r[`${n.key}.${d}`].position=o,r[`${n.key}.${d}`].key=`${n.key}.${d}`,r[n.key].fields=Ui(n,u)}}}),Object.keys(s).length===0&&(r[n.key]=n),r},Vi=(s,t)=>{let n=[];return Object.keys(s).forEach(r=>{Object.prototype.hasOwnProperty.call(s,r)&&(s[r].key===t?n=n.concat(t):s[r].wf_info&&s[r].wf_info.source_layer===t&&(n=n.concat(Vi(s,s[r].key))))}),n},pd=(s={},t="",n={})=>{const r=s;if(!(n.data&&n.data.layer?n.data.layer.key:null))return[];let a=[];return Object.keys(r).forEach(o=>{if(Object.prototype.hasOwnProperty.call(r,o)){const d=r[o].wf_info;d&&d.source_layer===t&&d.node_id===n.id&&(a=a.concat(Vi(r,r[o].key)))}}),a.forEach(o=>delete r[o]),r},En=s=>{const t=X(s),{layers:n,flow:r,flowObject:i}=t,{nodes:a,edges:o,viewport:d}=i?X(i):vn(r),u=ce(n,p=>p.position);if(a?.filter(p=>!["input","output"].includes(p.type).length>0)){const p=a,f=o,h=p.filter(C=>C.type==="default"&&C.data),y=f.filter(C=>C.source==="1").map(C=>C.target),b=h.filter(C=>y.includes(C.id)),x=[];u.forEach(C=>{const T=C;if(T.wf){const S=(T.fields||[]).length+1;b.filter(E=>E.data.layer.key===T.key).forEach(E=>{const _=f.filter(F=>F.source===E.id&&F.source!==F.target).map(F=>F.target),R=h.filter(F=>_.includes(F.id)).map(F=>({key:F.id,label:`${F.data.layer.label}(${F.data.layer.key})`}));R.length>0&&T.fields.push({type:m.FieldTypes.F_WF_NEXT,default:"",field:"_wf_next",label:"Next",required:!1,sub_fields:[],text_sub_fields:[],position:S,wf_options:R}),T.wf_info={node_id:E.id},T.wf_position=1,T.wf_uuid=ie.v4(),x.push(T)})}else x.push(T)});const j=m.orgLayerObject(x);t.layers=j}else t.layers=n;return t},fd=(s,t,n)=>{const r=g.useRef(),[i,a]=g.useReducer(s,t,n);return g.useEffect(()=>{r.current&&(r.current(i),r.current=null)},[i]),[i,(d,u)=>{r.current=u,a(d)}]};function Tn({disabled:s,readOnly:t}){const{refSource:n}=Tt(),r=n?.datasetContainer,i=n?.currentUser,a=n?.fnRef,o=r?.extended_metadata?.general_description||{},d=Cs(i).name||"",u=(y,b)=>{if(a){const x={...r};x.extended_metadata||(x.extended_metadata={}),x.extended_metadata.general_description||(x.extended_metadata.general_description={}),x.extended_metadata.general_description[y]=b,a(x)}},p=y=>y==="creator"?o[y]||d:o[y]||"",f=[{key:"title",label:"Title",type:"text",placeholder:"Enter title",readOnly:!1},{key:"date",label:"Date",type:"text",placeholder:"",readOnly:!1},{key:"time",label:"Time",type:"text",placeholder:"",readOnly:!1},{key:"contributor",label:"Contributor",type:"text",placeholder:"Enter contributor name",readOnly:!1},{key:"creator",label:"Creator",type:"text",placeholder:"",readOnly:!0},{key:"operator",label:"Operator",type:"text",placeholder:"Enter operator name",readOnly:!1}],h=[];for(let y=0;y<f.length;y+=3)h.push(f.slice(y,y+3));return e.jsx(c.Accordion,{defaultActiveKey:"0",className:"mb-4",children:e.jsxs(c.Accordion.Item,{eventKey:"0",style:{border:"none"},children:[e.jsx(c.Accordion.Header,{as:"div",className:`lu-ds-element-accordion-header flex-grow-1 ${Ve()}`,style:{boxShadow:"none"},children:e.jsx("span",{className:"panel_generic_heading",style:{pointerEvents:"none"},children:"General description"})}),e.jsx(c.Accordion.Body,{className:"py-0",children:e.jsx("div",{className:"container-fluid",children:h.map((y,b)=>e.jsxs("div",{className:`row ${b===0?"mt-1":""} mb-3`,children:[y.map(x=>e.jsxs("div",{className:"col-md-4",children:[e.jsx(c.Form.Label,{children:x.label}),e.jsx(c.Form.Control,{type:x.type,value:p(x.key),placeholder:x.placeholder,disabled:t||s||x.readOnly,readOnly:x.readOnly,onChange:j=>u(x.key,j.target.value),style:x.readOnly?{backgroundColor:"#f5f5f5"}:{}})]},x.key)),y.length<3&&Array.from({length:3-y.length}).map((x,j)=>e.jsx("div",{className:"col-md-4"},`empty-col-${y[0].key}-pos${j+y.length}`))]},y.map(x=>x.key).join("-")))})})]})})}Tn.propTypes={disabled:l.bool,readOnly:l.bool};Tn.defaultProps={datasetContainer:{},currentUser:{},disabled:!1,readOnly:!1};const hd=[{key:"type",label:"Type",hover_text:"Information on where your analyte comes from",source:"element"},{key:"id",label:"Id",hover_text:"ID of the source of your analyte",source:"element"},{key:"short_label",label:"Short Label",hover_text:"Additional Name or Label",source:"element"},{key:"name",label:"Name",source:"element"}],md=["type","id","short_label","name",{key:"resource_identifier",label:"Identifier",source:"element"},{key:"external_label",label:"External Label",source:"element"},{key:"purity",label:"Concentration",source:"element"},{key:"molarity_value",label:"Molarity",source:"element",additionalKey:"molarity_unit"}],yd=["type","id","short_label","name",{key:"rxno",label:"Name Reaction Ontology",source:"element"}],gd=["type","id","name"],xd=["type","id","short_label","name",{key:"size",label:"Size",source:"element"}],bd=["type","id","name",{key:"collaborator",label:"Collaborator",source:"element"},{key:"requirements",label:"Requirements",source:"element"},{key:"conditions",label:"Conditions",source:"element"},{key:"result",label:"Result",source:"element"}],_d=["type","id","short_label","name",{key:"device_type",label:"Device Type",source:"element"},{key:"device_type_detail",label:"Device Type Detail",source:"element"},{key:"operation_mode",label:"Operation Mode",source:"element"},{key:"vendor_device_name",label:"Device Name",source:"element"},{key:"vendor_device_id",label:"Device ID",source:"element"},{key:"serial_number",label:"Serial Number",source:"element"},{key:"vendor_company_name",label:"Vendor",source:"element"},{key:"vendor_id",label:"Vendor ID",source:"element"}],jd=["type","id","short_label",{key:"cellLineName",label:"Name",source:"element"},{key:"amount",label:"Amount",source:"element"}],_s={baseFields:hd,sample:md,reaction:yd,research_plan:gd,wellplate:xd,screen:bd,device_description:_d,cell_line:jd,"Sem S":["type","id","short_label","name"],default:["type","id","short_label","name"]},zi=(s,t)=>{if(!s||!t)return"";const{protocol:n,hostname:r,port:i}=window.location,a=i?`:${i}`:"";return`${n}//${r}${a}/mydb/collection/all/${s.toLowerCase()}/${t}`},vd=s=>{const t=s[0]?.resource_context_type,n=s[0]?.resource_context_id;return zi(t,n)},Ed=s=>zi(s?.type,s?.id),Td=(s,t)=>{if(s.key==="resource_identifier")return t?.id;if(s.key==="resource_context_identifier"){const n=t?.tag?.taggable_data?.resources;return!n||!Array.isArray(n)||n.length===0?"":n[0]?.resource_context_id||""}return""},Cd=(s,t)=>{if(s.key==="resource_identifier")return Ed(t);if(s.key==="resource_context_identifier"){const n=t?.tag?.taggable_data?.resources;return!n||!Array.isArray(n)||n.length===0?"":vd(n)}return""},Yi=(s,t)=>{const n=Td(s,t);if(!n)return e.jsx(c.Form.Control,{type:"text",value:"",readOnly:!0,style:{backgroundColor:"#f5f5f5"}});const r=Cd(s,t);return e.jsx("div",{children:e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"block",padding:"0.375rem 0.75rem",backgroundColor:"#f5f5f5",border:"1px solid #ced4da",borderRadius:"0.25rem",textDecoration:"none",color:"#0d6efd",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n})})};function Cn(){const{refSource:s}=Tt(),t=s?.element;let n=t?.type?.toLowerCase()||"default";t?.klassType==="GenericEl"&&(n=t?.element_klass?.label||"default");const r=f=>typeof f=="string"?_s.baseFields.find(h=>h.key===f):f,a=(_s[n]||_s.default).map(r).filter(f=>f!==void 0),o=n.split("_").map(f=>f.charAt(0).toUpperCase()+f.slice(1)).join(" "),d=f=>{const{key:h,additionalKey:y,source:b}=f;if(b==="system")return h==="current_datetime"?new Date().toLocaleString():"";if(h==="type"&&n)return`${n} analysis`;if(h==="rxno")return t?.rxno?.split("|")?.pop().trim();if(y){const x=t?.[h]||"",j=t?.[y]||"";return j?`${x} ${j}`:x}return t?.[h]||""},u=(f,h)=>f==="type"?"Type of the data":`${o} ${h}`,p=[];for(let f=0;f<a.length;f+=4)p.push(a.slice(f,f+4));return e.jsx(c.Accordion,{defaultActiveKey:"0",className:"mb-4",children:e.jsxs(c.Accordion.Item,{eventKey:"0",style:{border:"none"},children:[e.jsx(c.Accordion.Header,{as:"div",className:`lu-ds-element-accordion-header flex-grow-1 ${Ve()}`,style:{boxShadow:"none"},children:e.jsxs("span",{className:"panel_generic_heading",style:{pointerEvents:"none"},children:["Source details:"," ",o]})}),e.jsx(c.Accordion.Body,{className:"py-0",children:e.jsx("div",{className:"container-fluid",style:{paddingTop:"6px"},children:p.map(f=>e.jsxs("div",{className:"row mb-3",children:[f.map(h=>e.jsxs("div",{className:"col-md-3",children:[e.jsx(c.Form.Label,{title:h.hover_text||"",children:u(h.key,h.label)}),h.key==="resource_identifier"?Yi(h,t):e.jsx(c.Form.Control,{type:"text",value:d(h),readOnly:!0,style:{backgroundColor:"#f5f5f5"}})]},h.key)),f.length<4&&Array.from({length:4-f.length}).map((h,y)=>e.jsx("div",{className:"col-md-3"},`empty-col-${f[0].key}-pos${y+f.length}`))]},f.map(h=>h.key).join("-")))})})]})})}Cn.propTypes={};Cn.defaultProps={};function Sn(){const{refSource:s}=Tt(),t=s?.element,n=t?.tag?.taggable_data?.resources;if(t?.type?.toLowerCase()!=="sample"||!n||!Array.isArray(n)||n.length===0)return null;const i=[{key:"resource_context_id",label:"Resource Context ID"},{key:"resource_context_type",label:"Resource Context Type"},{key:"resource_context_label",label:"Resource Context Label"},{key:"resource_context_identifier",label:"Resource Context Identifier"}],a=d=>n[0]?.[d]||"",o=i;return e.jsx(c.Accordion,{defaultActiveKey:"0",className:"mb-4",children:e.jsxs(c.Accordion.Item,{eventKey:"0",style:{border:"none"},children:[e.jsx(c.Accordion.Header,{as:"div",className:`lu-ds-element-accordion-header flex-grow-1 ${Ve()}`,style:{boxShadow:"none"},children:e.jsx("span",{className:"panel_generic_heading",style:{pointerEvents:"none"},children:"Contextual Information/Origin of the sample"})}),e.jsx(c.Accordion.Body,{className:"py-0",children:e.jsx("div",{className:"container-fluid",style:{paddingTop:"6px"},children:e.jsx("div",{className:"row mb-3",children:o.map(d=>e.jsxs("div",{className:"col-md-3",children:[e.jsx(c.Form.Label,{children:d.label}),d.key==="resource_context_identifier"?Yi(d,t):e.jsx(c.Form.Control,{type:"text",value:a(d.key),readOnly:!0,style:{backgroundColor:"#f5f5f5"}})]},d.key))})})})]})})}Sn.propTypes={};Sn.defaultProps={};const Sd={showViewLayer:!1,selectedLayerKey:"",showAnaModal:!1},wd=(s,t)=>({...s,...t}),nt=s=>{const[t,n]=fd(wd,Sd),{generic:r,fnChange:i,extLayers:a,genId:o,isPreview:d,isActiveWF:u,isSearch:p,fnNavi:f,isSpCall:h,aiComp:y,expandAll:b,editMode:x,genericType:j,refSource:C}=s;if(Object.keys(r).length===0)return null;const{container:T,metadata:S={}}=r,v=j||ua(r),E=(M,O)=>{Ua(r,M,O),i(r)},_=M=>{Ba(r,M,"REACTION"),i(r)},R=(M,O)=>{const{layers:V}=r.properties;let z=ce(V,["position","wf_position"]);const K=z.findIndex(Z=>Z.key===M),J=z[K];let $=z.findIndex(Z=>Z.key===O);if(Math.abs(K-$)===1)z=m.swapAryEls(z,K,$);else{z.splice(K,1),$=z.findIndex(le=>le.key===O);const Z=z[$];J.position=Z.position,J.wf_position=(Z.wf_position||0)+1,z.splice($+1,0,J)}z.filter(Z=>Z.position===J.position).map((Z,le)=>{const ne=Z;return ne.wf_position=le,ne});const H=m.orgLayerObject(z);r.properties.layers=H,r.changed=!0,i(r)},F=(M,O,V)=>{const{properties:z}=r;if(M){const K=new Date(M).toLocaleString("en-GB").split(", ").join(" ");z.layers[V.key][O]=K}else delete z.layers[V.key][O];r.changed=!0,i(r)},D=(M,O)=>{const{layers:V}=r.properties,z=(S.groups||[]).find(H=>H.layers?.includes(O.key));if(z){const H=S.groups.findIndex(ne=>ne.id===z.id),Z=S.groups[H].layers||[],le=Z.indexOf(O.key);le!==-1&&Z.splice(le,1),S.groups[H].layers=Z,r.metadata=S}const K=ce(V,["position","wf_position"]),J=K.findIndex(H=>H.key===O.key),$=K[J];K.splice(J,1),K.filter(H=>H.position===$.position).map((H,Z)=>{const le=H;return le.wf_position=Z,le}),r.properties.layers=m.orgLayerObject(K),r.changed=!0,i(r)},L=(M,O)=>{const V=M?M.value:null;if(V){const{properties:z,properties_release:K}=r;let J=!1;const $=z.layers[`${O}`].fields.find(H=>H.field==="_wf_next").value;if(V!==$){$&&$!==""&&$!==V&&(J=!0);const{flow:H,flowObject:Z}=K,le=z.layers[`${O}`],{nodes:ne,edges:ae,viewport:we}=Z?X(Z):vn(H),Rt=cd({nodes:ne,edges:ae},V,O,le.wf_position);Rt&&(z.layers=ud(z.layers,O,Rt)),J&&(z.layers=pd(z.layers,O,dd({nodes:ne},$))),z.layers[`${O}`].fields.find(Ul=>Ul.field==="_wf_next").value=V,r.properties=z,r.changed=!0,i(r)}}},P=(M,O,V)=>{let z=!1;const{layers:K}=r.properties,J=K[O];let $=J.ai||[];switch(V){case w.BTN_AI_UNLINK:$=$.filter(H=>H!==M),z=!0;break;case w.BTN_AI_LINK:$.push(M),z=!0;break}z&&(J.ai=$,r.properties.layers[O]=J,n({showAnaModal:!1,selectedLayerKey:O},()=>{i(r)}))},G=(M,O)=>{const V=O,{layers:z}=r.properties,K=ce(z,["position","wf_position"]),J=K.findIndex(ne=>ne.key===t.selectedLayerKey),$=K[J];V.position=$.position,V.wf_position=$.wf_position+1,V.wf=!1,V.wf_uuid=null,delete V.cond_fields;const H=K.filter(ne=>ne.key===V.key||ne.key.startsWith(`${V.key}.`)).length;if(H>0){const ne=V.key;V.key=`${V.key}.${H}`,V.fields=Ui(V,ne)}const Z=(S.groups||[]).find(ne=>ne.layers?.includes(t.selectedLayerKey));if(Z){const ne=S.groups.findIndex(Rt=>Rt.id===Z.id),ae=S.groups[ne].layers||[],we=ae.indexOf(t.selectedLayerKey);we!==-1?ae.splice(we+1,0,V.key):ae.push(V.key),S.groups[ne].layers=ae,r.metadata=S}K.splice(J+1,0,V),K.filter(ne=>ne.position===$.position).map((ne,ae)=>{const we=ne;return we.wf_position=ae,we});const le=m.orgLayerObject(K);r.properties.layers=le,n({showViewLayer:!1,selectedLayerKey:V.key},()=>{i(r)})},k=(M,O,V,z=m.FieldTypes.F_TEXT)=>{const{properties:K}=r;let J="",$=!0;switch(z){case"drop-layer":R(O,V),$=!1;break;case"layer-data-change":F(M,O,V),$=!1;break;case"layer-remove":M.stopPropagation(),D(O,V),$=!1;break;case m.FieldTypes.F_SYS_REACTION:{const{target:H}=M;$=!1,E(H,V);break}case"layer-add-reaction":M.stopPropagation(),$=!1,_(V);break;case"layer-modal":M.stopPropagation(),$=!1,n({showViewLayer:!0,selectedLayerKey:V.key});break;case"ana-modal":M.stopPropagation(),$=!1,n({showAnaModal:!0,selectedLayerKey:V.key});break;case m.FieldTypes.F_WF_NEXT:$=!1,L(M,V);break;case m.FieldTypes.F_CHECKBOX:J=M.target.checked;break;case m.FieldTypes.F_FORMULA_FIELD:M.target?{value:J}=M.target:J=M;break;case m.FieldTypes.F_UPLOAD:{const H=so(K,M,O,V);if(J=H[0],H[1].length>0&&(r.files=(r.files||[]).concat(H[1])),H.length>2){const Z=Ie(r.files||[],le=>le.uid===M.uid);Z>=0&&r.files&&r.files.length>0&&r.files.splice(Z,1)}break}case m.FieldTypes.F_SELECT:J=M?M.value:null;break;case m.FieldTypes.F_SELECT_MULTI:J=lo(M||[]);break;case m.FieldTypes.F_DRAG_MOLECULE:case m.FieldTypes.F_DRAG_SAMPLE:case m.FieldTypes.F_DRAG_ELEMENT:case m.FieldTypes.F_DATETIME_RANGE:J=M;break;case m.FieldTypes.F_DATETIME:J=new Date(M).toLocaleString("en-GB").split(", ").join(" ");break;case m.FieldTypes.F_INTEGER:({value:J}=M.target),J=Math.trunc(J);break;default:({value:J}=M.target)}if(V===""&&["name","search_name","search_short_label"].includes(O)&&({value:J}=M.target,r[O]=J),p&&z.startsWith("drag_")&&({value:J}=M.target),$){if(z===m.FieldTypes.F_DATETIME)M?(K.layers[`${V}`].fields.find(H=>H.field===O).value=J,r.properties=K,p&&(r.search_properties=K)):delete K.layers[`${V}`].fields.find(H=>H.field===O).value;else if(z===m.FieldTypes.F_SELECT_MULTI)K.layers[V].fields.find(H=>H.field===O).sub_fields=J,r.properties=K,p&&(r.search_properties=K);else if(z===m.FieldTypes.F_DATETIME_RANGE)K.layers[V].fields.find(H=>H.field===O).sub_fields=J,r.properties=K,p&&(r.search_properties=K);else if(!(V===""&&["name","search_name","search_short_label"].includes(O))){if(K.layers[`${V}`].fields.find(H=>H.field===O).value=J,z===m.FieldTypes.F_SYSTEM_DEFINED&&(!K.layers[`${V}`].fields.find(H=>H.field===O).value_system||K.layers[`${V}`].fields.find(H=>H.field===O).value_system==="")){const H=K.layers[`${V}`].fields.find(Z=>Z.field===O).option_layers;K.layers[`${V}`].fields.find(Z=>Z.field===O).value_system=m.genUnits(H)[0].key}r.properties=K,p&&(r.search_properties=K)}r.changed=!0,i(r)}},U=(M,O,V=!1)=>{const{properties:z}=r;if(!V){const K=z.layers[`${M}`].fields.find($=>$.field===O.f.field).sub_fields||[],J=K.findIndex($=>$.id===O.sub.id);K.splice(J,1,O.sub),z.layers[`${M}`].fields.find($=>$.field===O.f.field).sub_fields=K}z.layers[`${M}`].fields.find(K=>K.field===O.f.field).sub_values=O.f.sub_values||[],r.properties=z,r.changed=!0,i(r)},N=(M,O)=>{const{properties:V}=r,z=m.unitConversion(O.option_layers,O.value_system,O.value);V.layers[`${M}`].fields.find(K=>K.field===O.field).value_system=O.value_system,V.layers[`${M}`].fields.find(K=>K.field===O.field).value=z,r.properties=V,r.changed=!0,i(r)};let A=T&&T.children&&T.children[0].children||[];A=A.filter(M=>!M.is_new);const q={generic:r,funcChange:k,funcSubChange:U,funcClick:N,extLys:a||[],id:o,isPreview:d||!1,activeWF:u||!1,isSearch:p,fnNavi:f,isSpCall:h,hasAi:A.length>0,aiComp:y,expandAll:b,editMode:x,genericType:v},Y=e.jsx(nd,{...q}),B=e.jsx(oi,{show:t.showAnaModal,generic:r,layer:t.selectedLayerKey,fnHide:()=>n({showAnaModal:!t.showAnaModal}),fnLink:P});return e.jsxs(sd,{value:{refSource:C},children:[e.jsx(Mi,{generic:r,refElement:C?.element}),v===w.GENERIC_TYPES.DATASET&&e.jsx(Tn,{disabled:!1,readOnly:!1}),v===w.GENERIC_TYPES.DATASET&&e.jsx(Cn,{}),v===w.GENERIC_TYPES.DATASET&&e.jsx(Sn,{}),Y,e.jsx($i,{show:t.showViewLayer,selectedLayerKey:t.selectedLayerKey,generic:X(r)||{},fnClose:()=>n({showViewLayer:!t.showViewLayer}),fnAdd:G}),B]})};nt.propTypes={generic:l.object.isRequired,fnChange:l.func.isRequired,extLayers:l.array,genId:l.oneOfType([l.string,l.number]),isPreview:l.bool.isRequired,isActiveWF:l.bool.isRequired,isSearch:l.bool,fnNavi:l.func,isSpCall:l.bool,aiComp:l.any,expandAll:l.bool,editMode:l.bool,genericType:l.string,refSource:l.object};nt.defaultProps={extLayers:[],isSearch:!1,genId:0,fnNavi:()=>{},isSpCall:!1,aiComp:null,expandAll:void 0,genericType:"",refSource:{element:{},datasetContainer:{},currentUser:{},fnRef:()=>{}}};const Rd=({_layer:s})=>{const{generic:t,ext:n}=s,{name:r,label:i,description:a}=n,[o,d]=g.useState(t);g.useEffect(()=>{d(t)},[t]);const u=p=>{p.changed&&d(X(p))};return e.jsxs("div",{style:{height:"600px",width:"100%",overflow:"auto",padding:"0px 20px",maxHeight:"600px"},children:[e.jsxs("div",{className:"gu-mb-2",children:[e.jsxs("h4",{children:[e.jsx("b",{children:"Standard Layer : "})," ",r," ",i&&`(${i})`]}),e.jsxs("div",{style:{display:"flex",gap:"5px"},children:[e.jsx("div",{children:e.jsx("b",{children:"Description : "})}),e.jsx("div",{style:{whiteSpace:"pre-wrap"},children:a})]})]}),e.jsx(nt,{generic:o||{},fnChange:u,genId:0,isPreview:!0,isActiveWF:!1})]})},Fd=({fnCreate:s,fnDelete:t})=>{const[n,r]=g.useState(!1),[i,a]=g.useState(null);g.useEffect(()=>{n||a(null)},[n]);const o=()=>r(!0),d=()=>r(!1),u=y=>{s(y.data?.properties),r(!1)},p=y=>{t(y.data),r(!1)},f=y=>{const b=y.data.properties?.select_options,x={properties:{layers:{[y.data.name]:{...y.data.properties}},...b&&{select_options:b}},properties_release:{layers:{[y.data.name]:{...y.data.properties}},...b&&{select_options:b}}},j={description:y.data.description,label:y.data.label,name:y.data.name};a({generic:x,ext:j})},h=()=>{a(null)};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"sel_lyr2tpl",children:e.jsxs(c.Button,{className:"fw-medium",size:"sm",variant:"primary",onClick:o,children:[I.faGlobe," Standard Layers"]})}),e.jsxs(c.Modal,{centered:!0,show:n,onHide:d,dialogClassName:"gu_modal-68w",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Standard Layer List"})}),e.jsx(c.Modal.Body,{children:i?e.jsx(Rd,{_layer:i}):e.jsx(Za,{onLayerSelect:u,onLayerDelete:p,onLayerView:f})}),e.jsxs(c.Modal.Footer,{className:"justify-content-start",children:[i&&e.jsx(Q,{idf:"return_to_list",children:e.jsx(c.Button,{className:"gu-mr-1",onClick:h,children:"Back to list"})}),e.jsx(Q,{idf:"close",children:e.jsx(c.Button,{variant:"primary",onClick:d,children:"Close"})})]})]})]})},Nd=["checkbox","text","select"];function wn({entityKey:s,restriction:t,availableLayers:n,onUpdateRestriction:r,idSuffix:i="lc",filterCurrentLayer:a=!1}){const[o,d]=g.useState(!1),[u,p]=g.useState([]),[f,h]=g.useState(""),[y,b]=g.useState(""),[x,j]=g.useState(""),[C,T]=g.useState([]),[S,v]=g.useState(1),[E,_]=g.useState("");g.useEffect(()=>{t&&t.cond&&(p(t.cond),v(t.op??1))},[t]);const R=N=>{if(!N||!N.fields){T([]);return}const A=N.fields.filter(q=>Nd.includes(q.type));T(A),A.length>0?b(A[0].field):b("")};return{showRestrictionForm:o,setShowRestrictionForm:d,conditions:u,selectedLayer:f,selectedField:y,fieldValue:x,setFieldValue:j,availableFields:C,selectedOp:S,handleRestrictionClick:()=>{if(d(!o),!o&&n&&n.length>0){const N=a?n.filter(A=>A.key!==s):n;if(N.length>0){const A=N[0];h(A.key),R(A)}}},handleLayerChange:N=>{const A=N.target.value;h(A);const q=n.find(Y=>Y.key===A);q&&R(q),j("")},handleFieldChange:N=>{b(N.target.value),j("")},handleSourceChange:N=>{_(N.target.value)},handleAddCondition:N=>{let A;if(N&&typeof N=="string")A={id:`${ie.v4()}-${i}`,field:"TYPE",layer:"SRC-EL",value:N};else{if(!f||!y)return;const M=n.find(V=>V.key===f)?.fields?.find(V=>V.field===y)?.type===m.FieldTypes.F_CHECKBOX;let O=x.trim();M&&(O=es(O)),A={id:`${ie.v4()}-${i}`,field:y,layer:f,value:O}}const q=[...u,A];p(q),j(""),r&&r(s,{op:S,cond:q})},handleRemoveCondition:N=>{const A=u.filter(q=>q.id!==N);p(A),r&&(A.length===0?r(s,null):r(s,{op:S,cond:A}))},handleOpChange:N=>{v(N),r&&u.length>0&&r(s,{op:N,cond:u})},selectedSource:E,setSelectedSource:_}}function Rn({selectedOp:s,onOpChange:t}){return e.jsxs("div",{className:"d-flex align-items-center justify-content-between mb-3",children:[e.jsxs("small",{className:"text-muted",children:["The visibility is controlled by configurable [Layer, Field, Value] criteria using ",e.jsx("strong",{children:"Match One, Match All, or Match None"})," ","rules."]}),e.jsx(c.ButtonGroup,{size:"sm",children:m.condOperatorOptions.map(n=>e.jsx(c.Button,{variant:s===n.value?"primary":"outline-primary",onClick:()=>t(n.value),children:n.label},n.value))})]})}Rn.propTypes={selectedOp:l.number.isRequired,onOpChange:l.func.isRequired};function Ct({conditions:s,selectedLayer:t,selectedField:n,fieldValue:r,availableFields:i,selectedOp:a,availableLayers:o,selectOptions:d={},filterCurrentLayer:u=!1,currentEntityKey:p,onClose:f,onLayerChange:h,onFieldChange:y,onValueChange:b,onAddCondition:x,onRemoveCondition:j,onOpChange:C,selectedSource:T,onSourceChange:S}){const{klasses:v=[],genericType:E}=Ms(),_=u?o.filter(k=>k.key!==p):o,R=i.find(k=>k.field===n),F=R?.type==="select",D=R?.type==="checkbox",L=F&&R?.option_layers?d[R.option_layers]?.options||[]:[],P=()=>F?e.jsxs(c.Form.Select,{size:"sm",value:r,onChange:b,style:{flex:1},children:[e.jsx("option",{value:"",children:"Select a value..."}),L.map(k=>e.jsx("option",{value:k.key,children:k.label},k.key))]}):D?e.jsxs(c.Form.Select,{size:"sm",value:r,onChange:b,style:{flex:1},children:[e.jsx("option",{value:"false",children:"Unchecked (false)"}),e.jsx("option",{value:"true",children:"Checked (true)"})]}):e.jsx(c.Form.Control,{type:"text",size:"sm",placeholder:"Enter expected value",value:r,onChange:b,style:{flex:1}}),G=()=>F?"Select from predefined options":D?"Select the expected checkbox state":"Enter the expected value (case-sensitive)";return e.jsxs(c.Card,{className:"mb-3 border border-info",children:[e.jsxs(c.Card.Header,{className:"bg-info text-white d-flex justify-content-between align-items-center",children:[e.jsx("small",{children:"Restriction Conditions"}),e.jsx(c.Button,{variant:"light",size:"xsm",onClick:f,children:"Close"})]}),e.jsxs(c.Card.Body,{className:"p-3",children:[e.jsx(Rn,{selectedOp:a,onOpChange:C}),s.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("small",{className:"text-muted d-block mb-2",children:"Existing Conditions:"}),s.map(k=>{const{layerTitle:U,fieldTitle:N,valueTitle:A}=Xr(k,o,v);return e.jsxs("div",{className:"d-flex align-items-center gap-2 mb-2 p-2 border rounded bg-white",children:[e.jsxs("small",{className:"flex-grow-1",children:[e.jsx("strong",{children:U})," → ",N,' = "',A,'"']}),e.jsx(c.Button,{variant:"danger",size:"xsm",onClick:()=>j(k.id),title:"Remove condition",children:I.faTrashCan})]},k.id)})]}),e.jsxs("div",{className:"border-top pt-3",children:[e.jsx("small",{className:"text-muted d-block mb-2",children:"Add New Condition:"}),e.jsxs(c.Form.Group,{className:"mb-2",children:[e.jsx(c.Form.Label,{className:"small",children:"Select Layer (appearance order)"}),e.jsx(c.Form.Select,{size:"sm",value:t,onChange:h,children:_&&_.map(k=>e.jsxs("option",{value:k.key,children:[k.label||k.key," (",k.key,")"]},k.key))})]}),e.jsxs("div",{className:"row mb-2 align-items-start",children:[e.jsx("div",{className:"col-md-6",children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{className:"small",children:"Select Field"}),e.jsx(c.Form.Select,{size:"sm",value:n,onChange:y,disabled:i.length===0,children:i.map(k=>e.jsxs("option",{value:k.field,children:[k.label||k.field," (",k.field,", type: ",k.type,")"]},k.field))}),e.jsx(c.Form.Text,{muted:!0,children:"Eligible fields (checkbox, text, select)"})]})}),e.jsx("div",{className:"col-md-6",children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{className:"small",children:"Enter Value"}),e.jsxs("div",{className:"d-flex gap-2 align-items-start",children:[P(),e.jsx(c.Button,{variant:"success",size:"sm",onClick:x,disabled:!t||!n||i.length===0,style:{flexShrink:0},title:"Add condition",children:I.faPlus})]}),e.jsx(c.Form.Text,{muted:!0,children:G()})]})})]}),E===w.GENERIC_TYPES.DATASET&&e.jsx("div",{className:"row align-items-start",children:e.jsx("div",{className:"col-md-12",children:e.jsxs(c.Form.Group,{className:"border-top pt-3",children:[e.jsx(c.Form.Label,{className:"small",children:"Reference Source"}),e.jsxs("div",{className:"d-flex gap-2 align-items-start",children:[e.jsxs(c.Form.Select,{size:"sm",value:T||"",onChange:S,disabled:v.length===0,style:{flex:1},children:[e.jsx("option",{value:"",children:"Select a source..."}),v.map(k=>e.jsxs("option",{value:k.name,children:[k.label||k.name," (",k.name,")"]},k.name))]}),e.jsx(c.Button,{variant:"success",size:"sm",onClick:()=>x(T),disabled:!T||v.length===0,style:{flexShrink:0},title:"Add condition",children:I.faPlus})]}),e.jsx(c.Form.Text,{muted:!0,children:"Eligible reference sources"})]})})})]})]})]})}Ct.propTypes={conditions:l.arrayOf(l.shape({id:l.string,field:l.string,layer:l.string,value:l.oneOfType([l.string,l.bool])})).isRequired,selectedLayer:l.string.isRequired,selectedField:l.string.isRequired,fieldValue:l.string.isRequired,availableFields:l.arrayOf(l.shape({field:l.string,label:l.string,type:l.string})).isRequired,selectedOp:l.number.isRequired,availableLayers:l.arrayOf(l.shape({key:l.string.isRequired,label:l.string,fields:l.arrayOf(l.object)})).isRequired,selectOptions:l.object,filterCurrentLayer:l.bool,currentEntityKey:l.string,onClose:l.func.isRequired,onLayerChange:l.func.isRequired,onFieldChange:l.func.isRequired,onValueChange:l.func.isRequired,onAddCondition:l.func.isRequired,onRemoveCondition:l.func.isRequired,onOpChange:l.func.isRequired,selectedSource:l.string,onSourceChange:l.func};Ct.defaultProps={filterCurrentLayer:!1,currentEntityKey:null,selectOptions:{}};const Ge="existing",pt="new";function Fn({layerKey:s,layerData:t,children:n,onAssignToGroup:r,existingGroups:i,onUpdateRestriction:a,restriction:o,availableLayers:d,selectOptions:u}){const{label:p,style:f}=t,[h,y]=g.useState(!1),[b,x]=g.useState(Ge),[j,C]=g.useState(""),[T,S]=g.useState(""),{showRestrictionForm:v,setShowRestrictionForm:E,conditions:_,selectedLayer:R,selectedField:F,fieldValue:D,setFieldValue:L,availableFields:P,selectedOp:G,handleRestrictionClick:k,handleLayerChange:U,handleFieldChange:N,handleAddCondition:A,handleRemoveCondition:q,handleOpChange:Y,selectedSource:B,handleSourceChange:M}=wn({entityKey:s,restriction:o,availableLayers:d,onUpdateRestriction:a,idSuffix:"lc",filterCurrentLayer:!0}),O=()=>{if(y(!h),!h){x(Ge);const z=hr(i||[],[K=>K.label.toLowerCase()],["asc"]);C(z.length>0?z[0].id:""),S("")}},V=()=>{r&&(b===Ge?j&&(r(s,j,null),y(!1)):b===pt&&T.trim()&&(r(s,null,T.trim()),y(!1)))};return e.jsxs(c.Card,{className:"mb-3 border",children:[e.jsxs(c.Card.Header,{className:`${Ve()} d-flex justify-content-between align-items-center`,children:[e.jsx("span",{className:f||"panel_generic_heading",children:p||s}),e.jsxs("div",{className:"d-flex gap-2",children:[t.wf&&e.jsx(Le,{variant:"outline",color:"warning",text:"workflow"}),a&&e.jsx("span",{title:t.wf?"Restrictions cannot be set on workflow layers":"Manage restrictions",style:t.wf?{cursor:"not-allowed"}:{},children:e.jsxs(c.Button,{variant:"primary",size:"xsm",onClick:k,disabled:t.wf,style:t.wf?{pointerEvents:"none"}:{},children:[e.jsx("span",{children:I.faGears})," ",_.length>0&&`(${_.length})`]})}),r&&e.jsx("span",{title:t.wf?"A workflow layer cannot be assigned to a group":"Assign this layer to a group",style:t.wf?{cursor:"not-allowed"}:{},children:e.jsx(c.Button,{variant:h?"light":"primary",size:"xsm",onClick:O,disabled:t.wf,style:t.wf?{pointerEvents:"none"}:{},children:h?"Close":e.jsxs(e.Fragment,{children:[I.faLayerGroup," Assign to a group"]})})})]})]}),e.jsxs(c.Card.Body,{className:"py-2 px-3",children:[n,a&&v&&!t.wf&&e.jsx(Ct,{conditions:_,selectedLayer:R,selectedField:F,fieldValue:D,availableFields:P,selectedOp:G,availableLayers:d,selectOptions:u,filterCurrentLayer:!0,currentEntityKey:s,onClose:()=>E(!1),onLayerChange:U,onFieldChange:N,onValueChange:z=>L(z.target.value),onAddCondition:A,onRemoveCondition:q,onOpChange:Y,selectedSource:B,onSourceChange:M}),r&&h&&e.jsx("div",{className:"mt-3 p-3 border rounded bg-light",children:e.jsxs("div",{className:"row align-items-start",children:[e.jsx("div",{className:"col-md-5",children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Check,{type:"radio",id:`${s}-new`,label:"Create new group",checked:b===pt,onChange:()=>x(pt)}),b===pt&&e.jsx(c.Form.Control,{type:"text",size:"sm",placeholder:"Enter group name",className:"mt-2",value:T,onChange:z=>S(z.target.value)})]})}),e.jsx("div",{className:"col-md-5",children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Check,{type:"radio",id:`${s}-existing`,label:"Add to existing group",checked:b===Ge,onChange:()=>x(Ge)}),b===Ge&&i&&i.length>0&&e.jsx(c.Form.Select,{size:"sm",className:"mt-2",value:j,onChange:z=>C(z.target.value),children:hr(i,[z=>z.label.toLowerCase()],["asc"]).map(z=>e.jsx("option",{value:z.id,children:z.label},z.id))}),b===Ge&&(!i||i.length===0)&&e.jsx("div",{className:"text-muted small mt-2",children:"No existing groups available"})]})}),e.jsx("div",{className:"col-md-2 text-end",children:e.jsx(c.Button,{variant:"primary",size:"xsm",onClick:V,disabled:b===Ge&&!j||b===pt&&!T.trim(),children:"Assign"})})]})})]})]})}Fn.propTypes={layerKey:l.string.isRequired,layerData:l.shape({label:l.string,color:l.string,style:l.string,wf:l.bool}).isRequired,children:l.node.isRequired,onAssignToGroup:l.func.isRequired,existingGroups:l.arrayOf(l.shape({id:l.string.isRequired,label:l.string.isRequired})),onUpdateRestriction:l.func,restriction:l.shape({op:l.number,cond:l.arrayOf(l.shape({id:l.string,field:l.string,layer:l.string,value:l.oneOfType([l.string,l.bool])}))}),availableLayers:l.arrayOf(l.shape({key:l.string.isRequired,label:l.string,fields:l.arrayOf(l.object)})),selectOptions:l.object};Fn.defaultProps={existingGroups:[],onUpdateRestriction:null,restriction:null,availableLayers:[],selectOptions:{}};function Nn({layerKey:s,layerData:t,children:n,onRemoveFromGroup:r,groupId:i,onUpdateRestriction:a,restriction:o,availableLayers:d,selectOptions:u}){const{label:p,color:f,style:h}=t,{showRestrictionForm:y,setShowRestrictionForm:b,conditions:x,selectedLayer:j,selectedField:C,fieldValue:T,setFieldValue:S,availableFields:v,selectedOp:E,handleRestrictionClick:_,handleLayerChange:R,handleFieldChange:F,handleAddCondition:D,handleRemoveCondition:L,handleOpChange:P}=wn({entityKey:s,restriction:o,availableLayers:d,onUpdateRestriction:a,idSuffix:"lc",filterCurrentLayer:!0}),G=()=>{r&&i&&r(i,s)};return e.jsxs(c.Card,{className:"mb-2 border border-secondary",children:[e.jsxs(c.Card.Header,{className:`fs-6 ${Ve()} d-flex justify-content-between align-items-center`,children:[e.jsx("span",{className:h||"panel_generic_subheading",children:p||s}),e.jsxs("div",{className:"d-flex gap-2",children:[a&&e.jsx("span",{title:t.wf?"Restrictions cannot be set on workflow layers":"Manage restrictions",style:t.wf?{cursor:"not-allowed"}:{},children:e.jsxs(c.Button,{variant:"primary",size:"xsm",onClick:_,disabled:t.wf,style:t.wf?{pointerEvents:"none"}:{},children:[e.jsx("span",{children:I.faGears})," ",x.length>0&&`(${x.length})`]})}),r&&e.jsx(c.Button,{variant:"danger",size:"xsm",onClick:G,title:"Remove from group",children:I.faTrashCan})]})]}),e.jsxs(c.Card.Body,{className:"py-2 px-3",children:[a&&y&&!t.wf&&e.jsx(Ct,{conditions:x,selectedLayer:j,selectedField:C,fieldValue:T,availableFields:v,selectedOp:E,availableLayers:d,selectOptions:u,filterCurrentLayer:!0,currentEntityKey:s,onClose:()=>b(!1),onLayerChange:R,onFieldChange:F,onValueChange:k=>S(k.target.value),onAddCondition:D,onRemoveCondition:L,onOpChange:P}),n]})]})}Nn.propTypes={layerKey:l.string.isRequired,layerData:l.shape({label:l.string,color:l.string,style:l.string,wf:l.bool}).isRequired,children:l.node.isRequired,onRemoveFromGroup:l.func,groupId:l.string,onUpdateRestriction:l.func,restriction:l.shape({op:l.number,cond:l.arrayOf(l.shape({id:l.string,field:l.string,layer:l.string,value:l.oneOfType([l.string,l.bool])}))}),availableLayers:l.arrayOf(l.shape({key:l.string.isRequired,label:l.string,fields:l.arrayOf(l.object)})),selectOptions:l.object};Nn.defaultProps={onRemoveFromGroup:null,groupId:null,onUpdateRestriction:null,restriction:null,availableLayers:[],selectOptions:{}};function kn({groupId:s,groupLabel:t,groupPosition:n,layers:r,renderLayer:i,onRemove:a,onRemoveLayerFromGroup:o,onUpdateRestriction:d,restriction:u,availableLayers:p,onUpdateLayerRestriction:f,groupLayers:h,selectOptions:y}){const{showRestrictionForm:b,setShowRestrictionForm:x,conditions:j,selectedLayer:C,selectedField:T,fieldValue:S,setFieldValue:v,availableFields:E,selectedOp:_,handleRestrictionClick:R,handleLayerChange:F,handleFieldChange:D,handleAddCondition:L,handleRemoveCondition:P,handleOpChange:G,selectedSource:k,handleSourceChange:U}=wn({entityKey:s,restriction:u,availableLayers:p,onUpdateRestriction:d,idSuffix:"gc",filterCurrentLayer:!1}),N=()=>{a&&a(s)};return e.jsxs(c.Card,{className:"mb-3 border border-primary border-2",children:[e.jsxs(c.Card.Header,{className:"d-flex justify-content-between align-items-center",children:[e.jsxs("span",{className:"panel_generic_heading",children:[e.jsx("span",{children:I.faLayerGroup}),t||s]}),e.jsxs("div",{className:"d-flex gap-2",children:[d&&e.jsxs(c.Button,{variant:"primary",size:"xsm",onClick:R,title:"Manage restrictions",children:[e.jsx("span",{children:I.faGears})," ",j.length>0&&`(${j.length})`]}),a&&e.jsx(c.Button,{variant:"danger",size:"xsm",onClick:N,title:"Remove this group",children:I.faTrashCan})]})]}),e.jsxs(c.Card.Body,{className:"py-3 px-2 bg-light",children:[b&&e.jsx(Ct,{conditions:j,selectedLayer:C,selectedField:T,fieldValue:S,availableFields:E,selectedOp:_,availableLayers:p,selectOptions:y,filterCurrentLayer:!1,currentEntityKey:s,onClose:()=>x(!1),onLayerChange:F,onFieldChange:D,onValueChange:A=>v(A.target.value),onAddCondition:L,onRemoveCondition:P,onOpChange:G,selectedSource:k,onSourceChange:U}),r&&r.map(A=>e.jsx(Nn,{layerKey:A.key,layerData:A.data,onRemoveFromGroup:o,groupId:s,onUpdateRestriction:f,restriction:A.data.cond_fields?{op:A.data.cond_operator??1,cond:A.data.cond_fields}:null,availableLayers:h,selectOptions:y,children:i?i(A):null},A.key))]})]})}kn.propTypes={groupId:l.string.isRequired,groupLabel:l.string.isRequired,groupPosition:l.number,layers:l.arrayOf(l.shape({key:l.string.isRequired,position:l.number,data:l.shape({}).isRequired})).isRequired,renderLayer:l.func.isRequired,onRemove:l.func,onRemoveLayerFromGroup:l.func,onUpdateRestriction:l.func,restriction:l.shape({op:l.number,cond:l.arrayOf(l.shape({id:l.string,field:l.string,layer:l.string,value:l.oneOfType([l.string,l.bool])}))}),availableLayers:l.arrayOf(l.shape({key:l.string.isRequired,label:l.string,fields:l.arrayOf(l.object)})),onUpdateLayerRestriction:l.func,groupLayers:l.arrayOf(l.shape({key:l.string.isRequired,label:l.string,fields:l.arrayOf(l.object)})),selectOptions:l.object};kn.defaultProps={groupPosition:null,onRemove:null,onRemoveLayerFromGroup:null,onUpdateRestriction:null,restriction:null,availableLayers:[],onUpdateLayerRestriction:null,groupLayers:[],selectOptions:{}};function Ln({klass:s,klassMetadata:t,onMetadataChange:n}){const[r,i]=g.useState(t?.groups||[]),[a,o]=g.useState(t?.restrict||{});g.useEffect(()=>{i(t?.groups||[]),o(t?.restrict||{})},[t]);const d=(v,E)=>{const _={...E},R=new Set(v);return Object.keys(_).forEach(F=>{const D=_[F];if(D&&D.cond){const L=D.cond.filter(P=>!R.has(P.layer));L.length===0?delete _[F]:L.length!==D.cond.length&&(_[F]={...D,cond:L})}}),_},u=(v,E,_)=>{const R=et(v.layers,{groups:E,restrict:_}),F=X({...v,layers:R.layers});i(R.metadata.groups||[]),o(R.metadata.restrict||{}),n&&n({groups:R.metadata.groups||[],restrict:R.metadata.restrict||{},klass:F})},p=v=>{const E=[...r],_=E.find(D=>D.id===v),R=_?_.layers:[];if(vr(E,v).success){let D={...a};delete D[v],D=d(R,D);const L={...s};L.layers&&R.forEach(P=>{L.layers[P]&&(delete L.layers[P].cond_fields,delete L.layers[P].cond_operator)}),u(L,E,D)}},f=(v,E,_)=>{const R=[...r];let F;if(E)F=Er(R,E,v,s?.layers);else if(_){const D=R.find(L=>L.label.toLowerCase()===_.toLowerCase());if(D)F=Er(R,D.id,v,s?.layers);else{const L=`${ie.v4()}-g`,P=s?.layers?.[v]?.position||0;F=$a(R,{id:L,label:_,layers:[v],position:P},s?.layers)}}if(F&&F.success){const D=d([v],a),L=X(s);L.layers&&(L.layers[v]&&(delete L.layers[v].cond_fields,delete L.layers[v].cond_operator),Object.keys(L.layers).forEach(P=>{const G=L.layers[P];if(G.cond_fields&&Array.isArray(G.cond_fields)){const k=G.cond_fields.filter(U=>U.layer!==v);k.length===0?(delete G.cond_fields,delete G.cond_operator):k.length!==G.cond_fields.length&&(G.cond_fields=k)}})),u(L,R,D)}else F&&F.error&&console.error("Error assigning to group:",F.error)},h=(v,E)=>{const _=[...r],R=qa(_,v,E);if(R&&R.success){R.isEmpty&&vr(_,v);const F=d([E],a),D=X(s);D.layers&&(D.layers[E]&&(delete D.layers[E].cond_fields,delete D.layers[E].cond_operator),Object.keys(D.layers).forEach(L=>{const P=D.layers[L];if(P.cond_fields&&Array.isArray(P.cond_fields)){const G=P.cond_fields.filter(k=>k.layer!==E);G.length===0?(delete P.cond_fields,delete P.cond_operator):G.length!==P.cond_fields.length&&(P.cond_fields=G)}})),u(D,_,F)}else R&&R.error&&console.error("Error removing layer from group:",R.error)},y=(v,E)=>{const _={...a};E===null||!E.cond||E.cond.length===0?delete _[v]:_[v]=E,o(_),n&&n({groups:r,restrict:_})},b=(v,E)=>{if(n){const _=X(s);if(_.layers||(_.layers={}),!_.layers[v])return;E===null||!E.cond||E.cond.length===0?(delete _.layers[v].cond_fields,delete _.layers[v].cond_operator):(_.layers[v].cond_fields=E.cond,_.layers[v].cond_operator=E.op),n({groups:r,restrict:a,klass:_})}},x=v=>{const{data:E}=v,{cols:_}=E;return e.jsx("span",{})},j=tt(s?.layers||{},r),C=[];j.forEach(v=>{v.type==="group"?v.layers.forEach(E=>{C.push({key:E.key,label:E.data.label,fields:E.data.fields||[]})}):C.push({key:v.key,label:v.data.label,fields:v.data.fields||[]})});const T=new Set;r.forEach(v=>{v.layers&&v.layers.forEach(E=>T.add(E))});const S=C.filter(v=>!T.has(v.key));return e.jsxs(c.Container,{fluid:!0,className:"p-3",children:[j.length===0&&e.jsx("div",{className:"text-center text-muted py-5",children:e.jsx("p",{children:"No layers available"})}),j.map(v=>{if(v.type==="group"){const E=v.layers.map(_=>({key:_.key,label:_.data.label||_.key,fields:_.data.fields||[]}));return e.jsx(kn,{groupId:v.id,groupLabel:v.label,groupPosition:v.position,layers:v.layers,renderLayer:x,onRemove:p,onRemoveLayerFromGroup:h,onUpdateRestriction:y,restriction:a[v.id],availableLayers:S,onUpdateLayerRestriction:b,groupLayers:E,selectOptions:s?.select_options||{}},v.id)}return e.jsx(Fn,{layerKey:v.key,layerData:v.data,onAssignToGroup:f,existingGroups:r,onUpdateRestriction:b,restriction:v.data.cond_fields?{op:v.data.cond_operator??1,cond:v.data.cond_fields}:null,availableLayers:S,selectOptions:s?.select_options||{},children:x(v)},v.key)})]})}Ln.propTypes={klass:l.shape({layers:l.objectOf(l.object)}).isRequired,klassMetadata:l.shape({groups:l.arrayOf(l.object),restrict:l.objectOf(l.object)}),onMetadataChange:l.func};Ln.defaultProps={klassMetadata:{groups:[],restrict:{}},onMetadataChange:null};function kd(){const[s,t]=g.useState(!0),n=()=>{t(!s)};return e.jsxs("div",{className:"d-flex flex-column align-items-start w-100",children:[e.jsxs(c.Button,{variant:"danger",size:"xsm",onClick:n,className:"mb-0",children:[e.jsx("span",{className:"me-2",children:I.faExclamationCircle}),"Important Note",e.jsx("span",{className:`fa fa-chevron-${s?"up":"down"} ms-2`})]}),s&&e.jsx(c.Alert,{variant:"danger",className:"mt-2 mb-0 w-100",onClose:()=>t(!1),dismissible:!0,children:e.jsxs("div",{className:"small",children:[e.jsxs("p",{className:"mb-2",children:[e.jsx("span",{className:"me-2",children:I.faExclamationCircle}),e.jsx("strong",{children:"Important — Layer Grouping Effects"})]}),e.jsx("p",{className:"mb-0 text-muted",children:"Assigning or removing a layer from a group automatically removes its restrictions and any restrictions that reference it, ensuring consistent restriction logic."})]})})]})}function Hi({generic:s,onSave:t,showProps:n}){const{show:r,setShow:i}=n,[a,o]=g.useState(null),[d,u]=g.useState(null),[p,f]=g.useState(null);if(g.useEffect(()=>{r&&(u(JSON.parse(JSON.stringify(s?.properties_template||{}))),f(JSON.parse(JSON.stringify(s?.metadata||{groups:[],restrict:{}}))),o(null))},[r,s]),!r)return null;const h=x=>{o(x),x.klass&&u(x.klass),(x.groups!==void 0||x.restrict!==void 0)&&f({groups:x.groups,restrict:x.restrict})},y=()=>{t({groups:p.groups,restrict:p.restrict,klass:d}),i(!1)},b=()=>{o(null),u(null),f(null),i(!1)};return!d||!p?null:e.jsxs(c.Modal,{centered:!0,show:r,onHide:()=>i(!1),size:"xl",backdrop:"static",scrollable:!0,style:{maxWidth:"90%",margin:"0 auto"},dialogClassName:"h-auto",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Group Layers and Set Conditions"})}),e.jsxs(c.Modal.Body,{className:"d-flex flex-column p-3",style:{overflowY:"auto",maxHeight:"70vh"},children:[e.jsx("div",{children:e.jsx(kd,{})}),e.jsx(Ln,{klass:d,klassMetadata:p,onMetadataChange:h})]}),e.jsxs(c.Modal.Footer,{className:"justify-content-start",children:[e.jsx(c.Button,{variant:"secondary",onClick:b,children:"Cancel"}),e.jsx(c.Button,{variant:"success",onClick:y,disabled:!a,children:"Save"})]})]})}Hi.propTypes={generic:l.object.isRequired,onSave:l.func.isRequired,showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired};function An({generic:s={},genericType:t,fnSave:n=()=>{}}){const[r,i]=g.useState(!1);if(s?.is_new||Object.keys(s.properties_template).length===0)return null;const a=o=>{const d=o.groups||[],u=X(s);if(o.klass&&(u.properties_template=o.klass),d.length===0){u.metadata={},u.changed=!0,n(new ee(se(),u));return}const p=new Set(d.map(h=>h.id)),f={};Object.keys(o.restrict||{}).forEach(h=>{p.has(h)&&(f[h]=o.restrict[h])}),u.metadata={groups:d,restrict:f},u.changed=!0,n(new ee(se(),u))};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"group_layer",children:e.jsxs(c.Button,{className:"fw-medium",size:"sm",variant:"primary",onClick:()=>i(!0),children:[I.faLayerGroup," Group & ",I.faGears," Restrictions"]})}),e.jsx(Hi,{generic:s,genericType:t,showProps:{show:r,setShow:i},onSave:a})]})}An.propTypes={generic:l.object,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnSave:l.func};An.defaultProps={generic:{},fnSave:()=>{}};const St=s=>{const{all:t,onChange:n,node:r,dVal:i}=s;return e.jsx(c.Form.Group,{children:e.jsx(c.Form.Control,{as:"select",placeholder:"select...",onChange:a=>n(a,r),defaultValue:i,id:`${r.data.id}__${i}`,children:t.map(a=>e.jsx("option",{value:a.val,children:a.lab},a.key))})})};St.propTypes={all:l.arrayOf(l.shape({key:l.oneOfType([l.string,l.number]),val:l.oneOfType([l.string,l.number]),lab:l.oneOfType([l.string,l.number])})).isRequired,onChange:l.func.isRequired,node:l.object.isRequired,dVal:l.oneOfType([l.string,l.number]).isRequired};const Fs=s=>{const{unitConfig:t,selDefined:n,node:r}=s,i=t.map(o=>({key:o.value,val:o.value,lab:o.label})),a=r.data.option_layers;return e.jsx(St,{all:i,onChange:n,node:r,dVal:a})};Fs.propTypes={unitConfig:l.arrayOf(l.object).isRequired,selDefined:l.func.isRequired,node:l.object.isRequired};const Ns=s=>{const{chkAttr:t,node:n,attrOpts:r}=s;return e.jsx(e.Fragment,{children:r.map(i=>e.jsx(c.Form.Check,{inline:!0,checked:n.data.value.includes(i.value),onChange:()=>t(i.value,!n.data.value.includes(i.value),n),type:"checkbox",label:i.label,className:"generic_attr_chks"},i.value))})};Ns.propTypes={chkAttr:l.func.isRequired,node:l.object.isRequired,attrOpts:l.array.isRequired};const Wi=s=>{const{unitConfig:t,node:n,selDefined:r,chkAttr:i,selectOptions:a}=s;return n.data.type===m.FieldTypes.F_SELECT?a.length>0?e.jsx(Fs,{unitConfig:a,selDefined:r,node:n}):null:n.data.type===m.FieldTypes.F_SYSTEM_DEFINED?e.jsx(Fs,{unitConfig:t,selDefined:r,node:n}):n.data.type===m.FieldTypes.F_DRAG_MOLECULE?e.jsx(Ns,{chkAttr:i,node:n,attrOpts:ui}):n.data.type===m.FieldTypes.F_DRAG_SAMPLE?e.jsx(Ns,{chkAttr:i,node:n,attrOpts:pi}):n.data.value||null},Ki=({selType:s,node:t})=>e.jsx(c.Form.Group,{size:"sm",style:{marginRight:"-10px",marginLeft:"-10px"},children:e.jsxs(c.Form.Control,{as:"select",placeholder:"select the type",onChange:n=>s(n,t),defaultValue:t.data.type,children:[e.jsx("option",{value:"label",children:"label"}),e.jsx("option",{value:"number",children:"number"}),e.jsx("option",{value:"text",children:"text"}),e.jsx("option",{value:"system-defined",children:"System-Defined"})]})});Ki.propTypes={selType:l.func.isRequired,node:l.object.isRequired};class Xi extends g.Component{constructor(t){super(t),this.state={unitConfig:t.unitsFields.map(n=>({value:n.field,name:n.label,label:n.label}))},this.autoSizeAll=this.autoSizeAll.bind(this),this.onGridReady=this.onGridReady.bind(this),this.delRow=this.delRow.bind(this),this.addRow=this.addRow.bind(this),this.selType=this.selType.bind(this),this.selDefined=this.selDefined.bind(this),this.refresh=this.refresh.bind(this),this.onCellValueChanged=this.onCellValueChanged.bind(this),this.columnDefs=[{rowDrag:!0,headerName:"Id",field:"id",editable:!1,minWidth:100,width:100},{headerName:"Data Type",field:"type",editable:!1,minWidth:150,width:150,cellRenderer:Ki,cellRendererParams:{selType:this.selType}},{headerName:"Default Value",field:"value",editable:n=>n.data.type!==m.FieldTypes.F_SYSTEM_DEFINED,minWidth:250,cellRenderer:Wi,cellRendererParams:{unitConfig:this.state.unitConfig,selDefined:this.selDefined},onCellValueChanged:this.onCellValueChanged},{headerName:"Option Layers(hidden)",field:"option_layers",width:10,hide:!0},{headerName:"Value System(hidden)",field:"value_system",width:10,hide:!0},{headerName:"",colId:"actions",headerComponent:vt,headerComponentParams:{addRow:this.addRow},cellRenderer:Et,cellRendererParams:{delRow:this.delRow},editable:!1,filter:!1,minWidth:60,width:60,suppressSizeToFit:!0,pinned:"left"}],this.savedColumnState=null}componentDidUpdate(){this.autoSizeAll()}saveColumnState(){if(this.gridColumnApi&&typeof this.gridColumnApi.getColumnState=="function")try{return this.savedColumnState=this.gridColumnApi.getColumnState(),!0}catch(t){console.warn("Failed to save column state:",t)}return!1}restoreColumnState(){if(this.gridColumnApi&&this.savedColumnState)try{return this.gridColumnApi.applyColumnState({state:this.savedColumnState}),!0}catch(t){console.warn("Failed to restore column state:",t)}return!1}onGridReady(t){this.gridApi=t.api,this.gridColumnApi=t.columnApi,this.autoSizeAll()}onCellValueChanged(t){const{oldValue:n,newValue:r}=t;n!==r&&(this.saveColumnState(),this.refresh())}autoSizeAll(){const{panelIsExpanded:t}=this.props;t&&this.gridApi&&setTimeout(()=>{this.gridApi.sizeColumnsToFit()},10)}delRow(){this.saveColumnState();const t=this.gridApi.getSelectedRows();this.gridApi.applyTransaction({remove:t}),this.refresh()}addRow(){this.saveColumnState();const t=new ve({type:m.FieldTypes.F_TEXT,value:""}),n=this.gridApi.getDisplayedRowCount();this.gridApi.applyTransaction({add:[t],addIndex:n}),this.refresh()}selType(t,n){const{data:r}=n;if(t.target.value===r.type)return;this.saveColumnState(),r.type=t.target.value,r.value="";const{unitConfig:i}=this.state;r.type===m.FieldTypes.F_SYSTEM_DEFINED?(r.option_layers=(i||[])[0].value,r.value_system=((this.props.unitsFields.find(p=>p.field===r.option_layers)||{}).units||[])[0].key):(delete r.option_layers,delete r.value_system);const{updSub:a,layerKey:o,field:d}=this.props,u=[];this.gridApi.forEachNode(p=>{u.push(p.data)}),d.sub_fields=u,this.gridApi.setGridOption("rowData",u),a(o,d,()=>{this.restoreColumnState()})}selDefined(t,n){const{data:r}=n;t.target.value!==r.option_layers&&(r.option_layers=t.target.value,r.value_system=((this.props.unitsFields.find(i=>i.field===r.option_layers)||{}).units||[])[0].key,this.saveColumnState(),this.refresh())}refresh(){const{updSub:t,layerKey:n,field:r}=this.props,i=[];this.gridApi.forEachNode(a=>{i.push(a.data)}),r.sub_fields=i,t(n,r,()=>{i.length>0&&this.restoreColumnState()})}render(){const{field:t}=this.props,n=t.sub_fields||[];return e.jsx("div",{children:e.jsx("div",{className:w.GRID_THEME.QUARTZ.VALUE,style:{width:"100%",height:"100%"},children:e.jsx(Se.AgGridReact,{enableColResize:!0,columnDefs:this.columnDefs,rowSelection:{mode:"singleRow",checkboxes:!1,enableClickSelection:!0},onGridReady:this.onGridReady,rowData:n,singleClickEdit:!0,stopEditingWhenCellsLoseFocus:!0,domLayout:"autoHeight",rowDragManaged:!0,onRowDragEnd:this.refresh})})})}}Xi.propTypes={layerKey:l.string.isRequired,field:l.object.isRequired,updSub:l.func.isRequired,unitsFields:l.arrayOf(l.object).isRequired,panelIsExpanded:l.bool.isRequired};const Zi=s=>{const{allLayers:t,selLayer:n,node:r}=s,i=t.map(o=>({key:o.key,val:o.key,lab:o.key})),a=r.data.layer;return e.jsx(St,{all:i,onChange:n,node:r,dVal:a})};Zi.propTypes={allLayers:l.arrayOf(l.object).isRequired,selLayer:l.func.isRequired,node:l.object.isRequired};const In=s=>{const{allLayers:t,selField:n,types:r,node:i,tableText:a}=s,d=((t.find(p=>p.key===i.data.layer)||{}).fields||[]).filter(p=>(r||[m.FieldTypes.F_TEXT]).includes(p.type)).map(p=>({key:p.field,val:p.field,lab:p.field}));a&&a===!0&&((t.find(f=>f.key===i.data.layer)||{}).fields||[]).filter(f=>f.type===m.FieldTypes.F_TABLE).forEach(f=>{((f.sub_fields||[]).filter(h=>h.type===m.FieldTypes.F_TEXT)||[]).forEach(h=>{const y={key:`${f.field}${h.id}`,val:`${f.field}[${w.SEPARATOR_TAG}]${h.id}`,lab:`${f.field}.${h.col_name}`};d.push(y)})});const u=i.data.field;return e.jsx(St,{all:d,onChange:n,node:i,dVal:u})};In.propTypes={allLayers:l.arrayOf(l.object).isRequired,types:l.arrayOf(String).isRequired,tableText:l.bool,selField:l.func.isRequired,node:l.object.isRequired};In.defaultProps={tableText:!1};class Dn extends g.Component{constructor(t){super(t),this.autoSizeAll=this.autoSizeAll.bind(this),this.onGridReady=this.onGridReady.bind(this),this.delRow=this.delRow.bind(this),this.addRow=this.addRow.bind(this),this.selLayer=this.selLayer.bind(this),this.selField=this.selField.bind(this),this.refresh=this.refresh.bind(this),this.onCellValueChanged=this.onCellValueChanged.bind(this),this.savedColumnState=null}componentDidUpdate(t){const{field:n,allLayers:r}=this.props,i=n.text_sub_fields||[];if(r!==t.allLayers&&this.gridApi){const a=this.gridApi.getColumnDefs();a.find(o=>o.field==="layer").cellRendererParams.allLayers=r,a.find(o=>o.field==="field").cellRendererParams.allLayers=r,this.gridApi.setGridOption("columnDefs",a),this.gridApi.setGridOption("rowData",i)}}saveColumnState(){if(this.gridColumnApi&&typeof this.gridColumnApi.getColumnState=="function")try{return this.savedColumnState=this.gridColumnApi.getColumnState(),!0}catch(t){console.warn("Failed to save column state:",t)}return!1}restoreColumnState(){if(this.gridColumnApi&&this.savedColumnState)try{return this.gridColumnApi.applyColumnState({state:this.savedColumnState}),!0}catch(t){console.warn("Failed to restore column state:",t)}return!1}onGridReady(t){const{allLayers:n}=this.props;this.gridApi=t.api,this.gridColumnApi=t.columnApi;const r=[{rowDrag:!0,resizable:!0,headerName:"Id",field:"id",editable:!1,minWidth:100,width:100},{headerName:"Layer",field:"layer",editable:!1,minWidth:150,width:150,cellRenderer:Zi,cellRendererParams:{allLayers:n,selLayer:this.selLayer}},{headerName:"Field (type: text)",field:"field",editable:!1,minWidth:250,cellRenderer:In,cellRendererParams:{allLayers:n,selField:this.selField,types:[m.FieldTypes.F_TEXT],tableText:!0}},{headerName:"Separator",field:"separator",editable:!0,minWidth:80,width:80,onCellValueChanged:this.onCellValueChanged},{headerName:"",colId:"actions",headerComponent:vt,headerComponentParams:{addRow:this.addRow},cellRenderer:Et,cellRendererParams:{delRow:this.delRow},editable:!1,filter:!1,minWidth:60,width:60,suppressSizeToFit:!0,pinned:"left"}];this.gridApi.setGridOption("columnDefs",r),this.autoSizeAll()}onCellValueChanged(t){const{oldValue:n,newValue:r}=t;n!==r&&(this.saveColumnState(),this.refresh())}delRow(){this.saveColumnState();const t=this.gridApi.getSelectedRows();this.gridApi.applyTransaction({remove:t}),this.refresh()}addRow(){this.saveColumnState();const{allLayers:t}=this.props,n=t.filter(d=>(d.fields||[]).filter(u=>u.type===m.FieldTypes.F_TEXT).length>0),r=n.length>0&&n[0].key||"",i=r===""?"":((t.find(d=>d.key===r)||{}).fields||[]).filter(d=>d.type===m.FieldTypes.F_TEXT)[0].field,a=new ve({layer:r,field:i,separator:"."}),o=this.gridApi.getDisplayedRowCount();this.gridApi.applyTransaction({add:[a],addIndex:o}),this.refresh()}selLayer(t,n){const{data:r}=n;if(t.target.value===r.layer)return;this.saveColumnState(),r.layer=t.target.value;const{allLayers:i}=this.props,a=r.layer,o=((i.find(y=>y.key===a)||{}).fields||[]).filter(y=>y.type===m.FieldTypes.F_TEXT)||[],d=o.length>0&&o[0].field||"";r.field=d;const{updSub:u,layerKey:p,field:f}=this.props,h=[];this.gridApi.forEachNode(y=>{h.push(y.data)}),f.text_sub_fields=h,this.gridApi.setGridOption("rowData",h),u(p,f,()=>{this.restoreColumnState()})}selField(t,n){const{data:r}=n;t.target.value!==r.field&&(this.saveColumnState(),r.field=t.target.value,this.refresh())}refresh(){const{updSub:t,layerKey:n,field:r}=this.props,i=[];this.gridApi.forEachNode(a=>{i.push(a.data)}),r.text_sub_fields=i,t(n,r,()=>{i.length>0&&this.restoreColumnState()})}autoSizeAll(){const{panelIsExpanded:t}=this.props;t&&this.gridApi&&setTimeout(()=>{this.gridApi.sizeColumnsToFit()},10)}render(){const{field:t}=this.props,n=t.text_sub_fields||[];return e.jsx("div",{children:e.jsx("div",{style:{width:"100%",height:"100%"},className:w.GRID_THEME.QUARTZ.VALUE,children:e.jsx(Se.AgGridReact,{enableColResize:!0,defaultColDef:{suppressMovable:!0},rowSelection:{mode:"singleRow",checkboxes:!1,enableClickSelection:!0},onGridReady:this.onGridReady,rowData:n,singleClickEdit:!0,stopEditingWhenCellsLoseFocus:!0,domLayout:"autoHeight",rowDragManaged:!0,onRowDragEnd:this.refresh})})})}}Dn.propTypes={layerKey:l.string.isRequired,field:l.object.isRequired,updSub:l.func.isRequired,allLayers:l.arrayOf(l.object),panelIsExpanded:l.bool.isRequired};Dn.defaultProps={allLayers:[]};const Qi=s=>{const{all:t,selType:n,node:r}=s,i=r.data.type;return e.jsx(St,{all:t,onChange:n,node:r,dVal:i})};Qi.propTypes={all:l.arrayOf(l.object).isRequired,selType:l.func.isRequired,node:l.object.isRequired};const Ld={mode:"singleRow",checkboxes:!1,enableClickSelection:!0,headerCheckbox:!1},Ad={suppressMovable:!0,resizable:!0,sortable:!1,filter:!1},Id=[m.FieldTypes.F_DRAG_MOLECULE,m.FieldTypes.F_SELECT,m.FieldTypes.F_SYSTEM_DEFINED,m.FieldTypes.F_TEXT],Dd=ce(Id.concat([m.FieldTypes.F_DRAG_SAMPLE])),Od=[m.FieldTypes.F_DRAG_MOLECULE,m.FieldTypes.F_DRAG_SAMPLE,m.FieldTypes.F_SELECT,m.FieldTypes.F_SYSTEM_DEFINED],Ji=s=>{const{field:t,genericType:n,layerKey:r,selectOptions:i,unitsFields:a,updSub:o}=s,d=g.useRef(null),[u,p]=g.useState([]),[f,h]=g.useState(!1),[y,b]=g.useState(!1),[x,j]=g.useState([]),[C]=g.useState(()=>Dd.map(N=>({key:N,val:N,lab:vs(N)}))),[T]=g.useState(a.map(N=>({value:N.field,name:N.label,label:N.label}))),S=g.useMemo(()=>Ad,[]),v=g.useCallback(()=>{b(!0)},[]),E=g.useCallback(()=>{const N=[];return d.current?.api&&d.current.api.forEachNode(A=>{N.push({...A.data})}),N},[]),_=g.useCallback(N=>{const A=X(t);if(!N||N.length===0){A.sub_fields=[],delete A.sub_values,o(r,A);return}if(A.sub_fields=N,!A.sub_values?.length){o(r,A);return}const q=new Set(N.map(B=>B.id).filter(Boolean));A.sub_values=A.sub_values.map(B=>{const M={};return B.id?M.id=B.id:M.id=ve.buildID(),Object.keys(B).forEach(O=>{O!=="id"&&q.has(O)&&(M[O]=B[O])}),M});let Y=new ve;N.map(B=>{if(B.type===m.FieldTypes.F_TEXT)return Object.assign(Y,{[B.id]:""});if(B.type===m.FieldTypes.F_SYSTEM_DEFINED){const M=wr(B.option_layers);return Object.assign(Y,{[B.id]:{value_system:M?.key??"",value:""}})}if(B.type===m.FieldTypes.F_SELECT){const M=i?.[B.option_layers];return Object.assign(Y,{[B.id]:{value:M?.options?.[0]?.key??""}})}return B.type.startsWith(m.FieldTypes.F_DRAG)?Object.assign(Y,{[B.id]:{}}):Object.assign(Y,{[B.id]:{value:"",value_system:B.value_system}})}),N.forEach(B=>{if(!(!B.id||!B.type)){for(const M of A.sub_values)M.hasOwnProperty(B.id)||(M[B.id]={...Y[B.id]});A.sub_values.forEach(M=>{if(B.id in M){if(B.type.startsWith(m.FieldTypes.F_DRAG))bs(M[B.id])||(M[B.id]={}),M[B.id].value={},delete M[B.id].value_system;else if(B.type===m.FieldTypes.F_TEXT)M[B.id]="",delete M[B.id].value_system;else if(B.type===m.FieldTypes.F_SYSTEM_DEFINED){const O=wr(B.option_layers);bs(M[B.id])||(M[B.id]={value:"",value_system:""}),M[B.id].value==null&&(M[B.id].value=""),M[B.id].value_system=O?.key??""}else if(B.type===m.FieldTypes.F_SELECT){bs(M[B.id])||(M[B.id]={});const O=i?.[B.option_layers];M[B.id].value=O?.options?.[0]?.key??"",delete M[B.id].value_system}}})}}),o(r,A)},[t,r,o,i]),R=g.useCallback(()=>{try{const N=new ve({col_name:"",type:m.FieldTypes.F_TEXT,value:""}),A=d.current.api.getDisplayedRowCount(),q=d.current.api.applyTransaction({add:[N],addIndex:A});if(q&&q.add){const Y=E();_(Y)}}catch(N){console.error("Error adding row:",N)}},[E,_]),F=g.useCallback(()=>{try{const N=d.current.api.getSelectedRows(),A=d.current.api.applyTransaction({remove:N});if(A&&A.remove){const q=E();_(q)}}catch(N){console.error("Error deleting row:",N)}},[E,_]),D=g.useCallback(N=>{const{oldValue:A,newValue:q}=N;if(A===q)return;N.node.setDataValue(N.column.colId,q);const Y=E();_(Y)},[E,_]),L=g.useCallback((N,A)=>{const{data:q}=A;if(N.target.value===q.type)return;q.type=N.target.value,q.value="",q.type===m.FieldTypes.F_SELECT?(q.option_layers=i[0]?.value,delete q.value_system):q.type===m.FieldTypes.F_SYSTEM_DEFINED?(q.option_layers=(T||[])[0].value,q.value_system=((a.find(B=>B.field===q.option_layers)||{}).units||[])[0].key):(delete q.option_layers,delete q.value_system);const Y=E();_(Y)},[i,T,a,E,_]),P=g.useCallback((N,A)=>{const{data:q}=A;if(N.target.value===q.option_layers)return;q.option_layers=N.target.value,A.data.type===m.FieldTypes.F_SYSTEM_DEFINED&&(q.value_system=((a.find(B=>B.field===q.option_layers)||{}).units||[])[0].key);const Y=E();_(Y)},[a,E,_]),G=g.useCallback((N,A,q)=>{const{data:Y}=q,B=new RegExp(`${N};`,"gi");A?Y.value=Y.value.concat(`${N};`):Y.value=Y.value?.replace(B,"");const M=E();_(M)},[E,_]),k=g.useCallback(()=>[{rowDrag:!0,headerName:"Id",field:"id",editable:!1,minWidth:100,width:100},{headerName:"Column Heading",field:"col_name",editable:!0,minWidth:150,width:150,onCellValueChanged:D},{headerName:"Column Type",field:"type",editable:!1,minWidth:150,width:150,cellRenderer:Qi,cellRendererParams:{all:C,selType:L}},{headerName:"Default Value",field:"value",editable:A=>!Od.includes(A.data.type),minWidth:350,cellRenderer:Wi,cellRendererParams:{unitConfig:T,selDefined:P,chkAttr:G,selectOptions:i},onCellValueChanged:D},{headerName:"Option Layers(hidden)",field:"option_layers",width:10,hide:!0},{headerName:"Value System(hidden)",field:"value_system",width:10,hide:!0},{headerName:"",colId:"actions",headerComponent:vt,headerComponentParams:{addRow:R},cellRenderer:Et,cellRendererParams:{delRow:F},editable:!1,filter:!1,minWidth:60,width:60,suppressSizeToFit:!0,pinned:"left"}],[T,P,G,i,C,L]),U=g.useCallback(()=>{try{const N=E();_(N)}catch(N){console.error("Error handling row drag:",N)}},[E,_]);return g.useEffect(()=>{if(!y||f)return;const N=d.current.api.getColumnState();p(k()),setTimeout(()=>{d.current.api.applyColumnState({state:N,applyOrder:!0}),h(!0)},0)},[y,f,k]),g.useEffect(()=>{f&&j(t.sub_fields||[])},[f,t.sub_fields]),g.useEffect(()=>{if(d.current?.api){const N=u.find(Y=>Y.field==="value");if(!N)return;const A=N.cellRendererParams.selectOptions;if(!(!A||A.length!==i.length||JSON.stringify(A)!==JSON.stringify(i)))return;N.cellRendererParams.selectOptions=i,d.current.api.setGridOption("columnDefs",u)}},[i,u]),e.jsx("div",{children:e.jsx("div",{style:{width:"100%",height:"100%"},className:w.GRID_THEME.QUARTZ.VALUE,children:e.jsx(Se.AgGridReact,{columnDefs:u,defaultColDef:S,domLayout:"autoHeight",enableColResize:!0,onGridReady:v,onRowDragEnd:U,ref:d,rowData:x,rowDragManaged:!0,rowSelection:Ld,singleClickEdit:!0,stopEditingWhenCellsLoseFocus:!0})})})};Ji.propTypes={genericType:l.string.isRequired,layerKey:l.string.isRequired,field:l.object.isRequired,updSub:l.func.isRequired,unitsFields:l.arrayOf(l.object).isRequired,selectOptions:l.arrayOf(l.object).isRequired};const Pd=g.memo(Ji),Gd=["checkbox","text","select"];function On({showModal:s,field:t,layer:n,sortedLayers:r,onUpdate:i,onClose:a,groupedLayerKeys:o,sameGroupLayerKeys:d,selectOptions:u={}}){const[p,f]=g.useState([]),[h,y]=g.useState(""),[b,x]=g.useState(""),[j,C]=g.useState(""),[T,S]=g.useState(""),[v,E]=g.useState([]),[_,R]=g.useState(1),[F,D]=g.useState([]),[L,P]=g.useState([]),[G,k]=g.useState(1),{klasses:U=[],genericType:N}=Ms(),[A,q]=g.useState("");g.useEffect(()=>{if(!r){D([]);return}let $;if(d&&d.length>0)$=r.filter(H=>d.includes(H.key));else{const H=new Set(o||[]);$=r.filter(Z=>!H.has(Z.key))}D($)},[r,o,d]),g.useEffect(()=>{if(s&&(t?.cond_fields?(f(t.cond_fields),R(t.cond_operator??1),P(t.cond_fields),k(t.cond_operator??1)):(f([]),R(1),P([]),k(1)),F&&F.length>0)){const $=F[0];y($.key),Y($)}},[s,t,F]);const Y=$=>{if(!$||!$.fields){E([]);return}let H=$.fields.filter(Z=>Gd.includes(Z.type));$.key===n.key&&(H=H.filter(Z=>Z.field!==t.field)),E(H),H.length>0?x(H[0].field):x("")},B=$=>{const H=$.target.value;y(H);const Z=F.find(le=>le.key===H);Z&&Y(Z),C("")},M=()=>{if(!h||!b)return;const Z=F.find(we=>we.key===h)?.fields?.find(we=>we.field===b)?.type===m.FieldTypes.F_CHECKBOX;let le=j.trim();Z&&(le=es(j));const ne={id:`${ie.v4()}-fc`,field:b,layer:h,value:le,label:T.trim()},ae=[...p,ne];f(ae),C(""),S("")},O=()=>{if(!A)return;const $={id:`${ie.v4()}-fc`,field:"TYPE",layer:"SRC-EL",value:A},H=[...p,$];f(H)},V=$=>{const H=p.filter(Z=>Z.id!==$);f(H)},z=$=>{R($)},K=()=>{if(i)if(p.length===0){const $={...t};delete $.cond_fields,delete $.cond_operator,i($)}else i({...t,cond_fields:p,cond_operator:_});a()},J=()=>{f(L),R(G),a()};return s?e.jsxs(c.Modal,{centered:!0,backdrop:"static",dialogClassName:"gu_modal-68w",show:s,onHide:J,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsxs(c.Modal.Title,{children:["Field Restriction Setting [ ",t.label," ] in [ ",n.label," ]"]})}),e.jsx(c.Modal.Body,{style:{maxHeight:"70vh",overflow:"auto"},children:e.jsx(c.Card,{className:"border-0",children:e.jsxs(c.Card.Body,{className:"p-0",children:[e.jsx(Rn,{selectedOp:_,onOpChange:z}),p.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("small",{className:"text-muted d-block mb-2",children:"Existing Conditions:"}),p.map($=>{const{layerTitle:H,fieldTitle:Z,valueTitle:le}=Xr($,F,U);return e.jsxs("div",{className:"d-flex align-items-center gap-2 mb-2 p-2 border rounded bg-white",children:[e.jsx("div",{className:"flex-grow-1",children:e.jsxs("small",{children:[e.jsx("strong",{children:H})," → ",Z,' = "',le,'"',$.label&&e.jsxs("span",{className:"text-muted",children:[" ","[Display as: ",e.jsx("em",{children:$.label}),"]"]})]})}),e.jsx(c.Button,{variant:"danger",size:"xsm",onClick:()=>V($.id),title:"Remove condition",children:I.faTrashCan})]},$.id)})]}),e.jsxs("div",{className:"border-top pt-3",children:[e.jsx("small",{className:"text-muted d-block mb-2",children:"Add New Condition:"}),e.jsxs(c.Form.Group,{className:"mb-2",children:[e.jsx(c.Form.Label,{className:"small",children:"Select Layer (appearance order)"}),e.jsx(c.Form.Select,{size:"sm",value:h,onChange:B,children:F&&F.map($=>e.jsxs("option",{value:$.key,children:[$.label||$.key," (",$.key,")"]},$.key))})]}),e.jsxs("div",{className:"row mb-3 align-items-start",children:[e.jsx("div",{className:"col-md-4",children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{className:"small",children:"Select Field"}),e.jsx(c.Form.Select,{size:"sm",value:b,onChange:$=>x($.target.value),disabled:v.length===0,children:v.map($=>e.jsxs("option",{value:$.field,children:[$.label||$.field," (",$.field,", type: ",$.type,")"]},$.field))}),e.jsx(c.Form.Text,{muted:!0,children:"Eligible fields (checkbox, text, select)"})]})}),e.jsx("div",{className:"col-md-4",children:e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{className:"small",children:"Enter Value"}),(()=>{const H=F.find(ae=>ae.key===h)?.fields?.find(ae=>ae.field===b),Z=H?.type==="select",le=H?.type===m.FieldTypes.F_CHECKBOX,ne=Z&&H?.option_layers?u[H.option_layers]?.options||[]:[];return Z?e.jsxs(c.Form.Select,{size:"sm",value:j,onChange:ae=>C(ae.target.value),children:[e.jsx("option",{value:"",children:"Select a value..."}),ne.map(ae=>e.jsx("option",{value:ae.key,children:ae.label},ae.key))]}):le?e.jsxs(c.Form.Select,{size:"sm",value:j,onChange:ae=>C(ae.target.value),children:[e.jsx("option",{value:"false",children:"Unchecked (false)"}),e.jsx("option",{value:"true",children:"Checked (true)"})]}):e.jsx(c.Form.Control,{type:"text",size:"sm",placeholder:"Enter expected value",value:j,onChange:ae=>C(ae.target.value)})})(),e.jsx(c.Form.Text,{muted:!0,children:(()=>{const H=F.find(Z=>Z.key===h)?.fields?.find(Z=>Z.field===b);return H?.type==="select"?"Select from predefined options":H?.type===m.FieldTypes.F_CHECKBOX?"Select the expected checkbox state":"Enter the expected value (case-sensitive)"})()})]})}),e.jsx("div",{className:"col-md-4",children:e.jsxs(c.Form.Group,{children:[e.jsxs(c.Form.Label,{className:"small",children:["Display as (optional)",_!==1&&e.jsx("span",{className:"text-muted",children:" - Match One only"})]}),e.jsxs("div",{className:"d-flex gap-2 align-items-start",children:[e.jsx(c.Form.Control,{type:"text",size:"sm",placeholder:"Alternative name",value:T,onChange:$=>S($.target.value),disabled:_!==1,style:{flex:1}}),e.jsx(c.Button,{variant:"success",size:"sm",onClick:M,disabled:!h||!b||v.length===0,style:{flexShrink:0},title:"Add condition",children:I.faPlus})]})]})})]}),N===w.GENERIC_TYPES.DATASET&&e.jsx("div",{className:"row align-items-start",children:e.jsx("div",{className:"col-md-12",children:e.jsxs(c.Form.Group,{className:"border-top pt-3",children:[e.jsx(c.Form.Label,{className:"small",children:"Reference Source"}),e.jsxs("div",{className:"d-flex gap-2 align-items-start",children:[e.jsxs(c.Form.Select,{size:"sm",value:A,onChange:$=>q($.target.value),disabled:U.length===0,style:{flex:1},children:[e.jsx("option",{value:"",children:"Select a source..."}),U.map($=>e.jsxs("option",{value:$.name,children:[$.label||$.name," (",$.name,")"]},$.name))]}),e.jsx(c.Button,{variant:"success",size:"sm",onClick:O,disabled:!A||U.length===0,style:{flexShrink:0},title:"Add condition",children:I.faPlus})]}),e.jsx(c.Form.Text,{muted:!0,children:"Eligible reference sources"})]})})})]})]})})}),e.jsxs(c.Modal.Footer,{className:"justify-content-start",children:[e.jsx(c.Button,{variant:"secondary",onClick:J,children:"Cancel"}),e.jsx(c.Button,{variant:"success",onClick:K,children:"Save"})]})]}):null}On.propTypes={showModal:l.bool.isRequired,field:l.shape({label:l.string.isRequired,field:l.string.isRequired,cond_fields:l.arrayOf(l.shape({id:l.string,field:l.string,layer:l.string,value:l.oneOfType([l.string,l.bool]),label:l.string})),cond_operator:l.number}).isRequired,layer:l.shape({key:l.string.isRequired,label:l.string}).isRequired,sortedLayers:l.arrayOf(l.shape({key:l.string.isRequired,label:l.string,fields:l.array})).isRequired,onUpdate:l.func.isRequired,onClose:l.func.isRequired,groupedLayerKeys:l.arrayOf(l.string),sameGroupLayerKeys:l.arrayOf(l.string),selectOptions:l.object};On.defaultProps={groupedLayerKeys:[],sameGroupLayerKeys:null,selectOptions:{}};function Pn(s){const{field:t,fnUpdateSub:n,layer:r,sortedLayers:i,as:a,groupedLayerKeys:o,sameGroupLayerKeys:d,selectOptions:u,disabled:p}=s,[f,h]=g.useState(!1),y=()=>{p||h(!0)},b=()=>{h(!1)},x=T=>{n(r.key,T)},j=e.jsx(c.Button,{variant:t?.cond_fields?.length>0?"warning":"light",className:"rounded-0",onClick:y,disabled:p,children:I.faGears}),C=e.jsxs(c.Dropdown.Item,{eventKey:"_field_cond_menu_item",onClick:y,className:t?.cond_fields?.length>0?"gu-menu-item-cond":"",disabled:p,children:[I.faGears,"  ",Ce.restriction_setting]});return e.jsxs(e.Fragment,{children:[a==="menu"?C:e.jsx(Q,{idf:p?"restric_not_on_required":"restriction_setting",children:j}),e.jsx(On,{showModal:f,field:t,layer:r,sortedLayers:i,onUpdate:x,onClose:b,groupedLayerKeys:o,sameGroupLayerKeys:d,selectOptions:u})]})}Pn.propTypes={field:l.object.isRequired,fnUpdateSub:l.func.isRequired,layer:l.object.isRequired,sortedLayers:l.array.isRequired,as:l.string,groupedLayerKeys:l.arrayOf(l.string),sameGroupLayerKeys:l.arrayOf(l.string),selectOptions:l.object,disabled:l.bool};Pn.defaultProps={as:"menu",groupedLayerKeys:[],sameGroupLayerKeys:null,selectOptions:{},disabled:!1};const el=({init:s})=>{const{label:t,field:n,ontology:r}=s,{description:i=[""],short_form:a="",label:o=""}=r||{},d=zt(r,o)||"(No terminology linked yet)";return e.jsxs(c.Row,{children:[e.jsxs(c.Col,{md:6,children:[e.jsx("h4",{children:e.jsx("b",{children:t})}),e.jsxs(c.Form,{children:[e.jsxs(c.Form.Group,{className:"props_text",children:[e.jsx(c.Form.Label,{children:"Field Name"}),e.jsx(c.Form.Control,{type:"text",value:n,readOnly:!0,disabled:!0})]}),e.jsxs(c.Form.Group,{className:"props_text",children:[e.jsx(c.Form.Label,{children:"Display Name"}),e.jsx(c.Form.Control,{type:"text",value:t,placeholder:"Give a name to display on the UI. Empty is allow.",readOnly:!0,disabled:!0})]}),e.jsxs(c.Form.Group,{className:"p-3 mt-3",children:[e.jsx(c.Form.Label,{children:"Who can use this vocabulary?"}),e.jsxs(c.Form.Check,{type:"radio",children:[e.jsx(c.Form.Check.Input,{type:"radio",checked:!0,readOnly:!0}),e.jsxs(c.Form.Check.Label,{children:[e.jsx("span",{className:"gu-mr-1",children:I.faGlobe}),e.jsx("b",{children:"LabIMotion Generic Module"}),e.jsx("div",{children:"This vocabulary can be used by any designer within templates. Designers can reuse fields, with references automatically inheriting values from the original fields."})]})]})]})]})]}),e.jsxs(c.Col,{md:6,children:[e.jsx("h4",{className:"gu-ontology-text-link",children:d}),e.jsxs(c.Form,{children:[e.jsxs(c.Form.Group,{className:"props_text",children:[e.jsx(c.Form.Label,{children:"Term ID"}),e.jsx(c.Form.Control,{type:"text",value:a,readOnly:!0,disabled:!0})]}),e.jsxs(c.Form.Group,{children:[e.jsx(c.Form.Label,{children:"Description"}),e.jsx(c.Form.Control,{as:"textarea",value:i.join(`
3
+ `),readOnly:!0,disabled:!0,rows:6,style:{resize:"none"}})]}),e.jsxs("div",{className:"pt-3 mt-3",children:[e.jsx("span",{className:"me-2",children:I.faCircleInfo}),e.jsxs("span",{children:[e.jsx("b",{children:"Please note:"}),e.jsx("p",{className:"mb-0",children:"1. When no terminology is linked, this field cannot be saved as a LabIMotion Vocabulary (Lab-Vocab) for future use in the template."}),e.jsx("p",{className:"mb-0",children:"2. The following field types are not supported:"}),e.jsx("ul",{children:ai.map(u=>e.jsx("li",{children:u.label},u.value))})]})]})]})]})]})};el.propTypes={init:l.shape({label:l.string,field:l.string,ontology:l.shape({description:l.arrayOf(l.string),short_form:l.string,label:l.string})}).isRequired};const rs=({acts:s,title:t,showProps:n,close:r,children:i})=>{const{show:a}=n;return a?e.jsx(c.Modal,{centered:!0,show:a,onHide:r,dialogClassName:"gu_modal-68w",children:e.jsxs("div",{onClick:o=>{o.stopPropagation(),o.preventDefault()},onKeyDown:o=>o.key==="Enter"&&o.stopPropagation(),role:"button",tabIndex:0,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:t})}),e.jsx(c.Modal.Body,{children:i}),e.jsx(c.Modal.Footer,{className:"justify-content-start",children:s.map(o=>o)})]})}):null};rs.propTypes={acts:l.arrayOf(l.node),title:l.string.isRequired,showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired,close:l.func.isRequired,children:l.node.isRequired};rs.defaultProps={acts:[]};const Md="vocab";class $e{static#e=async(t,n="GET",r=null)=>{const i=`${Md}/${t}`,a=r?await xe.execApiData(r,i):await xe.execApi(i,n);return new ee(Xe(a.mc,a.msg||""),{data:a.data})};static saveVocabulary=(t={})=>$e.#e("save_vocabulary","POST",t);static deleteVocabulary=t=>$e.#e(`delete_vocabulary/${t}`,"DELETE");static getVocabulary=t=>$e.#e(`get_vocabulary/${t}`);static getAllVocabularies=()=>$e.#e("get_all_vocabularies")}const is=({notify:s,onClose:t})=>s===null?null:e.jsxs(c.Alert,{variant:s.isSuccess?"success":"danger",children:[e.jsxs("span",{children:[e.jsx("b",{children:s.title}),`: ${s.msg}`]}),e.jsx(c.Button,{size:"xsm",className:"gu_button_right",onClick:n=>{n.stopPropagation(),t()},variant:"light",children:I.faTimes})]});is.propTypes={notify:l.shape({isSuccess:l.bool,title:l.string,msg:l.string}),onClose:l.func.isRequired};is.defaultProps={notify:null};const $d=(s,t)=>{const n={select_options:{}},r=X(s),i=X(t);if([m.FieldTypes.F_SELECT,m.FieldTypes.F_SELECT_MULTI].includes(r.type)){const a=r.option_layers;i?.properties_template?.select_options?.[a]&&(n.select_options[a]=i.properties_template.select_options[a],n.select_options[a].desc=a)}return Object.keys(n.select_options||{}).length===0?null:n},tl={show:!1,field:null,layer:null,data:null,notify:null},qd=(s,t)=>t.type==="reset"?{...tl,field:t.payload.field,layer:t.payload.layer,data:t.payload.data}:{...s,[t.type]:t.payload},Bd=s=>{const{field:t,data:n,layer:r,genericType:i}=s,[a,o]=g.useReducer(qd,{...tl,field:t,data:n,layer:r});g.useEffect(()=>{o({type:"field",payload:t})},[t]),g.useEffect(()=>{o({type:"data",payload:n})},[n]),g.useEffect(()=>{o({type:"layer",payload:r})},[r]);const d=async()=>{const h={source:i,source_id:a.data.identifier,layer_id:a.layer.key},y=$d(a.field,a.data),b={...a.field,...y,term_id:a.field.ontology?.short_form,...h,voc:{...h}};b.name=b.field,b.field_type=b.type,delete b.field,delete b.type;const x=await $e.saveVocabulary(b);o({type:"notify",payload:x.notify})},u=()=>{o({type:"reset",payload:{field:t,data:n,layer:r}})},p=e.jsx(c.Button,{variant:"success",onClick:d,disabled:!zt(a.field.ontology,a.field.ontology?.label)||ai.some(h=>h.name===a.field.type),children:"Save"},"success"),f=e.jsx(c.Button,{variant:"secondary",onClick:u,children:"Close"},"secondary");return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"voc_add",children:e.jsx(c.Button,{variant:"light",onClick:()=>o({type:"show",payload:!0}),children:I.faSpellCheck})}),e.jsx(rs,{acts:[p,f],title:"LabIMotion Vocabulary (Lab-Vocab)",showProps:{show:a.show,setShow:h=>o({type:"show",payload:h})},close:u,children:e.jsxs("div",{children:[e.jsx(is,{notify:a.notify,onClose:()=>o({type:"notify",payload:null})}),e.jsx(el,{init:a.field})]})})]})};function Ee({children:s,tooltip:t,isCheckLabel:n}){const r=n?c.Form.Check.Label:c.Form.Label,i=e.jsx(r,{className:"fw-bold mt-2",children:s});return t==null||g.Children.count(t)===0?i:e.jsx(c.OverlayTrigger,{overlay:e.jsx(c.Tooltip,{children:t}),placement:"top",delay:{show:250,hide:400},children:i})}Ee.propTypes={children:l.node.isRequired,tooltip:l.node,isCheckLabel:l.bool};Ee.defaultProps={tooltip:null,isCheckLabel:!1};const Ud=(s,t)=>{const n=t.findIndex(i=>i.key===s);if(n===-1)return null;const r=(n+1)%t.length;return t[r]},Vd=(s=[])=>{const t=s.units.map(n=>e.jsxs("div",{children:[st(n.label),e.jsx("br",{})]},ie.v4()));return e.jsxs(c.Popover,{id:"popover-positioned-scrolling-left",children:[e.jsx(c.Popover.Header,{as:"h3",children:"Available units"}),e.jsx(c.Popover.Body,{children:t})]})},sl=s=>{const{fObj:t,fnUnitChange:n}=s,{option_layers:r,value_system:i}=t,o=m.getUnitSystem().filter(f=>f.field===r)[0];if(!o||Object.keys(o).length===0)return null;const d=o?.units[0],u=m.genUnit(o.field,i||d?.key);if(!u||Object.keys(u).length===0)return null;const p=()=>{const f=Ud(u.key,o.units);n({data:f.key})};return e.jsxs(c.Form.Group,{as:c.Col,children:[e.jsx(Ee,{children:e.jsxs(e.Fragment,{children:[me("supportedUnits").label," ",me("supportedUnits").fieldTooltip]})}),e.jsx("div",{className:"d-flex align-items-center",children:e.jsx(c.OverlayTrigger,{animation:!0,placement:"top",root:!0,trigger:["hover","focus"],overlay:Vd(o),children:e.jsx(c.Button,{onClick:p,variant:"success",size:"sm",children:st(u.label)||""})})})]})};sl.propTypes={fObj:l.object.isRequired,fnUnitChange:l.func.isRequired};const zd=(s,t="link")=>{const n=m.buildTS(s);if(!n)return null;const{label:r}=s,i=t==="link"?"":"ms-1 badge rounded-pill bg-success",a=t==="link"?I.faCircleQuestion:r;return e.jsx(Q,{idf:`link_term.${r}`,children:e.jsx(c.Button,{variant:"link",href:n,target:"_blank",onClick:o=>o.stopPropagation(),className:i,children:a})})},Yd=s=>{if(s){const t=s.description?.join("")||"";return{value:s.id,label:e.jsxs(e.Fragment,{children:[s.label,e.jsxs("span",{children:[e.jsx("span",{className:"gu-ontology-select-code-short badge",children:s.short_form})," ",e.jsx("span",{className:"gu-ontology-select-code-prefix badge",children:s.ontology_prefix}),t?e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("span",{style:{fontSize:"11px"},children:t})]}):null]})]})}}return s},Hd=s=>s?s.map(t=>Object.assign(Yd(t),{data:t})):[],Wd=s=>{const{fnSelected:t,defaultValue:n}=s,[,r]=g.useState(null),i=async a=>{try{if(!a.trim()||a.length<2)return[];const o=await fetch(m.buildTSS(a));if(!o.ok)throw new Error("Network request failed");const d=await o.json();return Hd(d?.response?.docs)}catch(o){return console.error("Error fetching data:",o),[]}};return g.useEffect(()=>{i("").then(r)},[]),e.jsx(ta,{backspaceRemoves:!0,isClearable:!0,value:n,valueKey:"value",labelKey:"label",loadOptions:(a,o)=>{i(a).then(d=>o(d))},onChange:a=>{t(a)},styles:{container:a=>({...a,width:"100%"}),control:a=>({...a,height:"36px",minHeight:"36px",minWidth:"200px",border:"1px solid #ccc"})}})},nl=s=>{const{showProps:t,modalComponent:n}=s,{show:r,setShow:i}=t;return e.jsxs(c.Modal,{centered:!0,backdrop:"static",show:r,onHide:()=>i(!1),children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Select Term"})}),e.jsx(c.Modal.Body,{children:n})]})};nl.propTypes={modalComponent:l.element.isRequired,showProps:l.object.isRequired};const Kd=s=>{const{modalComponent:t,customClass:n}=s,[r,i]=g.useState(!1),a=e.jsx(c.Popover,{id:"popover-positioned-scrolling-left",children:e.jsx("div",{className:"p-3",children:"Link to ontology terminology"})});return e.jsxs(e.Fragment,{children:[e.jsx(c.OverlayTrigger,{animation:!0,placement:"top",root:!0,trigger:["hover","focus","click"],overlay:a,children:e.jsxs(c.Button,{variant:"light",onClick:()=>i(!0),className:"flex-shrink-0",children:[n?e.jsxs("span",{children:[e.jsx("span",{style:{color:"green"},children:I.faCircleCheck})," "]}):null,"Term"]})}),e.jsx(nl,{modalComponent:t,showProps:{show:r,setShow:i}})]})},Dr=[{value:1,label:"1"},{value:2,label:"2"},{value:3,label:"3"},{value:4,label:"4"},{value:5,label:"5"},{value:6,label:"6"}],Xd=()=>e.jsx(c.Form.Group,{as:c.Col,children:e.jsx(Ee,{children:" "})}),Zd=({fieldObject:s})=>[m.FieldTypes.F_DUMMY].includes(s.type)?e.jsxs(c.Form.Group,{as:c.Col,children:[e.jsx(Ee,{children:e.jsxs(e.Fragment,{children:["(",s.type,")"]})}),e.jsx(c.Form.Control,{type:"text",name:`f_${s.field}`,defaultValue:`${s.type}, an invisible entry (${s.field})`,disabled:!0})]}):null,Qd=({layer:s,fieldObject:t,field:n,fnChange:r,fnOntChange:i})=>e.jsxs(c.Form.Group,{as:c.Col,children:[e.jsx(Ee,{children:e.jsxs(e.Fragment,{children:[me(n).label," ",me(n).fieldTooltip]})}),e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx(c.Form.Control,{type:"text",name:`f_${n}`,defaultValue:t[n],disabled:n==="field",onChange:a=>r(a,t[n],t.field,s.key,n,m.FieldTypes.F_TEXT),className:"me-0"}),e.jsx(Kd,{modalComponent:e.jsx(Wd,{fnSelected:i,defaultValue:t?.ontology}),customClass:t?.ontology?"gu-ontology-selected":null})]})]}),Dt=({layer:s,fieldObject:t,field:n,fnChange:r,xs:i})=>[m.FieldTypes.F_DUMMY].includes(t.type)?null:e.jsxs(c.Form.Group,{as:c.Col,xs:i,children:[e.jsx(Ee,{children:e.jsxs(e.Fragment,{children:[me(n).label," ",me(n).fieldTooltip]})}),e.jsx(c.Form.Control,{type:"text",name:`f_${n}`,defaultValue:t[n],disabled:n==="field",onChange:a=>r(a,t[n],t.field,s.key,n,m.FieldTypes.F_TEXT)})]}),ls=({layer:s,fieldObject:t,fnChange:n,field:r,note:i,disabled:a=!1,isLabel:o=!1,xs:d,skipLabel:u=!1})=>{const p=e.jsxs(e.Fragment,{children:[me(r).label," ",me(r).fieldTooltip]});return e.jsxs(c.Form.Group,{as:c.Col,xs:d,children:[!u&&e.jsx(Ee,{children:o?p:e.jsx(e.Fragment,{children:" "})}),e.jsxs(c.Form.Check,{type:"checkbox",id:`frmChk_${s.key}_f_${r}`,children:[e.jsx(c.Form.Check.Input,{className:"mt-2",type:"checkbox",checked:!!t[r],disabled:a,onChange:f=>n(f,t[r]||!1,t.field,s.key,r,"checkbox")}),o?null:e.jsx(c.Form.Check.Label,{className:"mt-1",children:e.jsx("b",{children:p})})]}),i&&e.jsx(c.Form.Text,{className:"text-muted",children:i})]})},Jd=({layer:s,fieldObject:t,field:n,fnChange:r})=>e.jsxs(c.Form.Group,{as:c.Col,children:[e.jsx(Ee,{children:e.jsxs(e.Fragment,{children:[me(n).label," ",me(n).fieldTooltip]})}),e.jsx("div",{style:{display:"flex"},children:e.jsx("span",{style:{width:"100%"},children:e.jsx(Ue,{styles:Ye,name:n,multi:!1,options:Dr,value:Dr.find(i=>i.value===(t[n]||s.cols)),onChange:i=>r(i,t[n],t.field,s.key,"cols","select"),menuPlacement:"auto",menuPortalTarget:document.body})})})]}),ec=({layer:s,fieldObject:t,fnChange:n,xs:r})=>[m.FieldTypes.F_FORMULA_FIELD].includes(t.type)?ls({layer:s,fieldObject:t,fnChange:n,field:"canAdjust",disabled:!1,xs:r}):null,tc=({layer:s,fieldObject:t,fnChange:n})=>[m.FieldTypes.F_DUMMY,m.FieldTypes.F_TABLE].includes(t.type)?null:ls({layer:s,fieldObject:t,fnChange:n,field:"hasOwnRow",disabled:m.FieldTypes.F_DATETIME_RANGE===t.type}),sc=({layer:s,fieldObject:t,fnChange:n,xs:r})=>[m.FieldTypes.F_INTEGER,m.FieldTypes.F_TEXT].includes(t.type)?ls({layer:s,fieldObject:t,fnChange:n,field:"required",disabled:!1,skipLabel:!0,xs:r}):null,nc=({layer:s,fieldObject:t,fnChange:n})=>[m.FieldTypes.F_TEXT].includes(t.type)?ls({layer:s,fieldObject:t,fnChange:n,field:"readonly",note:"In 'Read-Only' mode, it shows plain text with an available placeholder.",skipLabel:!0}):null,rc=({layer:s,fieldObject:t,fnChange:n,typeOpts:r,xs:i})=>[m.FieldTypes.F_DUMMY].includes(t.type)?null:e.jsxs(c.Form.Group,{as:c.Col,xs:i,children:[e.jsx(Ee,{children:e.jsxs(e.Fragment,{children:[me("type").label," ",me("type").fieldTooltip,e.jsxs("span",{className:"text-warning ms-2 fw-normal small",children:[I.faTriangleExclamation," Changing the field type will remove it from layer display name, restrictions, etc., if used."]})]})}),e.jsx("div",{style:{display:"flex",alignItems:"center"},children:e.jsx("span",{style:{width:"100%"},children:e.jsx(Ue,{styles:Ye,name:t.field,multi:!1,options:r,value:r?.find(a=>a.value===t.type),onChange:a=>n(a,t.type,t.field,s.key,"type","select"),menuPlacement:"auto",menuPortalTarget:document.body})})})]}),ic=({layer:s,fieldObject:t,field:n,fnChange:r,xs:i})=>e.jsxs(c.Form.Group,{as:c.Col,xs:i,children:[e.jsx(Ee,{children:e.jsxs(e.Fragment,{children:[me(n).label," ",me(n).fieldTooltip]})}),e.jsx(c.Form.Control,{type:"number",name:`frmDec_${s.key}_f_${t.field}`,value:t.decimal,onChange:a=>r(a,t.label,t.field,s.key,n,m.FieldTypes.F_TEXT),min:1})]}),as=g.memo(({type:s,field:t,rowValue:n,isButton:r=!1})=>{const[{isDragging:i},a]=be.useDrag({type:s,item:{fid:t,rid:n},collect:p=>({isDragging:p.isDragging()})}),o=`${i?" gu_is-dragging":""}`,d={cursor:i?"grabbing":"grab",zIndex:900,position:"relative"};return r?e.jsx(c.Button,{ref:a,className:"px-3",style:d,variant:"outline-light",onClick:p=>{p.stopPropagation()},children:e.jsx("div",{className:"text-primary",children:I.faArrowsUpDownLeftRight})}):e.jsx("div",{onMouseEnter:()=>console.log("Mouse enter:",t?.field),onMouseLeave:()=>console.log("Mouse leave:",t?.field),ref:a,className:`px-3 py-2 ${o}`,style:d,children:e.jsx("div",{className:"dnd-btn text-primary",children:e.jsx("span",{children:I.faArrowsUpDownLeftRight})})})});as.propTypes={type:l.string.isRequired,field:l.object.isRequired,rowValue:l.object.isRequired,isButton:l.bool};as.defaultProps={isButton:!1};as.displayName="PositionDnD";const ks={LAYER_FIELD:"-LAYER-FIELD"},lc=(s,t,n)=>{const r=[];let i=new ve;s.map(p=>Object.assign(i,{[p.id]:""}));const a=Object.keys(i),o=Object.keys(n[0]),d=o.filter(p=>!a.includes(p)),u={};return s.map(p=>p.type===m.FieldTypes.F_TEXT?Object.assign(u,{[p.id]:""}):Object.assign(u,{[p.id]:{value:"",value_system:p.value_system}})),n.forEach(p=>{i=new ve,Object.assign(i,u,p),d.forEach(f=>delete i[f]),o.forEach(f=>{if(i[f]===void 0||f==="id")return;const h=s.find(b=>b.id===f),y=t.find(b=>b.id===f);h.type===m.FieldTypes.F_DRAG_MOLECULE&&[m.FieldTypes.F_TEXT,m.FieldTypes.F_SYSTEM_DEFINED,m.FieldTypes.F_DRAG_SAMPLE].includes(y.type)&&(i[f]={value:void 0}),h.type===m.FieldTypes.F_TEXT&&(y.type===m.FieldTypes.F_SYSTEM_DEFINED&&(i[f]=i[f].value),[m.FieldTypes.F_DRAG_MOLECULE,m.FieldTypes.F_DRAG_SAMPLE].includes(y.type)&&(i[f]="")),h.type===m.FieldTypes.F_SYSTEM_DEFINED&&(y.type===m.FieldTypes.F_SYSTEM_DEFINED&&h.option_layers!==y.option_layers&&(i[f].value_system=h.value_system),[m.FieldTypes.F_TEXT,m.FieldTypes.F_DRAG_MOLECULE,m.FieldTypes.F_DRAG_SAMPLE].includes(y.type)&&(i[f]={value:"",value_system:h.value_system}),i[f].value=m.unitConversion(h.option_layers,i[f].value_system,i[f].value))}),r.push(i)}),r},ac=(s,t)=>{const n=X(s.sub_fields||[]),r=X(t.sub_fields||[]),i=X(t.sub_values||[]);return n.length<1||r.length<1||i.length<1?[]:lc(n,r,i)},Gn=(s,t)=>sa({},s,t,(n,r)=>{if(mr(n)&&mr(r))return[...n,...r].filter((a,o,d)=>o===d.findIndex(u=>u.key===a.key))}),oc=(s,t)=>{if(!s||Object.keys(t||{}).length<1||!s.properties||!t.properties_release)return[void 0,void 0];const n=X(t.properties_release);n.klass=s.properties.klass,n.klass_uuid=t.uuid;const r=n.select_options||{};return Object.keys(n.layers).forEach(i=>{const a=n.layers[i]||{};a.ai=s.properties.layers[i]?.ai||[],s.properties.layers[i]?.timeRecord&&(a.timeRecord=s.properties.layers[i]?.timeRecord);const o=s.properties.layers[i]&&s.properties.layers[i].fields||[];(a.fields||[]).forEach((d,u)=>{const p=Ie(o,h=>h.field===d.field),f=n.layers[i].fields[u].type;if(p===-1&&f===m.FieldTypes.F_CHECKBOX){const h=n.layers[i].fields[u].value;h==null&&(n.layers[i].fields[u].value=!1)}if(p>=0){const h=s.properties.layers[i].fields[p].value,y=typeof h;if(f===m.FieldTypes.F_DATETIME_RANGE)if(s.properties.layers[i].fields[p].type!==f)n.layers[i].fields[u].sub_fields=[];else{const b=s.properties.layers[i].fields[p].sub_fields||[];n.layers[i].fields[u].sub_fields=b}if([m.FieldTypes.F_SELECT,m.FieldTypes.F_TEXT,m.FieldTypes.F_TEXTAREA,m.FieldTypes.F_FORMULA_FIELD].includes(f)&&(n.layers[i].fields[u].value=y!==m.FieldTypes.V_UNDEFINED?(h||"").toString():""),f===m.FieldTypes.F_SELECT_MULTI)if(n.layers[i].fields[u].value="",s.properties.layers[i].fields[p].type!==f)n.layers[i].fields[u].sub_fields=[];else{const b=n.layers[i].fields[u].option_layers,x=(r[b]||{}).options||[];if(x.length<1)n.layers[i].fields[u].sub_fields=[];else{const j=new Set(x.map(T=>T.key)),C=s.properties.layers[i].fields[p].sub_fields||[];n.layers[i].fields[u].sub_fields=C.filter(T=>j.has(T.value))}}if(f===m.FieldTypes.F_INTEGER){const b=y===m.FieldTypes.V_UNDEFINED||y===m.FieldTypes.V_BOOLEAN||isNaN(h);n.layers[i].fields[u].value=b?0:parseInt(h,10)}if(f===m.FieldTypes.F_CHECKBOX&&(h==null?n.layers[i].fields[u].value=!1:n.layers[i].fields[u].value=es(h)),(f===m.FieldTypes.F_DRAG_ELEMENT&&s.properties.layers[i].fields[p].type===m.FieldTypes.F_DRAG_ELEMENT||f===m.FieldTypes.F_DRAG_SAMPLE&&s.properties.layers[i].fields[p].type===m.FieldTypes.F_DRAG_SAMPLE||f===m.FieldTypes.F_DRAG_MOLECULE&&s.properties.layers[i].fields[p].type===m.FieldTypes.F_DRAG_MOLECULE||f===m.FieldTypes.F_DATETIME)&&typeof h<"u"&&(n.layers[i].fields[u].value=h),f===m.FieldTypes.F_SYSTEM_DEFINED){const b=m.genUnits(n.layers[i].fields[u].option_layers),x=b.find(j=>j.key===s.properties.layers[i].fields[p].value_system);n.layers[i].fields[u].value_system=x&&x.key||b[0].key,h&&(n.layers[i].fields[u].value=gr(h))}if(f===m.FieldTypes.F_INPUT_GROUP)if(s.properties.layers[i].fields[p].type!==f)n.layers[i].fields[u].value=void 0;else{const b=n.layers[i].fields[u].sub_fields||[],x=s.properties.layers[i].fields[p].sub_fields||[],j=[];b.length<1?n.layers[i].fields[u].value=void 0:b.forEach(C=>{const T=x.find(S=>S.id===C.id)||{};if(C.type===m.FieldTypes.F_LABEL&&j.push(C),C.type===m.FieldTypes.F_TEXT&&(T.type===m.FieldTypes.F_LABEL?j.push(C):j.push({...C,value:(T.value||"").toString()})),[m.FieldTypes.F_NUMBER,m.FieldTypes.F_SYSTEM_DEFINED].includes(C.type)){const S=typeof T.value>"u"||T.value==null||T.value.length===0?"":gr(T.value);C.option_layers===T.option_layers?j.push({...C,value:S,value_system:T.value_system}):j.push({...C,value:S})}}),n.layers[i].fields[u].sub_fields=j}f===m.FieldTypes.F_UPLOAD&&(s.properties.layers[i].fields[p].type===f?n.layers[i].fields[u].value=s.properties.layers[i].fields[p].value:n.layers[i].fields[u].value={}),f===m.FieldTypes.F_TABLE&&(s.properties.layers[i].fields[p].type!==f?n.layers[i].fields[u].sub_values=[]:n.layers[i].fields[u].sub_values=ac(n.layers[i].fields[u],s.properties.layers[i].fields[p]))}})}),[s.properties,n]},dc=(s,t)=>{let n=t,r=!1;if(s&&s.properties&&t&&t.properties){const a=s.properties.layers,o=Object.keys(a).filter(d=>d.startsWith(w.SYS_REACTION));o.length>0&&(r=!0,n=X(t),o.forEach(d=>{n.properties.layers[d]=a[d]}))}return[r,n]},cc=(s,t)=>{const n={Element:on,Segment:li,default:ii},r=n[t]||n.default;return{...s,fields:s.fields.map(i=>{if(!r.some(a=>a.value===i.type)){const{option_layers:a,...o}=i;return{...o,type:m.FieldTypes.F_TEXT,text_sub_fields:[],sub_fields:[]}}return i})}},uc=(s,t)=>{const n=[],r=s?.properties_template?.layers||{};return Object.keys(r).forEach(i=>{(r[i]?.fields||[]).forEach(d=>{d.type===m.FieldTypes.F_SELECT&&d.option_layers===t&&(delete d.option_layers,n.push([i,d.field]))})}),n},Ls=(s,t)=>{if(!t||t.length===0)return;const n=s?.properties_template?.layers||{},r=s?.metadata||{},i=new Set(t.map(([o,d])=>`${o}.${d}`));Object.keys(n).forEach(o=>{const d=n[o];d.cond_fields&&Array.isArray(d.cond_fields)&&(d.cond_fields=d.cond_fields.filter(u=>{const p=`${u.layer}.${u.field}`;return!i.has(p)}),d.cond_fields.length===0&&(delete d.cond_fields,delete d.cond_operator)),d.fields&&Array.isArray(d.fields)&&d.fields.forEach(u=>{u.cond_fields&&Array.isArray(u.cond_fields)&&(u.cond_fields=u.cond_fields.filter(p=>{const f=`${p.layer}.${p.field}`;return!i.has(f)}),u.cond_fields.length===0&&(delete u.cond_fields,delete u.cond_operator))})});const a=r?.restrict||{};Object.keys(a).forEach(o=>{const d=a[o];d.cond&&Array.isArray(d.cond)&&(d.cond=d.cond.filter(u=>{const p=`${u.layer}.${u.field}`;return!i.has(p)}),d.cond.length===0&&delete a[o])}),Object.keys(a).length===0&&delete r.restrict},pc=(s,t,n)=>{const r=s?.properties_template?.layers||{},i=s?.metadata||{},a=[];if(Object.keys(r).forEach(u=>{(r[u]?.fields||[]).forEach(h=>{h.type===m.FieldTypes.F_SELECT&&h.option_layers===t&&a.push([u,h.field])})}),a.length===0)return;const o=new Set(a.map(([u,p])=>`${u}.${p}`));Object.keys(r).forEach(u=>{const p=r[u];p.cond_fields&&Array.isArray(p.cond_fields)&&(p.cond_fields=p.cond_fields.filter(f=>{const h=`${f.layer}.${f.field}`;return!(o.has(h)&&f.value===n)}),p.cond_fields.length===0&&(delete p.cond_fields,delete p.cond_operator))});const d=i?.restrict||{};Object.keys(d).forEach(u=>{const p=d[u];p.cond&&Array.isArray(p.cond)&&(p.cond=p.cond.filter(f=>{const h=`${f.layer}.${f.field}`;return!(o.has(h)&&f.value===n)}),p.cond.length===0&&delete d[u])}),Object.keys(d).length===0&&delete i.restrict},fc=(s,t)=>{const n=s?.properties_template?.layers||{},r=s?.metadata||{};Object.keys(n).forEach(a=>{const o=n[a];o.cond_fields&&Array.isArray(o.cond_fields)&&(o.cond_fields=o.cond_fields.filter(d=>d.layer!==t),o.cond_fields.length===0&&(delete o.cond_fields,delete o.cond_operator))});const i=r?.restrict||{};Object.keys(i).forEach(a=>{const o=i[a];o.cond&&Array.isArray(o.cond)&&(o.cond=o.cond.filter(d=>d.layer!==t),o.cond.length===0&&delete i[a])}),Object.keys(i).length===0&&delete r.restrict},hc=(s,t)=>{const n=s?.metadata||{},r=n?.groups||[],i=n?.restrict||{},a=[];r.forEach(o=>{if(o.layers&&Array.isArray(o.layers)){const d=o.layers.indexOf(t);d!==-1&&o.layers.splice(d,1),o.layers.length===0&&a.push(o.id)}}),n.groups=r.filter(o=>o.layers&&o.layers.length>0),a.forEach(o=>{i[o]&&delete i[o]}),n.groups.length===0&&(delete n.groups,delete n.restrict)},mc="http://json-schema.org/draft-07/schema#",yc="urn:labimotion:schemas:property-base",gc="Property Base Schema",xc="Base schema for properties with package, layers, and select options references.",bc="object",_c={pkg:{$ref:"urn:labimotion:schemas:package"},uuid:{type:"string"},klass:{type:"string",enum:["Element","Segment","Dataset","Layer","Vocabulary","ElementKlass","SegmentKlass","DatasetKlass"]},layers:{$ref:"urn:labimotion:schemas:layers"},version:{type:"string"},identifier:{type:"string"},released_at:{type:"string"},select_options:{$ref:"urn:labimotion:schemas:select-options"},metadata:{$ref:"urn:labimotion:schemas:metadata"}},jc=["pkg","uuid","klass","layers","version","identifier"],vc=!0,Ec={$schema:mc,$id:yc,title:gc,description:xc,type:bc,properties:_c,required:jc,additionalProperties:vc},Tc="http://json-schema.org/draft-07/schema#",Cc="urn:labimotion:schemas:package",Sc="Package Configuration Schema",wc="Schema for package configuration including LabIMotion and compatible ELN version information.",Rc="object",Fc={eln:{type:"object",required:["version","base_revision","current_revision"],properties:{version:{type:"string",description:"ELN version"},base_revision:{type:["string","null"],description:"Base revision hash"},current_revision:{type:["string","null"],description:"Current revision hash"}},additionalProperties:!0},name:{const:"chem-generic-ui",description:"Package name"},version:{type:"string",description:"Package version"},labimotion:{type:"string",description:"LabIMotion version compatibility"}},Nc=["eln","name","version","labimotion"],kc=!0,Lc={$schema:Tc,$id:Cc,title:Sc,description:wc,type:Rc,properties:Fc,required:Nc,additionalProperties:kc},Ac="http://json-schema.org/draft-07/schema#",Ic="urn:labimotion:schemas:layers",Dc="Layers Schema",Oc="Schema for layers configuration with field references.",Pc="object",Gc={type:"string"},Mc=0,$c={"^.*$":{type:"object",properties:{wf:{type:"boolean",default:!1},key:{type:"string"},cols:{type:"integer",default:1},color:{type:"string",enum:["none","warning","primary","info","danger","success","default"],default:"default"},label:{type:"string"},label_fields:{type:"array",items:{type:"string"}},style:{type:"string",enum:["panel_generic_heading","panel_generic_heading_bu","panel_generic_heading_bui"],default:"panel_generic_heading"},position:{type:"integer",default:-1},wf_position:{type:"integer"},wf_uuid:{type:["string","null"]},fields:{type:"array",items:{allOf:[{$ref:"urn:labimotion:schemas:field-base"},{type:"object",properties:{value:{type:["string","number","boolean","null"]},hasOwnRow:{type:"boolean"},description:{type:"string"}}}]}}},required:["key","cols","color","position"],additionalProperties:!0}},qc=!1,Bc={$schema:Ac,$id:Ic,title:Dc,description:Oc,type:Pc,propertyNames:Gc,minProperties:Mc,patternProperties:$c,additionalProperties:qc},Uc="http://json-schema.org/draft-07/schema#",Vc="urn:labimotion:schemas:select-options",zc="Select Options Configuration Schema",Yc="Schema for dynamic select options configuration with key-label pairs.",Hc="object",Wc={"^.*$":{type:"object",properties:{options:{type:"array",items:{type:"object",properties:{key:{type:"string"},label:{type:"string"}},required:["key","label"],additionalProperties:!1}}},additionalProperties:!1}},Kc=!1,Xc={$schema:Uc,$id:Vc,title:zc,description:Yc,type:Hc,patternProperties:Wc,additionalProperties:Kc},Zc="http://json-schema.org/draft-07/schema#",Qc="urn:labimotion:schemas:field-base",Jc="Field Base Schema",eu="Base schema for dynamic field definitions with valid field types from FieldTypes enum.",tu="object",su={cols:{type:"integer"},type:{type:"string",enum:["checkbox","date","datetime","datetime-range","drag","drag_element","drag_molecule","drag_sample","drag_reaction","dummy","formula-field","input-group","integer","label","number","ontology-select","select","select-multi","sys-reaction","system-defined","table","text","textarea","text-formula","upload","wf-next"]},field:{type:"string"},label:{type:"string"},default:{type:"string"},position:{type:"integer"},required:{type:"boolean",default:!1},cond_operator:{type:"integer",default:1},cond_fields:{type:"array",items:{type:"object",properties:{id:{type:"string"},field:{type:"string"},layer:{type:"string"},value:{type:["string","number","boolean","null"]},label:{type:["string","null"]}},required:["id","field","layer","value"],additionalProperties:!1}},sub_fields:{type:"array",items:{type:"object"}},option_layers:{type:"string"},text_sub_fields:{type:"array",items:{type:"object"}}},nu=["type","field"],ru=!0,iu={$schema:Zc,$id:Qc,title:Jc,description:eu,type:tu,properties:su,required:nu,additionalProperties:ru},lu="http://json-schema.org/draft-07/schema#",au="urn:labimotion:schemas:system-unit",ou="System Unit Schema",du="Schema for system-defined unit fields with measurable quantities.",cu="object",uu={type:{const:"system-defined"},measurable_quantity:{type:"string"},unit:{type:"string"},values:{type:"array",items:{anyOf:[{type:"number"},{type:"string"}]}}},pu=["type","measurable_quantity"],rl={$schema:lu,$id:au,title:ou,description:du,type:cu,properties:uu,required:pu},fu="http://json-schema.org/draft-07/schema#",hu="urn:labimotion:schemas:metadata",mu="Metadata Schema",yu="Schema for metadata configuration with groups and restrictions.",gu="object",xu={groups:{type:"array",items:{type:"object",properties:{id:{type:"string"},label:{type:"string"},position:{type:"integer"},layers:{type:"array",items:{type:"string"}}},required:["id","label","position","layers"]}},restrict:{type:["object","null"],patternProperties:{"^.*$":{type:"object",properties:{op:{type:"integer"},cond:{type:"array",items:{type:"object",properties:{id:{type:"string"},field:{type:"string"},layer:{type:"string"},value:{type:["string","number","boolean","null"]}},required:["id","field","layer","value"]}}},required:["op","cond"]}}}},bu={restrict:["groups"]},_u=!1,ju={$schema:fu,$id:hu,title:mu,description:yu,type:gu,properties:xu,dependencies:bu,additionalProperties:_u},rt=new Vr({allErrors:!0,allowUnionTypes:!0,useDefaults:!0,verbose:!0,strict:!1});rt.addSchema(Lc);rt.addSchema(Bc);rt.addSchema(Xc);rt.addSchema(iu);rt.addSchema(rl);rt.addSchema(ju);const Or=rt.compile(Ec),vu=s=>{if(!s||typeof s!="object")return{valid:!1,errors:[{message:"Properties must be a valid object"}]};const t=Or(s);return{valid:t,errors:t?[]:Or.errors||[]}},yt=(s,t,n={})=>{const r=new ee(s,t);return r.additional=n,r},at=(s,t,n)=>{const r=new ee(s,t);return r.layerKey=n,r},Eu=(s,t)=>{const[n,r]=[t,s],i=qs(r);if(!i.isSuccess)return at(i,n,r.key);if(n&&n.properties_template&&n.properties_template.layers[`${r.key}`])return at(te("This Layer is already taken. Please choose another one.",`Layer [${r.key}]`),n,r.key);(r.position===void 0||r.position===null)&&(r.position=-1),r.timeRecord="",n.properties_template.layers[`${r.key}`]=r;const a=et(n.properties_template.layers,n.metadata||{});return n.properties_template.layers=a.layers,a.metadata&&Object.keys(a.metadata).length>0&&(n.metadata=a.metadata),at(se(["The new layer has been added.","Remember to save once you've finished editing."].join(" "),`Layer [${r.key}]`),n,r.key)},Tu=(s,t,n)=>{const[r,i,a]=[t,s,n],o=qs(i);if(!o.isSuccess)return at(o,r,i.key);const d=cc(i,a),u=d.select_options||{};delete d.select_options;const p=d.key;return r?.properties_template?.layers[p]?at(te("This Layer is already exist. Please choose another one.",`Layer [${d.key}]`),r,d.key):(d.position=1,d.timeRecord="",r.properties_template.layers[`${d.key}`]=d,r.properties_template?.select_options?r.properties_template.select_options=Gn(u,r.properties_template.select_options):r.properties_template.select_options=u,Object.keys(r.properties_template?.select_options||{}).length===0&&delete r.properties_template.select_options,at(se(["A Standard Layer has been added into the template.","Remember to save once you've finished editing."].join(" "),`Layer [${d.key}]`),r,d.key))},Cu=(s,t,n)=>{const[r,i,a]=[s,t,n];let o=qs(a,"upd");if(!o.isSuccess)return new ee(o,r);if(o=ja(r,a),!o.isSuccess)return new ee(o,r);let d=r?.properties_template?.layers[i];const u=["The layer has been updated.","Remember to save once you've finished editing."];return d={...d,...a},d.wf&&(u.push("For a Workflow layer, the Field Restrict Setting is only applicable on its own layer."),(d.fields||[]).map(p=>{const f=p;return f.cond_fields&&f.cond_fields.length>0&&(f.cond_fields=p.cond_fields.filter(h=>h.layer===d.key),f.cond_fields.length<1&&delete f.cond_fields),f})),d.position=d.position!==void 0&&d.position!==null?parseInt(d.position,10):0,r.properties_template.layers[`${d.key}`]=d,new ee(se(u.join(" ")),r)},Su=(s,t,n,r)=>{const i=r;let a=[];if(s===m.FieldTypes.DEL_SELECT){delete i.properties_template.select_options[t],a=Object.keys(i.properties_template.select_options).map(u=>({value:u,name:u,label:u}));const d=uc(i,t);Ls(i,d)}if(s===m.FieldTypes.DEL_OPTION){const{options:d}=i.properties_template.select_options[n];if(d&&d.length>0){const u=d.findIndex(p=>p.key===t);u!==-1&&d.splice(u,1)}pc(i,n,t)}if(s===m.FieldTypes.DEL_LAYER){const d=_a(i,t);if(!d.isSuccess){const u=new ee(d,i);return u.selectOptions=[],u}delete i.properties_template.layers[t],fc(i,t),hc(i,t)}if(s===m.FieldTypes.DEL_FIELD){const d=i.properties_template.layers[n],{fields:u}=d,p=u.findIndex(f=>f.field===t);p!==-1&&u.splice(p,1),d.label_fields&&Array.isArray(d.label_fields)&&(d.label_fields=Rs(d.label_fields,t)),Ls(i,[[n,t]])}const o=new ee(se(),i);return o.selectOptions=a,o},il=(s,t,n)=>{const[r,i,a]=[s,t,n],o=r?.properties_template?.layers[i];let{fields:d}=o||{};d=d||[];let u=d.findIndex(p=>p.field===a);return u===-1&&d.length>0&&(u=d.length-1),d.splice(u+1,0,new no),r.properties_template.layers[i].fields=d,new ee(ya(),r)},wu=(s,t,n)=>{const[r,i,a]=[s,t,n],o=va(r,i);if(o.isSuccess){r.properties_template.select_options=a;const d=Object.keys(a).map(u=>({value:u,name:u,label:u}));return yt(o,r,{selectOptions:d})}return yt(o,r,{selectOptions:a})},Ru=(s,t,n,r)=>{const[i,a,o,d]=[s,t,n,r],u=Ea(o,d);return u.isSuccess&&(i.properties_template.select_options[a].options=d),yt(u,i)},Fu=(s,t,n,r)=>{const[i,a,o,d]=[s,t,n,r],u=i?.properties_template?.select_options[o]?.options||[],p=Ie(u,h=>h.key===a),f={};return f.key=a,f.label=d,u.splice(p,1,f),new ee(se(),i)},Nu=(s,t,n,r,i,a,o)=>{const[d,u,p,f,h,y,b]=[s,t,n,r,i,a,o];let x="";[m.FieldTypes.F_SELECT,m.FieldTypes.F_SYSTEM_DEFINED,m.FieldTypes.F_SELECT_MULTI].includes(b)?{value:x}=u:b?.startsWith(m.FieldTypes.F_DRAG)?x=u:{value:x}=u.target;const j=d?.properties_template?.layers[h];if(typeof j>"u"||j==null)return{notify:te("Layer is undefined"),element:d};const{fields:C}=j;if(C==null||C.length===0)return{notify:te("Layer has no fields"),element:d};const T=C.find(v=>v.field===f);if(!T||Object.keys(T||{}).length===0)return{notify:te("Field is undefined"),element:d};switch(y){case"required":case"hasOwnRow":case"canAdjust":T[`${y}`]=!p;break;case"readonly":{T[`${y}`]=!p,b===m.FieldTypes.F_TEXT&&T[`${y}`]===!0&&j?.label_fields?.length>0&&(j.label_fields=Rs(j.label_fields,f));break}case"ontology":x?T[`${y}`]=x:delete T[`${y}`];break;case"option_layers":if(T[`${y}`]=x,b===m.FieldTypes.F_SYSTEM_DEFINED){const v=m.reUnit(x);T[`${y}`]=v;const E=m.genUnits(v)[0]?.key;T.value_system=E}break;case"type":{if(T[`${y}`]=x,x===m.FieldTypes.F_SYSTEM_DEFINED){const v=m.reUnit("");T.option_layers=v,T.value_system=m.genUnits(v)[0]?.key}else T.option_layers=void 0,T.value_system=void 0,T.sub_fields=void 0;j?.label_fields?.length>0&&(j.label_fields=Rs(j.label_fields,f)),Ls(d,[[h,f]]);break}case"value_system":x&&(T[`${y}`]=x);break;default:T[`${y}`]=x;break}const S=Ie(C,v=>v.field===f);return C.splice(S,1,T),d.properties_template.layers[h].fields=C,new ee(se(),d)},ku=(s,t)=>{const r=s.target.result;let i={};try{return i=JSON.parse(r),i.klass.endsWith(`${t}Klass`)?vu(i).valid?new ee(se(),i):new ee(Xe("set01",br("si00")),i):new ee(Xe("set00",["You are attempting to update a template",`from [${i.klass}] to [${t}Klass]`].join(" ")),i)}catch{return new ee(Xe("set02",br("si00")),i)}},Lu=(s,t)=>{const n=`${t}Klass`,i=s.target.result;let a={};try{a=JSON.parse(i);const o=a?.properties_template?.klass;if(!o||typeof o!="string"||o.length===0||!o.endsWith(n))return new ee(te(["The template upload has failed.",`You are attempting to upload a ${t}`,`from [${o}] to [${n}]`].join(" ")),a);const d={label:a?.label?.trim(),desc:a?.desc?.trim(),name:a?.name?.trim(),klass_prefix:a?.klass_prefix?.trim(),icon_name:a?.icon_name?.trim(),klass_element:a?.element_klass?.id},u=w.GENERIC_TYPES.SEGMENT===n?Pt(d):Ot(d);return new ee(u,a)}catch(o){return new ee(te(`Error Format: ${o}`),a)}},Wt={BUTTON:"button",MENU:"menu"},Au=new Set(Object.entries(m.FieldTypes).filter(([s])=>s.startsWith("DEL_")).map(([,s])=>s)),Iu={[m.FieldTypes.DEL_SELECT]:{label:"this select option",hasRoot:!1},[m.FieldTypes.DEL_OPTION]:{label:"this option",hasRoot:!0,rootLabel:"select"},[m.FieldTypes.DEL_LAYER]:{label:"this layer",hasRoot:!1},[m.FieldTypes.DEL_FIELD]:{label:"this field",hasRoot:!0,rootLabel:"layer"}};function Du(s,t,n){const r=Iu[s];if(!r)return`remove ???: ${s}`;let i=`Removing ${r.label} will remove it from layer display name, restrictions, etc., if used. Continue with removing:`;return m.FieldTypes.DEL_FIELD!==s&&(i=i.replace("layer display name, ","")),r.hasRoot?`${i} ${r.label.replace("this ","")} [${t}] from ${r.rootLabel} [${n}] ?`:`${i} [${t}] ?`}function Pr({generic:s,delType:t,delKey:n,delRoot:r,fnConfirm:i}){const a=Su(t,n,r,s);i(a)}function wt(s){const{generic:t,delType:n,delKey:r,delRoot:i,fnConfirm:a,as:o}=s;if(!Au.has(n))return null;const d=Du(n,r,i),u={generic:t,delType:n,delKey:r,delRoot:i,fnConfirm:a};return o===Wt.MENU?e.jsxs(c.Dropdown.Item,{eventKey:"_del_menu_item",onClick:()=>Pr(u),className:"gu-menu-item-del",children:[I.faTrashCan,"  ",d]}):e.jsx(Qe,{msg:d,fnClick:Pr,fnParams:u})}wt.propTypes={generic:l.object.isRequired,delType:l.string.isRequired,delKey:l.string,delRoot:l.string,fnConfirm:l.func.isRequired,as:l.oneOf([Wt.BUTTON,Wt.MENU])};wt.defaultProps={delKey:"",delRoot:"",as:Wt.BUTTON};const Mn=({children:s,condSet:t})=>{const[,n]=g.useState(!1),[,r]=g.useState(!1),i=(a,o)=>{o.stopPropagation(),r(!1),n(!1),a.props.onClick&&a.props.onClick(o)};return e.jsx(e.Fragment,{children:e.jsx(c.DropdownButton,{variant:t?"warning":"default",title:I.faEllipsis,as:c.ButtonGroup,className:"ug-no-caret",id:"dropdown-no-caret",onClick:a=>a.stopPropagation(),onToggle:a=>r(a),children:g.Children.map(s,a=>a.type!==c.Dropdown.Divider?g.cloneElement(a,{onClick:o=>i(a,o)}):a)})})};Mn.propTypes={children:l.node.isRequired,condSet:l.bool.isRequired};class $n extends g.Component{constructor(t){super(t),this.state={parentIsExpanded:t.parentExpand,expandLayers:{}},this.handleChange=this.handleChange.bind(this),this.handleMove=this.handleMove.bind(this),this.handleOntChange=this.handleOntChange.bind(this),this.handleUnitChange=this.handleUnitChange.bind(this),this.handleAddDummy=this.handleAddDummy.bind(this),this.handleAddVoc=this.handleAddVoc.bind(this),this.updSubField=this.updSubField.bind(this),this.handleDrop=this.handleDrop.bind(this),this.toggleExpandLayer=this.toggleExpandLayer.bind(this)}componentDidUpdate(t){const{parentExpand:n}=this.props;t.parentExpand!==n&&this.setState({parentIsExpanded:n})}handleDrop=t=>{const{onMove:n}=this.props,{source:r,target:i,rid:a}=t;n.onPosition(a.key,i,r.fid)};handleChange(t,n,r,i,a,o){if([m.FieldTypes.F_SELECT,m.FieldTypes.F_SYSTEM_DEFINED,m.FieldTypes.F_SELECT_MULTI].includes(o)&&t===null)return;const{onChange:d}=this.props,u=t;a==="decimal"&&(u.target.value=Hr(t.target.value)||5),d(u,n,r,i,a,o)}handleMove(t){const{onMove:n}=this.props,{l:r,f:i,isUp:a}=t;n.onField(r,i,a)}handleOntChange(t){const{field:n,layer:r}=this.props;this.handleChange({value:t?.data},n.field,n.field,r.key,"ontology",m.FieldTypes.F_SELECT)}handleUnitChange(t){const{field:n,layer:r}=this.props;this.handleChange({value:t?.data},n.field,n.field,r.key,"value_system",m.FieldTypes.F_SYSTEM_DEFINED)}handleAddDummy(t){const{onDummyAdd:n}=this.props;n(t)}handleAddVoc(t){this.handleChange(t)}toggleExpandLayer=t=>{this.setState(n=>({expandLayers:{...n.expandLayers,[t]:!n.expandLayers[t]}}))};updSubField(t,n,r){const{onFieldSubFieldChange:i}=this.props;i(t,n,r)}availableUnits(t){const{unitsSystem:n}=this.props,r=n.find(o=>o.field===t);if(r===void 0)return null;const i=r.units.map(o=>e.jsxs("div",{children:[st(o.label),e.jsx("br",{})]},ie.v4())),a=e.jsxs(c.Popover,{id:"popover-positioned-scrolling-left",children:[e.jsx(c.Popover.Header,{as:"h3",children:"Available units"}),e.jsx(c.Popover.Body,{children:i})]});return e.jsx(c.OverlayTrigger,{animation:!0,placement:"top",root:!0,trigger:["hover","focus","click"],overlay:a,children:e.jsx(c.Button,{variant:"success",size:"sm",children:I.faTableCells})})}renderComponent(){const{unitsSystem:t,field:n,layer:r,layerKey:i,genericType:a,allLayers:o,select_options:d,position:u,generic:p,onDelete:f,vocabularies:h}=this.props,{parentIsExpanded:y,expandLayers:b}=this.state,x=y&&(b[i]||!1),C=(p?.metadata||{}).groups||[],T=C.flatMap(Y=>Y.layers||[]),v=C.find(Y=>(Y.layers||[]).includes(i))?.layers||null,E=t.map(Y=>({value:Y.field,name:Y.label,label:Y.label}));let _=ii;a==="Element"?_=on:a==="Segment"&&(_=li),_.sort((Y,B)=>Y.label.localeCompare(B.label));const R=n,F=Object.keys(d||{}).map(Y=>({value:Y,name:Y,label:Y})),D=[m.FieldTypes.F_SELECT,m.FieldTypes.F_SELECT_MULTI].includes(R.type)?F:E,L=D?.find(Y=>Y.value===R.option_layers)||null,P=[m.FieldTypes.F_SYSTEM_DEFINED,m.FieldTypes.F_SELECT,m.FieldTypes.F_SELECT_MULTI].includes(R.type)?e.jsxs(e.Fragment,{children:[e.jsxs(c.Form.Group,{as:c.Col,children:[[m.FieldTypes.F_SELECT,m.FieldTypes.F_SELECT_MULTI].includes(R.type)?e.jsx(Ee,{children:e.jsxs(e.Fragment,{children:[me("options").label," ",me("options").fieldTooltip]})}):e.jsx(Ee,{children:e.jsx(e.Fragment,{children:me("si").label})}),e.jsx("div",{style:{display:"flex"},children:e.jsx("span",{style:{width:"100%"},children:e.jsx(Ue,{styles:Ye,name:R.field,multi:!1,options:D,value:L,onChange:Y=>this.handleChange(Y,R.option_layers,R.field,i,"option_layers",R.type),menuPlacement:"auto",menuPortalTarget:document.body})})})]}),[m.FieldTypes.F_SELECT,m.FieldTypes.F_SELECT_MULTI].includes(R.type)?null:e.jsx(c.Form.Group,{as:c.Col,xs:2,children:e.jsx(sl,{fObj:R,fnUnitChange:this.handleUnitChange})})]}):null,G=[m.FieldTypes.F_INPUT_GROUP].includes(R.type)?e.jsx(c.Row,{className:"mb-1",children:e.jsx(c.Form.Group,{as:c.Col,children:e.jsx(Xi,{layerKey:i,field:R,updSub:this.updSubField,unitsFields:t,panelIsExpanded:x})})}):null,k=[m.FieldTypes.F_TABLE].includes(R.type)?e.jsx(c.Row,{className:"mb-1",children:e.jsxs(c.Form.Group,{as:c.Col,children:[e.jsx(Pd,{genericType:a,layerKey:i,field:R,updSub:this.updSubField,unitsFields:t,selectOptions:F,panelIsExpanded:x}),e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Tables per row"}),e.jsxs(c.Form.Control,{name:`frmPerRow_${r.key}_f_${n.field}`,as:"select",defaultValue:R.cols||1,onChange:Y=>this.handleChange(Y,R.cols,R.field,i,"cols",R.cols),children:[e.jsx("option",{value:1,children:"1"}),e.jsx("option",{value:2,children:"2"})]})]})]})}):null,U=[m.FieldTypes.F_TEXT_FORMULA].includes(R.type)?e.jsx(c.Row,{className:"mb-1",children:e.jsx(c.Form.Group,{as:c.Col,children:e.jsx(Dn,{layerKey:i,field:R,updSub:this.updSubField,allLayers:o,panelIsExpanded:x})})}):null,N=e.jsxs("span",{className:"flex-grow-1",children:[e.jsxs("span",{className:"fw-bold",children:[u," ",[m.FieldTypes.F_DUMMY].includes(R.type)?"(dummy field)":R.label]}),e.jsx(lt,{fieldObj:R,prop:"field"}),zd(n.ontology,"!link"),e.jsx(lt,{fieldObj:R,prop:"type"}),e.jsx(lt,{fieldObj:R,prop:"cols"})]}),A=e.jsxs("div",{onClick:Y=>Y.stopPropagation(),children:[a!==w.GENERIC_TYPES.DATASET&&e.jsx(c.ButtonGroup,{className:"me-2",children:e.jsx(Bd,{field:n,data:p,layer:r,genericType:a})}),e.jsxs(c.ButtonGroup,{children:[e.jsx(ue,{idf:"mv_up",fnClick:this.handleMove,element:{l:i,f:R.field,isUp:!0},fa:"faArrowUp",place:"top",disabled:u===1}),e.jsx(ue,{idf:"mv_down",fnClick:this.handleMove,element:{l:i,f:R.field,isUp:!1},fa:"faArrowDown",place:"top"}),e.jsx(Pn,{field:R,fnUpdateSub:this.updSubField,layer:r,sortedLayers:o,groupedLayerKeys:T,sameGroupLayerKeys:v,selectOptions:d||{},as:"button",disabled:!1}),e.jsxs(Mn,{condSet:!1,children:[e.jsx(ue,{idf:"fld_dum_add",fnClick:this.handleAddDummy,element:{layerKey:i,field:R.field},fa:"faSquare",place:"top",as:"menu"}),e.jsx(c.Dropdown.Divider,{}),e.jsx(wt,{delType:m.FieldTypes.DEL_FIELD,delKey:R.field,delRoot:i,generic:p,fnConfirm:f,as:"menu"})]})]})]});`${ks.LAYER_FIELD}${r.key}`,R.field,r.key,`${ks.LAYER_FIELD}${R.field}${r.key}`;const q=e.jsxs(e.Fragment,{children:[N,A]});return e.jsx("div",{children:e.jsx(c.Card,{className:"border-0 gu-square-corners",children:e.jsx(c.Card.Body,{className:"p-0",children:e.jsx(_t,{layerKey:`${R.field}_${i}`,toggleExpand:this.toggleExpandLayer,propHeader:q,children:e.jsxs(c.Form,{children:[e.jsxs(c.Row,{className:"mb-1",children:[Qd({layer:r,fieldObject:n,field:"field",fnChange:this.handleChange,fnOntChange:this.handleOntChange}),Dt({layer:r,fieldObject:n,field:"label",fnChange:this.handleChange}),Zd({fieldObject:n})]}),e.jsxs(c.Row,{className:"mb-1",children:[Dt({layer:r,fieldObject:n,field:"description",fnChange:this.handleChange,xs:6}),Jd({layer:r,fieldObject:n,field:"cols",fnChange:this.handleChange}),tc({layer:r,fieldObject:n,fnChange:this.handleChange})]}),e.jsx(c.Row,{className:"mb-1",children:rc({layer:r,fieldObject:n,fnChange:this.handleChange,typeOpts:_,xs:([m.FieldTypes.F_SELECT,m.FieldTypes.F_SYSTEM_DEFINED,m.FieldTypes.F_SELECT_MULTI].includes(R.type),void 0)})}),[m.FieldTypes.F_SELECT,m.FieldTypes.F_SYSTEM_DEFINED,m.FieldTypes.F_SELECT_MULTI].includes(R.type)&&e.jsx(c.Row,{className:"mb-1",children:P}),[m.FieldTypes.F_FORMULA_FIELD].includes(R.type)?e.jsxs(c.Row,{className:"mb-1",children:[Dt({layer:r,fieldObject:n,field:"formula",fnChange:this.handleChange,xs:8}),ic({layer:r,fieldObject:n,field:"decimal",fnChange:this.handleChange,xs:2}),ec({layer:r,fieldObject:n,fnChange:this.handleChange,xs:2})]}):null,G,k,U,[m.FieldTypes.F_INTEGER,m.FieldTypes.F_TEXT].includes(R.type)&&e.jsxs(e.Fragment,{children:[e.jsx(c.Row,{className:"mb-1",children:Dt({layer:r,fieldObject:n,field:"placeholder",fnChange:this.handleChange,xs:void 0})}),e.jsxs(c.Row,{className:"mb-1",children:[nc({layer:r,fieldObject:n,fnChange:this.handleChange}),["Element"].includes(a)?sc({layer:r,fieldObject:n,fnChange:this.handleChange,xs:6}):Xd()]})]})]})},`_prop_content_${R.field}_${i}`)})})})}render(){return e.jsx(c.Col,{md:12,className:"ps-0",children:this.renderComponent()})}}$n.propTypes={genericType:l.string,layer:l.object.isRequired,layerKey:l.string.isRequired,select_options:l.object,position:l.number.isRequired,field:l.object.isRequired,onMove:l.shape({onField:l.func.isRequired,onPosition:l.func.isRequired}).isRequired,onDelete:l.func.isRequired,onChange:l.func.isRequired,unitsSystem:l.array,onFieldSubFieldChange:l.func.isRequired,onDummyAdd:l.func.isRequired,vocabularies:l.array,parentExpand:l.bool};$n.defaultProps={genericType:"Element",unitsSystem:[],vocabularies:[],parentExpand:!1,select_options:{}};const Ou=(s,t,n={})=>{const r=new ee(s,t);return r.additional=n,r},Pu=(s,t,n,r=()=>{})=>{const[i,a,o]=[s,t,n,r],d=i?.properties_template?.layers[a],{fields:u}=d;if(d!=null){const p=(u||[]).find(f=>f.field===o.field);if(p&&Object.keys(p||{}).length>0){const f=(u||[]).findIndex(h=>h.field===o.field);u.splice(f,1,o),i.properties_template.layers[a].fields=u}}return Ou(se(),i,{fieldObj:o,layerKey:a})},Gu=s=>s.map((n,r)=>({...n,position:r+1})),Mu=(s,t,n)=>{const[r,i,a]=[s,t,n],o=i.fields||[],d=Ps(o,f=>f.field===a.name);if(d&&d.length>0)return new ee(Ke(!1,`Field (${a.name}) ${a.label} is already exist.`),r);const u=a.properties?.select_options||{},p={is_voc:!0,identifier:a.identifier,type:a.field_type,ontology:a.ontology,field:a.name,position:100,label:a.label,default:""};return a.opid&&(p.opid=a.opid),a.source&&(p.source=a.source),a.source_id&&(p.source_id=a.source_id),a.layer_id&&(p.layer_id=a.layer_id),a.field_id&&(p.field_id=a.field_id),a.properties?.option_layers&&(p.option_layers=a.properties?.option_layers),o.push(p),r.properties_template.layers[i.key].fields=o,r.properties_template?.select_options?r.properties_template.select_options=Gn(u,r.properties_template.select_options):r.properties_template.select_options=u,Object.keys(r.properties_template?.select_options||{}).length===0&&delete r.properties_template.select_options,new ee(Ke(!0,"New field (from Lab-Voc) has been added successfully."),r)},$u=(s,t,n)=>{const[r,i,a]=[s,t,n],o=ba(r);if(!o.isSuccess)return new ee(o,i);const d=a.fields||[],u=Ps(d,f=>f.field===r);if(u&&u.length>0)return new ee(Ke(!1,`Field [${r}] is already in use, please choose a different field name.`),i);const p={type:m.FieldTypes.F_TEXT,field:r,position:100,label:r,default:""};return d.push(p),i.properties_template.layers[a.key].fields=d,new ee(Ke(!0,`Field [${r}] has been added successfully.`),i)},qu=(s,t,n,r)=>{const[i,a,o,d]=[s,t,n,r],u=i?.properties_template?.layers[a],{fields:p}=u,f=Ie(p,h=>h.field===o);if(f>=0&&d){const h=p[f];h.position-=1;const y=p[f-1];y.position+=1,p[f]=y,p[f-1]=h}else if(f<p.length-1&&!d){const h=p[f];h.position+=1;const y=p[f+1];y.position-=1,p[f]=y,p[f+1]=h}return i.properties_template.layers[a].fields=p,new ee(se(),i)},Bu=(s,t,n,r)=>{const[i,a,o,d]=[s,t,n,r],u=i?.properties_template?.layers[a];if(u){const{fields:p}=u,f=Ie(p,b=>b.field===d.field),h=Ie(p,b=>b.field===o.field);if(f<0||h<0)return new ee(se(),i);const y=p.splice(f,1)[0];return p.splice(h,0,y),i.properties_template.layers[a].fields=Gu(p),new ee(se(),i)}return new ee(se(),i)},qn=s=>{const{generic:t,genericType:n,fnUpdate:r,layer:i,vocabularies:a,parentExpand:o}=s,d=T=>{const{layerKey:S,field:v}=T,E=il(t,S,v);r(E)},u=(T,S,v)=>{const E=qu(t,T,S,v);r(E)},p=T=>{r(T)},f=(T,S,v,E,_,R)=>{const F=Nu(t,T,S,v,E,_,R);r(F)},h=(T,S,v)=>{const E=Pu(t,T,S,v);r(E)},y=(T,S,v)=>{const E=Bu(t,T,S,v);r(E)},b=tt(t.properties_template.layers||{},t.metadata?.groups||[]),x=[];b.forEach(T=>{T.type==="group"?T.layers.forEach(S=>{x.push(S.data)}):x.push(T.data)});const j=t.properties_template?.select_options||{},C=(i?.fields||[]).map((T,S)=>e.jsx($n,{generic:t,genericType:n,layer:i,layerKey:i.key,position:S+1,field:T,select_options:j,onMove:{onField:u,onPosition:y},onDelete:p,onChange:f,unitsSystem:m.getUnitSystem(),onFieldSubFieldChange:h,onDummyAdd:d,allLayers:x,vocabularies:a,parentExpand:o},`_propF_${n}_${i.key}_${T.field}_${S}`));return e.jsx(e.Fragment,{children:C})};qn.propTypes={generic:l.object.isRequired,genericType:l.string.isRequired,fnUpdate:l.func.isRequired,layer:l.object.isRequired,vocabularies:l.array,parentExpand:l.bool};qn.defaultProps={vocabularies:[],parentExpand:!1};const Bn=({fnUpdate:s,layer:t,children:n})=>{const[r,i]=g.useState(""),a=o=>{i(o.target.value)};return e.jsx("div",{onMouseDown:o=>o.stopPropagation(),onClick:o=>o.stopPropagation(),onKeyDown:o=>o.stopPropagation(),role:"button",tabIndex:0,children:e.jsxs(c.InputGroup,{children:[e.jsx(c.Form.Control,{type:"text",name:"field_new",placeholder:"Input new field name",size:"sm",onChange:o=>a(o),onFocus:o=>{o.stopPropagation(),o.preventDefault()},style:{maxWidth:"140px",boxShadow:"none"}}),e.jsx(ue,{idf:"fld_add",fnClick:s,element:{layer:t,newFieldKey:r},fa:"faPlus",place:"top"}),n]})})};Bn.propTypes={fnUpdate:l.func.isRequired,layer:l.object.isRequired,children:l.node};Bn.defaultProps={children:null};const ll=({init:s,layer:t,onChange:n})=>{const{label:r,key:i}=s,{description:a,label:o,key:d}=t;return e.jsxs(c.Row,{children:[e.jsxs(c.Col,{xs:6,children:[e.jsx("h4",{children:"Current Setting"}),e.jsxs(c.Form,{children:[e.jsxs(de,{children:[e.jsx(c.Form.Label,{children:"Name"}),e.jsx(c.Form.Control,{type:"text",value:i,placeholder:"An identifier for the layer, must be unique in Standard Layers.",disabled:!0,readOnly:!0})]}),e.jsxs(de,{children:[e.jsx(c.Form.Label,{children:"Display Name"}),e.jsx(c.Form.Control,{type:"text",value:r,placeholder:"Give a name to display on the UI. Empty is allow.",disabled:!0,readOnly:!0})]}),e.jsxs("div",{style:{fontSize:"12px",display:"flex"},children:[e.jsx("span",{className:"mr-1",children:I.faCircleInfo}),e.jsxs("span",{children:[e.jsx("b",{children:'About "Name"'}),e.jsxs("p",{className:"mb-1",children:["1. The layer name is a unique identifier within"," ",e.jsx("b",{children:"Standard Layers"})," and must be at least 3 characters long."]}),e.jsx("p",{className:"mb-1",children:"2. It should consist only of lowercase letters and underscores, but underscores cannot be placed at the beginning or end."}),e.jsx("p",{className:"mb-1",children:"3. Special characters such as $, !, %, and others are not allowed."})]})]})]})]}),e.jsxs(c.Col,{xs:6,children:[e.jsx("h4",{children:"Please give the below information"}),e.jsxs(c.Form,{children:[e.jsxs(de,{children:[e.jsx(c.Form.Label,{children:"Name"}),e.jsx(c.Form.Control,{required:!0,type:"text",value:d,placeholder:"An identifier for the layer, must be unique in Standard Layers.",onChange:u=>n("key",u.target.value)})]}),e.jsxs(de,{children:[e.jsx(c.Form.Label,{children:"Display Name"}),e.jsx(c.Form.Control,{type:"text",value:o,placeholder:"Give a name to display on the UI. Empty is allow.",disabled:!0,readOnly:!0})]}),e.jsxs(de,{children:[e.jsx(c.Form.Label,{children:"Description"}),e.jsx(c.Form.Control,{as:"textarea",rows:3,value:a,placeholder:"Give a description to describe the usage/purpose.",onChange:u=>n("description",u.target.value)})]}),e.jsxs(de,{children:[e.jsx(c.Form.Label,{children:"Who can use this layer?"}),e.jsxs(c.Form.Check,{type:"radio",children:[e.jsx(c.Form.Check.Input,{type:"radio",checked:!0,readOnly:!0}),e.jsxs(c.Form.Check.Label,{children:[e.jsx("span",{className:"gu-mr-1",children:I.faGlobe}),e.jsx("b",{children:"Standard"}),e.jsx("div",{children:"This can be used by any designer later in the template."})]})]})]})]})]})]})};ll.propTypes={init:l.shape({label:l.string,key:l.string}).isRequired,layer:l.shape({description:l.string,label:l.string,key:l.string}).isRequired,onChange:l.func.isRequired};const Uu=s=>s.key===""?te("Please input Name.",`Layer [${s.key}]`):/^[a-z][a-z_]+[a-z]$/g.test(s.key)?se():te("This Name is invalid, please try a different one.",`Layer [${s.key}]`),Vu=(s,t)=>{const n={select_options:{}},r=X(s),i=X(t);return r.fields.filter(o=>o.type===m.FieldTypes.F_TABLE).forEach(o=>{(o.sub_fields||[]).forEach(d=>{if([m.FieldTypes.F_SELECT,m.FieldTypes.F_SELECT_MULTI].includes(d.type)&&d.option_layers){const u=d.option_layers;i?.properties_template?.select_options?.[u]&&(n.select_options[u]=i.properties_template.select_options[u],n.select_options[u].desc=u)}})}),Object.keys(n.select_options||{}).length===0?null:n},zu=(s,t)=>{const n={select_options:{}},r=X(s),i=X(t);return r.fields.filter(o=>[m.FieldTypes.F_SELECT,m.FieldTypes.F_SELECT_MULTI].includes(o.type)).forEach(o=>{const d=o.option_layers;i?.properties_template?.select_options?.[d]&&(n.select_options[d]=i.properties_template.select_options[d],n.select_options[d].desc=d)}),Object.keys(n.select_options||{}).length===0?null:n},al={show:!1,layer:null,data:null,notify:null},Yu=(s,t)=>t.type==="reset"?{...al,layer:t.payload.layer,data:t.payload.data}:{...s,[t.type]:t.payload},Hu=s=>{const{layer:t,data:n}=s,[r,i]=g.useReducer(Yu,{...al,layer:t,data:n});g.useEffect(()=>{i({type:"layer",payload:t})},[t]),g.useEffect(()=>{i({type:"data",payload:n})},[n]);const a=(f,h)=>{i({type:"layer",payload:{...r.layer,[f]:h}})},o=async()=>{let f=Uu(r.layer);if(!f.isSuccess)i({type:"notify",payload:f});else{const h=zu(r.layer,r.data),y=Vu(r.layer,r.data),b=Gn(y||{},h||{}),x={...r.layer,...b};f=await Me.saveStandardLayer(x),i({type:"notify",payload:f.notify})}},d=f=>{f&&f.stopPropagation&&f.stopPropagation(),i({type:"reset",payload:{layer:t,data:n}})},u=e.jsx(c.Button,{variant:"success",onClick:f=>{f.stopPropagation(),o()},children:"Save"},"success"),p=e.jsx(c.Button,{variant:"secondary",onClick:f=>d(f),children:"Close"},"primary");return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"lyr_add2std",children:e.jsx(c.Button,{variant:"light",onClick:f=>{f.stopPropagation(),i({type:"show",payload:!0})},children:I.faGlobe})}),e.jsx(rs,{acts:[u,p],title:"Standard Layer",showProps:{show:r.show,setShow:f=>i({type:"show",payload:f})},close:d,children:e.jsxs(e.Fragment,{children:[e.jsx(is,{notify:r.notify,onClose:()=>i({type:"notify",payload:null})}),e.jsx(ll,{init:t,layer:r.layer,onChange:a})]})})]})},Wu=[w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET],Ku={minWidth:70,filter:!1,sortable:!0},ol=({onVocSelect:s,onVocDelete:t})=>{const n=g.useRef(),r=g.useRef(),i=g.useMemo(()=>({height:"600px",width:"100%"}),[]),[a,o]=g.useState([]),[d]=g.useState([{headerName:"Action",cellRenderer:p=>e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"voc_add2tpl",children:e.jsx(c.Button,{size:"sm",onClick:()=>s(p),children:"Add"})}),Wu.includes(p.data.source)&&e.jsx(Qe,{cls:"gu-ml-1",msg:"Delete this Lab-Vocab permanently?",fnClick:t,fnParams:p,disabled:!1})]}),sortable:!1,width:100},{field:"id",headerName:"ID",sortable:!1,width:70},{field:"name",headerName:"Field Name",width:200},{field:"label",headerName:"Display Name",width:200},{field:"field_type",headerName:"Type",width:120},{field:"source",headerName:"Ref. Source",width:120},{field:"voc.source_name",headerName:"Ref. Source Name",width:200},{field:"layer_id",headerName:"Ref. Source Layer",width:200},{field:"ontology.short_form",headerName:"Ref. Terminology",width:120}]);g.useEffect(()=>{(async()=>{const f=await $e.getAllVocabularies();f.notify.isSuccess&&o(f.element.data||[])})()},[]);const u=g.useCallback(()=>{n.current.api.setGridOption("quickFilterText",r.current.value)},[]);return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2",children:e.jsxs("div",{className:"position-relative",children:[e.jsx("span",{className:"position-absolute top-50 translate-middle-y ms-2 text-muted",children:I.faMagnifyingGlass}),e.jsx(c.Form.Control,{ref:r,type:"text",placeholder:"Enter text to filter...",style:{paddingLeft:"2rem"},onChange:u})]})}),e.jsx("div",{className:w.GRID_THEME.QUARTZ.VALUE,style:i,children:e.jsx(Se.AgGridReact,{ref:n,columnDefs:d,defaultColDef:Ku,rowData:a})})]})};ol.propTypes={onVocSelect:l.func.isRequired,onVocDelete:l.func.isRequired};const dl=s=>{const{element:t,fnUpdate:n,layer:r}=s,[i,a]=g.useState(!1),o=()=>a(!0),d=()=>a(!1),u=async f=>{await $e.deleteVocabulary(f.data.id),a(!1)},p=f=>{const h=Mu(t,r,f.data);n(h),a(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"sel_voc2tpl",children:e.jsx(c.Button,{variant:"light",size:"sm",onClick:f=>{f.stopPropagation(),o()},children:I.faSpellCheck})}),e.jsxs(c.Modal,{centered:!0,show:i,onHide:d,dialogClassName:"gu_modal-68w",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"LabIMotion Vocabulary (Lab-Vocab) List"})}),e.jsx(c.Modal.Body,{children:e.jsx(ol,{onVocSelect:p,onVocDelete:u})}),e.jsx(c.Modal.Footer,{className:"justify-content-start",children:e.jsx(Q,{idf:"close",children:e.jsx(c.Button,{variant:"secondary",onClick:f=>{f.stopPropagation(),d()},children:"Close"})})})]})]})};dl.propTypes={element:l.object.isRequired,fnUpdate:l.func.isRequired,layer:l.object.isRequired};const cl=({conditions:s})=>{const{cond_fields:t=[],cond_operator:n=1}=s;if(!t.length)return null;const r=m.getCondOperator[n],i=t.map(a=>{const{id:o,layer:d,field:u,value:p}=a;return e.jsxs("tr",{children:[e.jsx("td",{children:d}),e.jsx("td",{children:u}),e.jsx("td",{children:p})]},o)});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fw-semibold fst-italic",children:["Restriction Setting: ",r]}),e.jsxs(c.Table,{size:"sm",bordered:!0,responsive:!0,className:"m-0",children:[e.jsx("thead",{className:"table-light",children:e.jsx("tr",{children:["Layer","Field","Value"].map(a=>e.jsx("th",{children:a},a))})}),e.jsx("tbody",{children:i})]})]})};cl.propTypes={conditions:l.shape({cond_fields:l.arrayOf(l.shape({id:l.string,layer:l.string,field:l.string,value:l.string})),cond_operator:l.number}).isRequired};const ul=g.forwardRef(({layer:s},t)=>{const n=s?.fields||[],[r,i]=g.useState(n),a=g.useRef(null);if(g.useImperativeHandle(t,()=>({getUpdates:()=>r})),n.length===0)return za;const o=(y,b)=>{const x=m.moveField(r,y,b);i(x)},d=ce(n,["position"])||[],u=ce(r,["position"])||[],p=(y,b=!1)=>{const{label:x,field:j,type:C}=y,T=`p-3 rounded border border-${b?"primary":"secondary"} `,S=e.jsxs("div",{className:T,children:[Ha(x,j,m.FieldTypes.F_DUMMY===C?"dummy":C),e.jsx(cl,{conditions:y})]});return b?e.jsx(Ae,{type:ks.LAYER_FIELD,layer:{key:y.field,...y},field:"position",handleMove:o,canDrag:!0,children:S},`${j}-${b?"new":"current"}`):e.jsx("div",{className:"w-100 p-2 m-2",children:e.jsx("div",{children:S})},`${j}-${b?"new":"current"}`)},f=d.map(y=>p(y,!1)).filter(Boolean),h=u.map(y=>p(y,!0)).filter(Boolean);return e.jsxs("div",{className:"d-flex flex-column h-100",children:[e.jsxs(_e,{className:"mx-0 p-3",children:[e.jsx(he,{md:6,children:e.jsx(Ze,{title:"Current Arrangement",children:"The existing arrangement"})}),e.jsx(he,{md:6,className:"text-primary",children:e.jsxs(Ze,{title:"New Arrangement",children:["Drag and drop (",I.faArrowsUpDownLeftRight,") to reorder fields"]})})]}),e.jsx("div",{ref:a,className:"flex-grow-1",style:{overflowY:"auto",overflowX:"hidden",minHeight:0,position:"relative"},children:e.jsxs(_e,{className:"mx-0 h-100",children:[e.jsx(he,{md:6,style:{position:"relative"},children:f}),e.jsx(he,{md:6,style:{position:"relative"},children:h})]})}),e.jsx(rn,{scrollableContainerRef:a})]})});ul.displayName="FieldOrderContent";const Un=({layer:s={},generic:t={},genericType:n,fnSave:r=()=>{}})=>{const[i,a]=g.useState(!1),o=g.useRef(null);if((s.fields||[]).length===0)return null;const d=u=>{const p=X(t);p.properties_template.layers[s.key].fields=u,p.changed=!0,r(new ee(se(),p))};return e.jsxs(e.Fragment,{children:[e.jsxs(c.Dropdown.Item,{eventKey:`arrange_fields.${s.label}`,onClick:()=>a(!0),children:[I.faBars,"  Arrange Fields Order"]}),e.jsx(ts,{genericType:n,showProps:{show:i,setShow:a},onSave:d,children:e.jsx(ul,{ref:o,layer:s})})]})};Un.propTypes={layer:l.object,generic:l.object,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnSave:l.func};Un.defaultProps={layer:{},generic:{},fnSave:()=>{}};function Vn(s){const{data:t,genericType:n,fnUpdate:r,vocabularies:i}=s,[a,o]=g.useState({}),d=S=>{o(v=>({...v,[S]:!v[S]}))},u=S=>{const{newFieldKey:v,layer:E}=S,_=$u(v,t,E);r(_)},p=S=>{const{layerKey:v,field:E}=S,_=il(t,v,E);r(_)},f=S=>{const v=Eu(S,t);r(v)},h=async S=>{const v=Tu(S,t,n);r(v)},y=async S=>{await Me.deleteStandardLayer(S.id)},b=(S,v)=>{const E=Cu(t,S,v);r(E)},x=S=>{r(S)},j=[],C=tt(t.properties_template.layers||{},t.metadata?.groups||[]),T=[];return C.forEach(S=>{S.type==="group"?S.layers.forEach(v=>{T.push(v.data)}):T.push(S.data)}),(T||[]).forEach(S=>{const v=`${S.key}`,E=Ga(t.metadata,v),_=e.jsx(qn,{generic:t,genericType:n,fnUpdate:r,layer:S,vocabularies:i,parentExpand:a[v]}),R=[w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT].includes(n),F=e.jsx(tn,{layer:S,groupInfo:E}),D=e.jsxs("div",{className:"d-flex",children:[e.jsx("div",{className:"me-2",children:e.jsx(Bn,{fnUpdate:u,layer:S,children:e.jsx(dl,{element:t,fnUpdate:r,layer:S})})}),e.jsx(c.ButtonGroup,{className:"me-2",children:e.jsx(Hu,{layer:S,data:t})}),e.jsx(c.ButtonGroup,{children:e.jsxs(Mn,{condSet:!1,children:[e.jsx(dn,{fnUpdate:b,isAttrOnWF:R,layer:S,as:"menu"}),e.jsx(ue,{idf:"fld_dum_add",fnClick:p,element:{layerKey:v,field:null},fa:"faSquare",place:"top",as:"menu"}),e.jsx(Un,{layer:S,generic:t,genericType:n,fnSave:r}),e.jsx(c.Dropdown.Divider,{}),e.jsx(wt,{delType:m.FieldTypes.DEL_LAYER,delKey:v,generic:t,fnConfirm:x,as:"menu"})]})})]}),L=e.jsxs(e.Fragment,{children:[F,D]}),P=e.jsx(_t,{layerKey:v,toggleExpand:d,propHeader:L,children:_},`_prop_content_${v}`);j.push(P)}),e.jsx("div",{children:e.jsxs(c.Card,{className:"border-0",children:[e.jsxs(c.Card.Header,{as:"h5",className:`${ze} lu-bg-white px-1`,children:["Layers",e.jsxs("span",{className:"button-right d-flex gap-1",children:[e.jsx(ln,{generic:t,genericType:n,fnSave:r}),e.jsx(An,{generic:t,genericType:n,fnSave:r}),e.jsx(cn,{fnCreate:f}),e.jsx(Fd,{fnCreate:h,fnDelete:y})]})]}),e.jsx(c.Card.Body,{className:"p-0",children:e.jsx("div",{children:j})})]})})}Vn.propTypes={data:l.object.isRequired,fnUpdate:l.func.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,vocabularies:l.array};Vn.defaultProps={vocabularies:[]};class pl extends g.Component{constructor(t){super(t),this.s_selectKey=g.createRef()}handleCreate(){const{fnCreate:t}=this.props;t(this.s_selectKey.current.value.trim())}render(){const{showModal:t,fnClose:n}=this.props;return e.jsxs(c.Modal,{centered:!0,backdrop:"static",show:t,onHide:()=>n(),size:"lg",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"New Select List"})}),e.jsx(c.Modal.Body,{style:{overflow:"auto"},children:e.jsxs("div",{className:"col-md-12",children:[e.jsx(c.Form,{className:"row mb-3 input-form",children:e.jsxs(c.Form.Group,{controlId:"formControlSelectKey",children:[e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:"Name"}),e.jsx(c.Form.Control,{type:"text",ref:this.s_selectKey})]}),e.jsxs("div",{className:"help",children:["Select List name is unique in the template.",e.jsx("br",{}),"Select List name must start with a lowercase letter, and then have one or more lowercase letters or underscores in the middle, and end with a lowercase letter.",e.jsx("br",{}),"Select List name should not contain special characters like $, !, %, etc."]})]})}),e.jsxs(c.Form.Group,{children:[e.jsx(c.Button,{variant:"primary",onClick:()=>this.handleCreate(),children:"Add new select list to template workarea"})," ",e.jsx(c.Button,{variant:"secondary",onClick:()=>n(),children:"Cancel"})]})]})})]})}}pl.propTypes={showModal:l.bool.isRequired,fnClose:l.func.isRequired,fnCreate:l.func.isRequired};const Gr=s=>{s.stopPropagation()};class fl extends g.Component{constructor(t){super(t),this.inputNewOption=g.createRef()}handleCreate(){const{generic:t,root:n,fnAddOption:r}=this.props,i=this.inputNewOption.current.value.trim(),a={key:i,label:i},d=X(t)?.properties_template?.select_options[n]?.options||[];d.push(a),r(n,i,d)}render(){const{root:t,children:n}=this.props;return e.jsxs(c.Form.Group,{size:"sm",as:c.Row,style:{marginBottom:"unset",display:"inline-table"},children:[e.jsxs(c.Form.Label,{children:[I.faList," ",t]}),e.jsxs(c.InputGroup,{className:"ug-input-group",children:[e.jsx(c.Form.Control,{type:"text",name:"input_newOption",ref:this.inputNewOption,placeholder:"Input new option",size:"sm",onClick:Gr,onFocus:Gr}),e.jsx(ue,{idf:"sel_opt_add",fnClick:()=>this.handleCreate(),fa:"faPlus"}),n]})]})}}fl.propTypes={generic:l.object.isRequired,root:l.string.isRequired,fnAddOption:l.func.isRequired,children:l.node.isRequired};const hl=(s,t,n,r,i,a="button")=>e.jsx(wt,{generic:s,delType:t,delKey:n,delRoot:r,fnConfirm:i,as:a});function Xu({name:s,label:t,generic:n,root:r,fnInputChg:i,fnDel:a}){const[o,d]=g.useState(t);g.useEffect(()=>{d(t)},[t]);const u=p=>{const f=p.target.value;d(f),i(p,s,r)};return e.jsx(c.Form.Group,{size:"sm",controlId:`_cgu_frmSelectOption_${s}`,children:e.jsxs(c.InputGroup,{children:[e.jsx(c.InputGroup.Text,{children:s}),e.jsx(c.Form.Control,{type:"text",name:"lf_label",value:o,onChange:u}),hl(n,"Option",s,r,a)]})})}const ml=g.memo(Xu);ml.displayName="SelectOption";function yl(s){const{generic:t,root:n,fnInputChg:r,fnDel:i}=s,a=t?.properties_template?.select_options[n]?.options||[];return a.length<1?null:e.jsx(c.Col,{md:12,children:e.jsx(c.Card.Body,{children:a.map(o=>e.jsx("div",{className:"mb-2",children:e.jsx(ml,{name:o.key,label:o.label,generic:t,root:n,fnInputChg:r,fnDel:i})},`${o.key}_${n}`))})})}yl.propTypes={generic:l.object.isRequired,root:l.string.isRequired,fnInputChg:l.func.isRequired,fnDel:l.func.isRequired};function gl(s){const{generic:t,root:n,fnAdd:r,fnChange:i,fnInputChg:a}=s,[o,d]=g.useState(!1),u=(p,f,h)=>{d(!0),r(p,f,h)};return e.jsxs(c.Row,{children:[e.jsx(c.Col,{md:12,children:e.jsxs(fl,{generic:t,root:n,fnAddOption:u,fnChange:i,children:[hl(t,"Select",n,"",i),e.jsx(ue,{idf:`dtl_${o?"collapse":"expand"}`,fnClick:()=>d(!o),fa:`faCaret${o?"Up":"Down"}`})]})}),o&&e.jsx(yl,{generic:t,root:n,fnInputChg:a,fnDel:i})]})}gl.propTypes={generic:l.object.isRequired,root:l.string.isRequired,fnAdd:l.func.isRequired,fnInputChg:l.func.isRequired,fnChange:l.func.isRequired};function xl(s){const{generic:t,fnChange:n}=s,[r,i]=g.useState(!1),a=(u,p,f)=>{const h=Ru(t,u,p,f);n(h),i(!1)},o=u=>{const p={...t.properties_template?.select_options};p[u]={};const f=wu(t,u,p);n(f),i(!1)},d=(u,p,f)=>{const h=u.target.value,y=Fu(t,p,f,h);n(y)};return e.jsxs("div",{children:[e.jsxs(c.Card,{className:"border-0",children:[e.jsxs(c.Card.Header,{as:"h5",className:`${ze} lu-bg-white`,children:["Selection Lists",e.jsx(ue,{idf:"sel_add",fnClick:()=>i(!0),fa:"faPlus",size:"sm",bs:"primary",txt:"Add new selection list",btnCls:"ms-auto fw-medium"})]}),e.jsx(c.Card.Body,{children:Object.keys(t.properties_template?.select_options||{}).map(u=>e.jsx(gl,{generic:t,root:u,fnAdd:a,fnChange:n,fnInputChg:d},u))})]}),e.jsx(pl,{showModal:r,fnClose:()=>i(!1),fnCreate:o})]})}xl.propTypes={generic:l.object.isRequired,fnChange:l.func.isRequired};const os=({showProps:s,children:t})=>{const{show:n,setShow:r}=s;return n?e.jsxs(c.Modal,{centered:!0,show:n,onHide:()=>r(!1),fullscreen:!0,backdrop:"static",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Design Workflow"})}),e.jsx(c.Modal.Body,{children:t})]}):null};os.propTypes={showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired,children:l.node.isRequired};const bl=s=>{const{node:t}=s,[{isDragging:n},r]=be.useDrag(()=>({type:"lim-dnd-type",collect:i=>({isDragging:i.isDragging()}),item:t}));return e.jsxs("div",{className:"react-flow__node-default",ref:r,children:[e.jsx("div",{className:"gu_flow_dnd_sidebar",children:e.jsx("b",{children:t.label})}),e.jsxs("div",{children:["(",t.key,")"]})]},t.key)};bl.propTypes={node:l.object.isRequired};const zn=s=>{const{nodes:t}=s;return e.jsx(e.Fragment,{children:t.map(n=>e.jsx(bl,{id:n.id,node:n},n.key))})};zn.propTypes={nodes:l.array.isRequired};const _l=s=>{const{element:t}=s;if(t?.properties_template==null)return null;const r=ce(t.properties_template.layers||[],i=>i.position).filter(i=>i.wf);return e.jsxs("aside",{children:[e.jsx("div",{className:"description",children:"You can drag the nodes listed below to the left pane to design your flow."}),e.jsx("div",{className:"description",children:"To remove the node from the pane, click on the node and press 'Del' button."}),e.jsx(zn,{nodes:r})]})};_l.propTypes={element:l.object.isRequired};const jl={background:"red"},Zu={...jl,top:10},Qu=s=>console.log("handle onConnect",s),Ju=({data:s})=>e.jsxs(e.Fragment,{children:[e.jsx(re.Handle,{type:"target",position:re.Position.Top,style:jl,onConnect:Qu}),e.jsxs("div",{children:[e.jsx("div",{className:"gu_flow_dnd_sidebar",children:e.jsx("b",{children:s.layer.label})}),e.jsxs("div",{children:["(",s.layer.key,")"]})]}),e.jsx(re.Handle,{type:"source",position:re.Position.Bottom,id:"a",style:Zu})]}),Yn=g.memo(Ju),vl=({nodeClass:s,nodeIcon:t})=>e.jsx("div",{className:s,children:t});vl.propTypes={nodeClass:l.string.isRequired,nodeIcon:l.object.isRequired};const dt=(s,t,n="chk",r="")=>{const i=n==="chk"?I.faCircleCheck:I.faCirclePlus,a=`border_line ${r}`;return e.jsxs("div",{className:"gu_flow_default_element",children:[t?e.jsx(vl,{nodeClass:n,nodeIcon:i}):null,e.jsx("div",{className:a,children:e.jsx("b",{children:s.label})}),e.jsxs("div",{children:["(",s.key,")"]})]})},ep=(s,t)=>{const n=s.filter(u=>u.type===w.NODE_TYPES.DEFAULT);if(n.length<1)return{nodes:[],edges:[]};const r=[],i=[],{layers:a}=t;(ce(a,["position","wf_position"])||[]).forEach(u=>{let p=n.find(b=>u.key===b.data.lKey),f=dt(u,!0);if(!p){if(p=n.find(b=>u.key.startsWith(`${b.data.lKey}.`)),!p)return;f=dt(u,!0,"add")}const h=u.key,y={id:h,type:w.NODE_TYPES.DEFAULT,data:{label:f,layer:u,lKey:h},width:p.width,height:p.height};r.push(y)}),r.unshift(qi),r.push(Bi);const d=[];return r.forEach((u,p)=>{if(p===0)d.push(u);else{const f=d[p-1],h={x:f.position.x,y:f.position.y+(p*10+10+u.height)};d.push({...u,position:h})}}),d.forEach((u,p)=>{if(p===0)return;const f=d[p-1];i.push({id:`${f.id}-${u.id}`,source:f.id,target:u.id,animated:!0})}),{nodes:d,edges:i}},tp=s=>{const t=X(s||{});return Object.keys(t).reduce((n,r)=>(r.startsWith(w.SYS_REACTION)||(n[r]=t[r]),n),{})},sp=(s,t)=>{const n=X(s||{}),i=(t?.groups||[]).flatMap(a=>a.layers||[]);return Object.keys(n).reduce((a,o)=>(i.includes(o)||(a[o]=n[o]),a),{})},np=(s,t,n)=>s.map(r=>{if(r.type===w.NODE_TYPES.DEFAULT&&r.data){const{lKey:i}=r.data,a=t[i]||{},d=na(n.layers||{},u=>u.wf&&(u.key===i||u.key.startsWith(`${i}.`)))?dt(a,!0):dt(a,!1);r.data={label:d,layer:a,lKey:a.key}}return(r.type===w.NODE_TYPES.INPUT||r.type===w.NODE_TYPES.OUTPUT)&&(r.deletable=!1),r}),El=s=>{const{id:t,layer:n,position:r}=s;return{id:t||ie.v4(),type:w.NODE_TYPES.DEFAULT,data:{lKey:n.key,layer:n,label:dt(n,!1)},position:r||{x:0,y:0}}},Mr=(s,t=[])=>{const n=r=>t.includes(r.key);return s.map(r=>r.data.layer?{...r,data:{label:dt(r.data.layer,!1,"",n(r.data.layer)?"":"invalid"),layer:r.data.layer,lKey:r.data.layer.key},style:{border:n(r.data.layer)?"1px solid #000":"1px solid lightcoral",color:n(r.data.layer)?"#000":"lightcoral"}}:r)},Kt=s=>{const{properties:t,propertiesRelease:n,flowType:r="default"}=s,{flow:i,flowObject:a,layers:o}=n,{nodes:d,edges:u,viewport:p}=a?X(a):vn(i);if(r!=="default"){const h=Object.keys(t).length===0?n:t,y=ep(d,h);return{nodes:y.nodes,edges:y.edges,viewport:{x:0,y:0,zoom:1}}}return{nodes:np(d,o,t),edges:u,viewport:p}},rp={selectorNode:Yn},Hn=s=>{const{element:t,fnSave:n}=s,r=t.properties_template,i=g.useRef(null),[a,o]=g.useState(()=>Kt({properties:r,propertiesRelease:r})),[d,u]=g.useState(null),[p,f,h]=re.useNodesState(a.nodes),[y,b,x]=re.useEdgesState(a.edges),j=g.useCallback(_=>b(R=>re.addEdge({..._,animated:!0,markerEnd:{type:re.MarkerType.ArrowClosed},label:"next"},R)),[]),C=g.useCallback(()=>{if(d){const _=d.toObject();n({flowObject:_})}},[d]),T=(_,R)=>{if(d){const F=R.getClientOffset(),D=i.current.getBoundingClientRect();let L={x:F.x-D.left,y:F.y-D.top};L=d.project(L);const P=El({layer:_,position:L});f(G=>G.concat(P))}},[{isOver:S,canDrop:v},E]=be.useDrop({accept:"lim-dnd-type",drop:(_,R)=>{T(_,R)},collect:_=>({isOver:_.isOver(),canDrop:_.canDrop()})});return g.useEffect(()=>{o(Kt({properties:r,propertiesRelease:r}))},[r]),e.jsx(e.Fragment,{children:e.jsx("div",{ref:E,className:"dndflow",children:e.jsxs(re.ReactFlowProvider,{children:[e.jsx("div",{className:"reactflow-wrapper",ref:i,children:e.jsxs(re,{nodes:p,edges:y,onConnect:j,onNodesChange:h,onEdgesChange:x,onInit:u,connectionMode:re.ConnectionMode.Loose,nodeTypes:rp,deleteKeyCode:["Delete","Backspace"],fitView:!0,children:[e.jsx("div",{className:"save__controls",children:e.jsxs(c.Button,{size:"sm",onClick:C,children:[I.faFloppyDisk," Save to draft"]})}),e.jsx(re.Controls,{})]})}),e.jsx(_l,{element:t})]})})})};Hn.propTypes={element:l.object.isRequired,fnSave:l.func.isRequired};const Wn=s=>{const{element:t,fnSave:n,genericType:r,btnCls:i}=s,[a,o]=g.useState(!1);if(![w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT].includes(r))return null;const d=u=>{const p=u.flowObject;p.nodes=p.nodes.map(f=>(f.data&&f.type==="default"&&delete f.data.label,f)),t.properties_template.flowObject=p,delete t.properties_template.flow,n(new ee(se(),t)),o(!1)};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"design_flow",children:e.jsxs(c.Button,{onClick:()=>o(!0),variant:"light",size:"sm",className:i,children:[e.jsx(De,{wf:!0})," Workflow"]})}),e.jsx(os,{genericType:r,showProps:{show:a,setShow:o},children:e.jsx(Hn,{element:t,fnSave:d})})]})};Wn.propTypes={element:l.object.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnSave:l.func.isRequired,btnCls:l.string};Wn.defaultProps={btnCls:""};const Tl=s=>{const{data:t,fnUpload:n,genericType:r,showProps:i}=s,{show:a,setShow:o}=i,d=p=>{const f=ku(p,r);if(f.notify.isSuccess){const h=X(t);Object.prototype.hasOwnProperty.call(f.element,"metadata")?h.metadata=X(f.element.metadata):delete h.metadata;const y=X(f.element);delete y.metadata,h.properties_template=y,f.element=h}n(f),o(!1)},u=p=>{const f=new FileReader;f.onload=d,f.readAsText(p[0])};return e.jsxs(c.Modal,{centered:!0,show:a,onHide:()=>o(!1),children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Upload template to Work Area"})}),e.jsx(c.Modal.Body,{style:{overflow:"auto"},children:e.jsx(Os,{onDrop:p=>u(p),className:"lu-drop-zone",style:{height:50},children:e.jsx("div",{style:{paddingTop:12},children:"Drop File, or Click to Select."})})})]})};Tl.propTypes={data:l.object.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnUpload:l.func.isRequired,showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired};const Kn=s=>{const{data:t,fnUpload:n,genericType:r,btnCls:i}=s,[a,o]=g.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"imp_temp_to_area",children:e.jsxs(c.Button,{onClick:()=>o(!0),variant:"outline-secondary",size:"sm",className:i,children:[I.faArrowRightToBracket," Import template into Work Area"]})}),a&&e.jsx(Tl,{data:t,fnUpload:n,genericType:r,showProps:{show:a,setShow:o}})]})};Kn.propTypes={data:l.object.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnUpload:l.func.isRequired,btnCls:l.string};Kn.defaultProps={btnCls:""};const $t=({position:s,fontSize:t="10px"})=>{const n=()=>{switch(s){case"top":return{top:"20px",left:"50%",transform:"translate(-50%, -50%)"};case"center":return{top:"50%",left:"50%",transform:"translate(-50%, -50%)"};case"bottom":return{bottom:"20px",left:"50%",transform:"translate(-50%, 50%)"};default:return{}}};return e.jsx("div",{style:{position:"absolute",color:"#6c757d",backgroundColor:"rgba(108, 117, 125, 0.1)",opacity:.8,fontSize:t,height:"24px",width:"6px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"2px",...n()},children:I.faGripLinesVertical})};$t.propTypes={position:l.oneOf(["top","center","bottom"]).isRequired,fontSize:l.string};const Cl=({leftPanel:s,rightPanel:t,defaultLeftWidth:n=66.67,minLeftWidth:r=50,minRightWidth:i=20,className:a="",style:o={},minHeightForMultipleIndicators:d=200})=>{const[u,p]=g.useState(n),[f,h]=g.useState(!1),[y,b]=g.useState(!1),x=g.useRef(null),j=g.useRef(null),C=g.useCallback(_=>{_.preventDefault(),h(!0)},[]),T=g.useCallback(_=>{if(!f||!x.current)return;const R=x.current.getBoundingClientRect(),F=R.width;let L=(_.clientX-R.left)/F*100;L=Math.max(r,L),L=Math.min(100-i,L),p(L)},[f,r,i]),S=g.useCallback(()=>{h(!1)},[]),v=g.useCallback(()=>{if(j.current){const _=j.current.offsetHeight;b(_>=d)}},[d]);g.useEffect(()=>{v();const _=new ResizeObserver(()=>{v()});return j.current&&_.observe(j.current),()=>{_.disconnect()}},[v]),g.useEffect(()=>{if(f)return document.addEventListener("mousemove",T),document.addEventListener("mouseup",S),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",S),document.body.style.cursor="",document.body.style.userSelect=""}},[f,T,S]);const E=100-u;return e.jsxs("div",{ref:x,className:`d-flex ${a}`,style:{height:"100%",overflow:"hidden",...o},children:[e.jsx("div",{style:{width:`${u}%`,overflow:"hidden",paddingRight:"4px"},children:s}),e.jsxs("div",{ref:j,onMouseDown:C,style:{width:"8px",backgroundColor:f?"#6c757d":"#dee2e6",cursor:"col-resize",borderLeft:"1px solid #dee2e6",borderRight:"1px solid #dee2e6",position:"relative",flexShrink:0,transition:f?"none":"background-color 0.2s ease"},onMouseEnter:_=>{f||(_.target.style.backgroundColor="#adb5bd")},onMouseLeave:_=>{f||(_.target.style.backgroundColor="#dee2e6")},children:[y&&e.jsx($t,{position:"top",fontSize:"10px"}),e.jsx($t,{position:"center",fontSize:"12px"}),y&&e.jsx($t,{position:"bottom",fontSize:"10px"})]}),e.jsx("div",{style:{width:`${E}%`,overflow:"hidden",paddingLeft:"4px"},children:t})]})};Cl.propTypes={leftPanel:l.node.isRequired,rightPanel:l.node.isRequired,defaultLeftWidth:l.number,minLeftWidth:l.number,minRightWidth:l.number,className:l.string,style:l.object,minHeightForMultipleIndicators:l.number};const ip=(s,t)=>{const{name:n,label:r,desc:i}=t;let a="";switch(s){case w.GENERIC_TYPES.ELEMENT:a=`${s} Template: ${r} (${n})`;break;case w.GENERIC_TYPES.SEGMENT:a=`${s} Template: ${i} (${r})`;break;case w.GENERIC_TYPES.DATASET:a=`${s} Template: ${r}`;break}return a},Xn=s=>{const{data:t,vocabularies:n,fnSubmit:r,genericType:i,innerAction:a}=s;return e.jsx("div",{children:e.jsxs(c.Card,{children:[e.jsxs(c.Card.Header,{className:`fs-5 fw-bold ${ze}`,children:[ip(i,t),e.jsxs("span",{className:"button-right d-flex gap-1",children:[e.jsx(Kn,{data:t,fnUpload:a,genericType:i,btnCls:"fw-medium"}),e.jsx(Wn,{element:t,fnSave:a,genericType:i,btnCls:"fw-medium"}),e.jsx(ue,{txt:"Save and Release (Major)",idf:"tpl_save_rel_major",fnClick:r,element:{data:t,release:"major"},fa:"faFloppyDisk",place:"top",bs:"success",size:"sm",btnCls:"fw-medium"}),e.jsx(ue,{txt:"Save and Release (Minor)",idf:"tpl_save_rel_minor",fnClick:r,element:{data:t,release:"minor"},fa:"faFloppyDisk",place:"top",bs:"success",size:"sm",btnCls:"fw-medium"}),e.jsx(ue,{txt:"Save as draft",idf:"tpl_save_draft",fnClick:r,element:{data:t,release:"draft"},fa:"faFloppyDisk",place:"top",bs:"primary",size:"sm",btnCls:"fw-medium"})]})]}),e.jsx(c.Card.Body,{children:e.jsx("div",{style:{maxWidth:"2000px",margin:"auto",height:"100%"},children:e.jsx(Cl,{defaultLeftWidth:66.67,minLeftWidth:50,minRightWidth:20,leftPanel:e.jsx(Vn,{data:t,vocabularies:n,fnDerive:a,fnUpdate:a,genericType:i}),rightPanel:e.jsx("div",{children:e.jsx(xl,{generic:t,fnChange:a})})})})})]})})};Xn.propTypes={data:l.object,vocabularies:l.array,fnSubmit:l.func.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,innerAction:l.func.isRequired};Xn.defaultProps={vocabularies:[]};const ds=({isSelected:s,onChange:t,className:n="me-2"})=>e.jsx(ra.Check,{type:"checkbox",checked:s,onChange:t,className:n});ds.fnId=Fe.FN_DIFF;ds.propTypes={isSelected:l.bool.isRequired,onChange:l.func.isRequired,className:l.string};ds.defaultProps={className:"me-2"};const lp=jt(ds),$r=s=>it(s,"DD.MM.YYYY, HH:mm").format("YYYY-MM-DD HH:mm"),cs=({download:s,idxSelect:t,rev:n,src:r,fnDelete:i,fnRetrieve:a,fnView:o,isSelected:d,onSelectionChange:u})=>{const{id:p,uuid:f,released_at:h,created_at:y,properties:b,properties_release:x,version:j}=n,{canDL:C,fnDownload:T}=s,[S,v]=t.split(":"),E=parseInt(S,10),_=isNaN(E)?0:E,R=ge([f,p])===v?"border-info border-3":"border-1";let F="",D="",L="";r==="properties_release"&&(F=h?`Released at: ${$r(h)} (UTC)`:"(In Progress)",D=j&&(h?`v${j}`:""),L=`ID: ${f||""}`),r==="properties"&&(F=`Saved at: ${$r(y)} (UTC)`,D=`v${b.version}`,L=`Template ID: ${b.klass_uuid||""}`);const P=h&&_>1?e.jsx(Qe,{msg:"Delete this version permanently?",fnClick:i,fnParams:{id:p}}):null,G=h?e.jsx(Qe,{msg:"Retrieve this version?",fnClick:a,fnParams:{id:p},fa:"faReply"}):null,k=C?e.jsx(ue,{idf:"ver_download",fnClick:T,element:{id:p},fa:"faDownload",place:"top"}):null,U=N=>{u&&u(n,N.target.checked,{verID:L,verBase:D})};return e.jsxs("div",{className:`d-block p-2 m-1 fs-5 border ${R}`,children:[e.jsxs("div",{className:"d-flex flex-nowrap gap-2 align-items-center",children:[e.jsx(lp,{isSelected:d,onChange:U}),e.jsx("div",{className:"flex-grow-1",children:L}),e.jsx("div",{className:"fs-6 fw-bold text-primary",children:D}),e.jsxs("div",{className:"fs-6",children:[" #",_+1]})]}),e.jsxs("div",{className:"d-flex flex-nowrap gap-2",children:[e.jsx("div",{className:"w-100",children:F}),e.jsxs(js,{size:"sm",className:"gap-1",children:[P,k,G,e.jsx(ue,{idf:"ver_view",fnClick:o,element:{uuid:f,id:p},fa:"faEye",place:"top"})]})]})]},f)};cs.propTypes={download:l.shape({canDL:l.bool,fnDownload:l.func}).isRequired,idxSelect:l.string.isRequired,rev:l.object.isRequired,src:l.oneOf(["properties_release","properties"]),fnDelete:l.func,fnRetrieve:l.func,fnView:l.func.isRequired,isSelected:l.bool,onSelectionChange:l.func};cs.defaultProps={fnRetrieve:()=>{},fnDelete:()=>{},src:"properties_release",isSelected:!1,onSelectionChange:null};zr.create({objectHash:s=>s?.key||JSON.stringify(s),arrays:{detectMove:!0}});const Xt={added:"#d4edda",removed:"#f8d7da"},ap=["pkg","uuid","klass","identifier","_versionDisplay","id"],op=["key","wf_position","wf_uuid","timeRecord"],dp={wf:"workflow",cols:"columns_per_row",color:"header_color",label:"display_name",cond_fields:"restriction_setting",select_options:"selection_list",option_layers:"selection",description:"hover_information",hasOwnRow:"has_its_own_row",col_name:"column_heading",sub_fields:"content",style:"text_style"},cp=["label","type","description","ontology"],up={text:["field","cols","hasOwnRow","placeholder","readonly","required"],textarea:["field","cols","hasOwnRow"],checkbox:["field","cols","hasOwnRow"],upload:["field","cols","hasOwnRow"],datetime:["field","cols","hasOwnRow"],"datetime-range":["field","cols","hasOwnRow"],"drag-molecule":["field","cols","hasOwnRow"],"drag-sample":["field","cols","hasOwnRow"],"drag-element":["field","cols","hasOwnRow"],"formula-field":["field","cols","hasOwnRow","formula","decimal","canAdjust"],"input-group":["field","cols","hasOwnRow","sub_fields"],integer:["field","cols","hasOwnRow","placeholder","required"],select:["field","cols","hasOwnRow","option_layers"],"select-multi":["field","cols","hasOwnRow","option_layers"],"system-defined":["field","cols","hasOwnRow","option_layers"],table:["field","cols","sub_fields"],dummy:["cols"],number:["value"]},pp=(s,t)=>{const n={};return Object.entries(t).forEach(([r,i])=>{const a=["field",...s,...i].filter((o,d,u)=>u.indexOf(o)===d);n[r]=a}),n},fp=pp(cp,up),hp={"select-multi":"select (multiple)","input-group":"input group","text-formula":"text formula","datetime-range":"datetime range","drag-molecule":"drag molecule","drag-sample":"drag sample","drag-element":"drag element","formula-field":"formula field","system-defined":"system defined"},mp={primary:"Ocean Blue",info:"Sky Blue",success:"Fresh Green",default:"Grey",danger:"Crimson",warning:"Amber"},yp={panel_generic_heading:"bold",panel_generic_heading_bu:"bold + underline",panel_generic_heading_bui:"bold + underline + italic"},Zt={defaultColDef:{sortable:!1,filter:!1},animateRows:!0,height:500,indentSize:20},Sl=s=>{if(!s||typeof s!="object"||!s.type)return s;const t=fp[s.type]||[],n={};return t.forEach(r=>{r in s&&(r==="ontology"&&s[r]&&typeof s[r]=="object"?n[r]={iri:s[r].iri}:n[r]=s[r])}),n},gp=(s,t=null)=>{if(!s||typeof s!="object")return s;const n={...s};return n.sub_fields&&Array.isArray(n.sub_fields)&&(n.sub_fields=n.sub_fields.map(r=>{if(r&&typeof r=="object"){let i=Sl(r);return je(i,t)}return je(r,t)})),je(n,t)},je=(s,t=null)=>{if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(r=>je(r,t));if(s.layers&&typeof s.layers=="object"&&!Array.isArray(s.layers))if(t&&t.length>0){const r={};t.forEach(i=>{s.layers[i]&&(r[i]=s.layers[i])}),Object.keys(s.layers).forEach(i=>{i in r||(r[i]=s.layers[i])}),s={...s,layers:r}}else{const r=ce(Object.entries(s.layers),"[1].position");s={...s,layers:Object.fromEntries(r)}}const n={};for(const[r,i]of Object.entries(s)){if(ap.includes(r))continue;const a=dp[r]||r;r==="select_options"&&i&&typeof i=="object"&&!Array.isArray(i)?n[a]=xp(i,t):r==="layers"&&i&&typeof i=="object"&&!Array.isArray(i)?n[a]=bp(i,t):n[a]=je(i,t)}return n},xp=(s,t)=>{const n={};for(const[r,i]of Object.entries(s))i&&typeof i=="object"&&i.options&&Array.isArray(i.options)?n[r]=je(i.options,t):n[r]=je(i,t);return n},bp=(s,t)=>{const n={};for(const[r,i]of Object.entries(s))if(i&&typeof i=="object"&&!Array.isArray(i)){const a={...i};op.forEach(o=>{o in a&&delete a[o]}),a.fields&&Array.isArray(a.fields)&&(a.fields=a.fields.map(o=>{if(o&&typeof o=="object"&&o.type){let d=Sl(o);return["input-group","table"].includes(o.type)?gp(d,t):je(d,t)}return je(o,t)})),n[r]=je(a,t)}else n[r]=je(i,t);return n},gt=(s,t,n)=>t==="type"&&typeof s=="string"?hp[s]||s:t==="header_color"&&typeof s=="string"?mp[s]||s:t==="text_style"&&typeof s=="string"?yp[s]||s:t==="workflow"&&typeof s=="boolean"?s?"enabled":"disabled":["has_its_own_row","required"].includes(t)&&typeof s=="boolean"?s?"yes":"no":s,qr=(s,t,n,r)=>{if(!t)return"";if(s===null)return"null";if(s===void 0||r==="layers"&&typeof s=="object"&&s!==null)return"";const i=gt(s,n);return typeof i=="string"?i:String(i)},_p=zr.create({objectHash:s=>s?.key||JSON.stringify(s),arrays:{detectMove:!0}}),jp=(s,t,n,r,i,a,o)=>s!=="added"&&s!=="removed"||t&&n?!1:!t||!n,vp=(s,t,n,r,i,a,o)=>{let d="same";return(n!==void 0||s!==t&&r&&i)&&(s===void 0?d="added":t===void 0?d="removed":d="modified"),jp(d,r,i)&&(d="modified"),d},As=(s,t,n="",r=0)=>{const i=[],a=_p.diff(s||{},t||{}),o=Object.keys(t||{}),u=Object.keys(s||{}).filter(f=>!o.includes(f));return[...o,...u].forEach(f=>{const h=s?.[f],y=t?.[f],b=n?`${n}.${f}`:f,x=a?.[f],j=h==null||typeof h!="object",C=y==null||typeof y!="object",T=vp(h,y,x,j,C),S={id:b,key:f,parentKey:n,fullKey:b,level:r,oldValue:qr(h,j,f,n),newValue:qr(y,C,f,n),change:T,isParent:!j||!C,rawOldValue:h,rawNewValue:y};if(i.push(S),!j||!C)if(Array.isArray(h)||Array.isArray(y)){const v=Math.max(Array.isArray(h)?h.length:0,Array.isArray(y)?y.length:0);for(let E=0;E<v;E++){const _=Array.isArray(h)?h[E]:void 0,R=Array.isArray(y)?y[E]:void 0;i.push(...As({[E]:_},{[E]:R},b,r+1))}}else i.push(...As(h||{},y||{},b,r+1))}),i},wl=({oldStr:s="",newStr:t=""})=>{const n=ia.diffChars(s,t);return e.jsx("span",{children:n.map((r,i)=>{const a={backgroundColor:r.added?Xt.added:r.removed?Xt.removed:"transparent"};return e.jsx("span",{style:a,children:r.value},i)})})},Ep=(s,t)=>{if(/^\d+$/.test(s)){const n=parseInt(s,10)+1;return String(n)}return s},Tp=s=>{const{data:t}=s,n=t.level*Zt.indentSize,r=Ep(t.key,t.parentKey);return e.jsxs("div",{style:{paddingLeft:`${n}px`,display:"flex",alignItems:"center"},children:[t.isParent&&e.jsx("span",{style:{marginRight:"5px",color:"#666"},children:I.faMinus}),e.jsx("span",{children:r})]})},Cp=s=>{const{data:t}=s,{rawOldValue:n,rawNewValue:r,change:i}=t;if(i==="modified"&&(typeof n=="string"||typeof n=="number"||typeof n=="boolean")&&(typeof r=="string"||typeof r=="number"||typeof r=="boolean")){const o=String(gt(n,t.key,t.fullKey));return String(gt(r,t.key,t.fullKey)),e.jsx(wl,{oldStr:o,newStr:""})}const a=s.value;return i==="removed"?e.jsx("span",{style:{backgroundColor:Xt.removed,padding:"2px 4px",borderRadius:"3px"},children:a}):e.jsx("span",{children:a})},Sp=s=>{const{data:t}=s,{rawOldValue:n,rawNewValue:r,change:i}=t;if(i==="modified"&&(typeof n=="string"||typeof n=="number"||typeof n=="boolean")&&(typeof r=="string"||typeof r=="number"||typeof r=="boolean")){String(gt(n,t.key,t.fullKey));const o=String(gt(r,t.key,t.fullKey));return e.jsx(wl,{oldStr:"",newStr:o})}const a=s.value;return i==="added"?e.jsx("span",{style:{backgroundColor:Xt.added,padding:"2px 4px",borderRadius:"3px"},children:a}):e.jsx("span",{children:a})},wp=(s,t)=>[{field:"key",headerName:"Key",cellRenderer:Tp,flex:2,minWidth:300,pinned:"left"},{field:"oldValue",headerName:`${s||"Old Value"} (baseline)`,cellRenderer:Cp,flex:1,minWidth:200},{field:"newValue",headerName:t||"New Value",cellRenderer:Sp,flex:1,minWidth:200},{field:"change",headerName:"Change",width:100,minWidth:100}],Rp=()=>Zt.defaultColDef,Fp=()=>s=>({backgroundColor:s.data.change==="same"?"transparent":"#f8f9fa"});function Np({oldJson:s,newJson:t,oldVersionId:n,newVersionId:r}){const[i,a]=g.useState(!0),{preprocessedOldJson:o,preprocessedNewJson:d}=g.useMemo(()=>{let x=null;return t?.layers&&typeof t.layers=="object"&&!Array.isArray(t.layers)&&(x=ce(Object.entries(t.layers),"[1].position").map(([C])=>C)),{preprocessedOldJson:je(s,x),preprocessedNewJson:je(t,x)}},[s,t]),u=g.useMemo(()=>As(o,d),[o,d]),p=g.useMemo(()=>i?u.filter(x=>x.change!=="same"):u,[u,i]),f=x=>{a(x.target.checked)},h=wp(n,r),y=Rp(),b=Fp();return e.jsxs("div",{style:{width:"100%"},children:[e.jsx("div",{className:"mb-3",children:e.jsx(c.Form.Check,{type:"checkbox",id:"showChangesOnly",label:"Show changes only",checked:i,onChange:f})}),e.jsx("div",{className:w.GRID_THEME.QUARTZ.VALUE,style:{height:Zt.height,width:"100%"},children:e.jsx(Se.AgGridReact,{rowData:p,columnDefs:h,defaultColDef:y,animateRows:Zt.animateRows,getRowStyle:b})})]})}const Rl=({showProps:s,selectedRevisions:t})=>{const{show:n,setShow:r}=s,[i,a]=g.useState(!0);if(!n)return null;const o=t.slice(0,2),d=v=>{if(!v||v==="(In Progress)")return null;const E=v.match(/^v(\d+)\.(\d+)$/);return E?[parseInt(E[1],10),parseInt(E[2],10)]:null},u=(v,E)=>{if(!v&&!E)return 0;if(!v)return 1;if(!E)return-1;const[_,R]=v,[F,D]=E;return _!==F?_-F:R-D},p=o[0]?._versionDisplay?.verBase||"(In Progress)",f=o[1]?._versionDisplay?.verBase||"(In Progress)",h=d(p),y=d(f),b=u(h,y);let x,j,C,T;b<=0?(x=o[0]||{},j=o[1]||{},C=p,T=f):(x=o[1]||{},j=o[0]||{},C=f,T=p);const S=()=>{r(!1)};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
4
+ .modal-90w {
5
+ --bs-modal-width: 90vw;
6
+ max-width: 90vw;
7
+ }
8
+ .modal-90w .modal-dialog {
9
+ width: 90vw;
10
+ max-width: 90vw;
11
+ margin: auto;
12
+ display: flex;
13
+ align-items: center;
14
+ min-height: calc(100vh - 3.5rem);
15
+ }
16
+ `}),e.jsxs(c.Modal,{"aria-labelledby":"contained-modal-title-vcenter",show:n,onHide:S,backdrop:"static",dialogClassName:"modal-90w",centered:!0,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsxs(c.Modal.Title,{children:["Compare Revisions",o.length===2&&e.jsx("small",{className:"text-muted ms-2",children:"(Showing differences between selected versions)"})]})}),e.jsx(c.Modal.Body,{style:{maxHeight:"70vh",overflow:"auto",padding:"1rem"},children:o.length<2?e.jsxs("div",{className:"text-center p-4",children:[e.jsx("p",{className:"text-muted",children:"Please select exactly 2 revisions to compare."}),e.jsxs("p",{className:"text-muted",children:["Currently selected: ",t.length," revision(s)"]})]}):e.jsx("div",{children:e.jsx(Np,{oldJson:x,newJson:j,oldVersionId:C,newVersionId:T})})}),e.jsx(c.Modal.Footer,{className:"justify-content-start",children:e.jsx(c.Button,{variant:"secondary",onClick:S,children:"Close"})})]})]})};Rl.propTypes={showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired,selectedRevisions:l.array.isRequired};const us=({onClick:s,disabled:t=!1,selectedCount:n=0})=>e.jsxs(Ne,{variant:"primary",size:"sm",onClick:s,disabled:t,title:n!==2?"Select exactly 2 revisions to compare":"Compare selected revisions",children:["Compare (",n,")"]});us.fnId=Fe.FN_DIFF;us.propTypes={onClick:l.func.isRequired,disabled:l.bool,selectedCount:l.number};us.defaultProps={disabled:!1,selectedCount:0};const kp=jt(us),Lp=new Map([[!1,{idf:"scn_full",fa:"faUpRightAndDownLeftFromCenter",label:"Full Screen"}],[!0,{idf:"scn_full_exit",fa:"faDownLeftAndUpRightToCenter",label:"Exit Full Screen"}]]),Fl=({isFullScreen:s,onToggle:t})=>{const n=Lp.get(s);return e.jsxs(Ne,{onClick:t,size:"sm",variant:"light",children:[I[n?.fa]," ",n?.label]})};Fl.propTypes={isFullScreen:l.bool.isRequired,onToggle:l.func.isRequired};const ps=({onClick:s,disabled:t=!1,text:n=""})=>e.jsxs(Ne,{onClick:s,size:"sm",variant:"primary",disabled:t,className:"me-2",children:[I.faPaperPlane," Contribute to Template Hub ",n]});ps.fnId=Fe.FN_CONTRIBUTE_TEMPLATE;ps.propTypes={onClick:l.func.isRequired,disabled:l.bool,text:l.string};ps.defaultProps={disabled:!1,text:""};const Ap=jt(ps),Ip=()=>{const[s,t]=g.useState(!0),n=()=>{t(!s)};return e.jsxs("div",{className:"d-flex flex-row align-items-stretch",children:[e.jsxs(c.Button,{title:"Important Note for Preview",variant:"danger",size:"sm",onClick:n,className:`d-flex align-items-center px-3 z-1 border-danger text-nowrap ${s?"rounded-start border-end-0":"rounded"}`,children:[e.jsx("span",{className:"me-2",children:I.faExclamationCircle}),e.jsx("span",{className:"me-2",children:"Important"}),s?I.faCaretLeft:I.faCaretRight]}),s&&e.jsxs(c.Alert,{variant:"danger",className:"mb-0 py-0 px-3 border-start-0 d-flex align-items-center rounded-0 rounded-end text-nowrap",children:[e.jsx("span",{style:{fontSize:"0.875rem"},children:"Data entered here will be used as the default value of the template."}),e.jsx("span",{onClick:()=>t(!1),style:{cursor:"pointer",opacity:.6},className:"ms-2 opacity-50",title:"Close",children:I.faTimes})]})]})},Zn=({showProps:s,data:t,currentUser:n,onSubmitSuccess:r})=>{const{show:i,setShow:a}=s,o=g.useRef(),[d,u]=g.useState(!1),[p,f]=g.useState({type:"",content:""}),[h,y]=g.useState({isValid:!0,message:""}),b=()=>{a(!1),f({type:"",content:""}),y({isValid:!0,message:""})},x=v=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(v),j=v=>{const E=v.target.value.trim();E===""?y({isValid:!0,message:""}):x(E)?y({isValid:!0,message:""}):y({isValid:!1,message:"Please enter a valid email address (e.g., user@example.com)"})},C=v=>{if(v.key==="Enter"){const E=v.target.value.trim();E!==""&&!x(E)&&y({isValid:!1,message:"Please enter a valid email address (e.g., user@example.com)"})}},T=()=>{const v=o.current;if(!v)return!1;const E=v.querySelector('[name="contributorName"]'),_=v.querySelector('[name="contributorEmail"]'),R=v.querySelector('[name="contactEmail"]'),F=v.querySelector('[name="application"]'),D=v.querySelector('[name="message"]'),L=E?E.value.trim():"",P=_?_.value.trim():"",G=R?R.value.trim():"",k=F?F.value.trim():"",U=D?D.value.trim():"";return!L||!P||!G||!k||!U?(f({type:"danger",content:"All fields are required. Please fill in all the fields."}),!1):x(G)?!0:(f({type:"danger",content:"Please enter a valid email address."}),!1)},S=async v=>{if(v.preventDefault(),!!T()){u(!0),f({type:"",content:""});try{const E=o.current,_=E.querySelector('[name="contactEmail"]'),R=E.querySelector('[name="application"]'),F=E.querySelector('[name="message"]'),D=t?.properties_release?.klass,L={contact_email:_?_.value.trim():"",application:R?R.value.trim():"",message:F?F.value.trim():"",klass:D||"",id:t?.id,templateUuid:t?.uuid},P=await xe.execApiData(L,"labimotion_hub/submit","POST");P.mc==="se00"?f({type:"danger",content:P.msg||"Failed to submit template contribution."}):(f({type:"success",content:"Template contribution submitted successfully! Thank you for your contribution."}),E.reset(),y({isValid:!0,message:""}),r&&r())}catch{f({type:"danger",content:"An error occurred while submitting. Please try again."})}finally{u(!1)}}};return i?e.jsxs(c.Modal,{show:i,onHide:b,backdrop:"static",keyboard:!1,centered:!0,size:"lg",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Contribute this template to Template Hub"})}),e.jsxs(c.Modal.Body,{children:[p.content&&e.jsx(c.Alert,{variant:p.type,className:"mb-3",children:p.content}),e.jsxs(c.Form,{ref:o,onSubmit:S,children:[e.jsxs(c.Form.Group,{className:"mb-3",children:[e.jsxs(c.Form.Label,{children:["Registered Name ",e.jsx("span",{className:"text-danger",children:"*"})]}),e.jsx(c.Form.Control,{type:"text",name:"contributorName",placeholder:"Enter your full name",required:!0,disabled:!0,defaultValue:Cs(n).name||""})]}),e.jsxs(c.Form.Group,{className:"mb-3",children:[e.jsxs(c.Form.Label,{children:["Registered E-Mail ",e.jsx("span",{className:"text-danger",children:"*"})]}),e.jsx(c.Form.Control,{type:"email",name:"contributorEmail",placeholder:"Enter your email address",required:!0,disabled:!0,defaultValue:Cs(n).email||""})]}),e.jsxs(c.Form.Group,{className:"mb-3",children:[e.jsxs(c.Form.Label,{children:["Contact E-Mail ",e.jsx("span",{className:"text-danger",children:"*"})]}),e.jsx(c.Form.Control,{type:"email",name:"contactEmail",placeholder:"Enter your email address",required:!0,onChange:j,onKeyPress:C,isInvalid:!h.isValid}),!h.isValid&&e.jsx(c.Form.Control.Feedback,{type:"invalid",children:h.message})]}),e.jsxs(c.Form.Group,{className:"mb-3",children:[e.jsxs(c.Form.Label,{children:["Application ",e.jsx("span",{className:"text-danger",children:"*"})]}),e.jsx(c.Form.Control,{type:"text",name:"application",placeholder:"Enter the application name or context",required:!0})]}),e.jsxs(c.Form.Group,{className:"mb-3",children:[e.jsxs(c.Form.Label,{children:["Leave a message ",e.jsx("span",{className:"text-danger",children:"*"})]}),e.jsx(c.Form.Control,{as:"textarea",rows:4,name:"message",placeholder:"Please describe your template, its purpose, and why it would be valuable for the template hub...",required:!0})]}),e.jsxs("div",{className:"text-muted small mb-3",children:[e.jsx("strong",{children:"Template Information:"}),e.jsx("br",{}),"ID: ",t?.uuid||"N/A",e.jsx("br",{}),"Version: ",t?.version||"N/A"]})]})]}),e.jsxs(c.Modal.Footer,{className:"justify-content-start",children:[e.jsx(c.Button,{variant:"secondary",onClick:b,disabled:d,children:"Cancel"}),e.jsx(c.Button,{variant:"primary",onClick:S,disabled:d,children:d?"Submitting...":"Submit to Template Hub"})]})]}):null};Zn.propTypes={showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired,data:l.object,onSubmitSuccess:l.func};Zn.defaultProps={data:{},onSubmitSuccess:null};const oe={MAX_REVISIONS_DISPLAY:10,DEFAULT_COMPARE_UUID:"none",LAYOUT:{REVISION_LIST_COLS:4,PREVIEW_COLS_NORMAL:8,PREVIEW_COLS_FULLSCREEN:12,MIN_PREVIEW_HEIGHT:"50vh"},SOURCES:{PROPERTIES:"properties",PROPERTIES_RELEASE:"properties_release"}},Br={[oe.SOURCES.PROPERTIES]:{fetch:"revisions",delete:"deleteRevision"},[oe.SOURCES.PROPERTIES_RELEASE]:{fetch:"klassRevisions",delete:"deleteKlassRevision"}},Dp=(s,t,n)=>{switch(s){case oe.SOURCES.PROPERTIES:return{id:t.id,type:n.toLowerCase()};case oe.SOURCES.PROPERTIES_RELEASE:return{id:t.id,klass:`${n}Klass`};default:return{}}},Op=(s,t,n,r)=>{switch(s){case oe.SOURCES.PROPERTIES:return{id:r.id,element_id:t.id,klass:n};case oe.SOURCES.PROPERTIES_RELEASE:return{id:r.id,klass_id:t.id,klass:`${n}Klass`};default:return{}}},Pp=(s,t,n)=>s===oe.SOURCES.PROPERTIES?(t||[]).map(i=>({...i,released_at:i.created_at})):[{metadata:{...n.metadata},properties_release:{...n.properties_template},uuid:n.properties_template.uuid,version:n.properties_template.version,klass_id:n.id,id:0},...t||[]],Gp=(s,t)=>s===oe.SOURCES.PROPERTIES_RELEASE&&t?.properties_template?ge([t.properties_template.uuid,t.properties_template.id||0]):oe.DEFAULT_COMPARE_UUID,fs=({genericType:s,data:t={},refSource:n={currentUser:{}},fnRetrieve:r=()=>{},src:i=oe.SOURCES.PROPERTIES_RELEASE,canDL:a=!1})=>{const[o,d]=g.useState([]),[u,p]=g.useState([]),[f,h]=g.useState(!1),[y,b]=g.useState(!1),[x,j]=g.useState(()=>Gp(i,t)),[C,T]=g.useState(!1),S=()=>{t?.id&&fe[Br[i].fetch](Dp(i,t,s)).then(O=>{O.notify.isSuccess&&d(Pp(i,O.element?.data?.revisions||[],t))})},v=g.useCallback(O=>{fe[Br[i].delete](Op(i,t,s,O)).then(V=>{V.notify.isSuccess&&S()})},[i,t]);g.useEffect(()=>{S()},[]);const E=g.useCallback(O=>{let V=(o||[]).find(z=>ge([z.uuid,z.id])===x);V&&V[i]&&(V=O,d([...o]))},[x,o,i]),_=g.useCallback(O=>{j(ge([O.uuid,O.id]))},[o]),R=g.useCallback(O=>{const V=X(o.find(z=>z.id===O.id));i===oe.SOURCES.PROPERTIES_RELEASE?(t.properties_template=V[i],t.metadata=V.metadata,r(yt(se(),t,{active:"w"}))):r({metadata:V.metadata,[i]:V[i]},()=>{})},[r,o,i,t]),F=g.useCallback(O=>{const V=o.find(J=>J.id===O.id),z=X(V.properties_release);z.klass=V.properties_release.klass,z.released_at=V.released_at||"",z.metadata=V.metadata||{};const K=`data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(z))}`;m.downloadFile({contents:K,name:`${z.klass}_${t.label}_${V.uuid}.json`})},[t,o]),D=g.useCallback((O,V,{verID:z,verBase:K})=>{p(J=>V?J.length<2&&!J.some($=>ge([$.uuid,$.id])===ge([O.uuid,O.id]))?[...J,{...O[i],uuid:O.uuid,id:O.id,_versionDisplay:{verID:z,verBase:K}}]:J:J.filter($=>{const H=ge([$.uuid,$.id]),Z=ge([O.uuid,O.id]);return H!==Z}))},[i]),L=g.useCallback(()=>{h(!0)},[]),P=g.useCallback(O=>u.some(V=>{const z=ge([V.uuid,V.id]),K=ge([O.uuid,O.id]);return z===K}),[u]),G=g.useCallback(()=>{T(O=>!O)},[]),k=g.useCallback(()=>{b(!0)},[]),U=g.useCallback(()=>{S()},[]);if(o.length<1)return null;const N=[],A=(o||[]).find(O=>ge([O.uuid,O.id])===x)||{},q=A&&A[i]&&A[i].select_options||{},Y=A.submitted||0,B=()=>Y===0?"":Y===1?"(1 time)":`(${Y} times)`;A.name&&N.push({generic:A,type:m.FieldTypes.F_TEXT,isEditable:!0,isRequire:!1,field:"name"}),A[i]=A[i]||{},A[i].layers=A[i].layers||{},i===oe.SOURCES.PROPERTIES?A.properties_release={select_options:q}:A.properties=A.properties_release;const M=e.jsx(nt,{generic:A||{},fnChange:E,extLayers:N,genId:A.uuid||0,isPreview:i===oe.SOURCES.PROPERTIES_RELEASE,editMode:i===oe.SOURCES.PROPERTIES_RELEASE,isActiveWF:!1,genericType:s});return e.jsxs(_e,{className:"g-0",children:[!C&&e.jsxs(he,{md:oe.LAYOUT.REVISION_LIST_COLS,children:[e.jsxs("div",{className:"d-flex align-items-center justify-content-between mb-2",children:[e.jsxs("b",{children:["Only show the latest ",oe.MAX_REVISIONS_DISPLAY," ","revisions."]}),e.jsx(kp,{onClick:L,disabled:u.length!==2,selectedCount:u.length})]}),o.map((O,V)=>e.jsx(cs,{data:t,download:{canDL:a,fnDownload:F},idxSelect:`${V}:${x}`,rev:O,src:i,fnDelete:v,fnRetrieve:R,fnView:_,isSelected:P(O),onSelectionChange:D},ge([O.uuid,O.id])))]}),e.jsxs(he,{md:C?oe.LAYOUT.PREVIEW_COLS_FULLSCREEN:oe.LAYOUT.PREVIEW_COLS_NORMAL,children:[e.jsxs("div",{className:"d-flex align-items-center justify-content-between ms-1 mb-2",children:[e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsxs("div",{className:"me-2",children:[A.version&&A.released_at&&e.jsx(Jt,{bg:"info",className:"fs-6",children:`v${A.version}`}),!A.version&&e.jsx("span",{})]}),i===oe.SOURCES.PROPERTIES_RELEASE&&e.jsx(Ip,{})]}),e.jsxs("div",{className:"d-flex align-items-center",children:[e.jsx(Ap,{onClick:k,disabled:!A.id||!A.version||!n.currentUser?.id,text:B()}),e.jsx(Fl,{isFullScreen:C,onToggle:G})]})]}),Object.keys(A).length!==0&&e.jsx("div",{style:{width:"100%",minHeight:oe.LAYOUT.MIN_PREVIEW_HEIGHT},children:M})]}),e.jsx(Rl,{showProps:{show:f,setShow:h},selectedRevisions:u}),e.jsx(Zn,{showProps:{show:y,setShow:b},data:A,currentUser:n.currentUser,onSubmitSuccess:U})]})};fs.propTypes={genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,data:l.object,fnRetrieve:l.func,canDL:l.bool,src:l.oneOf([oe.SOURCES.PROPERTIES_RELEASE,oe.SOURCES.PROPERTIES])};fs.defaultProps={data:{},fnRetrieve:()=>{},src:oe.SOURCES.PROPERTIES_RELEASE,canDL:!1};const Qn=s=>{const{data:t,vocabularies:n,fnSubmit:r,genericType:i,refSource:a}=s,[o,d]=g.useState({data:t,notify:null,active:"w"});if(g.useEffect(()=>{d(h=>({...h,data:t,notify:null,active:"w"}))},[t]),!t||Object.keys(t).length===0)return null;const u=h=>{const{element:y,notify:b,additional:x}=h;b.isSuccess?d(j=>({...j,data:y,notify:b,active:x?.active?x?.active:j.active})):d(j=>({...j,notify:b}))},p=h=>{d(y=>({...y,active:h}))},f=h=>{const{data:y,release:b}=h,x=Oa(y);r(x,b)};return e.jsxs("div",{children:[e.jsx(Qs,{notify:o.notify,active:o.active,fnSwitch:p}),e.jsxs("div",{className:"mt-3",style:{overflowY:"auto",maxHeight:"58vh",height:"58vh"},children:[o.active==="w"&&e.jsx(Xn,{data:o.data,vocabularies:n,genericType:i,innerAction:u,fnSubmit:f}),o.active==="p"&&e.jsx(fs,{genericType:i,data:o.data,refSource:a,fnRetrieve:u,canDL:!0})]})]})};Qn.propTypes={data:l.object,fnSubmit:l.func.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,vocabularies:l.array,refSource:l.object};Qn.defaultProps={vocabularies:[],refSource:{}};const Nl=s=>{const{genericType:t,fnUpload:n,showProps:r}=s,{show:i,setShow:a}=r,o=u=>{const p=Lu(u,t);n(p),a(!1)},d=u=>{const p=new FileReader;p.onload=o,p.readAsText(u[0])};return e.jsxs(c.Modal,{size:"lg",centered:!0,show:i,onHide:()=>a(!1),children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:`Import ${t} and its template`})}),e.jsx(c.Modal.Body,{style:{overflow:"auto"},children:e.jsx(Os,{onDrop:u=>d(u),className:"lu-drop-zone",style:{height:50},children:e.jsx("div",{style:{paddingTop:12},children:"Drop File, or Click to Select."})})})]})};Nl.propTypes={genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnUpload:l.func.isRequired,showProps:l.shape({show:l.bool.isRequired,setShow:l.func.isRequired}).isRequired};function Jn(s){const{fnUpload:t,genericType:n}=s,[r,i]=g.useState(!1);return n===w.GENERIC_TYPES.DATASET?null:e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:`imp_${n.toLowerCase()}_n_temp`,children:e.jsxs(c.Button,{onClick:()=>i(!0),variant:"outline-secondary",className:"gu-btn-outline-secondary",children:[I.faFileImport," Import"]})}),e.jsx(Nl,{fnUpload:t,genericType:n,showProps:{show:r,setShow:i}})]})}Jn.propTypes={genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnUpload:l.func};Jn.defaultProps={fnUpload:()=>{}};const er=s=>{const{data:t,fnApi:n,node:r}=s,i=a=>{r.setSelected(!0,!0),n(a)};return e.jsx("span",{children:e.jsx(ue,{idf:"tpl_fetch",fa:"faArrowsRotate",element:t,fnClick:i})})},ft={[w.GENERIC_TYPES.ELEMENT]:"generic_elements",[w.GENERIC_TYPES.SEGMENT]:"segments",[w.GENERIC_TYPES.DATASET]:"generic_dataset"};class Te{static#e=Ht.exec;static#t=Ht.execRaw;static deleteVersion=t=>Te.#e(`${ft[w.GENERIC_TYPES.ELEMENT]}/delete_revision`,"POST",t);static getVersions=(t,n)=>Te.#e(`${ft[w.GENERIC_TYPES.ELEMENT]}/${t}_revisions.json`,"GET",null,n);static saveTemplate=(t,n={})=>Te.#e(`${ft[t]}/create_repo_klass`,"POST",n);static getAllTemplates=t=>Te.#e(`${ft[t]}/fetch_repo`);static exportAsFile=t=>Te.#t(`${ft[w.GENERIC_TYPES.ELEMENT]}/export.json`,"GET",null,t)}function kl({fnApi:s}){const[t,n]=g.useState([]),[r,i]=g.useState(!0),a=g.useMemo(()=>({minWidth:100,flex:1}),[]),o=g.useCallback(()=>{(async()=>{i(!0);const p=await Te.getAllTemplates(w.GENERIC_TYPES.DATASET);p.error?console.error(p.error):n(p.element.data||[]),i(!1)})()},[]),d=[{hide:!0,headerName:"#",sortable:!1},{headerName:"Action",cellRenderer:er,cellRendererParams:{fnApi:s}},{headerName:"Chemical Methods Ontology",field:"label",flex:3},{headerName:"Version",field:"version"},{headerName:"Released at",minWidth:120,field:"released_at",flex:2},{headerName:"Identifier",minWidth:120,field:"identifier"}];return e.jsx("div",{className:w.GRID_THEME.QUARTZ.VALUE,style:{height:"600px",width:"100%",overflow:"auto"},children:e.jsx(Se.AgGridReact,{loading:r,onGridReady:o,columnDefs:d,defaultColDef:a,rowData:t,domLayout:"normal",suppressAutoSize:!0})})}kl.propTypes={fnApi:l.func.isRequired};function Mp(s){const{data:t}=s;return e.jsxs(e.Fragment,{children:[t.element_klass?.label," ",e.jsx("i",{className:t.element_klass?.icon_name,"aria-hidden":"true"})]})}function Ll({fnApi:s}){const[t,n]=g.useState([]),[r,i]=g.useState(!0),a=g.useMemo(()=>({minWidth:100,flex:1}),[]),o=g.useCallback(()=>{(async()=>{i(!0);const p=await Te.getAllTemplates(w.GENERIC_TYPES.SEGMENT);p.error?console.error(p.error):n(p.element.data||[]),i(!1)})()},[]),d=[{hide:!0,headerName:"#",sortable:!1},{headerName:"Action",cellRenderer:er,cellRendererParams:{fnApi:s}},{headerName:"Label",field:"label",flex:2},{headerName:"Belongs to",field:"element_klass.name",cellRenderer:Mp,flex:2},{headerName:"Version",field:"version"},{headerName:"Released at",field:"released_at",flex:2},{headerName:"Identifier",field:"identifier"}];return e.jsx("div",{className:w.GRID_THEME.QUARTZ.VALUE,style:{height:"600px",width:"100%",overflow:"auto"},children:e.jsx(Se.AgGridReact,{loading:r,onGridReady:o,columnDefs:d,defaultColDef:a,rowData:t,domLayout:"normal",suppressAutoSize:!0})})}Ll.propTypes={fnApi:l.func.isRequired};function Al({fnApi:s}){const[t,n]=g.useState([]),[r,i]=g.useState(!0),a=g.useMemo(()=>({minWidth:100,flex:1}),[]),o=g.useCallback(()=>{(async()=>{i(!0);const p=await Te.getAllTemplates(w.GENERIC_TYPES.ELEMENT);p.error?console.error(p.error):n(p.element?.data||[]),i(!1)})()},[]),d=[{hide:!0,headerName:"#",sortable:!1},{headerName:"Action",cellRenderer:er,cellRendererParams:{fnApi:s}},{headerName:"Name",field:"name"},{headerName:"Element Label",field:"label",flex:2},{headerName:"Description",field:"description",flex:2},{headerName:"Version",field:"version"},{headerName:"Released at",field:"released_at",flex:2},{headerName:"Identifier",field:"identifier"}];return e.jsx("div",{className:w.GRID_THEME.QUARTZ.VALUE,style:{height:"600px",width:"100%",overflow:"auto"},children:e.jsx(Se.AgGridReact,{loading:r,onGridReady:o,columnDefs:d,defaultColDef:a,rowData:t,domLayout:"normal",suppressAutoSize:!0})})}Al.propTypes={fnApi:l.func.isRequired};const $p={Dataset:kl,Segment:Ll,Element:Al};function tr({showModal:s,fnClose:t,fnCreate:n,content:r}){const i=$p[r];if(!i)return null;const a=`Generic ${r} Templates`;return e.jsxs(c.Modal,{centered:!0,backdrop:"static",size:"lg",show:s,onHide:t,dialogClassName:"gu_modal-68w",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:a})}),e.jsx(c.Modal.Body,{style:{overflow:"auto"},children:e.jsx(i,{fnApi:n})})]})}tr.propTypes={showModal:l.bool.isRequired,content:l.string.isRequired,fnClose:l.func.isRequired,fnCreate:l.func.isRequired};function sr(s){const{fnRefresh:t,genericType:n,fnCallback:r}=s,[i,a]=g.useState(!1),o=()=>a(!0),d=()=>a(!1),u=async p=>{try{const f=await Te.saveTemplate(n,{identifier:p.identifier});f.notify.isSuccess?t():r(new ee(f.notify,[]))}catch(f){console.error("Error creating template:",f),r(new ee(te(`Error creating template: ${f}`),[]))}finally{a(!1)}};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"tpl_view_hub",children:e.jsxs(c.Button,{variant:"primary",onClick:o,children:[I.faArrowsRotate," Fetch from LabIMotion Hub"]})}),e.jsx(tr,{content:n,fnClose:d,fnCreate:u,showModal:i})]})}sr.propTypes={fnRefresh:l.func.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnCallback:l.func};sr.defaultProps={fnCallback:()=>{}};const qp={[w.GENERIC_TYPES.ELEMENT]:"Generic Elements Designer",[w.GENERIC_TYPES.SEGMENT]:"Generic Segments Designer",[w.GENERIC_TYPES.DATASET]:"Generic Datasets Designer"},Bp=s=>{const t=qp[s];return e.jsxs("div",{className:"col-auto",children:[e.jsx("span",{children:"You're in the "}),e.jsx("span",{className:"fw-bold",children:t})]})},Up=s=>{const{fnCopy:t,fnCreate:n,fnUpload:r,fnDelete:i,fnSubmit:a,fnActive:o,fnDownload:d,fnUpdate:u,fnRefresh:p,genericType:f,gridData:h=[],klasses:y,preview:b,refSource:x={currentUser:{}}}=s,[j,C]=g.useState(w.GRID_THEME.QUARTZ.VALUE),[T,S]=g.useState(null),[v,E]=g.useState(""),_=g.useRef(),R=g.useRef(),F=g.useRef(),D=g.useMemo(()=>ce(y||[],["label"]),[y]);g.useEffect(()=>{if(h.length>0&&T){const A=h.find(q=>q.id===T.id);A&&A.properties_template?.uuid!==T.properties_release?.uuid&&S(X(A))}},[h]);const L=A=>{if(A){const q=X(A);S(q)}},P=g.useCallback(()=>{E(_.current.value)},[]),G=g.useCallback(A=>{R.current=A},[]),k=g.useCallback(A=>{F.current=A},[]),U=g.useCallback(()=>{S(null),E(""),_.current&&(_.current.value=""),F.current&&F.current(),R.current&&R.current()},[]),N=()=>{switch(f){case w.GENERIC_TYPES.ELEMENT:return e.jsx(Ks,{fnCopyKlass:t,fnDeActivateKlass:o,fnDownloadKlass:d,fnDeleteKlass:i,fnEditKlass:u,fnShowProp:L,gridData:h,pageSize:ys(j),theme:j,rowSelected:T!==null,filterText:v,onSetAutoHeight:G,onClearSelection:k});case w.GENERIC_TYPES.SEGMENT:return e.jsx(Xs,{fnCopyKlass:t,fnDeActivateKlass:o,fnDownloadKlass:d,fnDeleteKlass:i,fnEditKlass:u,fnShowProp:L,gridData:h,pageSize:ys(j),theme:j,rowSelected:T!==null,filterText:v,onSetAutoHeight:G,onClearSelection:k});case w.GENERIC_TYPES.DATASET:return e.jsx(Zs,{fnCopyKlass:t,fnDeActivateKlass:o,fnDownloadKlass:d,fnEditKlass:u,fnShowProp:L,gridData:h,pageSize:ys(j),theme:j,rowSelected:T!==null,filterText:v,onSetAutoHeight:G,onClearSelection:k});default:return e.jsx(e.Fragment,{children:"Undefined Data."})}};return e.jsxs(oa,{value:{klasses:D,genericType:f},children:[e.jsxs(c.Row,{className:"mb-2 align-items-center",children:[e.jsx(c.Col,{xs:"auto",children:e.jsxs(c.ButtonToolbar,{style:{display:"inline-block"},children:[e.jsx(sr,{fnRefresh:p,genericType:f}),e.jsx(Us,{btnNew:e.jsx(Bs,{fnCreate:n,genericType:f}),btnUpload:e.jsx(Jn,{fnUpload:r,genericType:f}),fnClickLarge:()=>C(w.GRID_THEME.QUARTZ.VALUE),fnClickSmall:()=>C(w.GRID_THEME.BALHAM.VALUE),children:e.jsx(c.Button,{variant:"outline-secondary",onClick:U,className:"gu-btn-outline-secondary",children:"Full List"})})]})}),e.jsx(c.Col,{children:e.jsxs("div",{className:"d-flex gap-2",children:[e.jsxs("div",{className:"position-relative flex-grow-1",children:[e.jsx("span",{className:"position-absolute top-50 translate-middle-y ms-2 text-muted",children:I.faMagnifyingGlass}),e.jsx(c.Form.Control,{ref:_,type:"text",placeholder:"Enter text to filter...",style:{paddingLeft:"2rem"},onChange:P})]}),e.jsx(c.OverlayTrigger,{delayShow:1e3,placement:"top",overlay:e.jsx(c.Tooltip,{id:"_field_docsite_tooltip",children:"Learn more"}),children:e.jsx(c.Button,{variant:"link",href:[mt.DOC_SITE,"designer"].join("/"),target:"_blank",onClick:A=>A.stopPropagation(),children:I.faCircleQuestion})})]})}),Bp(f)]}),N(),T?e.jsx(Qn,{data:T,fnSubmit:a,fnUpdate:u,genericType:f,preview:b,refSource:x}):e.jsx(e.Fragment,{})]})},Il=g.forwardRef(({element:s},t)=>{const n=s?.properties?.layers||{},r=s?.metadata||{groups:[],restrict:{}},[i,a]=g.useState(n),[o,d]=g.useState(r),u=g.useRef(null);if(g.useEffect(()=>{const E=et(n,r);a(E.layers),d(E.metadata)},[]),g.useImperativeHandle(t,()=>({getUpdates:()=>({layers:i,metadata:o})})),!s?.properties?.layers||Object.values(n).length===0)return Ut;const f=(E,_)=>{const R=_.groups||[],F=Object.values(E),D=new Set;R.forEach(k=>{k.layers?.forEach(U=>D.add(U))});const L=F.filter(k=>!D.has(k.key)),P=[...R.map(k=>({type:"group",data:k,position:k.position||0})),...L.map(k=>({type:"layer",data:k,position:k.position||0}))];return{items:ce(P,"position"),allLayers:E}},h=f(n,r),y=f(i,o),b=(E,_,R)=>{const F=[...o.groups||[]],D=F.findIndex(A=>A.id===R);if(D===-1)return;const L=F[D],P=L.layers||[],G=P.indexOf(E),k=P.indexOf(_);if(G===-1||k===-1)return;const U=[...P],[N]=U.splice(G,1);U.splice(k,0,N),F[D]={...L,layers:U},d({...o,groups:F})},x=(E,_)=>{const R=y.items.findIndex(k=>k.type==="group"&&k.data.id===E||k.type==="layer"&&k.data.key===E),F=y.items.findIndex(k=>k.type==="group"&&k.data.id===_||k.type==="layer"&&k.data.key===_);if(R===-1||F===-1)return;const D=[...y.items],[L]=D.splice(R,1);D.splice(F,0,L);const P=[...o.groups||[]],G={...i};D.forEach((k,U)=>{if(k.type==="group"){const N=P.findIndex(A=>A.id===k.data.id);N!==-1&&(P[N]={...P[N],position:U},P[N].layers?.forEach(A=>{G[A]&&(G[A]={...G[A],position:U})}))}else if(k.type==="layer"){const N=k.data.key;G[N]&&(G[N]={...G[N],position:U})}}),d({...o,groups:P}),a(G)},j=(E,_=!1,R=null)=>{const{label:F,color:D,style:L="panel_generic_heading",wf:P,key:G,fields:k}=E;if(!m.isLayerVisible(E,_?i:n))return null;const N=e.jsx("div",{className:`${Ve(D)} p-3 rounded`,style:{userSelect:"none"},children:Ya(L,F,G,k,P)});return!_&&!R||P?e.jsx("div",{className:"w-100 p-2 m-2",children:e.jsx("div",{children:N})},`${G}-${_?"new":"current"}`):R?e.jsx(Ae,{type:`layer-in-group-${R}`,layer:E,field:"position",handleMove:(A,q)=>b(A,q,R),canDrag:!0,children:N},`${G}-${_?"new":"current"}`):e.jsx(Ae,{type:"top-level-item",layer:{type:"layer",key:G,label:F,position:E.position},field:"position",handleMove:(A,q)=>x(A,q),canDrag:!0,children:N},`${G}-${_?"new":"current"}`)},C=(E,_=!1,R=null)=>j(E,_,R),T=(E,_=!1)=>{const R=E.layers?.map(D=>(_?y:h).allLayers[D]).filter(Boolean)||[],F=e.jsxs("div",{className:"border border-2 border-secondary rounded p-2 mb-2",style:{userSelect:"none"},children:[e.jsxs("div",{className:"d-flex align-items-center mb-2",children:[e.jsx(Jt,{bg:"secondary",className:"me-2",children:I.faLayerGroup}),e.jsx("strong",{children:E.label})]}),e.jsxs("div",{children:[R.map(D=>C(D,_,E.id)),R.length===0&&e.jsx("div",{className:"text-muted fst-italic",children:"No layers in this group"})]})]},`group-${E.id}-${_?"new":"current"}`);return _?e.jsx(Ae,{type:"top-level-item",layer:{type:"group",id:E.id,label:E.label,key:E.id,position:E.position},field:"position",handleMove:(D,L)=>x(D,L),canDrag:!0,children:F},`group-${E.id}-new`):e.jsx("div",{className:"w-100 p-2 m-2",children:F},`group-${E.id}-current`)},S=()=>{const{items:E}=h;return e.jsx(e.Fragment,{children:E.map(_=>_.type==="group"?T(_.data,!1):C(_.data,!1,null))})},v=()=>{const{items:E}=y;return e.jsx(e.Fragment,{children:E.map(_=>_.type==="group"?T(_.data,!0):C(_.data,!0,null))})};return e.jsxs("div",{className:"d-flex flex-column h-100",children:[e.jsxs(_e,{className:"mx-0 p-3",children:[e.jsx(he,{md:6,children:e.jsx(Ze,{title:"Current Arrangement",children:"The existing arrangement"})}),e.jsx(he,{md:6,className:"text-primary",children:e.jsxs(Ze,{title:"New Arrangement",children:["Drag (",I.faArrowsUpDownLeftRight,") groups and layers to reorder. Layers within groups can only be reordered within their group."]})})]}),e.jsx("div",{ref:u,className:"flex-grow-1",style:{overflowY:"auto",overflowX:"hidden",minHeight:0,position:"relative"},children:e.jsxs(_e,{className:"mx-0 h-100",children:[e.jsx(he,{md:6,style:{position:"relative"},children:S()}),e.jsx(he,{md:6,style:{position:"relative"},children:v()})]})}),e.jsx(rn,{scrollableContainerRef:u})]})});Il.displayName="ArrangeContent";function nr({generic:s={},genericType:t,fnSave:n=()=>{}}){const[r,i]=g.useState(!1),a=g.useRef(null);if(s?.is_new||Object.keys(s.properties).length===0||t===w.GENERIC_TYPES.DATASET)return null;const o=d=>{const u=X(s);u.properties.layers=d.layers;const p=d.metadata?.groups||[];p.length===0?u.metadata={}:u.metadata={groups:p,restrict:d.metadata?.restrict||{}},u.changed=!0,n(u)};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"arrange_layer",children:e.jsxs(c.Button,{size:"sm",variant:"primary",onClick:()=>i(!0),children:[I.faBars," Arrange"]})}),e.jsx(ts,{genericType:t,showProps:{show:r,setShow:i},onSave:o,children:e.jsx(Il,{ref:a,element:X(s||{})})})]})}nr.propTypes={generic:l.object,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT]).isRequired,fnSave:l.func};nr.defaultProps={generic:{},fnSave:()=>{}};const Vp={selectorNode:Yn},Is=(s,t)=>{const n=tp(s?.layers||{});return sp(n,t)},zp=({properties:s={},metadata:t={},nodes:n=[]})=>{if(!s||Object.keys(s).length<1)return null;const r=Is(s,t),i=ce(r,d=>d.position)||[],a=n.map(d=>d.data.lKey),o=i.filter(d=>!a.includes(d.key));return e.jsxs("aside",{children:[e.jsx("div",{className:"description",children:"You can drag the nodes listed below to the left pane to design your flow."}),e.jsx("div",{className:"description",children:"To remove the node from the pane, click on the node and press 'Del' button."}),e.jsx(zn,{nodes:o})]})},Dl=({element:s,fnSave:t})=>{const{properties:n,metadata:r}=s,[i]=g.useState(n?.u?.draw||{}),a=g.useRef(null),[o,d]=g.useState(null),[u,p]=g.useState(Mr(i.nodes||[],Object.keys(Is(n,r)))),[f,h]=g.useState(i.edges||[]),[y,b]=g.useState(!1),x=g.useCallback(()=>{if(o){const E=o.toObject();t({draw:E})}},[o,t]);g.useEffect(()=>{y&&(x(),b(!1))},[y,x]);const j=g.useCallback(E=>{p(_=>re.applyNodeChanges(E,_)),b(!0)},[]),C=g.useCallback(E=>{h(_=>re.applyEdgeChanges(E,_)),b(!0)},[]),T=g.useCallback(E=>{h(_=>re.addEdge({...E,animated:!0,markerEnd:{type:re.MarkerType.ArrowClosed},label:"next"},_)),b(!0)},[]),S=(E,_)=>{if(o){const R=_.getClientOffset(),F=a.current.getBoundingClientRect();let D={x:R.x-F.left,y:R.y-F.top};D=o.project(D);const L=El({layer:E,position:D});p(P=>P.concat(L))}},[,v]=be.useDrop({accept:"lim-dnd-type",drop:(E,_)=>{S(E,_)},collect:E=>({isOver:E.isOver(),canDrop:E.canDrop()})});return g.useEffect(()=>{const E=n?.u?.draw||{};Object.keys(E).length!==0&&(p(Mr(E.nodes||[],Object.keys(Is(n,r)))),h(E.edges||[]))},[n]),e.jsx("div",{ref:v,className:"dndflow",children:e.jsxs(re.ReactFlowProvider,{children:[e.jsx("div",{className:"reactflow-wrapper",ref:a,children:e.jsx(re,{nodes:u,edges:f,onConnect:T,onNodesChange:j,onEdgesChange:C,onInit:d,connectionMode:re.ConnectionMode.Loose,nodeTypes:Vp,deleteKeyCode:["Delete","Backspace"],fitView:!0,children:e.jsx(re.Controls,{})})}),e.jsx(zp,{properties:n,metadata:r,nodes:u})]})})};Dl.propTypes={element:l.object.isRequired,fnSave:l.func.isRequired};function rr({generic:s={},genericType:t,fnSave:n=()=>{}}){const[r,i]=g.useState(!1);if(s?.is_new||Object.keys(s.properties).length===0||t!==w.GENERIC_TYPES.ELEMENT)return null;const a=({draw:o})=>{const d=X(s||{});let{nodes:u}=o;const p={...o};d.properties&&(u.length===0?delete d.properties.u:(u=u.map(f=>{if(f.type===w.NODE_TYPES.DEFAULT){const{label:h,...y}=f.data;return{...f,data:y}}return f}),p.nodes=u,Object.assign(d.properties,{u:{draw:p}})),d.changed=!0,n(d))};return e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"draw_flow",children:e.jsxs(Ne,{size:"sm",variant:"primary",onClick:()=>i(!0),children:[e.jsx(De,{wf:!0})," ",I.faPaintbrush," Workflow (Custom)"]})}),e.jsx(os,{genericType:t,showProps:{show:r,setShow:i},children:e.jsx(Dl,{element:X(s||{}),fnSave:a})})]})}rr.propTypes={generic:l.object,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT]).isRequired,fnSave:l.func};rr.defaultProps={generic:{},fnSave:()=>{}};const Yp={selectorNode:Yn},ir=({properties:s,propertiesRelease:t})=>{const n=g.useRef(null),[,r]=g.useState(null),[i,a]=g.useState(()=>Kt({properties:s,propertiesRelease:t})),[o,,d]=re.useNodesState(i.nodes),[u,,p]=re.useEdgesState(i.edges||[]);return g.useEffect(()=>{a(Kt({properties:s,propertiesRelease:t}))},[s,t]),e.jsx("div",{className:"dndflow",children:e.jsx(re.ReactFlowProvider,{children:e.jsx("div",{className:"reactflow-wrapper",ref:n,children:e.jsx(re,{nodes:o,edges:u||[],onNodesChange:d,onEdgesChange:p,onInit:r,nodeTypes:Yp,fitView:!0,children:e.jsx(re.Controls,{})})})})})};ir.propTypes={properties:l.object.isRequired,propertiesRelease:l.object.isRequired};const Ol=({generic:s})=>{const[t,n]=g.useState(!1),r=s.properties||{},i=s.properties_release||{};if(s?.is_new||Object.keys(i||{}).length<1)return null;const a=Object.keys(i.flow||{}).length>0&&i.flow?.elements?.length>2||!1,o=Object.keys(i.flowObject||{}).length>0&&i.flowObject?.nodes?.length>2||!1;return!a&&!o?null:e.jsxs(e.Fragment,{children:[e.jsx(Q,{idf:"fl_view",children:e.jsxs(Ne,{size:"sm",variant:"primary",onClick:()=>n(!0),children:[e.jsx(De,{wf:!0})," Workflow (Predefined)"]})}),e.jsx(os,{showProps:{show:t,setShow:n},children:e.jsx(ir,{properties:r,propertiesRelease:i})})]})};Ol.propTypes={generic:l.object.isRequired};const lr=({generic:s,variant:t,size:n})=>{const[r,i]=g.useState(!1);if(s?.is_new||![w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET].includes(s.properties?.klass))return null;const a=async()=>{try{i(!0);const o=await Te.exportAsFile({id:s.id,klass:s.properties?.klass,export_format:"docx"});await Ti(o)}catch(o){console.error("Error exporting file:",o)}finally{i(!1)}};return e.jsxs(ct,{tooltipId:"export_docx",size:n,variant:t,onClick:a,disabled:r,children:[r?I.faSpinner:I.faFileWord," Export"]})};lr.propTypes={generic:l.object,variant:l.string,size:l.string};lr.defaultProps={generic:{},variant:"primary",size:"sm"};function Hp(){return e.jsxs("div",{children:[e.jsx(Ds.FontAwesomeIcon,{icon:W.faSpinner,spin:!0,size:"2x"}),e.jsx("p",{children:"Loading..."})]})}const ar=({show:s,fnClose:t,fnRetrieve:n,element:r,genericType:i})=>{const[a,o]=g.useState(!1);if(![w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET].includes(i))return null;const d=()=>{t()},u=(p,f)=>{n(p,f)};return e.jsxs(c.Modal,{centered:!0,show:s,onHide:d,fullscreen:!0,backdrop:"static",children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"Previous Versions"})}),e.jsx(c.Modal.Body,{className:"d-flex flex-column",style:{height:"calc(100vh - 56px)"},children:a?e.jsx("div",{className:"d-flex justify-content-center align-items-center flex-grow-1",children:e.jsx(Hp,{})}):e.jsx("div",{className:"flex-grow-1 overflow-auto",children:e.jsx(fs,{genericType:i,data:r,fnRetrieve:u,src:"properties"})})})]})};ar.propTypes={show:l.bool.isRequired,fnClose:l.func.isRequired,fnRetrieve:l.func,element:l.object,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired};ar.defaultProps={element:{},fnRetrieve:()=>{}};const hs=({generic:s,genericType:t,fnRetrieve:n})=>{const[r,i]=g.useState(!1);if(![w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET].includes(t))return null;if(s?.is_new)return e.jsxs(c.Button,{onClick:()=>{},size:"sm",variant:"primary",disabled:!0,children:[I.faClockRotateLeft," No Revision"]});const a=(o,d)=>{i(!1),n(o,d)};return e.jsxs(e.Fragment,{children:[e.jsx(c.OverlayTrigger,{delayShow:1e3,placement:"top",overlay:e.jsx(c.Tooltip,{id:ie.v4(),children:"View the revisions"}),children:e.jsxs(c.Button,{onClick:()=>i(!r),size:"sm",variant:"primary",children:[I.faClockRotateLeft," Revision"]})}),r&&e.jsx(ar,{fnRetrieve:a,show:r||!1,fnClose:()=>i(!1),element:s,genericType:t})]})};hs.propTypes={generic:l.object.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,fnRetrieve:l.func};hs.defaultProps={fnRetrieve:()=>{}};function Qt(s){const{klass:t,generic:n,fnReload:r}=s;if(n&&(typeof n.klass_uuid>"u"||n.klass_uuid===t.uuid||n.is_new))return null;const i=()=>{const a=X(n);let o=n;const d=oc(n,t);if(d[1]){o.properties=d[1],o.properties_release=t.properties_release,o.metadata=t.metadata||{},o.changed=!0;const u=dc(a,o);if(u[0]){o=u[1];const p=ce(Object.values(o.properties.layers),["position","wf_position"]),f=m.orgLayerObject(p),h=et(f,o.metadata);o.properties.layers=h.layers,o.metadata=h.metadata}}else o=d[1];r(o)};return e.jsx(Q,{idf:"reload_temp",children:e.jsxs(c.Button,{size:"sm",variant:"primary",onClick:()=>i(),children:[I.faArrowsRotate," Reload"]})})}Qt.propTypes={klass:l.object,generic:l.object,fnReload:l.func};Qt.defaultProps={klass:{},generic:{},fnReload:()=>{}};const or=({generic:s,genericType:t,klass:n,fnReload:r,fnRetrieve:i,onExpandAll:a,editMode:o})=>{const{showOverview:d,toggleOverview:u,isProviderPresent:p}=Di(),[f,h]=g.useState(!1),y=()=>{const x=!f;h(x),a(x)};if(![w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET].includes(t))return null;const b=We(o,!0);return t===w.GENERIC_TYPES.DATASET?b?e.jsx(yr,{className:"p-1 gap-1",children:e.jsx(Qt,{klass:n,generic:s,fnReload:r})}):null:e.jsxs(yr,{className:"p-1 gap-1 d-flex",children:[p&&e.jsxs(Ne,{variant:"primary",size:"sm",onClick:u,title:d?"Hide Overview Map":"Show Overview Map",children:[I.faChartBar," ","Overview Map"]}),e.jsxs(Ne,{variant:"primary",size:"sm",onClick:y,title:f?"Collapse all Layers":"Expand all Layers",style:{minWidth:"80px"},children:[f?I.faAnglesUp:I.faAnglesDown," ",f?"Collapse":"Expand"]}),b&&e.jsx(nr,{generic:s,genericType:t,fnSave:r}),w.GENERIC_TYPES.ELEMENT&&b&&e.jsx(rr,{generic:s,genericType:t,fnSave:r}),b&&e.jsx(Ol,{generic:s}),e.jsx(lr,{generic:s}),e.jsx(hs,{generic:s,fnRetrieve:i,genericType:t}),b&&e.jsx(Qt,{klass:n,generic:s,fnReload:r})]})};or.propTypes={generic:l.object.isRequired,genericType:l.oneOf([w.GENERIC_TYPES.ELEMENT,w.GENERIC_TYPES.SEGMENT,w.GENERIC_TYPES.DATASET]).isRequired,klass:l.object.isRequired,fnReload:l.func,fnRetrieve:l.func,onExpandAll:l.func,editMode:l.bool};or.defaultProps={fnReload:()=>{},fnRetrieve:()=>{},onExpandAll:()=>{},editMode:!0};const Pl=s=>{const{show:t,data:n,fnHide:r}=s;if(!t)return null;const{properties_release:i,properties:a,shortLabel:o,flowType:d}=n;if(Object.keys(i||{}).length<1)return null;const u=Object.keys(i.flow||{}).length>0&&i.flow?.elements?.length>2||!1,p=Object.keys(i.flowObject||{}).length>0&&i.flowObject?.nodes?.length>2||!1;return!u&&!p?e.jsxs(c.Modal,{centered:!0,show:t,size:"sm",onHide:r,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:`${o} workflow`})}),e.jsx(c.Modal.Body,{children:"No defined workflow"})]}):e.jsx(la,{handle:".layer_header",bounds:"body",children:e.jsx("div",{className:"flow_view_draggable",children:e.jsxs(c.Card,{variant:"info",children:[e.jsxs(c.Card.Header,{className:"layer_header",children:[`${o} workflow`,e.jsx(c.Button,{size:"sm",variant:"danger",className:"gu_button_right",onClick:r,children:I.faTimes})]}),e.jsx(c.Card.Body,{children:e.jsx("div",{className:"body_bg",children:e.jsx("div",{className:"body_canvas",children:e.jsx(ir,{properties:a,propertiesRelease:i,flowType:d})})})})]})})})};Pl.propTypes={show:l.bool.isRequired,data:l.shape({properties_release:l.object,properties:l.object,shortLabel:l.string,flowType:l.string}).isRequired,fnHide:l.func.isRequired};const Gl=s=>{const{element:t,fnSaveFlow:n}=s;return Object.keys(t).length<1?null:e.jsx(Hn,{element:t,fnSave:n})};Gl.propTypes={element:l.object.isRequired,fnSaveFlow:l.func.isRequired};function Wp(s){return class Ml extends s{static buildEmpty(n,r){const i=n&&n.metadata?X(n.metadata):{},a=n&&n.properties_release?X(n.properties_release):{};return new Ml({dataset_klass_id:this.dataset_klass_id||n&&n.id,element_type:w.MODEL_TYPES.CONTAINER,element_id:r,metadata:i,properties:a,properties_release:a,klass_ols:n?.ols_term_id,klass_label:n?.label,changed:!1})}serialize(){return super.serialize({dataset_klass_id:this.dataset_klass_id,element_type:w.MODEL_TYPES.CONTAINER,element_id:this.element_id,metadata:this.metadata,properties:this.properties,properties_release:this.properties_release})}get datasetKlassId(){return this.dataset_klass_id}set datasetKlassId(n){this.dataset_klass_id=n}get klassOls(){return this.klass_ols}set klassOls(n){this.klass_ols=n}get klassLabel(){return this.klass_label}set klassLabel(n){this.klass_label=n}}}function Kp(s,t,n){return class qt extends s{static buildEmpty(i,a,o){const d=a&&a.metadata?X(a.metadata):{},u=a&&a.properties_release?X(a.properties_release):{};return new qt({collection_id:i,type:a.name,element_klass_id:this.element_klass_id||a&&a.id,short_label:qt.buildNewShortLabel(a,o),name:`New ${a.label}`,container:t.init(),metadata:d,properties:En(u),properties_release:u,element_klass:a,can_copy:!1,attachments:[],files:[],segments:[],wfLayers:u})}serialize(){return super.serialize({name:this.name,can_copy:!0,klassType:w.MODEL_TYPES.GENERICEL,element_klass:this.element_klass,element_klass_id:this.element_klass_id,metadata:this.metadata,properties:this.properties,properties_release:this.properties_release,container:this.container,attachments:this.attachments,files:this.files,user_labels:this.user_labels||[],segments:this.segments.map(i=>i.serialize())})}analysesContainers(){const i="analyses";if(this.container.children.length===0){const a=t.buildEmpty();a.container_type=i,this.container.children.push(a)}return this.container.children.filter(a=>~a.container_type.indexOf(i))}analysisContainers(){const i="analysis";let a=[];return this.analysesContainers().forEach(o=>{const d=o.children.filter(u=>~u.container_type.indexOf(i));a=[...a,...d]}),a}datasetContainers(){const i="dataset";let a=[];return this.analysisContainers().forEach(o=>{const d=o.children.filter(u=>~u.container_type.indexOf(i));a=[...a,...d]}),a}static buildNewShortLabel(i,a){return a?`${a.initials}-${i.klass_prefix}${parseInt(a.counters[i.name]||0,10)+1}`:`new_${i.label}`}buildCopy(i,a={}){const o=super.buildCopy(),d=Object.assign(o,a);return d.short_label=qt.buildNewShortLabel(d.element_klass,i),d.container=t.init(),d.can_update=!0,d.can_copy=!1,d}static copyFromCollectionId(i,a,o){const d=X(i.properties),u={collection_id:a,properties:m.resetProperties(d)},p=i.buildCopy(o,u);return p.origin={id:i.id,short_label:i.short_label},p}get klassType(){return w.MODEL_TYPES.GENERICEL}get name(){return this._name}set name(i){this._name=i}get label(){return this.element_klass&&this.element_klass.label||""}get desc(){return this.element_klass&&this.element_klass.desc||""}get element_klass(){return this._element_klass}set element_klass(i){this._element_klass=i}get klassName(){return this._klass_name}set klassName(i){this._klass_name=i}get metadata(){return this._metadata}set metadata(i){this._metadata=i||{}}get properties(){return this._properties}set properties(i){this._properties=i}get element_klass_id(){return this._element_klass_id}set element_klass_id(i){this._element_klass_id=i}set segments(i){this._segments=i&&i.map(a=>new n(a))||[]}get segments(){return this._segments||[]}set klass_uuid(i){this._klass_uuid=i}get klass_uuid(){return this._klass_uuid}get uuid(){return this._uuid}set uuid(i){this._uuid=i}title(){return`${this.short_label} ${this.name}`}userLabels(){return this.user_labels}setUserLabels(i){this.user_labels=i}get isPendingToSave(){return!aa(this)&&(this.isNew||this.changed)}isValidated(){if(!!!(this.name&&this.name.trim()!==""))return!1;const a=this.properties?.layers||{},o=this.metadata||{},d=o.groups||[],u=o.restrict||{},p=tt(a,d);for(const f of p)if(f.type==="group"){const h=u[f.id];if(h&&h.cond?.length>0){const[y]=qe(h,a);if(!y)continue}for(const y of f.layers){const b=y.data;if(b.cond_fields?.length>0){const[x]=qe(b,a);if(!x)continue}if(!this.validateFields(b.fields,b,(x,j)=>{const[C]=Je(x,j,a);return C}))return!1}}else{const h=f.data;if(h.cond_fields?.length>0){const[y]=qe(h,a);if(!y)continue}if(!this.validateFields(h.fields,h,(y,b)=>{const[x]=Je(y,b,a);return x}))return!1}return!0}validateFields(i,a,o){for(const d of i||[])if((d.required===!0||d.required==="true")&&[m.FieldTypes.F_TEXT,m.FieldTypes.F_INTEGER].includes(d.type)&&o(d,a)){const u=d.value;if(u==null||u.toString().trim()==="")return!1}return!0}}}function Xp(s){return class $l extends s{static buildEmpty(n){const r=n&&n.metadata?X(n.metadata):{},i=n&&n.properties_release?X(n.properties_release):{};return new $l({segment_klass_id:this.segment_klass_id||n&&n.id,metadata:r,properties:En(i),select_options:i.select_options||{},segment_klass:n,properties_release:i,files:[],wfLayers:i})}static buildCopy(n){const r=X(n);return r.map(i=>(i.properties=m.resetProperties(i.properties),i)),r}serialize(){return super.serialize({klassType:w.MODEL_TYPES.SEGMENT,segment_klass:this.segment_klass,segment_klass_id:this.segment_klass_id,metadata:this.metadata,properties:this.properties,properties_release:this.properties_release,files:this.files})}}}function dr(s){const t=s.component;return s.show?e.jsxs(c.Modal,{centered:!0,dialogClassName:"generic_criteria_modal",animation:!1,show:s.show,onHide:s.onHide,children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:s.title})}),e.jsx(c.Modal.Body,{children:t})]}):e.jsx("span",{})}dr.propTypes={show:l.bool,component:l.oneOfType([l.func,l.element]),title:l.oneOfType([l.string,l.element]),onHide:l.func};dr.defaultProps={show:!1,component:null,title:"",onHide:()=>{}};const cr=s=>{const{segment:t,onChange:n}=s;if(!t)return null;const r=e.jsx(c.Row,{children:e.jsxs(c.Col,{md:12,style:{fontWeight:"bold",fontStyle:"italic",fontSize:"large"},children:[t.label," (",t.desc,")"]})},"criteria_init");t.properties=t.properties_release;const i=e.jsx(nt,{generic:t,fnChange:n,extLayers:[],genId:t.id||0,isPreview:!1,isActiveWF:!0,isSearch:!0,fnNavi:()=>{}});return e.jsxs("div",{style:{margin:"15px"},children:[r,i]})};cr.propTypes={segment:l.object,onChange:l.func};cr.defaultProps={segment:{},onChange:()=>{}};const Zp={"CHMO:0000025":[{var:"cvConc",layer:"sample_preparation",field:"concentration"},{var:"cvSolvent",layer:"sample_preparation",field:"solvent"},{var:"cvSolventOthers",layer:"sample_preparation",field:"solvent_other"},{var:"cvRef",layer:"meas",field:"reference_internal"},{var:"cvRefOthers",layer:"meas",field:"reference_internal_others"},{var:"cvScanRate",layer:"meas",field:"scan_rate"}]};function Qp(s,t){const n={},r=s?.filter(d=>t===d.id);if(r?.length===0||!r[0].dataset)return n;const{properties:i,klass_ols:a}=r[0].dataset,o=Zp?.[a];return o&&o.forEach(d=>{const u=i.layers[d.layer]?.fields.find(p=>p.field===d.field);if(u)switch(u.type){case m.FieldTypes.F_SYSTEM_DEFINED:{const p=m.genUnit(u.option_layers,u.value_system)?.label||"";n[d.var]=`${u.value} ${p}`;break}case m.FieldTypes.F_TEXT:case m.FieldTypes.F_INTEGER:case m.FieldTypes.F_SELECT:n[d.var]=u.value;break;default:n[d.var]=""}}),n}class ur extends g.Component{constructor(t){super(t),this.state={revisions:[],compareUUID:"current",fullScreen:!1},this.compare=this.compare.bind(this),this.setRevision=this.setRevision.bind(this),this.delRevision=this.delRevision.bind(this),this.retrieveRevision=this.retrieveRevision.bind(this),this.handleChanged=this.handleChanged.bind(this),this.dlRevision=this.dlRevision.bind(this),this.setScreen=this.setScreen.bind(this)}componentDidMount(){const{revisions:t}=this.props;t&&this.setRevision(X(t))}componentDidUpdate(t){const{revisions:n}=this.props;n!==t.revisions&&this.setRevision(X(n))}handleChanged(t){const{compareUUID:n,revisions:r}=this.state,{src:i}=this.props;let a=(r||[]).find(o=>ge([o.uuid,o.id])===n);a&&a[i]&&(a=t,this.setRevision(r))}setRevision(t){this.setState({revisions:t})}setScreen(t){this.setState({fullScreen:t})}compare(t){const{revisions:n}=this.props;this.setState({revisions:X(n),compareUUID:ge([t.uuid,t.id])})}delRevision(t){const{fnDelete:n}=this.props;n(t)}retrieveRevision(t){const{fnRetrieve:n,revisions:r,src:i,data:a}=this.props,o=X(r.find(d=>d.id===t.id));i==="properties_release"?(a.properties_template=o[i],n(yt(se(),a,{active:"w"}))):n(o[i],()=>{})}dlRevision(t){const{data:n,revisions:r}=this.props,i=r.find(d=>d.id===t.id),a=X(i.properties_release);a.klass=i.properties_release.klass,a.released_at=i.released_at||"",a.metadata=i.metadata||{};const o=`data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(a))}`;m.downloadFile({contents:o,name:`${a.klass}_${n.label}_${i.uuid}.json`})}render(){const{compareUUID:t,revisions:n,fullScreen:r}=this.state;if(n.length<1)return null;const{data:i,src:a,canDL:o}=this.props,d=[],u=(n||[]).find(j=>ge([j.uuid,j.id])===t)||{},p=u&&u[a]&&u[a].select_options||{};u.name&&d.push({generic:u,type:m.FieldTypes.F_TEXT,isEditable:!0,isRequire:!1,field:"name"}),u[a]=u[a]||{},u[a].layers=u[a].layers||{},a==="properties"?u.properties_release={select_options:p}:u.properties=u.properties_release;const f=e.jsx(nt,{generic:u||{},fnChange:this.handleChanged,extLayers:d,genId:u.uuid||0,isPreview:!0,isActiveWF:!1}),h=r?null:e.jsxs(he,{md:4,children:[e.jsx("b",{children:"Only show the latest 10 revisions."}),n.map((j,C)=>e.jsx(cs,{data:i,download:{canDL:o,fnDownload:this.dlRevision},idxSelect:`${C}:${t}`,rev:j,src:a,fnDelete:this.delRevision,fnRetrieve:this.retrieveRevision,fnView:this.compare},ge([j.uuid,j.id])))]}),y=r?12:8,b=r?"faDownLeftAndUpRightToCenter":"faUpRightAndDownLeftFromCenter",x=r?"scn_full_exit":"scn_full";return e.jsxs(_e,{className:"m-2",children:[h,e.jsxs(he,{md:y,children:[e.jsxs("div",{style:{margin:"10px 0px"},children:[e.jsx("div",{style:{float:"right"},children:e.jsx(ue,{idf:x,fnClick:this.setScreen,element:!r,fa:b,place:"left",bs:"default",size:"sm"})}),e.jsx(Jt,{bg:"warning",text:"dark",children:"Sketch Map: The data input here will not be saved."})]}),e.jsx("div",{style:{width:"100%",minHeight:"50vh"},children:f})]})]})}}ur.propTypes={data:l.object,revisions:l.array,fnRetrieve:l.func,fnDelete:l.func,canDL:l.bool,src:l.oneOf(["properties_release","properties"])};ur.defaultProps={data:{},revisions:[],fnRetrieve:()=>{},fnDelete:()=>{},src:"properties_release",canDL:!1};class pr extends g.Component{constructor(t){super(t),this.state={revisions:[]},this.handleClose=this.handleClose.bind(this),this.setRevisions=this.setRevisions.bind(this),this.retrieveRevision=this.retrieveRevision.bind(this),this.delRevision=this.delRevision.bind(this),this.fetchRevisions=this.fetchRevisions.bind(this)}componentDidUpdate(t){const{element:n,showModal:r}=this.props;(r!==t.showModal&&r||n.id!==t.element.id)&&this.fetchRevisions()}setRevisions(t){this.setState({revisions:t})}fetchRevisions(){const{fetcher:t,fetcherFn:n,element:r}=this.props;t[n](r.id).then(i=>{(i.revisions||[]).map(a=>Object.assign(a,{released_at:a.created_at})),this.setState({revisions:i.revisions})})}handleClose(){this.props.fnClose()}retrieveRevision(t,n){this.props.fnRetrieve(t,n)}delRevision(t){this.props.fnDelete({id:t.id},this.fetchRevisions)}render(){const{showModal:t}=this.props,{revisions:n}=this.state;return n.length<1?null:e.jsxs(c.Modal,{centered:!0,backdrop:"static",dialogClassName:"importChemDrawModal",show:t,onHide:()=>this.handleClose(),children:[e.jsx(c.Modal.Header,{closeButton:!0,children:e.jsx(c.Modal.Title,{children:"History"})}),e.jsx(c.Modal.Body,{style:{overflow:"auto"},children:e.jsx("div",{className:"col-md-12",children:e.jsx(ur,{revisions:n,fnRetrieve:this.retrieveRevision,fnDelete:this.delRevision,src:"properties"})})})]})}}pr.propTypes={showModal:l.bool.isRequired,fnClose:l.func.isRequired,fnRetrieve:l.func,element:l.object,fetcher:l.func.isRequired,fetcherFn:l.string.isRequired,fnDelete:l.func.isRequired};pr.defaultProps={element:{},fnRetrieve:()=>{}};const Jp=new Vr({allErrors:!0,strict:!1}),ql=Jp.compile(rl),ef=s=>s?ql(s):!1,tf=()=>ql.errors,sf=(s,t,n)=>(n||[]).map(r=>r===""||r===void 0?"":m.unitConversion(s,t,r)),fr=({generic:s,variant:t,size:n,fnCb:r})=>{if(!s)return console.error("Error: input object is undefined or null!"),null;if(!ef(s))return console.error("Invalid generic object:",tf()),null;const{measurable_quantity:a,unit:o,values:d=[]}=s,u=g.useMemo(()=>m.genUnits(a),[a]);if(!u||u.length===0)return console.error(`Error: ${a} is not in the list of supported units!`),null;const p=g.useMemo(()=>m.genUnit(a,o),[a,o]),f=!!p.unit_type,h=o||u[0]?.key||"",y=()=>{const b={...s};try{let x=u.findIndex(T=>T.key===h);x<u.length-1?x+=1:x=0;const j=u.length>0?u[x].key:"",C=sf(a,j,d);b.unit=j,b.values=C}catch(x){console.error("Error changing unit:",x)}finally{r(b)}};return e.jsx(c.Button,{size:n,variant:t,onClick:y,title:f?Ce.no_unit_conversion:void 0,className:"gen-unit-btn",children:st(p.label||"")||""})};fr.propTypes={generic:l.shape({type:l.string.isRequired,measurable_quantity:l.string.isRequired,unit:l.string,values:l.arrayOf(l.oneOfType([l.string,l.number]))}).isRequired,variant:l.string,size:l.string,fnCb:l.func};fr.defaultProps={variant:"success",size:"sm",fnCb:()=>{}};const Bl=(s,t)=>s&&t.some(n=>n.name===s),nf=(s,t)=>Bl(s?.type,t)||(s?.segments||[]).length>0,Ur={cell_line:"tryFetchCellLineElById",device_description:"fetchDeviceDescriptionById",element:"fetchGenericElById",reaction:"fetchReactionById",research_plan:"fetchResearchPlanById",sample:"fetchSampleById",screen:"fetchScreenById",wellplate:"fetchWellplateById"},rf=(s,t=[])=>Bl(s,t)?Ur[oo]:fi.includes(s)?Ur[s]:null,lf=(s,t,n,r,i=[],a=!1)=>{const o=isNaN(r)?`${s?.id}/${n}`:`${s?.id}/${n}/${r}`,d=`/${t?"s":""}collection/${o}`;if(a){const p=`/${w.MYDB}${d}`;return window.open(p,"_blank"),null}const u=rf(n,i);return u?(window.history.pushState({},"",d),u):null};Object.defineProperty(exports,"absOlsTermId",{enumerable:!0,get:()=>m.absOlsTermId});Object.defineProperty(exports,"absOlsTermLabel",{enumerable:!0,get:()=>m.absOlsTermLabel});Object.defineProperty(exports,"convertUnits",{enumerable:!0,get:()=>m.convertUnits});Object.defineProperty(exports,"getGenSI",{enumerable:!0,get:()=>m.genUnits});Object.defineProperty(exports,"isLayerInWF",{enumerable:!0,get:()=>m.isLayerInWF});Object.defineProperty(exports,"reUnit",{enumerable:!0,get:()=>m.reUnit});Object.defineProperty(exports,"resetProperties",{enumerable:!0,get:()=>m.resetProperties});exports.Constants=w;exports.Designer=Up;exports.FlowViewerModal=Pl;exports.GenInterface=nt;exports.GenToolbar=or;exports.GenUIProvider=Ii;exports.GenUnitBtn=fr;exports.GenVersionsBtn=hs;exports.GenericElCriteriaModal=dr;exports.InlineMetadata=Qp;exports.PreviewModal=pr;exports.RepoNewModal=tr;exports.SegmentCriteria=cr;exports.Workflow=Gl;exports.browseElement=lf;exports.buildInitWF=En;exports.createDataset=Wp;exports.createElement=Kp;exports.createSegment=Xp;exports.useDnD=nf;
17
+ //# sourceMappingURL=chem-generic-ui.cjs.js.map