Liferay.Loader.define("@liferay/search-experiences-web@3.0.30/semantic_search/js/configuration/ModelAutocomplete",["module","exports","require","@frontend-taglib-clay$clayui/autocomplete","@frontend-taglib-clay$clayui/data-provider","@frontend-taglib-clay$clayui/drop-down","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/autocomplete")),n=a("@frontend-taglib-clay$clayui/data-provider"),l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/drop-down")),o=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var i=function ModelAutocomplete({label:e,name:t,onBlur:a,onChange:i,required:u,value:c=""}){const[d,f]=(0,o.useState)(c),[s,p]=(0,o.useState)((()=>({error:!1,loading:!1,networkStatus:4}))),[g,y]=(0,o.useState)(!1),m=(0,o.useRef)(c),{resource:v}=(0,n.useResource)({fetchOptions:{credentials:"include",headers:new Headers({Accept:"application/json","Accept-Language":Liferay.ThemeDisplay.getBCP47LanguageId(),"Content-Type":"application/json","x-csrf-token":Liferay.authToken})},fetchPolicy:"cache-first",link:"".concat(window.location.origin).concat(Liferay.ThemeDisplay.getPathContext(),"\n\t\t/o/search-experiences-rest/v1.0/sentence-transformer/ml-models"),onNetworkStatusChange:e=>{p({error:5===e,loading:e>1&&e<4,networkStatus:e})},variables:{limit:20,pipeline_tag:"feature-extraction",query:d.trim()}});return(0,o.useEffect)((()=>{g||f(m.current)}),[g]),o.default.createElement(r.default,null,o.default.createElement(r.default.Input,{"aria-label":e,id:t,name:t,onBlur:a,onChange:e=>{s.loading||p({error:!1,loading:!0,networkStatus:4}),e.target.value||(m.current="",i("")),f(e.target.value),y(!0)},onFocus:()=>{y(!0)},onKeyDown:e=>{"Enter"===e.key&&e.preventDefault()},required:u,value:d}),o.default.createElement(r.default.DropDown,{active:g,onSetActive:y},o.default.createElement(l.default.ItemList,null,s.loading?o.default.createElement(l.default.Item,{disabled:!0},Liferay.Language.get("loading")):(null==v||null===(b=v.items)||void 0===b?void 0:b.length)?(null==v?void 0:v.items)?((null==v?void 0:v.items)||[]).map((({modelId:e})=>o.default.createElement(l.default.Item,{key:e,onClick:()=>{return t=e,m.current=t,i(t),f(t),void y(!1);var t}},e))):void 0:o.default.createElement(l.default.Item,{disabled:!0},Liferay.Language.get("no-results-found")))));var b};t.default=i}}));
//# sourceMappingURL=ModelAutocomplete.js.map