Liferay.Loader.define("data-engine-js-components-web@1.0.112/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,formId:n,objectFields:s,pages:u,portletNamespace:d,properties:p,rules:c,submitButtonId:g,viewMode:y}){return async b=>{const{fieldInstance:E,key:f,value:j}=p,{evaluable:v,fieldName:P}=E,m=getEditedPages({editingLanguageId:a,key:f,name:E.name,pages:u,value:j});if(l=m,b({payload:m,type:o.EVENT_TYPES.PAGE.UPDATE}),v)try{(0,i.disableSubmitButton)(g);let u=await(0,r.evaluate)(P,{defaultLanguageId:t,editingLanguageId:a,formId:n,objectFields:s,pages:m,portletNamespace:d,rules:c,viewMode:y});if(b({payload:p,type:o.EVENT_TYPES.FIELD.CHANGE}),e.length&&(e.forEach((e=>{u=getEditedPages(_objectSpread(_objectSpread({},e),{},{pages:u}))})),e=[]),E.isDisposed())return;const f=(0,r.mergePages)(t,a,P,u,l,y);b({payload:f,type:o.EVENT_TYPES.PAGE.UPDATE}),b({payload:f,type:o.EVENT_TYPES.FIELD.EVALUATE})}catch(e){b({payload:e,type:o.EVENT_TYPES.FIELD_EVALUATION_ERROR})}else b({payload:p,type:o.EVENT_TYPES.FIELD.CHANGE}),e.push({editingLanguageId:a,name:E.name,value:j})}};var r=a("../../utils/evaluation.es"),n=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 r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,r)}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:r,value:o})=>new n.PagesVisitor(r).mapFields((r=>{var n;return r.name===a?_objectSpread(_objectSpread({},r),{},"value"!==t?{[t]:o}:{localizedValue:_objectSpread(_objectSpread({},r.localizedValue),{},{[e]:o}),localizedValueEdited:_objectSpread(_objectSpread({},null!==(n=r.localizedValueEdited)&&void 0!==n?n:{}),{},{[e]:!0}),value:o}):r}),!1,!0);let l=[]}}));
//# sourceMappingURL=fieldChange.es.js.map