Liferay.Loader.define("data-engine-js-components-web@1.0.89/js/utils/dataConverter",["module","exports","require","./visitors.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.fieldToDataDefinition=function fieldToDataDefinition({nestedFields:t=[],settingsContext:r}){const n={customProperties:{},nestedDataDefinitionFields:t.map((e=>fieldToDataDefinition(e)))};return new i.PagesVisitor(r.pages).mapFields((({fieldName:t,localizable:r,localizedValue:i={},value:o})=>{"predefinedValue"===t?t="defaultValue":"type"===t&&(t="fieldType");(e.has(t)?n:n.customProperties)[t]=r?i:o}),!1),n},t.getDDMFormFieldSettingsContext=function getDDMFormFieldSettingsContext({dataDefinitionField:t,defaultLanguageId:r=Liferay.ThemeDisplay.getDefaultLanguageId(),editingLanguageId:n=r,fieldTypes:o}){const{settingsContext:a}=o.find((({name:e})=>e===t.fieldType)),l=new i.PagesVisitor(a.pages);return _objectSpread(_objectSpread({},a),{},{pages:l.mapFields((i=>{const{fieldName:o,localizable:a,type:l}=i,{customProperties:s}=t,d=_fromDDMFormToDataDefinitionPropertyName(o),u=s&&!e.has(d)?s[d]:t[d],f=null!=u?u:i.value;let p={};a&&(p=_objectSpread({},u)),Object.keys(p).length||(p={[r]:""});const c=_objectSpread(_objectSpread({},i),{},{defaultLanguageId:r,locale:r,localizedValue:p,value:f});return"select"===l&&"predefinedValue"===o&&(c.multiple=t.customProperties.multiple,c.options=t.customProperties.options[n]),c}))})},t._fromDDMFormToDataDefinitionPropertyName=_fromDDMFormToDataDefinitionPropertyName;var i=r("./visitors.es");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}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}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}const e=new Set(["defaultValue","fieldType","indexable","indexType","label","localizable","name","readOnly","repeatable","required","showLabel","tip"]);function _fromDDMFormToDataDefinitionPropertyName(e){switch(e){case"fieldName":return"name";case"nestedFields":return"nestedDataDefinitionFields";case"predefinedValue":return"defaultValue";case"type":return"fieldType";default:return e}}}}));
//# sourceMappingURL=dataConverter.js.map