"use strict";var e=require('./../../ext-esm/tslib/tslib.es6.js'),t=require("react/jsx-runtime"),n=require("react"),r=require("classnames"),o=require("lodash"),i=require("@material-ui/core"),a=require("@material-ui/lab/Autocomplete"),l=require("@material-ui/icons/Close"),u=require("../Tooltip/Tooltip.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../Tooltip/ScrollableTooltip.js");var p=s(r),c=s(a),d=s(l),f=function(e){return o.get(o.get(e.split('Create "'),"1","").split('"'),"0","")},x=i.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(r){var i=r.isCreatable,a=r.options,l=r.value,s=r.getOptionLabel,g=r.onInputChange,h=r.onChange,m=void 0===h?o.noop:h,v=r.renderOption,b=r.classes,_=e.__rest(r,["isCreatable","options","value","getOptionLabel","onInputChange","onChange","renderOption","classes"]),C=x(),q=n.useMemo((function(){return null==a?void 0:a.map((function(e){return i?s(e):e}))}),[a]),j=n.useMemo((function(){return i?s(l)||"":l}),[l]),I=n.useState(q),w=I[0],S=I[1],y=n.useState(null),L=y[0],O=y[1];n.useEffect((function(){S(q)}),[q]);return t.jsx(c.default,e.__assign({value:j,onChange:i?function(t,n){return function(t){if((null==t?void 0:t.includes('Create "'))&&s(t)===s(L)){O(null);var n=f(L);S(e.__spreadArray(e.__spreadArray([],q,!0),[n],!1)),m(n,!0)}else m(t,!1)}(n)}:m,onInputChange:i?function(t,n){return function(t){if(""===t)O(null),S(q);else if(q.find((function(e){return e===t}))){var n=q.filter((function(e){return!e.includes('Create "')}));S(n)}else{var r=function(e){return'Create "'.concat(e,'"')}(t);O(r),S(e.__spreadArray(e.__spreadArray([],q,!0),[r],!1))}}(n)}:g,options:w,getOptionLabel:i?function(e){return String(e)}:s,renderOption:i?function(e){var n,r=f(e);return t.jsx(u.Tooltip,{title:e,children:t.jsx("div",{className:p.default((n={},n[C.createLabel]=r&&e!==r,n),C.option,null==b?void 0:b.optionLabelClass),children:e})})}:v,classes:e.__assign({root:p.default(C.root,null==b?void 0:b.root),paper:p.default(C.paper,null==b?void 0:b.paper),popupIndicator:C.openIcon},b),closeIcon:(j||L)&&t.jsx(d.default,{className:C.closeIcon})},_))};
