1import{j as e}from"./ui-D9vYnNRd.js";import{L as h}from"./router-BDCNlvNV.js";import{L as v}from"./Layout-hz1-jJ1O.js";import{B as x}from"./button-DhNYK_Jg.js";import{B as c}from"./badge-M7N4me7f.js";import{u as j}from"./query-CK-6UiBM.js";import{s as f}from"./index-BDadkGoc.js";import{S as b}from"./StayUpdatedSection-Dk_Z3-NU.js";import{f as d}from"./label-CLwipVk1.js";import{s as m}from"./sv-BXx6zA7E.js";import"./vendor-o8UMtg5z.js";import"./supabase-CFT6Uc19.js";import"./NewsletterModal-DBqcWHUG.js";import"./dialog-CzVBhzwN.js";import"./circle-check-y9KJf9TH.js";import"./mail-BVxz_7k6.js";import"./clock-BXvVykH7.js";import"./instagram-fJNTvvhA.js";const $=()=>{const{data:i}=j({queryKey:["homepage-content"],queryFn:async()=>{const r=new Date().toISOString().split("T")[0],{data:s,error:a}=await f.from("homepage_content").select(` 2 *, 3 show:shows( 4 id, title, date, time, description, price, discounted_price, external_ticket_url, image_url, available_tickets, sold_tickets, 5 venue:venues(name) 6 ), 7 course:courses( 8 id, title, start_date, end_date, start_time, end_time, description, price, discounted_price, level, instructor, image_url, status, max_participants 9 ) 10 `).eq("is_active",!0).order("position",{ascending:!0});if(a)throw a;if(!s)return[];const l=s.filter(t=>t.type==="show"&&t.show?t.show.date>=r:t.type==="course"&&t.course?["active","full"].includes(t.course.status):!0);return await Promise.all(l.map(async t=>{if(t.type==="course"&&t.course){const{data:n,error:u}=await f.rpc("get_course_registration_count",{course_id_param:t.course.id});return u?(console.error("Error fetching registration count:",u),{...t,course:{...t.course,registration_count:0}}):{...t,course:{...t.course,registration_count:n||0}}}return t}))}}),g=r=>{if(!r.max_participants)return{spotsLeft:null,isFull:!1,showWarning:!1};const s=r.max_participants-(r.registration_count||0),a=s<=0,l=s>0&&s<=4;return{spotsLeft:s,isFull:a,showWarning:l}},p=()=>!i||i.length===0?null:i.map(r=>{if(r.type==="show"&&r.show){const s=r.show;return s.venue,e.jsxs("div",{className:"bg-gray-100 border-0 h-full flex flex-col",children:[s.image_url&&e.jsx("div",{className:"aspect-video flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:s.image_url,alt:s.title||"",className:"w-full h-full object-cover",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:"flex-1 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex-grow",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx("h3",{className:"text-xl",children:s.title}),(()=>{if(s.external_ticket_url)return null;const a=s.available_tickets??0,l=(s.available_tickets??0)+(s.sold_tickets??0),o=Math.ceil(l*.1),t=Math.ceil(l*.2);return a<=0?e.jsx(c,{variant:"destructive",className:"bg-red-600 hover:bg-red-700 flex-shrink-0 mt-1",children:"Fullsatt!"}):a<=15?e.jsxs(c,{variant:"destructive",className:"bg-red-600 hover:bg-red-700 text-center whitespace-nowrap flex-shrink-0 mt-1",children:[a," ",a===1?"plats":"platser"," kvar!"]}):a<=o?e.jsx(c,{variant:"destructive",className:"bg-red-600 hover:bg-red-700 text-center whitespace-nowrap flex-shrink-0 mt-1",children:"Fåtal kvar"}):a<=t?e.jsx(c,{variant:"destructive",className:"bg-red-600 hover:bg-red-700 text-center whitespace-nowrap flex-shrink-0 mt-1",children:"Snart slutsåld"}):null})()]}),e.jsx("div",{className:"text-sm text-stone-700 dark:text-stone-200 mb-4",children:s.date&&s.time&&`${d(new Date(s.date),"d MMMM yyyy",{locale:m})}, ${s.time.slice(0,5)}`}),s.description&&e.jsxs("div",{className:"relative mb-4",children:[e.jsx("div",{className:"text-foreground/80 line-clamp-5",children:s.description.split(` 11`).map((a,l)=>a.trim().startsWith("- ")?e.jsxs("div",{className:"flex items-start gap-2 my-1",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full mt-2 flex-shrink-0"}),e.jsx("span",{children:a.trim().substring(2)})]},l):a.trim()?e.jsx("div",{className:"my-1",children:a},l):e.jsx("div",{children:" "},l))}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-6 bg-gradient-to-t from-gray-100 to-transparent pointer-events-none"})]})]}),e.jsx(x,{className:"w-full",asChild:!0,children:e.jsx(h,{to:"/forestallningar",children:"Läs mer"})})]})]},r.id)}else if(r.type==="course"&&r.course){const s=r.course,{spotsLeft:a,isFull:l,showWarning:o}=g(s);return e.jsxs("div",{className:"bg-gray-100 border-0 h-full flex flex-col",children:[s.image_url&&e.jsx("div",{className:"aspect-video flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:s.image_url,alt:s.title||"",className:"w-full h-full object-cover",loading:"lazy",decoding:"async"})}),e.jsxs("div",{className:"flex-1 p-6 flex flex-col",children:[e.jsxs("div",{className:"flex-grow",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx("h3",{className:"text-xl",children:s.title}),l&&e.jsx(c,{variant:"destructive",className:"bg-red-600 hover:bg-red-700",children:"Fullbokad!"}),o&&!l&&e.jsx(c,{variant:"destructive",className:"bg-red-600 hover:bg-red-700",children:"Fåtal platser kvar!"})]}
11),e.jsx("div",{className:"text-sm text-foreground/70 mb-4",children:s.start_date&&e.jsxs(e.Fragment,{children:[d(new Date(s.start_date),"d MMMM yyyy",{locale:m}),s.end_date&&` - ${d(new Date(s.end_date),"d MMMM yyyy",{locale:m})}`]})}),s.description&&e.jsxs("div",{className:"relative mb-4",children:[e.jsx("div",{className:"text-foreground/80 line-clamp-5",children:s.description.split(` 12`).map((t,n)=>t.trim().startsWith("- ")?e.jsxs("div",{className:"flex items-start gap-2 my-1",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full mt-2 flex-shrink-0"}),e.jsx("span",{children:t.trim().substring(2)})]},n):t.trim()?e.jsx("div",{className:"my-1",children:t},n):e.jsx("div",{children:" "},n))}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-6 bg-gradient-to-t from-gray-100 to-transparent pointer-events-none"})]})]}),e.jsx(x,{className:"w-full",asChild:!0,children:e.jsx(h,{to:"/kurser",children:"Läs mer"})})]})]},r.id)}else if(r.type==="custom")return e.jsxs("div",{className:"bg-gray-100 border-0 h-full flex flex-col",children:[r.image_url&&e.jsx("div",{className:"aspect-video flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:r.image_url,alt:r.title||"",className:"w-full h-full object-cover",loading:"lazy",decoding:"async"})}),e.jsx("div",{className:"flex-1 p-6 flex flex-col",children:e.jsxs("div",{className:"flex-grow",children:[r.title&&e.jsx("h3",{className:"text-xl mb-4",children:r.title}),r.description&&e.jsxs("div",{className:"relative",children:[e.jsx("p",{className:"text-foreground/80 line-clamp-5",children:r.description}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-6 bg-gradient-to-t from-gray-100 to-transparent pointer-events-none"})]})]})})]},r.id);return null});return e.jsxs(v,{noPadding:!0,children:[e.jsxs("section",{className:"relative min-h-[70vh] flex items-center pt-20 bg-[#2a2a2a]",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:"/lovable-uploads/3dc7dadd-b3b5-490c-9bbf-2df4830e8323.png",alt:"Dramaverket teater scen",className:"w-full h-full object-cover",loading:"eager",fetchPriority:"high",decoding:"async"}),e.jsx("div",{className:"absolute inset-0 bg-black/40"})]}),e.jsxs("div",{className:"relative z-10 container mx-auto max-w-4xl text-center px-6 py-20",children:[e.jsx("h1",{className:"hero-title mb-8 text-white",children:"Vi är Karlstads improvisationsteater"}),e.jsx("p",{className:"text-base text-white/90 leading-relaxed max-w-3xl mx-auto",children:"Våra föreställningar skapas i stunden och tillsammans med vår publik gör vi Värmlands kulturliv mer nyskapande, underhållande och oförutsägbart. Följ oss på Facebook eller Instagram för uppdateringar kring våra föreställningar. Eller skriv upp dig på vårt nyhetsbrev här nedan."})]})]}),i&&i.length>0&&e.jsx("section",{className:"py-10 px-2 bg-section-gray",children:e.jsx("div",{className:"w-full max-w-none",children:e.jsx("div",{className:`grid gap-4 md:grid-cols-2 lg:mx-auto items-stretch ${i.length===3?"lg:grid-cols-3 lg:max-w-6xl":"lg:grid-cols-2 lg:max-w-4xl"}`,children:p()})})}),e.jsx(b,{showIcons:!0})]})};export{$ 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.