function DirtHouseTour(){
 const id=new URLSearchParams(location.search).get('tour'),[data,setData]=React.useState(null),[error,setError]=React.useState(''),[busy,setBusy]=React.useState(false);
 async function refresh(){setBusy(true);setError('');try{setData(await operatorTourRequest('public_tour',{service_id:id}));}catch(e){setError(e.message);}finally{setBusy(false);}}
 React.useEffect(()=>{refresh();},[id]);const requestedDeparture=new URLSearchParams(location.search).get('departure');const t=data?.tour,o=data?.operator,money=n=>new Intl.NumberFormat('en-GB',{style:'currency',currency:'GBP'}).format(n/100);
 return <><div className="demo-strip">Private Dirt House listing preview · fictional operator · test payments only</div><header className="dh-nav"><a href={'dirt-house-tour.html?tour='+encodeURIComponent(id||'')}>DIRT HOUSE</a><span>Discover the ride.<br/>Book with the people who know it.</span></header><main className="dh-listing">{error&&<p role="alert">{error}</p>}{!data?<p role="status">{busy?'Loading the tour…':'Tour unavailable.'}</p>:<><p className="dh-badge">Guided motorcycle tours / {t.days} days</p><h1>{t.name}</h1><p>With {o.display_name}</p><div className="dh-columns"><section><img className="dh-photo" src="assets/img/northline-byway.jpg" alt="Motorcycle riders exploring a woodland trail; illustrative demo photograph"/><h2>A local operator. A shared adventure.</h2><p>{t.description}</p><h2>Your three-day escape</h2><ol>{t.itinerary.map((x,i)=><li key={i}><p><strong>Day {i+1}</strong><br/>{x}</p></li>)}</ol><h3>Before you go</h3><p>{t.inclusions}</p><p><strong>Meeting point:</strong> {t.meeting_point}</p><p>{t.cancellation_policy}</p></section><aside className="dh-card"><p className="dh-badge">Book with {o.display_name}</p><h2>{money(t.price_cents)} per guest</h2><p>{t.deposit_bps/100}% deposit · balance {t.balance_due_days} days before departure.</p><p>Choose a departure, then continue to the operator’s branded booking page. Your places and payment are managed by Bookuno.</p>{data.sessions.filter(s=>!requestedDeparture||s.id===requestedDeparture).map(s=><div className="dh-departure" key={s.id}><strong>{operatorDateRange(s)}</strong><p>{s.available} of {s.capacity} places available</p>{data.payments_ready&&s.available>0?<a className="north-button" href={t.website_url+'&source=dirt_house&departure='+s.id}>Choose this tour</a>:<p>{s.available===0?'This departure is full.':'Test payments are not ready yet.'}</p>}</div>)}{!(requestedDeparture?data.sessions.filter(s=>s.id===requestedDeparture):data.sessions).length&&<p>{requestedDeparture?'This departure is closed or unavailable. Check the other tour dates.':'New departures are being prepared.'}</p>}<button className="north-button secondary" disabled={busy} onClick={refresh}>{busy?'Checking…':'Refresh available places'}</button><p className="north-small">Private preview only. This listing is not published on the live Dirt House website. No emails or real payments.</p></aside></div></>}</main></>;
}
ReactDOM.createRoot(document.getElementById('root')).render(<DirtHouseTour/>);
