"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/toConsumableArray"),r=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/helpers/objectWithoutProperties"),o=require("react/jsx-runtime"),i=require("react"),a=require("classnames"),l=require("lodash"),u=require("@material-ui/core"),p=require("@material-ui/lab/Autocomplete"),c=require("@material-ui/icons/Close"),s=require("../Tooltip/Tooltip.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../Tooltip/ScrollableTooltip.js");var d=f(e),b=f(t),h=f(r),g=f(n),m=f(a),O=f(p),v=f(c),x=["isCreatable","options","value","getOptionLabel","onInputChange","onChange","renderOption","classes"];function j(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?j(Object(r),!0).forEach((function(t){d.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):j(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var C=function(e){return l.get(l.get(e.split('Create "'),"1","").split('"'),"0","")},w=u.makeStyles((function(e){return{root:{width:200},paper:{maxHeight:400,boxShadow:"0px 5px 5px -3px rgb(0 0 0 / 20%), 0px 8px 10px 1px rgb(0 0 0 / 14%), 0px 3px 14px 2px rgb(0 0 0 / 12%)",margin:0},createLabel:{fontSize:"16px",lineHeight:"22.5px",color:e.palette.primary.main},openIcon:{marginLeft:5},option:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",width:"100%"},closeIcon:{width:16,height:16}}}));module.exports=function(e){var t=e.isCreatable,r=e.options,n=e.value,a=e.getOptionLabel,u=e.onInputChange,p=e.onChange,c=void 0===p?l.noop:p,f=e.renderOption,j=e.classes,q=g.default(e,x),P=w(),S=i.useMemo((function(){return null==r?void 0:r.map((function(e){return t?a(e):e}))}),[r]),I=i.useMemo((function(){return t?n?a(n):"":n}),[n]),L=i.useState(S),T=h.default(L,2),D=T[0],A=T[1],E=i.useState(null),k=h.default(E,2),H=k[0],M=k[1];i.useEffect((function(){A(S)}),[S]);return o.jsx(O.default,y({value:I,onChange:t?function(e,t){return function(e){if(null!=e&&e.includes('Create "')&&H&&a(e)===a(H)){M(null);var t=C(H);A([].concat(b.default(S),[t])),c(t,!0)}else c(e,!1)}(t)}:c,onInputChange:t?function(e,t){return function(e){if(""===e)M(null),A(S);else if(S.find((function(t){return t===e}))){var t=S.filter((function(e){return!e.includes('Create "')}));A(t)}else{var r=function(e){return'Create "'.concat(e,'"')}(e);M(r),A([].concat(b.default(S),[r]))}}(t)}:u,options:D,getOptionLabel:t?function(e){return String(e)}:a,renderOption:t?function(e){var t=C(e);return o.jsx(s.Tooltip,{title:e,children:o.jsx("div",{className:m.default(d.default({},P.createLabel,t&&e!==t),P.option,null==j?void 0:j.optionLabelClass),children:e})})}:f,classes:y({root:m.default(P.root,null==j?void 0:j.root),paper:m.default(P.paper,null==j?void 0:j.paper),popupIndicator:P.openIcon},j),closeIcon:(I||H)&&o.jsx(v.default,{className:P.closeIcon})},q))};
//# sourceMappingURL=Autocomplete.js.map
