{
  "version": 3,
  "sources": ["ssg:https://framerusercontent.com/modules/Da01OZwYRzmGJl2CIfjO/RsDuOyNWHrpywF4AQJS0/Loops_Form2.js"],
  "sourcesContent": ["////////////////\n//\n// Using Framer?\n// See https://www.framer.com/learn/code-components/ for more info\n//\n////////////////\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { useState } from \"react\";\nconst INIT = \"INIT\";\nconst SUBMITTING = \"SUBMITTING\";\nconst ERROR = \"ERROR\";\nconst SUCCESS = \"SUCCESS\";\nconst formStates = [INIT, SUBMITTING, ERROR, SUCCESS];\nconst formStyles = {\n  id: \"clgv6cfdj0074l60fogqms9gc\",\n  name: \"Default\",\n  formStyle: \"buttonBelow\",\n  placeholderText: \"you@example.com\",\n  formFont: \"Inter\",\n  formFontColor: \"#000000\",\n  formFontSizePx: 14,\n  buttonText: \"Start Now\",\n  buttonFont: \"Inter\",\n  buttonFontColor: \"#ffffff\",\n  buttonColor: \"#FB3657\",\n  buttonFontSizePx: 14,\n  successMessage: \"Thanks! We'll be in touch!\",\n  successFont: \"Inter\",\n  successFontColor: \"#000000\",\n  successFontSizePx: 14,\n  userGroup: \"API Users\"\n};\nconst domain = \"app.loops.so\";\nexport default function SignUpFormReact() {\n  const [email, setEmail] = useState(\"\");\n  const [formState, setFormState] = useState(INIT);\n  const [errorMessage, setErrorMessage] = useState(\"\");\n  const resetForm = () => {\n    setEmail(\"\");\n    setFormState(INIT);\n    setErrorMessage(\"\");\n  }; /**\n     * Rate limit the number of submissions allowed\n     * @returns {boolean} true if the form has been successfully submitted in the past minute\n     */\n  const hasRecentSubmission = () => {\n    const time = new Date();\n    const timestamp = time.valueOf();\n    const previousTimestamp = localStorage.getItem(\"loops-form-timestamp\"); // Indicate if the last sign up was less than a minute ago\n    if (previousTimestamp && Number(previousTimestamp) + 60 * 1e3 > timestamp) {\n      setFormState(ERROR);\n      setErrorMessage(\"Too many signups, please try again in a little while\");\n      return true;\n    }\n    localStorage.setItem(\"loops-form-timestamp\", timestamp.toString());\n    return false;\n  };\n  const handleSubmit = event => {\n    // Prevent the default form submission\n    event.preventDefault(); // boundary conditions for submission\n    if (formState !== INIT) return;\n    if (!isValidEmail(email)) {\n      setFormState(ERROR);\n      setErrorMessage(\"Please enter a valid email\");\n      return;\n    }\n    if (hasRecentSubmission()) return;\n    setFormState(SUBMITTING); // build body\n    const formBody = `userGroup=${encodeURIComponent(formStyles.userGroup)}&email=${encodeURIComponent(email)}`; // API request to add user to newsletter\n    fetch(`https://${domain}/api/newsletter-form/${formStyles.id}`, {\n      method: \"POST\",\n      body: formBody,\n      headers: {\n        \"Content-Type\": \"application/x-www-form-urlencoded\"\n      }\n    }).then(res => [res.ok, res.json(), res]).then(([ok, dataPromise, res]) => {\n      if (ok) {\n        resetForm();\n        setFormState(SUCCESS);\n        window.open(\"https://docs.prodia.com\", \"_blank\");\n      } else {\n        dataPromise.then(data => {\n          setFormState(ERROR);\n          setErrorMessage(data.message || res.statusText);\n          localStorage.setItem(\"loops-form-timestamp\", \"\");\n        });\n      }\n    }).catch(error => {\n      setFormState(ERROR); // check for cloudflare error\n      if (error.message === \"Failed to fetch\") {\n        setErrorMessage(\"Too many signups, please try again in a little while\");\n      } else if (error.message) {\n        setErrorMessage(error.message);\n      }\n      localStorage.setItem(\"loops-form-timestamp\", \"\");\n    });\n  };\n  const isInline = formStyles.formStyle === \"inline\";\n  switch (formState) {\n    case SUCCESS:\n      return /*#__PURE__*/_jsx(\"div\", {\n        style: {\n          display: \"flex\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          width: \"100%\"\n        },\n        children: /*#__PURE__*/_jsx(\"p\", {\n          style: {\n            fontFamily: `'${formStyles.successFont}', sans-serif`,\n            color: formStyles.successFontColor,\n            fontSize: `${formStyles.successFontSizePx}px`\n          },\n          children: formStyles.successMessage\n        })\n      });\n    case ERROR:\n      return /*#__PURE__*/_jsxs(_Fragment, {\n        children: [/*#__PURE__*/_jsx(SignUpFormError, {}), /*#__PURE__*/_jsx(BackButton, {})]\n      });\n    default:\n      return /*#__PURE__*/_jsx(_Fragment, {\n        children: /*#__PURE__*/_jsxs(\"form\", {\n          onSubmit: handleSubmit,\n          style: {\n            display: \"flex\",\n            flexDirection: isInline ? \"row\" : \"column\",\n            alignItems: \"center\",\n            justifyContent: \"center\",\n            width: \"100%\"\n          },\n          children: [/*#__PURE__*/_jsx(\"input\", {\n            type: \"text\",\n            name: \"email\",\n            placeholder: formStyles.placeholderText,\n            value: email,\n            onChange: e => setEmail(e.target.value),\n            required: true,\n            style: {\n              color: formStyles.formFontColor,\n              fontFamily: `'${formStyles.formFont}', sans-serif`,\n              fontSize: `${formStyles.formFontSizePx}px`,\n              margin: isInline ? \"0px 10px 0px 0px\" : \"0px 0px 10px\",\n              width: \"100%\",\n              maxWidth: \"300px\",\n              minWidth: \"100px\",\n              background: \"#FFFFFF\",\n              border: \"1px solid #D1D5DB\",\n              boxSizing: \"border-box\",\n              boxShadow: \"rgba(0, 0, 0, 0.05) 0px 1px 2px\",\n              borderRadius: \"6px\",\n              padding: \"8px 12px\"\n            }\n          }), /*#__PURE__*/_jsx(SignUpFormButton, {})]\n        })\n      });\n  }\n  function SignUpFormError() {\n    return /*#__PURE__*/_jsx(\"div\", {\n      style: {\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        width: \"100%\"\n      },\n      children: /*#__PURE__*/_jsx(\"p\", {\n        style: {\n          fontFamily: \"Inter, sans-serif\",\n          color: \"rgb(185, 28, 28)\",\n          fontSize: \"14px\"\n        },\n        children: errorMessage || \"Oops! Something went wrong, please try again\"\n      })\n    });\n  }\n  function BackButton() {\n    const [isHovered, setIsHovered] = useState(false);\n    return /*#__PURE__*/_jsx(\"button\", {\n      style: {\n        color: \"#6b7280\",\n        font: \"14px, Inter, sans-serif\",\n        margin: \"10px auto\",\n        textAlign: \"center\",\n        background: \"transparent\",\n        border: \"none\",\n        cursor: \"pointer\",\n        textDecoration: isHovered ? \"underline\" : \"none\"\n      },\n      onMouseOut: () => setIsHovered(false),\n      onMouseOver: () => setIsHovered(true),\n      onClick: resetForm,\n      children: \"\u2190 Back\"\n    });\n  }\n  function SignUpFormButton({\n    props\n  }) {\n    return /*#__PURE__*/_jsx(\"button\", {\n      type: \"submit\",\n      style: {\n        background: formStyles.buttonColor,\n        fontSize: `${formStyles.buttonFontSizePx}px`,\n        color: formStyles.buttonFontColor,\n        fontFamily: `'${formStyles.buttonFont}', sans-serif`,\n        width: isInline ? \"min-content\" : \"100%\",\n        maxWidth: \"300px\",\n        whiteSpace: isInline ? \"nowrap\" : \"normal\",\n        height: \"38px\",\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        flexDirection: \"row\",\n        padding: \"9px 17px\",\n        boxShadow: \"0px 1px 2px rgba(0, 0, 0, 0.05)\",\n        borderRadius: \"6px\",\n        textAlign: \"center\",\n        fontStyle: \"normal\",\n        fontWeight: 500,\n        lineHeight: \"20px\",\n        border: \"none\",\n        cursor: \"pointer\"\n      },\n      children: formState === SUBMITTING ? \"Please wait...\" : formStyles.buttonText\n    });\n  }\n}\n;\nfunction isValidEmail(email) {\n  return /.+@.+/.test(email);\n}\nexport const __FramerMetadata__ = {\n  \"exports\": {\n    \"default\": {\n      \"type\": \"reactComponent\",\n      \"name\": \"SignUpFormReact\",\n      \"slots\": [],\n      \"annotations\": {\n        \"framerContractVersion\": \"1\"\n      }\n    },\n    \"__FramerMetadata__\": {\n      \"type\": \"variable\"\n    }\n  }\n};\n//# sourceMappingURL=./Loops_Form2.map"],
  "mappings": "oIAQA,IAAMA,EAAO,OACPC,EAAa,aACbC,EAAQ,QACRC,EAAU,UAEhB,IAAMC,EAAa,CACjB,GAAI,4BACJ,KAAM,UACN,UAAW,cACX,gBAAiB,kBACjB,SAAU,QACV,cAAe,UACf,eAAgB,GAChB,WAAY,YACZ,WAAY,QACZ,gBAAiB,UACjB,YAAa,UACb,iBAAkB,GAClB,eAAgB,6BAChB,YAAa,QACb,iBAAkB,UAClB,kBAAm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B,CAAC,CAAC,CAAC,CAC7C,CAAC,CACH,CAAC,CACL,CACA,SAASH,GAAkB,CACzB,OAAoBH,EAAK,MAAO,CAC9B,MAAO,CACL,WAAY,SACZ,eAAgB,SAChB,MAAO,MACT,EACA,SAAuBA,EAAK,IAAK,CAC/B,MAAO,CACL,WAAY,oBACZ,MAAO,mBACP,SAAU,MACZ,EACA,SAAUpB,GAAgB,8CAC5B,CAAC,CACH,CAAC,CACH,CACA,SAASwB,GAAa,CACpB,GAAM,CAACG,EAAWC,CAAY,EAAIhC,EAAS,EAAK,EAChD,OAAoBwB,EAAK,SAAU,CACjC,MAAO,CACL,MAAO,UACP,KAAM,0BACN,OAAQ,YACR,UAAW,SACX,WAAY,cACZ,OAAQ,OACR,OAAQ,UACR,eAAgBO,EAAY,YAAc,MAC5C,EACA,WAAY,IAAMC,EAAa,EAAK,EACpC,YAAa,IAAMA,EAAa,EAAI,EACpC,QAAS1B,EACT,SAAU,aACZ,CAAC,CACH,CACA,SAASwB,EAAiB,CACxB,MAAAG,CACF,EAAG,CACD,OAAoBT,EAAK,SAAU,CACjC,KAAM,SACN,MAAO,CACL,WAAY7B,EAAW,YACvB,SAAU,GAAGA,EAAW,qBACxB,MAAOA,EAAW,gBAClB,WAAY,IAAIA,EAAW,0BAC3B,MAAO4B,EAAW,cAAgB,OAClC,SAAU,QACV,WAAYA,EAAW,SAAW,SAClC,OAAQ,OACR,WAAY,SACZ,eAAgB,SAChB,cAAe,MACf,QAAS,WACT,UAAW,kCACX,aAAc,MACd,UAAW,SACX,UAAW,SACX,WAAY,IACZ,WAAY,OACZ,OAAQ,OACR,OAAQ,SACV,EACA,SAAUtB,IAAca,EAAa,iBAAmBnB,EAAW,UACrE,CAAC,CACH,CACF,CAEA,SAASkB,EAAaf,EAAO,CAC3B,MAAO,QAAQ,KAAKA,CAAK,CAC3B",
  "names": ["INIT", "SUBMITTING", "ERROR", "SUCCESS", "formStyles", "domain", "SignUpFormReact", "email", "setEmail", "ye", "formState", "setFormState", "INIT", "errorMessage", "setErrorMessage", "resetForm", "hasRecentSubmission", "timestamp", "previousTimestamp", "ERROR", "handleSubmit", "event", "isValidEmail", "SUBMITTING", "formBody", "res", "ok", "dataPromise", "SUCCESS", "window", "data", "error", "isInline", "p", "u", "l", "SignUpFormError", "BackButton", "e", "SignUpFormButton", "isHovered", "setIsHovered", "props"]
}
