1import{j as e}from"./vendor-ui-H1D6CPX1.js";import{i as Q,r as i,L as b}from"./vendor-react-C_2DhnoR.js";import{v as X}from"./venue-aerial-day-c1M6MAuQ.js";import{B as _,b as ee,f as R,a as r,C as w,R as F}from"./format-wjyquUe2.js";import{D as I,c as C,s as M}from"./index-DiWNeDq-.js";import{d as te,g as ae,f as se,S as ne,a as le,b as ie}from"./bleTournaments-DM4fQ2w9.js";import"./vendor-utils-BYW5fuj6.js";const re={teamName:"",club:"",coachName:"",email:"",phone:"",homeCity:""};function oe(l){const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return{teamName:l.teamName.trim()?void 0:"Team name is required.",coachName:l.coachName.trim()?void 0:"Coach name is required.",email:t.test(l.email.trim())?void 0:"Enter a valid email.",phone:l.phone.trim().length>=7?void 0:"Enter a phone number."}}function be(){const{slug:l=""}=Q(),[t,c]=i.useState(null),[v,d]=i.useState(!0),[m,y]=i.useState("deposit"),[s,o]=i.useState(re),[g,p]=i.useState({}),[f,G]=i.useState(!1),[S,j]=i.useState(!1),[B,N]=i.useState(null),[W,z]=i.useState(!1),[E,H]=i.useState(!1),[q,J]=i.useState(!1),x=i.useMemo(()=>oe(s),[s]),U=Object.values(x).some(Boolean);if(i.useEffect(()=>{let a=!0;return d(!0),te(l).then(n=>{a&&c(n)}).catch(n=>console.error("[youth-2027] failed to load tournament",n)).finally(()=>{a&&d(!1)}),()=>{a=!1}},[l]),v)return e.jsx("div",{className:"ble-scope min-h-screen bg-bg text-ink",children:e.jsx("main",{className:"ble-container flex min-h-[70vh] items-center justify-center py-16",children:e.jsx("p",{className:"text-body-copy text-ink-secondary",children:"Loading tournamentâ¦"})})});if(!t)return e.jsxs("div",{className:"ble-scope min-h-screen bg-bg text-ink",children:[e.jsx(I,{title:"Reserve a spot | Gameday Baseball",noindex:!0}),e.jsx("main",{className:"ble-container flex min-h-[70vh] items-center justify-center py-16 text-center",children:e.jsxs("div",{className:"max-w-lg",children:[e.jsx("h1",{className:"text-section-heading text-ink",children:"Tournament not found."}),e.jsx("p",{className:"mt-4 text-body-copy text-ink-secondary",children:"This tournament is not part of the 2027 BLE schedule."}),e.jsx("div",{className:"mt-8",children:e.jsx(_,{asChild:!0,children:e.jsx(b,{to:"/youth-2027",children:"See tournaments"})})})]})})]});const T=ae(t.capacity,t.spots_taken),D=T==="full",P=t.deposit_cents??t.price_cents,k=m==="deposit"?P:t.price_cents,V=Math.max(t.price_cents-k,0),Z=Math.max(t.capacity-t.spots_taken,0),$=se(t.early_bird_deadline),K=async a=>{if(a.preventDefault(),p({teamName:!0,coachName:!0,email:!0,phone:!0}),U||!f){N(f?"Please complete the highlighted fields to continue.":"Please agree to the tournament terms to continue.");return}j(!0),N(null);try{if(D||E){const{data:O,error:A}=await M.functions.invoke("ble-join-waitlist",{body:{slug:t.slug,teamName:s.teamName,club:s.club,coachName:s.coachName,email:s.email,phone:s.phone,homeCity:s.homeCity}});if(A)throw new Error(A.message);if(O?.error)throw new Error(O.error);J(!0),j(!1);return}const{data:n,error:L}=await M.functions.invoke("ble-start-reservation",{body:{slug:t.slug,teamName:s.teamName,club:s.club,coachName:s.coachName,email:s.email,phone:s.phone,homeCity:s.homeCity,termsAccepted:f,payMode:m,returnOrigin:window.location.origin}});if(L)throw new Error(L.message);if(n?.error){n.full&&H(!0),N(n.error),j(!1);return}z(!0),window.location.assign(n.url)}catch(n){N(n instanceof Error?n.message:"Something went wrong."),j(!1)}};return e.jsxs("div",{className:"ble-scope min-h-screen bg-bg text-ink",children:[e.jsx(I,{title:`Reserve ${t.name} ${t.division} | Gameday Baseball`,description:`Hold your team's spot in ${t.name}, ${t.division}.`,noindex:!0}),e.jsx(ee,{}),e.jsxs("main",{className:"ble-container section-space grid gap-12 lg:grid-cols-[minmax(0,1fr)_340px] lg:items-start",children:[e.jsxs("section",{className:"min-w-0",children:[e.jsxs("nav",{"aria-label":"Breadcrumb",className:"text-label-copy font-semibold text-ink-secondary",children:[e.jsx(b,{to:"/youth-2027#tournaments",className:"text-ble-navy hover:underline focus-visible:underline",children:"2027 Tournaments"}),e.jsx("span",{"aria-hidden":"true",children:" / "}),e.jsx(b,{to:`/youth-2027/t/${t.slug}`,className:"text-ink hover:underline focus-visible:underline",children:t.name})]}),e.jsxs("div",{className:"mt-10 overflow-hidden rounded-sm border border-hairline bg-bg-alt",children:[e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:X,alt:"Aerial view of the baseball fields at Double Angel",width:1296,height:720,loading:"lazy",className:"aspect-video w-full object-cover"}),e.jsxs("div",{className:"absolute inset-x-0 bottom-0 bg-ble-navy/95 px-4 py-4 text-center md:px-8 md:py-5",children:[e.jsx("h1",{className:"font-expanded text-hero uppercase leading-none text-ble-chalk",children:t.name}),e.jsx("div",{className:"mx-auto mt-2 h-[3px] w-40 bg-ble-amber md:w-56"}),e.jsxs("p",{className:"mt-2 text-label-copy font-semibold uppercase tracking-wide text-ble-chalk",children:[R(t.start_date,t.end_date,!0),t.one_day?" · One
1-day event":""," · ",t.division]}),e.jsxs("p",{className:"mt-1 text-label-copy font-semibold uppercase tracking-wide text-ble-chalk/85",children:["12 teams · ",t.venue]})]})]}),e.jsx("div",{className:"p-6 md:p-8",children:Z===t.capacity?e.jsxs("p",{className:"text-label-copy font-semibold text-ink-secondary",children:["All ",t.capacity," spots open"]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{capacity:t.capacity,spotsTaken:t.spots_taken,showLabel:!1}),e.jsx("p",{className:C("mt-3 text-label-copy font-semibold",le[T]),children:ie(t.capacity,t.spots_taken)})]})})]}),q?e.jsxs("div",{className:"mt-10 rounded-sm border border-hairline bg-bg-alt p-6 md:p-8",children:[e.jsx("h2",{className:"text-card-title text-ink",children:"Your team is on the waitlist."}),e.jsxs("p",{className:"mt-3 text-body-copy text-ink-secondary",children:["We will email ",s.email," if a spot opens in this tournament."]})]}):W?e.jsxs("div",{className:"mt-10 rounded-sm border border-hairline bg-bg-alt p-6 md:p-8",children:[e.jsx("h2",{className:"text-card-title text-ink",children:"Taking you to secure checkoutâ¦"}),e.jsx("p",{className:"mt-3 text-body-copy text-ink-secondary",children:"Your spot is held for 30 minutes while you pay. Do not close this window."})]}):e.jsxs("form",{className:"mt-10 grid gap-5",noValidate:!0,onSubmit:K,children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsx(u,{label:"Team name",value:s.teamName,error:g.teamName?x.teamName:void 0,onBlur:()=>p(a=>({...a,teamName:!0})),onChange:a=>o(n=>({...n,teamName:a}))}),e.jsx(u,{label:"Club or organization",value:s.club,onBlur:()=>{},onChange:a=>o(n=>({...n,club:a}))}),e.jsx(u,{label:"Coach name",value:s.coachName,error:g.coachName?x.coachName:void 0,onBlur:()=>p(a=>({...a,coachName:!0})),onChange:a=>o(n=>({...n,coachName:a}))}),e.jsx(u,{label:"Address",placeholder:"Street, city, state, ZIP",value:s.homeCity,onBlur:()=>{},onChange:a=>o(n=>({...n,homeCity:a}))}),e.jsx(u,{label:"Email",type:"email",value:s.email,error:g.email?x.email:void 0,onBlur:()=>p(a=>({...a,email:!0})),onChange:a=>o(n=>({...n,email:a}))}),e.jsx(u,{label:"Phone",type:"tel",value:s.phone,error:g.phone?x.phone:void 0,onBlur:()=>p(a=>({...a,phone:!0})),onChange:a=>o(n=>({...n,phone:a}))})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-label-copy font-semibold text-ink-secondary",children:"Division"}),e.jsx("input",{value:t.division,readOnly:!0,className:"min-h-11 rounded-sm border border-hairline bg-bg-alt px-4 text-body-copy text-ink outline-none"})]}),D?e.jsx("p",{className:"text-body-copy text-ink-secondary",children:"This tournament is full. Join the waitlist and we will contact you if a spot opens."}):e.jsxs("div",{children:[e.jsx("p",{className:"text-label-copy font-semibold text-ink-secondary",children:"Payment"}),e.jsxs("div",{className:"mt-2 grid rounded-sm border border-hairline bg-bg-alt p-1 sm:grid-cols-2",children:[e.jsx(Y,{selected:m==="deposit",onClick:()=>y("deposit"),label:`Pay ${r(P)} deposit`}),e.jsx(Y,{selected:m==="full",onClick:()=>y("full"),label:`Pay in full (${r(t.price_cents)})`})]}),e.jsxs("p",{className:"mt-3 text-label-copy text-ink-secondary",children:["Your spot is held for 30 minutes while you complete payment. Balance due"," ",w.balanceDueDate,"."]}),t.early_bird_active?e.jsxs("div",{className:"mt-3 border border-ble-amber/60 bg-ble-amber/10 p-4",children:[e.jsx("p",{className:"font-expanded text-lg leading-none tracking-wide text-ble-clay",children:"Early bird pricing"}),e.jsxs("p",{className:"mt-1 text-label-copy text-ink-secondary",children:["Locked in today â you save"," ",r(t.regular_price_cents-t.price_cents),".",$?` Good through ${$}.`:""]})]}):null]}),e.jsxs("label",{className:"grid grid-cols-[auto_minmax(0,1fr)] items-start gap-3 py-2",children:[e.jsx("input",{type:"checkbox",checked:f,onChange:a=>G(a.target.checked),className:"mt-1 h-4 w-4 rounded border-hairline"}),e.jsxs("span",{className:"text-label-copy text-ink-secondary",children:["I have read and accept the tournament terms and"," ",e.jsx(b,{to:`/youth-2027#${F}`,className:"font-semibold text-ble-navy underline underline-offset-2",children:"refund policy"}),"."]})]}),B?e.jsx("p",{className:"text-label-copy font-semibold text-status-nearly-full",children:B}):null,e.jsx(_,{type:"submit",disabled:S,className:"w-full sm:w-auto",children:S?"Holding your spotâ¦":E?"Join the waitlist":`Continue to payment · ${r(k)}`})]})]}),e.jsxs("aside",{className:"rounded-sm border border-hairline bg-bg p-6 lg:sticky lg:top-28 lg:p-8",children:[e.jsx("h2",{className:"text-card-title text-ink",children:"Order summary"}),e.jsxs("div",{className:"mt-6 divide-y divide-hairline border-y border-hairline",children:[e.jsx(h,{label:"Tournament",value:t.name}),e.jsx(h,{label:"Division",value:t.division}),e.jsx(h,{label:"Dates",value:R(t.start_date,t.end_date,!0)}),e.jsx(h,{label:"Entry",value:t.early_bird_active?`${r(t.price_cents)} (was ${r(t.regular_price_cents)})`:r(t.price_cents)}),e.jsx(h,{label:"Due today",value:r(k),emphasis:!0}),e.jsx(h,{label:"Balance later",value:r(V)})]}),e.jsxs("p",{className:"mt-6 text-label-copy text-ink-secondary",children:["Balance due 30 days before the tournament."," ",e.jsx(b,{to:`/youth-2027#${F}`,className:"font-semibold text-ble-navy underline underline-offset-2",children:"See refund policy"}),"."]}),e.jsxs("p",{className:"mt-3 text-label-copy text-ink-secondary",children:[w.gameGuarantee," · ",w.umpireFeesIncluded,"."]})]})]})]})}function u({label:l,value:t,onChange:c,onBlur:v,error:d,type:m="text",placeholder:y}){const s=l.toLowerCase().replace(/ /g,"-");return e.jsxs("label",{className:"grid gap-2",htmlFor:s,children:[e.jsx("span",{className:"text-label-copy font-semibold text-ink-secondary",children:l}),e.jsx("input",{id:s,type:m,value:t,placeholder:y,onChange:o=>c(o.target.value),onBlur:v,"aria-invalid":!!d,className:"min-h-11 rounded-sm border border-hairline bg-bg px-4 text-body-copy text-ink outline-none transition-colors focus:border-ble-navy"}),d?e.jsx("span",{className:"text-label-copy font-semibold text-status-nearly-full",children:d}):null]})}function Y({selected:l,onClick:t,label:c}){return e.jsx(_,{type:"button",variant:"segmented",size:"segmented","aria-pressed":l,className:C("min-h-11",l?"bg-bg text-ink":"text-ink-secondary hover:text-ink"),onClick:t,children:c})}function h({label:l,value:t,emphasis:c=!1}){return e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-4 py-4",children:[e.jsx("span",{className:"min-w-0 text-label-copy font-semibold text-ink-secondary",children:l}),e.jsx("span",{className:C("max-w-44 truncate text-right text-body-copy",c?"font-semibold text-ink":"text-ink"),children:t})]})}
1export{be as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.