1import{f as X,r as i,dB as re,dC as oe,dD as te,aH as q,aY as le,dE as ie,dF as de,dG as H,d as D,dH as ce,dI as pe,j as e,P as Z,e as ee,dJ as E,dK as ue,dL as he,dM as W,dN as me,dO as ve,dP as _,dQ as G,dR as ge,dS as be,dT as K,F as j,dU as fe,dV as U,aF as xe,G as je,dW as ye,i as Ne,o as Pe,bf as Ie,aT as we,bE as De}from"./index-JR75wn-F.js";import{D as ke,C as J,P as Q}from"./dnd.esm-CyR6C2pR.js";import"./vendor-firebase-DNzSL88b.js";import"./extends-CF3RwP-h.js";const Ve=({canEdit:p})=>{const b=X(),d=i.useMemo(()=>re(),[]),P=i.useMemo(()=>oe(te(d)),[d]),[h,k]=i.useState([]),[x,I]=i.useState([]),[g,m]=i.useState([]),[r,y]=i.useState(!0),[$,L]=i.useState(null),[F,w]=i.useState(null),R=i.useCallback(async()=>{y(!0),L(null);try{const[a,t,s]=await Promise.all([q(),le(),ie([...d])]),o=de(t,s,d);o.length>0&&await Promise.all(o.map(l=>H(l.id)));const n=new Set(o.map(l=>l.id));k(a),I(t),m(s.filter(l=>!n.has(l.id)))}catch(a){console.error("Venue planner load failed:",a),L(D(a,"venue planning"))}finally{y(!1)}},[d]);i.useEffect(()=>{R()},[R]);const z=i.useMemo(()=>ce({shows:x,plans:g,years:d}),[h,x,g,d]),A=i.useMemo(()=>pe(x,d),[x,d]),O=(a,t)=>{const s=K(a,t),o=z[s]??[];return new Set(o.filter(n=>n.type==="planned").map(n=>n.venueId))},T=async a=>{if(!p)return;const t=g;m(s=>s.filter(o=>o.id!==a)),w(null);try{await H(a)}catch(s){console.error("Remove venue plan failed:",s),m(t),w(D(s,"removing the planned venue"))}},ne=async a=>{if(!p)return;const{source:t,destination:s,draggableId:o}=a;if(!s||t.droppableId===s.droppableId&&t.index===s.index)return;const n=W(s.droppableId),l=W(t.droppableId),V=t.droppableId===E,S=s.droppableId===E,c=me(o),v=ve(o);w(null);try{if(V&&n&&c){if(_(n.year,n.month)||G(A,n.year,n.month).has(c)||O(n.year,n.month).has(c))return;const Y=await ge(c,n.year,n.month);m(B=>[...B,{id:Y,venueId:c,year:n.year,month:n.month,createdAt:{toDate:()=>new Date}}]);return}if(v&&S){await T(v);return}if(v&&n&&l){if(l.year===n.year&&l.month===n.month||_(n.year,n.month))return;const u=g.find(f=>f.id===v);if(!u||G(A,n.year,n.month).has(u.venueId)||O(n.year,n.month).has(u.venueId))return;const B=g;m(f=>f.map(N=>N.id===v?{...N,year:n.year,month:n.month}:N));try{const f=await be(v,u.venueId,n.year,n.month);m(N=>N.map(C=>C.id===v?{...C,id:f}:C))}catch(f){throw m(B),f}}}catch(u){console.error("Venue planner drag failed:",u),w(D(u,"updating the venue plan"))}},ae=a=>e.jsxs("div",{className:"venue-planner-chip venue-planner-chip--booked",onClick:()=>b(`/shows/${a.showId}`),title:"Booked show â open show",children:[e.jsx(j,{icon:fe,className:"venue-planner-chip-lock"}),e.jsxs("div",{className:"venue-planner-chip-body",children:[e.jsx("span",{className:"venue-planner-chip-name",children:U(h,a.venueId)}),e.jsx("span",{className:"venue-planner-chip-meta",children:xe(a.date,"MMM d")})]})]},`booked-${a.showId}`),se=(a,t,s)=>e.jsx(Q,{draggableId:ye(a.planId),index:t,isDragDisabled:s,children:(o,n)=>e.jsxs("div",{ref:o.innerRef,...o.draggableProps,...o.dragHandleProps,className:`venue-planner-chip venue-planner-chip--planned${n.isDragging?" venue-planner-chip--dragging":""}`,onClick:()=>b(`/venues/${a.venueId}`),title:"Planned venue â drag to move or remove",children:[e.jsxs("div",{className:"venue-planner-chip-body",children:[e.jsx("span",{className:"venue-planner-chip-name",children:U(h,a.venueId)}),e.jsx("span",{className:"venue-planner-chip-meta",children:"Planned"})]}),p&&e.jsx("button",{type:"button",className:"venue-planner-chip-remove","aria-label":"Remove planned venue",onClick:l=>{l.stopPropagation(),T(a.planId)},children:e.jsx(j,{icon:je})})]})},a.planId);return r?e.jsx(Z,{label:"Loading venue plannerâ¦"}):$?e.jsx(ee,{title:"Venue Planning",message:$}):e.jsxs("div",{className:"venue-planner",children:[F&&e.jsx("div",{className:"venue-planner-error",role:"alert",children:F}),e.jsxs(ke,{onDragEnd:ne,children:[e.jsxs("section",{className:"venue-planner-section venue-planner-pool-section",children:[e.jsxs("div",{className:"venue-planner-section-header",children:[e.jsx("h2",{className:"venue-planner-section-title",children:"Available Venues"}),e.jsx("p",{className:"venue-planner-section-subtitle",children:p?"Drag venues into a month below. Planned venues can be moved or removed.":"View-only mode â planned venues and booked shows are shown by month."})]}),e.jsx(J,{droppableId:E,direction:"horizontal",isDropDisabled:!p,children:(a,t)=>e.jsxs("div",{ref:a.innerRef,...a.droppableProps,className:`venue-planner-pool${t.isDraggingOver?" venue-planner-pool--active":""}`,children:[h.length===0?e.jsx("p",{className:"venue-planner-empty",children:"No venues yet â add venues in the Directory tab."}):h.map((s,o)=>e.jsx(Q,{draggableId:ue(s.id),index:o,isDragDisabled:!p,children:(n,l)=>e.jsx("div",{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,className:`venue-planner-chip venue-planner-chip--pool${l.isDragging?" venue-planner-chip--dragging":""}`,onClick:()=>b(`/venues/${s.id}`),children:e.jsx("span",{className:"venue-planner-chip-name",children:s.name})})},s.id)),a.placeholder]})})]}),P.map(({year:a,months:t})=>e.jsxs("section",{className:"venue-planner-section",children:[e.jsx("h2",{className:"venue-planner-year",children:a}),e.jsx("div",{className:"venue-planner-month-grid",children:t.map(({month:s,label:o})=>{const n=K(a,s),l=z[n]??[],V=l.filter(c=>c.type==="booked"),S=l.filter(c=>c.type==="planned");return e.jsxs("div",{className:"venue-planner-month",children:[e.jsx("p",{className:"venue-planner-month-label",children:o}),e.jsx(J,{droppableId:he(a,s),isDropDisabled:!p,children:(c,v)=>e.jsxs("div",{ref:c.innerRef,...c.droppableProps,className:`venue-planner-month-body${v.isDraggingOver?" venue-planner-month-body--active":""}`,children:[l.length===0&&e.jsx("p",{className:"venue-planner-month-empty",children:"Drop here"}),V.map(u=>ae(u)),S.map((u,M)=>se(u,M,!p)),c.placeholder]})})]},n)})})]},a))]})]})},Ee=()=>{const p=X(),{canEdit:b}=Ne(),[d,P]=i.useState("directory"),[h,k]=i.useState([]),[x,I]=i.useState(!0),[g,m]=i.useState(null);return i.useEffect(()=>{q().then(r=>{k(r),m(null),I(!1)}).catch(r=>{console.error("Venue list load failed:",r),m(D(r,"venues")),I(!1)})},[]),x?e.jsx(Z,{label:"Loading venuesâ¦"}):g?e.jsx(ee,{title:"Venues",message:g}):e.jsxs("div",{children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Venues"}),e.jsxs("p",{className:"text-secondary mb-2",style:{fontSize:"0.85rem"},children:[h.length," venue",h.length!==1?"s":""]}),e.jsxs("div",{className:"venue-planner-tabs",children:[e.jsx("button",{type:"button",className:`venue-planner-tab${d==="directory"?" venue-planner-tab--active":""}`,onClick:()=>P("directory"),children:"Directory"}),e.jsx("button",{type:"button",className:`venue-planner-tab${d==="plan"?" venue-planner-tab--active":""}`,onClick:()=>P("plan"),children:"Monthly Plan"})]})]}),b&&d==="directory"&&e.jsxs("button",{className:"btn btn-primary d-flex align-items-center gap-2",onClick:()=>p("/venues/new"),children:[e.jsx(j,{icon:Pe}),"Add New"]})]}),d==="plan"?e.jsx(Ve,{canEdit:b}):h.length===0?e.jsxs("div",{className:"d-flex flex-column align-items-center justify-content-center",style:{padding:"4rem 2rem",gap:"0.75rem"},children:[e.jsx(j,{icon:Ie,style:{fontSize:"2rem",color:"#2e2e2e"}}),e.jsx("p",{style:{color:"#606060",marginBottom:0},children:"No venues yet â add your first one!"}),b&&e.jsx("button",{className:"btn btn-primary mt-1",onClick:()=>p("/venues/new"),children:"Add New"})]}):e.jsx("div",{className:"d-flex flex-column gap-2",children:h.map(r=>{var y;return e.jsx("div",{className:"card",style:{cursor:"pointer"},onClick:()=>p(`/venues/${r.id}`),children:e.jsx("div",{className:"card-body",style:{padding:"1rem 1.25rem"},children:e.jsx("div",{className:"d-flex align-items-start justify-content-between gap-2",children:e.jsxs("div",{className:"flex-grow-1",children:[e.jsx("p",{style:{fontFamily:"'Bebas Neue', sans-serif",fontSize:"1.2rem",letterSpacing:"0.04em",color:"#f0f0f0",marginBottom:"0.3rem"},children:r.name}),r.address&&e.jsxs("div",{className:"d-flex align-items-center gap-1 mb-1",children:[e.jsx(j,{icon:we,style:{color:"#606060",fontSize:"0.72rem"}}),e.jsx("span",{style:{fontSize:"0.8rem",color:"#a0a0a0"},children:r.address})]}),r.contacts&&r.contacts.length>0&&e.jsxs("div",{className:"d-flex align-items-center gap-1",children:[e.jsx(j,{icon:De,style:{color:"#606060",fontSize:"0.72rem"}}),e.jsxs("span",{style:{fontSize:"0.8rem",color:"#606060"},children:[r.contacts[0].name,r.contacts[0].role&&` · ${r.contacts[0].role}`,r.contacts.length>1&&` +${r.contacts.length-1} more`]})]}),((y=r.notes)==null?void 0:y.trim())&&e.jsx("p",{style:{fontSize:"0.8rem",color:"#808080",marginBottom:0,marginTop:"0.35rem",whiteSpace:"pre-wrap",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:r.notes.trim()})]})})})},r.id)})})]})};export{Ee 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.