'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),i=require("@gem-sdk/core"),l=require("react-dom"),r=require("../hooks/useModalContainer.js"),s=require("../../grid/components/ChildrenDroppable.js");exports.default=({setting:a,styles:p,children:n,willUnmount:d,closeOnEscape:g,onKeypressEscape:c,keyCodeForClose:o,closeOnClickOutside:u,onClose:h,contentClass:x,disableIframeClickEvent:m})=>{let{open:f}=a??{},v=r.default(),w=t.useRef(null),j=t.useRef(null),y=t.useCallback(e=>{let t=e.code;o?.includes(t),g&&"Escape"===t&&c?.(e)},[g,o,c]);t.useEffect(()=>(document.addEventListener("keydown",y,!1),()=>{document.removeEventListener("keydown",y,!1),d?.()}),[y,d]);let C=t.useCallback(e=>{let t=e.target===w.current,i=e.target===j.current;(u&&t||i)&&(window?.parent?.postMessage?.(JSON.stringify({type:"active-modal",value:!1}),"*"),h?.())},[u,h]);return(t.useEffect(()=>{window?.parent?.postMessage?.(JSON.stringify({type:"active-modal",value:f}),"*")},[f]),v&&f)?l.createPortal(e.jsx(e.Fragment,{children:e.jsx("div",{className:"gp-fixed gp-inset-0 gp-z-50 gp-overflow-y-auto","data-disable-iframe-click-event":m||!1,children:e.jsxs("div",{className:"gp-min-h-screen gp-px-4 gp-text-center",children:[e.jsx("div",{ref:w,className:i.cls("gp-fixed gp-inset-0 gp-bg-black/60 gp-backdrop-blur-sm gp-transition-all gp-duration-100",{"gp-opacity-100":f,"gp-opacity-0":!f}),onClick:C,"aria-hidden":!0}),e.jsx("span",{className:"gp-inline-block gp-h-screen gp-align-middle"}),e.jsxs("div",{className:i.cls("gp-relative gp-my-8 gp-inline-block gp-w-full gp-overflow-hidden gp-rounded gp-bg-white gp-p-6 gp-text-left gp-align-middle gp-shadow-xl gp-transition-all gp-duration-100",{"gp-max-w-2xl":!p?.width,"gp-scale-100 gp-opacity-100":f,"gp-scale-0 gp-opacity-0":!f},x),style:{width:p?.width},children:[e.jsx("div",{className:"gp-absolute gp-right-[16px] gp-top-[16px] gp-z-10 gp-cursor-pointer",onClick:C,"aria-hidden":"true",children:e.jsx("svg",{ref:j,width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M11.1758 12.0241C11.4101 12.2584 11.79 12.2584 12.0243 12.0241C12.2586 11.7898 12.2586 11.4099 12.0243 11.1755L8.84858 7.9998L12.0243 4.82407C12.2586 4.58975 12.2586 4.20986 12.0243 3.97554C11.79 3.74123 11.4101 3.74123 11.1758 3.97554L8.00005 7.15128L4.82431 3.97554C4.59 3.74123 4.2101 3.74123 3.97578 3.97554C3.74147 4.20986 3.74147 4.58975 3.97578 4.82407L7.15152 7.9998L3.97579 11.1755C3.74147 11.4099 3.74147 11.7898 3.97579 12.0241C4.2101 12.2584 4.59 12.2584 4.82431 12.0241L8.00005 8.84833L11.1758 12.0241Z",fill:"#676767"})})}),e.jsx("div",{children:i.isEmptyChildren(n)?e.jsx(s.default,{}):n})]})]})})}),v):null};
