Liferay.Loader.define("commerce-frontend-js@4.0.52/components/modal/Modal",["module","exports","require","@frontend-taglib-clay$clayui/loading-indicator","@frontend-taglib-clay$clayui/modal","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../../utilities/eventsDefinitions","../../utilities/index","../../utilities/modals/constants","../../utilities/modals/index"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=c(a("@frontend-taglib-clay$clayui/loading-indicator")),i=f(a("@frontend-taglib-clay$clayui/modal")),r=(c(a("liferay!frontend-js-react-web$prop-types")),f(a("liferay!frontend-js-react-web$react"))),o=a("../../utilities/eventsDefinitions"),l=a("../../utilities/index"),s=a("../../utilities/modals/constants"),u=a("../../utilities/modals/index");function d(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return d=function(){return e},e}function f(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=d();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=n?Object.getOwnPropertyDescriptor(e,i):null;r&&(r.get||r.set)?Object.defineProperty(a,i,r):a[i]=e[i]}return a.default=e,t&&t.set(e,a),a}function c(e){return e&&e.__esModule?e:{default:e}}const e=()=>window.location!==window.parent.location;var y=function(t){const[a,d]=(0,r.useState)(!1),[f,c]=(0,r.useState)(!1),[y,m]=(0,r.useState)(null),[L,p]=(0,r.useState)(t.title),[O,b]=(0,r.useState)(t.url),[_,v]=(0,r.useState)(s.INITIAL_MODAL_SIZE),{observer:g,onClose:M}=(0,i.useModal)({onClose:e=>{y&&y(e),c(!1),d(!1)}});return(0,r.useEffect)((()=>{function n(n){t.id!==n.id||a||e()||(c(!0),d(!0),n.url&&b(n.url),n.onClose&&m((()=>n.onClose)),n.title&&p(n.title),n.size||v(s.INITIAL_MODAL_SIZE))}function i({redirectURL:e="",successNotification:t={}}){a&&(e?(0,l.liferayNavigate)(e):M(t))}function r(e){const{isLoading:t}=e;c(t||!1)}function u(){Liferay.detach(o.OPEN_MODAL,n),Liferay.detach(o.CLOSE_MODAL,i),Liferay.detach(o.IS_LOADING_MODAL,r),Liferay.detach("destroyPortlet",u)}return Liferay.on&&(Liferay.on(o.OPEN_MODAL,n),Liferay.on(o.CLOSE_MODAL,i),Liferay.on(o.IS_LOADING_MODAL,r),Liferay.on("destroyPortlet",u)),()=>u()}),[M,t.id,a]),(0,r.useEffect)((()=>{m((()=>t.onClose))}),[t.onClose]),r.default.createElement(r.default.Fragment,null,a&&r.default.createElement(i.default,{className:"commerce-modal",observer:g,size:_,status:t.status},L&&r.default.createElement(i.default.Header,null,L),r.default.createElement("div",{className:"modal-body modal-body-iframe",style:{height:(0,u.resolveModalHeight)(_),maxHeight:"100%"}},r.default.createElement("iframe",{src:O,title:L}),f&&r.default.createElement("div",{className:"loader-container"},r.default.createElement(n.default,null)))))};t.default=y}}));
//# sourceMappingURL=Modal.js.map