import{a as e,o as t,r as n,t as r}from"./i18n-CjHYiQIU.js";import{V as i,j as a}from"./index-D2kkGKae.js";import"./TurnstileWidget-CrEz8tBB.js";var o=t(),s=e();function c({context:e,onClose:t}){let{bugReportModal:c}=r().strings,[l,u]=(0,o.useState)(`gameplay`),[d,f]=(0,o.useState)(``),[p,m]=(0,o.useState)(``),[h,g]=(0,o.useState)(``),[_,v]=(0,o.useState)(``),[y,b]=(0,o.useState)(``),[x,S]=(0,o.useState)(``),[C,w]=(0,o.useState)(``);(0,o.useCallback)(e=>S(e),[]),(0,o.useCallback)(e=>w(e),[]);let T=e=>{let t=e instanceof Error?e.message:``;return t===`rate-limited`?c.reportRateLimited:t===`invalid-report`||t===`report-too-large`?c.reportRejected:t===`backend-disabled`||t===`database-unavailable`?c.reportUnavailable:c.reportFailed},E=async t=>{t.preventDefault(),w(c.reportSending);try{let t=await a({category:l,summary:d,description:p,reproductionSteps:h,expectedBehavior:_,contactEmail:y,turnstileToken:x,context:e});w(n(c.reportStored,{id:t.reportId}))}catch(e){w(T(e))}};return(0,s.jsx)(i,{title:c.title,onClose:t,children:(0,s.jsxs)(`form`,{className:`bug-report-form`,onSubmit:e=>void E(e),children:[(0,s.jsx)(`p`,{children:c.intro}),(0,s.jsxs)(`label`,{children:[c.area,(0,s.jsxs)(`select`,{value:l,onChange:e=>u(e.target.value),children:[(0,s.jsx)(`option`,{value:`gameplay`,children:c.gameplay}),(0,s.jsx)(`option`,{value:`riddle`,children:c.riddleOrHint}),(0,s.jsx)(`option`,{value:`display`,children:c.displayOrControls}),(0,s.jsx)(`option`,{value:`audio`,children:c.musicOrAudio}),(0,s.jsx)(`option`,{value:`progress`,children:c.progressOrStorage}),(0,s.jsx)(`option`,{value:`leaderboard`,children:c.leaderboard}),(0,s.jsx)(`option`,{value:`other`,children:c.other})]})]}),(0,s.jsxs)(`label`,{children:[c.shortSummary,(0,s.jsx)(`input`,{required:!0,minLength:5,maxLength:120,value:d,onChange:e=>f(e.target.value)})]}),(0,s.jsxs)(`label`,{children:[c.problemDescription,(0,s.jsx)(`textarea`,{required:!0,minLength:10,maxLength:3e3,rows:5,value:p,onChange:e=>m(e.target.value)})]}),(0,s.jsxs)(`label`,{children:[c.reproductionSteps,(0,s.jsx)(`textarea`,{rows:3,value:h,onChange:e=>g(e.target.value)})]}),(0,s.jsxs)(`label`,{children:[c.expectedBehaviour,(0,s.jsx)(`textarea`,{rows:3,value:_,onChange:e=>v(e.target.value)})]}),(0,s.jsxs)(`label`,{children:[c.contactEmail,(0,s.jsx)(`input`,{type:`email`,value:y,onChange:e=>b(e.target.value)})]}),``,(0,s.jsx)(`p`,{className:`legal-note`,children:c.privacyNote}),(0,s.jsx)(`button`,{className:`primary`,type:`submit`,children:c.sendReport}),C&&(0,s.jsx)(`p`,{role:`status`,children:C})]})})}export{c as BugReportModal};