1import{cl as S,cm as T,r as h,f as P,j as e,co as V,bZ as c,m,M as j,J as f,s as B}from"./index-q_lmBneL.js";import{T as O,a as q,b,c as y}from"./tabs-DtWbWAqM.js";import{C as N,d as v}from"./card-DpDgnJCl.js";import{u as A,a as D,P as E,C as F}from"./CampaignDetail-BH_2xjBv.js";import{L as C}from"./loader-circle-CYxiN9Q_.js";import"./accordion-Dz5ETJYc.js";import"./index-DWE3xqpF.js";import"./dialog-C0RHa-0_.js";import"./input-dMEYRult.js";import"./jspdf.es.min-DMhPQwDn.js";import"./arrow-left-CmT9Ikwk.js";import"./pencil-hbNeCWia.js";import"./eye-off-CCIGUIzt.js";import"./download-DZuskDI3.js";import"./upload-Bo55_LPi.js";import"./trash-2-CeLXw4II.js";import"./save-CgdwMioE.js";import"./lock-B1_v-BKY.js";import"./lock-open-CYudfz9I.js";import"./user-check-D7anktZO.js";import"./star-3dRx5pLS.js";import"./zap-CvdONQIj.js";import"./list-checks-BvBCC_dV.js";import"./phone-BvLPYZeo.js";import"./mail-BDTA2WIb.js";import"./shield-C_bqkhsJ.js";import"./copy-CBB2MTMU.js";import"./label-CD3sLOd5.js";import"./alert-dialog-CLDv3CFn.js";import"./dateUtils-D3RDZiN1.js";import"./parseISO-ChBsMj5u.js";import"./plus-uLP-Nf2t.js";import"./sticky-note-BeImrRZE.js";import"./linkedin-C7f-avGp.js";const w={draft:"bg-slate-50 text-slate-700 border-slate-200",active:"bg-green-50 text-green-700 border-green-200",paused:"bg-amber-50 text-amber-700 border-amber-200",completed:"bg-blue-50 text-blue-700 border-blue-200"},ye=()=>{const{effectiveClientId:l}=S(),{flags:k,isLoading:_}=T(),[n,x]=h.useState(null),[o,p]=h.useState(null),{data:d}=P({queryKey:["client-delivery-project",l],queryFn:async()=>{const{data:t,error:i}=await B.from("delivery_projects").select("id").eq("client_id",l).order("created_at",{ascending:!1}).limit(1).maybeSingle();if(i)throw i;return t},enabled:!!l}),r=(d==null?void 0:d.id)||"",{data:s,isLoading:L}=A(r),{data:a,isLoading:M}=D(r),u=n?(s==null?void 0:s.find(t=>t.id===n.id))||n:null,g=o?(a==null?void 0:a.find(t=>t.id===o.id))||o:null;return!_&&!k.client_campaigns_enabled?e.jsx(V,{to:"/portal/client/dashboard",replace:!0}):u&&r?e.jsx("div",{className:"space-y-4",children:e.jsx(E,{playbook:u,projectId:r,onBack:()=>x(null)})}):g&&r?e.jsx(F,{campaign:g,projectId:r,onBack:()=>p(null),readOnly:!0}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground",children:"Campaigns"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"View playbooks and campaigns for your project"})]}),e.jsxs(O,{defaultValue:"playbooks",className:"space-y-4",children:[e.jsxs(q,{children:[e.jsxs(b,{value:"playbooks",className:"gap-1.5",children:[e.jsx(c,{className:"w-4 h-4"}),"Playbooks",((s==null?void 0:s.length)??0)>0&&e.jsx(m,{variant:"secondary",className:"ml-1 h-4 px-1 text-[10px]",children:s.length})]}),e.jsxs(b,{value:"campaigns",className:"gap-1.5",children:[e.jsx(j,{className:"w-4 h-4"}),"Campaigns",((a==null?void 0:a.length)??0)>0&&e.jsx(m,{variant:"secondary",className:"ml-1 h-4 px-1 text-[10px]",children:a.length})]})]}),e.jsx(y,{value:"playbooks",children:e.jsx(N,{children:e.jsx(v,{className:"pt-6",children:L?e.jsx("div",{className:"text-center py-8",children:e.jsx(C,{className:"w-6 h-6 mx-auto animate-spin text-muted-foreground"})}):s!=null&&s.length?e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:s.map(t=>e.jsxs("button",{onClick:()=>x(t),className:"text-left p-4 rounded-lg border bg-card hover:bg-muted/50 transition-colors",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:t.sales_play_name}),t.target_audience&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:t.target_audience}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:f(new Date(t.created_at),"MMM d, yyyy")})]},t.id))}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(c,{className:"w-10 h-10 mx-auto mb-3 text-muted-foreground opacity-30"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No playbooks shared yet"})]})})})}),e.jsx(y,{value:"campaigns",children:e.jsx(N,{children:e.jsx(v,{className:"pt-6",children:M?e.jsx("div",{className:"text-center py-8",children:e.jsx(C,{className:"w-6 h-6 mx-auto animate-spin text-muted-foreground"})}):a!=null&&a.length?e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:a.map(t=>{const i=w[t.status]||w.draft;return e.jsx("button",{onClick:()=>p(t),className:"text-left p-4 rounded-lg border bg-card hover:bg-muted/50 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:t.name}),t.playbook_name&&e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx(c,{className:"w-3 h-3 text-muted-foreground shrink-0"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.playbook_name})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:f(new Date(t.created_at),"MMM d, yyyy")})]}),e.jsx(m,{variant:"outline",className:`shrink-0 text-xs font-medium ${i}`,children:t.status.charAt(0).toUpperCase()+t.status.slice(1)})]})},t.id)})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(j,{className:"w-10 h-10 mx-auto mb-3 text-muted-foreground opacity-30"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No campaigns shared yet"})]})})})})]})]})};export{ye 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.