1import{j as e,r as m}from"./ui-i0JM3VPo.js";import{f as et,d as z,b as S,L as re,F as je,aI as bt,aT as vt,e as q,ad as wt,B as y,am as le,S as yt,q as tt,Z as Nt,ac as kt,W as st,t as u,V as fe,ay as Te,az as Re,aA as Le,aB as Ie,r as v,R as T,a1 as me,s as K,w as X,x as Q,y as Z,z as W,aD as Be,G as Ct,X as at,p as St,P as ze,Y as Ee,aU as it,a as Et,aC as _t,C as nt,j as rt}from"./index-Dkv7DG6j.js";import{C as H,a as oe,b as de,d as Y}from"./card-BN7YMoCL.js";import{a as At}from"./use-chart-colors-CF-OW0Zj.js";import{U as Tt}from"./users-S_Wu2Pnh.js";import{T as Rt}from"./workflow-DA1hBejn.js";import{M as Lt,P as It,a as Bt}from"./PieChart-CzCO3y4a.js";import{T as Dt,f as De}from"./use-document-hub-controller-E-jtA-8I.js";import{R as Ce,C as Ue,X as Ve,Y as qe,T as Se,B as Ge,a as He}from"./generateCategoricalChart-CfNuitmw.js";import{B as We}from"./BarChart-CHtIuI3r.js";import{I as lt,e as Ft,d as Pt,F as Mt}from"./Dashboard-DxHm7vVV.js";import{S as ne}from"./switch-BIWfB82T.js";import{C as ct}from"./calendar-days-BOUV7-IB.js";import{L as Ot,C as ot}from"./tooltip-CFojKnbH.js";import{U as $t}from"./upload-BkQUkwE5.js";import{B as dt,i as mt,a as Fe,S as xt,c as zt,d as Ut}from"./SiteRenderer-B3j9qniX.js";import{u as Vt}from"./use-auth-token-CC681kE8.js";import{G as Pe}from"./globe-CU-qsUxU.js";import{A as qt}from"./arrow-down-B5Pem3X8.js";import"./SpreadsheetEditor-B-YErdHF.js";import{C as Gt}from"./format-56wLaaDX.js";import"./vendor-DE2u6Cep.js";import"./_baseAssignValue-BqITUFqV.js";import"./tiny-invariant-BaFNuDhB.js";import"./extends-CF3RwP-h.js";import"./alert-dialog-BWGz0WvX.js";import"./checkbox-DQDdJgoA.js";import"./circle-x-CeF-4pnB.js";import"./refresh-cw-BUP6IyOH.js";import"./zap-DKiVXM_E.js";import"./path-CXeFd1JH.js";import"./string-D5IbFMk5.js";import"./band-CquvqAHh.js";import"./init-Dmth1JHB.js";import"./ordinal-DILIJJjt.js";import"./linear-2ZJu5wfc.js";import"./time-Cirizg45.js";import"./array-BKyUJesY.js";import"./line-C7httTAJ.js";import"./CitationSidePanel-BICJYMft.js";import"./shield-D5pyp__a.js";import"./message-square-plus-DtpGskHn.js";import"./multipleChoiceHelpers-D8CAEynu.js";import"./lock-vnIczjf0.js";import"./server-DqgoyXy7.js";import"./map-pin-CttiNrIe.js";import"./star-Cs73K0eY.js";import"./clock-3-BSbJvu1q.js";import"./tabs-y-kr09sh.js";import"./SubscriptionPaywall-2Vxepp3u.js";import"./registryCsv-TJ4yzQt6.js";import"./OnboardingChat-bqs4kDN8.js";import"./arrow-right-B6mWFZhr.js";import"./dayjs.min-BtIAEy0j.js";import"./immer.esm-CVTVa0NE.js";import"./__vite-browser-external-BL-VM64D.js";/** 2 * @license lucide-react v0.511.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Ht=[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]],be=et("megaphone",Ht);/** 7 * @license lucide-react v0.511.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Wt=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],Yt=et("wand-sparkles",Wt);function ee({title:t,value:i,subtitle:a,icon:s}){return e.jsx(H,{className:"bg-white/5 border-white/10",children:e.jsx(Y,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-white/60 uppercase tracking-wide",children:t}),e.jsx("p",{className:"text-2xl font-bold text-white mt-1",children:i}),a&&e.jsx("p",{className:"text-xs text-white/50 mt-0.5",children:a})]}),e.jsx("div",{className:"h-10 w-10 rounded-lg bg-white/10 flex items-center justify-center",children:e.jsx(s,{className:"h-5 w-5 text-white/70"})})]})})})}function ba({workspaceId:t}){const i=At(6),a=z(S.marketing.queries.dashboardStats,{workspaceId:t});if(!a)return e.jsxs("div",{className:"flex items-center justify-center h-full",children:[e.jsx(re,{className:"h-8 w-8 animate-spin text-white/50"}),e.jsx("span",{className:"ml-3 text-white/50",children:"Loading marketing dashboard..."})]});const s=Object.entries(a.typeBreakdown).map(([h,p])=>({name:h.charAt(0).toUpperCase()+h.slice(1),value:p})),r=Object.entries(a.statusBreakdown).map(([h,p])=>({name:h.charAt(0).toUpperCase()+h.slice(1),value:p})),d=Object.entries(a.sourceBreakdown).sort((h,p)=>p[1]-h[1]).slice(0,6).map(([h,p])=>({name:h,value:p})),x=a.totalEmailsSent>0?(a.totalEmailsOpened/a.totalEmailsSent*100).toFixed(1)+"%":"â",j=a.totalEmailsSent>0?(a.totalEmailsClicked/a.totalEmailsSent*100).toFixed(1)+"%":"â";return e.jsxs("div",{className:"h-full overflow-y-auto p-4 md:p-6 space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Marketing Dashboard"}),e.jsx("p",{className:"text-sm text-white/60 mt-1",children:"Performance overview and ke
11y metrics"})]})}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(ee,{title:"Total Campaigns",value:a.totalCampaigns,subtitle:`${a.activeCampaigns} active`,icon:be}),e.jsx(ee,{title:"Audiences",value:a.totalAudiences,subtitle:`${a.totalAudienceContacts} contacts`,icon:Tt}),e.jsx(ee,{title:"Conversions",value:a.totalConversions,subtitle:`${a.recentConversions} last 30 days`,icon:Rt}),e.jsx(ee,{title:"Form Submissions",value:a.totalFormSubmissions,subtitle:`${a.totalForms} forms`,icon:je})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(ee,{title:"Emails Sent",value:a.totalEmailsSent,icon:bt}),e.jsx(ee,{title:"Open Rate",value:x,icon:vt}),e.jsx(ee,{title:"Click Rate",value:j,icon:Lt}),e.jsx(ee,{title:"Conversion Value",value:`$${a.totalConversionValue.toLocaleString()}`,icon:Dt})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(H,{className:"bg-white/5 border-white/10",children:[e.jsx(oe,{className:"pb-2",children:e.jsx(de,{className:"text-sm font-medium text-white/80",children:"Campaign Status"})}),e.jsx(Y,{children:r.length>0?e.jsx(Ce,{width:"100%",height:200,children:e.jsxs(We,{data:r,children:[e.jsx(Ue,{strokeDasharray:"3 3",stroke:"var(--border)"}),e.jsx(Ve,{dataKey:"name",tick:{fill:"var(--muted-foreground)",fontSize:11}}),e.jsx(qe,{tick:{fill:"var(--muted-foreground)",fontSize:11}}),e.jsx(Se,{contentStyle:{backgroundColor:"var(--popover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--foreground)"}}),e.jsx(Ge,{dataKey:"value",radius:[4,4,0,0],children:r.map((h,p)=>e.jsx(He,{fill:i[p%i.length]},p))})]})}):e.jsx("div",{className:"h-[200px] flex items-center justify-center text-white/40 text-sm",children:"No campaigns yet"})})]}
11),e.jsxs(H,{className:"bg-white/5 border-white/10",children:[e.jsx(oe,{className:"pb-2",children:e.jsx(de,{className:"text-sm font-medium text-white/80",children:"Campaign Types"})}),e.jsx(Y,{children:s.length>0?e.jsx(Ce,{width:"100%",height:200,children:e.jsxs(It,{children:[e.jsx(Bt,{data:s,cx:"50%",cy:"50%",outerRadius:70,dataKey:"value",label:({name:h,percent:p})=>`${h} ${(p*100).toFixed(0)}%`,children:s.map((h,p)=>e.jsx(He,{fill:i[p%i.length]},p))}),e.jsx(Se,{contentStyle:{backgroundColor:"var(--popover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--foreground)"}})]})}):e.jsx("div",{className:"h-[200px] flex items-center justify-center text-white/40 text-sm",children:"No campaigns yet"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(H,{className:"bg-white/5 border-white/10",children:[e.jsx(oe,{className:"pb-2",children:e.jsx(de,{className:"text-sm font-medium text-white/80",children:"Top Sources"})}),e.jsx(Y,{children:d.length>0?e.jsx(Ce,{width:"100%",height:200,children:e.jsxs(We,{data:d,layout:"vertical",children:[e.jsx(Ue,{strokeDasharray:"3 3",stroke:"var(--border)"}),e.jsx(Ve,{type:"number",tick:{fill:"var(--muted-foreground)",fontSize:11}}),e.jsx(qe,{dataKey:"name",type:"category",tick:{fill:"var(--muted-foreground)",fontSize:11},width:80}),e.jsx(Se,{contentStyle:{backgroundColor:"var(--popover)",border:"1px solid var(--border)",borderRadius:8,color:"var(--foreground)"}}),e.jsx(Ge,{dataKey:"value",fill:i[0],radius:[0,4,4,0]})]})}):e.jsx("div",{className:"h-[200px] flex items-center justify-center text-white/40 text-sm",children:"No source data yet"})})]}
11),e.jsxs(H,{className:"bg-white/5 border-white/10",children:[e.jsx(oe,{className:"pb-2",children:e.jsx(de,{className:"text-sm font-medium text-white/80",children:"Top Campaigns"})}),e.jsx(Y,{children:a.topCampaigns.length>0?e.jsx("div",{className:"space-y-3",children:a.topCampaigns.map((h,p)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-xs text-white/40 w-4",children:[p+1,"."]}),e.jsx("span",{className:"text-sm text-white truncate",children:h.name}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${h.status==="active"?"bg-green-500/20 text-green-300":h.status==="draft"?"bg-yellow-500/20 text-yellow-300":"bg-white/10 text-white/60"}`,children:h.status})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-white/50 shrink-0",children:[e.jsxs("span",{children:[h.sent," sent"]}),e.jsxs("span",{children:[h.opened," opened"]})]})]},h._id))}):e.jsx("div",{className:"h-[200px] flex items-center justify-center text-white/40 text-sm",children:"No campaigns yet"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(H,{
11className:"bg-white/5 border-white/10",children:[e.jsx(oe,{className:"pb-2",children:e.jsx(de,{className:"text-sm font-medium text-white/80",children:"Top Forms"})}),e.jsx(Y,{children:a.topForms.length>0?e.jsx("div",{className:"space-y-3",children:a.topForms.map((h,p)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-xs text-white/40 w-4",children:[p+1,"."]}),e.jsx(je,{className:"h-3.5 w-3.5 text-white/50"}),e.jsx("span",{className:"text-sm text-white truncate",children:h.formName})]}),e.jsxs("span",{className:"text-xs text-white/50 shrink-0",children:[h.submissions," submissions"]})]},p))}):e.jsx("div",{className:"py-8 text-center text-white/40 text-sm",children:"No forms yet"})})]}),e.jsxs(H,{className:"bg-white/5 border-white/10",children:[e.jsx(oe,{className:"pb-2",children:e.jsx(de,{className:"text-sm font-medium text-white/80",children:"Quick Stats"})}),e.jsx(Y,{children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-white/60",children:"Draft campaigns"}),e.jsx("span",{className:"text-white font-medium",children:a.draftCampaigns})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-white/60",children:"Pending tasks"}),e.jsx("span",{className:"text-white font-medium",children:a.pendingTasks})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-white/60",children:"Active campaigns"}),e.jsx("span",{className:"text-white font-medium",children:a.activeCampaigns})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-white/60",children:"Recent emails sent (30d)"}),e.jsx("span",{className:"text-white font-medium",children:a.recentEmailsSent})]}),e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-white/60",children:"Total audience contacts"}),e.jsx("span",{className:"text-white font-medium",children:a.totalAudienceContacts})]})]})})]})]})]})}const _e=typeof window<"u"?window.location.origin:"";function xe(t){if(!t)return"";const i=new Date(t),a=s=>String(s).padStart(2,"0");return`${i.getFullYear()}-${a(i.getMonth()+1)}-${a(i.getDate())}T${a(i.getHours())}:${a(i.getMinutes())}`}function Ae(t){if(!t)return;const i=new Date(t).getTime();return Number.isFinite(i)?i:void 0}function Ye({storageId:t,onPickFile:i,onClear:a,uploading:s,label:r}){const d=z(S.crmEvents.queries.getStorageUrl,t?{storageId:t}:"skip"),x=m.useRef(null);return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:r}),d?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("img",{src:d,alt:r,className:"h-16 w-28 object-cover rounded border border-border"}),e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>{var j;return(j=x.current)==null?void 0:j.click()},disabled:s,children:[e.jsx($t,{className:"h-3.5 w-3.5 mr-1.5"}),"Replace"]}),e.jsxs(y,{variant:"ghost",size:"sm",onClick:a,disabled:s,children:[e.jsx(at,{className:"h-3.5 w-3.5 mr-1.5"}),"Remove"]})]}):e.jsxs(y,{variant:"outline",size:"sm",onClick:()=>{var j;return(j=x.current)==null?void 0:j.click()},disabled:s,children:[e.jsx(lt,{className:"h-3.5 w-3.5 mr-1.5"}),s?"Uploading...":"Upload image"]}),e.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",className:"hidden",onChange:j=>{var p;const h=(p=j.target.files)==null?void 0:p[0];j.target.value="",h&&i(h)}})]})}const Je=[{value:"text",label:"Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"number",label:"Number"},{value:"textarea",label:"Long Text"},{value:"select",label:"Dropdown"},{value:"checkbox",label:"Checkbox"},{value:"date",label:"Date"},{value:"url",label:"URL"}],Ke=[{value:"__none__",label:"Not mapped (just stored on the RSVP)"},{value:"contact.name",label:"Contact â Name"},{value:"contact.email",label:"Contact â Email"},{value:"contact.phone",label:"Contact â Phone"},{value:"contact.notes",label:"Contact â Notes"},{value:"opportunity.title",label:"Opportunity â Title"},{value:"opportunity.description",label:"Opportunity â Description"},{value:"opportunity.value",label:"Opportunity â Value"}];function Jt({workspaceId:t}){const i=z(S.crmEvents.queries.listEvents,{workspaceId:t}),a=z(S.pipelines.queries.listPipelines,{workspaceId:t}),s=q(S.crmEvents.mutations.createEvent),r=q(S.crmEvents.mutations.updateEvent),d=q(S.crmEvents.mutations.deleteEvent),x=q(S.crmEvents.mutations.generateEventUploadUrl),j=wt(),[h,p]=m.useState(!1),[R,E]=m.useState(""),[_,D]=m.useState(""),[$,g]=m.useState(()=>{const c=new Date;return c.setDate(c.getDate()+1),c.setHours(9,0,0,0),xe(c.getTime())}),[A,F]=m.useState(""),[P,M]=m.useState(""),[B,V]=m.useState(null),[U,o]=m.useState(null),O=async()=>
11{if(!R.trim()){u.error("Give your event a name first");return}const c=Ae($);if(!c){u.error("Pick a valid start date and time");return}try{const N=await s({workspaceId:t,name:R.trim(),description:_.trim()||void 0,eventStartAt:c,location:A.trim()||void 0,pipelineId:P||void 0});p(!1),E(""),D(""),F(""),M(""),V(String(N)),u.success("Event created â finish setting it up below")}catch(N){u.error(N instanceof Error?N.message:"Failed to create event")}},f=async(c,N)=>{if(await j({title:"Delete event?",message:`Delete â${N}â and all of its RSVPs? This can't be undone.`,confirmLabel:"Delete",destructive:!0}))try{await d({eventId:c}),u.success("Event deleted"),B===c&&V(null)}catch(n){u.error(n instanceof Error?n.message:"Failed to delete event")}},w=async(c,N,l)=>{o(`${c}:${N}`);try{const n=await x({eventId:c}),k=await fetch(n,{method:"POST",headers:{"Content-Type":l.type},body:l});if(!k.ok)throw new Error("Upload failed");const{storageId:C}=await k.json();await r({eventId:c,[N]:C}),u.success("Image uploaded")}catch(n){u.error(n instanceof Error?n.message:"Upload failed")}finally{o(null)}};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ct,{className:"h-4 w-4 text-primary"}),e.jsx("h2",{className:"text-sm font-bold text-foreground",children:"Events"})]}),e.jsxs(y,{size:"sm",onClick:()=>p(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"New event"]})]}),e.jsx(yt,{className:"flex-1 min-h-0",children:e.jsxs("div",{className:"p-4 space-y-3",children:[i===void 0&&e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loadingâ¦"}),i&&i.length===0&&e.jsxs(H,{className:"p-8 text-center text-sm text-muted-foreground",children:["No events yet. Click ",e.jsx("strong",{children:"New event"})," to start."]}),i==null?void 0:i.map(c=>{const N=B===String(c._id),l=`${_e}/events/${c.slug}`;return e.jsxs(H,{className:"overflow-hidden",children:[e.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between gap-2 hover:bg-accent/30 transition-colors",onClick:()=>V(N?null:String(c._id)),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 text-left",children:[N?e.jsx(tt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):e.jsx(Nt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-foreground truncate",children:c.name}),c.isPublished?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-green-500/15 text-green-700 dark:text-green-300",children:"Live"}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"Draft"})]}),e.jsxs("div",{className:"text-[11px] text-muted-foreground",children:[new Date(c.eventStartAt).toLocaleString()," â¢"," ",c.attendingCount," attending",c.waitlistCount>0?` ⢠${c.waitlistCount} waitlist`:"",c.pipelineName?` ⢠â ${c.pipelineName}`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center justify-center h-7 w-7 rounded hover:bg-accent/40 text-muted-foreground hover:text-foreground",title:"Open public page",children:e.jsx(kt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),navigator.clipboard.writeText(l),u.success("Public link copied")},className:"inline-flex items-center justify-center h-7 w-7 rounded hover:bg-accent/40 text-muted-foreground hover:text-foreground",title:"Copy public link",children:e.jsx(st,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),f(c._id,c.name)},className:"inline-flex items-center justify-center h-7 w-7 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive",title:"Delete event",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})]})]}),N&&e.jsx(Kt,{event:c,pipelines:a??[],onUpdate:n=>r({eventId:c._id,...n}).catch(k=>u.error(k instanceof Error?k.message:"Update failed")),onUploadImage:(n,k)=>w(c._id,n,k),uploadingFor:U,eventId:c._id})]},c._id)})]})}),e.jsx(Te,{open:h,onOpenChange:p,children:e.jsxs(Re,{className:"max-w-lg",children:[e.jsx(Le,{children:e.jsx(Ie,{children:"New event"})}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"ev-name",children:"Event name"}),e.jsx(T,{id:"ev-name",value:R,onChange:c=>E(c.target.value),placeholder:"Summer kickoff"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"ev-desc",children:"Description"}
11),e.jsx(me,{id:"ev-desc",value:_,onChange:c=>D(c.target.value),rows:3,placeholder:"What's this event about?"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"ev-start",children:"Start date / time"}),e.jsx(T,{id:"ev-start",type:"datetime-local",value:$,onChange:c=>g(c.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"ev-location",children:"Location"}),e.jsx(T,{id:"ev-location",value:A,onChange:c=>F(c.target.value),placeholder:"Optional"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Link to pipeline (optional)"}),e.jsxs(K,{value:P,onValueChange:M,children:[e.jsx(X,{children:e.jsx(Q,{placeholder:"No pipeline"})}),e.jsx(Z,{children:(a??[]).map(c=>e.jsx(W,{value:c._id,children:c.name},c._id))})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"When set, every RSVP creates a contact in the first column (you can choose a specific column after creating)."})]})]}),e.jsxs(Be,{children:[e.jsx(y,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsx(y,{onClick:()=>void O(),children:"Create event"})]})]})})]})}function Kt({event:t,pipelines:i,onUpdate:a,onUploadImage:s,uploadingFor:r,eventId:d}){const[x,j]=m.useState(t.name),[h,p]=m.useState(t.description??""),[R,E]=m.useState(xe(t.eventStartAt)),[_,D]=m.useState(xe(t.eventEndAt)),[$,g]=m.useState(t.timezone??""),[A,F]=m.useState(t.location??""),[P,M]=m.useState(t.locationUrl??""),[B,V]=m.useState(t.rsvpButtonText??"RSVP"),[U,o]=m.useState(t.successMessage??""),[O,f]=m.useState(typeof t.capacity=="number"?String(t.capacity):""),[w,c]=m.useState(typeof t.maxGuestsPerRsvp=="number"?String(t.maxGuestsPerRsvp):"");m.useEffect(()=>{j(t.name),p(t.description??""),E(xe(t.eventStartAt)),D(xe(t.eventEndAt)),g(t.timezone??""),F(t.location??""),M(t.locationUrl??""),V(t.rsvpButtonText??"RSVP"),o(t.successMessage??""),f(typeof t.capacity=="number"?String(t.capacity):""),c(typeof t.maxGuestsPerRsvp=="number"?String(t.maxGuestsPerRsvp):"")},[t._id]);const N=z(S.pipelines.queries.getPipeline,t.pipelineId?{pipelineId:t.pipelineId}:"skip"),l=z(S.crmEvents.queries.listEventRsvps,{eventId:d});return e.jsxs("div",{className:"border-t border-border bg-muted/30 p-4 space-y-5",children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-5",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-xs uppercase tracking-wider font-semibold text-muted-foreground flex items-center gap-1.5",children:[e.jsx(lt,{className:"h-3.5 w-3.5"}),"Branding"]}),e.jsx(Ye,{storageId:t.headerImageStorageId??null,onPickFile:n=>s("headerImageStorageId",n),onClear:()=>a({headerImageStorageId:null}),uploading:r===`${d}:headerImageStorageId`,label:"Header image"}),e.jsx(Ye,{storageId:t.logoStorageId??null,onPickFile:n=>s("logoStorageId",n),onClear:()=>a({logoStorageId:null}),uploading:r===`${d}:logoStorageId`,label:"Logo (top-right)"}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border p-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Apply workspace color palette"}),e.jsx(ne,{checked:t.applyWorkspaceBranding!==!1,onCheckedChange:n=>a({applyWorkspaceBranding:n})})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border p-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Dark theme on the public page"}),e.jsx(ne,{checked:t.displayTheme==="dark",onCheckedChange:n=>a({displayTheme:n?"dark":"light"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-xs uppercase tracking-wider font-semibold text-muted-foreground flex items-center gap-1.5",children:[e.jsx(ct,{className:"h-3.5 w-3.5"}),"Schedule & location"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Event name"}),e.jsx(T,{value:x,onChange:n=>j(n.target.value),onBlur:()=>x.trim()&&x!==t.name&&a({name:x.trim()})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Description"}),e.jsx(me,{rows:4,value:h,onChange:n=>p(n.target.value),onBlur:()=>h!==(t.description??"")&&a({description:h||void 0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Starts"}),e.jsx(T,{type:"datetime-local",value:R,onChange:n=>E(n.target.value),onBlur:()=>{const n=Ae(R);n&&n!==t.eventStartAt&&a({eventStartAt:n})}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Ends (optional)"}
11),e.jsx(T,{type:"datetime-local",value:_,onChange:n=>D(n.target.value),onBlur:()=>{const n=Ae(_);a({eventEndAt:n??null})}})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Timezone"}),e.jsx(T,{value:$,onChange:n=>g(n.target.value),onBlur:()=>$!==(t.timezone??"")&&a({timezone:$||void 0}),placeholder:"e.g. America/New_York"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Location"}),e.jsx(T,{value:A,onChange:n=>F(n.target.value),onBlur:()=>A!==(t.location??"")&&a({location:A||void 0})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Location URL (map or virtual link)"}),e.jsx(T,{value:P,onChange:n=>M(n.target.value),onBlur:()=>P!==(t.locationUrl??"")&&a({locationUrl:P||void 0}),placeholder:"https://"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-xs uppercase tracking-wider font-semibold text-muted-foreground flex items-center gap-1.5",children:[e.jsx(Ft,{className:"h-3.5 w-3.5"}),"RSVP behaviour"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"RSVP button text"}),e.jsx(T,{value:B,onChange:n=>V(n.target.value),onBlur:()=>B.trim()!==(t.rsvpButtonText??"RSVP")&&a({rsvpButtonText:B.trim()||"RSVP"}),placeholder:"RSVP"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:`Try "I'm in", "Save my seat", "Count me in".`})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Success message"}),e.jsx(me,{rows:2,value:U,onChange:n=>o(n.target.value),onBlur:()=>U!==(t.successMessage??"")&&a({successMessage:U||void 0})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Capacity"}),e.jsx(T,{type:"number",min:0,value:O,onChange:n=>f(n.target.value),onBlur:()=>{const n=O.trim()===""?null:Number(O);(n===null||Number.isFinite(n))&&a({capacity:n===null?null:Math.max(0,n)})},placeholder:"No cap"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Max +guests per RSVP"}),e.jsx(T,{type:"number",min:0,value:w,onChange:n=>c(n.target.value),onBlur:()=>{const n=w.trim()===""?null:Number(w);(n===null||Number.isFinite(n))&&a({maxGuestsPerRsvp:n===null?null:Math.max(0,n)})}})]})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border p-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Allow +guests field"}),e.jsx(ne,{checked:!!t.allowGuestCount,onCheckedChange:n=>a({allowGuestCount:n})})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border p-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Allow waitlist when full"}),e.jsx(ne,{checked:t.allowWaitlist!==!1,onCheckedChange:n=>a({allowWaitlist:n})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("h3",{className:"text-xs uppercase tracking-wider font-semibold text-muted-foreground flex items-center gap-1.5",children:[e.jsx(Ot,{className:"h-3.5 w-3.5"}),"Pipeline integration"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Pipeline"}),e.jsxs(K,{value:t.pipelineId??"__none__",onValueChange:n=>a(n==="__none__"?{pipelineId:null,pipelineColumnId:null}:{pipelineId:n}),children:[e.jsx(X,{children:e.jsx(Q,{placeholder:"No pipeline"})}),e.jsxs(Z,{children:[e.jsx(W,{value:"__none__",children:"No pipeline"}),i.map(n=>e.jsx(W,{value:n._id,children:n.name},n._id))]})]})]}),t.pipelineId&&N&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Target column"}),e.jsxs(K,{value:t.pipelineColumnId??"__first__",onValueChange:n=>a(n==="__first__"?{pipelineColumnId:null}:{pipelineColumnId:n}),children:[e.jsx(X,{children:e.jsx(Q,{placeholder:"First column"})}),e.jsxs(Z,{children:[e.jsx(W,{value:"__first__",children:"First column"}),((N==null?void 0:N.columns)??[]).map(n=>e.jsx(W,{value:n._id,children:n.name},n._id))]})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Each new RSVP becomes a contact (and an opportunity) in the linked column."})]})]}),e.jsx(Xt,{eventId:d}),e.jsxs("div",{className:"border-t border-border pt-4 flex flex-col md:flex-row md:items-center md:justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ne,{checked:!!t.isPublished,onCheckedChange:n=>a({isPublished:n})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:t.isPublished?"Published":"Draft"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:t.isPublished?"Your event is live and accepting RSVPs.":"Toggle on to start collecting RSVPs."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"text-[11px] bg-muted/80 px-2 py-1 rounded truncate max-w-[260px]",children:`${_e}/events/${t.slug}`}),e.jsxs(y,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(`${_e}/events/${t.slug}`),u.success("Public link copied")},children:[e.jsx(st,{className:"h-3.5 w-3.5 mr-1.5"}),"Copy link"]})]})]}),e.jsxs("div",{className:"border-t border-border pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs uppercase tracking-wider font-semibold text-muted-foreground",children:"Recent RSVPs"}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[(l??[]).length," total"]})]}),!l||l.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No RSVPs yet."}):e.jsx("div",{className:"space-y-1",children:l.slice(0,8).map(n=>
11{var k,C,J;return e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[n.status==="attending"?e.jsx(Ct,{className:"h-3 w-3 text-green-600 shrink-0"}):n.status==="waitlist"?e.jsx("span",{className:"text-[10px] uppercase font-semibold text-amber-600",children:"WL"}):e.jsx(at,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"font-medium truncate",children:((k=n.data)==null?void 0:k.name)??"Unnamed"}),e.jsx("span",{className:"text-muted-foreground truncate",children:(C=n.data)==null?void 0:C.email}),(J=n.data)!=null&&J.guestCount?e.jsxs("span",{className:"text-muted-foreground shrink-0",children:["+",n.data.guestCount]}):null,e.jsx("span",{className:"ml-auto text-muted-foreground shrink-0",children:new Date(n.submittedAt).toLocaleDateString()})]},n._id)})})]})]})}function Xt({eventId:t}){const i=z(S.crmEvents.queries.listEventFields,{eventId:t}),a=q(S.crmEvents.mutations.addEventField),s=q(S.crmEvents.mutations.updateEventField),r=q(S.crmEvents.mutations.deleteEventField),d=q(S.crmEvents.mutations.reorderEventFields),x=q(S.crmEvents.mutations.seedEventDefaultFields),[j,h]=m.useState(!1),[p,R]=m.useState(""),[E,_]=m.useState("text"),[D,$]=m.useState(!1),[g,A]=m.useState(""),[F,P]=m.useState(""),[M,B]=m.useState("__none__"),V=async()=>{if(!p.trim()){u.error("Add a label first");return}try{await a({eventId:t,label:p.trim(),type:E,required:D,placeholder:g.trim()||void 0,options:E==="select"&&F.trim()?F.split(",").map(o=>o.trim()).filter(Boolean):void 0,mappedTo:M==="__none__"?void 0:M}),h(!1),R(""),_("text"),$(!1),A(""),P(""),B("__none__")}catch(o){u.error(o instanceof Error?o.message:"Failed to add field")}},U=(o,O)=>{if(!i)return;const f=o+O;if(f<0||f>=i.length)return;const w=[...i];[w[o],w[f]]=[w[f],w[o]],d({eventId:t,orderedFieldIds:w.map(c=>c._id)}).catch(c=>u.error(c instanceof Error?c.message:"Reorder failed"))};return e.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs uppercase tracking-wider font-semibold text-muted-foreground",children:"RSVP fields"}),e.jsxs("div",{className:"flex items-center gap-2",children:[i!==void 0&&i.length===0&&e.jsx(y,{size:"sm",variant:"outline",onClick:()=>x({eventId:t}).catch(o=>u.error(o instanceof Error?o.message:"Failed to seed")),children:"Seed defaults"}),e.jsxs(y,{size:"sm",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Add field"]})]})]}),i===void 0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading fieldsâ¦"}):i.length===0?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["No RSVP fields yet. Add one, or click ",e.jsx("strong",{children:"Seed defaults"})," to start with Name, Email, and Notes mapped to the linked pipeline."]}):e.jsx("div",{className:"space-y-2",children:i.map((o,O)=>e.jsxs("div",{className:"grid grid-cols-12 gap-2 items-center rounded border border-border p-2 bg-card",children:[e.jsx("div",{className:"col-span-3",children:e.jsx(T,{defaultValue:o.label,className:"h-8 text-xs",onBlur:f=>{const w=f.target.value.trim();w&&w!==o.label&&s({fieldId:o._id,label:w}).catch(c=>u.error(c instanceof Error?c.message:"Update failed"))}})}),e.jsx("div",{className:"col-span-2",children:e.jsxs(K,{value:o.type,onValueChange:f=>s({fieldId:o._id,type:f}).catch(w=>u.error(w instanceof Error?w.message:"Update failed")),children:[e.jsx(X,{className:"h-8 text-xs",children:e.jsx(Q,{})}),e.jsx(Z,{children:Je.map(f=>e.jsx(W,{value:f.value,children:f.label},f.value))})]})}),e.jsx("div",{className:"col-span-4",children:e.jsxs(K,{value:o.mappedTo??"__none__",onValueChange:f=>s({fieldId:o._id,mappedTo:f==="__none__"?null:f}).catch(w=>u.error(w instanceof Error?w.message:"Update failed")),children:[e.jsx(X,{className:"h-8 text-xs",children:e.jsx(Q,{})}),e.jsx(Z,{children:Ke.map(f=>e.jsx(W,{value:f.value,children:f.label},f.value))})]})}),e.jsxs("div",{className:"col-span-2 flex items-center gap-2",children:[e.jsx(ne,{checked:!!o.required,onCheckedChange:f=>s({fieldId:o._id,required:f}).catch(w=>u.error(w instanceof Error?w.message:"Update failed"))}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Required"})]}),e.jsxs("div",{className:"col-span-1 flex items-center justify-end gap-1",children:[e.jsx("button",{className:"h-6 w-6 inline-flex items-center justify-center rounded hover:bg-accent/40 text-muted-foreground",onClick:()=>U(O,-1),disabled:O===0,"aria-label":"Move up",title:"Move up",children:e.jsx(St,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"h-6 w-6 inline-flex items-center justify-center rounded hover:bg-accent/40 text-muted-foreground",onClick:()=>U(O,1),disabled:O===i.length-1,"aria-label":"Move down",title:"Move down",children:e.jsx(tt,{className:"h-3.5 w-3.5"})}),e.jsx("button",{className:"h-6 w-6 inline-flex items-center justify-center rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive",onClick:()=>r({fieldId:o._id}).catch(f=>u.error(f instanceof Error?f.message:"Delete failed")),"aria-label":"Delete field",title:"Delete field",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})]}),(o.type==="text"||o.type==="email"||o.type==="phone"||o.type==="number"||o.type==="textarea"||o.type==="url"||o.type==="date")&&e.jsx("div",{className:"col-span-12 -mt-1",children:e.jsx(T,{defaultValue:o.placeholder??"",placeholder:"Placeholder (optional)",className:"h-7 text-[11px]",onBlur:f=>{const w=f.target.value;w!==(o.placeholder??"")&&s({fieldId:o._id,placeholder:w||void 0}).catch(c=>u.error(c instanceof Error?c.message:"Update failed"))}})}),o.type==="select"&&e.jsx("div",{className:"col-span-12 -mt-1",children:e.jsx(T,{defaultValue:(o.options??[]).join(", "),placeholder:"Comma-separated options",className:"h-7 text-[11px]",onBlur:f=>{const w=f.target.value.split(",").map(c=>
11c.trim()).filter(Boolean);s({fieldId:o._id,options:w}).catch(c=>u.error(c instanceof Error?c.message:"Update failed"))}})})]},o._id))}),e.jsx(Te,{open:j,onOpenChange:h,children:e.jsxs(Re,{className:"max-w-md",children:[e.jsx(Le,{children:e.jsx(Ie,{children:"Add RSVP field"})}),e.jsxs("div",{className:"space-y-3 py-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Label"}),e.jsx(T,{value:p,onChange:o=>R(o.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Type"}),e.jsxs(K,{value:E,onValueChange:_,children:[e.jsx(X,{children:e.jsx(Q,{})}),e.jsx(Z,{children:Je.map(o=>e.jsx(W,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1.5 flex flex-col",children:[e.jsx(v,{children:"Required"}),e.jsx("div",{className:"flex items-center h-10",children:e.jsx(ne,{checked:D,onCheckedChange:$})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Map to CRM (optional)"}),e.jsxs(K,{value:M,onValueChange:B,children:[e.jsx(X,{children:e.jsx(Q,{})}),e.jsx(Z,{children:Ke.map(o=>e.jsx(W,{value:o.value,children:o.label},o.value))})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"When set, the value flows into the linked pipeline's contact or opportunity row."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Placeholder (optional)"}),e.jsx(T,{value:g,onChange:o=>A(o.target.value)})]}),E==="select"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{children:"Options"}),e.jsx(T,{value:F,onChange:o=>P(o.target.value),placeholder:"Comma-separated"})]})]}),e.jsxs(Be,{children:[e.jsx(y,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsx(y,{onClick:()=>void V(),children:"Add field"})]})]})})]})}function Qt(){return`You are a senior landing-page designer composing pages from a fixed component library. Respond ONLY in this exact envelope: 12 13<reply>One short sentence (⤠20 words) summarising what you did. Plain English, like a designer reporting back.</reply> 14<blocks> 15[ ⦠ordered array of block objects, see schema below ⦠] 16</blocks> 17 18No prose outside the tags. No markdown code fences anywhere. The <blocks> body must be valid JSON. 19 20STRUCTURE RULES (MANDATORY): 21 1. Always at least 4 blocks: a hero, a featureGrid (3+ items), a cta, and a footer. Always. 22 2. Order: hero first, footer last. 23 3. Insert at most 2 sections between the hero and the featureGrid (text or imageText). 24 4. Insert a cta block right before the footer. 25 5. Only use formEmbed / eventEmbed when the workspace context lists a published slug for that block to reference. 26 27COPY RULES: 28 ⢠Write the copy yourself. Don't echo the user prompt back as content. 29 ⢠title fields: short headlines, ⤠7 words, no period at end. 30 ⢠buttonLabel / ctaLabel: 2â4 words MAX, action verb, no punctuation. 31 ⢠subtitle / body fields: full sentences. Long-form descriptions go here, NEVER in button labels. 32 ⢠Hero title and CTA title must differ â don't repeat the same headline. 33 34BLOCK SHAPES (every block has a "type" field; everything else listed is optional unless noted): 35 36hero (required: type, title): 37 { "type": "hero", 38 "title": "Build sites your team will use", 39 "subtitle": "A drag-and-drop builder with built-in forms and analytics.", 40 "eyebrow": "NOW IN BETA", 41 "ctaLabel": "Get started", 42 "ctaHref": "#signup", 43 "backgroundImageUrl": "https://â¦", 44 "align": "center" // or "left" 45 } 46 47text (required: type, body): 48 { "type": "text", 49 "body": "Short paragraph in plain prose. Newlines preserved.", 50 "align": "left" // or "center" 51 } 52 53imageText (required: type): 54 { "type": "imageText", 55 "imageUrl": "https://images.unsplash.com/â¦", 56 "imageAlt": "Short description", 57 "title": "Section title", 58 "body": "One or two sentences explaining this section.", 59 "layout": "imageLeft" // or "imageRight" 60 } 61 62featureGrid (required: type, items): 63 { "type": "featureGrid", 64 "title": "What's included", 65 "columns": 3, // 2 or 3 66 "items": [ 67 { "icon": "zap", "title": "Same-day onboarding", "body": "Live in under an hour." }, 68 { "icon": "shield", "title": "Your data stays yours", "body": "Encrypted at rest, never sold." }, 69 { "icon": "sparkles", "title": "Built-in copilot", "body": "Ask in plain English." } 70 ] 71 } 72 Allowed icon values: "sparkles", "star", "zap", "heart", "shield". Anything else falls back to a default. 73 74cta (required: type, title, buttonLabel, buttonHref): 75 { "type": "cta", 76 "title": "Ready to launch with us?", 77 "subtitle": "Spots fill quickly each cohort.", 78 "buttonLabel": "Request access", 79 "buttonHref": "#signup" 80 } 81 82formEmbed (required: type; formSlug must come from the workspace context): 83 { "type": "formEmbed", 84 "formSlug": "exact-published-slug", 85 "title": "Apply for access", 86 "body": "We onboard a new cohort every Friday." 87 } 88 89eventEmbed (required: type; eventSlug must come from the workspace context): 90 { "type": "eventEmbed", 91 "eventSlug": "exact-published-slug", 92 "title": "Join us", 93 "body": "Q1 launch on March 14." 94 } 95 96footer (required: type): 97 { "type": "footer", 98 "body": "© Your Company", 99 "links": [ 100 { "label": "Privacy", "href": "/privacy" }, 101 { "label": "Terms", "href": "/terms" } 102 ] 103 } 104 105EXAMPLE â what a complete, valid response looks like: 106 107<reply>Drafted a beta launch page with three benefits, a sign-up section, and a CTA.</reply> 108<blocks> 109[ 110 { "type": "hero", "title": "Join the spring beta", "subtitle": "A small group of teams shaping the next chapter.", "eyebrow": "NOW INVITING", "ctaLabel": "Request access", "ctaHref": "#signup", "align": "center" }, 111 { "type": "imageText", "imageUrl": "https://images.unsplash.com/photo-1551434678-e076c223a692?w=1200", "title": "Built for real teams", "body": "We designed every screen with operators who run the day-to-day.", "layout": "imageRight" }, 112 { "type": "featureGrid", "title": "What you get", "columns": 3, "items": [ { "icon": "zap", "title": "Same-day onboarding", "body": "Live in under an hour." }, { "icon": "shield", "title": "Your data stays yours", "body": "Encrypted at rest, never sold." }, { "icon": "sparkles", "title": "Built-in copilot", "body": "Ask in plain English." } ] }, 113 { "type": "cta", "title": "Ready when you are", "subtitle": "Spots fill quickly each cohort.", "buttonLabel": "Request access", "buttonHref": "#signup" }, 114 { "type": "footer", "body": "© Beta Co", "links": [ { "label": "Privacy", "href": "/privacy" } ] } 115] 116</blocks>`}function Xe(t){const i=t.indexOf("<blocks>");if(i<0)return null;const a=t.slice(i+8),s=a.indexOf("</blocks>");let r=s>=0?a.slice(0,s):a;r=r.trim();const d=r.match(/^```[a-zA-Z0-9_-]*\n?([\s\S]*?)\n?```$/);return d&&(r=d[1].trim()),r}function Qe(t){const i=t.indexOf("<reply>");if(i<0)return null;const a=t.slice(i+7),s=a.indexOf("</reply>");return(s>=0?a.slice(0,s):a).trim()}function Zt(t){let i=t.trim();if(i.length===0)return i;let a=!1,s=!1;const r=[];for(let d=0;d<i.length;d++){const x=i[d];if(s){s=!1;continue}if(a){if(x==="\\"){s=!0;continue}x==='"'&&(a=!1);continue}if(x==='"'){a=!0;continue}if(x==="{"||x==="[")r.push(x);else if(x==="}"||x==="]"){const j=x==="}"?"{":"[";r[r.length-1]===j&&r.pop()}}for(a&&(i+='"'),i=i.replace(/,\s*$/,"");r.length>0;){const d=r.pop();i+=d==="{"?"}":"]"}return i}function ht(t){if(!Array.isArray(t))return[];const i=[];for(const a of t){if(!a||typeof a!="object")continue;const s=a,r=s.type;if(typeof r!="string"||!dt.includes(r))continue;const d={id:es(),...s};mt(d)&&i.push(d)}return i}function es(){return Math.random().toString(36).slice(2,10)}function ut(t){if(!t||t.trim().length===0)return null;try{return ht(JSON.parse(t))}catch{return null}}function Ze(t){const i=ut(t);if(i!==null)return i;try{return ht(JSON.parse(Zt(t)))}catch{return[]}}function ts({siteId:t,onBack:i}){const a=S,s=z(a.marketingSites.getSite,{siteId:t}),r=q(a.marketingSites.updateSite),d=q(a.marketingSites.setPublishStatus),[x,j]=m.useState(""),[h,p]=m.useState([]),[R,E]=m.useState(""),[_,D]=m.useState(null),[$,g]=m.useState("manual"),A=m.useRef(!1);m.useEffect(()=>{if(!s||A.current)return;A.current=!0,j(s.name),E(s.brandColor??"");const l=Array.isArray(s.blocks)?s.blocks.filter(mt):[];p(l),l.length>0&&D(l[0].id)},[s]);const F=m.useRef(null),P=m.useRef({}),M=m.useCallback(()=>{F.current&&(clearTimeout(F.current),F.current=null);const l=P.current;P.current={},Object.keys(l).length!==0&&r({siteId:t,...l})},[t,r]),B=m.useCallback(l=>{P.current={...P.current,...l}
116,F.current&&clearTimeout(F.current),F.current=setTimeout(M,500)},[M]);m.useEffect(()=>()=>{M()},[M]);const V=m.useCallback(l=>{p(l),B({blocks:l})},[B]),U=l=>{const n=zt(l),k=[...h,n];V(k),D(n.id)},o=l=>{var k;const n=h.filter(C=>C.id!==l);V(n),_===l&&D(((k=n[0])==null?void 0:k.id)??null)},O=(l,n)=>{const k=h.findIndex(he=>he.id===l);if(k<0)return;const C=k+n;if(C<0||C>=h.length)return;const J=[...h];[J[k],J[C]]=[J[C],J[k]],V(J)},f=(l,n)=>{const k=h.map(C=>C.id===l?{...C,...n}:C);V(k)},w=async()=>{if(!s)return;M();const l=!s.isPublished;try{await d({siteId:t,isPublished:l}),u.success(l?"Site published":"Site unpublished")}catch(n){u.error(n.message??"Failed to update publish status")}},c=async()=>{if(!s)return;const l=`${window.location.origin}/sites/${s.slug}`;try{await navigator.clipboard.writeText(l),u.success("Public link copied")}catch{u.error("Could not copy link")}},N=m.useMemo(()=>h.find(l=>l.id===_)??null,[h,_]);return s===void 0?e.jsx("div",{className:"text-sm text-white/60 p-4",children:"Loading siteâ¦"}):s===null?e.jsxs("div",{className:"p-4",children:[e.jsxs(y,{variant:"ghost",onClick:i,size:"sm",children:[e.jsx(ze,{className:"h-4 w-4 mr-1.5"}),"Back"]}),e.jsx("p",{className:"text-sm text-white/60 mt-4",children:"Site not found. It may have been deleted."})]}):e.jsxs("div",{className:"h-full flex flex-col -m-4 md:-m-6",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-white/10 bg-black/20 shrink-0",children:[e.jsxs(y,{variant:"ghost",size:"sm",onClick:i,className:"text-white/70 hover:text-white",children:[e.jsx(ze,{className:"h-4 w-4 mr-1.5"}),"Sites"]}),e.jsx(T,{value:x,onChange:l=>{j(l.target.value),B({name:l.target.value})},className:"bg-transparent border-0 text-white font-semibold focus-visible:ring-0 px-2 max-w-md",placeholder:"Site name"}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-0.5 rounded-md border border-white/15 bg-white/5 p-0.5",children:[e.jsx("button",{onClick:()=>g("manual"),className:`text-xs px-2 py-1 rounded transition-colors ${$==="manual"?"bg-white/20 text-white":"text-white/60 hover:text-white"}`,children:"Manual"}),e.jsxs("button",{onClick:()=>g("ai"),className:`text-xs px-2 py-1 rounded transition-colors flex items-center gap-1 ${$==="ai"?"bg-white/20 text-white":"text-white/60 hover:text-white"}`,children:[e.jsx(Ee,{className:"h-3 w-3"}),"AI"]})]}),s.isPublished&&e.jsxs(y,{variant:"outline",size:"sm",onClick:c,className:"text-white/80 border-white/20 hover:bg-white/10",children:[e.jsx(it,{className:"h-3.5 w-3.5 mr-1.5"}),"Copy link"]}),e.jsxs(y,{size:"sm",onClick:w,className:s.isPublished?"bg-white/10 text-white hover:bg-white/20":"bg-white text-purple-900 hover:bg-white/90",children:[e.jsx(Pe,{className:"h-3.5 w-3.5 mr-1.5"}),s.isPublished?"Unpublish":"Publish"]})]})]}),$==="ai"?e.jsx(as,{workspaceId:s.workspaceId,brandColor:R||void 0,initialBlocks:h,onApply:l=>{var n;V(l),D(((n=l[0])==null?void 0:n.id)??null),g("manual"),u.success("Applied to site")}}):e.jsxs("div",{className:"flex-1 min-h-0 grid grid-cols-[180px_1fr_320px] overflow-hidden",children:[e.jsxs("div",{className:"border-r border-white/10 bg-black/10 overflow-y-auto p-3 space-y-1.5",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider font-semibold text-white/40 px-1 mb-1.5",children:"Add block"}),dt.map(l=>e.jsxs("button",{onClick:()=>U(l),className:"w-full text-left px-2 py-1.5 rounded text-xs text-white/80 hover:bg-white/10 hover:text-white transition-colors flex items-center gap-1.5",children:[e.jsx(le,{className:"h-3 w-3 opacity-60"}),Fe[l]]},l)),e.jsxs("div",{className:"pt-3 mt-3 border-t border-white/10 space-y-2",children:[e.jsx(v,{className:"text-[10px] uppercase tracking-wider font-semibold text-white/40 px-1",children:"Brand color"}),e.jsxs("div",{className:"flex items-center gap-2 px-1",children:[e.jsx("input",{type:"color",value:R||"#7c3aed",onChange:l=>{E(l.target.value),B({brandColor:l.target.value})},className:"h-7 w-7 rounded cursor-pointer bg-transparent border border-white/20"}),e.jsx("span",{className:"text-xs text-white/60 font-mono",children:R||"default"}),R&&e.jsx("button",{onClick:()=>{E(""),B({brandColor:""})},className:"text-[10px] text-white/40 hover:text-white/70 ml-auto",children:"clear"})]})]})]}),e.jsxs("div",{className:"overflow-y-auto bg-muted/20",children:[e.jsx(xt,{blocks:h,brandColor:R||void 0,renderBlockWrapper:(l,n,k)=>e.jsx(is,{block:l,isSelected:l.id===_,onSelect:()=>D(l.id),children:k})}),h.length===0&&e.jsx("div",{className:"p-16 text-center text-white/50 text-sm",children:"Add your first block from the left panel."})]}),e.jsx("div",{className:"border-l border-white/10 bg-black/10 overflow-y-auto p-3",children:N?e.jsx(ns,{block:N,workspaceId:s.workspaceId,onPatch:l=>f(N.id,l),onDelete:()=>o(N.id),onMove:l=>O(N.id,l)},N.id):e.jsx("p",{className:"text-xs text-white/50",children:"Click a block in the preview to edit it."})})]})]})}function ss(){return"https://cheerful-rat-345.convex.cloud".replace(/\.convex\.cloud(?:\/?$)/,".convex.site").replace(/\/$/,"")}function as({workspaceId:t,brandColor:i,initialBlocks:a,onApply:s}){const r=S,d=Et(r.marketingSitesAi.generateSiteFromChat),x=z(r.crmForms.queries.listForms,{workspaceId:t}),j=z(r.crmEvents.queries.listEvents,{workspaceId:t}),h=m.useMemo(()=>Qt(),[]),p=Vt(),R=m.useRef(p);R.current=p;const[E,_]=m.useState([]),[D,$]=m.useState(""),[g,A]=m.useState(()=>a??[]),[F,P]=m.useState(""),[M,B]=m.useState(!1),[V,U]=m.useState(""),[o,O]=m.useState(!1),f=m.useRef(null);m.useEffect(()=>{requestAnimationFrame(()=>{var l;(l=f.current)==null||l.scrollIntoView({behavior:"smooth"})})},[E,o]);const w=m.useMemo(()=>{const l=[],n=(x??[]).filter(C=>C.isPublished),k=(j??[]).filter(C=>C.isPublished);return n.length>0?l.push(`Available form slugs (use exact slug in FormEmbed): ${n.map(C=>`${C.slug} ("${C.name}")`).join(", ")}`):l.push("No published forms â avoid emitting FormEmbed; use a CTA pointing to '#contact' instead."),k.length>0&&l.push(`Available event slugs (use exact slug in EventEmbed): ${k.map(C=>`${C.slug} ("${C.name}")`).join(", ")}`),i&&l.push(`Brand color: ${i}`),l.join(` 117`)},[x,j,i]),c=async()=>{const l=D.trim();if(!l||o)return;$("");const n=[...E,{role:"user",content:l}];_(n),O(!0),U(""),P(""),B(!1);const k=g.length>0?JSON.stringify(g.map(({id:L,...I})=>I)):void 0,C={workspaceId:t,systemPrompt:h,contextHints:w,currentOpenUiLang:k,messages:n},J=R.current,he=ss();if(!J||!he){try{const L=await d(C);_(b=>[...b,{role:"assistant",content:L.reply}]),P(L.openUiLang??"");const I=Ze(L.openUiLang??"");I.length>0?(A(I),B(!1)):B(!0)}catch(L){const I=(L==null?void 0:L.message)??"Generation failed";u.error(I),_(b=>[...b,{role:"assistant",content:`â ï¸ ${I}`}])}finally{O(!1),U("")}return}let te="",we="",Me="",se;try{se=await fetch(`${he}/api/marketing-site-copilot/stream`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${J}`},body:JSON.stringify(C)})}catch(L){const I=(L==null?void 0:L.message)??"Network error";u.error(I),_(b=>[...b,{role:"assistant",content:`â ï¸ ${I}`}]),O(!1),U("");return}if(!se.ok||!se.body){const I=(await se.text().catch(()=>se.statusText)).includes("OPENROUTER_API_KEY")?"OPENROUTER_API_KEY isn't set in the Convex deployment env. Ask your admin to add it.":`Stream failed (${se.status})`;u.error(I),_(b=>[...b,{role:"assistant",content:`â ï¸ ${I}`}]),O(!1),U("");return}const Oe=se.body.getReader(),pt=new TextDecoder;let ye="",Ne=null;const gt=(L,I)=>{let b;try{b=JSON.parse(I)}catch{return}if(L==="text"&&typeof(b==null?void 0:b.delta)=="string"){te+=b.delta,P(te);const ae=Xe(te);if(ae!==null){const ce=ut(ae);ce!==null&&ce.length>0&&A(ce)}const ue=Qe(te);ue!==null&&U(ue)}else L==="done"?(we=typeof(b==null?void 0:b.reply)=="string"?b.reply:we,Me=typeof(b==null?void 0:b.blocksJson)=="string"?b.blocksJson:typeof(b==null?void 0:b.openUiLang)=="str
117ing"?b.openUiLang:""):L==="error"&&typeof(b==null?void 0:b.message)=="string"&&(Ne=b.message)};try{for(;;){const{done:ae,value:ue}=await Oe.read();if(ae)break;ye+=pt.decode(ue,{stream:!0});const ce=ye.split(` 118 119`);ye=ce.pop()??"";for(const jt of ce){const ft=jt.split(` 120`);let $e="message";const ke=[];for(const pe of ft)pe.startsWith("event:")?$e=pe.slice(6).trim():pe.startsWith("data:")&&ke.push(pe.slice(5).trim());ke.length>0&>($e,ke.join(` 121`))}}if(Ne)throw new Error(Ne);const L=we||Qe(te)||"Updated the page.",I=Me||Xe(te)||"";_(ae=>[...ae,{role:"assistant",content:L}]),P(I||te);const b=Ze(I);b.length>0?(A(b),B(!1)):I.trim().length>0&&B(!0)}catch(L){const I=(L==null?void 0:L.message)??"Streaming failed";u.error(I),_(b=>[...b,{role:"assistant",content:`â ï¸ ${I}`}])}finally{try{Oe.releaseLock()}catch{}O(!1),U("")}},N=g;return e.jsxs("div",{className:"flex-1 min-h-0 grid grid-cols-[minmax(280px,340px)_1fr] overflow-hidden",children:[e.jsxs("div",{className:"border-r border-white/10 bg-black/20 flex flex-col min-h-0",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-white/10 flex items-center gap-2 shrink-0",children:[e.jsx(Yt,{className:"h-4 w-4 text-purple-300"}),e.jsx("h3",{className:"text-sm font-semibold text-white",children:"Site copilot"}),e.jsxs("span",{className:"ml-auto text-[10px] text-white/40",children:[E.filter(l=>l.role==="user").length," turn",E.filter(l=>l.role==="user").length===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-3 space-y-3",children:[E.length===0&&!o&&e.jsxs("div",{className:"text-[11px] text-white/55 leading-relaxed space-y-2 pt-2",children:[e.jsx("p",{children:`Tell me what this page is for and who it's for. I'll draft it using your existing blocks, then you can keep refining it â "punchier hero", "swap the second feature", "add a testimonial section", etc.`}),e.jsx("p",{className:"text-white/40",children:'Example: "Spring beta launch â three benefit cards, an early-access sign-up form, friendly tone."'})]}),E.map((l,n)=>e.jsx("div",{className:`flex ${l.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] rounded-lg px-3 py-2 text-xs leading-relaxed whitespace-pre-wrap ${l.role==="user"?"bg-purple-500/30 text-white":"bg-white/10 text-white/90"}`,children:l.content})},n)),o&&e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"rounded-lg bg-white/10 px-3 py-2 text-xs text-white/90 leading-relaxed whitespace-pre-wrap max-w-[85%] flex items-start gap-2",children:[e.jsx(re,{className:"h-3 w-3 mt-0.5 animate-spin shrink-0"}),e.jsxs("span",{children:[V||"Composingâ¦",e.jsx("span",{className:"inline-block w-1.5 h-3 bg-white/60 ml-0.5 animate-pulse"})]})]})}),e.jsx("div",{ref:f})]}),e.jsxs("div",{className:"border-t border-white/10 p-3 space-y-2 shrink-0",children:[e.jsx(me,{value:D,onChange:l=>$(l.target.value),onKeyDown:l=>{l.key==="Enter"&&!l.shiftKey&&(l.preventDefault(),c())},placeholder:E.length===0?"Describe your landing pageâ¦":"Ask for a changeâ¦",rows:3,disabled:o,className:"text-sm bg-white/5 border-white/10 resize-none"}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-[10px] text-white/40",children:"Enter to send · Shift+Enter for newline"}),e.jsx(y,{onClick:()=>void c(),disabled:o||!D.trim(),size:"sm",className:"bg-white text-purple-900 hover:bg-white/90",children:o?e.jsx(re,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{className:"h-3.5 w-3.5 mr-1"}),"Send"]})})]}),(g.length>0||F.length>0)&&e.jsxs(y,{onClick:()=>s(N),disabled:N.length===0||o,className:"w-full bg-green-500/20 text-green-200 hover:bg-green-500/30 border border-green-500/30",size:"sm",children:["Apply ",N.length," block",N.length===1?"":"s"," to site"]}),(M||F.length>0)&&e.jsxs("details",{className:"text-[10px] text-white/40",open:M,children:[e.jsx("summary",{className:"cursor-pointer hover:text-white/70 select-none",children:M?"â JSON parse failed â show raw output":"Show raw model output"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[M&&e.jsx("p",{className:"bg-yellow-500/10 border border-yellow-500/30 rounded p-2 text-yellow-200",children:"The model returned content but it didn't parse to a SiteBlock array. Either the JSON was truncated or the <blocks> envelope was malformed."}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-white/50 font-semibold uppercase tracking-wider",children:"Raw model output"}),e.jsx("pre",{className:"bg-black/30 p-2 rounded overflow-x-auto whitespace-pre-wrap break-all max-h-72 overflow-y-auto text-white/60",children:F})]})]})]})]})]}),e.jsx("div",{className:"overflow-y-auto bg-muted/20",children:g.length>0?e.jsx(xt,{blocks:g,brandColor:i}):e.jsx("div",{className:"h-full flex items-center justify-center text-center px-8",children:e.jsxs("div",{className:"text-white/50 text-sm max-w-md",children:[e.jsx(Ee,{className:"h-10 w-10 mx-auto mb-3 text-purple-300/60"}),e.jsx("p",{className:"mb-1 font-semibold text-white/70",children:"Site copilot"}),e.jsx("p",{className:"text-xs text-white/40 leading-relaxed",children:"Start the conversation on the left. The page will appear here using your existing blocks, and you can keep iterating until it's right before applying it to the site."})]})})})]})}function is({block:t,isSelected:i,onSelect:a,children:s}){return e.jsxs("div",{role:"button",tabIndex:0,onClick:a,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),a())},className:`relative group cursor-pointer transition-shadow ${i?"outline outline-2 outline-purple-400 outline-offset-[-2px]":"hover:outline hover:outline-1 hover:outline-white/30 hover:outline-offset-[-1px]"}`,children:[e.jsx("div",{className:"absolute top-1 left-1 z-10 text-[10px] uppercase tracking-wider font-semibold text-white/0 group-hover:text-white/70 bg-black/40 px-1.5 py-0.5 rounded pointer-events-none",children:Fe[t.type]}),s]})}function ns({block:t,workspaceId:i,onPatch:a,onDelete:s,onMove:r}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs uppercase tracking-wider font-semibold text-white/60",children:Fe[t.type]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-white/60 hover:text-white hover:bg-white/10",onClick:()=>r(-1),title:"Move up",children:e.jsx(Pt,{className:"h-3 w-3"})}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-white/60 hover:text-white hover:bg-white/10",onClick:()=>r(1),title:"Move down",children:e.jsx(qt,{className:"h-3 w-3"})}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-6 w-6 text-white/60 hover:text-red-400 hover:bg-red-500/10",onClick:s,title:"Delete block",children:e.jsx(fe,{className:"h-3 w-3"})})]})]}),rs(t,i,a)]})}function rs(t,i,a){switch(t.type){case"hero":return e.jsxs(e.Fragment,{children:[e.jsx(G,{label:"Eyebrow",value:t.eyebrow??"",onChange:s=>a({eyebrow:s})}),e.jsx(G,{label:"Title",value:t.title,onChange:s=>a({title:s})}),e.jsx(ie,{label:"Subtitle",value:t.subtitle??"",onChange:s=>a({subtitle:s})}),e.jsx(G,{label:"CTA label",value:t.ctaLabel??"",onChange:s=>a({ctaLabel:s})}),e.jsx(G,{label:"CTA link",value:t.ctaHref??"",onChange:s=>a({ctaHref:s}),placeholder:"e.g. /forms/intake-foo or https://â¦"}
121),e.jsx(G,{label:"Background image URL",value:t.backgroundImageUrl??"",onChange:s=>a({backgroundImageUrl:s})}),e.jsx(ge,{label:"Alignment",value:t.align??"center",options:[{value:"center",label:"Center"},{value:"left",label:"Left"}],onChange:s=>a({align:s})})]});case"text":return e.jsxs(e.Fragment,{children:[e.jsx(ie,{label:"Body",value:t.body,onChange:s=>a({body:s}),rows:6}),e.jsx(ge,{label:"Alignment",value:t.align??"left",options:[{value:"left",label:"Left"},{value:"center",label:"Center"}],onChange:s=>a({align:s})})]});case"imageText":return e.jsxs(e.Fragment,{children:[e.jsx(G,{label:"Image URL",value:t.imageUrl,onChange:s=>a({imageUrl:s})}),e.jsx(G,{label:"Image alt text",value:t.imageAlt??"",onChange:s=>a({imageAlt:s})}),e.jsx(G,{label:"Title",value:t.title??"",onChange:s=>a({title:s})}),e.jsx(ie,{label:"Body",value:t.body??"",onChange:s=>a({body:s})}),e.jsx(ge,{label:"Layout",value:t.layout??"imageLeft",options:[{value:"imageLeft",label:"Image left"},{value:"imageRight",label:"Image right"}],onChange:s=>a({layout:s})})]});case"featureGrid":return e.jsxs(e.Fragment,{children:[e.jsx(G,{label:"Section title",value:t.title??"",onChange:s=>a({title:s})}),e.jsx(ge,{label:"Columns",value:String(t.columns??3),options:[{value:"2",label:"2 columns"},{value:"3",label:"3 columns"}],onChange:s=>a({columns:Number(s)})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-[10px] uppercase tracking-wider font-semibold text-white/60",children:"Features"}),t.items.map((s,r)=>e.jsxs("div",{className:"rounded border border-white/10 p-2 space-y-1.5 bg-white/[0.03]",children:[e.jsx(T,{value:s.title,placeholder:"Feature title",onChange:d=>{const x=[...t.items];x[r]={...x[r],title:d.target.value},a({items:x})},className:"text-xs bg-white/5 border-white/10"}),e.jsx(me,{value:s.body??"",placeholder:"Description",rows:2,onChange:d=>{const x=[...t.items];x[r]={...x[r],body:d.target.value},a({items:x})},className:"text-xs bg-white/5 border-white/10"}),e.jsx("button",{onClick:()=>{const d=t.items.filter((x,j)=>j!==r);a({items:d})},className:"text-[10px] text-white/40 hover:text-red-400",children:"Remove"})]},r)),e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>a({items:[...t.items,{title:"New feature",body:"Describe it."}]}),className:"w-full text-xs text-white/70 hover:text-white hover:bg-white/10",children:[e.jsx(le,{className:"h-3 w-3 mr-1"}),"Add feature"]})]})]});case"cta":return e.jsxs(e.Fragment,{children:[e.jsx(G,{label:"Title",value:t.title,onChange:s=>a({title:s})}),e.jsx(ie,{label:"Subtitle",value:t.subtitle??"",onChange:s=>a({subtitle:s})}),e.jsx(G,{label:"Button label",value:t.buttonLabel,onChange:s=>a({buttonLabel:s})}),e.jsx(G,{label:"Button link",value:t.buttonHref,onChange:s=>a({buttonHref:s}),placeholder:"e.g. /forms/intake-foo or https://â¦"})]});case"formEmbed":return e.jsxs(e.Fragment,{children:[e.jsx(G,{label:"Title",value:t.title??"",onChange:s=>a({title:s})}),e.jsx(ie,{label:"Intro text",value:t.body??"",onChange:s=>a({body:s})}),e.jsx(ls,{workspaceId:i,value:t.formId,onChange:s=>a({formId:s==null?void 0:s.id,formSlug:s==null?void 0:s.slug,formName:s==null?void 0:s.name})})]});case"eventEmbed":return e.jsxs(e.Fragment,{children:[e.jsx(G,{label:"Title",value:t.title??"",onChange:s=>a({title:s})}),e.jsx(ie,{label:"Intro text",value:t.body??"",onChange:s=>a({body:s})}),e.jsx(cs,{workspaceId:i,value:t.eventId,onChange:s=>a({eventId:s==null?void 0:s.id,eventSlug:s==null?void 0:s.slug,eventName:s==null?void 0:s.name})})]});case"footer":return e.jsxs(e.Fragment,{children:[e.jsx(ie,{label:"Body",value:t.body??"",onChange:s=>a({body:s})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"text-[10px] uppercase tracking-wider font-semibold text-white/60",children:"Links"}),(t.links??[]).map((s,r)=>e.jsxs("div",{className:"space-y-1 border border-white/10 p-2 rounded bg-white/[0.03]",children:[e.jsx(T,{placeholder:"Label",value:s.label,onChange:d=>{const x=[...t.links??[]];x[r]={...x[r],label:d.target.value},a({links:x})},className:"text-xs bg-white/5 border-white/10"}
121),e.jsx(T,{placeholder:"URL",value:s.href,onChange:d=>{const x=[...t.links??[]];x[r]={...x[r],href:d.target.value},a({links:x})},className:"text-xs bg-white/5 border-white/10"}),e.jsx("button",{onClick:()=>{const d=(t.links??[]).filter((x,j)=>j!==r);a({links:d})},className:"text-[10px] text-white/40 hover:text-red-400",children:"Remove"})]},r)),e.jsxs(y,{variant:"ghost",size:"sm",onClick:()=>a({links:[...t.links??[],{label:"Privacy",href:"/privacy"}]}),className:"w-full text-xs text-white/70 hover:text-white hover:bg-white/10",children:[e.jsx(le,{className:"h-3 w-3 mr-1"}),"Add link"]})]})]})}return null}function G({label:t,value:i,onChange:a,placeholder:s}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:"text-[10px] uppercase tracking-wider font-semibold text-white/60",children:t}),e.jsx(T,{value:i,onChange:r=>a(r.target.value),placeholder:s,className:"text-xs bg-white/5 border-white/10"})]})}function ie({label:t,value:i,onChange:a,rows:s=3}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:"text-[10px] uppercase tracking-wider font-semibold text-white/60",children:t}),e.jsx(me,{value:i,onChange:r=>a(r.target.value),rows:s,className:"text-xs bg-white/5 border-white/10"})]})}function ge({label:t,value:i,options:a,onChange:s}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:"text-[10px] uppercase tracking-wider font-semibold text-white/60",children:t}),e.jsxs(K,{value:i,onValueChange:s,children:[e.jsx(X,{className:"text-xs bg-white/5 border-white/10 h-8",children:e.jsx(Q,{})}),e.jsx(Z,{children:a.map(r=>e.jsx(W,{value:r.value,children:r.label},r.value))})]})]})}function ls({workspaceId:t,value:i,onChange:a}){const r=z(S.crmForms.queries.listForms,{workspaceId:t});return e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:"text-[10px] uppercase tracking-wider font-semibold text-white/60",children:"Form to embed"}),e.jsxs(K,{value:i?String(i):"",onValueChange:d=>{const x=r==null?void 0:r.find(j=>String(j._id)===d);a(x?{id:x._id,slug:x.slug,name:x.name}:null)},children:[e.jsx(X,{className:"text-xs bg-white/5 border-white/10 h-8",children:e.jsx(Q,{placeholder:"Pick a formâ¦"})}),e.jsxs(Z,{children:[(r??[]).map(d=>e.jsxs(W,{value:String(d._id),children:[d.name,!d.isPublished&&" (draft)"]},d._id)),(r??[]).length===0&&e.jsx(W,{value:"__none__",disabled:!0,children:"No forms yet"})]})]}),e.jsx("p",{className:"text-[10px] text-white/40",children:"Forms must be published to render on the public page."})]})}function cs({workspaceId:t,value:i,onChange:a}){const r=z(S.crmEvents.queries.listEvents,{workspaceId:t});return e.jsxs("div",{className:"space-y-1",children:[e.jsx(v,{className:"text-[10px] uppercase tracking-wider font-semibold text-white/60",children:"Event to embed"}),e.jsxs(K,{value:i?String(i):"",onValueChange:d=>{const x=r==null?void 0:r.find(j=>String(j._id)===d);a(x?{id:x._id,slug:x.slug,name:x.name}:null)},children:[e.jsx(X,{className:"text-xs bg-white/5 border-white/10 h-8",children:e.jsx(Q,{placeholder:"Pick an eventâ¦"})}),e.jsxs(Z,{children:[(r??[]).map(d=>e.jsxs(W,{value:String(d._id),children:[d.name,!d.isPublished&&" (draft)"]},d._id)),(r??[]).length===0&&e.jsx(W,{value:"__none__",disabled:!0,children:"No events yet"})]})]}),e.jsx("p",{className:"text-[10px] text-white/40",children:"Events must be published to render on the public page."})]})}function os({workspaceId:t}){const[i,a]=m.useState(null);return i?e.jsx(ts,{siteId:i,onBack:()=>a(null)}):e.jsx(ds,{workspaceId:t,onOpenSite:s=>a(s)})}function ds({workspaceId:t,onOpenSite:i}){const a=S,s=z(a.marketingSites.listSites,{workspaceId:t}),r=q(a.marketingSites.createSite),d=q(a.marketingSites.deleteSite),[x,j]=m.useState(!1),[h,p]=m.useState(""),[R,E]=m.useState(!1),_=async()=>{const g=h.trim()||"Untitled site";E(!0);try{const A=await r({workspaceId:t,name:g,blocks:Ut()});u.success("Site created"),j(!1),p(""),i(A)}catch(A){u.error(A.message??"Failed to create site")}finally{E(!1)}},D=async g=>{const A=`${window.location.origin}/sites/${g}`;try{await navigator.clipboard.writeText(A),u.success("Public link copied")}catch{u.error("Could not copy link")}},$=async g=>
121{if(confirm("Delete this site? This can't be undone."))try{await d({siteId:g}),u.success("Site deleted")}catch(A){u.error(A.message??"Failed to delete site")}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sites"}),e.jsx("p",{className:"text-xs text-white/60 mt-0.5",children:"Build landing pages for events, campaigns, or product launches. Embed Forms and Events you've already created."})]}),e.jsxs(y,{onClick:()=>j(!0),className:"bg-white text-purple-900 hover:bg-white/90",size:"sm",children:[e.jsx(le,{className:"h-4 w-4 mr-1.5"}),"New site"]})]}),s===void 0?e.jsx("div",{className:"text-sm text-white/60",children:"Loadingâ¦"}):s.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center",children:[e.jsx(Pe,{className:"h-10 w-10 text-white/20 mb-3"}),e.jsx("p",{className:"text-sm text-white/70 mb-1",children:"No sites yet"}),e.jsx("p",{className:"text-xs text-white/50 mb-4",children:"Create your first landing page to get started."}),e.jsxs(y,{onClick:()=>j(!0),className:"bg-white text-purple-900 hover:bg-white/90",size:"sm",children:[e.jsx(le,{className:"h-4 w-4 mr-1.5"}),"New site"]})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:s.map(g=>e.jsx("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] p-4 hover:bg-white/[0.05] transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("button",{onClick:()=>i(g._id),className:"flex-1 text-left min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-white truncate",children:g.name}),e.jsx("span",{className:`text-[10px] uppercase tracking-wide font-semibold px-1.5 py-0.5 rounded ${g.isPublished?"bg-green-500/20 text-green-300":"bg-white/10 text-white/60"}`,children:g.isPublished?"Published":"Draft"})]}),e.jsxs("p",{className:"text-xs text-white/50 mt-1 truncate",children:["/sites/",g.slug," · ",g.blockCount," block",g.blockCount===1?"":"s"]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-white/60 hover:text-white hover:bg-white/10",onClick:()=>i(g._id),title:"Edit",children:e.jsx(De,{className:"h-3.5 w-3.5"})}),g.isPublished&&e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-white/60 hover:text-white hover:bg-white/10",onClick:()=>D(g.slug),title:"Copy public link",children:e.jsx(it,{className:"h-3.5 w-3.5"})}),e.jsx(y,{variant:"ghost",size:"icon",className:"h-7 w-7 text-white/60 hover:text-red-400 hover:bg-red-500/10",onClick:()=>$(g._id),title:"Delete",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})]})]})},g._id))}),e.jsx(Te,{open:x,onOpenChange:j,children:e.jsxs(Re,{className:"bg-popover/95 backdrop-blur-xl border-border text-foreground max-w-md",children:[e.jsxs(Le,{children:[e.jsx(Ie,{children:"New site"}),e.jsx(_t,{children:"A starter hero / features / CTA / footer layout will be added automatically â you can edit it after."})]}),e.jsx("div",{className:"space-y-3 py-2",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(v,{htmlFor:"site-name",children:"Site name"}),e.jsx(T,{id:"site-name",placeholder:"Spring product launch",value:h,onChange:g=>p(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!R&&_()},autoFocus:!0})]})}),e.jsxs(Be,{children:[e.jsx(y,{variant:"ghost",onClick:()=>j(!1),disabled:R,children:"Cancel"}),e.jsx(y,{onClick:_,disabled:R,children:R?"Creatingâ¦":"Create site"})]})]})})]})}const ms=[{key:"forms",label:"Forms",icon:je},{key:"events",label:"Events",icon:Gt},{key:"sites",label:"Sites",icon:Pe}];function va({workspaceId:t}){const[i,a]=m.useState("forms");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-white/10 overflow-x-auto shrink-0",children:ms.map(s=>{const r=s.icon,d=i===s.key;return e.jsxs("button",{onClick:()=>a(s.key),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium whitespace-nowrap transition-colors ${d?"bg-white/20 text-white":"text-white/50 hover:text-white/80 hover:bg-white/10"}`,children:[e.jsx(r,{className:"h-3.5 w-3.5"}),s.label]},s.key)})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:[i==="forms"&&e.jsx(Mt,{workspaceId:t}),i==="events"&&e.jsx(Jt,{workspaceId:t}),i==="sites"&&e.jsx(os,{workspaceId:t})]})]})}function ve({status:t}){const i={draft:"bg-yellow-500/20 text-yellow-300",scheduled:"bg-blue-500/20 text-blue-300",active:"bg-green-500/20 text-green-300",paused:"bg-orange-500/20 text-orange-300",completed:"bg-slate-500/20 text-slate-300",archived:"bg-slate-700/20 text-slate-400",pending:"bg-yellow-500/20 text-yellow-300",in_progress:"bg-blue-500/20 text-blue-300",rejected:"bg-red-500/20 text-red-300"};return e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${i[t]||"bg-white/10 text-white/60"}`,children:t.replace(/_/g," ")})}function xs({workspaceId:t}){const i=z(S.marketing.queries.myCampaigns,{workspaceId:t});return i?i.length===0?e.jsxs("div",{className:"text-center py-12 text-white/40",children:[e.jsx(be,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"You haven't created any campaigns yet"}),e.jsx("p",{className:"text-xs mt-1",children:"Switch to Management view to create campaigns"})]}):e.jsx("div",{className:"space-y-2",children:i.map(a=>e.jsx(H,{className:"bg-white/5 border-white/10 hover:bg-white/8 transition-colors",children:e.jsx(Y,{className:"p-3",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-white text-sm truncate",children:a.name}),e.jsx(ve,{status:a.status}),e.jsx("span",{className:"text-[10px] text-white/40 bg-white/5 px-1.5 py-0.5 rounded",children:a.type})]}),a.description&&e.jsx("p",{className:"text-xs text-white/50 mt-0.5 truncate",children:a.description}),e.jsxs("p",{className:"text-[10px] text-white/30 mt-0.5",children:["Updated ",new Date(a.updatedAt).toLocaleDateString()]})]})})})},a._id))}):e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(re,{className:"h-5 w-5 animate-spin text-white/40"})})}function hs({workspaceId:t}){const i=z(S.marketing.queries.myCampaigns,{workspaceId:t}),a=z(S.marketing.queries.listTemplates,{workspaceId:t});if(!i||!a)return e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(re,{className:"h-5 w-5 animate-spin text-white/40"})});const s=i.filter(r=>r.status==="draft");return s.length===0&&a.length===0?e.jsxs("div",{className:"text-center py-12 text-white/40",children:[e.jsx(De,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No drafts"}),e.jsx("p",{className:"text-xs mt-1",children:"Draft campaigns and templates will appear here"})]}):e.jsxs("div",{className:"space-y-4",children:[s.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-medium text-white/50 uppercase tracking-wider mb-2",children:"Draft Campaigns"}),e.jsx("div",{className:"space-y-2",children:s.map(r=>e.jsx(H,{className:"bg-white/5 border-white/10",children:e.jsxs(Y,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(be,{className:"h-3.5 w-3.5 text-yellow-400/60"}),e.jsx("span",{className:"font-medium text-white text-sm truncate",children:r.name}),e.jsx(ve,{status:"draft"})]}),r.description&&e.jsx("p",{className:"text-xs text-white/50 mt-0.5 truncate ml-5",children:r.description})]})},r._id))})]}),a.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-medium text-white/50 uppercase tracking-wider mb-2",children:"Email Templates"}),e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(H,{className:"bg-white/5 border-white/10",children:e.jsxs(Y,{className:"p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-3.5 w-3.5 text-blue-400/60"}),e.jsx("span",{className:"font-medium text-white text-sm truncate",children:r.name})]}),r.subject&&e.jsxs("p",{className:"text-xs text-white/50 mt-0.5 truncate ml-5",children:["Subject: ",r.subject]})]})},r._id))})]})]})}function us({workspaceId:t}){const i=z(S.marketing.queries.myApprovals,{workspaceId:t}),a=q(S.marketing.mutations.updateTask);return i?i.length===0?e.jsxs("div",{className:"text-center py-12 text-white/40",children:[e.jsx(nt,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No pending approvals"}),e.jsx("p",{className:"text-xs mt-1",children:"Items needing your review will appear here"})]}):e.jsx("div",{className:"space-y-2",children:i.map(s=>e.jsx(H,{className:"bg-white/5 border-white/10",children:e.jsx(Y,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-white text-sm",children:s.title}),e.jsx(ve,{status:s.status}),e.jsx("span",{className:"text-[10px] bg-white/10 text-white/50 px-1.5 py-0.5 rounded",children:s.type})]}),s.description&&e.jsx("p",{className:"text-xs text-white/50 mt-0.5 truncate",children:s.description}),s.dueAt&&e.jsxs("p",{className:"text-[10px] text-white/30 mt-0.5 flex items-center gap-1",children:[e.jsx(rt,{className:"h-3 w-3"}),"Due ",new Date(s.dueAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[e.jsx(y,{variant:"ghost",size:"sm",className:"h-7 text-xs text-green-600 dark:text-green-400",onClick:async()=>{try{await a({taskId:s._id,status:"completed"}),u.success("Approved")}catch(r){u.error(r.message)}},children:"Approve"}),e.jsx(y,{variant:"ghost",size:"sm",className:"h-7 text-xs text-red-600 dark:text-red-400",onClick:async()=>{try{await a({taskId:s._id,status:"rejected"}),u.success("Rejected")}catch(r){u.error(r.message)}},children:"Reject"})]})]})})},s._id))}):e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(re,{className:"h-5 w-5 animate-spin text-white/40"})})}function ps({workspaceId:t}){const i=z(S.marketing.queries.myTasks,{workspaceId:t}),a=q(S.marketing.mutations.updateTask);if(!i)return e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(re,{className:"h-5 w-5 animate-spin text-white/40"})});const s=i.filter(r=>r.status!=="completed"&&r.status!=="rejected");return s.length===0?e.jsxs("div",{className:"text-center py-12 text-white/40",children:[e.jsx(ot,{className:"h-10 w-10 mx-auto mb-3 opacity-30"}),e.jsx("p",{children:"No active tasks"}),e.jsx("p",{className:"text-xs mt-1",children:"Tasks assigned to you will appear here"})]}):e.jsx("div",{className:"space-y-2",children:s.map(r=>e.jsx(H,{className:"bg-white/5 border-white/10",children:e.jsx(Y,{className:"p-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-white text-sm",children:r.title}),e.jsx(ve,{status:r.status})]}),r.description&&e.jsx("p",{className:"text-xs text-white/50 mt-0.5 truncate",children:r.description}),r.dueAt&&e.jsxs("p",{className:"text-[10px] text-white/30 mt-0.5 flex items-center gap-1",children:[e.jsx(rt,{className:"h-3 w-3"}),"Due ",new Date(r.dueAt).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0 ml-2",children:[r.status==="pending"&&e.jsx(y,{variant:"ghost",size:"sm",className:"h-7 text-xs text-blue-600 dar
121k:text-blue-400",onClick:async()=>{try{await a({taskId:r._id,status:"in_progress"}),u.success("Started")}catch(d){u.error(d.message)}},children:"Start"}),r.status==="in_progress"&&e.jsx(y,{variant:"ghost",size:"sm",className:"h-7 text-xs text-green-600 dark:text-green-400",onClick:async()=>{try{await a({taskId:r._id,status:"completed"}),u.success("Completed")}catch(d){u.error(d.message)}},children:"Complete"})]})]})})},r._id))})}const gs=[{key:"my-campaigns",label:"My Campaigns",icon:be},{key:"my-drafts",label:"My Drafts",icon:De},{key:"my-approvals",label:"My Approvals",icon:nt},{key:"my-tasks",label:"My Tasks",icon:ot}];function wa({workspaceId:t}){const[i,a]=m.useState("my-campaigns");return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex items-center gap-1 px-4 py-2 border-b border-white/10 overflow-x-auto shrink-0",children:gs.map(s=>{const r=s.icon,d=i===s.key;return e.jsxs("button",{onClick:()=>a(s.key),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium whitespace-nowrap transition-colors ${d?"bg-white/20 text-white":"text-white/50 hover:text-white/80 hover:bg-white/10"}`,children:[e.jsx(r,{className:"h-3.5 w-3.5"}),s.label]},s.key)})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:[i==="my-campaigns"&&e.jsx(xs,{workspaceId:t}),i==="my-drafts"&&e.jsx(hs,{workspaceId:t}),i==="my-approvals"&&e.jsx(us,{workspaceId:t}),i==="my-tasks"&&e.jsx(ps,{workspaceId:t})]})]})}export{ba as MarketingDashboard,va as MarketingManagementBoard,wa as MarketingYouBoard};
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.