"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("react"),r=require("lodash"),u=require("../utils/getFormattedOptions.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(e);exports.useAutocompletOptions=function(e){var o=e.value,n=e.options,s=e.groups,a=e.selectedGroup,l=e.isPrioritizedSelectedOptions,p=t.useState(n),c=i.default(p,2),d=c[0],f=c[1],m=(null==n?void 0:n.some((function(e){return e.group})))||!r.isEmpty(s),v=u.getFormattedOptions(n,m,a),y=t.useCallback((function(e){if(!Array.isArray(e))return v;var t=new Set(e.map((function(e){return e.id})));return r.sortBy(v,(function(e){return!t.has(e.id)}))}),[v.length]);return t.useEffect((function(){l?f(y(o)):r.isEqual(v,d)||f(v)}),[v]),{autocompleteOptions:d,handleAutocompleOptionsUpdate:function(){l&&f(y(o))},isGrouped:m}};
