research-agent-ui 0.1.293 → 0.1.294
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/README.md +42 -1
- package/dist/ArticleExtractPanel-25tRTnpl.cjs +2 -0
- package/dist/ArticleExtractPanel-D_y16YHG.js +389 -0
- package/dist/ChatConversationThread-BIJ8aNug.js +1428 -0
- package/dist/ChatConversationThread-BoNH0wvs.cjs +17 -0
- package/dist/DownloadsDialog-CCPj0hA8.cjs +1 -0
- package/dist/{DownloadsDialog-bTEDe2DI.js → DownloadsDialog-DvS23Dh-.js} +8 -9
- package/dist/api/handlers/autocomplete.d.ts +6 -9
- package/dist/api/handlers/openai-transcription.d.ts +53 -0
- package/dist/api/handlers/transcript.d.ts +33 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api.cjs +10 -10
- package/dist/api.mjs +161 -208
- package/dist/app/index.d.ts +1 -1
- package/dist/app/useChunkErrorReload.d.ts +13 -2
- package/dist/components/ArticleReader/ArticleReaderMount.d.ts +5 -0
- package/dist/components/ArticleReader/ExtractPanelContext.d.ts +17 -1
- package/dist/components/ChatConversation/MessageBubble/AssistantMessageActions.d.ts +2 -1
- package/dist/components/ChatConversation/background-art.d.ts +3 -1
- package/dist/components/ChatConversation/background-cache.d.ts +41 -0
- package/dist/components/Footer.d.ts +5 -4
- package/dist/components/Footer.stories.d.ts +3 -3
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.mjs +4 -3
- package/dist/dialog-7GDz0sWx.cjs +1 -0
- package/dist/dialog-Cufn2u50.js +80 -0
- package/dist/hooks/voice/useKokoroTTS.d.ts +2 -0
- package/dist/hooks/voice/useTextToVoice.d.ts +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +4 -2
- package/dist/lib/file-sources.d.ts +8 -0
- package/dist/lib/google-drive-source.d.ts +100 -0
- package/dist/lib/kokoro.d.ts +14 -2
- package/dist/lib/qwksearch-connect.d.ts +79 -0
- package/dist/settings/index.d.ts +15 -0
- package/dist/src-GPr1ceY8.js +6165 -0
- package/dist/src-ebmQu_if.cjs +34 -0
- package/dist/tooltip-Bl3IdX-I.js +179 -0
- package/dist/tooltip-DmUO6ZUz.cjs +1 -0
- package/dist/types/fileSource.d.ts +9 -0
- package/dist/workspace/QwkSearchWorkspaceApp.d.ts +9 -2
- package/dist/workspace/ResearchWorkspaceView.d.ts +18 -4
- package/dist/workspace.cjs +1 -1
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.mjs +234 -91
- package/package.json +54 -51
- package/src/app/useChunkErrorReload.ts +92 -0
- package/src/settings/index.ts +23 -0
- package/src/settings/search.json +19 -1
- package/dist/DownloadsDialog-Ca6aRRcP.cjs +0 -1
- package/dist/src-HL9JjPc-.js +0 -8218
- package/dist/src-r4BsCIB4.cjs +0 -51
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BocRIvOZ.cjs"),t=require("./config.cjs"),n=require("./tooltip-DmUO6ZUz.cjs"),r=require("./dialog-7GDz0sWx.cjs");let i=require("react");i=e.t(i,1);let a=require("next/navigation"),o=require("react/jsx-runtime"),s=require("motion/react"),c=require("search-autocomplete/react"),l=require("lucide-react"),u=require("sonner"),d=require("grab-url");d=e.t(d,1);let f=require("qwksearch-api-client"),p=require("use-voice-control/client"),m=require("use-voice-control/react"),h=require("@radix-ui/react-dropdown-menu");h=e.t(h,1);let g=require("next/link");g=e.t(g,1);let _=require("@radix-ui/react-slot"),v=require("class-variance-authority"),y=require("quantum-sphere-loading-icon/react");y=e.t(y,1);let b=require("dompurify");b=e.t(b,1);let x=require("streamdown"),S=require("react-icons/fa"),C=require("shadcn-theme-menu"),w=require("shadcn-app-dock"),T=require("next/image");T=e.t(T,1);let E=require("legal-terms-privacy-policy/react");function D({radius:e=60,opacityDecay:t=.025,backgroundColor:n=`transparent`,color:r,colorGenerator:a}){let s=(0,i.useRef)(null),c=(0,i.useRef)({x:0,y:0}),l=(0,i.useRef)([]),u=()=>[Math.floor(Math.random()*130+10),Math.floor(.5*Math.random()*50),Math.floor(.5*Math.random()*255)],d=()=>r||a?.()||u();return(0,i.useEffect)(()=>{let r=s.current;if(!r)return;let i=r.getContext(`2d`);if(!i)return;let a=0,o=()=>{r.width=window.innerWidth,r.height=window.innerHeight};o();let u=()=>{i.globalCompositeOperation=`source-over`,n===`transparent`?i.clearRect(0,0,r.width,r.height):(i.fillStyle=n,i.fillRect(0,0,r.width,r.height)),i.globalCompositeOperation=`lighter`;let o={col:d(),x:c.current.x,y:c.current.y,grdblur:i.createRadialGradient(c.current.x,c.current.y,0,c.current.x,c.current.y,e),alpha:1};l.current.push(o);let s=[];for(let n=0;n<l.current.length;n++){let r=l.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&&s.push(n)}for(let e=s.length-1;e>=0;e--)l.current.splice(s[e],1);i.globalAlpha=1,a=requestAnimationFrame(u)},f=e=>{c.current.x=e.pageX,c.current.y=e.pageY},p=e=>{c.current.x=e.touches[0].pageX,c.current.y=e.touches[0].pageY};return window.addEventListener(`mousemove`,f),window.addEventListener(`touchmove`,p,{passive:!0}),window.addEventListener(`resize`,o),u(),()=>{cancelAnimationFrame(a),window.removeEventListener(`mousemove`,f),window.removeEventListener(`touchmove`,p),window.removeEventListener(`resize`,o),l.current=[]}},[e,t,n,r,a]),(0,o.jsx)(`div`,{className:`relative w-full h-screen overflow-hidden pointer-events-none`,children:(0,o.jsx)(`canvas`,{ref:s,className:`absolute inset-0`,style:{background:`transparent`}})})}var O={Plus:l.Plus,Paperclip:l.Paperclip,Cloud:l.Cloud,Upload:l.Upload,File:l.File,SquarePen:l.SquarePen,Thinking:e=>(0,o.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,o.jsx)(`path`,{d:`M10.3857 2.50977C14.3486 2.71054 17.5 5.98724 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 9.72386 2.72386 9.5 3 9.5C3.27614 9.5 3.5 9.72386 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10C16.5 6.5225 13.7691 3.68312 10.335 3.50879L10 3.5L9.89941 3.49023C9.67145 3.44371 9.5 3.24171 9.5 3C9.5 2.72386 9.72386 2.5 10 2.5L10.3857 2.50977ZM10 5.5C10.2761 5.5 10.5 5.72386 10.5 6V9.69043L13.2236 11.0527C13.4706 11.1762 13.5708 11.4766 13.4473 11.7236C13.3392 11.9397 13.0957 12.0435 12.8711 11.9834L12.7764 11.9473L9.77637 10.4473C9.60698 10.3626 9.5 10.1894 9.5 10V6C9.5 5.72386 9.72386 5.5 10 5.5ZM3.66211 6.94141C4.0273 6.94159 4.32303 7.23735 4.32324 7.60254C4.32324 7.96791 4.02743 8.26446 3.66211 8.26465C3.29663 8.26465 3 7.96802 3 7.60254C3.00021 7.23723 3.29676 6.94141 3.66211 6.94141ZM4.95605 4.29395C5.32146 4.29404 5.61719 4.59063 5.61719 4.95605C5.6171 5.3214 5.3214 5.61709 4.95605 5.61719C4.59063 5.61719 4.29403 5.32146 4.29395 4.95605C4.29395 4.59057 4.59057 4.29395 4.95605 4.29395ZM7.60254 3C7.96802 3 8.26465 3.29663 8.26465 3.66211C8.26446 4.02743 7.96791 4.32324 7.60254 4.32324C7.23736 4.32302 6.94159 4.0273 6.94141 3.66211C6.94141 3.29676 7.23724 3.00022 7.60254 3Z`})}),SelectArrow:l.ChevronDown,ArrowUp:l.ArrowUp,X:l.X,FileText:l.FileText,Loader2:l.Loader2,Check:l.Check,Archive:l.Archive,Mic:l.Mic,Stop:l.Square,Clock:e=>(0,o.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`currentColor`,...e,children:(0,o.jsx)(`path`,{d:`M10.3857 2.50977C14.3486 2.71054 17.5 5.98724 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 9.72386 2.72386 9.5 3 9.5C3.27614 9.5 3.5 9.72386 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10C16.5 6.5225 13.7691 3.68312 10.335 3.50879L10 3.5L9.89941 3.49023C9.67145 3.44371 9.5 3.24171 9.5 3C9.5 2.72386 9.72386 2.5 10 2.5L10.3857 2.50977ZM10 5.5C10.2761 5.5 10.5 5.72386 10.5 6V9.69043L13.2236 11.0527C13.4706 11.1762 13.5708 11.4766 13.4473 11.7236C13.3392 11.9397 13.0957 12.0435 12.8711 11.9834L12.7764 11.9473L9.77637 10.4473C9.60698 10.3626 9.5 10.1894 9.5 10V6C9.5 5.72386 9.72386 5.5 10 5.5ZM3.66211 6.94141C4.0273 6.94159 4.32303 7.23735 4.32324 7.60254C4.32324 7.96791 4.02743 8.26446 3.66211 8.26465C3.29663 8.26465 3 7.96802 3 7.60254C3.00021 7.23723 3.29676 6.94141 3.66211 6.94141ZM4.95605 4.29395C5.32146 4.29404 5.61719 4.59063 5.61719 4.95605C5.6171 5.3214 5.3214 5.61709 4.95605 5.61719C4.59063 5.61719 4.29403 5.32146 4.29395 4.95605C4.29395 4.59057 4.59057 4.29395 4.95605 4.29395ZM7.60254 3C7.96802 3 8.26465 3.29663 8.26465 3.66211C8.26446 4.02743 7.96791 4.32324 7.60254 4.32324C7.23736 4.32302 6.94159 4.0273 6.94141 3.66211C6.94141 3.29676 7.23724 3.00022 7.60254 3Z`})})},k=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/t**r).toFixed(2))+` `+n[r]},A=({file:e,onRemove:t})=>{let n=e.type.startsWith(`image/`)&&e.preview;return(0,o.jsxs)(`div`,{className:`relative group flex-shrink-0 w-24 h-24 rounded-xl overflow-hidden border border-bg-300 bg-bg-200 animate-fade-in transition-all hover:border-text-400`,children:[n?(0,o.jsxs)(`div`,{className:`w-full h-full relative`,children:[(0,o.jsx)(`img`,{src:e.preview,alt:e.file.name,className:`w-full h-full object-cover`}),(0,o.jsx)(`div`,{className:`absolute inset-0 bg-black/20 group-hover:bg-black/0 transition-colors`}),(0,o.jsx)(`span`,{className:`absolute bottom-1 left-1 px-1.5 py-0.5 rounded-md bg-black/60 text-white text-[10px] font-medium leading-none backdrop-blur-sm pointer-events-none`,title:e.file.name,children:k(e.file.size)})]}):(0,o.jsxs)(`div`,{className:`w-full h-full p-3 flex flex-col justify-between`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(`div`,{className:`p-1.5 bg-bg-300 rounded`,children:(0,o.jsx)(O.FileText,{className:`w-4 h-4 text-text-300`})}),(0,o.jsx)(`span`,{className:`text-[10px] font-medium text-text-400 uppercase tracking-wider truncate`,children:e.file.name.split(`.`).pop()})]}),(0,o.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,o.jsx)(`p`,{className:`text-xs font-medium text-text-200 truncate`,title:e.file.name,children:e.file.name}),(0,o.jsx)(`p`,{className:`text-[10px] text-text-500`,children:k(e.file.size)})]})]}),(0,o.jsx)(`button`,{onClick:()=>t(e.id),className:`absolute top-1 right-1 p-1 bg-black/50 hover:bg-black/70 rounded-full text-white opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,o.jsx)(O.X,{className:`w-3 h-3`})}),e.uploadStatus===`uploading`&&(0,o.jsx)(`div`,{className:`absolute inset-0 bg-black/40 flex items-center justify-center`,children:(0,o.jsx)(O.Loader2,{className:`w-5 h-5 text-white animate-spin`})}),e.uploadStatus===`error`&&(0,o.jsx)(`div`,{className:`absolute inset-0 bg-red-900/60 flex items-center justify-center`,children:(0,o.jsx)(O.X,{className:`w-5 h-5 text-red-300`})})]})},j=({content:e,onRemove:t})=>(0,o.jsxs)(`div`,{className:`relative group flex-shrink-0 w-28 h-28 rounded-2xl overflow-hidden border border-[#E5E5E5] dark:border-[#30302E] bg-white dark:bg-[#20201F] animate-fade-in p-3 flex flex-col justify-between shadow-[0_1px_2px_rgba(0,0,0,0.05)]`,children:[(0,o.jsx)(`div`,{className:`overflow-hidden w-full`,children:(0,o.jsx)(`p`,{className:`text-[10px] text-[#9CA3AF] leading-[1.4] font-mono break-words whitespace-pre-wrap line-clamp-4 select-none`,children:e.content})}),(0,o.jsx)(`div`,{className:`flex items-center justify-between w-full mt-2`,children:(0,o.jsx)(`div`,{className:`inline-flex items-center justify-center px-1.5 py-[2px] rounded border border-[#E5E5E5] dark:border-[#404040] bg-white dark:bg-transparent`,children:(0,o.jsx)(`span`,{className:`text-[9px] font-bold text-[#6B7280] dark:text-[#9CA3AF] uppercase tracking-wider font-sans`,children:`PASTED`})})}),(0,o.jsx)(`button`,{onClick:()=>t(e.id),className:`absolute top-2 right-2 p-[3px] bg-white dark:bg-[#30302E] border border-[#E5E5E5] dark:border-[#404040] rounded-full text-[#9CA3AF] hover:text-[#6B7280] dark:hover:text-white transition-colors shadow-sm opacity-0 group-hover:opacity-100`,children:(0,o.jsx)(O.X,{className:`w-2 h-2`})})]}),M=async(e,t,n)=>{try{let n=localStorage.getItem(`chatModelKey`),r=localStorage.getItem(`chatModelProviderId`),i=(await(0,d.default)(`agent/providers`))?.providers||[];if(!i||i.length===0){t(!0);return}let a=i.find(e=>e.id===r&&(e.chatModels?.length??0)>0);if(a||=i.find(e=>e.name.toLowerCase().includes(`openrouter`)&&(e.chatModels?.length??0)>0)||i.find(e=>e.name.toLowerCase().includes(`anyapi`)&&(e.chatModels?.length??0)>0)||i.find(e=>e.name.toLowerCase().includes(`nvidia`)&&(e.chatModels?.length??0)>0)||i.find(e=>(e.chatModels?.length??0)>0),!a){t(!0);return}r=a.id;let o=a.chatModels.find(e=>e.key===n);if(o||(a.name.toLowerCase().includes(`openrouter`)&&(o=a.chatModels.find(e=>e.key===`openrouter/free`)),!o&&a.name.toLowerCase().includes(`openrouter`)&&(o=a.chatModels.find(e=>e.key===`nvidia/nemotron-3-super-120b-a12b:free`)),!o&&a.name.toLowerCase().includes(`anyapi`)&&(o=a.chatModels.find(e=>e.key===`deepseek/deepseek-v3:free`)),o||=a.chatModels.find(e=>(e.key.toLowerCase().includes(`nemotron-3-super`)||e.name.toLowerCase().includes(`nemotron 3 super`))&&e.key.toLowerCase().includes(`120b`)),o||=a.chatModels.find(e=>e.key.toLowerCase().includes(`nemotron`)||e.name.toLowerCase().includes(`nemotron`)),o||=a.chatModels[0]),!o){t(!0);return}n=o.key,localStorage.setItem(`chatModelKey`,n),localStorage.setItem(`chatModelProviderId`,r),e({key:n,providerId:r}),t(!0)}catch(e){console.error(`An error occurred while checking the configuration:`,e),u.toast.error(`Could not load AI providers: ${e?.message??String(e)}`),t(!0)}},N=`qwksearch_guest_chats`,P=typeof window<`u`;function F(){if(!P)return[];try{let e=localStorage.getItem(N);return e?JSON.parse(e).sort((e,t)=>new Date(t.createdAt).getTime()-new Date(e.createdAt).getTime()):[]}catch(e){return console.error(`Failed to get guest chats:`,e),[]}}function I(e){return P&&F().find(t=>t.id===e)||null}function L(e){if(P)try{let t=F(),n=t.findIndex(t=>t.id===e.id);n>=0?t[n]=e:t.push(e),localStorage.setItem(N,JSON.stringify(t))}catch(e){console.error(`Failed to save guest chat:`,e)}}function R(e){if(P)try{let t=F().filter(t=>t.id!==e);localStorage.setItem(N,JSON.stringify(t))}catch(e){console.error(`Failed to delete guest chat:`,e)}}function z(){if(P)try{localStorage.removeItem(N)}catch(e){console.error(`Failed to clear guest chats:`,e)}}function B(e,t){if(!P)return;let n=I(e);n&&(n.title=t,L(n))}var V=async(e,t,n,r,i,a,o,s,c)=>{if(!t){let t=I(e);if(t){n(t.messages);let e=t.messages.filter(e=>e.role===`user`||e.role===`assistant`),o=e.map(e=>[e.role,e.content]);e.length>0&&(document.title=e[0].content),s(t.files||[]),c((t.files||[]).map(e=>e.fileId)),i(o),a(t.focusMode),r(!0);return}try{let{data:t,error:l}=await(0,f.getChatById)({path:{id:e}});if(l){let e=l.status;if(e===404||e===403){o(!0),r(!0);return}throw Error(`Failed to load chat: ${l.message}`)}let{messages:u,chat:d}=t||{};if(!u||!d){o(!0),r(!0);return}n(u);let p=u.filter(e=>e.role===`user`||e.role===`assistant`),m=p.map(e=>[e.role,e.content]);p.length>0&&(document.title=p[0].content);let h=d.files.map(e=>({fileName:e.name,fileExtension:e.name.split(`.`).pop(),fileId:e.fileId}));s(h),c(h.map(e=>e.fileId)),i(m),a(d.focusMode),r(!0);return}catch(e){console.error(`[chatMessages] Failed to load public chat:`,e),o(!0),r(!0);return}}try{let{data:t,error:l}=await(0,f.getChatById)({path:{id:e}});if(l){let e=l.status;if(e===404||e===401||e===403){o(!0),r(!0);return}throw Error(`Failed to load chat: ${l.message}`)}let{messages:u,chat:d}=t||{};if(!u||!d){o(!0),r(!0);return}n(u);let p=u.filter(e=>e.role===`user`||e.role===`assistant`),m=p.map(e=>[e.role,e.content]);console.debug(new Date,`app:messages_loaded`),p.length>0&&(document.title=p[0].content);let h=d.files.map(e=>({fileName:e.name,fileExtension:e.name.split(`.`).pop(),fileId:e.fileId}));s(h),c(h.map(e=>e.fileId)),i(m),a(d.focusMode),r(!0)}catch(e){console.error(`[chatMessages] Failed to load chat:`,e),o(!0),r(!0)}},H=e=>{let t=[];return e.forEach((n,r)=>{if(n.role===`user`){let i=e.findIndex((e,t)=>t>r&&e.role===`user`),a=e.find((e,t)=>t>r&&e.role===`assistant`&&(i===-1||t<i)),o=e.find((e,t)=>t>r&&e.role===`source`&&e.sources&&(i===-1||t<i)),s=e.find((e,t)=>t>r&&e.role===`searching`&&(i===-1||t<i)),c=!1,l=a?.content??``,u=a?.content??``,d=[];if(a){let t=/\[([^\]]+)\]/g,n=/\[(\d+)\]/g;if(l.includes(`<think>`)){let e=l.match(/<think>/g)?.length||0,t=l.match(/<\/think>/g)?.length||0;e&&!t&&(l+=`</think> <a> </a>`)}a.content.includes(`</think>`)&&(c=!0),o&&o.sources&&o.sources.length>0?(l=l.replace(t,(e,t)=>t.split(`,`).map(e=>e.trim()).map(e=>{let t=parseInt(e);if(isNaN(t)||t<=0)return`[${e}]`;let n=(o.sources?.[t-1])?.metadata?.url;return n?`<citation href="${n}">${e}</citation>`:``}).join(``)),u=a.content.replace(n,``)):(l=l.replace(n,``),u=a.content.replace(n,``));let s=e.find((e,t)=>t>r&&e.role===`suggestion`&&(i===-1||t<i));s&&s.suggestions.length>0&&(d=s.suggestions)}t.push({userMessage:n,assistantMessage:a,sourceMessage:o,searchingMessage:s,parsedAssistantMessage:l,speechMessage:u,thinkingEnded:c,suggestions:d})}}),t},ee=async e=>{let t=localStorage.getItem(`chatModelKey`),n=localStorage.getItem(`chatModelProviderId`),r=parseInt(localStorage.getItem(`maxFollowupQuestions`)||`4`),i=localStorage.getItem(`followUpQuestionsPrompt`)?.trim()||void 0,a=e.filter(e=>e.role===`user`||e.role===`assistant`);try{let e=await(0,d.default)(`agent/suggestions`,{method:`POST`,body:JSON.stringify({chatHistory:a,chatModel:{providerId:n,key:t},maxQuestions:r,promptTemplate:i})});return Array.isArray(e.suggestions)?e.suggestions:[]}catch{return[]}},te=3,ne=`Analyze the uploaded file(s) and summarize the key points.`,U=()=>Array.from(crypto.getRandomValues(new Uint8Array(7)),e=>e.toString(16).padStart(2,`0`)).join(``),re=`sourceExtractionEnabled`,ie=`thinkingTimeLimit`;async function ae(e,n){let{message:r,messageId:i,rewrite:a=!1}=e,{chatId:o,loading:s,messages:c,fileIds:l,files:p,focusMode:m,category:h,optimizationMode:g,chatHistory:_,chatModelProvider:v,isAuthenticated:y,messagesRef:b,abortControllerRef:x,setLoading:S,setMessageAppeared:C,setMessages:w,setChatHistory:T,setChatModelProvider:E}=n,D=typeof window<`u`&&localStorage.getItem(re)===`true`,O=typeof window<`u`&&Number(localStorage.getItem(ie)??`0`)||0;if(s)return;let k=r?.trim()??``,A=Array.isArray(l)&&l.length>0;if(!k&&!A)return;let j=k?r:ne,M=new AbortController;if(x.current=M,S(!0),C(!1),c.length<=1&&!t.researchAgentUIConfig.onOpenChat){let e=new URL(window.location.href);e.searchParams.set(`chat`,o),window.history.replaceState(null,``,`${e.pathname}?${e.searchParams.toString()}${e.hash}`)}let N=``,P=!1,F=!1,I=[],L=Date.now(),R=O>0,z=``,B=``,V=i??U(),H=Array.isArray(p)?[...p]:[];w(e=>[...e,{content:j,messageId:V,chatId:o,role:`user`,createdAt:new Date,...H.length>0?{files:H}:{}}]);let ae=e=>{w(t=>[...t,{content:`⚠️ **The response failed:** ${e}`,messageId:U(),chatId:o,role:`assistant`,createdAt:new Date}]),C(!0)},W=async e=>{if(e.type===`error`){let t=e.data;typeof t==`string`&&(t.includes(`no longer available`)||t.includes(`deprecated`)||t.includes(`410`))&&(localStorage.removeItem(`chatModelKey`),localStorage.removeItem(`chatModelProviderId`),E?.({key:``,providerId:``})),u.toast.error(t),ae(t),S(!1)}else{if(e.type===`searching`){let t=e.data;w(n=>{let r=n.findIndex(t=>t.messageId===e.messageId&&t.role===`searching`);return r===-1?[...n,{role:`searching`,messageId:e.messageId,chatId:o,createdAt:new Date,queries:[{query:t.query,category:t.category,status:t.status}]}]:n.map((e,n)=>{if(n!==r)return e;let i=e,a=i.queries.findIndex(e=>e.query===t.query);if(a===-1)return{...i,queries:[...i.queries,{query:t.query,category:t.category,status:t.status}]};let o=i.queries.map((e,n)=>n===a?{...e,status:t.status}:e);return{...i,queries:o}})})}if(e.type===`sources`&&(I=e.data||[],w(t=>[...t,{messageId:e.messageId,chatId:o,role:`source`,sources:I,createdAt:new Date}]),I.length>0&&(C(!0),I.slice(0,te).forEach(e=>{let t=e?.metadata?.url;t&&t!==`File`&&(0,d.default)(`doc/article?url=${encodeURIComponent(t)}`).catch(()=>{})}))),e.type===`message`&&(N+=e.data,R?(z+=e.data,B||=e.messageId,P=!0):P?w(t=>t.map(t=>t.messageId===e.messageId&&t.role===`assistant`?{...t,content:t.content+e.data}:t)):(w(t=>[...t,{content:e.data,messageId:e.messageId,chatId:o,role:`assistant`,createdAt:new Date}]),P=!0,C(!0))),e.type===`messageEnd`){let e=async()=>{R&&z&&(w(e=>[...e,{content:z,messageId:B,chatId:o,role:`assistant`,createdAt:new Date}]),C(!0)),T(e=>[...e,[`human`,j],[`assistant`,N]]),S(!1);let e=b.current[b.current.length-1];if(t.researchAgentUIConfig.getAutoMediaSearch()&&(document.getElementById(`search-images-${e.messageId}`)?.click(),document.getElementById(`search-videos-${e.messageId}`)?.click()),!F){F=!0;let e=await ee(b.current),t=U();if(w(n=>[...n,{role:`suggestion`,suggestions:e,chatId:o,createdAt:new Date,messageId:t}]),y&&e.length>0)try{await(0,f.saveMessage)({body:{chatId:o,messageId:t,role:`suggestion`,suggestions:e}})}catch(e){console.error(`Failed to save suggestions:`,e)}}};if(R){let e=Date.now()-L,t=O*1e3-e;t>0&&await new Promise(e=>setTimeout(e,t))}await e()}}},G=c.findIndex(e=>e.messageId===V);try{let{stream:e}=await(0,f.agentChat)({signal:M.signal,body:{message:{messageId:V,chatId:o,content:j},optimizationMode:g,focusMode:m,category:h,history:a?_.slice(0,G===-1?void 0:G):_,files:l,chatModel:{key:v.key,providerId:v.providerId},sourceExtractionEnabled:D,thinkingTimeLimit:O,systemInstructions:localStorage.getItem(`systemInstructions`)??void 0,queryExpansionPrompt:localStorage.getItem(`queryExpansionPrompt`)??void 0,queryExpansionEnabled:localStorage.getItem(`queryExpansionEnabled`)===`true`},sseMaxRetryAttempts:1,onSseError:e=>{let t=e instanceof Error?e.message:String(e);t.includes(`401`)&&y?(u.toast.error(`Your session has expired. Please sign in again.`),S(!1),window.location.href=`/`):(u.toast.error(`Failed to send message. Please try again.`),ae(`${t}. Please try again.`),S(!1))}});for await(let t of e)await W(t)}catch(e){if(e.name===`AbortError`){R&&z&&(w(e=>[...e,{content:z,messageId:B,chatId:o,role:`assistant`,createdAt:new Date}]),C(!0)),N&&T(e=>[...e,[`human`,j],[`assistant`,N]]),S(!1),x.current=null;return}throw e}x.current=null}function W(e){let[t,n]=(0,i.useState)(e),[r,a]=(0,i.useState)(!1),[o,s]=(0,i.useState)(!1),[c,l]=(0,i.useState)(!1),[u,d]=(0,i.useState)(!1),[f,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(!1),[g,_]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),[b,x]=(0,i.useState)([]),[S,C]=(0,i.useState)([]),[w,T]=(0,i.useState)([]),[E,D]=(0,i.useState)([]),[O,k]=(0,i.useState)(`webSearch`),[A,j]=(0,i.useState)(`general`),[M,N]=(0,i.useState)(`speed`),[P,F]=(0,i.useState)({key:``,providerId:``}),I=(0,i.useRef)([]),L=(0,i.useMemo)(()=>S.filter(e=>e.role===`user`||e.role===`assistant`),[S]),R=(0,i.useMemo)(()=>H(S),[S]);return{state:{chatId:t,newChatCreated:r,loading:o,messageAppeared:c,chatHistory:b,messages:S,files:w,fileIds:E,focusMode:O,category:A,optimizationMode:M,isMessagesLoaded:u,notFound:v,chatModelProvider:P,isConfigReady:f,hasError:m,isReady:g},setters:{setChatId:n,setNewChatCreated:a,setLoading:s,setMessageAppeared:l,setChatHistory:x,setMessages:C,setFiles:T,setFileIds:D,setFocusMode:k,setCategory:j,setOptimizationMode:N,setIsMessagesLoaded:d,setNotFound:y,setChatModelProvider:F,setIsConfigReady:p,setHasError:h,setIsReady:_},messagesRef:I,chatTurns:L,sections:R}}var G=async(e,t)=>{let n=localStorage.getItem(`chatModelKey`),r=localStorage.getItem(`chatModelProviderId`),i=t.filter(e=>e.role===`user`||e.role===`assistant`).map(e=>({role:e.role,content:e.content??``}));if(i.length===0)return``;try{let t=await(0,d.default)(`agent/chat-title`,{method:`POST`,body:JSON.stringify({chatId:e,chatHistory:i,chatModel:{providerId:r,key:n}})});return typeof t.title==`string`?t.title:``}catch{return``}};function oe({children:e}){let t=(0,a.useParams)(),r=(0,a.useSearchParams)(),s=(0,a.useRouter)(),c=r.get(`q`),{isAuthenticated:l,isLoading:d}=n.c(),{state:p,setters:m,messagesRef:h,chatTurns:g,sections:_}=W(t.chatId),v=(0,i.useRef)(null),[y,b]=(0,i.useState)(!1),x=(0,i.useRef)({}),S=(0,i.useRef)(new Set);(0,i.useEffect)(()=>{M(m.setChatModelProvider,m.setIsConfigReady,m.setHasError)},[]),(0,i.useEffect)(()=>{t.chatId&&t.chatId!==p.chatId&&(m.setChatId(t.chatId),m.setMessages([]),m.setChatHistory([]),m.setFiles([]),m.setFileIds([]),m.setIsMessagesLoaded(!1),m.setNotFound(!1),m.setNewChatCreated(!1))},[t.chatId,p.chatId]),(0,i.useEffect)(()=>{if(p.chatId&&!p.newChatCreated&&!p.isMessagesLoaded&&p.messages.length===0){if(d)return;V(p.chatId,l,m.setMessages,m.setIsMessagesLoaded,m.setChatHistory,m.setFocusMode,m.setNotFound,m.setFiles,m.setFileIds)}else p.chatId||(m.setNewChatCreated(!0),m.setIsMessagesLoaded(!0),m.setChatId(crypto.randomUUID()))},[p.chatId,p.isMessagesLoaded,p.newChatCreated,p.messages.length,l,d]),(0,i.useEffect)(()=>{if(!y&&!l&&p.chatId&&p.messages.length>0){let e=p.messages.filter(e=>e.role===`user`||e.role===`assistant`);if(e.length>0){let t=x.current[p.chatId]??e[0].content.slice(0,50);L({id:p.chatId,title:t,createdAt:new Date().toISOString(),focusMode:p.focusMode,files:p.files,messages:p.messages})}}},[p.messages,p.chatId,l,p.focusMode,p.files]),(0,i.useEffect)(()=>{if(y||!p.chatId||!p.isMessagesLoaded||!p.newChatCreated||p.loading||g.filter(e=>e.role===`user`).length<2)return;let e=p.chatId;S.current.has(e)||(S.current.add(e),(async()=>{let t=await G(e,p.messages);t?(x.current[e]=t,l||B(e,t)):S.current.delete(e)})())},[g,p.messages,p.chatId,p.loading,p.isMessagesLoaded,p.newChatCreated,y,l]),(0,i.useEffect)(()=>{h.current=p.messages},[p.messages]),(0,i.useEffect)(()=>{p.isMessagesLoaded&&p.isConfigReady?(m.setIsReady(!0),console.debug(new Date,`app:ready`)):m.setIsReady(!1)},[p.isMessagesLoaded,p.isConfigReady]),(0,i.useEffect)(()=>{p.isReady&&c&&p.isConfigReady&&C(c)},[p.isConfigReady,p.isReady,c]);let C=(0,i.useCallback)(async(e,t,n=!1)=>{p.chatId&&await ae({message:e,messageId:t,rewrite:n},{chatId:p.chatId,loading:p.loading,messages:p.messages,fileIds:p.fileIds,files:p.files,focusMode:p.focusMode,category:p.category,optimizationMode:p.optimizationMode,chatHistory:p.chatHistory,chatModelProvider:p.chatModelProvider,isAuthenticated:l,messagesRef:h,abortControllerRef:v,setLoading:m.setLoading,setMessageAppeared:m.setMessageAppeared,setMessages:m.setMessages,setChatHistory:m.setChatHistory,setChatModelProvider:m.setChatModelProvider})},[p.chatId,p.loading,p.messages,p.fileIds,p.files,p.focusMode,p.category,p.optimizationMode,p.chatHistory,p.chatModelProvider,l,h]),w=(0,i.useCallback)(e=>{let t=p.messages.findIndex(t=>t.messageId===e),n=g.findIndex(t=>t.messageId===e);if(t===-1)return;let r=g[n-1];m.setMessages(e=>[...e.slice(0,p.messages.length>2?p.messages.indexOf(r):0)]),m.setChatHistory(e=>[...e.slice(0,g.length>2?n-1:0)]),C(r.content,r.messageId,!0)},[p.messages,g,C]),T=(0,i.useCallback)(async e=>{m.setFiles(p.files.filter(t=>t.fileId!==e)),m.setFileIds(p.fileIds.filter(t=>t!==e)),m.setMessages(t=>t.map(t=>{if(t.role!==`user`)return t;let n=t;return n.files?.some(t=>t.fileId===e)?{...n,files:n.files.filter(t=>t.fileId!==e)}:t}));try{let{error:t}=await(0,f.deleteUploadedFile)({query:{fileId:e}});if(t)throw Error(t.message??`Delete failed`)}catch(e){console.error(`[ChatProvider] Failed to delete uploaded file:`,e),u.toast.error(`Removed from the chat, but the file could not be deleted from storage.`)}},[p.files,p.fileIds]),E=(0,i.useCallback)(()=>{v.current&&=(v.current.abort(),null)},[]),D=(0,i.useCallback)(()=>{E(),m.setMessages([]),m.setChatHistory([]),m.setFiles([]),m.setFileIds([]),m.setChatId(void 0),m.setNewChatCreated(!1),m.setIsMessagesLoaded(!1),m.setNotFound(!1),s.push(`/`)},[E,s]),O=(0,i.useCallback)(e=>{E(),m.setMessages([]),m.setChatHistory([]),m.setFiles([]),m.setFileIds([]),m.setNotFound(!1),m.setNewChatCreated(!0),m.setIsMessagesLoaded(!0),m.setChatId(e)},[E]),k=(0,i.useCallback)(e=>{e!==p.chatId&&(E(),m.setMessages([]),m.setChatHistory([]),m.setFiles([]),m.setFileIds([]),m.setIsMessagesLoaded(!1),m.setNotFound(!1),m.setNewChatCreated(!1),m.setChatId(e))},[E,p.chatId]),A={messages:p.messages,chatTurns:g,sections:_,chatHistory:p.chatHistory,files:p.files,fileIds:p.fileIds,focusMode:p.focusMode,category:p.category,chatId:p.chatId,hasError:p.hasError,isMessagesLoaded:p.isMessagesLoaded,isReady:p.isReady,loading:p.loading,messageAppeared:p.messageAppeared,notFound:p.notFound,optimizationMode:p.optimizationMode,chatModelProvider:p.chatModelProvider,incognito:y,setFileIds:m.setFileIds,setFiles:m.setFiles,deleteAttachedFile:T,setFocusMode:m.setFocusMode,setCategory:m.setCategory,setOptimizationMode:m.setOptimizationMode,rewrite:w,sendMessage:C,setChatModelProvider:m.setChatModelProvider,stopStreaming:E,newChat:D,startNewChat:O,switchToChat:k,setIncognito:b};return(0,o.jsx)(n.l.Provider,{value:A,children:e})}function se(){return typeof window>`u`?!1:!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function ce(e,t,n={}){let[r,a]=(0,i.useState)(!1),[o,s]=(0,i.useState)(``),[c,l]=(0,i.useState)(``),[f,m]=(0,i.useState)(0),h=(0,i.useRef)(null),g=(0,i.useRef)(null),_=(0,i.useRef)([]),v=(0,i.useRef)({onTranscript:e,onEnd:t,onPartial:n.onPartial});v.current={onTranscript:e,onEnd:t,onPartial:n.onPartial};let y=(0,i.useMemo)(()=>new p.LiveTranscriber({engine:`webspeech`,language:n.language??`en-US`,onStateChange:a,onPartial:e=>{s(e),e&&(l(e),m(e=>e+1)),v.current.onPartial?.(e)},onCommit:e=>{s(``),l(e),m(e=>e+1),v.current.onTranscript(e)},onError:()=>{u.toast.error(`Speech recognition stopped unexpectedly.`)}}),[n.language]),b=(0,i.useCallback)(()=>{let e=h.current;e&&e.state!==`inactive`?e.stop():(g.current?.getTracks().forEach(e=>e.stop()),g.current=null,h.current=null)},[]),x=async e=>{let t=new FormData;return t.append(`file`,e,`speech-input.webm`),t.append(`languageCode`,`en`),((await(0,d.default)(`agent/transcript`,{method:`POST`,body:t}))?.text??``).trim()},S=(0,i.useCallback)(async()=>{if(typeof navigator>`u`||!navigator.mediaDevices?.getUserMedia||typeof MediaRecorder>`u`)u.toast.error(`Speech input is not supported in this browser`,{duration:5e3}),a(!1),v.current.onEnd();else try{let e=await navigator.mediaDevices.getUserMedia({audio:!0}),t=new MediaRecorder(e);_.current=[],g.current=e,h.current=t,t.ondataavailable=e=>{e.data.size>0&&_.current.push(e.data)},t.onstart=()=>{a(!0)},t.onstop=async()=>{try{let e=new Blob(_.current,{type:`audio/webm`});if(_.current=[],g.current?.getTracks().forEach(e=>e.stop()),g.current=null,h.current=null,a(!1),e.size===0)return;let t=await x(e);t?(l(t),m(e=>e+1),v.current.onTranscript(t)):u.toast.error(`No speech detected. Please try again.`)}catch{u.toast.error(`Unable to transcribe audio.`)}finally{v.current.onEnd()}},t.start()}catch{u.toast.error(`Microphone access is required for speech input.`),a(!1),v.current.onEnd()}},[]),C=(0,i.useCallback)(async()=>{y.isListening()?(await y.stop(),s(``),v.current.onEnd()):h.current?b():se()?await y.start():await S()},[y,S,b]);(0,i.useEffect)(()=>{let e=e=>{e.ctrlKey&&e.key==="`"&&(e.preventDefault(),C())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C]),(0,i.useEffect)(()=>()=>{y.stop(),b()},[y,b]);let w=typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<`u`;return{isListening:r,toggleSpeech:C,isSpeechSupported:se()||w,partial:o,lastPhrase:c,phraseId:f}}var le=`voiceAutoStart`,ue=`voiceAutoStartTriggered`,de=typeof window<`u`;function fe(){return de?localStorage.getItem(le)===`true`:!1}function pe(e){de&&localStorage.setItem(le,String(e))}function me(){de&&localStorage.setItem(ue,`true`)}function he({enabled:e,isSpeechSupported:t,isListening:n},r){return e&&t&&!n&&!r}function ge(){return de?localStorage.getItem(ue)===`true`:!1}function _e({isSpeechSupported:e,isListening:t,toggleSpeech:n}){(0,i.useEffect)(()=>{he({enabled:fe(),isSpeechSupported:e,isListening:t},ge())&&(me(),n())},[e])}var ve=[`pdf`,`docx`,`txt`,`md`,`html`,`htm`],ye=[`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`avif`],be=[...ve,...ye],xe=10,Se=52428800,Ce=(e,t)=>{if(e&&typeof e==`object`){let t=e.message??e.error??e.data?.message;if(typeof t==`string`&&t.length>0)return t}return typeof e==`string`&&e.length>0?e:t};function we({setMessage:e,contextFiles:t,contextFileIds:n,setContextFiles:r,setContextFileIds:a}){let[o,s]=(0,i.useState)([]),[c,l]=(0,i.useState)([]),[d,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(!1),g=(0,i.useCallback)(async e=>{let i=Array.from(e);i.length>xe&&(u.toast.error(`You can attach up to ${xe} files at a time.`),i=i.slice(0,xe));let o=i.filter(e=>e.size>Se);if(o.length>0&&(u.toast.error(`${o.map(e=>e.name).join(`, `)} exceed${o.length===1?`s`:``} the 50 MB per-file limit.`),i=i.filter(e=>e.size<=Se)),i.length===0)return;let c=i.map(e=>{let t=e.type.startsWith(`image/`)||/\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.name),n=e.name.split(`.`).pop()?.toLowerCase()??``,r=be.includes(n);return{id:Math.random().toString(36).substr(2,9),file:e,type:t?`image/unknown`:e.type||`application/octet-stream`,preview:t?URL.createObjectURL(e):null,uploadStatus:r?`uploading`:`pending`,_ext:n}});s(e=>[...e,...c]),c.filter(e=>!be.includes(e._ext)).forEach(e=>{setTimeout(()=>{s(t=>t.map(t=>t.id===e.id?{...t,uploadStatus:`complete`}:t))},600+Math.random()*600)});let l=c.filter(e=>be.includes(e._ext));if(l.length!==0)try{let{data:e,error:i}=await(0,f.uploadFiles)({body:{files:l.map(e=>e.file)}});if(i||!e?.files)throw Error(Ce(i??e,`Upload failed.`));s(e=>e.map(e=>l.some(t=>t.id===e.id)?{...e,uploadStatus:`complete`}:e)),r([...t,...e.files]),a([...n,...e.files.map(e=>e.fileId)])}catch(e){u.toast.error(Ce(e,`Failed to upload files.`)),s(e=>e.map(e=>l.some(t=>t.id===e.id)?{...e,uploadStatus:`error`}:e))}},[e,t,n,r,a]);return{files:o,setFiles:s,pastedContent:c,setPastedContent:l,isDragging:d,isExtractingUrl:m,handleFiles:g,extractUrl:(0,i.useCallback)(async e=>{let i=e.trim();if(!/^https?:\/\//i.test(i))return u.toast.error(`Enter a valid http(s) URL.`),!1;h(!0);try{let e=await(await fetch(`/api/doc/uploads`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:i})})).json();if(!e?.files||e.files.length===0)throw Error(Ce(e,`Could not extract content from ${i}`));return r([...t,...e.files]),a([...n,...e.files.map(e=>e.fileId)]),u.toast.success(`Added "${e.files[0].fileName}" as context.`),!0}catch(e){return u.toast.error(Ce(e,`Failed to extract URL.`)),!1}finally{h(!1)}},[t,n,r,a]),onDragOver:e=>{e.preventDefault(),p(!0)},onDragLeave:e=>{e.preventDefault(),p(!1)},onDrop:e=>{e.preventDefault(),p(!1),e.dataTransfer.files&&g(e.dataTransfer.files)},handlePaste:e=>{let t=e.clipboardData.items,n=[];for(let e=0;e<t.length;e++)if(t[e].kind===`file`){let r=t[e].getAsFile();r&&n.push(r)}if(n.length>0){e.preventDefault(),g(n);return}let r=e.clipboardData.getData(`text`);if(r.length>300){e.preventDefault();let t={id:Math.random().toString(36).substr(2,9),content:r,timestamp:new Date};l(e=>[...e,t])}},resetAttachments:()=>{s([]),l([]),r([]),a([])}}}function Te({...e}){return(0,o.jsx)(h.Root,{"data-slot":`dropdown-menu`,...e})}function Ee({...e}){return(0,o.jsx)(h.Trigger,{"data-slot":`dropdown-menu-trigger`,...e})}function De({className:e,sideOffset:t=4,...n}){return(0,o.jsx)(h.Portal,{children:(0,o.jsx)(h.Content,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:r.o(`bg-card text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-2xl border p-1 shadow-md`,e),...n})})}function K({className:e,inset:t,variant:n=`default`,...i}){return(0,o.jsx)(h.Item,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:r.o(`focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-2xl px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...i})}function Oe({className:e,children:t,checked:n,...i}){return(0,o.jsxs)(h.CheckboxItem,{"data-slot":`dropdown-menu-checkbox-item`,className:r.o(`focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-2xl py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),checked:n,...i,children:[(0,o.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,o.jsx)(h.ItemIndicator,{children:(0,o.jsx)(l.CheckIcon,{className:`size-4`})})}),t]})}function ke({className:e,inset:t,...n}){return(0,o.jsx)(h.Label,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:r.o(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function q({className:e,...t}){return(0,o.jsx)(h.Separator,{"data-slot":`dropdown-menu-separator`,className:r.o(`bg-border -mx-1 my-1 h-px`,e),...t})}function J({...e}){return(0,o.jsx)(h.Sub,{"data-slot":`dropdown-menu-sub`,...e})}function Y({className:e,inset:t,children:n,...i}){return(0,o.jsxs)(h.SubTrigger,{"data-slot":`dropdown-menu-sub-trigger`,"data-inset":t,className:r.o(`focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-2xl px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8`,e),...i,children:[n,(0,o.jsx)(l.ChevronRightIcon,{className:`ml-auto size-4`})]})}function X({className:e,...t}){return(0,o.jsx)(h.SubContent,{"data-slot":`dropdown-menu-sub-content`,className:r.o(`bg-card text-popover-foreground 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 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-2xl border p-1 shadow-lg`,e),...t})}var Ae=()=>window.gapi,je=()=>window.google,Me=null;function Ne(e){return new Promise((t,n)=>{let r=document.createElement(`script`);r.src=e,r.async=!0,r.onload=()=>t(),r.onerror=()=>n(Error(`Failed to load ${e}`)),document.body.appendChild(r)})}function Pe(){if(Ae()&&je()?.picker)return Promise.resolve();if(!Me){let e=(Ae()?Promise.resolve():Ne(`https://apis.google.com/js/api.js`)).then(()=>new Promise(e=>Ae().load(`client:picker`,()=>e()))),t=je()?.picker?Promise.resolve():Ne(`https://www.google.com/jsapi`);Me=Promise.all([e,t]).then(()=>void 0),Me.catch(()=>{Me=null})}return Me}var Fe=()=>({openPicker:async(e,n,r)=>{try{await Pe()}catch{r?.(`Google Picker API could not be loaded. Please try again.`);return}let i=je();if(!i?.picker)r?.(`Google Picker API not loaded yet. Please try again.`);else try{let{picker:r}=i,a=new r.PickerBuilder().addView(r.ViewId.DOCS).addView(r.ViewId.DOCS_IMAGES).addView(r.ViewId.DOCS_VIDEOS).addView(new r.DocsView().setIncludeFolders(!0).setMimeTypes(`application/pdf,application/vnd.google-apps.document,application/vnd.google-apps.spreadsheet,text/plain,image/jpeg,image/png`)).setOAuthToken(e).setDeveloperKey(t.researchAgentUIConfig.googleApiKey);t.researchAgentUIConfig.googleAppId&&a.setAppId(t.researchAgentUIConfig.googleAppId),a.setCallback(e=>{if(e.action===r.Action.PICKED){let t=e.docs;t&&n(t)}else e.action===r.Action.CANCEL&&console.log(`User cancelled picker`)}).build().setVisible(!0)}catch(e){r?.(e.message||`Failed to open Google Picker`)}}});function Ie(e){return(0,o.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 214.6279 198.1416`,...e,children:[(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{fill:`#5CB0FF`,d:`M171.748,142.3193c0-15.4375-12.5625-28-28-28s-28,12.5625-28,28s12.5625,28,28,28 S171.748,157.7568,171.748,142.3193z`}),(0,o.jsx)(`path`,{fill:`#1C71DA`,d:`M95.748,166.3193v-76h42.989c0.0146,0.7878,0.0696,1.5579,0.0696,2.3516c0,2.2109,1.7891,4,4,4 s4-1.7891,4-4c0-0.7937-0.0603-1.5632-0.0745-2.3516h25.0159h5.6484h2.3516c0-46.3164-37.6836-84-84-84h-8v0.4053 c-42.5754,4.0447-76,39.9785-76,83.5947c0,46.3164,37.6836,84,84,84c2.2109,0,4-1.7891,4-4S97.959,166.3193,95.748,166.3193z M87.748,164.9949c-19.9287-6.438-35.0586-36.3945-35.0586-72.324c0-0.7937,0.0549-1.5637,0.0696-2.3516h34.989V164.9949z M53.1655,82.3193C55.75,51.1135,69.7729,26.157,87.748,20.3506v61.9688H53.1655z M95.748,82.3193v-63.293 c21.6829,0,39.6248,27.5808,42.5825,63.293H95.748z M171.3181,82.3193h-24.9685c-2.3884-29.9812-14.96-54.8911-31.9993-65.6013 C144.7681,24.4146,167.9641,50.417,171.3181,82.3193z M77.1458,16.718C60.1064,27.4282,47.5349,52.3381,45.1465,82.3193H20.178 C23.532,50.417,46.728,24.4146,77.1458,16.718z M19.748,90.3193h25.0159c-0.0142,0.7883-0.0745,1.5579-0.0745,2.3516 c0,28.5327,9.217,53.6572,23.1233,68.2603C39.7031,149.769,19.748,122.3567,19.748,90.3193z`}),(0,o.jsx)(`path`,{fill:`#1C71DA`,d:`M191.5137,184.4287l-19.665-19.665c4.9307-6.1609,7.8994-13.9573,7.8994-22.4443 c0-19.8516-16.1484-36-36-36s-36,16.1484-36,36s16.1484,36,36,36c8.4871,0,16.2834-2.9688,22.4443-7.8994l19.665,19.665 L191.5137,184.4287z M115.748,142.3193c0-15.4375,12.5625-28,28-28s28,12.5625,28,28s-12.5625,28-28,28 S115.748,157.7568,115.748,142.3193z`})]}),(0,o.jsx)(`path`,{fill:`#FF5D5D`,d:`M4,22.1416c-1.0234,0-2.0479-0.3906-2.8281-1.1719c-1.5625-1.5615-1.5625-4.0947,0-5.6562L15.3145,1.1719 c1.5625-1.5625,4.0957-1.5625,5.6562,0c1.5625,1.5615,1.5625,4.0947,0,5.6562L6.8281,20.9697 C6.0469,21.751,5.0234,22.1416,4,22.1416z`}),(0,o.jsx)(`path`,{fill:`#FF5D5D`,d:`M18.1426,22.1416c-1.0234,0-2.0469-0.3906-2.8281-1.1719L1.1719,6.8281 c-1.5625-1.5615-1.5625-4.0947,0-5.6562c1.5605-1.5625,4.0938-1.5625,5.6562,0l14.1426,14.1416 c1.5625,1.5615,1.5625,4.0947,0,5.6562C20.1904,21.751,19.166,22.1416,18.1426,22.1416z`}),(0,o.jsx)(`path`,{fill:`#00D40B`,d:`M14,198.1416c-7.7197,0-14-6.2803-14-14s6.2803-14,14-14s14,6.2803,14,14S21.7197,198.1416,14,198.1416z M14,178.1416c-3.3086,0-6,2.6914-6,6s2.6914,6,6,6s6-2.6914,6-6S17.3086,178.1416,14,178.1416z`}),(0,o.jsx)(`path`,{fill:`#FFC504`,d:`M199.3145,56.7695c-1.0605,0-2.0781-0.4219-2.8281-1.1719l-11.3145-11.3145 c-0.75-0.75-1.1719-1.7676-1.1719-2.8281s0.4219-2.0781,1.1719-2.8281l11.3145-11.3135c1.5625-1.5625,4.0938-1.5625,5.6562,0 l11.3135,11.3135c1.5625,1.5615,1.5625,4.0947,0,5.6562l-11.3135,11.3145C201.3926,56.3477,200.375,56.7695,199.3145,56.7695z M193.6572,41.4551l5.6572,5.6572l5.6572-5.6572l-5.6572-5.6572L193.6572,41.4551z`})]})}function Le(e){return(0,o.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 508 508`,...e,children:[(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M316.1,353.2H191.9c13.2,60.9,37.8,102.2,62.1,102.2C278.3,455.4,302.9,414.1,316.1,353.2z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M78.2,353.2c26.2,46.5,69.8,80.1,120.6,94.5c-15.4-22.5-27.7-54.7-35.7-94.5H78.2z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M429.8,353.2h-84.9c-8,39.8-20.4,72-35.7,94.5C360,433.4,403.6,399.7,429.8,353.2z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M429.3,154.8c-26.3-46.4-69.6-80-120-94.4c15.3,22.4,27.7,54.7,35.6,94.4H429.3z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M163.1,154.8c8-39.7,20.3-71.9,35.7-94.4c-50.4,14.4-93.8,48-120,94.4H163.1z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M479.8,310.9V197.1c0-7.8-6.3-14.1-14.1-14.1H42.3c-7.8,0-14.1,6.3-14.1,14.1v113.8 c0,7.8,6.3,14.1,14.1,14.1h423.3C473.4,325,479.8,318.7,479.8,310.9z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M254,52.6c-24.3,0-48.9,41.3-62.1,102.2h124.2C302.9,93.9,278.3,52.6,254,52.6z`})]}),(0,o.jsx)(`path`,{style:{fill:`#56ACE0`},d:`M254,426.5c-95.3,0-172.9-77.5-172.9-172.9S158.7,80.8,254,80.8s172.9,77.5,172.9,172.9 S349.3,426.5,254,426.5z`}),(0,o.jsx)(`rect`,{x:`56.4`,y:`211.2`,style:{fill:`#FFC10D`},width:`395.1`,height:`85.6`}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{style:{fill:`#194F82`},d:`M465.7,154.8H461C422.8,75.3,342.7,24.4,254,24.4S85.1,75.3,47,154.8h-4.7C19,154.8,0,173.7,0,197.1 v113.8c0,23.3,19,42.3,42.3,42.3h4.2c38,79.5,118.4,130.4,207.5,130.4c89.2,0,169.5-50.9,207.5-130.4h4.2c23.3,0,42.3-19,42.3-42.3 V197.1C508,173.7,489,154.8,465.7,154.8z M429.3,154.8h-84.4c-8-39.7-20.3-71.9-35.6-94.4C359.7,74.7,403,108.4,429.3,154.8z M254,52.6c24.3,0,48.9,41.3,62.1,102.2H191.9C205.1,93.9,229.7,52.6,254,52.6z M198.7,60.4c-15.3,22.4-27.7,54.7-35.7,94.4H78.7 C105,108.4,148.3,74.7,198.7,60.4z M78.2,353.2h84.9c8,39.8,20.4,72,35.7,94.5C148,433.4,104.4,399.7,78.2,353.2z M254,455.4 c-24.3,0-48.9-41.3-62.1-102.2h124.2C302.9,414.1,278.3,455.4,254,455.4z M309.2,447.7c15.4-22.5,27.7-54.7,35.7-94.5h84.9 C403.6,399.7,360,433.4,309.2,447.7z M479.8,310.9c0,7.8-6.3,14.1-14.1,14.1H42.3c-7.8,0-14.1-6.3-14.1-14.1V197.1 c0-7.8,6.3-14.1,14.1-14.1h423.3c7.8,0,14.1,6.3,14.1,14.1v113.8H479.8z`}),(0,o.jsx)(`polygon`,{style:{fill:`#194F82`},points:`146,265.7 109.1,215.3 93.4,215.3 93.4,293.6 110.2,293.6 110.2,244.5 146,293.6 162.7,293.6 162.7,215.3 146,215.3 `}),(0,o.jsx)(`polygon`,{style:{fill:`#194F82`},points:`197.9,261.9 231.6,261.9 231.6,247 197.9,247 197.9,230.9 235.3,230.9 235.3,215.3 181.2,215.3 181.2,293.6 236.5,293.6 236.5,278.1 197.9,278.1 `}),(0,o.jsx)(`polygon`,{style:{fill:`#194F82`},points:`318.9,260.3 305.7,215.3 288.1,215.3 274.8,260.3 260,215.3 241.9,215.3 268.1,293.6 280.5,293.6 296.8,239.2 313.3,293.6 325.7,293.6 351.9,215.3 333.8,215.3 `}),(0,o.jsx)(`path`,{style:{fill:`#194F82`},d:`M392,246.6c-8.2-1.9-16.5-3.8-16.6-10.2c0.5-5.4,3.9-7.5,9-7.6c6.9,0,13.7,2.6,20.2,7.7l8.5-12.8 c-8-6.2-17-10.4-28.1-10.3c-12.5-0.6-27,7.6-26.8,23.2c-1,15.4,10.4,21.4,25.2,24.8c9.2,2,14.5,5.1,13.9,9.8 c0.1,5.2-4.6,7.7-9.9,7.7c-6.9,0-14.3-3.7-22.4-11.1l-10,12.8c9.5,9.2,20.2,13.8,32.1,13.8c15.1,0.7,27.6-8.8,27.5-23.6 C414.8,257.3,406.3,250,392,246.6z`})]})]})}function Re(e){return(0,o.jsxs)(`svg`,{version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 512 512`,...e,children:[(0,o.jsx)(`circle`,{style:{fill:`#8AD5DD`},cx:`256`,cy:`256`,r:`256`}),(0,o.jsx)(`rect`,{id:`SVGCleanerId_0`,x:`115`,y:`68`,style:{fill:`#FFFFFF`},width:`282`,height:`376`}),(0,o.jsx)(`rect`,{id:`SVGCleanerId_1`,x:`146.336`,y:`339.8`,style:{fill:`#2D2D2D`},width:`97.696`,height:`8`}),(0,o.jsx)(`rect`,{id:`SVGCleanerId_2`,x:`146.336`,y:`371.12`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,o.jsx)(`rect`,{id:`SVGCleanerId_3`,x:`146.336`,y:`386.8`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,o.jsx)(`rect`,{id:`SVGCleanerId_4`,x:`146.336`,y:`402.48`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`}),(0,o.jsx)(`path`,{id:`SVGCleanerId_5`,style:{fill:`#DB2B42`},d:`M355.872,316.384H156.128c-6.464,0-11.752-5.288-11.752-11.752v-144.92 c0-6.464,5.288-11.752,11.752-11.752H355.88c6.464,0,11.752,5.288,11.752,11.752v144.92 C367.624,311.096,362.336,316.384,355.872,316.384z`}),(0,o.jsx)(`g`,{children:(0,o.jsx)(`rect`,{id:`SVGCleanerId_0_1_`,x:`115`,y:`68`,style:{fill:`#FFFFFF`},width:`282`,height:`376`})}),(0,o.jsx)(`g`,{children:(0,o.jsx)(`rect`,{id:`SVGCleanerId_1_1_`,x:`146.336`,y:`339.8`,style:{fill:`#2D2D2D`},width:`97.696`,height:`8`})}),(0,o.jsx)(`g`,{children:(0,o.jsx)(`rect`,{id:`SVGCleanerId_2_1_`,x:`146.336`,y:`371.12`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,o.jsx)(`g`,{children:(0,o.jsx)(`rect`,{id:`SVGCleanerId_3_1_`,x:`146.336`,y:`386.8`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,o.jsx)(`g`,{children:(0,o.jsx)(`rect`,{id:`SVGCleanerId_4_1_`,x:`146.336`,y:`402.48`,style:{fill:`#E0E0E0`},width:`97.696`,height:`8`})}),(0,o.jsx)(`g`,{children:(0,o.jsx)(`path`,{id:`SVGCleanerId_5_1_`,style:{fill:`#DB2B42`},d:`M355.872,316.384H156.128c-6.464,0-11.752-5.288-11.752-11.752v-144.92 c0-6.464,5.288-11.752,11.752-11.752H355.88c6.464,0,11.752,5.288,11.752,11.752v144.92 C367.624,311.096,362.336,316.384,355.872,316.384z`})}),(0,o.jsx)(`polygon`,{style:{fill:`#FFFFFF`},points:`232.496,191.472 303,232.176 232.496,272.88 `}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`rect`,{x:`269.928`,y:`339.04`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`}),(0,o.jsx)(`rect`,{x:`269.928`,y:`365.624`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`}),(0,o.jsx)(`rect`,{x:`269.928`,y:`392.24`,style:{fill:`#E0E0E0`},width:`97.696`,height:`19.016`})]}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`rect`,{x:`269.928`,y:`392.24`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`}),(0,o.jsx)(`rect`,{x:`269.928`,y:`365.624`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`}),(0,o.jsx)(`rect`,{x:`269.928`,y:`339.04`,style:{fill:`#2D2D2D`},width:`20.304`,height:`19.016`})]}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{style:{fill:`#E0E0E0`},d:`M365.664,100.072v19.616h-135.24v-19.616H365.664 M367.624,98.112h-139.16v23.536h139.16 L367.624,98.112L367.624,98.112z`}),(0,o.jsx)(`rect`,{x:`341.312`,y:`98.112`,style:{fill:`#E0E0E0`},width:`26.312`,height:`23.536`})]}),(0,o.jsx)(`path`,{style:{fill:`#DB2B42`},d:`M207.656,121.648H173.2c-1.312,0-2.384-1.072-2.384-2.384v-18.768c0-1.312,1.072-2.384,2.384-2.384 h34.456c1.312,0,2.384,1.072,2.384,2.384v18.768C210.04,120.576,208.96,121.648,207.656,121.648z`}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M178.008,107.264h-2.784v-1.488h7.384v1.488h-2.816v8.28h-1.784L178.008,107.264L178.008,107.264z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M189.28,113.424c0,0.84,0.032,1.544,0.056,2.12h-1.568l-0.088-1.08h-0.024 c-0.304,0.504-1,1.232-2.264,1.232c-1.288,0-2.464-0.768-2.464-3.072v-4.144h1.784v3.84c0,1.176,0.384,1.936,1.32,1.936 c0.712,0,1.176-0.504,1.36-0.96c0.064-0.16,0.104-0.344,0.104-0.552v-4.264h1.784V113.424z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M191.144,115.544c0.032-0.48,0.064-1.264,0.064-1.984v-8.312h1.784v4.2h0.032 c0.432-0.672,1.2-1.128,2.256-1.128c1.728,0,2.96,1.432,2.944,3.584c0,2.536-1.608,3.8-3.208,3.8c-0.912,0-1.728-0.352-2.232-1.216 h-0.032l-0.088,1.056H191.144z M192.992,112.632c0,0.152,0.016,0.288,0.04,0.424c0.192,0.712,0.808,1.256,1.584,1.256 c1.12,0,1.8-0.904,1.8-2.32c0-1.256-0.592-2.264-1.784-2.264c-0.72,0-1.376,0.528-1.584,1.304 c-0.024,0.128-0.056,0.288-0.056,0.464V112.632z`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M200.952,112.512c0.04,1.28,1.04,1.832,2.176,1.832c0.824,0,1.416-0.12,1.96-0.32l0.264,1.232 c-0.616,0.248-1.456,0.44-2.472,0.44c-2.288,0-3.64-1.408-3.64-3.576c0-1.952,1.192-3.8,3.448-3.8c2.296,0,3.048,1.888,3.048,3.44 c0,0.336-0.032,0.592-0.056,0.752C205.68,112.512,200.952,112.512,200.952,112.512z M204.056,111.264 c0.016-0.648-0.272-1.728-1.464-1.728c-1.104,0-1.568,1.008-1.64,1.728H204.056z`})]}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M147.464,115.544v-4.072l-3.088-5.696h2.032l1.176,2.504c0.336,0.728,0.584,1.28,0.848,1.944h0.024 c0.248-0.624,0.52-1.232,0.856-1.944l1.176-2.504h2.016l-3.248,5.656v4.112H147.464z`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M158.864,111.944c0,2.6-1.824,3.76-3.624,3.76c-2,0-3.536-1.376-3.536-3.632 c0-2.328,1.52-3.744,3.656-3.744C157.464,108.32,158.864,109.8,158.864,111.944z M153.544,112.024c0,1.36,0.664,2.392,1.752,2.392 c1.016,0,1.728-1,1.728-2.424c0-1.104-0.496-2.368-1.712-2.368C154.056,109.624,153.544,110.84,153.544,112.024z`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M166.656,113.424c0,0.84,0.032,1.544,0.056,2.12h-1.568l-0.088-1.08h-0.024 c-0.304,0.504-1,1.232-2.264,1.232c-1.288,0-2.464-0.768-2.464-3.072v-4.144h1.784v3.84c0,1.176,0.384,1.936,1.32,1.936 c0.712,0,1.176-0.504,1.36-0.96c0.064-0.16,0.104-0.344,0.104-0.552v-4.264h1.784V113.424z`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M353.936,113.776c-3.096,0-5.616-2.52-5.616-5.616s2.52-5.616,5.616-5.616s5.616,2.52,5.616,5.616 C359.552,111.256,357.032,113.776,353.936,113.776z M353.936,103.816c-2.392,0-4.344,1.952-4.344,4.344s1.952,4.344,4.344,4.344 s4.344-1.952,4.344-4.344S356.328,103.816,353.936,103.816z`}),(0,o.jsx)(`rect`,{x:`356.02`,y:`113.813`,transform:`matrix(-0.6044 -0.7967 0.7967 -0.6044 484.7665 469.5985)`,style:{fill:`#2D2D2D`},width:`5.896`,height:`1.272`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M240.088,113.168c0.48,0.296,1.184,0.544,1.92,0.544c1.096,0,1.736-0.576,1.736-1.416 c0-0.768-0.44-1.216-1.56-1.648c-1.352-0.48-2.192-1.184-2.192-2.352c0-1.296,1.072-2.248,2.68-2.248 c0.848,0,1.464,0.192,1.832,0.4l-0.296,0.872c-0.272-0.152-0.824-0.392-1.576-0.392c-1.136,0-1.56,0.672-1.56,1.24 c0,0.776,0.504,1.152,1.648,1.6c1.4,0.544,2.12,1.216,2.12,2.432c0,1.28-0.952,2.392-2.904,2.392c-0.8,0-1.68-0.24-2.12-0.528 L240.088,113.168z`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M246.984,111.688c0.024,1.472,0.96,2.064,2.048,2.064c0.776,0,1.24-0.128,1.648-0.304l0.184,0.776 c-0.384,0.176-1.032,0.368-1.984,0.368c-1.832,0-2.928-1.208-2.928-3s1.056-3.216,2.792-3.216c1.952,0,2.464,1.704,2.464,2.808 c0,0.216-0.024,0.392-0.04,0.496h-4.184V111.688z M250.16,110.92c0.016-0.688-0.288-1.76-1.504-1.76 c-1.096,0-1.576,1.008-1.664,1.76H250.16z`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M255.88,114.472l-0.088-0.752h-0.032c-0.336,0.472-0.968,0.888-1.824,0.888 c-1.208,0-1.824-0.848-1.824-1.704c0-1.448,1.28-2.232,3.584-2.216v-0.128c0-0.488-0.136-1.384-1.36-1.384 c-0.552,0-1.128,0.176-1.552,0.448l-0.248-0.72c0.488-0.312,1.208-0.528,1.96-0.528c1.824,0,2.264,1.24,2.264,2.432v2.232 c0,0.52,0.024,1.024,0.104,1.424h-0.984V114.472z M255.72,111.44c-1.184-0.024-2.528,0.184-2.528,1.336 c0,0.704,0.472,1.032,1.024,1.032c0.776,0,1.272-0.488,1.44-1c0.04-0.112,0.064-0.24,0.064-0.344V111.44z`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M258.552,110.376c0-0.704-0.016-1.304-0.056-1.864h0.944l0.04,1.176h0.04 c0.272-0.8,0.928-1.304,1.656-1.304c0.12,0,0.2,0.008,0.304,0.032v1.024c-0.112-0.024-0.224-0.032-0.368-0.032 c-0.768,0-1.312,0.576-1.456,1.392c-0.024,0.144-0.056,0.312-0.056,0.496v3.176h-1.072v-4.096H258.552z`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M266.72,114.256c-0.288,0.152-0.912,0.344-1.72,0.344c-1.792,0-2.968-1.216-2.968-3.04 c0-1.84,1.264-3.168,3.208-3.168c0.64,0,1.208,0.168,1.504,0.304l-0.248,0.84c-0.264-0.152-0.664-0.28-1.264-0.28 c-1.368,0-2.104,1.008-2.104,2.248c0,1.384,0.888,2.232,2.064,2.232c0.616,0,1.024-0.168,1.328-0.296L266.72,114.256z`}),(0,o.jsx)(`path`,{style:{fill:`#2D2D2D`},d:`M268.016,105.736h1.08v3.712h0.024c0.176-0.304,0.448-0.576,0.776-0.76 c0.312-0.184,0.704-0.304,1.104-0.304c0.808,0,2.08,0.488,2.08,2.544v3.544H272v-3.424c0-0.96-0.352-1.768-1.376-1.768 c-0.704,0-1.264,0.488-1.456,1.08c-0.064,0.152-0.08,0.304-0.08,0.52v3.6h-1.08v-8.744H268.016z`})]})]})}function ze(e){return(0,o.jsx)(`svg`,{width:`800px`,height:`800px`,viewBox:`0 0 73 73`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,...e,children:(0,o.jsx)(`g`,{id:`fundamentals/css/images`,stroke:`none`,strokeWidth:`1`,fill:`none`,fillRule:`evenodd`,children:(0,o.jsxs)(`g`,{id:`container`,transform:`translate(2.000000, 2.000000)`,fillRule:`nonzero`,children:[(0,o.jsx)(`rect`,{id:`mask`,stroke:`#000000`,strokeWidth:`2`,fill:`#424A60`,x:`-1`,y:`-1`,width:`71`,height:`71`,rx:`14`}),(0,o.jsx)(`circle`,{id:`Oval`,fill:`#EFCE4A`,cx:`21.069`,cy:`23.069`,r:`9.069`}),(0,o.jsx)(`polygon`,{id:`Shape`,fill:`#1A9172`,points:`69.5 56.7492553 68.1170213 55.212766 51.5212766 40 37 55.9042553 44.5828723 63.4871277 50.1382979 69.0425532 60.7455406 69.0425532 69.5 60.1780353`}),(0,o.jsx)(`polygon`,{id:`Shape`,fill:`#25AE88`,points:`47.8532188 64.0501875 33.8030313 50 12 69.1969687 53 69.1969687`}),(0,o.jsx)(`rect`,{id:`mask`,stroke:`#000000`,strokeWidth:`2`,x:`-1`,y:`-1`,width:`71`,height:`71`,rx:`14`})]})})})}function Be(e){return(0,o.jsxs)(`svg`,{width:`800px`,height:`800px`,viewBox:`0 0 32 32`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[(0,o.jsx)(`path`,{d:`M23.3 8.40007L21.82 6.40008C21.7248 6.27314 21.6008 6.17066 21.4583 6.10111C21.3157 6.03156 21.1586 5.99693 21 6.00008H11.2C11.0555 6.00007 10.9128 6.03135 10.7816 6.09177C10.6504 6.15219 10.5339 6.24031 10.44 6.35007L8.71998 8.35008C8.57227 8.53401 8.49435 8.76424 8.49998 9.00008V16.2901C8.50262 18.0317 9.19567 19.7013 10.4272 20.9328C11.6588 22.1644 13.3283 22.8574 15.07 22.8601H16.93C18.6716 22.8574 20.3412 22.1644 21.5728 20.9328C22.8043 19.7013 23.4973 18.0317 23.5 16.2901V9.00008C23.5 8.7837 23.4298 8.57317 23.3 8.40007Z`,fill:`#FFCC80`}),(0,o.jsx)(`path`,{d:`M29.78 28.38L25.78 23.38C25.664 23.2321 25.5086 23.1198 25.3318 23.0562C25.1549 22.9925 24.9637 22.98 24.78 23.02L16 25L7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H29C29.1885 29.9995 29.373 29.9457 29.5322 29.8448C29.6914 29.744 29.8189 29.6002 29.9 29.43C29.98 29.2613 30.0112 29.0734 29.99 28.8879C29.9688 28.7023 29.8961 28.5264 29.78 28.38Z`,fill:`#01579B`}),(0,o.jsx)(`path`,{d:`M29.29 6.00003L16.29 2.00003C16.0999 1.95002 15.9001 1.95002 15.71 2.00003L2.71 6.00003C2.49742 6.06422 2.31226 6.19735 2.1837 6.37841C2.05515 6.55947 1.99052 6.77817 2 7.00003C1.9917 7.22447 2.0592 7.44518 2.19163 7.62659C2.32405 7.80799 2.5137 7.93954 2.73 8.00003L15.73 11.6C15.906 11.6534 16.094 11.6534 16.27 11.6L29.27 8.00003C29.4863 7.93954 29.6759 7.80799 29.8084 7.62659C29.9408 7.44518 30.0083 7.22447 30 7.00003C30.0095 6.77817 29.9448 6.55947 29.8163 6.37841C29.6877 6.19735 29.5026 6.06422 29.29 6.00003Z`,fill:`#01579B`}),(0,o.jsx)(`path`,{d:`M11.22 6C11.0756 5.99999 10.9328 6.03127 10.8016 6.09169C10.6704 6.15211 10.5539 6.24023 10.46 6.35L8.74 8.35C8.58509 8.53114 8.49998 8.76166 8.5 9V16.29C8.50264 18.0317 9.19569 19.7012 10.4272 20.9328C11.6588 22.1643 13.3283 22.8574 15.07 22.86H16V6H11.22Z`,fill:`#FFE0B2`}),(0,o.jsx)(`path`,{d:`M7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H16V25L7.21999 23Z`,fill:`#0277BD`}),(0,o.jsx)(`path`,{d:`M15.71 2.00002L2.71 6.00002C2.49742 6.06422 2.31226 6.19734 2.1837 6.3784C2.05515 6.55947 1.99052 6.77817 2 7.00002C1.9917 7.22447 2.0592 7.44518 2.19163 7.62658C2.32405 7.80799 2.5137 7.93954 2.73 8.00002L15.73 11.6C15.8194 11.6146 15.9106 11.6146 16 11.6V2.00002C15.9039 1.98469 15.8061 1.98469 15.71 2.00002Z`,fill:`#0277BD`}),(0,o.jsx)(`path`,{d:`M2.73 8.00003L8.5 9.56003V16.29C8.50264 18.0317 9.19569 19.7013 10.4272 20.9328C11.6588 22.1643 13.3283 22.8574 15.07 22.86H16.93C18.6717 22.8574 20.3412 22.1643 21.5728 20.9328C22.8043 19.7013 23.4974 18.0317 23.5 16.29V9.56003L29.27 8.00003C29.4863 7.93954 29.6759 7.80799 29.8084 7.62659C29.9408 7.44518 30.0083 7.22447 30 7.00003C30.0095 6.77817 29.9448 6.55947 29.8163 6.37841C29.6877 6.19735 29.5026 6.06422 29.29 6.00003L16.29 2.00003C16.0999 1.95002 15.9001 1.95002 15.71 2.00003L2.71 6.00003C2.49742 6.06422 2.31226 6.19735 2.1837 6.37841C2.05515 6.55947 1.99052 6.77817 2 7.00003C1.9917 7.22447 2.0592 7.44518 2.19163 7.62659C2.32405 7.80799 2.5137 7.93954 2.73 8.00003ZM21.5 16.29C21.4974 17.5013 21.015 18.6621 20.1586 19.5186C19.3021 20.3751 18.1412 20.8574 16.93 20.86H15.07C13.8588 20.8574 12.6979 20.3751 11.8414 19.5186C10.985 18.6621 10.5026 17.5013 10.5 16.29V10.11L15.73 11.56C15.906 11.6134 16.094 11.6134 16.27 11.56L21.5 10.11V16.29ZM16 4.05003L25.44 7.00003L16 9.56003L6.56 7.00003L16 4.05003Z`,fill:`#263238`}),(0,o.jsx)(`path`,{d:`M25.78 23.38C25.664 23.2321 25.5086 23.1198 25.3318 23.0562C25.1549 22.9925 24.9637 22.98 24.78 23.02L16 25L7.21999 23C7.03632 22.96 6.84507 22.9725 6.6682 23.0362C6.49133 23.0998 6.33598 23.2121 6.21999 23.36L2.21999 28.36C2.10392 28.5064 2.03116 28.6823 2.00995 28.8679C1.98874 29.0534 2.01993 29.2413 2.09999 29.41C2.17815 29.5839 2.3044 29.7319 2.46385 29.8364C2.62331 29.9409 2.80933 29.9977 2.99999 30H29C29.1885 29.9995 29.373 29.9457 29.5322 29.8448C29.6914 29.744 29.8189 29.6002 29.9 29.43C29.98 29.2613 30.0112 29.0734 29.99 28.8879C29.9688 28.7023 29.8961 28.5264 29.78 28.38L25.78 23.38ZM5.07999 28L7.38999 25.11L15.78 27C15.9251 27.0299 16.0748 27.0299 16.22 27L24.61 25.13L26.92 28H5.07999Z`,fill:`#263238`})]})}function Ve(e){return(0,o.jsxs)(`svg`,{height:`800px`,width:`800px`,version:`1.1`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 503.322 503.322`,...e,children:[(0,o.jsx)(`path`,{style:{fill:`#FBC176`},d:`M0,73.763v130.169c0,6.942,6.075,13.017,13.017,13.017h225.627c6.942,0,13.017-6.075,13.017-13.017 V73.763c0-6.942-6.075-13.017-13.017-13.017H13.017C6.075,60.746,0,66.82,0,73.763`}),(0,o.jsx)(`path`,{style:{fill:`#C39A6E`},d:`M225.627,60.746V39.051c0-6.942-6.075-13.017-13.017-13.017h-69.424L121.492,0H30.373 c-6.942,0-13.017,6.075-13.017,13.017v47.729H225.627z`}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M86.78,104.136H34.712c-5.207,0-8.678-3.471-8.678-8.678c0-5.207,3.471-8.678,8.678-8.678H86.78 c5.207,0,8.678,3.471,8.678,8.678C95.458,100.664,91.986,104.136,86.78,104.136`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M86.78,138.847H34.712c-5.207,0-8.678-3.471-8.678-8.678s3.471-8.678,8.678-8.678H86.78 c5.207,0,8.678,3.471,8.678,8.678S91.986,138.847,86.78,138.847`})]}),(0,o.jsx)(`path`,{style:{fill:`#FBC176`},d:`M251.661,360.136v130.169c0,6.942,6.075,13.017,13.017,13.017h225.627 c6.942,0,13.017-6.075,13.017-13.017V360.136c0-6.942-6.075-13.017-13.017-13.017H264.678 C257.736,347.119,251.661,353.193,251.661,360.136`}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M338.441,390.508h-52.068c-5.207,0-8.678-3.471-8.678-8.678s3.471-8.678,8.678-8.678h52.068 c5.207,0,8.678,3.471,8.678,8.678S343.647,390.508,338.441,390.508`}),(0,o.jsx)(`path`,{style:{fill:`#FFFFFF`},d:`M338.441,425.22h-52.068c-5.207,0-8.678-3.471-8.678-8.678c0-5.207,3.471-8.678,8.678-8.678h52.068 c5.207,0,8.678,3.471,8.678,8.678C347.119,421.749,343.647,425.22,338.441,425.22`})]}),(0,o.jsx)(`path`,{style:{fill:`#F38774`},d:`M208.271,451.254H78.102c-5.207,0-8.678-3.471-8.678-8.678V260.339c0-5.207,3.471-8.678,8.678-8.678 c5.207,0,8.678,3.471,8.678,8.678v173.559h121.492c5.207,0,8.678,3.471,8.678,8.678 C216.949,447.783,213.478,451.254,208.271,451.254`}),(0,o.jsx)(`path`,{style:{fill:`#26B999`},d:`M433.898,277.695c-5.207,0-8.678-3.471-8.678-8.678V95.458H295.051c-5.207,0-8.678-3.471-8.678-8.678 c0-5.207,3.471-8.678,8.678-8.678h138.847c5.207,0,8.678,3.471,8.678,8.678v182.237 C442.576,274.224,439.105,277.695,433.898,277.695`}),(0,o.jsx)(`path`,{style:{fill:`#C39A6E`},d:`M477.288,347.119v-21.695c0-6.942-6.075-13.017-13.017-13.017h-69.424l-21.695-26.034h-91.119 c-6.942,0-13.017,6.075-13.017,13.017v47.729H477.288z`})]})}function He(e){return(0,o.jsxs)(`svg`,{height:`800px`,width:`800px`,viewBox:`0 0 128 128`,xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,"aria-hidden":`true`,role:`img`,className:`iconify iconify--noto`,preserveAspectRatio:`xMidYMid meet`,...e,children:[(0,o.jsx)(`path`,{d:`M106 24.79H22.15c-1.92 0-3.48 1.56-3.48 3.48v57.59c0 1.92 1.56 3.48 3.48 3.48H106c1.92 0 3.48-1.56 3.48-3.48V28.27c0-1.92-1.55-3.48-3.48-3.48z`,fill:`#b7d5e5`}),(0,o.jsxs)(`radialGradient`,{id:`IconifyId17ecdb2904d178eab9910`,cx:`48.408`,cy:`13.024`,r:`75.465`,gradientTransform:`matrix(1 0 0 1.0843 0 -10.19)`,gradientUnits:`userSpaceOnUse`,children:[(0,o.jsx)(`stop`,{offset:`0`,stopColor:`#2f7889`}),(0,o.jsx)(`stop`,{offset:`1`,stopColor:`#424242`})]}),(0,o.jsx)(`path`,{fill:`url(#IconifyId17ecdb2904d178eab9910)`,d:`M104.75 83.2H23.4l.96-52.27h79.43z`}),(0,o.jsx)(`path`,{d:`M121.09 123.82H7.59c-.43 0-.83-.03-1.2-.09c-2.88-.44-4.21-4.18-2.5-6.74l.39-.59h119.59l.4.6c1.86 2.78.12 6.76-3.04 6.81c-.04.01-.09.01-.14.01z`,fill:`#2f7889`}),(0,o.jsx)(`path`,{d:`M106.84 90.41H20.6c-1.27 0-2.54.77-3.25 1.99l-14 25.48c-.59.88-.01 2.12.99 2.12H123.8c1 0 1.58-1.24.99-2.12l-14.71-25.63c-.7-1.08-1.97-1.84-3.24-1.84z`,fill:`#eee`}),(0,o.jsx)(`path`,{fill:`#b7d5e5`,d:`M86.36 115.52H41.8l2.85-7.98h39.07z`}),(0,o.jsxs)(`g`,{opacity:`0.57`,fill:`#69a1ba`,children:[(0,o.jsx)(`path`,{d:`M72.69 94.84l-.27-2.2h-3.44l.13 2.2z`}),(0,o.jsx)(`path`,{d:`M67.14 94.84l-.14-2.2h-3.45v2.2z`}),(0,o.jsx)(`path`,{d:`M93.61 94.84l-.81-2.2h-3.26l.68 2.2z`}),(0,o.jsx)(`path`,{d:`M88.36 94.84l-.68-2.2h-3.32l.54 2.2z`}),(0,o.jsx)(`path`,{d:`M83.18 94.84l-.54-2.2h-3.37l.41 2.2z`}),(0,o.jsx)(`path`,{d:`M102.11 94.84l-.95-2.2h-6.71l.82 2.2z`}),(0,o.jsx)(`path`,{d:`M77.61 94.84l-.41-2.2h-3.41l.28 2.2z`}),(0,o.jsx)(`path`,{d:`M33.76 94.84l.68-2.2h-3.26l-.81 2.2z`}),(0,o.jsx)(`path`,{d:`M50.51 94.84l.27-2.2h-3.41l-.4 2.2z`}),(0,o.jsx)(`path`,{d:`M39.35 94.84l.54-2.2h-3.32l-.67 2.2z`}),(0,o.jsx)(`path`,{d:`M28.17 94.84l.81-2.2H25.8l-.95 2.2z`}),(0,o.jsx)(`path`,{d:`M44.93 94.84l.41-2.2h-3.37l-.54 2.2z`}),(0,o.jsx)(`path`,{d:`M56.08 94.84l.14-2.2h-3.44l-.27 2.2z`}),(0,o.jsx)(`path`,{d:`M61.65 94.84v-2.2H58.2l-.14 2.2z`}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{d:`M83.78 103.73H44.36l-.75 2.2h41.08z`}),(0,o.jsx)(`path`,{d:`M102.15 105.93l-1.21-2.2h6.54l.95 2.2z`}),(0,o.jsx)(`path`,{d:`M86.75 105.93l-.83-2.2h6.29l.96 2.2z`}),(0,o.jsx)(`path`,{d:`M95.39 105.93l-.96-2.2h4.31l1.1 2.2z`}),(0,o.jsx)(`path`,{d:`M25.67 105.93l1.21-2.2h-6.54l-.95 2.2z`}),(0,o.jsx)(`path`,{d:`M41.07 105.93l.83-2.2h-6.29l-.96 2.2z`}),(0,o.jsx)(`path`,{d:`M32.42 105.93l.97-2.2h-4.31l-1.11 2.2z`})]}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{d:`M29.71 98.51l.82-2.19h-6.67l-.95 2.19z`}),(0,o.jsx)(`path`,{d:`M97.95 98.51l-.81-2.19h6.66l.95 2.19z`}),(0,o.jsx)(`path`,{d:`M96.25 98.51l-.96-2.19h-3.85l.82 2.19z`}),(0,o.jsx)(`path`,{d:`M86.23 98.51l-.65-2.19h3.85l.78 2.19z`}),(0,o.jsx)(`path`,{d:`M80.19 98.51l-.47-2.19h3.85l.6 2.19z`}),(0,o.jsx)(`path`,{d:`M74.15 98.51l-.28-2.19h3.84l.43 2.19z`}),(0,o.jsx)(`path`,{d:`M68.12 98.51l-.11-2.19h3.85l.24 2.19z`}),(0,o.jsx)(`path`,{d:`M62.08 98.51l.07-2.19H66l.06 2.19z`}),(0,o.jsx)(`path`,{d:`M56.04 98.51l.25-2.19h3.85l-.11 2.19z`}),(0,o.jsx)(`path`,{d:`M50.01 98.51l.42-2.19h3.85l-.29 2.19z`}),(0,o.jsx)(`path`,{d:`M43.97 98.51l.6-2.19h3.85l-.47 2.19z`}),(0,o.jsx)(`path`,{d:`M37.93 98.51l.78-2.19h3.85l-.64 2.19z`}),(0,o.jsx)(`path`,{d:`M31.9 98.51l.95-2.19h3.85l-.82 2.19z`})]}),(0,o.jsxs)(`g`,{children:[(0,o.jsx)(`path`,{d:`M29.7 102.22l.81-2.2h-8.75l-.95 2.2z`}),(0,o.jsx)(`path`,{d:`M95.87 102.22l-.77-2.2h-4.17l.64 2.2z`}),(0,o.jsx)(`path`,{d:`M84.93 102.22l-.48-2.2h4.16l.62 2.2z`}),(0,o.jsx)(`path`,{d:`M78.28 102.22l-.32-2.2h4.17l.45 2.2z`}),(0,o.jsx)(`path`,{d:`M71.64 102.22l-.17-2.2h4.17l.3 2.2z`}),(0,o.jsx)(`path`,{d:`M65 102.22l-.01-2.2h4.16l.15 2.2z`}),(0,o.jsx)(`path`,{d:`M58.36 102.22l.14-2.2h4.17l-.01 2.2z`}),(0,o.jsx)(`path`,{d:`M51.71 102.22l.3-2.2h4.17l-.17 2.2z`}),(0,o.jsx)(`path`,{d:`M45.07 102.22l.46-2.2h4.16l-.32 2.2z`}),(0,o.jsx)(`path`,{d:`M38.43 102.22l.61-2.2h4.17l-.48 2.2z`}),(0,o.jsx)(`path`,{d:`M31.78 102.22l.77-2.2h4.17l-.63 2.2z`}),(0,o.jsx)(`path`,{d:`M97.47 102.22l-.82-2.2h8.75l.95 2.2z`})]})]}),(0,o.jsx)(`path`,{d:`M124.73 117.88L110.39 92.4c-.71-1.07-1.98-1.84-3.25-1.84c0 0 1.22 1.1 1.59 1.63l12.59 23.59c.56 1.02-.18 2.26-1.34 2.26H7.96c-1.15 0-1.89-1.23-1.35-2.24l11.95-23.18c.35-.6 1.88-1.99 1.88-1.99h-.45c-1.27 0-2.54.77-3.25 1.99L3.28 117.88c-.59.88-.01 2.12.99 2.12h119.46c1.01 0 1.59-1.24 1-2.12z`,fill:`#b7d5e5`}),(0,o.jsx)(`path`,{fill:`none`,stroke:`#eee`,strokeWidth:`2.936`,strokeLinecap:`round`,strokeMiterlimit:`10`,d:`M25.97 28.02h13.21`}),(0,o.jsx)(`path`,{d:`M109.37 30.11c0-1.04-1.01-1.12-1.01.11v55.8c0 1.34-1.09 2.43-2.43 2.43H22.08c-1.34 0-2.43-1.09-2.43-2.43v-55.8c0-1.23-1.01-1.15-1.01-.11l-.95 55.91c0 2.42 1.24 4.39 4.39 4.39h83.85c2.73 0 4.39-1.97 4.39-4.39l-.95-55.91z`,fill:`#75a7bc`})]})}var Ue=[{code:`general`,icon:Ie,name:`Web`},{code:`news`,icon:Le,name:`News`},{code:`videos`,icon:Re,name:`Videos`},{code:`images`,icon:ze,name:`Images`},{code:`science`,icon:Be,name:`Academic`},{code:`files`,icon:Ve,name:`Files`},{code:`it`,icon:He,name:`Tech`}],We=()=>{let{chatModelProvider:e,setChatModelProvider:t}=n.u(),[s,c]=(0,i.useState)([]),[u,d]=(0,i.useState)(!0),p=(0,a.useRouter)();(0,i.useEffect)(()=>{(async()=>{try{d(!0);let{data:n}=await(0,f.listProviders)(),r=n?.providers??[];if(c(r),!e.key&&r.length>0){let e=localStorage.getItem(`chatModelKey`),n=localStorage.getItem(`chatModelProviderId`);if(e&&n)t({key:e,providerId:n});else{let e=r.find(e=>e.chatModels.length>0);e&&t({key:e.chatModels[0].key,providerId:e.id})}}}catch(e){console.error(`Error loading providers:`,e)}finally{d(!1)}})()},[]);let m=(0,i.useMemo)(()=>{if(!e.key)return`Select`;for(let t of s){let n=t.chatModels.find(t=>t.key===e.key);if(n)return n.name}return e.key},[s,e.key]),h=(e,n)=>{t({providerId:e,key:n}),localStorage.setItem(`chatModelProviderId`,e),localStorage.setItem(`chatModelKey`,n)};return(0,o.jsxs)(J,{children:[(0,o.jsxs)(Y,{className:`gap-2`,children:[(0,o.jsx)(l.Cpu,{className:`w-4 h-4 flex-shrink-0 text-sky-500`}),(0,o.jsx)(`span`,{children:`Model`}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground truncate max-w-[55px]`,children:m})]}),(0,o.jsxs)(X,{className:`w-52 max-h-[400px] overflow-y-auto`,children:[u?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,o.jsx)(l.Loader2,{className:`h-4 w-4 animate-spin text-muted-foreground`})}):s.length===0?(0,o.jsx)(`div`,{className:`px-3 py-2 text-xs text-muted-foreground`,children:`No models configured`}):s.map((t,n)=>(0,o.jsxs)(`div`,{children:[(0,o.jsx)(ke,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:t.name}),t.chatModels.map(n=>(0,o.jsxs)(K,{onSelect:()=>h(t.id,n.key),className:r.o(`gap-2`,e?.providerId===t.id&&e?.key===n.key&&`bg-secondary`),children:[(0,o.jsx)(l.Cpu,{className:r.o(`h-3.5 w-3.5 flex-shrink-0`,e?.providerId===t.id&&e?.key===n.key?`text-sky-500`:`text-muted-foreground`)}),(0,o.jsx)(`span`,{className:`truncate`,children:n.name}),e?.providerId===t.id&&e?.key===n.key&&(0,o.jsx)(`svg`,{className:`w-3 h-3 text-primary ml-auto shrink-0`,fill:`none`,viewBox:`0 0 10 10`,children:(0,o.jsx)(`path`,{d:`M1.5 5l2.5 2.5 4.5-4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]},n.key)),n<s.length-1&&(0,o.jsx)(q,{})]},t.id)),(0,o.jsx)(q,{}),(0,o.jsxs)(K,{onSelect:()=>p.push(`/settings?section=models`),className:`gap-2`,children:[(0,o.jsx)(l.Plus,{className:`h-3.5 w-3.5 text-sky-500 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Add model`})]})]})]})};function Ge(e){let t=e.messages?.[e.messages.length-1],n=t&&`createdAt`in t?t.createdAt:void 0;if(n){let e=new Date(n).getTime();if(!Number.isNaN(e))return new Date(e).toISOString()}return e.createdAt}var Ke=e=>new Date(e.lastMessageAt||e.createdAt).getTime();function qe(){return F().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0,lastMessageAt:Ge(e)}))}function Je(e=10){let[t,r]=(0,i.useState)([]),[a,o]=(0,i.useState)(!1),{isAuthenticated:s,isLoading:c}=n.c(),l=(0,i.useRef)(!1),u=(0,i.useCallback)(async(e=!1)=>{if(!c&&(!l.current||e)){l.current=!0,o(!0);try{if(s){let{data:e,error:t}=await(0,f.listChats)();if(t){r(qe());return}r(Array.isArray(e?.chats)?e.chats:[])}else r(qe())}catch(e){console.error(`Failed to fetch recent chats:`,e),r([])}finally{o(!1)}}},[s,c]);return{recentChats:[...t].sort((e,t)=>Ke(t)-Ke(e)).slice(0,e),loading:a,load:u}}function Ye(e){let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=Math.round((Date.now()-t)/1e3);if(n<5)return`just now`;if(n<60)return`${n} sec`;let r=Math.round(n/60);if(r<60)return`${r} min`;let i=Math.round(r/60);if(i<24)return`${i} hr`;let a=Math.round(i/24);if(a<7)return`${a} day${a===1?``:`s`}`;let o=Math.round(a/7);if(o<5)return`${o} week${o===1?``:`s`}`;let s=Math.round(a/30);if(s<12)return`${s} month${s===1?``:`s`}`;let c=Math.round(a/365);return`${c} year${c===1?``:`s`}`}var Xe=10,Ze=()=>{let e=(0,a.useRouter)(),{incognito:r,setIncognito:i}=n.u(),{recentChats:s,loading:c,load:d}=Je(Xe),f=e=>{i(e),u.toast.success(e?`Private mode on — messages won't be saved`:`Private mode off`)},p=n=>{t.researchAgentUIConfig.onOpenChat?.(n)||e.push(`/c/${n}`)};return(0,o.jsxs)(J,{onOpenChange:e=>{e&&d()},children:[(0,o.jsxs)(Y,{className:`gap-2`,children:[(0,o.jsx)(l.History,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,o.jsx)(`span`,{children:`History`})]}),(0,o.jsxs)(X,{className:`w-64 max-h-[70vh] overflow-y-auto`,children:[(0,o.jsxs)(Oe,{checked:r,onCheckedChange:f,onSelect:e=>e.preventDefault(),className:`gap-2`,children:[(0,o.jsx)(l.EyeOff,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,o.jsx)(`span`,{children:`Private`})]}),(0,o.jsx)(q,{}),c?(0,o.jsxs)(K,{disabled:!0,className:`gap-2`,children:[(0,o.jsx)(l.Loader2,{className:`w-3.5 h-3.5 animate-spin flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Loading…`})]}):s.length===0?(0,o.jsx)(K,{disabled:!0,children:(0,o.jsx)(`span`,{className:`text-muted-foreground`,children:`No recent chats`})}):s.map(e=>{let t=Ye(e.lastMessageAt||e.createdAt);return(0,o.jsxs)(K,{onSelect:()=>p(e.id),className:`gap-2`,title:e.title,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.title}),t&&(0,o.jsx)(`span`,{className:`ml-auto pl-2 text-xs italic text-muted-foreground/70 whitespace-nowrap`,children:t})]},e.id)}),(0,o.jsx)(q,{}),(0,o.jsxs)(K,{onSelect:()=>e.push(`/library`),className:`gap-2`,children:[(0,o.jsx)(l.History,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,o.jsx)(`span`,{children:`All history`})]})]})]})},Qe=new Map;function $e(e){if(typeof window>`u`)return Promise.reject(Error(`CDN scripts require a browser environment`));let t=Qe.get(e);if(t)return t;let n=new Promise((t,n)=>{let r=document.querySelector(`script[data-cdn-loader="${e}"]`);if(r){r.dataset.loaded===`true`?t():(r.addEventListener(`load`,()=>t(),{once:!0}),r.addEventListener(`error`,()=>n(Error(`Failed to load ${e}`)),{once:!0}));return}let i=document.createElement(`script`);i.src=e,i.async=!0,i.dataset.cdnLoader=e,i.onload=()=>{i.dataset.loaded=`true`,t()},i.onerror=()=>{Qe.delete(e),n(Error(`Failed to load ${e}`))},document.head.appendChild(i)});return Qe.set(e,n),n}var et=`https://cdn.jsdelivr.net/npm/jspdf@2.5.2/dist/jspdf.umd.min.js`,tt=`https://cdn.jsdelivr.net/npm/docx@9.5.1/build/index.umd.min.js`;async function nt(){await $e(et);let e=window.jspdf?.jsPDF;if(!e)throw Error(`jsPDF global not found after CDN load`);return e}async function rt(){await $e(tt);let e=window.docx;if(!e)throw Error(`docx global not found after CDN load`);return e}async function it(e,t){let{default:n}=await import(`turndown`);ct(`# ${e}\n\n${new n({headingStyle:`atx`,codeBlockStyle:`fenced`}).turndown(t)}`,`${e}.md`,`text/markdown`)}async function at(e,t){let{Document:n,Paragraph:r,TextRun:i,HeadingLevel:a,Packer:o}=await rt(),s=new DOMParser().parseFromString(t,`text/html`),c=[];c.push(new r({text:e,heading:a.HEADING_1,spacing:{after:200}}));let l=e=>{if(e.nodeType===Node.TEXT_NODE){let t=e.textContent?.trim();t&&c.push(new r({children:[new i(t)]}))}else if(e.nodeType===Node.ELEMENT_NODE){let t=e,n=t.tagName.toLowerCase();switch(n){case`h1`:c.push(new r({text:t.textContent||``,heading:a.HEADING_1}));break;case`h2`:c.push(new r({text:t.textContent||``,heading:a.HEADING_2}));break;case`h3`:c.push(new r({text:t.textContent||``,heading:a.HEADING_3}));break;case`p`:let e=[];t.childNodes.forEach(t=>{if(t.nodeType===Node.TEXT_NODE)e.push(new i(t.textContent||``));else if(t.nodeType===Node.ELEMENT_NODE){let n=t,r={text:n.textContent||``};(n.tagName===`STRONG`||n.tagName===`B`)&&(r.bold=!0),(n.tagName===`EM`||n.tagName===`I`)&&(r.italics=!0),n.tagName===`U`&&(r.underline={}),n.tagName===`CODE`&&(r.font=`Courier New`),e.push(new i(r))}}),e.length>0?c.push(new r({children:e})):c.push(new r({text:t.textContent||``}));break;case`ul`:case`ol`:t.querySelectorAll(`li`).forEach(e=>{c.push(new r({text:e.textContent||``,bullet:n===`ul`?{level:0}:void 0,numbering:n===`ol`?{reference:`default`,level:0}:void 0}))});break;case`blockquote`:c.push(new r({children:[new i({text:t.textContent||``,italics:!0})],indent:{left:720}}));break;default:t.childNodes.forEach(l)}}};s.body.childNodes.forEach(l);let u=new n({sections:[{properties:{},children:c}]}),d=await o.toBlob(u),f=URL.createObjectURL(d),p=document.createElement(`a`);p.href=f,p.download=`${e}.docx`,p.click(),URL.revokeObjectURL(f)}async function ot(e,t){let n=document.createElement(`div`);n.style.position=`absolute`,n.style.left=`-9999px`,n.style.width=`210mm`,n.style.padding=`20mm`,n.style.backgroundColor=`white`,n.style.fontFamily=`Arial, sans-serif`,n.style.fontSize=`12pt`,n.style.lineHeight=`1.6`,n.innerHTML=`
|
|
2
|
+
<h1 style="font-size: 24pt; margin-bottom: 20px;">${e}</h1>
|
|
3
|
+
${t}
|
|
4
|
+
`,document.body.appendChild(n);try{let[t,{default:r}]=await Promise.all([nt(),import(`html2canvas`)]),i=await r(n,{scale:2,useCORS:!0,logging:!1}),a=i.toDataURL(`image/png`),o=new t({orientation:`portrait`,unit:`mm`,format:`a4`}),s=i.height*210/i.width,c=s,l=0;for(o.addImage(a,`PNG`,0,l,210,s),c-=297;c>=0;)l=c-s,o.addPage(),o.addImage(a,`PNG`,0,l,210,s),c-=297;o.save(`${e}.pdf`)}finally{document.body.removeChild(n)}}async function st(e,t){try{let{default:n}=await import(`turndown`),r=`${e}\n\n${new n().turndown(t)}`;await navigator.clipboard.writeText(r),window.open(`https://docs.google.com/document/create`,`_blank`),alert(`Content copied to clipboard! Paste it into the new Google Doc.`)}catch(e){console.error(`Failed to export to Google Docs:`,e),alert(`Failed to copy content to clipboard. Please try again.`)}}function ct(e,t,n){let r=new Blob([e],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,a.click(),URL.revokeObjectURL(i)}var lt=[{label:`5s`,value:5},{label:`15s`,value:15},{label:`30s`,value:30},{label:`45s`,value:45},{label:`60s`,value:60},{label:`Unlimited`,value:0}],ut=[`pdf`,`docx`,`txt`,`md`,`html`,`htm`],dt=`markdown.js.jsx.ts.tsx.py.rb.go.rs.java.c.cpp.h.hpp.cs.swift.kt.sh.bash.zsh.json.yaml.yml.toml.ini.cfg.conf.xml.csv.tsv.log.env.sql.graphql.vue.svelte.astro.css.scss.less.sass.tex.bib.rst.adoc.org`.split(`.`),ft=({onFileSelect:e,disabled:s=!1})=>{let c=(0,a.useRouter)(),{category:d,setCategory:p,sections:m,chatId:h}=n.u(),{isAuthenticated:g}=n.c(),_=d?d.split(`,`).filter(Boolean):[`general`],v=Ue.find(e=>e.code===_[0])||Ue[0],y=e=>{let t=d?d.split(`,`).filter(Boolean):[`general`],n=t.includes(e)?t.filter(t=>t!==e):[...t,e];p(n.length>0?n.join(`,`):`general`)},[b,x]=(0,i.useState)(!1),[S,C]=(0,i.useState)(!1),[w,T]=(0,i.useState)(!1),[E,D]=(0,i.useState)(!1),[O,k]=(0,i.useState)(()=>{if(typeof window>`u`)return 5;let e=Number(localStorage.getItem(`thinkingTimeLimit`)??`5`);return Number.isFinite(e)?e:5}),A=i.default.useRef(null),{openPicker:j}=Fe();(0,i.useEffect)(()=>{M()},[]);let M=async()=>{try{let{data:e}=await(0,f.googleDocsAuthStatus)();x(e?.isConnected||!1)}catch{}},N=e=>{k(e),localStorage.setItem(`thinkingTimeLimit`,String(e))},P=async()=>{if(`showOpenFilePicker`in window)try{let t=await window.showOpenFilePicker({multiple:!0,types:[{description:`Supported files`,accept:{"application/pdf":[`.pdf`],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[`.docx`],"text/plain":[`.txt`],"text/markdown":[`.md`],"text/html":[`.html`,`.htm`],"image/*":[`.jpg`,`.jpeg`,`.png`,`.gif`,`.webp`,`.svg`]}}]}),n=await Promise.all(t.map(e=>e.getFile()));n.length>0&&e(n)}catch(e){e?.name!==`AbortError`&&(console.error(`Failed to open file picker:`,e),A.current?.click())}else A.current?.click()};async function F(e,t=``){let n=[];for await(let r of e.values())if(r.kind===`file`){let e=await r.getFile(),i=e.name.split(`.`).pop()?.toLowerCase()??``;if(ut.includes(i))n.push(e);else if(dt.includes(i))try{let r=await e.text(),i=t?`${t}/${e.name}`:e.name;n.push(new File([r],`${i.replace(/[/\\]/g,`_`)}.txt`,{type:`text/plain`}))}catch{}}else if(r.kind===`directory`){let e=r;if(e.name.startsWith(`.`)||e.name===`node_modules`||e.name===`__pycache__`)continue;n.push(...await F(e,t?`${t}/${e.name}`:e.name))}return n}let I=async()=>{if(!(`showDirectoryPicker`in window))alert(`Your browser does not support the File System Access API. Please use Chrome or Edge.`);else{D(!0);try{let t=await F(await window.showDirectoryPicker({mode:`read`}));t.length>0?e(t):alert(`No supported files found in the selected folder.`)}catch(e){e?.name!==`AbortError`&&console.error(`Failed to access folder:`,e)}finally{D(!1)}}},L=async()=>{C(!0);try{let{data:e}=await(0,f.googleDocsAuth)();if(e?.success&&e?.data?.authUrl){let t=e.data.authUrl,n=window.screenX+(window.outerWidth-600)/2,r=window.screenY+(window.outerHeight-700)/2,i=window.open(t,`Google Drive Authorization`,`width=600,height=700,left=${n},top=${r}`),a=e=>{e.data.type===`google-drive-connected`&&(x(!0),i?.close(),window.removeEventListener(`message`,a))};window.addEventListener(`message`,a)}}catch{console.error(`Failed to connect to Google Drive`)}finally{C(!1)}},R=async()=>{try{let{data:t}=await(0,f.getGoogleToken)();if(!t?.success||!t.accessToken)throw Error(`Failed to get access token`);await j(t.accessToken,async t=>{T(!0);try{let n=[];for(let e of t){let{data:t}=await(0,f.getGoogleDriveFile)({query:{fileId:e.id}});if(t?.success&&t?.file){let e=atob(t.file.content),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);n.push(new File([new Blob([r],{type:t.file.mimeType})],t.file.name,{type:t.file.mimeType}))}}n.length>0&&e(n)}catch{alert(`Failed to load files from Google Drive`)}finally{T(!1)}},e=>{console.error(`Google Picker error:`,e),alert(e)})}catch(e){alert(e.message||`Failed to open Google Drive picker`)}},z=lt.find(e=>e.value===O)?.label??`Unlimited`;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(`div`,{className:`relative flex shrink min-w-8 !shrink-0 group`,children:[(0,o.jsxs)(Te,{children:[(0,o.jsx)(Ee,{asChild:!0,children:(0,o.jsx)(`button`,{disabled:s,className:`inline-flex items-center justify-center relative shrink-0 transition-colors duration-200 h-8 w-8 rounded-lg active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed group-active:scale-95`,type:`button`,"aria-label":`Search options`,children:(0,o.jsx)(l.SlidersHorizontal,{className:`w-5 h-5`})})}),(0,o.jsxs)(De,{align:`start`,side:`top`,sideOffset:8,className:`w-44`,children:[(0,o.jsxs)(J,{children:[(0,o.jsxs)(Y,{className:`gap-2`,children:[v&&(0,o.jsx)(v.icon,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Category`})]}),(0,o.jsxs)(X,{className:`w-44`,children:[(0,o.jsxs)(Oe,{checked:_.length===0,onCheckedChange:()=>p(`general`),onSelect:e=>e.preventDefault(),className:`gap-2`,children:[(0,o.jsx)(`div`,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`None`})]}),(0,o.jsx)(q,{}),Ue.map(e=>(0,o.jsxs)(Oe,{checked:_.includes(e.code),onCheckedChange:()=>y(e.code),onSelect:e=>e.preventDefault(),className:`gap-2`,children:[e.icon&&(0,o.jsx)(e.icon,{className:`w-3.5 h-3.5 flex-shrink-0`}),(0,o.jsx)(`span`,{children:e.name})]},e.code))]})]}),(0,o.jsxs)(J,{children:[(0,o.jsxs)(Y,{className:`gap-2`,children:[(0,o.jsx)(l.Clock,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,o.jsx)(`span`,{children:`Speed`}),(0,o.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:z})]}),(0,o.jsx)(X,{className:`w-36`,children:lt.map(e=>(0,o.jsxs)(K,{onSelect:()=>N(e.value),className:r.o(`justify-between`,O===e.value&&`bg-secondary`),children:[(0,o.jsx)(`span`,{children:e.label}),O===e.value&&(0,o.jsx)(`svg`,{className:`w-3 h-3 text-primary`,fill:`none`,viewBox:`0 0 10 10`,children:(0,o.jsx)(`path`,{d:`M1.5 5l2.5 2.5 4.5-4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})]},e.value))})]}),(0,o.jsx)(q,{}),(0,o.jsx)(We,{}),(0,o.jsx)(q,{}),(0,o.jsxs)(J,{children:[(0,o.jsxs)(Y,{className:`gap-2`,children:[(0,o.jsx)(l.Upload,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,o.jsx)(`span`,{children:`Upload`})]}),(0,o.jsxs)(X,{className:`w-44`,children:[(0,o.jsxs)(K,{onSelect:P,className:`gap-2`,children:[(0,o.jsx)(l.Upload,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Your Device`})]}),(0,o.jsxs)(K,{onSelect:I,disabled:E,className:`gap-2`,children:[E?(0,o.jsx)(l.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,o.jsx)(l.FolderOpen,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,o.jsx)(`span`,{children:E?`Scanning…`:`Local Folder`})]}),(0,o.jsx)(q,{}),(0,o.jsx)(ke,{className:`text-xs font-normal text-muted-foreground`,children:`Cloud`}),b?(0,o.jsxs)(K,{onSelect:R,disabled:w,className:`gap-2`,children:[w?(0,o.jsx)(l.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,o.jsx)(l.CloudIcon,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,o.jsx)(`span`,{children:w?`Loading…`:`Google Drive`})]}):(0,o.jsxs)(K,{onSelect:L,disabled:S,className:`gap-2`,children:[S?(0,o.jsx)(l.Loader2,{className:`h-3.5 w-3.5 animate-spin flex-shrink-0`}):(0,o.jsx)(l.CloudIcon,{className:`h-3.5 w-3.5 flex-shrink-0`}),(0,o.jsx)(`span`,{children:S?`Connecting…`:`Connect Google Drive`})]})]})]}),(0,o.jsx)(q,{}),m.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(J,{children:[(0,o.jsxs)(Y,{className:`gap-2`,children:[(0,o.jsx)(l.Share2,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,o.jsx)(`span`,{children:`Share`})]}),(0,o.jsxs)(X,{className:`w-48`,children:[(0,o.jsxs)(K,{onSelect:async()=>{if(!h)u.toast.error(`No chat to share`);else if(!g)u.toast.error(`Please sign in to share chats`);else try{let{data:e,error:t}=await(0,f.shareChat)({body:{chatId:h}});if(!t&&e?.success&&e?.data?.shareUrl)await navigator.clipboard.writeText(e.data.shareUrl),u.toast.success(`Chat is now public - link copied to clipboard`);else throw Error(t?.error||`Failed to share chat`)}catch(e){console.error(`Error sharing chat:`,e);let t=e instanceof Error?e.message:`Failed to share chat`;u.toast.error(t)}},className:`gap-2`,children:[(0,o.jsx)(l.Link,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Copy link`})]}),(0,o.jsxs)(K,{onSelect:async()=>{let e=m[0]?.userMessage?.content||`Chat`,t=m.map(e=>`## ${e.userMessage.content}\n\n${e.assistantMessage?.content||``}`).join(`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
`);try{await(0,f.createDocument)({body:{title:e,name:e,content:t,metadata:{source:`chat`,chatId:window.location.pathname}}}),u.toast.success(`Saved to QwkDocs`)}catch{u.toast.error(`Failed to save to QwkDocs`)}},className:`gap-2`,children:[(0,o.jsx)(l.BookMarked,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Save to QwkDocs`})]}),(0,o.jsx)(q,{}),(0,o.jsxs)(K,{onSelect:()=>{it(m[0]?.userMessage?.content||`Chat`,m.map(e=>`<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content||``}`).join(`
|
|
9
|
+
`))},className:`gap-2`,children:[(0,o.jsx)(l.FileText,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Export as Markdown`})]}),(0,o.jsxs)(K,{onSelect:()=>{ot(m[0]?.userMessage?.content||`Chat`,m.map(e=>`<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content||``}`).join(`
|
|
10
|
+
`))},className:`gap-2`,children:[(0,o.jsx)(l.FileType,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Export as PDF`})]}),(0,o.jsxs)(K,{onSelect:()=>{at(m[0]?.userMessage?.content||`Chat`,m.map(e=>`<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content||``}`).join(`
|
|
11
|
+
`))},className:`gap-2`,children:[(0,o.jsx)(l.FileDown,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Export as DOCX`})]}),(0,o.jsxs)(K,{onSelect:()=>{st(m[0]?.userMessage?.content||`Chat`,m.map(e=>`<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content||``}`).join(`
|
|
12
|
+
`))},className:`gap-2`,children:[(0,o.jsx)(l.FileSpreadsheet,{className:`w-4 h-4 flex-shrink-0`}),(0,o.jsx)(`span`,{children:`Export to Google Docs`})]})]})]}),(0,o.jsx)(q,{})]}),(0,o.jsx)(Ze,{}),(0,o.jsxs)(K,{onSelect:()=>{t.researchAgentUIConfig.onOpenSettings?.()||c.push(`/settings`)},className:`gap-2`,children:[(0,o.jsx)(l.Settings,{className:`w-4 h-4 flex-shrink-0 text-muted-foreground`}),(0,o.jsx)(`span`,{children:`Settings`})]})]})]}),(0,o.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,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`Search options`})})]}),(0,o.jsxs)(`div`,{className:`relative hidden sm:flex shrink-0 group -ml-1`,children:[(0,o.jsx)(`button`,{type:`button`,disabled:s,onClick:P,"aria-label":`Attach files`,className:`inline-flex items-center justify-center relative shrink-0 transition-colors duration-200 h-7 w-7 rounded-md active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed group-active:scale-95`,children:(0,o.jsx)(l.Paperclip,{className:`w-[18px] h-[18px]`})}),(0,o.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,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`Attach files`})})]}),(0,o.jsx)(`input`,{ref:A,type:`file`,multiple:!0,onChange:t=>{t.target.files&&(e(t.target.files),t.target.value=``)},className:`hidden`})]})},pt=(0,i.forwardRef)(({active:e=!1,processing:t=!1,barWidth:n=3,barHeight:r=4,barGap:a=1,barRadius:s=1.5,barColor:c,fadeEdges:l=!0,fadeWidth:u=24,height:d=64,sensitivity:f=1,smoothingTimeConstant:p=.8,fftSize:m=256,historySize:h=60,updateRate:g=30,mode:_=`static`,onError:v,onStreamReady:y,onStreamEnd:b,className:x,...S},C)=>{let w=(0,i.useRef)(null),T=(0,i.useRef)(null),E=(0,i.useRef)(null),D=(0,i.useRef)(null),O=(0,i.useRef)(null),k=(0,i.useRef)(0),A=(0,i.useRef)([]),j=(0,i.useRef)(0),M=(0,i.useRef)(0),N=(0,i.useCallback)(()=>{k.current&&=(cancelAnimationFrame(k.current),0),O.current&&=(O.current.disconnect(),null),D.current&&=(D.current.getTracks().forEach(e=>e.stop()),null),T.current&&=(T.current.close().catch(()=>{}),null),E.current=null,A.current=[],b?.()},[b]),P=(0,i.useCallback)((e,t,i,o,c)=>{let l=n+a,u=Math.floor(t/c/l),d=u*l-a,p=(t/c-d)/2,m=o.length;for(let t=0;t<u;t++){let a=o[Math.floor(t/u*m)]/255*f,d=Math.max(r,i/c*a),h=p+t*l,g=(i/c-d)/2;e.beginPath(),e.roundRect(h*c,g*c,n*c,d*c,s*c),e.fill()}},[n,a,r,s,f]),F=(0,i.useCallback)((e,t,i,o)=>{let c=A.current,l=n+a,u=Math.min(c.length,h),d=t/o-u*l;for(let t=0;t<u;t++){let a=c[c.length-u+t]*f,p=Math.max(r,i/o*a),m=d+t*l,h=(i/o-p)/2;e.beginPath(),e.roundRect(m*o,h*o,n*o,p*o,s*o),e.fill()}},[n,a,r,s,f,h]),I=(0,i.useCallback)((e,t,i,o,c)=>{let l=n+a,u=Math.floor(t/o/l),d=u*l-a,f=(t/o-d)/2;for(let t=0;t<u;t++){let a=Math.sin(t/u*Math.PI*2+c)*.5+.5,d=Math.max(r,i/o*a*.6),p=f+t*l,m=(i/o-d)/2;e.beginPath(),e.roundRect(p*o,m*o,n*o,d*o,s*o),e.fill()}},[n,a,r,s]),L=(0,i.useCallback)((e,t,n)=>{if(!l)return;e.save(),e.globalCompositeOperation=`destination-in`;let r=e.createLinearGradient(0,0,t,0);r.addColorStop(0,`rgba(0,0,0,0)`),r.addColorStop(Math.min(u/(t||1),.3),`rgba(0,0,0,1)`),r.addColorStop(Math.max(1-u/(t||1),.7),`rgba(0,0,0,1)`),r.addColorStop(1,`rgba(0,0,0,0)`),e.fillStyle=r,e.fillRect(0,0,t,n),e.restore()},[l,u]);(0,i.useEffect)(()=>{if(!e&&!t){let e=w.current;if(e){let t=e.getContext(`2d`);t&&t.clearRect(0,0,e.width,e.height)}return}let n=!0,r=i=>{if(!n)return;let a=w.current;if(!a||i-M.current<g){k.current=requestAnimationFrame(r);return}M.current=i;let o=window.devicePixelRatio||1,s=a.getBoundingClientRect(),l=s.width*o,u=s.height*o;(a.width!==l||a.height!==u)&&(a.width=l,a.height=u);let d=a.getContext(`2d`);if(!d)k.current=requestAnimationFrame(r);else{if(d.clearRect(0,0,l,u),d.fillStyle=c||getComputedStyle(a).getPropertyValue(`color`)||`#888`,d.save(),d.setTransform(1,0,0,1,0,0),t&&!e)j.current+=.06,I(d,l,u,o,j.current);else if(e&&E.current){let e=new Uint8Array(E.current.frequencyBinCount);if(E.current.getByteFrequencyData(e),_===`scrolling`){let t=0;for(let n=0;n<e.length;n++)t+=e[n];let n=t/e.length/255;A.current.push(n),A.current.length>h*2&&(A.current=A.current.slice(-h)),F(d,l,u,o)}else P(d,l,u,e,o)}L(d,l,u),d.restore(),k.current=requestAnimationFrame(r)}};return k.current=requestAnimationFrame(r),()=>{n=!1,k.current&&=(cancelAnimationFrame(k.current),0)}},[e,t,_,c,g,h,P,F,I,L]),(0,i.useEffect)(()=>{if(!e){N();return}let t=!1;return(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});if(t){e.getTracks().forEach(e=>e.stop());return}let n=new AudioContext,r=n.createAnalyser();r.fftSize=m,r.smoothingTimeConstant=p;let i=n.createMediaStreamSource(e);i.connect(r),T.current=n,E.current=r,D.current=e,O.current=i,y?.(e)}catch(e){t||v?.(e instanceof Error?e:Error(String(e)))}})(),()=>{t=!0,N()}},[e,m,p,N,v,y]);let R=typeof d==`number`?`${d}px`:d;return(0,o.jsx)(`div`,{ref:C,className:x,style:{height:R,width:`100%`,position:`relative`},...S,children:(0,o.jsx)(`canvas`,{ref:w,style:{width:`100%`,height:`100%`,display:`block`,color:c||`currentColor`}})})});pt.displayName=`LiveWaveform`;var mt=async(e,{signal:t,limit:n})=>{let{data:r,error:i}=await(0,f.autocomplete)({query:{q:e,limit:n},signal:t});return i?null:{suggestions:r?.suggestions??[],domains:r?.domains??[]}},ht=[`What are you curious to research?`,`Search the latest news...`,`Analyze a video, doc, or URL...`,`Find academic research on...`,`Compare products to buy...`],gt={initial:{},animate:{transition:{staggerChildren:.025}},exit:{transition:{staggerChildren:.015,staggerDirection:-1}}},_t={initial:{opacity:0,filter:`blur(12px)`,y:10},animate:{opacity:1,filter:`blur(0px)`,y:0,transition:{opacity:{duration:.25},filter:{duration:.4},y:{type:`spring`,stiffness:80,damping:20}}},exit:{opacity:0,filter:`blur(12px)`,y:-10,transition:{opacity:{duration:.2},filter:{duration:.3},y:{type:`spring`,stiffness:80,damping:20}}}},vt=({onNewChat:e})=>{let{loading:t,sendMessage:r,stopStreaming:a,files:l,fileIds:u,setFiles:d,setFileIds:f,newChat:p,sections:h}=n.u(),[g,_]=(0,i.useState)(``),v=(0,i.useRef)(null),y=(0,i.useRef)(null),{files:b,setFiles:x,pastedContent:S,setPastedContent:C,isDragging:w,handleFiles:T,onDragOver:E,onDragLeave:D,onDrop:k,handlePaste:M,resetAttachments:N}=we({setMessage:_,contextFiles:l,contextFileIds:u,setContextFiles:d,setContextFileIds:f}),P=()=>{_(``),N(),v.current&&(v.current.style.height=`auto`)},F=(0,i.useRef)(``),I=(e,t)=>e&&!/\s$/.test(e)?`${e} ${t}`:`${e}${t}`,{isListening:L,toggleSpeech:R,isSpeechSupported:z,lastPhrase:B,phraseId:V}=ce(e=>{_(()=>{let t=`${I(F.current,e)} `;return F.current=t,t})},()=>{_(e=>(e.trim()&&setTimeout(()=>{r(e),P()},0),e))},{onPartial:e=>_(e?I(F.current,e):F.current)});(0,i.useEffect)(()=>{L&&(F.current=g)},[L]),_e({isSpeechSupported:z,isListening:L,toggleSpeech:R});let[H,ee]=(0,i.useState)(0),[te,ne]=(0,i.useState)(!0),[U,re]=(0,i.useState)(!1),{handleKeyDown:ie,...ae}=(0,c.useAutocomplete)({value:g,onChange:_,enabled:U,fetchSuggestions:mt,anchorRef:y,inputRef:v});(0,i.useEffect)(()=>{if(U||g)return;let e=setInterval(()=>{ne(!1),setTimeout(()=>{ee(e=>(e+1)%ht.length),ne(!0)},400)},3e3);return()=>clearInterval(e)},[U,g]),(0,i.useEffect)(()=>{let e=e=>{y.current&&!y.current.contains(e.target)&&(g||re(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[g]),(0,i.useEffect)(()=>{v.current&&(v.current.style.height=`auto`,v.current.style.height=Math.min(v.current.scrollHeight,384)+`px`)},[g]);let W=()=>{t||(g.trim()||b.length!==0||S.length!==0)&&(r(g),P())},G=e=>{ie(e)||e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),W())},oe=!!(g.trim()||b.length>0||S.length>0);return(0,o.jsxs)(`div`,{className:`relative w-full max-w-2xl mx-auto transition-all duration-300 font-sans`,onDragOver:E,onDragLeave:D,onDrop:k,children:[(0,o.jsxs)(s.motion.div,{ref:y,className:`!box-content flex flex-col mx-2 md:mx-0 items-stretch relative z-10 rounded-[28px] bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent cursor-text font-sans antialiased`,animate:{boxShadow:U||g?`0 8px 32px 0 rgba(0,0,0,0.16)`:`0 2px 8px 0 rgba(0,0,0,0.08)`},transition:{type:`spring`,stiffness:120,damping:18},onClick:()=>re(!0),children:[(b.length>0||S.length>0)&&(0,o.jsxs)(`div`,{className:`flex gap-3 overflow-x-auto custom-scrollbar px-3 pt-3 pb-1`,children:[S.map(e=>(0,o.jsx)(j,{content:e,onRemove:e=>C(t=>t.filter(t=>t.id!==e))},e.id)),b.map(e=>(0,o.jsx)(A,{file:e,onRemove:e=>x(t=>t.filter(t=>t.id!==e))},e.id))]}),L&&(0,o.jsx)(`div`,{className:`px-3 pt-2`,children:(0,o.jsx)(pt,{active:L,mode:`static`,height:48,barWidth:3,barGap:2,barColor:`gray`,fadeEdges:!0,sensitivity:1.2,className:`w-full rounded-lg`})}),(0,o.jsx)(m.SpokenPhraseOverlay,{phrase:B,phraseId:V,visible:L}),(0,o.jsxs)(`div`,{className:`flex items-center gap-2 p-3`,children:[(0,o.jsx)(ft,{onFileSelect:T,disabled:t}),(0,o.jsxs)(`div`,{className:`relative flex-1`,children:[(0,o.jsx)(`div`,{className:`max-h-96 w-full overflow-y-auto custom-scrollbar`,children:(0,o.jsx)(`textarea`,{ref:v,value:g,onChange:e=>_(e.target.value),onPaste:M,onKeyDown:G,onFocus:()=>re(!0),className:`w-full bg-transparent border-0 outline-none text-text-200 dark:text-text-100 text-[16px] resize-none overflow-hidden py-1 leading-relaxed block font-normal antialiased`,rows:1,autoFocus:!0,style:{minHeight:`1.5em`}})}),(0,o.jsx)(`div`,{className:`absolute left-0 top-0 w-full h-full pointer-events-none flex items-center`,children:(0,o.jsx)(s.AnimatePresence,{mode:`wait`,children:te&&!U&&!g&&(0,o.jsx)(s.motion.span,{className:`absolute left-0 top-1/2 -translate-y-1/2 text-text-400 select-none pointer-events-none text-[16px] font-normal`,style:{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},variants:gt,initial:`initial`,animate:`animate`,exit:`exit`,children:ht[H].split(``).map((e,t)=>(0,o.jsx)(s.motion.span,{variants:_t,style:{display:`inline-block`},children:e===` `?`\xA0`:e},t))},H)})})]}),z&&(0,o.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[(0,o.jsx)(`button`,{onClick:e=>{e.stopPropagation(),R()},disabled:t,className:`transition-all duration-200 h-8 w-8 flex items-center justify-center rounded-full active:scale-95
|
|
13
|
+
${L?`text-red-500 bg-red-500/10 animate-pulse`:`text-text-400 hover:text-text-200 hover:bg-bg-200`}
|
|
14
|
+
`,"aria-label":L?`Stop listening`:`Voice input`,children:(0,o.jsx)(O.Mic,{className:`w-5 h-5`})}),(0,o.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,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:L?`Stop listening`:`Voice input`})})]}),h.length>0&&(0,o.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[(0,o.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,o.jsx)(O.SquarePen,{className:`w-5 h-5`})}),(0,o.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,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:`New chat`})})]}),(0,o.jsxs)(`div`,{className:`relative flex shrink !shrink-0 group`,children:[t?(0,o.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a()},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,o.jsx)(O.Stop,{className:`w-3.5 h-3.5 fill-current`})}):(0,o.jsx)(`button`,{onClick:e=>{e.stopPropagation(),W()},disabled:!oe,className:`inline-flex items-center justify-center shrink-0 transition-all duration-200 h-8 w-8 rounded-full active:scale-95
|
|
15
|
+
${oe?`bg-accent text-bg-0 hover:bg-accent-hover shadow-md`:`bg-bg-300 text-text-400 cursor-default opacity-50`}
|
|
16
|
+
`,type:`button`,"aria-label":`Send message`,children:(0,o.jsx)(O.ArrowUp,{className:`w-4 h-4`})}),(0,o.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,o.jsx)(`span`,{className:`text-[#ECECEC] dark:text-[#1F1E1D]`,children:t?`Stop generating`:`Send message`})})]})]})]}),(0,o.jsx)(c.AutocompleteDropdown,{...ae}),w&&(0,o.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,o.jsx)(O.Archive,{className:`w-10 h-10 text-accent mb-2 animate-bounce`}),(0,o.jsx)(`p`,{className:`text-accent font-medium`,children:`Drop files to upload`})]})]})},yt=200,bt=[`message`,`error`,`detail`];function xt(e){return e.length>yt?`${e.slice(0,199).trimEnd()}…`:e}function St(e,t){let n=t?`HTTP ${t}`:`Unknown error`;if(typeof e==`string`){let t=e.trim();return!t||t.startsWith(`<`)?n:xt(t)}if(e&&typeof e==`object`){let t=e;for(let e of bt){let n=t[e];if(typeof n==`string`&&n.trim())return xt(n.trim())}}return n}var Ct=`qwksearch_pinned_chats`;function wt(e){let t=e.messages?.[e.messages.length-1],n=t&&`createdAt`in t?t.createdAt:void 0;if(n){let e=new Date(n).getTime();if(!Number.isNaN(e))return new Date(e).toISOString()}return e.createdAt}function Tt(){if(typeof window>`u`)return[];try{let e=localStorage.getItem(Ct);return e?JSON.parse(e):[]}catch{return[]}}function Et(e){typeof window<`u`&&localStorage.setItem(Ct,JSON.stringify(e))}function Dt(){let[e,t]=(0,i.useState)([]),[r,a]=(0,i.useState)(!0),[o,s]=(0,i.useState)(!1),[c,l]=(0,i.useState)(null),[d,p]=(0,i.useState)(!1),[m,h]=(0,i.useState)(!1),[g,_]=(0,i.useState)(!1),[v,y]=(0,i.useState)([]),[b,x]=(0,i.useState)(``),[S,C]=(0,i.useState)([]),[w,T]=(0,i.useState)(!1),{isAuthenticated:E,isLoading:D}=n.c(),{incognito:O,setIncognito:k}=n.u();(0,i.useEffect)(()=>{y(Tt())},[]);let A=(0,i.useCallback)((e,t)=>{e.preventDefault(),e.stopPropagation(),y(e=>{let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];return Et(n),n})},[]),j=(0,i.useMemo)(()=>[...e].sort((e,t)=>{let n=v.includes(e.id),r=v.includes(t.id);return n&&!r?-1:!n&&r?1:0}),[e,v]),M=(0,i.useMemo)(()=>b.trim()?S:j,[b,S,j]),N=(0,i.useCallback)(async()=>{if(!D){a(!0);try{if(E){let{data:e,error:n,response:r}=await(0,f.listChats)();if(n&&r?.status===401){let e=F().map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0,lastMessageAt:wt(e)}));t(e);return}if(n)throw Error(`Failed to fetch chats: ${St(n,r?.status)}`);t(Array.isArray(e?.chats)?e.chats:[])}else{let e=F().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([]),u.toast.error(`Failed to load chat history`)}finally{a(!1)}}},[E,D]);(0,i.useEffect)(()=>{N()},[N]);let P=(e,t)=>{e.preventDefault(),e.stopPropagation(),l(t),s(!0)},I=async()=>{if(c){p(!0);try{if(E){let{error:e,response:t}=await(0,f.deleteChatById)({path:{id:c}});if(e)throw Error(`Failed to delete chat: ${St(e,t?.status)}`)}else R(c);t(e=>e.filter(e=>e.id!==c)),u.toast.success(`Chat deleted`)}catch(e){u.toast.error(e.message||`Failed to delete chat`)}finally{s(!1),l(null),p(!1)}}},L=()=>{h(!0)},B=async()=>{_(!0);try{if(E){let{error:e,response:t}=await(0,f.deleteAllChats)();if(e)throw Error(`Failed to clear history: ${St(e,t?.status)}`)}else z();t([]),u.toast.success(`All history cleared`)}catch(e){u.toast.error(e.message||`Failed to clear history`)}finally{h(!1),_(!1)}},V=()=>{k(!O),u.toast.success(O?`Private mode off`:`Private mode on — messages won't be saved`)},H=(0,i.useCallback)(async e=>{if(!e.trim())C([]),T(!1);else{T(!0);try{if(E){let{data:t,error:n,response:r}=await(0,f.searchChats)({query:{q:e}});if(n)throw Error(`Failed to search chats: ${St(n,r?.status)}`);C(Array.isArray(t?.chats)?t.chats:[])}else{let t=F().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});C(t.map(e=>({...e,messageCount:e.messages?.filter(e=>e.role===`user`).length??0,lastMessageAt:wt(e)})))}}catch(e){console.error(`Failed to search chat history:`,e),C([]),u.toast.error(`Failed to search chat history`)}finally{T(!1)}}},[E]);return(0,i.useEffect)(()=>{let e=setTimeout(()=>{H(b)},300);return()=>clearTimeout(e)},[b,H]),{chats:e,sortedChats:j,displayChats:M,loading:r,pinnedIds:v,togglePin:A,incognito:O,toggleIncognito:V,searchQuery:b,searchResults:S,searching:w,handleSearchChange:(0,i.useCallback)(e=>{x(e)},[]),deleteDialogOpen:o,setDeleteDialogOpen:s,chatToDelete:c,setChatToDelete:l,deleting:d,handleDeleteClick:P,handleConfirmDelete:I,clearAllDialogOpen:m,setClearAllDialogOpen:h,clearingAll:g,handleClearAllClick:L,handleConfirmClearAll:B}}function Ot({incognito:e,onToggleIncognito:t,showClearAll:n,onClearAll:r,searchQuery:i,onSearchChange:a}){return(0,o.jsxs)(`div`,{className:`mb-2 pb-2 border-b border-border space-y-2`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,o.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground/80 uppercase tracking-wide`,children:`Chat History`}),(0,o.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,o.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,o.jsx)(l.Lock,{size:12}),(0,o.jsx)(`span`,{children:`Private`})]}),n&&(0,o.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,o.jsx)(l.Trash2,{size:12}),(0,o.jsx)(`span`,{children:`Clear All`})]})]})]}),(0,o.jsxs)(`div`,{className:`relative`,children:[(0,o.jsx)(l.Search,{className:`absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground`,size:14}),(0,o.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,o.jsx)(`button`,{onClick:()=>a(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,o.jsx)(l.X,{size:14})})]})]})}var kt=(0,v.cva)(`inline-flex items-center justify-center rounded-2xl border px-3 py-1.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-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 transition-[color,box-shadow] overflow-hidden`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`border-transparent bg-gray-100 text-gray-700 [a&]:hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:[a&]:hover:bg-gray-700`,destructive:`border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60`,outline:`text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,new:`text-purple-600 dark:text-purple-300 bg-purple-600/30 dark:bg-purple-600/30`,beta:`text-blue-600 dark:text-blue-300 bg-blue-600/30 dark:bg-blue-600/30`,highlight:`text-green-800 dark:text-green-300 bg-green-600/30 dark:bg-green-600/30`}},defaultVariants:{variant:`default`}});function At({className:e,variant:t,asChild:n=!1,...i}){return(0,o.jsx)(n?_.Slot:`span`,{"data-slot":`badge`,className:r.o(kt({variant:t}),e),...i})}function jt({chat:e,isPinned:n,onTogglePin:i,onDelete:a}){let s=e.messageCount??0;return(0,o.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200`,children:[(0,o.jsxs)(g.default,{href:`/c/${e.id}`,onClick:n=>{t.researchAgentUIConfig.onOpenChat?.(e.id)&&n.preventDefault()},className:`flex-1 min-w-0 flex items-center gap-1.5`,children:[(0,o.jsxs)(`span`,{className:`flex items-center gap-1 shrink-0`,children:[s>0&&(0,o.jsxs)(At,{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:[s,`Q`]}),(0,o.jsx)(At,{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:r.c(new Date,e.createdAt)})]}),(0,o.jsxs)(`p`,{className:`text-xs text-popover-foreground truncate`,children:[n&&(0,o.jsx)(l.Pin,{size:10,className:`inline mr-1 text-primary`}),e.title]})]}),(0,o.jsx)(`button`,{onClick:t=>i(t,e.id),className:`p-1.5 rounded-lg transition-all duration-200 ${n?`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:n?`Unpin chat`:`Pin chat`,children:(0,o.jsx)(l.Pin,{size:14})}),(0,o.jsx)(`button`,{onClick:t=>a(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,o.jsx)(l.Trash,{size:14})})]})}function Mt({open:e,onOpenChange:t,title:n,description:i,confirmLabel:a,loadingLabel:s,loading:c,onConfirm:l}){return(0,o.jsx)(r.t,{open:e,onOpenChange:e=>{!e&&!c&&t(!1)},children:(0,o.jsxs)(r.n,{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,o.jsx)(r.i,{className:`text-lg font-medium leading-6 dark:text-white`,children:n}),(0,o.jsx)(r.r,{className:`text-sm dark:text-white/70 text-black/70 mt-2`,children:i}),(0,o.jsxs)(`div`,{className:`flex flex-row items-end justify-end space-x-4 mt-6`,children:[(0,o.jsx)(`button`,{onClick:()=>{c||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,o.jsx)(`button`,{onClick:l,disabled:c,className:`text-red-400 text-sm hover:text-red-500 transition duration-200 disabled:opacity-50`,children:c?s:a})]})]})})}function Nt({deleteDialogOpen:e,setDeleteDialogOpen:t,chatToDelete:n,setChatToDelete:r,deleting:i,onConfirmDelete:a,clearAllDialogOpen:s,setClearAllDialogOpen:c,clearingAll:l,onConfirmClearAll:u}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(Mt,{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,o.jsx)(Mt,{open:s,onOpenChange:c,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:l,onConfirm:u})]})}var Pt={Today:(0,o.jsx)(l.Sun,{size:12}),Yesterday:(0,o.jsx)(l.Clock,{size:12}),"This Week":(0,o.jsx)(l.CalendarDays,{size:12}),Older:(0,o.jsx)(l.Archive,{size:12})};function Ft(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()-5184e5),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 It=({showLabel:e=!1})=>{let t=Dt();return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(r.t,{children:[(0,o.jsxs)(r.a,{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,o.jsx)(l.History,{size:e?14:18}),e&&(0,o.jsx)(`span`,{children:`History`})]}),(0,o.jsxs)(r.n,{className:`max-w-[420px] p-3`,children:[(0,o.jsx)(r.i,{className:`sr-only`,children:`Chat History`}),(0,o.jsx)(Ot,{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,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.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,o.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,o.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,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No matching chats found.`})}):t.chats.length===0?(0,o.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,o.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No chats found.`})}):(0,o.jsx)(`div`,{className:`space-y-1 max-h-[500px] overflow-y-auto`,children:t.searchQuery.trim()?t.displayChats.map(e=>(0,o.jsx)(jt,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id)):Ft(t.displayChats).map(({label:e,chats:n})=>(0,o.jsxs)(`div`,{children:[(0,o.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:[Pt[e],e]}),n.map(e=>(0,o.jsx)(jt,{chat:e,isPinned:t.pinnedIds.includes(e.id),onTogglePin:t.togglePin,onDelete:t.handleDeleteClick},e.id))]},e))}),t.chats.length>0&&(0,o.jsx)(`div`,{className:`mt-2 pt-2 border-t border-border`,children:(0,o.jsx)(g.default,{href:`/library`,className:`block text-center text-xs text-primary hover:underline`,children:`View all chats`})})]})]}),(0,o.jsx)(Nt,{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})]})},Lt=e=>new Date(e.lastMessageAt||e.createdAt).getTime();function Rt(){let{chats:e,loading:n}=Dt(),r=[...e].sort((e,t)=>Lt(t)-Lt(e)).slice(0,5);return n||r.length===0?null:(0,o.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2 flex-wrap`,children:[(0,o.jsx)(It,{showLabel:!0}),r.map(e=>{let n=Ye(e.lastMessageAt||e.createdAt);return(0,o.jsxs)(g.default,{href:`/c/${e.id}`,onClick:n=>{t.researchAgentUIConfig.onOpenChat?.(e.id)&&n.preventDefault()},className:`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 max-w-[220px]`,title:e.title,children:[(0,o.jsx)(`span`,{className:`truncate`,children:e.title}),n&&(0,o.jsx)(`span`,{className:`italic text-muted-foreground/70 whitespace-nowrap`,children:n})]},e.id)})]})}var zt={Bot:l.Bot,BookOpen:l.BookOpen,Building2:l.Building2,Download:l.Download,HelpCircle:l.HelpCircle,Info:l.Info,Lock:l.Lock,Mail:l.Mail,MessageCircle:l.MessageCircle,Newspaper:l.Newspaper,Sparkles:l.Sparkles};function Bt({name:e}){let t=zt[e];return t?(0,o.jsx)(t,{size:14}):null}var Vt=`relative group inline-flex items-center gap-1 px-[3px] sm:px-1.5 py-0.5 rounded-md whitespace-nowrap transition-all duration-300 ease-[cubic-bezier(0.34,1.56,0.64,1)] hover:text-white hover:bg-white/10 hover:-translate-y-0.5 hover:scale-110 hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] active:scale-95 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/60`;function Ht({listFooterLinks:e=[],optionShowIcons:t=!0,optionBackgroundColor:n=`bg-black/40`}){return e.length===0?null:(0,o.jsx)(`nav`,{"aria-label":`Footer`,className:`relative z-20 mx-auto flex w-max flex-nowrap items-center justify-center gap-0 sm:gap-1 max-w-full text-slate-200 ${n} backdrop-blur-sm rounded-full px-1 sm:px-1.5 py-0.5 shadow-lg hover:shadow-xl transition-shadow duration-300`,children:e.map(({url:e,text:n,icon:r,onClick:i})=>{let a=e.startsWith(`http`),s=a?{target:`_blank`,rel:`noopener noreferrer`}:{},c=(0,o.jsxs)(o.Fragment,{children:[t&&r&&(0,o.jsx)(`span`,{className:`hidden sm:inline-flex transition-transform duration-300 group-hover:-rotate-12 group-hover:scale-125`,children:(0,o.jsx)(Bt,{name:r})}),(0,o.jsx)(`span`,{className:`font-semibold tracking-wide text-[11px] sm:text-xs`,style:{fontVariant:`small-caps`},children:n}),(0,o.jsx)(`span`,{className:`absolute bottom-0 left-1/2 w-0 h-px -translate-x-1/2 bg-current transition-all duration-300 group-hover:w-3/4 group-hover:shadow-[0_0_8px_rgba(255,255,255,0.6)]`})]});return i?(0,o.jsx)(`button`,{type:`button`,onClick:i,className:Vt,children:c},e):a?(0,o.jsx)(`a`,{href:e,...s,className:Vt,children:c},e):(0,o.jsx)(g.default,{href:e,className:Vt,children:c},e)})})}var Ut=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./ArticleExtractPanel-25tRTnpl.cjs")));function Wt(){let e=n.o()?.isOpen??!1,[t,r]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{e&&r(!0)},[e]),!t&&!e?null:(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsx)(Ut,{})})}var Gt=`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(`,`).map(e=>`https://i.imgur.com/`+e),Kt=`qwksearch-background-art-v1`,qt=`backgroundArtCache`,Jt=e=>typeof e==`string`&&Gt.includes(e);function Yt(){try{let e=JSON.parse(localStorage.getItem(`backgroundArtCache`)||`[]`);return Array.isArray(e)?[...new Set(e.filter(Jt))]:[]}catch{return[]}}function Xt(e){try{localStorage.setItem(qt,JSON.stringify(e))}catch{}}function Zt(e){let t=Yt().filter(t=>t!==e);t.push(e);let n=t.splice(0,Math.max(0,t.length-10));return Xt(t),n}function Qt(e){Xt(Yt().filter(t=>t!==e))}var $t=e=>e.length?e[Math.floor(Math.random()*e.length)]:null;function en(e){return $t(Yt().filter(t=>t!==e))}function tn(){let e=new Set(Yt());return $t(Gt.filter(t=>!e.has(t)))}async function nn(){if(typeof caches>`u`)return null;try{return await caches.open(Kt)}catch{return null}}async function rn(e){let t=await nn();if(!t)return null;try{let n=await t.match(e);return n?URL.createObjectURL(await n.blob()):(Qt(e),null)}catch{return null}}async function an(e){let t=await nn();if(!t)return e;let n;try{let t=await fetch(e,{mode:`cors`,credentials:`omit`});if(!t.ok)return null;n=await t.blob()}catch{return e}if(n.size<=15728640)try{await t.put(e,new Response(n,{headers:{"Content-Type":n.type}}));let r=Zt(e);await Promise.all(r.map(e=>t.delete(e)))}catch{}return URL.createObjectURL(n)}var on=(0,i.lazy)(()=>import(`use-weather-forecast`).then(e=>({default:e.WeatherForecast}))),sn=(0,i.lazy)(()=>import(`trending-news-api`).then(e=>({default:e.TrendingNews}))),cn=(0,i.lazy)(()=>import(`education-playlists`).then(e=>({default:e.EducationPlaylists}))),ln=(0,i.lazy)(()=>Promise.resolve().then(()=>require("./DownloadsDialog-CCPj0hA8.cjs"))),un=15;function dn(e){return e?e.split(/[,\n]/).map(e=>e.trim()).filter(Boolean):[]}function fn(e){return e?e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.split(`,`).map(e=>e.trim()),n=Number(t[t.length-2]),r=Number(t[t.length-1]);return t.length>=2&&t[t.length-2]!==``&&t[t.length-1]!==``&&Number.isFinite(n)&&Number.isFinite(r)?{label:t.slice(0,t.length-2).filter(Boolean).join(`, `)||void 0,latitude:n,longitude:r}:{label:e}}):[]}var pn=e=>e.endsWith(`.webm`)||e.endsWith(`.mp4`),mn=e=>e.startsWith(`blob:`);function hn({url:e,src:t}){return pn(e)?Promise.resolve(!0):new Promise(e=>{let n=new Image;n.decoding=`async`,n.onload=()=>e(!0),n.onerror=()=>e(!1),n.src=t})}function gn(){let{sendMessage:e}=n.u(),r=n.o(),a=r?e=>r.openPanel(e.url,``,{suggestQuestions:!0}):void 0,[s,c]=(0,i.useState)(null),[l,u]=(0,i.useState)(null),[d,f]=(0,i.useState)(!1),[p,m]=(0,i.useState)(!1),[h,g]=(0,i.useState)(!1),[_,v]=(0,i.useState)([]),[b,x]=(0,i.useState)(!0),[S,C]=(0,i.useState)(5),[w,T]=(0,i.useState)(12),[E,O]=(0,i.useState)(`fahrenheit`),[k,A]=(0,i.useState)(null),[j,M]=(0,i.useState)(!0),[N,P]=(0,i.useState)(null),[F,I]=(0,i.useState)(null),[L,R]=(0,i.useState)([]),[z,B]=(0,i.useState)(null),[V,H]=(0,i.useState)(!0),[ee,te]=(0,i.useState)(!1),[ne,U]=(0,i.useState)(!1),[re,ie]=(0,i.useState)(!1),ae=t.researchAgentUIConfig.footerLinks.map(e=>e.url===`/#downloads`?{...e,onClick:()=>{g(!0),m(!0)}}:e),W=k||t.researchAgentUIConfig.trendingNewsApiUrl,G=z?.enabled!==!1,oe=z?.allowUserTopics===!1?[]:L,se=N??z?.maxTopics??6,ce=F??z?.showImages??!0,le=j&&G;(0,i.useEffect)(()=>{let e=t.researchAgentUIConfig.trendingNewsSettingsUrl;if(!e)return;let n=!0;return fetch(e).then(e=>e.ok?e.json():null).then(e=>{n&&e&&B(e)}).catch(()=>{}),()=>{n=!1}},[]),(0,i.useEffect)(()=>{let e=()=>{v(fn(localStorage.getItem(`weatherLocations`))),x(localStorage.getItem(`showWeatherWidget`)!==`false`),C(Number(localStorage.getItem(`weatherForecastDays`))||5),T(Number(localStorage.getItem(`weatherForecastHours`))||12),O(localStorage.getItem(`weatherTemperatureUnit`)===`celsius`?`celsius`:`fahrenheit`),A(localStorage.getItem(`trendingNewsApiUrl`)),M(localStorage.getItem(`showTrendingNewsWidget`)!==`false`);let e=localStorage.getItem(`trendingNewsMaxTopics`);P(e&&Number(e)||null);let t=localStorage.getItem(`trendingNewsShowImages`);I(t===null?null:t!==`false`),R(dn(localStorage.getItem(`trendingNewsCustomTopics`))),H(localStorage.getItem(`showEducationPlaylistsWidget`)!==`false`),U(localStorage.getItem(`orbHoverGlow`)===`true`),ie(localStorage.getItem(`cursorGlowTrail`)===`true`)};return e(),window.addEventListener(`client-config-changed`,e),window.addEventListener(`storage`,e),()=>{window.removeEventListener(`client-config-changed`,e),window.removeEventListener(`storage`,e)}},[]),(0,i.useEffect)(()=>{let e,t=()=>{if(typeof window.requestIdleCallback==`function`){let t=window.requestIdleCallback(()=>te(!0),{timeout:2500});e=()=>window.cancelIdleCallback(t)}else{let t=window.setTimeout(()=>te(!0),800);e=()=>window.clearTimeout(t)}};return document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0}),()=>{window.removeEventListener(`load`,t),e?.()}},[]),(0,i.useEffect)(()=>{if(localStorage.getItem(`showBackgroundArt`)===`false`)return;let e=!1,t,n,r,i=null,a=null,o=new Set,s=e=>(e&&mn(e.src)&&o.add(e.src),e),l=e=>{e&&mn(e.src)&&(URL.revokeObjectURL(e.src),o.delete(e.src))},d=async t=>t?e||!await hn(t)?(l(t),null):t:null,p=async e=>{if(!e)return null;let t=await rn(e);return d(s(t?{url:e,src:t}:null))},m=async e=>{let t=Yt().length<10?tn():null;if(t){let e=await an(t),n=await d(s(e?{url:t,src:e}:null));if(n)return n}return p(en(e?.url))},h=e=>{let t=i;i=e,t?(u(e),f(!0),n=setTimeout(()=>{c(e),f(!1),u(null),l(t)},1e3)):c(e)},g=!1,_=async()=>{if(document.hidden||g)return;g=!0;let t=await(a??m(i));a=null,g=!1,e||(t&&h(t),a=m(i))},v=p(en()).then(t=>{t&&!e&&h(t)}),y=()=>{v.then(()=>{e||(i?a=m(i):_(),t=setInterval(_,2e4))})},b=()=>{if(typeof window.requestIdleCallback==`function`){let e=window.requestIdleCallback(y,{timeout:3e3});r=()=>window.cancelIdleCallback(e)}else{let e=window.setTimeout(y,1e3);r=()=>window.clearTimeout(e)}};return document.readyState===`complete`?b():window.addEventListener(`load`,b,{once:!0}),()=>{e=!0,window.removeEventListener(`load`,b),r?.(),clearInterval(t),clearTimeout(n);for(let e of o)URL.revokeObjectURL(e)}},[]);let ue=({url:e,src:t},n)=>pn(e)?(0,o.jsx)(`video`,{src:t,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${n}`},t):(0,o.jsx)(`img`,{src:t,alt:``,decoding:`async`,className:`absolute inset-0 w-full h-full object-cover transition-opacity duration-1000 ${n}`},t);return(0,o.jsxs)(`div`,{className:`relative min-h-screen w-full`,children:[(0,o.jsxs)(`div`,{className:`absolute inset-0 z-0`,children:[s&&ue(s,d?`opacity-0`:`opacity-30`),l&&ue(l,d?`opacity-30`:`opacity-0`),re&&(0,o.jsx)(D,{})]}),(0,o.jsx)(`div`,{className:`relative z-10`,children:(0,o.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,o.jsx)(`div`,{style:{height:`160px`,width:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},className:ne?void 0:`pointer-events-none`,children:(0,o.jsx)(y.default,{autoRandomize:!0,onSphereClick:()=>console.log(`Sphere clicked`),className:`my-custom-class`})}),(0,o.jsxs)(`div`,{className:`w-full max-w-2xl mt-2 space-y-2`,children:[(0,o.jsx)(Rt,{}),(0,o.jsx)(vt,{}),ee&&(V||b||le)&&(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsxs)(`div`,{className:`flex flex-col gap-2 w-full`,children:[V&&(0,o.jsx)(cn,{planEndpoint:t.researchAgentUIConfig.educationPlaylistsApiUrl||void 0,openHref:t.researchAgentUIConfig.educationPlaylistsPageUrl||void 0,onOpenItem:a,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`,maxWidth:`100%`}}),le&&(0,o.jsx)(sn,{expandable:!0,maxTopics:se,expandedMaxTopics:un,showImages:ce,apiEndpoint:W,topics:oe,limit:un,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`,maxWidth:`100%`}}),b&&(0,o.jsx)(on,{forecastDays:S,forecastHours:w,temperatureUnit:E,locations:_.length>0?_:void 0,className:`rounded-2xl w-full`,style:{background:`rgba(255,255,255,0.08)`,border:`1px solid rgba(255,255,255,0.15)`,color:`inherit`,backdropFilter:`blur(8px)`}})]})}),(0,o.jsx)(Ht,{listFooterLinks:ae})]})]})}),h&&(0,o.jsx)(i.Suspense,{fallback:null,children:(0,o.jsx)(ln,{open:p,onOpenChange:m})}),(0,o.jsx)(Wt,{})]})}var _n=()=>(0,o.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,o.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,o.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 vn(){return(0,o.jsx)(`div`,{className:`flex min-h-screen flex-col items-center justify-center p-8`,children:(0,o.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,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsx)(`h1`,{className:`text-2xl font-semibold text-black dark:text-white`,children:`⚠️ Configuration Required`}),(0,o.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,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsx)(`h2`,{className:`text-lg font-medium text-black dark:text-white`,children:`Quick Setup:`}),(0,o.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`1. Create environment file:`}),(0,o.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,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`2. Add required variables:`}),(0,o.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
|
|
17
|
+
DATABASE_URL=file:./data/qwksearch.db
|
|
18
|
+
|
|
19
|
+
# Auth (generate: openssl rand -base64 32)
|
|
20
|
+
BETTER_AUTH_SECRET=your-secret-here
|
|
21
|
+
BETTER_AUTH_URL=http://localhost:3000
|
|
22
|
+
NEXT_PUBLIC_BASE_URL=http://localhost:3000
|
|
23
|
+
|
|
24
|
+
# Add ONE of these providers:
|
|
25
|
+
|
|
26
|
+
# Groq (FREE - Recommended)
|
|
27
|
+
GROQ_API_KEY=gsk_your_key_here
|
|
28
|
+
|
|
29
|
+
# Or OpenAI
|
|
30
|
+
OPENAI_API_KEY=sk-your_key_here
|
|
31
|
+
OPENAI_BASE_URL=https://api.openai.com/v1
|
|
32
|
+
|
|
33
|
+
# Or Anthropic
|
|
34
|
+
ANTHROPIC_API_KEY=sk-ant-your_key_here`})]}),(0,o.jsxs)(`div`,{className:`bg-black/5 dark:bg-white/5 rounded p-4`,children:[(0,o.jsx)(`p`,{className:`font-medium text-black dark:text-white mb-2`,children:`3. Restart the server`}),(0,o.jsx)(`code`,{className:`block bg-black/10 dark:bg-white/10 rounded p-2 text-xs`,children:`Ctrl+C, then: npm run dev`})]})]}),(0,o.jsxs)(`div`,{className:`pt-4 border-t border-black/10 dark:border-white/10`,children:[(0,o.jsx)(`h3`,{className:`font-medium text-black dark:text-white mb-2`,children:`Get API Keys:`}),(0,o.jsxs)(`ul`,{className:`space-y-2 text-sm text-black/70 dark:text-white/70`,children:[(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`Groq`}),` (FREE): `,(0,o.jsx)(`a`,{href:`https://console.groq.com/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`console.groq.com/keys`})]}),(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`OpenAI`}),`: `,(0,o.jsx)(`a`,{href:`https://platform.openai.com/api-keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`platform.openai.com/api-keys`})]}),(0,o.jsxs)(`li`,{children:[(0,o.jsx)(`strong`,{children:`Anthropic`}),`: `,(0,o.jsx)(`a`,{href:`https://console.anthropic.com/settings/keys`,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:`console.anthropic.com`})]})]})]})]}),(0,o.jsxs)(`div`,{className:`text-xs text-black/50 dark:text-white/50 pt-4 border-t border-black/10 dark:border-white/10`,children:[`See `,(0,o.jsx)(`code`,{children:`SETUP_INSTRUCTIONS.md`}),` in the project root for full details.`]})]})})}var yn=()=>Promise.resolve().then(()=>require("./ChatConversationThread-BoNH0wvs.cjs")),bn=(0,i.lazy)(yn),xn=()=>{let e=(0,a.useRouter)(),{hasError:t,isReady:r,notFound:s,messages:c}=n.u(),{isAuthenticated:l}=n.c(),u=r&&!s&&c.length===0;return(0,i.useEffect)(()=>{if(!u)return;if(typeof window.requestIdleCallback==`function`){let e=window.requestIdleCallback(()=>void yn(),{timeout:5e3});return()=>window.cancelIdleCallback(e)}let e=window.setTimeout(()=>void yn(),3e3);return()=>window.clearTimeout(e)},[u]),(0,i.useEffect)(()=>{r&&s&&!l&&e.replace(`/`)},[r,s,l,e]),t?(0,o.jsx)(vn,{}):r&&s&&!l?(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(_n,{})}):r?s?(0,o.jsxs)(`div`,{className:`flex min-h-screen flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,o.jsx)(`p`,{className:`text-sm text-black/70 dark:text-white/70`,children:`This chat could not be found.`}),(0,o.jsx)(`button`,{type:`button`,onClick:()=>e.push(`/`),className:`rounded-md border border-black/15 px-3 py-1.5 text-sm hover:bg-black/5 dark:border-white/20 dark:hover:bg-white/10`,children:`Go Home`})]}):(0,o.jsx)(`div`,{children:c.length>0?(0,o.jsx)(o.Fragment,{children:(0,o.jsx)(i.Suspense,{fallback:(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(_n,{})}),children:(0,o.jsx)(bn,{})})}):(0,o.jsx)(gn,{})}):(0,o.jsx)(`div`,{className:`flex flex-row items-center justify-center min-h-screen`,children:(0,o.jsx)(_n,{})})},Sn=`https://qwksearch.com`,Cn=null,wn=Sn,Tn=!1;function En(e,t){let n;n=typeof e==`string`?e:e instanceof URL?e.href:e.url;try{let e=typeof window<`u`?window.location.href:t,r=new URL(n,e);return r.origin===t&&r.pathname.startsWith(`/api/`)}catch{return!1}}function Dn(){if(Tn||typeof window>`u`||typeof window.fetch!=`function`)return;Tn=!0;let e=window.fetch.bind(window);window.fetch=(t,n)=>{if(!Cn||!En(t,wn))return e(t,n);let r=new Headers(n?.headers??(t instanceof Request?t.headers:void 0));return!r.has(`x-api-key`)&&!r.has(`authorization`)&&r.set(`X-API-Key`,Cn),e(t,{...n,headers:r})}}function On(e,t=Sn){Cn=e||null,wn=t.replace(/\/+$/,``),Cn&&Dn()}function kn(){return Cn}function An(e,t){let n=t??(typeof window<`u`?`${window.location.pathname}${window.location.search}`:`/`);return`${e}${e.includes(`?`)?`&`:`?`}returnTo=${encodeURIComponent(n)}`}function jn(e){let t=e.qwksearchOrigin??`https://qwksearch.com`,n={connected:!1},r=new Set,i=i=>{n=i,On(i.connected?i.apiKey??null:null,t),e.onSession?.(i),r.forEach(e=>e())},a=null,o=()=>(a??=fetch(e.sessionUrl,{credentials:`same-origin`,headers:{Accept:`application/json`}}).then(async e=>e.ok?await e.json():{connected:!1}).catch(()=>({connected:!1})).then(e=>(i(e),e)).finally(()=>{a=null}),a);return{getCachedSession:()=>n,refresh:o,subscribe:e=>(r.add(e),()=>r.delete(e)),getSession:async()=>{let e=await o();return{data:e.connected&&e.user?{user:e.user}:null}},oneTap:e=>{},signIn:{social:t=>{typeof window<`u`&&window.location.assign(An(e.connectUrl))}},signOut:async t=>{try{await fetch(e.disconnectUrl,{method:`POST`,credentials:`same-origin`})}finally{i({connected:!1}),t?.fetchOptions?.onSuccess?.()}return{data:null}}}}var Mn=({onClose:e})=>(0,o.jsx)(`div`,{className:`flex items-center justify-between bg-secondary px-4 py-3 border-b border-border`,children:(0,o.jsx)(`button`,{onClick:e,className:`rounded-md p-1 hover:bg-accent transition-colors`,children:(0,o.jsx)(l.X,{className:`h-5 w-5`})})}),Nn=(0,v.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 Z({className:e,variant:t,size:n,asChild:i=!1,...a}){return(0,o.jsx)(i?_.Slot:`button`,{"data-slot":`button`,className:r.o(Nn({variant:t,size:n,className:e})),...a})}var Pn={ask:{alt:!0,key:`a`},suggest:{alt:!0,key:`s`},copy:{alt:!0,key:`c`},highlight:{alt:!0,key:`h`},favorite:{alt:!0,key:`f`},open:{alt:!0,key:`o`},zoomOut:{alt:!0,key:`-`},zoomReset:{alt:!0,key:`0`},zoomIn:{alt:!0,key:`=`},close:{alt:!1,key:`Escape`}},Fn=typeof navigator<`u`&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||``);function In(e){let{alt:t,key:n}=Pn[e],r=n===`Escape`?`Esc`:n.length===1?n.toUpperCase():n;return t?Fn?`⌥${r}`:`Alt+${r}`:r}var Ln=r.o(`h-9 w-9 rounded-xl transition-all duration-200`,`hover:bg-muted/80 hover:text-foreground text-muted-foreground`),Q=({label:e,action:t,children:r})=>(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:r}),(0,o.jsx)(n.n,{side:`bottom`,children:(0,o.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,o.jsx)(`span`,{children:e}),t&&(0,o.jsx)(`kbd`,{className:`rounded bg-primary-foreground/20 px-1 py-0.5 text-[10px] font-semibold leading-none tracking-wide`,children:In(t)})]})})]}),Rn=({isLoadingAI:e,isLoadingFollowups:t,isLoadingFavorite:n,isFavorited:i,isHighlightMode:a,articleUrl:s,fontScale:c,onAskClick:u,onSuggestClick:d,onCopyClick:f,onShareClick:p,onFavoriteClick:m,onHighlightToggle:h,onZoomIn:g,onZoomOut:_,onZoomReset:v,onClose:y})=>{let b=g||_,x=Math.round((c??1)*100);return(0,o.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,o.jsx)(Q,{label:`Ask AI about this article`,action:`ask`,children:(0,o.jsxs)(Z,{onClick:u,disabled:e,variant:`ghost`,size:`sm`,className:r.o(`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,o.jsx)(l.Bot,{className:`size-4`}),(0,o.jsx)(`span`,{className:`font-medium`,children:e?`...`:`Ask`})]})}),(0,o.jsx)(Q,{label:`Suggest follow-up questions`,action:`suggest`,children:(0,o.jsxs)(Z,{onClick:d,disabled:t,variant:`ghost`,size:`sm`,className:r.o(`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,o.jsx)(l.MessageCircleQuestion,{className:`size-4`}),(0,o.jsx)(`span`,{className:`font-medium`,children:`Suggest`})]})}),(0,o.jsx)(Q,{label:`Copy article`,action:`copy`,children:(0,o.jsx)(Z,{onClick:f,variant:`ghost`,size:`icon`,className:Ln,children:(0,o.jsx)(l.Clipboard,{className:`size-4`})})}),(0,o.jsx)(Q,{label:`Share article`,children:(0,o.jsx)(Z,{onClick:p,variant:`ghost`,size:`icon`,className:Ln,children:(0,o.jsx)(l.Share2,{className:`size-4`})})}),(0,o.jsx)(Q,{label:a?`Disable highlighting`:`Enable highlighting`,action:`highlight`,children:(0,o.jsx)(Z,{onClick:h,variant:`ghost`,size:`icon`,className:r.o(`h-9 w-9 rounded-xl transition-all duration-200`,a?`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`),children:(0,o.jsx)(l.Highlighter,{className:`size-4`})})}),(0,o.jsx)(Q,{label:i?`Remove from favorites`:`Add to favorites`,action:`favorite`,children:(0,o.jsx)(Z,{onClick:m,disabled:n,variant:`ghost`,size:`icon`,className:r.o(`h-9 w-9 rounded-xl transition-all duration-200`,i?`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`),children:(0,o.jsx)(l.Star,{className:r.o(`size-4`,i&&`fill-yellow-400`)})})}),s&&(0,o.jsx)(Q,{label:`Open in new tab`,action:`open`,children:(0,o.jsx)(Z,{asChild:!0,variant:`ghost`,size:`icon`,className:Ln,children:(0,o.jsx)(`a`,{href:s,target:`_blank`,rel:`noopener noreferrer`,children:(0,o.jsx)(l.ExternalLink,{className:`size-4`})})})}),b&&(0,o.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5 rounded-xl border border-muted/60 bg-muted/20 px-1`,children:[(0,o.jsx)(Q,{label:`Zoom out`,action:`zoomOut`,children:(0,o.jsx)(Z,{onClick:_,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted/80 hover:text-foreground`,children:(0,o.jsx)(l.ZoomOut,{className:`size-4`})})}),(0,o.jsx)(Q,{label:`Reset zoom`,action:`zoomReset`,children:(0,o.jsxs)(`button`,{type:`button`,onClick:v,className:`min-w-[3rem] rounded-md px-1 text-center text-xs font-medium tabular-nums text-muted-foreground transition-colors hover:text-foreground`,children:[x,`%`]})}),(0,o.jsx)(Q,{label:`Zoom in`,action:`zoomIn`,children:(0,o.jsx)(Z,{onClick:g,variant:`ghost`,size:`icon`,className:`h-8 w-8 rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted/80 hover:text-foreground`,children:(0,o.jsx)(l.ZoomIn,{className:`size-4`})})})]}),(0,o.jsx)(Q,{label:`Close`,action:`close`,children:(0,o.jsx)(Z,{onClick:y,variant:`ghost`,size:`icon`,className:r.o(Ln,!b&&`ml-auto`),children:(0,o.jsx)(l.X,{className:`size-4`})})})]})},zn=({value:e,onChange:t,onSubmit:n})=>(0,o.jsx)(`div`,{className:`relative`,children:(0,o.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`})}),Bn=({questions:e,isLoading:n,error:r,onQuestionClick:a})=>{let s=i.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,o.jsxs)(o.Fragment,{children:[s.length>0&&(0,o.jsxs)(`div`,{className:`space-y-3 bg-accent/30 rounded-lg p-4 border border-primary/20`,children:[(0,o.jsx)(`h3`,{className:`text-sm font-bold text-primary mb-2`,children:`💡 Suggested Follow-up Questions`}),(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.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}),s.map((e,t)=>(0,o.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))]})]}),n&&(0,o.jsx)(`div`,{className:`flex justify-center`,children:(0,o.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),r&&(0,o.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:r})]})},Vn=({response:e,isLoading:t,error:n})=>(0,o.jsxs)(o.Fragment,{children:[t&&(0,o.jsx)(`div`,{className:`flex justify-center`,children:(0,o.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500`})}),e&&(0,o.jsx)(`div`,{ref:e=>{},className:`bg-muted rounded-lg shadow-md p-4`,dangerouslySetInnerHTML:{__html:e}}),n&&(0,o.jsx)(`div`,{className:`bg-red-500 text-white p-2 rounded-md text-sm`,children:n})]}),Hn=({html:e,isHighlightMode:t=!1,fontScale:n=1})=>{let[r,a]=(0,i.useState)(``);return(0,i.useEffect)(()=>{a(b.default.sanitize(e||``,{ADD_TAGS:[`figure`,`figcaption`],ADD_ATTR:[`loading`]}))},[e]),(0,o.jsx)(`div`,{className:[`prose prose-neutral dark:prose-invert max-w-none`,`prose-p:leading-[1.9] prose-li:leading-[1.9] prose-p:my-5 prose-li:my-1.5`,`prose-headings:font-semibold prose-headings:tracking-tight prose-headings:leading-snug`,`prose-h1:mt-8 prose-h2:mt-8 prose-h3:mt-6`,`prose-blockquote:leading-[1.8] prose-blockquote:border-l-2`,`prose-img:rounded-lg prose-img:my-6`,t?`select-text`:``].join(` `),style:{fontSize:`${n}em`,fontFamily:`ui-serif, Georgia, Cambria, "Times New Roman", Times, serif`},dangerouslySetInnerHTML:{__html:r}})},Un=({article:e,isHighlightMode:t,fontScale:n=1})=>(0,o.jsx)(`div`,{className:`border-t border-border pt-6`,children:(0,o.jsxs)(`div`,{children:[(0,o.jsx)(`div`,{className:`flex items-start justify-between mb-2`}),e.cite&&(0,o.jsx)(`div`,{className:`mb-3 text-sm text-muted-foreground`,dangerouslySetInnerHTML:{__html:e.cite}}),(0,o.jsx)(`div`,{className:`mb-3 text-xs text-muted-foreground space-y-1`,children:e.word_count&&(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`span`,{className:`font-semibold`,children:`Words:`}),` `,e.word_count.toLocaleString()]})}),(0,o.jsx)(`div`,{id:`article-content`,children:(0,o.jsx)(Hn,{html:e.html||``,isHighlightMode:t,fontScale:n})})]})}),Wn=/(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g,Gn=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;function Kn(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 qn(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}function Jn(e){if(!e||typeof e!=`string`)return e;let t=e,n=[],r;for(Gn.lastIndex=0;(r=Gn.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(Wn.lastIndex=0;(a=Wn.exec(t))!==null;){let e=a[0],n=a.index;if(Gn.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}Kn(e)&&i.push({url:e,index:n})}for(let e=i.length-1;e>=0;e--){let{url:n,index:r}=i[e],a=qn(n);t=t.substring(0,r)+`[${n}](${a})`+t.substring(r+n.length)}return t}function Yn(e){return!e||e.startsWith(`http://`)||e.startsWith(`https://`)||e.includes(`://`)?!1:e.startsWith(`/`)||e.startsWith(`#`)}function Xn(e,t){if(t.startsWith(`#`)){e.preventDefault();let n=t.substring(1),r=document.getElementById(n);r&&r.scrollIntoView({behavior:`smooth`,block:`start`})}}function Zn({code:e}){let[t,n]=(0,i.useState)(!1),a=(0,i.useCallback)(async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),2e3)}catch(e){console.error(`Failed to copy:`,e)}},[e]);return(0,o.jsx)(`button`,{onClick:a,className:r.o(`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,o.jsx)(l.Check,{className:`h-4 w-4 text-green-600 dark:text-green-400`}):(0,o.jsx)(l.Copy,{className:`h-4 w-4`})})}function Qn({children:e}){let t=(0,i.useRef)(null),[n,a]=(0,i.useState)(``);return(0,i.useEffect)(()=>{if(t.current){let e=t.current.querySelector(`code`);if(e){let t=e.textContent||``;a(t.trim())}}},[e]),(0,o.jsxs)(`div`,{className:`relative group my-5`,children:[(0,o.jsx)(`pre`,{ref:t,className:r.o(`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}),n&&(0,o.jsx)(Zn,{code:n})]})}var $n=i.default.memo(({content:e,className:t,isStreaming:n=!1})=>{if(!e)return(0,o.jsx)(`div`,{className:r.o(`text-muted-foreground text-sm`,t),children:`No content`});let i=Jn(e);return(0,o.jsx)(`div`,{className:r.o(`kortix-markdown`,t),children:(0,o.jsx)(x.Streamdown,{isAnimating:n,components:{h1:({children:e})=>(0,o.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,o.jsx)(`h2`,{className:`text-xl font-semibold tracking-tight text-foreground mt-8 mb-3 first:mt-0`,children:e}),h3:({children:e})=>(0,o.jsx)(`h3`,{className:`text-lg font-semibold text-foreground mt-6 mb-2 first:mt-0`,children:e}),h4:({children:e})=>(0,o.jsx)(`h4`,{className:`text-base font-semibold text-foreground mt-5 mb-2 first:mt-0`,children:e}),h5:({children:e})=>(0,o.jsx)(`h5`,{className:`text-sm font-semibold text-foreground mt-4 mb-1 first:mt-0`,children:e}),h6:({children:e})=>(0,o.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,o.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,o.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,o.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,o.jsx)(`li`,{className:`text-sm text-foreground leading-relaxed pl-1`,children:e}),a:({href:e,children:t})=>{let n=Yn(e),i=e?.startsWith(`#`),a=r.o(`font-medium text-foreground`,`underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]`,`hover:decoration-foreground/60 transition-colors duration-150`);return i?(0,o.jsx)(`a`,{href:e,onClick:t=>Xn(t,e),className:a,children:t}):n?(0,o.jsx)(g.default,{href:e||`#`,className:a,children:t}):(0,o.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:a,children:t})},code:({children:e,className:t})=>t?.includes(`language-`)?(0,o.jsx)(`code`,{className:`text-[13px] leading-relaxed text-inherit`,children:e}):(0,o.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,o.jsx)(Qn,{children:e}),blockquote:({children:e})=>(0,o.jsx)(`blockquote`,{className:r.o(`my-5 pl-4 py-1 text-sm`,`border-l-2 border-border`,`text-muted-foreground`,`[&>p]:my-2`),children:e}),hr:()=>(0,o.jsx)(`hr`,{className:`my-8 border-0 h-px bg-border/60`}),table:({children:e})=>(0,o.jsx)(`div`,{className:`my-5 overflow-x-auto rounded-xl border border-border/60`,children:(0,o.jsx)(`table`,{className:`w-full text-sm`,children:e})}),thead:({children:e})=>(0,o.jsx)(`thead`,{className:`bg-muted/50 dark:bg-muted/30 border-b border-border/60`,children:e}),tbody:({children:e})=>(0,o.jsx)(`tbody`,{className:`divide-y divide-border/40`,children:e}),tr:({children:e})=>(0,o.jsx)(`tr`,{className:`transition-colors hover:bg-muted/30`,children:e}),th:({children:e})=>(0,o.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-semibold text-foreground uppercase tracking-wider`,children:e}),td:({children:e})=>(0,o.jsx)(`td`,{className:`px-4 py-3 text-foreground`,children:e}),img:({src:e,alt:t})=>e?(0,o.jsxs)(`span`,{className:`block my-5`,children:[(0,o.jsx)(`img`,{src:e,alt:t||``,className:r.o(`max-w-full h-auto rounded-xl`,`border border-border/40`,`shadow-sm`),loading:`lazy`}),t&&(0,o.jsx)(`span`,{className:`block mt-2 text-center text-sm text-muted-foreground`,children:t})]}):null,strong:({children:e})=>(0,o.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e}),em:({children:e})=>(0,o.jsx)(`em`,{className:`italic text-foreground/90`,children:e}),del:({children:e})=>(0,o.jsx)(`del`,{className:`line-through text-muted-foreground decoration-muted-foreground/50`,children:e}),input:({checked:e,...t})=>(0,o.jsx)(`input`,{type:`checkbox`,checked:e,readOnly:!0,className:r.o(`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,...i})=>(0,o.jsx)(`div`,{className:r.o(`text-sm text-foreground`,n),style:t,...i,children:e}),span:({children:e,style:t,className:n,...i})=>(0,o.jsx)(`span`,{className:r.o(`text-foreground`,n),style:t,...i,children:e})},children:i})})});$n.displayName=`UnifiedMarkdown`;var er=(0,i.createContext)(null),tr=`qwksearch-main-view`;function nr({children:e,docsEnabled:t=!0}){let[n,r]=(0,i.useState)(`research`),[a,s]=(0,i.useState)(0),c=(0,i.useCallback)(e=>r(t?e:`research`),[t]);(0,i.useEffect)(()=>{if(typeof window>`u`||!t)return;let e=window.localStorage.getItem(tr);(e===`research`||e===`docs`)&&r(e)},[t]),(0,i.useEffect)(()=>{typeof window<`u`&&t&&window.localStorage.setItem(tr,n)},[n,t]);let l=(0,i.useMemo)(()=>({activeView:n,setActiveView:c,docsEnabled:t,toggleToDocs:()=>c(`docs`),toggleToResearch:()=>c(`research`),filesSidebarRequestId:a,requestFilesSidebar:()=>s(e=>e+1)}),[n,c,t,a]);return(0,o.jsx)(er.Provider,{value:l,children:e})}var rr=Object.freeze({activeView:`research`,setActiveView:()=>{},docsEnabled:!1,toggleToDocs:()=>{},toggleToResearch:()=>{},filesSidebarRequestId:0,requestFilesSidebar:()=>{}}),ir=!1;function ar(){return(0,i.useContext)(er)||(!ir&&process.env.NODE_ENV!==`production`&&(ir=!0,console.error(`useMainView was called outside a MainViewProvider. The component is rendering with view switching disabled — mount it inside MainViewProvider (see QwkSearchProviders).`)),rr)}var or=[{key:`account`,name:`Account`,description:`Manage your profile, password, and linked accounts.`,icon:`UserCircle`,dataAdd:`account`},{key:`models`,name:`Language Models`,description:`Connect to AI services and manage connections.`,icon:`BrainCog`,dataAdd:`modelProviders`},{key:`mcpservers`,name:`Connectors`,description:`Configure Model Context Protocol servers.`,icon:`Server`,dataAdd:`mcpServers`},{key:`skills-memory`,name:`Skills & Memory`,description:`Manage agent skills and view your stored memories.`,icon:`Brain`,dataAdd:`skillsMemory`},{key:`searchEngines`,name:`Search Sources`,description:`Manage search engine sources by category.`,icon:`Search`,dataAdd:`searchEngines`},{key:`search`,name:`Search Settings`,description:`Configure search parameters.`,icon:`Search`,dataAdd:`search`},{key:`fileSources`,name:`Cloud Storage`,description:`Manage storage sources (SSH, S3, R2, B2, Google Docs, Turso DB).`,icon:`HardDrive`,dataAdd:`storage`},{key:`aiRewriteModes`,name:`Rewrite Modes`,description:`Customize AI rewrite prompts and add your own modes.`,icon:`Wand2`,dataAdd:`rewritePrompts`},{key:`voice`,name:`Voice Settings`,description:`Configure text-to-speech with Kokoro.js or Cloudflare TTS.`,icon:`Volume2`,dataAdd:`voice`}],sr=[{key:`webSearch`,title:`All`,description:`Searches across all of the internet`,icon:(0,o.jsx)(l.Globe,{size:16})},{key:`academicSearch`,title:`Academic`,description:`Search in published academic papers`,icon:(0,o.jsx)(l.SwatchBook,{size:16})},{key:`writingAssistant`,title:`Writing`,description:`Chat without searching the web`,icon:(0,o.jsx)(l.Pencil,{size:16})},{key:`wolframAlphaSearch`,title:`Wolfram Alpha`,description:`Computational knowledge engine`,icon:(0,o.jsx)(l.BadgePercent,{size:16})},{key:`youtubeSearch`,title:`Youtube`,description:`Search and watch videos`,icon:(0,o.jsx)(S.FaYoutube,{className:`h-[16px] w-auto mr-0.5`})},{key:`redditSearch`,title:`Reddit`,description:`Search for discussions and opinions`,icon:(0,o.jsx)(S.FaReddit,{className:`h-[16px] w-auto mr-0.5`})}],cr=[{href:`/`,label:`Research`,description:`The search and chat window`,keywords:`home chat ask question search`},{href:`/workspace`,label:`REASON Editor`,description:`Write up findings in the document editor`,keywords:`docs document write draft report`,docsOnly:!0},{href:`/library`,label:`Library`,description:`Saved chats, uploads and extracted articles`,keywords:`history saved files uploads archive`},{href:`/news`,label:`News`,description:`Trending stories by topic`,keywords:`discover trending headlines`},{href:`/docs`,label:`User Guide`,description:`How every part of the app works`,keywords:`documentation help manual`},{href:`/features`,label:`Features`,description:`Everything the research agent can do`,keywords:`capabilities tour`},{href:`/settings`,label:`Settings`,description:`Models, connectors, search sources and preferences`,keywords:`preferences configure options`},{href:`/enterprise`,label:`Enterprise`,description:`Self-hosting and team plans`,keywords:`business pricing teams`},{href:`/legal/privacy`,label:`Privacy Policy`,description:`What is stored and what is not`,keywords:`legal terms data`}];function lr(e){let t=e=>e===`/`?l.Search:e===`/workspace`?l.FileText:e===`/settings`?l.Settings:e===`/docs`?l.BookOpen:l.LayoutGrid;return cr.filter(t=>!t.docsOnly||e.docsEnabled).map(n=>({id:`page:${n.href}`,source:`page`,name:n.label,meta:n.description,keywords:`${n.keywords??``} ${n.href}`,icon:t(n.href),run:()=>e.navigate(n.href)}))}function ur(e,t){let n=new Date;return e.map(e=>({id:`chat:${e.id}`,source:`chat`,name:e.title||`Untitled chat`,meta:`${e.messageCount??0} question${(e.messageCount??0)===1?``:`s`}`,keywords:e.focusMode??``,icon:l.MessageSquare,hint:r.c(n,e.lastMessageAt||e.createdAt),run:()=>t.openChat(e.id)}))}function dr(e){return or.map(t=>({id:`setting:${t.key}`,source:`setting`,name:t.name,meta:t.description,keywords:`settings ${t.key}`,icon:l.SlidersHorizontal,run:()=>e.openSettings(t.key)}))}function fr(e){let t=[{id:`action:new-chat`,source:`action`,name:`New chat`,meta:`Start a fresh conversation`,keywords:`clear reset blank`,icon:l.Plus,run:e.newChat},{id:`action:settings`,source:`action`,name:`Open settings`,meta:`Models, connectors, search sources and preferences`,keywords:`preferences configure`,icon:l.Settings,run:()=>e.openSettings()},{id:`action:incognito`,source:`action`,name:e.incognito?`Turn off incognito`:`Turn on incognito`,meta:`Stop saving this conversation to history`,keywords:`private incognito history off`,icon:l.EyeOff,hint:e.incognito?`on`:`off`,run:()=>e.setIncognito(!e.incognito)}];for(let n of sr)t.push({id:`action:focus:${n.key}`,source:`action`,name:`Focus: ${n.title}`,meta:n.description,keywords:`focus mode ${n.key}`,icon:l.Globe,hint:e.focusMode===n.key?`current`:void 0,run:()=>e.setFocusMode(n.key)});return e.docsEnabled&&t.push({id:`action:view-docs`,source:`action`,name:`Switch to documents`,meta:`Open the REASON editor view`,keywords:`reason editor write docs`,icon:l.FileText,run:()=>e.setActiveView(`docs`)},{id:`action:view-research`,source:`action`,name:`Switch to research`,meta:`Back to the search and chat view`,keywords:`chat search`,icon:l.Search,run:()=>e.setActiveView(`research`)},{id:`action:files-sidebar`,source:`action`,name:`Show files sidebar`,meta:`Browse REASON documents`,keywords:`files documents sidebar`,icon:l.FileText,run:()=>{e.setActiveView(`docs`),e.requestFilesSidebar()}}),t.push(e.isAuthenticated?{id:`action:sign-out`,source:`action`,name:`Sign out`,meta:`End this session`,keywords:`logout log out`,icon:l.LogOut,run:e.signOut}:{id:`action:sign-in`,source:`action`,name:`Sign in`,meta:`Sync chats and settings across devices`,keywords:`login log in account`,icon:l.LogIn,run:e.signIn}),t}function pr(e,t){let n=e.trim();return n?{id:`search:ask`,source:`search`,name:n,meta:`Ask ${t.appName} — searches the web and answers with sources`,icon:l.Sparkles,hint:`Enter`,run:()=>t.ask(n)}:null}var $=[{prefix:`c`,source:`chat`,label:`chats`},{prefix:`t`,source:`page`,label:`pages`},{prefix:`s`,source:`setting`,label:`settings`},{prefix:`a`,source:`action`,label:`actions`},{prefix:`w`,source:`search`,label:`web`}];function mr(e){let t=e.match(/^([a-zA-Z])\s+(.*)$/);if(t){let e=t[1].toLowerCase(),n=$.find(t=>t.prefix===e);if(n)return{prefix:n.prefix,query:t[2]}}return{prefix:null,query:e}}var hr=18;function gr(e){return`${e.meta??``} ${e.keywords??``}`.toLowerCase()}function _r(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e.map(e=>({item:e,matchedName:!0,snippet:null}));let r=[],i=[];for(let t of e){let e=t.name.toLowerCase();if(n.every(t=>e.includes(t)))r.push(t);else{let r=`${e} ${gr(t)}`;n.every(e=>r.includes(e))&&i.push(t)}}let a=n[0];return r.sort((e,t)=>e.name.toLowerCase().indexOf(a)-t.name.toLowerCase().indexOf(a)),[...r.map(e=>({item:e,matchedName:!0,snippet:null})),...i.map(e=>({item:e,matchedName:!1,snippet:vr(gr(e),a)}))]}function vr(e,t){let n=e.indexOf(t);if(n<0)return``;let r=Math.max(0,n-hr),i=Math.min(e.length,n+t.length+hr),a=e.slice(r,i).replace(/\s+/g,` `).trim();return r>0&&(a=`…`+a),i<e.length&&(a+=`…`),a}var yr=`qwksearch:open-spotlight`,br=100,xr=6,Sr=40;function Cr(){typeof window<`u`&&window.dispatchEvent(new Event(yr))}function wr(e){return e.ctrlKey&&!e.metaKey&&!e.altKey&&(e.code===`Space`||e.key===` `)}var Tr={search:`ask`,chat:`chat`,page:`page`,setting:`setting`,action:`action`};function Er(){let[e,s]=(0,i.useState)(!1),[c,u]=(0,i.useState)(``),[d,f]=(0,i.useState)(0),p=(0,a.useRouter)(),m=n.u(),{isAuthenticated:h,signIn:g,signOut:_}=n.c(),{docsEnabled:v,setActiveView:y,requestFilesSidebar:b}=ar(),{recentChats:x,load:S}=Je(br),C=(0,i.useRef)(null),w=(0,i.useRef)(null),T=(0,i.useRef)(null),E=(0,i.useCallback)(()=>s(!1),[]),D=(0,i.useRef)(S);(0,i.useEffect)(()=>{D.current=S},[S]);let O=(0,i.useMemo)(()=>({appName:t.researchAgentUIConfig.appName,navigate:e=>p.push(e),openChat:e=>{t.researchAgentUIConfig.onOpenChat?.(e)||p.push(`/c/${e}`)},openSettings:e=>{t.researchAgentUIConfig.onOpenSettings?.(e)||p.push(e?`/settings/${e}`:`/settings`)},ask:e=>{m.newChat(),p.push(`/?q=${encodeURIComponent(e)}`)},newChat:m.newChat,focusMode:m.focusMode,setFocusMode:m.setFocusMode,incognito:m.incognito,setIncognito:m.setIncognito,isAuthenticated:h,signIn:g,signOut:_,docsEnabled:v,setActiveView:y,requestFilesSidebar:b}),[p,m.newChat,m.focusMode,m.setFocusMode,m.incognito,m.setIncognito,h,g,_,v,y,b]),{prefix:k,query:A}=mr(c),j=A.trim(),M=(0,i.useMemo)(()=>({chat:ur(x,O),page:lr(O),setting:dr(O),action:fr(O)}),[x,O]),N=(0,i.useMemo)(()=>{let e=pr(A,O);if(k===`w`)return e?[e]:[];if(k){let e=$.find(e=>e.prefix===k).source;return _r(M[e],A).map(e=>e.item).slice(0,Sr)}if(!j)return[...M.chat.slice(0,xr),...M.action,...M.page].slice(0,Sr);let t=_r([...M.action,...M.page,...M.setting,...M.chat],A).map(e=>e.item);return[...e?[e]:[],...t].slice(0,Sr)},[k,A,j,M,O]);(0,i.useEffect)(()=>{let e=e=>{wr(e)&&(e.preventDefault(),s(e=>!e))},t=()=>s(!0);return window.addEventListener(`keydown`,e),window.addEventListener(yr,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(yr,t)}},[]),(0,i.useEffect)(()=>{e?(f(0),D.current(),w.current?.focus()):(u(``),f(0))},[e]),(0,i.useEffect)(()=>{if(!e)return;let t=e=>{C.current&&!C.current.contains(e.target)&&E()};return document.addEventListener(`pointerdown`,t,!0),()=>document.removeEventListener(`pointerdown`,t,!0)},[e,E]),(0,i.useEffect)(()=>{f(e=>e<N.length?e:Math.max(0,N.length-1))},[N.length]),(0,i.useEffect)(()=>{T.current?.querySelector(`[data-selected="true"]`)?.scrollIntoView?.({block:`nearest`})},[d,N.length]);let P=(0,i.useCallback)(e=>{e&&(E(),e.run())},[E]),F=(0,i.useCallback)(()=>{let e=$.map(e=>e.prefix),t=e[((k?e.indexOf(k):-1)+1)%e.length];u(`${t} ${A}`),f(0)},[k,A]),I=e=>{switch(e.key){case`Escape`:e.preventDefault(),E();break;case`ArrowDown`:e.preventDefault(),f(e=>N.length?(e+1)%N.length:0);break;case`ArrowUp`:e.preventDefault(),f(e=>N.length?(e-1+N.length)%N.length:0);break;case`Enter`:e.preventDefault(),e.stopPropagation(),P(N[d]);break;case`Tab`:e.preventDefault(),F()}};if(!e)return null;let L=k?$.find(e=>e.prefix===k):null;return(0,o.jsx)(`div`,{className:`fixed inset-0 z-[10000] flex items-start justify-center bg-black/40 backdrop-blur-[2px] px-4 pt-[12vh]`,role:`presentation`,children:(0,o.jsxs)(`div`,{ref:C,role:`dialog`,"aria-modal":`true`,"aria-label":`Search everything`,className:`w-full max-w-xl overflow-hidden rounded-2xl border border-border bg-popover shadow-2xl`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-4`,children:[(0,o.jsx)(l.Search,{size:18,className:`shrink-0 text-muted-foreground`}),(0,o.jsx)(`input`,{ref:w,value:c,onChange:e=>{u(e.target.value),f(0)},onKeyDown:I,type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Search everything`,"aria-autocomplete":`list`,"aria-controls":`spotlight-results`,"aria-activedescendant":N[d]?.id,placeholder:L?`Search ${L.label}…`:`Search chats, pages, settings — or ask anything`,className:`w-full bg-transparent py-4 text-base text-popover-foreground outline-none placeholder:text-muted-foreground`}),L&&(0,o.jsx)(`span`,{className:`shrink-0 rounded-md bg-secondary px-2 py-0.5 text-[10px] uppercase tracking-wide text-muted-foreground`,children:L.label})]}),(0,o.jsx)(`div`,{ref:T,id:`spotlight-results`,role:`listbox`,"aria-label":`Results`,className:`max-h-[50vh] overflow-y-auto p-1`,onMouseDown:e=>e.preventDefault(),children:N.length===0?(0,o.jsx)(`p`,{className:`px-3 py-6 text-center text-sm text-muted-foreground`,children:`No matches. Press Tab to search another source.`}):N.map((e,t)=>{let n=e.icon;return(0,o.jsxs)(`div`,{id:e.id,role:`option`,"aria-selected":t===d,"data-selected":t===d,onMouseMove:()=>f(t),onClick:()=>P(e),className:r.o(`flex cursor-pointer items-center gap-3 rounded-lg px-3 py-2 transition-colors`,t===d?`bg-secondary`:`hover:bg-secondary/60`),children:[(0,o.jsx)(n,{size:16,className:r.o(`shrink-0`,t===d?`text-primary`:`text-muted-foreground`)}),(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`p`,{className:`truncate text-sm text-popover-foreground`,children:e.name}),e.meta&&(0,o.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.meta})]}),e.hint&&(0,o.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:e.hint}),(0,o.jsx)(`span`,{className:`shrink-0 rounded-md bg-secondary px-1.5 py-0 text-[10px] text-muted-foreground`,children:Tr[e.source]})]},e.id)})}),(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-t border-border px-4 py-2 text-[11px] text-muted-foreground`,children:[(0,o.jsx)(`span`,{children:`↑↓ move`}),(0,o.jsx)(`span`,{children:`↵ open`}),(0,o.jsx)(`span`,{children:`⇥ next source`}),(0,o.jsx)(`span`,{children:`esc close`}),(0,o.jsx)(`span`,{className:`ml-auto`,children:$.map(e=>`${e.prefix} ${e.label}`).join(` · `)})]})]})})}var Dr={device:`webgpu`,dtype:`fp32`},Or={device:`wasm`,dtype:`q8`},kr=`hexgrad/Kokoro-82M`,Ar=null,jr=null;function Mr(){return typeof navigator<`u`&&`gpu`in navigator}async function Nr(){if(!Mr())return!1;try{return await navigator.gpu.requestAdapter()!=null}catch{return!1}}async function Pr(e){let t=[];await Nr()&&t.push(Dr),t.push(Or);let{KokoroTTS:n}=await import(`kokoro-js`),r;for(let i of t)try{let t=await n.from_pretrained(kr,{device:i.device,dtype:i.dtype,progress_callback:e});return jr=i.device,t}catch(e){r=e,console.warn(`Kokoro model failed to load on "${i.device}" backend:`,e)}throw r instanceof Error?r:Error(`Failed to load Kokoro model`)}async function Fr(e){return Ar||=Pr(e).catch(e=>{throw Ar=null,e}),Ar}async function Ir(e){return Fr(e)}async function Lr(){let e=await Ir();return Object.keys(e.voices)}function Rr(){return jr}function zr(e,t){let[n,r]=(0,i.useState)(`idle`),[a,o]=(0,i.useState)(!1),[s,c]=(0,i.useState)([]),[l,u]=(0,i.useState)(`af_heart`),[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(null),h=(0,i.useRef)(null),g=(0,i.useRef)(null);(0,i.useEffect)(()=>{t?.autoPreload&&!a&&v()},[t?.autoPreload,a]),(0,i.useEffect)(()=>{let e=localStorage.getItem(`kokoroVoice`);e&&u(e)},[]),(0,i.useEffect)(()=>()=>{h.current&&h.current.pause(),g.current?.abort()},[]);let _=(0,i.useCallback)(()=>{h.current&&=(h.current.pause(),h.current.src.startsWith(`blob:`)&&URL.revokeObjectURL(h.current.src),null),g.current?.abort(),g.current=null},[]),v=(0,i.useCallback)(async()=>{try{r(`loading`),f(null),m(null),await Fr(e=>{m(e)});let e=await Lr();c(e),e.length&&!e.includes(l)&&u(e[0]),o(!0),r(`idle`)}catch(e){let t=e instanceof Error?e.message:`Failed to load model`;f(t),r(`error`),console.error(`Failed to load Kokoro model:`,e)}},[l]);return{status:n,modelReady:a,voices:s,selectedVoice:l,error:d,progress:p,warmupModel:v,speak:(0,i.useCallback)(async()=>{if(e?.trim()){if(!a)f(`Model not loaded. Click "Preload Model" first.`);else try{_(),r(`generating`),f(null);let t=new AbortController;g.current=t;let n=(await(await Ir()).generate(e.slice(0,5e3),{voice:l})).toWav(),i=new Blob([n],{type:`audio/wav`}),a=URL.createObjectURL(i),o=new Audio(a);h.current=o,o.onended=()=>{r(`idle`),URL.revokeObjectURL(a),h.current=null},o.onerror=()=>{r(`error`),f(`Failed to play audio`),URL.revokeObjectURL(a),h.current=null},r(`playing`),await o.play()}catch(e){if(e?.name!==`AbortError`){let t=e instanceof Error?e.message:`Speech generation failed`;f(t),r(`error`),console.error(`Kokoro TTS error:`,e)}}}},[e,l,a,_]),stop:(0,i.useCallback)(()=>{_(),r(`idle`),f(null)},[_]),changeVoice:(0,i.useCallback)(e=>{u(e),localStorage.setItem(`kokoroVoice`,e)},[]),backend:Rr()}}function Br(e,t){let[n,r]=(0,i.useState)(`stopped`),[a,o]=(0,i.useState)(!1),s=(0,i.useRef)(null),c=(0,i.useRef)(null),l=(0,i.useRef)(null),u=(0,i.useRef)(t);u.current=t;let f=(0,i.useCallback)(()=>{s.current&&=(s.current.pause(),s.current.src.startsWith(`blob:`)&&URL.revokeObjectURL(s.current.src),null),l.current?.abort(),l.current=null},[]),p=(0,i.useCallback)(()=>{f(),c.current=null,window.speechSynthesis?.cancel(),r(`stopped`),o(!1)},[f]),m=(0,i.useCallback)(()=>{if(!(`speechSynthesis`in window))return!1;try{window.speechSynthesis.cancel();let t=new SpeechSynthesisUtterance(e);return c.current=t,t.onend=()=>{c.current=null,r(`stopped`)},t.onerror=()=>{c.current=null,r(`stopped`)},window.speechSynthesis.speak(t),r(`started`),!0}catch{return!1}},[e]);return{speechStatus:n,isLoading:a,start:(0,i.useCallback)(async()=>{if(!e?.trim())return;f(),window.speechSynthesis?.cancel(),c.current=null,r(`started`),o(!0);let t=new AbortController;l.current=t;try{let n=localStorage.getItem(`useTTSKokoro`);if(n===null||n!==`false`)try{let t=await Ir(e=>{(e.status===`progress_total`||e.status===`progress`||e.status===`download`)&&console.log(`[Kokoro] Loading: ${Math.round(e.progress??0)}%`)}),n=localStorage.getItem(`kokoroVoice`)||`af_heart`,i=(await t.generate(e.slice(0,5e3),{voice:n})).toWav(),a=new Blob([i],{type:`audio/wav`}),c=URL.createObjectURL(a),l=new Audio(c);s.current=l,l.onended=()=>{r(`stopped`),URL.revokeObjectURL(c),s.current=null},l.onerror=()=>{URL.revokeObjectURL(c),s.current=null,m()||r(`stopped`)},o(!1),await l.play();return}catch(e){console.debug(`Kokoro TTS unavailable, using server-side TTS:`,e instanceof Error?e.message:String(e)),o(!1)}o(!1);let i=await(0,d.default)(`agent/voice`,{method:`POST`,body:{text:e.slice(0,5e3),voice:localStorage.getItem(`kokoroVoice`)||`af_heart`},signal:t.signal}),a=typeof i.blob==`function`?await i.blob():i;if(!a||a.size===0){m()||r(`stopped`);return}let c=URL.createObjectURL(a),l=new Audio(c);s.current=l,l.onended=()=>{r(`stopped`),URL.revokeObjectURL(c),s.current=null},l.onerror=()=>{URL.revokeObjectURL(c),s.current=null,m()||r(`stopped`)},await l.play()}catch{m()||r(`stopped`)}},[e,f,m]),stop:p}}var Vr={af_heart:`American Female - Heart`,af_bella:`American Female - Bella`,af_nicole:`American Female - Nicole`,af_sarah:`American Female - Sarah`,am_adam:`American Male - Adam`,am_michael:`American Male - Michael`,am_tony:`American Male - Tony`,bf_emma:`British Female - Emma`,bm_george:`British Male - George`,bm_thomas:`British Male - Thomas`};function Hr({preloadOnMount:e=!1}){let{status:t,modelReady:a,voices:s,selectedVoice:c,error:u,progress:d,warmupModel:f,changeVoice:p,backend:m}=zr(``,{autoPreload:e}),[h,g]=(0,i.useState)(!1),_=t===`loading`,v=t===`error`;return(0,o.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`button`,{onClick:f,disabled:_||a,className:r.o(`p-2 rounded-full transition duration-200`,a?`bg-green-500/10 text-green-600 dark:text-green-400`:`bg-white/10 dark:bg-black/10 text-muted-foreground hover:bg-white/20 dark:hover:bg-black/20`,_&&`opacity-70 cursor-not-allowed`),children:_?(0,o.jsx)(l.Loader2,{size:18,className:`animate-spin`}):(0,o.jsx)(l.Download,{size:18})})}),(0,o.jsx)(n.n,{side:`bottom`,children:_?d?d.status===`progress_total`||d.status===`progress`?`Downloading Kokoro model... ${Math.round(d.progress??0)}%`:`Loading Kokoro model... ${d.status}`:`Loading Kokoro model...`:a?`Model ready`:`Preload Kokoro.js model`})]}),a&&m&&(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[m,` • `,s.length,` voices`]}),_&&d&&(d.status===`progress_total`||d.status===`progress`||d.status===`download`)&&(0,o.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 max-w-xs`,children:[(0,o.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-white/10 dark:bg-black/10`,children:(0,o.jsx)(`div`,{className:`h-1.5 bg-blue-500 transition-all duration-200`,style:{width:`${Math.round(d.progress??0)}%`}})}),(0,o.jsxs)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap tabular-nums`,children:[Math.round(d.progress??0),`%`]})]}),v&&(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(l.AlertCircle,{size:18,className:`text-red-500`})}),(0,o.jsx)(n.n,{side:`bottom`,className:`max-w-xs`,children:u})]})]}),a&&(0,o.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,o.jsx)(`button`,{onClick:()=>g(!h),className:`w-full text-left px-3 py-2 rounded-md bg-white/5 dark:bg-black/5 hover:bg-white/10 dark:hover:bg-black/10 transition text-sm font-medium`,children:(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(l.Volume2,{size:16}),Vr[c]||c]})}),h&&(0,o.jsx)(`div`,{className:`grid grid-cols-2 gap-2 p-2 bg-white/5 dark:bg-black/5 rounded-md max-h-64 overflow-y-auto`,children:s.map(e=>(0,o.jsx)(`button`,{onClick:()=>{p(e),g(!1)},className:r.o(`p-2 text-left text-sm rounded transition duration-200`,c===e?`bg-blue-500/20 text-blue-600 dark:text-blue-400 font-medium`:`bg-white/5 dark:bg-black/5 text-foreground hover:bg-white/10 dark:hover:bg-black/10`),children:Vr[e]||e},e))})]})]})}function Ur(){let[e,t]=(0,i.useState)(!1),[a,s]=(0,i.useState)(()=>{let e=localStorage.getItem(`useTTSKokoro`);return e===null||e!==`false`}),[c,u]=(0,i.useState)(()=>localStorage.getItem(`ttsSpeaker`)||`angus`),[d,f]=(0,i.useState)(()=>fe()),{start:p,speechStatus:m}=Br(`This is a preview of the selected voice.`,{enableInterrupt:!1}),h=e=>{s(e),localStorage.setItem(`useTTSKokoro`,String(e))},g=e=>{u(e),localStorage.setItem(`ttsSpeaker`,e)},_=e=>{f(e),pe(e)};return(0,o.jsxs)(`div`,{className:`space-y-4`,children:[(0,o.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(l.Settings2,{size:18}),(0,o.jsx)(`h3`,{className:`font-semibold`,children:`Voice Settings`})]}),(0,o.jsx)(`button`,{onClick:()=>t(!e),className:`text-xs px-3 py-1 rounded-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition`,children:e?`Collapse`:`Expand`})]}),e&&(0,o.jsxs)(`div`,{className:`space-y-4 p-4 rounded-lg bg-white/5 dark:bg-black/5 border border-white/10 dark:border-black/10`,children:[(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>h(e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Use Kokoro.js (Local TTS)`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Runs locally in your browser. No server requests, lower latency, and multiple voice options.`})]})]}),a&&(0,o.jsx)(Hr,{preloadOnMount:!1})]}),(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:!a,onChange:e=>h(!e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Use Cloudflare TTS (Fallback)`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Uses Cloudflare Workers AI. Slightly higher latency but can be a fallback.`})]})]}),!a&&(0,o.jsxs)(`div`,{className:`space-y-2`,children:[(0,o.jsxs)(`select`,{value:c,onChange:e=>g(e.target.value),className:`w-full px-3 py-2 rounded-md bg-white/10 dark:bg-black/10 border border-white/20 dark:border-black/20 text-sm`,children:[(0,o.jsx)(`option`,{value:`angus`,children:`Angus`}),(0,o.jsx)(`option`,{value:`flora`,children:`Flora`}),(0,o.jsx)(`option`,{value:`james`,children:`James`}),(0,o.jsx)(`option`,{value:`natalie`,children:`Natalie`})]}),(0,o.jsxs)(`button`,{onClick:()=>p(),disabled:m===`started`,className:r.o(`w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition`,m===`started`?`bg-gray-500/20 text-gray-600 dark:text-gray-400 cursor-not-allowed`:`bg-blue-500/20 text-blue-600 dark:text-blue-400 hover:bg-blue-500/30`),children:[(0,o.jsx)(l.Volume2,{size:16}),m===`started`?`Playing...`:`Preview`]})]})]}),(0,o.jsx)(`div`,{className:`space-y-2 pt-2 border-t border-white/10 dark:border-black/10`,children:(0,o.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer`,children:[(0,o.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>_(e.target.checked),className:`rounded`}),(0,o.jsx)(`span`,{className:`font-medium text-sm`,children:`Start talking automatically on first visit`}),(0,o.jsxs)(n.t,{children:[(0,o.jsx)(n.r,{asChild:!0,children:(0,o.jsx)(`span`,{className:`text-xs text-muted-foreground cursor-help`,children:`ⓘ`})}),(0,o.jsx)(n.n,{side:`right`,className:`max-w-xs`,children:`Opens the mic the first time you load the chat composer in this browser, so you can start talking right away instead of clicking the mic button.`})]})]})}),(0,o.jsx)(`div`,{className:`text-xs text-muted-foreground pt-2 border-t border-white/10 dark:border-black/10`,children:(0,o.jsxs)(`p`,{children:[(0,o.jsx)(`strong`,{children:`Tip:`}),` Kokoro.js loads once and runs locally. The first model load may take a few seconds, but subsequent TTS generation is very fast.`]})})]})]})}var Wr=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='iso-8859-1'?%3e%3csvg%20height='800px'%20width='800px'%20version='1.1'%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%20512%20512'%20xml:space='preserve'%3e%3cpath%20style='fill:%23FE5022;'%20d='M438.802,390.609V278.595h55.174c9.938,0,18.023,8.085,18.023,18.023v75.967%20c0,9.938-8.086,18.024-18.023,18.024L438.802,390.609L438.802,390.609z'/%3e%3cpath%20style='fill:%23ECE5DD;'%20d='M28.107,511.637C12.609,511.637,0,499.027,0,483.529V134.326c0-1.441,0-12.123,0-12.123%20L121.715,0.363c0,0,10.8,0,12.248,0h271.569c15.498,0,28.107,12.609,28.107,28.106v455.059c0,15.499-12.609,28.108-28.107,28.108%20H28.107V511.637z'/%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M405.533,0.363h-31.991c15.498,0,28.107,12.609,28.107,28.107v455.059%20c0,15.499-12.609,28.108-28.107,28.108h31.991c15.498,0,28.107-12.609,28.107-28.108V28.469%20C433.64,12.972,421.031,0.363,405.533,0.363z'/%3e%3cg%3e%3cpath%20style='fill:%23BABABA;'%20d='M167.639,132.2h133.086c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318H167.639%20c-4.594,0-8.318,3.723-8.318,8.318C159.321,128.477,163.045,132.2,167.639,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M356.178,132.2h22.181c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318h-22.181%20c-4.594,0-8.318,3.723-8.318,8.318C347.86,128.477,351.584,132.2,356.178,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M242.5,212.606c0-4.595-3.724-8.318-8.318-8.318H56.734c-4.594,0-8.318,3.723-8.318,8.318%20s3.724,8.318,8.318,8.318h177.449C238.776,220.924,242.5,217.201,242.5,212.606z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M378.359,204.288h-99.815c-4.594,0-8.318,3.723-8.318,8.318s3.724,8.318,8.318,8.318h99.815%20c4.594,0,8.318-3.723,8.318-8.318S382.953,204.288,378.359,204.288z'/%3e%3c/g%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M0.726,123.171L122.442,1.331l1.39,105.939c0,9.465-7.7,17.166-17.166,17.166L0.726,123.171z'/%3e%3cpath%20style='fill:%23FFB656;'%20d='M270.226,401.7V267.504H456.87c5.938,0,10.768,4.83,10.768,10.768v112.659%20c0,5.938-4.83,10.769-10.768,10.769H270.226z'/%3e%3cpath%20style='fill:%23D9CBBD;'%20d='M367.785,335.156c-12.822,0-23.252-10.431-23.252-23.254v-44.399h89.833v44.399%20c0,12.823-10.431,23.254-23.252,23.254H367.785z'/%3e%3cg%3e%3cpath%20style='fill:%23BABABA;'%20d='M167.639,132.2h133.086c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318H167.639%20c-4.594,0-8.318,3.723-8.318,8.318C159.321,128.477,163.045,132.2,167.639,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M356.178,132.2h22.181c4.594,0,8.318-3.723,8.318-8.318c0-4.595-3.724-8.318-8.318-8.318h-22.181%20c-4.594,0-8.318,3.723-8.318,8.318C347.86,128.477,351.584,132.2,356.178,132.2z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M242.5,212.606c0-4.595-3.724-8.318-8.318-8.318H56.734c-4.594,0-8.318,3.723-8.318,8.318%20s3.724,8.318,8.318,8.318h177.449C238.776,220.924,242.5,217.201,242.5,212.606z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M378.359,204.288h-99.815c-4.594,0-8.318,3.723-8.318,8.318s3.724,8.318,8.318,8.318h99.815%20c4.594,0,8.318-3.723,8.318-8.318S382.953,204.288,378.359,204.288z'/%3e%3cpath%20style='fill:%23BABABA;'%20d='M345.087,448.28H101.096c-4.594,0-8.318,3.723-8.318,8.318c0,4.595,3.724,8.318,8.318,8.318h243.992%20c4.594,0,8.318-3.723,8.318-8.318C353.405,452.003,349.681,448.28,345.087,448.28z'/%3e%3c/g%3e%3cpath%20style='fill:%23FE5022;'%20d='M163.689,357.337c-3.692,0-6.094-3.886-4.443-7.189l16.225-32.451%20c1.799-3.597,5.416-5.833,9.438-5.833h44.282v45.471h-65.503V357.337z'/%3e%3cpolygon%20style='fill:%23FFB656;'%20points='256.918,278.252%20211.447,300.988%20211.447,368.216%20256.918,390.953%20284.321,390.953%20284.321,278.214%20'/%3e%3cg%3e%3cpath%20style='fill:%23FE5022;'%20d='M268.64,401.7c-7.075,0-12.832-5.756-12.832-12.832V280.336c0-7.075,5.756-12.831,12.832-12.831%20h19.808c7.075,0,12.832,5.756,12.832,12.831v108.532c0,7.076-5.756,12.832-12.832,12.832H268.64z'/%3e%3cpath%20style='fill:%23FE5022;'%20d='M104.156,379.377H26.143V301.33h91.398c8.546,0,14.88,7.936,12.986,16.27l-11.313,49.758%20C117.615,374.388,111.366,379.377,104.156,379.377z'/%3e%3c/g%3e%3c/svg%3e`,Gr=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20height='800px'%20width='800px'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%2064%2064'%20xml:space='preserve'%3e%3cstyle%20type='text/css'%3e%20.st0{fill:%2376C2AF;}%20.st1{fill:%234F5D73;}%20.st2{opacity:0.2;}%20.st3{fill:%23231F20;}%20.st4{fill:%23FFFFFF;}%20%3c/style%3e%3cg%20id='Layer_1'%3e%3cg%3e%3ccircle%20class='st0'%20cx='32'%20cy='32'%20r='32'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M32,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C34,51.1,33.1,52,32,52L32,52z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M46,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C48,51.1,47.1,52,46,52L46,52z'/%3e%3c/g%3e%3cg%3e%3cpath%20class='st1'%20d='M18,52c-1.1,0-2-0.9-2-2V18c0-1.1,0.9-2,2-2l0,0c1.1,0,2,0.9,2,2v32C20,51.1,19.1,52,18,52L18,52z'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='45.9'%20cy='38'%20r='4'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='32'%20cy='27'%20r='4'/%3e%3c/g%3e%3cg%20class='st2'%3e%3ccircle%20class='st3'%20cx='18'%20cy='44'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='45.9'%20cy='36'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='32'%20cy='25'%20r='4'/%3e%3c/g%3e%3cg%3e%3ccircle%20class='st4'%20cx='18'%20cy='42'%20r='4'/%3e%3c/g%3e%3c/g%3e%3cg%20id='Layer_2'%3e%3c/g%3e%3c/svg%3e`;function Kr(){let e=(0,a.usePathname)(),r=(0,a.useRouter)(),{isAuthenticated:i,signIn:s,signOut:c}=n.c(),{newChat:u}=n.u(),{activeView:d,setActiveView:f,docsEnabled:p,requestFilesSidebar:m}=ar(),h=[{href:`/`,label:`Research`,icon:t.researchAgentUIConfig.appIconUrl},...p?[{href:`/workspace`,label:`Docs`,icon:(0,o.jsx)(T.default,{src:Wr,alt:`Docs`,width:24,height:24,unoptimized:!0,className:`w-full h-full`})}]:[]],g=e===`/`||e.startsWith(`/c`),_=[...h.map(({href:e,label:t,icon:n})=>({key:e,label:t,icon:n,active:e===`/`?d===`research`:d===`docs`,onClick:()=>{e===`/`?(f(`research`),g&&u()):f(`docs`)}})),...p?[{key:`files`,label:`Files`,icon:(0,o.jsx)(l.FileText,{className:`w-full h-full p-1`}),onClick:()=>{f(`docs`),m()}}]:[],{key:`settings`,label:`Settings`,icon:(0,o.jsx)(T.default,{src:Gr,alt:`Settings`,width:24,height:24,unoptimized:!0,className:`w-full h-full`}),menu:{renderContent:()=>(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(w.DropdownMenuItem,{onClick:()=>Cr(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(l.Search,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Search`}),(0,o.jsx)(`span`,{className:`ml-auto pl-3 text-[10px] text-muted-foreground`,children:`Ctrl Space`})]}),(0,o.jsxs)(w.DropdownMenuItem,{onClick:()=>{t.researchAgentUIConfig.onOpenSettings?.()||r.push(`/settings`)},className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(l.Settings,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Settings`})]}),i?(0,o.jsxs)(w.DropdownMenuItem,{onClick:()=>c(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(l.LogOut,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Logout`})]}):(0,o.jsxs)(w.DropdownMenuItem,{onClick:()=>s(),className:`cursor-pointer py-1 h-7`,children:[(0,o.jsx)(l.LogIn,{className:`mr-2 h-3.5 w-3.5`}),(0,o.jsx)(`span`,{className:`text-sm`,children:`Login`})]}),(0,o.jsx)(w.DropdownMenuSeparator,{}),(0,o.jsx)(w.ThemeMenu,{})]})}}],v=_.filter(e=>e.key!==`files`),y=(e,t,n)=>(0,o.jsx)(T.default,{src:e,alt:t,width:n,height:n,unoptimized:!0,className:`w-full h-full`});return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(w.CategoryDock,{items:v,enableKeyboardShortcuts:!0,placements:{desktop:!0,mobile:!1},renderImage:y}),(0,o.jsx)(w.CategoryDock,{items:_,placements:{desktop:!1,mobile:!0},mobileAlign:d===`docs`?`end`:`center`,renderImage:y})]})}function qr(){return(0,o.jsx)(E.CookieConsent,{appName:t.researchAgentUIConfig.appName,links:t.researchAgentUIConfig.footerLinks,heightVar:`--qs-bottom-right-inset`})}var Jr=`qwk:chunk-error-reload`,Yr=6e4,Xr=/Loading (CSS )?chunk|ChunkLoadError|Failed to fetch dynamically imported module|error loading dynamically imported module|Importing a module script failed|Unable to preload CSS/i;function Zr(e){if(typeof e==`string`)return Xr.test(e);if(e&&typeof e==`object`){let{name:t,message:n}=e;return t===`ChunkLoadError`||typeof n==`string`&&Xr.test(n)}return!1}function Qr(e){if(typeof window>`u`||!Zr(e))return!1;try{let e=Number(window.sessionStorage.getItem(Jr));if(e&&Date.now()-e<Yr)return!1;window.sessionStorage.setItem(Jr,String(Date.now()))}catch{return!1}return window.location.reload(),!0}function $r(){(0,i.useEffect)(()=>{let e=e=>{Qr(e.error??e.message)},t=e=>{Qr(e.reason)},n=e=>{Qr(e.payload??`Loading chunk`)&&e.preventDefault()};return window.addEventListener(`error`,e),window.addEventListener(`unhandledrejection`,t),window.addEventListener(`vite:preloadError`,n),()=>{window.removeEventListener(`error`,e),window.removeEventListener(`unhandledrejection`,t),window.removeEventListener(`vite:preloadError`,n)}},[])}var ei=({children:e})=>(0,o.jsx)(o.Fragment,{children:e});function ti(e){let[t,n]=(0,i.useState)(e===!0);return(0,i.useEffect)(()=>{if(e!==`auto`){n(e);return}let t=!1;return(0,d.default)(`auth/providers`).then(e=>{t||n(!!e.providers?.includes(`google`))}).catch(()=>{t||n(!1)}),()=>{t=!0}},[e]),t}function ni({children:e,authClient:r,config:i,googleOneTap:a=`auto`,docsEnabled:s=!0,ChromeProvider:c=ei,showDock:l=!0,showCookieConsent:d=!0,showToaster:f=!0,showSpotlight:p=!0}){i&&t.configureResearchAgentUI(i);let m=ti(a);return $r(),(0,o.jsx)(C.ThemeProvider,{attribute:`class`,defaultTheme:`system`,enableSystem:!0,disableTransitionOnChange:!0,children:(0,o.jsx)(n.s,{authClient:r,enableGoogleOneTap:m,children:(0,o.jsx)(n.i,{children:(0,o.jsx)(oe,{children:(0,o.jsx)(nr,{docsEnabled:s,children:(0,o.jsx)(w.CategoryDockProvider,{children:(0,o.jsxs)(c,{children:[(0,o.jsxs)(`div`,{id:`app-scroll-root`,className:`w-screen h-screen overflow-y-auto overflow-x-hidden pb-[calc(60px+env(safe-area-inset-bottom,0px))] md:pb-0`,children:[l&&(0,o.jsx)(Kr,{}),(0,o.jsx)(`main`,{className:`bg-light-primary dark:bg-dark-primary min-h-screen`,children:e})]}),f&&(0,o.jsx)(u.Toaster,{toastOptions:{unstyled:!0,classNames:{toast:`bg-light-secondary dark:bg-dark-secondary dark:text-white/70 text-black-70 rounded-lg p-4 flex flex-row items-center space-x-2`}}}),d&&(0,o.jsx)(qr,{}),p&&(0,o.jsx)(Er,{})]})})})})})})})}function ri(e){return(0,o.jsx)(ni,{...e,docsEnabled:!1,children:(0,o.jsx)(xn,{})})}var ii=`qwksearch-open-chat-tabs`,ai=50;function oi(){if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(ii);return e?JSON.parse(e):[]}catch{return[]}}function si(){let{chatId:e,chatTurns:t,startNewChat:r,switchToChat:a}=n.u(),[o,s]=(0,i.useState)(oi);(0,i.useEffect)(()=>{window.localStorage.setItem(ii,JSON.stringify(o))},[o]),(0,i.useEffect)(()=>{if(!e)return;let n=t[0]?.content?.slice(0,ai),r=t.length>0;s(t=>{let i=t.find(t=>t.id===e);return i?n&&i.title!==n||i.hasMessages!==r?t.map(t=>t.id===e?{...t,title:n||t.title,hasMessages:r}:t):t:[...t,{id:e,title:n||`New Chat`,hasMessages:r}]})},[e,t]);let c=(0,i.useCallback)((e,t)=>{let n=t.find(t=>t.id===e);n&&!n.hasMessages?r(e):a(e)},[r,a]),l=(0,i.useCallback)(e=>{c(e,o)},[c,o]),u=(0,i.useCallback)(()=>{let e=crypto.randomUUID();return s(t=>[...t,{id:e,title:`New Chat`}]),r(e),e},[r]),d=(0,i.useCallback)(t=>{let n=new Set(t),r=o.filter(e=>!n.has(e.id));s(r);let i=e!=null&&n.has(e);if(!i)return{closedWasActive:!1,nextActiveId:null};if(r.length===0)return{closedWasActive:i,nextActiveId:null};let a=o.findIndex(t=>t.id===e),l=e=>e!=null&&!n.has(e.id),u;for(let e=a-1;e>=0&&!u;e--)l(o[e])&&(u=o[e]);for(let e=a+1;e<o.length&&!u;e++)l(o[e])&&(u=o[e]);let d=(u??r[0]).id;return c(d,r),{closedWasActive:i,nextActiveId:d}},[o,e,c]),f=(0,i.useCallback)(e=>d([e]),[d]);return{chatTabs:o,activeChatId:e??null,openChat:l,newChat:u,closeChat:f,closeChats:d}}Object.defineProperty(exports,"$",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return Mn}}),Object.defineProperty(exports,"B",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return Hn}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return Pn}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return zn}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return En}}),Object.defineProperty(exports,"G",{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,"H",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return On}}),Object.defineProperty(exports,"J",{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,"K",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return xn}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return An}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return jn}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return Rn}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return kn}}),Object.defineProperty(exports,"Q",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"R",{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return Un}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return Bn}}),Object.defineProperty(exports,"U",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(exports,"V",{enumerable:!0,get:function(){return At}}),Object.defineProperty(exports,"W",{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,"X",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"Y",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,"Z",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return mr}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Qr}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return Kr}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Br}}),Object.defineProperty(exports,"et",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return zr}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Zr}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return In}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return Ur}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Cr}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return ri}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return $r}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return Er}}),Object.defineProperty(exports,"q",{enumerable:!0,get:function(){return st}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ni}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return qr}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return si}}),Object.defineProperty(exports,"tt",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return Hr}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return Vn}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return $n}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(exports,"z",{enumerable:!0,get:function(){return It}});
|