Liferay.Loader.define("data-engine-js-components-web@1.0.79/js/core/utils/columnResizedHandler",["module","exports","require","../../utils/FormSupport.es","../../utils/settingsContext"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.getColumn=d,t.handleResizeRight=c,t.handleResizeLeft=a,t.default=function({column:e,direction:t,loc:n,props:o,state:r}){const{pages:s}=r;let i=[...s];d(s,n)&&(i="left"===t?a(o,r,n,e):c(o,r,n,e+1));return{pages:i}};var o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(n,r,i):n[r]=e[r]}n.default=e,t&&t.set(e,n);return n}(n("../../utils/FormSupport.es")),r=n("../../utils/settingsContext");function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function l(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e,t=[]){let n,r=e;return t.forEach((t=>{const{columnIndex:s,pageIndex:i,rowIndex:l}=t;let u=i;e.length-1<i&&(u=0),n=o.getColumn(r,n?0:u,l,s),r=n&&r[0].nestedFields?r[0].nestedFields.filter((e=>n.fields.includes(e.fieldName))):n&&n.fields})),n}const e=(e,t=[])=>(t.length&&t.forEach(((t,n)=>{const{columnIndex:o,pageIndex:r,rowIndex:s}=t;let i=e[n>0?0:r].rows[s].columns[o].fields;e[0].nestedFields&&(i=i.map((t=>e[0].nestedFields.find((e=>e.fieldName===t))))),e=i})),e),f=(e,t)=>{const{columnIndex:n,pageIndex:r,rowIndex:s}=t;return o.getColumnPosition(e,r,s,n)};function c(t,n,s,i){const{pages:u}=n,{columnIndex:c,pageIndex:a,rowIndex:g}=s[s.length-1],p=e(u,s.slice(0,-1)),h=d(p,[s[s.length-1]]),m=d(p,[{columnIndex:c+1,pageIndex:a,rowIndex:g}]),x=f(p,{columnIndex:c,pageIndex:s.length>1?0:a,rowIndex:g});let w,z,b=p;if(!m&&h.size>x-i&&i<x){const e=x-i;w=l(l({},h),{},{size:h.size-e}),b=o.addColumn(b,c+1,s.length>1?0:a,g,{fields:[],size:e})}else if(m){const e=Math.abs(x-i);i<x&&h.size>e?(w=l(l({},h),{},{size:Math.max(h.size-e,1)}),z=l(l({},m),{},{size:Math.min(m.size+e,12)})):i>x&&(1!==m.size||m.fields.length?m.size>e&&(w=l(l({},h),{},{size:h.size+e}),z=l(l({},m),{},{size:m.size-e})):(w=l(l({},h),{},{size:h.size+e}),b=o.removeColumn(b,s.length>1?0:a,g,c+1)))}return w&&(b=o.updateColumn(b,s.length>1?0:a,g,c,w)),z&&(b=o.updateColumn(b,s.length>1?0:a,g,c+1,z)),s.length>1&&(b=[(0,r.updateField)(t,b[0],"rows",b[0].rows)],p[0].settingsContext=b[0].settingsContext),p[s.length>1?0:a].rows=b[s.length>1?0:a].rows,u}function a(t,n,s,i){const{pages:u}=n,{columnIndex:c,pageIndex:a,rowIndex:g}=s[s.length-1],p=e(u,s.slice(0,-1)),h=d(p,[s[s.length-1]]),m=d(p,[{columnIndex:c-1,pageIndex:a,rowIndex:g}]),x=f(p,{columnIndex:c-1,pageIndex:s.length>1?0:a,rowIndex:g});let w=p;if(0===c&&i>0)w=o.addColumn(w,c,s.length>1?0:a,g,{fields:[],size:i}),w=o.updateColumn(w,s.length>1?0:a,g,c+1,l(l({},h),{},{size:h.size-i}));else if(m&&1===m.size&&!m.fields.length&&i<=x)w=o.removeColumn(w,s.length>1?0:a,g,c-1),w=o.updateColumn(w,s.length>1?0:a,g,c-1,l(l({},h),{},{size:h.size+1}));else if(m){const e=Math.abs(x-i);x>=i&&m.size>e?(h.size+=e,m.size-=e):x<i&&h.size>e&&(h.size-=e,m.size+=e),w=o.updateColumn(w,s.length>1?0:a,g,c,h),w=o.updateColumn(w,s.length>1?0:a,g,c-1,m)}return s.length>1&&(w=[(0,r.updateField)(t,w[0],"rows",w[0].rows)],p[0].settingsContext=w[0].settingsContext),p[s.length>1?0:a].rows=w[s.length>1?0:a].rows,u}}}));
//# sourceMappingURL=columnResizedHandler.js.map