Liferay.Loader.define("fragment-web@4.0.73/js/MultiStepFormModal",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/modal","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.MultiStepFormModal=function MultiStepFormModal({children:e,className:t,observer:r,onClose:o,onFormError:d,size:f,submitLabel:c=Liferay.Language.get("submit"),submitURL:s,title:p}){const[y,m]=(0,u.useState)(0),[g,b]=(0,u.useState)(null),v=u.default.Children.count(e),h=y>0,_=y<v-1,j=(0,u.useRef)(null),handleFormSubmit=e=>{if(e.preventDefault(),!isValid(g))return;const t=new FormData(j.current);(0,i.fetch)(s,{body:t,method:"POST"}).then((e=>e.json())).then((({error:e,redirectURL:t})=>{e&&d(e),t&&(0,i.navigate)(t)})).catch((()=>{(0,i.openToast)({message:Liferay.Language.get("an-unexpected-error-occurred"),type:"danger"})}))};return u.default.createElement(l.default,{className:t,observer:r,onSubmit:handleFormSubmit,size:f},u.default.createElement(n.default,{ref:j},p&&u.default.createElement(l.default.Header,null,p),u.default.createElement(l.default.Body,null,u.default.Children.map(e,((e,t)=>{const r=t===y;return u.default.cloneElement(e,{isActive:r,ref:r?b:()=>{}})}))),u.default.createElement(l.default.Footer,{last:u.default.createElement(a.default.Group,{spaced:!0},u.default.createElement(a.default,{displayType:"secondary",onClick:h?()=>{m((e=>e-1))}:o},h?Liferay.Language.get("previous"):Liferay.Language.get("cancel")),u.default.createElement(a.default,{displayType:"primary",onClick:_?()=>{isValid(g)&&m((e=>e+1))}:handleFormSubmit},_?Liferay.Language.get("next"):c))})))},t.MultiStepFormModalStep=void 0;var a=_interopRequireDefault(r("@frontend-taglib-clay$clayui/button")),n=_interopRequireDefault(r("@frontend-taglib-clay$clayui/form")),l=_interopRequireDefault(r("@frontend-taglib-clay$clayui/modal")),i=r("frontend-js-web"),u=(_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=a?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(r,n,l):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function isValid(e){return Array.from(e.querySelectorAll("*")).every((e=>!e.reportValidity||e.reportValidity()))}const e=u.default.forwardRef((({children:e,isActive:t},r)=>u.default.createElement("div",{"aria-hidden":!t,ref:r,style:{display:t?"":"none"}},e)));t.MultiStepFormModalStep=e}}));
//# sourceMappingURL=MultiStepFormModal.js.map