Liferay.Loader.define("@liferay/object-web@1.0.132/js/components/ObjectRelationship/ObjectRelationshipFormBase",["module","exports","require","@frontend-taglib-clay$clayui/label","@liferay/object-js-components-web","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.useObjectRelationshipForm=function useObjectRelationshipForm({initialValues:t,onSubmit:a,parameterRequired:n}){const{errors:r,handleChange:l,handleSubmit:o,setValues:u,values:c}=(0,i.useForm)({initialValues:t,onSubmit:a,validate:t=>{var a,r;const l={},o=null===(a=t.label)||void 0===a?void 0:a[Liferay.ThemeDisplay.getDefaultLanguageId()];return(0,i.invalidateRequired)(o)&&(l.label=s),(0,i.invalidateRequired)(null!==(r=t.name)&&void 0!==r?r:o)&&(l.name=s),(0,i.invalidateRequired)(t.type)&&(l.type=s),t.objectDefinitionId2||(l.objectDefinitionId2=s),n&&t.type===e.ONE_TO_MANY&&!t.parameterObjectFieldId&&(l.parameterObjectFieldId=s),l}});return{errors:r,handleChange:l,handleSubmit:o,setValues:u,values:c}},t.ObjectRelationshipFormBase=function ObjectRelationshipFormBase({errors:e,ffOneToOneRelationshipConfigurationEnabled:t,handleChange:a,readonly:s,setValues:d,values:f}){const[y,b]=(0,r.useState)([]),[g,m]=(0,r.useState)(""),[p,j]=(0,r.useMemo)((()=>{var e;const a=[o,l];return t&&a.push(u),[a,null===(e=a.find((({value:e})=>e===f.type)))||void 0===e?void 0:e.label]}),[t,f.type]);(0,r.useEffect)((()=>{s?b([{id:f.objectDefinitionId2,label:f.label,name:f.objectDefinitionName2,system:!1}]):(async()=>{const e=await i.API.getAllObjectDefinitions(),t=e.find((({id:e})=>f.objectDefinitionId1===e)),a=e.filter((({parameterRequired:e,storageType:a,system:n})=>!(t.system&&n||Liferay.FeatureFlags["LPS-135430"]&&"default"!==a||e)));b(a)})()}),[s,f.objectDefinitionId1]);const O=(0,r.useMemo)((()=>(0,i.filterArrayByQuery)(y,"label",g)),[y,g]);return r.default.createElement(r.default.Fragment,null,r.default.createElement(i.Input,{disabled:s,error:e.name,label:Liferay.Language.get("name"),name:"name",onChange:a,required:!0,value:f.name}),r.default.createElement(i.SingleSelect,{disabled:s,error:e.type,label:Liferay.Language.get("type"),onChange:({value:e})=>d({type:e}),options:p,required:!0,value:j}),r.default.createElement(i.AutoComplete,{disabled:s,emptyStateMessage:Liferay.Language.get("no-objects-were-found"),error:e.objectDefinitionId2,items:O,label:Liferay.Language.get("object"),onChangeQuery:m,onSelectItem:e=>{d({objectDefinitionId2:e.id,objectDefinitionName2:e.name})},query:g,required:!0,value:f.objectDefinitionName2},(({label:e,name:t,system:a})=>{var i;return r.default.createElement("div",{className:"d-flex justify-content-between"},r.default.createElement("div",null,null!==(i=e[c])&&void 0!==i?i:t),r.default.createElement(n.default,{displayType:a?"info":"warning"},a?Liferay.Language.get("system"):Liferay.Language.get("custom")))})))},t.ObjectRelationshipType=void 0;var n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(a("@frontend-taglib-clay$clayui/label")),i=a("@liferay/object-js-components-web"),r=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={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=n?Object.getOwnPropertyDescriptor(e,i):null;r&&(r.get||r.set)?Object.defineProperty(a,i,r):a[i]=e[i]}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}let e;t.ObjectRelationshipType=e,function(e){e.MANY_TO_MANY="manyToMany",e.ONE_TO_MANY="oneToMany",e.ONE_TO_ONE="oneToOne"}(e||(t.ObjectRelationshipType=e={}));const l={description:Liferay.Language.get("multiple-object's-entries-can-interact-with-many-others-object's-entries"),label:Liferay.Language.get("many-to-many"),value:e.MANY_TO_MANY},o={description:Liferay.Language.get("one-object's-entry-interacts-with-many-others-object's-entries"),label:Liferay.Language.get("one-to-many"),value:e.ONE_TO_MANY},u={description:Liferay.Language.get("one-object's-entry-interacts-only-with-one-other-object's-entry"),label:Liferay.Language.get("one-to-one"),value:e.ONE_TO_ONE},s=Liferay.Language.get("required"),c=Liferay.ThemeDisplay.getDefaultLanguageId()}}));
//# sourceMappingURL=ObjectRelationshipFormBase.js.map