cortex-react-components 2.18.4 → 2.18.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3DZFESHK.mjs → chunk-2E7GRMZB.mjs} +1 -1
- package/dist/{chunk-QILFMWE5.mjs → chunk-2GZQYAN3.mjs} +1 -1
- package/dist/{chunk-JNJJAJPI.mjs → chunk-4NHQXOKZ.mjs} +1 -1
- package/dist/{chunk-HHPTGV4F.mjs → chunk-4RET4JGB.mjs} +1 -1
- package/dist/{chunk-MGSTQLZC.mjs → chunk-5KS3DITB.mjs} +1 -1
- package/dist/{chunk-3ZQFJ5WD.mjs → chunk-5RKIC5BC.mjs} +1 -1
- package/dist/{chunk-RMZLEIRP.mjs → chunk-66ODXUVL.mjs} +1 -1
- package/dist/{chunk-32V5QT3S.mjs → chunk-6RQED6RT.mjs} +1 -1
- package/dist/{chunk-LAQ3QAUW.mjs → chunk-75WE6ZXB.mjs} +1 -1
- package/dist/chunk-7HII2RTR.mjs +1 -0
- package/dist/{chunk-ANCSWAD7.mjs → chunk-BDNY6OKE.mjs} +1 -1
- package/dist/{chunk-MFUZNS7C.mjs → chunk-BGADMIWV.mjs} +1 -1
- package/dist/{chunk-VQBOJHZF.mjs → chunk-BN747TQM.mjs} +1 -1
- package/dist/{chunk-IYJOABIM.mjs → chunk-CPZ42O7I.mjs} +1 -1
- package/dist/{chunk-R5P4ZICA.mjs → chunk-D6K6RO5P.mjs} +1 -1
- package/dist/{chunk-RS4VD3ML.mjs → chunk-DZ7AGPLI.mjs} +1 -1
- package/dist/{chunk-4KQPMKRD.mjs → chunk-HEW44L6X.mjs} +1 -1
- package/dist/{chunk-QAJBJFRP.mjs → chunk-HNHUOQGZ.mjs} +1 -1
- package/dist/{chunk-HLTP3ZQN.mjs → chunk-JLUX7EHB.mjs} +1 -1
- package/dist/{chunk-YWRU7OE3.mjs → chunk-JT65KF7C.mjs} +1 -1
- package/dist/{chunk-CCJJAUGB.mjs → chunk-JUFFNFV6.mjs} +1 -1
- package/dist/{chunk-MEVSHOG4.mjs → chunk-KRLNPNMZ.mjs} +1 -1
- package/dist/{chunk-4DR4ILAP.mjs → chunk-LYQOKIQY.mjs} +1 -1
- package/dist/{chunk-GO42W2BM.mjs → chunk-M74BIPBM.mjs} +1 -1
- package/dist/{chunk-PTJVI53B.mjs → chunk-NN4QIXZ2.mjs} +1 -1
- package/dist/{chunk-33CHGT4N.mjs → chunk-NXG2Y4N4.mjs} +1 -1
- package/dist/{chunk-3EGSOIRH.mjs → chunk-PRK2XFAZ.mjs} +1 -1
- package/dist/{chunk-R33MOMFK.mjs → chunk-PZZTGPEO.mjs} +1 -1
- package/dist/{chunk-3QSJWNSG.mjs → chunk-QRJCVFHT.mjs} +1 -1
- package/dist/{chunk-P55W6AFU.mjs → chunk-RIRZRO6U.mjs} +1 -1
- package/dist/{chunk-H5VFV6Q4.mjs → chunk-SSMQFOZF.mjs} +1 -1
- package/dist/{chunk-JCWFPKF3.mjs → chunk-SYJIMO4P.mjs} +1 -1
- package/dist/{chunk-YPSUDHCJ.mjs → chunk-T36QUKC6.mjs} +1 -1
- package/dist/{chunk-RSDUFAIB.mjs → chunk-T5HJS6OF.mjs} +1 -1
- package/dist/{chunk-QZIJTAPO.mjs → chunk-UX5OJ3WS.mjs} +1 -1
- package/dist/{chunk-X3JZSN3W.mjs → chunk-UZSBX5GO.mjs} +1 -1
- package/dist/{chunk-XGIYNUGC.mjs → chunk-VNYUNZ3M.mjs} +1 -1
- package/dist/{chunk-2BR55L74.mjs → chunk-VRE6VCHX.mjs} +1 -1
- package/dist/{chunk-CTC6WSB6.mjs → chunk-WDZOGIT2.mjs} +1 -1
- package/dist/{chunk-L3BLBPSR.mjs → chunk-WUA65ZZB.mjs} +1 -1
- package/dist/{chunk-6EKGV4I2.mjs → chunk-Y62OBV2E.mjs} +1 -1
- package/dist/{chunk-UTRR5NUU.mjs → chunk-YFOSTZOD.mjs} +1 -1
- package/dist/{chunk-UG72MXTU.mjs → chunk-ZZ6VZFRV.mjs} +1 -1
- package/dist/components/Blocks/Banner.mjs +1 -1
- package/dist/components/Blocks/CallToAction.mjs +1 -1
- package/dist/components/Blocks/CollapsibleArea.mjs +1 -1
- package/dist/components/Blocks/Content.mjs +1 -1
- package/dist/components/Blocks/FeaturesBlock.mjs +1 -1
- package/dist/components/Blocks/ImageBlock.mjs +1 -1
- package/dist/components/Blocks/MediaBlock.mjs +1 -1
- package/dist/components/Blocks/RelatedPosts.mjs +1 -1
- package/dist/components/Blocks/RenderBlocks.mjs +1 -1
- package/dist/components/Blocks/ReusableContentBlock.mjs +1 -1
- package/dist/components/Blocks/index.mjs +1 -1
- package/dist/components/Cards/ContentCard.mjs +1 -1
- package/dist/components/Cards/FeatureCard.mjs +1 -1
- package/dist/components/Cards/index.mjs +1 -1
- package/dist/components/Chat/ChatInterface.js +1 -1
- package/dist/components/Chat/ChatInterface.mjs +1 -1
- package/dist/components/Chat/CopilotInterface.js +1 -1
- package/dist/components/Chat/CopilotInterface.mjs +1 -1
- package/dist/components/Chat/PartTypes/MessageHandler.js +1 -1
- package/dist/components/Chat/PartTypes/MessageHandler.mjs +1 -1
- package/dist/components/Chat/demo-long-messages.js +2 -2
- package/dist/components/Chat/demo-long-messages.mjs +1 -1
- package/dist/components/Chat/demo-tests.js +1 -1
- package/dist/components/Chat/demo-tests.mjs +1 -1
- package/dist/components/Chat/demo.js +1 -1
- package/dist/components/Chat/demo.mjs +1 -1
- package/dist/components/Chat/example-usage.js +1 -1
- package/dist/components/Chat/example-usage.mjs +1 -1
- package/dist/components/Chat/example-with-vercel-ai.js +1 -1
- package/dist/components/Chat/example-with-vercel-ai.mjs +1 -1
- package/dist/components/Chat/index.js +1 -1
- package/dist/components/Chat/index.mjs +1 -1
- package/dist/components/DigitalColleagues/MainPage.mjs +1 -1
- package/dist/components/DigitalColleagues/Views/index.mjs +1 -1
- package/dist/components/DigitalColleagues/index.mjs +1 -1
- package/dist/components/Foundary/MainPage.mjs +1 -1
- package/dist/components/Foundary/Pages/dashboardpage.mjs +1 -1
- package/dist/components/Foundary/RichText/index.mjs +1 -1
- package/dist/components/Foundary/RichText/plugins/toolbar-plugin.mjs +1 -1
- package/dist/components/Foundary/Views/KnowledgeView.mjs +1 -1
- package/dist/components/Foundary/Views/index.mjs +1 -1
- package/dist/components/Foundary/document-edit.mjs +1 -1
- package/dist/components/Foundary/document-preview-examples.mjs +1 -1
- package/dist/components/Foundary/document-preview.mjs +1 -1
- package/dist/components/Foundary/index.mjs +1 -1
- package/dist/components/Foundary/knowledge-browser.mjs +1 -1
- package/dist/components/HeaderFooter/Header.mjs +1 -1
- package/dist/components/HeaderFooter/HeaderDesktop.mjs +1 -1
- package/dist/components/HeaderFooter/SectionHeading.mjs +1 -1
- package/dist/components/HeaderFooter/index.mjs +1 -1
- package/dist/components/Heros/HighImpact/index.mjs +1 -1
- package/dist/components/Heros/LowImpact/index.mjs +1 -1
- package/dist/components/Heros/MediumImpact/index.mjs +1 -1
- package/dist/components/Heros/RenderHero.mjs +1 -1
- package/dist/components/Heros/index.mjs +1 -1
- package/dist/components/Holidays/HolidayTracker.mjs +1 -1
- package/dist/components/Holidays/index.mjs +1 -1
- package/dist/components/Layouts/OutputHeaderFooter.mjs +1 -1
- package/dist/components/Layouts/Print.mjs +1 -1
- package/dist/components/Layouts/SlideShow.mjs +1 -1
- package/dist/components/Layouts/index.mjs +1 -1
- package/dist/components/Payload/CollectionArchive/index.mjs +1 -1
- package/dist/components/Payload/Media/index.mjs +1 -1
- package/dist/components/Payload/PayloadCard/index.mjs +1 -1
- package/dist/components/Payload/RichText/index.mjs +1 -1
- package/dist/components/Payload/RichText/serialize.mjs +1 -1
- package/dist/components/Payload/index.mjs +1 -1
- package/dist/components/dc-temp/index.mjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/pages/Blog.mjs +1 -1
- package/dist/pages/Documentation.mjs +1 -1
- package/dist/pages/IndexPage.mjs +1 -1
- package/dist/pages/Intranet.mjs +1 -1
- package/dist/pages/LandingPage.mjs +1 -1
- package/dist/pages/Page.mjs +1 -1
- package/dist/pages/Publish.mjs +1 -1
- package/dist/pages/Website.mjs +1 -1
- package/dist/sections/AboutSection.mjs +1 -1
- package/dist/sections/BlogDetail.mjs +1 -1
- package/dist/sections/BlogList.mjs +1 -1
- package/dist/sections/ContactSection.mjs +1 -1
- package/dist/sections/PageSections.mjs +1 -1
- package/dist/sections/PricingSection.mjs +1 -1
- package/dist/sections/ServiceDetail.mjs +1 -1
- package/dist/sections/ServiceDetailSection.mjs +1 -1
- package/dist/sections/ServiceSection.mjs +1 -1
- package/dist/sections/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-CEAEO2FN.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)}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});
|
|
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 console.log("Rendering PartApprovalTool with toolPart:",n),(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-
|
|
1
|
+
import{a}from"../../chunk-CPZ42O7I.mjs";import"../../chunk-7HII2RTR.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};
|
|
@@ -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)}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),j=(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:j,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:j="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:F=>{G?.setMessages(ce=>[...ce,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:F.message}]}]),console.error("Error in CopilotInterface:",F)}},E=(0,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?(F,ce,ee)=>{G.addToolResult({tool:ce,toolCallId:F,output:ee}),console.log("Tool result added:",{toolCallId:F,tool:ce,output:ee}),G.sendMessage()}:()=>{console.log("addToolResult not available")},dt=n||[],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(F=>F.id===j)||dt[0]),[pt,xt]=(0,ct.useState)([]),[Ka,_a]=(0,ct.useState)(!1),Ja=F=>{if(!F||!$)return;let ce=[];Array.from(F).forEach(ee=>{if(ee.size>se*1024*1024){alert(`File ${ee.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>ee.type.match(wt))){alert(`File type ${ee.type} is not allowed.`);return}let wo={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ee,status:"pending",progress:0};if(ee.type.startsWith("image/")){let wt=new FileReader;wt.onload=ei=>{xt(ti=>ti.map($t=>$t.id===wo.id?{...$t,preview:ei.target?.result}:$t))},wt.readAsDataURL(ee)}ce.push(wo)}),xt(ee=>[...ee,...ce])},Xa=F=>{xt(ce=>ce.filter(ee=>ee.id!==F))},xo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let F=pt.length>0?Qa(pt.map(ce=>ce.file)):void 0;G.sendMessage({text:Ae,files:F},{body:{timestamp:Date.now()}}),be("")}else console.log("Message to send:",Ae),console.log("Files to upload:",pt),be(""),U(!0),setTimeout(()=>{U(!1)},1500);xt([])}},Qa=F=>{let ce=new DataTransfer;return F.forEach(ee=>ce.items.add(ee)),ce.files},Ya=F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),xo())},Za=F=>{be(F)};return(0,Bo.jsx)(ca,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:$a,onBusinessUnitChange:F=>{F&&(qa(F),R?.(F))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:I,actionText:Se,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,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 console.log("Rendering PartApprovalTool with toolPart:",r),(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),j=(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:j,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:j="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:F=>{G?.setMessages(ce=>[...ce,{role:"assistant",id:`error-${Date.now()}`,createdAt:new Date,parts:[{type:"text",text:F.message}]}]),console.error("Error in CopilotInterface:",F)}},E=(0,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?(F,ce,ee)=>{G.addToolResult({tool:ce,toolCallId:F,output:ee}),console.log("Tool result added:",{toolCallId:F,tool:ce,output:ee}),G.sendMessage()}:()=>{console.log("addToolResult not available")},dt=n||[],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(F=>F.id===j)||dt[0]),[pt,xt]=(0,ct.useState)([]),[Ka,_a]=(0,ct.useState)(!1),Ja=F=>{if(!F||!$)return;let ce=[];Array.from(F).forEach(ee=>{if(ee.size>se*1024*1024){alert(`File ${ee.name} is too large. Maximum size is ${se}MB.`);return}if(J.length>0&&!J.some(wt=>ee.type.match(wt))){alert(`File type ${ee.type} is not allowed.`);return}let wo={id:Date.now().toString()+Math.random().toString(36).substr(2,9),file:ee,status:"pending",progress:0};if(ee.type.startsWith("image/")){let wt=new FileReader;wt.onload=ei=>{xt(ti=>ti.map($t=>$t.id===wo.id?{...$t,preview:ei.target?.result}:$t))},wt.readAsDataURL(ee)}ce.push(wo)}),xt(ee=>[...ee,...ce])},Xa=F=>{xt(ce=>ce.filter(ee=>ee.id!==F))},xo=()=>{if(!(!Ae.trim()&&pt.length===0)){if(G){let F=pt.length>0?Qa(pt.map(ce=>ce.file)):void 0;G.sendMessage({text:Ae,files:F},{body:{timestamp:Date.now()}}),be("")}else console.log("Message to send:",Ae),console.log("Files to upload:",pt),be(""),U(!0),setTimeout(()=>{U(!1)},1500);xt([])}},Qa=F=>{let ce=new DataTransfer;return F.forEach(ee=>ce.items.add(ee)),ce.files},Ya=F=>{F.key==="Enter"&&!F.shiftKey&&(F.preventDefault(),xo())},Za=F=>{be(F)};return(0,Bo.jsx)(ca,{sidebarItems:r||[],title:_,notifications:s||[],businessUnits:dt,currentBusinessUnit:$a,onBusinessUnitChange:F=>{F&&(qa(F),R?.(F))},onSearch:N,showTabs:!1,onActionClick:C,actionIcon:I,actionText:Se,onNotificationRemove:A,onRemoveAll:T,logo:W,appName:X,tagline:le,sidebarInitiallyClosed:d,children:(0,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-
|
|
2
|
+
"use strict";import{a}from"../../chunk-HEW44L6X.mjs";import"../../chunk-CTTBF7F4.mjs";import"../../chunk-56X4PU43.mjs";import"../../chunk-CPZ42O7I.mjs";import"../../chunk-7HII2RTR.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};
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
`,children:r?"Processing...":"Deny"}),(0,L.jsx)("button",{onClick:f,disabled:r,className:`
|
|
18
18
|
px-4 py-2 text-white border-none rounded text-sm
|
|
19
19
|
${r?"bg-gray-400 cursor-not-allowed":"bg-gray-500 hover:bg-gray-600 cursor-pointer"}
|
|
20
|
-
`,children:"Cancel"})]})]}):null};var $e=({toolPart:e,index:t,addToolResult:o})=>{let[s,a]=Ne.default.useState(!0),[n,r]=Ne.default.useState(null),i=()=>{o(e.input?.toolCallId,e.input?.tool,"Approved"),a(!1),r("approve")},d=()=>{o(e.input?.toolCallId,e.input?.tool,"Denied"),a(!1),r("deny")};switch(e.state){case"input-available":return(0,L.jsxs)("div",{className:"mb-2",children:[(0,L.jsx)(We,{isOpen:s,onApprove:i,onDeny:d,onClose:()=>a(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!s&&(0,L.jsxs)(L.Fragment,{children:[n==="approve"&&(0,L.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,L.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,L.jsx)("svg",{className:"L-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,L.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),n==="deny"&&(0,L.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,L.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,L.jsx)("svg",{className:"L-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,L.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,L.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var Re=require("@radix-ui/react-use-controllable-state");var q=ee(require("@radix-ui/react-collapsible")),ce=q.Root,pe=q.CollapsibleTrigger,ue=q.CollapsibleContent;var et=require("clsx");var Pe="-",Lt=e=>{let t=zt(e),{conflictingClassGroups:o,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:r=>{let i=r.split(Pe);return i[0]===""&&i.length!==1&&i.shift(),Je(i,t)||It(r)},getConflictingClassGroupIds:(r,i)=>{let d=o[r]||[];return i&&s[r]?[...d,...s[r]]:d}}},Je=(e,t)=>{if(e.length===0)return t.classGroupId;let o=e[0],s=t.nextPart.get(o),a=s?Je(e.slice(1),s):void 0;if(a)return a;if(t.validators.length===0)return;let n=e.join(Pe);return t.validators.find(({validator:r})=>r(n))?.classGroupId},_e=/^\[(.+)\]$/,It=e=>{if(_e.test(e)){let t=_e.exec(e)[1],o=t?.substring(0,t.indexOf(":"));if(o)return"arbitrary.."+o}},zt=e=>{let{theme:t,prefix:o}=e,s={nextPart:new Map,validators:[]};return Dt(Object.entries(e.classGroups),o).forEach(([n,r])=>{Te(r,s,n,t)}),s},Te=(e,t,o,s)=>{e.forEach(a=>{if(typeof a=="string"){let n=a===""?t:qe(t,a);n.classGroupId=o;return}if(typeof a=="function"){if(Et(a)){Te(a(s),t,o,s);return}t.validators.push({validator:a,classGroupId:o});return}Object.entries(a).forEach(([n,r])=>{Te(r,qe(t,n),o,s)})})},qe=(e,t)=>{let o=e;return t.split(Pe).forEach(s=>{o.nextPart.has(s)||o.nextPart.set(s,{nextPart:new Map,validators:[]}),o=o.nextPart.get(s)}),o},Et=e=>e.isThemeGetter,Dt=(e,t)=>t?e.map(([o,s])=>{let a=s.map(n=>typeof n=="string"?t+n:typeof n=="object"?Object.fromEntries(Object.entries(n).map(([r,i])=>[t+r,i])):n);return[o,a]}):e,Bt=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,o=new Map,s=new Map,a=(n,r)=>{o.set(n,r),t++,t>e&&(t=0,s=o,o=new Map)};return{get(n){let r=o.get(n);if(r!==void 0)return r;if((r=s.get(n))!==void 0)return a(n,r),r},set(n,r){o.has(n)?o.set(n,r):a(n,r)}}},Xe="!",Ht=e=>{let{separator:t,experimentalParseClassName:o}=e,s=t.length===1,a=t[0],n=t.length,r=i=>{let d=[],p=0,f=0,u;for(let v=0;v<i.length;v++){let w=i[v];if(p===0){if(w===a&&(s||i.slice(v,v+n)===t)){d.push(i.slice(f,v)),f=v+n;continue}if(w==="/"){u=v;continue}}w==="["?p++:w==="]"&&p--}let g=d.length===0?i:i.substring(f),C=g.startsWith(Xe),k=C?g.substring(1):g,y=u&&u>f?u-f:void 0;return{modifiers:d,hasImportantModifier:C,baseClassName:k,maybePostfixModifierPosition:y}};return o?i=>o({className:i,parseClassName:r}):r},Ot=e=>{if(e.length<=1)return e;let t=[],o=[];return e.forEach(s=>{s[0]==="["?(t.push(...o.sort(),s),o=[]):o.push(s)}),t.push(...o.sort()),t},Gt=e=>({cache:Bt(e.cacheSize),parseClassName:Ht(e),...Lt(e)}),jt=/\s+/,Ut=(e,t)=>{let{parseClassName:o,getClassGroupId:s,getConflictingClassGroupIds:a}=t,n=[],r=e.trim().split(jt),i="";for(let d=r.length-1;d>=0;d-=1){let p=r[d],{modifiers:f,hasImportantModifier:u,baseClassName:g,maybePostfixModifierPosition:C}=o(p),k=!!C,y=s(k?g.substring(0,C):g);if(!y){if(!k){i=p+(i.length>0?" "+i:i);continue}if(y=s(g),!y){i=p+(i.length>0?" "+i:i);continue}k=!1}let v=Ot(f).join(":"),w=u?v+Xe:v,S=w+y;if(n.includes(S))continue;n.push(S);let Z=a(y,k);for(let W=0;W<Z.length;++W){let se=Z[W];n.push(w+se)}i=p+(i.length>0?" "+i:i)}return i};function Ft(){let e=0,t,o,s="";for(;e<arguments.length;)(t=arguments[e++])&&(o=Ke(t))&&(s&&(s+=" "),s+=o);return s}var Ke=e=>{if(typeof e=="string")return e;let t,o="";for(let s=0;s<e.length;s++)e[s]&&(t=Ke(e[s]))&&(o&&(o+=" "),o+=t);return o};function Vt(e,...t){let o,s,a,n=r;function r(d){let p=t.reduce((f,u)=>u(f),e());return o=Gt(p),s=o.cache.get,a=o.cache.set,n=i,i(d)}function i(d){let p=s(d);if(p)return p;let f=Ut(d,o);return a(d,f),f}return function(){return n(Ft.apply(null,arguments))}}var b=e=>{let t=o=>o[e]||[];return t.isThemeGetter=!0,t},Ye=/^\[(?:([a-z-]+):)?(.+)\]$/i,Wt=/^\d+\/\d+$/,$t=new Set(["px","full","screen"]),_t=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|me|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|L|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Jt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Xt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)L-?((\d+)?\.?(\d+)[a-z]+|0)/,Kt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,O=e=>J(e)||$t.has(e)||Wt.test(e),U=e=>X(e,"length",no),J=e=>!!e&&!Number.isNaN(Number(e)),ke=e=>X(e,"number",J),te=e=>!!e&&Number.isInteger(Number(e)),Yt=e=>e.endsWith("%")&&J(e.slice(0,-1)),c=e=>Ye.test(e),F=e=>_t.test(e),Zt=new Set(["length","size","percentage"]),Qt=e=>X(e,Zt,Ze),eo=e=>X(e,"position",Ze),to=new Set(["image","url"]),oo=e=>X(e,to,so),ro=e=>X(e,"",ao),oe=()=>!0,X=(e,t,o)=>{let s=Ye.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):o(s[2]):!1},no=e=>qt.test(e)&&!Jt.test(e),Ze=()=>!1,ao=e=>Xt.test(e),so=e=>Kt.test(e);var io=()=>{let e=b("colors"),t=b("spacing"),o=b("blur"),s=b("brightness"),a=b("borderColor"),n=b("borderRadius"),r=b("borderSpacing"),i=b("borderWidth"),d=b("contrast"),p=b("grayscale"),f=b("hueRotate"),u=b("invert"),g=b("gap"),C=b("gradientColorStops"),k=b("gradientColorStopPositions"),y=b("inset"),v=b("margin"),w=b("opacity"),S=b("padding"),Z=b("saturate"),W=b("scale"),se=b("sepia"),ze=b("skew"),Ee=b("space"),De=b("translate"),he=()=>["auto","contain","none"],xe=()=>["auto","hidden","clip","visible","scroll"],ve=()=>["auto",c,t],x=()=>[c,t],Be=()=>["",O,U],ie=()=>["auto",J,c],He=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],le=()=>["solid","dashed","dotted","double","none"],Oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ye=()=>["start","end","center","between","around","evenly","stretch"],Q=()=>["","0",c],Ge=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>[J,c];return{cacheSize:500,separator:":",theme:{colors:[oe],spacing:[O,U],blur:["none","",F,c],brightness:D(),borderColor:[e],borderRadius:["none","","full",F,c],borderSpacing:x(),borderWidth:Be(),contrast:D(),grayscale:Q(),hueRotate:D(),invert:Q(),gap:x(),gradientColorStops:[e],gradientColorStopPositions:[Yt,U],inset:ve(),margin:ve(),opacity:D(),padding:x(),saturate:D(),scale:D(),sepia:Q(),skew:D(),space:x(),translate:x()},classGroups:{aspect:[{aspect:["auto","square","video",c]}],container:["container"],columns:[{columns:[F]}],"break-after":[{"break-after":Ge()}],"break-before":[{"break-before":Ge()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...He(),c]}],overflow:[{overflow:xe()}],"overflow-x":[{"overflow-x":xe()}],"overflow-y":[{"overflow-y":xe()}],overscroll:[{overscroll:he()}],"overscroll-x":[{"overscroll-x":he()}],"overscroll-y":[{"overscroll-y":he()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",te,c]}],basis:[{basis:ve()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",c]}],grow:[{grow:Q()}],shrink:[{shrink:Q()}],order:[{order:["first","last","none",te,c]}],"grid-cols":[{"grid-cols":[oe]}],"col-start-end":[{col:["auto",{span:["full",te,c]},c]}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":[oe]}],"row-start-end":[{row:["auto",{span:[te,c]},c]}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",c]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",c]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...ye()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ye(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ye(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],me:[{me:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[Ee]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[Ee]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",c,t]}],"min-w":[{"min-w":[c,t,"min","max","fit"]}],"max-w":[{"max-w":[c,t,"none","full","min","max","fit","prose",{screen:[F]},F]}],L:[{L:[c,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-L":[{"min-L":[c,t,"min","max","fit","svh","lvh","dvh"]}],"max-L":[{"max-L":[c,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[c,t,"auto","min","max","fit"]}],"font-size":[{text:["base",F,U]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ke]}],"font-family":[{font:[oe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",c]}],"line-clamp":[{"line-clamp":["none",J,ke]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",O,c]}],"list-image":[{"list-image":["none",c]}],"list-style-type":[{list:["none","disc","decimal",c]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[w]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[w]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...le(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",O,U]}],"underline-offset":[{"underline-offset":["auto",O,c]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",c]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",c]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[w]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...He(),eo]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Qt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","L","tl"]},oo]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[k]}],"gradient-via-pos":[{via:[k]}],"gradient-to-pos":[{to:[k]}],"gradient-from":[{from:[C]}],"gradient-via":[{via:[C]}],"gradient-to":[{to:[C]}],rounded:[{rounded:[n]}],"rounded-s":[{"rounded-s":[n]}],"rounded-e":[{"rounded-e":[n]}],"rounded-t":[{"rounded-t":[n]}],"rounded-r":[{"rounded-r":[n]}],"rounded-b":[{"rounded-b":[n]}],"rounded-L":[{"rounded-L":[n]}],"rounded-ss":[{"rounded-ss":[n]}],"rounded-se":[{"rounded-se":[n]}],"rounded-ee":[{"rounded-ee":[n]}],"rounded-es":[{"rounded-es":[n]}],"rounded-tl":[{"rounded-tl":[n]}],"rounded-tr":[{"rounded-tr":[n]}],"rounded-br":[{"rounded-br":[n]}],"rounded-bl":[{"rounded-bl":[n]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-L":[{"border-L":[i]}],"border-opacity":[{"border-opacity":[w]}],"border-style":[{border:[...le(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[w]}],"divide-style":[{divide:le()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-L":[{"border-L":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...le()]}],"outline-offset":[{"outline-offset":[O,c]}],"outline-w":[{outline:[O,U]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Be()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[w]}],"ring-offset-w":[{"ring-offset":[O,U]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",F,ro]}],"shadow-color":[{shadow:[oe]}],opacity:[{opacity:[w]}],"mix-blend":[{"mix-blend":[...Oe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Oe()}],filter:[{filter:["","none"]}],blur:[{blur:[o]}],brightness:[{brightness:[s]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",F,c]}],grayscale:[{grayscale:[p]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[u]}],saturate:[{saturate:[Z]}],sepia:[{sepia:[se]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[o]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[p]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[w]}],"backdrop-saturate":[{"backdrop-saturate":[Z]}],"backdrop-sepia":[{"backdrop-sepia":[se]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[r]}],"border-spacing-x":[{"border-spacing-x":[r]}],"border-spacing-y":[{"border-spacing-y":[r]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",c]}],duration:[{duration:D()}],ease:[{ease:["linear","in","out","in-out",c]}],delay:[{delay:D()}],animate:[{animate:["none","spin","ping","pulse","bounce",c]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[W]}],"scale-x":[{"scale-x":[W]}],"scale-y":[{"scale-y":[W]}],rotate:[{rotate:[te,c]}],"translate-x":[{"translate-x":[De]}],"translate-y":[{"translate-y":[De]}],"skew-x":[{"skew-x":[ze]}],"skew-y":[{"skew-y":[ze]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",c]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",c]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",c]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[O,U,ke]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","me","pr","pb","pl"],px:["pr","pl"],py:["me","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","L"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-L","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-L":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-L"],"border-w-x":["border-w-r","border-w-L"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-L"],"border-color-x":["border-color-r","border-color-L"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-me","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-me","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}};var Qe=Vt(io);function m(...e){return Qe((0,et.clsx)(e))}var me=require("lucide-react");var ot=require("streamdown"),re=(0,Ce.memo)(({className:e,...t})=>(0,L.jsx)(ot.Streamdown,{className:m("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);re.displayName="Response";var nt=(0,Ce.createContext)(null),lo=()=>{let e=(0,Ce.useContext)(nt);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},co=1e3,po=1e3,Ae=(0,Ce.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:s=!0,onOpenChange:a,duration:n,children:r,...i})=>{let[d,p]=(0,Re.useControllableState)({prop:o,defaultProp:s,onChange:a}),[f,u]=(0,Re.useControllableState)({prop:n,defaultProp:0}),[g,C]=(0,Ce.useState)(!1),[k,y]=(0,Ce.useState)(null);(0,Ce.useEffect)(()=>{t?k===null&&y(Date.now()):k!==null&&(u(Math.ceil((Date.now()-k)/po)),y(null))},[t,k,u]),(0,Ce.useEffect)(()=>{if(s&&!t&&d&&!g){let w=setTimeout(()=>{p(!1),C(!0)},co);return()=>clearTimeout(w)}},[t,d,s,p,g]);let v=w=>{p(w)};return(0,L.jsx)(nt.Provider,{value:{isStreaming:t,isOpen:d,setIsOpen:p,duration:f},children:(0,L.jsx)(ce,{className:m("not-prose mb-4",e),onOpenChange:v,open:d,...i,children:r})})}),uo=(e,t)=>e||t===0?(0,L.jsx)("p",{children:"Thinking..."}):t===void 0?(0,L.jsx)("p",{children:"Thought for a few seconds"}):(0,L.jsxs)("p",{children:["Thought for ",t," seconds"]}),Se=(0,Ce.memo)(({className:e,children:t,...o})=>{let{isStreaming:s,isOpen:a,duration:n}=lo();return(0,L.jsx)(pe,{className:m("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(me.BrainIcon,{className:"size-4"}),uo(s,n),(0,L.jsx)(me.ChevronDownIcon,{className:m("size-4 transition-transform",a?"rotate-180":"rotate-0")})]})})}),Me=(0,Ce.memo)(({className:e,children:t,...o})=>(0,L.jsx)(ue,{className:m("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,L.jsx)(re,{className:"grid gap-2",children:t})}));Ae.displayName="Reasoning";Se.displayName="ReasoningTrigger";Me.displayName="ReasoningContent";var at=require("class-variance-authority");var mo=(0,at.cva)("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function K({className:e,variant:t,...o}){return(0,L.jsx)("div",{className:m(mo({variant:t}),e),...o})}var it=require("@radix-ui/react-slot"),dt=ee(require("react")),go=(0,at.cva)("inline-flex items-center justify-center whitespace-nowrap rounded text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{defaultVariants:{size:"default",variant:"default"},variants:{size:{clear:"",default:"L-10 px-4 py-2",icon:"L-10 w-10",lg:"L-11 rounded px-8",sm:"L-9 rounded px-3"},variant:{default:"bg-accent text-accent-foreground hover:bg-background hover:text-accent hover:border-accent hover:border",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",ghost:"hover:bg-card hover:text-accent",link:"text-primary items-start justify-start underline-offset-4 hover:underline",outline:"border border-border bg-background hover:bg-card hover:text-accent",secondary:"bg-secondary text-secondary-foreground hover:bg-accent"}}}),ne=dt.forwardRef(({asChild:e=!1,className:t,size:o,variant:s,...a},n)=>(0,L.jsx)(e?it.Slot:"button",{className:m(go({className:t,size:o,variant:s})),ref:n,...a}));ne.displayName="Button";var Le=require("react-syntax-highlighter"),fe=require("react-syntax-highlighter/dist/esm/styles/prism"),fo=(0,Ce.createContext)({code:""}),be=({code:e,language:t,showLineNumbers:o=!1,className:s,children:a,...n})=>(0,L.jsx)(fo.Provider,{value:{code:e},children:(0,L.jsx)("div",{className:m("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",s),...n,children:(0,L.jsxs)("div",{className:"relative",children:[(0,L.jsx)(Le.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:fe.oneLight,children:e}),(0,L.jsx)(Le.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:fe.oneDark,children:e}),a&&(0,L.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:a})]})})});var ut=({className:e,...t})=>(0,L.jsx)(ce,{className:m("not-prose mb-4 w-full",e),...t}),bo=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,L.jsxs)(K,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,L.jsx)(me.CircleIcon,{className:"size-4"}),"input-available":(0,L.jsx)(me.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,L.jsx)(me.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,L.jsx)(me.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},mt=({className:e,type:t,state:o,...s})=>(0,L.jsxs)(pe,{className:m("flex w-full items-center justify-between gap-4 p-3 pl-0 w-2xl",e),...s,children:[(0,L.jsxs)("div",{className:"flex items-center gap-2",children:[(0,L.jsx)(me.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,L.jsx)("span",{className:"font-medium text-sm",children:t}),bo(o)]}),(0,L.jsx)(me.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),gt=({className:e,...t})=>(0,L.jsx)(ue,{className:m("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}),ft=({className:e,input:t,...o})=>(0,L.jsxs)("div",{className:m("space-y-2 overflow-hidden p-4",e),...o,children:[(0,L.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,L.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,L.jsx)(be,{code:JSON.stringify(t,null,2),language:"json"})})]}),bt=({className:e,output:t,errorText:o,...s})=>{if(!(t||o))return null;let a=(0,L.jsx)("div",{children:t});return typeof t=="object"?a=(0,L.jsx)(be,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(a=(0,L.jsx)(be,{code:t,language:"json"})),(0,L.jsxs)("div",{className:m("space-y-2 p-4",e),...s,children:[(0,L.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,L.jsxs)("div",{className:m("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[o&&(0,L.jsx)("div",{children:o}),a]})]})};var $=ee(require("react"));var I=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("rounded-xl border bg-card text-card-foreground shadow",e),...t}));I.displayName="Card";var G=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("flex flex-col space-y-1.5 p-6",e),...t}));G.displayName="CardHeader";var j=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("font-semibold leading-none tracking-tight",e),...t}));j.displayName="CardTitle";var Ie=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("text-sm text-muted-foreground",e),...t}));Ie.displayName="CardDescription";var z=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("p-6 me-0",e),...t}));z.displayName="CardContent";var ae=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("flex items-center p-6 me-0",e),...t}));ae.displayName="CardFooter";var vt=require("date-fns");function ht({taskId:e,polling:t=!0,system:o="payload"}){let[s,a]=(0,Ce.useState)(null),[n,r]=(0,Ce.useState)(!1),[i,d]=(0,Ce.useState)(null),p=async(u=!0)=>{if(e){u&&r(!0);try{let g=await fetch(`/api/tasks/${e}`);if(!g.ok)throw new Error(`Failed to fetch task: ${g.statusText}`);let C=await g.json();a(C)}catch(g){console.error("Error fetching task:",g),d(g instanceof Error?g:new Error("Unknown error occurred"))}finally{u&&r(!1)}}},f=()=>p(!1);return(0,Ce.useEffect)(()=>{e&&p(!0);let u=null;return e&&t&&(u=setInterval(f,5e3)),()=>{u&&clearInterval(u)}},[e,t]),{task:s,loading:n,error:i}}var ho=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"}},xo=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function yt({data:e}){let{id:t,system:o,fetchLatest:s,taskData:a,error:n}=e||{};if(!t)return null;let r=null,i=!0,d=n,p=s!==void 0?s:!0;if(r=a||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:s,system:o,fetchLatest:p,taskData:r,error:d}),p){let{task:C,loading:k,error:y}=ht({taskId:t,system:o});r=C,i=k,d=y}else i=!1;let f=ho(r?.status||"todo"),u=xo(r?.status||"todo"),g=r?.dateLogged||new Date().toISOString();try{let C=new Date(r?.dateLogged||"");isNaN(C.getTime())||(g=(0,vt.formatDistanceToNow)(C,{addSuffix:!0}))}catch{}return(0,L.jsxs)(I,{className:m("w-full max-w-md shadow-md",d&&"border border-destructive"),children:[(0,L.jsxs)(G,{className:"pb-2",children:[(0,L.jsxs)("div",{className:"flex justify-between items-start",children:[(0,L.jsx)(j,{className:"text-lg font-semibold",children:i?"Loading...":r?.name||"Task"}),(0,L.jsx)(K,{className:`${f}`,children:u})]}),r?.project&&(0,L.jsxs)(Ie,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,L.jsx)(z,{className:"pb-2",children:i?(0,L.jsx)("div",{className:"animate-pulse L-4 bg-gray-200 rounded w-3/4 mb-2"}):d?(0,L.jsx)("p",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,L.jsx)("p",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,L.jsx)(ae,{className:"me-2 flex items-center justify-between",children:(0,L.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,L.jsx)(me.Clock,{className:"L-3 w-3 mr-1"}),(0,L.jsxs)("span",{children:["Created ",g]}),(0,L.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,L.jsxs)("span",{children:["Task #",t]})]})})]})}function Nt({artefact:e,taskId:t,taskData:o,loading:s=!1,error:a=null}){let n=o||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},r=n.dateLogged;try{let i=new Date(n.dateLogged);isNaN(i.getTime())||(r=(0,vt.formatDistanceToNow)(i,{addSuffix:!0}))}catch{}return(0,L.jsxs)(I,{className:"w-full max-w-md shadow-md",children:[(0,L.jsx)(G,{className:"pb-2",children:(0,L.jsx)("div",{className:"flex justify-between items-start",children:(0,L.jsx)(j,{className:"text-lg font-semibold",children:s?"Loading...":n.name})})}),(0,L.jsx)(z,{className:"pb-2",children:s?(0,L.jsx)("div",{className:"animate-pulse L-4 bg-gray-200 rounded w-3/4 mb-2"}):a?(0,L.jsx)("p",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,L.jsx)("p",{className:"text-sm text-foreground",children:e})}),(0,L.jsx)(ae,{className:"me-2 flex items-center justify-between",children:(0,L.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,L.jsx)(me.Clock,{className:"L-3 w-3 mr-1"}),(0,L.jsxs)("span",{children:["Created ",r]}),(0,L.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,L.jsxs)("span",{children:["Task #",n.id]})]})})]})}var vo=e=>e.startsWith("image/")?(0,L.jsx)(me.Image,{className:"L-4 w-4"}):e.startsWith("text/")?(0,L.jsx)(me.FileText,{className:"L-4 w-4"}):(0,L.jsx)(me.File,{className:"L-4 w-4"}),yo=({message:e,addToolResult:t,status:o,messages:s})=>e.parts.map((a,n)=>{if(a.type==="text")return(0,L.jsx)(re,{children:a.text},`${n}`);if(a.type==="file"){let r=a;return(0,L.jsx)("div",{className:"mb-2 p-2 bg-background/50 rounded-lg",children:(0,L.jsxs)("div",{className:"flex items-center gap-2",children:[vo(r.mediaType||"application/octet-stream"),(0,L.jsx)("div",{className:"flex-1 min-w-0",children:(0,L.jsx)("p",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,L.jsx)(ne,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"L-8 w-8 p-0",children:(0,L.jsx)(me.Download,{className:"L-4 w-4"})})]})},n)}if(a.type.startsWith("tool-")){let r=a,i=a.type.replace("tool-","");if(i==="task")switch(r.state){case"input-available":return(0,L.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},n);case"output-available":return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(yt,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},n);case"output-error":return(0,L.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},n);default:return null}if(a.type==="tool-requestEndpointLogin")return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(we,{toolPart:r,index:n,addToolResult:t??(()=>{})})},n);if(a.type==="tool-authenticate")return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(we,{toolPart:r,index:n,addToolResult:t??(()=>{})})},n);if(a.type==="tool-requestApproval")return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)($e,{toolPart:r,index:n,addToolResult:t??(()=>{})})},n);if(i==="artefact")switch(r.state){case"input-available":return(0,L.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},n);case"output-available":return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(Nt,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},n);case"output-error":return(0,L.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},n);default:return null}return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsxs)(I,{className:"w-full max-w-md",children:[(0,L.jsx)(G,{children:(0,L.jsx)(j,{className:"text-lg",children:i})}),(0,L.jsxs)(z,{children:[r.state==="input-available"&&(0,L.jsxs)("p",{className:"text-sm",children:["Processing ",i,"..."]}),r.state==="output-available"&&(0,L.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,L.jsxs)("p",{className:"text-sm text-red-500",children:["Error: ",r.errorText]})]})]})},n)}if(a.type.startsWith("data-")){let r=a,i=a.type.replace("data-","");return i==="reference"?(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(I,{className:"w-full",children:(0,L.jsx)(z,{className:"p-4",children:(0,L.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((d,p)=>(0,L.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/50",children:[(0,L.jsx)(K,{variant:"outline",children:d.type||"link"}),(0,L.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,L.jsx)("p",{className:"text-sm font-medium truncate",children:d.title}),d.description&&(0,L.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:d.description})]}),d.url&&(0,L.jsx)(ne,{variant:"ghost",size:"sm",onClick:()=>window.open(d.url,"_blank"),className:"L-8 w-8 p-0",children:(0,L.jsx)(me.ExternalLink,{className:"L-4 w-4"})})]},p))})})})},n):i==="menu"?(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsxs)(I,{className:"w-full",children:[(0,L.jsx)(G,{children:(0,L.jsx)(j,{className:"text-lg",children:r.data?.title})}),(0,L.jsx)(z,{children:(0,L.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((d,p)=>(0,L.jsx)(ne,{variant:"outline",className:"w-full justify-start",onClick:d.action,children:(0,L.jsxs)("div",{className:"text-left",children:[(0,L.jsx)("p",{className:"font-medium",children:d.label}),d.description&&(0,L.jsx)("p",{className:"text-xs text-muted-foreground",children:d.description})]})},p))})})]})},n):(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsxs)(I,{className:"w-full max-w-md",children:[(0,L.jsx)(G,{children:(0,L.jsx)(j,{className:"text-lg",children:i})}),(0,L.jsx)(z,{children:(0,L.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},n)}if(a.type==="reasoning")return(0,L.jsxs)(Ae,{className:"w-full",isStreaming:o==="streaming"&&n===e.parts.length-1&&e.id===s.at(-1)?.id,children:[(0,L.jsx)(Se,{}),(0,L.jsx)(Me,{children:a.text})]},`${n}`);if(a.type==="dynamic-tool")return(0,L.jsxs)(ut,{defaultOpen:a.state!=="output-available",children:[(0,L.jsx)(mt,{type:`tool-${a.toolName}`,state:a.state}),(0,L.jsxs)(gt,{children:[(0,L.jsx)(ft,{input:a.input}),(0,L.jsx)(bt,{output:a.output,errorText:a.errorText})]})]},`${e.id}-${n}`)});0&&(module.exports={messageHandler});
|
|
20
|
+
`,children:"Cancel"})]})]}):null};var $e=({toolPart:e,index:t,addToolResult:o})=>{let[s,a]=Ne.default.useState(!0),[n,r]=Ne.default.useState(null),i=()=>{o(e.input?.toolCallId,e.input?.tool,"Approved"),a(!1),r("approve")},d=()=>{o(e.input?.toolCallId,e.input?.tool,"Denied"),a(!1),r("deny")};switch(e.state){case"input-available":return(0,L.jsxs)("div",{className:"mb-2",children:[(0,L.jsx)(We,{isOpen:s,onApprove:i,onDeny:d,onClose:()=>a(!1),title:e.input?.title||"Approval Required",reason:e.output?.reason||e.input?.reason}),!s&&(0,L.jsxs)(L.Fragment,{children:[n==="approve"&&(0,L.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,L.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,L.jsx)("svg",{className:"L-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,L.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Approved"]})}),n==="deny"&&(0,L.jsx)("div",{className:"flex items-center justify-center mt-3",children:(0,L.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,L.jsx)("svg",{className:"L-4 w-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,L.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Denied"]})})]})]},t);case"output-error":return(0,L.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",e.errorText]},t);default:return null}};var Re=require("@radix-ui/react-use-controllable-state");var q=ee(require("@radix-ui/react-collapsible")),ce=q.Root,pe=q.CollapsibleTrigger,ue=q.CollapsibleContent;var et=require("clsx");var Pe="-",Lt=e=>{let t=zt(e),{conflictingClassGroups:o,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:r=>{let i=r.split(Pe);return i[0]===""&&i.length!==1&&i.shift(),Je(i,t)||It(r)},getConflictingClassGroupIds:(r,i)=>{let d=o[r]||[];return i&&s[r]?[...d,...s[r]]:d}}},Je=(e,t)=>{if(e.length===0)return t.classGroupId;let o=e[0],s=t.nextPart.get(o),a=s?Je(e.slice(1),s):void 0;if(a)return a;if(t.validators.length===0)return;let n=e.join(Pe);return t.validators.find(({validator:r})=>r(n))?.classGroupId},_e=/^\[(.+)\]$/,It=e=>{if(_e.test(e)){let t=_e.exec(e)[1],o=t?.substring(0,t.indexOf(":"));if(o)return"arbitrary.."+o}},zt=e=>{let{theme:t,prefix:o}=e,s={nextPart:new Map,validators:[]};return Dt(Object.entries(e.classGroups),o).forEach(([n,r])=>{Te(r,s,n,t)}),s},Te=(e,t,o,s)=>{e.forEach(a=>{if(typeof a=="string"){let n=a===""?t:qe(t,a);n.classGroupId=o;return}if(typeof a=="function"){if(Et(a)){Te(a(s),t,o,s);return}t.validators.push({validator:a,classGroupId:o});return}Object.entries(a).forEach(([n,r])=>{Te(r,qe(t,n),o,s)})})},qe=(e,t)=>{let o=e;return t.split(Pe).forEach(s=>{o.nextPart.has(s)||o.nextPart.set(s,{nextPart:new Map,validators:[]}),o=o.nextPart.get(s)}),o},Et=e=>e.isThemeGetter,Dt=(e,t)=>t?e.map(([o,s])=>{let a=s.map(n=>typeof n=="string"?t+n:typeof n=="object"?Object.fromEntries(Object.entries(n).map(([r,i])=>[t+r,i])):n);return[o,a]}):e,Bt=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,o=new Map,s=new Map,a=(n,r)=>{o.set(n,r),t++,t>e&&(t=0,s=o,o=new Map)};return{get(n){let r=o.get(n);if(r!==void 0)return r;if((r=s.get(n))!==void 0)return a(n,r),r},set(n,r){o.has(n)?o.set(n,r):a(n,r)}}},Xe="!",Ht=e=>{let{separator:t,experimentalParseClassName:o}=e,s=t.length===1,a=t[0],n=t.length,r=i=>{let d=[],p=0,f=0,u;for(let v=0;v<i.length;v++){let w=i[v];if(p===0){if(w===a&&(s||i.slice(v,v+n)===t)){d.push(i.slice(f,v)),f=v+n;continue}if(w==="/"){u=v;continue}}w==="["?p++:w==="]"&&p--}let g=d.length===0?i:i.substring(f),C=g.startsWith(Xe),k=C?g.substring(1):g,y=u&&u>f?u-f:void 0;return{modifiers:d,hasImportantModifier:C,baseClassName:k,maybePostfixModifierPosition:y}};return o?i=>o({className:i,parseClassName:r}):r},Ot=e=>{if(e.length<=1)return e;let t=[],o=[];return e.forEach(s=>{s[0]==="["?(t.push(...o.sort(),s),o=[]):o.push(s)}),t.push(...o.sort()),t},Gt=e=>({cache:Bt(e.cacheSize),parseClassName:Ht(e),...Lt(e)}),jt=/\s+/,Ut=(e,t)=>{let{parseClassName:o,getClassGroupId:s,getConflictingClassGroupIds:a}=t,n=[],r=e.trim().split(jt),i="";for(let d=r.length-1;d>=0;d-=1){let p=r[d],{modifiers:f,hasImportantModifier:u,baseClassName:g,maybePostfixModifierPosition:C}=o(p),k=!!C,y=s(k?g.substring(0,C):g);if(!y){if(!k){i=p+(i.length>0?" "+i:i);continue}if(y=s(g),!y){i=p+(i.length>0?" "+i:i);continue}k=!1}let v=Ot(f).join(":"),w=u?v+Xe:v,S=w+y;if(n.includes(S))continue;n.push(S);let Z=a(y,k);for(let W=0;W<Z.length;++W){let se=Z[W];n.push(w+se)}i=p+(i.length>0?" "+i:i)}return i};function Ft(){let e=0,t,o,s="";for(;e<arguments.length;)(t=arguments[e++])&&(o=Ke(t))&&(s&&(s+=" "),s+=o);return s}var Ke=e=>{if(typeof e=="string")return e;let t,o="";for(let s=0;s<e.length;s++)e[s]&&(t=Ke(e[s]))&&(o&&(o+=" "),o+=t);return o};function Vt(e,...t){let o,s,a,n=r;function r(d){let p=t.reduce((f,u)=>u(f),e());return o=Gt(p),s=o.cache.get,a=o.cache.set,n=i,i(d)}function i(d){let p=s(d);if(p)return p;let f=Ut(d,o);return a(d,f),f}return function(){return n(Ft.apply(null,arguments))}}var b=e=>{let t=o=>o[e]||[];return t.isThemeGetter=!0,t},Ye=/^\[(?:([a-z-]+):)?(.+)\]$/i,Wt=/^\d+\/\d+$/,$t=new Set(["px","full","screen"]),_t=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|me|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|L|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Jt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Xt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)L-?((\d+)?\.?(\d+)[a-z]+|0)/,Kt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,O=e=>J(e)||$t.has(e)||Wt.test(e),U=e=>X(e,"length",no),J=e=>!!e&&!Number.isNaN(Number(e)),ke=e=>X(e,"number",J),te=e=>!!e&&Number.isInteger(Number(e)),Yt=e=>e.endsWith("%")&&J(e.slice(0,-1)),c=e=>Ye.test(e),F=e=>_t.test(e),Zt=new Set(["length","size","percentage"]),Qt=e=>X(e,Zt,Ze),eo=e=>X(e,"position",Ze),to=new Set(["image","url"]),oo=e=>X(e,to,so),ro=e=>X(e,"",ao),oe=()=>!0,X=(e,t,o)=>{let s=Ye.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):o(s[2]):!1},no=e=>qt.test(e)&&!Jt.test(e),Ze=()=>!1,ao=e=>Xt.test(e),so=e=>Kt.test(e);var io=()=>{let e=b("colors"),t=b("spacing"),o=b("blur"),s=b("brightness"),a=b("borderColor"),n=b("borderRadius"),r=b("borderSpacing"),i=b("borderWidth"),d=b("contrast"),p=b("grayscale"),f=b("hueRotate"),u=b("invert"),g=b("gap"),C=b("gradientColorStops"),k=b("gradientColorStopPositions"),y=b("inset"),v=b("margin"),w=b("opacity"),S=b("padding"),Z=b("saturate"),W=b("scale"),se=b("sepia"),ze=b("skew"),Ee=b("space"),De=b("translate"),he=()=>["auto","contain","none"],xe=()=>["auto","hidden","clip","visible","scroll"],ve=()=>["auto",c,t],x=()=>[c,t],Be=()=>["",O,U],ie=()=>["auto",J,c],He=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],le=()=>["solid","dashed","dotted","double","none"],Oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ye=()=>["start","end","center","between","around","evenly","stretch"],Q=()=>["","0",c],Ge=()=>["auto","avoid","all","avoid-page","page","left","right","column"],D=()=>[J,c];return{cacheSize:500,separator:":",theme:{colors:[oe],spacing:[O,U],blur:["none","",F,c],brightness:D(),borderColor:[e],borderRadius:["none","","full",F,c],borderSpacing:x(),borderWidth:Be(),contrast:D(),grayscale:Q(),hueRotate:D(),invert:Q(),gap:x(),gradientColorStops:[e],gradientColorStopPositions:[Yt,U],inset:ve(),margin:ve(),opacity:D(),padding:x(),saturate:D(),scale:D(),sepia:Q(),skew:D(),space:x(),translate:x()},classGroups:{aspect:[{aspect:["auto","square","video",c]}],container:["container"],columns:[{columns:[F]}],"break-after":[{"break-after":Ge()}],"break-before":[{"break-before":Ge()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...He(),c]}],overflow:[{overflow:xe()}],"overflow-x":[{"overflow-x":xe()}],"overflow-y":[{"overflow-y":xe()}],overscroll:[{overscroll:he()}],"overscroll-x":[{"overscroll-x":he()}],"overscroll-y":[{"overscroll-y":he()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[y]}],"inset-x":[{"inset-x":[y]}],"inset-y":[{"inset-y":[y]}],start:[{start:[y]}],end:[{end:[y]}],top:[{top:[y]}],right:[{right:[y]}],bottom:[{bottom:[y]}],left:[{left:[y]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",te,c]}],basis:[{basis:ve()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",c]}],grow:[{grow:Q()}],shrink:[{shrink:Q()}],order:[{order:["first","last","none",te,c]}],"grid-cols":[{"grid-cols":[oe]}],"col-start-end":[{col:["auto",{span:["full",te,c]},c]}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":[oe]}],"row-start-end":[{row:["auto",{span:[te,c]},c]}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",c]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",c]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...ye()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ye(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ye(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[S]}],px:[{px:[S]}],py:[{py:[S]}],ps:[{ps:[S]}],pe:[{pe:[S]}],me:[{me:[S]}],pr:[{pr:[S]}],pb:[{pb:[S]}],pl:[{pl:[S]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[Ee]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[Ee]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",c,t]}],"min-w":[{"min-w":[c,t,"min","max","fit"]}],"max-w":[{"max-w":[c,t,"none","full","min","max","fit","prose",{screen:[F]},F]}],L:[{L:[c,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-L":[{"min-L":[c,t,"min","max","fit","svh","lvh","dvh"]}],"max-L":[{"max-L":[c,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[c,t,"auto","min","max","fit"]}],"font-size":[{text:["base",F,U]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ke]}],"font-family":[{font:[oe]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",c]}],"line-clamp":[{"line-clamp":["none",J,ke]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",O,c]}],"list-image":[{"list-image":["none",c]}],"list-style-type":[{list:["none","disc","decimal",c]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[w]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[w]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...le(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",O,U]}],"underline-offset":[{"underline-offset":["auto",O,c]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:x()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",c]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",c]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[w]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...He(),eo]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Qt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","L","tl"]},oo]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[k]}],"gradient-via-pos":[{via:[k]}],"gradient-to-pos":[{to:[k]}],"gradient-from":[{from:[C]}],"gradient-via":[{via:[C]}],"gradient-to":[{to:[C]}],rounded:[{rounded:[n]}],"rounded-s":[{"rounded-s":[n]}],"rounded-e":[{"rounded-e":[n]}],"rounded-t":[{"rounded-t":[n]}],"rounded-r":[{"rounded-r":[n]}],"rounded-b":[{"rounded-b":[n]}],"rounded-L":[{"rounded-L":[n]}],"rounded-ss":[{"rounded-ss":[n]}],"rounded-se":[{"rounded-se":[n]}],"rounded-ee":[{"rounded-ee":[n]}],"rounded-es":[{"rounded-es":[n]}],"rounded-tl":[{"rounded-tl":[n]}],"rounded-tr":[{"rounded-tr":[n]}],"rounded-br":[{"rounded-br":[n]}],"rounded-bl":[{"rounded-bl":[n]}],"border-w":[{border:[i]}],"border-w-x":[{"border-x":[i]}],"border-w-y":[{"border-y":[i]}],"border-w-s":[{"border-s":[i]}],"border-w-e":[{"border-e":[i]}],"border-w-t":[{"border-t":[i]}],"border-w-r":[{"border-r":[i]}],"border-w-b":[{"border-b":[i]}],"border-w-L":[{"border-L":[i]}],"border-opacity":[{"border-opacity":[w]}],"border-style":[{border:[...le(),"hidden"]}],"divide-x":[{"divide-x":[i]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[i]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[w]}],"divide-style":[{divide:le()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-L":[{"border-L":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...le()]}],"outline-offset":[{"outline-offset":[O,c]}],"outline-w":[{outline:[O,U]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Be()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[w]}],"ring-offset-w":[{"ring-offset":[O,U]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",F,ro]}],"shadow-color":[{shadow:[oe]}],opacity:[{opacity:[w]}],"mix-blend":[{"mix-blend":[...Oe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Oe()}],filter:[{filter:["","none"]}],blur:[{blur:[o]}],brightness:[{brightness:[s]}],contrast:[{contrast:[d]}],"drop-shadow":[{"drop-shadow":["","none",F,c]}],grayscale:[{grayscale:[p]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[u]}],saturate:[{saturate:[Z]}],sepia:[{sepia:[se]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[o]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[d]}],"backdrop-grayscale":[{"backdrop-grayscale":[p]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[u]}],"backdrop-opacity":[{"backdrop-opacity":[w]}],"backdrop-saturate":[{"backdrop-saturate":[Z]}],"backdrop-sepia":[{"backdrop-sepia":[se]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[r]}],"border-spacing-x":[{"border-spacing-x":[r]}],"border-spacing-y":[{"border-spacing-y":[r]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",c]}],duration:[{duration:D()}],ease:[{ease:["linear","in","out","in-out",c]}],delay:[{delay:D()}],animate:[{animate:["none","spin","ping","pulse","bounce",c]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[W]}],"scale-x":[{"scale-x":[W]}],"scale-y":[{"scale-y":[W]}],rotate:[{rotate:[te,c]}],"translate-x":[{"translate-x":[De]}],"translate-y":[{"translate-y":[De]}],"skew-x":[{"skew-x":[ze]}],"skew-y":[{"skew-y":[ze]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",c]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",c]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":x()}],"scroll-mx":[{"scroll-mx":x()}],"scroll-my":[{"scroll-my":x()}],"scroll-ms":[{"scroll-ms":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-mt":[{"scroll-mt":x()}],"scroll-mr":[{"scroll-mr":x()}],"scroll-mb":[{"scroll-mb":x()}],"scroll-ml":[{"scroll-ml":x()}],"scroll-p":[{"scroll-p":x()}],"scroll-px":[{"scroll-px":x()}],"scroll-py":[{"scroll-py":x()}],"scroll-ps":[{"scroll-ps":x()}],"scroll-pe":[{"scroll-pe":x()}],"scroll-me":[{"scroll-me":x()}],"scroll-pr":[{"scroll-pr":x()}],"scroll-pb":[{"scroll-pb":x()}],"scroll-pl":[{"scroll-pl":x()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",c]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[O,U,ke]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","me","pr","pb","pl"],px:["pr","pl"],py:["me","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","L"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-L","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-L":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-L"],"border-w-x":["border-w-r","border-w-L"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-L"],"border-color-x":["border-color-r","border-color-L"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-me","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-me","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}};var Qe=Vt(io);function m(...e){return Qe((0,et.clsx)(e))}var me=require("lucide-react");var ot=require("streamdown"),re=(0,Ce.memo)(({className:e,...t})=>(0,L.jsx)(ot.Streamdown,{className:m("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",e),...t}),(e,t)=>e.children===t.children);re.displayName="Response";var nt=(0,Ce.createContext)(null),lo=()=>{let e=(0,Ce.useContext)(nt);if(!e)throw new Error("Reasoning components must be used within Reasoning");return e},co=1e3,po=1e3,Ae=(0,Ce.memo)(({className:e,isStreaming:t=!1,open:o,defaultOpen:s=!0,onOpenChange:a,duration:n,children:r,...i})=>{let[d,p]=(0,Re.useControllableState)({prop:o,defaultProp:s,onChange:a}),[f,u]=(0,Re.useControllableState)({prop:n,defaultProp:0}),[g,C]=(0,Ce.useState)(!1),[k,y]=(0,Ce.useState)(null);(0,Ce.useEffect)(()=>{t?k===null&&y(Date.now()):k!==null&&(u(Math.ceil((Date.now()-k)/po)),y(null))},[t,k,u]),(0,Ce.useEffect)(()=>{if(s&&!t&&d&&!g){let w=setTimeout(()=>{p(!1),C(!0)},co);return()=>clearTimeout(w)}},[t,d,s,p,g]);let v=w=>{p(w)};return(0,L.jsx)(nt.Provider,{value:{isStreaming:t,isOpen:d,setIsOpen:p,duration:f},children:(0,L.jsx)(ce,{className:m("not-prose mb-4",e),onOpenChange:v,open:d,...i,children:r})})}),uo=(e,t)=>e||t===0?(0,L.jsx)("p",{children:"Thinking..."}):t===void 0?(0,L.jsx)("p",{children:"Thought for a few seconds"}):(0,L.jsxs)("p",{children:["Thought for ",t," seconds"]}),Se=(0,Ce.memo)(({className:e,children:t,...o})=>{let{isStreaming:s,isOpen:a,duration:n}=lo();return(0,L.jsx)(pe,{className:m("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...o,children:t??(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(me.BrainIcon,{className:"size-4"}),uo(s,n),(0,L.jsx)(me.ChevronDownIcon,{className:m("size-4 transition-transform",a?"rotate-180":"rotate-0")})]})})}),Me=(0,Ce.memo)(({className:e,children:t,...o})=>(0,L.jsx)(ue,{className:m("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,L.jsx)(re,{className:"grid gap-2",children:t})}));Ae.displayName="Reasoning";Se.displayName="ReasoningTrigger";Me.displayName="ReasoningContent";var at=require("class-variance-authority");var mo=(0,at.cva)("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function K({className:e,variant:t,...o}){return(0,L.jsx)("div",{className:m(mo({variant:t}),e),...o})}var it=require("@radix-ui/react-slot"),dt=ee(require("react")),go=(0,at.cva)("inline-flex items-center justify-center whitespace-nowrap rounded text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{defaultVariants:{size:"default",variant:"default"},variants:{size:{clear:"",default:"L-10 px-4 py-2",icon:"L-10 w-10",lg:"L-11 rounded px-8",sm:"L-9 rounded px-3"},variant:{default:"bg-accent text-accent-foreground hover:bg-background hover:text-accent hover:border-accent hover:border",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",ghost:"hover:bg-card hover:text-accent",link:"text-primary items-start justify-start underline-offset-4 hover:underline",outline:"border border-border bg-background hover:bg-card hover:text-accent",secondary:"bg-secondary text-secondary-foreground hover:bg-accent"}}}),ne=dt.forwardRef(({asChild:e=!1,className:t,size:o,variant:s,...a},n)=>(0,L.jsx)(e?it.Slot:"button",{className:m(go({className:t,size:o,variant:s})),ref:n,...a}));ne.displayName="Button";var Le=require("react-syntax-highlighter"),fe=require("react-syntax-highlighter/dist/esm/styles/prism"),fo=(0,Ce.createContext)({code:""}),be=({code:e,language:t,showLineNumbers:o=!1,className:s,children:a,...n})=>(0,L.jsx)(fo.Provider,{value:{code:e},children:(0,L.jsx)("div",{className:m("relative max-w-2xl overflow-hidden rounded-md border bg-background text-foreground",s),...n,children:(0,L.jsxs)("div",{className:"relative",children:[(0,L.jsx)(Le.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:fe.oneLight,children:e}),(0,L.jsx)(Le.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:fe.oneDark,children:e}),a&&(0,L.jsx)("div",{className:"absolute top-2 right-2 flex items-center gap-2",children:a})]})})});var ut=({className:e,...t})=>(0,L.jsx)(ce,{className:m("not-prose mb-4 w-full",e),...t}),bo=e=>{let t={"input-streaming":"Pending","input-available":"Running","output-available":"Completed","output-error":"Error"};return(0,L.jsxs)(K,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[{"input-streaming":(0,L.jsx)(me.CircleIcon,{className:"size-4"}),"input-available":(0,L.jsx)(me.ClockIcon,{className:"size-4 animate-pulse"}),"output-available":(0,L.jsx)(me.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-error":(0,L.jsx)(me.XCircleIcon,{className:"size-4 text-red-600"})}[e],t[e]]})},mt=({className:e,type:t,state:o,...s})=>(0,L.jsxs)(pe,{className:m("flex w-full items-center justify-between gap-4 p-3 pl-0 w-2xl",e),...s,children:[(0,L.jsxs)("div",{className:"flex items-center gap-2",children:[(0,L.jsx)(me.WrenchIcon,{className:"size-4 text-muted-foreground"}),(0,L.jsx)("span",{className:"font-medium text-sm",children:t}),bo(o)]}),(0,L.jsx)(me.ChevronDownIcon,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),gt=({className:e,...t})=>(0,L.jsx)(ue,{className:m("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}),ft=({className:e,input:t,...o})=>(0,L.jsxs)("div",{className:m("space-y-2 overflow-hidden p-4",e),...o,children:[(0,L.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),(0,L.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,L.jsx)(be,{code:JSON.stringify(t,null,2),language:"json"})})]}),bt=({className:e,output:t,errorText:o,...s})=>{if(!(t||o))return null;let a=(0,L.jsx)("div",{children:t});return typeof t=="object"?a=(0,L.jsx)(be,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(a=(0,L.jsx)(be,{code:t,language:"json"})),(0,L.jsxs)("div",{className:m("space-y-2 p-4",e),...s,children:[(0,L.jsx)("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),(0,L.jsxs)("div",{className:m("overflow-x-auto rounded-md text-xs [&_table]:w-full",o?"bg-destructive/10 text-destructive":"bg-muted/50 text-foreground"),children:[o&&(0,L.jsx)("div",{children:o}),a]})]})};var $=ee(require("react"));var I=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("rounded-xl border bg-card text-card-foreground shadow",e),...t}));I.displayName="Card";var G=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("flex flex-col space-y-1.5 p-6",e),...t}));G.displayName="CardHeader";var j=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("font-semibold leading-none tracking-tight",e),...t}));j.displayName="CardTitle";var Ie=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("text-sm text-muted-foreground",e),...t}));Ie.displayName="CardDescription";var z=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("p-6 me-0",e),...t}));z.displayName="CardContent";var ae=$.forwardRef(({className:e,...t},o)=>(0,L.jsx)("div",{ref:o,className:m("flex items-center p-6 me-0",e),...t}));ae.displayName="CardFooter";var vt=require("date-fns");function ht({taskId:e,polling:t=!0,system:o="payload"}){let[s,a]=(0,Ce.useState)(null),[n,r]=(0,Ce.useState)(!1),[i,d]=(0,Ce.useState)(null),p=async(u=!0)=>{if(e){u&&r(!0);try{let g=await fetch(`/api/tasks/${e}`);if(!g.ok)throw new Error(`Failed to fetch task: ${g.statusText}`);let C=await g.json();a(C)}catch(g){console.error("Error fetching task:",g),d(g instanceof Error?g:new Error("Unknown error occurred"))}finally{u&&r(!1)}}},f=()=>p(!1);return(0,Ce.useEffect)(()=>{e&&p(!0);let u=null;return e&&t&&(u=setInterval(f,5e3)),()=>{u&&clearInterval(u)}},[e,t]),{task:s,loading:n,error:i}}var ho=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"}},xo=e=>{switch(e){case"inProgress":return"In Progress";default:return e.charAt(0).toUpperCase()+e.slice(1)}};function yt({data:e}){let{id:t,system:o,fetchLatest:s,taskData:a,error:n}=e||{};if(!t)return null;let r=null,i=!0,d=n,p=s!==void 0?s:!0;if(r=a||{id:t,name:"Loading...",description:"",status:"todo",dateLogged:new Date().toISOString(),project:void 0},console.log("ChatCardTask",{data:e,id:t,initialFetchLatest:s,system:o,fetchLatest:p,taskData:r,error:d}),p){let{task:C,loading:k,error:y}=ht({taskId:t,system:o});r=C,i=k,d=y}else i=!1;let f=ho(r?.status||"todo"),u=xo(r?.status||"todo"),g=r?.dateLogged||new Date().toISOString();try{let C=new Date(r?.dateLogged||"");isNaN(C.getTime())||(g=(0,vt.formatDistanceToNow)(C,{addSuffix:!0}))}catch{}return(0,L.jsxs)(I,{className:m("w-full max-w-md shadow-md",d&&"border border-destructive"),children:[(0,L.jsxs)(G,{className:"pb-2",children:[(0,L.jsxs)("div",{className:"flex justify-between items-start",children:[(0,L.jsx)(j,{className:"text-lg font-semibold",children:i?"Loading...":r?.name||"Task"}),(0,L.jsx)(K,{className:`${f}`,children:u})]}),r?.project&&(0,L.jsxs)(Ie,{className:"text-sm text-gray-500",children:["Project: ",r.project.name]})]}),(0,L.jsx)(z,{className:"pb-2",children:i?(0,L.jsx)("div",{className:"animate-pulse L-4 bg-gray-200 rounded w-3/4 mb-2"}):d?(0,L.jsx)("p",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,L.jsx)("p",{className:"text-sm text-foreground",children:r?.description||"......."})}),(0,L.jsx)(ae,{className:"me-2 flex items-center justify-between",children:(0,L.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,L.jsx)(me.Clock,{className:"L-3 w-3 mr-1"}),(0,L.jsxs)("span",{children:["Created ",g]}),(0,L.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,L.jsxs)("span",{children:["Task #",t]})]})})]})}function Nt({artefact:e,taskId:t,taskData:o,loading:s=!1,error:a=null}){let n=o||{id:t,name:"Loading...",description:"",status:"done",dateLogged:new Date().toISOString(),project:{id:-1,name:""}},r=n.dateLogged;try{let i=new Date(n.dateLogged);isNaN(i.getTime())||(r=(0,vt.formatDistanceToNow)(i,{addSuffix:!0}))}catch{}return(0,L.jsxs)(I,{className:"w-full max-w-md shadow-md",children:[(0,L.jsx)(G,{className:"pb-2",children:(0,L.jsx)("div",{className:"flex justify-between items-start",children:(0,L.jsx)(j,{className:"text-lg font-semibold",children:s?"Loading...":n.name})})}),(0,L.jsx)(z,{className:"pb-2",children:s?(0,L.jsx)("div",{className:"animate-pulse L-4 bg-gray-200 rounded w-3/4 mb-2"}):a?(0,L.jsx)("p",{className:"text-sm text-red-500",children:"Error loading task details"}):(0,L.jsx)("p",{className:"text-sm text-foreground",children:e})}),(0,L.jsx)(ae,{className:"me-2 flex items-center justify-between",children:(0,L.jsxs)("div",{className:"flex items-center text-xs text-gray-500",children:[(0,L.jsx)(me.Clock,{className:"L-3 w-3 mr-1"}),(0,L.jsxs)("span",{children:["Created ",r]}),(0,L.jsx)("span",{className:"mx-2",children:"\u2022"}),(0,L.jsxs)("span",{children:["Task #",n.id]})]})})]})}var vo=e=>e.startsWith("image/")?(0,L.jsx)(me.Image,{className:"L-4 w-4"}):e.startsWith("text/")?(0,L.jsx)(me.FileText,{className:"L-4 w-4"}):(0,L.jsx)(me.File,{className:"L-4 w-4"}),yo=({message:e,addToolResult:t,status:o,messages:s})=>e.parts.map((a,n)=>{if(a.type==="text")return(0,L.jsx)(re,{children:a.text},`${n}`);if(a.type==="file"){let r=a;return(0,L.jsx)("div",{className:"mb-2 p-2 bg-background/50 rounded-lg",children:(0,L.jsxs)("div",{className:"flex items-center gap-2",children:[vo(r.mediaType||"application/octet-stream"),(0,L.jsx)("div",{className:"flex-1 min-w-0",children:(0,L.jsx)("p",{className:"text-sm font-medium truncate",children:r.filename||r.url?.split("/").pop()||"File"})}),r.url&&(0,L.jsx)(ne,{variant:"ghost",size:"sm",onClick:()=>window.open(r.url,"_blank"),className:"L-8 w-8 p-0",children:(0,L.jsx)(me.Download,{className:"L-4 w-4"})})]})},n)}if(a.type.startsWith("tool-")){let r=a,i=a.type.replace("tool-","");if(i==="task")switch(r.state){case"input-available":return(0,L.jsx)("div",{className:"text-sm opacity-70",children:"Loading task..."},n);case"output-available":return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(yt,{data:{id:r.output?.id||r.input?.id,fetchLatest:!1,taskData:r.output||r.input}})},n);case"output-error":return(0,L.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},n);default:return null}if(a.type==="tool-requestEndpointLogin")return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(we,{toolPart:r,index:n,addToolResult:t??(()=>{})})},n);if(a.type==="tool-authenticate")return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(we,{toolPart:r,index:n,addToolResult:t??(()=>{})})},n);if(a.type==="tool-requestApproval")return console.log("Rendering PartApprovalTool with toolPart:",r),(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)($e,{toolPart:r,index:n,addToolResult:t??(()=>{})})},n);if(i==="artefact")switch(r.state){case"input-available":return(0,L.jsx)("div",{className:"text-sm opacity-70",children:"Loading artefact..."},n);case"output-available":return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(Nt,{artefact:r.output?.description||"",taskId:r.output?.id||r.input?.id,taskData:r.output||r.input})},n);case"output-error":return(0,L.jsxs)("div",{className:"text-sm text-red-500",children:["Error: ",r.errorText]},n);default:return null}return(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsxs)(I,{className:"w-full max-w-md",children:[(0,L.jsx)(G,{children:(0,L.jsx)(j,{className:"text-lg",children:i})}),(0,L.jsxs)(z,{children:[r.state==="input-available"&&(0,L.jsxs)("p",{className:"text-sm",children:["Processing ",i,"..."]}),r.state==="output-available"&&(0,L.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.output,null,2)}),r.state==="output-error"&&(0,L.jsxs)("p",{className:"text-sm text-red-500",children:["Error: ",r.errorText]})]})]})},n)}if(a.type.startsWith("data-")){let r=a,i=a.type.replace("data-","");return i==="reference"?(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsx)(I,{className:"w-full",children:(0,L.jsx)(z,{className:"p-4",children:(0,L.jsx)("div",{className:"space-y-2",children:r.data?.references?.map((d,p)=>(0,L.jsxs)("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/50",children:[(0,L.jsx)(K,{variant:"outline",children:d.type||"link"}),(0,L.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,L.jsx)("p",{className:"text-sm font-medium truncate",children:d.title}),d.description&&(0,L.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:d.description})]}),d.url&&(0,L.jsx)(ne,{variant:"ghost",size:"sm",onClick:()=>window.open(d.url,"_blank"),className:"L-8 w-8 p-0",children:(0,L.jsx)(me.ExternalLink,{className:"L-4 w-4"})})]},p))})})})},n):i==="menu"?(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsxs)(I,{className:"w-full",children:[(0,L.jsx)(G,{children:(0,L.jsx)(j,{className:"text-lg",children:r.data?.title})}),(0,L.jsx)(z,{children:(0,L.jsx)("div",{className:"space-y-2",children:r.data?.items?.map((d,p)=>(0,L.jsx)(ne,{variant:"outline",className:"w-full justify-start",onClick:d.action,children:(0,L.jsxs)("div",{className:"text-left",children:[(0,L.jsx)("p",{className:"font-medium",children:d.label}),d.description&&(0,L.jsx)("p",{className:"text-xs text-muted-foreground",children:d.description})]})},p))})})]})},n):(0,L.jsx)("div",{className:"mb-2",children:(0,L.jsxs)(I,{className:"w-full max-w-md",children:[(0,L.jsx)(G,{children:(0,L.jsx)(j,{className:"text-lg",children:i})}),(0,L.jsx)(z,{children:(0,L.jsx)("pre",{className:"text-sm",children:JSON.stringify(r.data,null,2)})})]})},n)}if(a.type==="reasoning")return(0,L.jsxs)(Ae,{className:"w-full",isStreaming:o==="streaming"&&n===e.parts.length-1&&e.id===s.at(-1)?.id,children:[(0,L.jsx)(Se,{}),(0,L.jsx)(Me,{children:a.text})]},`${n}`);if(a.type==="dynamic-tool")return(0,L.jsxs)(ut,{defaultOpen:a.state!=="output-available",children:[(0,L.jsx)(mt,{type:`tool-${a.toolName}`,state:a.state}),(0,L.jsxs)(gt,{children:[(0,L.jsx)(ft,{input:a.input}),(0,L.jsx)(bt,{output:a.output,errorText:a.errorText})]})]},`${e.id}-${n}`)});0&&(module.exports={messageHandler});
|