{"version":3,"file":"ActivateLicenseForm.B0TA3-JC.mjs","names":["ActivateLicenseForm","useState","useMemo","auth","BaseForm"],"sources":["https:/framerusercontent.com/modules/73E1D602x7AcbDbkwc50/X92cRddvq0XKtHZfC3yK/ActivateLicenseForm.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useMemo,useState}from\"react\";// @ts-ignore\nimport{addPropertyControls,ControlType,withCSS}from\"framer\";// @ts-ignore\nimport{auth}from\"https://cdn.framerauth.com/packages/sdk/live/latest/framerauth.esm.js\";import BaseForm,{basePropertyControls}from\"https://framerusercontent.com/modules/ExV5oOjPmSTY0gHEjmby/NpqywsqBSPokrP5l2Kmw/BaseForm.js\";//////////////////////////////////\n/////// FORM CONFIGURATION ///////\n//////////////////////////////////\n// Define inputs\nconst baseInputs=[{label:\"License Key\",name:\"license_key\",type:\"text\",required:true,extra:false,placeholder:\"License Key\"}];const formId=\"activate_license\"// Unique form ID for this form.\n;const defaultButtonLabel=\"Activate\"// Default submit button label on this form.\n;const exposeIconColor=false// Expose icon color property for input icons (eg hide/show password icon).\n;const buttonLabelKey=`${formId}_button_label`// Key for button label property control.\n;/**\n * Activate License Form\n * By Joel Whitaker\n *\n * @framerDisableUnlink\n *\n * @framerIntrinsicWidth 300\n * @framerIntrinsicHeight 40\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight any\n */const ActivateLicenseForm=withCSS(function ActivateLicenseForm({...baseProps}){const[inputs,setInputs]=useState(baseInputs)// We can override inputs with property controls.\n;const[licenseKey,setLicenseKey]=useState(null);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(()=>{const defaultLicenseKey=getParamValue(\"license_key\");setLicenseKey(defaultLicenseKey);},[]);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.\nconsole.log(`Input ${inputControlName} not found in inputFields object.`);return;}const inputField=baseProps.inputFields[inputControlName];const display=inputField.display;const label=inputField.label;const placeholder=label;if(display===true||display===undefined){newInputs.push({...input,label,placeholder});}});setInputs(newInputs);}},[baseProps.inputFields]);const onSubmit=async formData=>{const{data:_,error}=await auth.activateLicenseKey({license_key:formData.license_key});if(error){return{ok:false,message:error.message};}// const event = new Event('framerAuthRefetchUser');\n// window.dispatchEvent(event);\nreturn{ok:true,message:\"License key validated.\"};};return /*#__PURE__*/_jsx(BaseForm,{...baseProps,button:buttonProps,inputs:inputs,onSubmit:onSubmit,defaultValues:{license_key:licenseKey}});},[]);const isBrowser=()=>{return typeof window!==\"undefined\";};const getParamValue=paramName=>{if(!isBrowser()){return null;}const urlParams=new URLSearchParams(window.location.search);if(urlParams.has(paramName)){return urlParams.get(paramName);}const hashParams=new URLSearchParams(window.location.hash.substring(1))// Remove the '#' part\n;if(hashParams.has(paramName)){return hashParams.get(paramName);}return null;};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.label}`,type:ControlType.Object,controls:{display:input.extra===true?{title:\"Display\",type:ControlType.Boolean,defaultValue:true}:undefined,label:{title:\"Label\",type:ControlType.String,defaultValue:input.label}}};});const exportBasePropertyControls={...basePropertyControls,inputFields:{title:\"Inputs\",type:ControlType.Object,controls:inputsPropertyControls},link:{title:\"Redirect\",type:ControlType.Link},input:{...basePropertyControls.input,controls:{...basePropertyControls.input.controls,iconColor:exposeIconColor?{// Add icon color property so users can control input icons (eg hide/show password icon).\ntitle:\"Icons\",type:ControlType.Color,defaultValue:\"#000\"}:undefined}},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(ActivateLicenseForm,exportBasePropertyControls);ActivateLicenseForm.defaultProps={...BaseForm.defaultProps,...ActivateLicenseForm.defaultProps};export default ActivateLicenseForm;\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ActivateLicenseForm\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerSupportedLayoutHeight\":\"any\",\"framerIntrinsicHeight\":\"40\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ActivateLicenseForm.map"],"mappings":"+TAA2C,IAA8C,IAC7B,IAC4B,IAAwI,CAI1N,EAAW,CAAC,CAAC,MAAM,cAAc,KAAK,cAAc,KAAK,OAAO,SAAS,GAAK,MAAM,GAAM,YAAY,cAAc,CAAC,CAAO,EAAO,mBAClI,EAAmB,WAEnB,EAAe,GAAG,EAAO,eAYvB,EAAoB,EAAQ,SAA6B,CAAC,GAAG,GAAW,CAAC,GAAK,CAAC,EAAO,GAAWC,EAAS,EAAW,CACxH,CAAC,EAAW,GAAeA,EAAS,KAAK,CAAO,EAAYC,OAE5D,CAAC,GAAG,EAAU,OAAO,MAAM,EAAU,OAAO,GAAgB,EAAG,CAAC,EAAU,OAAO,EAAU,OAAO,GAAgB,CAAC,CAAC,MAAc,CAAsD,EAA7B,EAAc,cAAc,CAAiC,EAAG,EAAE,CAAC,CAAC,MAAc,CACnP,GAAG,EAAU,YAAY,CAAC,IAAM,EAAU,EAAE,CAAC,EAAW,SAAS,EAAM,IAAO,CAAC,IAAM,EAAiB,E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