(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,38036,e=>{"use strict";var t=e.i(54858);let r="auth_token";function n(){return localStorage.getItem(r)}function s(e){localStorage.setItem(r,e)}function o(){localStorage.removeItem(r)}function a(){return null!==n()}async function i(e){let r=await (0,t.apiRequest)("/auth/login",{method:"POST",body:JSON.stringify(e)});return s(r.token),r}function l(){o()}e.s(["getToken",()=>n,"isAuthenticated",()=>a,"login",()=>i,"logout",()=>l,"removeToken",()=>o,"setToken",()=>s])},54858,e=>{"use strict";let t="http://localhost:3000";async function r(e,n={}){let s=`${t}${e}`,o=await fetch(s,{...n,headers:{"Content-Type":"application/json",...n.headers}}),a=await o.json();if(!o.ok)throw Error(a.error||"Request failed");return a}async function n(r,s={},o){let{getToken:a,removeToken:i}=await e.A(48323),l=a();if(!l)throw o&&o(),Error("Authentication required");let u=`${t}${r}`,c=await fetch(u,{...s,headers:{"Content-Type":"application/json",Authorization:`Bearer ${l}`,...s.headers}}),d=await c.json();if(401===c.status)throw i(),o&&o(),Error(d.error||"Authentication failed");if(!c.ok)throw Error(d.error||"Request failed");return d}e.s(["apiRequest",()=>r,"authenticatedRequest",()=>n])},18566,(e,t,r)=>{t.exports=e.r(76562)},8240,e=>{"use strict";var t=e.i(43476),r=e.i(71645),n=e.i(18566),s=e.i(38036),o=e.i(54858);function a(){let e=(0,n.useRouter)(),[a,i]=(0,r.useState)(!1),[l,u]=(0,r.useState)(""),[c,d]=(0,r.useState)(""),[m,h]=(0,r.useState)("celebration"),[p,b]=(0,r.useState)(""),[f,x]=(0,r.useState)(null),[g,v]=(0,r.useState)(!1);(0,r.useEffect)(()=>{i(!0),(0,s.isAuthenticated)()||e.push("/login")},[e]);let y=async t=>{t.preventDefault(),x(null),v(!0);try{let t={title:l,person_name:c,event_type:m};p.trim()&&(t.description=p.trim());let r=await (0,o.authenticatedRequest)("/events",{method:"POST",body:JSON.stringify(t)},()=>{e.push("/login")});e.push(`/events/${r.id}`)}catch(t){t instanceof Error&&"Authentication required"===t.message?e.push("/login"):x(t instanceof Error?t.message:"Failed to create event")}finally{v(!1)}};return a&&(0,s.isAuthenticated)()?(0,t.jsx)("div",{className:"min-h-screen p-8",children:(0,t.jsxs)("main",{className:"max-w-2xl mx-auto",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold mb-6",children:"Create Event"}),(0,t.jsxs)("form",{onSubmit:y,className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"title",className:"block text-sm font-medium mb-1",children:"Title *"}),(0,t.jsx)("input",{id:"title",type:"text",value:l,onChange:e=>u(e.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"person_name",className:"block text-sm font-medium mb-1",children:"Person Name *"}),(0,t.jsx)("input",{id:"person_name",type:"text",value:c,onChange:e=>d(e.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"event_type",className:"block text-sm font-medium mb-1",children:"Event Type *"}),(0,t.jsxs)("select",{id:"event_type",value:m,onChange:e=>h(e.target.value),required:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[(0,t.jsx)("option",{value:"celebration",children:"Celebration"}),(0,t.jsx)("option",{value:"remembrance",children:"Remembrance"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"description",className:"block text-sm font-medium mb-1",children:"Description (optional)"}),(0,t.jsx)("textarea",{id:"description",value:p,onChange:e=>b(e.target.value),rows:4,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),f&&(0,t.jsx)("div",{className:"text-red-600 text-sm",children:f}),(0,t.jsxs)("div",{className:"flex gap-4",children:[(0,t.jsx)("button",{type:"submit",disabled:g,className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",children:g?"Creating...":"Create Event"}),(0,t.jsx)("button",{type:"button",onClick:()=>e.push("/events"),className:"px-4 py-2 border border-gray-300 rounded-md hover:bg-gray-50",children:"Cancel"})]})]})]})}):null}e.s(["default",()=>a])},48323,e=>{e.v(e=>Promise.resolve().then(()=>e(38036)))}]);