"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../../ext-esm/tslib/tslib.es6.js'),s=require("react/jsx-runtime"),i=require("@material-ui/core"),n=require("@material-ui/icons/AddCircle"),r=require("react"),o=require("classnames"),t=require("lodash"),c=require("./GradientPreview/GradientPreview.js"),a=require("../Select/index.js"),u=require("../IconButton/index.js"),d=require("./GradientSelect.styles.js"),l=require("../../icons/iconParkIcons.js");function m(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 j=m(n),p=m(o);exports.GradientSelect=function(n){var o=n.value,m=n.gradients,q=n.onChange,I=n.defaultGradients,h=n.onAction,v=n.readonly,g=d.useStyles(),x=r.useState(!1),f=x[0],_=x[1],b=function(e){var s,i;if(e.stopPropagation(),!v){var n=null===(i=null===(s=e.currentTarget.closest("li"))||void 0===s?void 0:s.dataset)||void 0===i?void 0:i.value;o===n&&_(!1),h("delete",n)}},C=t.isEmpty(m)&&v;return s.jsxs(a,e.__assign({"data-testid":"gradient-select",label:"Gradients",value:o||"",className:g.select,onChange:function(e){var s=e.target;s.value&&q(s.value)},open:f,onClose:function(){return _(!1)},onOpen:function(){return _(!0)},inputProps:{name:"gradientId",id:"gradientId"},FormControlProps:{fullWidth:!0},fullWidth:!0,defaultValue:"",InputLabelProps:{shrink:!0}},{children:[s.jsx(i.ListSubheader,e.__assign({className:g.listHeader},{children:"Gradients"})),!C&&s.jsxs(i.ListSubheader,e.__assign({className:g.subHeader},{children:["My Gradients",!v&&s.jsx(u,e.__assign({color:"primary","data-testid":"add-gradient-btn",className:g.addButton,onClick:function(){return h("add")},tooltipProps:{title:"Create Custom Gradient"}},{children:s.jsx(j.default,{color:"primary"})}))]})),m.map((function(n){var r=n.id,o=n.name,t=n.gradientStops;return s.jsxs(i.MenuItem,e.__assign({value:r,className:g.customGradientListItem},{children:[s.jsx(c.GradientPreview,{gradientStops:t}),s.jsx("span",{children:o}),s.jsx(u,e.__assign({className:p.default({disabled:v}),onClick:b,tooltipProps:{title:"Remove Gradient"},size:"medium"},{children:s.jsx(l.DeleteFourIcon,{})}))]}),r)})),!t.isEmpty(I)&&s.jsx(i.ListSubheader,e.__assign({className:g.subHeader},{children:"Default Gradients"})),I.map((function(n){var r=n.id,o=n.name,t=n.gradientStops;return s.jsxs(i.MenuItem,e.__assign({value:r,className:g.customGradientListItem},{children:[s.jsx(c.GradientPreview,{gradientStops:t}),s.jsx("span",{children:o})]}),r)}))]}))};
