1import{c as le,j as e,L as S,u as de,a as ce,b as ue,r as d,g as me,s as w,F as W,C as xe,U as ge,d as H,S as T,f as pe,B as P,e as f,N as he,h as fe,i as ve,k as be,l as O}from"./index-C8n-dv4k.js";import{N as je,S as Ne}from"./NextDepartureHero-BD1549mI.js";import{U as V}from"./user-lrenHvnW.js";import{A as Z}from"./anchor-DdjENiGj.js";import{S as ye,d as we,g as _e}from"./courseRegistrationPdf-fhvaCyYy.js";import{T as $}from"./triangle-alert-BnKU9vZj.js";import{G as Ce}from"./graduation-cap-D287hS8J.js";import{A as Q}from"./arrow-right-Cgp-JfVw.js";import{C as Se}from"./circle-check-big-moItuxVf.js";import{W as ke}from"./waves-YaaS5GVa.js";import"./eye-CeVGgZ1L.js";import"./addDays-DuunSd0l.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 ze=le("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);function Ae(){const n=[{label:"First Name",value:"Sarah"},{label:"Last Name",value:"Johnson"},{label:"Cert Level",value:"Advanced OW"},{label:"Dive Type",value:"Fun Dive"}];return e.jsx("div",{className:"w-full h-full flex flex-col gap-1 overflow-hidden px-1",children:n.map(r=>e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground/60 font-medium",children:r.label}),e.jsx("div",{className:"h-4 rounded bg-muted/40 overflow-hidden relative",children:e.jsx("span",{className:"text-[10px] text-foreground/70 font-medium px-1.5 leading-4 absolute inset-0",children:r.value})})]},r.label))})}function De(){return e.jsxs("div",{className:"w-full h-full flex gap-2 px-1 items-end",children:[e.jsxs("div",{className:"flex-1 flex flex-col gap-1",children:[e.jsx("span",{className:"text-[8px] text-muted-foreground/50 font-bold uppercase",children:"Guests"}),e.jsx("div",{className:"flex flex-col gap-0.5",children:[1,2].map(n=>e.jsxs("div",{className:"h-4 rounded text-[9px] flex items-center gap-1 px-1 bg-muted/50 text-foreground/50",children:[e.jsx(V,{size:8}),e.jsxs("span",{children:["Guest ",n+1]})]},n))})]}),e.jsxs("div",{className:"flex-1 flex flex-col gap-1",children:[e.jsx("span",{className:"text-[8px] text-muted-foreground/50 font-bold uppercase",children:"Reef Star"}),e.jsx("div",{className:"border border-border/40 rounded p-1 min-h-[40px] flex flex-col gap-0.5 bg-muted/20",children:e.jsxs("div",{className:"h-4 rounded text-[9px] flex items-center gap-1 px-1 bg-primary/15 text-primary",children:[e.jsx(V,{size:8}),e.jsx("span",{children:"Guest 1"})]})})]})]})}function Ie(){const n=[{name:"Reef Star",guests:8,status:"At sea",statusClass:"bg-success/15 text-success"},{name:"Blue Fin",guests:5,status:"Loading",statusClass:"bg-muted text-muted-foreground"}];return e.jsx("div",{className:"w-full h-full flex flex-col gap-1.5 px-1",children:n.map(r=>e.jsxs("div",{className:"flex items-center gap-1.5 bg-muted/30 rounded px-1.5 py-1",children:[e.jsx(Z,{size:10,className:"text-primary/60 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[9px] font-bold text-foreground/70 truncate",children:r.name}),e.jsxs("div",{className:"text-[8px] text-muted-foreground/60",children:[r.guests," guests"]})]}),e.jsx("span",{className:`text-[8px] font-medium px-1 py-0.5 rounded ${r.statusClass}`,children:r.status})]},r.name))})}const Re={"/check-in":Ae,"/planning":De,"/tv-display":Ie};function Te({to:n,label:r,icon:v,desc:k}){const p=Re[n];return e.jsxs(S,{to:n,className:"group flex flex-col rounded-xl border-2 border-border bg-card shadow-lg ring-1 ring-border/50 hover:border-primary/40 hover:shadow-xl transition-all overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 border-b-2 border-border/60",children:[e.jsx("div",{className:"bg-primary/10 text-primary p-2 rounded-lg group-hover:bg-primary group-hover:text-primary-foreground transition-colors",children:e.jsx(v,{size:20})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-base text-foreground",children:r}),e.jsx("div",{className:"text-sm text-muted-foreground",children:k})]})]}),e.jsx("div",{className:"h-24 bg-muted/50 p-2 overflow-hidden",children:p&&e.jsx(p,{})})]})}
6const J=[{icon:O,title:"All clear!",sub:"Everything is set for today â smooth sailing ahead."},{icon:Z,title:"Ship-shape!",sub:"No issues found. Ready to dive in."},{icon:ke,title:"Smooth seas ahead",sub:"All guests assigned, gear sorted, forms complete."},{icon:Ne,title:"Looking good!",sub:"Nothing needs your attention right now."},{icon:O,title:"All systems go",sub:"Crew is ready, guests are set. Have a great day!"}];function $e({style:n}){const[r]=d.useState(()=>J[Math.floor(Math.random()*J.length)]),v=r.icon;return e.jsxs("div",{style:n,className:"rounded-xl border border-success/30 bg-success/5 p-4 h-full flex flex-col items-center justify-center text-center overflow-hidden",children:[e.jsx("div",{className:"bg-success/15 text-success p-2.5 rounded-full mb-2",children:e.jsx(v,{size:20})}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:r.title}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:r.sub})]})}function Qe(){const{guests:n,staff:r,boats:v,trips:k,assignments:p,diveGroups:b,selectedDate:c,centerConfig:u,setSelectedDate:K,loadDate:X,silentRefresh:Y}=de(),{activeCenterId:h}=ce(),{hasFormsDocuments:z,hasTvDisplay:ee}=ue(),[j,te]=d.useState(0),[A,M]=d.useState([]),[D,q]=d.useState({}),[G,E]=d.useState(null),F=d.useRef(null);d.useEffect(()=>{const t=me();c!==t&&K(t),X(t),Y()},[]);const o=n.filter(t=>t.diveDate===c),m=k.filter(t=>t.diveDate===c),se=new Set(m.map(t=>t.id)),B=new Set(p.filter(t=>t.guestId&&se.has(t.tripId)).map(t=>t.guestId)),x=o.filter(t=>!B.has(t.id)),L=v.filter(t=>t.active);r.filter(t=>t.active),d.useEffect(()=>{if(!h)return;w.from("bookings").select("id",{count:"exact",head:!0}).eq("center_id",h).eq("dive_date",c).neq("status","cancelled").neq("payment_status","paid").is("stripe_payment_intent_id",null).is("paid_offline_at",null).gt("total_cents",0).then(({count:s})=>te(s??0)),w.from("review_requests").select("id, guest_name, rating, review_text, dive_date").eq("center_id",h).not("review_submitted_at","is",null).eq("published",!1).order("review_submitted_at",{ascending:!1}).limit(5).then(({data:s})=>M(s||[]));const t=n.filter(s=>s.diveDate===c).map(s=>s.id);t.length>0?w.from("guest_documents").select("guest_id, document_type").in("guest_id",t).then(({data:s})=>{const i={};(s||[]).forEach(a=>{i[a.guest_id]||(i[a.guest_id]=new Set),i[a.guest_id].add(a.document_type)}),q(i)}):q({})},[h,c,n]);const N=d.useMemo(()=>{const t=[],s=o.filter(l=>!l.wetsuitSize||!l.bcdSize||!l.bootSize||!l.finSize);s.length>0&&t.push({icon:ye,text:`${s.length} guest${s.length>1?"s":""} missing equipment sizes`,severity:"warning",to:"/guests-today",count:s.length});const i=new Set(["instructor","divemaster","dmt"]),a=m.filter(l=>{const C=p.filter(g=>g.tripId===l.id&&g.staffId).some(g=>{const y=r.find(R=>R.id===g.staffId);return y&&i.has(y.role)}),oe=((b==null?void 0:b.filter(g=>g.tripId===l.id))||[]).some(g=>{const y=r.find(R=>R.id===g.staffId);return y&&i.has(y.role)});return!C&&!oe});a.length>0&&t.push({icon:$,text:`${a.length} trip${a.length>1?"s":""} missing divemaster`,severity:"warning",to:"/planning",count:a.length}),x.length>0&&t.push({icon:ze,text:`${x.length} guest${x.length>1?"s":""} not assigned to a trip`,severity:"warning",to:"/planning",count:x.length});const _=z?o.filter(l=>{var I,C;return!((I=D[l.id])!=null&&I.has("medical_questionnaire")&&((C=D[l.id])!=null&&C.has("liability_release")))}):[];return _.length>0&&t.push({icon:W,text:`${_.length} guest${_.length>1?"s":""} with incomplete forms`,severity:"info",to:"/guests-today",count:_.length}),j>0&&t.push({icon:xe,text:`${j} booking${j>1?"s":""} unpaid`,severity:"warning",to:"/tasks",count:j}),!z&&o.length>0&&t.push({icon:W,text:"Forms & Documents module not enabled â no liability/medical forms will be collected",severity:"warning",to:"/store",count:1}),t},[o,m,p,r,b,x,j,z,D]),ie=o.filter(t=>B.has(t.id)).length;L.reduce((t,s)=>t+s.capacity,0);const re=new Set(m.map(t=>t.boatId).filter(Boolean)),ne=[{label:"Guests",value:o.length,icon:ge,color:"text-primary",to:"/guests-today",sub:`${ie} assigned`},{label:"Trips Today",value:m.length,icon:H,color:"text-accent",to:"/planning",sub:`${m.length>0?m.length+" scheduled":"None planned"}`},{label:"Boats Out",value:re.size,icon:T,color:"text-success",to:"/boats",sub:`of ${L.length} active`},{label:"Unassigned",value:x.length,icon:$,color:x.length>0?"text-warning":"text-muted-foreground",to:"/planning",sub:x.length>0?"Needs attention":"All assigned"}];d.useEffect(()=>{const t=F.current;if(!t||typeof window>"u")return;const s=()=>
6{if(window.innerWidth<1024){E(null);return}E(t.getBoundingClientRect().height)};s();const i=typeof ResizeObserver<"u"?new ResizeObserver(()=>s()):null;return i==null||i.observe(t),window.addEventListener("resize",s),()=>{i==null||i.disconnect(),window.removeEventListener("resize",s)}},[]);const U=G?{height:`${G}px`}:void 0,ae=[{to:"/check-in",label:"Guest Registration",icon:be,desc:"Register a new guest"},{to:"/planning",label:"Planning Board",icon:H,desc:"Manage trip assignments"},...ee?[{to:"/tv-display",label:"TV-Display",icon:T,desc:"Full-screen TV mode"}]:[]];return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold tracking-tight",children:["Today",u.centerName&&e.jsxs("span",{className:"text-muted-foreground font-medium text-lg ml-2",children:["â ",u.centerName]})]}),e.jsx("p",{className:"text-muted-foreground",children:pe(new Date(c+"T12:00:00"),"EEEE, MMMM d, yyyy")})]}),e.jsxs(P,{variant:"outline",className:"touch-target shrink-0",onClick:async()=>{try{const t=await we({dateISO:c,guests:o}),s=_e({dateISO:c,centerName:(u==null?void 0:u.centerName)??"",guests:o,staff:r,diveGroups:b,assignments:p,autoCompletedIds:t});f.success(`Generated ${s.count} registration${s.count===1?"":"s"}`)}catch(t){(t==null?void 0:t.message)==="No course participants to include"?f.error("No courses finishing today."):f.error((t==null?void 0:t.message)||"Could not generate PDF")}},children:[e.jsx(Ce,{size:18})," Course Registrations"]})]}),e.jsx(je,{latitude:u.latitude,longitude:u.longitude,locationName:u.locationName}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3",children:[e.jsx("div",{className:"lg:col-span-2 grid grid-cols-2 lg:grid-cols-4 gap-2",children:ne.map((t,s)=>{const i=t.icon;return e.jsxs(S,{ref:s===0?F:void 0,to:t.to,className:"aspect-square flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-border/80 p-3 hover:border-primary/40 hover:bg-muted/50 transition-colors cursor-pointer overflow-hidden text-center",children:[e.jsx("div",{className:`${t.color} shrink-0`,children:e.jsx(i,{size:100,strokeWidth:1})}),e.jsxs("div",{className:"min-w-0 w-full overflow-hidden",children:[e.jsx("div",{className:"text-xs font-bold text-foreground leading-tight truncate",children:t.label}),e.jsx("div",{className:"text-3xl font-extrabold text-foreground leading-tight",children:t.value}),e.jsx("div",{className:"text-[10px] text-muted-foreground truncate",children:t.sub})]})]},t.label)})}),e.jsx("div",{className:"lg:col-span-1",children:N.length>0?e.jsxs("div",{style:U,className:"rounded-xl border-2 border-destructive/40 bg-gradient-to-br from-destructive/10 to-warning/5 px-4 py-4 flex flex-col shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3 pb-3 border-b border-destructive/20",children:[e.jsxs("div",{className:"relative bg-destructive/20 p-2 rounded-lg",children:[e.jsx($,{size:22,className:"text-destructive"}),e.jsx(he,{count:N.reduce((t,s)=>t+s.count,0),floating:!0})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-bold tracking-tight text-destructive",children:"Attention Needed"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.reduce((t,s)=>t+s.count,0)," issue",N.reduce((t,s)=>t+s.count,0)>1?"s":""," require action"]})]})]}),e.jsx("div",{className:"space-y-1 flex-1 overflow-y-auto min-h-0 pr-1",children:N.map((t,s)=>{const i=t.icon;return e.jsxs(S,{to:t.to,className:"flex items-center gap-3 rounded-lg px-3 py-2.5 hover:bg-destructive/10 transition-colors group border border-transparent hover:border-destructive/20",children:[e.jsx("div",{className:`shrink-0 p-1.5 rounded-md ${t.severity==="warning"?"bg-destructive/15 text-destructive":"bg-muted text-muted-foreground"}`,children:e.jsx(i,{size:16})}),e.jsx("span",{className:"text-sm font-medium text-foreground flex-1 leading-snug",children:t.text}),e.jsx(Q,{size:14,className:"text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]},s)})})]}):e.jsx($e,{style:U})})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground mb-2",children:"Qu
6ick Actions"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:ae.map(t=>e.jsx(Te,{...t},t.to))})]}),A.length>0&&e.jsxs("div",{className:"rounded-xl border-2 border-border/80 bg-card px-4 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(fe,{size:18,className:"text-primary"}),e.jsx("h2",{className:"text-sm font-bold",children:"Tasks"}),e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded-full font-medium",children:A.length})]}),e.jsxs(S,{to:"/tasks",className:"text-xs text-primary hover:underline flex items-center gap-1",children:["Visa alla ",e.jsx(Q,{size:12})]})]}),e.jsx("div",{className:"space-y-2",children:A.map(t=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg border border-border px-3 py-2.5",children:[e.jsx("div",{className:"flex items-center gap-0.5 shrink-0",children:Array.from({length:5}).map((s,i)=>e.jsx(ve,{size:12,className:i<(t.rating||0)?"fill-yellow-400 text-yellow-400":"text-muted-foreground/30"},i))}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:t.guest_name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.review_text})]}),e.jsxs(P,{size:"sm",variant:"outline",className:"shrink-0 text-xs gap-1",onClick:async()=>{const{error:s}=await w.from("review_requests").update({published:!0}).eq("id",t.id);if(s){f.error("Failed");return}if(t.rating&&t.review_text&&h){const{error:i}=await w.from("website_reviews").insert({center_id:h,author_name:t.guest_name,rating:t.rating,review_text:t.review_text,review_date:t.dive_date,visible:!0,sort_order:0});if(i){f.error("Review approved, but it could not be added to the website",{description:i.message});return}}f.success("Review approved"),M(i=>i.filter(a=>a.id!==t.id))},children:[e.jsx(Se,{size:12}),"Godkänn"]})]},t.id))})]}),o.length===0&&m.length===0&&e.jsxs("div",{className:"ops-card text-center py-12 text-muted-foreground",children:[e.jsx(T,{size:48,className:"mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-lg font-medium",children:"No activities scheduled for today"}),e.jsx("p",{className:"text-sm",children:"Start by adding boats, staff, and registering guests"})]})]})}export{Qe 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.