Liferay.Loader.define("data-engine-js-components-web@1.0.79/js/core/thunks/pageLanguageUpdate.es",["module","exports","require","frontend-js-web","../../utils/formatFieldValue.es","../../utils/setDataRecord.es","../../utils/visitors.es","../actions/eventTypes.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function({ddmStructureLayoutId:t,defaultLanguageId:a,nextEditingLanguageId:r,pages:i,portletNamespace:l,preserveValue:d,prevEditingLanguageId:c,readOnly:p}){return f=>{const y=e({nextEditingLanguageId:r,pages:i,preserveValue:d,prevEditingLanguageId:c});(0,n.fetch)("/o/data-engine/v2.0/data-layouts/".concat(t,"/context"),{body:JSON.stringify({dataRecordValues:y,namespace:l,pathThemeImages:themeDisplay.getPathThemeImages(),readOnly:p,scopeGroupId:themeDisplay.getScopeGroupId(),siteGroupId:themeDisplay.getSiteGroupId()}),headers:{"Accept-Language":r.replace("_","-"),"Content-Type":"application/json"},method:"POST"}).then((e=>e.json())).then((e=>{const t=new o.PagesVisitor(e.pages).mapFields((e=>(e.localizedValue||(e.localizedValue={}),e.localizable||(e.localizedValue={[a]:e.value}),u(u(u({},e),g(e.fieldName,i)),{},{editingLanguageId:r}))),!0,!0);f({payload:{defaultLanguageId:a,editingLanguageId:r,pages:t},type:s.EVENT_TYPES.LANGUAGE.CHANGE})}))}};var n=a("frontend-js-web"),r=l(a("../../utils/formatFieldValue.es")),i=l(a("../../utils/setDataRecord.es")),o=a("../../utils/visitors.es"),s=a("../actions/eventTypes.es");function l(e){return e&&e.__esModule?e:{default:e}}function d(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function u(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?d(Object(a),!0).forEach((function(t){c(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):d(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function c(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}const e=({nextEditingLanguageId:e,pages:t,preserveValue:a,prevEditingLanguageId:n})=>{const s=new o.PagesVisitor(t),l={};return s.mapFields((t=>{(0,i.default)(u(u({},t),{},{value:(0,r.default)(t,a,e,n)}),l,a?e:n,a)}),!0,!0),l},g=(e,t)=>{const a=new o.PagesVisitor(t),{itemSelectorURL:n,locale:r,localizedValueEdited:i={[r]:!0}}=a.findField((t=>t.fieldName===e));return{itemSelectorURL:n,localizedValueEdited:i}}}}));
//# sourceMappingURL=pageLanguageUpdate.es.js.map