{"version":3,"file":"Embed.DO9Z6PPC.mjs","names":[],"sources":["https:/framerusercontent.com/modules/o1PI5S8YtkA5bP5g4dFz/4uFi0eQcCd35PpjiP8FM/Embed.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useIsOnCanvas,emptyStateStyle,containerStyles}from\"https://framer.com/m/framer/default-utils.js\";/**\n * @framerIntrinsicWidth 600\n * @framerIntrinsicHeight 400\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */ export default function Embed({type,url,html}){if(type===\"url\"&&url){return(/*#__PURE__*/ _jsx(EmbedURL,{url:url}));}if(type===\"html\"&&html){return(/*#__PURE__*/ _jsx(EmbedHTML,{html:html}));}return(/*#__PURE__*/ _jsx(Instructions,{}));};addPropertyControls(Embed,{type:{type:ControlType.Enum,defaultValue:\"url\",displaySegmentedControl:true,options:[\"url\",\"html\"],optionTitles:[\"URL\",\"HTML\"]},url:{title:\"URL\",type:ControlType.String,description:\"Some websites don’t support embedding.\",hidden(props){return props.type!==\"url\";}},html:{title:\"HTML\",displayTextArea:true,type:ControlType.String,hidden(props){return props.type!==\"html\";}}});function Instructions(){return(/*#__PURE__*/ _jsx(\"div\",{style:{...emptyStateStyle,overflow:\"hidden\"},children:/*#__PURE__*/ _jsx(\"div\",{style:centerTextStyle,children:\"To embed a website or widget, add it to the properties\\xa0panel.\"})}));}function EmbedURL({url}){// Add https:// if the URL does not have a protocol\nif(!/[a-z]+:\\/\\//.test(url)){url=\"https://\"+url;}const onCanvas=useIsOnCanvas();// We need to check if the url is blocked inside an iframe by the X-Frame-Options\n// or Content-Security-Policy headers on the backend:\nconst[state,setState]=useState(onCanvas?undefined:false);useEffect(()=>{// We only want to check on the canvas.\n// On the website we want to avoid the additional delay.\nif(!onCanvas)return;// TODO: We could also use AbortController here.\nlet isLastEffect=true;setState(undefined);async function load(){const response=await fetch(\"https://api.framer.com/functions/check-iframe-url?url=\"+encodeURIComponent(url));if(response.status==200){const{isBlocked}=await response.json();if(isLastEffect){setState(isBlocked);}}else{const message=await response.text();console.error(message);const error=new Error(\"This site can’t be reached.\");setState(error);}}load().catch(error=>{console.error(error);setState(error);});return()=>{isLastEffect=false;};},[url]);if(!url.startsWith(\"https://\")){return(/*#__PURE__*/ _jsx(ErrorMessage,{message:\"Unsupported protocol.\"}));}if(state===undefined){return(/*#__PURE__*/ _jsx(LoadingIndicator,{}));}if(state instanceof Error){return(/*#__PURE__*/ _jsx(ErrorMessage,{message:state.message}));}if(state===true){const message=`Can't embed ${url} due to its content security policy.`;return(/*#__PURE__*/ _jsx(ErrorMessage,{message:message}));}return(/*#__PURE__*/ _jsx(\"iframe\",{src:url,style:iframeStyle,loading:\"lazy\",// @ts-ignore\nfetchPriority:onCanvas?\"low\":\"auto\",referrerPolicy:\"no-referrer\",sandbox:getSandbox(onCanvas)}));}const iframeStyle={width:\"100%\",height:\"100%\",border:\"none\"};function getSandbox(onCanvas){const result=[\"allow-same-origin\",\"allow-scripts\"];if(!onCanvas){result.push(\"allow-downloads\",\"allow-forms\",\"allow-modals\",\"allow-orientation-lock\",\"allow-pointer-lock\",\"allow-popups\",\"allow-popups-to-escape-sandbox\",\"allow-presentation\",\"allow-storage-access-by-user-activation\",\"allow-top-navigation-by-user-activation\");}return result.join(\" \");}function EmbedHTML({html}){const ref=useRef();useEffect(()=>{const div=ref.current;div.innerHTML=html;return()=>{div.innerHTML=\"\";};},[html]);return(/*#__PURE__*/ _jsx(\"div\",{ref:ref,style:htmlStyle}));}const htmlStyle={width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",justifyContent:\"center\",alignItems:\"center\"};// Generic components\nfunction LoadingIndicator(){return(/*#__PURE__*/ _jsx(\"div\",{className:\"framerInternalUI-componentPlaceholder\",style:{...containerStyles,overflow:\"hidden\"},children:/*#__PURE__*/ _jsx(\"div\",{style:centerTextStyle,children:\"Loading…\"})}));}function ErrorMessage({message}){return(/*#__PURE__*/ _jsx(\"div\",{className:\"framerInternalUI-errorPlaceholder\",style:{...containerStyles,overflow:\"hidden\"},children:/*#__PURE__*/ _jsxs(\"div\",{style:centerTextStyle,children:[\"Error: \",message]})}));}const centerTextStyle={textAlign:\"center\",minWidth:140};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Embed\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"600\",\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Embed.map"],"mappings":"0eAMI,SAAwB,EAAM,CAAC,OAAK,MAAI,OAAK,CAAC,CAAkJ,OAA9I,IAAO,OAAO,EAA0B,EAAK,EAAS,CAAK,KAAI,EAAC,CAAM,IAAO,QAAQ,EAA2B,EAAK,EAAU,CAAM,MAAK,EAAC,CAAwB,EAAK,EAAa,CAAE,EAAC,AAAG,CAAmZ,SAAS,GAAc,CAAC,MAAqB,GAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAgB,SAAS,QAAS,EAAC,SAAuB,EAAK,MAAM,CAAC,MAAM,EAAgB,SAAS,kEAAmE,EAAC,AAAC,EAAC,AAAG,UAAS,EAAS,CAAC,MAAI,CAAC,CAC74B,AAAI,cAAc,KAAK,EAAI,GAAE,EAAI,WAAW,GAAK,IAAM,EAAS,GAAe,CAE1E,CAAC,EAAM,EAAS,CAAC,EAAS,MAAA,IAAmB,EAAM,CAGyc,GAHxc,EAAU,IAAI,CAEvE,IAAI,EAAS,OACb,IAAI,GAAa,EAAK,MAAA,GAAmB,CAAC,eAAe,GAAM,CAAC,IAAM,EAAS,KAAM,OAAM,yDAAyD,mBAAmB,EAAI,CAAC,CAAC,GAAG,EAAS,QAAQ,IAAI,CAAC,GAAK,CAAC,YAAU,CA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