Liferay.Loader.define("@liferay/object-web@1.0.153/js/components/ObjectField/useObjectFieldForm",["module","exports","require","@liferay/object-js-components-web","frontend-js-web","../../utils/fieldSettings"],(function(e,i,t){window;{Object.defineProperty(i,"__esModule",{value:!0}),i.useObjectFieldForm=function useObjectFieldForm({forbiddenChars:i,forbiddenLastChars:t,forbiddenNames:l,initialValues:o,onSubmit:u}){const{errors:r,handleChange:d,handleSubmit:m,setValues:c,values:f}=(0,a.useForm)({initialValues:o,onSubmit:u,validate:o=>{var u,r;const d={},m=null===(u=o.label)||void 0===u?void 0:u[e],c=(0,s.normalizeFieldSettings)(o.objectFieldSettings);if((0,a.invalidateRequired)(m)&&(d.label=a.REQUIRED_MSG),(0,a.invalidateRequired)(null!==(r=o.name)&&void 0!==r?r:m)&&(d.name=a.REQUIRED_MSG),o.businessType)if("Aggregation"===o.businessType)c.function||(d.function=a.REQUIRED_MSG),"COUNT"===c.function||c.objectFieldName||(d.objectFieldName=a.REQUIRED_MSG),c.objectRelationshipName||(d.objectRelationshipName=a.REQUIRED_MSG);else if("Attachment"===o.businessType){const e=Math.floor(Liferay.PropsValues.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE/1048576);if((0,a.invalidateRequired)(c.acceptedFileExtensions)&&(d.acceptedFileExtensions=a.REQUIRED_MSG),c.fileSource||(d.fileSource=a.REQUIRED_MSG),c.maximumFileSize||0===c.maximumFileSize?c.maximumFileSize>e?d.maximumFileSize=(0,n.sub)(Liferay.Language.get("file-size-is-larger-than-the-allowed-overall-maximum-upload-request-size-x-mb"),e):c.maximumFileSize<0&&(d.maximumFileSize=(0,n.sub)(Liferay.Language.get("only-integers-greater-than-or-equal-to-x-are-allowed"),0)):d.maximumFileSize=a.REQUIRED_MSG,c.showFilesInDocumentsAndMedia)if((0,a.invalidateRequired)(c.storageDLFolderPath))d.storageDLFolderPath=a.REQUIRED_MSG;else{const e=(e=>{const a=e[e.length-1];if(null==t?void 0:t.some((e=>e===a)))return(0,n.sub)(Liferay.Language.get("the-folder-name-cannot-end-with-the-following-characters-x"),t.join(" "));if(null==i?void 0:i.some((i=>e.includes(i))))return(0,n.sub)(Liferay.Language.get("the-folder-name-cannot-contain-the-following-invalid-characters-x"),i.join(" "));const s=new Set(l);return l&&e.split("/").some((e=>s.has(e)))?(0,n.sub)(Liferay.Language.get("the-folder-name-cannot-have-a-reserved-word-such-as-x"),l.join(", ")):null})(c.storageDLFolderPath);null!==e&&(d.storageDLFolderPath=e)}}else"Formula"===o.businessType?(0,a.invalidateRequired)(c.output)&&(d.output=a.REQUIRED_MSG):"LongText"===o.businessType||"Text"===o.businessType?c.showCounter&&!c.maxLength&&(d.maxLength=a.REQUIRED_MSG):"Picklist"===o.businessType&&(o.listTypeDefinitionId||(d.listTypeDefinitionId=a.REQUIRED_MSG),o.state&&!o.defaultValue&&(d.defaultValue=a.REQUIRED_MSG));else d.businessType=a.REQUIRED_MSG;return d}});return{errors:r,handleChange:d,handleSubmit:m,setValues:c,values:f}};var a=t("@liferay/object-js-components-web"),n=t("frontend-js-web"),s=t("../../utils/fieldSettings");const e=Liferay.ThemeDisplay.getDefaultLanguageId()}}));
//# sourceMappingURL=useObjectFieldForm.js.map