Liferay.Loader.define("data-engine-js-components-web@1.0.75/js/core/utils/rules",["module","exports","require","../../utils/Token","../../utils/Tokenizer","../../utils/visitors.es"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.renameFieldInsideExpression=a,t.updateRulesReferences=function(t,n,r){const o=n.fieldName,s=r.fieldName,l=new i.RulesVisitor(t);return t=l.mapActions((e=>(e.target===o&&(e=u(u({},e),{},{target:s})),"calculate"===e.action?e=u(u({},e),{},{expression:a(e.expression,o,s)}):"auto-fill"===e.action&&(e=u(u({},e),{},{inputs:f(e.inputs,o,s),outputs:f(e.outputs,o,s)})),e))),l.setRules(t),l.mapConditions((t=>u(u({},t),{},{operands:t.operands.map(((i,l)=>{const a=n.options,f=r.options;if("field"===i.type&&i.value===o)return u(u({},i),{},{value:s});if(1===l&&c(t.operands)&&e(a,f)&&p(a,i.value)){const e=f.find((({value:e})=>e===a.find((({label:e})=>e===i.value)).value));if(e)return u(u({},i),{},{value:e.label})}return i}))})))};var r=n("../../utils/Token"),o=n("../../utils/Tokenizer"),i=n("../../utils/visitors.es");function s(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?s(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const e=(e,t)=>!(!e||!t)&&e.length===t.length,c=e=>2===e.length&&"field"===e[0].type&&"string"===e[1].type,p=(e,t)=>e.some((({label:e})=>t===e));function a(e,t,n){const i=o.Tokenizer.tokenize(e);return o.Tokenizer.stringifyTokens(i.map((e=>(e.type===r.Token.VARIABLE&&e.value===t&&(e=new r.Token(r.Token.VARIABLE,n)),e))))}const f=(e,t,n)=>(Object.keys(e).map((r=>{e[r]===t&&(e[r]=n)})),e)}}));
//# sourceMappingURL=rules.js.map