cortex-react-components 2.18.0 → 2.18.1
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-WIRQ5IRT.mjs → chunk-2GM2LPLB.mjs} +1 -1
- package/dist/{chunk-3HNU2NYP.mjs → chunk-2OOJ4ZFB.mjs} +1 -1
- package/dist/{chunk-ZEALRBXW.mjs → chunk-3ANJOET7.mjs} +1 -1
- package/dist/{chunk-7R47MHQE.mjs → chunk-4SRUEQTP.mjs} +1 -1
- package/dist/{chunk-3ZQFJ5WD.mjs → chunk-5KO67YNF.mjs} +1 -1
- package/dist/{chunk-UECG3SCG.mjs → chunk-5PJLI46T.mjs} +1 -1
- package/dist/{chunk-ITJH72Z2.mjs → chunk-75WE6ZXB.mjs} +1 -1
- package/dist/chunk-7JDMW5R3.mjs +4 -0
- package/dist/{chunk-7IARWH7M.mjs → chunk-7JX3L2MA.mjs} +1 -1
- package/dist/{chunk-CXOVEABI.mjs → chunk-7OMPPFGG.mjs} +1 -1
- package/dist/{chunk-75F3LJMX.mjs → chunk-BQQ4V4PX.mjs} +1 -1
- package/dist/{chunk-V6GK2FJG.mjs → chunk-CQAMS7RZ.mjs} +1 -1
- package/dist/{chunk-LX3D4J7I.mjs → chunk-DEVPAZSJ.mjs} +1 -1
- package/dist/{chunk-GHOL5L32.mjs → chunk-F64CA5CH.mjs} +1 -1
- package/dist/{chunk-3Y7QG6VP.mjs → chunk-FEWOSBUJ.mjs} +1 -1
- package/dist/{chunk-TTWEHUP5.mjs → chunk-FMV74RKL.mjs} +1 -1
- package/dist/{chunk-2BRDNDUB.mjs → chunk-FYQBRCQM.mjs} +1 -1
- package/dist/{chunk-RJGYVDOU.mjs → chunk-GAZHKHGB.mjs} +1 -1
- package/dist/{chunk-RGOKBIQ5.mjs → chunk-GETYSIZV.mjs} +1 -1
- package/dist/{chunk-3NRXQBBS.mjs → chunk-HDKHF3EA.mjs} +1 -1
- package/dist/{chunk-6R6NYDWN.mjs → chunk-HGL6JHJQ.mjs} +1 -1
- package/dist/{chunk-C4RWEPVF.mjs → chunk-HKMNAXLM.mjs} +1 -1
- package/dist/{chunk-TKCFCYEQ.mjs → chunk-HSQAHQNP.mjs} +1 -1
- package/dist/{chunk-WHDV4REI.mjs → chunk-IG36QUEI.mjs} +1 -1
- package/dist/{chunk-5EQXJS23.mjs → chunk-JYPPWTB3.mjs} +1 -1
- package/dist/{chunk-PWFVXG44.mjs → chunk-KVLUT4U2.mjs} +1 -1
- package/dist/{chunk-L5NPH5RX.mjs → chunk-LLP4EFT4.mjs} +1 -1
- package/dist/{chunk-5MWZTJYP.mjs → chunk-MO4HRQEL.mjs} +1 -1
- package/dist/{chunk-KWYJ3XZI.mjs → chunk-O24GFE6Q.mjs} +1 -1
- package/dist/{chunk-GTZJWMZR.mjs → chunk-P6OSMPUQ.mjs} +1 -1
- package/dist/{chunk-FE7ZGUPU.mjs → chunk-PNUBVBSR.mjs} +1 -1
- package/dist/{chunk-AJQHGVZ5.mjs → chunk-PTZT4QJW.mjs} +1 -1
- package/dist/chunk-QADUAIFH.mjs +1 -0
- package/dist/{chunk-D6K6RO5P.mjs → chunk-R5P4ZICA.mjs} +1 -1
- package/dist/{chunk-EM3T2XYC.mjs → chunk-R6AYIVIR.mjs} +1 -1
- package/dist/{chunk-P55W6AFU.mjs → chunk-RIRZRO6U.mjs} +1 -1
- package/dist/{chunk-TXVA6XJT.mjs → chunk-SRUG246N.mjs} +1 -1
- package/dist/{chunk-RSDUFAIB.mjs → chunk-T5HJS6OF.mjs} +1 -1
- package/dist/{chunk-NINFDOV5.mjs → chunk-U3FYDDE2.mjs} +1 -1
- package/dist/chunk-UA2E23AS.mjs +4 -0
- package/dist/{chunk-X3JZSN3W.mjs → chunk-UZSBX5GO.mjs} +1 -1
- package/dist/{chunk-6PS55VJZ.mjs → chunk-VDFRWGXR.mjs} +1 -1
- package/dist/{chunk-XGIYNUGC.mjs → chunk-VNYUNZ3M.mjs} +1 -1
- package/dist/{chunk-2BR55L74.mjs → chunk-VRE6VCHX.mjs} +1 -1
- package/dist/{chunk-L3BLBPSR.mjs → chunk-WUA65ZZB.mjs} +1 -1
- package/dist/{chunk-HUYTXZLC.mjs → chunk-WYLCN44C.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/CodeBlock.js +1 -1
- package/dist/components/Chat/PartTypes/CodeBlock.mjs +1 -1
- package/dist/components/Chat/PartTypes/MessageHandler.js +3 -3
- package/dist/components/Chat/PartTypes/MessageHandler.mjs +1 -1
- package/dist/components/Chat/PartTypes/Tool.js +1 -1
- package/dist/components/Chat/PartTypes/Tool.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/Pages/dashboardpage.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/Views/KnowledgeView.mjs +1 -1
- package/dist/components/Foundary/Views/index.mjs +1 -1
- package/dist/components/Foundary/index.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/Projects/EpicsView.mjs +1 -1
- package/dist/components/Projects/KanbanBoardView.mjs +1 -1
- package/dist/components/Projects/ProjectPage.mjs +1 -1
- package/dist/components/Projects/ProjectView.mjs +1 -1
- package/dist/components/Projects/ProjectsIndexView.mjs +1 -1
- package/dist/components/Projects/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/form/index.mjs +1 -1
- package/dist/sections/index.mjs +1 -1
- package/package.json +4 -4
- package/dist/chunk-GXRWKWKJ.mjs +0 -1
- package/dist/chunk-UGBDJDPW.mjs +0 -4
- package/dist/chunk-ZN7NNMB7.mjs +0 -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 w-full 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 rounded-md border",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",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(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)}return n.type==="reasoning"?(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}`):n.type==="dynamic-tool"?(0,Lo.jsxs)(Pa,{defaultOpen:!0,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}`):(0,Lo.jsxs)(Lo.Fragment,{children:["Unknown part type: ",n.type]})});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),F=(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:F,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:F="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:H=>{G?.setMessages(de=>[...de,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:H.message}]}]),console.error("Error in CopilotInterface:",H)}},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?(H,de,oe)=>{G.addToolResult({tool:de,toolCallId:H,output:oe}),G.sendMessage()}:()=>{},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(H=>H.id===F)||dt[0]),[pt,xt]=(0,$a.useState)([]),[Qa,Ya]=(0,$a.useState)(!1),Za=H=>{if(!H||!$)return;let de=[];Array.from(H).forEach(oe=>{if(oe.size>se*1024*1024){alert(`File ${oe.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>oe.type.match(wt))){alert(`File type ${oe.type} is not allowed.`);return}let Co={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:oe,status:"pending",progress:0};if(oe.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(oe)}de.push(Co)}),xt(oe=>[...oe,...de])},ei=H=>{xt(de=>de.filter(oe=>oe.id!==H))},wo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let H=pt.length>0?ti(pt.map(de=>de.file)):void 0;G.sendMessage({text:Ae,files:H},{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=H=>{let de=new DataTransfer;return H.forEach(oe=>de.items.add(oe)),de.files},oi=H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),wo())},ai=H=>{be(H)};return(0,Lo.jsx)(da,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:Ja,onBusinessUnitChange:H=>{H&&(Xa(H),R?.(H))},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.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(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)}return n.type==="reasoning"?(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}`):n.type==="dynamic-tool"?(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}`):(0,Lo.jsxs)(Lo.Fragment,{children:["Unknown part type: ",n.type]})});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),F=(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:F,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:F="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:H=>{G?.setMessages(de=>[...de,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:H.message}]}]),console.error("Error in CopilotInterface:",H)}},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?(H,de,oe)=>{G.addToolResult({tool:de,toolCallId:H,output:oe}),G.sendMessage()}:()=>{},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(H=>H.id===F)||dt[0]),[pt,xt]=(0,$a.useState)([]),[Qa,Ya]=(0,$a.useState)(!1),Za=H=>{if(!H||!$)return;let de=[];Array.from(H).forEach(oe=>{if(oe.size>se*1024*1024){alert(`File ${oe.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>oe.type.match(wt))){alert(`File type ${oe.type} is not allowed.`);return}let Co={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:oe,status:"pending",progress:0};if(oe.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(oe)}de.push(Co)}),xt(oe=>[...oe,...de])},ei=H=>{xt(de=>de.filter(oe=>oe.id!==H))},wo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let H=pt.length>0?ti(pt.map(de=>de.file)):void 0;G.sendMessage({text:Ae,files:H},{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=H=>{let de=new DataTransfer;return H.forEach(oe=>de.items.add(oe)),de.files},oi=H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),wo())},ai=H=>{be(H)};return(0,Lo.jsx)(da,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:Ja,onBusinessUnitChange:H=>{H&&(Xa(H),R?.(H))},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-7JX3L2MA.mjs";import"../../chunk-CTTBF7F4.mjs";import"../../chunk-56X4PU43.mjs";import"../../chunk-DEVPAZSJ.mjs";import"../../chunk-QADUAIFH.mjs";import"../../chunk-EH3PJU6C.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};
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
`,children:r?"Processing...":"Deny"}),(0,kt.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 ka=({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,kt.jsxs)("div",{className:"mb-2",children:[(0,kt.jsx)(Na,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,kt.jsxs)(kt.Fragment,{children:[i==="approve"&&(0,kt.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,kt.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,kt.jsx)("svg",{className:"kt-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,kt.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,kt.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,kt.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,kt.jsx)("svg",{className:"kt-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,kt.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,kt.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 st=V(require("@radix-ui/react-collapsible")),zt=st.Root,Ut=st.CollapsibleTrigger,Ft=st.CollapsibleContent;var Ta=require("streamdown"),yt=(0,ot.memo)(({className:e,...t})=>(0,kt.jsx)(Ta.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 Ra=(0,ot.createContext)(null),sr=()=>{let e=(0,ot.useContext)(Ra);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},lr=1e3,cr=1e3,bo=(0,ot.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,ot.useState)(!1),[A,T]=(0,ot.useState)(null);(0,ot.useEffect)(()=>{t?A===null&&T(Date.now()):A!==null&&(f(Math.ceil((Date.now()-A)/cr)),T(null))},[t,A,f]),(0,ot.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,kt.jsx)(Ra.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,kt.jsx)(zt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),dr=(e,t)=>e||t===0?(0,kt.jsx)("kt",{children:"Thinking..."}):t===void 0?(0,kt.jsx)("kt",{children:"Thought for a few seconds"}):(0,kt.jsxs)("kt",{children:["Thought for ",t," seconds"]}),vo=(0,ot.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=sr();return(0,kt.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,kt.jsxs)(kt.Fragment,{children:[(0,kt.jsx)(Eo.BrainIcon,{className:"size-4"}),dr(a,i),(0,kt.jsx)(Eo.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),ho=(0,ot.memo)(({className:e,children:t,...o})=>(0,kt.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,kt.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,ot.createContext)({code:""}),Vt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,kt.jsx)(pr.Provider,{value:{code:e},children:(0,kt.jsx)("div",{className:l("relative w-full overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,kt.jsxs)("div",{className:"relative",children:[(0,kt.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,kt.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,kt.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Aa=({className:e,...t})=>(0,kt.jsx)(zt,{className:l("not-prose mb-4 w-full rounded-md border",e),...t}),mr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,kt.jsxs)(ae,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,kt.jsx)(Eo.CircleIcon,{className:"size-4"}),"input-available":(0,kt.jsx)(Eo.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,kt.jsx)(Eo.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,kt.jsx)(Eo.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Ia=({className:e,type:t,state:o,...a})=>(0,kt.jsxs)(Ut,{className:l("flex w-full items-center justify-between gap-4 kt-3",e),...a,children:[(0,kt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,kt.jsx)(Eo.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,kt.jsx)("span",{className:"font-medium text-sm",children:t}),mr(o)]}),(0,kt.jsx)(Eo.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Ma=({className:e,...t})=>(0,kt.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}),Ba=({className:e,input:t,...o})=>(0,kt.jsxs)("div",{className:l("space-y-2 overflow-hidden kt-4",e),...o,children:[(0,kt.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,kt.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,kt.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"})})]}),La=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,kt.jsx)("div",{children:t});return typeof t=="object"?n=(0,kt.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,kt.jsx)(Vt,{code:t,language:"json"})),(0,kt.jsxs)("div",{className:l("space-y-2 kt-4",e),...a,children:[(0,kt.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,kt.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,kt.jsx)("div",{children:o}),n]})]})};var ur=e=>e.startsWith("image/")?(0,kt.jsx)(Eo.Image,{className:"kt-4 w-4"}):e.startsWith("text/")?(0,kt.jsx)(Eo.FileText,{className:"kt-4 w-4"}):(0,kt.jsx)(Eo.File,{className:"kt-4 w-4"}),Ea=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,kt.jsx)(yt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,kt.jsx)("div",{className:"mb-2 kt-2 bg-background/50 rounded-lg",children:(0,kt.jsxs)("div",{className:"flex items-center gap-2",children:[ur(r.mediaType||"application/octet-stream"),(0,kt.jsx)("div",{className:"flex-1 min-w-0",children:(0,kt.jsx)("kt",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,kt.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"kt-8 w-8 kt-0",children:(0,kt.jsx)(Eo.Download,{className:"kt-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,kt.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(Uo,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,kt.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(ka,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,kt.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(Vo,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,kt.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsxs)(me,{className:"w-full max-w-md",children:[(0,kt.jsx)(Be,{children:(0,kt.jsx)(Le,{className:"text-lg",children:s})}),(0,kt.jsxs)(Ce,{children:[r.state==="input-available"&&(0,kt.jsxs)("kt",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,kt.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,kt.jsxs)("kt",{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,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(me,{className:"w-full",children:(0,kt.jsx)(Ce,{className:"kt-4",children:(0,kt.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,kt.jsxs)("div",{className:"flex items-center gap-2 kt-2 rounded-md bg-muted/50",children:[(0,kt.jsx)(ae,{variant:"outline",children:c.type||"link"}),(0,kt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,kt.jsx)("kt",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,kt.jsx)("kt",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,kt.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"kt-8 w-8 kt-0",children:(0,kt.jsx)(Eo.ExternalLink,{className:"kt-4 w-4"})})]},m))})})})},i):s==="menu"?(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsxs)(me,{className:"w-full",children:[(0,kt.jsx)(Be,{children:(0,kt.jsx)(Le,{className:"text-lg",children:r.data?.title})}),(0,kt.jsx)(Ce,{children:(0,kt.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,kt.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,kt.jsxs)("div",{className:"text-left",children:[(0,kt.jsx)("kt",{className:"font-medium",children:c.label}),c.description&&(0,kt.jsx)("kt",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsxs)(me,{className:"w-full max-w-md",children:[(0,kt.jsx)(Be,{children:(0,kt.jsx)(Le,{className:"text-lg",children:s})}),(0,kt.jsx)(Ce,{children:(0,kt.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}return n.type==="reasoning"?(0,kt.jsxs)(bo,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.at(-1)?.id,children:[(0,kt.jsx)(vo,{}),(0,kt.jsx)(ho,{children:n.text})]},`${i}`):n.type==="dynamic-tool"?(0,kt.jsxs)(Aa,{defaultOpen:!0,children:[(0,kt.jsx)(Ia,{type:`tool-${n.toolName}`,state:n.state}),(0,kt.jsxs)(Ma,{children:[(0,kt.jsx)(Ba,{input:n.input}),(0,kt.jsx)(La,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`):(0,kt.jsxs)(kt.Fragment,{children:["Unknown part type: ",n.type]})});var Ua=({className:e,from:t,...o})=>(0,kt.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}),gr=(0,Mo.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"}}),Fa=({children:e,className:t,variant:o,...a})=>(0,kt.jsx)("div",{className:l(gr({variant:o,className:t})),...a,children:e});function ja({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,ot.useRef)(null),F=(0,ot.useRef)(null),S=(0,ot.useRef)(null),[I,_]=(0,ot.useState)(!1),[$,se]=(0,ot.useState)({path:[],selectedItems:[],filters:{}});(0,ot.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,ot.useEffect)(()=>{I&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[I]);let J=()=>Yt($),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=Yt({path:[],selectedItems:[],filters:{}}),M=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,kt.jsx)(Eo.Image,{className:"kt-4 w-4"}):u.startsWith("text/")?(0,kt.jsx)(Eo.FileText,{className:"kt-4 w-4"}):(0,kt.jsx)(Eo.File,{className:"kt-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,kt.jsxs)("div",{className:`kt-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,kt.jsxs)(Ne,{ref:F,className:"flex-1 kt-4 bg-background border-0",onDragOver:Se,onDragLeave:d,onDrop:L,children:[(0,kt.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,kt.jsx)(lt.animate,{children:e.map(u=>(0,kt.jsx)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,kt.jsx)(Ua,{from:u.role,children:(0,kt.jsx)(Fa,{variant:"flat",children:Ea({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),I&&(0,kt.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,kt.jsx)(et,{className:"kt-8 w-8",children:(0,kt.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,kt.jsx)(Eo.Bot,{className:"kt-4 w-4"})})}),(0,kt.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,kt.jsx)(ya,{capabilities:n,isOpen:I,onToggle:()=>_(!I),onActionSelect:X,className:"w-full"})})]}),o&&(0,kt.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,kt.jsx)(et,{className:"kt-8 w-8",children:(0,kt.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,kt.jsx)(Eo.Bot,{className:"kt-4 w-4"})})}),(0,kt.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,kt.jsxs)("div",{className:"flex space-x-1",children:[(0,kt.jsx)("div",{className:"w-2 kt-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,kt.jsx)("div",{className:"w-2 kt-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,kt.jsx)("div",{className:"w-2 kt-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,kt.jsx)("div",{ref:N})]}),i.length>0&&(0,kt.jsx)("div",{className:"kt-4 border-t bg-muted/10",children:(0,kt.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,kt.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg kt-2 border",children:[G(u.file.type),(0,kt.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,kt.jsx)("span",{className:"text-xs text-muted-foreground",children:E(u.file.size)}),(0,kt.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"kt-6 w-6 kt-0",children:(0,kt.jsx)(Eo.X,{className:"kt-4 w-4"})})]},u.id))})}),(0,kt.jsxs)("div",{className:"border rounded-2xl kt-4 bg-muted/20",children:[(0,kt.jsxs)("div",{className:"flex gap-3",children:[(0,kt.jsx)(ft,{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,kt.jsx)(D,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl kt-10 w-10 shadow-sm",children:(0,kt.jsx)(Eo.Paperclip,{className:"kt-4 w-4"})}),(0,kt.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl kt-10 w-10 shadow-sm",children:(0,kt.jsx)(Eo.Send,{className:"kt-4 w-4"})})]}),(0,kt.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,kt.jsxs)(D,{onClick:()=>_(!I),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,kt.jsx)(Eo.Menu,{className:"kt-3 w-3 mr-1"}),I?"Hide":"Show"," Capabilities"]}),(0,kt.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,kt.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,kt.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,kt.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,kt.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:M,className:"hidden"})]})]})}function Va({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:F="design",currentSession:S=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,kt.jsx)(Eo.Users,{className:"mr-2 kt-4 w-4"}),actionText:Se="Collaborate",sidebarInitiallyClosed:d=!1}){let L={...e,onError:j=>{G?.setMessages(de=>[...de,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:j.message}]}]),console.error("Error in CopilotInterface:",j)}},E=(0,Ha.useChat)(L||{}),G=o?t||E:null,[Z,be]=(0,ot.useState)(""),[u,U]=(0,ot.useState)(!1),ve=G?.messages||a,Ae=Z,Ga=G?.status==="submitted"||u,$a=G?.addToolResult?(j,de,oe)=>{G.addToolResult({tool:de,toolCallId:j,output:oe}),G.sendMessage()}:()=>{},dt=n||[],qa={id:"default",name:"Default Team",description:"Default team when kt business units are available",icon:"\u{1F3E2}",color:"bg-gray-500",accentColor:"bg-gray-600"},[Ka,_a]=(0,ot.useState)(()=>dt.length===0?qa:dt.find(j=>j.id===F)||dt[0]),[pt,xt]=(0,ot.useState)([]),[Ja,Xa]=(0,ot.useState)(!1),Qa=j=>{if(!j||!$)return;let de=[];Array.from(j).forEach(oe=>{if(oe.size>se*1024*1024){alert(`File ${oe.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>oe.type.match(wt))){alert(`File type ${oe.type} is not allowed.`);return}let wo={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:oe,status:"pending",progress:0};if(oe.type.startsWith("image/")){let wt=new FileReader;wt.onload=oi=>{xt(ai=>ai.map($t=>$t.id===wo.id?{...$t,preview:oi.target?.result}:$t))},wt.readAsDataURL(oe)}de.push(wo)}),xt(oe=>[...oe,...de])},Ya=j=>{xt(de=>de.filter(oe=>oe.id!==j))},xo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let j=pt.length>0?Za(pt.map(de=>de.file)):void 0;G.sendMessage({text:Ae,files:j},{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([])}},Za=j=>{let de=new DataTransfer;return j.forEach(oe=>de.items.add(oe)),de.files},ei=j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),xo())},ti=j=>{be(j)};return(0,kt.jsx)(va,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:Ka,onBusinessUnitChange:j=>{j&&(_a(j),R?.(j))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:M,actionText:Se,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,kt.jsx)(Gt.AnimatePresence,{mode:"wait",children:(0,kt.jsx)(Gt.motion.div,{className:"flex-1 kt-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,kt.jsxs)("div",{className:"kt-full flex",children:[(0,kt.jsx)("div",{className:"w-80 flex-shrink-0 kt-full kt-2",children:(0,kt.jsx)(ha,{sessions:c||[],currentSession:S,teams:dt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,kt.jsx)("div",{className:"flex-1 kt-full kt-2",children:(0,kt.jsx)(ja,{messages:ve||[],input:Ae,isTyping:Ga,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:ti,addToolResult:$a,onSendMessage:xo,onKeyPress:ei,fileUploads:pt,isDragOver:Ja,enableFileUpload:$,onFileUpload:Qa,onRemoveFile:Ya,onDragOver:Xa})})]})},"chat-interface")})})}var fr=[{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 create and manage tasks."}]},{id:"3",role:"user",parts:[{type:"text",text:"Here is a file with project requirements"},{type:"file",mimeType:"application/pdf",url:"/path/to/file.pdf"}]},{id:"4",role:"assistant",parts:[{type:"text",text:"I'll create a task based on your requirements."},{type:"tool-task",toolCallId:"call-123",state:"output-available",input:{title:"Project Requirements Review",description:"Review and analyze the uploaded requirements document"},output:{id:"task-123",title:"Project Requirements Review",description:"Review and analyze the uploaded requirements document",status:"created",assignee:"AI Assistant",priority:"high"}}]},{id:"5",role:"assistant",parts:[{type:"text",text:"Here are some relevant resources for your project:"},{type:"data-reference",data:{references:[{id:"ref-1",title:"Project Management Best Practices",url:"https://example.com/pm-best-practices",description:"Comprehensive guide to project management",type:"document"},{id:"ref-2",title:"Requirements Gathering Template",url:"https://example.com/requirements-template",description:"Template for gathering project requirements",type:"link"}]}}]},{id:"6",role:"assistant",parts:[{type:"text",text:"What would you like to do next?"},{type:"data-menu",data:{title:"Available Actions",items:[{id:"action-1",label:"Create another task",description:"Set up a new task for the project",action:()=>console.log("Create task clicked")},{id:"action-2",label:"View project timeline",description:"See the project schedule and milestones",action:()=>console.log("View timeline clicked")},{id:"action-3",label:"Assign team members",description:"Add team members to the project",action:()=>console.log("Assign team clicked")}]}}]}];function br(){return(0,kt.jsx)(Va,{messages:fr,businessUnits:[{id:"engineering",name:"Engineering",description:"Software development team",icon:"\u2699\uFE0F",color:"bg-blue-500",accentColor:"bg-blue-600"}],capabilities:[],sessions:[],onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),enableFileUpload:!0,title:"AI Assistant"})}0&&(module.exports={ExampleChatInterface});
|
|
21
|
+
`,children:"Cancel"})]})]}):null};var ka=({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,kt.jsxs)("div",{className:"mb-2",children:[(0,kt.jsx)(Na,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,kt.jsxs)(kt.Fragment,{children:[i==="approve"&&(0,kt.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,kt.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,kt.jsx)("svg",{className:"kt-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,kt.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,kt.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,kt.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,kt.jsx)("svg",{className:"kt-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,kt.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,kt.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 st=V(require("@radix-ui/react-collapsible")),zt=st.Root,Ut=st.CollapsibleTrigger,Ft=st.CollapsibleContent;var Ta=require("streamdown"),yt=(0,ot.memo)(({className:e,...t})=>(0,kt.jsx)(Ta.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 Ra=(0,ot.createContext)(null),sr=()=>{let e=(0,ot.useContext)(Ra);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},lr=1e3,cr=1e3,bo=(0,ot.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,ot.useState)(!1),[A,T]=(0,ot.useState)(null);(0,ot.useEffect)(()=>{t?A===null&&T(Date.now()):A!==null&&(f(Math.ceil((Date.now()-A)/cr)),T(null))},[t,A,f]),(0,ot.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,kt.jsx)(Ra.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,kt.jsx)(zt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),dr=(e,t)=>e||t===0?(0,kt.jsx)("kt",{children:"Thinking..."}):t===void 0?(0,kt.jsx)("kt",{children:"Thought for a few seconds"}):(0,kt.jsxs)("kt",{children:["Thought for ",t," seconds"]}),vo=(0,ot.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=sr();return(0,kt.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,kt.jsxs)(kt.Fragment,{children:[(0,kt.jsx)(Eo.BrainIcon,{className:"size-4"}),dr(a,i),(0,kt.jsx)(Eo.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),ho=(0,ot.memo)(({className:e,children:t,...o})=>(0,kt.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,kt.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,ot.createContext)({code:""}),Vt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,kt.jsx)(pr.Provider,{value:{code:e},children:(0,kt.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,kt.jsxs)("div",{className:"relative",children:[(0,kt.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,kt.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,kt.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Aa=({className:e,...t})=>(0,kt.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,kt.jsxs)(ae,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,kt.jsx)(Eo.CircleIcon,{className:"size-4"}),"input-available":(0,kt.jsx)(Eo.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,kt.jsx)(Eo.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,kt.jsx)(Eo.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Ia=({className:e,type:t,state:o,...a})=>(0,kt.jsxs)(Ut,{className:l("flex w-full items-center justify-between gap-4 kt-3 pl-0 w-2xl",e),...a,children:[(0,kt.jsxs)("div",{className:"flex items-center gap-2",children:[(0,kt.jsx)(Eo.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,kt.jsx)("span",{className:"font-medium text-sm",children:t}),mr(o)]}),(0,kt.jsx)(Eo.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Ma=({className:e,...t})=>(0,kt.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}),Ba=({className:e,input:t,...o})=>(0,kt.jsxs)("div",{className:l("space-y-2 overflow-hidden kt-4",e),...o,children:[(0,kt.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,kt.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,kt.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"})})]}),La=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,kt.jsx)("div",{children:t});return typeof t=="object"?n=(0,kt.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,kt.jsx)(Vt,{code:t,language:"json"})),(0,kt.jsxs)("div",{className:l("space-y-2 kt-4",e),...a,children:[(0,kt.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,kt.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,kt.jsx)("div",{children:o}),n]})]})};var ur=e=>e.startsWith("image/")?(0,kt.jsx)(Eo.Image,{className:"kt-4 w-4"}):e.startsWith("text/")?(0,kt.jsx)(Eo.FileText,{className:"kt-4 w-4"}):(0,kt.jsx)(Eo.File,{className:"kt-4 w-4"}),Ea=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,kt.jsx)(yt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,kt.jsx)("div",{className:"mb-2 kt-2 bg-background/50 rounded-lg",children:(0,kt.jsxs)("div",{className:"flex items-center gap-2",children:[ur(r.mediaType||"application/octet-stream"),(0,kt.jsx)("div",{className:"flex-1 min-w-0",children:(0,kt.jsx)("kt",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,kt.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"kt-8 w-8 kt-0",children:(0,kt.jsx)(Eo.Download,{className:"kt-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,kt.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(Uo,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,kt.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(ka,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,kt.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(Vo,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,kt.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsxs)(me,{className:"w-full max-w-md",children:[(0,kt.jsx)(Be,{children:(0,kt.jsx)(Le,{className:"text-lg",children:s})}),(0,kt.jsxs)(Ce,{children:[r.state==="input-available"&&(0,kt.jsxs)("kt",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,kt.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,kt.jsxs)("kt",{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,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsx)(me,{className:"w-full",children:(0,kt.jsx)(Ce,{className:"kt-4",children:(0,kt.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,kt.jsxs)("div",{className:"flex items-center gap-2 kt-2 rounded-md bg-muted/50",children:[(0,kt.jsx)(ae,{variant:"outline",children:c.type||"link"}),(0,kt.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,kt.jsx)("kt",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,kt.jsx)("kt",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,kt.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"kt-8 w-8 kt-0",children:(0,kt.jsx)(Eo.ExternalLink,{className:"kt-4 w-4"})})]},m))})})})},i):s==="menu"?(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsxs)(me,{className:"w-full",children:[(0,kt.jsx)(Be,{children:(0,kt.jsx)(Le,{className:"text-lg",children:r.data?.title})}),(0,kt.jsx)(Ce,{children:(0,kt.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,kt.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,kt.jsxs)("div",{className:"text-left",children:[(0,kt.jsx)("kt",{className:"font-medium",children:c.label}),c.description&&(0,kt.jsx)("kt",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,kt.jsx)("div",{className:"mb-2",children:(0,kt.jsxs)(me,{className:"w-full max-w-md",children:[(0,kt.jsx)(Be,{children:(0,kt.jsx)(Le,{className:"text-lg",children:s})}),(0,kt.jsx)(Ce,{children:(0,kt.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}return n.type==="reasoning"?(0,kt.jsxs)(bo,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.at(-1)?.id,children:[(0,kt.jsx)(vo,{}),(0,kt.jsx)(ho,{children:n.text})]},`${i}`):n.type==="dynamic-tool"?(0,kt.jsxs)(Aa,{defaultOpen:n.state!=="output-available",children:[(0,kt.jsx)(Ia,{type:`tool-${n.toolName}`,state:n.state}),(0,kt.jsxs)(Ma,{children:[(0,kt.jsx)(Ba,{input:n.input}),(0,kt.jsx)(La,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`):(0,kt.jsxs)(kt.Fragment,{children:["Unknown part type: ",n.type]})});var Ua=({className:e,from:t,...o})=>(0,kt.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}),gr=(0,Mo.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"}}),Fa=({children:e,className:t,variant:o,...a})=>(0,kt.jsx)("div",{className:l(gr({variant:o,className:t})),...a,children:e});function ja({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,ot.useRef)(null),F=(0,ot.useRef)(null),S=(0,ot.useRef)(null),[I,_]=(0,ot.useState)(!1),[$,se]=(0,ot.useState)({path:[],selectedItems:[],filters:{}});(0,ot.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,ot.useEffect)(()=>{I&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[I]);let J=()=>Yt($),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=Yt({path:[],selectedItems:[],filters:{}}),M=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,kt.jsx)(Eo.Image,{className:"kt-4 w-4"}):u.startsWith("text/")?(0,kt.jsx)(Eo.FileText,{className:"kt-4 w-4"}):(0,kt.jsx)(Eo.File,{className:"kt-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,kt.jsxs)("div",{className:`kt-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,kt.jsxs)(Ne,{ref:F,className:"flex-1 kt-4 bg-background border-0",onDragOver:Se,onDragLeave:d,onDrop:L,children:[(0,kt.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,kt.jsx)(lt.animate,{children:e.map(u=>(0,kt.jsx)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,kt.jsx)(Ua,{from:u.role,children:(0,kt.jsx)(Fa,{variant:"flat",children:Ea({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),I&&(0,kt.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,kt.jsx)(et,{className:"kt-8 w-8",children:(0,kt.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,kt.jsx)(Eo.Bot,{className:"kt-4 w-4"})})}),(0,kt.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,kt.jsx)(ya,{capabilities:n,isOpen:I,onToggle:()=>_(!I),onActionSelect:X,className:"w-full"})})]}),o&&(0,kt.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,kt.jsx)(et,{className:"kt-8 w-8",children:(0,kt.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,kt.jsx)(Eo.Bot,{className:"kt-4 w-4"})})}),(0,kt.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,kt.jsxs)("div",{className:"flex space-x-1",children:[(0,kt.jsx)("div",{className:"w-2 kt-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,kt.jsx)("div",{className:"w-2 kt-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,kt.jsx)("div",{className:"w-2 kt-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,kt.jsx)("div",{ref:N})]}),i.length>0&&(0,kt.jsx)("div",{className:"kt-4 border-t bg-muted/10",children:(0,kt.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,kt.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg kt-2 border",children:[G(u.file.type),(0,kt.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,kt.jsx)("span",{className:"text-xs text-muted-foreground",children:E(u.file.size)}),(0,kt.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"kt-6 w-6 kt-0",children:(0,kt.jsx)(Eo.X,{className:"kt-4 w-4"})})]},u.id))})}),(0,kt.jsxs)("div",{className:"border rounded-2xl kt-4 bg-muted/20",children:[(0,kt.jsxs)("div",{className:"flex gap-3",children:[(0,kt.jsx)(ft,{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,kt.jsx)(D,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl kt-10 w-10 shadow-sm",children:(0,kt.jsx)(Eo.Paperclip,{className:"kt-4 w-4"})}),(0,kt.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl kt-10 w-10 shadow-sm",children:(0,kt.jsx)(Eo.Send,{className:"kt-4 w-4"})})]}),(0,kt.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,kt.jsxs)(D,{onClick:()=>_(!I),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,kt.jsx)(Eo.Menu,{className:"kt-3 w-3 mr-1"}),I?"Hide":"Show"," Capabilities"]}),(0,kt.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,kt.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,kt.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,kt.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,kt.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:M,className:"hidden"})]})]})}function Va({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:F="design",currentSession:S=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,kt.jsx)(Eo.Users,{className:"mr-2 kt-4 w-4"}),actionText:Se="Collaborate",sidebarInitiallyClosed:d=!1}){let L={...e,onError:j=>{G?.setMessages(de=>[...de,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:j.message}]}]),console.error("Error in CopilotInterface:",j)}},E=(0,Ha.useChat)(L||{}),G=o?t||E:null,[Z,be]=(0,ot.useState)(""),[u,U]=(0,ot.useState)(!1),ve=G?.messages||a,Ae=Z,Ga=G?.status==="submitted"||u,$a=G?.addToolResult?(j,de,oe)=>{G.addToolResult({tool:de,toolCallId:j,output:oe}),G.sendMessage()}:()=>{},dt=n||[],qa={id:"default",name:"Default Team",description:"Default team when kt business units are available",icon:"\u{1F3E2}",color:"bg-gray-500",accentColor:"bg-gray-600"},[Ka,_a]=(0,ot.useState)(()=>dt.length===0?qa:dt.find(j=>j.id===F)||dt[0]),[pt,xt]=(0,ot.useState)([]),[Ja,Xa]=(0,ot.useState)(!1),Qa=j=>{if(!j||!$)return;let de=[];Array.from(j).forEach(oe=>{if(oe.size>se*1024*1024){alert(`File ${oe.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>oe.type.match(wt))){alert(`File type ${oe.type} is not allowed.`);return}let wo={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:oe,status:"pending",progress:0};if(oe.type.startsWith("image/")){let wt=new FileReader;wt.onload=oi=>{xt(ai=>ai.map($t=>$t.id===wo.id?{...$t,preview:oi.target?.result}:$t))},wt.readAsDataURL(oe)}de.push(wo)}),xt(oe=>[...oe,...de])},Ya=j=>{xt(de=>de.filter(oe=>oe.id!==j))},xo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let j=pt.length>0?Za(pt.map(de=>de.file)):void 0;G.sendMessage({text:Ae,files:j},{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([])}},Za=j=>{let de=new DataTransfer;return j.forEach(oe=>de.items.add(oe)),de.files},ei=j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),xo())},ti=j=>{be(j)};return(0,kt.jsx)(va,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:Ka,onBusinessUnitChange:j=>{j&&(_a(j),R?.(j))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:M,actionText:Se,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,kt.jsx)(Gt.AnimatePresence,{mode:"wait",children:(0,kt.jsx)(Gt.motion.div,{className:"flex-1 kt-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,kt.jsxs)("div",{className:"kt-full flex",children:[(0,kt.jsx)("div",{className:"w-80 flex-shrink-0 kt-full kt-2",children:(0,kt.jsx)(ha,{sessions:c||[],currentSession:S,teams:dt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,kt.jsx)("div",{className:"flex-1 kt-full kt-2",children:(0,kt.jsx)(ja,{messages:ve||[],input:Ae,isTyping:Ga,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:ti,addToolResult:$a,onSendMessage:xo,onKeyPress:ei,fileUploads:pt,isDragOver:Ja,enableFileUpload:$,onFileUpload:Qa,onRemoveFile:Ya,onDragOver:Xa})})]})},"chat-interface")})})}var fr=[{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 create and manage tasks."}]},{id:"3",role:"user",parts:[{type:"text",text:"Here is a file with project requirements"},{type:"file",mimeType:"application/pdf",url:"/path/to/file.pdf"}]},{id:"4",role:"assistant",parts:[{type:"text",text:"I'll create a task based on your requirements."},{type:"tool-task",toolCallId:"call-123",state:"output-available",input:{title:"Project Requirements Review",description:"Review and analyze the uploaded requirements document"},output:{id:"task-123",title:"Project Requirements Review",description:"Review and analyze the uploaded requirements document",status:"created",assignee:"AI Assistant",priority:"high"}}]},{id:"5",role:"assistant",parts:[{type:"text",text:"Here are some relevant resources for your project:"},{type:"data-reference",data:{references:[{id:"ref-1",title:"Project Management Best Practices",url:"https://example.com/pm-best-practices",description:"Comprehensive guide to project management",type:"document"},{id:"ref-2",title:"Requirements Gathering Template",url:"https://example.com/requirements-template",description:"Template for gathering project requirements",type:"link"}]}}]},{id:"6",role:"assistant",parts:[{type:"text",text:"What would you like to do next?"},{type:"data-menu",data:{title:"Available Actions",items:[{id:"action-1",label:"Create another task",description:"Set up a new task for the project",action:()=>console.log("Create task clicked")},{id:"action-2",label:"View project timeline",description:"See the project schedule and milestones",action:()=>console.log("View timeline clicked")},{id:"action-3",label:"Assign team members",description:"Add team members to the project",action:()=>console.log("Assign team clicked")}]}}]}];function br(){return(0,kt.jsx)(Va,{messages:fr,businessUnits:[{id:"engineering",name:"Engineering",description:"Software development team",icon:"\u2699\uFE0F",color:"bg-blue-500",accentColor:"bg-blue-600"}],capabilities:[],sessions:[],onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),enableFileUpload:!0,title:"AI Assistant"})}0&&(module.exports={ExampleChatInterface});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../chunk-LUPNE23E.mjs";import"../../chunk-N7M6FTIO.mjs";import"../../chunk-BAB3ATRB.mjs";import{a as t}from"../../chunk-
|
|
1
|
+
import"../../chunk-LUPNE23E.mjs";import"../../chunk-N7M6FTIO.mjs";import"../../chunk-BAB3ATRB.mjs";import{a as t}from"../../chunk-7JX3L2MA.mjs";import"../../chunk-CTTBF7F4.mjs";import"../../chunk-56X4PU43.mjs";import"../../chunk-DEVPAZSJ.mjs";import"../../chunk-QADUAIFH.mjs";import"../../chunk-EH3PJU6C.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"../../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{jsx as i}from"react/jsx-runtime";var a=[{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 create and manage tasks."}]},{id:"3",role:"user",parts:[{type:"text",text:"Here is a file with project requirements"},{type:"file",mimeType:"application/pdf",url:"/path/to/file.pdf"}]},{id:"4",role:"assistant",parts:[{type:"text",text:"I'll create a task based on your requirements."},{type:"tool-task",toolCallId:"call-123",state:"output-available",input:{title:"Project Requirements Review",description:"Review and analyze the uploaded requirements document"},output:{id:"task-123",title:"Project Requirements Review",description:"Review and analyze the uploaded requirements document",status:"created",assignee:"AI Assistant",priority:"high"}}]},{id:"5",role:"assistant",parts:[{type:"text",text:"Here are some relevant resources for your project:"},{type:"data-reference",data:{references:[{id:"ref-1",title:"Project Management Best Practices",url:"https://example.com/pm-best-practices",description:"Comprehensive guide to project management",type:"document"},{id:"ref-2",title:"Requirements Gathering Template",url:"https://example.com/requirements-template",description:"Template for gathering project requirements",type:"link"}]}}]},{id:"6",role:"assistant",parts:[{type:"text",text:"What would you like to do next?"},{type:"data-menu",data:{title:"Available Actions",items:[{id:"action-1",label:"Create another task",description:"Set up a new task for the project",action:()=>console.log("Create task clicked")},{id:"action-2",label:"View project timeline",description:"See the project schedule and milestones",action:()=>console.log("View timeline clicked")},{id:"action-3",label:"Assign team members",description:"Add team members to the project",action:()=>console.log("Assign team clicked")}]}}]}];function o(){return i(t,{messages:a,businessUnits:[{id:"engineering",name:"Engineering",description:"Software development team",icon:"\u2699\uFE0F",color:"bg-blue-500",accentColor:"bg-blue-600"}],capabilities:[],sessions:[],onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),enableFileUpload:!0,title:"AI Assistant"})}export{o as ExampleChatInterface};
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
`,children:r?"Processing...":"Deny"}),(0,Oo.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 ka=({toolPart:e,index:t,addToolResult:o})=>{let[a,n]=wo.default.useState(!0),[i,r]=wo.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,Oo.jsxs)("div",{className:"mb-2",children:[(0,Oo.jsx)(Na,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,Oo.jsxs)(Oo.Fragment,{children:[i==="approve"&&(0,Oo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Oo.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,Oo.jsx)("svg",{className:"Oo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Oo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,Oo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Oo.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,Oo.jsx)("svg",{className:"Oo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Oo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Oo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var Co=require("@radix-ui/react-use-controllable-state");var mt=V(require("@radix-ui/react-collapsible")),Wt=mt.Root,Gt=mt.CollapsibleTrigger,$t=mt.CollapsibleContent;var Ta=require("streamdown"),Tt=(0,ft.memo)(({className:e,...t})=>(0,Oo.jsx)(Ta.Streamdown,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);Tt.displayName="Response";var Ra=(0,ft.createContext)(null),dr=()=>{let e=(0,ft.useContext)(Ra);if(!e)throw new Error("Reasoning components must _a used within Reasoning");return e},pr=1e3,mr=1e3,No=(0,ft.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:a=!0,onOpenChange:n,duration:i,children:r,...s})=>{let[c,m]=(0,Co.useControllableState)({prop:o,defaultProp:a,onChange:n}),[w,f]=(0,Co.useControllableState)({prop:i,defaultProp:0}),[y,R]=(0,ft.useState)(!1),[I,T]=(0,ft.useState)(null);(0,ft.useEffect)(()=>{t?I===null&&T(Date.now()):I!==null&&(f(Math.ceil((Date.now()-I)/mr)),T(null))},[t,I,f]),(0,ft.useEffect)(()=>{if(a&&!t&&c&&!y){let N=setTimeout(()=>{m(!1),R(!0)},pr);return()=>clearTimeout(N)}},[t,c,a,m,y]);let C=N=>{m(N)};return(0,Oo.jsx)(Ra.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,Oo.jsx)(Wt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),ur=(e,t)=>e||t===0?(0,Oo.jsx)("Oo",{children:"Thinking..."}):t===void 0?(0,Oo.jsx)("Oo",{children:"Thought for a few seconds"}):(0,Oo.jsxs)("Oo",{children:["Thought for ",t," seconds"]}),ko=(0,ft.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=dr();return(0,Oo.jsx)(Gt,{className:l("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,Oo.jsxs)(Oo.Fragment,{children:[(0,Oo.jsx)(_a.BrainIcon,{className:"size-4"}),ur(a,i),(0,Oo.jsx)(_a.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),Po=(0,ft.memo)(({className:e,children:t,...o})=>(0,Oo.jsx)($t,{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,Oo.jsx)(Tt,{className:"grid gap-2",children:t})}));No.displayName="Reasoning";ko.displayName="ReasoningTrigger";Po.displayName="ReasoningContent";var To=require("react-syntax-highlighter"),_t=require("react-syntax-highlighter/dist/esm/styles/prism"),gr=(0,ft.createContext)({code:""}),Jt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,Oo.jsx)(gr.Provider,{value:{code:e},children:(0,Oo.jsx)("div",{className:l("relative w-full overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,Oo.jsxs)("div",{className:"relative",children:[(0,Oo.jsx)(To.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:_t.oneLight,children:e}),(0,Oo.jsx)(To.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:_t.oneDark,children:e}),n&&(0,Oo.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Aa=({className:e,...t})=>(0,Oo.jsx)(Wt,{className:l("not-prose mb-4 w-full rounded-md border",e),...t}),fr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Oo.jsxs)(ie,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Oo.jsx)(_a.CircleIcon,{className:"size-4"}),"input-available":(0,Oo.jsx)(_a.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Oo.jsx)(_a.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Oo.jsx)(_a.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Ia=({className:e,type:t,state:o,...a})=>(0,Oo.jsxs)(Gt,{className:l("flex w-full items-center justify-between gap-4 Oo-3",e),...a,children:[(0,Oo.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Oo.jsx)(_a.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Oo.jsx)("span",{className:"font-medium text-sm",children:t}),fr(o)]}),(0,Oo.jsx)(_a.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Ma=({className:e,...t})=>(0,Oo.jsx)($t,{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}),Ba=({className:e,input:t,...o})=>(0,Oo.jsxs)("div",{className:l("space-y-2 overflow-hidden Oo-4",e),...o,children:[(0,Oo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Oo.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Oo.jsx)(Jt,{code:JSON.stringify(t,null,2),language:"json"})})]}),La=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,Oo.jsx)("div",{children:t});return typeof t=="object"?n=(0,Oo.jsx)(Jt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,Oo.jsx)(Jt,{code:t,language:"json"})),(0,Oo.jsxs)("div",{className:l("space-y-2 Oo-4",e),...a,children:[(0,Oo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Oo.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,Oo.jsx)("div",{children:o}),n]})]})};var Ua=require("date-fns");function Ea({taskId:e,polling:t=!0,system:o="payload"}){let[a,n]=(0,ft.useState)(null),[i,r]=(0,ft.useState)(!1),[s,c]=(0,ft.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,ft.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 br=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"}},vr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Fa({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:I,error:T}=Ea({taskId:t,system:o});r=R,s=I,c=T}else s=!1;let w=br(r?.status||"todo"),f=vr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let R=new Date(r?.dateLogged||"");isNaN(R.getTime())||(y=(0,Ua.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Oo.jsxs)(fe,{className:l("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Oo.jsxs)(Ee,{className:"pb-2",children:[(0,Oo.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Oo.jsx)(ze,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,Oo.jsx)(ie,{className:`${w}`,children:f})]}),r?.project&&(0,Oo.jsxs)(vo,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,Oo.jsx)(Pe,{className:"pb-2",children:s?(0,Oo.jsx)("div",{className:"animate-pulse Oo-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Oo.jsx)("Oo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Oo.jsx)("Oo",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,Oo.jsx)(Pt,{className:"pt-2 flex items-center justify-between",children:(0,Oo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Oo.jsx)(_a.Clock,{className:"Oo-3 w-3 mr-1"}),(0,Oo.jsxs)("span",{children:["Created ",y]}),(0,Oo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Oo.jsxs)("span",{children:["Task #",t]})]})})]})}function Oa({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,Ua.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,Oo.jsxs)(fe,{className:"w-full max-w-md shadow-md",children:[(0,Oo.jsx)(Ee,{className:"pb-2",children:(0,Oo.jsx)("div",{className:"flex justify-between items-start",children:(0,Oo.jsx)(ze,{className:"text-lg font-semibold",children:a?"Loading...":i.name})})}),(0,Oo.jsx)(Pe,{className:"pb-2",children:a?(0,Oo.jsx)("div",{className:"animate-pulse Oo-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,Oo.jsx)("Oo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Oo.jsx)("Oo",{className:"text-sm text-foreground",children:e})}),(0,Oo.jsx)(Pt,{className:"pt-2 flex items-center justify-between",children:(0,Oo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Oo.jsx)(_a.Clock,{className:"Oo-3 w-3 mr-1"}),(0,Oo.jsxs)("span",{children:["Created ",r]}),(0,Oo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Oo.jsxs)("span",{children:["Task #",i.id]})]})})]})}var hr=e=>e.startsWith("image/")?(0,Oo.jsx)(_a.Image,{className:"Oo-4 w-4"}):e.startsWith("text/")?(0,Oo.jsx)(_a.FileText,{className:"Oo-4 w-4"}):(0,Oo.jsx)(_a.File,{className:"Oo-4 w-4"}),Va=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,Oo.jsx)(Tt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,Oo.jsx)("div",{className:"mb-2 Oo-2 bg-background/50 rounded-lg",children:(0,Oo.jsxs)("div",{className:"flex items-center gap-2",children:[hr(r.mediaType||"application/octet-stream"),(0,Oo.jsx)("div",{className:"flex-1 min-w-0",children:(0,Oo.jsx)("Oo",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,Oo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"Oo-8 w-8 Oo-0",children:(0,Oo.jsx)(_a.Download,{className:"Oo-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,Oo.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(Fa,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,Oo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(xo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(xo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(ka,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,Oo.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(Oa,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,Oo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsxs)(fe,{className:"w-full max-w-md",children:[(0,Oo.jsx)(Ee,{children:(0,Oo.jsx)(ze,{className:"text-lg",children:s})}),(0,Oo.jsxs)(Pe,{children:[r.state==="input-available"&&(0,Oo.jsxs)("Oo",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,Oo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,Oo.jsxs)("Oo",{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,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(fe,{className:"w-full",children:(0,Oo.jsx)(Pe,{className:"Oo-4",children:(0,Oo.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,Oo.jsxs)("div",{className:"flex items-center gap-2 Oo-2 rounded-md bg-muted/50",children:[(0,Oo.jsx)(ie,{variant:"outline",children:c.type||"link"}),(0,Oo.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Oo.jsx)("Oo",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Oo.jsx)("Oo",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Oo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"Oo-8 w-8 Oo-0",children:(0,Oo.jsx)(_a.ExternalLink,{className:"Oo-4 w-4"})})]},m))})})})},i):s==="menu"?(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsxs)(fe,{className:"w-full",children:[(0,Oo.jsx)(Ee,{children:(0,Oo.jsx)(ze,{className:"text-lg",children:r.data?.title})}),(0,Oo.jsx)(Pe,{children:(0,Oo.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,Oo.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Oo.jsxs)("div",{className:"text-left",children:[(0,Oo.jsx)("Oo",{className:"font-medium",children:c.label}),c.description&&(0,Oo.jsx)("Oo",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsxs)(fe,{className:"w-full max-w-md",children:[(0,Oo.jsx)(Ee,{children:(0,Oo.jsx)(ze,{className:"text-lg",children:s})}),(0,Oo.jsx)(Pe,{children:(0,Oo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}return n.type==="reasoning"?(0,Oo.jsxs)(No,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.Oo(-1)?.id,children:[(0,Oo.jsx)(ko,{}),(0,Oo.jsx)(Po,{children:n.text})]},`${i}`):n.type==="dynamic-tool"?(0,Oo.jsxs)(Aa,{defaultOpen:!0,children:[(0,Oo.jsx)(Ia,{type:`tool-${n.toolName}`,state:n.state}),(0,Oo.jsxs)(Ma,{children:[(0,Oo.jsx)(Ba,{input:n.input}),(0,Oo.jsx)(La,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`):(0,Oo.jsxs)(Oo.Fragment,{children:["Unknown part type: ",n.type]})});var Ga=({className:e,from:t,...o})=>(0,Oo.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}),yr=(0,jo.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"}}),$a=({children:e,className:t,variant:o,...a})=>(0,Oo.jsx)("div",{className:l(yr({variant:o,className:t})),...a,children:e});function qa({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:I,className:T,status:C="ready"}){let N=(0,ft.useRef)(null),F=(0,ft.useRef)(null),S=(0,ft.useRef)(null),[M,_]=(0,ft.useState)(!1),[$,le]=(0,ft.useState)({path:[],selectedItems:[],filters:{}});(0,ft.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,ft.useEffect)(()=>{M&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[M]);let J=()=>ho($),W=()=>{let u=[];return n.forEach(U=>{U.actions&&U.actions.forEach(he=>{u.push({label:he.label,action:()=>X(he.id,{path:[U],selectedItems:[],filters:{}})})}),U.children&&U.children.forEach(he=>{he.type==="list"&&he.data&&u.push({label:`View ${he.name}`,action:()=>_(!0)})})}),u.slice(0,5)},X=(u,U)=>{console.log("Capability action:",u,U);let he=`Executing ${u} with context: ${JSON.stringify(U.path.map(Ae=>Ae.name))}`;_(!1)},ce=ho({path:[],selectedItems:[],filters:{}}),B=u=>{y(u.target.files),u.target.files&&(u.target.value="")},Se=u=>{u.preventDefault(),I(!0)},d=u=>{u.preventDefault(),I(!1)},E=u=>{u.preventDefault(),I(!1),y(u.dataTransfer.files)},z=u=>{if(u===0)return"0 Bytes";let U=1024,he=["Bytes","KB","MB","GB"],Ae=Math.floor(Math.log(u)/Math.log(U));return parseFloat((u/Math.pow(U,Ae)).toFixed(2))+" "+he[Ae]},G=u=>u.startsWith("image/")?(0,Oo.jsx)(_a.Image,{className:"Oo-4 w-4"}):u.startsWith("text/")?(0,Oo.jsx)(_a.FileText,{className:"Oo-4 w-4"}):(0,Oo.jsx)(_a.File,{className:"Oo-4 w-4"}),Z={messages:e,currentSessionTitle:a,capabilities:n,currentCapabilityContext:$,contextualActions:ce,getQuickSuggestions:W().map(u=>u.label)},ve=()=>{navigator.clipboard.writeText(JSON.stringify(Z,null,2)),alert("Debug info copied to clipboard")};return(0,Oo.jsxs)("div",{className:`Oo-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,Oo.jsxs)(Ce,{ref:F,className:"flex-1 Oo-4 bg-background border-0",onDragOver:Se,onDragLeave:d,onDrop:E,children:[(0,Oo.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Oo.jsx)(gt.animate,{children:e.map(u=>(0,Oo.jsx)(gt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Oo.jsx)(Ga,{from:u.role,children:(0,Oo.jsx)($a,{variant:"flat",children:Va({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),M&&(0,Oo.jsxs)(gt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Oo.jsx)(nt,{className:"Oo-8 w-8",children:(0,Oo.jsx)(st,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Oo.jsx)(_a.Bot,{className:"Oo-4 w-4"})})}),(0,Oo.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Oo.jsx)(ya,{capabilities:n,isOpen:M,onToggle:()=>_(!M),onActionSelect:X,className:"w-full"})})]}),o&&(0,Oo.jsxs)(gt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Oo.jsx)(nt,{className:"Oo-8 w-8",children:(0,Oo.jsx)(st,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Oo.jsx)(_a.Bot,{className:"Oo-4 w-4"})})}),(0,Oo.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Oo.jsxs)("div",{className:"flex space-x-1",children:[(0,Oo.jsx)("div",{className:"w-2 Oo-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Oo.jsx)("div",{className:"w-2 Oo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Oo.jsx)("div",{className:"w-2 Oo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Oo.jsx)("div",{ref:N})]}),i.length>0&&(0,Oo.jsx)("div",{className:"Oo-4 border-t bg-muted/10",children:(0,Oo.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,Oo.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Oo-2 border",children:[G(u.file.type),(0,Oo.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Oo.jsx)("span",{className:"text-xs text-muted-foreground",children:z(u.file.size)}),(0,Oo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"Oo-6 w-6 Oo-0",children:(0,Oo.jsx)(_a.X,{className:"Oo-4 w-4"})})]},u.id))})}),(0,Oo.jsxs)("div",{className:"border rounded-2xl Oo-4 bg-muted/20",children:[(0,Oo.jsxs)("div",{className:"flex gap-3",children:[(0,Oo.jsx)(wt,{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,Oo.jsx)(D,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl Oo-10 w-10 shadow-sm",children:(0,Oo.jsx)(_a.Paperclip,{className:"Oo-4 w-4"})}),(0,Oo.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl Oo-10 w-10 shadow-sm",children:(0,Oo.jsx)(_a.Send,{className:"Oo-4 w-4"})})]}),(0,Oo.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Oo.jsxs)(D,{onClick:()=>_(!M),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Oo.jsx)(_a.Menu,{className:"Oo-3 w-3 mr-1"}),M?"Hide":"Show"," Capabilities"]}),(0,Oo.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,Oo.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,Oo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,Oo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:ve,children:"Debug"})]})]}),s&&(0,Oo.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:B,className:"hidden"})]})]})}function ot({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:I=()=>{},onRemoveAll:T=()=>{},onActionClick:C=()=>{},onSearch:N=E=>console.log("Search query:",E),initialTeam:F="design",currentSession:S=null,showCapabilities:M=!0,title:_="Digital Colleagues",enableFileUpload:$=!0,maxFileSize:le=10,allowedFileTypes:J=["image/*","text/*","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],logo:W="/headerlogo.png",appName:X="Nuvia",tagline:ce="AI-Powered Workspace",actionIcon:B=(0,Oo.jsx)(_a.Users,{className:"mr-2 Oo-4 w-4"}),actionText:Se="Collaborate",sidebarInitiallyClosed:d=!1}){let E={...e,onError:H=>{G?.setMessages(pe=>[...pe,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:H.message}]}]),console.error("Error in CopilotInterface:",H)}},z=(0,Do.useChat)(E||{}),G=o?t||z:null,[Z,ve]=(0,ft.useState)(""),[u,U]=(0,ft.useState)(!1),he=G?.messages||a,Ae=Z,Ja=G?.status==="submitted"||u,Xa=G?.addToolResult?(H,pe,ae)=>{G.addToolResult({tool:pe,toolCallId:H,output:ae}),G.sendMessage()}:()=>{},vt=n||[],Qa={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"},[Ya,Za]=(0,ft.useState)(()=>vt.length===0?Qa:vt.find(H=>H.id===F)||vt[0]),[ht,Dt]=(0,ft.useState)([]),[ei,ti]=(0,ft.useState)(!1),oi=H=>{if(!H||!$)return;let pe=[];Array.from(H).forEach(ae=>{if(ae.size>le*1024*1024){alert(`File ${ae.name} is too large. Maximum size is ${le}MB.`);return}if(J.length>0&&!J.some(Rt=>ae.type.match(Rt))){alert(`File type ${ae.type} is not allowed.`);return}let So={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ae,status:"pending",progress:0};if(ae.type.startsWith("image/")){let Rt=new FileReader;Rt.onload=si=>{Dt(li=>li.map(Yt=>Yt.id===So.id?{...Yt,preview:si.target?.result}:Yt))},Rt.readAsDataURL(ae)}pe.push(So)}),Dt(ae=>[...ae,...pe])},ai=H=>{Dt(pe=>pe.filter(ae=>ae.id!==H))},Ro=()=>{if(!(!Ae.trim()&&ht.length===0)){if(G){let H=ht.length>0?ii(ht.map(pe=>pe.file)):void 0;G.sendMessage({text:Ae,files:H},{body:{timestamp:Date.now()}}),ve("")}else console.log("Message to send:",Ae),console.log("Files to upload:",ht),ve(""),U(!0),setTimeout(()=>{U(!1)},1500);Dt([])}},ii=H=>{let pe=new DataTransfer;return H.forEach(ae=>pe.items.add(ae)),pe.files},ri=H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),Ro())},ni=H=>{ve(H)};return(0,Oo.jsx)(ba,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:vt,currentBusinessUnit:Ya,onBusinessUnitChange:H=>{H&&(Za(H),R?.(H))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:B,actionText:Se,onNotificationRemove:I,onRemoveAll:T,logo:W,appName:X,tagline:ce,sidebarInitiallyClosed:d,children:(0,Oo.jsx)(Qt.AnimatePresence,{mode:"wait",children:(0,Oo.jsx)(Qt.motion.div,{className:"flex-1 Oo-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,Oo.jsxs)("div",{className:"Oo-full flex",children:[(0,Oo.jsx)("div",{className:"w-80 flex-shrink-0 Oo-full Oo-2",children:(0,Oo.jsx)(va,{sessions:c||[],currentSession:S,teams:vt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,Oo.jsx)("div",{className:"flex-1 Oo-full Oo-2",children:(0,Oo.jsx)(qa,{messages:he||[],input:Ae,isTyping:Ja,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:ni,addToolResult:Xa,onSendMessage:Ro,onKeyPress:ri,fileUploads:ht,isDragOver:ei,enableFileUpload:$,onFileUpload:oi,onRemoveFile:ai,onDragOver:ti})})]})},"chat-interface")})})}var bt=[{id:"1",title:"AI Assistant Chat",lastMessage:"How can I help you today?"}];function xr(){return(0,Oo.jsx)(ot,{businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"AI-Powered Copilot"})}function wr(){return(0,Oo.jsx)(ot,{aiConfig:{onError:e=>console.error("Chat error:",e)},businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"Custom AI Copilot"})}function Cr(){return(0,Oo.jsx)(ot,{enableAI:!1,messages:[{id:"1",role:"assistant",parts:[{type:"text",text:"This is demo mode - no AI involved!"}]}],businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>console.log("New chat started"),onSessionSelect:t=>console.log("Session selected:",t),onSessionDelete:t=>console.log("Session deleted:",t),title:"Demo Copilot"})}function Nr(){let e=(0,Do.useChat)({onError:t=>console.error("Custom chat error:",t)});return(0,Oo.jsx)(ot,{useCustomChat:e,businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>{e.setMessages([]),console.log("New chat started - messages cleared")},onSessionSelect:t=>console.log("Session selected:",t),onSessionDelete:t=>console.log("Session deleted:",t),title:"Advanced AI Copilot"})}function kr(){return(0,Oo.jsx)(ot,{sidebarInitiallyClosed:!0,businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"Focused AI Chat"})}function Pr(){let e=(0,Do.useChat)({onError:t=>console.error("File upload chat error:",t),onFinish:t=>console.log("Message with files completed:",t)});return(0,Oo.jsx)(ot,{useCustomChat:e,enableAI:!0,enableFileUpload:!0,maxFileSize:10,allowedFileTypes:["image/*","text/*","application/pdf"],businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>{e.setMessages([]),console.log("New file upload chat started - messages cleared")},onSessionSelect:t=>console.log("Session selected:",t),onSessionDelete:t=>console.log("Session deleted:",t),title:"AI Copilot with File Uploads"})}0&&(module.exports={AdvancedAICopilot,CustomAICopilot,DemoCopilot,FileUploadAICopilot,FocusedChatCopilot,SimpleAICopilot});
|
|
21
|
+
`,children:"Cancel"})]})]}):null};var ka=({toolPart:e,index:t,addToolResult:o})=>{let[a,n]=wo.default.useState(!0),[i,r]=wo.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,Oo.jsxs)("div",{className:"mb-2",children:[(0,Oo.jsx)(Na,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,Oo.jsxs)(Oo.Fragment,{children:[i==="approve"&&(0,Oo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Oo.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,Oo.jsx)("svg",{className:"Oo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Oo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,Oo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Oo.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,Oo.jsx)("svg",{className:"Oo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Oo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Oo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var Co=require("@radix-ui/react-use-controllable-state");var mt=V(require("@radix-ui/react-collapsible")),Wt=mt.Root,Gt=mt.CollapsibleTrigger,$t=mt.CollapsibleContent;var Ta=require("streamdown"),Tt=(0,ft.memo)(({className:e,...t})=>(0,Oo.jsx)(Ta.Streamdown,{className:l("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);Tt.displayName="Response";var Ra=(0,ft.createContext)(null),dr=()=>{let e=(0,ft.useContext)(Ra);if(!e)throw new Error("Reasoning components must _a used within Reasoning");return e},pr=1e3,mr=1e3,No=(0,ft.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:a=!0,onOpenChange:n,duration:i,children:r,...s})=>{let[c,m]=(0,Co.useControllableState)({prop:o,defaultProp:a,onChange:n}),[w,f]=(0,Co.useControllableState)({prop:i,defaultProp:0}),[y,R]=(0,ft.useState)(!1),[I,T]=(0,ft.useState)(null);(0,ft.useEffect)(()=>{t?I===null&&T(Date.now()):I!==null&&(f(Math.ceil((Date.now()-I)/mr)),T(null))},[t,I,f]),(0,ft.useEffect)(()=>{if(a&&!t&&c&&!y){let N=setTimeout(()=>{m(!1),R(!0)},pr);return()=>clearTimeout(N)}},[t,c,a,m,y]);let C=N=>{m(N)};return(0,Oo.jsx)(Ra.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,Oo.jsx)(Wt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),ur=(e,t)=>e||t===0?(0,Oo.jsx)("Oo",{children:"Thinking..."}):t===void 0?(0,Oo.jsx)("Oo",{children:"Thought for a few seconds"}):(0,Oo.jsxs)("Oo",{children:["Thought for ",t," seconds"]}),ko=(0,ft.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=dr();return(0,Oo.jsx)(Gt,{className:l("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,Oo.jsxs)(Oo.Fragment,{children:[(0,Oo.jsx)(_a.BrainIcon,{className:"size-4"}),ur(a,i),(0,Oo.jsx)(_a.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),Po=(0,ft.memo)(({className:e,children:t,...o})=>(0,Oo.jsx)($t,{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,Oo.jsx)(Tt,{className:"grid gap-2",children:t})}));No.displayName="Reasoning";ko.displayName="ReasoningTrigger";Po.displayName="ReasoningContent";var To=require("react-syntax-highlighter"),_t=require("react-syntax-highlighter/dist/esm/styles/prism"),gr=(0,ft.createContext)({code:""}),Jt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,Oo.jsx)(gr.Provider,{value:{code:e},children:(0,Oo.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,Oo.jsxs)("div",{className:"relative",children:[(0,Oo.jsx)(To.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:_t.oneLight,children:e}),(0,Oo.jsx)(To.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:_t.oneDark,children:e}),n&&(0,Oo.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Aa=({className:e,...t})=>(0,Oo.jsx)(Wt,{className:l("not-prose mb-4 w-full",e),...t}),fr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Oo.jsxs)(ie,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Oo.jsx)(_a.CircleIcon,{className:"size-4"}),"input-available":(0,Oo.jsx)(_a.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Oo.jsx)(_a.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Oo.jsx)(_a.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Ia=({className:e,type:t,state:o,...a})=>(0,Oo.jsxs)(Gt,{className:l("flex w-full items-center justify-between gap-4 Oo-3 pl-0 w-2xl",e),...a,children:[(0,Oo.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Oo.jsx)(_a.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Oo.jsx)("span",{className:"font-medium text-sm",children:t}),fr(o)]}),(0,Oo.jsx)(_a.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Ma=({className:e,...t})=>(0,Oo.jsx)($t,{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}),Ba=({className:e,input:t,...o})=>(0,Oo.jsxs)("div",{className:l("space-y-2 overflow-hidden Oo-4",e),...o,children:[(0,Oo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Oo.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Oo.jsx)(Jt,{code:JSON.stringify(t,null,2),language:"json"})})]}),La=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,Oo.jsx)("div",{children:t});return typeof t=="object"?n=(0,Oo.jsx)(Jt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,Oo.jsx)(Jt,{code:t,language:"json"})),(0,Oo.jsxs)("div",{className:l("space-y-2 Oo-4",e),...a,children:[(0,Oo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Oo.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,Oo.jsx)("div",{children:o}),n]})]})};var Ua=require("date-fns");function Ea({taskId:e,polling:t=!0,system:o="payload"}){let[a,n]=(0,ft.useState)(null),[i,r]=(0,ft.useState)(!1),[s,c]=(0,ft.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,ft.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 br=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"}},vr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Fa({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:I,error:T}=Ea({taskId:t,system:o});r=R,s=I,c=T}else s=!1;let w=br(r?.status||"todo"),f=vr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let R=new Date(r?.dateLogged||"");isNaN(R.getTime())||(y=(0,Ua.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Oo.jsxs)(fe,{className:l("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Oo.jsxs)(Ee,{className:"pb-2",children:[(0,Oo.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Oo.jsx)(ze,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,Oo.jsx)(ie,{className:`${w}`,children:f})]}),r?.project&&(0,Oo.jsxs)(vo,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,Oo.jsx)(Pe,{className:"pb-2",children:s?(0,Oo.jsx)("div",{className:"animate-pulse Oo-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Oo.jsx)("Oo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Oo.jsx)("Oo",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,Oo.jsx)(Pt,{className:"pt-2 flex items-center justify-between",children:(0,Oo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Oo.jsx)(_a.Clock,{className:"Oo-3 w-3 mr-1"}),(0,Oo.jsxs)("span",{children:["Created ",y]}),(0,Oo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Oo.jsxs)("span",{children:["Task #",t]})]})})]})}function Oa({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,Ua.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,Oo.jsxs)(fe,{className:"w-full max-w-md shadow-md",children:[(0,Oo.jsx)(Ee,{className:"pb-2",children:(0,Oo.jsx)("div",{className:"flex justify-between items-start",children:(0,Oo.jsx)(ze,{className:"text-lg font-semibold",children:a?"Loading...":i.name})})}),(0,Oo.jsx)(Pe,{className:"pb-2",children:a?(0,Oo.jsx)("div",{className:"animate-pulse Oo-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,Oo.jsx)("Oo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Oo.jsx)("Oo",{className:"text-sm text-foreground",children:e})}),(0,Oo.jsx)(Pt,{className:"pt-2 flex items-center justify-between",children:(0,Oo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Oo.jsx)(_a.Clock,{className:"Oo-3 w-3 mr-1"}),(0,Oo.jsxs)("span",{children:["Created ",r]}),(0,Oo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Oo.jsxs)("span",{children:["Task #",i.id]})]})})]})}var hr=e=>e.startsWith("image/")?(0,Oo.jsx)(_a.Image,{className:"Oo-4 w-4"}):e.startsWith("text/")?(0,Oo.jsx)(_a.FileText,{className:"Oo-4 w-4"}):(0,Oo.jsx)(_a.File,{className:"Oo-4 w-4"}),Va=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,Oo.jsx)(Tt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,Oo.jsx)("div",{className:"mb-2 Oo-2 bg-background/50 rounded-lg",children:(0,Oo.jsxs)("div",{className:"flex items-center gap-2",children:[hr(r.mediaType||"application/octet-stream"),(0,Oo.jsx)("div",{className:"flex-1 min-w-0",children:(0,Oo.jsx)("Oo",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,Oo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"Oo-8 w-8 Oo-0",children:(0,Oo.jsx)(_a.Download,{className:"Oo-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,Oo.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(Fa,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,Oo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(xo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(xo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(ka,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,Oo.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(Oa,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,Oo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsxs)(fe,{className:"w-full max-w-md",children:[(0,Oo.jsx)(Ee,{children:(0,Oo.jsx)(ze,{className:"text-lg",children:s})}),(0,Oo.jsxs)(Pe,{children:[r.state==="input-available"&&(0,Oo.jsxs)("Oo",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,Oo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,Oo.jsxs)("Oo",{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,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsx)(fe,{className:"w-full",children:(0,Oo.jsx)(Pe,{className:"Oo-4",children:(0,Oo.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,Oo.jsxs)("div",{className:"flex items-center gap-2 Oo-2 rounded-md bg-muted/50",children:[(0,Oo.jsx)(ie,{variant:"outline",children:c.type||"link"}),(0,Oo.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Oo.jsx)("Oo",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Oo.jsx)("Oo",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Oo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"Oo-8 w-8 Oo-0",children:(0,Oo.jsx)(_a.ExternalLink,{className:"Oo-4 w-4"})})]},m))})})})},i):s==="menu"?(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsxs)(fe,{className:"w-full",children:[(0,Oo.jsx)(Ee,{children:(0,Oo.jsx)(ze,{className:"text-lg",children:r.data?.title})}),(0,Oo.jsx)(Pe,{children:(0,Oo.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,Oo.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Oo.jsxs)("div",{className:"text-left",children:[(0,Oo.jsx)("Oo",{className:"font-medium",children:c.label}),c.description&&(0,Oo.jsx)("Oo",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,Oo.jsx)("div",{className:"mb-2",children:(0,Oo.jsxs)(fe,{className:"w-full max-w-md",children:[(0,Oo.jsx)(Ee,{children:(0,Oo.jsx)(ze,{className:"text-lg",children:s})}),(0,Oo.jsx)(Pe,{children:(0,Oo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}return n.type==="reasoning"?(0,Oo.jsxs)(No,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.Oo(-1)?.id,children:[(0,Oo.jsx)(ko,{}),(0,Oo.jsx)(Po,{children:n.text})]},`${i}`):n.type==="dynamic-tool"?(0,Oo.jsxs)(Aa,{defaultOpen:n.state!=="output-available",children:[(0,Oo.jsx)(Ia,{type:`tool-${n.toolName}`,state:n.state}),(0,Oo.jsxs)(Ma,{children:[(0,Oo.jsx)(Ba,{input:n.input}),(0,Oo.jsx)(La,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`):(0,Oo.jsxs)(Oo.Fragment,{children:["Unknown part type: ",n.type]})});var Ga=({className:e,from:t,...o})=>(0,Oo.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}),yr=(0,jo.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"}}),$a=({children:e,className:t,variant:o,...a})=>(0,Oo.jsx)("div",{className:l(yr({variant:o,className:t})),...a,children:e});function qa({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:I,className:T,status:C="ready"}){let N=(0,ft.useRef)(null),F=(0,ft.useRef)(null),S=(0,ft.useRef)(null),[M,_]=(0,ft.useState)(!1),[$,le]=(0,ft.useState)({path:[],selectedItems:[],filters:{}});(0,ft.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,ft.useEffect)(()=>{M&&setTimeout(()=>{N.current?.scrollIntoView({behavior:"smooth"})},100)},[M]);let J=()=>ho($),W=()=>{let u=[];return n.forEach(U=>{U.actions&&U.actions.forEach(he=>{u.push({label:he.label,action:()=>X(he.id,{path:[U],selectedItems:[],filters:{}})})}),U.children&&U.children.forEach(he=>{he.type==="list"&&he.data&&u.push({label:`View ${he.name}`,action:()=>_(!0)})})}),u.slice(0,5)},X=(u,U)=>{console.log("Capability action:",u,U);let he=`Executing ${u} with context: ${JSON.stringify(U.path.map(Ae=>Ae.name))}`;_(!1)},ce=ho({path:[],selectedItems:[],filters:{}}),B=u=>{y(u.target.files),u.target.files&&(u.target.value="")},Se=u=>{u.preventDefault(),I(!0)},d=u=>{u.preventDefault(),I(!1)},E=u=>{u.preventDefault(),I(!1),y(u.dataTransfer.files)},z=u=>{if(u===0)return"0 Bytes";let U=1024,he=["Bytes","KB","MB","GB"],Ae=Math.floor(Math.log(u)/Math.log(U));return parseFloat((u/Math.pow(U,Ae)).toFixed(2))+" "+he[Ae]},G=u=>u.startsWith("image/")?(0,Oo.jsx)(_a.Image,{className:"Oo-4 w-4"}):u.startsWith("text/")?(0,Oo.jsx)(_a.FileText,{className:"Oo-4 w-4"}):(0,Oo.jsx)(_a.File,{className:"Oo-4 w-4"}),Z={messages:e,currentSessionTitle:a,capabilities:n,currentCapabilityContext:$,contextualActions:ce,getQuickSuggestions:W().map(u=>u.label)},ve=()=>{navigator.clipboard.writeText(JSON.stringify(Z,null,2)),alert("Debug info copied to clipboard")};return(0,Oo.jsxs)("div",{className:`Oo-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,Oo.jsxs)(Ce,{ref:F,className:"flex-1 Oo-4 bg-background border-0",onDragOver:Se,onDragLeave:d,onDrop:E,children:[(0,Oo.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Oo.jsx)(gt.animate,{children:e.map(u=>(0,Oo.jsx)(gt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Oo.jsx)(Ga,{from:u.role,children:(0,Oo.jsx)($a,{variant:"flat",children:Va({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),M&&(0,Oo.jsxs)(gt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Oo.jsx)(nt,{className:"Oo-8 w-8",children:(0,Oo.jsx)(st,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Oo.jsx)(_a.Bot,{className:"Oo-4 w-4"})})}),(0,Oo.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Oo.jsx)(ya,{capabilities:n,isOpen:M,onToggle:()=>_(!M),onActionSelect:X,className:"w-full"})})]}),o&&(0,Oo.jsxs)(gt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Oo.jsx)(nt,{className:"Oo-8 w-8",children:(0,Oo.jsx)(st,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Oo.jsx)(_a.Bot,{className:"Oo-4 w-4"})})}),(0,Oo.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Oo.jsxs)("div",{className:"flex space-x-1",children:[(0,Oo.jsx)("div",{className:"w-2 Oo-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Oo.jsx)("div",{className:"w-2 Oo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Oo.jsx)("div",{className:"w-2 Oo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Oo.jsx)("div",{ref:N})]}),i.length>0&&(0,Oo.jsx)("div",{className:"Oo-4 border-t bg-muted/10",children:(0,Oo.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,Oo.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Oo-2 border",children:[G(u.file.type),(0,Oo.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Oo.jsx)("span",{className:"text-xs text-muted-foreground",children:z(u.file.size)}),(0,Oo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"Oo-6 w-6 Oo-0",children:(0,Oo.jsx)(_a.X,{className:"Oo-4 w-4"})})]},u.id))})}),(0,Oo.jsxs)("div",{className:"border rounded-2xl Oo-4 bg-muted/20",children:[(0,Oo.jsxs)("div",{className:"flex gap-3",children:[(0,Oo.jsx)(wt,{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,Oo.jsx)(D,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl Oo-10 w-10 shadow-sm",children:(0,Oo.jsx)(_a.Paperclip,{className:"Oo-4 w-4"})}),(0,Oo.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl Oo-10 w-10 shadow-sm",children:(0,Oo.jsx)(_a.Send,{className:"Oo-4 w-4"})})]}),(0,Oo.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Oo.jsxs)(D,{onClick:()=>_(!M),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Oo.jsx)(_a.Menu,{className:"Oo-3 w-3 mr-1"}),M?"Hide":"Show"," Capabilities"]}),(0,Oo.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,Oo.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,Oo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,Oo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:ve,children:"Debug"})]})]}),s&&(0,Oo.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:B,className:"hidden"})]})]})}function ot({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:I=()=>{},onRemoveAll:T=()=>{},onActionClick:C=()=>{},onSearch:N=E=>console.log("Search query:",E),initialTeam:F="design",currentSession:S=null,showCapabilities:M=!0,title:_="Digital Colleagues",enableFileUpload:$=!0,maxFileSize:le=10,allowedFileTypes:J=["image/*","text/*","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],logo:W="/headerlogo.png",appName:X="Nuvia",tagline:ce="AI-Powered Workspace",actionIcon:B=(0,Oo.jsx)(_a.Users,{className:"mr-2 Oo-4 w-4"}),actionText:Se="Collaborate",sidebarInitiallyClosed:d=!1}){let E={...e,onError:H=>{G?.setMessages(pe=>[...pe,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:H.message}]}]),console.error("Error in CopilotInterface:",H)}},z=(0,Do.useChat)(E||{}),G=o?t||z:null,[Z,ve]=(0,ft.useState)(""),[u,U]=(0,ft.useState)(!1),he=G?.messages||a,Ae=Z,Ja=G?.status==="submitted"||u,Xa=G?.addToolResult?(H,pe,ae)=>{G.addToolResult({tool:pe,toolCallId:H,output:ae}),G.sendMessage()}:()=>{},vt=n||[],Qa={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"},[Ya,Za]=(0,ft.useState)(()=>vt.length===0?Qa:vt.find(H=>H.id===F)||vt[0]),[ht,Dt]=(0,ft.useState)([]),[ei,ti]=(0,ft.useState)(!1),oi=H=>{if(!H||!$)return;let pe=[];Array.from(H).forEach(ae=>{if(ae.size>le*1024*1024){alert(`File ${ae.name} is too large. Maximum size is ${le}MB.`);return}if(J.length>0&&!J.some(Rt=>ae.type.match(Rt))){alert(`File type ${ae.type} is not allowed.`);return}let So={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ae,status:"pending",progress:0};if(ae.type.startsWith("image/")){let Rt=new FileReader;Rt.onload=si=>{Dt(li=>li.map(Yt=>Yt.id===So.id?{...Yt,preview:si.target?.result}:Yt))},Rt.readAsDataURL(ae)}pe.push(So)}),Dt(ae=>[...ae,...pe])},ai=H=>{Dt(pe=>pe.filter(ae=>ae.id!==H))},Ro=()=>{if(!(!Ae.trim()&&ht.length===0)){if(G){let H=ht.length>0?ii(ht.map(pe=>pe.file)):void 0;G.sendMessage({text:Ae,files:H},{body:{timestamp:Date.now()}}),ve("")}else console.log("Message to send:",Ae),console.log("Files to upload:",ht),ve(""),U(!0),setTimeout(()=>{U(!1)},1500);Dt([])}},ii=H=>{let pe=new DataTransfer;return H.forEach(ae=>pe.items.add(ae)),pe.files},ri=H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),Ro())},ni=H=>{ve(H)};return(0,Oo.jsx)(ba,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:vt,currentBusinessUnit:Ya,onBusinessUnitChange:H=>{H&&(Za(H),R?.(H))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:B,actionText:Se,onNotificationRemove:I,onRemoveAll:T,logo:W,appName:X,tagline:ce,sidebarInitiallyClosed:d,children:(0,Oo.jsx)(Qt.AnimatePresence,{mode:"wait",children:(0,Oo.jsx)(Qt.motion.div,{className:"flex-1 Oo-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,Oo.jsxs)("div",{className:"Oo-full flex",children:[(0,Oo.jsx)("div",{className:"w-80 flex-shrink-0 Oo-full Oo-2",children:(0,Oo.jsx)(va,{sessions:c||[],currentSession:S,teams:vt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,Oo.jsx)("div",{className:"flex-1 Oo-full Oo-2",children:(0,Oo.jsx)(qa,{messages:he||[],input:Ae,isTyping:Ja,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:ni,addToolResult:Xa,onSendMessage:Ro,onKeyPress:ri,fileUploads:ht,isDragOver:ei,enableFileUpload:$,onFileUpload:oi,onRemoveFile:ai,onDragOver:ti})})]})},"chat-interface")})})}var bt=[{id:"1",title:"AI Assistant Chat",lastMessage:"How can I help you today?"}];function xr(){return(0,Oo.jsx)(ot,{businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"AI-Powered Copilot"})}function wr(){return(0,Oo.jsx)(ot,{aiConfig:{onError:e=>console.error("Chat error:",e)},businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"Custom AI Copilot"})}function Cr(){return(0,Oo.jsx)(ot,{enableAI:!1,messages:[{id:"1",role:"assistant",parts:[{type:"text",text:"This is demo mode - no AI involved!"}]}],businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>console.log("New chat started"),onSessionSelect:t=>console.log("Session selected:",t),onSessionDelete:t=>console.log("Session deleted:",t),title:"Demo Copilot"})}function Nr(){let e=(0,Do.useChat)({onError:t=>console.error("Custom chat error:",t)});return(0,Oo.jsx)(ot,{useCustomChat:e,businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>{e.setMessages([]),console.log("New chat started - messages cleared")},onSessionSelect:t=>console.log("Session selected:",t),onSessionDelete:t=>console.log("Session deleted:",t),title:"Advanced AI Copilot"})}function kr(){return(0,Oo.jsx)(ot,{sidebarInitiallyClosed:!0,businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"Focused AI Chat"})}function Pr(){let e=(0,Do.useChat)({onError:t=>console.error("File upload chat error:",t),onFinish:t=>console.log("Message with files completed:",t)});return(0,Oo.jsx)(ot,{useCustomChat:e,enableAI:!0,enableFileUpload:!0,maxFileSize:10,allowedFileTypes:["image/*","text/*","application/pdf"],businessUnits:Me,capabilities:et,sidebarItems:_e,notifications:Je,sessions:bt,onNewChat:()=>{e.setMessages([]),console.log("New file upload chat started - messages cleared")},onSessionSelect:t=>console.log("Session selected:",t),onSessionDelete:t=>console.log("Session deleted:",t),title:"AI Copilot with File Uploads"})}0&&(module.exports={AdvancedAICopilot,CustomAICopilot,DemoCopilot,FileUploadAICopilot,FocusedChatCopilot,SimpleAICopilot});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";import{a as l}from"../../chunk-
|
|
2
|
+
"use strict";import{a as l}from"../../chunk-7JX3L2MA.mjs";import"../../chunk-CTTBF7F4.mjs";import"../../chunk-56X4PU43.mjs";import"../../chunk-DEVPAZSJ.mjs";import"../../chunk-QADUAIFH.mjs";import"../../chunk-EH3PJU6C.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{a as t,b as i,c as n}from"../../chunk-NPVUICIF.mjs";import"../../chunk-VDN4LQSS.mjs";import"../../chunk-FGEFYI5E.mjs";import"../../chunk-MU5WPW4N.mjs";import"../../chunk-AZKOVKSK.mjs";import{b as o}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{useChat as r}from"@ai-sdk/react";import{jsx as c}from"react/jsx-runtime";var a=[{id:"1",title:"AI Assistant Chat",lastMessage:"How can I help you today?"}];function C(){return c(l,{businessUnits:n,capabilities:o,sidebarItems:t,notifications:i,sessions:a,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"AI-Powered Copilot"})}function S(){return c(l,{aiConfig:{onError:e=>console.error("Chat error:",e)},businessUnits:n,capabilities:o,sidebarItems:t,notifications:i,sessions:a,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"Custom AI Copilot"})}function g(){return c(l,{enableAI:!1,messages:[{id:"1",role:"assistant",parts:[{type:"text",text:"This is demo mode - no AI involved!"}]}],businessUnits:n,capabilities:o,sidebarItems:t,notifications:i,sessions:a,onNewChat:()=>console.log("New chat started"),onSessionSelect:s=>console.log("Session selected:",s),onSessionDelete:s=>console.log("Session deleted:",s),title:"Demo Copilot"})}function h(){let e=r({onError:s=>console.error("Custom chat error:",s)});return c(l,{useCustomChat:e,businessUnits:n,capabilities:o,sidebarItems:t,notifications:i,sessions:a,onNewChat:()=>{e.setMessages([]),console.log("New chat started - messages cleared")},onSessionSelect:s=>console.log("Session selected:",s),onSessionDelete:s=>console.log("Session deleted:",s),title:"Advanced AI Copilot"})}function b(){return c(l,{sidebarInitiallyClosed:!0,businessUnits:n,capabilities:o,sidebarItems:t,notifications:i,sessions:a,onNewChat:()=>console.log("New chat started"),onSessionSelect:e=>console.log("Session selected:",e),onSessionDelete:e=>console.log("Session deleted:",e),title:"Focused AI Chat"})}function f(){let e=r({onError:s=>console.error("File upload chat error:",s),onFinish:s=>console.log("Message with files completed:",s)});return c(l,{useCustomChat:e,enableAI:!0,enableFileUpload:!0,maxFileSize:10,allowedFileTypes:["image/*","text/*","application/pdf"],businessUnits:n,capabilities:o,sidebarItems:t,notifications:i,sessions:a,onNewChat:()=>{e.setMessages([]),console.log("New file upload chat started - messages cleared")},onSessionSelect:s=>console.log("Session selected:",s),onSessionDelete:s=>console.log("Session deleted:",s),title:"AI Copilot with File Uploads"})}export{h as AdvancedAICopilot,S as CustomAICopilot,g as DemoCopilot,f as FileUploadAICopilot,b as FocusedChatCopilot,C as SimpleAICopilot};
|