{"version":3,"file":"CalComEmbed.42F8YHBA.mjs","names":["useRef","useState","p"],"sources":["https:/framerusercontent.com/modules/Q18AnMCxEJa5mKr0R7uN/kbJFEgCgdHXtBv7yYYe0/CalComEmbed.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";const NAMESPACE=\"kime-cal-embed\";const ELEMENT_ID=\"kime-cal-inline-embed\";/**\n * Cal.com inline embed. The container height mirrors Cal's reported\n * iframe height (no artificial cap), with one exception: when the\n * iframe is on a routing-form route (calLink starts with `forms/`),\n * Cal reserves the booker's full height even though only the short\n * form card is visible. To avoid a big empty band around the form,\n * we clamp the wrapper to `routingFormMaxHeight` while a routing-form\n * route is active, then release the clamp once Cal navigates to the\n * booker route (event-type slug). Detection is done by listening for\n * Cal's `__routeChanged` postMessage events.\n *\n * If `pageBackground` is provided, Cal's internal page background\n * (cal-bg) is overridden so any padding Cal adds inside the iframe\n * blends with the surrounding section. Leave it empty to use Cal's\n * own default. The white booker card (cal-bg-emphasis) is never\n * touched.\n */export default function CalComEmbed({calLink=\"forms/208a102c-c108-454a-ad75-d26cf9b91c40\",theme=\"light\",brandColor=\"#4C7A6D\",pageBackground=\"\",layout=\"month_view\",minHeight=200,routingFormMaxHeight=420}){const initialized=useRef(false);const containerRef=useRef(null);const[contentHeight,setContentHeight]=useState(minHeight);// Whether the iframe is currently on a routing-form route. Start as\n// true when the initial calLink is a routing form so we clamp from\n// the first render, then flip to false once Cal navigates to the\n// booker (or any non-form) route.\nconst[onRoutingForm,setOnRoutingForm]=useState(()=>(calLink||\"\").startsWith(\"forms/\"));// 1) Initialise Cal.com inline embed once\nuseEffect(()=>{if(initialized.current)return;initialized.current=true;(function(C,A,L){const p=(a,ar)=>a.q.push(ar);const d=C.document;C.Cal=C.Cal||function(){const cal=C.Cal;const ar=arguments;if(!cal.loaded){cal.ns={};cal.q=cal.q||[];d.head.appendChild(d.createElement(\"script\")).src=A;cal.loaded=true;}if(ar[0]===L){const api=function(){p(api,arguments);};const ns=ar[1];api.q=api.q||[];if(typeof ns===\"string\"){cal.ns[ns]=cal.ns[ns]||api;p(cal.ns[ns],ar);p(cal,[\"initNamespace\",ns]);}else{p(cal,ar);}return;}p(cal,ar);};})(window,\"https://app.cal.com/embed/embed.js\",\"init\");// Build the css vars per theme — only include cal-bg when the\n// user provided a pageBackground. Otherwise Cal uses its own\n// default light/dark page background.\nconst buildVars=()=>{const vars={\"cal-brand\":brandColor};if(pageBackground&&pageBackground.trim()!==\"\"){vars[\"cal-bg\"]=pageBackground;}return vars;};window.Cal(\"init\",NAMESPACE,{origin:\"https://app.cal.com\"});window.Cal.ns[NAMESPACE](\"inline\",{elementOrSelector:`#${ELEMENT_ID}`,config:{layout,useSlotsViewOnSmallScreen:\"true\",theme},calLink});window.Cal.ns[NAMESPACE](\"ui\",{theme,cssVarsPerTheme:{light:buildVars(),dark:buildVars()},hideEventTypeDetails:false,layout});// eslint-disable-next-line react-hooks/exhaustive-deps\n},[]);// 2) Track the iframe's actual rendered height — Cal.com sizes its\n//    iframe to fit content in each state, so we just mirror that.\nuseEffect(()=>{const root=containerRef.current;if(!root)return;let stopped=false;let timer=null;let resizeObs=null;const attach=()=>{if(stopped)return;const iframe=root.querySelector(\"iframe\");if(!iframe){timer=window.setTimeout(attach,200);return;}const update=()=>{const h=iframe.offsetHeight;if(h&&h>0){setContentHeight(Math.max(h,minHeight));}};resizeObs=new ResizeObserver(update);resizeObs.observe(iframe);update();};attach();return()=>{stopped=true;if(timer)window.clearTimeout(timer);resizeObs?.disconnect();};},[minHeight]);// 3) postMessage backup channel — also used to detect route changes\n//    (form -> booker) so we can release the routing-form height clamp.\nuseEffect(()=>{const handler=event=>{if(typeof event.origin!==\"string\"||!event.origin.includes(\"cal.com\")){return;}const d=event.data;if(!d||typeof d!==\"object\")return;const action=d.type||d.action;if(action===\"__dimensionChanged\"){const h=d?.data?.iframeHeight??d?.detail?.data?.iframeHeight;if(typeof h===\"number\"&&h>0){setContentHeight(Math.max(h,minHeight));}return;}if(action===\"__routeChanged\"){// Cal posts a routeChanged event with the new path/url.\n// Common shapes: data.data.pathname, data.detail.data.pathname,\n// data.data.url. Sniff a few fallbacks.\nconst detail=d?.data??d?.detail?.data??{};const path=detail.pathname??detail.path??detail.url??\"\";const isForm=typeof path===\"string\"&&path.includes(\"/forms/\");setOnRoutingForm(isForm);}};window.addEventListener(\"message\",handler);return()=>window.removeEventListener(\"message\",handler);},[minHeight]);// Effective height: when the routing form is showing, clamp so the\n// wrapper doesn't reserve the booker's full height. When the booker\n// (or any non-form route) is showing, use the height Cal reports.\nconst effectiveHeight=onRoutingForm?Math.min(contentHeight,routingFormMaxHeight):contentHeight;return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:`${effectiveHeight}px`,overflow:\"hidden\",transition:\"height 0.45s cubic-bezier(0.4, 0, 0.2, 1)\"},children:/*#__PURE__*/_jsx(\"div\",{id:ELEMENT_ID,ref:containerRef,style:{width:\"100%\",height:\"100%\"}})});}addPropertyControls(CalComEmbed,{calLink:{type:ControlType.String,title:\"Cal Link\",defaultValue:\"forms/208a102c-c108-454a-ad75-d26cf9b91c40\"},theme:{type:ControlType.Enum,title:\"Theme\",options:[\"light\",\"dark\"],defaultValue:\"light\"},brandColor:{type:ControlType.Color,title:\"Brand Color\",defaultValue:\"#4C7A6D\"},pageBackground:{type:ControlType.String,title:\"Cal Page BG\",description:\"Override Cal's page background (cal-bg). Leave empty to use Cal.com's default.\",defaultValue:\"\",placeholder:\"e.g. #4C7A6D or empty for default\"},layout:{type:ControlType.Enum,title:\"Layout\",options:[\"month_view\",\"week_view\",\"column_view\"],defaultValue:\"month_view\"},minHeight:{type:ControlType.Number,title:\"Min Height (px)\",defaultValue:200,min:100,max:600,step:10},routingFormMaxHeight:{type:ControlType.Number,title:\"Form Max Height (px)\",description:\"Max wrapper height while a routing form is showing, so the short form doesn't sit in a big empty band.\",defaultValue:420,min:200,max:800,step:10}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CalComEmbed\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CalComEmbed.map"],"mappings":"uMAgBG,SAAwB,EAAY,CAAC,UAAQ,6CAA6C,QAAM,QAAQ,aAAW,UAAU,iBAAe,GAAG,SAAO,aAAa,YAAU,IAAI,uBAAqB,KAAK,CAAC,IAAM,EAAYA,EAAO,GAAM,CAAO,EAAaA,EAAO,KAAK,CAAM,CAAC,EAAc,GAAkBC,EAAS,EAAU,CAInU,CAAC,EAAc,GAAkBA,OAAc,GAAS,IAAI,WAAW,SAAS,CAAC,CAeS,OAd/F,MAAc,CAAC,GAAG,EAAY,QAAQ,OAAO,EAAY,QAAQ,IAAM,SAAS,EAAE,EAAE,EAAE,CAAC,IAAMC,GAAG,EAAE,IAAK,EAAE,EAAE,KAAK,EAAG,CAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,UAAU,CAAC,IAAM,EAAI,EAAE,IAAU,EAAG,UAAyH,GAA/G,AAA8F,EAAI,UAAlF,EAAI,GAAG,EAAE,CAAC,EAAI,EAAE,EAAI,GAAG,EAAE,CAAC,EAAE,KAAK,YAAY,EAAE,cAAc,SAAS,CAAC,CAAC,IAAI,EAAa,IAAS,EAAG,KAAK,EAAE,CAAC,IAAM,EAAI,UAAU,CAAC,EAAE,EAAI,UAAU,EAAS,EAAG,EAAG,GAAG,EAAI,EAAE,EAAI,GAAG,EAAE,CAAI,OAAO,GAAK,UAAU,EAAI,GAAG,GAAI,EAAI,GAAG,IAAK,EAAI,EAAE,EAAI,GAAG,GAAI,EAAG,CAAC,EAAE,EAAI,CAAC,gBAAgB,EAAG,CAAC,EAAO,EAAE,EAAI,EAAG,CAAE,OAAQ,EAAE,EAAI,EAAG,IAAM,EAAO,qCAAqC,OAAO,CAGlkB,IAAM,MAAc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