Liferay.Loader.define("data-engine-js-components-web@1.0.55/js/core/reducers/dragAndDropReducer.es",["module","exports","require","../../utils/FormSupport.es","../../utils/constants","../../utils/fieldSupport","../../utils/settingsContext","../../utils/visitors.es","../actions/eventTypes.es","../utils/columnResizedHandler","../utils/sectionAddedHandler","./fieldEditableReducer.es"],(function(e,a,d){var i;window;Object.defineProperty(a,"__esModule",{value:!0}),a.default=function(e,a,d){switch(a.type){case r.EVENT_TYPES.DND.MOVE:{const{sourceFieldName:i,sourceFieldPage:r,targetFieldName:u,targetIndexes:m,targetParentFieldName:F}=a.payload,{activePage:p,availableLanguageIds:L,defaultLanguageId:N,editingLanguageId:c,pages:I,rules:E}=e,{fieldTypes:b,generateFieldNameUsingFieldLabel:y,getFieldNameGenerator:P}=d,v=P(I,y);let{sourceParentField:w}=a.payload;const T=(0,l.findFieldByFieldName)(I,i);if(w&&u&&w.fieldName===u)return e;let R=(0,f.deleteField)({defaultLanguageId:N,editingLanguageId:c,fieldName:i,fieldNameGenerator:v,fieldPage:r,generateFieldNameUsingFieldLabel:y,pages:I});if(w&&w.type===t.FIELD_TYPE_FIELDSET&&1===w.nestedFields.length){let e=w?w.fieldName:"";do{w&&(e=w.fieldName),w=(0,n.getParentField)(I,w.fieldName)}while(w&&w.type===t.FIELD_TYPE_FIELDSET&&w.fieldName!==F&&1===w.nestedFields.length);e&&e!==F&&(R=(0,f.deleteField)({defaultLanguageId:N,editingLanguageId:c,fieldName:e,fieldNameGenerator:v,fieldPage:r,generateFieldNameUsingFieldLabel:y,pages:I}))}if(u)return R=(0,f.deleteField)({clean:!0,defaultLanguageId:N,editingLanguageId:c,fieldName:i,fieldNameGenerator:v,fieldPage:r,generateFieldNameUsingFieldLabel:y,pages:I}),(0,o.default)({availableLanguageIds:L,defaultLanguageId:N,editingLanguageId:c,fieldNameGenerator:v,fieldTypes:b,generateFieldNameUsingFieldLabel:y},{activePage:p,pages:R,rules:E},{data:{fieldName:u,parentFieldName:F},indexes:m,newField:T});R=(0,n.addFieldToPage)({defaultLanguageId:N,editingLanguageId:c,fieldNameGenerator:v,generateFieldNameUsingFieldLabel:y,indexes:m,newField:T,pages:R,parentFieldName:F});const G=new s.PagesVisitor(R);return R=G.mapFields((e=>"grid"!==e.type&&e.rows?(0,g.updateField)({availableLanguageIds:L,defaultLanguageId:N,fieldNameGenerator:v,generateFieldNameUsingFieldLabel:y},e,"rows",(0,l.removeEmptyRows)([e],0)):e)),R[r].rows=(0,l.removeEmptyRows)(R,r),{pages:R}}case r.EVENT_TYPES.DND.RESIZE:{const{column:i,direction:l,loc:t}=a.payload,{defaultLanguageId:n,editingLanguageId:g,pages:s}=e,{generateFieldNameUsingFieldLabel:r,getFieldNameGenerator:o}=d,f=o(s,r);let m=[...s];return(0,u.getColumn)(s,t)&&(m="left"===l?(0,u.handleResizeLeft)({defaultLanguageId:n,editingLanguageId:g,fieldNameGenerator:f,generateFieldNameUsingFieldLabel:r},{pages:s},t,i):(0,u.handleResizeRight)({defaultLanguageId:n,editingLanguageId:g,fieldNameGenerator:f,generateFieldNameUsingFieldLabel:r},{pages:s},t,i+1)),{pages:m}}default:return e}};var l=d("../../utils/FormSupport.es"),t=d("../../utils/constants"),n=d("../../utils/fieldSupport"),g=d("../../utils/settingsContext"),s=d("../../utils/visitors.es"),r=d("../actions/eventTypes.es"),u=d("../utils/columnResizedHandler"),o=(i=d("../utils/sectionAddedHandler"))&&i.__esModule?i:{default:i},f=d("./fieldEditableReducer.es")}));
//# sourceMappingURL=dragAndDropReducer.es.js.map