PageSourceSearch

https://tyrrst.com/assets/AdminAgent-k96WGxbn.js

js tyrrst.com collected 2026-10-04 08:36:50 UTC 57,418 bytes, 33 lines download raw bytes

1import{am as qt,y as d,j as e,C as ge,c as be,B as de,bG as at,l as It,e as E,ar as Pe,a7 as Tt,D as Ht,q as Wt,t as Mt,aQ as Dt,bc as tt,a8 as nt,af as rt,bi as Jt,aJ as Kt,aK as ze,cK as Vt,aL as Qt,di as Yt,h5 as Xt,aZ as Zt,aj as Et,cv as es,an as ts,N as we,f as ss,g as as,at as ns,h6 as rs,R as is,s as G,a9 as os,h7 as ls,a as cs,c5 as ds,h8 as us,bK as ms,c6 as ps,dV as hs,h9 as wt,b as fs,E as gs,F as xs,H as ys,I as js,K as bt,ah as vs,et as ws,ct as bs,d as Ns,U as _s,bd as Ss,be as Cs,aw as Nt,bg as ks,bM as As,cx as Ps,dj as $s}from"./index-DbRCge_b.js";import{f as Is,u as Ts,A as _t,M as Ds,a as Es,b as Us,P as St,c as Ct,d as Os}from"./AgentMarkdown-D5ffi1d9.js";import{B as Rs}from"./BlogPostPreviewDialog-CBo_bFkx.js";import{C as Ls}from"./CampaignPreviewDialog-BEINE9Na.js";import{L as it}from"./layers-qQiDzmCl.js";import{C as Ut}from"./chevron-left-otQvquz5.js";import{T as Gs}from"./twitter-RpePWtVU.js";import{P as Bs}from"./panel-left-close-BjVwfhdJ.js";import{F as zs}from"./folder-kanban-Dla34vO_.js";import{C as Fs}from"./camera-8d2r8buE.js";import{F as qs}from"./file-spreadsheet-DQcjtS1V.js";import"./thumbs-up-DPq2hQ6O.js";import"./thumbs-down-DwnpK21T.js";import"./pin-wH2IdiVg.js";import"./ellipsis-C52q1PAX.js";import"./pin-off-dOYEmYFk.js";import"./archive-Db1TKwYv.js";import"./safeHref-Dp_8p3pl.js";import"./CalendarItemCard-BCgvZcV8.js";import"./repeat-2-CxVPhkXW.js";import"./RegenerateAsVideoDialog-DXsr0_Gl.js";import"./calendar-clock-4oo4na1N.js";import"./confirmDialog-Cm1Gmyxw.js";import"./socialCaption-BBgsKNHu.js";import"./useLibraryImageGenerator-bXN5e2Hw.js";import"./checkbox-sFWhOlLj.js";import"./file-image-C8lbLm3o.js";import"./undo-2-ByfDhlmT.js";import"./wand-sparkles-qYWYiSai.js";import"./images-DPf8Txyt.js";import"./save-DswrUs6y.js";import"./calendar-D9KMM6YQ.js";import"./isSameDay-BPXu8SUl.js";import"./subDays-F8Uwy2sH.js";import"./startOfMonth-BCFvYu0R.js";import"./addMonths-D3omS4bB.js";import"./endOfWeek-z0QK1Wl8.js";import"./time-picker-C1lzYAm-.js";import"./setMinutes-BZtdMhhh.js";import"./startOfTomorrow-Dp4YPFZy.js";import"./check-check-DPnn-GeD.js";import"./smartphone-j6W-bAKV.js";import"./copy-Dv1HM7yJ.js";import"./index-5xf1HqAF.js";import"./generateCategoricalChart-DbgS7qOm.js";import"./isEqual-zGZ-YF4u.js";import"./index-B3RdVPIz.js";import"./PieChart-CidJXHyo.js";import"./LineChart-DujBePG5.js";import"./Line-T4V52IYx.js";import"./YAxis-D17Hup7O.js";import"./BarChart-BqpRPRNU.js";import"./campaignConditions-0peUYoPv.js";import"./EmailBodyRenderer-Dn7rT71U.js";import"./monitor-CgjHojax.js";function Ot({images:s,labels:a,initialIndex:r=0,open:n,onOpenChange:j}){const x=s.length,[l,p]=d.useState(r);d.useEffect(()=>{n&&p(r)},[n,r]);const b=()=>p(f=>f>0?f-1:x-1),h=()=>p(f=>f<x-1?f+1:0);d.useEffect(()=>{if(!n||x<=1)return;const f=y=>{y.key==="ArrowLeft"?(y.preventDefault(),b()):y.key==="ArrowRight"&&(y.preventDefault(),h())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[n,x]);const S=s[l],o=(a==null?void 0:a[l])||`Slide ${l+1}`,U=()=>{const f=document.createElement("a");f.href=S,f.download=(a==null?void 0:a[l])||`slide-${l+1}.png`,f.target="_blank",f.click()};return e.jsx(Ht,{open:n,onOpenChange:j,children:e.jsxs(Wt,{className:"max-w-[90vw] max-h-[90vh] p-2 flex flex-col items-center gap-2","aria-describedby":void 0,children:[e.jsx(Mt,{className:"sr-only",children:o}),e.jsxs("div",{className:"relative w-full flex items-center justify-center",children:[e.jsx("img",{src:S,alt:o,className:"max-w-full max-h-[75vh] object-contain rounded"}),x>1&&e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"secondary",size:"icon",className:"absolute left-2 top-1/2 -translate-y-1/2 h-9 w-9 rounded-full opacity-90 hover:opacity-100 shadow",onClick:b,"aria-label":"Previous slide",children:e.jsx(Ut,{className:"h-5 w-5"})}),e.jsx(E,{variant:"secondary",size:"icon",className:"absolute right-2 top-1/2 -translate-y-1/2 h-9 w-9 rounded-full opacity-90 hover:opacity-100 shadow",onClick:h,"aria-label":"Next slide",children:e.jsx(Dt,{className:"h-5 w-5"})}),e.jsxs("div",{className:"absolute bottom-2 right-2 bg-background/80 text-foreground text-xs px-2 py-0.5 rounded-full font-medium",children:[l+1," / ",x]})]})]}),x>1&&e.jsx("div",{className:"flex justify-center gap-1.5",children:s.map((f,y)=>e.jsx("button",{className:tt("w-2 h-2 rounded-full transition-all",y===l?"bg-primary scale-110":"bg-muted-foreground
1/30 hover:bg-muted-foreground/50"),onClick:()=>p(y),"aria-label":`Go to slide ${y+1}`},y))}),(a==null?void 0:a[l])&&e.jsx("p",{className:"text-xs text-muted-foreground text-center truncate max-w-full px-4",children:a[l]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(E,{variant:"outline",size:"sm",className:"text-xs gap-1",onClick:U,children:[e.jsx(nt,{className:"w-3 h-3"}),"Download ",x>1?"slide":"image"]}),e.jsx(E,{variant:"outline",size:"sm",className:"text-xs gap-1",asChild:!0,children:e.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Pe,{className:"w-3 h-3"}),"Open in new tab"]})})]})]})})}const Hs={blog:{icon:rt,label:"Blog Post",color:"bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300",dashboardPath:"/admin/marketing/posts",dashboardLabel:"Blog Dashboard"},social:{icon:Jt,label:"Social Media Post",color:"bg-pink-100 text-pink-800 dark:bg-pink-900/40 dark:text-pink-300",dashboardPath:"/admin/marketing/social-posts",dashboardLabel:"Social Dashboard"},email:{icon:Kt,label:"Email / Campaign",color:"bg-amber-100 text-amber-800 dark:bg-amber-900/40 dark:text-amber-300",dashboardPath:"/admin/marketing/campaigns",dashboardLabel:"Campaigns"},carousel:{icon:it,label:"Carousel",color:"bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300",dashboardPath:"/admin/marketing/generated-images",dashboardLabel:"Image Library"},event_image:{icon:at,label:"Event Image",color:"bg-emerald-100 text-emerald-800 dark:bg-emerald-900/40 dark:text-emerald-300",dashboardPath:"/admin/events",dashboardLabel:"Events Dashboard"}},Ws={instagram:ze,"instagram-post":ze,"instagram-story":ze,"instagram-reel":ze,linkedin:Vt,twitter:Gs,facebook:Qt};function Ms({imageUrls:s,slideLabels:a}){const[r,n]=d.useState(0),[j,x]=d.useState(!1),l=s.length,p=()=>n(S=>S>0?S-1:l-1),b=()=>n(S=>S<l-1?S+1:0),h=()=>{const S=s[r],o=document.createElement("a");o.href=S,o.download=(a==null?void 0:a[r])||`slide-${r+1}.png`,o.target="_blank",o.click()};return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Ot,{images:s,labels:a,initialIndex:r,open:j,onOpenChange:x}),e.jsxs("div",{className:"relative rounded-md overflow-hidden bg-muted aspect-square max-h-[300px] cursor-zoom-in",onClick:()=>x(!0),children:[e.jsx("img",{src:s[r],alt:(a==null?void 0:a[r])||`Slide ${r+1}`,className:"w-full h-full object-contain"}),l>1&&e.jsxs(e.Fragment,{children:[e.jsx(E,{variant:"secondary",size:"icon",className:"absolute left-1 top-1/2 -translate-y-1/2 h-7 w-7 rounded-full opacity-80 hover:opacity-100",onClick:p,children:e.jsx(Ut,{className:"h-4 w-4"})}),e.jsx(E,{variant:"secondary",size:"icon",className:"absolute right-1 top-1/2 -translate-y-1/2 h-7 w-7 rounded-full opacity-80 hover:opacity-100",onClick:b,children:e.jsx(Dt,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"absolute bottom-2 right-2 bg-background/80 text-foreground text-[10px] px-2 py-0.5 rounded-full font-medium",children:[r+1," / ",l]})]}),l>1&&e.jsx("div",{className:"flex justify-center gap-1.5",children:s.map((S,o)=>e.jsx("button",{className:tt("w-2 h-2 rounded-full transition-all",o===r?"bg-primary scale-110":"bg-muted-foreground/30 hover:bg-muted-foreground/50"),onClick:()=>n(o),"aria-label":`Go to slide ${o+1}`},o))}),l>1&&e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-1",children:s.map((S,o)=>e.jsx("button",{className:tt("flex-shrink-0 w-12 h-12 rounded border-2 overflow-hidden transition-all",o===r?"border-primary":"border-transparent opacity-60 hover:opacity-100"),onClick:()=>n(o),children:e.jsx("img",{src:S,alt:(a==null?void 0:a[o])||`Thumb ${o+1}`,className:"w-full h-full object-cover"})},o))}),(a==null?void 0:a[r])&&e.jsx("p",{className:"text-xs text-muted-foreground text-center truncate",children:a[r]}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(E,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:h,children:[e.jsx(nt,{className:"w-3 h-3"}),"Download Slide"]})})]})}function Ye({block:s,onOpenSocial:a}){const r=qt(),[n,j]=d.useState(!1),[x,l]=d.useState(!1),[p,b]=d.useState(!1),[h,S]=d.use
1State(!1),o=Hs[s.type],U=o.icon,f=()=>{s.type==="blog"?j(!0):s.type==="email"?l(!0):s.type==="social"&&(a&&s.id?a(s.id):r(o.dashboardPath))},y=s.platform?Ws[s.platform.toLowerCase()]:null;return s.type==="event_image"&&s.imageUrl?e.jsxs(e.Fragment,{children:[e.jsx(Ot,{images:s.imageUrl?[s.imageUrl]:[],labels:s.title?[s.title]:void 0,open:h,onOpenChange:S}),e.jsx(ge,{className:"mt-2 border-l-4",style:{borderLeftColor:"#10b981"},children:e.jsxs(be,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(de,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${o.color}`,children:[e.jsx(at,{className:"w-3 h-3 mr-1"}),s.status==="attached"?"Event Image Attached":"Event Image Preview"]}),s.status&&e.jsx(de,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:s.status==="attached"?"✓ Attached":"Preview"})]}),e.jsx("div",{className:"relative rounded-md overflow-hidden bg-muted aspect-video max-h-[250px] cursor-zoom-in",onClick:()=>!p&&S(!0),children:p?e.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center text-muted-foreground gap-2 p-4",children:[e.jsx(It,{className:"w-8 h-8"}),e.jsx("p",{className:"text-xs text-center",children:"Preview unavailable"}),e.jsx("a",{href:s.imageUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-primary underline",children:"Open image link"})]}):e.jsx("img",{src:s.imageUrl,alt:s.title||"Event image preview",className:"w-full h-full object-contain",onError:()=>b(!0)})}),s.title&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.title}),e.jsxs("div",{className:"flex gap-2 justify-center",children:[!p&&e.jsx(E,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",asChild:!0,children:e.jsxs("a",{href:s.imageUrl,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Pe,{className:"w-3 h-3"}),"Open Full Size"]})}),e.jsxs(E,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>r(o.dashboardPath),children:[e.jsx(Pe,{className:"w-3 h-3"}),o.dashboardLabel]})]})]})})]}):s.type==="carousel"&&s.imageUrls&&s.imageUrls.length>0?e.jsx(ge,{className:"mt-2 border-l-4",style:{borderLeftColor:"#a855f7"},children:e.jsxs(be,{className:"p-3 space-y-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(de,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${o.color}`,children:[e.jsx(it,{className:"w-3 h-3 mr-1"}),"Carousel • ",s.imageUrls.length," slides"]})}),e.jsx(Ms,{imageUrls:s.imageUrls,slideLabels:s.slideLabels}),e.jsx("div",{className:"flex justify-center",children:e.jsxs(E,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>r(o.dashboardPath),children:[e.jsx(Pe,{className:"w-3 h-3"}),o.dashboardLabel]})})]})}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"mt-2 border-l-4",style:{borderLeftColor:s.type==="blog"?"#3b82f6":s.type==="social"?"#ec4899":"#f59e0b"},children:e.jsxs(be,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(de,{variant:"secondary",className:`text-[10px] px-1.5 py-0 ${o.color}`,children:[e.jsx(U,{className:"w-3 h-3 mr-1"}),o.label," Created"]}),s.status&&e.jsx(de,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:s.status}),y&&e.jsx(y,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),e.jsxs("div",{className:"text-sm space-y-1",children:[s.title&&e.jsx("p",{className:"font-medium line-clamp-1",children:s.title}),s.subject&&e.jsxs("p",{className:"font-medium line-clamp-1",children:["Subject: ",s.subject]}),s.excerpt&&e.jsx("p",{className:"text-muted-foreground text-xs line-clamp-2",children:s.excerpt}),s.caption&&e.jsx("p",{className:"text-muted-foreground text-xs line-clamp-2",children:s.caption}),s.body&&!s.caption&&!s.excerpt&&e.jsx("p",{className:"text-muted-foreground text-xs line-clamp-2",dangerouslySetInnerHTML:{__html:s.body.replace(/<[^>]+>/g,"").slice(0,200)}}),s.hashtags&&s.hashtags.length>0&&e.jsx("p",{className:"text-xs text-primary/70 truncate",children:s.hashtags.map($=>$.startsWith("#")?$:`#${$}`).join(" ")})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsxs(E,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:f,children:[e.jsx(Tt,{className:"w-3 h-3"}),"Preview"]}),e.jsxs(E,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>r(o.dashboardPath),children:[e.jsx(Pe,{className:"w-3 h-3"}),o.dashboardLabel]})]})]})}),s.type==="blog"&&e.jsx(Rs,{open:n,onOpenChange:j,post:{title:s.title||"Untitled",excerpt:s.excerpt,content:s.content||s.body}}),s.type==="email"&&e.jsx(Ls,{open:x,onOpenChange:l,subject:s.subject||"(No subject)",body:s.body||s.c
1ontent||""})]})}const kt=(s,a)=>{if(!s)return"";const r=(a??new Date).getTime()-s.getTime(),n=Math.max(0,Math.floor(r/1e3)),j=Math.floor(n/60),x=n%60;return`${String(j).padStart(2,"0")}:${String(x).padStart(2,"0")}`},At=s=>{switch(s){case"running":return e.jsx(we,{className:"h-3.5 w-3.5 animate-spin text-primary"});case"queued":return e.jsx(Et,{className:"h-3.5 w-3.5 text-muted-foreground"});case"done":return e.jsx(ts,{className:"h-3.5 w-3.5 text-green-600"});case"error":return e.jsx(It,{className:"h-3.5 w-3.5 text-destructive"});case"cancelled":return e.jsx(es,{className:"h-3.5 w-3.5 text-muted-foreground"})}},Js=()=>{const s=Yt(),[a,r]=d.useState(null),n=(s==null?void 0:s.runningTasks)??[],j=(s==null?void 0:s.tasks.filter(p=>p.status==="queued"))??[];if(Xt(n.length>0),d.useEffect(()=>{if(!s)return;const p=[...s.tasks].filter(h=>h.status==="done"||h.status==="error").sort((h,S)=>{var o,U;return(((o=S.finishedAt)==null?void 0:o.getTime())??0)-(((U=h.finishedAt)==null?void 0:U.getTime())??0)})[0];if(!p||(a==null?void 0:a.id)===p.id)return;r(p);const b=setTimeout(()=>{r(h=>(h==null?void 0:h.id)===p.id?null:h)},4e3);return()=>clearTimeout(b)},[s==null?void 0:s.tasks.map(p=>`${p.id}:${p.status}`).join("|")]),!s)return null;const x=n[0],l=!x&&a;return!x&&j.length===0&&!l?null:e.jsxs("div",{className:"border-b bg-muted/30",children:[x&&e.jsxs("div",{className:"px-4 py-2.5 flex items-start gap-2.5",children:[e.jsx("div",{className:"pt-0.5",children:At(x.status)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[e.jsx("span",{className:"text-foreground font-medium",children:"Working on: "}),e.jsxs("span",{className:"italic",children:['"',x.prompt,'"']})]}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground shrink-0",children:kt(x.startedAt)})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx(Zt,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("p",{className:"text-xs font-medium text-foreground truncate",children:x.progressLabel||"Thinking…"})]}),e.jsx("div",{className:"mt-1.5 h-1 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full w-1/3 bg-primary/70 rounded-full animate-[indeterminate_1.4s_ease-in-out_infinite]"})}),n.length>1&&e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-1",children:["+",n.length-1," more running"]})]}),e.jsx(E,{size:"sm",variant:"ghost",className:"h-7 px-2 text-[11px] text-destructive hover:text-destructive shrink-0",onClick:()=>s.cancel(x.id),children:"Cancel"})]}),l&&!x&&e.jsxs("div",{className:"px-4 py-2 flex items-center gap-2.5",children:[At(a.status),e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex-1",children:[e.jsxs("span",{className:"text-foreground font-medium",children:[a.status==="done"?"Done":"Failed",a.startedAt?` · ${kt(a.startedAt,a.finishedAt)}`:""," · "]}),e.jsxs("span",{className:"italic",children:['"',a.prompt,'"']})]})]}),j.length>0&&e.jsxs("div",{className:"px-4 py-1.5 border-t border-border/50 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsx(Et,{className:"h-3 w-3 shrink-0"}),e.jsxs("span",{className:"font-medium text-foreground",children:["Queued (",j.length,"):"]}),e.jsx("span",{className:"truncate",children:j.map(p=>`"${p.prompt}"`).join(", ")})]})]})},Ks=s=>(s==null?void 0:s.type)==="text/html"||/\.html?$/i.test((s==null?void 0:s.name)||""),Vs=s=>{const a={create_task:"Creating task…",update_task:"Updating task…",delete_task:"Deleting task…",create_lead:"Creating lead…",update_lead:"Updating lead…",create_contact:"Creating contact…",update_contact:"Updating contact…",create_event:"Creating event…",update_event:"Updating event…",create_blog_post:"Drafting blog post…",create_social_post:"Drafting social post…",create_carousel_post:"Designing carousel…",create_discount:"Creating discount…",commit_marketing_plan:"Committing marketing calendar…",send_email:"Sending email…",create_calendar_event:"Adding to Google Calendar…",exp
1ort_data_document:"Generating document…"};return a[s]?a[s]:/^(search|find|list|get|fetch|lookup)_/.test(s)?"Searching…":/^create_/.test(s)?`Creating ${s.replace(/^create_/,"").replace(/_/g," ")}…`:/^update_/.test(s)?`Updating ${s.replace(/^update_/,"").replace(/_/g," ")}…`:/^delete_/.test(s)?`Deleting ${s.replace(/^delete_/,"").replace(/_/g," ")}…`:`Running tool: ${s}`},Qs={"CRM Agent":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200","Users Agent":"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200","Products Agent":"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200","Sales Agent":"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200","Marketing Agent":"bg-pink-100 text-pink-800 dark:bg-pink-900 dark:text-pink-200","Billing Agent":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200","Tax Agent":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200","Logistics Agent":"bg-teal-100 text-teal-800 dark:bg-teal-900 dark:text-teal-200","System Agent":"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200","Analytics Agent":"bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200"},Pt={super_admin:["How many sellers and buyers do we have?","Show me German buyers who signed up last month","What's the current lead pipeline status?","Show today's orders","What's our revenue this month?","List all unread emails in the inbox"],admin:["How many sellers and buyers do we have?","What's the current lead pipeline status?","Show today's orders","Show me brands without products"],sales:["What's the current lead pipeline status?","Show me new leads from this week","How many sellers do we have?"],customer_support:["Show me pending orders","How many buyers do we have?","List brands with products"],customer_relations:["What's the lead pipeline status?","Show me buyers from Germany","Show today's orders"],marketing:["Show me all brands","What's today's order volume?","List upcoming events"],publicist:["List upcoming events","Show me all brands"]},Rt=/^[ \t]*(?:[-*][ \t]+)?(?:\*\*)?([a-z][a-z0-9_]*|the [a-z]+ (?:lookup|update|conversion|send|check|tool))(?:[ \t]*\([^()\n]{0,60}\))?(?:\*\*)?[ \t]*:[ \t]*([\[{].*)$/,Ys=/^[ \t]*(?:\[Tool Results Context\]|\[NO ACTION\]|NO ACTION PROVIDED\b)/i,Xs=/^[ \t]*(?:\{"|\[\{"|\[")/;function Xe(s,a){for(let r=0;r<s.length;r++){const n=s[r];a.inString?a.escaped?a.escaped=!1:n==="\\"?a.escaped=!0:n==='"'&&(a.inString=!1):n==='"'?a.inString=!0:n==="{"||n==="["?a.depth++:(n==="}"||n==="]")&&a.depth--}}function Zs(s){const a=s.split(`
2`),r=[],n=[];let j=null,x=!1,l=0;for(;l<a.length;){const h=a[l],S=h.match(/^[ \t]*(```|~~~)/);if(S&&(j===null||j===S[1])){j=j===null?S[1]:null,r.push(h),n.push(!0),l++;continue}if(j!==null){r.push(h),n.push(!0),l++;continue}if(Ys.test(h)){x=!0,l++;continue}const o=h.match(Rt);if(o){const U=o[2],f={depth:0,inString:!1,escaped:!1};if(Xe(U,f),f.depth<=0||f.inString){let y=/^(?:\{"|\[\{|\[")/.test(U);if(!y)try{JSON.parse(U.trim()),y=!0}catch{}if(y){x=!0,l++;continue}}else{x=!0,l++;let y=l,$=!1;for(;y<a.length;){if(Xe(a[y],f),y++,f.depth<=0){$=!0;break}if(f.inString)break}$&&(l=y);continue}}if(Xs.test(h)){const U={depth:0,inString:!1,escaped:!1},f=[];let y=l,$=!1;for(;y<a.length;){if(Xe(a[y],U),f.push(a[y]),y++,U.depth<=0){$=!0;break}if(U.inString)break}if($){let ae=!1;try{JSON.parse(f.join(`
3`)),ae=!0}catch{}if(ae){x=!0,l=y;continue}}}r.push(h),n.push(!1),l++}if(!x)return s;const p=[];let b=0;for(let h=0;h<r.length;h++){if(!n[h]&&r[h].trim()===""){if(b++,b>1)continue}else b=0;p.push(r[h])}return p.join(`
4`).trim()}function ea(s){const a=[];for(const r of s.split(`
5`)){const n=r.match(Rt);n&&a.push(n[1].replace(/_/g," "))}return a}function Ze(s){let a,r=[],n=Zs(s);const j=n.match(/^\[([A-Za-z\s]+Agent)\]\s*/);j&&(a=j[1],n=n.slice(j[0].length));const x=n.match(/>\s*\*\*Try:\*\*\s*(.+)$/m);return x&&(r=x[1].split("|").map(l=>l.trim().replace(/^[""]|[""]$/g,"").replace(/^"|"$/g,"")).filter(Boolean),n=n.replace(/>\s*\*\*Try:\*\*\s*.+$/m,"").trimEnd()),{agentLabel:a,suggestions:r,cleanContent:n}}function $t(s){if(!s||s.name!=="export_data_document")return;let a=s.content;
5try{typeof a=="string"&&(a=JSON.parse(a))}catch{}if(!(!(a!=null&&a.url)||!(a!=null&&a.filename)))return{url:a.url,filename:a.filename,format:a.format||"pdf"}}function ta({document:s,onPreview:a}){const r=s.format==="pdf",n=s.format==="html"||s.format==="htm",j=s.format==="xlsx"?qs:rt;return e.jsx(ge,{className:"mt-2 border-l-4 border-l-primary",children:e.jsxs(be,{className:"p-3 flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-9 w-9 rounded-md bg-primary/10 flex items-center justify-center shrink-0",children:e.jsx(j,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.filename}),e.jsxs("p",{className:"text-xs text-muted-foreground uppercase",children:[s.format," document"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[(r||n)&&e.jsxs(E,{size:"sm",variant:"outline",className:"h-8 gap-1",onClick:a,children:[e.jsx(Tt,{className:"h-3.5 w-3.5"}),"Preview"]}),e.jsx(E,{size:"sm",className:"h-8 gap-1",asChild:!0,children:e.jsxs("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",download:s.filename,children:[e.jsx(nt,{className:"h-3.5 w-3.5"}),"Download"]})})]})]})})}function sa(s){var Ee,ie,me,re,xe,pe,_e,Ue,ye;const a=[],r=s.match(/\*\*Title:\*\*\s*(.+)/),n=s.match(/\*\*Status:\*\*\s*(\w+)/i),j=s.match(/\*\*Excerpt:\*\*\s*(.+)/),x=s.match(/\*\*Slug:\*\*\s*(.+)/),l=s.match(/\*\*Platform:\*\*\s*(.+)/i),p=s.match(/\*\*Caption:\*\*\s*([\s\S]*?)(?=\n\*\*|\n\n>|\n\n$|$)/),b=s.match(/\*\*Hashtags?:\*\*\s*(.+)/i),h=s.match(/(?:^|\n)\s*>?\s*\*\*Subject(?:\s*Line)?:\*\*\s*(.+)/i)||s.match(/(?:^|\n)\s*>?\s*Subject(?:\s*Line)?:\s*(.+)/i),S="(?=\\n\\s*>?\\s*\\*\\*(?:Subject|To|Platform|Title|Status|ID|Post ID|Campaign ID|Slug|Excerpt|Try|Note|Tip):\\*\\*|\\n#{1,4}\\s|\\n---|\\n\\n---|\\n\\s*(?:Shall I|Should I|Since|Would you like|Note:|Tip:|Email\\s*\\/\\s*Campaign Created)|\\s*$)";let o=s.match(new RegExp(`\\*\\*(?:Body|Draft|Email\\s*Body|Message):\\*\\*\\s*"?([\\s\\S]*?)"?\\s*${S}`,"i"));if(!o&&h){const k=s.indexOf(h[0])+h[0].length,q=s.slice(k).match(/\n\s*((?:>[^\n]*\n?){2,})/);q&&(o=["",q[1]])}if(!o&&h){const k=s.indexOf(h[0])+h[0].length,q=s.slice(k).match(new RegExp(`^\\s*\\n([\\s\\S]*?)${S}`));q&&q[1]&&q[1].trim().length>=20&&(o=["",q[1]])}const U=k=>{if(!k)return k;let J=k.split(`
6`).map(q=>q.replace(/^\s*>\s?/,"")).join(`
7`).trim().replace(/^"+|"+$/g,"").trim();return J=J.replace(/^#{1,6}\s.*\n+/,"").trim(),J=J.replace(/^\s*\*?\*?Subject(?:\s*Line)?:\*?\*?\s*.+\n+/i,"").trim(),J},f=s.match(/\*\*(?:ID|Post ID|Campaign ID):\*\*\s*`?([0-9a-f-]{36})`?/i),y=r&&(/blog\s*post/i.test(s)||x&&/article|blog/i.test(s)||/\*\*Post Type:\*\*\s*blog/i.test(s))&&!l,$=s.match(/\*\*Caption(?:\s*Content)?:\*\*\s*([\s\S]*?)(?=\n\*\*|\n\n>|\n\n$|$)/),ae=s.match(/\*\*(?:Number of\s*)?Slides?:\*\*\s*(\d+)/i),$e=l&&(p||$)||l&&ae,Ne=/carousel|slide\s*\d|slides?\s*(ready|prepared|count)|aspect\s*ratio|\b\d{1,2}\s*slides?\b/i.test(s)||l&&(ae||$),Fe=!!(l&&(p||$||ae)),Te=/\bemail\b|\bcampaign\b|newsletter|outreach|\bdraft\s+(email|message)\b|sending|recipients?/i,ne=/<p[\s>]|<\/p>|<br\s*\/?>/i.test((o==null?void 0:o[1])??""),De=h&&o&&(Te.test(s)||ne)&&!Ne&&!Fe;if(y&&a.push({type:"blog",id:f==null?void 0:f[1],title:(Ee=r==null?void 0:r[1])==null?void 0:Ee.trim(),excerpt:(ie=j==null?void 0:j[1])==null?void 0:ie.trim(),status:(me=n==null?void 0:n[1])==null?void 0:me.trim()}),$e&&!y){const k=(re=b==null?void 0:b[1])==null?void 0:re.split(/[\s,]+/).map(J=>J.trim()).filter(Boolean);a.push({type:"social",id:f==null?void 0:f[1],platform:(xe=l==null?void 0:l[1])==null?void 0:xe.trim().toLowerCase(),caption:(pe=(p==null?void 0:p[1])||($==null?void 0:$[1]))==null?void 0:pe.trim(),hashtags:k,status:(_e=n==null?void 0:n[1])==null?void 0:_e.trim()})}if(De&&!y&&!$e){const k=U(o==null?void 0:o[1]);k&&k.length>=20&&a.push({type:"email",id:f==null?void 0:f[1],subject:(Ue=h==null?void 0:h[1])==null?void 0:Ue.trim(),body:k,status:(ye=n==null?void 0:n[1])==null?void 0:ye.trim()})}const qe=/\[([^\]]+)\]\((https?:\/\/[^\s)]+\.(?:png|jpg|jpeg|webp)[^\s)]*)\)/gi,ue=[...s.matchAll(qe)].filter(k=>{const J=k[2];return/agent-attachments/i.test(J)?!1:/social-media\/carousel-|social-media\/generated-|product-images\/.*ai-generated|product-images\/generated-|product-images\/marketing\/|product-images\/events\//i.test(J)});return ue.length>0&&a.push({type:"carousel",imageUrls:ue.map(k=>k[2]),slideLabels:ue.map(k=>k[1])}),a}const aa=new Set(["create_social_post","update_social_post","generate_social_post","query_social_posts","show_social_post_preview"]);function st(s,a=0,r=[]){return!s||a>4?r:Array.isArray(s)?(s.forEach(n=>st(n,a+1,r)),r):(typeof s=="object"&&(typeof s.id=="string"&&("caption"in s||"platform"in s)&&!r.some(n=>
7n.id===s.id)&&r.push({id:s.id,caption:typeof s.caption=="string"?s.caption:void 0}),Object.values(s).forEach(n=>st(n,a+1,r))),r)}async function et(){const{data:{session:s}}=await G.auth.getSession();if(!s)return null;const a=s.expires_at??0,r=Math.floor(Date.now()/1e3);if(a-r<60){const{data:n,error:j}=await G.auth.refreshSession();return j||!n.session?null:n.session.access_token}return s.access_token}const rn=({embedded:s=!1}={})=>{var jt;const{user:a}=ss(),{profile:r}=as(),{toast:n}=ns(),{enqueue:j,setNavigator:x,updateProgress:l}=rs(),[p,b]=d.useState([]),[h,S]=d.useState([]),[o,U]=d.useState(null),[f,y]=d.useState(""),[$,ae]=d.useState(!1),[$e,Ie]=d.useState(!1),[Ne,Fe]=d.useState(!0),[Te,ne]=d.useState(null),[De,qe]=d.useState([]),[ue,Ee]=d.useState(!1),[ie,me]=d.useState(null),[re,xe]=d.useState([]),[pe,_e]=d.useState(!1),[Ue,ye]=d.useState(!1),[k,J]=d.useState(null),[q,He]=d.useState(null),We=d.useRef(null),Lt=d.useRef(null),Se=d.useRef(null),ot=d.useRef(null),lt=d.useRef(null),ct=d.useRef(null),Ce=d.useRef(0),je=d.useRef(null),[dt]=is(),ut=d.useRef(!1),Oe=d.useMemo(()=>r?r.admin_sub_role||"super_admin":"admin",[r]),Gt=d.useMemo(()=>r&&`${r.first_name||""} ${r.last_name||""}`.trim()||"there",[r]),Bt=d.useMemo(()=>Pt[Oe]||Pt.admin,[Oe]);d.useEffect(()=>()=>{var t;(t=ct.current)==null||t.abort()},[]),d.useEffect(()=>{je.current=o},[o]),d.useEffect(()=>{x(t=>{t&&t!==je.current&&Je(t)})},[x]);const Re=d.useCallback(async(t,g)=>{if(t)try{const{data:m}=await G.from("admin_agent_messages").select("id, tool_results").eq("conversation_id",t).eq("role","assistant").order("created_at",{ascending:!1}).limit(1),u=m==null?void 0:m[0];if(!u)return;let I=u.tool_results;if(typeof I=="string")try{I=JSON.parse(I)}catch{I=null}const c=Array.isArray(I)?{results:I}:I||{},X={...c.previews||{},...g},T={...c,previews:X};await G.from("admin_agent_messages").update({tool_results:T}).eq("id",u.id)}catch(m){console.warn("persistMessagePreview failed:",m)}},[]),mt=d.useCallback(async(t,g)=>{if(!await et())return;const u=Array.from({length:t.slide_count},(A,C)=>C),I=Array(t.slide_count).fill(null),c={draft:t,generatedUrls:[],pendingIndexes:u.slice(),failedIndexes:[],currentSlide:0,totalSlides:t.slide_count,status:"generating",messageId:g};b(A=>A.map(C=>C.id===g?{...C,carouselGen:{...c}}:C));const Q=t.product_ref_count>0?`
8
9FEATURED PRODUCT (anchor every slide on the real product photo): Use the EXACT bottle, label, packaging, and brand mark from the product reference image(s). Do NOT redesign the bottle, swap colors, invent a new label, or change the brand mark. The product reference image is a real platform product — keep it photorealistic and recognizable on every slide.`:t.reference_images.length>0?`
10
11REFERENCE MATERIALS: Attached images are style/context references only unless the backend marks them as product references. Do NOT treat them as official Tyrrst logos, product labels, or packaging assets. Do NOT invent logos, monograms, products, or bottle labels.`:"",X=Date.now(),T=async(A,C=3)=>{var N;const H=t.slide_descriptions[A]||`Professional carousel slide ${A+1} about: ${t.topic}`,B=((N=t.slide_titles)==null?void 0:N[A])||"",K=H&&!H.startsWith("Professional carousel slide"),oe=t.aspect_ratio?` Aspect ratio: ${t.aspect_ratio}.`:"",R=B?`
12
13TITLE (render as a large BOLD headline at the top — weight 700+, sans-serif, identical style to every other slide in this carousel):
14${B}`:"",ee=`
15
16CAROUSEL CONSISTENCY RULES (apply identically to every slide 1–${t.slide_count}):
17- Title weight: BOLD (700+) on EVERY slide — never vary between slides.
18- Body weight: regular (400).
19- Same font family, color palette, alignment, and logo placement across all slides.
20- Minimalist, professional layout. No placeholder text, no "Key point #N", no generic filler.`,z=K?`Create a professional social media carousel slide image (slide ${A+1} of ${t.slide_count}) for topic: ${t.topic}.${oe}${R}
21
22BODY TEXT (render below the title in regular weight, smaller than the title):
23${H}${ee}${Q}`:`Create a professional, clean social media carousel slide image (slide ${A+1} of ${t.slide_count}) for a post about: ${t.topic}.${R||`
24
25TITLE (BOLD, weight 700+, top of slide): ${t.topic}`}
26
27Slide concept: ${H}.${ee}${oe}${Q}`;for(let P=1;P<=C;P++){try{const{data:v,error:he}=await G.functions.invoke("generate-event-image",{body:{prompt:z,referenceImages:t.reference_images,productRefCount:t.product_ref_count||0,width:t.width,height:t.height,scope:"tyrrst",companyId:null}});if(he||v!=null&&v.error)console.warn(`Slide ${A+1} attempt ${P}/${C} failed:`,he||(v==null?void 0:v.error));else if(v!=null&&v.image){let ke;if(String(v.image).startsWith("http://")||String(v.image).startsWith("https://")){const F=await fetch(v.image);if(!F.ok)throw new Error(`Failed to fetch generated slide: ${F.status}`);ke=await F.blob()}else{const F=v.image.replace(/^data:image\/[^;]+;base64,/,""),ve=atob(F),Ae=new Uint8Array(ve.length);for(let te=0;te<ve.length;te++)Ae[te]=ve.charCodeAt(te);ke=new Blob([Ae],{type:"image/png"})}const L=`marketing/ai-generated-carousel-slide-${A+1}-${X}-${Math.random().toString(36).slice(2,8)}.png`,{error:le}=await G.storage.from("product-images").upload(L,ke,{contentType:"image/png"});if(le)console.warn(`Slide ${A+1} upload attempt ${P} failed:`,le);else{const{data:F}=G.storage.from("product-images").getPublicUrl(L);if(F!=null&&F.publicUrl)return F.publicUrl}}}catch(v){console.warn(`Slide ${A+1} attempt ${P} threw:`,v)}P<C&&await new Promise(v=>setTimeout(v,600*Math.pow(2,P)))}return null},W=()=>({draft:t,generatedUrls:c.generatedUrls.slice(),failedIndexes:c.failedIndexes.slice(),totalSlides:c.totalSlides,status:c.status,error:c.error,messageId:g}),Z=async A=>{for(const C of A){c.currentSlide=C,b(B=>B.map(K=>K.id===g?{...K,carouselGen:{...c}}:K));const H=await T(C);H?(I[C]=H,c.generatedUrls=I.filter(B=>!!B),c.failedIndexes=c.failedIndexes.filter(B=>B!==C)):c.failedIndexes.includes(C)||c.failedIndexes.push(C),c.pendingIndexes=c.pendingIndexes.filter(B=>B!==C),b(B=>B.map(K=>K.id===g?{...K,carouselGen:{...c}}:K)),Re(je.current,{carouselGen:W()})}};if(await Z(u),c.failedIndexes.length>0){const A=c.failedIndexes.slice();c.pendingIndexes=A.slice(),b(C=>C.map(H=>H.id===g?{...H,carouselGen:{...c}}:H)),await Z(A)}c.generatedUrls.length>0&&await G.from("social_media_posts").insert({platform:t.platform,caption:t.caption,hashtags:t.hashtags,image_url:c.generatedUrls[0],image_urls:c.generatedUrls,status:"draft",created_by:a==null?void 0:a.id}),c.generatedUrls.length===t.slide_count?c.status="complete":c.generatedUrls.length>0?(c.status="partial",c.error=`Generated ${c.generatedUrls.length} of ${t.slide_count} slides — ${c.failedIndexes.length} failed. Click Retry to attempt the missing slides again.`):(c.status="error",c.error="Failed to generate any slides. Please try again."),b(A=>A.map(C=>C.id===g?{...C,carouselGen:{...c}}:C)),Re(je.current,{carouselGen:W()})},[a==null?void 0:a.id,Re]);d.useEffect(()=>{if(We.current){const t=We.current.querySelector("[data-radix-scroll-area-viewport]");t&&(t.scrollTop=t.scrollHeight)}},[p,$]),d.useEffect(()=>{a!=null&&a.id&&Me()},[a==null?void 0:a.id,ue]);const Me=async()=>{if(!(a!=null&&a.id))return;let t=G.from("admin_agent_conversations").select("id, title, created_at, project_id, pinned, archived_at, shared_with_project").eq("user_id",a.id);t=ue?t.not("archived_at","is",null):t.is("archived_at",null);const{data:g}=await t.order("pinned",{ascending:!1}).order("created_at",{ascending:!1}).limit(50);g&&S(g)},Je=async t=>{me(null);const{data:g}=await G.from("admin_agent_messages").select("*").eq("conversation_id",t).order("created_at",{ascending:!0});if(g){b(g.map(m=>{var Z,A,C,H,B,K,oe;const u=m.role==="assistant"?Ze(m.content):null;let I,c=[],Q,X,T;if(m.role==="assistant"&&m.tool_results)try{const R=typeof m.tool_results=="string"?JSON.parse(m.tool_results):m.tool_results,ee=Array.isArray(R)?R:Array.isArray(R==null?void 0:R.results)?R.results:[];ee.length>0&&(I=ee.map(N=>{const P=N.name||N.tool||"tool",v=typeof N.content=="string"?N.content:JSON.stringify(N.content);return`${P}: ${v.slice(0,2e3)}`}).join(`
28`),c=ee.map(N=>String(N.name||N.tool||"").replace(/_/g," ").trim()).filter(Boolean),T=ee.map($t).find(Boolean));const z=Array.isArray(R)||R==null?void 0:R.previews;if(((A=(Z=z==null?void 0:z.carouselGen)==null?void 0:Z.generatedUrls)==null?void 0:A.length)>0||(C=z==null?void 0:z.carouselGen)!=null&&C.draft){const N=z.carouselGen;Q={draft:N.draft,generatedUrls:N.generatedUrls||[],pendingIndexes:[],failedIndexes:N.failedIndexes||[],currentSlide:((H=N.generatedUrls)==null?void 0:H.length)||0,totalSlides:N.totalSlides||((B=N.draft)==null?void 0:B.slide_count)||((K=N.generatedUrls)==null?void 0:K.length)||0,status:N.status||"complete",error:N.error,messageId:m.id}}(oe=z==null?void 0:z.eventImagePreview)!=null&&oe.imageUrl&&(X={imageUrl:z.eventImagePreview.imageUrl,eventId:z.eventImagePreview.eventId||"",attached:z.eventImagePreview.attached===!0})}catch{}let W=u?u.cleanContent:m.content;if(u&&!W){const R=c.length>0?c:ea(m.content);W=R.length>0?`Done: ${R.join(", ")}.`:"This reply could not be displayed."}return{id:m.id,role:m.role,content:W,timestamp:new Date(m.created_at),agentLabel:u==null?void 0:u.agentLabel,suggestions:u==null?void 0:u.suggestions,attachments:m.role==="user"&&Array.isArray(m.attachments)?m.attachments:void 0,toolResultsSummary:I,carouselGen:Q,eventImagePreview:X,documentPreview:T}})),U(t),Ie(!1);try{const{data:m}=await G.from("crm_ai_prompts").select("project_id").eq("conversation_id",t).order("created_at",{ascending:!1}).limit(1).maybeSingle();m!=null&&m.project_id&&me(m.project_id)}catch{}}};d.useEffect(()=>{if(ut.current)return;const t=dt.get("conversation");!t||!(a!=null&&a.id)||(ut.current=!0,Je(t))},[a==null?void 0:a.id,dt]),d.useEffect(()=>{G.from("crm_projects").select("id, name").neq("status","completed").order("created_at",{ascending:!1}).limit(50).then(({data:t})=>qe(t||[]))},[]);
28const zt=()=>{var t;(t=ct.current)==null||t.abort(),ne(null),b([]),U(null),me(null),y(""),Ie(!1)},pt=async(t,g,m)=>fetch(`${Ps}/functions/v1/admin-brain-agent`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`,apikey:$s},body:JSON.stringify(g),signal:m}),ht=t=>{Ve(`✓ Selected: ${t}`)},Ke=async t=>{const g=Array.from(t.target.files||[]);await ft(g),Se.current&&(Se.current.value="")},ft=async t=>{if(t.length!==0){_e(!0);try{if(!await et())throw new Error("Not authenticated");const{data:{user:m}}=await G.auth.getUser();if(!m)throw new Error("Not authenticated");for(const u of t){if(u.size>10*1024*1024){n({title:"File too large",description:`${u.name} exceeds 10MB limit`,variant:"destructive"});continue}const I=u.name.split(".").pop(),c=`${m.id}/${Date.now()}-${Math.random().toString(36).slice(2)}.${I}`,{data:Q,error:X}=await G.storage.from("agent-attachments").upload(c,u,{cacheControl:"3600",upsert:!1});if(X){n({title:"Upload failed",description:X.message,variant:"destructive"});continue}const{data:T,error:W}=await G.storage.from("agent-attachments").createSignedUrl(Q.path,60*60*24*7);if(W||!(T!=null&&T.signedUrl)){n({title:"Upload failed",description:(W==null?void 0:W.message)||"Could not sign URL",variant:"destructive"});continue}xe(Z=>[...Z,{url:T.signedUrl,name:u.name,type:u.type,size:u.size}])}}catch(g){n({title:"Upload error",description:g.message,variant:"destructive"})}finally{_e(!1)}}},gt=t=>{xe(g=>g.filter((m,u)=>u!==t))},Ve=d.useCallback(async t=>{if(!(t??f).trim()&&re.length===0)return;const g=(t??f).trim(),m=[...re];y(""),xe([]);const u={id:crypto.randomUUID(),role:"user",content:g||`[Sent ${m.length} file(s)]`,timestamp:new Date,attachments:m.length>0?m:void 0};b(T=>[...T,u]);const I=[...p,u],c=je.current;let Q=Promise.resolve(null),X=!1;if(ie&&(a!=null&&a.id)&&g&&!g.startsWith("✓ Selected:")&&!g.startsWith("[Sent "))try{Q=G.from("crm_ai_prompts").insert({project_id:ie,task_id:null,source:"agent",conversation_id:c||null,title:g.slice(0,80),prompt_content:g,status:"draft",created_by:a.id}).select("id").single().then(({data:T,error:W})=>W?(console.warn("AI prompt recording failed:",W.message),null):(T==null?void 0:T.id)??null,()=>null)}catch{}j({prompt:g||`[Sent ${m.length} file(s)]`,conversationId:c,run:async(T,W)=>{var A,C,H,B,K,oe,R,ee,z;ae(!0),l(T,{progressLabel:"Thinking…"});const Z={signal:W};try{let N=await et();if(!N)throw new Error("Session expired. Please sign in again.");const P={message:g||`[Sent ${m.length} file(s)]`,conversationId:c,project_id:ie||void 0,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,messages:I.slice(0,-1).flatMap(i=>{const D={role:i.role,content:i.content,attachments:i.role==="user"&&i.attachments&&i.attachments.length>0?i.attachments:void 0};return i.toolResultsSummary?[D,{role:"system",content:`[Tool Results Context] (read-only reference: results of the tools run for the previous reply — use for follow-ups, never quote or repeat verbatim)
29`+i.toolResultsSummary,attachments:void 0}]:[D]})};m.length>0&&(P.attachments=m);let v=await pt(N,P,Z.signal);if(v.status===401){const{data:i,error:D}=await G.auth.refreshSession();if(D||!i.session)throw new Error("Session expired. Please sign in again.");N=i.session.access_token,v=await pt(N,P,Z.signal)}if(!v.ok){const i=await v.json();throw new Error(i.error||`Request failed (${v.status})`)}const he=(A=v.body)==null?void 0:A.getReader();if(!he)throw new Error("No response body");const ke=new TextDecoder;let L="";const le=crypto.randomUUID();let F=[],ve=!1,Ae=0;for(b(i=>[...i,{id:le,role:"assistant",content:"",timestamp:new Date}]);;){const{done:i,value:D}=await he.read();if(i)break;const _=ke.decode(D,{stream:!0}).split(`
30`);for(const O of _){if(!O.startsWith("data: "))continue;const Y=O.slice(6).trim();if(Y!=="[DONE]")try{const M=JSON.parse(Y);if(M.conversationId&&!o&&(U(M.conversationId),Me()),M.conversationId&&!c&&!X){X=!0;const V=M.conversationId;try{Q.then(fe=>{fe&&G.from("crm_ai_prompts").update({conversation_id:V}).eq("id",fe).then(({error:se})=>{se&&console.warn("AI prompt conversation backfill failed:",se.message)})})}catch{}}if(M.toolResults&&Array.isArray(M.toolResults)){F=M.toolResults;const V=M.toolResults[M.toolResults.length-1];V!=null&&V.name&&l(T,{progressLabel:Vs(V.name)})}const Be=(B=(H=(C=M.choices)==null?void 0:C[0])==null?void 0:H.delta)==null?void 0:B.content;if(Be){ve||(ve=!0,l(T,{progressLabel:"Writing response…"})),L+=Be,L.length-Ae>200&&(Ae=L.length,l(T,{tokenCount:L.length}));const{agentLabel:V,suggestions:fe,cleanContent:se}=Ze(L);b(ce=>ce.map(Qe=>Qe.id===le?{...Qe,content:se,agentLabel:V,suggestions:fe}:Qe))}}catch{}}}if(L)try{const{cleanContent:i}=Ze(L),D=Array.from(i||L).slice(0,400).join("");Q.then(w=>
30{w&&G.from("crm_ai_prompts").update({context_summary:{result_preview:D,result_recorded_at:new Date().toISOString()}}).eq("id",w).then(({error:_})=>{_&&console.warn("AI prompt result backfill failed:",_.message)})})}catch{}let te=null;const Le=F.find(i=>i.name==="create_carousel_post");if(Le)try{const i=typeof Le.content=="string"?JSON.parse(Le.content):Le.content,D=[];for(const w of p)if(w.role==="user"&&w.attachments)for(const _ of w.attachments)(K=_.type)!=null&&K.startsWith("image/")&&D.push(_.url);te={platform:i.platform||"linkedin",caption:i.caption||"",hashtags:i.hashtags||[],slide_count:Math.min(i.slide_count||i.slideCount||5,10),slide_titles:i.slide_titles||i.slideTitles||[],slide_descriptions:i.slide_descriptions||i.slideDescriptions||[],reference_images:D,topic:i.topic||"carousel content",tone:i.tone||"professional",aspect_ratio:i.aspect_ratio||i.aspectRatio,width:i.width,height:i.height}}catch(i){console.error("Failed to parse structured carousel data:",i)}if(!te&&L.match(/carousel draft.*?prepared|slide prompts|slides will now be generated/i)){const D=L.match(/(\d+)\s*slide/i),w=L.match(/\*\*Caption:\*\*\s*([\s\S]*?)(?=\n\*\*|\n\n|$)/),_=L.match(/\*\*Platform:\*\*\s*(\S+)/i),O=L.match(/\*\*Hashtags?:\*\*\s*(.+)/i),Y=L.match(/\*\*Topic:\*\*\s*(.+)/i),M=[],Be=L.matchAll(/(?:slide\s*\d+|^\d+\.)\s*[:\-–]\s*(.+)/gim);for(const V of Be)M.push(V[1].trim());if(D){const V=parseInt(D[1]),fe=[];for(const se of p)if(se.role==="user"&&se.attachments)for(const ce of se.attachments)(oe=ce.type)!=null&&oe.startsWith("image/")&&fe.push(ce.url);te={platform:((R=_==null?void 0:_[1])==null?void 0:R.trim().toLowerCase())||"linkedin",caption:((ee=w==null?void 0:w[1])==null?void 0:ee.trim())||"",hashtags:((z=O==null?void 0:O[1])==null?void 0:z.split(/[\s,]+/).filter(Boolean))||[],slide_count:Math.min(V,10),slide_titles:M.map((se,ce)=>`Slide ${ce+1}`),slide_descriptions:M.length>=V?M.slice(0,V):Array.from({length:V},(se,ce)=>M[ce]||(Y==null?void 0:Y[1])||"Professional carousel slide"),reference_images:fe,topic:(Y==null?void 0:Y[1])||"carousel content",tone:"professional"}}}te&&mt(te,le);const Ge=F.find(i=>i.name==="generate_event_image");if(Ge)try{const i=typeof Ge.content=="string"?JSON.parse(Ge.content):Ge.content;if(i!=null&&i.image_url){const D={imageUrl:i.image_url,eventId:i.event_id||"",attached:i.attached===!0};b(w=>w.map(_=>_.id===le?{..._,eventImagePreview:D}:_)),setTimeout(()=>{Re(je.current,{eventImagePreview:D})},800)}}catch(i){console.error("Failed to parse event image tool result:",i)}if(F.length>0){const i=F.map($t).find(Boolean),D=F.map(w=>{const _=typeof w.content=="string"?w.content:JSON.stringify(w.content);return`${w.name}: ${_.slice(0,2e3)}`}).join(`
31`);b(w=>w.map(_=>_.id===le?{..._,toolResultsSummary:D,documentPreview:i}:_))}const vt=Is(L);vt&&ne(vt);try{const i=F.filter(w=>aa.has(w.name));let D=!1;for(const w of i){if(w.name!=="show_social_post_preview")continue;let _=w.content;if(typeof _=="string")try{_=JSON.parse(_)}catch{continue}const O=_==null?void 0:_.preview_post;O!=null&&O.id&&(ne({kind:"social-post",id:O.id,title:(O.caption||"Social post draft").slice(0,60)}),D=!0)}if(!D){const w=[];for(const O of i){let Y=O.content;if(typeof Y=="string")try{Y=JSON.parse(Y)}catch{continue}st(Y,0,w)}const _=i.some(O=>O.name!=="query_social_posts"&&O.name!=="show_social_post_preview");if(w.length===1||_&&w.length>0){const O=w[w.length-1];ne({kind:"social-post",id:O.id,title:(O.caption||"Social post draft").slice(0,60)})}}}catch{}}catch(N){if(N.name==="AbortError")return;console.error("Error:",N);const P=N.message||"Failed to send message";let v=`Sorry, I encountered an error: ${P}`;P.includes("rate limit")||P.includes("429")||P.includes("busy")?v="The AI service is busy. Please wait a moment and try again.":P.includes("credits")||P.includes("402")||P.includes("funds")?v="AI credits are exhausted. Please add funds at Settings > Workspace > Usage.":P.includes("504")||P.includes("timed out")||P.includes("Gateway")?v=`That request took too long (likely several email lookups in a row). Try again and ask me to "queue the lookups in the background" — I'll return immediately and you can ask for results in a minute or two.`:v=`Could not complete the request: ${P}. Would you like me to try again?`,n({title:"Error",description:v,variant:"destructive"}),b(he=>[...he,{id:crypto.randomUUID(),role:"assistant",content:v+`
32
33> **Try:** "Retry the last action" | "What can you help me with?"`,timestamp:new Date}])}finally{ae(!1)}}})},[f,p,n,re,j,l,ie,a==null?void 0:a.id]),xt=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),Ve())},Ft=Ts("admin_agent_conversations",Me),yt={conversations:h,currentConversationId:o,onLoadConversation:Je,onNewConversation:zt,projects:De,actions:Ft,showingArchived:ue,onToggleArchivedView:()=>Ee(t=>!t)};return e.jsxs("div",{className:`flex gap-4 ${s?"h-full p-3":"h-[calc(100vh-7rem)] p-4"}`,children:[e.jsx(os,{open:!!k,onOpenChange:t=>!t&&J(null),pdfUrl:(k==null?void 0:k.url)||"",title:(k==null?void 0:k.filename)||"Document preview"}),e.jsx(ls,{open:!!q,onOpenChange:t=>!t&&He(null),fileName:(q==null?void 0:q.filename)||"HTML preview",fileUrl:q==null?void 0:q.url}),Ne&&e.jsx(ge,{className:"w-64 flex-shrink-0 hidden md:block",children:e.jsx(_t,{...yt})}),e.jsxs(ge,{className:"flex-1 flex flex-col relative",onDragEnter:t=>{t.preventDefault(),Ce.current++,Ce.current===1&&ye(!0)},onDragOver:t=>{t.preventDefault()},onDragLeave:t=>{t.preventDefault(),Ce.current--,Ce.current===0&&ye(!1)},onDrop:t=>{t.preventDefault(),Ce.current=0,ye(!1);const g=Array.from(t.dataTransfer.files);g.length>0&&ft(g)},children:[e.jsx(cs,{className:"pb-2 border-b",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(ds,{open:$e,onOpenChange:Ie,children:[e.jsx(us,{asChild:!0,children:e.jsx(E,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(ms,{className:"w-5 h-5"})})}),e.jsx(ps,{side:"left",className:"w-72 p-0 [&_.agent-sidebar-head]:pr-12",children:e.jsx(_t,{...yt})})]}),e.jsx(E,{variant:"ghost",size:"icon",className:"hidden md:inline-flex",onClick:()=>Fe(t=>!t),title:Ne?"Hide recents":"Show recents",children:Ne?e.jsx(Bs,{className:"w-5 h-5"}):e.jsx(hs,{className:"w-5 h-5"})}),e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx("img",{src:wt,alt:"Brain",className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(fs,{className:"text-lg",children:"Tyrrst Brain Agent"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Multi-agent orchestrator • Query and manage platform data"})]}),e.jsx("div",{className:"ml-auto hidden sm:block",children:e.jsxs(gs,{value:ie??"none",onValueChange:t=>me(t==="none"?null:t),children:[e.jsxs(xs,{className:"h-8 w-[210px] text-xs",children:[e.jsx(zs,{className:"mr-1.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx(ys,{placeholder:"No project"})]}),e.jsxs(js,{children:[e.jsx(bt,{value:"none",children:"No project"}),De.map(t=>e.jsx(bt,{value:t.id,children:t.name},t.id))]})]})})]})}),e.jsxs(be,{className:"flex-1 flex flex-col p-0 overflow-hidden",children:[e.jsx(Js,{}),e.jsx(vs,{className:"flex-1 p-4",ref:We,children:p.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-12",children:[e.jsx("div",{className:"w-20 h-20 bg-primary/10 rounded-full flex items-center justify-center mb-6",children:e.jsx("img",{src:wt,alt:"Brain",className:"w-10 h-10"})}),e.jsxs("h3",{className:"text-xl font-semibold mb-1",children:["Welcome, ",Gt]}
33),e.jsx(de,{variant:"outline",className:"mb-4 text-xs",children:ws[Oe]||Oe.replace(/_/g," ")}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-6",children:"I can help you manage the platform using natural language. Try asking:"}),e.jsx("div",{className:"grid gap-2 text-sm text-left max-w-lg",children:Bt.map((t,g)=>e.jsxs("div",{className:"bg-muted p-3 rounded-lg cursor-pointer hover:bg-muted/80 transition-colors",onClick:()=>ht(t),children:['"',t,'"']},g))})]}):e.jsxs("div",{className:"space-y-4",children:[p.map((t,g)=>{var m;return e.jsxs("div",{children:[e.jsxs("div",{className:`flex gap-3 ${t.role==="user"?"justify-end":"justify-start"}`,children:[t.role==="assistant"&&e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(bs,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{className:"max-w-[75%]",children:[t.role==="assistant"&&t.agentLabel&&e.jsx(de,{variant:"secondary",className:`mb-1 text-[10px] px-1.5 py-0 ${Qs[t.agentLabel]||""}`,children:t.agentLabel}),e.jsx("div",{className:`rounded-lg px-4 py-3 ${t.role==="user"?"bg-primary text-primary-foreground":"bg-muted"}`,children:t.role==="user"?e.jsxs("div",{children:[e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.content}),t.attachments&&t.attachments.length>0&&e.jsx(Ds,{attachments:t.attachments,isHtml:Ks,onHtmlClick:u=>He({url:u.url,filename:u.name})})]}):e.jsx(Es,{content:t.content,onOpenArtifact:ne})}),t.role==="assistant"&&t.carouselGen&&e.jsx("div",{className:"mt-2",children:e.jsx(ge,{className:"border-l-4",style:{borderLeftColor:"#a855f7"},children:e.jsxs(be,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(de,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-purple-100 text-purple-800 dark:bg-purple-900/40 dark:text-purple-300",children:[e.jsx(it,{className:"w-3 h-3 mr-1"}),t.carouselGen.status==="generating"?`Generating slides... ${t.carouselGen.generatedUrls.length}/${t.carouselGen.totalSlides}`:t.carouselGen.status==="complete"?`Carousel • ${t.carouselGen.generatedUrls.length} slides`:t.carouselGen.status==="partial"?`Partial: ${t.carouselGen.generatedUrls.length}/${t.carouselGen.totalSlides} slides`:"Generation failed"]}),(t.carouselGen.status==="partial"||t.carouselGen.status==="error")&&e.jsx(E,{size:"sm",variant:"outline",className:"h-6 text-[10px] px-2",onClick:()=>t.carouselGen&&mt(t.carouselGen.draft,t.id),children:"Retry missing slides"})]}),t.carouselGen.status==="generating"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(Ns,{value:t.carouselGen.generatedUrls.length/t.carouselGen.totalSlides*100,className:"h-2"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Generating slide ",t.carouselGen.currentSlide+1," of ",t.carouselGen.totalSlides,"..."]})]}),t.carouselGen.generatedUrls.length>0&&e.jsx(Ye,{block:{type:"carousel",imageUrls:t.carouselGen.generatedUrls,slideLabels:t.carouselGen.draft.slide_titles.slice(0,t.carouselGen.generatedUrls.length)}}),(t.carouselGen.status==="partial"||t.carouselGen.status==="error")&&t.carouselGen.error&&e.jsx("p",{className:"text-xs text-destructive",children:t.carouselGen.error})]})})}),t.role==="assistant"&&t.eventImagePreview&&e.jsx("div",{className:"mt-2",children:e.jsx(Ye,{block:{type:"event_image",imageUrl:t.eventImagePreview.imageUrl,status:t.eventImagePreview.attached?"attached":"preview",title:`Event image ${t.eventImagePreview.attached?"(attached)":"(preview)"}`}})}),t.role==="assistant"&&t.documentPreview&&e.jsx(ta,{document:t.documentPreview,onPreview:()=>{const u=t.documentPreview;u&&(u.format==="html"||u.format==="htm"?He({url:u.url,filename:u.filename}):J(u))}}),t.role==="assistant"&&!t.carouselGen&&(()=>{const u=sa(t.content);return u.length>0?e.jsx("div",{className:"mt-2 space-y-2",children:u.map((I,c)=>e.jsx(Ye,{block:I,onOpenSocial:Q=>ne({kind:"social-post",id:Q,title:(I.caption||"Social post draft").slice(0,60)})},c))}):null})()]}),t.role==="user"&&e.jsx("div",{className:"flex-shrink-0 w-8 h-8 rounded-full bg-primary flex items-center justify-center",children:e.jsx(_s,{className:"w-4 h-4 text-primary-foreground"})})]}),t.role==="assistant"&&!($&&g===p.length-1)&&e.jsx(Us,{agent:"admin",conversationId:o,messageId:t.id,assistantExcerpt:t.content,userRequest:(m=p.slice(0,g).reverse().find(u=>u.role==="user"))==null?void 0:m.content}),t.role==="assistant"&&t.suggestions&&t.suggestions.length>0&&g===p.length-1&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2 ml-11",children:t.suggestions.map((u,I)=>e.jsx(E,{variant:"outline",size:"sm",className:"text-xs h-7",onClick:()=>ht(u),children:u},I))})]},t.id)}),$&&((jt=p[p.length-1])==null?void 0:jt.role)==="user"&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(we,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Processing query..."})]})]})}),e.jsxs("div",{className:"p-4 border-t",children:[e.jsx("input",{ref:Se,type:"file",accept:"image/*,application/pdf,text/html,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.csv,.txt,.html,.htm",multiple:!0,onChange:Ke,className:"hidden"}),e.jsx("input",{ref:ot,type:"file",accept:"image/*",capture:"environment",onChange:Ke,className:"hidden"}),e.jsx("input",{ref:lt,type:"file",accept:"image/*",multiple:!0,onChange:Ke,className:"hidden"}),e.jsxs("div",{className:"sm:hidden rounded-2xl border bg-background px-2 pt-1 pb-2 focus-within:ring-2 focus-within:ring-ring",children:[e.jsx(St,{attachments:re,onRemove:gt}),e.jsx(Ct,{ref:Lt,value:f,onChange:t=>y(t.target.value),onKeyDown:xt,placeholder:"Message Brain…",disabled:!1,rows:1,maxHeight:220,className:"min-h-[52px] resize-none border-0 focus-visible:ring-0 focus-visible:ring-offset-0 px-2 py-1.5 text-base shadow-none"}),e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[e.jsxs(Ss,{children:[e.jsx(Cs,{asChild:!0,children:e.jsx(E,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-full",disabled:$||pe,"aria-label":"Add attachment",children:pe?e.jsx(we,{className:"w-5 h-5 animate-spin"}):e.jsx(Nt,{className:"w-5 h-5"})})}),e.jsxs(ks,{align:"start",sideOffset:8,className:"w-56 p-1",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2 text-sm hover:bg-accent",onClick:()=>{var t;return(t=ot.current)==null?void 0:t.click()},children:[e.jsx(Fs,{className:"w-4 h-4"})," Camera"]}),e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2 text-sm hover:bg-accent",onClick:()=>{var t;return(t=lt.current)==null?void 0:t.click()},children:[e.jsx(at,{className:"w-4 h-4"})," Photos"]}),e.jsxs("button",{type:"button",className:"flex w-full items-center gap-3 rounded-md px-3 py-2 text-sm hover:bg-accent",onClick:()=>{var t;return(t=Se.current)==null?void 0:t.click()},children:[e.jsx(rt,{className:"w-4 h-4"})," Files"]})]})]}),$&&e.jsx(we,{className:"w-4 h-4 animate-spin text-muted-foreground mr-2"})]})]}),e.jsxs("div",{className:"hidden sm:block rounded-md border border-input bg-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",children:[e.jsx(St,{attachments:re,onRemove:gt}),e.jsx(Ct,{value:f,onChange:t=>y(t.target.value),onKeyDown:xt,placeholder:"Ask about users, leads, orders, analytics...",disabled:!1,className:"min-h-[44px] resize-none border-0 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",rows:1,maxHeight:220}),e.jsxs("div",{className:"flex items-center justify-between px-1.5 pb-1.5",children:[e.jsx(E,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>{var t;return(t=Se.current)==null?void 0:t.click()},disabled:$||pe,title:"Attach files",children:pe?e.jsx(we,{className:"w-4 h-4 animate-spin"}):e.jsx(Nt,{className:"w-4 h-4"})}),e.jsx(E,{onClick:()=>Ve(),disabled:!f.trim()&&re.length===0,size:"icon",className:"h-8 w-8",children:$?e.jsx(we,{className:"w-4 h-4 animate-spin"}):e.jsx(As,{className:"w-4 h-4"})})]})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground text-center mt-2",children:"Brain can make mistakes. Verify important information."})]})]}),Ue&&e.jsx("div",{className:"absolute inset-0 bg-primary/10 z-50 flex items-center justify-center rounded-lg",children:e.jsxs("div",{className:"bg-background border-2 border-dashed border-primary rounded-lg px-8 py-6 shadow-lg",children:[e.jsx("p",{className:"text-lg font-medium text-foreground",children:"Drop files to upload"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Files will be attached to your message"})]})})]}),Te&&e.jsx(Os,{artifact:Te,onClose:()=>ne(null)})]})};export{rn 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.