Liferay.Loader.define("@liferay/object-web@1.0.145/js/components/ObjectRelationship/SelectRelationship",["module","exports","require","@liferay/object-js-components-web","liferay!frontend-js-react-web$react"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function SelectRelationship(t){let{error:r,objectDefinitionExternalReferenceCode:o,onChange:i,value:l}=t,u=function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,a=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}(t,["error","objectDefinitionExternalReferenceCode","onChange","value"]);const[c,f]=(0,a.useState)([]),[s,d]=(0,a.useState)(""),p=(0,a.useMemo)((()=>c.map((({label:t,name:r})=>({label:t[e],name:r})))),[c]),b=(0,a.useMemo)((()=>{if(p)return p.filter((e=>(0,n.stringIncludesQuery)(e.label,s)))}),[p,s]),y=(0,a.useMemo)((()=>c.find((({name:e})=>e===l))),[c,l]);return(0,a.useEffect)((()=>{o?(async()=>{const e=(await n.API.getObjectFieldsByExternalReferenceCode(o)).filter((({businessType:e})=>"Relationship"===e));f(e)})():f([])}),[o]),a.default.createElement(n.AutoComplete,_extends({emptyStateMessage:Liferay.Language.get("no-parameters-were-found"),error:r,items:null!=b?b:[],label:Liferay.Language.get("parameter"),onChangeQuery:d,onSelectItem:({name:e})=>{var t;i(null===(t=c.find((({name:t})=>t===e)))||void 0===t?void 0:t.name)},query:s,required:!0,tooltip:Liferay.Language.get("choose-a-relationship-field-from-the-selected-object"),value:null==y?void 0:y.label[e]},u),(({label:e,name:t})=>a.default.createElement("div",{className:"d-flex justify-content-between"},null!=e?e:t)))};var n=r("@liferay/object-js-components-web"),a=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 r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("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 _extends(){return(_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}const e=Liferay.ThemeDisplay.getDefaultLanguageId()}}));
//# sourceMappingURL=SelectRelationship.js.map