(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,t,a)=>{t.exports=e.r(76562)},11383,e=>{"use strict";var t=e.i(43476),a=e.i(71645),r=e.i(18566);e.s(["default",0,function(){let e=(0,r.useRouter)(),[n,i]=(0,a.useState)(""),[l,s]=(0,a.useState)(null),[o,u]=(0,a.useState)(!1);async function h(t){t.preventDefault(),s(null),u(!0);try{let t=await fetch("/api/trahs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n})});if(401===t.status)return void e.push("/login");let a=await t.json().catch(()=>null);if(t.ok&&a?.trahId)return void e.push(`/trahs/${a.trahId}`);s("Please enter a name for your Trah.")}catch{s("Something went wrong. Please try again.")}finally{u(!1)}}return(0,t.jsxs)("main",{style:{maxWidth:420,margin:"0 auto",padding:"2rem 1rem"},children:[(0,t.jsx)("h1",{children:"Create a Trah"}),(0,t.jsxs)("form",{onSubmit:h,children:[(0,t.jsxs)("div",{style:{marginBottom:"1rem"},children:[(0,t.jsx)("label",{htmlFor:"name",children:"Trah name"}),(0,t.jsx)("input",{id:"name",name:"name",type:"text",required:!0,value:n,onChange:e=>i(e.target.value),style:{display:"block",width:"100%"}})]}),l&&(0,t.jsx)("p",{role:"alert",style:{color:"crimson"},children:l}),(0,t.jsx)("button",{type:"submit",disabled:o,children:o?"Creating…":"Create Trah"})]})]})}])}]);