"use strict";const u=require("./Typography-eb50ec4c.js"),i=require("./Env-a6f11491.js"),r=require("./useRoutes-df841412.js"),a=require("classnames"),t=require("react"),E=require("react-dom"),h=require("react-feather");function p(){return r.SSRHelper.isSSR()?null:document.createElement("div")}function l(o){if(r.SSRHelper.isSSR())return null;const e=o?"editorModalWrapper":"modal-root";let n=document.getElementById(e);return n||(n=document.createElement("div"),n.id=e,n.style.zIndex="50",o?v(n):document.body.appendChild(n)),n}function v(o){const e=document.getElementById(i.EDITOR_PREVIEWER_ID);e&&e.appendChild(o)}class y extends t.Component{constructor(e){super(e),this.modalRoot=l(this.props.isPreviewMode),this.containerElement=p()}componentDidMount(){this.modalRoot||(this.modalRoot=l()),this.modalRoot&&this.containerElement&&this.modalRoot.appendChild(this.containerElement)}componentWillUnmount(){this.modalRoot&&this.containerElement&&this.modalRoot.removeChild(this.containerElement)}renderModal(){const{overlayBackground:e,overlayClassName:n,children:d,className:s,dataQa:c}=this.props;return t.createElement("div",{className:a("modalOverlay",n),style:e},t.createElement("section",{onClick:m=>m.stopPropagation(),className:a("modalContainer",s),"data-qa-id":c},d))}renderModalOverlay(){const{visible:e}=this.props;return e?t.createElement("div",{className:"modalOverlay editorModalOverlay"},this.renderModal()):t.createElement("div",null)}render(){const{visible:e,isPreviewMode:n}=this.props;return n?this.renderModalOverlay():!e||!this.containerElement?t.createElement("div",null):E.createPortal(this.renderModalOverlay(),this.containerElement)}}const M=o=>t.createElement("div",{className:"header"},t.createElement("div",{className:"header-wrapper"},t.createElement(f,{...o}))),R=o=>t.createElement("div",{className:a("body",o.className)},o.children),f=({className:o,onClose:e,...n})=>t.createElement(t.Fragment,null,t.createElement(u.Typography,{...n,className:a(o,i.OverrideCSS.TITLE_FONT),fontSize:e?"md":n.fontSize??"3xl",isCentered:!0}),e&&t.createElement(r.Button,{buttonType:r.ButtonType.TEXT,className:"btnClose",onClick:e,buttonStyle:r.ButtonStyle.SECONDARY},t.createElement(h.X,{size:"24",strokeWidth:1})));exports.Modal=y;exports.ModalBody=R;exports.ModalHeader=M;
