{"version":3,"file":"EmbedViewer.CfaGIIHv.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/JCdmLyWQ6VvAD4hzJuWp/QPIKSST3FmkhMfo0C2RN/EmbedViewer.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * HTML / Iframe Embed Viewer\n *\n * Supports:\n * - Inline HTML or URL embeds\n * - Auto-fit height (responsive to width + content)\n * - Iframe postMessage-based resizing\n */export default function EmbedViewer(props){const{htmlContent=\"\",height=400,autoFitContent=false,backgroundColor=\"#FFFFFF\",textColor=\"#000000\",padding=0,borderRadius=0,showLoadingState=true,loadingText=\"Loading...\",errorText=\"No content provided\"}=props;const containerRef=useRef(null);const iframeRef=useRef(null);const[isLoading,setIsLoading]=useState(true);const[hasError,setHasError]=useState(false);const[contentHeight,setContentHeight]=useState(null);const instanceId=useRef(`embed-${Math.random().toString(36).substr(2,9)}`).current;const[isIframeMode,setIsIframeMode]=useState(false);// Detect if the content should be rendered as an iframe\nuseEffect(()=>{if(!htmlContent){setHasError(true);setIsLoading(false);return;}const isIframe=htmlContent.trim().startsWith(\"http\")||htmlContent.toLowerCase().includes(\"<iframe\");setIsIframeMode(isIframe);setIsLoading(false);setHasError(false);},[htmlContent]);// Inline HTML mode — observe content and resize on mutation or container width change\nuseEffect(()=>{if(!autoFitContent||isIframeMode)return;if(!containerRef.current)return;const measure=()=>{const el=containerRef.current?.querySelector(\"div\");if(el){const scrollHeight=el.scrollHeight;startTransition(()=>{setContentHeight(scrollHeight+padding*2);});}};const mutationObserver=new MutationObserver(measure);mutationObserver.observe(containerRef.current,{childList:true,subtree:true,attributes:true});const resizeObserver=new ResizeObserver(measure);resizeObserver.observe(containerRef.current);const timer=setTimeout(measure,150);return()=>{clearTimeout(timer);mutationObserver.disconnect();resizeObserver.disconnect();};},[htmlContent,autoFitContent,isIframeMode,padding]);// Iframe mode — listen for resize messages from the embedded content\nuseEffect(()=>{if(!isIframeMode)return;const listener=event=>{if(event.data?.type===\"embed-resize\"){startTransition(()=>setContentHeight(event.data.height));}};window.addEventListener(\"message\",listener);return()=>window.removeEventListener(\"message\",listener);},[isIframeMode]);const effectiveHeight=autoFitContent&&contentHeight?contentHeight:height;return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,position:\"relative\",width:\"100%\",height:effectiveHeight,transition:\"height 0.3s ease\",backgroundColor,padding,borderRadius,overflow:\"hidden\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\"},children:[showLoadingState&&isLoading&&/*#__PURE__*/_jsx(\"div\",{style:{color:textColor,fontFamily:\"Inter, sans-serif\"},children:loadingText}),hasError&&/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:\"50%\",left:\"50%\",transform:\"translate(-50%, -50%)\",color:textColor,textAlign:\"center\",fontFamily:\"Inter, sans-serif\"},children:errorText}),!isIframeMode&&!hasError&&/*#__PURE__*/_jsx(\"div\",{ref:containerRef,className:instanceId,style:{width:\"100%\",opacity:isLoading?0:1,transition:\"opacity 0.3s ease\",color:textColor},children:/*#__PURE__*/_jsx(\"div\",{dangerouslySetInnerHTML:{__html:htmlContent}})}),isIframeMode&&!hasError&&/*#__PURE__*/_jsx(\"iframe\",{ref:iframeRef,src:htmlContent.trim().startsWith(\"http\")?htmlContent:undefined,srcDoc:htmlContent.trim().startsWith(\"http\")?undefined:htmlContent,sandbox:\"allow-scripts allow-same-origin\",style:{border:\"none\",width:\"100%\",height:\"100%\",borderRadius,background:backgroundColor},onLoad:()=>setIsLoading(false)})]});}// === Framer property controls ===\naddPropertyControls(EmbedViewer,{htmlContent:{type:ControlType.String,title:\"HTML or URL\",defaultValue:\"\",placeholder:\"<div>Your HTML here...</div> or https://example.com\",displayTextArea:true},autoFitContent:{type:ControlType.Boolean,title:\"Auto-fit\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},height:{type:ControlType.Number,title:\"Height\",defaultValue:400,min:100,max:2e3,step:10,unit:\"px\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},padding:{type:ControlType.Number,title:\"Padding\",defaultValue:0,min:0,max:100,step:1,unit:\"px\"},borderRadius:{type:ControlType.Number,title:\"Radius\",defaultValue:0,min:0,max:50,step:1,unit:\"px\"},showLoadingState:{type:ControlType.Boolean,title:\"Loading State\",defaultValue:true},loadingText:{type:ControlType.String,title:\"Loading Text\",defaultValue:\"Loading...\"},errorText:{type:ControlType.String,title:\"Error Text\",defaultValue:\"No content provided\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EmbedViewer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EmbedViewer.map"],"mappings":"+MAOG,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,cAAY,GAAG,SAAO,IAAI,iBAAe,GAAM,kBAAgB,UAAU,YAAU,UAAU,UAAQ,EAAE,eAAa,EAAE,mBAAiB,GAAK,cAAY,aAAa,YAAU,uBAAuB,EAAY,EAAaA,EAAO,KAAK,CAAO,EAAUA,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcC,EAAS,GAAK,CAAM,CAAC,EAAS,GAAaA,EAAS,GAAM,CAAM,CAAC,EAAc,GAAkBA,EAAS,KAAK,CAAO,EAAWD,EAAO,SAAS,KAAK,QAAQ,CAAC,SAAS,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,QAAa,CAAC,EAAa,GAAiBC,EAAS,GAAM,CACjlB,MAAc,CAAC,GAAG,CAAC,EAAY,CAAC,EAAY,GAAK,CAAC,EAAa,GAAM,CAAC,OAA4G,EAArF,EAAY,MAAM,CAAC,WAAW,OAAO,EAAE,EAAY,aAAa,CAAC,SAAS,UAAU,CAA0B,C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