{"version":3,"file":"Embed.BMFzF8dW.mjs","names":["useState","useRef","__esmMin","_e","de","init_jsx_runtime","c","p","init_npm_react_18_3_1","ce","addPropertyControls","init_framer_DymZktPS","ControlType","emptyStateStyle","containerStyles","useIsOnCanvas","init_OIjZRBmWDcIE2B6qgG1j","init_default_utils","Embed","type","url","EmbedURL","html","EmbedHTML","Instructions","centerTextStyle","onCanvas","state","setState","isLastEffect","load","response","isBlocked","message","error","ErrorMessage","LoadingIndicator","iframeStyle","getSandbox","result","ref","hasScript","div","executeScripts","htmlStyle","node","script","name","value","child","init_Embed","props"],"sources":["https:/framer.com/m/framer/default-utils.js","https:/framerusercontent.com/modules/o1PI5S8YtkA5bP5g4dFz/9zLIz4fn80IR9zpOx18Q/Embed.js"],"sourcesContent":["/*\n * index (framer/default-utils@0.45.0)\n *\n * Learn More: https://www.framer.com/asset-urls\n */\n\nexport * from \"https://framerusercontent.com/modules/G4IfyjvwmaeSBpdb4TWu/OIjZRBmWDcIE2B6qgG1j/index.js\"\n","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 *\n * @framerDisableUnlink\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();// If the HTML contains a script tag we can't use\n// dangerouslySetInnerHTML because it doesn't execute\n// scripts on the client. Otherwise, we can benefit\n// from SSG by using dangerouslySetInnerHTML.\nconst hasScript=html.includes(\"</script>\");useEffect(()=>{if(!hasScript)return;const div=ref.current;div.innerHTML=html;executeScripts(div);return()=>{div.innerHTML=\"\";};},[html,hasScript]);return /*#__PURE__*/ _jsx(\"div\",{ref:ref,style:htmlStyle,dangerouslySetInnerHTML:!hasScript?{__html:html}:undefined});}const htmlStyle={width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",justifyContent:\"center\",alignItems:\"center\"};// This function replaces scripts with executable ones.\n// https://stackoverflow.com/questions/1197575/can-scripts-be-inserted-with-innerhtml\nfunction executeScripts(node){if(node instanceof Element&&node.tagName===\"SCRIPT\"){const script=document.createElement(\"script\");script.text=node.innerHTML;for(const{name,value}of node.attributes){script.setAttribute(name,value);}node.parentElement.replaceChild(script,node);}else{for(const child of node.childNodes){executeScripts(child);}}}// 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\":{\"framerSupportedLayoutHeight\":\"fixed\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerDisableUnlink\":\"\",\"framerIntrinsicWidth\":\"600\",\"framerIntrinsicHeight\":\"400\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Embed.map"],"mappings":"A,oTCQI,SAAwBkB,EAAM,CAAC,OAAK,MAAI,QAAM,CAAgJ,OAA5IC,IAAO,OAAOC,EAA0B,gBAAKC,EAAS,CAAK,KAAG,CAAC,EAAMF,IAAO,QAAQG,EAA2B,gBAAKC,EAAU,CAAM,MAAI,CAAC,EAAwB,gBAAKC,EAAa,CAAC,CAAC,CAAE,CAAoZ,SAASA,GAAc,CAAC,MAAqB,gBAAK,MAAM,CAAC,MAAM,CAAC,GAAGX,EAAgB,SAAS,QAAQ,EAAE,SAAuB,gBAAK,MAAM,CAAC,MAAMY,EAAgB,SAAS,kEAAkE,CAAC,CAAC,CAAC,CAAE,CAAC,SAASJ,EAAS,CAAC,OAAK,CACr4B,cAAc,KAAKD,CAAG,IAAG,EAAI,WAAWA,GAAK,IAAMM,EAASX,EAAc,EAEzE,CAACY,EAAMC,GAAU5B,EAAS0B,EAAS,IAAA,GAAU,EAAK,EAG0c,GAHxcjB,MAAc,CAEvE,GAAG,CAACiB,EAAS,OACb,IAAIG,EAAa,GAAKD,EAAS,IAAA,EAAS,EAAE,eAAeE,GAAM,CAAC,IAAMC,EAAS,MAAM,MAAM,yDAAyD,mBAAmBX,CAAG,CAAC,EAAE,GAAGW,EAAS,QAAQ,IAAI,CAAC,GAAK,CAAC,aAAW,MAAMA,EAAS,KAAK,EAAKF,GAAcD,EAASI,CAAS,CAAG,KAAK,CAAC,IAAMC,EAAQ,MAAMF,EAAS,KAAK,EAAE,QAAQ,MAAME,CAAO,EAAuDL,EAAS,gBAA9C,MAAM,6BAA4C,CAAC,CAAE,CAAC,CAA8D,OAA7DE,EAAK,CAAC,CAAC,MAAM,GAAO,CAAC,QAAQ,MAAMI,CAAK,EAAEN,EAASM,CAA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