Liferay.Loader.define("data-engine-js-components-web@1.0.89/js/core/thunks/fieldChange.es",["module","exports","require","../../utils/evaluation.es","../../utils/visitors.es","../actions/eventTypes.es","../utils/submitButtonController.es"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function fieldChange({defaultLanguageId:t,editingLanguageId:a,objectFields:r,pages:s,portletNamespace:u,properties:d,rules:p,submitButtonId:c,viewMode:g}){return async y=>{const{fieldInstance:b,key:E,value:f}=d,{evaluable:j,fieldName:v}=b,P=getEditedPages({editingLanguageId:a,key:E,name:b.name,pages:s,value:f});if(l=P,y({payload:P,type:o.EVENT_TYPES.PAGE.UPDATE}),j)try{(0,i.disableSubmitButton)(c);let s=await(0,n.evaluate)(v,{defaultLanguageId:t,editingLanguageId:a,objectFields:r,pages:P,portletNamespace:u,rules:p,viewMode:g});if(y({payload:d,type:o.EVENT_TYPES.FIELD.CHANGE}),e.length&&(e.forEach((e=>{s=getEditedPages(_objectSpread(_objectSpread({},e),{},{pages:s}))})),e=[]),b.isDisposed())return;const E=(0,n.mergePages)(t,a,v,s,l,g);y({payload:E,type:o.EVENT_TYPES.PAGE.UPDATE}),y({payload:E,type:o.EVENT_TYPES.FIELD.EVALUATE})}catch(e){y({payload:e,type:o.EVENT_TYPES.FIELD_EVALUATION_ERROR})}else y({payload:d,type:o.EVENT_TYPES.FIELD.CHANGE}),e.push({editingLanguageId:a,name:b.name,value:f})}};var n=a("../../utils/evaluation.es"),r=a("../../utils/visitors.es"),o=a("../actions/eventTypes.es"),i=a("../utils/submitButtonController.es");function ownKeys(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 _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}let e=[];const getEditedPages=({editingLanguageId:e,key:t="value",name:a,pages:n,value:o})=>new r.PagesVisitor(n).mapFields((n=>{var r;return n.name===a?_objectSpread(_objectSpread({},n),{},"value"!==t?{[t]:o}:{localizedValue:_objectSpread(_objectSpread({},n.localizedValue),{},{[e]:o}),localizedValueEdited:_objectSpread(_objectSpread({},null!==(r=n.localizedValueEdited)&&void 0!==r?r:{}),{},{[e]:!0}),value:o}):n}),!1,!0);let l=[]}}));
//# sourceMappingURL=fieldChange.es.js.map