Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ObjectAction/useObjectActionForm",["module","exports","require","@liferay/object-js-components-web","liferay!frontend-js-react-web$react","../../utils/constants"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.useObjectActionForm=function useObjectActionForm({initialValues:e,onSubmit:t}){var r;const[a,c]=(0,n.useState)([]),l=(0,n.useMemo)((()=>{const e=new Map;return a.forEach((t=>{e.set(t.name,t)})),e}),[a]),s=(0,o.useForm)({initialValues:e,onSubmit:t,validate:e=>{var t,r,n,a;const c={};if((0,o.invalidateRequired)(null===(t=e.label)||void 0===t?void 0:t[i.defaultLanguageId])&&(c.label=o.REQUIRED_MSG),(0,o.invalidateRequired)(e.name)&&(c.name=o.REQUIRED_MSG),(0,o.invalidateRequired)(e.objectActionTriggerKey)&&(c.objectActionTriggerKey=o.REQUIRED_MSG),(0,o.invalidateRequired)(e.objectActionExecutorKey))c.objectActionExecutorKey=o.REQUIRED_MSG;else if("webhook"===e.objectActionExecutorKey&&(0,o.invalidateRequired)(null===(r=e.parameters)||void 0===r?void 0:r.url))c.url=o.REQUIRED_MSG;else if("groovy"===e.objectActionExecutorKey&&(null===(n=e.parameters)||void 0===n?void 0:n.lineCount)&&e.parameters.lineCount>2987)c.script=Liferay.Language.get("the-maximum-number-of-lines-available-is-2987");else if("add-object-entry"===e.objectActionExecutorKey){var s;(null===(s=e.parameters)||void 0===s?void 0:s.objectDefinitionExternalReferenceCode)||(c.objectDefinitionExternalReferenceCode=o.REQUIRED_MSG)}var u;if(("add-object-entry"===e.objectActionExecutorKey||"update-object-entry"===e.objectActionExecutorKey)&&(null===(u=e.parameters)||void 0===u?void 0:u.predefinedValues)){var d;(null===(d=e.parameters)||void 0===d?void 0:d.predefinedValues).forEach((({name:e,value:t})=>{var r;(null===(r=l.get(e))||void 0===r?void 0:r.required)&&(0,o.invalidateRequired)(t)&&(c.predefinedValues||(c.predefinedValues={}),c.predefinedValues[e]=o.REQUIRED_MSG)}))}return"standalone"===e.objectActionTriggerKey&&(0,o.invalidateRequired)(null===(a=e.errorMessage)||void 0===a?void 0:a[i.defaultLanguageId])&&(c.errorMessage=o.REQUIRED_MSG),"string"==typeof e.conditionExpression&&(0,o.invalidateRequired)(e.conditionExpression)&&(c.conditionExpression=o.REQUIRED_MSG),Object.keys(c).length&&(0,o.openToast)({message:o.REQUIRED_MSG,type:"danger"}),c}}),{errors:u,values:d}=s,b=function _objectWithoutProperties(e,t){if(null==e)return{};var r,o,n=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,o,n={},i=Object.keys(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(o=0;o<i.length;o++)r=i[o],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(s,["errors","values"]);return(0,n.useEffect)((()=>{var e;(null===(e=d.parameters)||void 0===e?void 0:e.objectDefinitionExternalReferenceCode)?(async()=>{var e;const t=(await o.API.getObjectFieldsByExternalReferenceCode(null===(e=d.parameters)||void 0===e?void 0:e.objectDefinitionExternalReferenceCode)).filter((({businessType:e,system:t})=>"Aggregation"!==e&&"Relationship"!==e&&!t));c(t)})():c([])}),[null===(r=d.parameters)||void 0===r?void 0:r.objectDefinitionExternalReferenceCode]),function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({errors:u,values:d},b)};var o=r("@liferay/object-js-components-web"),n=r("liferay!frontend-js-react-web$react"),i=r("../../utils/constants");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}}}));
//# sourceMappingURL=useObjectActionForm.js.map