"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("@material-ui/core"),i=require("@material-ui/icons/AddCircle"),r=require("react"),n=require("classnames"),o=require("lodash"),t=require("./GradientPreview/GradientPreview.js"),c=require("../Select/index.js"),a=require("../IconButton/index.js"),u=require("./GradientSelect.styles.js"),d=require("../../icons/iconParkIcons.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../../icons/customIcons/icons/AddMessage.js"),require("../../icons/customIcons/icons/Attention.js"),require("../../icons/customIcons/icons/Collapse.js"),require("../../icons/customIcons/icons/Dashboard.js"),require("../../icons/customIcons/icons/Expand.js"),require("../../icons/customIcons/icons/FolderClosed.js"),require("../../icons/customIcons/icons/FolderClosedFilled.js"),require("../../icons/customIcons/icons/FolderOpened.js"),require("../../icons/customIcons/icons/GreaterOrEqual.js"),require("../../icons/customIcons/icons/LessOrEqual.js"),require("../../icons/customIcons/icons/Search.js"),require("../../icons/customIcons/icons/Wellhub.js"),require("../../icons/customIcons/icons/MultiRuler.js"),require("../../icons/customIcons/icons/Checkbox.js"),require("../../icons/customIcons/icons/CheckboxChecked.js"),require("../../icons/customIcons/icons/CheckboxIndeterminate.js"),require("../../icons/customIcons/icons/Radio.js"),require("../../icons/customIcons/icons/RadioChecked.js"),require("../../icons/customIcons/icons/SimulFrac.js"),require("../../icons/customIcons/icons/ZipperFrac.js"),require("../../icons/customIcons/icons/CautionFilled.js"),require("../../icons/customIcons/icons/MoreApp.js");var m=l(i),j=l(n);exports.GradientSelect=function(i){var n=i.value,l=i.gradients,p=i.onChange,q=i.defaultGradients,I=i.onAction,h=i.readonly,v=u.useStyles(),x=r.useState(!1),f=x[0],C=x[1],b=function(e){var s,i;if(e.stopPropagation(),!h){var r=null===(i=null===(s=e.currentTarget.closest("li"))||void 0===s?void 0:s.dataset)||void 0===i?void 0:i.value;n===r&&C(!1),I("delete",r)}},G=o.isEmpty(l)&&h;return e.jsxs(c,{"data-testid":"gradient-select",label:"Gradients",value:n||"",className:v.select,onChange:function(e){var s=e.target;s.value&&p(s.value)},open:f,onClose:function(){return C(!1)},onOpen:function(){return C(!0)},inputProps:{name:"gradientId",id:"gradientId"},FormControlProps:{fullWidth:!0},fullWidth:!0,defaultValue:"",InputLabelProps:{shrink:!0},children:[e.jsx(s.ListSubheader,{className:v.listHeader,children:"Gradients"}),!G&&e.jsxs(s.ListSubheader,{className:v.subHeader,children:["My Gradients",!h&&e.jsx(a,{color:"primary","data-testid":"add-gradient-btn",className:v.addButton,onClick:function(){return I("add")},tooltipProps:{title:"Create Custom Gradient"},children:e.jsx(m.default,{color:"primary"})})]}),l.map((function(i){var r=i.id,n=i.name,o=i.gradientStops;return e.jsxs(s.MenuItem,{value:r,className:v.customGradientListItem,children:[e.jsx(t.GradientPreview,{gradientStops:o}),e.jsx("span",{children:n}),e.jsx(a,{className:j.default({disabled:h}),onClick:b,tooltipProps:{title:"Remove Gradient"},size:"medium",children:e.jsx(d.DeleteFourIcon,{})})]},r)})),!o.isEmpty(q)&&e.jsx(s.ListSubheader,{className:v.subHeader,children:"Default Gradients"}),q.map((function(i){var r=i.id,n=i.name,o=i.gradientStops;return e.jsxs(s.MenuItem,{value:r,className:v.customGradientListItem,children:[e.jsx(t.GradientPreview,{gradientStops:o}),e.jsx("span",{children:n})]},r)}))]})};
