import{_t as e,lt as t,n as r,t as o,yt as s}from"./render-cqdoDfd9.js";import"./modulepreload-polyfill-DgzdhEGd.js";import{t as n}from"./Box-pvlRBLzs.js";import{t as i}from"./Container-DQi3l0z9.js";import{t as a}from"./Typography-8v555lWC.js";import{t as m}from"./Button-D-nJohaT.js";import{t as l}from"./Alert-BpUkH7Nx.js";import{t as c}from"./TextField-CbQ6hH_9.js";import{t as d}from"./WorkspacePremium-BuOxKl4p.js";var x=s(e(),1),p=t();o({children:(0,p.jsx)(()=>{const[e,t]=(0,x.useState)(""),[o,s]=(0,x.useState)(""),[f,u]=(0,x.useState)(!1),{localeMessages:h,apiEndpoint:j,token:y,csrfToken:b}=r(),[g,v]=(0,x.useState)("");return(0,p.jsx)(n,{sx:{minHeight:"100vh",display:"flex",alignItems:"flex-start",justifyContent:"center",pt:"22vh",px:2,bgcolor:"background.main"},children:(0,p.jsxs)(i,{maxWidth:"sm",sx:{mt:0,py:4,px:{xs:3,sm:4},border:"1px solid",borderColor:"divider",borderRadius:3,boxShadow:2,bgcolor:"background.paper"},children:[(0,p.jsxs)(n,{display:"flex",alignItems:"center",my:4,justifyContent:"center",children:[(0,p.jsx)(d,{color:"secondary",sx:{fontSize:50,mr:1}}),(0,p.jsx)(a,{variant:"h4",component:"h1",children:h.form_title})]}),(0,p.jsx)(a,{variant:"body1",gutterBottom:!0,children:h.form_intro}),f?(0,p.jsx)(l,{severity:"success",sx:{mt:2},children:h.form_submission_success}):(0,p.jsxs)(n,{component:"form",method:"POST",action:"",sx:{mt:2},onSubmit:t=>{t.preventDefault(),e.trim()?(s(""),fetch(`${j}?token=${y}`,{method:"POST",headers:{"Content-Type":"application/json","X-CSRFToken":b},body:JSON.stringify({token:y,name:e})}).then(e=>{if(!e.ok)throw new Error(h.error_sending_data);return e.json()}).then(e=>{v(e.certificate_url)}).then(()=>{u(!0)}).catch(e=>{s(e.message)})):s(h.full_name_required)},children:[(0,p.jsx)(c,{fullWidth:!0,label:h.full_name,name:"full_name",required:!0,margin:"normal",value:e,onChange:e=>t(e.target.value)}),o&&(0,p.jsx)(l,{severity:"error",children:o}),(0,p.jsx)(m,{type:"submit",variant:"contained",color:"secondary",sx:{mt:3,mx:"auto",display:"block",px:4,fontSize:"1.1rem"},children:h.submit})]}),g&&(0,p.jsx)(n,{sx:{mt:2,mx:"auto",display:"flex",justifyContent:"center"},children:(0,p.jsx)(m,{variant:"contained",color:"secondary",href:g,target:"_blank",rel:"noopener noreferrer",sx:{px:4,fontSize:"1.1rem"},children:h.view_certificate})})]})})},{})});