cortex-react-components 2.18.5 → 2.18.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-2SMCWU5D.mjs → chunk-275W7H4O.mjs} +1 -1
- package/dist/{chunk-VRE6VCHX.mjs → chunk-2BR55L74.mjs} +1 -1
- package/dist/{chunk-NXG2Y4N4.mjs → chunk-33CHGT4N.mjs} +1 -1
- package/dist/{chunk-7HII2RTR.mjs → chunk-347B45ZS.mjs} +1 -1
- package/dist/{chunk-2E7GRMZB.mjs → chunk-3DZFESHK.mjs} +1 -1
- package/dist/{chunk-PRK2XFAZ.mjs → chunk-3EGSOIRH.mjs} +1 -1
- package/dist/{chunk-5RKIC5BC.mjs → chunk-3ZQFJ5WD.mjs} +1 -1
- package/dist/{chunk-LYQOKIQY.mjs → chunk-4DR4ILAP.mjs} +1 -1
- package/dist/{chunk-Y62OBV2E.mjs → chunk-6EKGV4I2.mjs} +1 -1
- package/dist/{chunk-BDNY6OKE.mjs → chunk-ANCSWAD7.mjs} +1 -1
- package/dist/{chunk-JUFFNFV6.mjs → chunk-CCJJAUGB.mjs} +1 -1
- package/dist/{chunk-WDZOGIT2.mjs → chunk-CTC6WSB6.mjs} +1 -1
- package/dist/{chunk-M74BIPBM.mjs → chunk-GO42W2BM.mjs} +1 -1
- package/dist/{chunk-SSMQFOZF.mjs → chunk-H5VFV6Q4.mjs} +1 -1
- package/dist/{chunk-4RET4JGB.mjs → chunk-HHPTGV4F.mjs} +1 -1
- package/dist/{chunk-JLUX7EHB.mjs → chunk-HLTP3ZQN.mjs} +1 -1
- package/dist/{chunk-SYJIMO4P.mjs → chunk-JCWFPKF3.mjs} +1 -1
- package/dist/{chunk-QRJCVFHT.mjs → chunk-JEWBD2UD.mjs} +1 -1
- package/dist/{chunk-4NHQXOKZ.mjs → chunk-JNJJAJPI.mjs} +1 -1
- package/dist/{chunk-HEW44L6X.mjs → chunk-JSHD7QTU.mjs} +1 -1
- package/dist/{chunk-WUA65ZZB.mjs → chunk-L3BLBPSR.mjs} +1 -1
- package/dist/{chunk-75WE6ZXB.mjs → chunk-LAQ3QAUW.mjs} +1 -1
- package/dist/{chunk-KRLNPNMZ.mjs → chunk-MEVSHOG4.mjs} +1 -1
- package/dist/{chunk-BGADMIWV.mjs → chunk-MFUZNS7C.mjs} +1 -1
- package/dist/{chunk-5KS3DITB.mjs → chunk-MGSTQLZC.mjs} +1 -1
- package/dist/{chunk-RIRZRO6U.mjs → chunk-P55W6AFU.mjs} +1 -1
- package/dist/{chunk-6RQED6RT.mjs → chunk-PAEL4O5F.mjs} +1 -1
- package/dist/{chunk-NN4QIXZ2.mjs → chunk-PTJVI53B.mjs} +1 -1
- package/dist/{chunk-HNHUOQGZ.mjs → chunk-QAJBJFRP.mjs} +1 -1
- package/dist/{chunk-2GZQYAN3.mjs → chunk-QILFMWE5.mjs} +1 -1
- package/dist/{chunk-UX5OJ3WS.mjs → chunk-QZIJTAPO.mjs} +1 -1
- package/dist/{chunk-PZZTGPEO.mjs → chunk-R33MOMFK.mjs} +1 -1
- package/dist/{chunk-D6K6RO5P.mjs → chunk-R5P4ZICA.mjs} +1 -1
- package/dist/{chunk-66ODXUVL.mjs → chunk-RMZLEIRP.mjs} +1 -1
- package/dist/{chunk-DZ7AGPLI.mjs → chunk-RS4VD3ML.mjs} +1 -1
- package/dist/{chunk-T5HJS6OF.mjs → chunk-RSDUFAIB.mjs} +1 -1
- package/dist/{chunk-YFOSTZOD.mjs → chunk-UTRR5NUU.mjs} +1 -1
- package/dist/{chunk-BN747TQM.mjs → chunk-VQBOJHZF.mjs} +1 -1
- package/dist/{chunk-CPZ42O7I.mjs → chunk-WAVVCASZ.mjs} +1 -1
- package/dist/chunk-WRZP5K5X.mjs +1 -0
- package/dist/{chunk-UZSBX5GO.mjs → chunk-X3JZSN3W.mjs} +1 -1
- package/dist/{chunk-VNYUNZ3M.mjs → chunk-XGIYNUGC.mjs} +1 -1
- package/dist/{chunk-ZZ6VZFRV.mjs → chunk-XYJ4S67W.mjs} +1 -1
- package/dist/{chunk-T36QUKC6.mjs → chunk-YPSUDHCJ.mjs} +1 -1
- package/dist/{chunk-JT65KF7C.mjs → chunk-YWRU7OE3.mjs} +1 -1
- package/dist/components/Blocks/Banner.mjs +1 -1
- package/dist/components/Blocks/CallToAction.mjs +1 -1
- package/dist/components/Blocks/CollapsibleArea.mjs +1 -1
- package/dist/components/Blocks/Content.mjs +1 -1
- package/dist/components/Blocks/FeaturesBlock.mjs +1 -1
- package/dist/components/Blocks/ImageBlock.mjs +1 -1
- package/dist/components/Blocks/MediaBlock.mjs +1 -1
- package/dist/components/Blocks/RelatedPosts.mjs +1 -1
- package/dist/components/Blocks/RenderBlocks.mjs +1 -1
- package/dist/components/Blocks/ReusableContentBlock.mjs +1 -1
- package/dist/components/Blocks/index.mjs +1 -1
- package/dist/components/Cards/ContentCard.mjs +1 -1
- package/dist/components/Cards/FeatureCard.mjs +1 -1
- package/dist/components/Cards/index.mjs +1 -1
- package/dist/components/Chat/ChatInterface.js +1 -1
- package/dist/components/Chat/ChatInterface.mjs +1 -1
- package/dist/components/Chat/CopilotInterface.js +1 -1
- package/dist/components/Chat/CopilotInterface.mjs +1 -1
- package/dist/components/Chat/PartTypes/MessageHandler.js +6 -6
- package/dist/components/Chat/PartTypes/MessageHandler.mjs +1 -1
- package/dist/components/Chat/PartTypes/PartApprovalTool.d.ts +1 -0
- package/dist/components/Chat/PartTypes/PartApprovalTool.js +2 -2
- package/dist/components/Chat/PartTypes/PartApprovalTool.mjs +1 -1
- package/dist/components/Chat/PartTypes/index.js +1 -1
- package/dist/components/Chat/PartTypes/index.mjs +1 -1
- package/dist/components/Chat/demo-long-messages.js +1 -1
- package/dist/components/Chat/demo-long-messages.mjs +1 -1
- package/dist/components/Chat/demo-tests.js +1 -1
- package/dist/components/Chat/demo-tests.mjs +1 -1
- package/dist/components/Chat/demo.js +1 -1
- package/dist/components/Chat/demo.mjs +1 -1
- package/dist/components/Chat/example-usage.js +1 -1
- package/dist/components/Chat/example-usage.mjs +1 -1
- package/dist/components/Chat/example-with-vercel-ai.js +1 -1
- package/dist/components/Chat/example-with-vercel-ai.mjs +1 -1
- package/dist/components/Chat/index.js +1 -1
- package/dist/components/Chat/index.mjs +1 -1
- package/dist/components/DigitalColleagues/MainPage.mjs +1 -1
- package/dist/components/DigitalColleagues/Views/index.mjs +1 -1
- package/dist/components/DigitalColleagues/index.mjs +1 -1
- package/dist/components/Foundary/MainPage.mjs +1 -1
- package/dist/components/Foundary/Pages/dashboardpage.mjs +1 -1
- package/dist/components/Foundary/RichText/index.mjs +1 -1
- package/dist/components/Foundary/RichText/plugins/toolbar-plugin.mjs +1 -1
- package/dist/components/Foundary/Views/ColleaguesView.mjs +1 -1
- package/dist/components/Foundary/Views/KnowledgeView.mjs +1 -1
- package/dist/components/Foundary/Views/index.mjs +1 -1
- package/dist/components/Foundary/document-edit.mjs +1 -1
- package/dist/components/Foundary/document-preview-examples.mjs +1 -1
- package/dist/components/Foundary/document-preview.mjs +1 -1
- package/dist/components/Foundary/index.mjs +1 -1
- package/dist/components/Foundary/knowledge-browser.mjs +1 -1
- package/dist/components/HeaderFooter/Header.mjs +1 -1
- package/dist/components/HeaderFooter/HeaderDesktop.mjs +1 -1
- package/dist/components/HeaderFooter/SectionHeading.mjs +1 -1
- package/dist/components/HeaderFooter/index.mjs +1 -1
- package/dist/components/Heros/HighImpact/index.mjs +1 -1
- package/dist/components/Heros/LowImpact/index.mjs +1 -1
- package/dist/components/Heros/MediumImpact/index.mjs +1 -1
- package/dist/components/Heros/RenderHero.mjs +1 -1
- package/dist/components/Heros/index.mjs +1 -1
- package/dist/components/Holidays/HolidayTracker.mjs +1 -1
- package/dist/components/Holidays/index.mjs +1 -1
- package/dist/components/Layouts/OutputHeaderFooter.mjs +1 -1
- package/dist/components/Layouts/Print.mjs +1 -1
- package/dist/components/Layouts/SlideShow.mjs +1 -1
- package/dist/components/Layouts/index.mjs +1 -1
- package/dist/components/Payload/CollectionArchive/index.mjs +1 -1
- package/dist/components/Payload/Media/index.mjs +1 -1
- package/dist/components/Payload/PayloadCard/index.mjs +1 -1
- package/dist/components/Payload/RichText/index.mjs +1 -1
- package/dist/components/Payload/RichText/serialize.mjs +1 -1
- package/dist/components/Payload/index.mjs +1 -1
- package/dist/components/dc-temp/index.mjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/pages/Blog.mjs +1 -1
- package/dist/pages/Documentation.mjs +1 -1
- package/dist/pages/IndexPage.mjs +1 -1
- package/dist/pages/Intranet.mjs +1 -1
- package/dist/pages/LandingPage.mjs +1 -1
- package/dist/pages/Page.mjs +1 -1
- package/dist/pages/Publish.mjs +1 -1
- package/dist/pages/Website.mjs +1 -1
- package/dist/sections/AboutSection.mjs +1 -1
- package/dist/sections/BlogDetail.mjs +1 -1
- package/dist/sections/BlogList.mjs +1 -1
- package/dist/sections/ContactSection.mjs +1 -1
- package/dist/sections/PageSections.mjs +1 -1
- package/dist/sections/PricingSection.mjs +1 -1
- package/dist/sections/ServiceDetail.mjs +1 -1
- package/dist/sections/ServiceDetailSection.mjs +1 -1
- package/dist/sections/ServiceSection.mjs +1 -1
- package/dist/sections/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-EH3PJU6C.mjs +0 -1
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
`,children:r?"Processing...":"Deny"}),(0,Lo.jsx)("button",{onClick:w,disabled:r,className:`
|
|
19
19
|
px-4 py-2 text-white border-none rounded text-sm
|
|
20
20
|
${r?"bg-gray-400 cursor-not-allowed":"bg-gray-500 hover:bg-gray-600 cursor-pointer"}
|
|
21
|
-
`,children:"Cancel"})]})]}):null};var ya=({toolPart:e,index:t,addToolResult:o})=>{let[a,n]=go.default.useState(!0),[i,r]=go.default.useState(null),s=()=>{o(e.input?.toolCallId,e.input?.tool,"Approved"),n(!1),r("approve")},c=()=>{o(e.input?.toolCallId,e.input?.tool,"Denied"),n(!1),r("deny")};switch(e.state){case"input-available":return(0,Lo.jsxs)("div",{className:"mb-2",children:[(0,Lo.jsx)(ha,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,Lo.jsxs)(Lo.Fragment,{children:[i==="approve"&&(0,Lo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Lo.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200",children:[(0,Lo.jsx)("svg",{className:"Lo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Lo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,Lo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Lo.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-red-100 text-red-800 text-sm font-medium border border-red-200",children:[(0,Lo.jsx)("svg",{className:"Lo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Lo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var fo=require("@radix-ui/react-use-controllable-state");var nt=V(require("@radix-ui/react-collapsible")),zt=nt.Root,Ut=nt.CollapsibleTrigger,Ft=nt.CollapsibleContent;var wa=require("streamdown"),yt=(0,qa.memo)(({className:e,...t})=>(0,Lo.jsx)(wa.Streamdown,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);yt.displayName="Response";var Na=(0,qa.createContext)(null),lr=()=>{let e=(0,qa.useContext)(Na);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},cr=1e3,dr=1e3,bo=(0,qa.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:a=!0,onOpenChange:n,duration:i,children:r,...s})=>{let[c,m]=(0,fo.useControllableState)({prop:o,defaultProp:a,onChange:n}),[w,f]=(0,fo.useControllableState)({prop:i,defaultProp:0}),[y,R]=(0,qa.useState)(!1),[S,T]=(0,qa.useState)(null);(0,qa.useEffect)(()=>{t?S===null&&T(Date.now()):S!==null&&(f(Math.ceil((Date.now()-S)/dr)),T(null))},[t,S,f]),(0,qa.useEffect)(()=>{if(a&&!t&&c&&!y){let N=setTimeout(()=>{m(!1),R(!0)},cr);return()=>clearTimeout(N)}},[t,c,a,m,y]);let C=N=>{m(N)};return(0,Lo.jsx)(Na.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,Lo.jsx)(zt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),pr=(e,t)=>e||t===0?(0,Lo.jsx)("Lo",{children:"Thinking..."}):t===void 0?(0,Lo.jsx)("Lo",{children:"Thought for a few seconds"}):(0,Lo.jsxs)("Lo",{children:["Thought for ",t," seconds"]}),vo=(0,qa.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=lr();return(0,Lo.jsx)(Ut,{className:l("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,Lo.jsxs)(Lo.Fragment,{children:[(0,Lo.jsx)(Wa.BrainIcon,{className:"size-4"}),pr(a,i),(0,Lo.jsx)(Wa.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),ho=(0,qa.memo)(({className:e,children:t,...o})=>(0,Lo.jsx)(Ft,{className:l("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...o,children:(0,Lo.jsx)(yt,{className:"grid gap-2",children:t})}));bo.displayName="Reasoning";vo.displayName="ReasoningTrigger";ho.displayName="ReasoningContent";var yo=require("react-syntax-highlighter"),Ot=require("react-syntax-highlighter/dist/esm/styles/prism"),mr=(0,qa.createContext)({code:""}),Vt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,Lo.jsx)(mr.Provider,{value:{code:e},children:(0,Lo.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,Lo.jsxs)("div",{className:"relative",children:[(0,Lo.jsx)(yo.Prism,{className:"overflow-hidden dark:hidden",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:o,style:Ot.oneLight,children:e}),(0,Lo.jsx)(yo.Prism,{className:"hidden overflow-hidden dark:block",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:o,style:Ot.oneDark,children:e}),n&&(0,Lo.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Pa=({className:e,...t})=>(0,Lo.jsx)(zt,{className:l("not-prose mb-4 w-full",e),...t}),ur=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Lo.jsxs)(ae,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Lo.jsx)(Wa.CircleIcon,{className:"size-4"}),"input-available":(0,Lo.jsx)(Wa.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Lo.jsx)(Wa.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Lo.jsx)(Wa.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Ta=({className:e,type:t,state:o,...a})=>(0,Lo.jsxs)(Ut,{className:l("flex w-full items-center justify-between gap-4 Lo-3 pl-0 w-2xl",e),...a,children:[(0,Lo.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Lo.jsx)(Wa.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Lo.jsx)("span",{className:"font-medium text-sm",children:t}),ur(o)]}),(0,Lo.jsx)(Wa.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Da=({className:e,...t})=>(0,Lo.jsx)(Ft,{className:l("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),Ra=({className:e,input:t,...o})=>(0,Lo.jsxs)("div",{className:l("space-y-2 overflow-hidden Lo-4",e),...o,children:[(0,Lo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Lo.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Lo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"})})]}),Aa=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,Lo.jsx)("div",{children:t});return typeof t=="object"?n=(0,Lo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,Lo.jsx)(Vt,{code:t,language:"json"})),(0,Lo.jsxs)("div",{className:l("space-y-2 Lo-4",e),...a,children:[(0,Lo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Lo.jsxs)("div",{className:l("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[o&&(0,Lo.jsx)("div",{children:o}),n]})]})};var Ma=require("date-fns");function Sa({taskId:e,polling:t=!0,system:o="payload"}){let[a,n]=(0,qa.useState)(null),[i,r]=(0,qa.useState)(!1),[s,c]=(0,qa.useState)(null),m=async(f=!0)=>{if(e){f&&r(!0);try{let y=await fetch(`/api/tasks/${e}`);if(!y.ok)throw new Error(`Failed to fetch task: ${y.statusText}`);let R=await y.json();n(R)}catch(y){console.error("Error fetching task:",y),c(y instanceof Error?y:new Error("Unknown error occurred"))}finally{f&&r(!1)}}},w=()=>m(!1);return(0,qa.useEffect)(()=>{e&&m(!0);let f=null;return e&&t&&(f=setInterval(w,5e3)),()=>{f&&clearInterval(f)}},[e,t]),{task:a,loading:i,error:s}}var gr=e=>{switch(e){case"backlog":return"bg-gray-200 text-gray-800";case"todo":return"bg-blue-200 text-blue-800";case"inProgress":return"bg-yellow-200 text-yellow-800";case"done":return"bg-green-200 text-green-800";case"cancelled":return"bg-red-200 text-red-800";default:return"bg-gray-200 text-gray-800"}},fr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Ba({data:e}){let{id:t,system:o,fetchLatest:a,taskData:n,error:i}=e||{};if(!t)return null;let r=null,s=!0,c=i,m=a!==void 0?a:!0;if(r=n||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:a,system:o,fetchLatest:m,taskData:r,error:c}),m){let{task:R,loading:S,error:T}=Sa({taskId:t,system:o});r=R,s=S,c=T}else s=!1;let w=gr(r?.status||"todo"),f=fr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let R=new Date(r?.dateLogged||"");isNaN(R.getTime())||(y=(0,Ma.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Lo.jsxs)(ge,{className:l("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Lo.jsxs)(Le,{className:"pb-2",children:[(0,Lo.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Lo.jsx)(Ee,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,Lo.jsx)(ae,{className:`${w}`,children:f})]}),r?.project&&(0,Lo.jsxs)(co,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,Lo.jsx)(Pe,{className:"pb-2",children:s?(0,Lo.jsx)("div",{className:"animate-pulse Lo-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Lo.jsx)("Lo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Lo.jsx)("Lo",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,Lo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Lo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Lo.jsx)(Wa.Clock,{className:"Lo-3 w-3 mr-1"}),(0,Lo.jsxs)("span",{children:["Created ",y]}),(0,Lo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Lo.jsxs)("span",{children:["Task #",t]})]})})]})}function za({artefact:e,taskId:t,taskData:o,loading:a=!1,error:n=null}){let i=o||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},r=i.dateLogged;try{let s=new Date(i.dateLogged);isNaN(s.getTime())||(r=(0,Ma.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,Lo.jsxs)(ge,{className:"w-full max-w-md shadow-md",children:[(0,Lo.jsx)(Le,{className:"pb-2",children:(0,Lo.jsx)("div",{className:"flex justify-between items-start",children:(0,Lo.jsx)(Ee,{className:"text-lg font-semibold",children:a?"Loading...":i.name})})}),(0,Lo.jsx)(Pe,{className:"pb-2",children:a?(0,Lo.jsx)("div",{className:"animate-pulse Lo-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,Lo.jsx)("Lo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Lo.jsx)("Lo",{className:"text-sm text-foreground",children:e})}),(0,Lo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Lo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Lo.jsx)(Wa.Clock,{className:"Lo-3 w-3 mr-1"}),(0,Lo.jsxs)("span",{children:["Created ",r]}),(0,Lo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Lo.jsxs)("span",{children:["Task #",i.id]})]})})]})}var br=e=>e.startsWith("image/")?(0,Lo.jsx)(Wa.Image,{className:"Lo-4 w-4"}):e.startsWith("text/")?(0,Lo.jsx)(Wa.FileText,{className:"Lo-4 w-4"}):(0,Lo.jsx)(Wa.File,{className:"Lo-4 w-4"}),Ua=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,Lo.jsx)(yt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,Lo.jsx)("div",{className:"mb-2 Lo-2 bg-background/50 rounded-lg",children:(0,Lo.jsxs)("div",{className:"flex items-center gap-2",children:[br(r.mediaType||"application/octet-stream"),(0,Lo.jsx)("div",{className:"flex-1 min-w-0",children:(0,Lo.jsx)("Lo",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"Lo-8 w-8 Lo-0",children:(0,Lo.jsx)(Wa.Download,{className:"Lo-4 w-4"})})]})},i)}if(n.type.startsWith("tool-")){let r=n,s=n.type.replace("tool-","");if(s==="task")switch(r.state){case"input-available":return(0,Lo.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(Ba,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return console.log("Rendering PartApprovalTool with toolPart:",r),(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(ya,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,Lo.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(za,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Lo.jsxs)(Pe,{children:[r.state==="input-available"&&(0,Lo.jsxs)("Lo",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,Lo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,Lo.jsxs)("Lo",{className:"text-sm text-red-500",children:["Error: ",r.errorText]})]})]})},i)}if(n.type.startsWith("data-")){let r=n,s=n.type.replace("data-","");return s==="reference"?(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(ge,{className:"w-full",children:(0,Lo.jsx)(Pe,{className:"Lo-4",children:(0,Lo.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,Lo.jsxs)("div",{className:"flex items-center gap-2 Lo-2 rounded-md bg-muted/50",children:[(0,Lo.jsx)(ae,{variant:"outline",children:c.type||"link"}),(0,Lo.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Lo.jsx)("Lo",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Lo.jsx)("Lo",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"Lo-8 w-8 Lo-0",children:(0,Lo.jsx)(Wa.ExternalLink,{className:"Lo-4 w-4"})})]},m))})})})},i):s==="menu"?(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:r.data?.title})}),(0,Lo.jsx)(Pe,{children:(0,Lo.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,Lo.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Lo.jsxs)("div",{className:"text-left",children:[(0,Lo.jsx)("Lo",{className:"font-medium",children:c.label}),c.description&&(0,Lo.jsx)("Lo",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Lo.jsx)(Pe,{children:(0,Lo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}if(n.type==="reasoning")return(0,Lo.jsxs)(bo,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.at(-1)?.id,children:[(0,Lo.jsx)(vo,{}),(0,Lo.jsx)(ho,{children:n.text})]},`${i}`);if(n.type==="dynamic-tool")return(0,Lo.jsxs)(Pa,{defaultOpen:n.state!=="output-available",children:[(0,Lo.jsx)(Ta,{type:`tool-${n.toolName}`,state:n.state}),(0,Lo.jsxs)(Da,{children:[(0,Lo.jsx)(Ra,{input:n.input}),(0,Lo.jsx)(Aa,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`)});var Ha=({className:e,from:t,...o})=>(0,Lo.jsx)("div",{className:l("group flex w-full items-end justify-end gap-2 py-4",t==="user"?"is-user":"is-assistant flex-row-reverse justify-end",e),...o}),vr=(0,Bo.cva)("is-user:dark flex flex-col gap-2 overflow-hidden rounded-lg text-sm",{variants:{variant:{contained:["max-w-[80%] px-4 py-3","group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground","group-[.is-assistant]:bg-secondary group-[.is-assistant]:text-foreground"],flat:["group-[.is-user]:max-w-[80%] group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground"]}},defaultVariants:{variant:"contained"}}),ja=({children:e,className:t,variant:o,...a})=>(0,Lo.jsx)("div",{className:l(vr({variant:o,className:t})),...a,children:e});function Oa({messages:e,input:t,isTyping:o=!1,currentSessionTitle:a,capabilities:n,fileUploads:i,isDragOver:r,enableFileUpload:s,onInputChange:c,addToolResult:m,onSendMessage:w,onKeyPress:f,onFileUpload:y,onRemoveFile:R,onDragOver:S,className:T,status:C="ready"}){let N=(0,qa.useRef)(null),H=(0,qa.useRef)(null),A=(0,qa.useRef)(null),[I,_]=(0,qa.useState)(!1),[$,se]=(0,qa.useState)({path:[],selectedItems:[],filters:{}});(0,qa.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,qa.useEffect)(()=>{I&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[I]);let J=()=>po($),W=()=>{let u=[];return n.forEach(U=>{U.actions&&U.actions.forEach(ve=>{u.push({label:ve.label,action:()=>X(ve.id,{path:[U],selectedItems:[],filters:{}})})}),U.children&&U.children.forEach(ve=>{ve.type==="list"&&ve.data&&u.push({label:`View ${ve.name}`,action:()=>_(!0)})})}),u.slice(0,5)},X=(u,U)=>{console.log("Capability action:",u,U);let ve=`Executing ${u} with context: ${JSON.stringify(U.path.map(Se=>Se.name))}`;_(!1)},le=po({path:[],selectedItems:[],filters:{}}),M=u=>{y(u.target.files),u.target.files&&(u.target.value="")},Ae=u=>{u.preventDefault(),S(!0)},d=u=>{u.preventDefault(),S(!1)},L=u=>{u.preventDefault(),S(!1),y(u.dataTransfer.files)},E=u=>{if(u===0)return"0 Bytes";let U=1024,ve=["Bytes","KB","MB","GB"],Se=Math.floor(Math.log(u)/Math.log(U));return parseFloat((u/Math.pow(U,Se)).toFixed(2))+" "+ve[Se]},G=u=>u.startsWith("image/")?(0,Lo.jsx)(Wa.Image,{className:"Lo-4 w-4"}):u.startsWith("text/")?(0,Lo.jsx)(Wa.FileText,{className:"Lo-4 w-4"}):(0,Lo.jsx)(Wa.File,{className:"Lo-4 w-4"}),Z={messages:e,currentSessionTitle:a,capabilities:n,currentCapabilityContext:$,contextualActions:le,getQuickSuggestions:W().map(u=>u.label)},be=()=>{navigator.clipboard.writeText(JSON.stringify(Z,null,2)),alert("Debug info copied to clipboard")};return(0,Lo.jsxs)("div",{className:`Lo-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,Lo.jsxs)(Ce,{ref:H,className:"flex-1 Lo-4 bg-background border-0",onDragOver:Ae,onDragLeave:d,onDrop:L,children:[(0,Lo.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Lo.jsx)(lt.animate,{children:e.map(u=>(0,Lo.jsx)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Lo.jsx)(Ha,{from:u.role,children:(0,Lo.jsx)(ja,{variant:"flat",children:Ua({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),I&&(0,Lo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Lo.jsx)(et,{className:"Lo-8 w-8",children:(0,Lo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Lo.jsx)(Wa.Bot,{className:"Lo-4 w-4"})})}),(0,Lo.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Lo.jsx)(ga,{capabilities:n,isOpen:I,onToggle:()=>_(!I),onActionSelect:X,className:"w-full"})})]}),o&&(0,Lo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Lo.jsx)(et,{className:"Lo-8 w-8",children:(0,Lo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Lo.jsx)(Wa.Bot,{className:"Lo-4 w-4"})})}),(0,Lo.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Lo.jsxs)("div",{className:"flex space-x-1",children:[(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Lo.jsx)("div",{ref:N})]}),i.length>0&&(0,Lo.jsx)("div",{className:"Lo-4 border-t bg-muted/10",children:(0,Lo.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,Lo.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Lo-2 border",children:[G(u.file.type),(0,Lo.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Lo.jsx)("span",{className:"text-xs text-muted-foreground",children:E(u.file.size)}),(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"Lo-6 w-6 Lo-0",children:(0,Lo.jsx)(Wa.X,{className:"Lo-4 w-4"})})]},u.id))})}),(0,Lo.jsxs)("div",{className:"border rounded-2xl Lo-4 bg-muted/20",children:[(0,Lo.jsxs)("div",{className:"flex gap-3",children:[(0,Lo.jsx)(gt,{value:t,onChange:u=>c(u.target.value),onKeyPress:f,placeholder:"How can I help you today?",className:"flex-1 rounded-2xl bg-background shadow-sm",disabled:o}),s&&(0,Lo.jsx)(D,{variant:"outline",size:"icon",onClick:()=>A.current?.click(),className:"rounded-2xl Lo-10 w-10 shadow-sm",children:(0,Lo.jsx)(Wa.Paperclip,{className:"Lo-4 w-4"})}),(0,Lo.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl Lo-10 w-10 shadow-sm",children:(0,Lo.jsx)(Wa.Send,{className:"Lo-4 w-4"})})]}),(0,Lo.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Lo.jsxs)(D,{onClick:()=>_(!I),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Lo.jsx)(Wa.Menu,{className:"Lo-3 w-3 mr-1"}),I?"Hide":"Show"," Capabilities"]}),(0,Lo.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,Lo.jsx)(D,{variant:"default",size:"sm",className:"rounded-full text-xs bg-accent hover:bg-accent/80",onClick:()=>X(u.id,$),children:u.label},`context-${u.id}`)),J().length===0&&W().map((u,U)=>(0,Lo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,Lo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,Lo.jsx)("input",{ref:A,type:"file",multiple:!0,onChange:M,className:"hidden"})]})]})}function Ga({aiConfig:e,useCustomChat:t,enableAI:o=!0,messages:a=[],businessUnits:n=[],capabilities:i=[],sidebarItems:r=[],notifications:s=[],sessions:c=[],onNewChat:m,onSessionSelect:w,onSessionDelete:f,onSessionEdit:y=()=>{},onBusinessUnitChange:R=()=>{},onNotificationRemove:S=()=>{},onRemoveAll:T=()=>{},onActionClick:C=()=>{},onSearch:N=L=>console.log("Search query:",L),initialTeam:H="design",currentSession:A=null,showCapabilities:I=!0,title:_="Digital Colleagues",enableFileUpload:$=!0,maxFileSize:se=10,allowedFileTypes:J=["image/*","text/*","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],logo:W="/headerlogo.png",appName:X="Nuvia",tagline:le="AI-Powered Workspace",actionIcon:M=(0,Lo.jsx)(Wa.Users,{className:"mr-2 Lo-4 w-4"}),actionText:Ae="Collaborate",sidebarInitiallyClosed:d=!1}){let L={...e,onError:F=>{G?.setMessages(ce=>[...ce,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:F.message}]}]),console.error("Error in CopilotInterface:",F)}},E=(0,Va.useChat)(L||{}),G=o?t||E:null,[Z,be]=(0,qa.useState)(""),[u,U]=(0,qa.useState)(!1),ve=G?.messages||a,Se=Z,Ka=G?.status==="submitted"||u,_a=G?.addToolResult?(F,ce,ee)=>{G.addToolResult({tool:ce,toolCallId:F,output:ee}),console.log("Tool result added:",{toolCallId:F,tool:ce,output:ee}),G.sendMessage()}:()=>{console.log("addToolResult not available")},dt=n||[],Ja={id:"default",name:"Default Team",description:"Default team when no business units are available",icon:"\u{1F3E2}",color:"bg-gray-500",accentColor:"bg-gray-600"},[Xa,Qa]=(0,qa.useState)(()=>dt.length===0?Ja:dt.find(F=>F.id===H)||dt[0]),[pt,xt]=(0,qa.useState)([]),[Ya,Za]=(0,qa.useState)(!1),ei=F=>{if(!F||!$)return;let ce=[];Array.from(F).forEach(ee=>{if(ee.size>se*1024*1024){alert(`File ${ee.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>ee.type.match(wt))){alert(`File type ${ee.type} is not allowed.`);return}let Co={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ee,status:"pending",progress:0};if(ee.type.startsWith("image/")){let wt=new FileReader;wt.onload=ri=>{xt(ni=>ni.map($t=>$t.id===Co.id?{...$t,preview:ri.target?.result}:$t))},wt.readAsDataURL(ee)}ce.push(Co)}),xt(ee=>[...ee,...ce])},ti=F=>{xt(ce=>ce.filter(ee=>ee.id!==F))},wo=()=>{if(!(!Se.trim()&&pt.length===0)){if(G){let F=pt.length>0?oi(pt.map(ce=>ce.file)):void 0;G.sendMessage({text:Se,files:F},{body:{timestamp:Date.now()}}),be("")}else console.log("Message to send:",Se),console.log("Files to upload:",pt),be(""),U(!0),setTimeout(()=>{U(!1)},1500);xt([])}},oi=F=>{let ce=new DataTransfer;return F.forEach(ee=>ce.items.add(ee)),ce.files},ai=F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),wo())},ii=F=>{be(F)};return(0,Lo.jsx)(da,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:Xa,onBusinessUnitChange:F=>{F&&(Qa(F),R?.(F))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:M,actionText:Ae,onNotificationRemove:S,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,Lo.jsx)(Gt.AnimatePresence,{mode:"wait",children:(0,Lo.jsx)(Gt.motion.div,{className:"flex-1 Lo-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,Lo.jsxs)("div",{className:"Lo-full flex",children:[(0,Lo.jsx)("div",{className:"w-80 flex-shrink-0 Lo-full Lo-2",children:(0,Lo.jsx)(pa,{sessions:c||[],currentSession:A,teams:dt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,Lo.jsx)("div",{className:"flex-1 Lo-full Lo-2",children:(0,Lo.jsx)(Oa,{messages:ve||[],input:Se,isTyping:Ka,currentSessionTitle:A?.title,capabilities:i||[],onInputChange:ii,addToolResult:_a,onSendMessage:wo,onKeyPress:ai,fileUploads:pt,isDragOver:Ya,enableFileUpload:$,onFileUpload:ei,onRemoveFile:ti,onDragOver:Za})})]})},"chat-interface")})})}var $a=[{id:"1",role:"user",parts:[{type:"text",text:"Can you write me a comprehensive analysis of the current state of artificial intelligence and machine learning technologies, including their applications, limitations, and future prospects?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:`Here's a comprehensive analysis of the current state of AI and ML technologies:
|
|
21
|
+
`,children:"Cancel"})]})]}):null};var ya=({toolPart:e,index:t,addToolResult:o})=>{let[a,n]=go.default.useState(!0),[i,r]=go.default.useState(null),s=()=>{o(e.toolCallId,e.type,"Approved"),n(!1),r("approve")},c=()=>{o(e.toolCallId,e.type,"Denied"),n(!1),r("deny")};switch(e.state){case"input-available":return(0,Lo.jsxs)("div",{className:"mb-2",children:[(0,Lo.jsx)(ha,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,Lo.jsxs)(Lo.Fragment,{children:[i==="approve"&&(0,Lo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Lo.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200",children:[(0,Lo.jsx)("svg",{className:"Lo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Lo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,Lo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Lo.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-red-100 text-red-800 text-sm font-medium border border-red-200",children:[(0,Lo.jsx)("svg",{className:"Lo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Lo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var fo=require("@radix-ui/react-use-controllable-state");var nt=V(require("@radix-ui/react-collapsible")),zt=nt.Root,Ut=nt.CollapsibleTrigger,Ft=nt.CollapsibleContent;var wa=require("streamdown"),yt=(0,qa.memo)(({className:e,...t})=>(0,Lo.jsx)(wa.Streamdown,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);yt.displayName="Response";var Na=(0,qa.createContext)(null),lr=()=>{let e=(0,qa.useContext)(Na);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},cr=1e3,dr=1e3,bo=(0,qa.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:a=!0,onOpenChange:n,duration:i,children:r,...s})=>{let[c,m]=(0,fo.useControllableState)({prop:o,defaultProp:a,onChange:n}),[w,f]=(0,fo.useControllableState)({prop:i,defaultProp:0}),[y,R]=(0,qa.useState)(!1),[S,T]=(0,qa.useState)(null);(0,qa.useEffect)(()=>{t?S===null&&T(Date.now()):S!==null&&(f(Math.ceil((Date.now()-S)/dr)),T(null))},[t,S,f]),(0,qa.useEffect)(()=>{if(a&&!t&&c&&!y){let N=setTimeout(()=>{m(!1),R(!0)},cr);return()=>clearTimeout(N)}},[t,c,a,m,y]);let C=N=>{m(N)};return(0,Lo.jsx)(Na.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,Lo.jsx)(zt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),pr=(e,t)=>e||t===0?(0,Lo.jsx)("Lo",{children:"Thinking..."}):t===void 0?(0,Lo.jsx)("Lo",{children:"Thought for a few seconds"}):(0,Lo.jsxs)("Lo",{children:["Thought for ",t," seconds"]}),vo=(0,qa.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=lr();return(0,Lo.jsx)(Ut,{className:l("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,Lo.jsxs)(Lo.Fragment,{children:[(0,Lo.jsx)(Wa.BrainIcon,{className:"size-4"}),pr(a,i),(0,Lo.jsx)(Wa.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),ho=(0,qa.memo)(({className:e,children:t,...o})=>(0,Lo.jsx)(Ft,{className:l("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...o,children:(0,Lo.jsx)(yt,{className:"grid gap-2",children:t})}));bo.displayName="Reasoning";vo.displayName="ReasoningTrigger";ho.displayName="ReasoningContent";var yo=require("react-syntax-highlighter"),Ot=require("react-syntax-highlighter/dist/esm/styles/prism"),mr=(0,qa.createContext)({code:""}),Vt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,Lo.jsx)(mr.Provider,{value:{code:e},children:(0,Lo.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,Lo.jsxs)("div",{className:"relative",children:[(0,Lo.jsx)(yo.Prism,{className:"overflow-hidden dark:hidden",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:o,style:Ot.oneLight,children:e}),(0,Lo.jsx)(yo.Prism,{className:"hidden overflow-hidden dark:block",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:o,style:Ot.oneDark,children:e}),n&&(0,Lo.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Pa=({className:e,...t})=>(0,Lo.jsx)(zt,{className:l("not-prose mb-4 w-full",e),...t}),ur=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Lo.jsxs)(ae,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Lo.jsx)(Wa.CircleIcon,{className:"size-4"}),"input-available":(0,Lo.jsx)(Wa.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Lo.jsx)(Wa.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Lo.jsx)(Wa.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Ta=({className:e,type:t,state:o,...a})=>(0,Lo.jsxs)(Ut,{className:l("flex w-full items-center justify-between gap-4 Lo-3 pl-0 w-2xl",e),...a,children:[(0,Lo.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Lo.jsx)(Wa.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Lo.jsx)("span",{className:"font-medium text-sm",children:t}),ur(o)]}),(0,Lo.jsx)(Wa.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Da=({className:e,...t})=>(0,Lo.jsx)(Ft,{className:l("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),Ra=({className:e,input:t,...o})=>(0,Lo.jsxs)("div",{className:l("space-y-2 overflow-hidden Lo-4",e),...o,children:[(0,Lo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Lo.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Lo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"})})]}),Aa=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,Lo.jsx)("div",{children:t});return typeof t=="object"?n=(0,Lo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,Lo.jsx)(Vt,{code:t,language:"json"})),(0,Lo.jsxs)("div",{className:l("space-y-2 Lo-4",e),...a,children:[(0,Lo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Lo.jsxs)("div",{className:l("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[o&&(0,Lo.jsx)("div",{children:o}),n]})]})};var Ma=require("date-fns");function Sa({taskId:e,polling:t=!0,system:o="payload"}){let[a,n]=(0,qa.useState)(null),[i,r]=(0,qa.useState)(!1),[s,c]=(0,qa.useState)(null),m=async(f=!0)=>{if(e){f&&r(!0);try{let y=await fetch(`/api/tasks/${e}`);if(!y.ok)throw new Error(`Failed to fetch task: ${y.statusText}`);let R=await y.json();n(R)}catch(y){console.error("Error fetching task:",y),c(y instanceof Error?y:new Error("Unknown error occurred"))}finally{f&&r(!1)}}},w=()=>m(!1);return(0,qa.useEffect)(()=>{e&&m(!0);let f=null;return e&&t&&(f=setInterval(w,5e3)),()=>{f&&clearInterval(f)}},[e,t]),{task:a,loading:i,error:s}}var gr=e=>{switch(e){case"backlog":return"bg-gray-200 text-gray-800";case"todo":return"bg-blue-200 text-blue-800";case"inProgress":return"bg-yellow-200 text-yellow-800";case"done":return"bg-green-200 text-green-800";case"cancelled":return"bg-red-200 text-red-800";default:return"bg-gray-200 text-gray-800"}},fr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Ba({data:e}){let{id:t,system:o,fetchLatest:a,taskData:n,error:i}=e||{};if(!t)return null;let r=null,s=!0,c=i,m=a!==void 0?a:!0;if(r=n||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:a,system:o,fetchLatest:m,taskData:r,error:c}),m){let{task:R,loading:S,error:T}=Sa({taskId:t,system:o});r=R,s=S,c=T}else s=!1;let w=gr(r?.status||"todo"),f=fr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let R=new Date(r?.dateLogged||"");isNaN(R.getTime())||(y=(0,Ma.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Lo.jsxs)(ge,{className:l("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Lo.jsxs)(Le,{className:"pb-2",children:[(0,Lo.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Lo.jsx)(Ee,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,Lo.jsx)(ae,{className:`${w}`,children:f})]}),r?.project&&(0,Lo.jsxs)(co,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,Lo.jsx)(Pe,{className:"pb-2",children:s?(0,Lo.jsx)("div",{className:"animate-pulse Lo-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Lo.jsx)("Lo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Lo.jsx)("Lo",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,Lo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Lo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Lo.jsx)(Wa.Clock,{className:"Lo-3 w-3 mr-1"}),(0,Lo.jsxs)("span",{children:["Created ",y]}),(0,Lo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Lo.jsxs)("span",{children:["Task #",t]})]})})]})}function za({artefact:e,taskId:t,taskData:o,loading:a=!1,error:n=null}){let i=o||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},r=i.dateLogged;try{let s=new Date(i.dateLogged);isNaN(s.getTime())||(r=(0,Ma.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,Lo.jsxs)(ge,{className:"w-full max-w-md shadow-md",children:[(0,Lo.jsx)(Le,{className:"pb-2",children:(0,Lo.jsx)("div",{className:"flex justify-between items-start",children:(0,Lo.jsx)(Ee,{className:"text-lg font-semibold",children:a?"Loading...":i.name})})}),(0,Lo.jsx)(Pe,{className:"pb-2",children:a?(0,Lo.jsx)("div",{className:"animate-pulse Lo-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,Lo.jsx)("Lo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Lo.jsx)("Lo",{className:"text-sm text-foreground",children:e})}),(0,Lo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Lo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Lo.jsx)(Wa.Clock,{className:"Lo-3 w-3 mr-1"}),(0,Lo.jsxs)("span",{children:["Created ",r]}),(0,Lo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Lo.jsxs)("span",{children:["Task #",i.id]})]})})]})}var br=e=>e.startsWith("image/")?(0,Lo.jsx)(Wa.Image,{className:"Lo-4 w-4"}):e.startsWith("text/")?(0,Lo.jsx)(Wa.FileText,{className:"Lo-4 w-4"}):(0,Lo.jsx)(Wa.File,{className:"Lo-4 w-4"}),Ua=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,Lo.jsx)(yt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,Lo.jsx)("div",{className:"mb-2 Lo-2 bg-background/50 rounded-lg",children:(0,Lo.jsxs)("div",{className:"flex items-center gap-2",children:[br(r.mediaType||"application/octet-stream"),(0,Lo.jsx)("div",{className:"flex-1 min-w-0",children:(0,Lo.jsx)("Lo",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"Lo-8 w-8 Lo-0",children:(0,Lo.jsx)(Wa.Download,{className:"Lo-4 w-4"})})]})},i)}if(n.type.startsWith("tool-")){let r=n,s=n.type.replace("tool-","");if(s==="task")switch(r.state){case"input-available":return(0,Lo.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(Ba,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return console.log("Rendering PartApprovalTool with toolPart:",r),(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(ya,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,Lo.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(za,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Lo.jsxs)(Pe,{children:[r.state==="input-available"&&(0,Lo.jsxs)("Lo",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,Lo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,Lo.jsxs)("Lo",{className:"text-sm text-red-500",children:["Error: ",r.errorText]})]})]})},i)}if(n.type.startsWith("data-")){let r=n,s=n.type.replace("data-","");return s==="reference"?(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(ge,{className:"w-full",children:(0,Lo.jsx)(Pe,{className:"Lo-4",children:(0,Lo.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,Lo.jsxs)("div",{className:"flex items-center gap-2 Lo-2 rounded-md bg-muted/50",children:[(0,Lo.jsx)(ae,{variant:"outline",children:c.type||"link"}),(0,Lo.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Lo.jsx)("Lo",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Lo.jsx)("Lo",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"Lo-8 w-8 Lo-0",children:(0,Lo.jsx)(Wa.ExternalLink,{className:"Lo-4 w-4"})})]},m))})})})},i):s==="menu"?(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:r.data?.title})}),(0,Lo.jsx)(Pe,{children:(0,Lo.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,Lo.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Lo.jsxs)("div",{className:"text-left",children:[(0,Lo.jsx)("Lo",{className:"font-medium",children:c.label}),c.description&&(0,Lo.jsx)("Lo",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Lo.jsx)(Pe,{children:(0,Lo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}if(n.type==="reasoning")return(0,Lo.jsxs)(bo,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.at(-1)?.id,children:[(0,Lo.jsx)(vo,{}),(0,Lo.jsx)(ho,{children:n.text})]},`${i}`);if(n.type==="dynamic-tool")return(0,Lo.jsxs)(Pa,{defaultOpen:n.state!=="output-available",children:[(0,Lo.jsx)(Ta,{type:`tool-${n.toolName}`,state:n.state}),(0,Lo.jsxs)(Da,{children:[(0,Lo.jsx)(Ra,{input:n.input}),(0,Lo.jsx)(Aa,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`)});var Ha=({className:e,from:t,...o})=>(0,Lo.jsx)("div",{className:l("group flex w-full items-end justify-end gap-2 py-4",t==="user"?"is-user":"is-assistant flex-row-reverse justify-end",e),...o}),vr=(0,Bo.cva)("is-user:dark flex flex-col gap-2 overflow-hidden rounded-lg text-sm",{variants:{variant:{contained:["max-w-[80%] px-4 py-3","group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground","group-[.is-assistant]:bg-secondary group-[.is-assistant]:text-foreground"],flat:["group-[.is-user]:max-w-[80%] group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground"]}},defaultVariants:{variant:"contained"}}),ja=({children:e,className:t,variant:o,...a})=>(0,Lo.jsx)("div",{className:l(vr({variant:o,className:t})),...a,children:e});function Oa({messages:e,input:t,isTyping:o=!1,currentSessionTitle:a,capabilities:n,fileUploads:i,isDragOver:r,enableFileUpload:s,onInputChange:c,addToolResult:m,onSendMessage:w,onKeyPress:f,onFileUpload:y,onRemoveFile:R,onDragOver:S,className:T,status:C="ready"}){let N=(0,qa.useRef)(null),H=(0,qa.useRef)(null),A=(0,qa.useRef)(null),[I,_]=(0,qa.useState)(!1),[$,se]=(0,qa.useState)({path:[],selectedItems:[],filters:{}});(0,qa.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,qa.useEffect)(()=>{I&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[I]);let J=()=>po($),W=()=>{let u=[];return n.forEach(U=>{U.actions&&U.actions.forEach(ve=>{u.push({label:ve.label,action:()=>X(ve.id,{path:[U],selectedItems:[],filters:{}})})}),U.children&&U.children.forEach(ve=>{ve.type==="list"&&ve.data&&u.push({label:`View ${ve.name}`,action:()=>_(!0)})})}),u.slice(0,5)},X=(u,U)=>{console.log("Capability action:",u,U);let ve=`Executing ${u} with context: ${JSON.stringify(U.path.map(Se=>Se.name))}`;_(!1)},le=po({path:[],selectedItems:[],filters:{}}),M=u=>{y(u.target.files),u.target.files&&(u.target.value="")},Ae=u=>{u.preventDefault(),S(!0)},d=u=>{u.preventDefault(),S(!1)},L=u=>{u.preventDefault(),S(!1),y(u.dataTransfer.files)},E=u=>{if(u===0)return"0 Bytes";let U=1024,ve=["Bytes","KB","MB","GB"],Se=Math.floor(Math.log(u)/Math.log(U));return parseFloat((u/Math.pow(U,Se)).toFixed(2))+" "+ve[Se]},G=u=>u.startsWith("image/")?(0,Lo.jsx)(Wa.Image,{className:"Lo-4 w-4"}):u.startsWith("text/")?(0,Lo.jsx)(Wa.FileText,{className:"Lo-4 w-4"}):(0,Lo.jsx)(Wa.File,{className:"Lo-4 w-4"}),Z={messages:e,currentSessionTitle:a,capabilities:n,currentCapabilityContext:$,contextualActions:le,getQuickSuggestions:W().map(u=>u.label)},be=()=>{navigator.clipboard.writeText(JSON.stringify(Z,null,2)),alert("Debug info copied to clipboard")};return(0,Lo.jsxs)("div",{className:`Lo-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,Lo.jsxs)(Ce,{ref:H,className:"flex-1 Lo-4 bg-background border-0",onDragOver:Ae,onDragLeave:d,onDrop:L,children:[(0,Lo.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Lo.jsx)(lt.animate,{children:e.map(u=>(0,Lo.jsx)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Lo.jsx)(Ha,{from:u.role,children:(0,Lo.jsx)(ja,{variant:"flat",children:Ua({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),I&&(0,Lo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Lo.jsx)(et,{className:"Lo-8 w-8",children:(0,Lo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Lo.jsx)(Wa.Bot,{className:"Lo-4 w-4"})})}),(0,Lo.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Lo.jsx)(ga,{capabilities:n,isOpen:I,onToggle:()=>_(!I),onActionSelect:X,className:"w-full"})})]}),o&&(0,Lo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Lo.jsx)(et,{className:"Lo-8 w-8",children:(0,Lo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Lo.jsx)(Wa.Bot,{className:"Lo-4 w-4"})})}),(0,Lo.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Lo.jsxs)("div",{className:"flex space-x-1",children:[(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Lo.jsx)("div",{ref:N})]}),i.length>0&&(0,Lo.jsx)("div",{className:"Lo-4 border-t bg-muted/10",children:(0,Lo.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,Lo.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Lo-2 border",children:[G(u.file.type),(0,Lo.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Lo.jsx)("span",{className:"text-xs text-muted-foreground",children:E(u.file.size)}),(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"Lo-6 w-6 Lo-0",children:(0,Lo.jsx)(Wa.X,{className:"Lo-4 w-4"})})]},u.id))})}),(0,Lo.jsxs)("div",{className:"border rounded-2xl Lo-4 bg-muted/20",children:[(0,Lo.jsxs)("div",{className:"flex gap-3",children:[(0,Lo.jsx)(gt,{value:t,onChange:u=>c(u.target.value),onKeyPress:f,placeholder:"How can I help you today?",className:"flex-1 rounded-2xl bg-background shadow-sm",disabled:o}),s&&(0,Lo.jsx)(D,{variant:"outline",size:"icon",onClick:()=>A.current?.click(),className:"rounded-2xl Lo-10 w-10 shadow-sm",children:(0,Lo.jsx)(Wa.Paperclip,{className:"Lo-4 w-4"})}),(0,Lo.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl Lo-10 w-10 shadow-sm",children:(0,Lo.jsx)(Wa.Send,{className:"Lo-4 w-4"})})]}),(0,Lo.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Lo.jsxs)(D,{onClick:()=>_(!I),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Lo.jsx)(Wa.Menu,{className:"Lo-3 w-3 mr-1"}),I?"Hide":"Show"," Capabilities"]}),(0,Lo.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,Lo.jsx)(D,{variant:"default",size:"sm",className:"rounded-full text-xs bg-accent hover:bg-accent/80",onClick:()=>X(u.id,$),children:u.label},`context-${u.id}`)),J().length===0&&W().map((u,U)=>(0,Lo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,Lo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,Lo.jsx)("input",{ref:A,type:"file",multiple:!0,onChange:M,className:"hidden"})]})]})}function Ga({aiConfig:e,useCustomChat:t,enableAI:o=!0,messages:a=[],businessUnits:n=[],capabilities:i=[],sidebarItems:r=[],notifications:s=[],sessions:c=[],onNewChat:m,onSessionSelect:w,onSessionDelete:f,onSessionEdit:y=()=>{},onBusinessUnitChange:R=()=>{},onNotificationRemove:S=()=>{},onRemoveAll:T=()=>{},onActionClick:C=()=>{},onSearch:N=L=>console.log("Search query:",L),initialTeam:H="design",currentSession:A=null,showCapabilities:I=!0,title:_="Digital Colleagues",enableFileUpload:$=!0,maxFileSize:se=10,allowedFileTypes:J=["image/*","text/*","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],logo:W="/headerlogo.png",appName:X="Nuvia",tagline:le="AI-Powered Workspace",actionIcon:M=(0,Lo.jsx)(Wa.Users,{className:"mr-2 Lo-4 w-4"}),actionText:Ae="Collaborate",sidebarInitiallyClosed:d=!1}){let L={...e,onError:F=>{G?.setMessages(ce=>[...ce,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:F.message}]}]),console.error("Error in CopilotInterface:",F)}},E=(0,Va.useChat)(L||{}),G=o?t||E:null,[Z,be]=(0,qa.useState)(""),[u,U]=(0,qa.useState)(!1),ve=G?.messages||a,Se=Z,Ka=G?.status==="submitted"||u,_a=G?.addToolResult?(F,ce,ee)=>{G.addToolResult({tool:ce,toolCallId:F,output:ee}),console.log("Tool result added:",{toolCallId:F,tool:ce,output:ee}),G.sendMessage()}:()=>{console.log("addToolResult not available")},dt=n||[],Ja={id:"default",name:"Default Team",description:"Default team when no business units are available",icon:"\u{1F3E2}",color:"bg-gray-500",accentColor:"bg-gray-600"},[Xa,Qa]=(0,qa.useState)(()=>dt.length===0?Ja:dt.find(F=>F.id===H)||dt[0]),[pt,xt]=(0,qa.useState)([]),[Ya,Za]=(0,qa.useState)(!1),ei=F=>{if(!F||!$)return;let ce=[];Array.from(F).forEach(ee=>{if(ee.size>se*1024*1024){alert(`File ${ee.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>ee.type.match(wt))){alert(`File type ${ee.type} is not allowed.`);return}let Co={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ee,status:"pending",progress:0};if(ee.type.startsWith("image/")){let wt=new FileReader;wt.onload=ri=>{xt(ni=>ni.map($t=>$t.id===Co.id?{...$t,preview:ri.target?.result}:$t))},wt.readAsDataURL(ee)}ce.push(Co)}),xt(ee=>[...ee,...ce])},ti=F=>{xt(ce=>ce.filter(ee=>ee.id!==F))},wo=()=>{if(!(!Se.trim()&&pt.length===0)){if(G){let F=pt.length>0?oi(pt.map(ce=>ce.file)):void 0;G.sendMessage({text:Se,files:F},{body:{timestamp:Date.now()}}),be("")}else console.log("Message to send:",Se),console.log("Files to upload:",pt),be(""),U(!0),setTimeout(()=>{U(!1)},1500);xt([])}},oi=F=>{let ce=new DataTransfer;return F.forEach(ee=>ce.items.add(ee)),ce.files},ai=F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),wo())},ii=F=>{be(F)};return(0,Lo.jsx)(da,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:Xa,onBusinessUnitChange:F=>{F&&(Qa(F),R?.(F))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:M,actionText:Ae,onNotificationRemove:S,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,Lo.jsx)(Gt.AnimatePresence,{mode:"wait",children:(0,Lo.jsx)(Gt.motion.div,{className:"flex-1 Lo-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,Lo.jsxs)("div",{className:"Lo-full flex",children:[(0,Lo.jsx)("div",{className:"w-80 flex-shrink-0 Lo-full Lo-2",children:(0,Lo.jsx)(pa,{sessions:c||[],currentSession:A,teams:dt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,Lo.jsx)("div",{className:"flex-1 Lo-full Lo-2",children:(0,Lo.jsx)(Oa,{messages:ve||[],input:Se,isTyping:Ka,currentSessionTitle:A?.title,capabilities:i||[],onInputChange:ii,addToolResult:_a,onSendMessage:wo,onKeyPress:ai,fileUploads:pt,isDragOver:Ya,enableFileUpload:$,onFileUpload:ei,onRemoveFile:ti,onDragOver:Za})})]})},"chat-interface")})})}var $a=[{id:"1",role:"user",parts:[{type:"text",text:"Can you write me a comprehensive analysis of the current state of artificial intelligence and machine learning technologies, including their applications, limitations, and future prospects?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:`Here's a comprehensive analysis of the current state of AI and ML technologies:
|
|
22
22
|
|
|
23
23
|
**Current State of Artificial Intelligence and Machine Learning**
|
|
24
24
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-JSHD7QTU.mjs";import"../../chunk-CTTBF7F4.mjs";import"../../chunk-56X4PU43.mjs";import"../../chunk-WAVVCASZ.mjs";import"../../chunk-347B45ZS.mjs";import"../../chunk-WRZP5K5X.mjs";import"../../chunk-V5VE3EIY.mjs";import"../../chunk-6OCLRAHU.mjs";import"../../chunk-5Y6FKL5W.mjs";import"../../chunk-EW6KWAHS.mjs";import"../../chunk-7JDMW5R3.mjs";import"../../chunk-6OT5PQXV.mjs";import"../../chunk-YPZAYXNQ.mjs";import"../../chunk-7TSR2LQB.mjs";import"../../chunk-QM5FOQHG.mjs";import"../../chunk-UA2E23AS.mjs";import"../../chunk-2LINLX4S.mjs";import"../../chunk-RL6365DN.mjs";import"../../chunk-LTTO57ZK.mjs";import"../../chunk-4WA47ZQA.mjs";import"../../chunk-NPVUICIF.mjs";import"../../chunk-VDN4LQSS.mjs";import"../../chunk-FGEFYI5E.mjs";import"../../chunk-MU5WPW4N.mjs";import"../../chunk-AZKOVKSK.mjs";import{b as e}from"../../chunk-Q2DPE66H.mjs";import"../../chunk-INCYANPB.mjs";import"../../chunk-RLVKIMGU.mjs";import"../../chunk-OCPX4QPC.mjs";import"../../chunk-FT3AE7L2.mjs";import"../../chunk-3UMMMQEH.mjs";import"../../chunk-YNCJATT7.mjs";import"../../chunk-L5JPAKPM.mjs";import"../../chunk-KY7WQYN4.mjs";import"../../chunk-ZUA4KNIR.mjs";import"../../chunk-SOLZ4VQH.mjs";import"../../chunk-CSBGSBEU.mjs";import"../../chunk-YO3GQYRJ.mjs";import"../../chunk-EGEO3FNE.mjs";import"../../chunk-MDJREBVI.mjs";import"../../chunk-ZWHGOTSF.mjs";import"../../chunk-Q3G5UAAD.mjs";import"../../chunk-XGRRLABA.mjs";import"../../chunk-FLHDNCNY.mjs";import"../../chunk-YEKQJ4YC.mjs";import{useState as r}from"react";import{jsx as i}from"react/jsx-runtime";var n=[{id:"1",role:"user",parts:[{type:"text",text:"Can you write me a comprehensive analysis of the current state of artificial intelligence and machine learning technologies, including their applications, limitations, and future prospects?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:`Here's a comprehensive analysis of the current state of AI and ML technologies:
|
|
2
2
|
|
|
3
3
|
**Current State of Artificial Intelligence and Machine Learning**
|
|
4
4
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
`,children:r?"Processing...":"Deny"}),(0,La.jsx)("button",{onClick:w,disabled:r,className:`
|
|
19
19
|
px-4 py-2 text-white border-none rounded text-sm
|
|
20
20
|
${r?"bg-gray-400 cursor-not-allowed":"bg-gray-500 hover:bg-gray-600 cursor-pointer"}
|
|
21
|
-
`,children:"Cancel"})]})]}):null};var wo=({toolPart:e,index:t,addToolResult:a})=>{let[o,n]=ba.default.useState(!0),[i,r]=ba.default.useState(null),s=()=>{a(e.input?.toolCallId,e.input?.tool,"Approved"),n(!1),r("approve")},d=()=>{a(e.input?.toolCallId,e.input?.tool,"Denied"),n(!1),r("deny")};switch(e.state){case"input-available":return(0,La.jsxs)("div",{className:"mb-2",children:[(0,La.jsx)(xo,{isOpen:o,onApprove:s,onDeny:d,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!o&&(0,La.jsxs)(La.Fragment,{children:[i==="approve"&&(0,La.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,La.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200",children:[(0,La.jsx)("svg",{className:"La-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,La.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,La.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,La.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-red-100 text-red-800 text-sm font-medium border border-red-200",children:[(0,La.jsx)("svg",{className:"La-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,La.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,La.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var ha=require("@radix-ui/react-use-controllable-state");var ct=j(require("@radix-ui/react-collapsible")),Ht=ct.Root,Ot=ct.CollapsibleTrigger,jt=ct.CollapsibleContent;var No=require("streamdown"),Nt=(0,tt.memo)(({className:e,...t})=>(0,La.jsx)(No.Streamdown,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);Nt.displayName="Response";var Po=(0,tt.createContext)(null),sr=()=>{let e=(0,tt.useContext)(Po);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},lr=1e3,dr=1e3,ya=(0,tt.memo)(({className:e,isStreaming:t=!1,open:a,defaultOpen:o=!0,onOpenChange:n,duration:i,children:r,...s})=>{let[d,m]=(0,ha.useControllableState)({prop:a,defaultProp:o,onChange:n}),[w,f]=(0,ha.useControllableState)({prop:i,defaultProp:0}),[y,D]=(0,tt.useState)(!1),[A,T]=(0,tt.useState)(null);(0,tt.useEffect)(()=>{t?A===null&&T(Date.now()):A!==null&&(f(Math.ceil((Date.now()-A)/dr)),T(null))},[t,A,f]),(0,tt.useEffect)(()=>{if(o&&!t&&d&&!y){let N=setTimeout(()=>{m(!1),D(!0)},lr);return()=>clearTimeout(N)}},[t,d,o,m,y]);let C=N=>{m(N)};return(0,La.jsx)(Po.Provider,{value:{isStreaming:t,isOpen:d,setIsOpen:m,duration:w},children:(0,La.jsx)(Ht,{className:l("not-prose mb-4",e),onOpenChange:C,open:d,...s,children:r})})}),cr=(e,t)=>e||t===0?(0,La.jsx)("La",{children:"Thinking..."}):t===void 0?(0,La.jsx)("La",{children:"Thought for a few seconds"}):(0,La.jsxs)("La",{children:["Thought for ",t," seconds"]}),xa=(0,tt.memo)(({className:e,children:t,...a})=>{let{isStreaming:o,isOpen:n,duration:i}=sr();return(0,La.jsx)(Ot,{className:l("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...a,children:t??(0,La.jsxs)(La.Fragment,{children:[(0,La.jsx)(Go.BrainIcon,{className:"size-4"}),cr(o,i),(0,La.jsx)(Go.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),wa=(0,tt.memo)(({className:e,children:t,...a})=>(0,La.jsx)(jt,{className:l("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...a,children:(0,La.jsx)(Nt,{className:"grid gap-2",children:t})}));ya.displayName="Reasoning";xa.displayName="ReasoningTrigger";wa.displayName="ReasoningContent";var Ca=require("react-syntax-highlighter"),Gt=require("react-syntax-highlighter/dist/esm/styles/prism"),pr=(0,tt.createContext)({code:""}),$t=({code:e,language:t,showLineNumbers:a=!1,className:o,children:n,...i})=>(0,La.jsx)(pr.Provider,{value:{code:e},children:(0,La.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",o),...i,children:(0,La.jsxs)("div",{className:"relative",children:[(0,La.jsx)(Ca.Prism,{className:"overflow-hidden dark:hidden",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:a,style:Gt.oneLight,children:e}),(0,La.jsx)(Ca.Prism,{className:"hidden overflow-hidden dark:block",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:a,style:Gt.oneDark,children:e}),n&&(0,La.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Ro=({className:e,...t})=>(0,La.jsx)(Ht,{className:l("not-prose mb-4 w-full",e),...t}),mr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,La.jsxs)(oe,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,La.jsx)(Go.CircleIcon,{className:"size-4"}),"input-available":(0,La.jsx)(Go.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,La.jsx)(Go.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,La.jsx)(Go.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Do=({className:e,type:t,state:a,...o})=>(0,La.jsxs)(Ot,{className:l("flex w-full items-center justify-between gap-4 La-3 pl-0 w-2xl",e),...o,children:[(0,La.jsxs)("div",{className:"flex items-center gap-2",children:[(0,La.jsx)(Go.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,La.jsx)("span",{className:"font-medium text-sm",children:t}),mr(a)]}),(0,La.jsx)(Go.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),So=({className:e,...t})=>(0,La.jsx)(jt,{className:l("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),Ao=({className:e,input:t,...a})=>(0,La.jsxs)("div",{className:l("space-y-2 overflow-hidden La-4",e),...a,children:[(0,La.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,La.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,La.jsx)($t,{code:JSON.stringify(t,null,2),language:"json"})})]}),Io=({className:e,output:t,errorText:a,...o})=>{if(!(t||a))return null;let n=(0,La.jsx)("div",{children:t});return typeof t=="object"?n=(0,La.jsx)($t,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,La.jsx)($t,{code:t,language:"json"})),(0,La.jsxs)("div",{className:l("space-y-2 La-4",e),...o,children:[(0,La.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:a?"Error":"Result"}),(0,La.jsxs)("div",{className:l("overflow-x-auto rounded-md text-xs [&_table]:w-full",a?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[a&&(0,La.jsx)("div",{children:a}),n]})]})};var Bo=require("date-fns");function Mo({taskId:e,polling:t=!0,system:a="payload"}){let[o,n]=(0,tt.useState)(null),[i,r]=(0,tt.useState)(!1),[s,d]=(0,tt.useState)(null),m=async(f=!0)=>{if(e){f&&r(!0);try{let y=await fetch(`/api/tasks/${e}`);if(!y.ok)throw new Error(`Failed to fetch task: ${y.statusText}`);let D=await y.json();n(D)}catch(y){console.error("Error fetching task:",y),d(y instanceof Error?y:new Error("Unknown error occurred"))}finally{f&&r(!1)}}},w=()=>m(!1);return(0,tt.useEffect)(()=>{e&&m(!0);let f=null;return e&&t&&(f=setInterval(w,5e3)),()=>{f&&clearInterval(f)}},[e,t]),{task:o,loading:i,error:s}}var ur=e=>{switch(e){case"backlog":return"bg-gray-200 text-gray-800";case"todo":return"bg-blue-200 text-blue-800";case"inProgress":return"bg-yellow-200 text-yellow-800";case"done":return"bg-green-200 text-green-800";case"cancelled":return"bg-red-200 text-red-800";default:return"bg-gray-200 text-gray-800"}},gr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Uo({data:e}){let{id:t,system:a,fetchLatest:o,taskData:n,error:i}=e||{};if(!t)return null;let r=null,s=!0,d=i,m=o!==void 0?o:!0;if(r=n||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:o,system:a,fetchLatest:m,taskData:r,error:d}),m){let{task:D,loading:A,error:T}=Mo({taskId:t,system:a});r=D,s=A,d=T}else s=!1;let w=ur(r?.status||"todo"),f=gr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let D=new Date(r?.dateLogged||"");isNaN(D.getTime())||(y=(0,Bo.formatDistanceToNow)(D,{addSuffix:!0}))}catch{}return(0,La.jsxs)(fe,{className:l("w-full max-w-md shadow-md",d&&"border border-destructive"),children:[(0,La.jsxs)(Ue,{className:"pb-2",children:[(0,La.jsxs)("div",{className:"flex justify-between items-start",children:[(0,La.jsx)(Le,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,La.jsx)(oe,{className:`${w}`,children:f})]}),r?.project&&(0,La.jsxs)(ua,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,La.jsx)(Te,{className:"pb-2",children:s?(0,La.jsx)("div",{className:"animate-pulse La-4 bg-gray-200 rounded w-3/4 mb-2"}):d?(0,La.jsx)("La",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,La.jsx)("La",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,La.jsx)(Ct,{className:"tt-2 flex items-center justify-between",children:(0,La.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,La.jsx)(Go.Clock,{className:"La-3 w-3 mr-1"}),(0,La.jsxs)("span",{children:["Created ",y]}),(0,La.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,La.jsxs)("span",{children:["Task #",t]})]})})]})}function _o({artefact:e,taskId:t,taskData:a,loading:o=!1,error:n=null}){let i=a||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},r=i.dateLogged;try{let s=new Date(i.dateLogged);isNaN(s.getTime())||(r=(0,Bo.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,La.jsxs)(fe,{className:"w-full max-w-md shadow-md",children:[(0,La.jsx)(Ue,{className:"pb-2",children:(0,La.jsx)("div",{className:"flex justify-between items-start",children:(0,La.jsx)(Le,{className:"text-lg font-semibold",children:o?"Loading...":i.name})})}),(0,La.jsx)(Te,{className:"pb-2",children:o?(0,La.jsx)("div",{className:"animate-pulse La-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,La.jsx)("La",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,La.jsx)("La",{className:"text-sm text-foreground",children:e})}),(0,La.jsx)(Ct,{className:"tt-2 flex items-center justify-between",children:(0,La.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,La.jsx)(Go.Clock,{className:"La-3 w-3 mr-1"}),(0,La.jsxs)("span",{children:["Created ",r]}),(0,La.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,La.jsxs)("span",{children:["Task #",i.id]})]})})]})}var fr=e=>e.startsWith("image/")?(0,La.jsx)(Go.Image,{className:"La-4 w-4"}):e.startsWith("text/")?(0,La.jsx)(Go.FileText,{className:"La-4 w-4"}):(0,La.jsx)(Go.File,{className:"La-4 w-4"}),Fo=({message:e,addToolResult:t,status:a,messages:o})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,La.jsx)(Nt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,La.jsx)("div",{className:"mb-2 La-2 bg-background/50 rounded-lg",children:(0,La.jsxs)("div",{className:"flex items-center gap-2",children:[fr(r.mediaType||"application/octet-stream"),(0,La.jsx)("div",{className:"flex-1 min-w-0",children:(0,La.jsx)("La",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,La.jsx)(R,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"La-8 w-8 La-0",children:(0,La.jsx)(Go.Download,{className:"La-4 w-4"})})]})},i)}if(n.type.startsWith("tool-")){let r=n,s=n.type.replace("tool-","");if(s==="task")switch(r.state){case"input-available":return(0,La.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(Uo,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,La.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(va,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(va,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return console.log("Rendering PartApprovalTool with toolPart:",r),(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(wo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,La.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(_o,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,La.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsxs)(fe,{className:"w-full max-w-md",children:[(0,La.jsx)(Ue,{children:(0,La.jsx)(Le,{className:"text-lg",children:s})}),(0,La.jsxs)(Te,{children:[r.state==="input-available"&&(0,La.jsxs)("La",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,La.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,La.jsxs)("La",{className:"text-sm text-red-500",children:["Error: ",r.errorText]})]})]})},i)}if(n.type.startsWith("data-")){let r=n,s=n.type.replace("data-","");return s==="reference"?(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(fe,{className:"w-full",children:(0,La.jsx)(Te,{className:"La-4",children:(0,La.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((d,m)=>(0,La.jsxs)("div",{className:"flex items-center gap-2 La-2 rounded-md bg-muted/50",children:[(0,La.jsx)(oe,{variant:"outline",children:d.type||"link"}),(0,La.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,La.jsx)("La",{className:"text-sm font-medium truncate",children:d.title}),d.description&&(0,La.jsx)("La",{className:"text-xs text-muted-foreground truncate",children:d.description})]}),d.url&&(0,La.jsx)(R,{variant:"ghost",size:"sm",onClick:()=>window.open(d.url,"_blank"),className:"La-8 w-8 La-0",children:(0,La.jsx)(Go.ExternalLink,{className:"La-4 w-4"})})]},m))})})})},i):s==="menu"?(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsxs)(fe,{className:"w-full",children:[(0,La.jsx)(Ue,{children:(0,La.jsx)(Le,{className:"text-lg",children:r.data?.title})}),(0,La.jsx)(Te,{children:(0,La.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((d,m)=>(0,La.jsx)(R,{variant:"outline",className:"w-full justify-start",onClick:d.action,children:(0,La.jsxs)("div",{className:"text-left",children:[(0,La.jsx)("La",{className:"font-medium",children:d.label}),d.description&&(0,La.jsx)("La",{className:"text-xs text-muted-foreground",children:d.description})]})},m))})})]})},i):(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsxs)(fe,{className:"w-full max-w-md",children:[(0,La.jsx)(Ue,{children:(0,La.jsx)(Le,{className:"text-lg",children:s})}),(0,La.jsx)(Te,{children:(0,La.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}if(n.type==="reasoning")return(0,La.jsxs)(ya,{className:"w-full",isStreaming:a==="streaming"&&i===e.parts.length-1&&e.id===o.at(-1)?.id,children:[(0,La.jsx)(xa,{}),(0,La.jsx)(wa,{children:n.text})]},`${i}`);if(n.type==="dynamic-tool")return(0,La.jsxs)(Ro,{defaultOpen:n.state!=="output-available",children:[(0,La.jsx)(Do,{type:`tool-${n.toolName}`,state:n.state}),(0,La.jsxs)(So,{children:[(0,La.jsx)(Ao,{input:n.input}),(0,La.jsx)(Io,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`)});var Oo=({className:e,from:t,...a})=>(0,La.jsx)("div",{className:l("group flex w-full items-end justify-end gap-2 py-4",t==="user"?"is-user":"is-assistant flex-row-reverse justify-end",e),...a}),vr=(0,Ua.cva)("is-user:dark flex flex-col gap-2 overflow-hidden rounded-lg text-sm",{variants:{variant:{contained:["max-w-[80%] px-4 py-3","group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground","group-[.is-assistant]:bg-secondary group-[.is-assistant]:text-foreground"],flat:["group-[.is-user]:max-w-[80%] group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground"]}},defaultVariants:{variant:"contained"}}),jo=({children:e,className:t,variant:a,...o})=>(0,La.jsx)("div",{className:l(vr({variant:a,className:t})),...o,children:e});function Wo({messages:e,input:t,isTyping:a=!1,currentSessionTitle:o,capabilities:n,fileUploads:i,isDragOver:r,enableFileUpload:s,onInputChange:d,addToolResult:m,onSendMessage:w,onKeyPress:f,onFileUpload:y,onRemoveFile:D,onDragOver:A,className:T,status:C="ready"}){let N=(0,tt.useRef)(null),F=(0,tt.useRef)(null),S=(0,tt.useRef)(null),[I,K]=(0,tt.useState)(!1),[G,se]=(0,tt.useState)({path:[],selectedItems:[],filters:{}});(0,tt.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,tt.useEffect)(()=>{I&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[I]);let J=()=>ga(G),W=()=>{let u=[];return n.forEach(z=>{z.actions&&z.actions.forEach(he=>{u.push({label:he.label,action:()=>Q(he.id,{path:[z],selectedItems:[],filters:{}})})}),z.children&&z.children.forEach(he=>{he.type==="list"&&he.data&&u.push({label:`View ${he.name}`,action:()=>K(!0)})})}),u.slice(0,5)},Q=(u,z)=>{console.log("Capability action:",u,z);let he=`Executing ${u} with context: ${JSON.stringify(z.path.map(Ie=>Ie.name))}`;K(!1)},le=ga({path:[],selectedItems:[],filters:{}}),M=u=>{y(u.target.files),u.target.files&&(u.target.value="")},Ae=u=>{u.preventDefault(),A(!0)},c=u=>{u.preventDefault(),A(!1)},B=u=>{u.preventDefault(),A(!1),y(u.dataTransfer.files)},U=u=>{if(u===0)return"0 Bytes";let z=1024,he=["Bytes","KB","MB","GB"],Ie=Math.floor(Math.log(u)/Math.log(z));return parseFloat((u/Math.pow(z,Ie)).toFixed(2))+" "+he[Ie]},V=u=>u.startsWith("image/")?(0,La.jsx)(Go.Image,{className:"La-4 w-4"}):u.startsWith("text/")?(0,La.jsx)(Go.FileText,{className:"La-4 w-4"}):(0,La.jsx)(Go.File,{className:"La-4 w-4"}),Z={messages:e,currentSessionTitle:o,capabilities:n,currentCapabilityContext:G,contextualActions:le,getQuickSuggestions:W().map(u=>u.label)},be=()=>{navigator.clipboard.writeText(JSON.stringify(Z,null,2)),alert("Debug info copied to clipboard")};return(0,La.jsxs)("div",{className:`La-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,La.jsxs)(Ne,{ref:F,className:"flex-1 La-4 bg-background border-0",onDragOver:Ae,onDragLeave:c,onDrop:B,children:[(0,La.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,La.jsx)(mt.animate,{children:e.map(u=>(0,La.jsx)(mt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,La.jsx)(Oo,{from:u.role,children:(0,La.jsx)(jo,{variant:"flat",children:Fo({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),I&&(0,La.jsxs)(mt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,La.jsx)(it,{className:"La-8 w-8",children:(0,La.jsx)(rt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,La.jsx)(Go.Bot,{className:"La-4 w-4"})})}),(0,La.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,La.jsx)(vo,{capabilities:n,isOpen:I,onToggle:()=>K(!I),onActionSelect:Q,className:"w-full"})})]}),a&&(0,La.jsxs)(mt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,La.jsx)(it,{className:"La-8 w-8",children:(0,La.jsx)(rt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,La.jsx)(Go.Bot,{className:"La-4 w-4"})})}),(0,La.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,La.jsxs)("div",{className:"flex space-x-1",children:[(0,La.jsx)("div",{className:"w-2 La-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,La.jsx)("div",{className:"w-2 La-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,La.jsx)("div",{className:"w-2 La-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,La.jsx)("div",{ref:N})]}),i.length>0&&(0,La.jsx)("div",{className:"La-4 border-t bg-muted/10",children:(0,La.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,La.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg La-2 border",children:[V(u.file.type),(0,La.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,La.jsx)("span",{className:"text-xs text-muted-foreground",children:U(u.file.size)}),(0,La.jsx)(R,{variant:"ghost",size:"sm",onClick:()=>D(u.id),className:"La-6 w-6 La-0",children:(0,La.jsx)(Go.La,{className:"La-4 w-4"})})]},u.id))})}),(0,La.jsxs)("div",{className:"border rounded-2xl La-4 bg-muted/20",children:[(0,La.jsxs)("div",{className:"flex gap-3",children:[(0,La.jsx)(ht,{value:t,onChange:u=>d(u.target.value),onKeyPress:f,placeholder:"How can I help you today?",className:"flex-1 rounded-2xl bg-background shadow-sm",disabled:a}),s&&(0,La.jsx)(R,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl La-10 w-10 shadow-sm",children:(0,La.jsx)(Go.Paperclip,{className:"La-4 w-4"})}),(0,La.jsx)(R,{onClick:w,disabled:!t.trim()&&i.length===0||a,size:"icon",className:"rounded-2xl La-10 w-10 shadow-sm",children:(0,La.jsx)(Go.Send,{className:"La-4 w-4"})})]}),(0,La.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,La.jsxs)(R,{onClick:()=>K(!I),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,La.jsx)(Go.Menu,{className:"La-3 w-3 mr-1"}),I?"Hide":"Show"," Capabilities"]}),(0,La.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,z)=>(0,La.jsx)(R,{variant:"default",size:"sm",className:"rounded-full text-xs bg-accent hover:bg-accent/80",onClick:()=>Q(u.id,G),children:u.label},`context-${u.id}`)),J().length===0&&W().map((u,z)=>(0,La.jsx)(R,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${z}`)),(0,La.jsx)(R,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,La.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:M,className:"hidden"})]})]})}function et({aiConfig:e,useCustomChat:t,enableAI:a=!0,messages:o=[],businessUnits:n=[],capabilities:i=[],sidebarItems:r=[],notifications:s=[],sessions:d=[],onNewChat:m,onSessionSelect:w,onSessionDelete:f,onSessionEdit:y=()=>{},onBusinessUnitChange:D=()=>{},onNotificationRemove:A=()=>{},onRemoveAll:T=()=>{},onActionClick:C=()=>{},onSearch:N=B=>console.log("Search query:",B),initialTeam:F="design",currentSession:S=null,showCapabilities:I=!0,title:K="Digital Colleagues",enableFileUpload:G=!0,maxFileSize:se=10,allowedFileTypes:J=["image/*","text/*","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],logo:W="/headerlogo.png",appName:Q="Nuvia",tagline:le="AI-Powered Workspace",actionIcon:M=(0,La.jsx)(Go.Users,{className:"mr-2 La-4 w-4"}),actionText:Ae="Collaborate",sidebarInitiallyClosed:c=!1}){let B={...e,onError:_=>{V?.setMessages(de=>[...de,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:_.message}]}]),console.error("Error in CopilotInterface:",_)}},U=(0,Vo.useChat)(B||{}),V=a?t||U:null,[Z,be]=(0,tt.useState)(""),[u,z]=(0,tt.useState)(!1),he=V?.messages||o,Ie=Z,$o=V?.status==="submitted"||u,qo=V?.addToolResult?(_,de,ee)=>{V.addToolResult({tool:de,toolCallId:_,output:ee}),console.log("Tool result added:",{toolCallId:_,tool:de,output:ee}),V.sendMessage()}:()=>{console.log("addToolResult not available")},gt=n||[],Ko={id:"default",name:"Default Team",description:"Default team when no business units are available",icon:"\u{1F3E2}",color:"bg-gray-500",accentColor:"bg-gray-600"},[Jo,Qo]=(0,tt.useState)(()=>gt.length===0?Ko:gt.find(_=>_.id===F)||gt[0]),[ft,kt]=(0,tt.useState)([]),[Xo,Yo]=(0,tt.useState)(!1),Zo=_=>{if(!_||!G)return;let de=[];Array.from(_).forEach(ee=>{if(ee.size>se*1024*1024){alert(`File ${ee.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(Pt=>ee.type.match(Pt))){alert(`File type ${ee.type} is not allowed.`);return}let ka={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ee,status:"pending",progress:0};if(ee.type.startsWith("image/")){let Pt=new FileReader;Pt.onload=ii=>{kt(ri=>ri.map(Jt=>Jt.id===ka.id?{...Jt,preview:ii.target?.result}:Jt))},Pt.readAsDataURL(ee)}de.push(ka)}),kt(ee=>[...ee,...de])},ei=_=>{kt(de=>de.filter(ee=>ee.id!==_))},Na=()=>{if(!(!Ie.trim()&&ft.length===0)){if(V){let _=ft.length>0?ti(ft.map(de=>de.file)):void 0;V.sendMessage({text:Ie,files:_},{body:{timestamp:Date.now()}}),be("")}else console.log("Message to send:",Ie),console.log("Files to upload:",ft),be(""),z(!0),setTimeout(()=>{z(!1)},1500);kt([])}},ti=_=>{let de=new DataTransfer;return _.forEach(ee=>de.items.add(ee)),de.files},ai=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Na())},oi=_=>{be(_)};return(0,La.jsx)(uo,{sidebarItems:r||[],title:K,notifications:s||[],businessUnits:gt,currentBusinessUnit:Jo,onBusinessUnitChange:_=>{_&&(Qo(_),D?.(_))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:M,actionText:Ae,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:Q,tagline:le,sidebarInitiallyClosed:c,children:(0,La.jsx)(Kt.AnimatePresence,{mode:"wait",children:(0,La.jsx)(Kt.motion.div,{className:"flex-1 La-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,La.jsxs)("div",{className:"La-full flex",children:[(0,La.jsx)("div",{className:"w-80 flex-shrink-0 La-full La-2",children:(0,La.jsx)(go,{sessions:d||[],currentSession:S,teams:gt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,La.jsx)("div",{className:"flex-1 La-full La-2",children:(0,La.jsx)(Wo,{messages:he||[],input:Ie,isTyping:$o,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:oi,addToolResult:qo,onSendMessage:Na,onKeyPress:ai,fileUploads:ft,isDragOver:Xo,enableFileUpload:G,onFileUpload:Zo,onRemoveFile:ei,onDragOver:Yo})})]})},"chat-interface")})})}function br(){let[e,t]=(0,tt.useState)([{id:"1",role:"user",parts:[{type:"text",text:"Can you help La analyze my sales data?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:`I'll help you analyze your sales data. Let La fetch the latest information.
|
|
21
|
+
`,children:"Cancel"})]})]}):null};var wo=({toolPart:e,index:t,addToolResult:a})=>{let[o,n]=ba.default.useState(!0),[i,r]=ba.default.useState(null),s=()=>{a(e.toolCallId,e.type,"Approved"),n(!1),r("approve")},d=()=>{a(e.toolCallId,e.type,"Denied"),n(!1),r("deny")};switch(e.state){case"input-available":return(0,La.jsxs)("div",{className:"mb-2",children:[(0,La.jsx)(xo,{isOpen:o,onApprove:s,onDeny:d,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!o&&(0,La.jsxs)(La.Fragment,{children:[i==="approve"&&(0,La.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,La.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200",children:[(0,La.jsx)("svg",{className:"La-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,La.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,La.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,La.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-red-100 text-red-800 text-sm font-medium border border-red-200",children:[(0,La.jsx)("svg",{className:"La-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,La.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,La.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var ha=require("@radix-ui/react-use-controllable-state");var ct=j(require("@radix-ui/react-collapsible")),Ht=ct.Root,Ot=ct.CollapsibleTrigger,jt=ct.CollapsibleContent;var No=require("streamdown"),Nt=(0,tt.memo)(({className:e,...t})=>(0,La.jsx)(No.Streamdown,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);Nt.displayName="Response";var Po=(0,tt.createContext)(null),sr=()=>{let e=(0,tt.useContext)(Po);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},lr=1e3,dr=1e3,ya=(0,tt.memo)(({className:e,isStreaming:t=!1,open:a,defaultOpen:o=!0,onOpenChange:n,duration:i,children:r,...s})=>{let[d,m]=(0,ha.useControllableState)({prop:a,defaultProp:o,onChange:n}),[w,f]=(0,ha.useControllableState)({prop:i,defaultProp:0}),[y,D]=(0,tt.useState)(!1),[A,T]=(0,tt.useState)(null);(0,tt.useEffect)(()=>{t?A===null&&T(Date.now()):A!==null&&(f(Math.ceil((Date.now()-A)/dr)),T(null))},[t,A,f]),(0,tt.useEffect)(()=>{if(o&&!t&&d&&!y){let N=setTimeout(()=>{m(!1),D(!0)},lr);return()=>clearTimeout(N)}},[t,d,o,m,y]);let C=N=>{m(N)};return(0,La.jsx)(Po.Provider,{value:{isStreaming:t,isOpen:d,setIsOpen:m,duration:w},children:(0,La.jsx)(Ht,{className:l("not-prose mb-4",e),onOpenChange:C,open:d,...s,children:r})})}),cr=(e,t)=>e||t===0?(0,La.jsx)("La",{children:"Thinking..."}):t===void 0?(0,La.jsx)("La",{children:"Thought for a few seconds"}):(0,La.jsxs)("La",{children:["Thought for ",t," seconds"]}),xa=(0,tt.memo)(({className:e,children:t,...a})=>{let{isStreaming:o,isOpen:n,duration:i}=sr();return(0,La.jsx)(Ot,{className:l("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...a,children:t??(0,La.jsxs)(La.Fragment,{children:[(0,La.jsx)(Go.BrainIcon,{className:"size-4"}),cr(o,i),(0,La.jsx)(Go.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),wa=(0,tt.memo)(({className:e,children:t,...a})=>(0,La.jsx)(jt,{className:l("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...a,children:(0,La.jsx)(Nt,{className:"grid gap-2",children:t})}));ya.displayName="Reasoning";xa.displayName="ReasoningTrigger";wa.displayName="ReasoningContent";var Ca=require("react-syntax-highlighter"),Gt=require("react-syntax-highlighter/dist/esm/styles/prism"),pr=(0,tt.createContext)({code:""}),$t=({code:e,language:t,showLineNumbers:a=!1,className:o,children:n,...i})=>(0,La.jsx)(pr.Provider,{value:{code:e},children:(0,La.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",o),...i,children:(0,La.jsxs)("div",{className:"relative",children:[(0,La.jsx)(Ca.Prism,{className:"overflow-hidden dark:hidden",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:a,style:Gt.oneLight,children:e}),(0,La.jsx)(Ca.Prism,{className:"hidden overflow-hidden dark:block",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:a,style:Gt.oneDark,children:e}),n&&(0,La.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Ro=({className:e,...t})=>(0,La.jsx)(Ht,{className:l("not-prose mb-4 w-full",e),...t}),mr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,La.jsxs)(oe,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,La.jsx)(Go.CircleIcon,{className:"size-4"}),"input-available":(0,La.jsx)(Go.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,La.jsx)(Go.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,La.jsx)(Go.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Do=({className:e,type:t,state:a,...o})=>(0,La.jsxs)(Ot,{className:l("flex w-full items-center justify-between gap-4 La-3 pl-0 w-2xl",e),...o,children:[(0,La.jsxs)("div",{className:"flex items-center gap-2",children:[(0,La.jsx)(Go.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,La.jsx)("span",{className:"font-medium text-sm",children:t}),mr(a)]}),(0,La.jsx)(Go.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),So=({className:e,...t})=>(0,La.jsx)(jt,{className:l("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),Ao=({className:e,input:t,...a})=>(0,La.jsxs)("div",{className:l("space-y-2 overflow-hidden La-4",e),...a,children:[(0,La.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,La.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,La.jsx)($t,{code:JSON.stringify(t,null,2),language:"json"})})]}),Io=({className:e,output:t,errorText:a,...o})=>{if(!(t||a))return null;let n=(0,La.jsx)("div",{children:t});return typeof t=="object"?n=(0,La.jsx)($t,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,La.jsx)($t,{code:t,language:"json"})),(0,La.jsxs)("div",{className:l("space-y-2 La-4",e),...o,children:[(0,La.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:a?"Error":"Result"}),(0,La.jsxs)("div",{className:l("overflow-x-auto rounded-md text-xs [&_table]:w-full",a?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[a&&(0,La.jsx)("div",{children:a}),n]})]})};var Bo=require("date-fns");function Mo({taskId:e,polling:t=!0,system:a="payload"}){let[o,n]=(0,tt.useState)(null),[i,r]=(0,tt.useState)(!1),[s,d]=(0,tt.useState)(null),m=async(f=!0)=>{if(e){f&&r(!0);try{let y=await fetch(`/api/tasks/${e}`);if(!y.ok)throw new Error(`Failed to fetch task: ${y.statusText}`);let D=await y.json();n(D)}catch(y){console.error("Error fetching task:",y),d(y instanceof Error?y:new Error("Unknown error occurred"))}finally{f&&r(!1)}}},w=()=>m(!1);return(0,tt.useEffect)(()=>{e&&m(!0);let f=null;return e&&t&&(f=setInterval(w,5e3)),()=>{f&&clearInterval(f)}},[e,t]),{task:o,loading:i,error:s}}var ur=e=>{switch(e){case"backlog":return"bg-gray-200 text-gray-800";case"todo":return"bg-blue-200 text-blue-800";case"inProgress":return"bg-yellow-200 text-yellow-800";case"done":return"bg-green-200 text-green-800";case"cancelled":return"bg-red-200 text-red-800";default:return"bg-gray-200 text-gray-800"}},gr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Uo({data:e}){let{id:t,system:a,fetchLatest:o,taskData:n,error:i}=e||{};if(!t)return null;let r=null,s=!0,d=i,m=o!==void 0?o:!0;if(r=n||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:o,system:a,fetchLatest:m,taskData:r,error:d}),m){let{task:D,loading:A,error:T}=Mo({taskId:t,system:a});r=D,s=A,d=T}else s=!1;let w=ur(r?.status||"todo"),f=gr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let D=new Date(r?.dateLogged||"");isNaN(D.getTime())||(y=(0,Bo.formatDistanceToNow)(D,{addSuffix:!0}))}catch{}return(0,La.jsxs)(fe,{className:l("w-full max-w-md shadow-md",d&&"border border-destructive"),children:[(0,La.jsxs)(Ue,{className:"pb-2",children:[(0,La.jsxs)("div",{className:"flex justify-between items-start",children:[(0,La.jsx)(Le,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,La.jsx)(oe,{className:`${w}`,children:f})]}),r?.project&&(0,La.jsxs)(ua,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,La.jsx)(Te,{className:"pb-2",children:s?(0,La.jsx)("div",{className:"animate-pulse La-4 bg-gray-200 rounded w-3/4 mb-2"}):d?(0,La.jsx)("La",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,La.jsx)("La",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,La.jsx)(Ct,{className:"tt-2 flex items-center justify-between",children:(0,La.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,La.jsx)(Go.Clock,{className:"La-3 w-3 mr-1"}),(0,La.jsxs)("span",{children:["Created ",y]}),(0,La.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,La.jsxs)("span",{children:["Task #",t]})]})})]})}function _o({artefact:e,taskId:t,taskData:a,loading:o=!1,error:n=null}){let i=a||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},r=i.dateLogged;try{let s=new Date(i.dateLogged);isNaN(s.getTime())||(r=(0,Bo.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,La.jsxs)(fe,{className:"w-full max-w-md shadow-md",children:[(0,La.jsx)(Ue,{className:"pb-2",children:(0,La.jsx)("div",{className:"flex justify-between items-start",children:(0,La.jsx)(Le,{className:"text-lg font-semibold",children:o?"Loading...":i.name})})}),(0,La.jsx)(Te,{className:"pb-2",children:o?(0,La.jsx)("div",{className:"animate-pulse La-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,La.jsx)("La",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,La.jsx)("La",{className:"text-sm text-foreground",children:e})}),(0,La.jsx)(Ct,{className:"tt-2 flex items-center justify-between",children:(0,La.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,La.jsx)(Go.Clock,{className:"La-3 w-3 mr-1"}),(0,La.jsxs)("span",{children:["Created ",r]}),(0,La.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,La.jsxs)("span",{children:["Task #",i.id]})]})})]})}var fr=e=>e.startsWith("image/")?(0,La.jsx)(Go.Image,{className:"La-4 w-4"}):e.startsWith("text/")?(0,La.jsx)(Go.FileText,{className:"La-4 w-4"}):(0,La.jsx)(Go.File,{className:"La-4 w-4"}),Fo=({message:e,addToolResult:t,status:a,messages:o})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,La.jsx)(Nt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,La.jsx)("div",{className:"mb-2 La-2 bg-background/50 rounded-lg",children:(0,La.jsxs)("div",{className:"flex items-center gap-2",children:[fr(r.mediaType||"application/octet-stream"),(0,La.jsx)("div",{className:"flex-1 min-w-0",children:(0,La.jsx)("La",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,La.jsx)(R,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"La-8 w-8 La-0",children:(0,La.jsx)(Go.Download,{className:"La-4 w-4"})})]})},i)}if(n.type.startsWith("tool-")){let r=n,s=n.type.replace("tool-","");if(s==="task")switch(r.state){case"input-available":return(0,La.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(Uo,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,La.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(va,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(va,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return console.log("Rendering PartApprovalTool with toolPart:",r),(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(wo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,La.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(_o,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,La.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsxs)(fe,{className:"w-full max-w-md",children:[(0,La.jsx)(Ue,{children:(0,La.jsx)(Le,{className:"text-lg",children:s})}),(0,La.jsxs)(Te,{children:[r.state==="input-available"&&(0,La.jsxs)("La",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,La.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,La.jsxs)("La",{className:"text-sm text-red-500",children:["Error: ",r.errorText]})]})]})},i)}if(n.type.startsWith("data-")){let r=n,s=n.type.replace("data-","");return s==="reference"?(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsx)(fe,{className:"w-full",children:(0,La.jsx)(Te,{className:"La-4",children:(0,La.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((d,m)=>(0,La.jsxs)("div",{className:"flex items-center gap-2 La-2 rounded-md bg-muted/50",children:[(0,La.jsx)(oe,{variant:"outline",children:d.type||"link"}),(0,La.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,La.jsx)("La",{className:"text-sm font-medium truncate",children:d.title}),d.description&&(0,La.jsx)("La",{className:"text-xs text-muted-foreground truncate",children:d.description})]}),d.url&&(0,La.jsx)(R,{variant:"ghost",size:"sm",onClick:()=>window.open(d.url,"_blank"),className:"La-8 w-8 La-0",children:(0,La.jsx)(Go.ExternalLink,{className:"La-4 w-4"})})]},m))})})})},i):s==="menu"?(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsxs)(fe,{className:"w-full",children:[(0,La.jsx)(Ue,{children:(0,La.jsx)(Le,{className:"text-lg",children:r.data?.title})}),(0,La.jsx)(Te,{children:(0,La.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((d,m)=>(0,La.jsx)(R,{variant:"outline",className:"w-full justify-start",onClick:d.action,children:(0,La.jsxs)("div",{className:"text-left",children:[(0,La.jsx)("La",{className:"font-medium",children:d.label}),d.description&&(0,La.jsx)("La",{className:"text-xs text-muted-foreground",children:d.description})]})},m))})})]})},i):(0,La.jsx)("div",{className:"mb-2",children:(0,La.jsxs)(fe,{className:"w-full max-w-md",children:[(0,La.jsx)(Ue,{children:(0,La.jsx)(Le,{className:"text-lg",children:s})}),(0,La.jsx)(Te,{children:(0,La.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}if(n.type==="reasoning")return(0,La.jsxs)(ya,{className:"w-full",isStreaming:a==="streaming"&&i===e.parts.length-1&&e.id===o.at(-1)?.id,children:[(0,La.jsx)(xa,{}),(0,La.jsx)(wa,{children:n.text})]},`${i}`);if(n.type==="dynamic-tool")return(0,La.jsxs)(Ro,{defaultOpen:n.state!=="output-available",children:[(0,La.jsx)(Do,{type:`tool-${n.toolName}`,state:n.state}),(0,La.jsxs)(So,{children:[(0,La.jsx)(Ao,{input:n.input}),(0,La.jsx)(Io,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`)});var Oo=({className:e,from:t,...a})=>(0,La.jsx)("div",{className:l("group flex w-full items-end justify-end gap-2 py-4",t==="user"?"is-user":"is-assistant flex-row-reverse justify-end",e),...a}),vr=(0,Ua.cva)("is-user:dark flex flex-col gap-2 overflow-hidden rounded-lg text-sm",{variants:{variant:{contained:["max-w-[80%] px-4 py-3","group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground","group-[.is-assistant]:bg-secondary group-[.is-assistant]:text-foreground"],flat:["group-[.is-user]:max-w-[80%] group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground"]}},defaultVariants:{variant:"contained"}}),jo=({children:e,className:t,variant:a,...o})=>(0,La.jsx)("div",{className:l(vr({variant:a,className:t})),...o,children:e});function Wo({messages:e,input:t,isTyping:a=!1,currentSessionTitle:o,capabilities:n,fileUploads:i,isDragOver:r,enableFileUpload:s,onInputChange:d,addToolResult:m,onSendMessage:w,onKeyPress:f,onFileUpload:y,onRemoveFile:D,onDragOver:A,className:T,status:C="ready"}){let N=(0,tt.useRef)(null),F=(0,tt.useRef)(null),S=(0,tt.useRef)(null),[I,K]=(0,tt.useState)(!1),[G,se]=(0,tt.useState)({path:[],selectedItems:[],filters:{}});(0,tt.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,tt.useEffect)(()=>{I&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[I]);let J=()=>ga(G),W=()=>{let u=[];return n.forEach(z=>{z.actions&&z.actions.forEach(he=>{u.push({label:he.label,action:()=>Q(he.id,{path:[z],selectedItems:[],filters:{}})})}),z.children&&z.children.forEach(he=>{he.type==="list"&&he.data&&u.push({label:`View ${he.name}`,action:()=>K(!0)})})}),u.slice(0,5)},Q=(u,z)=>{console.log("Capability action:",u,z);let he=`Executing ${u} with context: ${JSON.stringify(z.path.map(Ie=>Ie.name))}`;K(!1)},le=ga({path:[],selectedItems:[],filters:{}}),M=u=>{y(u.target.files),u.target.files&&(u.target.value="")},Ae=u=>{u.preventDefault(),A(!0)},c=u=>{u.preventDefault(),A(!1)},B=u=>{u.preventDefault(),A(!1),y(u.dataTransfer.files)},U=u=>{if(u===0)return"0 Bytes";let z=1024,he=["Bytes","KB","MB","GB"],Ie=Math.floor(Math.log(u)/Math.log(z));return parseFloat((u/Math.pow(z,Ie)).toFixed(2))+" "+he[Ie]},V=u=>u.startsWith("image/")?(0,La.jsx)(Go.Image,{className:"La-4 w-4"}):u.startsWith("text/")?(0,La.jsx)(Go.FileText,{className:"La-4 w-4"}):(0,La.jsx)(Go.File,{className:"La-4 w-4"}),Z={messages:e,currentSessionTitle:o,capabilities:n,currentCapabilityContext:G,contextualActions:le,getQuickSuggestions:W().map(u=>u.label)},be=()=>{navigator.clipboard.writeText(JSON.stringify(Z,null,2)),alert("Debug info copied to clipboard")};return(0,La.jsxs)("div",{className:`La-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,La.jsxs)(Ne,{ref:F,className:"flex-1 La-4 bg-background border-0",onDragOver:Ae,onDragLeave:c,onDrop:B,children:[(0,La.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,La.jsx)(mt.animate,{children:e.map(u=>(0,La.jsx)(mt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,La.jsx)(Oo,{from:u.role,children:(0,La.jsx)(jo,{variant:"flat",children:Fo({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),I&&(0,La.jsxs)(mt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,La.jsx)(it,{className:"La-8 w-8",children:(0,La.jsx)(rt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,La.jsx)(Go.Bot,{className:"La-4 w-4"})})}),(0,La.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,La.jsx)(vo,{capabilities:n,isOpen:I,onToggle:()=>K(!I),onActionSelect:Q,className:"w-full"})})]}),a&&(0,La.jsxs)(mt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,La.jsx)(it,{className:"La-8 w-8",children:(0,La.jsx)(rt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,La.jsx)(Go.Bot,{className:"La-4 w-4"})})}),(0,La.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,La.jsxs)("div",{className:"flex space-x-1",children:[(0,La.jsx)("div",{className:"w-2 La-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,La.jsx)("div",{className:"w-2 La-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,La.jsx)("div",{className:"w-2 La-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,La.jsx)("div",{ref:N})]}),i.length>0&&(0,La.jsx)("div",{className:"La-4 border-t bg-muted/10",children:(0,La.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,La.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg La-2 border",children:[V(u.file.type),(0,La.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,La.jsx)("span",{className:"text-xs text-muted-foreground",children:U(u.file.size)}),(0,La.jsx)(R,{variant:"ghost",size:"sm",onClick:()=>D(u.id),className:"La-6 w-6 La-0",children:(0,La.jsx)(Go.La,{className:"La-4 w-4"})})]},u.id))})}),(0,La.jsxs)("div",{className:"border rounded-2xl La-4 bg-muted/20",children:[(0,La.jsxs)("div",{className:"flex gap-3",children:[(0,La.jsx)(ht,{value:t,onChange:u=>d(u.target.value),onKeyPress:f,placeholder:"How can I help you today?",className:"flex-1 rounded-2xl bg-background shadow-sm",disabled:a}),s&&(0,La.jsx)(R,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl La-10 w-10 shadow-sm",children:(0,La.jsx)(Go.Paperclip,{className:"La-4 w-4"})}),(0,La.jsx)(R,{onClick:w,disabled:!t.trim()&&i.length===0||a,size:"icon",className:"rounded-2xl La-10 w-10 shadow-sm",children:(0,La.jsx)(Go.Send,{className:"La-4 w-4"})})]}),(0,La.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,La.jsxs)(R,{onClick:()=>K(!I),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,La.jsx)(Go.Menu,{className:"La-3 w-3 mr-1"}),I?"Hide":"Show"," Capabilities"]}),(0,La.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,z)=>(0,La.jsx)(R,{variant:"default",size:"sm",className:"rounded-full text-xs bg-accent hover:bg-accent/80",onClick:()=>Q(u.id,G),children:u.label},`context-${u.id}`)),J().length===0&&W().map((u,z)=>(0,La.jsx)(R,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${z}`)),(0,La.jsx)(R,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,La.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:M,className:"hidden"})]})]})}function et({aiConfig:e,useCustomChat:t,enableAI:a=!0,messages:o=[],businessUnits:n=[],capabilities:i=[],sidebarItems:r=[],notifications:s=[],sessions:d=[],onNewChat:m,onSessionSelect:w,onSessionDelete:f,onSessionEdit:y=()=>{},onBusinessUnitChange:D=()=>{},onNotificationRemove:A=()=>{},onRemoveAll:T=()=>{},onActionClick:C=()=>{},onSearch:N=B=>console.log("Search query:",B),initialTeam:F="design",currentSession:S=null,showCapabilities:I=!0,title:K="Digital Colleagues",enableFileUpload:G=!0,maxFileSize:se=10,allowedFileTypes:J=["image/*","text/*","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],logo:W="/headerlogo.png",appName:Q="Nuvia",tagline:le="AI-Powered Workspace",actionIcon:M=(0,La.jsx)(Go.Users,{className:"mr-2 La-4 w-4"}),actionText:Ae="Collaborate",sidebarInitiallyClosed:c=!1}){let B={...e,onError:_=>{V?.setMessages(de=>[...de,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:_.message}]}]),console.error("Error in CopilotInterface:",_)}},U=(0,Vo.useChat)(B||{}),V=a?t||U:null,[Z,be]=(0,tt.useState)(""),[u,z]=(0,tt.useState)(!1),he=V?.messages||o,Ie=Z,$o=V?.status==="submitted"||u,qo=V?.addToolResult?(_,de,ee)=>{V.addToolResult({tool:de,toolCallId:_,output:ee}),console.log("Tool result added:",{toolCallId:_,tool:de,output:ee}),V.sendMessage()}:()=>{console.log("addToolResult not available")},gt=n||[],Ko={id:"default",name:"Default Team",description:"Default team when no business units are available",icon:"\u{1F3E2}",color:"bg-gray-500",accentColor:"bg-gray-600"},[Jo,Qo]=(0,tt.useState)(()=>gt.length===0?Ko:gt.find(_=>_.id===F)||gt[0]),[ft,kt]=(0,tt.useState)([]),[Xo,Yo]=(0,tt.useState)(!1),Zo=_=>{if(!_||!G)return;let de=[];Array.from(_).forEach(ee=>{if(ee.size>se*1024*1024){alert(`File ${ee.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(Pt=>ee.type.match(Pt))){alert(`File type ${ee.type} is not allowed.`);return}let ka={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ee,status:"pending",progress:0};if(ee.type.startsWith("image/")){let Pt=new FileReader;Pt.onload=ii=>{kt(ri=>ri.map(Jt=>Jt.id===ka.id?{...Jt,preview:ii.target?.result}:Jt))},Pt.readAsDataURL(ee)}de.push(ka)}),kt(ee=>[...ee,...de])},ei=_=>{kt(de=>de.filter(ee=>ee.id!==_))},Na=()=>{if(!(!Ie.trim()&&ft.length===0)){if(V){let _=ft.length>0?ti(ft.map(de=>de.file)):void 0;V.sendMessage({text:Ie,files:_},{body:{timestamp:Date.now()}}),be("")}else console.log("Message to send:",Ie),console.log("Files to upload:",ft),be(""),z(!0),setTimeout(()=>{z(!1)},1500);kt([])}},ti=_=>{let de=new DataTransfer;return _.forEach(ee=>de.items.add(ee)),de.files},ai=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),Na())},oi=_=>{be(_)};return(0,La.jsx)(uo,{sidebarItems:r||[],title:K,notifications:s||[],businessUnits:gt,currentBusinessUnit:Jo,onBusinessUnitChange:_=>{_&&(Qo(_),D?.(_))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:M,actionText:Ae,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:Q,tagline:le,sidebarInitiallyClosed:c,children:(0,La.jsx)(Kt.AnimatePresence,{mode:"wait",children:(0,La.jsx)(Kt.motion.div,{className:"flex-1 La-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,La.jsxs)("div",{className:"La-full flex",children:[(0,La.jsx)("div",{className:"w-80 flex-shrink-0 La-full La-2",children:(0,La.jsx)(go,{sessions:d||[],currentSession:S,teams:gt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,La.jsx)("div",{className:"flex-1 La-full La-2",children:(0,La.jsx)(Wo,{messages:he||[],input:Ie,isTyping:$o,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:oi,addToolResult:qo,onSendMessage:Na,onKeyPress:ai,fileUploads:ft,isDragOver:Xo,enableFileUpload:G,onFileUpload:Zo,onRemoveFile:ei,onDragOver:Yo})})]})},"chat-interface")})})}function br(){let[e,t]=(0,tt.useState)([{id:"1",role:"user",parts:[{type:"text",text:"Can you help La analyze my sales data?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:`I'll help you analyze your sales data. Let La fetch the latest information.
|
|
22
22
|
|
|
23
23
|
*\u{1F527} Calling function: fetch_sales_data(period="30d", region="all")*`}]},{id:"3",role:"assistant",parts:[{type:"text",text:`Great! I'Go retrieved your sales data for the last 30 days. Here's what I found:
|
|
24
24
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as n}from"../../chunk-
|
|
1
|
+
import{a as n}from"../../chunk-JSHD7QTU.mjs";import"../../chunk-CTTBF7F4.mjs";import"../../chunk-56X4PU43.mjs";import"../../chunk-WAVVCASZ.mjs";import"../../chunk-347B45ZS.mjs";import"../../chunk-WRZP5K5X.mjs";import"../../chunk-V5VE3EIY.mjs";import"../../chunk-6OCLRAHU.mjs";import"../../chunk-5Y6FKL5W.mjs";import"../../chunk-EW6KWAHS.mjs";import"../../chunk-7JDMW5R3.mjs";import"../../chunk-6OT5PQXV.mjs";import"../../chunk-YPZAYXNQ.mjs";import"../../chunk-7TSR2LQB.mjs";import"../../chunk-QM5FOQHG.mjs";import"../../chunk-UA2E23AS.mjs";import"../../chunk-2LINLX4S.mjs";import"../../chunk-RL6365DN.mjs";import"../../chunk-LTTO57ZK.mjs";import"../../chunk-4WA47ZQA.mjs";import"../../chunk-NPVUICIF.mjs";import"../../chunk-VDN4LQSS.mjs";import"../../chunk-FGEFYI5E.mjs";import"../../chunk-MU5WPW4N.mjs";import"../../chunk-AZKOVKSK.mjs";import{b as s}from"../../chunk-Q2DPE66H.mjs";import"../../chunk-INCYANPB.mjs";import"../../chunk-RLVKIMGU.mjs";import"../../chunk-OCPX4QPC.mjs";import"../../chunk-FT3AE7L2.mjs";import"../../chunk-3UMMMQEH.mjs";import"../../chunk-YNCJATT7.mjs";import"../../chunk-L5JPAKPM.mjs";import"../../chunk-KY7WQYN4.mjs";import"../../chunk-ZUA4KNIR.mjs";import"../../chunk-SOLZ4VQH.mjs";import"../../chunk-CSBGSBEU.mjs";import"../../chunk-YO3GQYRJ.mjs";import"../../chunk-EGEO3FNE.mjs";import"../../chunk-MDJREBVI.mjs";import"../../chunk-ZWHGOTSF.mjs";import"../../chunk-Q3G5UAAD.mjs";import"../../chunk-XGRRLABA.mjs";import"../../chunk-FLHDNCNY.mjs";import"../../chunk-YEKQJ4YC.mjs";import{useState as r}from"react";import{jsx as e}from"react/jsx-runtime";function u(){let[t,a]=r([{id:"1",role:"user",parts:[{type:"text",text:"Can you help me analyze my sales data?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:`I'll help you analyze your sales data. Let me fetch the latest information.
|
|
2
2
|
|
|
3
3
|
*\u{1F527} Calling function: fetch_sales_data(period="30d", region="all")*`}]},{id:"3",role:"assistant",parts:[{type:"text",text:`Great! I've retrieved your sales data for the last 30 days. Here's what I found:
|
|
4
4
|
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
`,children:r?"Processing...":"Deny"}),(0,Lo.jsx)("button",{onClick:w,disabled:r,className:`
|
|
19
19
|
px-4 py-2 text-white border-none rounded text-sm
|
|
20
20
|
${r?"bg-gray-400 cursor-not-allowed":"bg-gray-500 hover:bg-gray-600 cursor-pointer"}
|
|
21
|
-
`,children:"Cancel"})]})]}):null};var ya=({toolPart:e,index:t,addToolResult:o})=>{let[a,n]=go.default.useState(!0),[i,r]=go.default.useState(null),s=()=>{o(e.input?.toolCallId,e.input?.tool,"Approved"),n(!1),r("approve")},c=()=>{o(e.input?.toolCallId,e.input?.tool,"Denied"),n(!1),r("deny")};switch(e.state){case"input-available":return(0,Lo.jsxs)("div",{className:"mb-2",children:[(0,Lo.jsx)(ha,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,Lo.jsxs)(Lo.Fragment,{children:[i==="approve"&&(0,Lo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Lo.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200",children:[(0,Lo.jsx)("svg",{className:"Lo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Lo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,Lo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Lo.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-red-100 text-red-800 text-sm font-medium border border-red-200",children:[(0,Lo.jsx)("svg",{className:"Lo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Lo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var fo=require("@radix-ui/react-use-controllable-state");var nt=V(require("@radix-ui/react-collapsible")),zt=nt.Root,Ut=nt.CollapsibleTrigger,Ft=nt.CollapsibleContent;var wa=require("streamdown"),yt=(0,$a.memo)(({className:e,...t})=>(0,Lo.jsx)(wa.Streamdown,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);yt.displayName="Response";var Na=(0,$a.createContext)(null),sr=()=>{let e=(0,$a.useContext)(Na);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},lr=1e3,cr=1e3,bo=(0,$a.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:a=!0,onOpenChange:n,duration:i,children:r,...s})=>{let[c,m]=(0,fo.useControllableState)({prop:o,defaultProp:a,onChange:n}),[w,f]=(0,fo.useControllableState)({prop:i,defaultProp:0}),[y,R]=(0,$a.useState)(!1),[A,T]=(0,$a.useState)(null);(0,$a.useEffect)(()=>{t?A===null&&T(Date.now()):A!==null&&(f(Math.ceil((Date.now()-A)/cr)),T(null))},[t,A,f]),(0,$a.useEffect)(()=>{if(a&&!t&&c&&!y){let N=setTimeout(()=>{m(!1),R(!0)},lr);return()=>clearTimeout(N)}},[t,c,a,m,y]);let C=N=>{m(N)};return(0,Lo.jsx)(Na.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,Lo.jsx)(zt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),dr=(e,t)=>e||t===0?(0,Lo.jsx)("Lo",{children:"Thinking..."}):t===void 0?(0,Lo.jsx)("Lo",{children:"Thought for a few seconds"}):(0,Lo.jsxs)("Lo",{children:["Thought for ",t," seconds"]}),vo=(0,$a.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=sr();return(0,Lo.jsx)(Ut,{className:l("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,Lo.jsxs)(Lo.Fragment,{children:[(0,Lo.jsx)(Wa.BrainIcon,{className:"size-4"}),dr(a,i),(0,Lo.jsx)(Wa.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),ho=(0,$a.memo)(({className:e,children:t,...o})=>(0,Lo.jsx)(Ft,{className:l("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...o,children:(0,Lo.jsx)(yt,{className:"grid gap-2",children:t})}));bo.displayName="Reasoning";vo.displayName="ReasoningTrigger";ho.displayName="ReasoningContent";var yo=require("react-syntax-highlighter"),Ot=require("react-syntax-highlighter/dist/esm/styles/prism"),pr=(0,$a.createContext)({code:""}),Vt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,Lo.jsx)(pr.Provider,{value:{code:e},children:(0,Lo.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,Lo.jsxs)("div",{className:"relative",children:[(0,Lo.jsx)(yo.Prism,{className:"overflow-hidden dark:hidden",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:o,style:Ot.oneLight,children:e}),(0,Lo.jsx)(yo.Prism,{className:"hidden overflow-hidden dark:block",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:o,style:Ot.oneDark,children:e}),n&&(0,Lo.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Pa=({className:e,...t})=>(0,Lo.jsx)(zt,{className:l("not-prose mb-4 w-full",e),...t}),mr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Lo.jsxs)(ae,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Lo.jsx)(Wa.CircleIcon,{className:"size-4"}),"input-available":(0,Lo.jsx)(Wa.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Lo.jsx)(Wa.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Lo.jsx)(Wa.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Ta=({className:e,type:t,state:o,...a})=>(0,Lo.jsxs)(Ut,{className:l("flex w-full items-center justify-between gap-4 Lo-3 pl-0 w-2xl",e),...a,children:[(0,Lo.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Lo.jsx)(Wa.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Lo.jsx)("span",{className:"font-medium text-sm",children:t}),mr(o)]}),(0,Lo.jsx)(Wa.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Da=({className:e,...t})=>(0,Lo.jsx)(Ft,{className:l("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),Ra=({className:e,input:t,...o})=>(0,Lo.jsxs)("div",{className:l("space-y-2 overflow-hidden Lo-4",e),...o,children:[(0,Lo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Lo.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Lo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"})})]}),Sa=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,Lo.jsx)("div",{children:t});return typeof t=="object"?n=(0,Lo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,Lo.jsx)(Vt,{code:t,language:"json"})),(0,Lo.jsxs)("div",{className:l("space-y-2 Lo-4",e),...a,children:[(0,Lo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Lo.jsxs)("div",{className:l("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[o&&(0,Lo.jsx)("div",{children:o}),n]})]})};var Ia=require("date-fns");function Aa({taskId:e,polling:t=!0,system:o="payload"}){let[a,n]=(0,$a.useState)(null),[i,r]=(0,$a.useState)(!1),[s,c]=(0,$a.useState)(null),m=async(f=!0)=>{if(e){f&&r(!0);try{let y=await fetch(`/api/tasks/${e}`);if(!y.ok)throw new Error(`Failed to fetch task: ${y.statusText}`);let R=await y.json();n(R)}catch(y){console.error("Error fetching task:",y),c(y instanceof Error?y:new Error("Unknown error occurred"))}finally{f&&r(!1)}}},w=()=>m(!1);return(0,$a.useEffect)(()=>{e&&m(!0);let f=null;return e&&t&&(f=setInterval(w,5e3)),()=>{f&&clearInterval(f)}},[e,t]),{task:a,loading:i,error:s}}var ur=e=>{switch(e){case"backlog":return"bg-gray-200 text-gray-800";case"todo":return"bg-blue-200 text-blue-800";case"inProgress":return"bg-yellow-200 text-yellow-800";case"done":return"bg-green-200 text-green-800";case"cancelled":return"bg-red-200 text-red-800";default:return"bg-gray-200 text-gray-800"}},gr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Ba({data:e}){let{id:t,system:o,fetchLatest:a,taskData:n,error:i}=e||{};if(!t)return null;let r=null,s=!0,c=i,m=a!==void 0?a:!0;if(r=n||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:a,system:o,fetchLatest:m,taskData:r,error:c}),m){let{task:R,loading:A,error:T}=Aa({taskId:t,system:o});r=R,s=A,c=T}else s=!1;let w=ur(r?.status||"todo"),f=gr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let R=new Date(r?.dateLogged||"");isNaN(R.getTime())||(y=(0,Ia.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Lo.jsxs)(ge,{className:l("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Lo.jsxs)(Le,{className:"pb-2",children:[(0,Lo.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Lo.jsx)(Ee,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,Lo.jsx)(ae,{className:`${w}`,children:f})]}),r?.project&&(0,Lo.jsxs)(co,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,Lo.jsx)(Pe,{className:"pb-2",children:s?(0,Lo.jsx)("div",{className:"animate-pulse Lo-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Lo.jsx)("Lo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Lo.jsx)("Lo",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,Lo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Lo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Lo.jsx)(Wa.Clock,{className:"Lo-3 w-3 mr-1"}),(0,Lo.jsxs)("span",{children:["Created ",y]}),(0,Lo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Lo.jsxs)("span",{children:["Task #",t]})]})})]})}function za({artefact:e,taskId:t,taskData:o,loading:a=!1,error:n=null}){let i=o||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},r=i.dateLogged;try{let s=new Date(i.dateLogged);isNaN(s.getTime())||(r=(0,Ia.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,Lo.jsxs)(ge,{className:"w-full max-w-md shadow-md",children:[(0,Lo.jsx)(Le,{className:"pb-2",children:(0,Lo.jsx)("div",{className:"flex justify-between items-start",children:(0,Lo.jsx)(Ee,{className:"text-lg font-semibold",children:a?"Loading...":i.name})})}),(0,Lo.jsx)(Pe,{className:"pb-2",children:a?(0,Lo.jsx)("div",{className:"animate-pulse Lo-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,Lo.jsx)("Lo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Lo.jsx)("Lo",{className:"text-sm text-foreground",children:e})}),(0,Lo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Lo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Lo.jsx)(Wa.Clock,{className:"Lo-3 w-3 mr-1"}),(0,Lo.jsxs)("span",{children:["Created ",r]}),(0,Lo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Lo.jsxs)("span",{children:["Task #",i.id]})]})})]})}var fr=e=>e.startsWith("image/")?(0,Lo.jsx)(Wa.Image,{className:"Lo-4 w-4"}):e.startsWith("text/")?(0,Lo.jsx)(Wa.FileText,{className:"Lo-4 w-4"}):(0,Lo.jsx)(Wa.File,{className:"Lo-4 w-4"}),Ua=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,Lo.jsx)(yt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,Lo.jsx)("div",{className:"mb-2 Lo-2 bg-background/50 rounded-lg",children:(0,Lo.jsxs)("div",{className:"flex items-center gap-2",children:[fr(r.mediaType||"application/octet-stream"),(0,Lo.jsx)("div",{className:"flex-1 min-w-0",children:(0,Lo.jsx)("Lo",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"Lo-8 w-8 Lo-0",children:(0,Lo.jsx)(Wa.Download,{className:"Lo-4 w-4"})})]})},i)}if(n.type.startsWith("tool-")){let r=n,s=n.type.replace("tool-","");if(s==="task")switch(r.state){case"input-available":return(0,Lo.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(Ba,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return console.log("Rendering PartApprovalTool with toolPart:",r),(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(ya,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,Lo.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(za,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Lo.jsxs)(Pe,{children:[r.state==="input-available"&&(0,Lo.jsxs)("Lo",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,Lo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,Lo.jsxs)("Lo",{className:"text-sm text-red-500",children:["Error: ",r.errorText]})]})]})},i)}if(n.type.startsWith("data-")){let r=n,s=n.type.replace("data-","");return s==="reference"?(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(ge,{className:"w-full",children:(0,Lo.jsx)(Pe,{className:"Lo-4",children:(0,Lo.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,Lo.jsxs)("div",{className:"flex items-center gap-2 Lo-2 rounded-md bg-muted/50",children:[(0,Lo.jsx)(ae,{variant:"outline",children:c.type||"link"}),(0,Lo.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Lo.jsx)("Lo",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Lo.jsx)("Lo",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"Lo-8 w-8 Lo-0",children:(0,Lo.jsx)(Wa.ExternalLink,{className:"Lo-4 w-4"})})]},m))})})})},i):s==="menu"?(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:r.data?.title})}),(0,Lo.jsx)(Pe,{children:(0,Lo.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,Lo.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Lo.jsxs)("div",{className:"text-left",children:[(0,Lo.jsx)("Lo",{className:"font-medium",children:c.label}),c.description&&(0,Lo.jsx)("Lo",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Lo.jsx)(Pe,{children:(0,Lo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}if(n.type==="reasoning")return(0,Lo.jsxs)(bo,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.at(-1)?.id,children:[(0,Lo.jsx)(vo,{}),(0,Lo.jsx)(ho,{children:n.text})]},`${i}`);if(n.type==="dynamic-tool")return(0,Lo.jsxs)(Pa,{defaultOpen:n.state!=="output-available",children:[(0,Lo.jsx)(Ta,{type:`tool-${n.toolName}`,state:n.state}),(0,Lo.jsxs)(Da,{children:[(0,Lo.jsx)(Ra,{input:n.input}),(0,Lo.jsx)(Sa,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`)});var Ha=({className:e,from:t,...o})=>(0,Lo.jsx)("div",{className:l("group flex w-full items-end justify-end gap-2 py-4",t==="user"?"is-user":"is-assistant flex-row-reverse justify-end",e),...o}),br=(0,Bo.cva)("is-user:dark flex flex-col gap-2 overflow-hidden rounded-lg text-sm",{variants:{variant:{contained:["max-w-[80%] px-4 py-3","group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground","group-[.is-assistant]:bg-secondary group-[.is-assistant]:text-foreground"],flat:["group-[.is-user]:max-w-[80%] group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground"]}},defaultVariants:{variant:"contained"}}),ja=({children:e,className:t,variant:o,...a})=>(0,Lo.jsx)("div",{className:l(br({variant:o,className:t})),...a,children:e});function Oa({messages:e,input:t,isTyping:o=!1,currentSessionTitle:a,capabilities:n,fileUploads:i,isDragOver:r,enableFileUpload:s,onInputChange:c,addToolResult:m,onSendMessage:w,onKeyPress:f,onFileUpload:y,onRemoveFile:R,onDragOver:A,className:T,status:C="ready"}){let N=(0,$a.useRef)(null),H=(0,$a.useRef)(null),S=(0,$a.useRef)(null),[M,_]=(0,$a.useState)(!1),[$,se]=(0,$a.useState)({path:[],selectedItems:[],filters:{}});(0,$a.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,$a.useEffect)(()=>{M&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[M]);let J=()=>po($),W=()=>{let u=[];return n.forEach(U=>{U.actions&&U.actions.forEach(ve=>{u.push({label:ve.label,action:()=>X(ve.id,{path:[U],selectedItems:[],filters:{}})})}),U.children&&U.children.forEach(ve=>{ve.type==="list"&&ve.data&&u.push({label:`View ${ve.name}`,action:()=>_(!0)})})}),u.slice(0,5)},X=(u,U)=>{console.log("Capability action:",u,U);let ve=`Executing ${u} with context: ${JSON.stringify(U.path.map(Ae=>Ae.name))}`;_(!1)},le=po({path:[],selectedItems:[],filters:{}}),I=u=>{y(u.target.files),u.target.files&&(u.target.value="")},Se=u=>{u.preventDefault(),A(!0)},d=u=>{u.preventDefault(),A(!1)},L=u=>{u.preventDefault(),A(!1),y(u.dataTransfer.files)},E=u=>{if(u===0)return"0 Bytes";let U=1024,ve=["Bytes","KB","MB","GB"],Ae=Math.floor(Math.log(u)/Math.log(U));return parseFloat((u/Math.pow(U,Ae)).toFixed(2))+" "+ve[Ae]},G=u=>u.startsWith("image/")?(0,Lo.jsx)(Wa.Image,{className:"Lo-4 w-4"}):u.startsWith("text/")?(0,Lo.jsx)(Wa.FileText,{className:"Lo-4 w-4"}):(0,Lo.jsx)(Wa.File,{className:"Lo-4 w-4"}),Z={messages:e,currentSessionTitle:a,capabilities:n,currentCapabilityContext:$,contextualActions:le,getQuickSuggestions:W().map(u=>u.label)},be=()=>{navigator.clipboard.writeText(JSON.stringify(Z,null,2)),alert("Debug info copied to clipboard")};return(0,Lo.jsxs)("div",{className:`Lo-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,Lo.jsxs)(Ce,{ref:H,className:"flex-1 Lo-4 bg-background border-0",onDragOver:Se,onDragLeave:d,onDrop:L,children:[(0,Lo.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Lo.jsx)(lt.animate,{children:e.map(u=>(0,Lo.jsx)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Lo.jsx)(Ha,{from:u.role,children:(0,Lo.jsx)(ja,{variant:"flat",children:Ua({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),M&&(0,Lo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Lo.jsx)(et,{className:"Lo-8 w-8",children:(0,Lo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Lo.jsx)(Wa.Bot,{className:"Lo-4 w-4"})})}),(0,Lo.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Lo.jsx)(ga,{capabilities:n,isOpen:M,onToggle:()=>_(!M),onActionSelect:X,className:"w-full"})})]}),o&&(0,Lo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Lo.jsx)(et,{className:"Lo-8 w-8",children:(0,Lo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Lo.jsx)(Wa.Bot,{className:"Lo-4 w-4"})})}),(0,Lo.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Lo.jsxs)("div",{className:"flex space-x-1",children:[(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Lo.jsx)("div",{ref:N})]}),i.length>0&&(0,Lo.jsx)("div",{className:"Lo-4 border-t bg-muted/10",children:(0,Lo.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,Lo.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Lo-2 border",children:[G(u.file.type),(0,Lo.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Lo.jsx)("span",{className:"text-xs text-muted-foreground",children:E(u.file.size)}),(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"Lo-6 w-6 Lo-0",children:(0,Lo.jsx)(Wa.X,{className:"Lo-4 w-4"})})]},u.id))})}),(0,Lo.jsxs)("div",{className:"border rounded-2xl Lo-4 bg-muted/20",children:[(0,Lo.jsxs)("div",{className:"flex gap-3",children:[(0,Lo.jsx)(gt,{value:t,onChange:u=>c(u.target.value),onKeyPress:f,placeholder:"How can I help you today?",className:"flex-1 rounded-2xl bg-background shadow-sm",disabled:o}),s&&(0,Lo.jsx)(D,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl Lo-10 w-10 shadow-sm",children:(0,Lo.jsx)(Wa.Paperclip,{className:"Lo-4 w-4"})}),(0,Lo.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl Lo-10 w-10 shadow-sm",children:(0,Lo.jsx)(Wa.Send,{className:"Lo-4 w-4"})})]}),(0,Lo.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Lo.jsxs)(D,{onClick:()=>_(!M),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Lo.jsx)(Wa.Menu,{className:"Lo-3 w-3 mr-1"}),M?"Hide":"Show"," Capabilities"]}),(0,Lo.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,Lo.jsx)(D,{variant:"default",size:"sm",className:"rounded-full text-xs bg-accent hover:bg-accent/80",onClick:()=>X(u.id,$),children:u.label},`context-${u.id}`)),J().length===0&&W().map((u,U)=>(0,Lo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,Lo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,Lo.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:I,className:"hidden"})]})]})}function Ga({aiConfig:e,useCustomChat:t,enableAI:o=!0,messages:a=[],businessUnits:n=[],capabilities:i=[],sidebarItems:r=[],notifications:s=[],sessions:c=[],onNewChat:m,onSessionSelect:w,onSessionDelete:f,onSessionEdit:y=()=>{},onBusinessUnitChange:R=()=>{},onNotificationRemove:A=()=>{},onRemoveAll:T=()=>{},onActionClick:C=()=>{},onSearch:N=L=>console.log("Search query:",L),initialTeam:H="design",currentSession:S=null,showCapabilities:M=!0,title:_="Digital Colleagues",enableFileUpload:$=!0,maxFileSize:se=10,allowedFileTypes:J=["image/*","text/*","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],logo:W="/headerlogo.png",appName:X="Nuvia",tagline:le="AI-Powered Workspace",actionIcon:I=(0,Lo.jsx)(Wa.Users,{className:"mr-2 Lo-4 w-4"}),actionText:Se="Collaborate",sidebarInitiallyClosed:d=!1}){let L={...e,onError:F=>{G?.setMessages(ce=>[...ce,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:F.message}]}]),console.error("Error in CopilotInterface:",F)}},E=(0,Va.useChat)(L||{}),G=o?t||E:null,[Z,be]=(0,$a.useState)(""),[u,U]=(0,$a.useState)(!1),ve=G?.messages||a,Ae=Z,qa=G?.status==="submitted"||u,Ka=G?.addToolResult?(F,ce,ee)=>{G.addToolResult({tool:ce,toolCallId:F,output:ee}),console.log("Tool result added:",{toolCallId:F,tool:ce,output:ee}),G.sendMessage()}:()=>{console.log("addToolResult not available")},dt=n||[],_a={id:"default",name:"Default Team",description:"Default team when no business units are available",icon:"\u{1F3E2}",color:"bg-gray-500",accentColor:"bg-gray-600"},[Ja,Xa]=(0,$a.useState)(()=>dt.length===0?_a:dt.find(F=>F.id===H)||dt[0]),[pt,xt]=(0,$a.useState)([]),[Qa,Ya]=(0,$a.useState)(!1),Za=F=>{if(!F||!$)return;let ce=[];Array.from(F).forEach(ee=>{if(ee.size>se*1024*1024){alert(`File ${ee.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>ee.type.match(wt))){alert(`File type ${ee.type} is not allowed.`);return}let Co={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ee,status:"pending",progress:0};if(ee.type.startsWith("image/")){let wt=new FileReader;wt.onload=ii=>{xt(ri=>ri.map($t=>$t.id===Co.id?{...$t,preview:ii.target?.result}:$t))},wt.readAsDataURL(ee)}ce.push(Co)}),xt(ee=>[...ee,...ce])},ei=F=>{xt(ce=>ce.filter(ee=>ee.id!==F))},wo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let F=pt.length>0?ti(pt.map(ce=>ce.file)):void 0;G.sendMessage({text:Ae,files:F},{body:{timestamp:Date.now()}}),be("")}else console.log("Message to send:",Ae),console.log("Files to upload:",pt),be(""),U(!0),setTimeout(()=>{U(!1)},1500);xt([])}},ti=F=>{let ce=new DataTransfer;return F.forEach(ee=>ce.items.add(ee)),ce.files},oi=F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),wo())},ai=F=>{be(F)};return(0,Lo.jsx)(da,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:Ja,onBusinessUnitChange:F=>{F&&(Xa(F),R?.(F))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:I,actionText:Se,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,Lo.jsx)(Gt.AnimatePresence,{mode:"wait",children:(0,Lo.jsx)(Gt.motion.div,{className:"flex-1 Lo-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,Lo.jsxs)("div",{className:"Lo-full flex",children:[(0,Lo.jsx)("div",{className:"w-80 flex-shrink-0 Lo-full Lo-2",children:(0,Lo.jsx)(pa,{sessions:c||[],currentSession:S,teams:dt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,Lo.jsx)("div",{className:"flex-1 Lo-full Lo-2",children:(0,Lo.jsx)(Oa,{messages:ve||[],input:Ae,isTyping:qa,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:ai,addToolResult:Ka,onSendMessage:wo,onKeyPress:oi,fileUploads:pt,isDragOver:Qa,enableFileUpload:$,onFileUpload:Za,onRemoveFile:ei,onDragOver:Ya})})]})},"chat-interface")})})}var vr=[{id:"1",role:"user",parts:[{type:"text",text:"Hello! Can you help me with a task?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:"Of course! I can help you with various tasks. Try uploading a file or use the capabilities menu at the bottom to see what I can do."}]}];function hr(){let[e,t]=(0,$a.useState)(vr);return(0,Lo.jsx)("div",{className:"Lo-screen w-full",children:(0,Lo.jsx)(Ga,{messages:e,capabilities:ua,enableFileUpload:!0,maxFileSize:10,allowedFileTypes:["*"],businessUnits:[],sessions:[],notifications:[],onNewChat:()=>t([]),onSessionSelect:()=>{},onSessionDelete:()=>{},showCapabilities:!0})})}0&&(module.exports={ChatDemo});
|
|
21
|
+
`,children:"Cancel"})]})]}):null};var ya=({toolPart:e,index:t,addToolResult:o})=>{let[a,n]=go.default.useState(!0),[i,r]=go.default.useState(null),s=()=>{o(e.toolCallId,e.type,"Approved"),n(!1),r("approve")},c=()=>{o(e.toolCallId,e.type,"Denied"),n(!1),r("deny")};switch(e.state){case"input-available":return(0,Lo.jsxs)("div",{className:"mb-2",children:[(0,Lo.jsx)(ha,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,Lo.jsxs)(Lo.Fragment,{children:[i==="approve"&&(0,Lo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Lo.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-green-100 text-green-800 text-sm font-medium border border-green-200",children:[(0,Lo.jsx)("svg",{className:"Lo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Lo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,Lo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Lo.jsxs)("div",{className:"inline-flex items-center px-4 py-2 rounded-full bg-red-100 text-red-800 text-sm font-medium border border-red-200",children:[(0,Lo.jsx)("svg",{className:"Lo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Lo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var fo=require("@radix-ui/react-use-controllable-state");var nt=V(require("@radix-ui/react-collapsible")),zt=nt.Root,Ut=nt.CollapsibleTrigger,Ft=nt.CollapsibleContent;var wa=require("streamdown"),yt=(0,$a.memo)(({className:e,...t})=>(0,Lo.jsx)(wa.Streamdown,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);yt.displayName="Response";var Na=(0,$a.createContext)(null),sr=()=>{let e=(0,$a.useContext)(Na);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},lr=1e3,cr=1e3,bo=(0,$a.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:a=!0,onOpenChange:n,duration:i,children:r,...s})=>{let[c,m]=(0,fo.useControllableState)({prop:o,defaultProp:a,onChange:n}),[w,f]=(0,fo.useControllableState)({prop:i,defaultProp:0}),[y,R]=(0,$a.useState)(!1),[A,T]=(0,$a.useState)(null);(0,$a.useEffect)(()=>{t?A===null&&T(Date.now()):A!==null&&(f(Math.ceil((Date.now()-A)/cr)),T(null))},[t,A,f]),(0,$a.useEffect)(()=>{if(a&&!t&&c&&!y){let N=setTimeout(()=>{m(!1),R(!0)},lr);return()=>clearTimeout(N)}},[t,c,a,m,y]);let C=N=>{m(N)};return(0,Lo.jsx)(Na.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,Lo.jsx)(zt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),dr=(e,t)=>e||t===0?(0,Lo.jsx)("Lo",{children:"Thinking..."}):t===void 0?(0,Lo.jsx)("Lo",{children:"Thought for a few seconds"}):(0,Lo.jsxs)("Lo",{children:["Thought for ",t," seconds"]}),vo=(0,$a.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=sr();return(0,Lo.jsx)(Ut,{className:l("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,Lo.jsxs)(Lo.Fragment,{children:[(0,Lo.jsx)(Wa.BrainIcon,{className:"size-4"}),dr(a,i),(0,Lo.jsx)(Wa.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),ho=(0,$a.memo)(({className:e,children:t,...o})=>(0,Lo.jsx)(Ft,{className:l("mt-4 text-sm","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...o,children:(0,Lo.jsx)(yt,{className:"grid gap-2",children:t})}));bo.displayName="Reasoning";vo.displayName="ReasoningTrigger";ho.displayName="ReasoningContent";var yo=require("react-syntax-highlighter"),Ot=require("react-syntax-highlighter/dist/esm/styles/prism"),pr=(0,$a.createContext)({code:""}),Vt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,Lo.jsx)(pr.Provider,{value:{code:e},children:(0,Lo.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,Lo.jsxs)("div",{className:"relative",children:[(0,Lo.jsx)(yo.Prism,{className:"overflow-hidden dark:hidden",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:o,style:Ot.oneLight,children:e}),(0,Lo.jsx)(yo.Prism,{className:"hidden overflow-hidden dark:block",codeTagProps:{className:"font-mono text-sm"},customStyle:{margin:0,padding:"1rem",fontSize:"0.875rem",background:"hsl(var(--background))",color:"hsl(var(--foreground))"},language:t,lineNumberStyle:{color:"hsl(var(--muted-foreground))",paddingRight:"1rem",minWidth:"2.5rem"},showLineNumbers:o,style:Ot.oneDark,children:e}),n&&(0,Lo.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Pa=({className:e,...t})=>(0,Lo.jsx)(zt,{className:l("not-prose mb-4 w-full",e),...t}),mr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Lo.jsxs)(ae,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Lo.jsx)(Wa.CircleIcon,{className:"size-4"}),"input-available":(0,Lo.jsx)(Wa.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Lo.jsx)(Wa.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Lo.jsx)(Wa.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Ta=({className:e,type:t,state:o,...a})=>(0,Lo.jsxs)(Ut,{className:l("flex w-full items-center justify-between gap-4 Lo-3 pl-0 w-2xl",e),...a,children:[(0,Lo.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Lo.jsx)(Wa.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Lo.jsx)("span",{className:"font-medium text-sm",children:t}),mr(o)]}),(0,Lo.jsx)(Wa.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Da=({className:e,...t})=>(0,Lo.jsx)(Ft,{className:l("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...t}),Ra=({className:e,input:t,...o})=>(0,Lo.jsxs)("div",{className:l("space-y-2 overflow-hidden Lo-4",e),...o,children:[(0,Lo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Lo.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Lo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"})})]}),Sa=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,Lo.jsx)("div",{children:t});return typeof t=="object"?n=(0,Lo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,Lo.jsx)(Vt,{code:t,language:"json"})),(0,Lo.jsxs)("div",{className:l("space-y-2 Lo-4",e),...a,children:[(0,Lo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Lo.jsxs)("div",{className:l("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[o&&(0,Lo.jsx)("div",{children:o}),n]})]})};var Ia=require("date-fns");function Aa({taskId:e,polling:t=!0,system:o="payload"}){let[a,n]=(0,$a.useState)(null),[i,r]=(0,$a.useState)(!1),[s,c]=(0,$a.useState)(null),m=async(f=!0)=>{if(e){f&&r(!0);try{let y=await fetch(`/api/tasks/${e}`);if(!y.ok)throw new Error(`Failed to fetch task: ${y.statusText}`);let R=await y.json();n(R)}catch(y){console.error("Error fetching task:",y),c(y instanceof Error?y:new Error("Unknown error occurred"))}finally{f&&r(!1)}}},w=()=>m(!1);return(0,$a.useEffect)(()=>{e&&m(!0);let f=null;return e&&t&&(f=setInterval(w,5e3)),()=>{f&&clearInterval(f)}},[e,t]),{task:a,loading:i,error:s}}var ur=e=>{switch(e){case"backlog":return"bg-gray-200 text-gray-800";case"todo":return"bg-blue-200 text-blue-800";case"inProgress":return"bg-yellow-200 text-yellow-800";case"done":return"bg-green-200 text-green-800";case"cancelled":return"bg-red-200 text-red-800";default:return"bg-gray-200 text-gray-800"}},gr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Ba({data:e}){let{id:t,system:o,fetchLatest:a,taskData:n,error:i}=e||{};if(!t)return null;let r=null,s=!0,c=i,m=a!==void 0?a:!0;if(r=n||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:a,system:o,fetchLatest:m,taskData:r,error:c}),m){let{task:R,loading:A,error:T}=Aa({taskId:t,system:o});r=R,s=A,c=T}else s=!1;let w=ur(r?.status||"todo"),f=gr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let R=new Date(r?.dateLogged||"");isNaN(R.getTime())||(y=(0,Ia.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Lo.jsxs)(ge,{className:l("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Lo.jsxs)(Le,{className:"pb-2",children:[(0,Lo.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Lo.jsx)(Ee,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,Lo.jsx)(ae,{className:`${w}`,children:f})]}),r?.project&&(0,Lo.jsxs)(co,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,Lo.jsx)(Pe,{className:"pb-2",children:s?(0,Lo.jsx)("div",{className:"animate-pulse Lo-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Lo.jsx)("Lo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Lo.jsx)("Lo",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,Lo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Lo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Lo.jsx)(Wa.Clock,{className:"Lo-3 w-3 mr-1"}),(0,Lo.jsxs)("span",{children:["Created ",y]}),(0,Lo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Lo.jsxs)("span",{children:["Task #",t]})]})})]})}function za({artefact:e,taskId:t,taskData:o,loading:a=!1,error:n=null}){let i=o||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},r=i.dateLogged;try{let s=new Date(i.dateLogged);isNaN(s.getTime())||(r=(0,Ia.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,Lo.jsxs)(ge,{className:"w-full max-w-md shadow-md",children:[(0,Lo.jsx)(Le,{className:"pb-2",children:(0,Lo.jsx)("div",{className:"flex justify-between items-start",children:(0,Lo.jsx)(Ee,{className:"text-lg font-semibold",children:a?"Loading...":i.name})})}),(0,Lo.jsx)(Pe,{className:"pb-2",children:a?(0,Lo.jsx)("div",{className:"animate-pulse Lo-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,Lo.jsx)("Lo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Lo.jsx)("Lo",{className:"text-sm text-foreground",children:e})}),(0,Lo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Lo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Lo.jsx)(Wa.Clock,{className:"Lo-3 w-3 mr-1"}),(0,Lo.jsxs)("span",{children:["Created ",r]}),(0,Lo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Lo.jsxs)("span",{children:["Task #",i.id]})]})})]})}var fr=e=>e.startsWith("image/")?(0,Lo.jsx)(Wa.Image,{className:"Lo-4 w-4"}):e.startsWith("text/")?(0,Lo.jsx)(Wa.FileText,{className:"Lo-4 w-4"}):(0,Lo.jsx)(Wa.File,{className:"Lo-4 w-4"}),Ua=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,Lo.jsx)(yt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,Lo.jsx)("div",{className:"mb-2 Lo-2 bg-background/50 rounded-lg",children:(0,Lo.jsxs)("div",{className:"flex items-center gap-2",children:[fr(r.mediaType||"application/octet-stream"),(0,Lo.jsx)("div",{className:"flex-1 min-w-0",children:(0,Lo.jsx)("Lo",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"Lo-8 w-8 Lo-0",children:(0,Lo.jsx)(Wa.Download,{className:"Lo-4 w-4"})})]})},i)}if(n.type.startsWith("tool-")){let r=n,s=n.type.replace("tool-","");if(s==="task")switch(r.state){case"input-available":return(0,Lo.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(Ba,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return console.log("Rendering PartApprovalTool with toolPart:",r),(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(ya,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,Lo.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(za,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,Lo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Lo.jsxs)(Pe,{children:[r.state==="input-available"&&(0,Lo.jsxs)("Lo",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,Lo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,Lo.jsxs)("Lo",{className:"text-sm text-red-500",children:["Error: ",r.errorText]})]})]})},i)}if(n.type.startsWith("data-")){let r=n,s=n.type.replace("data-","");return s==="reference"?(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsx)(ge,{className:"w-full",children:(0,Lo.jsx)(Pe,{className:"Lo-4",children:(0,Lo.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,Lo.jsxs)("div",{className:"flex items-center gap-2 Lo-2 rounded-md bg-muted/50",children:[(0,Lo.jsx)(ae,{variant:"outline",children:c.type||"link"}),(0,Lo.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Lo.jsx)("Lo",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Lo.jsx)("Lo",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"Lo-8 w-8 Lo-0",children:(0,Lo.jsx)(Wa.ExternalLink,{className:"Lo-4 w-4"})})]},m))})})})},i):s==="menu"?(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:r.data?.title})}),(0,Lo.jsx)(Pe,{children:(0,Lo.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,Lo.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Lo.jsxs)("div",{className:"text-left",children:[(0,Lo.jsx)("Lo",{className:"font-medium",children:c.label}),c.description&&(0,Lo.jsx)("Lo",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,Lo.jsx)("div",{className:"mb-2",children:(0,Lo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Lo.jsx)(Le,{children:(0,Lo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Lo.jsx)(Pe,{children:(0,Lo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}if(n.type==="reasoning")return(0,Lo.jsxs)(bo,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.at(-1)?.id,children:[(0,Lo.jsx)(vo,{}),(0,Lo.jsx)(ho,{children:n.text})]},`${i}`);if(n.type==="dynamic-tool")return(0,Lo.jsxs)(Pa,{defaultOpen:n.state!=="output-available",children:[(0,Lo.jsx)(Ta,{type:`tool-${n.toolName}`,state:n.state}),(0,Lo.jsxs)(Da,{children:[(0,Lo.jsx)(Ra,{input:n.input}),(0,Lo.jsx)(Sa,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`)});var Ha=({className:e,from:t,...o})=>(0,Lo.jsx)("div",{className:l("group flex w-full items-end justify-end gap-2 py-4",t==="user"?"is-user":"is-assistant flex-row-reverse justify-end",e),...o}),br=(0,Bo.cva)("is-user:dark flex flex-col gap-2 overflow-hidden rounded-lg text-sm",{variants:{variant:{contained:["max-w-[80%] px-4 py-3","group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground","group-[.is-assistant]:bg-secondary group-[.is-assistant]:text-foreground"],flat:["group-[.is-user]:max-w-[80%] group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground","group-[.is-assistant]:text-foreground"]}},defaultVariants:{variant:"contained"}}),ja=({children:e,className:t,variant:o,...a})=>(0,Lo.jsx)("div",{className:l(br({variant:o,className:t})),...a,children:e});function Oa({messages:e,input:t,isTyping:o=!1,currentSessionTitle:a,capabilities:n,fileUploads:i,isDragOver:r,enableFileUpload:s,onInputChange:c,addToolResult:m,onSendMessage:w,onKeyPress:f,onFileUpload:y,onRemoveFile:R,onDragOver:A,className:T,status:C="ready"}){let N=(0,$a.useRef)(null),H=(0,$a.useRef)(null),S=(0,$a.useRef)(null),[M,_]=(0,$a.useState)(!1),[$,se]=(0,$a.useState)({path:[],selectedItems:[],filters:{}});(0,$a.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,$a.useEffect)(()=>{M&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[M]);let J=()=>po($),W=()=>{let u=[];return n.forEach(U=>{U.actions&&U.actions.forEach(ve=>{u.push({label:ve.label,action:()=>X(ve.id,{path:[U],selectedItems:[],filters:{}})})}),U.children&&U.children.forEach(ve=>{ve.type==="list"&&ve.data&&u.push({label:`View ${ve.name}`,action:()=>_(!0)})})}),u.slice(0,5)},X=(u,U)=>{console.log("Capability action:",u,U);let ve=`Executing ${u} with context: ${JSON.stringify(U.path.map(Ae=>Ae.name))}`;_(!1)},le=po({path:[],selectedItems:[],filters:{}}),I=u=>{y(u.target.files),u.target.files&&(u.target.value="")},Se=u=>{u.preventDefault(),A(!0)},d=u=>{u.preventDefault(),A(!1)},L=u=>{u.preventDefault(),A(!1),y(u.dataTransfer.files)},E=u=>{if(u===0)return"0 Bytes";let U=1024,ve=["Bytes","KB","MB","GB"],Ae=Math.floor(Math.log(u)/Math.log(U));return parseFloat((u/Math.pow(U,Ae)).toFixed(2))+" "+ve[Ae]},G=u=>u.startsWith("image/")?(0,Lo.jsx)(Wa.Image,{className:"Lo-4 w-4"}):u.startsWith("text/")?(0,Lo.jsx)(Wa.FileText,{className:"Lo-4 w-4"}):(0,Lo.jsx)(Wa.File,{className:"Lo-4 w-4"}),Z={messages:e,currentSessionTitle:a,capabilities:n,currentCapabilityContext:$,contextualActions:le,getQuickSuggestions:W().map(u=>u.label)},be=()=>{navigator.clipboard.writeText(JSON.stringify(Z,null,2)),alert("Debug info copied to clipboard")};return(0,Lo.jsxs)("div",{className:`Lo-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,Lo.jsxs)(Ce,{ref:H,className:"flex-1 Lo-4 bg-background border-0",onDragOver:Se,onDragLeave:d,onDrop:L,children:[(0,Lo.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Lo.jsx)(lt.animate,{children:e.map(u=>(0,Lo.jsx)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Lo.jsx)(Ha,{from:u.role,children:(0,Lo.jsx)(ja,{variant:"flat",children:Ua({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),M&&(0,Lo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Lo.jsx)(et,{className:"Lo-8 w-8",children:(0,Lo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Lo.jsx)(Wa.Bot,{className:"Lo-4 w-4"})})}),(0,Lo.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Lo.jsx)(ga,{capabilities:n,isOpen:M,onToggle:()=>_(!M),onActionSelect:X,className:"w-full"})})]}),o&&(0,Lo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Lo.jsx)(et,{className:"Lo-8 w-8",children:(0,Lo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Lo.jsx)(Wa.Bot,{className:"Lo-4 w-4"})})}),(0,Lo.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Lo.jsxs)("div",{className:"flex space-x-1",children:[(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Lo.jsx)("div",{className:"w-2 Lo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Lo.jsx)("div",{ref:N})]}),i.length>0&&(0,Lo.jsx)("div",{className:"Lo-4 border-t bg-muted/10",children:(0,Lo.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,Lo.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Lo-2 border",children:[G(u.file.type),(0,Lo.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Lo.jsx)("span",{className:"text-xs text-muted-foreground",children:E(u.file.size)}),(0,Lo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"Lo-6 w-6 Lo-0",children:(0,Lo.jsx)(Wa.X,{className:"Lo-4 w-4"})})]},u.id))})}),(0,Lo.jsxs)("div",{className:"border rounded-2xl Lo-4 bg-muted/20",children:[(0,Lo.jsxs)("div",{className:"flex gap-3",children:[(0,Lo.jsx)(gt,{value:t,onChange:u=>c(u.target.value),onKeyPress:f,placeholder:"How can I help you today?",className:"flex-1 rounded-2xl bg-background shadow-sm",disabled:o}),s&&(0,Lo.jsx)(D,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl Lo-10 w-10 shadow-sm",children:(0,Lo.jsx)(Wa.Paperclip,{className:"Lo-4 w-4"})}),(0,Lo.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl Lo-10 w-10 shadow-sm",children:(0,Lo.jsx)(Wa.Send,{className:"Lo-4 w-4"})})]}),(0,Lo.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Lo.jsxs)(D,{onClick:()=>_(!M),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Lo.jsx)(Wa.Menu,{className:"Lo-3 w-3 mr-1"}),M?"Hide":"Show"," Capabilities"]}),(0,Lo.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,Lo.jsx)(D,{variant:"default",size:"sm",className:"rounded-full text-xs bg-accent hover:bg-accent/80",onClick:()=>X(u.id,$),children:u.label},`context-${u.id}`)),J().length===0&&W().map((u,U)=>(0,Lo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,Lo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,Lo.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:I,className:"hidden"})]})]})}function Ga({aiConfig:e,useCustomChat:t,enableAI:o=!0,messages:a=[],businessUnits:n=[],capabilities:i=[],sidebarItems:r=[],notifications:s=[],sessions:c=[],onNewChat:m,onSessionSelect:w,onSessionDelete:f,onSessionEdit:y=()=>{},onBusinessUnitChange:R=()=>{},onNotificationRemove:A=()=>{},onRemoveAll:T=()=>{},onActionClick:C=()=>{},onSearch:N=L=>console.log("Search query:",L),initialTeam:H="design",currentSession:S=null,showCapabilities:M=!0,title:_="Digital Colleagues",enableFileUpload:$=!0,maxFileSize:se=10,allowedFileTypes:J=["image/*","text/*","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],logo:W="/headerlogo.png",appName:X="Nuvia",tagline:le="AI-Powered Workspace",actionIcon:I=(0,Lo.jsx)(Wa.Users,{className:"mr-2 Lo-4 w-4"}),actionText:Se="Collaborate",sidebarInitiallyClosed:d=!1}){let L={...e,onError:F=>{G?.setMessages(ce=>[...ce,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:F.message}]}]),console.error("Error in CopilotInterface:",F)}},E=(0,Va.useChat)(L||{}),G=o?t||E:null,[Z,be]=(0,$a.useState)(""),[u,U]=(0,$a.useState)(!1),ve=G?.messages||a,Ae=Z,qa=G?.status==="submitted"||u,Ka=G?.addToolResult?(F,ce,ee)=>{G.addToolResult({tool:ce,toolCallId:F,output:ee}),console.log("Tool result added:",{toolCallId:F,tool:ce,output:ee}),G.sendMessage()}:()=>{console.log("addToolResult not available")},dt=n||[],_a={id:"default",name:"Default Team",description:"Default team when no business units are available",icon:"\u{1F3E2}",color:"bg-gray-500",accentColor:"bg-gray-600"},[Ja,Xa]=(0,$a.useState)(()=>dt.length===0?_a:dt.find(F=>F.id===H)||dt[0]),[pt,xt]=(0,$a.useState)([]),[Qa,Ya]=(0,$a.useState)(!1),Za=F=>{if(!F||!$)return;let ce=[];Array.from(F).forEach(ee=>{if(ee.size>se*1024*1024){alert(`File ${ee.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>ee.type.match(wt))){alert(`File type ${ee.type} is not allowed.`);return}let Co={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ee,status:"pending",progress:0};if(ee.type.startsWith("image/")){let wt=new FileReader;wt.onload=ii=>{xt(ri=>ri.map($t=>$t.id===Co.id?{...$t,preview:ii.target?.result}:$t))},wt.readAsDataURL(ee)}ce.push(Co)}),xt(ee=>[...ee,...ce])},ei=F=>{xt(ce=>ce.filter(ee=>ee.id!==F))},wo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let F=pt.length>0?ti(pt.map(ce=>ce.file)):void 0;G.sendMessage({text:Ae,files:F},{body:{timestamp:Date.now()}}),be("")}else console.log("Message to send:",Ae),console.log("Files to upload:",pt),be(""),U(!0),setTimeout(()=>{U(!1)},1500);xt([])}},ti=F=>{let ce=new DataTransfer;return F.forEach(ee=>ce.items.add(ee)),ce.files},oi=F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),wo())},ai=F=>{be(F)};return(0,Lo.jsx)(da,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:Ja,onBusinessUnitChange:F=>{F&&(Xa(F),R?.(F))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:I,actionText:Se,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,Lo.jsx)(Gt.AnimatePresence,{mode:"wait",children:(0,Lo.jsx)(Gt.motion.div,{className:"flex-1 Lo-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,Lo.jsxs)("div",{className:"Lo-full flex",children:[(0,Lo.jsx)("div",{className:"w-80 flex-shrink-0 Lo-full Lo-2",children:(0,Lo.jsx)(pa,{sessions:c||[],currentSession:S,teams:dt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,Lo.jsx)("div",{className:"flex-1 Lo-full Lo-2",children:(0,Lo.jsx)(Oa,{messages:ve||[],input:Ae,isTyping:qa,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:ai,addToolResult:Ka,onSendMessage:wo,onKeyPress:oi,fileUploads:pt,isDragOver:Qa,enableFileUpload:$,onFileUpload:Za,onRemoveFile:ei,onDragOver:Ya})})]})},"chat-interface")})})}var vr=[{id:"1",role:"user",parts:[{type:"text",text:"Hello! Can you help me with a task?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:"Of course! I can help you with various tasks. Try uploading a file or use the capabilities menu at the bottom to see what I can do."}]}];function hr(){let[e,t]=(0,$a.useState)(vr);return(0,Lo.jsx)("div",{className:"Lo-screen w-full",children:(0,Lo.jsx)(Ga,{messages:e,capabilities:ua,enableFileUpload:!0,maxFileSize:10,allowedFileTypes:["*"],businessUnits:[],sessions:[],notifications:[],onNewChat:()=>t([]),onSessionSelect:()=>{},onSessionDelete:()=>{},showCapabilities:!0})})}0&&(module.exports={ChatDemo});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"../../chunk-
|
|
1
|
+
import{a as s}from"../../chunk-JSHD7QTU.mjs";import"../../chunk-CTTBF7F4.mjs";import"../../chunk-56X4PU43.mjs";import"../../chunk-WAVVCASZ.mjs";import"../../chunk-347B45ZS.mjs";import"../../chunk-WRZP5K5X.mjs";import"../../chunk-V5VE3EIY.mjs";import"../../chunk-6OCLRAHU.mjs";import"../../chunk-5Y6FKL5W.mjs";import"../../chunk-EW6KWAHS.mjs";import"../../chunk-7JDMW5R3.mjs";import"../../chunk-6OT5PQXV.mjs";import"../../chunk-YPZAYXNQ.mjs";import"../../chunk-7TSR2LQB.mjs";import"../../chunk-QM5FOQHG.mjs";import"../../chunk-UA2E23AS.mjs";import"../../chunk-2LINLX4S.mjs";import"../../chunk-RL6365DN.mjs";import"../../chunk-LTTO57ZK.mjs";import"../../chunk-4WA47ZQA.mjs";import"../../chunk-NPVUICIF.mjs";import"../../chunk-VDN4LQSS.mjs";import"../../chunk-FGEFYI5E.mjs";import"../../chunk-MU5WPW4N.mjs";import"../../chunk-AZKOVKSK.mjs";import{b as e}from"../../chunk-Q2DPE66H.mjs";import"../../chunk-INCYANPB.mjs";import"../../chunk-RLVKIMGU.mjs";import"../../chunk-OCPX4QPC.mjs";import"../../chunk-FT3AE7L2.mjs";import"../../chunk-3UMMMQEH.mjs";import"../../chunk-YNCJATT7.mjs";import"../../chunk-L5JPAKPM.mjs";import"../../chunk-KY7WQYN4.mjs";import"../../chunk-ZUA4KNIR.mjs";import"../../chunk-SOLZ4VQH.mjs";import"../../chunk-CSBGSBEU.mjs";import"../../chunk-YO3GQYRJ.mjs";import"../../chunk-EGEO3FNE.mjs";import"../../chunk-MDJREBVI.mjs";import"../../chunk-ZWHGOTSF.mjs";import"../../chunk-Q3G5UAAD.mjs";import"../../chunk-XGRRLABA.mjs";import"../../chunk-FLHDNCNY.mjs";import"../../chunk-YEKQJ4YC.mjs";import{useState as o}from"react";import{jsx as t}from"react/jsx-runtime";var l=[{id:"1",role:"user",parts:[{type:"text",text:"Hello! Can you help me with a task?"}]},{id:"2",role:"assistant",parts:[{type:"text",text:"Of course! I can help you with various tasks. Try uploading a file or use the capabilities menu at the bottom to see what I can do."}]}];function u(){let[a,i]=o(l);return t("div",{className:"h-screen w-full",children:t(s,{messages:a,capabilities:e,enableFileUpload:!0,maxFileSize:10,allowedFileTypes:["*"],businessUnits:[],sessions:[],notifications:[],onNewChat:()=>i([]),onSessionSelect:()=>{},onSessionDelete:()=>{},showCapabilities:!0})})}export{u as ChatDemo};
|