1import{u as A,cv as z,r as p,dN as V,dD as W,c7 as r,j as e,e5 as D,q as S,C as k,e as b,B as w,b7 as H,a7 as I,a8 as L,a9 as _,as as $,w as B,x as P,y as R,z as q,al as F,b_ as G,E as T,o as M,a as Y}from"./index-CA5JHsqG.js";import{a as J,f as K}from"./useSocialOps-zLEFwb3C.js";import{S as Q}from"./scroll-area-DcWx6Ni1.js";import{e as U}from"./endOfWeek-CEnybBYN.js";import{s as X}from"./startOfMonth-Cghs6IBH.js";import{e as Z}from"./eachDayOfInterval-p-WlsofW.js";import{C as ee}from"./chevron-left-BDTN_0sH.js";import{s as se}from"./subWeeks-GbLPuPIt.js";import{s as te}from"./subMonths-B77ZWpdm.js";import{a as ae}from"./addWeeks-oriAtfwI.js";import{a as ne}from"./addMonths-CFn304Xr.js";import{i as E}from"./isSameDay-DQI_hb4m.js";import{i as re}from"./isSameMonth-KR9uH-HM.js";import{V as ce}from"./video-S5K381hs.js";import{S as ie}from"./send-9yO38K0i.js";import{M as de}from"./message-square-DgtfTfk9.js";const C={reddit:e.jsx(de,{className:"h-3 w-3 text-orange-500"}),x:e.jsx(ie,{className:"h-3 w-3 text-sky-500"}),youtube:e.jsx(ce,{className:"h-3 w-3 text-red-500"})};function De(){const d=A(),{isAdmin:j,loading:f}=z(),[i,l]=p.useState("week"),[n,a]=p.useState(new Date),[c,t]=p.useState(null),x=p.useMemo(()=>i==="week"?{start:V(n,{weekStartsOn:0}),end:U(n,{weekStartsOn:0})}:{start:X(n),end:W(n)},[n,i]),y=p.useMemo(()=>Z(x),[x]),{data:o}=J({dateRange:x}),{data:g}=K(),N=p.useMemo(()=>{const s={};return g?.forEach(m=>{if(m.scheduled_at){const h=r(new Date(m.scheduled_at),"yyyy-MM-dd");s[h]||(s[h]={content:[],tasks:[]}),s[h].content.push(m)}}),o?.forEach(m=>{const h=r(new Date(m.due_at),"yyyy-MM-dd");s[h]||(s[h]={content:[],tasks:[]}),s[h].tasks.push(m)}),s},[g,o]),v=()=>{a(i==="week"?se(n,1):te(n,1))},O=()=>{a(i==="week"?ae(n,1):ne(n,1))},u=c?N[r(c,"yyyy-MM-dd")]:null;return f?e.jsx(D,{children:e.jsxs("div",{className:"container mx-auto p-6 space-y-4",children:[e.jsx(S,{className:"h-8 w-48"}),e.jsx(S,{className:"h-[600px] w-full"})]})}):j?e.jsx(D,{children:e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>d("/admin/social-ops"),children:e.jsx(H,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Calendar"}),e.jsx("p",{className:"text-muted-foreground",children:"View scheduled content and tasks"})]})]})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(I,{value:i,onValueChange:s=>l(s),children:e.jsxs(L,{children:[e.jsx(_,{value:"week",children:"Week"}),e.jsx(_,{value:"month",children:"Month"})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:v,children:e.jsx(ee,{className:"h-4 w-4"})}),e.jsx("span",{className:"font-medium min-w-[150px] text-center",children:i==="week"?`${r(x.start,"MMM d")} - ${r(x.end,"MMM d, yyyy")}`:r(n,"MMMM yyyy")}),e.jsx(w,{variant:"ghost",size:"icon",onClick:O,children:e.jsx($,{className:"h-4 w-4"})}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>a(new Date),children:"Today"})]})]}),i==="week"?e.jsx(le,{days:y,itemsByDate:N,onDayClick:t}):e.jsx(oe,{days:y,currentDate:n,itemsByDate:N,onDayClick:t}),e.jsx(B,{open:!!c,onOpenChange:()=>t(null),children:e.jsxs(P,{className:"w-[400px] sm:max-w-[400px]",children:[e.jsx(R,{children:e.jsx(q,{children:c&&r(c,"EEEE, MMMM d, yyyy")})}),e.jsx("div",{className:"mt-4 mb-4",children:e.jsxs(w,{className:"w-full",onClick:()=>{c&&d(`/admin/social-ops/content?scheduleDate=${r(c,"yyyy-MM-dd")}`)},children:[e.jsx(F,{className:"h-4 w-4 mr-2"}),"Create Content for This Day"]})}),e.jsx(Q,{className:"h-[calc(100vh-180px)]",children:u?e.jsxs("div",{className:"space-y-6",children:[u.content.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-2 flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),"Scheduled Content"]}),e.jsx("div",{className:"space-y-2",children:u.content.map(s=>e.jsx(k,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>d(`/admin/social-ops/content/${s.id}`),children:e.jsxs(b,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[C[s.platform],e.jsx("span",{className:"text-xs text-muted-foreground",children:s.scheduled_at&&r(new Date(s.scheduled_at),"HH:mm")}
1)]}),e.jsx("p",{className:"font-medium text-sm",children:s.title}),e.jsx(T,{variant:"outline",className:"mt-1 text-xs capitalize",children:s.type})]})},s.id))})]}),u.tasks.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-2",children:["Tasks (",u.tasks.length,")"]}),e.jsx("div",{className:"space-y-2",children:u.tasks.sort((s,m)=>new Date(s.due_at).getTime()-new Date(m.due_at).getTime()).map(s=>e.jsx(k,{children:e.jsxs(b,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s.content_item&&C[s.content_item.platform],e.jsx("span",{className:"font-mono text-xs",children:r(new Date(s.due_at),"HH:mm")})]}),e.jsx(T,{variant:"secondary",className:M("text-xs",s.status==="done"&&"bg-green-500/10 text-green-600",s.status==="skipped"&&"bg-muted text-muted-foreground"),children:s.status})]}),e.jsx("p",{className:"text-sm font-medium",children:s.assigned_account?.persona_name}),e.jsxs("p",{className:"text-xs text-muted-foreground capitalize",children:[s.task_type.replace("_"," ")," ⢠",s.content_item?.title]})]})},s.id))})]})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No scheduled content or tasks for this day."})})]})})]})}):e.jsx(D,{children:e.jsx("div",{className:"container mx-auto p-6",children:e.jsx(k,{children:e.jsxs(b,{className:"p-8 text-center",children:[e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:"You need admin access to view this page."})]})})})})}function le({days:d,itemsByDate:j,onDayClick:f}){const i=new Date;return e.jsx("div",{className:"grid grid-cols-7 gap-2",children:d.map(l=>{const n=r(l,"yyyy-MM-dd"),a=j[n],c=E(l,i);return e.jsxs(k,{className:M("min-h-[150px] cursor-pointer transition-colors hover:bg-muted/50",c&&"ring-2 ring-primary"),onClick:()=>f(l),children:[e.jsx(Y,{className:"p-2 pb-1",children:e.jsx("div",{className:M("text-sm font-medium",c&&"text-primary"),children:r(l,"EEE d")})}),e.jsxs(b,{className:"p-2 pt-0 space-y-1",children:[a?.content.slice(0,3).map(t=>e.jsxs("div",{className:"flex items-center gap-1 text-xs bg-primary/10 rounded px-1 py-0.5",children:[C[t.platform],e.jsx("span",{className:"truncate",children:t.title})]},t.id)),a?.tasks&&a.tasks.length>0&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",a.tasks.length," task",a.tasks.length>1?"s":""]}),a?.content&&a.content.length>3&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["+",a.content.length-3," more"]})]})]},n)})})}function oe({days:d,currentDate:j,itemsByDate:f,onDayClick:i}){const l=new Date,a=d[0].getDay(),c=[...Array(a).fill(null),...d];return e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"grid grid-cols-7 gap-1",children:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].map(t=>e.jsx("div",{className:"text-center text-sm font-medium text-muted-foreground py-2",children:t},t))}),e.jsx("div",{className:"grid grid-cols-7 gap-1",children:c.map((t,x)=>{if(!t)return e.jsx("div",{className:"h-20"},`empty-${x}`);const y=r(t,"yyyy-MM-dd"),o=f[y],g=E(t,l),N=re(t,j);return e.jsxs("div",{className:M("h-20 p-1 border rounded cursor-pointer transition-colors hover:bg-muted/50",!N&&"opacity-50",g&&"ring-2 ring-primary"),onClick:()=>i(t),children:[e.jsx("div",{className:M("text-xs font-medium mb-1",g&&"text-primary"),children:r(t,"d")}),e.jsxs("div",{className:"space-y-0.5 overflow-hidden",children:[o?.content.slice(0,2).map(v=>e.jsxs("div",{className:"flex items-center gap-0.5 text-[10px] bg-primary/10 rounded px-0.5 truncate",children:[C[v.platform],e.jsx("span",{className:"truncate",children:v.title})]},v.id)),((o?.content?.length||0)>2||(o?.tasks?.length||0)>0)&&e.jsxs("div",{className:"text-[10px] text-muted-foreground",children:["+",(o?.content?.length||0)-2+(o?.tasks?.length||0)," more"]})]})]},y)})})]})}export{De 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.