Liferay.Loader.define("@liferay/object-web@1.0.145/js/components/ObjectAction/fetchUtil",["module","exports","require","@liferay/object-js-components-web"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.fetchObjectDefinitions=async function fetchObjectDefinitions(e,t,n,o){var c;const i=await r.API.fetchJSON(e),a=[],l=[];null==i||i.forEach((e=>{const{externalReferenceCode:t,id:n,label:r}=e;(e.related?a:l).push({label:r,value:"".concat(t,",").concat(n)})}));const f=[];(null===(c=t.parameters)||void 0===c?void 0:c.objectDefinitionExternalReferenceCode)||f.push({disabled:!0,label:Liferay.Language.get("choose-an-object"),selected:!0,value:""});fillSelect(Liferay.Language.get("related-objects"),a,f),fillSelect(Liferay.Language.get("unrelated-objects"),l,f),o(f),n(i)},t.fetchObjectDefinitionFields=async function fetchObjectDefinitionFields(e,t,n,o,c,i){let a=e,l=t,f=[];if("add-object-entry"===n.objectActionExecutorKey){var s,b;a=null==n||null===(s=n.parameters)||void 0===s?void 0:s.objectDefinitionId,l=null===(b=n.parameters)||void 0===b?void 0:b.objectDefinitionExternalReferenceCode}if(l){const e=await r.API.getObjectFieldsByExternalReferenceCode(l);f=e.filter(o)}c(f);const{predefinedValues:u=[]}=n.parameters,d=new Map;u.forEach((e=>{d.set(e.name,e)}));const p=[];f.forEach((({label:e,name:t,required:r})=>{if(d.has(t)){const e=d.get(t);p.push(e)}else r&&"add-object-entry"===n.objectActionExecutorKey&&p.push({inputAsValue:!1,label:e,name:t,value:""})})),i({parameters:_objectSpread(_objectSpread({},n.parameters),{},{objectDefinitionExternalReferenceCode:l,objectDefinitionId:a,predefinedValues:p})})};var r=n("@liferay/object-js-components-web");function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(n),!0).forEach((function(t){_defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fillSelect(e,t,n){t.length&&n.push({label:e,options:t,type:"group"})}}}));
//# sourceMappingURL=fetchUtil.js.map