{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/3W5nIN7ci05JVQxwk4KM/9LyyeRlWoie7r8tsHRpL/CryptoWidget.js"],
  "sourcesContent": ["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";addPropertyControls(CryptoWidget,{env:{title:\"Environment\",type:ControlType.Enum,optionTitles:[\"Production\",\"Test\",\"Development\"],options:[\"production\",\"test\",\"development\"],defaultValue:\"production\"},domain:{title:\"development Domain\",type:ControlType.String,hidden:props=>props.env!==\"development\",defaultValue:\"mhume.bp:8088\"},flow:{title:\"Starting Page\",type:ControlType.Enum,optionTitles:[\"Buy\",\"Sell\"],options:[\"buy\",\"sell\"],defaultValue:\"buy\"},cryptoCurrency:{title:\"Cryptocurrency\",type:ControlType.String,defaultValue:\"\"}});/**\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n * @framerIntrinsicHeight 850\n * @framerIntrinsicWidth 500\n */export default function CryptoWidget(props){const[isSetupComplete,setIsSetupComplete]=useState(false);async function fetchCryptoWidgetScript(props){const domain=getDomain(props);try{const response=await fetch(`https://${domain}/crypto-widget/script`);if(!response.ok){throw new Error(\"Unable to fetch crypto-widget script\");}const script=await response.text();setupCryptoWidgetScript(script);setIsSetupComplete(true);}catch(error){console.error(\"Error fetching crypto-widget script\");setIsSetupComplete(false);}}// Step 1: Fetches scripts and sets up the component\nuseEffect(()=>{fetchCryptoWidgetScript(props);},[]);// Step 2: Waits until setup is complete, then runs the component startup script\nuseEffect(()=>{if(isSetupComplete){runCryptoWidgetScript(props);}},[isSetupComplete]);// Step 3: Renders the script in the container\nreturn isSetupComplete?/*#__PURE__*/_jsx(\"div\",{id:\"bitpay-widget-container\",style:containerStyle}):null;}function setupCryptoWidgetScript(script){if(document.querySelector(\"script#bitpay-widget-script\")){return;}const scriptElement=document.createElement(\"script\");scriptElement.text=script;document.body.appendChild(scriptElement);}function runCryptoWidgetScript(props){if(typeof window.BitPayCryptoWidget===\"function\"){const widget=new window.BitPayCryptoWidget({flow:props.flow,env:props.env,domain:props.domain,cryptoCurrency:props.cryptoCurrency});widget.attach();}}function getDomain(props){let hostname=\"bitpay.com\";let subdomain;switch(props.env){case\"test\":subdomain=\"test\";break;case\"development\":subdomain=\"\";hostname=props.domain;case\"production\":default:subdomain=\"\";break;}return subdomain?`${subdomain}.${hostname}`:hostname;}const containerStyle={height:\"100%\",width:\"100%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",overflow:\"hidden\"};\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CryptoWidget\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"850\",\"framerIntrinsicWidth\":\"500\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CryptoWidget.map"],
  "mappings": "gJAAqIA,EAAoBC,EAAa,CAAC,IAAI,CAAC,MAAM,cAAc,KAAKC,EAAY,KAAK,aAAa,CAAC,aAAa,OAAO,aAAa,EAAE,QAAQ,CAAC,aAAa,OAAO,aAAa,EAAE,aAAa,YAAY,EAAE,OAAO,CAAC,MAAM,qBAAqB,KAAKA,EAAY,OAAO,OAAOC,GAAOA,EAAM,MAAM,cAAc,aAAa,eAAe,EAAE,KAAK,CAAC,MAAM,gBAAgB,KAAKD,EAAY,KAAK,aAAa,CAAC,MAAM,MAAM,EAAE,QAAQ,CAAC,MAAM,MAAM,EAAE,aAAa,KAAK,EAAE,eAAe,CAAC,MAAM,iBAAiB,KAAKA,EAAY,OAAO,aAAa,EAAE,CAAC,CAAC,EAMtoB,SAARD,EAA8BE,EAAM,CAAC,GAAK,CAACC,EAAgBC,CAAkB,EAAEC,EAAS,EAAK,EAAE,eAAeC,EAAwBJ,EAAM,C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SAAS,SAAS,QAAQ",
  "names": ["addPropertyControls", "CryptoWidget", "ControlType", "props", "isSetupComplete", "setIsSetupComplete", "ye", "fetchCryptoWidgetScript", "domain", "getDomain", "response", "script", "setupCryptoWidgetScript", "ue", "runCryptoWidgetScript", "containerStyle", "scriptElement", "window", "hostname", "subdomain"]
}
