import{j as e}from"./tanstack-1.0.74-aU0azVkW.js";import{r as a}from"./redux-1.0.74-D8bIc6ki.js";import{f as n,K as d,ae as g}from"./index-1.0.74-DxwH6OqZ.js";import{C as f}from"./index-1.0.74-ZVhq2TX8.js";import{e as u}from"./utils-1.0.74-7xWhx9mc.js";import{a as y}from"./hooks-1.0.74-NYCTWeI9.js";import{z as j}from"./StartQueryBuilder-1.0.74-WVV-m136.js";import{B as t}from"./Box-1.0.74-DEbuVvGV.js";import{L as m}from"./Link-1.0.74-Cr-Ob-AP.js";import{A as h}from"./AdminTheme-1.0.74-BtTaJUu_.js";import{M as C}from"./markdown-1.0.74-DQ3nhaiK.js";import{r as b}from"./rehyperaw-1.0.74-YJYMuCoH.js";import{C as v}from"./CircularProgress-1.0.74-QfwfRJ7i.js";import"./vendor-1.0.74-CN03Eozo.js";import"./ButtonBase-1.0.74-W6tAH7AI.js";import"./Typography-1.0.74-B4mhsevh.js";import"./useEnhancedEffect-1.0.74-B56M26dS.js";import"./ThemeProvider-1.0.74-4uzbYYLM.js";import"./Portal-1.0.74-BrUPeMX9.js";import"./iconBase-1.0.74-Cs0vntJu.js";import"./ctc-1.0.74-DGPqEIz4.js";import"./index-1.0.74-FmkvObU2.js";import"./lib-1.0.74-B5IEqfHg.js";import"./useViewHeight-1.0.74-CuK7XWCG.js";import"./RestApiError-1.0.74-Bb1un17k.js";import"./ActionsExplorer-1.0.74-BKccLQP2.js";import"./RestApi-1.0.74-5XKxNzpR.js";import"./DatabaseTypeEnum-1.0.74-DeJfpW1u.js";import"./Spinner-1.0.74-B63QTBL9.js";const w=({className:s,children:r})=>{var i;const p=y();return e.jsxs(t,{sx:{position:"relative","& > pre":{border:"1px solid rgba(0, 0, 0, 0.23)",borderRadius:"4px",backgroundColor:"#fafafa",padding:"35px 20px 20px 20px",whiteSpace:"pre-wrap"},"& > pre code":{padding:0,margin:0,background:"transparent"}},children:[e.jsx("pre",{className:s,children:r}),e.jsxs(t,{sx:{position:"absolute",top:10,right:12,whiteSpace:"nowrap",display:"flex",gap:"10px"},children:[e.jsx(f,{text:(i=r==null?void 0:r.props)==null?void 0:i.children,onCopy:()=>{u("Code successfully copied to clipboard",{variant:"info"})},children:e.jsx(n,{title:"Copy query to clipboard",children:e.jsxs(m,{sx:{fontSize:"0.875em",cursor:"pointer",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:"2px"},children:[e.jsx(d,{}),"Copy"]})})}),e.jsx(n,{title:"Copy query to editor",children:e.jsxs(m,{sx:{fontSize:"0.875em",cursor:"pointer",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:"2px"},onClick:()=>{var o;p(j({copyQuery:(o=r==null?void 0:r.props)==null?void 0:o.children}))},children:[e.jsx(g,{}),"Edit"]})})]})]})},$=({chatMessages:s,loading:r,fullScreen:p})=>{const i=a.useRef(null);return a.useEffect(()=>{if(i.current!==null){const o=i.current;o.scrollTo(0,o.scrollHeight)}},[s]),a.useEffect(()=>{if(r&&i.current!==null){const o=i.current;o.scrollTo(0,o.scrollHeight)}},[r]),e.jsxs(t,{ref:i,sx:{overflowX:"hidden",overflowY:"scroll",margin:"0 20px",fontSize:"14px"},children:[...s.map(o=>{var l,c,x;return e.jsxs(t,{className:o.type==="ai"?"pp-message-ai":"pp-message-me",sx:{"&.pp-message-ai":{marginTop:0},"&.pp-message-ai .pp-message":{padding:0},"&.pp-message-me":{display:"flex",flexDirection:"row-reverse",justifyContent:"end",alignItems:"center","&:hover .pp-message-icon":{visibility:"visible"}},"&.pp-message-me .pp-message":{borderTopLeftRadius:"4px",borderBottomLeftRadius:"4px",padding:"0 16px",bgcolor:"#f5f5f5"}},children:[o.message&&e.jsx(t,{className:"pp-message",sx:{whiteSpace:"normal",fontFamily:"monospace",...o.isError===!0&&{color:(x=(c=(l=h)==null?void 0:l.palette)==null?void 0:c.error)==null?void 0:x.dark},...o.isNote===!0&&{fontStyle:"italic"},"& > *":{margin:p?"2em 0":"1em 0",padding:0}},children:e.jsx(C,{rehypePlugins:[b],components:{pre:w},children:o.message})}),e.jsx(t,{className:"pp-message-icon",sx:{marginBottom:p?"2em":"1em",...o.type==="me"&&{visibility:"hidden",padding:"0 5px 0 30px",marginBottom:0}},children:o.isNote!==!0&&e.jsx(f,{text:o.message,onCopy:()=>{u("Message successfully copied to clipboard",{variant:"info"})},children:e.jsx(n,{title:"Copy to clipboard",children:e.jsxs(m,{style:{fontSize:"0.875em",cursor:"pointer",textDecoration:"none",display:"inline-flex",alignItems:"center",gap:"2px"},children:[e.jsx(d,{}),"Copy"]})})})})]})}),r?e.jsx(t,{sx:{padding:"30px",textAlign:"center","& svg":{color:"rgba(0, 0, 0, 0.23)"}},children:e.jsx(v,{size:24})}):""]})};export{$ as default};
