research-agent-ui 0.1.67 → 0.1.69
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/index.cjs +2 -2
- package/dist/index.mjs +20 -10
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
${j?`text-red-500 bg-red-500/10 animate-pulse`:`text-text-400 hover:text-text-200 hover:bg-bg-200`}
|
|
30
30
|
`,"aria-label":j?`Stop listening`:`Voice input`,children:(0,d.jsx)($.Mic,{className:`w-5 h-5`})}),(0,d.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide`,children:(0,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:j?`Stop listening`:`Voice input`})})]}),m.length>0&&(0,d.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),p()},disabled:t,className:`transition-all duration-200 h-8 w-8 flex items-center justify-center rounded-full active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200`,"aria-label":`New chat`,children:(0,d.jsx)($.SquarePen,{className:`w-5 h-5`})}),(0,d.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide`,children:(0,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`New chat`})})]}),(0,d.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[t?(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},className:`inline-flex items-center justify-center shrink-0 transition-colors h-8 w-8 rounded-full active:scale-95 bg-red-500 text-white hover:bg-red-600 shadow-md`,type:`button`,"aria-label":`Stop generating`,children:(0,d.jsx)($.Stop,{className:`w-3.5 h-3.5 fill-current`})}):(0,d.jsx)(`button`,{onClick:e=>{e.stopPropagation(),de()},disabled:!pe,className:`inline-flex items-center justify-center shrink-0 transition-all duration-200 h-8 w-8 rounded-full active:scale-95
|
|
31
31
|
${pe?`bg-accent text-bg-0 hover:bg-accent-hover shadow-md`:`bg-bg-300 text-text-400 cursor-default opacity-50`}
|
|
32
|
-
`,type:`button`,"aria-label":`Send message`,children:(0,d.jsx)($.ArrowUp,{className:`w-4 h-4`})}),(0,d.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide`,children:(0,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:t?`Stop generating`:`Send message`})})]})]})]}),(0,d.jsx)(u.AnimatePresence,{children:te&&le>0&&(0,d.jsx)(u.motion.div,{ref:e=>{e&&v.current&&v.current.contains(e)},initial:{opacity:0,y:re===`above`?4:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:re===`above`?4:-4},transition:{duration:.12},className:`absolute left-2 right-2 md:left-0 md:right-0 z-20 rounded-2xl bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent shadow-xl overflow-hidden ${re===`above`?`bottom-full`:`top-full`}`,onMouseDown:e=>e.preventDefault(),children:(0,d.jsxs)(`ul`,{className:`max-h-72 overflow-y-auto custom-scrollbar py-1`,children:[H.map((e,t)=>(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,onMouseEnter:()=>W(t),onClick:()=>ce(e),className:`w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${t===U?`bg-bg-200 text-text-100`:`text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]`}`,children:[(0,d.jsx)(`span`,{className:`w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0`,children:t+1}),(0,d.jsx)(`img`,{src:e.favicon,alt:``,className:`w-4 h-4 rounded-sm shrink-0`}),(0,d.jsx)(`span`,{className:`truncate font-medium`,children:e.name||e.domain}),(0,d.jsx)(`span`,{className:`truncate text-[13px] text-text-400 shrink-0`,children:e.domain})]})},`domain-${e.domain}`)),B.map((e,t)=>{let n=H.length+t;return(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,onMouseEnter:()=>W(n),onClick:()=>G(e),className:`w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${n===U?`bg-bg-200 text-text-100`:`text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]`}`,children:[(0,d.jsx)(`span`,{className:`w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0`,children:n+1}),(0,d.jsx)(s.Search,{className:`w-4 h-4 text-text-400 shrink-0`}),(0,d.jsx)(`span`,{className:`truncate`,children:e})]})},`${e}-${t}`)})]})})}),C&&(0,d.jsxs)(`div`,{className:`absolute inset-0 bg-bg-200/90 border-2 border-dashed border-accent rounded-[28px] z-50 flex flex-col items-center justify-center backdrop-blur-sm pointer-events-none`,children:[(0,d.jsx)($.Archive,{className:`w-10 h-10 text-accent mb-2 animate-bounce`}),(0,d.jsx)(`p`,{className:`text-accent font-medium`,children:`Drop files to upload`})]})]})};function It({...e}){return(0,d.jsx)(S.Root,{"data-slot":`dialog`,...e})}function Lt({...e}){return(0,d.jsx)(S.Trigger,{"data-slot":`dialog-trigger`,...e})}function Rt({...e}){return(0,d.jsx)(S.Portal,{"data-slot":`dialog-portal`,...e})}function zt({className:e,...t}){return(0,d.jsx)(S.Overlay,{"data-slot":`dialog-overlay`,className:E(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 backdrop-blur-xs`,e),...t})}function Bt({className:e,children:t,hideCloseButton:n=!1,...r}){return(0,d.jsxs)(Rt,{"data-slot":`dialog-portal`,children:[(0,d.jsx)(zt,{}),(0,d.jsxs)(S.Content,{"data-slot":`dialog-content`,"aria-describedby":r[`aria-describedby`]??void 0,className:E(`z-[9999] bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl border p-6 shadow-lg duration-200`,e),...r,children:[t,!n&&(0,d.jsxs)(S.Close,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,d.jsx)(s.XIcon,{}),(0,d.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Vt({className:e,...t}){return(0,d.jsx)(S.Title,{"data-slot":`dialog-title`,className:E(`text-lg leading-none font-semibold`,e),...t})}function Ht({className:e,...t}){return(0,d.jsx)(S.Description,{"data-slot":`dialog-description`,className:E(`text-muted-foreground text-sm`,e),...t})}var Ut=n.forwardRef(({className:e,...t},n)=>(0,d.jsx)(`span`,{ref:n,className:E(`absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap border-0`,e),style:{clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`},...t}));Ut.displayName=`VisuallyHidden`;var Wt=({onClose:e})=>(0,d.jsx)(`div`,{className:`flex items-center justify-between bg-secondary px-4 py-3 border-b border-border`,children:(0,d.jsx)(`button`,{onClick:e,className:`rounded-md p-1 hover:bg-accent transition-colors`,children:(0,d.jsx)(s.X,{className:`h-5 w-5`})})}),Gt=(0,b.cva)(`inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-2xl text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`border-[1.5px] bg-background hover:bg-accent hover:text-accent-foreground dark:bg-card dark:hover:bg-card/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-3 has-[>svg]:px-2.5`,lg:`h-10 px-6 has-[>svg]:px-4`,icon:`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function Kt({className:e,variant:t,size:n,asChild:r=!1,...i}){return(0,d.jsx)(r?y.Slot:`button`,{"data-slot":`button`,className:E(Gt({variant:t,size:n,className:e})),...i})}var qt=E(`h-9 w-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),Jt=({isLoadingAI:e,isLoadingFollowups:t,isLoadingFavorite:n,isFavorited:r,isHighlightMode:i,articleUrl:a,onAskClick:o,onSuggestClick:c,onCopyClick:l,onFavoriteClick:u,onHighlightToggle:f,onClose:p})=>(0,d.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-1 rounded-2xl border border-muted bg-gradient-to-b from-background to-muted/30 p-1 shadow-sm`,children:[(0,d.jsxs)(Kt,{onClick:o,disabled:e,variant:`ghost`,size:`sm`,className:E(`flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:[(0,d.jsx)(s.Bot,{className:`size-4`}),(0,d.jsx)(`span`,{className:`font-medium`,children:e?`...`:`Ask`})]}),(0,d.jsxs)(Kt,{onClick:c,disabled:t,variant:`ghost`,size:`sm`,className:E(`flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:[(0,d.jsx)(s.MessageCircleQuestion,{className:`size-4`}),(0,d.jsx)(`span`,{className:`font-medium`,children:`Suggest`})]}),(0,d.jsx)(Kt,{onClick:l,variant:`ghost`,size:`icon`,className:qt,title:`Copy article`,children:(0,d.jsx)(s.Clipboard,{className:`size-4`})}),(0,d.jsx)(Kt,{onClick:f,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,i?`text-yellow-500 bg-yellow-50 dark:bg-yellow-950/30 hover:bg-yellow-100 dark:hover:bg-yellow-950/50`:`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),title:i?`Disable highlighting`:`Enable highlighting`,children:(0,d.jsx)(s.Highlighter,{className:`size-4`})}),(0,d.jsx)(Kt,{onClick:u,disabled:n,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,r?`text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50 dark:hover:bg-yellow-950/30`:`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),title:r?`Remove from favorites`:`Add to favorites`,children:(0,d.jsx)(s.Star,{className:E(`size-4`,r&&`fill-yellow-400`)})}),a&&(0,d.jsx)(Kt,{asChild:!0,variant:`ghost`,size:`icon`,className:qt,title:`Open in new tab`,children:(0,d.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,children:(0,d.jsx)(s.ExternalLink,{className:`size-4`})})}),(0,d.jsx)(Kt,{onClick:p,variant:`ghost`,size:`icon`,className:E(qt,`ml-auto`),title:`Close`,children:(0,d.jsx)(s.X,{className:`size-4`})})]}),Yt=({value:e,onChange:t,onSubmit:n})=>(0,d.jsx)(`div`,{className:`relative`,children:(0,d.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&n(),type:`text`,placeholder:`Ask AI any question...`,className:`w-full px-3 py-2 text-sm rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),Xt=({questions:e,isLoading:r,error:i,onQuestionClick:a})=>{let o=n.default.useMemo(()=>{let t=[];return e.forEach(e=>{e.includes(`?`)&&e.split(`?`).length>2?e.split(`?`).map(e=>e.trim()).filter(Boolean).forEach(e=>{t.push(e.endsWith(`?`)?e:`${e}?`)}):t.push(e)}),t},[e]);return(0,d.jsxs)(d.Fragment,{children:[o.length>0&&(0,d.jsxs)(`div`,{className:`space-y-3 bg-accent/30 rounded-lg p-4 border border-primary/20`,children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-primary mb-2`,children:`💡 Suggested Follow-up Questions`}),(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`div`,{onClick:()=>a(t.researchAgentUIConfig.defaultSummarizePrompt),className:`cursor-pointer rounded-md p-3 text-sm font-semibold hover:bg-primary/10 bg-background border border-primary/30 transition-all hover:border-primary shadow-sm hover:shadow-md`,children:t.researchAgentUIConfig.defaultSummarizePrompt}),o.map((e,t)=>(0,d.jsx)(`div`,{onClick:()=>a(e),className:`cursor-pointer rounded-md p-3 text-sm font-semibold hover:bg-primary/10 bg-background border border-border transition-all hover:border-primary shadow-sm hover:shadow-md`,dangerouslySetInnerHTML:{__html:e}},t))]})]}),r&&(0,d.jsx)(`div`,{className:`flex justify-center`,children:(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),i&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:i})]})},Zt=({response:e,isLoading:t,error:n})=>(0,d.jsxs)(d.Fragment,{children:[t&&(0,d.jsx)(`div`,{className:`flex justify-center`,children:(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),e&&(0,d.jsx)(`div`,{ref:e=>{},className:`bg-muted rounded-lg shadow-md p-4`,dangerouslySetInnerHTML:{__html:e}}),n&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:n})]}),Qt=({html:e,isHighlightMode:t=!1})=>{let[r,i]=(0,n.useState)(``);return(0,n.useEffect)(()=>{i(C.default.sanitize(e||``,{ADD_TAGS:[`figure`,`figcaption`],ADD_ATTR:[`loading`]}))},[e]),(0,d.jsx)(`div`,{className:`prose prose-neutral dark:prose-invert max-w-none ${t?`select-text`:``}`,dangerouslySetInnerHTML:{__html:r}})},$t=({article:e,isHighlightMode:t})=>(0,d.jsx)(`div`,{className:`border-t border-border pt-6`,children:(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`flex items-start justify-between mb-2`}),e.cite&&(0,d.jsx)(`div`,{className:`mb-3 text-sm text-muted-foreground`,dangerouslySetInnerHTML:{__html:e.cite}}),(0,d.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground space-y-1`,children:e.word_count&&(0,d.jsxs)(`p`,{children:[(0,d.jsx)(`span`,{className:`font-semibold`,children:`Words:`}),` `,e.word_count.toLocaleString()]})}),(0,d.jsx)(`div`,{id:`article-content`,children:(0,d.jsx)(Qt,{html:e.html||``,isHighlightMode:t})})]})}),en=/(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g,tn=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;function nn(e){return e.includes(`](`)||e.includes(`)[`)?!1:/\.(com|org|net|io|dev|co|uk|de|fr|it|es|jp|cn|in|br|au|ca|us|gov|edu|mil|int|xyz|info|app|tech|online|site|website|store|shop|blog|news|tv|me|cc|ws|name|mobi|asia|tel|travel|jobs|pro|museum|coop|aero|arpa|biz|cat|jobs|post|tel|xxx|ac|ad|ae|af|ag|ai|al|am|ao|aq|ar|as|at|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?:\/|$)/i.test(e)}function rn(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}function an(e){if(!e||typeof e!=`string`)return e;let t=e,n=[],r;for(tn.lastIndex=0;(r=tn.exec(t))!==null;){let e=r[0],i=r.index,a=t.substring(0,i),o=t.substring(i+e.length);!a.endsWith(`](`)&&!o.startsWith(`)`)&&n.push({email:e,index:i})}for(let e=n.length-1;e>=0;e--){let{email:r,index:i}=n[e];t=t.substring(0,i)+`[${r}](mailto:${r})`+t.substring(i+r.length)}let i=[],a;for(en.lastIndex=0;(a=en.exec(t))!==null;){let e=a[0],n=a.index;if(tn.test(e))continue;let r=t.substring(0,n),o=t.substring(n+e.length);if(r.endsWith(`](`)||o.startsWith(`)`)||(r.match(/```/g)||[]).length%2!=0)continue;let s=r.lastIndexOf("`");if(s!==-1){let e=t.substring(s+1).indexOf("`");if(e!==-1&&e>n-s-1)continue}nn(e)&&i.push({url:e,index:n})}for(let e=i.length-1;e>=0;e--){let{url:n,index:r}=i[e],a=rn(n);t=t.substring(0,r)+`[${n}](${a})`+t.substring(r+n.length)}return t}function on(e){return!e||e.startsWith(`http://`)||e.startsWith(`https://`)||e.includes(`://`)?!1:e.startsWith(`/`)||e.startsWith(`#`)}function sn(e,t){if(t.startsWith(`#`)){e.preventDefault();let n=t.substring(1),r=document.getElementById(n);r&&r.scrollIntoView({behavior:`smooth`,block:`start`})}}function cn({code:e}){let[t,r]=(0,n.useState)(!1);return(0,d.jsx)(`button`,{onClick:(0,n.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}},[e]),className:E(`absolute top-3 right-3 p-1.5 rounded-md`,`opacity-0 group-hover:opacity-100 transition-opacity duration-150`,`bg-zinc-200/80 hover:bg-zinc-300 dark:bg-zinc-700/80 dark:hover:bg-zinc-600`,`text-zinc-600 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,`focus:outline-none focus:ring-1 focus:ring-zinc-400 dark:focus:ring-zinc-500`),"aria-label":t?`Copied!`:`Copy code`,children:t?(0,d.jsx)(s.Check,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,d.jsx)(s.Copy,{className:`h-4 w-4`})})}function ln({children:e}){let t=(0,n.useRef)(null),[r,i]=(0,n.useState)(``);return(0,n.useEffect)(()=>{if(t.current){let e=t.current.querySelector(`code`);if(e){let t=e.textContent||``;i(t.trim())}}},[e]),(0,d.jsxs)(`div`,{className:`relative group my-5`,children:[(0,d.jsx)(`pre`,{ref:t,className:E(`p-4 rounded-xl overflow-x-auto`,`bg-zinc-100 dark:bg-zinc-900`,`border border-zinc-200 dark:border-zinc-800`,`text-[13px] font-mono leading-relaxed`,`text-zinc-800 dark:text-zinc-200`,`[&_code]:bg-transparent [&_code]:text-inherit [&_code]:p-0`),children:e}),r&&(0,d.jsx)(cn,{code:r})]})}var un=n.default.memo(({content:e,className:t,isStreaming:n=!1})=>{if(!e)return(0,d.jsx)(`div`,{className:E(`text-muted-foreground text-sm`,t),children:`No content`});let r=an(e);return(0,d.jsx)(`div`,{className:E(`kortix-markdown`,t),children:(0,d.jsx)(T.Streamdown,{isAnimating:n,components:{h1:({children:e})=>(0,d.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground mt-8 mb-4 first:mt-0 pb-2 border-b border-border/40`,children:e}),h2:({children:e})=>(0,d.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-foreground mt-8 mb-3 first:mt-0`,children:e}),h3:({children:e})=>(0,d.jsx)(`h3`,{className:`text-lg font-semibold text-foreground mt-6 mb-2 first:mt-0`,children:e}),h4:({children:e})=>(0,d.jsx)(`h4`,{className:`text-base font-semibold text-foreground mt-5 mb-2 first:mt-0`,children:e}),h5:({children:e})=>(0,d.jsx)(`h5`,{className:`text-sm font-semibold text-foreground mt-4 mb-1 first:mt-0`,children:e}),h6:({children:e})=>(0,d.jsx)(`h6`,{className:`text-sm font-medium text-muted-foreground mt-4 mb-1 first:mt-0 uppercase tracking-wide`,children:e}),p:({children:e})=>(0,d.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed my-4 first:mt-0 last:mb-0 [&:has(img)]:my-0`,children:e}),ul:({children:e})=>(0,d.jsx)(`ul`,{className:`my-4 ml-6 list-disc marker:text-muted-foreground/60 space-y-2 first:mt-0 last:mb-0 text-sm`,children:e}),ol:({children:e})=>(0,d.jsx)(`ol`,{className:`my-4 ml-6 list-decimal marker:text-muted-foreground/60 marker:font-medium space-y-2 first:mt-0 last:mb-0 text-sm`,children:e}),li:({children:e})=>(0,d.jsx)(`li`,{className:`text-sm text-foreground leading-relaxed pl-1`,children:e}),a:({href:e,children:t})=>{let n=on(e),r=e?.startsWith(`#`),i=E(`font-medium text-foreground`,`underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]`,`hover:decoration-foreground/60 transition-colors duration-150`);return r?(0,d.jsx)(`a`,{href:e,onClick:t=>sn(t,e),className:i,children:t}):n?(0,d.jsx)(w.default,{href:e||`#`,className:i,children:t}):(0,d.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:i,children:t})},code:({children:e,className:t})=>t?.includes(`language-`)?(0,d.jsx)(`code`,{className:`text-[13px] leading-relaxed text-inherit`,children:e}):(0,d.jsx)(`code`,{className:`px-2 py-1 rounded-md text-[13px] font-mono bg-card dark:bg-[#161618] border border-neutral-200 dark:border-neutral-700/50 text-foreground`,children:e}),pre:({children:e})=>(0,d.jsx)(ln,{children:e}),blockquote:({children:e})=>(0,d.jsx)(`blockquote`,{className:E(`my-5 pl-4 py-1 text-sm`,`border-l-2 border-border`,`text-muted-foreground`,`[&>p]:my-2`),children:e}),hr:()=>(0,d.jsx)(`hr`,{className:`my-8 border-0 h-px bg-border/60`}),table:({children:e})=>(0,d.jsx)(`div`,{className:`my-5 overflow-x-auto rounded-xl border border-border/60`,children:(0,d.jsx)(`table`,{className:`w-full text-sm`,children:e})}),thead:({children:e})=>(0,d.jsx)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 border-b border-border/60`,children:e}),tbody:({children:e})=>(0,d.jsx)(`tbody`,{className:`divide-y divide-border/40`,children:e}),tr:({children:e})=>(0,d.jsx)(`tr`,{className:`transition-colors hover:bg-muted/30`,children:e}),th:({children:e})=>(0,d.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-semibold text-foreground uppercase tracking-wider`,children:e}),td:({children:e})=>(0,d.jsx)(`td`,{className:`px-4 py-3 text-foreground`,children:e}),img:({src:e,alt:t})=>e?(0,d.jsxs)(`span`,{className:`block my-5`,children:[(0,d.jsx)(`img`,{src:e,alt:t||``,className:E(`max-w-full h-auto rounded-xl`,`border border-border/40`,`shadow-sm`),loading:`lazy`}),t&&(0,d.jsx)(`span`,{className:`block mt-2 text-center text-sm text-muted-foreground`,children:t})]}):null,strong:({children:e})=>(0,d.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,d.jsx)(`em`,{className:`italic text-foreground/90`,children:e}),del:({children:e})=>(0,d.jsx)(`del`,{className:`line-through text-muted-foreground decoration-muted-foreground/50`,children:e}),input:({checked:e,...t})=>(0,d.jsx)(`input`,{type:`checkbox`,checked:e,readOnly:!0,className:E(`mr-2 h-4 w-4 rounded border-border`,`accent-secondary cursor-default`,`align-middle relative -top-[1px]`),...t}),div:({children:e,style:t,className:n,...r})=>(0,d.jsx)(`div`,{className:E(`text-sm text-foreground`,n),style:t,...r,children:e}),span:({children:e,style:t,className:n,...r})=>(0,d.jsx)(`span`,{className:E(`text-foreground`,n),style:t,...r,children:e})},children:r})})});un.displayName=`UnifiedMarkdown`;var dn=e=>{let{isOpen:r,url:i,searchText:a,panelWidth:o,setPanelWidth:s,closePanel:l}=A(),{isAuthenticated:u}=Me(),f=e.isOpen===void 0?r:e.isOpen,m=e.onClose||l,h=e.url||i,g=e.searchText===void 0?a:e.searchText,[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)([]),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(t.researchAgentUIConfig.defaultSummarizePrompt),[T,E]=(0,n.useState)(!1),[D,O]=(0,n.useState)(!1),[k,j]=(0,n.useState)(!1),[M,N]=(0,n.useState)(``),[P,F]=(0,n.useState)(``),[I,L]=(0,n.useState)([]),[R,z]=(0,n.useState)(``),[B,V]=(0,n.useState)(!1),[H,ee]=(0,n.useState)(!1),[U,W]=(0,n.useState)(!1),[te,ne]=(0,n.useState)(!1),[re,ie]=(0,n.useState)(o),[ae,oe]=(0,n.useState)(!1),[se,G]=(0,n.useState)(!1),ce=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=()=>{ne(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{let e=e=>{if(!ae)return;let t=window.innerWidth-e.clientX,n=Math.max(400,Math.min(t,window.innerWidth-100));ie(n),s(n)},t=()=>{oe(!1)};return ae&&(document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.cursor=`ew-resize`,document.body.style.userSelect=`none`),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[ae,s]),(0,n.useEffect)(()=>{f&&h?(G(!1),le()):f||G(!1)},[f,h]);let le=async()=>{console.log(`[ArticleExtractPanel] Extracting URL:`,h);try{let e=new URL(h);if([/^https?:\/\/(www\.)?google\.[^/]+\/search/i,/^https?:\/\/(www\.)?bing\.com\/search/i,/^https?:\/\/(www\.)?duckduckgo\.com\/\?/i].some(e=>e.test(h))){p.toast.error(`Cannot extract articles from search result pages`),E(!1),G(!0);return}(e.pathname===`/`||e.pathname===``)&&(console.error(`[ArticleExtractPanel] URL is domain-only, missing article path:`,h),p.toast.error(`Invalid article URL - only domain provided`))}catch(e){console.error(`[ArticleExtractPanel] Invalid URL format:`,h,e)}E(!0);try{let{data:e}=await(0,c.getArticle)({query:{url:h}}),t=e?.article,n=t?.html?.replace(/<[^>]*>/g,``).trim()||``;t?.error||n.length<20?(document.dispatchEvent(new CustomEvent(`onInvokeChromeAPI`,{detail:{type:`extractURL`,url:h}})),await Promise.race([new Promise(e=>{let t=async n=>{window.removeEventListener(`onExtractionResult`,t);let{data:r}=await(0,c.getArticle)({query:{url:h}}),i=r?.article;i&&(v(i),i.followUpQuestions?.length>0&&L(i.followUpQuestions)),e()};window.addEventListener(`onExtractionResult`,t)}),new Promise(e=>setTimeout(e,1e4))])):(v(t),t?.followUpQuestions&&t.followUpQuestions.length>0&&L(t.followUpQuestions)),u&&ue()}catch(e){console.error(`[ArticleExtractPanel] Error extracting URL:`,e),p.toast.error(`Failed to load article`)}finally{E(!1),G(!0)}},ue=async()=>{try{let{data:e}=await(0,c.listFavorites)(),t=e?.favorites?.some(e=>e.url===h);V(!!t)}catch(e){console.error(`Error checking favorite status:`,e)}},de=async()=>{if(_){ee(!0);try{B?(await(0,c.removeFavorite)({query:{url:h}}),V(!1),p.toast.info(`Removed from favorites`)):(await(0,c.addFavorite)({body:{url:_.url||h,title:_.title,cite:_.cite,author:_.author,author_cite:_.author_cite,date:_.date,source:_.source,word_count:_.word_count,html:_.html}}),V(!0),p.toast.success(`Added to favorites`))}catch(e){console.error(`Error toggling favorite:`,e),p.toast.error(`Failed to toggle favorite`)}finally{ee(!1)}}},fe=async e=>{if(!_)return;let n=_.html?.replace(/<[^>]*>?/g,``).slice(0,t.researchAgentUIConfig.maxArticleLength),r=e===`question`,i=r?O:j,a=r?F:z;i(!0),a(``);try{if(r){let{data:e,error:t}=await(0,c.articleQa)({body:{article:n,question:[g,C].filter(Boolean).join(`
|
|
33
|
-
`),chatHistory:y.slice(-5),provider:`groq`}});if(t)throw Error(t.error||`Article QA failed`);let r=e?.content||``;N(r),b(e=>[...e,{role:`user`,content:C,time:new Date().toISOString()},{role:`assistant`,content:r,time:new Date().toISOString()}]);try{await(0,c.updateArticle)({body:{url:h,question:C,answer:r}})}catch(e){console.error(`Error storing Q&A in cache:`,e)}}else{let e=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`),{data:t,error:r}=await(0,c.articleFollowups)({body:{article:n,chatHistory:y.slice(-5),maxQuestions:e,provider:`groq`}});if(r)throw Error(r.error||`Article followups failed`);let i=t?.extract||[];L(i);try{await(0,c.updateArticle)({body:{url:h,followUpQuestions:i}})}catch(e){console.error(`Error storing follow-up questions in cache:`,e)}}}catch(e){console.error(`Error calling language API:`,e),a(`Failed to get AI response`)}finally{i(!1)}},pe=e=>{w(e),fe(`question`)},me=async()=>{if(!_)return;let e=`${M}\n\n\n${_.cite||``}\n\n\n${_.html}`;try{await navigator.clipboard.writeText(e),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){console.error(`Failed to copy to clipboard:`,e)}},K=()=>(0,d.jsx)(`div`,{className:`flex h-full flex-col bg-background shadow-xl`,children:(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,d.jsxs)(`div`,{className:`p-4 space-y-6`,children:[(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(Jt,{isLoadingAI:D,isLoadingFollowups:k,isLoadingFavorite:H,isFavorited:B,isHighlightMode:U,articleUrl:_?.url||h,onAskClick:()=>fe(`question`),onSuggestClick:()=>fe(`suggest-followups`),onCopyClick:me,onFavoriteClick:de,onHighlightToggle:()=>W(!U),onClose:m}),x&&(0,d.jsx)(`div`,{className:`bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg`,children:`Copied!`}),(0,d.jsx)(Yt,{value:C,onChange:w,onSubmit:()=>fe(`question`)}),(0,d.jsx)(Xt,{questions:I,isLoading:k,error:R,onQuestionClick:pe}),y.length>0&&(0,d.jsx)(`div`,{className:`space-y-4`,children:y.map((e,t)=>(0,d.jsx)(`div`,{className:`space-y-2`,children:e.role===`user`?(0,d.jsxs)(`div`,{className:`bg-primary/10 border border-primary/20 rounded-lg p-3`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold text-primary mb-1`,children:`Your Question`}),(0,d.jsx)(`div`,{className:`text-sm text-foreground`,children:e.content})]}):(0,d.jsxs)(`div`,{className:`bg-muted rounded-lg shadow-md p-4`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-2`,children:`AI Response`}),(0,d.jsx)(`div`,{className:`text-sm`,dangerouslySetInnerHTML:{__html:e.content}})]})},t))}),(D||M&&y.length===0)&&(0,d.jsx)(Zt,{response:M,isLoading:D,error:P}),P&&!D&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:P})]}),_&&(0,d.jsx)($t,{article:_,isHighlightMode:U})]})})});return!f||!se?null:te?(0,d.jsxs)(`div`,{className:`fixed top-0 right-0 h-screen z-40 transition-all duration-300`,style:{width:`${re}px`},children:[(0,d.jsx)(`div`,{ref:ce,onMouseDown:()=>oe(!0),className:`absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-primary bg-transparent transition-colors z-50`,style:{touchAction:`none`},children:(0,d.jsx)(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-12 rounded-full bg-muted-foreground opacity-50 hover:opacity-100 transition-opacity`})}),K()]}):(0,d.jsx)(It,{open:f,onOpenChange:e=>!e&&m(),children:(0,d.jsxs)(Bt,{className:`pointer-events-auto fixed inset-0 !top-0 !left-0 !translate-x-0 !translate-y-0 h-full w-full max-w-none p-0 m-0 rounded-none border-0 overflow-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right`,hideCloseButton:!0,children:[(0,d.jsx)(Ut,{children:(0,d.jsx)(Vt,{children:`Article Details`})}),(0,d.jsx)(`div`,{className:`h-full overflow-y-auto`,children:K()})]})})},fn=()=>{let{sections:e,chatTurns:r,loading:i,messageAppeared:a,newChat:o,chatId:s}=q(),{isOpen:c,panelWidth:l}=A(),{isAuthenticated:u}=Me(),[f,p]=(0,n.useState)(!1),m=(0,n.useRef)(null),h=(0,n.useRef)(null),g=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{let e=()=>{p(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{if(r.length===1&&(document.title=`${r[0].content.substring(0,30)} - ${t.researchAgentUIConfig.appName}`),r[r.length-1]?.role===`user`){g.current=!0,h.current?.scrollIntoView({behavior:`auto`}),setTimeout(()=>{g.current=!1},100);return}},[r]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`flex flex-col min-h-full transition-all duration-300`,style:f&&c?{width:`calc(100% - ${l}px)`}:{},children:[(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col space-y-3 pb-48 ${f&&!c?`px-0 max-w-[800px] mx-auto w-full`:`px-4 lg:px-8`}`,children:[e.map((t,r)=>{let i=r===e.length-1;return(0,d.jsxs)(n.Fragment,{children:[(0,d.jsx)(pt,{section:t,sectionIndex:r,dividerRef:i?m:void 0,isLast:i}),!i&&(0,d.jsx)(`div`,{className:`h-px w-full bg-light-secondary dark:bg-dark-secondary`})]},t.userMessage.messageId)}),i&&!a&&(0,d.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,d.jsx)(`div`,{style:{height:`200px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,d.jsx)(x.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})})}),(0,d.jsx)(`div`,{ref:h,className:`h-0`})]}),(0,d.jsx)(`div`,{className:`sticky bottom-[60px] md:bottom-0 z-40 bg-gradient-to-t from-background via-background to-transparent pt-4 pb-2`,children:(0,d.jsx)(Ft,{})})]}),(0,d.jsx)(dn,{})]})};function pn({radius:e=60,opacityDecay:t=.025,backgroundColor:r=`transparent`,color:i,colorGenerator:a}){let o=(0,n.useRef)(null),s=(0,n.useRef)({x:0,y:0}),c=(0,n.useRef)([]),l=()=>[Math.floor(Math.random()*130+10),Math.floor(.5*Math.random()*50),Math.floor(.5*Math.random()*255)],u=()=>i||a?.()||l();return(0,n.useEffect)(()=>{let n=o.current;if(!n)return;let i=n.getContext(`2d`);if(!i)return;let a=()=>{n.width=window.innerWidth,n.height=window.innerHeight};a();let l=()=>{i.globalCompositeOperation=`source-over`,r===`transparent`?i.clearRect(0,0,n.width,n.height):(i.fillStyle=r,i.fillRect(0,0,n.width,n.height)),i.globalCompositeOperation=`lighter`;let a={col:u(),x:s.current.x,y:s.current.y,grdblur:i.createRadialGradient(s.current.x,s.current.y,0,s.current.x,s.current.y,e),alpha:1};c.current.push(a);let o=[];for(let n=0;n<c.current.length;n++){let r=c.current[n];r.grdblur.addColorStop(0,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.95)`),r.grdblur.addColorStop(.2,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.7)`),r.grdblur.addColorStop(.5,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.3)`),r.grdblur.addColorStop(1,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0)`),i.beginPath(),i.fillStyle=r.grdblur,i.globalAlpha=r.alpha,i.arc(r.x,r.y,e,0,Math.PI*2),i.fill(),r.alpha-=t,r.alpha<=0&&o.push(n)}for(let e=o.length-1;e>=0;e--)c.current.splice(o[e],1);i.globalAlpha=1,requestAnimationFrame(l)},d=e=>{s.current.x=e.pageX,s.current.y=e.pageY},f=e=>{s.current.x=e.touches[0].pageX,s.current.y=e.touches[0].pageY};return window.addEventListener(`mousemove`,d),window.addEventListener(`touchmove`,f,{passive:!0}),window.addEventListener(`resize`,a),l(),()=>{window.removeEventListener(`mousemove`,d),window.removeEventListener(`touchmove`,f),window.removeEventListener(`resize`,a)}},[e,t,r,i,a]),(0,d.jsx)(`div`,{className:`relative w-full h-screen overflow-hidden pointer-events-none`,children:(0,d.jsx)(`canvas`,{ref:o,className:`absolute inset-0`,style:{background:`transparent`}})})}var mn=`qwksearch_pinned_chats`;function hn(){if(typeof window>`u`)return[];try{let e=localStorage.getItem(mn);return e?JSON.parse(e):[]}catch{return[]}}function gn(e){typeof window>`u`||localStorage.setItem(mn,JSON.stringify(e))}function _n(){let[e,t]=(0,n.useState)([]),[r,i]=(0,n.useState)(!0),[a,o]=(0,n.useState)(!1),[s,l]=(0,n.useState)(null),[u,d]=(0,n.useState)(!1),[f,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)(!1),[_,v]=(0,n.useState)([]),[y,b]=(0,n.useState)(``),[x,S]=(0,n.useState)([]),[C,w]=(0,n.useState)(!1),{isAuthenticated:T,isLoading:E}=Me(),{incognito:D,setIncognito:O}=q();(0,n.useEffect)(()=>{v(hn())},[]);let k=(0,n.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),v(e=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];return gn(n),n})},[]),A=(0,n.useMemo)(()=>[...e].sort((e,t)=>{let n=_.includes(e.id),r=_.includes(t.id);return n&&!r?-1:!n&&r?1:0}),[e,_]),j=(0,n.useMemo)(()=>y.trim()?x:A,[y,x,A]),M=(0,n.useCallback)(async()=>{if(!E){i(!0);try{if(T){let{data:e,error:n}=await(0,c.listChats)();if(n&&n.status===401){let e=K().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0}));t(e);return}if(n)throw Error(`Failed to fetch chats: ${n.message}`);t(Array.isArray(e?.chats)?e.chats:[])}else{let e=K().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0}));t(e)}}catch(e){console.error(`Failed to fetch chat history:`,e),t([]),p.toast.error(`Failed to load chat history`)}finally{i(!1)}}},[T,E]);(0,n.useEffect)(()=>{M()},[M]);let N=(e,t)=>{e.preventDefault(),e.stopPropagation(),l(t),o(!0)},P=async()=>{if(s){d(!0);try{if(T){let{error:e}=await(0,c.deleteChatById)({path:{id:s}});if(e)throw Error(`Failed to delete chat: ${e.message}`)}else _e(s);t(e=>e.filter(e=>e.id!==s)),p.toast.success(`Chat deleted`)}catch(e){p.toast.error(e.message||`Failed to delete chat`)}finally{o(!1),l(null),d(!1)}}},F=()=>{m(!0)},I=async()=>{g(!0);try{if(T){let{error:e}=await(0,c.deleteAllChats)();if(e)throw Error(`Failed to clear history: ${e.message}`)}else ve();t([]),p.toast.success(`All history cleared`)}catch(e){p.toast.error(e.message||`Failed to clear history`)}finally{m(!1),g(!1)}},L=()=>{O(!D),p.toast.success(D?`Private mode off`:`Private mode on — messages won't be saved`)},R=(0,n.useCallback)(async e=>{if(!e.trim()){S([]),w(!1);return}w(!0);try{if(T){let{data:t,error:n}=await(0,c.searchChats)({query:{q:e}});if(n)throw Error(`Failed to search chats: ${n.message}`);S(Array.isArray(t?.chats)?t.chats:[])}else{let t=K().filter(t=>{let n=t.title.toLowerCase().includes(e.toLowerCase()),r=t.messages?.some(t=>`content`in t&&t.content?.toLowerCase().includes(e.toLowerCase()));return n||r});S(t.map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0})))}}catch(e){console.error(`Failed to search chat history:`,e),S([]),p.toast.error(`Failed to search chat history`)}finally{w(!1)}},[T]);return(0,n.useEffect)(()=>{let e=setTimeout(()=>{R(y)},300);return()=>clearTimeout(e)},[y,R]),{chats:e,sortedChats:A,displayChats:j,loading:r,pinnedIds:_,togglePin:k,incognito:D,toggleIncognito:L,searchQuery:y,searchResults:x,searching:C,handleSearchChange:(0,n.useCallback)(e=>{b(e)},[]),deleteDialogOpen:a,setDeleteDialogOpen:o,chatToDelete:s,setChatToDelete:l,deleting:u,handleDeleteClick:N,handleConfirmDelete:P,clearAllDialogOpen:f,setClearAllDialogOpen:m,clearingAll:h,handleClearAllClick:F,handleConfirmClearAll:I}}function vn({incognito:e,onToggleIncognito:t,showClearAll:n,onClearAll:r,searchQuery:i,onSearchChange:a}){return(0,d.jsxs)(`div`,{className:`mb-2 pb-2 border-b border-border space-y-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground/80 uppercase tracking-wide`,children:`Chat History`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,d.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1 px-2 py-1 text-xs rounded-lg transition-colors duration-200 ${e?`text-primary bg-primary/10`:`text-muted-foreground hover:text-foreground hover:bg-secondary`}`,title:e?`Private mode on`:`Private mode`,children:[(0,d.jsx)(s.Lock,{size:12}),(0,d.jsx)(`span`,{children:`Private`})]}),n&&(0,d.jsxs)(`button`,{onClick:r,className:`flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors duration-200`,title:`Clear all history`,children:[(0,d.jsx)(s.Trash2,{size:12}),(0,d.jsx)(`span`,{children:`Clear All`})]})]})]}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(s.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`,size:14}),(0,d.jsx)(`input`,{type:`text`,placeholder:`Search chats...`,value:i,onChange:e=>a(e.target.value),className:`w-full pl-7 pr-7 py-1.5 text-sm bg-secondary/50 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 placeholder:text-muted-foreground/50`}),i&&(0,d.jsx)(`button`,{onClick:()=>a(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,d.jsx)(s.X,{size:14})})]})]})}function yn({chat:e,isPinned:t,onTogglePin:n,onDelete:r}){let i=e.messageCount??0;return(0,d.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200`,children:[(0,d.jsxs)(w.default,{href:`/c/${e.id}`,className:`flex-1 min-w-0 flex items-center gap-1.5`,children:[(0,d.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[i>0&&(0,d.jsxs)(dt,{className:`px-1.5 py-0 text-[10px] font-medium bg-zinc-200 text-zinc-700 hover:bg-zinc-200 dark:bg-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-700 border-0 rounded-md`,children:[i,`Q`]}),(0,d.jsx)(dt,{className:`px-1.5 py-0 text-[10px] font-medium bg-zinc-100 text-zinc-500 hover:bg-zinc-100 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:bg-zinc-800 border-0 rounded-md`,children:D(new Date,e.createdAt)})]}),(0,d.jsxs)(`p`,{className:`text-xs text-popover-foreground truncate`,children:[t&&(0,d.jsx)(s.Pin,{size:10,className:`inline mr-1 text-primary`}),e.title]})]}),(0,d.jsx)(`button`,{onClick:t=>n(t,e.id),className:`p-1.5 rounded-lg transition-all duration-200 ${t?`opacity-100 text-primary hover:bg-primary/10`:`opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-primary hover:bg-primary/10`}`,title:t?`Unpin chat`:`Pin chat`,children:(0,d.jsx)(s.Pin,{size:14})}),(0,d.jsx)(`button`,{onClick:t=>r(t,e.id),className:`opacity-0 group-hover:opacity-100 p-1.5 rounded-lg hover:bg-red-500/10 text-muted-foreground hover:text-red-500 transition-all duration-200`,title:`Delete chat`,children:(0,d.jsx)(s.Trash,{size:14})})]})}function bn({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i,loadingLabel:a,loading:o,onConfirm:s}){return(0,d.jsx)(It,{open:e,onOpenChange:e=>{!e&&!o&&t(!1)},children:(0,d.jsxs)(Bt,{className:`w-full max-w-md transform rounded-2xl bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 p-6 text-left align-middle shadow-xl`,children:[(0,d.jsx)(Vt,{className:`text-lg font-medium leading-6 dark:text-white`,children:n}),(0,d.jsx)(Ht,{className:`text-sm dark:text-white/70 text-black/70 mt-2`,children:r}),(0,d.jsxs)(`div`,{className:`flex flex-row items-end justify-end space-x-4 mt-6`,children:[(0,d.jsx)(`button`,{onClick:()=>{o||t(!1)},className:`text-black/50 dark:text-white/50 text-sm hover:text-black/70 hover:dark:text-white/70 transition duration-200`,children:`Cancel`}),(0,d.jsx)(`button`,{onClick:s,disabled:o,className:`text-red-400 text-sm hover:text-red-500 transition duration-200 disabled:opacity-50`,children:o?a:i})]})]})})}function xn({deleteDialogOpen:e,setDeleteDialogOpen:t,chatToDelete:n,setChatToDelete:r,deleting:i,onConfirmDelete:a,clearAllDialogOpen:o,setClearAllDialogOpen:s,clearingAll:c,onConfirmClearAll:l}){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bn,{open:e,onOpenChange:e=>{t(e),e||r(null)},title:`Delete Confirmation`,description:`Are you sure you want to delete this chat?`,confirmLabel:`Delete`,loadingLabel:`Deleting...`,loading:i,onConfirm:a}),(0,d.jsx)(bn,{open:o,onOpenChange:s,title:`Clear All History`,description:`Are you sure you want to delete all your chat history? This action cannot be undone.`,confirmLabel:`Clear All`,loadingLabel:`Clearing...`,loading:c,onConfirm:l})]})}var Sn={Today:(0,d.jsx)(s.Sun,{size:12}),Yesterday:(0,d.jsx)(s.Clock,{size:12}),"This Week":(0,d.jsx)(s.CalendarDays,{size:12}),Older:(0,d.jsx)(s.Archive,{size:12})};function Cn(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-6*864e5),a={Today:[],Yesterday:[],"This Week":[],Older:[]};for(let t of e){let e=new Date(t.createdAt);e>=n?a.Today.push(t):e>=r?a.Yesterday.push(t):e>=i?a[`This Week`].push(t):a.Older.push(t)}return[`Today`,`Yesterday`,`This Week`,`Older`].filter(e=>a[e].length>0).map(e=>({label:e,chats:a[e]}))}var wn=({showLabel:e=!1})=>{let t=_n();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(It,{children:[(0,d.jsxs)(Lt,{className:e?`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150`:`p-2 text-muted-foreground rounded-2xl bg-background/60 backdrop-blur-md hover:bg-secondary/80 transition duration-200 hover:text-foreground border border-border/30`,children:[(0,d.jsx)(s.History,{size:e?14:18}),e&&(0,d.jsx)(`span`,{children:`History`})]}),(0,d.jsxs)(Bt,{className:`max-w-[420px] p-3`,children:[(0,d.jsx)(Vt,{className:`sr-only`,children:`Chat History`}),(0,d.jsx)(vn,{incognito:t.incognito,onToggleIncognito:t.toggleIncognito,showClearAll:t.chats.length>0&&!t.loading,onClearAll:t.handleClearAllClick,searchQuery:t.searchQuery,onSearchChange:t.handleSearchChange}),t.loading||t.searching?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-6 h-6 text-light-200 fill-light-secondary dark:text-[#202020] animate-spin dark:fill-[#ffffff3b]`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,d.jsx)(`path`,{d:`M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z`,fill:`currentColor`}),(0,d.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z`,fill:`currentFill`})]})}):t.searchQuery.trim()&&t.displayChats.length===0?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matching chats found.`})}):t.chats.length===0?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No chats found.`})}):(0,d.jsx)(`div`,{className:`space-y-1 max-h-[500px] overflow-y-auto`,children:t.searchQuery.trim()?t.displayChats.map(e=>(0,d.jsx)(yn,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id)):Cn(t.displayChats).map(({label:e,chats:n})=>(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground/70 uppercase tracking-wider`,children:[Sn[e],e]}),n.map(e=>(0,d.jsx)(yn,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id))]},e))}),t.chats.length>0&&(0,d.jsx)(`div`,{className:`mt-2 pt-2 border-t border-border`,children:(0,d.jsx)(w.default,{href:`/library`,className:`block text-center text-xs text-primary hover:underline`,children:`View all chats`})})]})]}),(0,d.jsx)(xn,{deleteDialogOpen:t.deleteDialogOpen,setDeleteDialogOpen:t.setDeleteDialogOpen,chatToDelete:t.chatToDelete,setChatToDelete:t.setChatToDelete,deleting:t.deleting,onConfirmDelete:t.handleConfirmDelete,clearAllDialogOpen:t.clearAllDialogOpen,setClearAllDialogOpen:t.setClearAllDialogOpen,clearingAll:t.clearingAll,onConfirmClearAll:t.handleConfirmClearAll})]})};function Tn(){let{chats:e,loading:t}=_n(),n=[...e].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()).slice(0,3);return t?null:(0,d.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2 flex-wrap`,children:[(0,d.jsx)(wn,{showLabel:!0}),n.map(e=>(0,d.jsx)(w.default,{href:`/c/${e.id}`,className:`px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150 truncate max-w-[160px]`,title:e.title,children:e.title},e.id))]})}function En({listFooterLinks:e=[],optionShowIcons:t=!0,optionBackgroundColor:r=`bg-black/40`}){let[i,a]=(0,n.useState)(!1),o=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!i)return;let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);let c=()=>e.map(({url:e,text:n,icon:r})=>{let i=r?s[r]:null,a=e.startsWith(`http`),o=a?{target:`_blank`,rel:`noopener noreferrer`}:{},c=(0,d.jsxs)(d.Fragment,{children:[t&&i&&(0,d.jsx)(i,{size:14}),(0,d.jsx)(`span`,{className:`font-semibold tracking-wide text-md`,style:{fontVariant:`small-caps`},children:n}),(0,d.jsx)(`span`,{className:`absolute bottom-0 left-0 w-0 h-0.5 bg-current transition-all duration-300 group-hover:w-full group-hover:shadow-[0_0_8px_rgba(255,255,255,0.6)]`})]});return a?(0,d.jsx)(`a`,{href:e,...o,className:`relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap`,children:c},e):(0,d.jsx)(w.default,{href:e,className:`relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap`,children:c},e)}),l=s.Info;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`hidden md:flex absolute bottom-2 left-1/2 -translate-x-1/2 text-slate-200 text-xs z-20 ${r} rounded-lg px-2 py-1 shadow-lg hover:shadow-xl hover:-translate-y-1 transition-all duration-300 flex-wrap items-center justify-center gap-x-6 max-w-[90vw]`,children:(0,d.jsx)(`div`,{className:`max-w-4xl mx-auto grid grid-cols-3 gap-2`,children:c()})}),(0,d.jsxs)(`div`,{ref:o,className:`md:hidden fixed top-[calc(8px+env(safe-area-inset-top,0px))] right-2 z-30`,children:[i&&(0,d.jsx)(`div`,{className:`absolute top-full right-0 mt-2 text-slate-200 text-xs ${r} rounded-lg px-3 py-2 shadow-lg flex flex-col items-start gap-2 backdrop-blur-sm`,children:c()}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-label":i?`Hide links`:`Show links`,"aria-expanded":i,className:`flex items-center justify-center h-8 w-8 rounded-full text-slate-200 ${r} shadow-lg backdrop-blur-sm hover:text-white transition-all duration-300`,children:l?(0,d.jsx)(l,{size:16}):`i`})]})]})}function Dn(){let e=`hyZbH3n.mp4,iOeZcCk.mp4,dUZlxYE.mp4,GpWeP6E.gif,LuKUsLE.png,w7X11Dd.png,MHmVtCr.png,HmnUAee.png,vKP22VU.png,l1lsV39.png,Ku8F2qc.png,KUEXtwm.png,vvKFPmY.png,5p8eaEf.png,VAKuJcG.png,sTMPtQW.png,m0gHbZZ.png,cKu7dWQ.png,ogfefYD.png,ey5vAae.png,twuLrvk.png,ELILiYt.png,9el5qpP.png,Up6xTkk.png,W1XKBo0.png,1Y6xvW0.png,JXOytMz.png,DNiI6pp.png,XDv5s6p.jpeg,eRwiRJ9.jpeg,DRAfJoc.jpeg,ASVRQ1G.jpeg,35svwUT.jpeg,81xLiVI.jpeg,6kod2Em.jpeg,eU0C8zt.jpeg,Bv0PBY8.jpeg,DQNbjIZ.jpeg,2uACPqZ.jpeg,XEKltMF.jpeg,WHgLfBm.jpeg,QFYM0Fw.jpeg,K12HCao.jpeg,oN8rtsE.jpeg,9fGnrns.jpeg,2ONJJeW.jpeg,DO23Va7.jpeg,QaKeoXk.jpeg,QU5oCBR.jpeg,MhlYZmh.jpeg,ylL1ToB.jpeg,AWWsCv8.jpeg,Tk9Tzzj.jpeg`.split(`,`);return`https://i.imgur.com/`+e[Math.floor(Math.random()*e.length)]}function On(){let{sendMessage:e}=q(),[r,i]=(0,n.useState)(null),[a,o]=(0,n.useState)(null),[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)({os:``});(0,n.useEffect)(()=>{if(localStorage.getItem(`showBackgroundArt`)===`false`)return;i(Dn());let e=setInterval(()=>{let e=Dn();o(e),c(!0),setTimeout(()=>{i(e),c(!1),o(null)},1e3)},2e4);return()=>clearInterval(e)},[]),(0,n.useEffect)(()=>{if(typeof window<`u`){let e=window.navigator.userAgent.toLowerCase();e.includes(`win`)?u({os:`Windows`}):e.includes(`mac`)?u({os:`MacOS`}):u({os:`Other`})}},[]);let f=e=>e.endsWith(`.webm`)||e.endsWith(`.mp4`),p=(e,t)=>f(e)?(0,d.jsx)(`video`,{src:e,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${t}`},e):(0,d.jsx)(`img`,{src:e,alt:``,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${t}`},e);return(0,d.jsxs)(`div`,{className:`relative min-h-screen w-full`,children:[(0,d.jsxs)(`div`,{className:`fixed inset-0 z-0`,children:[r&&p(r,s?`opacity-0`:`opacity-30`),a&&p(a,s?`opacity-30`:`opacity-0`),(0,d.jsx)(pn,{})]}),(0,d.jsx)(`div`,{className:`relative z-10`,children:(0,d.jsxs)(`div`,{className:`flex flex-col items-center justify-end md:justify-center min-h-[calc(100dvh-64px)] md:min-h-screen max-w-screen-sm mx-auto p-2 pb-1 md:pb-2`,children:[(0,d.jsx)(`div`,{style:{height:`200px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,d.jsx)(x.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})}),(0,d.jsxs)(`p`,{className:`text-lg text-gray-500 text-center justify-center mt-4`,children:[(0,d.jsx)(`a`,{"aria-label":`Chrome Web Store`,className:`download-chrome download-btn text-center justify-center`,target:`_blank`,href:t.researchAgentUIConfig.downloadChromeUrl}),(0,d.jsx)(`a`,{"aria-label":`Microsoft Store`,className:`download-windows download-btn text-center justify-center`,target:`_blank`,href:l.os==`Windows`?`ms-windows-store://pdp/?productid=${t.researchAgentUIConfig.downloadWindowsStoreId}`:`https://apps.microsoft.com/detail/${t.researchAgentUIConfig.downloadWindowsStoreId}?rtc=1`})]}),(0,d.jsxs)(`div`,{className:`w-full max-w-2xl mt-8 space-y-2`,children:[(0,d.jsx)(Tn,{}),(0,d.jsx)(Ft,{})]})]})}),(0,d.jsx)(En,{listFooterLinks:t.researchAgentUIConfig.footerLinks})]})}var kn=()=>(0,d.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-8 h-8 text-border fill-secondary animate-spin`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,d.jsx)(`path`,{d:`M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z`,fill:`currentColor`}),(0,d.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z`,fill:`currentFill`})]});function An(){return(0,d.jsx)(`div`,{className:`flex min-h-screen flex-col items-center justify-center p-8`,children:(0,d.jsxs)(`div`,{className:`max-w-2xl w-full space-y-6 bg-light-secondary dark:bg-dark-secondary rounded-lg p-8 border border-black/10 dark:border-white/10`,children:[(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold text-black dark:text-white`,children:`⚠️ Configuration Required`}),(0,d.jsx)(`p`,{className:`text-black/70 dark:text-white/70`,children:`No AI model providers are configured. Add at least one API key to continue.`})]}),(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(`h2`,{className:`text-lg font-medium text-black dark:text-white`,children:`Quick Setup:`}),(0,d.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`1. Create environment file:`}),(0,d.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs overflow-x-auto`,children:`apps/qwksearch-web/.env.local`})]}),(0,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`2. Add required variables:`}),(0,d.jsx)(`pre`,{className:`block bg-black/10 dark:bg-white/10 rounded p-3 text-xs overflow-x-auto text-black/80 dark:text-white/80`,children:`# Database
|
|
32
|
+
`,type:`button`,"aria-label":`Send message`,children:(0,d.jsx)($.ArrowUp,{className:`w-4 h-4`})}),(0,d.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide`,children:(0,d.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:t?`Stop generating`:`Send message`})})]})]})]}),(0,d.jsx)(u.AnimatePresence,{children:te&&le>0&&(0,d.jsx)(u.motion.div,{ref:e=>{e&&v.current&&v.current.contains(e)},initial:{opacity:0,y:re===`above`?4:-4},animate:{opacity:1,y:0},exit:{opacity:0,y:re===`above`?4:-4},transition:{duration:.12},className:`absolute left-2 right-2 md:left-0 md:right-0 z-20 rounded-2xl bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent shadow-xl overflow-hidden ${re===`above`?`bottom-full`:`top-full`}`,onMouseDown:e=>e.preventDefault(),children:(0,d.jsxs)(`ul`,{className:`max-h-72 overflow-y-auto custom-scrollbar py-1`,children:[H.map((e,t)=>(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,onMouseEnter:()=>W(t),onClick:()=>ce(e),className:`w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${t===U?`bg-bg-200 text-text-100`:`text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]`}`,children:[(0,d.jsx)(`span`,{className:`w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0`,children:t+1}),(0,d.jsx)(`img`,{src:e.favicon,alt:``,className:`w-4 h-4 rounded-sm shrink-0`}),(0,d.jsx)(`span`,{className:`truncate font-medium`,children:e.name||e.domain}),(0,d.jsx)(`span`,{className:`truncate text-[13px] text-text-400 shrink-0`,children:e.domain})]})},`domain-${e.domain}`)),B.map((e,t)=>{let n=H.length+t;return(0,d.jsx)(`li`,{children:(0,d.jsxs)(`button`,{type:`button`,onMouseEnter:()=>W(n),onClick:()=>G(e),className:`w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${n===U?`bg-bg-200 text-text-100`:`text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]`}`,children:[(0,d.jsx)(`span`,{className:`w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0`,children:n+1}),(0,d.jsx)(s.Search,{className:`w-4 h-4 text-text-400 shrink-0`}),(0,d.jsx)(`span`,{className:`truncate`,children:e})]})},`${e}-${t}`)})]})})}),C&&(0,d.jsxs)(`div`,{className:`absolute inset-0 bg-bg-200/90 border-2 border-dashed border-accent rounded-[28px] z-50 flex flex-col items-center justify-center backdrop-blur-sm pointer-events-none`,children:[(0,d.jsx)($.Archive,{className:`w-10 h-10 text-accent mb-2 animate-bounce`}),(0,d.jsx)(`p`,{className:`text-accent font-medium`,children:`Drop files to upload`})]})]})};function It({...e}){return(0,d.jsx)(S.Root,{"data-slot":`dialog`,...e})}function Lt({...e}){return(0,d.jsx)(S.Trigger,{"data-slot":`dialog-trigger`,...e})}function Rt({...e}){return(0,d.jsx)(S.Portal,{"data-slot":`dialog-portal`,...e})}function zt({className:e,...t}){return(0,d.jsx)(S.Overlay,{"data-slot":`dialog-overlay`,className:E(`data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 backdrop-blur-xs`,e),...t})}function Bt({className:e,children:t,hideCloseButton:n=!1,...r}){return(0,d.jsxs)(Rt,{"data-slot":`dialog-portal`,children:[(0,d.jsx)(zt,{}),(0,d.jsxs)(S.Content,{"data-slot":`dialog-content`,"aria-describedby":r[`aria-describedby`]??void 0,className:E(`z-[9999] bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl border p-6 shadow-lg duration-200`,e),...r,children:[t,!n&&(0,d.jsxs)(S.Close,{className:`ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,d.jsx)(s.XIcon,{}),(0,d.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function Vt({className:e,...t}){return(0,d.jsx)(S.Title,{"data-slot":`dialog-title`,className:E(`text-lg leading-none font-semibold`,e),...t})}function Ht({className:e,...t}){return(0,d.jsx)(S.Description,{"data-slot":`dialog-description`,className:E(`text-muted-foreground text-sm`,e),...t})}var Ut=n.forwardRef(({className:e,...t},n)=>(0,d.jsx)(`span`,{ref:n,className:E(`absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap border-0`,e),style:{clip:`rect(0, 0, 0, 0)`,clipPath:`inset(50%)`},...t}));Ut.displayName=`VisuallyHidden`;var Wt=({onClose:e})=>(0,d.jsx)(`div`,{className:`flex items-center justify-between bg-secondary px-4 py-3 border-b border-border`,children:(0,d.jsx)(`button`,{onClick:e,className:`rounded-md p-1 hover:bg-accent transition-colors`,children:(0,d.jsx)(s.X,{className:`h-5 w-5`})})}),Gt=(0,b.cva)(`inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-2xl text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`border-[1.5px] bg-background hover:bg-accent hover:text-accent-foreground dark:bg-card dark:hover:bg-card/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,sm:`h-8 gap-1.5 px-3 has-[>svg]:px-2.5`,lg:`h-10 px-6 has-[>svg]:px-4`,icon:`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function Kt({className:e,variant:t,size:n,asChild:r=!1,...i}){return(0,d.jsx)(r?y.Slot:`button`,{"data-slot":`button`,className:E(Gt({variant:t,size:n,className:e})),...i})}var qt=E(`h-9 w-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),Jt=({isLoadingAI:e,isLoadingFollowups:t,isLoadingFavorite:n,isFavorited:r,isHighlightMode:i,articleUrl:a,onAskClick:o,onSuggestClick:c,onCopyClick:l,onFavoriteClick:u,onHighlightToggle:f,onClose:p})=>(0,d.jsxs)(`div`,{className:`flex flex-nowrap items-center gap-1 rounded-2xl border border-muted bg-gradient-to-b from-background to-muted/30 p-1 shadow-sm`,children:[(0,d.jsxs)(Kt,{onClick:o,disabled:e,variant:`ghost`,size:`sm`,className:E(`flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:[(0,d.jsx)(s.Bot,{className:`size-4`}),(0,d.jsx)(`span`,{className:`font-medium`,children:e?`...`:`Ask`})]}),(0,d.jsxs)(Kt,{onClick:c,disabled:t,variant:`ghost`,size:`sm`,className:E(`flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),children:[(0,d.jsx)(s.MessageCircleQuestion,{className:`size-4`}),(0,d.jsx)(`span`,{className:`font-medium`,children:`Suggest`})]}),(0,d.jsx)(Kt,{onClick:l,variant:`ghost`,size:`icon`,className:qt,title:`Copy article`,children:(0,d.jsx)(s.Clipboard,{className:`size-4`})}),(0,d.jsx)(Kt,{onClick:f,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,i?`text-yellow-500 bg-yellow-50 dark:bg-yellow-950/30 hover:bg-yellow-100 dark:hover:bg-yellow-950/50`:`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),title:i?`Disable highlighting`:`Enable highlighting`,children:(0,d.jsx)(s.Highlighter,{className:`size-4`})}),(0,d.jsx)(Kt,{onClick:u,disabled:n,variant:`ghost`,size:`icon`,className:E(`h-9 w-9 rounded-xl transition-all duration-200`,r?`text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50 dark:hover:bg-yellow-950/30`:`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),title:r?`Remove from favorites`:`Add to favorites`,children:(0,d.jsx)(s.Star,{className:E(`size-4`,r&&`fill-yellow-400`)})}),a&&(0,d.jsx)(Kt,{asChild:!0,variant:`ghost`,size:`icon`,className:qt,title:`Open in new tab`,children:(0,d.jsx)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,children:(0,d.jsx)(s.ExternalLink,{className:`size-4`})})}),(0,d.jsx)(Kt,{onClick:p,variant:`ghost`,size:`icon`,className:E(qt,`ml-auto`),title:`Close`,children:(0,d.jsx)(s.X,{className:`size-4`})})]}),Yt=({value:e,onChange:t,onSubmit:n})=>(0,d.jsx)(`div`,{className:`relative`,children:(0,d.jsx)(`input`,{value:e,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&n(),type:`text`,placeholder:`Ask AI any question...`,className:`w-full px-3 py-2 text-sm rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),Xt=({questions:e,isLoading:r,error:i,onQuestionClick:a})=>{let o=n.default.useMemo(()=>{let t=[];return e.forEach(e=>{e.includes(`?`)&&e.split(`?`).length>2?e.split(`?`).map(e=>e.trim()).filter(Boolean).forEach(e=>{t.push(e.endsWith(`?`)?e:`${e}?`)}):t.push(e)}),t},[e]);return(0,d.jsxs)(d.Fragment,{children:[o.length>0&&(0,d.jsxs)(`div`,{className:`space-y-3 bg-accent/30 rounded-lg p-4 border border-primary/20`,children:[(0,d.jsx)(`h3`,{className:`text-sm font-bold text-primary mb-2`,children:`💡 Suggested Follow-up Questions`}),(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`div`,{onClick:()=>a(t.researchAgentUIConfig.defaultSummarizePrompt),className:`cursor-pointer rounded-md p-3 text-sm font-semibold hover:bg-primary/10 bg-background border border-primary/30 transition-all hover:border-primary shadow-sm hover:shadow-md`,children:t.researchAgentUIConfig.defaultSummarizePrompt}),o.map((e,t)=>(0,d.jsx)(`div`,{onClick:()=>a(e),className:`cursor-pointer rounded-md p-3 text-sm font-semibold hover:bg-primary/10 bg-background border border-border transition-all hover:border-primary shadow-sm hover:shadow-md`,dangerouslySetInnerHTML:{__html:e}},t))]})]}),r&&(0,d.jsx)(`div`,{className:`flex justify-center`,children:(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),i&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:i})]})},Zt=({response:e,isLoading:t,error:n})=>(0,d.jsxs)(d.Fragment,{children:[t&&(0,d.jsx)(`div`,{className:`flex justify-center`,children:(0,d.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),e&&(0,d.jsx)(`div`,{ref:e=>{},className:`bg-muted rounded-lg shadow-md p-4`,dangerouslySetInnerHTML:{__html:e}}),n&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:n})]}),Qt=({html:e,isHighlightMode:t=!1})=>{let[r,i]=(0,n.useState)(``);return(0,n.useEffect)(()=>{i(C.default.sanitize(e||``,{ADD_TAGS:[`figure`,`figcaption`],ADD_ATTR:[`loading`]}))},[e]),(0,d.jsx)(`div`,{className:`prose prose-neutral dark:prose-invert max-w-none ${t?`select-text`:``}`,dangerouslySetInnerHTML:{__html:r}})},$t=({article:e,isHighlightMode:t})=>(0,d.jsx)(`div`,{className:`border-t border-border pt-6`,children:(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`flex items-start justify-between mb-2`}),e.cite&&(0,d.jsx)(`div`,{className:`mb-3 text-sm text-muted-foreground`,dangerouslySetInnerHTML:{__html:e.cite}}),(0,d.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground space-y-1`,children:e.word_count&&(0,d.jsxs)(`p`,{children:[(0,d.jsx)(`span`,{className:`font-semibold`,children:`Words:`}),` `,e.word_count.toLocaleString()]})}),(0,d.jsx)(`div`,{id:`article-content`,children:(0,d.jsx)(Qt,{html:e.html||``,isHighlightMode:t})})]})}),en=/(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g,tn=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;function nn(e){return e.includes(`](`)||e.includes(`)[`)?!1:/\.(com|org|net|io|dev|co|uk|de|fr|it|es|jp|cn|in|br|au|ca|us|gov|edu|mil|int|xyz|info|app|tech|online|site|website|store|shop|blog|news|tv|me|cc|ws|name|mobi|asia|tel|travel|jobs|pro|museum|coop|aero|arpa|biz|cat|jobs|post|tel|xxx|ac|ad|ae|af|ag|ai|al|am|ao|aq|ar|as|at|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?:\/|$)/i.test(e)}function rn(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}function an(e){if(!e||typeof e!=`string`)return e;let t=e,n=[],r;for(tn.lastIndex=0;(r=tn.exec(t))!==null;){let e=r[0],i=r.index,a=t.substring(0,i),o=t.substring(i+e.length);!a.endsWith(`](`)&&!o.startsWith(`)`)&&n.push({email:e,index:i})}for(let e=n.length-1;e>=0;e--){let{email:r,index:i}=n[e];t=t.substring(0,i)+`[${r}](mailto:${r})`+t.substring(i+r.length)}let i=[],a;for(en.lastIndex=0;(a=en.exec(t))!==null;){let e=a[0],n=a.index;if(tn.test(e))continue;let r=t.substring(0,n),o=t.substring(n+e.length);if(r.endsWith(`](`)||o.startsWith(`)`)||(r.match(/```/g)||[]).length%2!=0)continue;let s=r.lastIndexOf("`");if(s!==-1){let e=t.substring(s+1).indexOf("`");if(e!==-1&&e>n-s-1)continue}nn(e)&&i.push({url:e,index:n})}for(let e=i.length-1;e>=0;e--){let{url:n,index:r}=i[e],a=rn(n);t=t.substring(0,r)+`[${n}](${a})`+t.substring(r+n.length)}return t}function on(e){return!e||e.startsWith(`http://`)||e.startsWith(`https://`)||e.includes(`://`)?!1:e.startsWith(`/`)||e.startsWith(`#`)}function sn(e,t){if(t.startsWith(`#`)){e.preventDefault();let n=t.substring(1),r=document.getElementById(n);r&&r.scrollIntoView({behavior:`smooth`,block:`start`})}}function cn({code:e}){let[t,r]=(0,n.useState)(!1);return(0,d.jsx)(`button`,{onClick:(0,n.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}},[e]),className:E(`absolute top-3 right-3 p-1.5 rounded-md`,`opacity-0 group-hover:opacity-100 transition-opacity duration-150`,`bg-zinc-200/80 hover:bg-zinc-300 dark:bg-zinc-700/80 dark:hover:bg-zinc-600`,`text-zinc-600 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200`,`focus:outline-none focus:ring-1 focus:ring-zinc-400 dark:focus:ring-zinc-500`),"aria-label":t?`Copied!`:`Copy code`,children:t?(0,d.jsx)(s.Check,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,d.jsx)(s.Copy,{className:`h-4 w-4`})})}function ln({children:e}){let t=(0,n.useRef)(null),[r,i]=(0,n.useState)(``);return(0,n.useEffect)(()=>{if(t.current){let e=t.current.querySelector(`code`);if(e){let t=e.textContent||``;i(t.trim())}}},[e]),(0,d.jsxs)(`div`,{className:`relative group my-5`,children:[(0,d.jsx)(`pre`,{ref:t,className:E(`p-4 rounded-xl overflow-x-auto`,`bg-zinc-100 dark:bg-zinc-900`,`border border-zinc-200 dark:border-zinc-800`,`text-[13px] font-mono leading-relaxed`,`text-zinc-800 dark:text-zinc-200`,`[&_code]:bg-transparent [&_code]:text-inherit [&_code]:p-0`),children:e}),r&&(0,d.jsx)(cn,{code:r})]})}var un=n.default.memo(({content:e,className:t,isStreaming:n=!1})=>{if(!e)return(0,d.jsx)(`div`,{className:E(`text-muted-foreground text-sm`,t),children:`No content`});let r=an(e);return(0,d.jsx)(`div`,{className:E(`kortix-markdown`,t),children:(0,d.jsx)(T.Streamdown,{isAnimating:n,components:{h1:({children:e})=>(0,d.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight text-foreground mt-8 mb-4 first:mt-0 pb-2 border-b border-border/40`,children:e}),h2:({children:e})=>(0,d.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-foreground mt-8 mb-3 first:mt-0`,children:e}),h3:({children:e})=>(0,d.jsx)(`h3`,{className:`text-lg font-semibold text-foreground mt-6 mb-2 first:mt-0`,children:e}),h4:({children:e})=>(0,d.jsx)(`h4`,{className:`text-base font-semibold text-foreground mt-5 mb-2 first:mt-0`,children:e}),h5:({children:e})=>(0,d.jsx)(`h5`,{className:`text-sm font-semibold text-foreground mt-4 mb-1 first:mt-0`,children:e}),h6:({children:e})=>(0,d.jsx)(`h6`,{className:`text-sm font-medium text-muted-foreground mt-4 mb-1 first:mt-0 uppercase tracking-wide`,children:e}),p:({children:e})=>(0,d.jsx)(`p`,{className:`text-sm text-foreground leading-relaxed my-4 first:mt-0 last:mb-0 [&:has(img)]:my-0`,children:e}),ul:({children:e})=>(0,d.jsx)(`ul`,{className:`my-4 ml-6 list-disc marker:text-muted-foreground/60 space-y-2 first:mt-0 last:mb-0 text-sm`,children:e}),ol:({children:e})=>(0,d.jsx)(`ol`,{className:`my-4 ml-6 list-decimal marker:text-muted-foreground/60 marker:font-medium space-y-2 first:mt-0 last:mb-0 text-sm`,children:e}),li:({children:e})=>(0,d.jsx)(`li`,{className:`text-sm text-foreground leading-relaxed pl-1`,children:e}),a:({href:e,children:t})=>{let n=on(e),r=e?.startsWith(`#`),i=E(`font-medium text-foreground`,`underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]`,`hover:decoration-foreground/60 transition-colors duration-150`);return r?(0,d.jsx)(`a`,{href:e,onClick:t=>sn(t,e),className:i,children:t}):n?(0,d.jsx)(w.default,{href:e||`#`,className:i,children:t}):(0,d.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:i,children:t})},code:({children:e,className:t})=>t?.includes(`language-`)?(0,d.jsx)(`code`,{className:`text-[13px] leading-relaxed text-inherit`,children:e}):(0,d.jsx)(`code`,{className:`px-2 py-1 rounded-md text-[13px] font-mono bg-card dark:bg-[#161618] border border-neutral-200 dark:border-neutral-700/50 text-foreground`,children:e}),pre:({children:e})=>(0,d.jsx)(ln,{children:e}),blockquote:({children:e})=>(0,d.jsx)(`blockquote`,{className:E(`my-5 pl-4 py-1 text-sm`,`border-l-2 border-border`,`text-muted-foreground`,`[&>p]:my-2`),children:e}),hr:()=>(0,d.jsx)(`hr`,{className:`my-8 border-0 h-px bg-border/60`}),table:({children:e})=>(0,d.jsx)(`div`,{className:`my-5 overflow-x-auto rounded-xl border border-border/60`,children:(0,d.jsx)(`table`,{className:`w-full text-sm`,children:e})}),thead:({children:e})=>(0,d.jsx)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 border-b border-border/60`,children:e}),tbody:({children:e})=>(0,d.jsx)(`tbody`,{className:`divide-y divide-border/40`,children:e}),tr:({children:e})=>(0,d.jsx)(`tr`,{className:`transition-colors hover:bg-muted/30`,children:e}),th:({children:e})=>(0,d.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-semibold text-foreground uppercase tracking-wider`,children:e}),td:({children:e})=>(0,d.jsx)(`td`,{className:`px-4 py-3 text-foreground`,children:e}),img:({src:e,alt:t})=>e?(0,d.jsxs)(`span`,{className:`block my-5`,children:[(0,d.jsx)(`img`,{src:e,alt:t||``,className:E(`max-w-full h-auto rounded-xl`,`border border-border/40`,`shadow-sm`),loading:`lazy`}),t&&(0,d.jsx)(`span`,{className:`block mt-2 text-center text-sm text-muted-foreground`,children:t})]}):null,strong:({children:e})=>(0,d.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,d.jsx)(`em`,{className:`italic text-foreground/90`,children:e}),del:({children:e})=>(0,d.jsx)(`del`,{className:`line-through text-muted-foreground decoration-muted-foreground/50`,children:e}),input:({checked:e,...t})=>(0,d.jsx)(`input`,{type:`checkbox`,checked:e,readOnly:!0,className:E(`mr-2 h-4 w-4 rounded border-border`,`accent-secondary cursor-default`,`align-middle relative -top-[1px]`),...t}),div:({children:e,style:t,className:n,...r})=>(0,d.jsx)(`div`,{className:E(`text-sm text-foreground`,n),style:t,...r,children:e}),span:({children:e,style:t,className:n,...r})=>(0,d.jsx)(`span`,{className:E(`text-foreground`,n),style:t,...r,children:e})},children:r})})});un.displayName=`UnifiedMarkdown`;var dn=e=>{let{isOpen:r,url:i,searchText:a,panelWidth:o,setPanelWidth:s,closePanel:l}=A(),{isAuthenticated:u}=Me(),f=e.isOpen===void 0?r:e.isOpen,m=e.onClose||l,h=e.url||i,g=e.searchText===void 0?a:e.searchText,[_,v]=(0,n.useState)(null),[y,b]=(0,n.useState)([]),[x,S]=(0,n.useState)(!1),[C,w]=(0,n.useState)(t.researchAgentUIConfig.defaultSummarizePrompt),[T,E]=(0,n.useState)(!1),[D,O]=(0,n.useState)(!1),[k,j]=(0,n.useState)(!1),[M,N]=(0,n.useState)(``),[P,F]=(0,n.useState)(``),[I,L]=(0,n.useState)([]),[R,z]=(0,n.useState)(``),[B,V]=(0,n.useState)(!1),[H,ee]=(0,n.useState)(!1),[U,W]=(0,n.useState)(!1),[te,ne]=(0,n.useState)(!1),[re,ie]=(0,n.useState)(o),[ae,oe]=(0,n.useState)(!1),[se,G]=(0,n.useState)(!1),ce=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=()=>{ne(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{let e=e=>{if(!ae)return;let t=window.innerWidth-e.clientX,n=Math.max(400,Math.min(t,window.innerWidth-100));ie(n),s(n)},t=()=>{oe(!1)};return ae&&(document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),document.body.style.cursor=`ew-resize`,document.body.style.userSelect=`none`),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t),document.body.style.cursor=``,document.body.style.userSelect=``}},[ae,s]),(0,n.useEffect)(()=>{f&&h?(G(!1),le()):f||G(!1)},[f,h]);let le=async()=>{console.log(`[ArticleExtractPanel] Extracting URL:`,h);try{let e=new URL(h);if([/^https?:\/\/(www\.)?google\.[^/]+\/search/i,/^https?:\/\/(www\.)?bing\.com\/search/i,/^https?:\/\/(www\.)?duckduckgo\.com\/\?/i].some(e=>e.test(h))){p.toast.error(`Cannot extract articles from search result pages`),E(!1),G(!0);return}(e.pathname===`/`||e.pathname===``)&&(console.error(`[ArticleExtractPanel] URL is domain-only, missing article path:`,h),p.toast.error(`Invalid article URL - only domain provided`))}catch(e){console.error(`[ArticleExtractPanel] Invalid URL format:`,h,e)}E(!0);try{let{data:e}=await(0,c.getArticle)({query:{url:h}}),t=e?.article,n=t?.html?.replace(/<[^>]*>/g,``).trim()||``;t?.error||n.length<20?(document.dispatchEvent(new CustomEvent(`onInvokeChromeAPI`,{detail:{type:`extractURL`,url:h}})),await Promise.race([new Promise(e=>{let t=async n=>{window.removeEventListener(`onExtractionResult`,t);let{data:r}=await(0,c.getArticle)({query:{url:h}}),i=r?.article;i&&(v(i),i.followUpQuestions?.length>0&&L(i.followUpQuestions)),e()};window.addEventListener(`onExtractionResult`,t)}),new Promise(e=>setTimeout(e,1e4))])):(v(t),t?.followUpQuestions&&t.followUpQuestions.length>0&&L(t.followUpQuestions)),u&&ue()}catch(e){console.error(`[ArticleExtractPanel] Error extracting URL:`,e),p.toast.error(`Failed to load article`)}finally{E(!1),G(!0)}},ue=async()=>{try{let{data:e}=await(0,c.listFavorites)(),t=e?.favorites?.some(e=>e.url===h);V(!!t)}catch(e){console.error(`Error checking favorite status:`,e)}},de=async()=>{if(_){ee(!0);try{B?(await(0,c.removeFavorite)({query:{url:h}}),V(!1),p.toast.info(`Removed from favorites`)):(await(0,c.addFavorite)({body:{url:_.url||h,title:_.title,cite:_.cite,author:_.author,author_cite:_.author_cite,date:_.date,source:_.source,word_count:_.word_count,html:_.html}}),V(!0),p.toast.success(`Added to favorites`))}catch(e){console.error(`Error toggling favorite:`,e),p.toast.error(`Failed to toggle favorite`)}finally{ee(!1)}}},fe=async e=>{if(!_)return;let n=_.html?.replace(/<[^>]*>?/g,``).slice(0,t.researchAgentUIConfig.maxArticleLength),r=e===`question`,i=r?O:j,a=r?F:z;i(!0),a(``);try{if(r){let e=[g,C].filter(Boolean).join(`
|
|
33
|
+
`);if(!n||n.length===0)throw Error(`Article content is empty`);let{data:t,error:r}=await(0,c.articleQa)({body:{article:n,question:e,chatHistory:y.slice(-5),provider:`groq`}});if(r){let e=r.error||r.message||`Article QA failed`;throw Error(e)}let i=t?.content||``;N(i),b(e=>[...e,{role:`user`,content:C,time:new Date().toISOString()},{role:`assistant`,content:i,time:new Date().toISOString()}]);try{await(0,c.updateArticle)({body:{url:h,question:C,answer:i}})}catch(e){console.error(`Error storing Q&A in cache:`,e)}}else{let e=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`);if(!n||n.length===0)throw Error(`Article content is empty`);let{data:t,error:r}=await(0,c.articleFollowups)({body:{article:n,chatHistory:y.slice(-5),maxQuestions:e,provider:`groq`}});if(r){let e=r.error||r.message||`Article followups failed`;throw Error(e)}let i=t?.extract||[];L(i);try{await(0,c.updateArticle)({body:{url:h,followUpQuestions:i}})}catch(e){console.error(`Error storing follow-up questions in cache:`,e)}}}catch(e){console.error(`Error calling language API:`,e),a(e instanceof Error||typeof e==`object`&&e&&`message`in e?e.message:`Failed to get AI response`)}finally{i(!1)}},pe=e=>{w(e),fe(`question`)},me=async()=>{if(!_)return;let e=`${M}\n\n\n${_.cite||``}\n\n\n${_.html}`;try{await navigator.clipboard.writeText(e),S(!0),setTimeout(()=>S(!1),2e3)}catch(e){console.error(`Failed to copy to clipboard:`,e)}},K=()=>(0,d.jsx)(`div`,{className:`flex h-full flex-col bg-background shadow-xl`,children:(0,d.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,d.jsxs)(`div`,{className:`p-4 space-y-6`,children:[(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(Jt,{isLoadingAI:D,isLoadingFollowups:k,isLoadingFavorite:H,isFavorited:B,isHighlightMode:U,articleUrl:_?.url||h,onAskClick:()=>fe(`question`),onSuggestClick:()=>fe(`suggest-followups`),onCopyClick:me,onFavoriteClick:de,onHighlightToggle:()=>W(!U),onClose:m}),x&&(0,d.jsx)(`div`,{className:`bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg`,children:`Copied!`}),(0,d.jsx)(Yt,{value:C,onChange:w,onSubmit:()=>fe(`question`)}),(0,d.jsx)(Xt,{questions:I,isLoading:k,error:R,onQuestionClick:pe}),y.length>0&&(0,d.jsx)(`div`,{className:`space-y-4`,children:y.map((e,t)=>(0,d.jsx)(`div`,{className:`space-y-2`,children:e.role===`user`?(0,d.jsxs)(`div`,{className:`bg-primary/10 border border-primary/20 rounded-lg p-3`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold text-primary mb-1`,children:`Your Question`}),(0,d.jsx)(`div`,{className:`text-sm text-foreground`,children:e.content})]}):(0,d.jsxs)(`div`,{className:`bg-muted rounded-lg shadow-md p-4`,children:[(0,d.jsx)(`div`,{className:`text-xs font-semibold text-muted-foreground mb-2`,children:`AI Response`}),(0,d.jsx)(`div`,{className:`text-sm`,dangerouslySetInnerHTML:{__html:e.content}})]})},t))}),(D||M&&y.length===0)&&(0,d.jsx)(Zt,{response:M,isLoading:D,error:P}),P&&!D&&(0,d.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:P})]}),_&&(0,d.jsx)($t,{article:_,isHighlightMode:U})]})})});return!f||!se?null:te?(0,d.jsxs)(`div`,{className:`fixed top-0 right-0 h-screen z-40 transition-all duration-300`,style:{width:`${re}px`},children:[(0,d.jsx)(`div`,{ref:ce,onMouseDown:()=>oe(!0),className:`absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-primary bg-transparent transition-colors z-50`,style:{touchAction:`none`},children:(0,d.jsx)(`div`,{className:`absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-12 rounded-full bg-muted-foreground opacity-50 hover:opacity-100 transition-opacity`})}),K()]}):(0,d.jsx)(It,{open:f,onOpenChange:e=>!e&&m(),children:(0,d.jsxs)(Bt,{className:`pointer-events-auto fixed inset-0 !top-0 !left-0 !translate-x-0 !translate-y-0 h-full w-full max-w-none p-0 m-0 rounded-none border-0 overflow-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right`,hideCloseButton:!0,children:[(0,d.jsx)(Ut,{children:(0,d.jsx)(Vt,{children:`Article Details`})}),(0,d.jsx)(`div`,{className:`h-full overflow-y-auto`,children:K()})]})})},fn=()=>{let{sections:e,chatTurns:r,loading:i,messageAppeared:a,newChat:o,chatId:s}=q(),{isOpen:c,panelWidth:l}=A(),{isAuthenticated:u}=Me(),[f,p]=(0,n.useState)(!1),m=(0,n.useRef)(null),h=(0,n.useRef)(null),g=(0,n.useRef)(!1);return(0,n.useEffect)(()=>{let e=()=>{p(window.innerWidth>=1024)};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,n.useEffect)(()=>{if(r.length===1&&(document.title=`${r[0].content.substring(0,30)} - ${t.researchAgentUIConfig.appName}`),r[r.length-1]?.role===`user`){g.current=!0,h.current?.scrollIntoView({behavior:`auto`}),setTimeout(()=>{g.current=!1},100);return}},[r]),(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`flex flex-col min-h-full transition-all duration-300`,style:f&&c?{width:`calc(100% - ${l}px)`}:{},children:[(0,d.jsxs)(`div`,{className:`flex-1 flex flex-col space-y-3 pb-48 ${f&&!c?`px-0 max-w-[800px] mx-auto w-full`:`px-4 lg:px-8`}`,children:[e.map((t,r)=>{let i=r===e.length-1;return(0,d.jsxs)(n.Fragment,{children:[(0,d.jsx)(pt,{section:t,sectionIndex:r,dividerRef:i?m:void 0,isLast:i}),!i&&(0,d.jsx)(`div`,{className:`h-px w-full bg-light-secondary dark:bg-dark-secondary`})]},t.userMessage.messageId)}),i&&!a&&(0,d.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,d.jsx)(`div`,{style:{height:`200px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,d.jsx)(x.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})})}),(0,d.jsx)(`div`,{ref:h,className:`h-0`})]}),(0,d.jsx)(`div`,{className:`sticky bottom-[60px] md:bottom-0 z-40 bg-gradient-to-t from-background via-background to-transparent pt-4 pb-2`,children:(0,d.jsx)(Ft,{})})]}),(0,d.jsx)(dn,{})]})};function pn({radius:e=60,opacityDecay:t=.025,backgroundColor:r=`transparent`,color:i,colorGenerator:a}){let o=(0,n.useRef)(null),s=(0,n.useRef)({x:0,y:0}),c=(0,n.useRef)([]),l=()=>[Math.floor(Math.random()*130+10),Math.floor(.5*Math.random()*50),Math.floor(.5*Math.random()*255)],u=()=>i||a?.()||l();return(0,n.useEffect)(()=>{let n=o.current;if(!n)return;let i=n.getContext(`2d`);if(!i)return;let a=()=>{n.width=window.innerWidth,n.height=window.innerHeight};a();let l=()=>{i.globalCompositeOperation=`source-over`,r===`transparent`?i.clearRect(0,0,n.width,n.height):(i.fillStyle=r,i.fillRect(0,0,n.width,n.height)),i.globalCompositeOperation=`lighter`;let a={col:u(),x:s.current.x,y:s.current.y,grdblur:i.createRadialGradient(s.current.x,s.current.y,0,s.current.x,s.current.y,e),alpha:1};c.current.push(a);let o=[];for(let n=0;n<c.current.length;n++){let r=c.current[n];r.grdblur.addColorStop(0,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.95)`),r.grdblur.addColorStop(.2,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.7)`),r.grdblur.addColorStop(.5,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.3)`),r.grdblur.addColorStop(1,`rgba(${r.col[0]},${r.col[1]},${r.col[2]},0)`),i.beginPath(),i.fillStyle=r.grdblur,i.globalAlpha=r.alpha,i.arc(r.x,r.y,e,0,Math.PI*2),i.fill(),r.alpha-=t,r.alpha<=0&&o.push(n)}for(let e=o.length-1;e>=0;e--)c.current.splice(o[e],1);i.globalAlpha=1,requestAnimationFrame(l)},d=e=>{s.current.x=e.pageX,s.current.y=e.pageY},f=e=>{s.current.x=e.touches[0].pageX,s.current.y=e.touches[0].pageY};return window.addEventListener(`mousemove`,d),window.addEventListener(`touchmove`,f,{passive:!0}),window.addEventListener(`resize`,a),l(),()=>{window.removeEventListener(`mousemove`,d),window.removeEventListener(`touchmove`,f),window.removeEventListener(`resize`,a)}},[e,t,r,i,a]),(0,d.jsx)(`div`,{className:`relative w-full h-screen overflow-hidden pointer-events-none`,children:(0,d.jsx)(`canvas`,{ref:o,className:`absolute inset-0`,style:{background:`transparent`}})})}var mn=`qwksearch_pinned_chats`;function hn(){if(typeof window>`u`)return[];try{let e=localStorage.getItem(mn);return e?JSON.parse(e):[]}catch{return[]}}function gn(e){typeof window>`u`||localStorage.setItem(mn,JSON.stringify(e))}function _n(){let[e,t]=(0,n.useState)([]),[r,i]=(0,n.useState)(!0),[a,o]=(0,n.useState)(!1),[s,l]=(0,n.useState)(null),[u,d]=(0,n.useState)(!1),[f,m]=(0,n.useState)(!1),[h,g]=(0,n.useState)(!1),[_,v]=(0,n.useState)([]),[y,b]=(0,n.useState)(``),[x,S]=(0,n.useState)([]),[C,w]=(0,n.useState)(!1),{isAuthenticated:T,isLoading:E}=Me(),{incognito:D,setIncognito:O}=q();(0,n.useEffect)(()=>{v(hn())},[]);let k=(0,n.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),v(e=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];return gn(n),n})},[]),A=(0,n.useMemo)(()=>[...e].sort((e,t)=>{let n=_.includes(e.id),r=_.includes(t.id);return n&&!r?-1:!n&&r?1:0}),[e,_]),j=(0,n.useMemo)(()=>y.trim()?x:A,[y,x,A]),M=(0,n.useCallback)(async()=>{if(!E){i(!0);try{if(T){let{data:e,error:n}=await(0,c.listChats)();if(n&&n.status===401){let e=K().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0}));t(e);return}if(n)throw Error(`Failed to fetch chats: ${n.message}`);t(Array.isArray(e?.chats)?e.chats:[])}else{let e=K().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0}));t(e)}}catch(e){console.error(`Failed to fetch chat history:`,e),t([]),p.toast.error(`Failed to load chat history`)}finally{i(!1)}}},[T,E]);(0,n.useEffect)(()=>{M()},[M]);let N=(e,t)=>{e.preventDefault(),e.stopPropagation(),l(t),o(!0)},P=async()=>{if(s){d(!0);try{if(T){let{error:e}=await(0,c.deleteChatById)({path:{id:s}});if(e)throw Error(`Failed to delete chat: ${e.message}`)}else _e(s);t(e=>e.filter(e=>e.id!==s)),p.toast.success(`Chat deleted`)}catch(e){p.toast.error(e.message||`Failed to delete chat`)}finally{o(!1),l(null),d(!1)}}},F=()=>{m(!0)},I=async()=>{g(!0);try{if(T){let{error:e}=await(0,c.deleteAllChats)();if(e)throw Error(`Failed to clear history: ${e.message}`)}else ve();t([]),p.toast.success(`All history cleared`)}catch(e){p.toast.error(e.message||`Failed to clear history`)}finally{m(!1),g(!1)}},L=()=>{O(!D),p.toast.success(D?`Private mode off`:`Private mode on — messages won't be saved`)},R=(0,n.useCallback)(async e=>{if(!e.trim()){S([]),w(!1);return}w(!0);try{if(T){let{data:t,error:n}=await(0,c.searchChats)({query:{q:e}});if(n)throw Error(`Failed to search chats: ${n.message}`);S(Array.isArray(t?.chats)?t.chats:[])}else{let t=K().filter(t=>{let n=t.title.toLowerCase().includes(e.toLowerCase()),r=t.messages?.some(t=>`content`in t&&t.content?.toLowerCase().includes(e.toLowerCase()));return n||r});S(t.map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0})))}}catch(e){console.error(`Failed to search chat history:`,e),S([]),p.toast.error(`Failed to search chat history`)}finally{w(!1)}},[T]);return(0,n.useEffect)(()=>{let e=setTimeout(()=>{R(y)},300);return()=>clearTimeout(e)},[y,R]),{chats:e,sortedChats:A,displayChats:j,loading:r,pinnedIds:_,togglePin:k,incognito:D,toggleIncognito:L,searchQuery:y,searchResults:x,searching:C,handleSearchChange:(0,n.useCallback)(e=>{b(e)},[]),deleteDialogOpen:a,setDeleteDialogOpen:o,chatToDelete:s,setChatToDelete:l,deleting:u,handleDeleteClick:N,handleConfirmDelete:P,clearAllDialogOpen:f,setClearAllDialogOpen:m,clearingAll:h,handleClearAllClick:F,handleConfirmClearAll:I}}function vn({incognito:e,onToggleIncognito:t,showClearAll:n,onClearAll:r,searchQuery:i,onSearchChange:a}){return(0,d.jsxs)(`div`,{className:`mb-2 pb-2 border-b border-border space-y-2`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground/80 uppercase tracking-wide`,children:`Chat History`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,d.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1 px-2 py-1 text-xs rounded-lg transition-colors duration-200 ${e?`text-primary bg-primary/10`:`text-muted-foreground hover:text-foreground hover:bg-secondary`}`,title:e?`Private mode on`:`Private mode`,children:[(0,d.jsx)(s.Lock,{size:12}),(0,d.jsx)(`span`,{children:`Private`})]}),n&&(0,d.jsxs)(`button`,{onClick:r,className:`flex items-center gap-1 px-2 py-1 text-xs text-muted-foreground hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors duration-200`,title:`Clear all history`,children:[(0,d.jsx)(s.Trash2,{size:12}),(0,d.jsx)(`span`,{children:`Clear All`})]})]})]}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(s.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`,size:14}),(0,d.jsx)(`input`,{type:`text`,placeholder:`Search chats...`,value:i,onChange:e=>a(e.target.value),className:`w-full pl-7 pr-7 py-1.5 text-sm bg-secondary/50 border border-border rounded-lg focus:outline-none focus:ring-2 focus:ring-primary/50 placeholder:text-muted-foreground/50`}),i&&(0,d.jsx)(`button`,{onClick:()=>a(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,d.jsx)(s.X,{size:14})})]})]})}function yn({chat:e,isPinned:t,onTogglePin:n,onDelete:r}){let i=e.messageCount??0;return(0,d.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200`,children:[(0,d.jsxs)(w.default,{href:`/c/${e.id}`,className:`flex-1 min-w-0 flex items-center gap-1.5`,children:[(0,d.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[i>0&&(0,d.jsxs)(dt,{className:`px-1.5 py-0 text-[10px] font-medium bg-zinc-200 text-zinc-700 hover:bg-zinc-200 dark:bg-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-700 border-0 rounded-md`,children:[i,`Q`]}),(0,d.jsx)(dt,{className:`px-1.5 py-0 text-[10px] font-medium bg-zinc-100 text-zinc-500 hover:bg-zinc-100 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:bg-zinc-800 border-0 rounded-md`,children:D(new Date,e.createdAt)})]}),(0,d.jsxs)(`p`,{className:`text-xs text-popover-foreground truncate`,children:[t&&(0,d.jsx)(s.Pin,{size:10,className:`inline mr-1 text-primary`}),e.title]})]}),(0,d.jsx)(`button`,{onClick:t=>n(t,e.id),className:`p-1.5 rounded-lg transition-all duration-200 ${t?`opacity-100 text-primary hover:bg-primary/10`:`opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-primary hover:bg-primary/10`}`,title:t?`Unpin chat`:`Pin chat`,children:(0,d.jsx)(s.Pin,{size:14})}),(0,d.jsx)(`button`,{onClick:t=>r(t,e.id),className:`opacity-0 group-hover:opacity-100 p-1.5 rounded-lg hover:bg-red-500/10 text-muted-foreground hover:text-red-500 transition-all duration-200`,title:`Delete chat`,children:(0,d.jsx)(s.Trash,{size:14})})]})}function bn({open:e,onOpenChange:t,title:n,description:r,confirmLabel:i,loadingLabel:a,loading:o,onConfirm:s}){return(0,d.jsx)(It,{open:e,onOpenChange:e=>{!e&&!o&&t(!1)},children:(0,d.jsxs)(Bt,{className:`w-full max-w-md transform rounded-2xl bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 p-6 text-left align-middle shadow-xl`,children:[(0,d.jsx)(Vt,{className:`text-lg font-medium leading-6 dark:text-white`,children:n}),(0,d.jsx)(Ht,{className:`text-sm dark:text-white/70 text-black/70 mt-2`,children:r}),(0,d.jsxs)(`div`,{className:`flex flex-row items-end justify-end space-x-4 mt-6`,children:[(0,d.jsx)(`button`,{onClick:()=>{o||t(!1)},className:`text-black/50 dark:text-white/50 text-sm hover:text-black/70 hover:dark:text-white/70 transition duration-200`,children:`Cancel`}),(0,d.jsx)(`button`,{onClick:s,disabled:o,className:`text-red-400 text-sm hover:text-red-500 transition duration-200 disabled:opacity-50`,children:o?a:i})]})]})})}function xn({deleteDialogOpen:e,setDeleteDialogOpen:t,chatToDelete:n,setChatToDelete:r,deleting:i,onConfirmDelete:a,clearAllDialogOpen:o,setClearAllDialogOpen:s,clearingAll:c,onConfirmClearAll:l}){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(bn,{open:e,onOpenChange:e=>{t(e),e||r(null)},title:`Delete Confirmation`,description:`Are you sure you want to delete this chat?`,confirmLabel:`Delete`,loadingLabel:`Deleting...`,loading:i,onConfirm:a}),(0,d.jsx)(bn,{open:o,onOpenChange:s,title:`Clear All History`,description:`Are you sure you want to delete all your chat history? This action cannot be undone.`,confirmLabel:`Clear All`,loadingLabel:`Clearing...`,loading:c,onConfirm:l})]})}var Sn={Today:(0,d.jsx)(s.Sun,{size:12}),Yesterday:(0,d.jsx)(s.Clock,{size:12}),"This Week":(0,d.jsx)(s.CalendarDays,{size:12}),Older:(0,d.jsx)(s.Archive,{size:12})};function Cn(e){let t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=new Date(n.getTime()-864e5),i=new Date(n.getTime()-6*864e5),a={Today:[],Yesterday:[],"This Week":[],Older:[]};for(let t of e){let e=new Date(t.createdAt);e>=n?a.Today.push(t):e>=r?a.Yesterday.push(t):e>=i?a[`This Week`].push(t):a.Older.push(t)}return[`Today`,`Yesterday`,`This Week`,`Older`].filter(e=>a[e].length>0).map(e=>({label:e,chats:a[e]}))}var wn=({showLabel:e=!1})=>{let t=_n();return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(It,{children:[(0,d.jsxs)(Lt,{className:e?`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150`:`p-2 text-muted-foreground rounded-2xl bg-background/60 backdrop-blur-md hover:bg-secondary/80 transition duration-200 hover:text-foreground border border-border/30`,children:[(0,d.jsx)(s.History,{size:e?14:18}),e&&(0,d.jsx)(`span`,{children:`History`})]}),(0,d.jsxs)(Bt,{className:`max-w-[420px] p-3`,children:[(0,d.jsx)(Vt,{className:`sr-only`,children:`Chat History`}),(0,d.jsx)(vn,{incognito:t.incognito,onToggleIncognito:t.toggleIncognito,showClearAll:t.chats.length>0&&!t.loading,onClearAll:t.handleClearAllClick,searchQuery:t.searchQuery,onSearchChange:t.handleSearchChange}),t.loading||t.searching?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-6 h-6 text-light-200 fill-light-secondary dark:text-[#202020] animate-spin dark:fill-[#ffffff3b]`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,d.jsx)(`path`,{d:`M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z`,fill:`currentColor`}),(0,d.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z`,fill:`currentFill`})]})}):t.searchQuery.trim()&&t.displayChats.length===0?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matching chats found.`})}):t.chats.length===0?(0,d.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No chats found.`})}):(0,d.jsx)(`div`,{className:`space-y-1 max-h-[500px] overflow-y-auto`,children:t.searchQuery.trim()?t.displayChats.map(e=>(0,d.jsx)(yn,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id)):Cn(t.displayChats).map(({label:e,chats:n})=>(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground/70 uppercase tracking-wider`,children:[Sn[e],e]}),n.map(e=>(0,d.jsx)(yn,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id))]},e))}),t.chats.length>0&&(0,d.jsx)(`div`,{className:`mt-2 pt-2 border-t border-border`,children:(0,d.jsx)(w.default,{href:`/library`,className:`block text-center text-xs text-primary hover:underline`,children:`View all chats`})})]})]}),(0,d.jsx)(xn,{deleteDialogOpen:t.deleteDialogOpen,setDeleteDialogOpen:t.setDeleteDialogOpen,chatToDelete:t.chatToDelete,setChatToDelete:t.setChatToDelete,deleting:t.deleting,onConfirmDelete:t.handleConfirmDelete,clearAllDialogOpen:t.clearAllDialogOpen,setClearAllDialogOpen:t.setClearAllDialogOpen,clearingAll:t.clearingAll,onConfirmClearAll:t.handleConfirmClearAll})]})};function Tn(){let{chats:e,loading:t}=_n(),n=[...e].sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()).slice(0,3);return t?null:(0,d.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2 flex-wrap`,children:[(0,d.jsx)(wn,{showLabel:!0}),n.map(e=>(0,d.jsx)(w.default,{href:`/c/${e.id}`,className:`px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150 truncate max-w-[160px]`,title:e.title,children:e.title},e.id))]})}function En({listFooterLinks:e=[],optionShowIcons:t=!0,optionBackgroundColor:r=`bg-black/40`}){let[i,a]=(0,n.useState)(!1),o=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!i)return;let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]);let c=()=>e.map(({url:e,text:n,icon:r})=>{let i=r?s[r]:null,a=e.startsWith(`http`),o=a?{target:`_blank`,rel:`noopener noreferrer`}:{},c=(0,d.jsxs)(d.Fragment,{children:[t&&i&&(0,d.jsx)(i,{size:14}),(0,d.jsx)(`span`,{className:`font-semibold tracking-wide text-md`,style:{fontVariant:`small-caps`},children:n}),(0,d.jsx)(`span`,{className:`absolute bottom-0 left-0 w-0 h-0.5 bg-current transition-all duration-300 group-hover:w-full group-hover:shadow-[0_0_8px_rgba(255,255,255,0.6)]`})]});return a?(0,d.jsx)(`a`,{href:e,...o,className:`relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap`,children:c},e):(0,d.jsx)(w.default,{href:e,className:`relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap`,children:c},e)}),l=s.Info;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`div`,{className:`hidden md:flex absolute bottom-2 left-1/2 -translate-x-1/2 text-slate-200 text-xs z-20 ${r} rounded-lg px-2 py-1 shadow-lg hover:shadow-xl hover:-translate-y-1 transition-all duration-300 flex-wrap items-center justify-center gap-x-6 max-w-[90vw]`,children:(0,d.jsx)(`div`,{className:`max-w-4xl mx-auto grid grid-cols-3 gap-2`,children:c()})}),(0,d.jsxs)(`div`,{ref:o,className:`md:hidden fixed top-[calc(8px+env(safe-area-inset-top,0px))] right-2 z-30`,children:[i&&(0,d.jsx)(`div`,{className:`absolute top-full right-0 mt-2 text-slate-200 text-xs ${r} rounded-lg px-3 py-2 shadow-lg flex flex-col items-start gap-2 backdrop-blur-sm`,children:c()}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-label":i?`Hide links`:`Show links`,"aria-expanded":i,className:`flex items-center justify-center h-8 w-8 rounded-full text-slate-200 ${r} shadow-lg backdrop-blur-sm hover:text-white transition-all duration-300`,children:l?(0,d.jsx)(l,{size:16}):`i`})]})]})}function Dn(){let e=`hyZbH3n.mp4,iOeZcCk.mp4,dUZlxYE.mp4,GpWeP6E.gif,LuKUsLE.png,w7X11Dd.png,MHmVtCr.png,HmnUAee.png,vKP22VU.png,l1lsV39.png,Ku8F2qc.png,KUEXtwm.png,vvKFPmY.png,5p8eaEf.png,VAKuJcG.png,sTMPtQW.png,m0gHbZZ.png,cKu7dWQ.png,ogfefYD.png,ey5vAae.png,twuLrvk.png,ELILiYt.png,9el5qpP.png,Up6xTkk.png,W1XKBo0.png,1Y6xvW0.png,JXOytMz.png,DNiI6pp.png,XDv5s6p.jpeg,eRwiRJ9.jpeg,DRAfJoc.jpeg,ASVRQ1G.jpeg,35svwUT.jpeg,81xLiVI.jpeg,6kod2Em.jpeg,eU0C8zt.jpeg,Bv0PBY8.jpeg,DQNbjIZ.jpeg,2uACPqZ.jpeg,XEKltMF.jpeg,WHgLfBm.jpeg,QFYM0Fw.jpeg,K12HCao.jpeg,oN8rtsE.jpeg,9fGnrns.jpeg,2ONJJeW.jpeg,DO23Va7.jpeg,QaKeoXk.jpeg,QU5oCBR.jpeg,MhlYZmh.jpeg,ylL1ToB.jpeg,AWWsCv8.jpeg,Tk9Tzzj.jpeg`.split(`,`);return`https://i.imgur.com/`+e[Math.floor(Math.random()*e.length)]}function On(){let{sendMessage:e}=q(),[r,i]=(0,n.useState)(null),[a,o]=(0,n.useState)(null),[s,c]=(0,n.useState)(!1),[l,u]=(0,n.useState)({os:``});(0,n.useEffect)(()=>{if(localStorage.getItem(`showBackgroundArt`)===`false`)return;i(Dn());let e=setInterval(()=>{let e=Dn();o(e),c(!0),setTimeout(()=>{i(e),c(!1),o(null)},1e3)},2e4);return()=>clearInterval(e)},[]),(0,n.useEffect)(()=>{if(typeof window<`u`){let e=window.navigator.userAgent.toLowerCase();e.includes(`win`)?u({os:`Windows`}):e.includes(`mac`)?u({os:`MacOS`}):u({os:`Other`})}},[]);let f=e=>e.endsWith(`.webm`)||e.endsWith(`.mp4`),p=(e,t)=>f(e)?(0,d.jsx)(`video`,{src:e,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${t}`},e):(0,d.jsx)(`img`,{src:e,alt:``,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${t}`},e);return(0,d.jsxs)(`div`,{className:`relative min-h-screen w-full`,children:[(0,d.jsxs)(`div`,{className:`fixed inset-0 z-0`,children:[r&&p(r,s?`opacity-0`:`opacity-30`),a&&p(a,s?`opacity-30`:`opacity-0`),(0,d.jsx)(pn,{})]}),(0,d.jsx)(`div`,{className:`relative z-10`,children:(0,d.jsxs)(`div`,{className:`flex flex-col items-center justify-end md:justify-center min-h-[calc(100dvh-64px)] md:min-h-screen max-w-screen-sm mx-auto p-2 pb-1 md:pb-2`,children:[(0,d.jsx)(`div`,{style:{height:`200px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,d.jsx)(x.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})}),(0,d.jsxs)(`p`,{className:`text-lg text-gray-500 text-center justify-center mt-4`,children:[(0,d.jsx)(`a`,{"aria-label":`Chrome Web Store`,className:`download-chrome download-btn text-center justify-center`,target:`_blank`,href:t.researchAgentUIConfig.downloadChromeUrl}),(0,d.jsx)(`a`,{"aria-label":`Microsoft Store`,className:`download-windows download-btn text-center justify-center`,target:`_blank`,href:l.os==`Windows`?`ms-windows-store://pdp/?productid=${t.researchAgentUIConfig.downloadWindowsStoreId}`:`https://apps.microsoft.com/detail/${t.researchAgentUIConfig.downloadWindowsStoreId}?rtc=1`})]}),(0,d.jsxs)(`div`,{className:`w-full max-w-2xl mt-8 space-y-2`,children:[(0,d.jsx)(Tn,{}),(0,d.jsx)(Ft,{})]})]})}),(0,d.jsx)(En,{listFooterLinks:t.researchAgentUIConfig.footerLinks})]})}var kn=()=>(0,d.jsxs)(`svg`,{"aria-hidden":`true`,className:`w-8 h-8 text-border fill-secondary animate-spin`,viewBox:`0 0 100 101`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,d.jsx)(`path`,{d:`M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z`,fill:`currentColor`}),(0,d.jsx)(`path`,{d:`M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z`,fill:`currentFill`})]});function An(){return(0,d.jsx)(`div`,{className:`flex min-h-screen flex-col items-center justify-center p-8`,children:(0,d.jsxs)(`div`,{className:`max-w-2xl w-full space-y-6 bg-light-secondary dark:bg-dark-secondary rounded-lg p-8 border border-black/10 dark:border-white/10`,children:[(0,d.jsxs)(`div`,{className:`space-y-2`,children:[(0,d.jsx)(`h1`,{className:`text-2xl font-semibold text-black dark:text-white`,children:`⚠️ Configuration Required`}),(0,d.jsx)(`p`,{className:`text-black/70 dark:text-white/70`,children:`No AI model providers are configured. Add at least one API key to continue.`})]}),(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsx)(`h2`,{className:`text-lg font-medium text-black dark:text-white`,children:`Quick Setup:`}),(0,d.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`1. Create environment file:`}),(0,d.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs overflow-x-auto`,children:`apps/qwksearch-web/.env.local`})]}),(0,d.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,d.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`2. Add required variables:`}),(0,d.jsx)(`pre`,{className:`block bg-black/10 dark:bg-white/10 rounded p-3 text-xs overflow-x-auto text-black/80 dark:text-white/80`,children:`# Database
|
|
34
34
|
DATABASE_URL=file:./data/qwksearch.db
|
|
35
35
|
|
|
36
36
|
# Auth (generate: openssl rand -base64 32)
|
package/dist/index.mjs
CHANGED
|
@@ -4821,15 +4821,20 @@ var ti = (e) => {
|
|
|
4821
4821
|
i(!0), a("");
|
|
4822
4822
|
try {
|
|
4823
4823
|
if (r) {
|
|
4824
|
-
let
|
|
4824
|
+
let e = [h, S].filter(Boolean).join("\n");
|
|
4825
|
+
if (!n || n.length === 0) throw Error("Article content is empty");
|
|
4826
|
+
let { data: t, error: r } = await Be({ body: {
|
|
4825
4827
|
article: n,
|
|
4826
|
-
question:
|
|
4828
|
+
question: e,
|
|
4827
4829
|
chatHistory: v.slice(-5),
|
|
4828
4830
|
provider: "groq"
|
|
4829
4831
|
} });
|
|
4830
|
-
if (
|
|
4831
|
-
|
|
4832
|
-
|
|
4832
|
+
if (r) {
|
|
4833
|
+
let e = r.error || r.message || "Article QA failed";
|
|
4834
|
+
throw Error(e);
|
|
4835
|
+
}
|
|
4836
|
+
let i = t?.content || "";
|
|
4837
|
+
j(i), y((e) => [
|
|
4833
4838
|
...e,
|
|
4834
4839
|
{
|
|
4835
4840
|
role: "user",
|
|
@@ -4838,7 +4843,7 @@ var ti = (e) => {
|
|
|
4838
4843
|
},
|
|
4839
4844
|
{
|
|
4840
4845
|
role: "assistant",
|
|
4841
|
-
content:
|
|
4846
|
+
content: i,
|
|
4842
4847
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
4843
4848
|
}
|
|
4844
4849
|
]);
|
|
@@ -4846,19 +4851,24 @@ var ti = (e) => {
|
|
|
4846
4851
|
await it({ body: {
|
|
4847
4852
|
url: m,
|
|
4848
4853
|
question: S,
|
|
4849
|
-
answer:
|
|
4854
|
+
answer: i
|
|
4850
4855
|
} });
|
|
4851
4856
|
} catch (e) {
|
|
4852
4857
|
console.error("Error storing Q&A in cache:", e);
|
|
4853
4858
|
}
|
|
4854
4859
|
} else {
|
|
4855
|
-
let e = parseInt(localStorage.getItem("maxFollowupQuestions") || "4")
|
|
4860
|
+
let e = parseInt(localStorage.getItem("maxFollowupQuestions") || "4");
|
|
4861
|
+
if (!n || n.length === 0) throw Error("Article content is empty");
|
|
4862
|
+
let { data: t, error: r } = await ze({ body: {
|
|
4856
4863
|
article: n,
|
|
4857
4864
|
chatHistory: v.slice(-5),
|
|
4858
4865
|
maxQuestions: e,
|
|
4859
4866
|
provider: "groq"
|
|
4860
4867
|
} });
|
|
4861
|
-
if (r)
|
|
4868
|
+
if (r) {
|
|
4869
|
+
let e = r.error || r.message || "Article followups failed";
|
|
4870
|
+
throw Error(e);
|
|
4871
|
+
}
|
|
4862
4872
|
let i = t?.extract || [];
|
|
4863
4873
|
F(i);
|
|
4864
4874
|
try {
|
|
@@ -4871,7 +4881,7 @@ var ti = (e) => {
|
|
|
4871
4881
|
}
|
|
4872
4882
|
}
|
|
4873
4883
|
} catch (e) {
|
|
4874
|
-
console.error("Error calling language API:", e), a("Failed to get AI response");
|
|
4884
|
+
console.error("Error calling language API:", e), a(e instanceof Error || typeof e == "object" && e && "message" in e ? e.message : "Failed to get AI response");
|
|
4875
4885
|
} finally {
|
|
4876
4886
|
i(!1);
|
|
4877
4887
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "research-agent-ui",
|
|
3
3
|
"description": "Chat research agent UI: conversation window, article reader, search config, file uploads, and chat history",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.69",
|
|
5
5
|
"author": "vtempest",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -63,19 +63,19 @@
|
|
|
63
63
|
"@radix-ui/react-slot": "^1.2.5",
|
|
64
64
|
"@radix-ui/react-tooltip": "^1.2.9",
|
|
65
65
|
"@ricky0123/vad-web": "^0.0.30",
|
|
66
|
-
"chat-agent-toolkit": "^1.2.
|
|
67
|
-
"domain-rank": "^0.1.
|
|
66
|
+
"chat-agent-toolkit": "^1.2.91",
|
|
67
|
+
"domain-rank": "^0.1.80",
|
|
68
68
|
"drizzle-orm": "^0.45.2",
|
|
69
69
|
"fuse.js": "^7.1.0",
|
|
70
70
|
"class-variance-authority": "^0.7.1",
|
|
71
71
|
"clsx": "^2.1.1",
|
|
72
72
|
"dompurify": "^3.4.9",
|
|
73
|
-
"extract-webpage": "^1.2.
|
|
74
|
-
"search-web-api": "^1.0.
|
|
73
|
+
"extract-webpage": "^1.2.92",
|
|
74
|
+
"search-web-api": "^1.0.51",
|
|
75
75
|
"framer-motion": "^12.40.0",
|
|
76
76
|
"grab-url": "^1.6.22",
|
|
77
77
|
"kokoro-js": "^1.2.1",
|
|
78
|
-
"qwksearch-api-client": "^0.9.
|
|
78
|
+
"qwksearch-api-client": "^0.9.40",
|
|
79
79
|
"html2canvas": "^1.4.1",
|
|
80
80
|
"lucide-react": "^1.17.0",
|
|
81
81
|
"markdown-to-jsx": "^9.8.2",
|