1import{bu as ts,r as m,bv as B,s as x,j as e,h as Z,y as L,B as P,a2 as as,bg as rs,C as ns,ai as ls,ab as y,k as os,R as is}from"./index-BvsqCpEz.js";import{I as G}from"./input-BedoGODD.js";import{S as Ae}from"./switch-D7vhGPpr.js";import{S as ne,a as le,b as oe,c as ie,d as F}from"./select-kTbLcfik.js";import{P as Fe,a as qe,b as $e}from"./popover-BRjrXi5Z.js";import{C as cs,a as ds,b as ms,c as ps,d as hs,e as us,f as Ce}from"./command-DKRzSa8u.js";import{i as xs,C as gs}from"./calendar-CAkD_jWe.js";import{o as ue,T as Re,A as xe,a as ge,b as fe,c as be,d as je,e as we,f as ve,g as Ne,h as Te,i as De,j as pe,k as he}from"./MemberDashboard-Cs5Sf23a.js";import{v as Pe,u as Ee}from"./upload-rules-DzRXK9g4.js";import{p as Le}from"./prepare-image-upload-Bby_BZou.js";import{C as fs}from"./calendar-BX6XEece.js";import{C as bs}from"./check-B97Uezjq.js";import{s as js,f as Oe}from"./format-Dogvratb.js";import{p as Ve}from"./parseISO-CVkWsmuV.js";import"./startOfMonth-Bq5nWt2t.js";import"./subDays-C60P-3D1.js";import"./chevron-left-DdeOtDWg.js";import"./chevron-right-CPI6eVSm.js";import"./use-auth-4OwtEfAA.js";import"./index-5yHiP4fM.js";import"./wind-DW6YfAyS.js";import"./arrow-left-DasGo8Zs.js";import"./user-DLmK3dAG.js";import"./download-0HDG1NIG.js";const ws=[{key:"longTerm",label:"Long-term",accent:"bg-primary"},{key:"midTerm",label:"Mid-term",accent:"bg-sfm-blue"},{key:"shortTerm",label:"Short-term",accent:"bg-amber-500"},{key:"singleShow",label:"Single show",accent:"bg-emerald-500"}],vs=[{key:"price",label:"Price",placeholder:"$1,500"},{key:"term",label:"Term",placeholder:"12 months"},{key:"spots",label:"Spots",placeholder:"40 Ã 30 sec / week"},{key:"total",label:"Total plays",placeholder:"2,080 plays / year"},{key:"cpp",label:"Cost per play",placeholder:"$1.20 per play"},{key:"window",label:"Time window",placeholder:"6amâ11pm (optional)"}],q=o=>JSON.parse(JSON.stringify(o)),Ns=o=>o+"-"+Math.random().toString(36).slice(2,7),ys=({getAssignedCount:o})=>{const{refresh:C}=ts(),[g,T]=m.useState(B),[j,w]=m.useState(B),[S,Y]=m.useState(!0),[U,W]=m.useState(!1);m.useEffect(()=>{Y(!0),x.from("page_content").select("content").eq("page","sponsorship").maybeSingle().then(({data:n})=>{const c=(n==null?void 0:n.content)??{},f={...B,...c,longTerm:c.longTerm??B.longTerm,midTerm:c.midTerm??B.midTerm,shortTerm:c.shortTerm??B.shortTerm,singleShow:c.singleShow??B.singleShow};T(q(f)),w(q(f)),Y(!1)})},[]);const z=m.useMemo(()=>JSON.stringify({longTerm:g.longTerm,midTerm:g.midTerm,shortTerm:g.shortTerm,singleShow:g.singleShow})!==JSON.stringify({longTerm:j.longTerm,midTerm:j.midTerm,shortTerm:j.shortTerm,singleShow:j.singleShow}),[g,j]),H=(n,c,f)=>{T(p=>{const u=q(p);return u[n][c]={...u[n][c],...f},u})},E=(n,c,f)=>{T(p=>{const u=q(p),b=u[n],D=c+f;return D<0||D>=b.length?p:([b[c],b[D]]=[b[D],b[c]],u)})},[O,$]=m.useState(null),K=(n,c)=>{const f=g[n][c],p=(o==null?void 0:o(n,f))??0,u=f.name||"this package",b=p>0?`Delete "${u}"? 2 3${p} sponsor${p===1?"":"s"} ${p===1?"is":"are"} currently assigned to this package. They will remain in the database but will no longer match a listed package on the public page.`:`Delete "${u}"?`;$({group:n,idx:c,msg:b})},ee=()=>{if(!O)return;const{group:n,idx:c}=O;$(null),T(f=>{const p=q(f);return p[n].splice(c,1),p})},Q=n=>{T(c=>{const f=q(c),p="New package";return f[n].push({id:Ns(p),name:p,price:"",term:"",spots:"",total:"",cpp:"",window:""}),f})},se=async()=>{var n;W(!0);try{const{data:c}=await x.from("page_content").select("content").eq("page","sponsorship").maybeSingle(),p={...(c==null?void 0:c.content)??{},longTerm:g.longTerm,midTerm:g.midTerm,shortTerm:g.shortTerm,singleShow:g.singleShow},{error:u}=await x.from("page_content").upsert({page:"sponsorship",content:p,updated_by:(n=(await x.auth.getUser()).data.user)==null?void 0:n.id},{onConflict:"page"});if(u)throw u;w(q(g)),y.success("Packages saved"),await C()}catch(c){y.error(c.message??"Failed to save")}finally{W(!1)}},[te,R]=m.useState(!1),ae=()=>{z&&R(!0)},V=()=>{R(!1),T(q(j))};return S?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Z,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"space-y-5",children:[ws.map(({key:n,label:c,accent:f})=>{const p=g[n];return e.jsxs("section",{className:"bg-card border border-border rounded-2xl overflow-hidden",children:[e.jsxs("header",{className:"flex items-center justify-between gap-3 px-4 py-3 border-b border-border bg-muted/30",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("span",{className:L("h-2.5 w-2.5 rounded-full flex-shrink-0",f)}),e.jsx("h3",{className:"font-display text-sm font-bold text-foreground truncate",children:c}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.length," ",p.length===1?"package":"packages"]})]}),e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>Q(n),className:"h-8 rounded-xl",children:[e.jsx(ue,{className:"h-3.5 w-3.5 mr-1"})," Add package"]})]}),e.jsxs("div",{className:"divide-y divide-border",children:[p.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground italic px-4 py-6 text-center",children:'No packages yet. Click "Add package" to create one.'}),p.map((u,b)=>{const D=(o==null?void 0:o(n,u))??0;return e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(G,{value:u.name,onChange:_=>H(n,b,{name:_.target.value}),placeholder:"Package name",className:"text-sm font-semibold h-9 rounded-xl flex-1 min-w-[180px]"}),e.jsxs("label",{className:L("flex items-center gap-2 h-9 px-3 rounded-xl border cursor-pointer transition-colors",u.popular?"border-amber-400 bg-amber-50 dark:bg-amber-500/10 text-amber-700 dark:text-amber-300":"border-border bg-background text-muted-foreground"),title:"Highlight as the popular pick on the public page",children:[e.jsx(as,{className:L("h-3.5 w-3.5",u.popular&&"fill-current")}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",children:"Popular"}),e.jsx(Ae,{checked:!!u.popular,onCheckedChange:_=>H(n,b,{popular:_})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(P,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-xl",onClick:()=>E(n,b,-1),disabled:b===0,title:"Move up",children:e.jsx(rs,{className:"h-4 w-4"})}),e.jsx(P,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-xl",onClick:()=>E(n,b,1),disabled:b===p.length-1,title:"Move down",children:e.jsx(ns,{className:"h-4 w-4"})}),e.jsx(P,{variant:"ghost",size:"icon",onClick:()=>K(n,b),className:"h-9 w-9 rounded-xl text-muted-foreground hover:text-destructive hover:bg-destructive/10",title:"Delete package",children:e.jsx(Re,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:vs.map(_=>e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[10px] font-semibold uppercase tracking-wider text-muted-foreground mb-1 px-1",children:_.label}),e.jsx(G,{value:u[_.key]??"",onChange:M=>H(n,b,{[_.key]:M.target.value}),placeholder:_.placeholder,className:"text-xs h-9 rounded-xl"})]},_.key))}),D>0&&e.jsxs("div",{className:"flex items-start gap-2 text-[11px] text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-500/10 border border-amber-200 dark:border-amber-500/30 rounded-xl px-3 py-2",children:[e.jsx(ls,{className:"h-3.5 w-3.5 mt-0.5 flex-shrink-0"}),e.jsxs("span",{children:[e.jsx("strong",{children:D})," sponsor",D===1?"":"s"," ",D===1?"is":"are"," currently assigned to this package. Renaming won't move them â update their tier on the Sponsors tab if needed."]})]})]},u.id??b)}
3)]})]},n)}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[e.jsx(P,{variant:"ghost",onClick:ae,disabled:!z||U,className:"rounded-xl",children:"Discard changes"}),e.jsxs(P,{onClick:se,disabled:!z||U,className:"rounded-xl",children:[U?e.jsx(Z,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save packages"]})]}),e.jsx(xe,{open:!!O,onOpenChange:n=>{n||$(null)},children:e.jsxs(ge,{children:[e.jsxs(fe,{children:[e.jsx(be,{children:"Delete package"}),e.jsx(je,{className:"whitespace-pre-line",children:O==null?void 0:O.msg})]}),e.jsxs(we,{children:[e.jsx(ve,{children:"Cancel"}),e.jsx(Ne,{onClick:ee,children:"Delete"})]})]})}),e.jsx(xe,{open:te,onOpenChange:n=>{n||R(!1)},children:e.jsxs(ge,{children:[e.jsxs(fe,{children:[e.jsx(be,{children:"Discard changes"}),e.jsx(je,{children:"Discard unsaved changes to packages?"})]}),e.jsxs(we,{children:[e.jsx(ve,{children:"Cancel"}),e.jsx(Ne,{onClick:V,children:"Discard"})]})]})})]})},ye=[{value:"long-term",label:"Long-term"},{value:"mid-term",label:"Mid-term"},{value:"short-term",label:"Short-term"},{value:"single-show",label:"Single show"}],Ss=Object.fromEntries(ye.map(o=>[o.value,o.label])),ce={"long-term":[{value:"major",label:"Major"},{value:"platinum",label:"Platinum"}],"mid-term":[{value:"6-month",label:"6-month"},{value:"3-month",label:"3-month"}],"short-term":[{value:"4-weeks",label:"4 weeks"}],"single-show":[{value:"12-months",label:"12 months"},{value:"6-months",label:"6 months"}]},N="__none__",J=o=>o?xs(Ve(o),js(new Date)):!1,de=({value:o,onChange:C,placeholder:g})=>{const[T,j]=m.useState(!1),w=o?Ve(o):void 0;return e.jsxs(Fe,{open:T,onOpenChange:j,children:[e.jsx(qe,{asChild:!0,children:e.jsxs(P,{variant:"outline",className:L("h-9 rounded-xl text-xs justify-start font-normal w-[130px]",!w&&"text-muted-foreground"),children:[e.jsx(fs,{className:"mr-1.5 h-3.5 w-3.5 flex-shrink-0"}),w?Oe(w,"d MMM yyyy"):g]})}),e.jsxs($e,{className:"w-auto p-0",align:"start",children:[e.jsx(gs,{mode:"single",selected:w,onSelect:S=>{C(S?Oe(S,"yyyy-MM-dd"):null),j(!1)},initialFocus:!0,className:L("p-3 pointer-events-auto")}),w&&e.jsx("div",{className:"p-2 border-t border-border",children:e.jsx(P,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>{C(null),j(!1)},children:"Clear"})})]})]})},Ue=({shows:o,value:C,onChange:g})=>{const[T,j]=m.useState(!1),w=o.find(S=>S.id===C);return e.jsxs(Fe,{open:T,onOpenChange:j,children:[e.jsx(qe,{asChild:!0,children:e.jsxs(P,{variant:"outline",role:"combobox","aria-expanded":T,className:L("text-sm h-9 w-full sm:w-80 justify-between rounded-xl",w?"font-medium text-foreground":"font-normal text-muted-foreground"),children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[e.jsx(is,{className:L("h-3.5 w-3.5 flex-shrink-0",w?"text-emerald-500":"text-muted-foreground")}),e.jsx("span",{className:"truncate",children:w?w.name:"Select showâ¦"})]}),e.jsx(cs,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx($e,{className:"w-[320px] p-0",align:"start",children:e.jsxs(ds,{children:[e.jsx(ms,{placeholder:"Search showsâ¦",className:"h-9"}),e.jsxs(ps,{children:[e.jsx(hs,{children:"No shows found."}),e.jsxs(us,{children:[w&&e.jsx(Ce,{value:"__clear__",onSelect:()=>{g(null),j(!1)},className:"text-muted-foreground",children:"Clear selection"}),o.map(S=>e.jsxs(Ce,{value:S.name,onSelect:()=>{g(S.id),j(!1)},children:[e.jsx(bs,{className:L("mr-2 h-4 w-4",C===S.id?"opacity-100":"opacity-0")}),S.name]},S.id))]})]})]})})]})},Me=o=>o.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),Ie={longTerm:"long-term",midTerm:"mid-term",shortTerm:"short-term",singleShow:"single-show"},Ws=()=>{const[o,C]=m.useState([]),[g,T]=m.useState([]),[j,w]=m.useState(!0),[S,Y]=m.useState(!1),[U,W]=m.useState(""),[z,H]=m.useState(""),[E,O]=m.useState(N),[$,K]=m.useState(N),[ee,Q]=m.useState(null),[se,te]=m.useState(null),[R,ae]=m.useState(null),[V,n]=m.useState(null),[c,f]=m.useState(null),[p,u]=m.useState(null),[b,D]=m.useState(null),_=os("sponsorship"),M=m.useMemo(()=>{const s={"long-term":[...ce["long-term"]],"mid-term":[...ce["mid-term"]],"short-term":[...ce["short-term"]],"single-show":[...ce["single-show"]]},r={longTerm:_.longTerm??[],midTerm:_.midTerm??[],shortTerm:_.shortTerm??[],singleShow:_.singleShow??[]};return Object.entries(r).forEach(([t,l])=>{const i=Ie[t];l.forEach(h=>{const d=((h==null?void 0:h.name)??"").trim();if(!d)return;const a=Me(d);if(!a)return;s[i].find(I=>I.value===a||I.label.toLowerCase()===d.toLowerCase())||s[i].push({value:a,label:d})})}),s},[_]),X=async()=>{const{data:s}=await x.from("sponsors").select("id, name, logo_url, website_url, display_order, is_active, show_id, sponsorship_type, sponsorship_tier, start_date, end_date").order("display_order",{ascending:!0}),r=s??[],t=r.filter(l=>l.is_active&&J(l.end_date));t.length>0&&(await x.from("sponsors").update({is_active:!1}).in("id",t.map(l=>l.id)),t.forEach(l=>{l.is_active=!1})),C(r),w(!1)},Be=async()=>{const{data:s}=await x.from("shows").select("id, name").eq("archived",!1).eq("vacant",!1).order("name",{ascending:!0});T(s??[])};m.useEffect(()=>{X(),Be()},[]);const Ye=s=>{n(s),f(s?URL.createObjectURL(s):null)},ze=async()=>
3{if(!U.trim())return;Y(!0);const s=o.length>0?Math.max(...o.map(a=>a.display_order))+1:0,r=E===N?null:E,t=r==="single-show"?ee:null,l=r&&$!==N?$:null,i=J(R),{data:h,error:d}=await x.from("sponsors").insert({name:U.trim(),website_url:z.trim()||null,display_order:s,sponsorship_type:r,sponsorship_tier:l,show_id:t,start_date:se,end_date:R,is_active:!i}).select("id").single();if(d||!h){y.error("Failed to add sponsor"),Y(!1);return}if(V){const a=Pe("sponsor-logos",V);if(a){y.error("Logo upload rejected",{description:a});return}const k=V.name.split(".").pop(),I=`${h.id}.${k}`,v=await Le(V),{error:A}=await x.storage.from("sponsor-logos").upload(I,v,{upsert:!0});if(A)y.error("Sponsor added but logo upload failed",{description:Ee("sponsor-logos",A,V)});else{const{data:ss}=x.storage.from("sponsor-logos").getPublicUrl(I);await x.from("sponsors").update({logo_url:ss.publicUrl+"?t="+Date.now()}).eq("id",h.id)}}y.success("Sponsor added"),W(""),H(""),O(N),K(N),Q(null),te(null),ae(null),n(null),f(null),X(),Y(!1)},He=async s=>{const{error:r}=await x.from("sponsors").delete().eq("id",s);r?y.error("Failed to delete"):(y.success("Deleted"),X())},Je=async(s,r,t)=>{if(!r&&J(t)){y.error("Cannot show an expired sponsor. Update the end date first.");return}await x.from("sponsors").update({is_active:!r}).eq("id",s),X()},Ge=async(s,r)=>{const t=Pe("sponsor-logos",r);if(t){y.error("Logo upload rejected",{description:t});return}u(s);const l=r.name.split(".").pop(),i=`${s}.${l}`,h=await Le(r),{error:d}=await x.storage.from("sponsor-logos").upload(i,h,{upsert:!0});if(d){y.error("Upload failed",{description:Ee("sponsor-logos",d,r)}),u(null);return}const{data:a}=x.storage.from("sponsor-logos").getPublicUrl(i),k=a.publicUrl+"?t="+Date.now();await x.from("sponsors").update({logo_url:k}).eq("id",s),y.success("Logo uploaded"),u(null),X()},We=async(s,r)=>{r.trim()&&await x.from("sponsors").update({name:r.trim()}).eq("id",s)},Ke=async(s,r)=>{await x.from("sponsors").update({website_url:r||null}).eq("id",s)},Qe=async(s,r)=>{const t=r===N?null:r,l={sponsorship_type:t,sponsorship_tier:null};t!=="single-show"&&(l.show_id=null);const{error:i}=await x.from("sponsors").update(l).eq("id",s);if(i){y.error("Failed to update type");return}C(h=>h.map(d=>d.id===s?{...d,...l}:d))},Xe=async(s,r)=>{const t=r===N?null:r,{error:l}=await x.from("sponsors").update({sponsorship_tier:t}).eq("id",s);if(l){y.error("Failed to update tier");return}C(i=>i.map(h=>h.id===s?{...h,sponsorship_tier:t}:h))},Ze=async(s,r)=>{const{error:t}=await x.from("sponsors").update({show_id:r}).eq("id",s);if(t){y.error("Failed to link show");return}C(l=>l.map(i=>i.id===s?{...i,show_id:r}:i))},Se=async(s,r,t)=>{const l={[r]:t};r==="end_date"&&J(t)&&(l.is_active=!1);const{error:i}=await x.from("sponsors").update(l).eq("id",s);if(i){y.error("Failed to update date");return}C(h=>h.map(d=>d.id===s?{...d,...l}:d))};if(j)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Z,{className:"h-6 w-6 animate-spin text-muted-foreground"})});const re=o.filter(s=>J(s.end_date)),me=o.filter(s=>!J(s.end_date)),_e=me.filter(s=>s.is_active).length,es={"long-term":"bg-primary","mid-term":"bg-sfm-blue","short-term":"bg-amber-500","single-show":"bg-emerald-500",untyped:"bg-muted-foreground/40",expired:"bg-destructive"},ke=(s,r=!1)=>e.jsx("div",{className:L("bg-card border border-border rounded-2xl p-3 shadow-sm transition-opacity",(!s.is_active||r)&&"opacity-60",r&&"border-destructive/30"),children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsxs("label",{className:"cursor-pointer flex-shrink-0 group",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:t=>{var i;const l=(i=t.target.files)==null?void 0:i[0];l&&Ge(s.id,l)}}),e.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-xl flex items-center justify-center overflow-hidden border border-dashed border-border group-hover:border-primary group-hover:bg-muted transition-colors relative",children:p===s.id?e.jsx(Z,{className:"h-4 w-4 animate-spin text-muted-foreground"}):s.logo_url?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:s.logo_url,alt:s.name,className:"max-w-full max-h-full object-contain p-1"}),e.jsx("div",{className:"absolute inset-0 bg-black/55 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:e.jsx("span",{className:"text-white text-[9px] font-semibold uppercase tracking-wider",children:"Change"})})]}):e.jsx("span",{className:"text-[9px] text-muted-foreground text-center px-1 font-medium leading-tight",children:"Upload logo"})})]}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsx(G,{placeholder:"Sponsor name",defaultValue:s.name,onBlur:t=>We(s.id,t.target.value),className:"text-sm font-semibold h-9 rounded-xl flex-1 min-w-0"}),e.jsx(G,{placeholder:"https://sponsor.com",defaultValue:s.website_url??"",onBlur:t=>Ke(s.id,t.target.value),className:"text-xs h-9 rounded-xl flex-1 min-w-0"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(ne,{value:s.sponsorship_type??N,onValueChange:t=>Qe(s.id,t),children:[e.jsx(le,{className:"text-sm h-9 w-40 rounded-xl",title:"Sponsorship package type",children:e.jsx(oe,{placeholder:"No type"})}),e.jsxs(ie,{children:[e.jsx(F,{value:N,children:"No type"}),ye.map(t=>e.jsx(F,{value:t.value,children:t.label},t.value))]})]}),s.sponsorship_type&&M[s.sponsorship_type]&&e.jsxs(ne,{value:s.sponsorship_tier??N,onValueChange:t=>Xe(s.id,t),children:[e.jsx(le,{className:"text-sm h-9 w-36 rounded-xl",title:"Package tier",children:e.jsx(oe,{placeholder:"No tier"})}),e.jsxs(ie,{children:[e.jsx(F,{value:N,children:"No tier"}),M[s.sponsorship_type].map(t=>e.jsx(F,{value:t.value,children:t.label},t.value))]})]}),s.sponsorship_type==="single-show"&&e.jsx(Ue,{shows:g,value:s.show_id,onChange:t=>Ze(s.id,t)}),s.sponsorship_type==="single-show"&&!s.show_id&&e.jsx("span",{className:"text-[11px] font-medium text-amber-700 dark:text-amber-400",children:"â Pick a show"}),e.jsx(de,{value:s.start_date,onChange:t=>Se(s.id,"start_date",t),placeholder:"Start date"}),e.jsx(de,{value:s.end_date,onChange:t=>Se(s.id,"end_date",t),placeholder:"End date"})]})]})]}),e.jsxs("div",{className:"flex flex-col items-stretch justify-center gap-2 flex-shrink-0 pt-2 sm:pt-0 sm:pl-3 border-t sm:border-t-0 sm:border-l border-border sm:self-stretch",children:[e.jsxs("button",{type:"button",onClick:()=>Je(s.id,s.is_active,s.end_date),className:"flex items-center justify-between gap-3 px-2 py-1 rounded-lg hover:bg-muted transition-colors",title:s.is_active?"Visible on website":"Hidden from website",disabled:r,children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:s.is_active?"Visible":"Hidden"}),e.jsx(Ae,{checked:s.is_active,className:"pointer-events-none"})]}),e.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>D(s.id),className:"h-8 px-2 text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-lg flex items-center justify-between gap-3",title:"Delete sponsor",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",children:"Delete"}),e.jsx(Re,{className:"h-3.5 w-3.5"})]})]})]})},s.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-end justify-between flex-wrap gap-3",children:e.jsxs("div",{children:[e.jsx("h2",{className:"font-display text-2xl font-bold text-foreground",children:"Sponsorship Management"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[o.length," total · ",_e," active · ",me.length-_e," hidden · ",re.length," expired"]})]})}),e.jsxs(Te,{defaultValue:"sponsors",className:"w-full",children:[e.jsxs(De,{className:"mb-2 flex-wrap h-auto gap-1 justify-start",children:[e.jsx(pe,{value:"sponsors",children:"Sponsorship"}),e.jsx(pe,{value:"packages",children:"Packages"})]}),e.jsxs(he,{value:"packages",className:"mt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Edit the sponsorship packages shown on the public Sponsorship page. Other sections (overview, benefits, header) are managed in Page Content."}),(()=>{const s=(t,l)=>{var a;if(!l)return null;const i=l.trim().toLowerCase(),h=Me(l),d=(a=M[t])==null?void 0:a.find(k=>k.label.toLowerCase()===i||k.value.toLowerCase()===i||k.value===h);return(d==null?void 0:d.value)??h??null},r=(t,l)=>{const i=Ie[t];if(!i)return 0;const h=s(i,(l==null?void 0:l.name)??"");return o.filter(d=>d.sponsorship_type===i&&(h?d.sponsorship_tier===h:!d.sponsorship_tier)).length};return e.jsx(ys,{getAssignedCount:r})})()]}),e.jsxs(he,{value:"sponsors",className:"mt-4 space-y-6",children:[e.jsxs("div",{className:"bg-card border border-border rounded-2xl p-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[e.jsx(ue,{className:"h-4 w-4 text-primary"}),e.jsx("h3",{className:"font-display text-sm font-bold text-foreground",children:"Add New Sponsor"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsxs("label",{className:"cursor-pointer flex-shrink-0 group",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:s=>{var r;return Ye(((r=s.target.files)==null?void 0:r[0])??null)}}),e.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-xl flex items-center justify-center overflow-hidden border border-dashed border-border group-hover:border-primary group-hover:bg-muted transition-colors relative",children:c?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:c,alt:"",className:"max-w-full max-h-full object-contain p-1"}),e.jsx("div",{className:"absolute inset-0 bg-black/55 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center",children:e.jsx("span",{className:"text-white text-[9px] font-semibold uppercase tracking-wider",children:"Change"})})]}):e.jsx("span",{className:"text-[9px] text-muted-foreground text-center px-1 font-medium leading-tight",children:"Upload logo"})})]}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2",children:[e.jsx(G,{placeholder:"Sponsor name",value:U,onChange:s=>W(s.target.value),className:"text-sm font-semibold h-9 rounded-xl flex-1 min-w-0"}),e.jsx(G,{placeholder:"Website URL (optional)",value:z,onChange:s=>H(s.target.value),className:"text-xs h-9 rounded-xl flex-1 min-w-0"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(ne,{value:E,onValueChange:s=>{O(s),K(N),s!=="single-show"&&Q(null)},children:[e.jsx(le,{className:"text-sm h-9 w-40 rounded-xl",children:e.jsx(oe,{placeholder:"No type"})}),e.jsxs(ie,{children:[e.jsx(F,{value:N,children:"No type"}),ye.map(s=>e.jsx(F,{value:s.value,children:s.label},s.value))]})]}),E!==N&&M[E]&&e.jsxs(ne,{value:$,onValueChange:K,children:[e.jsx(le,{className:"text-sm h-9 w-36 rounded-xl",children:e.jsx(oe,{placeholder:"No tier"})}),e.jsxs(ie,{children:[e.jsx(F,{value:N,children:"No tier"}),M[E].map(s=>e.jsx(F,{value:s.value,children:s.label},s.value))]})]}),E==="single-show"&&e.jsx(Ue,{shows:g,value:ee,onChange:Q}),e.jsx(de,{value:se,onChange:te,placeholder:"Start date"}),e.jsx(de,{value:R,onChange:ae,placeholder:"End date"})]})]})]}),e.jsx("div",{className:"flex sm:flex-col items-stretch sm:items-center justify-center gap-1 flex-shrink-0 pt-2 sm:pt-0 sm:pl-2 border-t sm:border-t-0 sm:border-l border-border sm:self-stretch",children:e.jsxs(P,{onClick:ze,disabled:S||!U.trim(),className:"w-full sm:w-auto
3sm:h-full sm:min-h-[64px] rounded-xl px-4 flex sm:flex-col items-center justify-center gap-1.5 sm:gap-1",children:[S?e.jsx(Z,{className:"h-4 w-4 animate-spin"}):e.jsx(ue,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs sm:text-[10px] font-semibold uppercase tracking-wider",children:"Add sponsor"})]})})]})]}),o.length===0&&e.jsx("div",{className:"bg-card border border-dashed border-border rounded-2xl py-12 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No sponsors yet. Add one above to get started."})}),(()=>{var d;const s=["long-term","mid-term","short-term","single-show","untyped"],r=a=>a==="untyped"?"No type":Ss[a]??a,t=a=>{switch(a){case"long-term":return"Annual or multi-year supporters";case"mid-term":return"Multi-month campaigns";case"short-term":return"Short campaign sponsors";case"single-show":return"Sponsors tied to one specific show";case"expired":return"End date has passed - automatically hidden from the website";default:return"Assign a sponsorship package to organise these"}},i=[...s.map(a=>({key:a,items:me.filter(k=>a==="untyped"?!k.sponsorship_type:k.sponsorship_type===a)})).map(a=>({key:a.key,label:r(a.key),count:a.items.length,items:a.items}))];re.length>0&&i.push({key:"expired",label:"Expired",count:re.length,items:re,expired:!0});const h=((d=i.find(a=>a.count>0))==null?void 0:d.key)??"long-term";return e.jsxs(Te,{defaultValue:h,className:"w-full",children:[e.jsx(De,{className:"mb-4 flex-wrap h-auto gap-1 justify-start",children:i.map(a=>e.jsxs(pe,{value:a.key,className:"gap-2",children:[e.jsx("span",{className:L("h-2 w-2 rounded-full",es[a.key]),"aria-hidden":!0}),a.label,e.jsxs("span",{className:"text-[10px] font-normal text-muted-foreground",children:["(",a.count,")"]})]},a.key))}),i.map(a=>{const k=!a.expired&&a.key!=="untyped"&&a.key!=="expired"?M[a.key]:void 0,I=k?[...k.map(v=>({key:v.value,label:v.label,items:a.items.filter(A=>A.sponsorship_tier===v.value)})),{key:"__no_tier__",label:"No tier",items:a.items.filter(v=>!v.sponsorship_tier||!k.some(A=>A.value===v.sponsorship_tier))}]:null;return e.jsxs(he,{value:a.key,className:"mt-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:t(a.key)}),a.items.length===0?e.jsx("div",{className:"bg-card border border-dashed border-border rounded-2xl py-10 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No sponsors in this category."})}):I?e.jsx("div",{className:"space-y-6",children:I.map(v=>v.items.length===0?null:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2 px-1",children:[e.jsx("h4",{className:"font-display text-sm font-bold text-foreground",children:v.label}),e.jsxs("span",{className:"text-[10px] font-normal text-muted-foreground",children:["(",v.items.length,")"]})]}),e.jsx("div",{className:"space-y-2",children:v.items.map(A=>ke(A,a.expired))})]},v.key))}):e.jsx("div",{className:"space-y-2",children:a.items.map(v=>ke(v,a.expired))})]},a.key)})]})})()]})]}),e.jsx(xe,{open:!!b,onOpenChange:s=>!s&&D(null),children:e.jsxs(ge,{children:[e.jsxs(fe,{children:[e.jsx(be,{children:"Delete sponsor"}),e.jsx(je,{children:"Delete this sponsor?"})]}),e.jsxs(we,{children:[e.jsx(ve,{children:"Cancel"}),e.jsx(Ne,{onClick:()=>{const s=b;D(null),s&&He(s)},children:"Delete"})]})]})})]})};export{Ws 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.