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