1import{c as $,r as p,a as z,d as y,j as e,P as W,b as Y,C as G,s as v,ax as Q}from"./index-408BZkP3.js";import{C as k,a as _}from"./card-h0r3lFQu.js";import{B as L}from"./button-DYuV0BK3.js";import{B as b}from"./badge-DCHt8ZdX.js";import{u as V}from"./useTrainingSchedules-G4Zcdhhm.js";import{s as D,t as H,f as g,d as M}from"./da-D5-qs0yw.js";import{a as S}from"./addDays-eqLulw-b.js";import{C as J}from"./chevron-left-BTF4FHev.js";import{c as U}from"./constructNow-Cp7jIJVz.js";import{C as X}from"./chevron-right-D0A5BtGC.js";import{B as N}from"./building-2-CRV36B8m.js";import{S as Z}from"./shirt-B0tEFth2.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const B=$("Goal",[["path",{d:"M12 13V2l8 4-8 4",key:"5wlwwj"}],["path",{d:"M20.561 10.222a9 9 0 1 1-12.55-5.29",key:"1c0wjv"}],["path",{d:"M8.002 9.997a5 5 0 1 0 8.9 2.02",key:"gb1g7m"}]]);function F(n,m){const i=D(n),f=D(m);return+i==+f}function ee(n){return H(n).getDay()}function te(n){return F(n,U(n))}const ae={Mandag:1,Tirsdag:2,Onsdag:3,Torsdag:4,Fredag:5,Lørdag:6,Søndag:0},C={bane:e.jsx(B,{className:"w-3.5 h-3.5"}),hal:e.jsx(N,{className:"w-3.5 h-3.5"}),omklædningsrum:e.jsx(Z,{className:"w-3.5 h-3.5"}),mødelokale:e.jsx(N,{className:"w-3.5 h-3.5"})},j={bane:"bg-green-100 text-green-800 border-green-200",hal:"bg-blue-100 text-blue-800 border-blue-200",mødelokale:"bg-amber-100 text-amber-800 border-amber-200",omklædningsrum:"bg-purple-100 text-purple-800 border-purple-200",andet:"bg-muted text-muted-foreground border-border"};function ue(){const[n,m]=p.useState(new Date),{t:i}=z(),f=g(n,"yyyy-MM-dd"),{data:x=[]}=y({queryKey:["facilities-public"],queryFn:async()=>{const{data:t,error:a}=await v.from("facilities").select("*").eq("enabled",!0).order("sort_order");if(a)throw a;return t}}),{data:u=[]}=y({queryKey:["facility-bookings-day",f],queryFn:async()=>{const{data:t,error:a}=await v.from("facility_bookings").select("*, facilities(id, name, type, location)").eq("booking_date",f).order("start_time");if(a)throw a;return t}}),{data:T=[]}=V({activeOnly:!0}),{data:R}=y({queryKey:["all-team-info-names-public"],queryFn:async()=>{const{data:t}=await v.from("team_info").select("team_id, team_name");return t??[]}}),E=new Map((R??[]).filter(t=>t.team_name).map(t=>[t.team_id,t.team_name])),{data:w=[]}=y({queryKey:["dbu-widget-matches-day",f],queryFn:async()=>(await Q()).filter(a=>a.date===f),staleTime:5*60*1e3}),O=ee(n),q=p.useMemo(()=>T.filter(t=>ae[t.day_of_week]===O),[T,O]),P=p.useMemo(()=>{const t={};for(const a of x)t[a.id]={facility:a,items:[]};for(const a of u)t[a.facility_id]&&t[a.facility_id].items.push({type:"booking",time:a.start_time.slice(0,5),endTime:a.end_time.slice(0,5),title:a.title,subtitle:a.description||void 0,color:"primary"});for(const a of q){const s=x.find(r=>r.name===a.location||a.location.startsWith(r.name));s&&t[s.id]&&t[s.id].items.push({type:"training",time:a.start_time.slice(0,5),endTime:a.end_time.slice(0,5),title:E.get(a.team_id)||i("facilities.training"),subtitle:i("facilities.training"),color:"amber"})}for(const a of Object.keys(t))t[a].items.sort((s,r)=>s.time.localeCompare(r.time));return t},[x,u,q,E,i]),A=Array.from({length:7},(t,a)=>S(D(new Date),a-1)),I=p.useMemo(()=>{const t=[];for(const a of w){const s=a.time,r=u.filter(l=>{const d=l.start_time.slice(0,5),h=l.end_time.slice(0,5);return d<=s&&h>s}),c=r.find(l=>{var d,h;return((d=l.facilities)==null?void 0:d.type)==="bane"||((h=l.facilities)==null?void 0:h.type)==="hal"}),o=r.find(l=>{var d;return((d=l.facilities)==null?void 0:d.type)==="omklædningsrum"});t.push({match:a,pitchBooking:c,changingRoomBooking:o})}return t},[w,u]),K={bane:i("facilities.pitches"),hal:i("facilities.halls"),omklædningsrum:i("facilities.changingRooms"),mødelokale:i("facilities.meetingRooms"),andet:i("facilities.other")};return e.jsx(W,{children:e.jsxs("div",{className:"container mx-auto px-4 py-8 max-w-6xl",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-heading font-bold mb-1",children:i("facilities.title")}),e.jsx("p",{className:"text-muted-foreground",children:i("facilities.subtitle")})]}),e.jsxs("div",{className:"flex items-center gap-2 mb-6 overflow-x-auto no-scrollbar pb-2",children:[e.jsx(L,{variant:"ghost",size:"icon",className:"shrink-0",onClick:()=>m(t=>S(t,-1)),children:e.jsx(J,{className:"w-4 h-4"})}),A.map(t=>e.jsxs("button",{onClick:()=>m(t),className:`shrink-0 flex flex-col items-center px-3 py-2 rounded-lg border transition-colors ${F(t,n)?"bg-primary text-primary-foreground border-primary":te(t)?"bg-primary/10 border-primary/30 text-foreground":"bg-card border-border text-foreground hover:bg-muted"}`,children:[e.jsx("span",{className:"text-[10px] uppercase font-heading",children:g(t,"EEE",{locale:M})}),e.jsx("span",{className:"text-lg font-bold font-heading leading-tight",children:g(t,"d")}),e.jsx("span",{className:"text-[10px]",children:g(t,"MMM",{locale:M})})]},t.toISOString())),e.jsx(L,{variant:"ghost",size:"icon",className:"shrink-0",onClick:()=>m(t=>S(t,1)),children:e.jsx(X,{className:"w-4 h-4"})})]}),e.jsx("h2",{className:"font-heading text-lg font-bold mb-4 capitalize",children:g(n,"EEEE d. MMMM yyyy",{locale:M})}),w.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("h3",{className:"font-heading text-sm font-bold uppercase tracking-wider text-muted-foreground mb-3 flex items-center gap-2",children:[e.jsx(B,{className:"w-4 h-4"})," ",i("facilities.matches")]}),e.jsx("div",{className:"grid gap-3",children:I.map(({match:t,pitchBooking:a,changingRoomBooking:s})=>{var r,c;return e.jsx(k,{className:"overflow-hidden border-l-4 border-l-primary",children:e.jsx(_,{className:"p-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"shrink-0",children:[e.jsx("div",{className:"text-lg font-heading font-bold text-primary",children:t.time}),e.jsx("div",{className:"text-[10px] text-muted-foreground",children:t.rowName})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"font-heading font-semibold text-foreground",children:[t.home," ",e.jsx("span",{className:"text-muted-foreground",children:i("common.vs")})," ",t.away]}),t.homeScore!==null&&t.awayScore!==null&&e.jsxs("div",{className:"text-sm font-bold text-primary mt-0.5",children:[t.homeScore," - ",t.awayScore]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[a&&e.jsxs(b,{variant:"secondary",className:j.bane,children:[C.bane," ",(r=a.facilities)==null?void 0:r.name]}),s&&e.jsxs(b,{variant:"secondary",className:j.omklædningsrum,children:[C.omklædningsrum," ",(c=s.facilities)==null?void 0:c.name]}),!a&&t.teamName&&e.jsxs(b,{variant:"secondary",className:"bg-muted text-muted-foreground",children:[e.jsx(Y,{className:"w-3 h-3 mr-1"})," ",t.teamName]})]})]})})},t.id)})})]}),["bane","hal","omklædningsrum","mødelokale","andet"].map(t=>{const a=x.filter(s=>s.type===t);return a.length===0?null:e.jsxs("div",{className:"mb-8",children:[e.jsxs("h3",{className:"font-heading text-sm font-bold uppercase tracking-wider text-muted-foreground mb-3 flex items-center gap-2",children:[C[t]||e.jsx(N,{className:"w-4 h-4"}),K[t]||t]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:a.map(s=>{var c;const r=((c=P[s.id])==null?void 0:c.items)||[];return e.jsx(k,{className:`overflow-hidden ${r.length===0?"opacity-60":""}`,children:e.jsxs(_,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(b,{variant:"outline",className:`text-[10px] ${j[s.type]||j.andet}`,children:s.type}),e.jsx("span",{className:"font-heading font-semibold text-sm",children:s.name})]}),r.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:i("facilities.noActivities")}):e.jsx("div",{className:"space-y-2",children:r.map((o,l)=>e.jsxs("div",{className:`rounded-md px-3 py-2 text-xs border ${o.type==="training"?"bg-amber-50 border-amber-200 text-amber-800":o.type==="match"?"bg-primary/10 border-primary/20 text-foreground":"bg-primary/5 border-primary/15 text-foreground"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-medium",children:o.title}),e.jsxs("span",{className:"flex items-center gap-1 text-[10px] opacity-75",children:[e.jsx(G,{className:"w-3 h-3"}),o.time,"â",o.endTime]})]}),o.subtitle&&e.jsx("div",{className:"text-[10px] opacity-60 mt-0.5",children:o.subtitle})]},l))})]})},s.id)})})]},t)}),x.length===0&&e.jsx(k,{children:e.jsxs(_,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(N,{className:"w-12 h-12 mx-auto mb-3 opacity-40"}),e.jsx("p",{children:i("facilities.noFacilities")})]})})]})})}export{ue 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.