{"version":3,"file":"AppEvent.Cz9MB-Jh.mjs","names":["__esmMin","c","init_jsx_runtime","ce","init_npm_react_18_3_1","getUrl","makeId","result","i","length","getCookie","cookiePrefix","cookieName","cookie","setCookie","documentCookie","cookieValue","AppEvent","clientId","COOKIE_NAME_CLIENT_ID","response","init_AppEvent"],"sources":["https:/framerusercontent.com/modules/SiomRcvyoh8l6TNy7dcV/cQ0aQqNnbLP62ADzKY1A/AppEvent.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect}from\"react\";const TEST=false;const COOKIE_NAME_CLIENT_ID=\"client_id\";function setTestCookie(cookieName,cookieValue){if(TEST){// Framer preview is in a iframe, so SameSite needs to be disabled.\nconst documentCookie=`${cookieName}=${cookieValue}; SameSite=None; Secure; Partitioned`;document.cookie=documentCookie;}}function setClientIdTestCookie(){// To do full end-to-end testing, launch sudowrite-express, get the content of the `client_id` cookie and past it there.  When previewing this component, you should be able to see the request going through your local sudowrite-express.\nconst clientId=\"bBxq5kW5Ym5QfNzJDBDalAp1l\";setTestCookie(COOKIE_NAME_CLIENT_ID,clientId);}function getUrl(){if(TEST){return\"http://localhost:5000/api/app-events/\";}else{return\"https://editor.sudowrite.com/api/app-events/\";}}// Extracted from https://github.com/jamesyu/sudowrite-express/blob/c9ccb84b42cf6cb24b8e42db1e46b9083f543e43/client/src/Utils.js#L35\nfunction makeId(length){let result=\"\";const characters=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";const charactersLength=characters.length;for(var i=0;i<length;i++){result+=characters.charAt(Math.floor(Math.random()*charactersLength));}return result;}function getCookie(cookieName){const cookiePrefix=`${cookieName}=`;const cookies=document.cookie.split(\"; \");const cookie=cookies.find(c=>c.startsWith(cookiePrefix));if(!cookie){return undefined;}return cookie.slice(cookiePrefix.length);}function setCookie(cookieName,cookieValue){const documentCookie=`${cookieName}=${cookieValue}; Domain=.sudowrite.com`;document.cookie=documentCookie;}/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function AppEvent(props){useEffect(()=>{setClientIdTestCookie();let clientId=getCookie(COOKIE_NAME_CLIENT_ID);if(clientId===undefined){clientId=makeId(25);setCookie(COOKIE_NAME_CLIENT_ID,clientId);}// Using `credentials: \"include\"` triggers CORS.  To simplify things and make everything more robust simply send `clientId` as part of the request data.\nfetch(getUrl(),{headers:{\"Content-Type\":\"application/json\"},method:\"POST\",body:JSON.stringify({name:\"Homepage View\",clientId})}).then(response=>response.text()).then(text=>{if(TEST){console.log(text);}});},[]);return /*#__PURE__*/_jsx(\"div\",{});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AppEvent\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AppEvent.map"],"mappings":"A,kHAE0F,SAASK,GAAQ,CAA8D,MAAM,8CAAgD,CAC/N,SAASC,EAAO,EAAO,CAAC,IAAIC,EAAO,GAA8H,IAAI,IAAIC,EAAE,EAAEA,EAAEC,EAAO,IAAK,GAAQ,iEAAW,OAAO,KAAK,MAAM,KAAK,OAAO,EAAE,EAAgB,CAAC,EAAG,OAAOF,CAAO,CAAC,SAASG,EAAU,EAAW,CAAC,IAAMC,EAAa,GAAGC,EAAW,GAAmDC,EAAlC,SAAS,OAAO,MAAM,IAAyB,CAAC,CAAC,KAAK,GAAGZ,EAAE,WAAWU,CAAY,CAAC,EAAE,GAAIE,EAA0B,OAAOA,EAAO,MAAMF,EAAa,MAAM,CAAE,CAAC,SAASG,EAAU,EAAW,EAAY,CAAC,IAAMC,EAAe,GAAGH,EAAW,GAAGI,EAAY,yBAAyB,SAAS,OAAOD,CAAe,CAMjpB,SAAwBE,EAAS,EAAM,CACwK,OADvKd,MAAc,CAAyB,IAAIe,EAASR,EAAUS,CAAqB,EAAKD,IAAW,IAAA,KAAW,EAASZ,EAAO,EAAE,EAAEQ,EAAUK,EAAsBD,CAAQ,GACrN,MAAMb,EAAO,EAAE,CAAC,QAAQ,CAAC,eAAe,kBAAkB,EAAE,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,KAAK,gBAAgB,UAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAUe,EAAS,KAAK,CAAC,CAAC,CAAC,KAAK,GAAM,CAA6B,CAAC,CAAE,EAAE,CAAC,CAAC,EAAsB,gBAAK,MAAM,CAAC,CAAC,CAAE,C,4CAVtJ,EAAsB,W"}