{"version":3,"file":"Calendly_migration.DI_DX41f.mjs","names":["useState","__esmMin","init_ssg_sandbox_shims","init_npm_react_18_3_1","_e","init_jsx_runtime","c","createStore","init_store_js__1_0","withMigration","loading","setLoading","migrationStatus","setMigrationStatus","store","setStore","useStore","buttonText","props","withMigrationMessage","Component","init_Calendly_migration"],"sources":["https:/framerusercontent.com/modules/N4JF8LNl8bzPM2chvbxM/9tx968r3zm1ZJrrFm2sF/Calendly_migration.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useState}from\"react\";import{createStore}from\"https://framer.com/m/framer/store.js@^1.0.0\";const useStore=createStore({migrationMessage:\"\",migrationStatus:\"idle\"});export function withMigration(Component){return props=>{const[loading,setLoading]=useState(false);const[migrationStatus,setMigrationStatus]=useState(\"idle\");const[store,setStore]=useStore();const handleMigrateClick=async()=>{setLoading(true);setMigrationStatus(\"loading\");setStore({migrationStatus:\"loading\",migrationMessage:\"\"});try{// Fetch token from Cal.com API\nconst response=await fetch(\"https://cal.com/api/integuru/initialize-token\",{method:\"GET\",headers:{\"Content-Type\":\"application/json\"},credentials:\"include\"});if(!response.ok){throw new Error(\"Failed to get token\");}const data=await response.json();const accessToken=data.access_token;if(window.Taiki&&accessToken){const TaikiModal=window.Taiki.Create({token:accessToken,platform:\"calendly\",environment:\"production\",onSuccess:()=>handleAuthSuccess(accessToken),onExit:handleAuthExit});TaikiModal.open();}else{throw new Error(\"Taiki not loaded or token missing\");}}catch(error){console.error(\"Error initializing token:\",error);setMigrationStatus(\"error\");setStore({migrationStatus:\"error\",migrationMessage:\"Failed to authenticate with Calendly. Please try again.\"});setLoading(false);}};const handleAuthSuccess=async accessToken=>{try{const response=await fetch(\"/api/integuru/migrate-calendly\",{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},credentials:\"include\",body:JSON.stringify({token:accessToken})});if(!response.ok){throw new Error(\"Migration failed\");}const data=await response.json();if(data.failed>0){setMigrationStatus(\"error\");setStore({migrationStatus:\"error\",migrationMessage:`Migration partially completed. Created: ${data.created}, Failed: ${data.failed}`});}else{setMigrationStatus(\"success\");setStore({migrationMessage:`Successfully migrated ${data.created} event type${data.created!==1?\"s\":\"\"}!`,migrationStatus:\"success\"});}}catch(error){console.error(\"Error migrating event types:\",error);setMigrationStatus(\"error\");setStore({migrationMessage:\"Failed to migrate events. Please try again or contact support.\",migrationStatus:\"error\"});}finally{setLoading(false);}};const handleAuthExit=()=>{if(migrationStatus!==\"idle\"&&migrationStatus!==\"loading\"){return;}setMigrationStatus(\"error\");setStore({migrationMessage:\"Authentication cancelled. Please try again.\",migrationStatus:\"error\"});setLoading(false);};// Determine button text based on state\nlet buttonText=\"Migrate Now\";if(loading){buttonText=\"Processing...\";}else if(migrationStatus===\"success\"){buttonText=\"✓ Migration Complete\";}else if(migrationStatus===\"error\"){buttonText=\"Try Again\";}return /*#__PURE__*/_jsx(\"div\",{...props,// onClick={handleMigrateClick}\ndisabled:loading,\"data-cal-link\":\"amit/quick-chat\",\"data-cal-namespace\":\"quick-chat\",\"data-cal-config\":JSON.stringify({layout:\"month_view\",useSlotsViewOnSmallScreen:true}),style:{...props.style,opacity:loading?.6:1,cursor:loading?\"not-allowed\":\"pointer\"},children:buttonText});};}export function withMigrationMessage(Component){return props=>{const[store]=useStore();if(!store.migrationMessage)return null;return /*#__PURE__*/_jsx(Component,{style:{...props.style,color:store.migrationStatus===\"error\"?\"#EF4444\":undefined},...props,text:store.migrationMessage});};}\nexport const __FramerMetadata__ = {\"exports\":{\"withMigration\":{\"type\":\"reactHoc\",\"name\":\"withMigration\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withMigrationMessage\":{\"type\":\"reactHoc\",\"name\":\"withMigrationMessage\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Calendly_migration.map"],"mappings":"A,iLAAqN,SAAgBS,EAAc,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAACC,EAAQC,GAAYX,EAAS,EAAK,EAAO,CAACY,EAAgBC,GAAoBb,EAAS,MAAM,EAAO,CAACc,EAAMC,GAAUC,EAAS,EAE7YC,EAAW,cAAyL,OAAxKP,EAAS,EAAW,gBAAyBE,IAAkB,UAAW,EAAW,uBAAgCA,IAAkB,UAAS,EAAW,aAAiC,gBAAK,MAAM,CAAC,GAAGM,EAC3O,SAASR,EAAQ,gBAAgB,kBAAkB,qBAAqB,aAAa,kBAAkB,KAAK,UAAU,CAAC,OAAO,aAAa,0BAA0B,EAAI,CAAC,EAAE,MAAM,CAAC,GAAGQ,EAAM,MAAM,QAAQR,EAAQ,GAAG,EAAE,OAAOA,EAAQ,cAAc,SAAS,EAAE,SAASO,CAAU,CAAC,CAAE,CAAE,CAAC,SAAgBE,EAAqB,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAACL,GAAOE,EAAS,EAAyC,OAAnCF,EAAM,iBAAiD,gBAAKM,EAAU,CAAC,MAAM,CAAC,GAAGF,EAAM,MAAM,MAAMJ,EAAM,kBAAkB,QAAQ,UAAU,IAAA,EAAS,EAAE,GAAGI,EAAM,KAAKJ,EAAM,gBAAgB,CAAC,EAA/J,IAAiK,CAAE,C,oDAHla,EAASP,EAAY,CAAC,iBAAiB,GAAG,gBAAgB,MAAM,CAAC,C"}