Liferay.Loader.define("data-engine-js-components-web@1.0.89/js/utils/objectFields",["module","exports","require","frontend-js-web","../custom/form/eventTypes"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getFieldsGroupedByTypes=function getFieldsGroupedByTypes(e){const t=e.map((({type:e})=>e));return t.filter(((e,n)=>t.indexOf(e)===n)).map((t=>({fields:e.filter((({type:e})=>t===e)),type:t})))},t.addObjectFields=async function addObjectFields(e){const t=(await Liferay.componentReady("formSettingsAPI")).reactComponentRef.current.getObjectDefinitionId();if(t){const{objectFields:n}=await fetchObjectFields(t);e({payload:{objectFields:n},type:r.EVENT_TYPES.OBJECT.FIELDS_CHANGE})}},t.updateObjectFields=async function updateObjectFields(e){const t=(await Liferay.componentReady("formSettingsAPI")).reactComponentRef.current.getObjectDefinitionId();if(t){const{objectFields:n}=await fetchObjectFields(t);e({payload:{objectFields:n},type:r.EVENT_TYPES.OBJECT.FIELDS_CHANGE})}else e({payload:{objectFields:[]},type:r.EVENT_TYPES.OBJECT.FIELDS_CHANGE})},t.getSelectedValue=function getSelectedValue(e){if("string"==typeof e&&""!==e){const t=JSON.parse(e);return Array.isArray(t)?t[0]:t}return e[0]},t.getObjectFieldName=function getObjectFieldName({settingsContext:e}){var t;const n=null===(t=e.pages.find((({title:e})=>e===Liferay.Language.get("advanced"))))||void 0===t?void 0:t.rows[0].columns[0].fields;if("fieldset"===e.type||!n)return;return n.find((e=>"objectFieldName"===e.fieldName))};var o=n("frontend-js-web"),r=n("../custom/form/eventTypes");function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}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}const e={Accept:"application/json","Accept-Language":Liferay.ThemeDisplay.getBCP47LanguageId(),"Content-Type":"application/json"},getURL=(e,t)=>{t=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}({p_auth:Liferay.authToken,t:Date.now()},t);const n=new URL("".concat(window.location.origin).concat(e));return Object.keys(t).forEach((e=>n.searchParams.set(e,t[e]))),n.toString()},fetchObjectFields=t=>{const n=themeDisplay.getPathContext();return(0,o.fetch)(getURL(n+"/o/object-admin/v1.0/object-definitions/".concat(t)),{headers:e,method:"GET"}).then((e=>e.json()))}}}));
//# sourceMappingURL=objectFields.js.map