{"version":3,"file":"GlobalCalModal.BA-eCEQs.mjs","names":["useState","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/3m3fbAN6dKipVRsOJg1i/ZyoY1P0jk8Z3LhHLy7Gv/GlobalCalModal.js"],"sourcesContent":["// Requested: Create a new Framer code file that exports two items: (1) a global code component named GlobalCalModal, and (2) a code override named withCalModalTrigger. This replaces duplicated native booking overlays with one reusable, site-wide Cal.com modal.\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{forwardRef,startTransition,useCallback,useEffect,useMemo,useState}from\"react\";import{createPortal}from\"react-dom\";import{addPropertyControls,ControlType}from\"framer\";const OPEN_EVENT_NAME=\"open-cal-demo\";const CAL_BOOKING_URL=\"https://cal.com/simonbellucci/demo-ironwise?embed=true&theme=dark\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function GlobalCalModal(props){const{maxWidth,maxHeight,cornerRadius}=props;const[isOpen,setIsOpen]=useState(false);const[isMounted,setIsMounted]=useState(false);const[portalNode,setPortalNode]=useState(null);const closeModal=useCallback(()=>{startTransition(()=>setIsOpen(false));},[]);useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\")return;startTransition(()=>setIsMounted(true));const node=document.createElement(\"div\");node.setAttribute(\"data-global-cal-modal\",\"true\");document.body.appendChild(node);startTransition(()=>setPortalNode(node));const handleOpen=()=>{startTransition(()=>setIsOpen(true));};window.addEventListener(OPEN_EVENT_NAME,handleOpen);return()=>{window.removeEventListener(OPEN_EVENT_NAME,handleOpen);if(node.parentNode)node.parentNode.removeChild(node);startTransition(()=>{setPortalNode(null);setIsMounted(false);setIsOpen(false);});};},[]);useEffect(()=>{if(typeof window===\"undefined\"||typeof document===\"undefined\"||!isOpen)return;const previousOverflow=document.body.style.overflow;document.body.style.overflow=\"hidden\";const onKeyDown=event=>{if(event.key===\"Escape\")closeModal();};window.addEventListener(\"keydown\",onKeyDown);return()=>{window.removeEventListener(\"keydown\",onKeyDown);document.body.style.overflow=previousOverflow;};},[isOpen,closeModal]);const iframeWrapperStyle=useMemo(()=>({width:\"min(94vw, 100%)\",maxWidth:`${maxWidth}px`,height:\"min(86vh, 760px)\",maxHeight:`${maxHeight}px`,borderRadius:`${cornerRadius}px`,overflow:\"hidden\",position:\"relative\",background:\"transparent\"}),[maxWidth,maxHeight,cornerRadius]);if(!isMounted||!portalNode||!isOpen)return null;return /*#__PURE__*/createPortal(/*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",width:\"100%\",height:\"100%\"},children:[/*#__PURE__*/_jsx(\"div\",{role:\"presentation\",onClick:closeModal,style:{position:\"fixed\",inset:0,background:\"rgba(17, 15, 13, 0.75)\",backdropFilter:\"blur(6px)\",zIndex:3}}),/*#__PURE__*/_jsx(\"div\",{role:\"dialog\",\"aria-modal\":\"true\",\"aria-label\":\"Book a demo\",style:{position:\"fixed\",inset:0,zIndex:9999,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",pointerEvents:\"none\"},children:/*#__PURE__*/_jsx(\"div\",{style:{...iframeWrapperStyle,pointerEvents:\"auto\"},onClick:event=>event.stopPropagation(),children:/*#__PURE__*/_jsx(\"iframe\",{src:CAL_BOOKING_URL,title:\"Book a demo\",style:{border:\"none\",width:\"100%\",height:\"100%\",background:\"transparent\"},allow:\"camera; microphone; fullscreen; autoplay\"})})})]}),portalNode);}export function withCalModalTrigger(Component){return /*#__PURE__*/forwardRef((props,ref)=>{const dispatchOpenModal=useCallback(()=>{if(typeof window===\"undefined\")return;window.dispatchEvent(new CustomEvent(OPEN_EVENT_NAME));},[]);const onClick=useCallback(event=>{if(event?.preventDefault)event.preventDefault();if(props.onClick)props.onClick(event);dispatchOpenModal();},[dispatchOpenModal,props]);const onKeyDown=useCallback(event=>{const key=event?.key;const isActivationKey=key===\"Enter\"||key===\" \";if(isActivationKey){if(event?.preventDefault)event.preventDefault();dispatchOpenModal();}if(props.onKeyDown)props.onKeyDown(event);},[dispatchOpenModal,props]);return /*#__PURE__*/_jsx(Component,{ref:ref,...props,onClick:onClick,onKeyDown:onKeyDown});});}addPropertyControls(GlobalCalModal,{maxWidth:{type:ControlType.Number,title:\"Max Width\",min:320,max:1280,step:1,defaultValue:1100},maxHeight:{type:ControlType.Number,title:\"Max Height\",min:420,max:920,step:1,defaultValue:760},cornerRadius:{type:ControlType.Number,title:\"Radius\",min:8,max:32,step:1,defaultValue:20}});\nexport const __FramerMetadata__ = {\"exports\":{\"withCalModalTrigger\":{\"type\":\"reactHoc\",\"name\":\"withCalModalTrigger\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"GlobalCalModal\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./GlobalCalModal.map"],"mappings":"2OAIG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,WAAS,YAAU,gBAAc,EAAW,CAAC,EAAO,GAAWA,EAAS,EAAK,EAAO,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAO,CAAC,EAAW,GAAeA,EAAS,IAAI,EAAQ,EAAWC,MAAgB,CAAC,MAAoB,EAAU,EAAK,CAAC,CAAE,EAAE,CAAC,CAAC,EAAE,MAAc,CAAC,GAAU,IAAS,QAAa,OAAO,SAAW,IAAY,OAAO,MAAoB,EAAa,EAAI,CAAC,EAAE,IAAM,EAAK,SAAS,cAAc,KAAK,EAAE,EAAK,aAAa,wBAAwB,MAAM,EAAE,SAAS,KAAK,YAAY,CAAI,EAAE,MAAoB,EAAc,CAAI,CAAC,EAAE,IAAM,MAAe,CAAC,MAAoB,EAAU,EAAI,CAAC,CAAE,EAAsD,OAApD,EAAO,iBAAiB,EAAgB,CAAU,MAAY,CAAC,EAAO,oBAAoB,EAAgB,CAAU,EAAK,EAAK,YAAW,EAAK,WAAW,YAAY,CAAI,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