Liferay.Loader.define("data-engine-js-components-web@1.0.87/js/utils/visitors.es",["module","exports","require"],(function(e,t,r){window;{function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}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}Object.defineProperty(t,"__esModule",{value:!0}),t.RulesVisitor=t.PagesVisitor=void 0;const identity=e=>e;class PagesVisitor{constructor(e){this.setPages(e)}dispose(){this._pages=null}containsField(e){return!!this.findField((t=>t.fieldName===e))}findField(e){let t;return this.visitFields((r=>!!e(r)&&(t=r,!0))),t}mapColumns(e){return this._map(identity,identity,e,identity)}mapFields(e,t=!0,r=!1){const recursiveMapFields=(s,...o)=>s.map(((s,i)=>{const n=_objectSpread(_objectSpread({},t?s:null),e(s,i,...o)),a=n.nestedFields;return r&&a&&(n.nestedFields=recursiveMapFields(a,...o,n)),n}));return this._map(identity,identity,identity,recursiveMapFields)}mapPages(e){return this._map(e,identity,identity,identity)}mapRows(e){return this._map(identity,e,identity,identity)}setPages(e){this._pages=[...e]}visitFields(e){const evaluateNode=t=>{var r,s;return!!t&&(t.fieldName?e(t)||evaluateNode(t.nestedFields):Array.isArray(t)?t.some((e=>evaluateNode(e))):evaluateNode(null!==(r=null!==(s=t.fields)&&void 0!==s?s:t.rows)&&void 0!==r?r:t.columns))};return evaluateNode(this._pages)}_map(e,t,r,s){return this._pages.map(((o,i)=>{const n=_objectSpread(_objectSpread({},o),e(o,i));return _objectSpread(_objectSpread({},n),{},{rows:n.rows.map(((e,o)=>{const n=_objectSpread(_objectSpread({},e),t(e,o,i));return _objectSpread(_objectSpread({},n),{},{columns:n.columns.map(((e,t)=>{const n=_objectSpread(_objectSpread({},e),r(e,t,o,i));return _objectSpread(_objectSpread({},n),{},{fields:s(n.fields,t,o,i)})}))})}))})}))}}t.PagesVisitor=PagesVisitor;class RulesVisitor{constructor(e){this.setRules(e)}containsField(e){return this._rules.some((t=>{const r=t.actions.some((({target:t})=>t===e)),s=t.conditions.some((t=>t.operands.some((({type:t,value:r})=>"field"===t&&r===e))));return r||s}))}containsFieldExpression(e){return this._rules.some((t=>t.actions.some((({action:t,expression:r})=>"calculate"===t&&r.includes(e)))))}dispose(){this._rules=null}mapActions(e){return this._rules.map((t=>_objectSpread(_objectSpread({},t),{},{actions:t.actions.map(e)})))}mapConditions(e){return this._rules.map((t=>_objectSpread(_objectSpread({},t),{},{conditions:t.conditions.map(e)})))}setRules(e){this._rules=[...e]}}t.RulesVisitor=RulesVisitor}}));
//# sourceMappingURL=visitors.es.js.map