{"version":3,"file":"EmailForm.PV83WiD6.mjs","names":["_Fragment"],"sources":["https:/framerusercontent.com/modules/EoOhFa7ssLXW8f40DiWo/FiW4tdibvHgWAZXZLA6g/EmailForm.js"],"sourcesContent":["// Welcome to Code in Framer\n// Get Started: https://www.framer.com/developers/\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useCallback,useState,useRef}from\"react\";import{useFontControls,fontControls}from\"https://framer.com/m/framer/default-utils.js@^0.45.0\";/**\n * These annotations control how your component sizes\n * Learn more: https://www.framer.com/developers/#code-components-auto-sizing\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function EmailForm(props){// This is a React component containing an Example component\n// - Replace <Example /> with your own code\n// - Find inspiration: https://www.framer.com/developers/\nconst promocode=window&&new URLSearchParams(window.location.search).get(\"promocode\")||\"\";const assetId=window&&new URLSearchParams(window.location.search).get(\"assetId\");const[state,setState]=useState({email:\"\",timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone,promocode});const ref=useRef();const[isLoading,setIsLoading]=useState(false);const[error,setError]=useState(null);const[isShowPromocode,setIsShowPromocode]=useState(Boolean(promocode));const handleShowPromocode=useCallback(e=>{e.preventDefault();setIsShowPromocode(true);},[]);const handleSubmit=useCallback(async e=>{e.preventDefault();const emailInput=ref.current;if(!emailInput||!emailInput.value||!emailInput.checkValidity()){setError(\"Невірний email\");return;}setIsLoading(true);setError(null);try{var _data_data_,_data_data;const response=await fetch(assetId?`https://api.uasystem.design/assets/${assetId}`:props.url,{method:\"POST\",headers:{\"Content-Type\":\"application/json\"},body:JSON.stringify(Object.fromEntries(Object.entries(state).filter(([key,value])=>value)))});if(response.ok){const{redirectUrl}=await response.json();if(!redirectUrl){return;}window.location=redirectUrl;return;}const data=await response.json();const message=data.data?((_data_data=data.data)===null||_data_data===void 0?void 0:(_data_data_=_data_data[0])===null||_data_data_===void 0?void 0:_data_data_.instancePath)===\"/email\"?\"Невірний email\":\"Сталася помилка. Спробуйте пізніше\":data.message;setError(message);}finally{setIsLoading(false);}},[state]);const handleChange=useCallback(e=>{setState(prevState=>({...prevState,[e.target.name]:e.target.value}));},[]);const errorFontStyles=useFontControls(props.error);const inputFontStyles=useFontControls(props.input);const buttonFontStyles=useFontControls(props.button);return /*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsxs(\"form\",{onSubmit:handleSubmit,style:{display:\"flex\",gap:props.gap,flexDirection:\"column\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:props.layout===\"horizontal\"?\"row\":\"column\",gap:props.gap},children:[/*#__PURE__*/_jsx(\"input\",{autoFocus:true,type:\"email\",name:\"email\",placeholder:props.input.placeholder,onChange:handleChange,style:{border:0,flex:1,...props.input,...inputFontStyles},ref:ref}),props.input.showPromocode&&/*#__PURE__*/_jsxs(_Fragment,{children:[!isShowPromocode&&/*#__PURE__*/_jsx(\"a\",{href:\"#\",onClick:handleShowPromocode,style:{color:props.input.color,fontSize:props.input.fontSize},children:props.input.promocodeLinkText}),isShowPromocode&&/*#__PURE__*/_jsx(\"input\",{type:\"text\",name:\"promocode\",placeholder:props.input.promocodePlaceholder,onChange:handleChange,style:{border:0,flex:1,...props.input,...inputFontStyles},value:state.promocode})]}),/*#__PURE__*/_jsx(\"style\",{children:` \n                    input:focus {\n                        outline: none;\n                    }\n                    ::placeholder { \n                        color: ${props.input.placeholderColor}; \n                    }`}),/*#__PURE__*/_jsx(\"button\",{disabled:isLoading,type:\"submit\",style:{cursor:\"pointer\",border:1,...props.button,...buttonFontStyles,borderRadius:props.input.borderRadius,boxShadow:props.button.shadow?`${props.button.shadow.shadowX}px ${props.button.shadow.shadowY}px ${props.button.shadow.shadowBlur}px ${props.button.shadow.shadowColor}`:null},children:isLoading?\"Обробка...\":props.button.label})]}),error&&/*#__PURE__*/_jsx(\"div\",{style:{...props.error,...errorFontStyles},children:error})]})});}const basePropertyControls={url:{title:\"URL\",type:ControlType.String,defaultValue:\"\"},layout:{title:\"Layout\",type:ControlType.Enum,displaySegmentedControl:true,options:[\"horizontal\",\"vertical\"]},button:{type:ControlType.Object,controls:{label:{title:\"Label\",type:ControlType.String,defaultValue:\"Button\"},backgroundColor:{title:\"Fill\",type:ControlType.Color,defaultValue:\"#333\"},borderRadius:{title:\"Radius\",type:ControlType.Number,defaultValue:16},color:{title:\"Text\",type:ControlType.Color,defaultValue:\"#fff\"},...fontControls,fontSize:{title:\"Font Size\",type:ControlType.Number,displayStepper:true,defaultValue:16},padding:{title:\"Padding\",type:ControlType.FusedNumber,toggleKey:\"paddingPerSide\",toggleTitles:[\"Padding\",\"Padding per side\"],defaultValue:16,valueKeys:[\"paddingTop\",\"paddingRight\",\"paddingBottom\",\"paddingLeft\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0},shadowObject:{type:ControlType.Object,title:\"Shadow\",optional:true,controls:{shadowColor:{title:\"Color\",type:ControlType.Color,defaultValue:\"rgba(0,0,0,0.25)\"},shadowX:{title:\"Shadow X\",type:ControlType.Number,min:-100,max:100,defaultValue:0},shadowY:{title:\"Shadow Y\",type:ControlType.Number,min:-100,max:100,defaultValue:2},shadowBlur:{title:\"Shadow B\",type:ControlType.Number,min:0,max:100,defaultValue:4}}}}},input:{type:ControlType.Object,controls:{placeholder:{title:\"Placeholder\",type:ControlType.String,defaultValue:\"Email\"},showPromocode:{title:\"Show promocode\",type:ControlType.Boolean,defaultValue:false},promocodePlaceholder:{title:\"Promocode placeholder\",type:ControlType.String,defaultValue:\"Promocode\"},promocodeLinkText:{title:\"Promocode link text\",type:ControlType.String,defaultValue:\"Have promocode\"},placeholderColor:{title:\" \",type:ControlType.Color,defaultValue:\"#0000004D\"},backgroundColor:{title:\"Fill\",type:ControlType.Color,defaultValue:\"#EBEBEB\"},color:{title:\"Text\",type:ControlType.Color,defaultValue:\"#000\"},...fontControls,fontSize:{title:\"Font Size\",type:ControlType.Number,displayStepper:true,defaultValue:16},padding:{title:\"Padding\",type:ControlType.FusedNumber,toggleKey:\"paddingPerSide\",toggleTitles:[\"Padding\",\"Padding per side\"],defaultValue:16,valueKeys:[\"paddingTop\",\"paddingRight\",\"paddingBottom\",\"paddingLeft\"],valueLabels:[\"T\",\"R\",\"B\",\"L\"],min:0},borderRadius:{title:\"Radius\",type:ControlType.Number,defaultValue:16}}},error:{type:ControlType.Object,controls:{color:{type:ControlType.Color,defaultValue:\"#EE4444\"},...fontControls,fontSize:{title:\"Font Size\",type:ControlType.Number,displayStepper:true,defaultValue:16}}},gap:{title:\"Gap\",type:ControlType.Number,defaultValue:16}};addPropertyControls(EmailForm,basePropertyControls);\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"EmailForm\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./EmailForm.map"],"mappings":"mcAQG,SAAwB,EAAU,EAAM,CAG3C,IAAM,EAAU,GAAQ,IAAI,gBAAgB,EAAO,SAAS,QAAQ,IAAI,YAAY,EAAE,GAAS,EAAQ,GAAQ,IAAI,gBAAgB,EAAO,SAAS,QAAQ,IAAI,UAAU,CAAM,CAAC,EAAM,EAAS,CAAC,EAAS,CAAC,MAAM,GAAG,SAAS,KAAK,gBAAgB,CAAC,iBAAiB,CAAC,SAAS,WAAU,EAAC,CAAO,EAAI,GAAQ,CAAM,CAAC,EAAU,EAAa,CAAC,GAAS,EAAM,CAAM,CAAC,EAAM,EAAS,CAAC,EAAS,KAAK,CAAM,CAAC,EAAgB,EAAmB,CAAC,IAAiB,EAAW,CAAO,EAAoB,EAAY,GAAG,CAAoB,AAAnB,EAAE,gBAAgB,CAAC,GAAmB,EAAK,AAAE,EAAC,CAAE,EAAC,CAAO,EAAa,EAAY,MAAM,GAAG,CA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