1import{o as ae}from"./rolldown-runtime-ChpBd9eV.js";import{a as ne,n as le}from"./vendor-react-DcWoBPJp.js";import{$n as ie,Ca as B,Ho as U,Jo as oe,Na as w,Oa as W,Pa as A,Wa as y,Xa as X,_i as j,_t as ce,da as k,es as J,gs as Z,ht as me,ir as de,kt as ue,li as H,mt as xe,oo as q}from"./vendor-ui-hcrcJjHJ.js";import{t as L}from"./cn-BYBzgThh.js";import{t as fe}from"./lib-Dh2qRnXK.js";import{_ as g,d as v,f as he,s as pe}from"./HyperionURIResolver-BRUR4y2k.js";import{t as ge}from"./chat-DnV-6lJN.js";import{r as C}from"./toast-transport-Tq2VomXc.js";import"./toast-4SUCBbO_.js";import{kt as je,m as f}from"./index-CL2aAkkR.js";import{n as Ne,r as be}from"./markdownListStyles-B8Ldj0-R.js";import{g as we,o as ye,r as ve,s as Ce}from"./SafeMedia-6QBmdMvX.js";import{t as ke}from"./MapRenderer-DdaG9rWq.js";import{t as _}from"./useAssetSrc-mWXh4YKw.js";import{t as Te}from"./DocumentStorageClient-CwQ-3oIh.js";import{a as Se,n as V,o as K,r as Ee,t as G}from"./Dialog-BGm0rtm_.js";import"./Dialog-8UuYf7cm.js";import{t as O}from"./Badge-8-nCtEoo.js";import"./Badge-Dyl1iSmB.js";var i=ae(ne(),1),e=le(),I={files:(0,e.jsx)(w,{className:"h-4 w-4"}),documents:(0,e.jsx)(B,{className:"h-4 w-4"}),agents:(0,e.jsx)(Z,{className:"h-4 w-4"}),teams:(0,e.jsx)(ue,{className:"h-4 w-4"}),maps:(0,e.jsx)(H,{className:"h-4 w-4"}),charts:(0,e.jsx)(J,{className:"h-4 w-4"}),default:(0,e.jsx)(k,{className:"h-4 w-4"})},M={files:"bg-blue-500/10 text-blue-500 border-blue-500/20",documents:"bg-green-500/10 text-green-500 border-green-500/20",agents:"bg-purple-500/10 text-purple-500 border-purple-500/20",teams:"bg-orange-500/10 text-orange-500 border-orange-500/20",maps:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",charts:"bg-indigo-500/10 text-indigo-500 border-indigo-500/20",default:"bg-gray-500/10 text-gray-500 border-gray-500/20"};function De(t){const s=[];t.parent?.assets&&s.push(...t.parent.assets);for(const r of t.subagents||[])s.push(...r.assets);return s}var R=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}_/i;function N(t){let s=t.split(` 2`)[0].trim();s=s.split("?")[0];const r=g(s).remainder.split("/");let a=r[r.length-1]||t;return a=a.trim(),R.test(a)?a.replace(R,""):a}function T(t){const s=t.split(` 3`)[0].trim().split("?")[0].split(".");return s.length>1?s[s.length-1].toLowerCase():""}function Ae(t){const s=T(t);return["mp4","webm","mov","avi","mkv","wmv","flv"].includes(s)?(0,e.jsx)(W,{className:"h-4 w-4"}):["mp3","wav","ogg","flac","aac","m4a","wma"].includes(s)?(0,e.jsx)(A,{className:"h-4 w-4"}):["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff"].includes(s)?(0,e.jsx)(w,{className:"h-4 w-4"}):(0,e.jsx)(w,{className:"h-4 w-4"})}function Y(t){try{return new Date(t).toLocaleTimeString()}catch{return""}}var Oe=["jpg","jpeg","png","gif","webp","svg","bmp","ico","tiff"],Ue=["mp4","webm","mov","avi","mkv","wmv","flv"],Le=["mp3","wav","ogg","flac","aac","m4a","wma"],_e=["pdf","doc","docx","txt","md","json","xml","html"];function Pe(t){const s=t.split(` 4`)[0].trim();if(v(s)&&g(s).remainder.startsWith("maps/"))return"map";if(v(s)&&g(s).remainder.startsWith("charts/"))return"chart";const r=T(t);return Oe.includes(r)?"image":Ue.includes(r)?"video":Le.includes(r)?"audio":_e.includes(r)?"document":"unknown"}function S(t){const s=t.uri.split(` 5`)[0].trim();if(he(s)){const r=pe(s);return`/storage-api/api/v1/storage/files/download?path=${encodeURIComponent(r)}`}return v(s)&&g(s).remainder.startsWith("documents/")?`/storage-api/api/v1/storage/files/${g(s).remainder.replace(/^documents\//,"")}/content`:s}function Ie(t){return S(t)}function Me(t,s){const[r,a]=(0,i.useState)(null),[n,l]=(0,i.useState)(!1),[c,d]=(0,i.useState)(null),u=(0,i.useCallback)(async()=>{if(t){l(!0),d(null);try{a(await ge.getContextAssets(t))}catch{d("Failed to load assets")}finally{l(!1)}}},[t]);return(0,i.useEffect)(()=>{s&&t&&u()},[s,t,u]),{assets:r,loading:n,error:c,refetch:u}}function Re(){const[t,s]=(0,i.useState)(null);return{copiedUri:t,copyToClipboard:(0,i.useCallback)(async r=>{try{await navigator.clipboard.writeText(r),s(r),C.success("URI copied to clipboard"),setTimeout(()=>s(null),2e3)}catch{C.error("Failed to copy")}},[])}}function Q(t){return I[t]||I.default}function P(t){return M[t]??M.default??""}function Fe(){return(0,e.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,e.jsx)(j,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}function $e({error:t,onRetry:s}){return(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,e.jsx)("p",{children:t}),(0,e.jsxs)(f,{variant:"outline",onClick:s,className:"mt-4",children:[(0,e.jsx)(de,{className:"h-4 w-4 mr-2"}),"Retry"]})]})}function ze(){return(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,e.jsx)(k,{className:"h-12 w-12 mb-4 opacity-50"}),(0,e.jsx)("p",{children:"No assets produced yet"}),(0,e.jsx)("p",{className:"text-sm mt-1",children:"Assets will appear here when tools create files, documents, or other resources"})]})}function Be({assets:t,selectedType:s,onSelectType:r}){const a=Object.keys(t.byType);return(0,e.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,e.jsxs)(O,{variant:s===null?"default":"outline",className:"cursor-pointer",onClick:()=>r(null),children:["All (",t.totalCount,")"]}),a.map(n=>(0,e.jsxs)(O,{variant:s===n?"default":"outline",className:L("cursor-pointer",s!==n&&P(n)),onClick:()=>r(n),children:[Q(n),(0,e.jsx)("span",{className:"ml-1 capitalize",children:n}),(0,e.jsxs)("span",{className:"ml-1",children:["(",t.byType[n].length,")"]})]},n))]})}function ee(t){return t.resourceType==="files"?Ae(t.uri):Q(t.resourceType)}function We({uri:t,alt:s}){const{src:r,isLoading:a,error:n}=_(t,"image/*"),[l,c]=(0,i.useState)(1),[d,u]=(0,i.useState)(0),[o,x]=(0,i.useState)(!0),[h,p]=(0,i.useState)(!1);(0,i.useEffect)(()=>{n&&(x(!1),p(!0))},[n]);const m=(0,i.useCallback)(()=>{c(b=>Math.min(b+.25,5))},[]),E=(0,i.useCallback)(()=>{c(b=>Math.max(b-.25,.25))},[]),D=(0,i.useCallback)(()=>{u(b=>(b+90)%360)},[]),re=(0,i.useCallback)(()=>{c(1),u(0)},[]);return(0,e.jsxs)("div",{className:"flex flex-col h-full",children:[(0,e.jsxs)("div",{className:"flex items-center justify-center gap-2 py-2 border-b border-white/10",children:[(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:E,disabled:l<=.25,className:"h-8 w-8 p-0",title:"Zoom out",children:(0,e.jsx)(xe,{className:"h-4 w-4"})}),(0,e.jsxs)("span",{className:"text-xs text-muted-foreground w-12 text-center",children:[Math.round(l*100),"%"]}),(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:m,disabled:l>=5,className:"h-8 w-8 p-0",title:"Zoom in",children:(0,e.jsx)(me,{className:"h-4 w-4"})}),(0,e.jsx)("div",{className:"w-px h-4 bg-white/20 mx-1"}),(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:D,className:"h-8 w-8 p-0",title:"Rotate",children:(0,e.jsx)(ie,{className:"h-4 w-4"})}),(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:re,className:"h-8 px-2 text-xs",title:"Reset view",children:"Reset"})]}),(0,e.jsxs)("div",{className:"flex-1 overflow-auto flex items-center justify-center p-4 bg-black/20",children:[(o||a)&&!h&&(0,e.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,e.jsx)(j,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),h?(0,e.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,e.jsx)(w,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),(0,e.jsx)("p",{children:"Failed to load image"})]}):r?(0,e.jsx)("img",{src:r,alt:s,className:"max-w-full max-h-full object-contain transition-transform duration-200",style:{transform:`scale(${l}) rotate(${d}deg)`,opacity:o?0:1},onLoad:()=>x(!1),onError:()=>{x(!1),p(!0)}}):null]})]})}function Xe({uri:t}){const{src:s,isLoading:r,error:a}=_(t,"video/*"),[n,l]=(0,i.useState)(!1);return a||n?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)(W,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),(0,e.jsx)("p",{children:"Failed to load video"})]})}):r||!s?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4 bg-black/20",children:(0,e.jsx)(j,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-4 bg-black/20",children:(0,e.jsx)("video",{src:s,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",onError:()=>l(!0),children:"Your browser does not support the video tag."})})}function Je({uri:t,filename:s}){const{src:r,isLoading:a,error:n}=_(t,"audio/*"),[l,c]=(0,i.useState)(!1);return n||l?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:(0,e.jsxs)("div",{className:"text-center",children:[(0,e.jsx)(A,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),(0,e.jsx)("p",{children:"Failed to load audio"})]})}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-8 bg-gradient-to-b from-purple-900/20 to-blue-900/20",children:[(0,e.jsx)("div",{className:"w-32 h-32 rounded-full bg-gradient-to-br from-purple-500/30 to-blue-500/30 flex items-center justify-center mb-6 border border-white/10",children:(0,e.jsx)(A,{className:"h-16 w-16 text-purple-400"})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground mb-4 text-center max-w-xs truncate",children:s}),a||!r?(0,e.jsx)(j,{className:"h-6 w-6 animate-spin text-muted-foreground"}):(0,e.jsx)("audio",{src:r,controls:!0,className:"w-full max-w-md",onError:()=>c(!0),children:"Your browser does not support the audio tag."})]})}var Ze=["md","txt","json","xml","html","css","js","ts","tsx","jsx","y
5aml","yml","toml","ini","cfg","conf","log","sh","bash","py","go","rs","java","kt","swift","c","cpp","h","hpp","cs","rb","php","sql"],He={h1:({children:t})=>(0,e.jsx)("h1",{className:"text-2xl font-bold mb-4 text-white border-b border-white/10 pb-2",children:t}),h2:({children:t})=>(0,e.jsx)("h2",{className:"text-xl font-semibold mb-3 text-white mt-6",children:t}),h3:({children:t})=>(0,e.jsx)("h3",{className:"text-lg font-semibold mb-2 text-white mt-4",children:t}),h4:({children:t})=>(0,e.jsx)("h4",{className:"text-base font-semibold mb-2 text-white mt-3",children:t}),p:({children:t})=>(0,e.jsx)("p",{className:"mb-3 leading-relaxed text-gray-200",children:t}),a:({href:t,children:s})=>(0,e.jsx)("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 hover:text-blue-300 underline decoration-dotted underline-offset-2",children:s}),ul:({children:t})=>(0,e.jsx)("ul",{className:`${be} text-gray-200`,children:t}),ol:({children:t})=>(0,e.jsx)("ol",{className:`${Ne} text-gray-200`,children:t}),li:({children:t})=>(0,e.jsx)("li",{children:t}),code:({className:t,children:s})=>{const r=/language-(\w+)/.exec(t||"");return!r&&typeof s=="string"&&!s.includes(` 6`)?(0,e.jsx)("code",{className:"px-1.5 py-0.5 bg-gray-700 text-blue-300 rounded text-sm font-mono",children:s}):(0,e.jsxs)("div",{className:"mb-3",children:[r&&(0,e.jsx)("div",{className:"bg-gray-700 text-gray-400 text-xs px-3 py-1 rounded-t border border-gray-600 border-b-0 font-mono",children:r[1]}),(0,e.jsx)("pre",{className:`bg-gray-800 border border-gray-600 ${r?"rounded-b":"rounded-lg"} p-3 overflow-x-auto`,children:(0,e.jsx)("code",{className:"text-sm font-mono text-gray-200",children:s})})]})},blockquote:({children:t})=>(0,e.jsx)("blockquote",{className:"border-l-4 border-blue-500 pl-4 py-1 mb-3 italic text-gray-400 bg-gray-800/50 rounded-r",children:t}),table:({children:t})=>(0,e.jsx)("div",{className:"mb-3 overflow-x-auto rounded-lg border border-gray-600",children:(0,e.jsx)("table",{className:"min-w-full",children:t})}),thead:({children:t})=>(0,e.jsx)("thead",{className:"bg-gray-700",children:t}),tbody:({children:t})=>(0,e.jsx)("tbody",{className:"divide-y divide-gray-700",children:t}),tr:({children:t})=>(0,e.jsx)("tr",{className:"hover:bg-gray-800/50",children:t}),th:({children:t})=>(0,e.jsx)("th",{className:"px-4 py-2 text-left font-semibold text-white text-sm",children:t}),td:({children:t})=>(0,e.jsx)("td",{className:"px-4 py-2 text-gray-200 text-sm",children:t}),hr:()=>(0,e.jsx)("hr",{className:"my-6 border-gray-600"}),strong:({children:t})=>(0,e.jsx)("strong",{className:"font-semibold text-white",children:t}),em:({children:t})=>(0,e.jsx)("em",{className:"italic text-gray-300",children:t}),del:({children:t})=>(0,e.jsx)("del",{className:"line-through opacity-60",children:t}),img:({src:t,alt:s})=>(0,e.jsx)("img",{src:t,alt:s,className:"max-w-full h-auto rounded-lg mb-3 border border-gray-600"})};function qe(t){const s=t.split(` 7`)[0].trim();return v(s)&&g(s).remainder.startsWith("documents/")?g(s).remainder.replace(/^documents\//,""):null}function te(t){const s=T(t);return Ze.includes(s)}function Ve(t){const[s,r]=(0,i.useState)(null),[a,n]=(0,i.useState)(!1),[l,c]=(0,i.useState)(null);return(0,i.useEffect)(()=>{if(!t){r(null),n(!1),c(null);return}const d=te(t.uri),u=qe(t.uri);if(t.resourceType==="documents"&&u){n(!0),c(null),Te.getDocumentContent(u).then(o=>{r(o),n(!1)}).catch(o=>{c(o.message||"Failed to load document content"),n(!1)});return}if(t.resourceType==="files"&&d){const o=S(t);n(!0),c(null),fetch(o).then(x=>{if(!x.ok)throw new Error(`HTTP ${x.status}: ${x.statusText}`);return x.text()}).then(x=>{r(x),n(!1)}).catch(x=>{c(x.message||"Failed to load file content"),n(!1)});return}r(null),n(!1),c(null)},[t]),{content:s,loading:a,error:l}}function Ke({content:t}){return(0,e.jsx)("div",{className:"prose prose-invert prose-sm max-w-none",children:(0,e.jsx)(je,{remarkPlugins:[fe],components:He,children:t})})}function Ge({content:t}){return(0,e.jsx)("pre",{className:"whitespace-pre-wrap font-mono text-sm text-gray-200 bg-gray-800/50 p-4 rounded-lg border border-gray-700 overflow-auto",children:t})}function Ye({content:t}){let s;try{const r=JSON.parse(t);s=JSON.stringify(r,null,2)}catch{s=t}return(0,e.jsx)("pre",{className:"font-mono text-sm bg-gray-800/50 p-4 rounded-lg border border-gray-700 overflow-auto",children:(0,e.jsx)("code",{className:"text-gray-200",children:s.split(` 8`).map((r,a)=>(0,e.jsx)("div",{className:"hover:bg-gray-700/30",children:Qe(r)},a))})})}function Qe(t){return t.replace(/"([^"\\]*(?:\\.[^"\\]*)*)"\s*:/g,'<key>"$1"</key>:').replace(/"([^"\\]*(?:\\.[^"\\]*)*)"/g,s=>s.includes("</key>")?s:`<string>${s}</string>`).split(/(<key>.*?<\/key>|<string>.*?<\/string>)/g).map((s,r)=>s.startsWith("<key>")?(0,e.jsx)("span",{className:"text-purple-400",children:s.replace(/<\/?key>/g,"")},r):s.startsWith("<string>")?(0,e.jsx)("span",{className:"text-green-400",children:s.replace(/<\/?string>/g,"")},r):s.replace(/\b(true|false|null)\b/g,"###BOOL###$1###/BOOL###").replace(/\b(-?\d+\.?\d*)\b/g,"###NUM###$1###/NUM###").split(/(###BOOL###.*?###\/BOOL###|###NUM###.*?###\/NUM###)/g).map((a,n)=>a.startsWith("###BOOL###")?(0,e.jsx)("span",{className:"text-yellow-400",children:a.replace(/###\/?BOOL###/g,"")},`${r}-${n}`):a.startsWith("###NUM###")?(0,e.jsx)("span",{className:"text-blue-400",children:a.replace(/###\/?NUM###/g,"")},`${r}-${n}`):a))}function F({asset:t,url:s}){const r=T(t.uri),a=r==="pdf",n=r==="md",l=r==="json",c=te(t.uri),d=t.resourceType==="documents",u=c||d,{content:o,loading:x,error:h}=Ve(u?t:null);if(a)return(0,e.jsx)("div",{className:"flex-1 flex flex-col",children:(0,e.jsx)(ve,{uri:t.uri,mimeType:"application/pdf",className:"flex-1 w-full bg-white rounded-lg",title:N(t.uri)})});if(u){if(x)return(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-8",children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,e.jsx)(j,{className:"h-8 w-8 animate-spin text-blue-400"}),(0,e.jsx)("p",{className:"text-sm text-gray-400",children:"Loading document content..."})]})});if(h)return(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-muted-foreground",children:[(0,e.jsx)(U,{className:"h-12 w-12 mb-4 text-red-400"}),(0,e.jsx)("p",{className:"text-lg font-medium mb-2 text-white",children:N(t.uri)}),(0,e.jsx)("p",{className:"text-sm mb-4 text-red-400",children:h}),(0,e.jsxs)(f,{variant:"outline",onClick:()=>window.open(s,"_blank"),className:"gap-2",children:[(0,e.jsx)(y,{className:"h-4 w-4"}),"Open in Browser"]})]});if(o!==null)return(0,e.jsx)("div",{className:"flex-1 overflow-auto p-6 bg-gray-900/50",children:n||d?(0,e.jsx)(Ke,{content:o}):l?(0,e.jsx)(Ye,{content:o}):(0,e.jsx)(Ge,{content:o})})}return(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-muted-foreground",children:[(0,e.jsx)(B,{className:"h-16 w-16 mb-4 opacity-50"}),(0,e.jsx)("p",{className:"text-lg font-medium mb-2",children:N(t.uri)}),(0,e.jsx)("p",{className:"text-sm mb-6",children:"Document preview not available"}),(0,e.jsxs)(f,{variant:"outline",onClick:()=>window.open(s,"_blank"),className:"gap-2",children:[(0,e.jsx)(y,{className:"h-4 w-4"}),"Open Document"]})]})}function et({asset:t,url:s}){return(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-muted-foreground",children:[(0,e.jsx)(k,{className:"h-16 w-16 mb-4 opacity-50"}),(0,e.jsx)("p",{className:"text-lg font-medium mb-2",children:N(t.uri)}),(0,e.jsx)("p",{className:"text-sm mb-6",children:"Preview not available for this file type"}),(0,e.jsxs)(f,{variant:"outline",onClick:()=>window.open(s,"_blank"),className:"gap-2",children:[(0,e.jsx)(X,{className:"h-4 w-4"}),"Download File"]})]})}function se(t,s){const r=t.split(` 9`)[0].trim();return r.startsWith(s)?r.replace(s,""):/^[0-9a-f]+$/i.test(r)&&!r.includes("/")&&!r.includes(":")?r:null}function tt(t){const s=["blue","red","green","orange","purple"],r=m=>m&&s.includes(m)?m:void 0,a=["default","dark","satellite"],n=m=>m&&a.includes(m)?m:"default",l=t.config,c=l?.markers||t.markers,d=l?.heatmapData||t.heatmapData,u=l?.choroplethData||t.choroplethData,o=l?.center||t.center,x=l?.zoom||t.zoom,h=l?.regionType||t.regionType,p=l?.style||t.style;
9return{mapType:t.mapType,title:t.title,markers:c?.map(m=>({lat:m.lat,lng:m.lng,title:m.title,description:m.description,color:r(m.color)})),heatmapData:d?.map(m=>({lat:m.lat,lng:m.lng,intensity:m.intensity})),regionType:h,choroplethData:u?.map(m=>({region:m.region,value:m.value,label:m.label})),center:o,zoom:x,style:p?{height:p.height,tileStyle:n(p.tileStyle)}:void 0}}function $({asset:t}){const{data:s,isLoading:r,error:a}=Ce(se(t.uri,"unago://maps/"));return r?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-8",children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,e.jsx)(j,{className:"h-8 w-8 animate-spin text-emerald-400"}),(0,e.jsx)("p",{className:"text-sm text-gray-400",children:"Loading map..."})]})}):a?(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-muted-foreground",children:[(0,e.jsx)(U,{className:"h-12 w-12 mb-4 text-red-400"}),(0,e.jsx)("p",{className:"text-lg font-medium mb-2 text-white",children:s?.title||"Map"}),(0,e.jsx)("p",{className:"text-sm mb-4 text-red-400",children:a?.message||"Failed to load map"})]}):s?(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(ke,{config:tt(s),maxHeight:700,className:"h-full"})}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-muted-foreground",children:[(0,e.jsx)(H,{className:"h-12 w-12 mb-4 opacity-50"}),(0,e.jsx)("p",{className:"text-lg font-medium mb-2",children:"Map not found"})]})}function z({asset:t}){const{data:s,isLoading:r,error:a}=ye(se(t.uri,"unago://charts/"));return r?(0,e.jsx)("div",{className:"flex-1 flex items-center justify-center p-8",children:(0,e.jsxs)("div",{className:"flex flex-col items-center gap-4",children:[(0,e.jsx)(j,{className:"h-8 w-8 animate-spin text-indigo-400"}),(0,e.jsx)("p",{className:"text-sm text-gray-400",children:"Loading chart..."})]})}):a?(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-muted-foreground",children:[(0,e.jsx)(U,{className:"h-12 w-12 mb-4 text-red-400"}),(0,e.jsx)("p",{className:"text-lg font-medium mb-2 text-white",children:"Chart"}),(0,e.jsx)("p",{className:"text-sm mb-4 text-red-400",children:a.message})]}):s?(0,e.jsx)("div",{className:"flex-1 overflow-auto p-4",children:(0,e.jsx)(we,{config:s,maxHeight:600,className:"h-full"})}):(0,e.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center p-8 text-muted-foreground",children:[(0,e.jsx)(J,{className:"h-12 w-12 mb-4 opacity-50"}),(0,e.jsx)("p",{className:"text-lg font-medium mb-2",children:"Chart not found"})]})}function st({asset:t,open:s,onClose:r}){if(!t||!s)return null;const a=S(t),n=Pe(t.uri),l=N(t.uri),c=(0,i.useCallback)(()=>{const o=document.createElement("a");o.href=Ie(t),o.download=l,o.target="_blank",document.body.appendChild(o),o.click(),document.body.removeChild(o)},[t,l]),d=(0,i.useCallback)(async()=>{try{await navigator.clipboard.writeText(t.uri),C.success("URI copied to clipboard")}catch{C.error("Failed to copy URI")}},[t.uri]),u=()=>{if(t.resourceType==="documents")return(0,e.jsx)(F,{asset:t,url:a});if(t.resourceType==="maps")return(0,e.jsx)($,{asset:t});if(t.resourceType==="charts")return(0,e.jsx)(z,{asset:t});switch(n){case"image":return(0,e.jsx)(We,{uri:t.uri,alt:l});case"video":return(0,e.jsx)(Xe,{uri:t.uri});case"audio":return(0,e.jsx)(Je,{uri:t.uri,filename:l});case"document":return(0,e.jsx)(F,{asset:t,url:a});case"map":return(0,e.jsx)($,{asset:t});case"chart":return(0,e.jsx)(z,{asset:t});default:return(0,e.jsx)(et,{asset:t,url:a})}};return(0,e.jsx)(G,{open:s,onOpenChange:o=>!o&&r(),children:(0,e.jsxs)(V,{className:"max-w-lg sm:max-w-[1800px] w-[95vw] h-[92vh] p-0 overflow-hidden bg-gray-900/95 backdrop-blur-xl border-white/10",children:[(0,e.jsxs)(K,{className:"sr-only",children:["Preview: ",l]}),(0,e.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/10 bg-black/20",children:[(0,e.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,e.jsx)("div",{className:L("p-2 rounded-lg border",P(t.resourceType)),children:ee(t)}),(0,e.jsxs)("div",{className:"min-w-0",children:[(0,e.jsx)("h3",{className:"font-medium text-white truncate",title:l,children:l}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground truncate",title:t.uri,children:[t.toolName,t.capturedAt&&` ⢠${Y(t.capturedAt)}`]})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",children:[(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:d,className:"h-8 w-8 p-0 hover:bg-white/10",title:"Copy URI",children:(0,e.jsx)(q,{className:"h-4 w-4"})}),(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:c,className:"h-8 w-8 p-0 hover:bg-white/10",title:"Download",children:(0,e.jsx)(X,{className:"h-4 w-4"})}),(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:()=>window.open(a,"_blank"),className:"h-8 w-8 p-0 hover:bg-white/10",title:"Open in new tab",children:(0,e.jsx)(y,{className:"h-4 w-4"})}),(0,e.jsx)("div",{className:"w-px h-4 bg-white/20 mx-1"}),(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:r,className:"h-8 w-8 p-0 hover:bg-white/10",title:"Close",children:(0,e.jsx)(ce,{className:"h-4 w-4"})})]})]}),(0,e.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",style:{height:"calc(100% - 60px)"},children:u()})]})})}function rt({asset:t,copiedUri:s,onCopy:r,onPreview:a}){const n=(0,i.useCallback)(()=>{a(t)},[t,a]),l=(0,i.useCallback)(d=>{d.stopPropagation(),r(t.uri)},[t.uri,r]),c=(0,i.useCallback)(d=>{d.stopPropagation();const u=S(t);window.open(u,"_blank")},[t]);return(0,e.jsxs)("div",{className:"flex items-center gap-2 py-2 px-3 rounded-md border bg-card hover:bg-accent/50 transition-colors cursor-pointer group",onClick:n,role:"button",tabIndex:0,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),n())},children:[(0,e.jsx)("div",{className:L("p-1.5 rounded border",P(t.resourceType)),children:ee(t)}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsx)("p",{className:"text-sm font-medium truncate",title:t.uri,children:N(t.uri)}),(0,e.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[t.toolName,t.capturedAt&&` ⢠${Y(t.capturedAt)}`]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:l,className:"h-7 w-7 p-0",title:"Copy URI",children:s===t.uri?(0,e.jsx)(oe,{className:"h-3.5 w-3.5 text-green-500"}):(0,e.jsx)(q,{className:"h-3.5 w-3.5"})}),t.resourceType==="files"&&(0,e.jsx)(f,{variant:"ghost",size:"sm",onClick:c,className:"h-7 w-7 p-0",title:"Open in new tab",children:(0,e.jsx)(y,{className:"h-3.5 w-3.5"})})]})]})}function at({assets:t,selectedType:s,copiedUri:r,onCopy:a,onPreview:n}){return(0,e.jsx)("div",{className:"flex-1 overflow-y-auto space-y-1.5 pr-1",children:(s?t.byType[s]||[]:De(t)).map((l,c)=>(0,e.jsx)(rt,{asset:l,copiedUri:r,onCopy:a,onPreview:n},`${l.uri}-${c}`))})}function nt({subagents:t}){if(!t||t.length===0)return null;const s=t.filter(r=>r.assets.length>0);return s.length===0?null:(0,e.jsxs)("div",{className:"border-t pt-3 mt-2",children:[(0,e.jsxs)("p",{className:"text-xs font-medium mb-2 text-muted-foreground",children:["From Subagents (",s.reduce((r,a)=>r+a.assets.length,0)," assets from ",s.length," ","subagent",s.length>
91?"s":"",")"]}),(0,e.jsx)("div",{className:"flex flex-wrap gap-2",children:s.map(r=>(0,e.jsxs)(O,{variant:"outline",className:"text-xs bg-purple-500/10 text-purple-600 dark:text-purple-400 border-purple-500/20",children:[(0,e.jsx)(Z,{className:"h-3 w-3 mr-1"}),r.contextName||"Subagent",": ",r.assets.length]},r.contextId))})]})}function kt({open:t,onOpenChange:s,conversationId:r}){const{assets:a,loading:n,error:l,refetch:c}=Me(r,t),{copiedUri:d,copyToClipboard:u}=Re(),[o,x]=(0,i.useState)(null),[h,p]=(0,i.useState)(null);(0,i.useEffect)(()=>{t&&(x(null),p(null))},[t]);const m=(0,i.useCallback)(D=>{p(D)},[]),E=(0,i.useCallback)(()=>{p(null)},[]);return(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(G,{open:t,onOpenChange:s,children:(0,e.jsxs)(V,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[(0,e.jsxs)(Se,{children:[(0,e.jsxs)(K,{className:"flex items-center gap-2",children:[(0,e.jsx)(k,{className:"h-5 w-5"}),"Produced Assets"]}),(0,e.jsx)(Ee,{children:"Resources created during this conversation. Click an asset to preview."})]}),n?(0,e.jsx)(Fe,{}):l?(0,e.jsx)($e,{error:l,onRetry:c}):!a||a.totalCount===0?(0,e.jsx)(ze,{}):(0,e.jsxs)("div",{className:"flex flex-col gap-4 overflow-hidden",children:[(0,e.jsx)(Be,{assets:a,selectedType:o,onSelectType:x}),(0,e.jsx)(at,{assets:a,selectedType:o,copiedUri:d,onCopy:u,onPreview:m}),(0,e.jsx)(nt,{subagents:a.subagents})]})]})}),(0,e.jsx)(st,{asset:h,open:h!==null,onClose:E})]})}export{kt as AssetsPopup};
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.