Liferay.Loader.define("dynamic-data-mapping-form-field-type@6.0.152/util/localizable/transform.es",["module","exports","require"],(function(e,l,a){window;{function ownKeys(e,l){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);l&&(o=o.filter((function(l){return Object.getOwnPropertyDescriptor(e,l).enumerable}))),a.push.apply(a,o)}return a}function _objectSpread(e){for(var l=1;l<arguments.length;l++){var a=null!=arguments[l]?arguments[l]:{};l%2?ownKeys(Object(a),!0).forEach((function(l){_defineProperty(e,l,a[l])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(a,l))}))}return e}function _defineProperty(e,l,a){return l in e?Object.defineProperty(e,l,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[l]=a,e}function convertValueToJSON(e){if(e&&"string"==typeof e)try{return JSON.parse(e)}catch(l){console.warn("Unable to parse JSON",e)}return e}Object.defineProperty(l,"__esModule",{value:!0}),l.convertValueToJSON=convertValueToJSON,l.convertStringToObject=function convertStringToObject(e,l){if("string"==typeof e){const a=new Object;return a[l]=e,a}return e},l.getEditingValue=function getEditingValue({defaultLocale:e,editingLocale:l,fieldName:a,value:o}){const t=convertValueToJSON(o);if(t)return"submitLabel"===a?t[l.localeId]||"":t[l.localeId]||t[e.localeId]||"";return l},l.getInitialInternalValue=function getInitialInternalValue({editingLocale:e,value:l}){const a=convertValueToJSON(l);return a?a[null==e?void 0:e.localeId]:""},l.normalizeLocaleId=normalizeLocaleId,l.transformAvailableLocales=function transformAvailableLocales(e,l,a){return{availableLocales:null==e?void 0:e.map((e=>({displayName:e[1].label,icon:normalizeLocaleId(e[0]),isDefault:isDefaultLocale({defaultLocale:l,localeId:e[0]}),isTranslated:isTranslated({localeId:e[0],value:a}),localeId:e[0]})))}},l.transformAvailableLocalesAndValue=function transformAvailableLocalesAndValue({availableLocales:e,defaultLocale:l,value:a}){return{availableLocales:null==e?void 0:e.map((e=>_objectSpread(_objectSpread({},e),{},{icon:normalizeLocaleId(e.localeId),isDefault:isDefaultLocale({defaultLocale:l,localeId:e.localeId}),isTranslated:isTranslated({localeId:e.localeId,value:a})}))),value:convertValueToString(a)}},l.transformEditingLocale=function transformEditingLocale({defaultLocale:e,editingLocale:l,value:a}){return{displayName:l.label,icon:l.icon,isDefault:isDefaultLocale({defaultLocale:e,localeId:l.id}),isTranslated:isTranslated({localeId:l.id,value:a}),localeId:l.id}};const convertValueToString=e=>e&&"object"==typeof e?JSON.stringify(e):e,isTranslated=({localeId:e,value:l})=>{const a=convertValueToJSON(l);return!!a&&!!a[e]},isDefaultLocale=({defaultLocale:e,localeId:l})=>e.localeId===l;function normalizeLocaleId(e){if(!e||""===e)throw new Error("localeId ".concat(e," is invalid"));return e.replaceAll("_","-").toLowerCase()}}}));
//# sourceMappingURL=transform.es.js.map