Liferay.Loader.define("@liferay/layout-content-page-editor-web@3.0.132/page_editor/app/components/FormValidationModal",["module","exports","require","@frontend-taglib-clay$clayui/alert","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/modal","@frontend-taglib-clay$clayui/panel","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../config/index","../contexts/FormValidationContext","../utils/getFormErrorDescription"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.FormValidationModal=function({onCloseModal:e,onPublish:t}){const{observer:a,onClose:n}=(0,l.useModal)({onClose:e}),c=(0,f.useFormValidations)();if(1===c.length&&1===c[0].errors.length){const[e]=c;return u.default.createElement(m,{formValidation:e,observer:a,onClose:n,onPublish:t})}return u.default.createElement(l.default,{className:"page-editor__form-validation-modal",observer:a,status:"warning"},u.default.createElement(l.default.Header,null,Liferay.Language.get("form-errors")),u.default.createElement(l.default.Body,null,u.default.createElement("p",{className:"mb-4"},Liferay.Language.get("the-following-errors-have-been-found-with-the-forms-on-the-page")),c.map(((e,t)=>{const a=d.config.formTypes.find((({value:t})=>t===e.classNameId)).label;return u.default.createElement(o.default,{className:"mb-0",collapsable:!0,defaultExpanded:!0,displayTitle:(0,i.sub)(Liferay.Language.get("x-form"),a),displayType:"link",key:t,showCollapseIcon:!0},u.default.createElement(o.default.Body,null,e.errors.map((e=>{const{summary:t}=(0,s.getFormErrorDescription)({name:a,type:e});return u.default.createElement(r.default,{displayType:"warning",key:e,variant:"feedback"},t)}))))}))),u.default.createElement(p,{onClose:n,onPublish:t}))};var r=y(a("@frontend-taglib-clay$clayui/alert")),n=y(a("@frontend-taglib-clay$clayui/button")),l=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("@frontend-taglib-clay$clayui/modal")),o=y(a("@frontend-taglib-clay$clayui/panel")),i=a("frontend-js-web"),u=(y(a("liferay!frontend-js-react-web$prop-types")),y(a("liferay!frontend-js-react-web$react"))),d=a("../config/index"),f=a("../contexts/FormValidationContext"),s=a("../utils/getFormErrorDescription");function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}function y(e){return e&&e.__esModule?e:{default:e}}function m({formValidation:e,observer:t,onClose:a,onPublish:r}){const[n]=e.errors,o=d.config.formTypes.find((({value:t})=>t===e.classNameId)).label,{message:i,title:f}=(0,s.getFormErrorDescription)({name:o,type:n});return u.default.createElement(l.default,{className:"page-editor__form-validation-modal",observer:t,status:"warning"},u.default.createElement(l.default.Header,null,f),u.default.createElement(l.default.Body,null,u.default.createElement("p",{className:"mb-0"},i)),u.default.createElement(p,{onClose:a,onPublish:r}))}function p({onClose:e,onPublish:t}){return u.default.createElement(l.default.Footer,{last:u.default.createElement(n.default.Group,{spaced:!0},u.default.createElement(n.default,{displayType:"secondary",onClick:e},Liferay.Language.get("cancel")),u.default.createElement(n.default,{displayType:"warning",onClick:t},Liferay.Language.get("publish")))})}}}));
//# sourceMappingURL=FormValidationModal.js.map