{"version":3,"file":"ForgotPassword.Ce6Xk70i.mjs","names":["useState","useMemo","sendForgotPasswordEmail"],"sources":["https:/framerusercontent.com/modules/ghBsTAf9L1Zpg8S8JAwn/2G18sZCXXiuxtItBzH86/ForgotPassword.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useMemo,useState}from\"react\";// @ts-ignore\nimport{addPropertyControls,ControlType,withCSS}from\"framer\";import{sendForgotPasswordEmail}from\"https://cdn.jsdelivr.net/npm/@framerauth/sdk@2/dist/framerauth.mjs\";import BaseForm,{basePropertyControls}from\"https://framerusercontent.com/modules/tU0OhNHakDNO2P6BFnP9/J4dB1XKps8sUUI6R9wpl/BaseForm.js\";//////////////////////////////////\n/////// FORM CONFIGURATION ///////\n//////////////////////////////////\n// Define inputs\nconst baseInputs=[{displayName:\"Email\",name:\"email\",type:\"string\",format:\"email\",required:true,overridable:false,placeholder:\"Email\",render:true,hidden:false}];const formId=\"forgot_password\"// Unique form ID for this form.\n;const defaultButtonLabel=\"Send Reset Email\"// Default submit button label on this form.\n;const buttonLabelKey=`${formId}_button_label`// Key for button label property control.\n;/**\n * ForgotPassword.tsx\n * By Joel Whitaker\n *\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 40\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any\n */const ForgotPassword=withCSS(function ForgotPassword({...baseProps}){const[inputs,setInputs]=useState(baseInputs)// We can override inputs with property controls.\n;const buttonProps=useMemo(()=>{// Map button label to button\n// This is to avoid style copy-pasting of the button label.\nreturn{...baseProps.button,label:baseProps.button[buttonLabelKey]};},[baseProps.button,baseProps.button[buttonLabelKey]]);useEffect(()=>{// Map input labels to inputs\nif(baseProps.inputFields){const newInputs=[];baseInputs.forEach((input,_idx)=>{const inputControlName=snakeToCamel(input.name);if(!(inputControlName in baseProps.inputFields)){// If the input is not in the inputFields object, skip it.\nreturn;}const inputField=baseProps.inputFields[inputControlName];const render=inputField.render||true;const hidden=inputField.hidden||false;const displayName=inputField.displayName;const placeholder=displayName;if(render===true){newInputs.push({...input,hidden,displayName,placeholder});}});setInputs(newInputs);}},[undefined,baseProps.inputFields]);const onSubmit=async formData=>{const forgotPasswordResponse=await sendForgotPasswordEmail(formData);if(forgotPasswordResponse.error){return{ok:false,message:forgotPasswordResponse.error.message};}return{ok:true,message:forgotPasswordResponse.data?.message||\"Email instructions sent.\"};};return /*#__PURE__*/_jsx(BaseForm,{...baseProps,button:buttonProps,fields:inputs,onSubmit:onSubmit});},[]);const snakeToCamel=str=>{return str.split(\"_\").map((word,index)=>{if(index===0){return word;}return word.charAt(0).toUpperCase()+word.slice(1);}).join(\"\");};// Here we can override property controls if we don't want to expose them to the user.\n// We generate the inputs property controls dynamically based on the inputs array.\nconst inputsPropertyControls={};baseInputs.forEach((input,_idx)=>{const inputControlName=snakeToCamel(input.name);inputsPropertyControls[inputControlName]={title:`${input.displayName}`,type:ControlType.Object,controls:{render:input.overridable===true?{title:\"Render\",type:ControlType.Boolean,defaultValue:true}:undefined,hidden:input.overridable===true?{title:\"Hidden\",type:ControlType.Boolean,defaultValue:false,hidden:props=>props.render===true}:undefined,displayName:{title:\"Display Name\",type:ControlType.String,defaultValue:input.displayName,hidden:props=>props.render===true&&props.hidden===false}}};});const exportBasePropertyControls={...basePropertyControls,inputFields:{title:\"Inputs\",type:ControlType.Object,controls:inputsPropertyControls},link:{title:\"Redirect\",type:ControlType.Link},button:{// Inject default button label\n...basePropertyControls.button,controls:{...basePropertyControls.button.controls,label:undefined,[buttonLabelKey]:{...basePropertyControls.button.controls.label,defaultValue:defaultButtonLabel}}}};// @ts-ignore - TS doesn't like our basePropertyControls type.\naddPropertyControls(ForgotPassword,exportBasePropertyControls);ForgotPassword.defaultProps={...BaseForm.defaultProps,...ForgotPassword.defaultProps};export default ForgotPassword;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ForgotPassword\",\"slots\":[],\"annotations\":{\"framerIntrinsicHeight\":\"40\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\",\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutWidth\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"6UAA0C,IAA8C,IAC7B,IAAwG,IAAwI,EAIrS,EAAW,CAAC,CAAC,YAAY,QAAQ,KAAK,QAAQ,KAAK,SAAS,OAAO,QAAQ,SAAS,GAAK,YAAY,GAAM,YAAY,QAAQ,OAAO,GAAK,OAAO,EAAK,CAAC,EAAQ,EAAO,kBACtK,EAAmB,mBACnB,EAAe,GAAG,EAAO,eAYvB,EAAe,EAAQ,SAAwB,CAAC,GAAG,GAAW,CAAC,GAAK,CAAC,EAAO,GAAWA,EAAS,CAAU,EAC5G,EAAYC,OAEb,CAAC,GAAG,EAAU,OAAO,MAAM,EAAU,OAAO,EAAe,GAAI,CAAC,EAAU,OAAO,EAAU,OAAO,EAAe,CAAC,EAAE,MAAc,CACxI,GAAG,EAAU,YAAY,CAAC,IAAM,EAAU,CAAC,EAAE,EAAW,SAAS,EAAM,IAAO,CAAC,IAAM,EAAiB,EAAa,EAAM,IAAI,EAAE,GAAG,EAAE,KAAoB,EAAU,aAClK,OAAQ,IAAM,EAAW,EAAU,YAAY,GAAwB,EAAO,EAAW,QAAQ,GAAW,EAAO,EAAW,QAAQ,GAAY,EAAY,EAAW,YAAkB,EAAY,EAAe,IAAS,IAAM,EAAU,KAAK,CAAC,GAAG,EAAM,SAAO,cAAY,aAAW,CAAC,CAAG,CAAC,EAAE,EAAU,CAAS,CAAE,CAAC,EAAE,CAAC,IAAA,GAAU,EAAU,WAAW,CAAC,EAAE,IAAM,EAAS,KAAM,IAAU,CAAC,IAAM,EAAuB,MAAMC,EAAwB,CAAQ,EAAkG,OAA7F,EAAuB,MAAa,CAAC,GAAG,GAAM,QAAQ,EAAuB,MAAM,OAAO,EAAS,CAAC,GA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