Liferay.Loader.define("data-engine-js-components-web@1.0.89/js/utils/evaluation.es",["module","exports","require","frontend-js-web","./fetch.es","./visitors.es"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeFieldOptions=mergeFieldOptions,t.mergePages=mergePages,t.evaluate=function evaluate(e,t){return new Promise(((r,a)=>{l(e,t,((e,t)=>{if(e)return a(e);r(t)}))}))};var a=r("frontend-js-web"),o=r("./fetch.es"),n=r("./visitors.es");function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e=themeDisplay.getPathContext()+"/o/dynamic-data-mapping-form-context-provider/";let i=null;function mergeFieldOptions(e,t){let r=_objectSpread({},t.value);return Object.keys(r).forEach((t=>{r=_objectSpread(_objectSpread({},r),{},{[t]:r[t].map((r=>{const a=e.value&&e.value[t]&&e.value[t].find((({value:e})=>e===r.value));return _objectSpread(_objectSpread({},r),{},{edited:a&&a.edited})}))})})),r}function mergePages(e,t,r,a,o,i){const l=new n.PagesVisitor(a),s=new n.PagesVisitor(o),d=new Map,c=new Map;return s.visitFields((e=>{d.set(e.name,e),c.set(e.fieldName,e)})),l.mapFields((a=>{var o,n;const l=null!==(o=null!==(n=d.get(a.name))&&void 0!==n?n:c.get(a.fieldName))&&void 0!==o?o:{};let s=a.valueChanged?a.value:l.value;a.visible!==l.visible&&a.visible&&i&&(s="");let u=_objectSpread(_objectSpread(_objectSpread({},l),a),{},{defaultLanguageId:e,displayErrors:l.displayErrors||a.fieldName===r,editingLanguageId:t,valid:!1!==a.valid,value:s});return"options"===u.type&&(u=_objectSpread(_objectSpread({},u),{},{value:mergeFieldOptions(l,u)})),u.localizable&&(u=_objectSpread(_objectSpread({},u),{},{localizedValue:_objectSpread({},l.localizedValue)})),u}),!1,!0)}const l=(0,a.debounce)(((t,r,a)=>{const{defaultLanguageId:n,editingLanguageId:l,formId:s,groupId:d,nextPage:c,pages:u,portletNamespace:p,previousPage:g,viewMode:b}=r;i&&i.abort(),window.AbortController&&(i=new AbortController),(0,o.makeFetch)({body:(0,o.convertToFormData)({languageId:l,p_auth:Liferay.authToken,portletNamespace:p,serializedFormContext:JSON.stringify(_objectSpread(_objectSpread({},r),{},{formId:s,groupId:d||themeDisplay.getScopeGroupId(),nextPage:c||null,portletNamespace:p,previousPage:g||null})),trigger:t}),signal:i&&i.signal,url:e}).then((e=>{const r=mergePages(n,l,t,e,u,b);a(null,r)})).catch((e=>a(e)))}),600)}}));
//# sourceMappingURL=evaluation.es.js.map