cortex-react-components 2.18.2 → 2.18.3

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.
Files changed (126) hide show
  1. package/dist/{chunk-VRE6VCHX.mjs → chunk-2BR55L74.mjs} +1 -1
  2. package/dist/{chunk-WC7IAORY.mjs → chunk-33CHGT4N.mjs} +1 -1
  3. package/dist/{chunk-2E7GRMZB.mjs → chunk-3DZFESHK.mjs} +1 -1
  4. package/dist/{chunk-2WP44BWJ.mjs → chunk-3EGSOIRH.mjs} +1 -1
  5. package/dist/{chunk-5RKIC5BC.mjs → chunk-3ZQFJ5WD.mjs} +1 -1
  6. package/dist/{chunk-LYQOKIQY.mjs → chunk-4DR4ILAP.mjs} +1 -1
  7. package/dist/{chunk-DEO6EQJR.mjs → chunk-6EKGV4I2.mjs} +1 -1
  8. package/dist/{chunk-5GV4XVLP.mjs → chunk-ANCSWAD7.mjs} +1 -1
  9. package/dist/{chunk-DEVPAZSJ.mjs → chunk-AXPE5U2T.mjs} +1 -1
  10. package/dist/{chunk-64ODZI5O.mjs → chunk-CCJJAUGB.mjs} +1 -1
  11. package/dist/{chunk-GBKD2LF4.mjs → chunk-CH3CCSBB.mjs} +1 -1
  12. package/dist/{chunk-QUOSFCS5.mjs → chunk-CTC6WSB6.mjs} +1 -1
  13. package/dist/{chunk-ONZ32NDG.mjs → chunk-DX3G3FKT.mjs} +1 -1
  14. package/dist/{chunk-4BKAUTKL.mjs → chunk-GO42W2BM.mjs} +1 -1
  15. package/dist/{chunk-4RET4JGB.mjs → chunk-HHPTGV4F.mjs} +1 -1
  16. package/dist/{chunk-YTCTK24K.mjs → chunk-HLTP3ZQN.mjs} +1 -1
  17. package/dist/chunk-IFU7M7BO.mjs +1 -0
  18. package/dist/{chunk-ZIZENXBP.mjs → chunk-JNJJAJPI.mjs} +1 -1
  19. package/dist/{chunk-GYLFNLRD.mjs → chunk-MEVSHOG4.mjs} +1 -1
  20. package/dist/{chunk-PC2PZNJ6.mjs → chunk-MFUZNS7C.mjs} +1 -1
  21. package/dist/{chunk-4OROP5TC.mjs → chunk-MGSTQLZC.mjs} +1 -1
  22. package/dist/{chunk-O2RJFVGE.mjs → chunk-OXKN6X62.mjs} +1 -1
  23. package/dist/{chunk-RIRZRO6U.mjs → chunk-P55W6AFU.mjs} +1 -1
  24. package/dist/{chunk-SWEGT5SP.mjs → chunk-PAEL4O5F.mjs} +1 -1
  25. package/dist/{chunk-NN4QIXZ2.mjs → chunk-PTJVI53B.mjs} +1 -1
  26. package/dist/{chunk-HNHUOQGZ.mjs → chunk-QAJBJFRP.mjs} +1 -1
  27. package/dist/{chunk-DAAAZF3S.mjs → chunk-QILFMWE5.mjs} +1 -1
  28. package/dist/{chunk-DOPDVMNN.mjs → chunk-QZIJTAPO.mjs} +1 -1
  29. package/dist/{chunk-N6J2WFC4.mjs → chunk-R33MOMFK.mjs} +1 -1
  30. package/dist/{chunk-RZM6JZBZ.mjs → chunk-RMZLEIRP.mjs} +1 -1
  31. package/dist/{chunk-T5HJS6OF.mjs → chunk-RSDUFAIB.mjs} +1 -1
  32. package/dist/{chunk-TXVA6XJT.mjs → chunk-SRUG246N.mjs} +1 -1
  33. package/dist/{chunk-SJON62H2.mjs → chunk-VQBOJHZF.mjs} +1 -1
  34. package/dist/{chunk-UZSBX5GO.mjs → chunk-X3JZSN3W.mjs} +1 -1
  35. package/dist/{chunk-VNYUNZ3M.mjs → chunk-XGIYNUGC.mjs} +1 -1
  36. package/dist/{chunk-ENBMBLW4.mjs → chunk-XRW62PGB.mjs} +1 -1
  37. package/dist/{chunk-HPTE7BNH.mjs → chunk-XYJ4S67W.mjs} +1 -1
  38. package/dist/{chunk-7CY3QPBJ.mjs → chunk-YPSUDHCJ.mjs} +1 -1
  39. package/dist/{chunk-ZKOJRF5P.mjs → chunk-YWRU7OE3.mjs} +1 -1
  40. package/dist/components/Blocks/Banner.mjs +1 -1
  41. package/dist/components/Blocks/CallToAction.mjs +1 -1
  42. package/dist/components/Blocks/CollapsibleArea.mjs +1 -1
  43. package/dist/components/Blocks/Content.mjs +1 -1
  44. package/dist/components/Blocks/FeaturesBlock.mjs +1 -1
  45. package/dist/components/Blocks/ImageBlock.mjs +1 -1
  46. package/dist/components/Blocks/MediaBlock.mjs +1 -1
  47. package/dist/components/Blocks/RelatedPosts.mjs +1 -1
  48. package/dist/components/Blocks/RenderBlocks.mjs +1 -1
  49. package/dist/components/Blocks/ReusableContentBlock.mjs +1 -1
  50. package/dist/components/Blocks/index.mjs +1 -1
  51. package/dist/components/Cards/ContentCard.mjs +1 -1
  52. package/dist/components/Cards/FeatureCard.mjs +1 -1
  53. package/dist/components/Cards/index.mjs +1 -1
  54. package/dist/components/Chat/ChatInterface.js +1 -1
  55. package/dist/components/Chat/ChatInterface.mjs +1 -1
  56. package/dist/components/Chat/CopilotInterface.js +1 -1
  57. package/dist/components/Chat/CopilotInterface.mjs +1 -1
  58. package/dist/components/Chat/PartTypes/MessageHandler.d.ts +1 -1
  59. package/dist/components/Chat/PartTypes/MessageHandler.js +1 -1
  60. package/dist/components/Chat/PartTypes/MessageHandler.mjs +1 -1
  61. package/dist/components/Chat/PartTypes/index.mjs +1 -1
  62. package/dist/components/Chat/demo-long-messages.js +1 -1
  63. package/dist/components/Chat/demo-long-messages.mjs +1 -1
  64. package/dist/components/Chat/demo-tests.js +1 -1
  65. package/dist/components/Chat/demo-tests.mjs +1 -1
  66. package/dist/components/Chat/demo.js +1 -1
  67. package/dist/components/Chat/demo.mjs +1 -1
  68. package/dist/components/Chat/example-usage.js +1 -1
  69. package/dist/components/Chat/example-usage.mjs +1 -1
  70. package/dist/components/Chat/example-with-vercel-ai.js +1 -1
  71. package/dist/components/Chat/example-with-vercel-ai.mjs +1 -1
  72. package/dist/components/Chat/index.js +5 -5
  73. package/dist/components/Chat/index.mjs +1 -1
  74. package/dist/components/DigitalColleagues/index.mjs +1 -1
  75. package/dist/components/Foundary/Pages/dashboardpage.mjs +1 -1
  76. package/dist/components/Foundary/RichText/index.mjs +1 -1
  77. package/dist/components/Foundary/RichText/plugins/toolbar-plugin.mjs +1 -1
  78. package/dist/components/Foundary/Views/KnowledgeView.mjs +1 -1
  79. package/dist/components/Foundary/Views/index.mjs +1 -1
  80. package/dist/components/Foundary/document-edit.mjs +1 -1
  81. package/dist/components/Foundary/document-preview-examples.mjs +1 -1
  82. package/dist/components/Foundary/document-preview.mjs +1 -1
  83. package/dist/components/Foundary/index.mjs +1 -1
  84. package/dist/components/Foundary/knowledge-browser.mjs +1 -1
  85. package/dist/components/HeaderFooter/SectionHeading.mjs +1 -1
  86. package/dist/components/Heros/HighImpact/index.mjs +1 -1
  87. package/dist/components/Heros/LowImpact/index.mjs +1 -1
  88. package/dist/components/Heros/MediumImpact/index.mjs +1 -1
  89. package/dist/components/Heros/RenderHero.mjs +1 -1
  90. package/dist/components/Heros/index.mjs +1 -1
  91. package/dist/components/Layouts/OutputHeaderFooter.mjs +1 -1
  92. package/dist/components/Layouts/Print.mjs +1 -1
  93. package/dist/components/Layouts/SlideShow.mjs +1 -1
  94. package/dist/components/Layouts/index.mjs +1 -1
  95. package/dist/components/Payload/CollectionArchive/index.mjs +1 -1
  96. package/dist/components/Payload/Media/index.mjs +1 -1
  97. package/dist/components/Payload/PayloadCard/index.mjs +1 -1
  98. package/dist/components/Payload/RichText/index.mjs +1 -1
  99. package/dist/components/Payload/RichText/serialize.mjs +1 -1
  100. package/dist/components/Payload/index.mjs +1 -1
  101. package/dist/components/index.js +5 -5
  102. package/dist/components/index.mjs +1 -1
  103. package/dist/index.js +6 -6
  104. package/dist/index.mjs +1 -1
  105. package/dist/metafile-cjs.json +1 -1
  106. package/dist/metafile-esm.json +1 -1
  107. package/dist/pages/Blog.mjs +1 -1
  108. package/dist/pages/IndexPage.mjs +1 -1
  109. package/dist/pages/LandingPage.mjs +1 -1
  110. package/dist/pages/Page.mjs +1 -1
  111. package/dist/pages/Publish.mjs +1 -1
  112. package/dist/pages/Website.mjs +1 -1
  113. package/dist/sections/AboutSection.mjs +1 -1
  114. package/dist/sections/BlogDetail.mjs +1 -1
  115. package/dist/sections/BlogList.mjs +1 -1
  116. package/dist/sections/BlogListSection.mjs +1 -1
  117. package/dist/sections/ContactSection.mjs +1 -1
  118. package/dist/sections/PageSections.mjs +1 -1
  119. package/dist/sections/PricingSection.mjs +1 -1
  120. package/dist/sections/ServiceDetail.mjs +1 -1
  121. package/dist/sections/ServiceDetailSection.mjs +1 -1
  122. package/dist/sections/ServiceSection.mjs +1 -1
  123. package/dist/sections/form/index.mjs +1 -1
  124. package/dist/sections/index.mjs +1 -1
  125. package/package.json +1 -1
  126. package/dist/chunk-QADUAIFH.mjs +0 -1
@@ -18,4 +18,4 @@
18
18
  `,children:n?"Processing...":"Deny"}),(0,Be.jsx)("button",{onClick:h,disabled:n,className:`
19
19
  px-4 py-2 text-white border-none rounded text-sm
20
20
  ${n?"bg-gray-400 cursor-not-allowed":"bg-gray-500 hover:bg-gray-600 cursor-pointer"}
21
- `,children:"Cancel"})]})]}):null};var Dt=({toolPart:e,index:t,addToolResult:o})=>{let[r,s]=tt.default.useState(!0),[a,n]=tt.default.useState(null),i=()=>{o(e.input?.toolCallId,e.input?.tool,"Approved"),s(!1),n("approve")},c=()=>{o(e.input?.toolCallId,e.input?.tool,"Denied"),s(!1),n("deny")};switch(e.state){case"input-available":return(0,Be.jsxs)("div",{className:"mb-2",children:[(0,Be.jsx)(Lt,{isOpen:r,onApprove:i,onDeny:c,onClose:()=>s(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!r&&(0,Be.jsxs)(Be.Fragment,{children:[a==="approve"&&(0,Be.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Be.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,Be.jsx)("svg",{className:"h-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Be.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),a==="deny"&&(0,Be.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Be.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,Be.jsx)("svg",{className:"h-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Be.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Be.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var ot=require("@radix-ui/react-use-controllable-state");var he=V(require("@radix-ui/react-collapsible")),He=he.Root,Oe=he.CollapsibleTrigger,Fe=he.CollapsibleContent;var zt=require("streamdown"),Te=(0,_.memo)(({className:e,...t})=>(0,Be.jsx)(zt.Streamdown,{className:d("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);Te.displayName="Response";var Ht=(0,_.createContext)(null),_o=()=>{let e=(0,_.useContext)(Ht);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},qo=1e3,Ko=1e3,rt=(0,_.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:r=!0,onOpenChange:s,duration:a,children:n,...i})=>{let[c,g]=(0,ot.useControllableState)({prop:o,defaultProp:r,onChange:s}),[h,f]=(0,ot.useControllableState)({prop:a,defaultProp:0}),[v,R]=(0,_.useState)(!1),[P,x]=(0,_.useState)(null);(0,_.useEffect)(()=>{t?P===null&&x(Date.now()):P!==null&&(f(Math.ceil((Date.now()-P)/Ko)),x(null))},[t,P,f]),(0,_.useEffect)(()=>{if(r&&!t&&c&&!v){let C=setTimeout(()=>{g(!1),R(!0)},qo);return()=>clearTimeout(C)}},[t,c,r,g,v]);let y=C=>{g(C)};return(0,Be.jsx)(Ht.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:g,duration:h},children:(0,Be.jsx)(He,{className:d("not-prose mb-4",e),onOpenChange:y,open:c,...i,children:n})})}),Jo=(e,t)=>e||t===0?(0,Be.jsx)("Be",{children:"Thinking..."}):t===void 0?(0,Be.jsx)("Be",{children:"Thought for a few seconds"}):(0,Be.jsxs)("Be",{children:["Thought for ",t," seconds"]}),at=(0,_.memo)(({className:e,children:t,...o})=>{let{isStreaming:r,isOpen:s,duration:a}=_o();return(0,Be.jsx)(Oe,{className:d("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)(I.BrainIcon,{className:"size-4"}),Jo(r,a),(0,Be.jsx)(I.ChevronDownIcon,{className:d("size-4 transition-transform",s?"rotate-180":"rotate-0")})]})})}),nt=(0,_.memo)(({className:e,children:t,...o})=>(0,Be.jsx)(Fe,{className:d("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,Be.jsx)(Te,{className:"grid gap-2",children:t})}));rt.displayName="Reasoning";at.displayName="ReasoningTrigger";nt.displayName="ReasoningContent";var st=require("react-syntax-highlighter"),Ge=require("react-syntax-highlighter/dist/esm/styles/prism"),Qo=(0,_.createContext)({code:""}),$e=({code:e,language:t,showLineNumbers:o=!1,className:r,children:s,...a})=>(0,Be.jsx)(Qo.Provider,{value:{code:e},children:(0,Be.jsx)("div",{className:d("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",r),...a,children:(0,Be.jsxs)("div",{className:"relative",children:[(0,Be.jsx)(st.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:Ge.oneLight,children:e}),(0,Be.jsx)(st.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:Ge.oneDark,children:e}),s&&(0,Be.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:s})]})})});var Ft=({className:e,...t})=>(0,Be.jsx)(He,{className:d("not-prose mb-4 w-full",e),...t}),Xo=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Be.jsxs)(X,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Be.jsx)(I.CircleIcon,{className:"size-4"}),"input-available":(0,Be.jsx)(I.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Be.jsx)(I.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Be.jsx)(I.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Vt=({className:e,type:t,state:o,...r})=>(0,Be.jsxs)(Oe,{className:d("flex w-full items-center justify-between gap-4 Be-3 pl-0 w-2xl",e),...r,children:[(0,Be.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Be.jsx)(I.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Be.jsx)("span",{className:"font-medium text-sm",children:t}),Xo(o)]}),(0,Be.jsx)(I.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Ut=({className:e,...t})=>(0,Be.jsx)(Fe,{className:d("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}),Gt=({className:e,input:t,...o})=>(0,Be.jsxs)("div",{className:d("space-y-2 overflow-hidden Be-4",e),...o,children:[(0,Be.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Be.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Be.jsx)($e,{code:JSON.stringify(t,null,2),language:"json"})})]}),$t=({className:e,output:t,errorText:o,...r})=>{if(!(t||o))return null;let s=(0,Be.jsx)("div",{children:t});return typeof t=="object"?s=(0,Be.jsx)($e,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(s=(0,Be.jsx)($e,{code:t,language:"json"})),(0,Be.jsxs)("div",{className:d("space-y-2 Be-4",e),...r,children:[(0,Be.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Be.jsxs)("div",{className:d("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[o&&(0,Be.jsx)("div",{children:o}),s]})]})};var de=V(require("react"));var $=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("rounded-xl border bg-card text-card-foreground shadow",e),...t}));$.displayName="Card";var te=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("flex flex-col space-y-1.5 Be-6",e),...t}));te.displayName="CardHeader";var oe=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("font-semibold leading-none tracking-tight",e),...t}));oe.displayName="CardTitle";var it=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("text-sm text-muted-foreground",e),...t}));it.displayName="CardDescription";var j=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("Be-6 pt-0",e),...t}));j.displayName="CardContent";var Re=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("flex items-center Be-6 pt-0",e),...t}));Re.displayName="CardFooter";var _t=require("date-fns");function jt({taskId:e,polling:t=!0,system:o="payload"}){let[r,s]=(0,_.useState)(null),[a,n]=(0,_.useState)(!1),[i,c]=(0,_.useState)(null),g=async(f=!0)=>{if(e){f&&n(!0);try{let v=await fetch(`/api/tasks/${e}`);if(!v.ok)throw new Error(`Failed to fetch task: ${v.statusText}`);let R=await v.json();s(R)}catch(v){console.error("Error fetching task:",v),c(v instanceof Error?v:new Error("Unknown error occurred"))}finally{f&&n(!1)}}},h=()=>g(!1);return(0,_.useEffect)(()=>{e&&g(!0);let f=null;return e&&t&&(f=setInterval(h,5e3)),()=>{f&&clearInterval(f)}},[e,t]),{task:r,loading:a,error:i}}var Yo=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"}},Zo=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function qt({data:e}){let{id:t,system:o,fetchLatest:r,taskData:s,error:a}=e||{};if(!t)return null;let n=null,i=!0,c=a,g=r!==void 0?r:!0;if(n=s||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:r,system:o,fetchLatest:g,taskData:n,error:c}),g){let{task:R,loading:P,error:x}=jt({taskId:t,system:o});n=R,i=P,c=x}else i=!1;let h=Yo(n?.status||"todo"),f=Zo(n?.status||"todo"),v=n?.dateLogged||new Date().toISOString();try{let R=new Date(n?.dateLogged||"");isNaN(R.getTime())||(v=(0,_t.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Be.jsxs)($,{className:d("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Be.jsxs)(te,{className:"pb-2",children:[(0,Be.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Be.jsx)(oe,{className:"text-lg font-semibold",children:i?"Loading...":n?.name||"Task"}),(0,Be.jsx)(X,{className:`${h}`,children:f})]}),n?.project&&(0,Be.jsxs)(it,{className:"text-sm text-gray-500",children:["Project: ",n.project.name]})]}),(0,Be.jsx)(j,{className:"pb-2",children:i?(0,Be.jsx)("div",{className:"animate-pulse h-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Be.jsx)("Be",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Be.jsx)("Be",{className:"text-sm text-foreground",children:n?.description||"......."})}),(0,Be.jsx)(Re,{className:"pt-2 flex items-center justify-between",children:(0,Be.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Be.jsx)(I.Clock,{className:"h-3 w-3 mr-1"}),(0,Be.jsxs)("span",{children:["Created ",v]}),(0,Be.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Be.jsxs)("span",{children:["Task #",t]})]})})]})}function Qt({artefact:e,taskId:t,taskData:o,loading:r=!1,error:s=null}){let a=o||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},n=a.dateLogged;try{let i=new Date(a.dateLogged);isNaN(i.getTime())||(n=(0,_t.formatDistanceToNow)(i,{addSuffix:!0}))}catch{}return(0,Be.jsxs)($,{className:"w-full max-w-md shadow-md",children:[(0,Be.jsx)(te,{className:"pb-2",children:(0,Be.jsx)("div",{className:"flex justify-between items-start",children:(0,Be.jsx)(oe,{className:"text-lg font-semibold",children:r?"Loading...":a.name})})}),(0,Be.jsx)(j,{className:"pb-2",children:r?(0,Be.jsx)("div",{className:"animate-pulse h-4 bg-gray-200 rounded w-3/4 mb-2"}):s?(0,Be.jsx)("Be",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Be.jsx)("Be",{className:"text-sm text-foreground",children:e})}),(0,Be.jsx)(Re,{className:"pt-2 flex items-center justify-between",children:(0,Be.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Be.jsx)(I.Clock,{className:"h-3 w-3 mr-1"}),(0,Be.jsxs)("span",{children:["Created ",n]}),(0,Be.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Be.jsxs)("span",{children:["Task #",a.id]})]})})]})}var er=e=>e.startsWith("image/")?(0,Be.jsx)(I.Image,{className:"h-4 w-4"}):e.startsWith("text/")?(0,Be.jsx)(I.FileText,{className:"h-4 w-4"}):(0,Be.jsx)(I.File,{className:"h-4 w-4"}),Xt=({message:e,addToolResult:t,status:o,messages:r})=>e.parts.map((s,a)=>{if(s.type==="text")return(0,Be.jsx)(Te,{children:s.text},`${a}`);if(s.type==="file"){let n=s;return(0,Be.jsx)("div",{className:"mb-2 Be-2 bg-background/50 rounded-lg",children:(0,Be.jsxs)("div",{className:"flex items-center gap-2",children:[er(n.mediaType||"application/octet-stream"),(0,Be.jsx)("div",{className:"flex-1 min-w-0",children:(0,Be.jsx)("Be",{className:"text-sm font-medium truncate",children:n.filename||n.url?.split("/").pop()||"File"})}),n.url&&(0,Be.jsx)(z,{variant:"ghost",size:"sm",onClick:()=>window.open(n.url,"_blank"),className:"h-8 w-8 Be-0",children:(0,Be.jsx)(I.Download,{className:"h-4 w-4"})})]})},a)}if(s.type.startsWith("tool-")){let n=s,i=s.type.replace("tool-","");if(i==="task")switch(n.state){case"input-available":return(0,Be.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},a);case"output-available":return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(qt,{data:{id:n.output?.id||n.input?.id,fetchLatest:!1,taskData:n.output||n.input}})},a);case"output-error":return(0,Be.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",n.errorText]},a);default:return null}if(s.type==="tool-requestEndpointLogin")return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(et,{toolPart:n,index:a,addToolResult:t??(()=>{})})},a);if(s.type==="tool-authenticate")return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(et,{toolPart:n,index:a,addToolResult:t??(()=>{})})},a);if(s.type==="tool-requestApproval")return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(Dt,{toolPart:n,index:a,addToolResult:t??(()=>{})})},a);if(i==="artefact")switch(n.state){case"input-available":return(0,Be.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},a);case"output-available":return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(Qt,{artefact:n.output?.description||"",taskId:n.output?.id||n.input?.id,taskData:n.output||n.input})},a);case"output-error":return(0,Be.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",n.errorText]},a);default:return null}return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsxs)($,{className:"w-full max-w-md",children:[(0,Be.jsx)(te,{children:(0,Be.jsx)(oe,{className:"text-lg",children:i})}),(0,Be.jsxs)(j,{children:[n.state==="input-available"&&(0,Be.jsxs)("Be",{className:"text-sm",children:["Processing ",i,"..."]}),n.state==="output-available"&&(0,Be.jsx)("pre",{className:"text-sm",children:JSON.stringify(n.output,null,2)}),n.state==="output-error"&&(0,Be.jsxs)("Be",{className:"text-sm text-red-500",children:["Error: ",n.errorText]})]})]})},a)}if(s.type.startsWith("data-")){let n=s,i=s.type.replace("data-","");return i==="reference"?(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)($,{className:"w-full",children:(0,Be.jsx)(j,{className:"Be-4",children:(0,Be.jsx)("div",{className:"space-y-2",children:n.data?.references?.map((c,g)=>(0,Be.jsxs)("div",{className:"flex items-center gap-2 Be-2 rounded-md bg-muted/50",children:[(0,Be.jsx)(X,{variant:"outline",children:c.type||"link"}),(0,Be.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Be.jsx)("Be",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Be.jsx)("Be",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Be.jsx)(z,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"h-8 w-8 Be-0",children:(0,Be.jsx)(I.ExternalLink,{className:"h-4 w-4"})})]},g))})})})},a):i==="menu"?(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsxs)($,{className:"w-full",children:[(0,Be.jsx)(te,{children:(0,Be.jsx)(oe,{className:"text-lg",children:n.data?.title})}),(0,Be.jsx)(j,{children:(0,Be.jsx)("div",{className:"space-y-2",children:n.data?.items?.map((c,g)=>(0,Be.jsx)(z,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Be.jsxs)("div",{className:"text-left",children:[(0,Be.jsx)("Be",{className:"font-medium",children:c.label}),c.description&&(0,Be.jsx)("Be",{className:"text-xs text-muted-foreground",children:c.description})]})},g))})})]})},a):(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsxs)($,{className:"w-full max-w-md",children:[(0,Be.jsx)(te,{children:(0,Be.jsx)(oe,{className:"text-lg",children:i})}),(0,Be.jsx)(j,{children:(0,Be.jsx)("pre",{className:"text-sm",children:JSON.stringify(n.data,null,2)})})]})},a)}return s.type==="reasoning"?(0,Be.jsxs)(rt,{className:"w-full",isStreaming:o==="streaming"&&a===e.parts.length-1&&e.id===r.at(-1)?.id,children:[(0,Be.jsx)(at,{}),(0,Be.jsx)(nt,{children:s.text})]},`${a}`):s.type==="dynamic-tool"?(0,Be.jsxs)(Ft,{defaultOpen:s.state!=="output-available",children:[(0,Be.jsx)(Vt,{type:`tool-${s.toolName}`,state:s.state}),(0,Be.jsxs)(Ut,{children:[(0,Be.jsx)(Gt,{input:s.input}),(0,Be.jsx)($t,{output:s.output,errorText:s.errorText})]})]},`${e.id}-${a}`):(0,Be.jsxs)(Be.Fragment,{children:["Unknown part type: ",s.type]})});var Zt=({className:e,from:t,...o})=>(0,Be.jsx)("div",{className:d("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}),tr=(0,yt.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"}}),eo=({children:e,className:t,variant:o,...r})=>(0,Be.jsx)("div",{className:d(tr({variant:o,className:t})),...r,children:e});function or({messages:e,input:t,isTyping:o=!1,currentSessionTitle:r,capabilities:s,fileUploads:a,isDragOver:n,enableFileUpload:i,onInputChange:c,addToolResult:g,onSendMessage:h,onKeyPress:f,onFileUpload:v,onRemoveFile:R,onDragOver:P,className:x,status:y="ready"}){let C=(0,_.useRef)(null),E=(0,_.useRef)(null),A=(0,_.useRef)(null),[S,q]=(0,_.useState)(!1),[ue,We]=(0,_.useState)({path:[],selectedItems:[],filters:{}});(0,_.useEffect)(()=>{C.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,_.useEffect)(()=>{S&&setTimeout(()=>{C.current?.scrollIntoView({behavior:"smooth"})},100)},[S]);let Ce=()=>Ye(ue),me=()=>{let u=[];return s.forEach(T=>{T.actions&&T.actions.forEach(K=>{u.push({label:K.label,action:()=>ie(K.id,{path:[T],selectedItems:[],filters:{}})})}),T.children&&T.children.forEach(K=>{K.type==="list"&&K.data&&u.push({label:`View ${K.name}`,action:()=>q(!0)})})}),u.slice(0,5)},ie=(u,T)=>{console.log("Capability action:",u,T);let K=`Executing ${u} with context: ${JSON.stringify(T.path.map(Ie=>Ie.name))}`;q(!1)},we=Ye({path:[],selectedItems:[],filters:{}}),w=u=>{v(u.target.files),u.target.files&&(u.target.value="")},Ae=u=>{u.preventDefault(),P(!0)},ge=u=>{u.preventDefault(),P(!1)},Se=u=>{u.preventDefault(),P(!1),v(u.dataTransfer.files)},fe=u=>{if(u===0)return"0 Bytes";let T=1024,K=["Bytes","KB","MB","GB"],Ie=Math.floor(Math.log(u)/Math.log(T));return parseFloat((u/Math.pow(T,Ie)).toFixed(2))+" "+K[Ie]},Me=u=>u.startsWith("image/")?(0,Be.jsx)(I.Image,{className:"h-4 w-4"}):u.startsWith("text/")?(0,Be.jsx)(I.FileText,{className:"h-4 w-4"}):(0,Be.jsx)(I.File,{className:"h-4 w-4"}),Ne={messages:e,currentSessionTitle:r,capabilities:s,currentCapabilityContext:ue,contextualActions:we,getQuickSuggestions:me().map(u=>u.label)},le=()=>{navigator.clipboard.writeText(JSON.stringify(Ne,null,2)),alert("Debug info copied to clipboard")};return(0,Be.jsxs)("div",{className:`h-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${x||""}`,children:[(0,Be.jsxs)(Xe,{ref:E,className:"flex-1 Be-4 bg-background border-0",onDragOver:Ae,onDragLeave:ge,onDrop:Se,children:[(0,Be.jsxs)("div",{className:d("space-y-4",n&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Be.jsx)(xe.animate,{children:e.map(u=>(0,Be.jsx)(xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Be.jsx)(Zt,{from:u.role,children:(0,Be.jsx)(eo,{variant:"flat",children:Xt({message:u,addToolResult:g??(()=>{}),status:y,messages:e})})},u.id)},u.id))}),S&&(0,Be.jsxs)(xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Be.jsx)(Ee,{className:"h-8 w-8",children:(0,Be.jsx)(ze,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Be.jsx)(I.Bot,{className:"h-4 w-4"})})}),(0,Be.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Be.jsx)(At,{capabilities:s,isOpen:S,onToggle:()=>q(!S),onActionSelect:ie,className:"w-full"})})]}),o&&(0,Be.jsxs)(xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Be.jsx)(Ee,{className:"h-8 w-8",children:(0,Be.jsx)(ze,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Be.jsx)(I.Bot,{className:"h-4 w-4"})})}),(0,Be.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Be.jsxs)("div",{className:"flex space-x-1",children:[(0,Be.jsx)("div",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Be.jsx)("div",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Be.jsx)("div",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Be.jsx)("div",{ref:C})]}),a.length>0&&(0,Be.jsx)("div",{className:"Be-4 border-t bg-muted/10",children:(0,Be.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(u=>(0,Be.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Be-2 border",children:[Me(u.file.type),(0,Be.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Be.jsx)("span",{className:"text-xs text-muted-foreground",children:fe(u.file.size)}),(0,Be.jsx)(z,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"h-6 w-6 Be-0",children:(0,Be.jsx)(I.X,{className:"h-4 w-4"})})]},u.id))})}),(0,Be.jsxs)("div",{className:"border rounded-2xl Be-4 bg-muted/20",children:[(0,Be.jsxs)("div",{className:"flex gap-3",children:[(0,Be.jsx)(Je,{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}),i&&(0,Be.jsx)(z,{variant:"outline",size:"icon",onClick:()=>A.current?.click(),className:"rounded-2xl h-10 w-10 shadow-sm",children:(0,Be.jsx)(I.Paperclip,{className:"h-4 w-4"})}),(0,Be.jsx)(z,{onClick:h,disabled:!t.trim()&&a.length===0||o,size:"icon",className:"rounded-2xl h-10 w-10 shadow-sm",children:(0,Be.jsx)(I.Send,{className:"h-4 w-4"})})]}),(0,Be.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Be.jsxs)(z,{onClick:()=>q(!S),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Be.jsx)(I.Menu,{className:"h-3 w-3 mr-1"}),S?"Hide":"Show"," Capabilities"]}),(0,Be.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[Ce().map((u,T)=>(0,Be.jsx)(z,{variant:"default",size:"sm",className:"rounded-full text-xs bg-accent hover:bg-accent/80",onClick:()=>ie(u.id,ue),children:u.label},`context-${u.id}`)),Ce().length===0&&me().map((u,T)=>(0,Be.jsx)(z,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${T}`)),(0,Be.jsx)(z,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:le,children:"Debug"})]})]}),i&&(0,Be.jsx)("input",{ref:A,type:"file",multiple:!0,onChange:w,className:"hidden"})]})]})}0&&(module.exports={ChatInterface});
21
+ `,children:"Cancel"})]})]}):null};var Dt=({toolPart:e,index:t,addToolResult:o})=>{let[r,s]=tt.default.useState(!0),[a,n]=tt.default.useState(null),i=()=>{o(e.input?.toolCallId,e.input?.tool,"Approved"),s(!1),n("approve")},c=()=>{o(e.input?.toolCallId,e.input?.tool,"Denied"),s(!1),n("deny")};switch(e.state){case"input-available":return(0,Be.jsxs)("div",{className:"mb-2",children:[(0,Be.jsx)(Lt,{isOpen:r,onApprove:i,onDeny:c,onClose:()=>s(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!r&&(0,Be.jsxs)(Be.Fragment,{children:[a==="approve"&&(0,Be.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Be.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,Be.jsx)("svg",{className:"h-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Be.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),a==="deny"&&(0,Be.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Be.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,Be.jsx)("svg",{className:"h-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Be.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Be.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var ot=require("@radix-ui/react-use-controllable-state");var he=V(require("@radix-ui/react-collapsible")),He=he.Root,Oe=he.CollapsibleTrigger,Fe=he.CollapsibleContent;var zt=require("streamdown"),Te=(0,_.memo)(({className:e,...t})=>(0,Be.jsx)(zt.Streamdown,{className:d("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);Te.displayName="Response";var Ht=(0,_.createContext)(null),_o=()=>{let e=(0,_.useContext)(Ht);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},qo=1e3,Ko=1e3,rt=(0,_.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:r=!0,onOpenChange:s,duration:a,children:n,...i})=>{let[c,g]=(0,ot.useControllableState)({prop:o,defaultProp:r,onChange:s}),[h,f]=(0,ot.useControllableState)({prop:a,defaultProp:0}),[v,R]=(0,_.useState)(!1),[P,x]=(0,_.useState)(null);(0,_.useEffect)(()=>{t?P===null&&x(Date.now()):P!==null&&(f(Math.ceil((Date.now()-P)/Ko)),x(null))},[t,P,f]),(0,_.useEffect)(()=>{if(r&&!t&&c&&!v){let C=setTimeout(()=>{g(!1),R(!0)},qo);return()=>clearTimeout(C)}},[t,c,r,g,v]);let y=C=>{g(C)};return(0,Be.jsx)(Ht.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:g,duration:h},children:(0,Be.jsx)(He,{className:d("not-prose mb-4",e),onOpenChange:y,open:c,...i,children:n})})}),Jo=(e,t)=>e||t===0?(0,Be.jsx)("Be",{children:"Thinking..."}):t===void 0?(0,Be.jsx)("Be",{children:"Thought for a few seconds"}):(0,Be.jsxs)("Be",{children:["Thought for ",t," seconds"]}),at=(0,_.memo)(({className:e,children:t,...o})=>{let{isStreaming:r,isOpen:s,duration:a}=_o();return(0,Be.jsx)(Oe,{className:d("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,Be.jsxs)(Be.Fragment,{children:[(0,Be.jsx)(I.BrainIcon,{className:"size-4"}),Jo(r,a),(0,Be.jsx)(I.ChevronDownIcon,{className:d("size-4 transition-transform",s?"rotate-180":"rotate-0")})]})})}),nt=(0,_.memo)(({className:e,children:t,...o})=>(0,Be.jsx)(Fe,{className:d("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,Be.jsx)(Te,{className:"grid gap-2",children:t})}));rt.displayName="Reasoning";at.displayName="ReasoningTrigger";nt.displayName="ReasoningContent";var st=require("react-syntax-highlighter"),Ge=require("react-syntax-highlighter/dist/esm/styles/prism"),Qo=(0,_.createContext)({code:""}),$e=({code:e,language:t,showLineNumbers:o=!1,className:r,children:s,...a})=>(0,Be.jsx)(Qo.Provider,{value:{code:e},children:(0,Be.jsx)("div",{className:d("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",r),...a,children:(0,Be.jsxs)("div",{className:"relative",children:[(0,Be.jsx)(st.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:Ge.oneLight,children:e}),(0,Be.jsx)(st.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:Ge.oneDark,children:e}),s&&(0,Be.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:s})]})})});var Ft=({className:e,...t})=>(0,Be.jsx)(He,{className:d("not-prose mb-4 w-full",e),...t}),Xo=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Be.jsxs)(X,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Be.jsx)(I.CircleIcon,{className:"size-4"}),"input-available":(0,Be.jsx)(I.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Be.jsx)(I.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Be.jsx)(I.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},Vt=({className:e,type:t,state:o,...r})=>(0,Be.jsxs)(Oe,{className:d("flex w-full items-center justify-between gap-4 Be-3 pl-0 w-2xl",e),...r,children:[(0,Be.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Be.jsx)(I.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Be.jsx)("span",{className:"font-medium text-sm",children:t}),Xo(o)]}),(0,Be.jsx)(I.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Ut=({className:e,...t})=>(0,Be.jsx)(Fe,{className:d("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}),Gt=({className:e,input:t,...o})=>(0,Be.jsxs)("div",{className:d("space-y-2 overflow-hidden Be-4",e),...o,children:[(0,Be.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Be.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Be.jsx)($e,{code:JSON.stringify(t,null,2),language:"json"})})]}),$t=({className:e,output:t,errorText:o,...r})=>{if(!(t||o))return null;let s=(0,Be.jsx)("div",{children:t});return typeof t=="object"?s=(0,Be.jsx)($e,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(s=(0,Be.jsx)($e,{code:t,language:"json"})),(0,Be.jsxs)("div",{className:d("space-y-2 Be-4",e),...r,children:[(0,Be.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Be.jsxs)("div",{className:d("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[o&&(0,Be.jsx)("div",{children:o}),s]})]})};var de=V(require("react"));var $=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("rounded-xl border bg-card text-card-foreground shadow",e),...t}));$.displayName="Card";var te=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("flex flex-col space-y-1.5 Be-6",e),...t}));te.displayName="CardHeader";var oe=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("font-semibold leading-none tracking-tight",e),...t}));oe.displayName="CardTitle";var it=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("text-sm text-muted-foreground",e),...t}));it.displayName="CardDescription";var j=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("Be-6 pt-0",e),...t}));j.displayName="CardContent";var Re=de.forwardRef(({className:e,...t},o)=>(0,Be.jsx)("div",{ref:o,className:d("flex items-center Be-6 pt-0",e),...t}));Re.displayName="CardFooter";var _t=require("date-fns");function jt({taskId:e,polling:t=!0,system:o="payload"}){let[r,s]=(0,_.useState)(null),[a,n]=(0,_.useState)(!1),[i,c]=(0,_.useState)(null),g=async(f=!0)=>{if(e){f&&n(!0);try{let v=await fetch(`/api/tasks/${e}`);if(!v.ok)throw new Error(`Failed to fetch task: ${v.statusText}`);let R=await v.json();s(R)}catch(v){console.error("Error fetching task:",v),c(v instanceof Error?v:new Error("Unknown error occurred"))}finally{f&&n(!1)}}},h=()=>g(!1);return(0,_.useEffect)(()=>{e&&g(!0);let f=null;return e&&t&&(f=setInterval(h,5e3)),()=>{f&&clearInterval(f)}},[e,t]),{task:r,loading:a,error:i}}var Yo=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"}},Zo=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function qt({data:e}){let{id:t,system:o,fetchLatest:r,taskData:s,error:a}=e||{};if(!t)return null;let n=null,i=!0,c=a,g=r!==void 0?r:!0;if(n=s||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:r,system:o,fetchLatest:g,taskData:n,error:c}),g){let{task:R,loading:P,error:x}=jt({taskId:t,system:o});n=R,i=P,c=x}else i=!1;let h=Yo(n?.status||"todo"),f=Zo(n?.status||"todo"),v=n?.dateLogged||new Date().toISOString();try{let R=new Date(n?.dateLogged||"");isNaN(R.getTime())||(v=(0,_t.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Be.jsxs)($,{className:d("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Be.jsxs)(te,{className:"pb-2",children:[(0,Be.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Be.jsx)(oe,{className:"text-lg font-semibold",children:i?"Loading...":n?.name||"Task"}),(0,Be.jsx)(X,{className:`${h}`,children:f})]}),n?.project&&(0,Be.jsxs)(it,{className:"text-sm text-gray-500",children:["Project: ",n.project.name]})]}),(0,Be.jsx)(j,{className:"pb-2",children:i?(0,Be.jsx)("div",{className:"animate-pulse h-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Be.jsx)("Be",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Be.jsx)("Be",{className:"text-sm text-foreground",children:n?.description||"......."})}),(0,Be.jsx)(Re,{className:"pt-2 flex items-center justify-between",children:(0,Be.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Be.jsx)(I.Clock,{className:"h-3 w-3 mr-1"}),(0,Be.jsxs)("span",{children:["Created ",v]}),(0,Be.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Be.jsxs)("span",{children:["Task #",t]})]})})]})}function Qt({artefact:e,taskId:t,taskData:o,loading:r=!1,error:s=null}){let a=o||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},n=a.dateLogged;try{let i=new Date(a.dateLogged);isNaN(i.getTime())||(n=(0,_t.formatDistanceToNow)(i,{addSuffix:!0}))}catch{}return(0,Be.jsxs)($,{className:"w-full max-w-md shadow-md",children:[(0,Be.jsx)(te,{className:"pb-2",children:(0,Be.jsx)("div",{className:"flex justify-between items-start",children:(0,Be.jsx)(oe,{className:"text-lg font-semibold",children:r?"Loading...":a.name})})}),(0,Be.jsx)(j,{className:"pb-2",children:r?(0,Be.jsx)("div",{className:"animate-pulse h-4 bg-gray-200 rounded w-3/4 mb-2"}):s?(0,Be.jsx)("Be",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Be.jsx)("Be",{className:"text-sm text-foreground",children:e})}),(0,Be.jsx)(Re,{className:"pt-2 flex items-center justify-between",children:(0,Be.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Be.jsx)(I.Clock,{className:"h-3 w-3 mr-1"}),(0,Be.jsxs)("span",{children:["Created ",n]}),(0,Be.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Be.jsxs)("span",{children:["Task #",a.id]})]})})]})}var er=e=>e.startsWith("image/")?(0,Be.jsx)(I.Image,{className:"h-4 w-4"}):e.startsWith("text/")?(0,Be.jsx)(I.FileText,{className:"h-4 w-4"}):(0,Be.jsx)(I.File,{className:"h-4 w-4"}),Xt=({message:e,addToolResult:t,status:o,messages:r})=>e.parts.map((s,a)=>{if(s.type==="text")return(0,Be.jsx)(Te,{children:s.text},`${a}`);if(s.type==="file"){let n=s;return(0,Be.jsx)("div",{className:"mb-2 Be-2 bg-background/50 rounded-lg",children:(0,Be.jsxs)("div",{className:"flex items-center gap-2",children:[er(n.mediaType||"application/octet-stream"),(0,Be.jsx)("div",{className:"flex-1 min-w-0",children:(0,Be.jsx)("Be",{className:"text-sm font-medium truncate",children:n.filename||n.url?.split("/").pop()||"File"})}),n.url&&(0,Be.jsx)(z,{variant:"ghost",size:"sm",onClick:()=>window.open(n.url,"_blank"),className:"h-8 w-8 Be-0",children:(0,Be.jsx)(I.Download,{className:"h-4 w-4"})})]})},a)}if(s.type.startsWith("tool-")){let n=s,i=s.type.replace("tool-","");if(i==="task")switch(n.state){case"input-available":return(0,Be.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},a);case"output-available":return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(qt,{data:{id:n.output?.id||n.input?.id,fetchLatest:!1,taskData:n.output||n.input}})},a);case"output-error":return(0,Be.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",n.errorText]},a);default:return null}if(s.type==="tool-requestEndpointLogin")return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(et,{toolPart:n,index:a,addToolResult:t??(()=>{})})},a);if(s.type==="tool-authenticate")return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(et,{toolPart:n,index:a,addToolResult:t??(()=>{})})},a);if(s.type==="tool-requestApproval")return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(Dt,{toolPart:n,index:a,addToolResult:t??(()=>{})})},a);if(i==="artefact")switch(n.state){case"input-available":return(0,Be.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},a);case"output-available":return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)(Qt,{artefact:n.output?.description||"",taskId:n.output?.id||n.input?.id,taskData:n.output||n.input})},a);case"output-error":return(0,Be.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",n.errorText]},a);default:return null}return(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsxs)($,{className:"w-full max-w-md",children:[(0,Be.jsx)(te,{children:(0,Be.jsx)(oe,{className:"text-lg",children:i})}),(0,Be.jsxs)(j,{children:[n.state==="input-available"&&(0,Be.jsxs)("Be",{className:"text-sm",children:["Processing ",i,"..."]}),n.state==="output-available"&&(0,Be.jsx)("pre",{className:"text-sm",children:JSON.stringify(n.output,null,2)}),n.state==="output-error"&&(0,Be.jsxs)("Be",{className:"text-sm text-red-500",children:["Error: ",n.errorText]})]})]})},a)}if(s.type.startsWith("data-")){let n=s,i=s.type.replace("data-","");return i==="reference"?(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsx)($,{className:"w-full",children:(0,Be.jsx)(j,{className:"Be-4",children:(0,Be.jsx)("div",{className:"space-y-2",children:n.data?.references?.map((c,g)=>(0,Be.jsxs)("div",{className:"flex items-center gap-2 Be-2 rounded-md bg-muted/50",children:[(0,Be.jsx)(X,{variant:"outline",children:c.type||"link"}),(0,Be.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Be.jsx)("Be",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Be.jsx)("Be",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Be.jsx)(z,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"h-8 w-8 Be-0",children:(0,Be.jsx)(I.ExternalLink,{className:"h-4 w-4"})})]},g))})})})},a):i==="menu"?(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsxs)($,{className:"w-full",children:[(0,Be.jsx)(te,{children:(0,Be.jsx)(oe,{className:"text-lg",children:n.data?.title})}),(0,Be.jsx)(j,{children:(0,Be.jsx)("div",{className:"space-y-2",children:n.data?.items?.map((c,g)=>(0,Be.jsx)(z,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Be.jsxs)("div",{className:"text-left",children:[(0,Be.jsx)("Be",{className:"font-medium",children:c.label}),c.description&&(0,Be.jsx)("Be",{className:"text-xs text-muted-foreground",children:c.description})]})},g))})})]})},a):(0,Be.jsx)("div",{className:"mb-2",children:(0,Be.jsxs)($,{className:"w-full max-w-md",children:[(0,Be.jsx)(te,{children:(0,Be.jsx)(oe,{className:"text-lg",children:i})}),(0,Be.jsx)(j,{children:(0,Be.jsx)("pre",{className:"text-sm",children:JSON.stringify(n.data,null,2)})})]})},a)}if(s.type==="reasoning")return(0,Be.jsxs)(rt,{className:"w-full",isStreaming:o==="streaming"&&a===e.parts.length-1&&e.id===r.at(-1)?.id,children:[(0,Be.jsx)(at,{}),(0,Be.jsx)(nt,{children:s.text})]},`${a}`);if(s.type==="dynamic-tool")return(0,Be.jsxs)(Ft,{defaultOpen:s.state!=="output-available",children:[(0,Be.jsx)(Vt,{type:`tool-${s.toolName}`,state:s.state}),(0,Be.jsxs)(Ut,{children:[(0,Be.jsx)(Gt,{input:s.input}),(0,Be.jsx)($t,{output:s.output,errorText:s.errorText})]})]},`${e.id}-${a}`)});var Zt=({className:e,from:t,...o})=>(0,Be.jsx)("div",{className:d("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}),tr=(0,yt.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"}}),eo=({children:e,className:t,variant:o,...r})=>(0,Be.jsx)("div",{className:d(tr({variant:o,className:t})),...r,children:e});function or({messages:e,input:t,isTyping:o=!1,currentSessionTitle:r,capabilities:s,fileUploads:a,isDragOver:n,enableFileUpload:i,onInputChange:c,addToolResult:g,onSendMessage:h,onKeyPress:f,onFileUpload:v,onRemoveFile:R,onDragOver:P,className:x,status:y="ready"}){let C=(0,_.useRef)(null),E=(0,_.useRef)(null),A=(0,_.useRef)(null),[S,q]=(0,_.useState)(!1),[ue,We]=(0,_.useState)({path:[],selectedItems:[],filters:{}});(0,_.useEffect)(()=>{C.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,_.useEffect)(()=>{S&&setTimeout(()=>{C.current?.scrollIntoView({behavior:"smooth"})},100)},[S]);let Ce=()=>Ye(ue),me=()=>{let u=[];return s.forEach(T=>{T.actions&&T.actions.forEach(K=>{u.push({label:K.label,action:()=>ie(K.id,{path:[T],selectedItems:[],filters:{}})})}),T.children&&T.children.forEach(K=>{K.type==="list"&&K.data&&u.push({label:`View ${K.name}`,action:()=>q(!0)})})}),u.slice(0,5)},ie=(u,T)=>{console.log("Capability action:",u,T);let K=`Executing ${u} with context: ${JSON.stringify(T.path.map(Ie=>Ie.name))}`;q(!1)},we=Ye({path:[],selectedItems:[],filters:{}}),w=u=>{v(u.target.files),u.target.files&&(u.target.value="")},Ae=u=>{u.preventDefault(),P(!0)},ge=u=>{u.preventDefault(),P(!1)},Se=u=>{u.preventDefault(),P(!1),v(u.dataTransfer.files)},fe=u=>{if(u===0)return"0 Bytes";let T=1024,K=["Bytes","KB","MB","GB"],Ie=Math.floor(Math.log(u)/Math.log(T));return parseFloat((u/Math.pow(T,Ie)).toFixed(2))+" "+K[Ie]},Me=u=>u.startsWith("image/")?(0,Be.jsx)(I.Image,{className:"h-4 w-4"}):u.startsWith("text/")?(0,Be.jsx)(I.FileText,{className:"h-4 w-4"}):(0,Be.jsx)(I.File,{className:"h-4 w-4"}),Ne={messages:e,currentSessionTitle:r,capabilities:s,currentCapabilityContext:ue,contextualActions:we,getQuickSuggestions:me().map(u=>u.label)},le=()=>{navigator.clipboard.writeText(JSON.stringify(Ne,null,2)),alert("Debug info copied to clipboard")};return(0,Be.jsxs)("div",{className:`h-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${x||""}`,children:[(0,Be.jsxs)(Xe,{ref:E,className:"flex-1 Be-4 bg-background border-0",onDragOver:Ae,onDragLeave:ge,onDrop:Se,children:[(0,Be.jsxs)("div",{className:d("space-y-4",n&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Be.jsx)(xe.animate,{children:e.map(u=>(0,Be.jsx)(xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Be.jsx)(Zt,{from:u.role,children:(0,Be.jsx)(eo,{variant:"flat",children:Xt({message:u,addToolResult:g??(()=>{}),status:y,messages:e})})},u.id)},u.id))}),S&&(0,Be.jsxs)(xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Be.jsx)(Ee,{className:"h-8 w-8",children:(0,Be.jsx)(ze,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Be.jsx)(I.Bot,{className:"h-4 w-4"})})}),(0,Be.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Be.jsx)(At,{capabilities:s,isOpen:S,onToggle:()=>q(!S),onActionSelect:ie,className:"w-full"})})]}),o&&(0,Be.jsxs)(xe.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Be.jsx)(Ee,{className:"h-8 w-8",children:(0,Be.jsx)(ze,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Be.jsx)(I.Bot,{className:"h-4 w-4"})})}),(0,Be.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Be.jsxs)("div",{className:"flex space-x-1",children:[(0,Be.jsx)("div",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Be.jsx)("div",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Be.jsx)("div",{className:"w-2 h-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Be.jsx)("div",{ref:C})]}),a.length>0&&(0,Be.jsx)("div",{className:"Be-4 border-t bg-muted/10",children:(0,Be.jsx)("div",{className:"flex flex-wrap gap-2",children:a.map(u=>(0,Be.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Be-2 border",children:[Me(u.file.type),(0,Be.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Be.jsx)("span",{className:"text-xs text-muted-foreground",children:fe(u.file.size)}),(0,Be.jsx)(z,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"h-6 w-6 Be-0",children:(0,Be.jsx)(I.X,{className:"h-4 w-4"})})]},u.id))})}),(0,Be.jsxs)("div",{className:"border rounded-2xl Be-4 bg-muted/20",children:[(0,Be.jsxs)("div",{className:"flex gap-3",children:[(0,Be.jsx)(Je,{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}),i&&(0,Be.jsx)(z,{variant:"outline",size:"icon",onClick:()=>A.current?.click(),className:"rounded-2xl h-10 w-10 shadow-sm",children:(0,Be.jsx)(I.Paperclip,{className:"h-4 w-4"})}),(0,Be.jsx)(z,{onClick:h,disabled:!t.trim()&&a.length===0||o,size:"icon",className:"rounded-2xl h-10 w-10 shadow-sm",children:(0,Be.jsx)(I.Send,{className:"h-4 w-4"})})]}),(0,Be.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Be.jsxs)(z,{onClick:()=>q(!S),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Be.jsx)(I.Menu,{className:"h-3 w-3 mr-1"}),S?"Hide":"Show"," Capabilities"]}),(0,Be.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[Ce().map((u,T)=>(0,Be.jsx)(z,{variant:"default",size:"sm",className:"rounded-full text-xs bg-accent hover:bg-accent/80",onClick:()=>ie(u.id,ue),children:u.label},`context-${u.id}`)),Ce().length===0&&me().map((u,T)=>(0,Be.jsx)(z,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${T}`)),(0,Be.jsx)(z,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:le,children:"Debug"})]})]}),i&&(0,Be.jsx)("input",{ref:A,type:"file",multiple:!0,onChange:w,className:"hidden"})]})]})}0&&(module.exports={ChatInterface});
@@ -1 +1 @@
1
- import{a}from"../../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-Q2DPE66H.mjs";import"../../chunk-FT3AE7L2.mjs";import"../../chunk-YNCJATT7.mjs";import"../../chunk-L5JPAKPM.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-YEKQJ4YC.mjs";export{a as ChatInterface};
1
+ import{a}from"../../chunk-AXPE5U2T.mjs";import"../../chunk-7TSR2LQB.mjs";import"../../chunk-IFU7M7BO.mjs";import"../../chunk-7JDMW5R3.mjs";import"../../chunk-YPZAYXNQ.mjs";import"../../chunk-UA2E23AS.mjs";import"../../chunk-EH3PJU6C.mjs";import"../../chunk-6OT5PQXV.mjs";import"../../chunk-V5VE3EIY.mjs";import"../../chunk-QM5FOQHG.mjs";import"../../chunk-6OCLRAHU.mjs";import"../../chunk-5Y6FKL5W.mjs";import"../../chunk-EW6KWAHS.mjs";import"../../chunk-2LINLX4S.mjs";import"../../chunk-RL6365DN.mjs";import"../../chunk-LTTO57ZK.mjs";import"../../chunk-Q2DPE66H.mjs";import"../../chunk-FT3AE7L2.mjs";import"../../chunk-YNCJATT7.mjs";import"../../chunk-L5JPAKPM.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-YEKQJ4YC.mjs";export{a as ChatInterface};
@@ -18,4 +18,4 @@
18
18
  `,children:r?"Processing...":"Deny"}),(0,Bo.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 va=({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,Bo.jsxs)("div",{className:"mb-2",children:[(0,Bo.jsx)(ba,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,Bo.jsxs)(Bo.Fragment,{children:[i==="approve"&&(0,Bo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Bo.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,Bo.jsx)("svg",{className:"Bo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Bo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,Bo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Bo.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,Bo.jsx)("svg",{className:"Bo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Bo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Bo.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 ya=require("streamdown"),yt=(0,ct.memo)(({className:e,...t})=>(0,Bo.jsx)(ya.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 wa=(0,ct.createContext)(null),ar=()=>{let e=(0,ct.useContext)(wa);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},ir=1e3,rr=1e3,bo=(0,ct.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,ct.useState)(!1),[A,T]=(0,ct.useState)(null);(0,ct.useEffect)(()=>{t?A===null&&T(Date.now()):A!==null&&(f(Math.ceil((Date.now()-A)/rr)),T(null))},[t,A,f]),(0,ct.useEffect)(()=>{if(a&&!t&&c&&!y){let N=setTimeout(()=>{m(!1),R(!0)},ir);return()=>clearTimeout(N)}},[t,c,a,m,y]);let C=N=>{m(N)};return(0,Bo.jsx)(wa.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,Bo.jsx)(zt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),nr=(e,t)=>e||t===0?(0,Bo.jsx)("Bo",{children:"Thinking..."}):t===void 0?(0,Bo.jsx)("Bo",{children:"Thought for a few seconds"}):(0,Bo.jsxs)("Bo",{children:["Thought for ",t," seconds"]}),vo=(0,ct.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=ar();return(0,Bo.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,Bo.jsxs)(Bo.Fragment,{children:[(0,Bo.jsx)(Oa.BrainIcon,{className:"size-4"}),nr(a,i),(0,Bo.jsx)(Oa.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),ho=(0,ct.memo)(({className:e,children:t,...o})=>(0,Bo.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,Bo.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"),sr=(0,ct.createContext)({code:""}),Vt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,Bo.jsx)(sr.Provider,{value:{code:e},children:(0,Bo.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,Bo.jsxs)("div",{className:"relative",children:[(0,Bo.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,Bo.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,Bo.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Na=({className:e,...t})=>(0,Bo.jsx)(zt,{className:l("not-prose mb-4 w-full",e),...t}),lr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Bo.jsxs)(ae,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Bo.jsx)(Oa.CircleIcon,{className:"size-4"}),"input-available":(0,Bo.jsx)(Oa.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Bo.jsx)(Oa.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Bo.jsx)(Oa.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},ka=({className:e,type:t,state:o,...a})=>(0,Bo.jsxs)(Ut,{className:l("flex w-full items-center justify-between gap-4 Bo-3 pl-0 w-2xl",e),...a,children:[(0,Bo.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Bo.jsx)(Oa.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Bo.jsx)("span",{className:"font-medium text-sm",children:t}),lr(o)]}),(0,Bo.jsx)(Oa.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Pa=({className:e,...t})=>(0,Bo.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}),Ta=({className:e,input:t,...o})=>(0,Bo.jsxs)("div",{className:l("space-y-2 overflow-hidden Bo-4",e),...o,children:[(0,Bo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Bo.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Bo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"})})]}),Da=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,Bo.jsx)("div",{children:t});return typeof t=="object"?n=(0,Bo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,Bo.jsx)(Vt,{code:t,language:"json"})),(0,Bo.jsxs)("div",{className:l("space-y-2 Bo-4",e),...a,children:[(0,Bo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Bo.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,Bo.jsx)("div",{children:o}),n]})]})};var Aa=require("date-fns");function Ra({taskId:e,polling:t=!0,system:o="payload"}){let[a,n]=(0,ct.useState)(null),[i,r]=(0,ct.useState)(!1),[s,c]=(0,ct.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,ct.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 cr=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"}},dr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Ma({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}=Ra({taskId:t,system:o});r=R,s=A,c=T}else s=!1;let w=cr(r?.status||"todo"),f=dr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let R=new Date(r?.dateLogged||"");isNaN(R.getTime())||(y=(0,Aa.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Bo.jsxs)(ge,{className:l("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Bo.jsxs)(Le,{className:"pb-2",children:[(0,Bo.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Bo.jsx)(Ee,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,Bo.jsx)(ae,{className:`${w}`,children:f})]}),r?.project&&(0,Bo.jsxs)(co,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,Bo.jsx)(Pe,{className:"pb-2",children:s?(0,Bo.jsx)("div",{className:"animate-pulse Bo-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Bo.jsx)("Bo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Bo.jsx)("Bo",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,Bo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Bo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Bo.jsx)(Oa.Clock,{className:"Bo-3 w-3 mr-1"}),(0,Bo.jsxs)("span",{children:["Created ",y]}),(0,Bo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Bo.jsxs)("span",{children:["Task #",t]})]})})]})}function La({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,Aa.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,Bo.jsxs)(ge,{className:"w-full max-w-md shadow-md",children:[(0,Bo.jsx)(Le,{className:"pb-2",children:(0,Bo.jsx)("div",{className:"flex justify-between items-start",children:(0,Bo.jsx)(Ee,{className:"text-lg font-semibold",children:a?"Loading...":i.name})})}),(0,Bo.jsx)(Pe,{className:"pb-2",children:a?(0,Bo.jsx)("div",{className:"animate-pulse Bo-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,Bo.jsx)("Bo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Bo.jsx)("Bo",{className:"text-sm text-foreground",children:e})}),(0,Bo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Bo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Bo.jsx)(Oa.Clock,{className:"Bo-3 w-3 mr-1"}),(0,Bo.jsxs)("span",{children:["Created ",r]}),(0,Bo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Bo.jsxs)("span",{children:["Task #",i.id]})]})})]})}var pr=e=>e.startsWith("image/")?(0,Bo.jsx)(Oa.Image,{className:"Bo-4 w-4"}):e.startsWith("text/")?(0,Bo.jsx)(Oa.FileText,{className:"Bo-4 w-4"}):(0,Bo.jsx)(Oa.File,{className:"Bo-4 w-4"}),Ea=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,Bo.jsx)(yt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,Bo.jsx)("div",{className:"mb-2 Bo-2 bg-background/50 rounded-lg",children:(0,Bo.jsxs)("div",{className:"flex items-center gap-2",children:[pr(r.mediaType||"application/octet-stream"),(0,Bo.jsx)("div",{className:"flex-1 min-w-0",children:(0,Bo.jsx)("Bo",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,Bo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"Bo-8 w-8 Bo-0",children:(0,Bo.jsx)(Oa.Download,{className:"Bo-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,Bo.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(Ma,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,Bo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(va,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,Bo.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(La,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,Bo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Bo.jsx)(Le,{children:(0,Bo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Bo.jsxs)(Pe,{children:[r.state==="input-available"&&(0,Bo.jsxs)("Bo",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,Bo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,Bo.jsxs)("Bo",{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,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(ge,{className:"w-full",children:(0,Bo.jsx)(Pe,{className:"Bo-4",children:(0,Bo.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,Bo.jsxs)("div",{className:"flex items-center gap-2 Bo-2 rounded-md bg-muted/50",children:[(0,Bo.jsx)(ae,{variant:"outline",children:c.type||"link"}),(0,Bo.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Bo.jsx)("Bo",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Bo.jsx)("Bo",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Bo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"Bo-8 w-8 Bo-0",children:(0,Bo.jsx)(Oa.ExternalLink,{className:"Bo-4 w-4"})})]},m))})})})},i):s==="menu"?(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsxs)(ge,{className:"w-full",children:[(0,Bo.jsx)(Le,{children:(0,Bo.jsx)(Ee,{className:"text-lg",children:r.data?.title})}),(0,Bo.jsx)(Pe,{children:(0,Bo.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,Bo.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Bo.jsxs)("div",{className:"text-left",children:[(0,Bo.jsx)("Bo",{className:"font-medium",children:c.label}),c.description&&(0,Bo.jsx)("Bo",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Bo.jsx)(Le,{children:(0,Bo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Bo.jsx)(Pe,{children:(0,Bo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}return n.type==="reasoning"?(0,Bo.jsxs)(bo,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.at(-1)?.id,children:[(0,Bo.jsx)(vo,{}),(0,Bo.jsx)(ho,{children:n.text})]},`${i}`):n.type==="dynamic-tool"?(0,Bo.jsxs)(Na,{defaultOpen:n.state!=="output-available",children:[(0,Bo.jsx)(ka,{type:`tool-${n.toolName}`,state:n.state}),(0,Bo.jsxs)(Pa,{children:[(0,Bo.jsx)(Ta,{input:n.input}),(0,Bo.jsx)(Da,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`):(0,Bo.jsxs)(Bo.Fragment,{children:["Unknown part type: ",n.type]})});var Ua=({className:e,from:t,...o})=>(0,Bo.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}),mr=(0,Io.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,Bo.jsx)("div",{className:l(mr({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,ct.useRef)(null),F=(0,ct.useRef)(null),S=(0,ct.useRef)(null),[M,_]=(0,ct.useState)(!1),[$,se]=(0,ct.useState)({path:[],selectedItems:[],filters:{}});(0,ct.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,ct.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,Bo.jsx)(Oa.Image,{className:"Bo-4 w-4"}):u.startsWith("text/")?(0,Bo.jsx)(Oa.FileText,{className:"Bo-4 w-4"}):(0,Bo.jsx)(Oa.File,{className:"Bo-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,Bo.jsxs)("div",{className:`Bo-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,Bo.jsxs)(Ce,{ref:F,className:"flex-1 Bo-4 bg-background border-0",onDragOver:Se,onDragLeave:d,onDrop:L,children:[(0,Bo.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Bo.jsx)(lt.animate,{children:e.map(u=>(0,Bo.jsx)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Bo.jsx)(Ua,{from:u.role,children:(0,Bo.jsx)(Fa,{variant:"flat",children:Ea({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),M&&(0,Bo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Bo.jsx)(et,{className:"Bo-8 w-8",children:(0,Bo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Bo.jsx)(Oa.Bot,{className:"Bo-4 w-4"})})}),(0,Bo.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Bo.jsx)(ma,{capabilities:n,isOpen:M,onToggle:()=>_(!M),onActionSelect:X,className:"w-full"})})]}),o&&(0,Bo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Bo.jsx)(et,{className:"Bo-8 w-8",children:(0,Bo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Bo.jsx)(Oa.Bot,{className:"Bo-4 w-4"})})}),(0,Bo.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Bo.jsxs)("div",{className:"flex space-x-1",children:[(0,Bo.jsx)("div",{className:"w-2 Bo-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Bo.jsx)("div",{className:"w-2 Bo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Bo.jsx)("div",{className:"w-2 Bo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Bo.jsx)("div",{ref:N})]}),i.length>0&&(0,Bo.jsx)("div",{className:"Bo-4 border-t bg-muted/10",children:(0,Bo.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,Bo.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Bo-2 border",children:[G(u.file.type),(0,Bo.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Bo.jsx)("span",{className:"text-xs text-muted-foreground",children:E(u.file.size)}),(0,Bo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"Bo-6 w-6 Bo-0",children:(0,Bo.jsx)(Oa.X,{className:"Bo-4 w-4"})})]},u.id))})}),(0,Bo.jsxs)("div",{className:"border rounded-2xl Bo-4 bg-muted/20",children:[(0,Bo.jsxs)("div",{className:"flex gap-3",children:[(0,Bo.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,Bo.jsx)(D,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl Bo-10 w-10 shadow-sm",children:(0,Bo.jsx)(Oa.Paperclip,{className:"Bo-4 w-4"})}),(0,Bo.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl Bo-10 w-10 shadow-sm",children:(0,Bo.jsx)(Oa.Send,{className:"Bo-4 w-4"})})]}),(0,Bo.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Bo.jsxs)(D,{onClick:()=>_(!M),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Bo.jsx)(Oa.Menu,{className:"Bo-3 w-3 mr-1"}),M?"Hide":"Show"," Capabilities"]}),(0,Bo.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,Bo.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,Bo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,Bo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,Bo.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:I,className:"hidden"})]})]})}function ur({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,Bo.jsx)(Oa.Users,{className:"mr-2 Bo-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,ct.useState)(""),[u,U]=(0,ct.useState)(!1),ve=G?.messages||a,Ae=Z,Va=G?.status==="submitted"||u,Wa=G?.addToolResult?(j,de,oe)=>{G.addToolResult({tool:de,toolCallId:j,output:oe}),G.sendMessage()}:()=>{console.log("addToolResult not available")},dt=n||[],Ga={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"},[$a,qa]=(0,ct.useState)(()=>dt.length===0?Ga:dt.find(j=>j.id===F)||dt[0]),[pt,xt]=(0,ct.useState)([]),[Ka,_a]=(0,ct.useState)(!1),Ja=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=ei=>{xt(ti=>ti.map($t=>$t.id===wo.id?{...$t,preview:ei.target?.result}:$t))},wt.readAsDataURL(oe)}de.push(wo)}),xt(oe=>[...oe,...de])},Xa=j=>{xt(de=>de.filter(oe=>oe.id!==j))},xo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let j=pt.length>0?Qa(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([])}},Qa=j=>{let de=new DataTransfer;return j.forEach(oe=>de.items.add(oe)),de.files},Ya=j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),xo())},Za=j=>{be(j)};return(0,Bo.jsx)(ca,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:$a,onBusinessUnitChange:j=>{j&&(qa(j),R?.(j))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:I,actionText:Se,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,Bo.jsx)(Gt.AnimatePresence,{mode:"wait",children:(0,Bo.jsx)(Gt.motion.div,{className:"flex-1 Bo-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,Bo.jsxs)("div",{className:"Bo-full flex",children:[(0,Bo.jsx)("div",{className:"w-80 flex-shrink-0 Bo-full Bo-2",children:(0,Bo.jsx)(da,{sessions:c||[],currentSession:S,teams:dt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,Bo.jsx)("div",{className:"flex-1 Bo-full Bo-2",children:(0,Bo.jsx)(ja,{messages:ve||[],input:Ae,isTyping:Va,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:Za,addToolResult:Wa,onSendMessage:xo,onKeyPress:Ya,fileUploads:pt,isDragOver:Ka,enableFileUpload:$,onFileUpload:Ja,onRemoveFile:Xa,onDragOver:_a})})]})},"chat-interface")})})}0&&(module.exports={CopilotInterface});
21
+ `,children:"Cancel"})]})]}):null};var va=({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,Bo.jsxs)("div",{className:"mb-2",children:[(0,Bo.jsx)(ba,{isOpen:a,onApprove:s,onDeny:c,onClose:()=>n(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!a&&(0,Bo.jsxs)(Bo.Fragment,{children:[i==="approve"&&(0,Bo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Bo.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,Bo.jsx)("svg",{className:"Bo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Bo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),i==="deny"&&(0,Bo.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,Bo.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,Bo.jsx)("svg",{className:"Bo-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,Bo.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,Bo.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 ya=require("streamdown"),yt=(0,ct.memo)(({className:e,...t})=>(0,Bo.jsx)(ya.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 wa=(0,ct.createContext)(null),ar=()=>{let e=(0,ct.useContext)(wa);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},ir=1e3,rr=1e3,bo=(0,ct.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,ct.useState)(!1),[A,T]=(0,ct.useState)(null);(0,ct.useEffect)(()=>{t?A===null&&T(Date.now()):A!==null&&(f(Math.ceil((Date.now()-A)/rr)),T(null))},[t,A,f]),(0,ct.useEffect)(()=>{if(a&&!t&&c&&!y){let N=setTimeout(()=>{m(!1),R(!0)},ir);return()=>clearTimeout(N)}},[t,c,a,m,y]);let C=N=>{m(N)};return(0,Bo.jsx)(wa.Provider,{value:{isStreaming:t,isOpen:c,setIsOpen:m,duration:w},children:(0,Bo.jsx)(zt,{className:l("not-prose mb-4",e),onOpenChange:C,open:c,...s,children:r})})}),nr=(e,t)=>e||t===0?(0,Bo.jsx)("Bo",{children:"Thinking..."}):t===void 0?(0,Bo.jsx)("Bo",{children:"Thought for a few seconds"}):(0,Bo.jsxs)("Bo",{children:["Thought for ",t," seconds"]}),vo=(0,ct.memo)(({className:e,children:t,...o})=>{let{isStreaming:a,isOpen:n,duration:i}=ar();return(0,Bo.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,Bo.jsxs)(Bo.Fragment,{children:[(0,Bo.jsx)(Oa.BrainIcon,{className:"size-4"}),nr(a,i),(0,Bo.jsx)(Oa.ChevronDownIcon,{className:l("size-4 transition-transform",n?"rotate-180":"rotate-0")})]})})}),ho=(0,ct.memo)(({className:e,children:t,...o})=>(0,Bo.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,Bo.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"),sr=(0,ct.createContext)({code:""}),Vt=({code:e,language:t,showLineNumbers:o=!1,className:a,children:n,...i})=>(0,Bo.jsx)(sr.Provider,{value:{code:e},children:(0,Bo.jsx)("div",{className:l("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",a),...i,children:(0,Bo.jsxs)("div",{className:"relative",children:[(0,Bo.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,Bo.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,Bo.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:n})]})})});var Na=({className:e,...t})=>(0,Bo.jsx)(zt,{className:l("not-prose mb-4 w-full",e),...t}),lr=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,Bo.jsxs)(ae,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,Bo.jsx)(Oa.CircleIcon,{className:"size-4"}),"input-available":(0,Bo.jsx)(Oa.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,Bo.jsx)(Oa.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,Bo.jsx)(Oa.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},ka=({className:e,type:t,state:o,...a})=>(0,Bo.jsxs)(Ut,{className:l("flex w-full items-center justify-between gap-4 Bo-3 pl-0 w-2xl",e),...a,children:[(0,Bo.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Bo.jsx)(Oa.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,Bo.jsx)("span",{className:"font-medium text-sm",children:t}),lr(o)]}),(0,Bo.jsx)(Oa.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),Pa=({className:e,...t})=>(0,Bo.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}),Ta=({className:e,input:t,...o})=>(0,Bo.jsxs)("div",{className:l("space-y-2 overflow-hidden Bo-4",e),...o,children:[(0,Bo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,Bo.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,Bo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"})})]}),Da=({className:e,output:t,errorText:o,...a})=>{if(!(t||o))return null;let n=(0,Bo.jsx)("div",{children:t});return typeof t=="object"?n=(0,Bo.jsx)(Vt,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=(0,Bo.jsx)(Vt,{code:t,language:"json"})),(0,Bo.jsxs)("div",{className:l("space-y-2 Bo-4",e),...a,children:[(0,Bo.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,Bo.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,Bo.jsx)("div",{children:o}),n]})]})};var Aa=require("date-fns");function Ra({taskId:e,polling:t=!0,system:o="payload"}){let[a,n]=(0,ct.useState)(null),[i,r]=(0,ct.useState)(!1),[s,c]=(0,ct.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,ct.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 cr=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"}},dr=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function Ma({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}=Ra({taskId:t,system:o});r=R,s=A,c=T}else s=!1;let w=cr(r?.status||"todo"),f=dr(r?.status||"todo"),y=r?.dateLogged||new Date().toISOString();try{let R=new Date(r?.dateLogged||"");isNaN(R.getTime())||(y=(0,Aa.formatDistanceToNow)(R,{addSuffix:!0}))}catch{}return(0,Bo.jsxs)(ge,{className:l("w-full max-w-md shadow-md",c&&"border border-destructive"),children:[(0,Bo.jsxs)(Le,{className:"pb-2",children:[(0,Bo.jsxs)("div",{className:"flex justify-between items-start",children:[(0,Bo.jsx)(Ee,{className:"text-lg font-semibold",children:s?"Loading...":r?.name||"Task"}),(0,Bo.jsx)(ae,{className:`${w}`,children:f})]}),r?.project&&(0,Bo.jsxs)(co,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,Bo.jsx)(Pe,{className:"pb-2",children:s?(0,Bo.jsx)("div",{className:"animate-pulse Bo-4 bg-gray-200 rounded w-3/4 mb-2"}):c?(0,Bo.jsx)("Bo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Bo.jsx)("Bo",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,Bo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Bo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Bo.jsx)(Oa.Clock,{className:"Bo-3 w-3 mr-1"}),(0,Bo.jsxs)("span",{children:["Created ",y]}),(0,Bo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Bo.jsxs)("span",{children:["Task #",t]})]})})]})}function La({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,Aa.formatDistanceToNow)(s,{addSuffix:!0}))}catch{}return(0,Bo.jsxs)(ge,{className:"w-full max-w-md shadow-md",children:[(0,Bo.jsx)(Le,{className:"pb-2",children:(0,Bo.jsx)("div",{className:"flex justify-between items-start",children:(0,Bo.jsx)(Ee,{className:"text-lg font-semibold",children:a?"Loading...":i.name})})}),(0,Bo.jsx)(Pe,{className:"pb-2",children:a?(0,Bo.jsx)("div",{className:"animate-pulse Bo-4 bg-gray-200 rounded w-3/4 mb-2"}):n?(0,Bo.jsx)("Bo",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,Bo.jsx)("Bo",{className:"text-sm text-foreground",children:e})}),(0,Bo.jsx)(ht,{className:"pt-2 flex items-center justify-between",children:(0,Bo.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,Bo.jsx)(Oa.Clock,{className:"Bo-3 w-3 mr-1"}),(0,Bo.jsxs)("span",{children:["Created ",r]}),(0,Bo.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,Bo.jsxs)("span",{children:["Task #",i.id]})]})})]})}var pr=e=>e.startsWith("image/")?(0,Bo.jsx)(Oa.Image,{className:"Bo-4 w-4"}):e.startsWith("text/")?(0,Bo.jsx)(Oa.FileText,{className:"Bo-4 w-4"}):(0,Bo.jsx)(Oa.File,{className:"Bo-4 w-4"}),Ea=({message:e,addToolResult:t,status:o,messages:a})=>e.parts.map((n,i)=>{if(n.type==="text")return(0,Bo.jsx)(yt,{children:n.text},`${i}`);if(n.type==="file"){let r=n;return(0,Bo.jsx)("div",{className:"mb-2 Bo-2 bg-background/50 rounded-lg",children:(0,Bo.jsxs)("div",{className:"flex items-center gap-2",children:[pr(r.mediaType||"application/octet-stream"),(0,Bo.jsx)("div",{className:"flex-1 min-w-0",children:(0,Bo.jsx)("Bo",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,Bo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"Bo-8 w-8 Bo-0",children:(0,Bo.jsx)(Oa.Download,{className:"Bo-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,Bo.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},i);case"output-available":return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(Ma,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},i);case"output-error":return(0,Bo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}if(n.type==="tool-requestEndpointLogin")return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-authenticate")return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(uo,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(n.type==="tool-requestApproval")return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(va,{toolPart:r,index:i,addToolResult:t??(()=>{})})},i);if(s==="artefact")switch(r.state){case"input-available":return(0,Bo.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},i);case"output-available":return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(La,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},i);case"output-error":return(0,Bo.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},i);default:return null}return(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Bo.jsx)(Le,{children:(0,Bo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Bo.jsxs)(Pe,{children:[r.state==="input-available"&&(0,Bo.jsxs)("Bo",{className:"text-sm",children:["Processing ",s,"..."]}),r.state==="output-available"&&(0,Bo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,Bo.jsxs)("Bo",{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,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsx)(ge,{className:"w-full",children:(0,Bo.jsx)(Pe,{className:"Bo-4",children:(0,Bo.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((c,m)=>(0,Bo.jsxs)("div",{className:"flex items-center gap-2 Bo-2 rounded-md bg-muted/50",children:[(0,Bo.jsx)(ae,{variant:"outline",children:c.type||"link"}),(0,Bo.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,Bo.jsx)("Bo",{className:"text-sm font-medium truncate",children:c.title}),c.description&&(0,Bo.jsx)("Bo",{className:"text-xs text-muted-foreground truncate",children:c.description})]}),c.url&&(0,Bo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>window.open(c.url,"_blank"),className:"Bo-8 w-8 Bo-0",children:(0,Bo.jsx)(Oa.ExternalLink,{className:"Bo-4 w-4"})})]},m))})})})},i):s==="menu"?(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsxs)(ge,{className:"w-full",children:[(0,Bo.jsx)(Le,{children:(0,Bo.jsx)(Ee,{className:"text-lg",children:r.data?.title})}),(0,Bo.jsx)(Pe,{children:(0,Bo.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((c,m)=>(0,Bo.jsx)(D,{variant:"outline",className:"w-full justify-start",onClick:c.action,children:(0,Bo.jsxs)("div",{className:"text-left",children:[(0,Bo.jsx)("Bo",{className:"font-medium",children:c.label}),c.description&&(0,Bo.jsx)("Bo",{className:"text-xs text-muted-foreground",children:c.description})]})},m))})})]})},i):(0,Bo.jsx)("div",{className:"mb-2",children:(0,Bo.jsxs)(ge,{className:"w-full max-w-md",children:[(0,Bo.jsx)(Le,{children:(0,Bo.jsx)(Ee,{className:"text-lg",children:s})}),(0,Bo.jsx)(Pe,{children:(0,Bo.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},i)}if(n.type==="reasoning")return(0,Bo.jsxs)(bo,{className:"w-full",isStreaming:o==="streaming"&&i===e.parts.length-1&&e.id===a.at(-1)?.id,children:[(0,Bo.jsx)(vo,{}),(0,Bo.jsx)(ho,{children:n.text})]},`${i}`);if(n.type==="dynamic-tool")return(0,Bo.jsxs)(Na,{defaultOpen:n.state!=="output-available",children:[(0,Bo.jsx)(ka,{type:`tool-${n.toolName}`,state:n.state}),(0,Bo.jsxs)(Pa,{children:[(0,Bo.jsx)(Ta,{input:n.input}),(0,Bo.jsx)(Da,{output:n.output,errorText:n.errorText})]})]},`${e.id}-${i}`)});var Ua=({className:e,from:t,...o})=>(0,Bo.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}),mr=(0,Io.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,Bo.jsx)("div",{className:l(mr({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,ct.useRef)(null),F=(0,ct.useRef)(null),S=(0,ct.useRef)(null),[M,_]=(0,ct.useState)(!1),[$,se]=(0,ct.useState)({path:[],selectedItems:[],filters:{}});(0,ct.useEffect)(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[e]),(0,ct.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,Bo.jsx)(Oa.Image,{className:"Bo-4 w-4"}):u.startsWith("text/")?(0,Bo.jsx)(Oa.FileText,{className:"Bo-4 w-4"}):(0,Bo.jsx)(Oa.File,{className:"Bo-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,Bo.jsxs)("div",{className:`Bo-full flex flex-col relative size-full shadow-sm max-w-4xl mx-auto ${T||""}`,children:[(0,Bo.jsxs)(Ce,{ref:F,className:"flex-1 Bo-4 bg-background border-0",onDragOver:Se,onDragLeave:d,onDrop:L,children:[(0,Bo.jsxs)("div",{className:l("space-y-4",r&&"ring-2 ring-primary ring-offset-2 bg-primary/5"),children:[(0,Bo.jsx)(lt.animate,{children:e.map(u=>(0,Bo.jsx)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},children:(0,Bo.jsx)(Ua,{from:u.role,children:(0,Bo.jsx)(Fa,{variant:"flat",children:Ea({message:u,addToolResult:m??(()=>{}),status:C,messages:e})})},u.id)},u.id))}),M&&(0,Bo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"flex gap-3",children:[(0,Bo.jsx)(et,{className:"Bo-8 w-8",children:(0,Bo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Bo.jsx)(Oa.Bot,{className:"Bo-4 w-4"})})}),(0,Bo.jsx)("div",{className:"flex-1 bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Bo.jsx)(ma,{capabilities:n,isOpen:M,onToggle:()=>_(!M),onActionSelect:X,className:"w-full"})})]}),o&&(0,Bo.jsxs)(lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex gap-3",children:[(0,Bo.jsx)(et,{className:"Bo-8 w-8",children:(0,Bo.jsx)(tt,{className:"bg-gradient-to-br from-purple-600 to-blue-600 text-white",children:(0,Bo.jsx)(Oa.Bot,{className:"Bo-4 w-4"})})}),(0,Bo.jsx)("div",{className:"bg-muted rounded-2xl px-4 py-3 shadow-sm",children:(0,Bo.jsxs)("div",{className:"flex space-x-1",children:[(0,Bo.jsx)("div",{className:"w-2 Bo-2 bg-muted-foreground/50 rounded-full animate-bounce"}),(0,Bo.jsx)("div",{className:"w-2 Bo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,Bo.jsx)("div",{className:"w-2 Bo-2 bg-muted-foreground/50 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]})]}),(0,Bo.jsx)("div",{ref:N})]}),i.length>0&&(0,Bo.jsx)("div",{className:"Bo-4 border-t bg-muted/10",children:(0,Bo.jsx)("div",{className:"flex flex-wrap gap-2",children:i.map(u=>(0,Bo.jsxs)("div",{className:"flex items-center gap-2 bg-background rounded-lg Bo-2 border",children:[G(u.file.type),(0,Bo.jsx)("span",{className:"text-sm font-medium",children:u.file.name}),(0,Bo.jsx)("span",{className:"text-xs text-muted-foreground",children:E(u.file.size)}),(0,Bo.jsx)(D,{variant:"ghost",size:"sm",onClick:()=>R(u.id),className:"Bo-6 w-6 Bo-0",children:(0,Bo.jsx)(Oa.X,{className:"Bo-4 w-4"})})]},u.id))})}),(0,Bo.jsxs)("div",{className:"border rounded-2xl Bo-4 bg-muted/20",children:[(0,Bo.jsxs)("div",{className:"flex gap-3",children:[(0,Bo.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,Bo.jsx)(D,{variant:"outline",size:"icon",onClick:()=>S.current?.click(),className:"rounded-2xl Bo-10 w-10 shadow-sm",children:(0,Bo.jsx)(Oa.Paperclip,{className:"Bo-4 w-4"})}),(0,Bo.jsx)(D,{onClick:w,disabled:!t.trim()&&i.length===0||o,size:"icon",className:"rounded-2xl Bo-10 w-10 shadow-sm",children:(0,Bo.jsx)(Oa.Send,{className:"Bo-4 w-4"})})]}),(0,Bo.jsxs)("div",{className:"flex items-center gap-3 mt-3",children:[(0,Bo.jsxs)(D,{onClick:()=>_(!M),variant:"outline",size:"sm",className:"rounded-full text-xs flex-shrink-0",children:[(0,Bo.jsx)(Oa.Menu,{className:"Bo-3 w-3 mr-1"}),M?"Hide":"Show"," Capabilities"]}),(0,Bo.jsxs)("div",{className:"flex flex-wrap gap-2 overflow-hidden",children:[J().map((u,U)=>(0,Bo.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,Bo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs",onClick:u.action,children:u.label},`suggestion-${U}`)),(0,Bo.jsx)(D,{variant:"outline",size:"sm",className:"rounded-full text-xs ml-auto",onClick:be,children:"Debug"})]})]}),s&&(0,Bo.jsx)("input",{ref:S,type:"file",multiple:!0,onChange:I,className:"hidden"})]})]})}function ur({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,Bo.jsx)(Oa.Users,{className:"mr-2 Bo-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,ct.useState)(""),[u,U]=(0,ct.useState)(!1),ve=G?.messages||a,Ae=Z,Va=G?.status==="submitted"||u,Wa=G?.addToolResult?(j,de,oe)=>{G.addToolResult({tool:de,toolCallId:j,output:oe}),G.sendMessage()}:()=>{console.log("addToolResult not available")},dt=n||[],Ga={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"},[$a,qa]=(0,ct.useState)(()=>dt.length===0?Ga:dt.find(j=>j.id===F)||dt[0]),[pt,xt]=(0,ct.useState)([]),[Ka,_a]=(0,ct.useState)(!1),Ja=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=ei=>{xt(ti=>ti.map($t=>$t.id===wo.id?{...$t,preview:ei.target?.result}:$t))},wt.readAsDataURL(oe)}de.push(wo)}),xt(oe=>[...oe,...de])},Xa=j=>{xt(de=>de.filter(oe=>oe.id!==j))},xo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let j=pt.length>0?Qa(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([])}},Qa=j=>{let de=new DataTransfer;return j.forEach(oe=>de.items.add(oe)),de.files},Ya=j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),xo())},Za=j=>{be(j)};return(0,Bo.jsx)(ca,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:$a,onBusinessUnitChange:j=>{j&&(qa(j),R?.(j))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:I,actionText:Se,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,Bo.jsx)(Gt.AnimatePresence,{mode:"wait",children:(0,Bo.jsx)(Gt.motion.div,{className:"flex-1 Bo-full",initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2},children:(0,Bo.jsxs)("div",{className:"Bo-full flex",children:[(0,Bo.jsx)("div",{className:"w-80 flex-shrink-0 Bo-full Bo-2",children:(0,Bo.jsx)(da,{sessions:c||[],currentSession:S,teams:dt,onNewChat:m,onSessionSelect:w,onSessionEdit:y,onSessionDelete:f})}),(0,Bo.jsx)("div",{className:"flex-1 Bo-full Bo-2",children:(0,Bo.jsx)(ja,{messages:ve||[],input:Ae,isTyping:Va,currentSessionTitle:S?.title,capabilities:i||[],onInputChange:Za,addToolResult:Wa,onSendMessage:xo,onKeyPress:Ya,fileUploads:pt,isDragOver:Ka,enableFileUpload:$,onFileUpload:Ja,onRemoveFile:Xa,onDragOver:_a})})]})},"chat-interface")})})}0&&(module.exports={CopilotInterface});
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";import{a}from"../../chunk-ENBMBLW4.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";export{a as CopilotInterface};
2
+ "use strict";import{a}from"../../chunk-XRW62PGB.mjs";import"../../chunk-CTTBF7F4.mjs";import"../../chunk-56X4PU43.mjs";import"../../chunk-AXPE5U2T.mjs";import"../../chunk-7TSR2LQB.mjs";import"../../chunk-IFU7M7BO.mjs";import"../../chunk-7JDMW5R3.mjs";import"../../chunk-YPZAYXNQ.mjs";import"../../chunk-UA2E23AS.mjs";import"../../chunk-EH3PJU6C.mjs";import"../../chunk-6OT5PQXV.mjs";import"../../chunk-V5VE3EIY.mjs";import"../../chunk-QM5FOQHG.mjs";import"../../chunk-6OCLRAHU.mjs";import"../../chunk-5Y6FKL5W.mjs";import"../../chunk-EW6KWAHS.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";export{a as CopilotInterface};
@@ -5,5 +5,5 @@ interface ChatInterfaceProps {
5
5
  status: 'submitted' | 'streaming' | 'ready' | 'error';
6
6
  message: UIMessage;
7
7
  }
8
- export declare const messageHandler: ({ message, addToolResult, status, messages, }: ChatInterfaceProps) => (import("react/jsx-runtime").JSX.Element | null)[];
8
+ export declare const messageHandler: ({ message, addToolResult, status, messages, }: ChatInterfaceProps) => (import("react/jsx-runtime").JSX.Element | null | undefined)[];
9
9
  export {};