import{memo as e}from"react";import n from"prop-types";import{get as i,map as t,includes as l}from"lodash";import{makeStyles as r,Button as o,Grid as a}from"@material-ui/core";import{BHA_COMPONENT_TYPES as c,BHA_GENERAL_FIELD_TYPES as d,BHA_TABLE_FIELD_TYPES as m,BHA_ALTERNATIVE_FIELD_TYPES as s,BHA_STABILIZER_FIELD_TYPES as u,UR_ACTIVATION_LOGIC_TYPES as f,FLOW_RATE_UNIT as h,UR_ACTIVATION_LOGIC_KEYS as p}from"./constants.js";import{getUnitDisplay as b}from"../../../utils/index.js";import{jsxs as _,jsx as g}from"react/jsx-runtime";var x=r({header:{marginBottom:"10px",borderBottom:"1px solid #888"},title:{fontWeight:"bold",fontSize:"2rem",marginTop:"0px"},done_button:{float:"right"},field_label:{color:"#ccc",fontSize:"0.8rem"},field_value:{fontSize:"1.2rem",lineHeight:"2rem",fontWeight:"bold"},thead:{borderBottom:"0px"},th:{color:"#ccc",fontSize:"0.8rem",padding:"0px"},td:{fontSize:"1.2rem",padding:"0px"},col:{padding:"0 0.75rem"},row:{marginBottom:"20px"},sub_title:{fontWeight:"bold",fontSize:"1.5rem",marginTop:"10px",padding:"0 0.75rem"}});function z(e){var n=e.component,r=e.onDone,z=e.currentUser,v=x(),N=n&&i(n,"family"),y=z?i(z,["preference","segment"],[]):[],T=z&&i(z,"current_segment"),S=-1===y.indexOf(T)?y[0]:T,A=c.filter((function(e){return e.family===N})),B=A&&A[0],D=B&&B.data,F=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,r=arguments.length>3?arguments[3]:void 0,o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],c=i(n,e)||"",d=o?h[S].unitType:r,m=d?"(".concat(b(d),")"):"";return _(a,{item:!0,md:l,xs:12,className:v.col,children:[g("span",{className:v.field_label,children:"".concat(t," ").concat(m)}),g("br",{}),g("span",{className:v.field_value,children:c.fixFloat?c.fixFloat(3):c||"n/a"})]},t)},j=function(e,r){return r?t(d,(function(t){return l(r,t.name)&&(!t.cond||t.cond&&i(n,t.cond,!1))&&(!t.family||t.family===N)&&(t.unit?F([t.name],t.label,t.col_size||e,t.unit):F([t.name],t.label,t.col_size||e))})):null},k=function(e){return e?g(a,{item:!0,xs:12,className:v.sub_title,children:e},"subTitle"):null},q=function(e,l,r){return g(a,{item:!0,xs:12,className:v.col,children:i(n,e,[]).length>0&&_("table",{children:[g("thead",{className:v.thead,children:g("tr",{children:t(l,(function(e,n){return g("th",{className:v.th,children:e},n)}))})}),g("tbody",{children:t(i(n,e,[]),(function(e,n){return g("tr",{children:t(r,(function(n,t){return g("td",{className:v.td,children:n.isNumber?i(e,n.field)&&i(e,n.field).fixFloat(3):i(e,n.field)},t)}))},n)}))})]})},"tbField")},C=function(e,r,o,c,d){return r?_(a,{container:!0,children:[o&&t(m,(function(t){return l(o,t.name)&&(!t.cond||t.cond&&i(n,t.cond,!1))&&(t.unit||t.unit_from_segment?F([t.name],t.label,t.col_size||e,t.unit,t.unit_from_segment):F([t.name],t.label,t.col_size||e))})),_(a,{item:!0,md:4,xs:12,className:v.col,children:[g("span",{className:v.field_label,children:"Activation Logic"}),g("br",{}),g("span",{className:v.field_value,children:(s=c,(f.find((function(e){return e.type===s}))||{}).name||"n/a")})]}),d&&l(o,"ur_opened_depth")&&F(["ur_opened_depth"],"Activation Depth",e,"length")]},r):null;var s},R=function(e,r){return r?t(s,(function(t){return l(r,t.name)&&(!t.cond||t.cond&&i(n,t.cond,!1))&&(!t.family||t.family===N)&&(t.unit?F([t.name],t.label,t.col_size||e,t.unit):F([t.name],t.label,t.col_size||e))})):null},W=function(e,r){return r&&i(n,"has_stabilizer")?t(u,(function(t){return l(r,t.name)&&(!t.cond||t.cond&&i(n,t.cond,!1))&&(!t.family||t.family===N)&&(t.unit?F(["stabilizer",t.name],t.label,t.col_size||e,t.unit):F(["stabilizer",t.name],t.label,t.col_size||e))})):null};return _("div",{children:[_("header",{className:v.header,children:[g(o,{variant:"contained",className:v.done_button,onClick:r,children:"Close"}),_("h4",{className:v.title,children:[i(n,"name")," ( ",i(n,"family")," )"]})]}),g(a,{container:!0,children:g(a,{item:!0,xs:12,className:v.col,children:t(D,(function(e){return function(e){var t=e&&+i(e,"col_size"),l=e&&i(e,"fields"),r=e&&i(e,"stablizer_fields"),o=e&&i(e,"sub_title"),c=e&&i(e,"sub_key"),d=e&&i(e,"sub_fields"),m=e&&i(e,"tb_field"),s=e&&i(e,"tb_head"),u=e&&i(e,"tb_body"),f=i(n,"activation_logic"),h=f===p.DEPTH_ACTIVATION;return _(a,{container:!0,className:v.row,children:[j(t,l),k(o),q(m,s,u),C(t,c,d,f,h),R(t,l),W(t,r)]},e.key)}(e)}))})})]})}z.propTypes={component:n.shape({}).isRequired,onDone:n.func.isRequired,currentUser:n.shape({}).isRequired};var v=e(z);export{v as default};
//# sourceMappingURL=index.js.map
