1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{48312:function(e,t,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return r(84477)}])},84477:function(e,t,r){"use strict";r.r(t),r.d(t,{__N_SSP:function(){return e1},default:function(){return e0}});var l,a,s,n,o=r(85893),i=r(67294),d=r(88767),c=r(61162),u=r(9008),m=r.n(u);let x=e=>{let{initialState:t}=e,r=(e,r)=>{if(!r.type)return{...e,[r.field]:r.value};if("reset"===r.type)return t;throw Error()},[l,a]=(0,i.useReducer)(r,t);return(0,i.useMemo)(()=>({state:l,dispatch:a}),[l,a])},h=()=>{let{t:e}=(0,c.$G)("chat");return{getModelsError:(0,i.useMemo)(()=>t=>t?{title:e("Error fetching models."),code:t.status||"unknown",messageLines:t.statusText?[t.statusText]:[e("Make sure your OpenAI API key is set in the bottom left of the sidebar."),e("If you completed this step, OpenAI may be experiencing issues.")]}:null,[e])}},p=()=>{let e=async(e,t,r)=>{let l=(null==t?void 0:t.params)?"".concat(e).concat(t.params):e,a=(null==t?void 0:t.body)?t.body instanceof FormData?{...t,body:t.body}:{...t,body:JSON.stringify(t.body)}:t,s={...(null==t?void 0:t.headers)?t.headers:(null==t?void 0:t.body)&&t.body instanceof FormData?{}:{"Content-type":"application/json"}};return fetch(l,{...a,headers:s,signal:r}).then(e=>{if(!e.ok)throw e;let t=e.headers.get("content-type"),r=e.headers.get("content-disposition");e.headers;let l=t&&((null==t?void 0:t.indexOf("application/json"))!==-1||(null==t?void 0:t.indexOf("text/plain"))!==-1)?e.json():(null==r?void 0:r.indexOf("attachment"))!==-1?e.blob():e;return l}).catch(async e=>{let t=e.headers.get("content-type"),r=t&&(null==t?void 0:t.indexOf("application/problem+json"))!==-1?await e.json():e;throw r})};return{get:async(t,r)=>e(t,{...r,method:"get"}),post:async(t,r)=>e(t,{...r,method:"post"}),put:async(t,r)=>e(t,{...r,method:"put"}),patch:async(t,r)=>e(t,{...r,method:"patch"}),delete:async(t,r)=>e(t,{...r,method:"delete"})}},g=()=>{let e=p(),t=(0,i.useCallback)((t,r)=>e.post("/api/models",{body:{key:t.key},headers:{"Content-Type":"application/json"},signal:r}),[e]);return{getModels:t}};(l=a||(a={})).GPT_3_5="gpt-3.5-turbo",l.GPT_3_5_AZ="gpt-35-turbo",l.GPT_4="gpt-4",l.GPT_4_32K="gpt-4-32k",a.GPT_3_5;let f={[a.GPT_3_5]:{id:a.GPT_3_5,name:"GPT-3.5",maxLength:12e3,tokenLimit:4e3},[a.GPT_3_5_AZ]:{id:a.GPT_3_5_AZ,name:"GPT-3.5",maxLength:12e3,tokenLimit:4e3},[a.GPT_4]:{id:a.GPT_4,name:"GPT-4",maxLength:24e3,tokenLimit:8e3},[a.GPT_4_32K]:{id:a.GPT_4_32K,name:"GPT-4-32K",maxLength:96e3,tokenLimit:32e3}};var v=r(83454);let b="You are MistralGPT, a large language model trained by Mistral. Follow the user's instructions carefully. Respond in Swedish.";v.env.OPENAI_API_HOST;let y=parseFloat("0.7");v.env.OPENAI_API_TYPE,v.env.OPENAI_API_VERSION,v.env.OPENAI_ORGANIZATION,v.env.AZURE_DEPLOYMENT_ID;let w=e=>{let t=e;return t.model||(t={...t,model:t.model||f[a.GPT_3_5]}),t.prompt||(t={...t,prompt:t.prompt||b}),t.temperature||(t={...t,temperature:t.temperature||y}),t.folderId||(t={...t,folderId:t.folderId||null}),t.messages||(t={...t,messages:t.messages||[]}),t},j=e=>Array.isArray(e)?e.reduce((e,t)=>{try{t.model||(t.model=f[a.GPT_3_5]),t.prompt||(t.prompt=b),t.temperature||(t.temperature=y),t.folderId||(t.folderId=null),t.messages||(t.messages=[]),e.push(t)}catch(e){console.warn("error while cleaning conversations' history. Removing culprit",e)}return e},[]):(console.warn("history is not an array. Returning an empty array."),[]),k=(e,t)=>{let r=t.map(t=>t.id===e.id?e:t);return N(e),C(r),{single:e,all:r}},N=e=>{localStorage.setItem("selectedConversation",JSON.stringify(e))},C=e=>{localStorage.setItem("conversationHistory",JSON.stringify(e))},S=e=>{localStorage.setItem("folders",JSON.stringify(e))},I=e=>{localStorage.setItem("prompts",JSON.stringify(e))},E=()=>{let e={theme:"dark"},t=localStorage.getItem("settings");if(t)try{let r=JSON.parse(t);e=Object.assign(e,r)}catch(e){console.error(e)}return e};var O=r(33111),_=r(51668),P=r(86501);(s||(s={})).GOOGLE_SEARCH="google-search",(n||(n={})).GOOGLE_SEARCH="Google Search";
1let T={[s.GOOGLE_SEARCH]:{id:s.GOOGLE_SEARCH,name:n.GOOGLE_SEARCH,requiredKeys:[{key:"GOOGLE_API_KEY",value:""},{key:"GOOGLE_CSE_ID",value:""}]}},D=Object.values(T),L=e=>e&&e.id===s.GOOGLE_SEARCH?"api/google":"api/chat",G=(0,i.createContext)(void 0),Z=e=>{let{size:t="1em",className:r=""}=e;return(0,o.jsxs)("svg",{stroke:"currentColor",fill:"none",strokeWidth:"2",viewBox:"0 0 24 24",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin ".concat(r),height:t,width:t,xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,o.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,o.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,o.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,o.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,o.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,o.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,o.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})};var z=r(94568),A=r(21223),K=r(19695),R=r(59348),M=r(23461),J=r(63072);let H=e=>{let{plugin:t,onPluginChange:r,onKeyDown:l}=e,{t:a}=(0,c.$G)("chat"),s=(0,i.useRef)(null),n=e=>{let t=s.current,a=(null==t?void 0:t.options.length)||0;"/"===e.key&&e.metaKey?(e.preventDefault(),t&&(t.selectedIndex=(t.selectedIndex+1)%a,t.dispatchEvent(new Event("change")))):"/"===e.key&&e.shiftKey&&e.metaKey?(e.preventDefault(),t&&(t.selectedIndex=(t.selectedIndex-1+a)%a,t.dispatchEvent(new Event("change")))):"Enter"===e.key?(e.preventDefault(),t&&t.dispatchEvent(new Event("change")),r(D.find(e=>e.name===(null==t?void 0:t.selectedOptions[0].innerText)))):l(e)};return(0,i.useEffect)(()=>{s.current&&s.current.focus()},[]),(0,o.jsx)("div",{className:"flex flex-col",children:(0,o.jsx)("div",{className:"mb-1 w-full rounded border border-neutral-200 bg-transparent pr-2 text-neutral-900 dark:border-neutral-600 dar
1k:text-white",children:(0,o.jsxs)("select",{ref:s,className:"w-full cursor-pointer bg-transparent p-2",placeholder:a("Select a plugin")||"",value:(null==t?void 0:t.id)||"",onChange:e=>{r(D.find(t=>t.id===e.target.value))},onKeyDown:e=>{n(e)},children:[(0,o.jsx)("option",{value:"chatgpt",className:"dark:bg-[#343541] dark:text-white",children:"ChatGPT"},"chatgpt"),D.map(e=>(0,o.jsx)("option",{value:e.id,className:"dark:bg-[#343541] dark:text-white",children:e.name},e.id))]})})})},U=e=>{let{prompts:t,activePromptIndex:r,onSelect:l,onMouseOver:a,promptListRef:s}=e;return(0,o.jsx)("ul",{ref:s,className:"z-10 max-h-52 w-full overflow-scroll rounded border border-black/10 bg-white shadow-[0_0_10px_rgba(0,0,0,0.10)] dark:border-neutral-500 dark:bg-[#343541] dark:text-white dark:shadow-[0_0_15px_rgba(0,0,0,0.10)]",children:t.map((e,t)=>(0,o.jsx)("li",{className:"".concat(t===r?"bg-gray-200 dark:bg-[#202123] dark:text-black":""," cursor-pointer px-3 py-2 text-sm text-black dark:text-white"),onClick:e=>{e.preventDefault(),e.stopPropagation(),l()},onMouseEnter:()=>a(t),children:e.name},e.id))})},$=e=>{let{prompt:t,variables:r,onSubmit:l,onClose:a}=e,[s,n]=(0,i.useState)(r.map(e=>({key:e,value:""})).filter((e,t,r)=>r.findIndex(t=>t.key===e.key)===t)),d=(0,i.useRef)(null),c=(0,i.useRef)(null),u=(e,t)=>{n(r=>{let l=[...r];return l[e].value=t,l})},m=()=>{if(s.some(e=>""===e.value)){alert("Please fill out all variables");return}l(s.map(e=>e.value)),a()},x=e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&a():(e.preventDefault(),m())};return(0,i.useEffect)(()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&a()};return window.addEventListener("click",e),()=>{window.removeEventListener("click",e)}},[a]),(0,i.useEffect)(()=>{c.current&&c.current.focus()},[]),(0,o.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onKeyDown:x,children:(0,o.jsxs)("div",{ref:d,className:"dark:border-netural-400 inline-block max-h-[400px] transform overflow-y-auto rounded-lg border border-gray-300 bg-white px-4 pt-5 pb-4 text-left align-bottom shadow-xl transition-all dark:bg-[#202123] sm:my-8 sm:max-h-[600px] sm:w-full sm:max-w-lg sm:p-6 sm:align-middle",role:"dialog",children:[(0,o.jsx)("div",{className:"mb-4 text-xl font-bold text-black dark:text-neutral-200",children:t.name}),(0,o.jsx)("div",{className:"mb-4 text-sm italic text-black dark:text-neutral-200",children:t.description}),s.map((e,t)=>(0,o.jsxs)("div",{className:"mb-4",children:[(0,o.jsx)("div",{className:"mb-2 text-sm font-bold text-neutral-200",children:e.key}),(0,o.jsx)("textarea",{ref:0===t?c:void 0,className:"mt-1 w-full rounded-lg border border-neutral-500 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100",style:{resize:"none"},placeholder:"Enter a value for ".concat(e.key,"..."),value:e.value,onChange:e=>u(t,e.target.value),rows:3})]},t)),(0,o.jsx)("button",{className:"mt-6 w-full rounded-lg border border-neutral-500 px-4 py-2 text-neutral-900 shadow hover:bg-neutral-100 focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-white dark:text-black dark:hover:bg-neutral-300",onClick:m,children:"Submit"})]})})},F=e=>{var t;let{onSend:r,onRegenerate:l,onScrollDownClick:a,stopConversationRef:s,textareaRef:n,showScrollDownButton:d}=e,{t:u}=(0,c.$G)("chat"),{state:{selectedConversation:m,messageIsStreaming:x,prompts:h},dispatch:p}=(0,i.useContext)(G),[g,f]=(0,i.useState)(),[v,b]=(0,i.useState)(!1),[y,w]=(0,i.useState)(!1),[j,k]=(0,i.useState)(0),[N,C]=(0,i.useState)(""),[S,I]=(0,i.useState)([]),[E,O]=(0,i.useState)(!1),[_,P]=(0,i.useState)(!1),[T,D]=(0,i.useState)(null),L=(0,i.useRef)(null),Z=h.filter(e=>e.name.toLowerCase().includes(N.toLowerCase())),F=e=>{let t=e.target.value,r=null==m?void 0:m.model.maxLength;if(r&&t.length>r){alert(u("Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.",{maxLength:r,valueLength:t.length}));return}f(t),Q(t)},B=()=>{if(!x){if(!g){alert(u("Please enter a message"));return}r({role:"user",content:g},T),f(""),D(null),window.innerWidth<640&&n&&n.current&&n.current.blur()}},W=()=>{s.current=!0,setTimeout(()=>{s.current=!1},1e3)},Y=()=>{let e=void 0===window.navigator?"":navigator.userAgent;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(e)},q=()=>{let e=Z[j];e&&(f(t=>{let r=null==t?void 0:t.replace(/\/\w*$/,e.content);return r}),ee(e)),w(!1)},V=e=>{y?"ArrowDown"===e.key?(e.preventDefault(),k(e=>e<h.length-1?e+1:e)):"ArrowUp"===e.key?(e.preventDefault(),k(e=>e>0?e-1:e)):"Tab"===e.key?(e.preventDefault(),k(e=>e<h.length-1?e+1:0)):"Enter"===e.key?(e.preventDefault(),q()):"Escape"===e.key?(e.preventDefault(),w(!1)):k(0):"Enter"!==e.key||v||Y()||e.shiftKey?"/"===e.key&&e.metaKey&&(e.preventDefault(),P(!_)):(e.preventDefault(),B())},X=e=>{let t;let r=/{{(.*?)}}/g,l=[];for(;null!==(t=r.exec(e));)l.push(t[1]);return l},Q=(0,i.useCallback)(e=>{let t=e.match(/\/\w*$/);t?(w(!0),C(t[0].slice(1))):(w(!1),C(""))},[]),ee=e=>{let t=X(e.content);I(t),t.length>0?O(!0):(f(t=>{let r=null==t?void 0:t.replace(/\/\w*$/,e.content);return r}),Q(e.content))},et=e=>{let t=null==g?void 0:g.replace(/{{(.*?)}}/g,(t,r)=>{let l=S.indexOf(r);return e[l]});f(t),n&&n.current&&n.current.focus()};return(0,i.useEffect)(()=>{L.current&&(L.current.scrollTop=30*j)},[j]),(0,i.useEffect)(()=>
1{if(n&&n.current){var e,t;n.current.style.height="inherit",n.current.style.height="".concat(null===(e=n.current)||void 0===e?void 0:e.scrollHeight,"px"),n.current.style.overflow="".concat((null==n?void 0:null===(t=n.current)||void 0===t?void 0:t.scrollHeight)>400?"auto":"hidden")}},[g]),(0,i.useEffect)(()=>{let e=e=>{L.current&&!L.current.contains(e.target)&&w(!1)};return window.addEventListener("click",e),()=>{window.removeEventListener("click",e)}},[]),(0,o.jsxs)("div",{className:"absolute bottom-0 left-0 w-full border-transparent bg-gradient-to-b from-transparent via-white to-white pt-6 dark:border-white/20 dark:via-[#343541] dark:to-[#343541] md:pt-2",children:[(0,o.jsxs)("div",{className:"stretch mx-2 mt-4 flex flex-row gap-3 last:mb-2 md:mx-4 md:mt-[52px] md:last:mb-6 lg:mx-auto lg:max-w-3xl",children:[x&&(0,o.jsxs)("button",{className:"absolute top-0 left-0 right-0 mx-auto mb-3 flex w-fit items-center gap-3 rounded border border-neutral-200 bg-white py-2 px-4 text-black hover:opacity-50 dark:border-neutral-600 dark:bg-[#343541] dark:text-white md:mb-0 md:mt-2",onClick:W,children:[(0,o.jsx)(z.Z,{size:16})," ",u("Stop Generating")]}),!x&&m&&m.messages.length>0&&(0,o.jsxs)("button",{className:"absolute top-0 left-0 right-0 mx-auto mb-3 flex w-fit items-center gap-3 rounded border border-neutral-200 bg-white py-2 px-4 text-black hover:opacity-50 dark:border-neutral-600 dar
1k:bg-[#343541] dark:text-white md:mb-0 md:mt-2",onClick:l,children:[(0,o.jsx)(A.Z,{size:16})," ",u("Regenerate response")]}),(0,o.jsxs)("div",{className:"relative mx-2 flex w-full flex-grow flex-col rounded-md border border-black/10 bg-white shadow-[0_0_10px_rgba(0,0,0,0.10)] dark:border-gray-900/50 dark:bg-[#40414F] dark:text-white dark:shadow-[0_0_15px_rgba(0,0,0,0.10)] sm:mx-4",children:[(0,o.jsx)("button",{className:"absolute left-2 top-2 rounded-sm p-1 text-neutral-800 opacity-60 hover:bg-neutral-200 hover:text-neutral-900 dark:bg-opacity-50 dark:text-neutral-100 dark:hover:text-neutral-200",onClick:()=>P(!_),onKeyDown:e=>{},children:T?(0,o.jsx)(K.Z,{size:20}):(0,o.jsx)(R.Z,{size:20})}),_&&(0,o.jsx)("div",{className:"absolute left-0 bottom-14 rounded bg-white dark:bg-[#343541]",children:(0,o.jsx)(H,{plugin:T,onKeyDown:e=>{if("Escape"===e.key){var t;e.preventDefault(),P(!1),null===(t=n.current)||void 0===t||t.focus()}},onPluginChange:e=>{D(e),P(!1),n&&n.current&&n.current.focus()}})}),(0,o.jsx)("textarea",{ref:n,className:"m-0 w-full resize-none border-0 bg-transparent p-0 py-2 pr-8 pl-10 text-black dark:bg-transparent dark:text-white md:py-3 md:pl-10",style:{resize:"none",bottom:"".concat(null==n?void 0:null===(t=n.current)||void 0===t?void 0:t.scrollHeight,"px"),maxHeight:"400px",overflow:"".concat(n.current&&n.current.scrollHeight>400?"auto":"hidden")},placeholder:u('Type a message or type "/" to select a prompt...')||"",value:g,rows:1,onCompositionStart:()=>b(!0),onCompositionEnd:()=>b(!1),onChange:F,onKeyDown:V}),(0,o.jsx)("button",{className:"absolute right-2 top-2 rounded-sm p-1 text-neutral-800 opacity-60 hover:bg-neutral-200 hover:text-neutral-900 dark:bg-opacity-50 dark:text-neutral-100 dark:hover:text-neutral-200",onClick:B,children:x?(0,o.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-t-2 border-neutral-800 opacity-60 dark:border-neutral-100"}):(0,o.jsx)(M.Z,{size:18})}),d&&(0,o.jsx)("div",{className:"absolute bottom-12 right-0 lg:bottom-0 lg:-right-10",children:(0,o.jsx)("button",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-neutral-300 text-gray-800 shadow-md hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-neutral-200",onClick:a,children:(0,o.jsx)(J.Z,{size:18})})}),y&&Z.length>0&&(0,o.jsx)("div",{className:"absolute bottom-12 w-full",children:(0,o.jsx)(U,{activePromptIndex:j,prompts:Z,onSelect:q,onMouseOver:k,promptListRef:L})}),E&&(0,o.jsx)($,{prompt:Z[j],variables:S,onSubmit:et,onClose:()=>O(!1)})]})]}),(0,o.jsxs)("div",{className:"px-3 pt-2 pb-3 text-center text-[12px] text-black/50 dark:text-white/50 md:px-4 md:pt-3 md:pb-6",children:[(0,o.jsx)("a",{href:"https://github.com/irony/mistral-ui",target:"_blank",rel:"noreferrer",className:"underline",children:"Mistral UI"}),u(" is an adapted version of the open source project "),(0,o.jsx)("a",{href:"https://github.com/mckaywrigley/chatbot-ui",target:"_blank",rel:"noreferrer",className:"underline",children:"Chatbot UI"}),u(". Adaption by Christian Landgren, Iteam.")]})]})};var B=r(25675),W=r.n(B);let Y=()=>(0,o.jsx)("div",{className:"group border-b border-black/10 bg-gray-50 text-gray-800 dark:border-gray-900/50 dark:bg-[#444654] dark:text-gray-100",style:{overflowWrap:"anywhere"},children:(0,o.jsxs)("div",{className:"m-auto flex gap-4 p-4 text-base md:max-w-2xl md:gap-6 md:py-6 lg:max-w-2xl lg:px-0 xl:max-w-3xl",children:[(0,o.jsx)("div",{className:"min-w-[40px] items-end",children:(0,o.jsx)(W(),{src:"/favicon.ico",width:30,height:30,alt:"M"})}),(0,o.jsx)("span",{className:"animate-pulse cursor-default mt-1",children:"â"})]})});var q=r(58403);let V=e=>{let{error:t}=e;return(0,o.jsxs)("div",{className:"mx-6 flex h-full flex-col items-center justify-center text-red-500",children:[(0,o.jsx)("div",{className:"mb-5",children:(0,o.jsx)(q.Z,{size:36})}),(0,o.jsx)("div",{className:"mb-3 text-2xl font-medium",children:t.title}),t.messageLines.map((e,t)=>(0,o.jsxs)("div",{className:"text-center",children:[" ",e," "]},t)),(0,o.jsx)("div",{className:"mt-4 text-xs opacity-50 dark:text-red-400",children:t.code?(0,o.jsxs)("i",{children:["Code: ",t.code]}):""})]})};var X=r(8861),Q=r(21942),ee=r(74075),et=r(88198),er=r(93625),el=r(67828),ea=r(80335),es=r(93179),en=r(84283);let eo={javascript:".js",python:".py",java:".java",c:".c",cpp:".cpp","c++":".cpp","c#":".cs",ruby:".rb",php:".php",swift:".swift","objective-c":".m",kotlin:".kt",typescript:".ts",go:".go",perl:".pl",rust:".rs",scala:".scala",haskell:".hs",lua:".lua",shell:".sh",sql:".sql",html:".html",css:".css"},ei=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="ABCDEFGHJKLMNPQRSTUVWXY3456789",l="";for(let t=0;t<e;t++)l+=r.charAt(Math.floor(Math.random()*r.length));return t?l.toLowerCase():l},ed=(0,i.memo)(e=>{let{language:t,value:r}=e,{t:l}=(0,c.$G)("markdown"),[a,s]=(0,i.useState)(!1),n=()=>{navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(r).then(()=>{s(!0),setTimeout(()=>{s(!1)},2e3)})},d=()=>{let e=eo[t]||".file",a="file-".concat(ei(3,!0)).concat(e),s=window.prompt(l("Enter file name")||"",a);if(!s)return;let n=new Blob([r],{type:"text/plain"}),o=URL.createObjectURL(n),i=document.createElement("a");i.download=s,i.href=o,i.style.display="none",document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(o)};return(0,o.jsxs)("div",{className:"codeblock relative font-sans text-[16px]",children:[(0,o.jsxs)("div",{className:"flex items-center justify-between py-1.5 px-4",children:[(0,o.jsx)("span",{className:"text-xs lowercase text-white",children:t}),(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{className:"flex gap-1.5 items-center rounded bg-none p-1 text-xs text-white",onClick:n,children:[a?(0,o.jsx)(et.Z,{size:18}):(0,o.jsx)(el.Z,{size:18}),a?l("Copied!"):l("Copy code")]}),(0,o.jsx)("button",{className:"flex items-center rounded bg-none p-1 text-xs text-white",onClick:d,children:(0,o.jsx)(ea.Z,{size:18})})]})]}),(0,o.jsx)(es.Z,{language:t,style:en.vk,customStyle:{margin:0},children:r})]})});ed.displayName="CodeBlock";var ec=r(16202);let eu=(0,i.memo)(ec.D,(e,t)=>e.children===t.children);var em=r(45884),ex=r(29758),eh=r(30399);let ep=(0,i.memo)(e=>{var t;let{message:r,messageIndex:l,onEdit:a}=e,{t:s}=(0,c.$G)("chat"),{state:{selectedConversation:n,conversations:d,currentMessage:u,messageIsStreaming:m},dispatch:x}=(0,i.useContext)(G),[h,p]=(0,i.useState)(!1),[g,f]=(0,i.useState)(!1),[v,b]=(0,i.useState)(r.content),[y,w]=(0,i.useState)(!1),j=(0,i.useRef)(null),N=()=>{p(!h)},C=e=>{b(e.target.value),j.current&&(j.current.style.height="inherit",j.current.style.height="".concat(j.current.scrollHeight,"px"))},S=()=>{r.content!=v&&n&&a&&a({...r,content:v}),p(!1)},I=()=>
1{if(!n)return;let{messages:e}=n,t=e.findIndex(e=>e===r);if(t<0)return;t<e.length-1&&"assistant"===e[t+1].role?e.splice(t,2):e.splice(t,1);let l={...n,messages:e},{single:a,all:s}=k(l,d);x({field:"selectedConversation",value:a}),x({field:"conversations",value:s})},E=e=>{"Enter"!==e.key||g||e.shiftKey||(e.preventDefault(),S())},O=()=>{navigator.clipboard&&navigator.clipboard.writeText(r.content).then(()=>{w(!0),setTimeout(()=>{w(!1)},2e3)})};return(0,i.useEffect)(()=>{b(r.content)},[r.content]),(0,i.useEffect)(()=>{j.current&&(j.current.style.height="inherit",j.current.style.height="".concat(j.current.scrollHeight,"px"))},[h]),(0,o.jsx)("div",{className:"group md:px-4 ".concat("assistant"===r.role?"border-b border-black/10 bg-gray-50 text-gray-800 dark:border-gray-900/50 dark:bg-[#444654] dark:text-gray-100":"border-b border-black/10 bg-white text-gray-800 dark:border-gray-900/50 dark:bg-[#343541] dark:text-gray-100"),style:{overflowWrap:"anywhere"},children:(0,o.jsxs)("div",{className:"relative m-auto flex p-4 text-base md:max-w-2xl md:gap-6 md:py-6 lg:max-w-2xl lg:px-0 xl:max-w-3xl",children:[(0,o.jsx)("div",{className:"min-w-[40px] text-right font-bold",children:"assistant"===r.role?(0,o.jsx)(W(),{src:"/favicon.ico",alt:"M",width:30,height:30}):(0,o.jsx)(X.Z,{size:30})}),(0,o.jsx)("div",{className:"prose mt-[-2px] w-full dark:prose-invert",children:"user"===r.role?(0,o.jsxs)("div",{className:"flex w-full",children:[h?(0,o.jsxs)("div",{className:"flex w-full flex-col",children:[(0,o.jsx)("textarea",{ref:j,className:"w-full resize-none whitespace-pre-wrap border-none dark:bg-[#343541]",value:v,onChange:C,onKeyDown:E,onCompositionStart:()=>f(!0),onCompositionEnd:()=>f(!1),style:{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit",padding:"0",margin:"0",overflow:"hidden"}}),(0,o.jsxs)("div",{className:"mt-10 flex justify-center space-x-4",children:[(0,o.jsx)("button",{className:"h-[40px] rounded-md bg-blue-500 px-4 py-1 text-sm font-medium text-white enabled:hover:bg-blue-600 disabled:opacity-50",onClick:S,disabled:v.trim().length<=0,children:s("Save & Submit")}),(0,o.jsx)("button",{className:"h-[40px] rounded-md border border-neutral-300 px-4 py-1 text-sm font-medium text-neutral-700 hover:bg-neutral-100 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-800",onClick:()=>{b(r.content),p(!1)},children:s("Cancel")})]})]}):(0,o.jsx)("div",{className:"prose whitespace-pre-wrap dark:prose-invert flex-1",children:r.content}),!h&&(0,o.jsxs)("div",{className:"md:-mr-8 ml-1 md:ml-0 flex flex-col md:flex-row gap-4 md:gap-1 items-center md:items-start justify-end md:justify-start",children:[(0,o.jsx)("button",{className:"invisible group-hover:visible focus:visible text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",onClick:N,children:(0,o.jsx)(Q.Z,{size:20})}),(0,o.jsx)("button",{className:"invisible group-hover:visible focus:visible text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",onClick:I,children:(0,o.jsx)(ee.Z,{size:20})})]})]}):(0,o.jsxs)("div",{className:"flex flex-row",children:[(0,o.jsx)(eu,{className:"prose dark:prose-invert flex-1",remarkPlugins:[ex.Z,eh.Z],rehypePlugins:[em.Z],components:{code(e){let{node:t,inline:r,className:l,children:a,...s}=e;if(a.length){if("â"==a[0])return(0,o.jsx)("span",{className:"animate-pulse cursor-default mt-1",children:"â"});a[0]=a[0].replace("`â`","â")}let n=/language-(\w+)/.exec(l||"");return r?(0,o.jsx)("code",{className:l,...s,children:a}):(0,o.jsx)(ed,{language:n&&n[1]||"",value:String(a).replace(/\n$/,""),...s},Math.random())},table(e){let{children:t}=e;return(0,o.jsx)("table",{className:"border-collapse border border-black px-3 py-1 dark:border-white",children:t})},th(e){let{children:t}=e;return(0,o.jsx)("th",{className:"break-words border border-black bg-gray-500 px-3 py-1 text-white dark:border-white",children:t})},td(e){let{children:t}=e;return(0,o.jsx)("td",{className:"break-words border border-black px-3 py-1 dark:border-white",children:t})}},children:"".concat(r.content).concat(m&&l==(null!==(t=null==n?void 0:n.messages.length)&&void 0!==t?t:0)-1?"`â`":"")}),(0,o.jsx)("div",{className:"md:-mr-8 ml-1 md:ml-0 flex flex-col md:flex-row gap-4 md:gap-1 items-center md:items-start justify-end md:justify-start",children:y?(0,o.jsx)(et.Z,{size:20,className:"text-green-500 dark:text-green-400"}):(0,o.jsx)("button",{className:"invisible group-hover:visible focus:visible text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",onClick:O,children:(0,o.jsx)(er.Z,{size:20})})})]})})]})})});ep.displayName="ChatMessage";let eg=(0,i.memo)(ep,(e,t)=>e.message.content===t.message.content);var ef=r(93844);let ev=()=>{var e;let{t}=(0,c.$G)("chat"),{state:{selectedConversation:r,models:l,defaultModelId:a}
1,handleUpdateConversation:s,dispatch:n}=(0,i.useContext)(G),d=e=>{r&&s(r,{key:"model",value:l.find(t=>t.id===e.target.value)})};return(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("label",{className:"mb-2 text-left text-neutral-700 dark:text-neutral-400",children:t("Model")}),(0,o.jsx)("div",{className:"w-full rounded-lg border border-neutral-200 bg-transparent pr-2 text-neutral-900 dark:border-neutral-600 dark:text-white",children:(0,o.jsx)("select",{className:"w-full bg-transparent p-2",placeholder:t("Select a model")||"",value:(null==r?void 0:null===(e=r.model)||void 0===e?void 0:e.id)||a,onChange:d,children:l.map(e=>(0,o.jsx)("option",{value:e.id,className:"dark:bg-[#343541] dark:text-white",children:e.id===a?"Default (".concat(e.name,")"):e.name},e.id))})}),(0,o.jsx)("div",{className:"w-full mt-3 text-left text-neutral-700 dark:text-neutral-400 flex items-center",children:(0,o.jsxs)("a",{href:"https://console.mistral.ai/billing",target:"_blank",className:"flex items-center",children:[(0,o.jsx)(ef.Z,{size:18,className:"inline mr-1"}),t("View Account Usage")]})})]})},eb=e=>{var t;let{conversation:r,prompts:l,onChangePrompt:a}=e,{t:s}=(0,c.$G)("chat"),[n,d]=(0,i.useState)(""),[u,m]=(0,i.useState)(0),[x,h]=(0,i.useState)(!1),[p,g]=(0,i.useState)(""),[f,v]=(0,i.useState)([]),[y,w]=(0,i.useState)(!1),j=(0,i.useRef)(null),k=(0,i.useRef)(null),N=l.filter(e=>e.name.toLowerCase().includes(p.toLowerCase())),C=e=>{let t=e.target.value,l=r.model.maxLength;if(t.length>l){alert(s("Prompt limit is {{maxLength}} characters. You have entered {{valueLength}} characters.",{maxLength:l,valueLength:t.length}));return}d(t),E(t),t.length>0&&a(t)},S=()=>{let e=N[u];d(t=>{let r=null==t?void 0:t.replace(/\/\w*$/,e.content);return r}),O(e),h(!1)},I=e=>{let t;let r=/{{(.*?)}}/g,l=[];for(;null!==(t=r.exec(e));)l.push(t[1]);return l},E=(0,i.useCallback)(e=>{let t=e.match(/\/\w*$/);t?(h(!0),g(t[0].slice(1))):(h(!1),g(""))},[]),O=e=>{let t=I(e.content);if(v(t),t.length>0)w(!0);else{let t=null==n?void 0:n.replace(/\/\w*$/,e.content);d(t),a(t),E(e.content)}},_=e=>{let t=null==n?void 0:n.replace(/{{(.*?)}}/g,(t,r)=>{let l=f.indexOf(r);return e[l]});d(t),a(t),j&&j.current&&j.current.focus()},P=e=>{x&&("ArrowDown"===e.key?(e.preventDefault(),m(e=>e<l.length-1?e+1:e)):"ArrowUp"===e.key?(e.preventDefault(),m(e=>e>0?e-1:e)):"Tab"===e.key?(e.preventDefault(),m(e=>e<l.length-1?e+1:0)):"Enter"===e.key?(e.preventDefault(),S()):"Escape"===e.key?(e.preventDefault(),h(!1)):m(0))};return(0,i.useEffect)(()=>{if(j&&j.current){var e;j.current.style.height="inherit",j.current.style.height="".concat(null===(e=j.current)||void 0===e?void 0:e.scrollHeight,"px")}},[n]),(0,i.useEffect)(()=>{r.prompt?d(r.prompt):d(b)},[r]),(0,i.useEffect)(()=>{let e=e=>{k.current&&!k.current.contains(e.target)&&h(!1)};return window.addEventListener("click",e),()=>{window.removeEventListener("click",e)}},[]),(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("label",{className:"mb-2 text-left text-neutral-700 dark:text-neutral-400",children:s("System Prompt")}),(0,o.jsx)("textarea",{ref:j,className:"w-full rounded-lg border border-neutral-200 bg-transparent px-4 py-3 text-neutral-900 dark:border-neutral-600 dar
1k:text-neutral-100",style:{resize:"none",bottom:"".concat(null==j?void 0:null===(t=j.current)||void 0===t?void 0:t.scrollHeight,"px"),maxHeight:"300px",overflow:"".concat(j.current&&j.current.scrollHeight>400?"auto":"hidden")},placeholder:s('Enter a prompt or type "/" to select a prompt...')||"",value:s(n)||"",rows:1,onChange:C,onKeyDown:P}),x&&N.length>0&&(0,o.jsx)("div",{children:(0,o.jsx)(U,{activePromptIndex:u,prompts:N,onSelect:S,onMouseOver:m,promptListRef:k})}),y&&(0,o.jsx)($,{prompt:l[u],variables:f,onSubmit:_,onClose:()=>w(!1)})]})},ey=e=>{var t;let{label:r,onChangeTemperature:l}=e,{state:{conversations:a}}=(0,i.useContext)(G),s=a[a.length-1],[n,d]=(0,i.useState)(null!==(t=null==s?void 0:s.temperature)&&void 0!==t?t:y),{t:u}=(0,c.$G)("chat"),m=e=>{let t=parseFloat(e.target.value);d(t),l(t)};return(0,o.jsxs)("div",{className:"flex flex-col",children:[(0,o.jsx)("label",{className:"mb-2 text-left text-neutral-700 dark:text-neutral-400",children:r}),(0,o.jsx)("span",{className:"text-[12px] text-black/50 dark:text-white/50 text-sm",children:u("Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.")}),(0,o.jsx)("span",{className:"mt-2 mb-1 text-center text-neutral-900 dark:text-neutral-100",children:n.toFixed(1)}),(0,o.jsx)("input",{className:"cursor-pointer",type:"range",min:0,max:1,step:.1,value:n,onChange:m}),(0,o.jsxs)("ul",{className:"w mt-2 pb-8 flex justify-between px-[24px] text-neutral-900 dark:text-neutral-100",children:[(0,o.jsx)("li",{className:"flex justify-center",children:(0,o.jsx)("span",{className:"absolute",children:u("Precise")})}),(0,o.jsx)("li",{className:"flex justify-center",children:(0,o.jsx)("span",{className:"absolute",children:u("Neutral")})}),(0,o.jsx)("li",{className:"flex justify-center",children:(0,o.jsx)("span",{className:"absolute",children:u("Creative")})})]})]})},ew=(0,i.memo)(e=>{let t,r,{stopConversationRef:l}=e,{t:a}=(0,c.$G)("chat"),{state:{selectedConversation:s,conversations:n,models:d,apiKey:u,pluginKeys:m,serverSideApiKeyIsSet:x,messageIsStreaming:h,modelError:p,loading:g,prompts:f},handleUpdateConversation:v,dispatch:b}=(0,i.useContext)(G),[y,w]=(0,i.useState)(),[j,S]=(0,i.useState)(!0),[I,E]=(0,i.useState)(!1),[T,D]=(0,i.useState)(!1),z=(0,i.useRef)(null),A=(0,i.useRef)(null),K=(0,i.useRef)(null),R=(0,i.useCallback)(async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(s){let c,x;if(t){let r=[...s.messages];for(let e=0;e<t;e++)r.pop();c={...s,messages:[...r,e]}}else c={...s,messages:[...s.messages,e]};b({field:"selectedConversation",value:c}),b({field:"loading",value:!0}),b({field:"messageIsStreaming",value:!0});let h={model:c.model,messages:c.messages,key:u,prompt:c.prompt,temperature:c.temperature},p=L(r);if(r){var a,o,i,d;x=JSON.stringify({...h,googleAPIKey:null===(a=null===(o=m.find(e=>"google-search"===e.pluginId))||void 0===o?void 0:o.requiredKeys.find(e=>"GOOGLE_API_KEY"===e.key))||void 0===a?void 0:a.value,googleCSEId:null===(i=null===(d=m.find(e=>"google-search"===e.pluginId))||void 0===d?void 0:d.requiredKeys.find(e=>"GOOGLE_CSE_ID"===e.key))||void 0===i?void 0:i.value})}else x=JSON.stringify(h);let g=new AbortController,f=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json"},signal:g.signal,body:x});if(!f.ok){b({field:"loading",value:!1}),b({field:"messageIsStreaming",value:!1}),P.ZP.error(f.statusText);return}let v=f.body;if(!v){b({field:"loading",value:!1}),b({field:"messageIsStreaming",value:!1});return}if(r){let{answer:e}=await f.json(),t=[...c.messages,{role:"assistant",content:e}];c={...c,messages:t},b({field:"selectedConversation",value:k}),N(c);let r=n.map(e=>e.id===s.id?c:e);0===r.length&&r.push(c),b({field:"conversations",value:r}),C(r),b({field:"loading",value:!1}),b({field:"messageIsStreaming",value:!1})}else{if(1===c.messages.length){let{content:t}=e,r=t.length>30?t.substring(0,30)+"...":t;c={...c,name:r}}b({field:"loading",value:!1});let t=v.getReader(),r=new TextDecoder,a=!1,o=!0,i="";for(;!a;){if(!0===l.current){g.abort(),a=!0;break}let{value:e,done:s}=await t.read();a=s;let n=r.decode(e);if(i+=n,o){o=!1;let e=[...c.messages,{role:"assistant",content:n}];b({field:"selectedConversation",value:c={...c,messages:e}})}else{let e=c.messages.map((e,t)=>t===c.messages.length-1?{...e,content:i}:e);b({field:"selectedConversation",value:c={...c,messages:e}})}}N(c);let d=n.map(e=>e.id===s.id?c:e);0===d.length&&d.push(c),b({field:"conversations",value:d}),C(d),b({field:"messageIsStreaming",value:!1})}}}
1,[u,n,m,s,l]);(0,i.useCallback)(()=>{if(j){var e,t;null===(e=z.current)||void 0===e||e.scrollIntoView({behavior:"smooth"}),null===(t=K.current)||void 0===t||t.focus()}},[j]);let M=()=>{if(A.current){let{scrollTop:e,scrollHeight:t,clientHeight:r}=A.current;e+r<t-30?(S(!1),D(!0)):(S(!0),D(!1))}},J=()=>{var e;null===(e=A.current)||void 0===e||e.scrollTo({top:A.current.scrollHeight,behavior:"smooth"})},H=()=>{E(!I)},U=()=>{confirm(a("Are you sure you want to clear all messages?"))&&s&&v(s,{key:"messages",value:[]})},$=()=>{if(j){var e;null===(e=z.current)||void 0===e||e.scrollIntoView(!0)}},B=function(){for(var e=arguments.length,l=Array(e),a=0;a<e;a++)l[a]=arguments[a];r?(clearTimeout(t),t=setTimeout(()=>{Date.now()-r>=250&&($(...l),r=Date.now())},250-(Date.now()-r))):($(...l),r=Date.now())};return(0,i.useEffect)(()=>{B(),s&&w(s.messages[s.messages.length-2])},[s,B]),(0,i.useEffect)(()=>{let e=new IntersectionObserver(e=>{let[t]=e;if(S(t.isIntersecting),t.isIntersecting){var r;null===(r=K.current)||void 0===r||r.focus()}},{root:null,threshold:.5}),t=z.current;return t&&e.observe(t),()=>{t&&e.unobserve(t)}},[z]),(0,o.jsx)("div",{className:"relative flex-1 overflow-hidden bg-white dark:bg-[#343541]",children:u||x?p?(0,o.jsx)(V,{error:p}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("div",{className:"max-h-full overflow-x-hidden",ref:A,onScroll:M,children:(null==s?void 0:s.messages.length)===0?(0,o.jsx)(o.Fragment,{children:(0,o.jsxs)("div",{className:"mx-auto flex flex-col space-y-5 md:space-y-10 px-3 pt-5 md:pt-12 sm:max-w-[600px]",children:[(0,o.jsx)("div",{className:"text-center text-3xl font-semibold text-gray-800 dark:text-gray-100",children:0===d.length?(0,o.jsx)("div",{children:(0,o.jsx)(Z,{size:"16px",className:"mx-auto"})}):"Mistral UI"}),d.length>0&&(0,o.jsxs)("div",{className:"flex h-full flex-col space-y-4 rounded-lg border border-neutral-200 p-4 dark:border-neutral-600",children:[(0,o.jsx)(ev,{}),(0,o.jsx)(eb,{conversation:s,prompts:f,onChangePrompt:e=>v(s,{key:"prompt",value:e})}),(0,o.jsx)(ey,{label:a("Temperature"),onChangeTemperature:e=>v(s,{key:"temperature",value:e})})]})]})}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"sticky top-0 z-10 flex justify-center border border-b-neutral-300 bg-neutral-100 py-2 text-sm text-neutral-500 dark:border-none dark:bg-[#444654] dark:text-neutral-200",children:[a("Model"),": ",null==s?void 0:s.model.name," | ",a("Temp"),": ",null==s?void 0:s.temperature," |",(0,o.jsx)("button",{className:"ml-2 cursor-pointer hover:opacity-50",onClick:H,children:(0,o.jsx)(O.Z,{size:18})}),(0,o.jsx)("button",{className:"ml-2 cursor-pointer hover:opacity-50",onClick:U,children:(0,o.jsx)(_.Z,{size:18})})]}),I&&(0,o.jsx)("div",{className:"flex flex-col space-y-10 md:mx-auto md:max-w-xl md:gap-6 md:py-3 md:pt-6 lg:max-w-2xl lg:px-0 xl:max-w-3xl",children:(0,o.jsx)("div",{className:"flex h-full flex-col space-y-4 border-b border-neutral-200 p-4 dark:border-neutral-600 md:rounded-lg md:border",children:(0,o.jsx)(ev,{})})}),null==s?void 0:s.messages.map((e,t)=>(0,o.jsx)(eg,{message:e,messageIndex:t,onEdit:e=>{w(e),R(e,(null==s?void 0:s.messages.length)-t)}},t)),g&&(0,o.jsx)(Y,{}),(0,o.jsx)("div",{className:"h-[162px] bg-white dark:bg-[#343541]",ref:z})]})}),(0,o.jsx)(F,{stopConversationRef:l,textareaRef:K,onSend:(e,t)=>{w(e),R(e,0,t)},onScrollDownClick:J,onRegenerate:()=>{y&&R(y,2,null)},showScrollDownButton:T})]}):(0,o.jsxs)("div",{className:"mx-auto flex h-full w-[300px] flex-col justify-center space-y-6 sm:w-[600px]",children:[(0,o.jsx)("div",{className:"text-center text-4xl font-bold text-black dark:text-white",children:"Welcome to Mistral UI"}),(0,o.jsxs)("div",{className:"text-center text-lg text-black dark:text-white",children:[(0,o.jsx)("div",{className:"mb-8",children:"Chatbot UI is an open source clone of OpenAI's ChatGPT UI."}),(0,o.jsx)("div",{className:"mb-2 font-bold",children:"Important: Mistral UI is 100% unaffiliated with OpenAI."})]}),(0,o.jsxs)("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[(0,o.jsx)("div",{className:"mb-2",children:"Mistral UI helps you to evaluate the european AI service Mistral which has no UI yet but you can test with this code."}),(0,o.jsxs)("div",{className:"mb-2",children:["It is ",(0,o.jsx)("span",{className:"italic",children:"only"})," used to communicate with their API."]}),(0,o.jsx)("div",{className:"mb-2",children:a("Please set your OpenAI API key in the bottom left of the sidebar.")}),(0,o.jsxs)("div",{children:[a("If you don't have an OpenAI API key, you can get one here: "),(0,o.jsx)("a",{href:"https://platform.openai.com/account/api-keys",target:"_blank",rel:"noreferrer",className:"text-blue-500 hover:underline",children:"open
1ai.com"})]})]})]})})});ew.displayName="Chat";let ej=()=>{let e=localStorage.getItem("conversationHistory"),t=localStorage.getItem("folders"),r=localStorage.getItem("prompts");e&&(e=JSON.parse(e)),t&&(t=JSON.parse(t)),r&&(r=JSON.parse(r));let l={version:4,history:e||[],folders:t||[],prompts:r||[]},a=new Blob([JSON.stringify(l,null,2)],{type:"application/json"}),s=URL.createObjectURL(a),n=document.createElement("a");n.download="chatbot_ui_history_".concat(function(){let e=new Date,t=e.getMonth()+1,r=e.getDate();return"".concat(t,"-").concat(r)}(),".json"),n.href=s,n.style.display="none",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)},ek=e=>{let{history:t,folders:r,prompts:l}=function(e){if(Array.isArray(e))return{version:4,history:j(e),folders:[],prompts:[]};if(!("version"in e)&&"folders"in e&&"history"in e)return{version:4,history:j(e.history||[]),folders:(e.folders||[]).map(e=>({id:e.id.toString(),name:e.name,type:"chat"})),prompts:[]};if(3===e.version)return{...e,version:4,prompts:[]};if(4===e.version)return e;throw Error("Unsupported data format")}(e),a=localStorage.getItem("conversationHistory"),s=a?JSON.parse(a):[],n=[...s,...t].filter((e,t,r)=>t===r.findIndex(t=>t.id===e.id));localStorage.setItem("conversationHistory",JSON.stringify(n)),n.length>0?localStorage.setItem("selectedConversation",JSON.stringify(n[n.length-1])):localStorage.removeItem("selectedConversation");let o=localStorage.getItem("folders"),i=o?JSON.parse(o):[],d=[...i,...r].filter((e,t,r)=>t===r.findIndex(t=>t.id===e.id));localStorage.setItem("folders",JSON.stringify(d));let c=localStorage.getItem("prompts"),u=c?JSON.parse(c):[],m=[...u,...l].filter((e,t,r)=>t===r.findIndex(t=>t.id===e.id));return localStorage.setItem("prompts",JSON.stringify(m)),{version:4,history:n,folders:d,prompts:m}};var eN=r(87664),eC=r(62577),eS=r(97283),eI=r(30471);let eE=e=>{let{handleClick:t,children:r}=e;return(0,o.jsx)("button",{className:"min-w-[20px] p-1 text-neutral-400 hover:text-neutral-100",onClick:t,children:r})},eO=e=>{let{currentFolder:t,searchTerm:r,handleDrop:l,folderComponent:a}=e,{handleDeleteFolder:s,handleUpdateFolder:n}=(0,i.useContext)(G),[d,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(""),[p,g]=(0,i.useState)(!1),f=e=>{"Enter"===e.key&&(e.preventDefault(),v())},v=()=>{n(t.id,x),h(""),m(!1)},b=e=>{e.dataTransfer&&(g(!0),l(e,t),e.target.style.background="none")},y=e=>{e.preventDefault()},w=e=>{e.target.style.background="#343541"},j=e=>{e.target.style.background="none"};return(0,i.useEffect)(()=>{u?c(!1):d&&m(!1)},[u,d]),(0,i.useEffect)(()=>{r?g(!0):g(!1)},[r]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("div",{className:"relative flex items-center",children:[u?(0,o.jsxs)("div",{className:"flex w-full items-center gap-3 bg-[#343541]/90 p-3",children:[p?(0,o.jsx)(eN.Z,{size:18}):(0,o.jsx)(eC.Z,{size:18}),(0,o.jsx)("input",{className:"mr-12 flex-1 overflow-hidden overflow-ellipsis border-neutral-400 bg-transparent text-left text-[12.5px] leading-3 text-white outline-none focus:border-neutral-100",type:"text",value:x,onChange:e=>h(e.target.value),onKeyDown:f,autoFocus:!0})]}):(0,o.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-3 rounded-lg p-3 text-sm transition-colors duration-200 hover:bg-[#343541]/90",onClick:()=>g(!p),onDrop:e=>b(e),onDragOver:y,onDragEnter:w,onDragLeave:j,children:[p?(0,o.jsx)(eN.Z,{size:18}):(0,o.jsx)(eC.Z,{size:18}),(0,o.jsx)("div",{className:"relative max-h-5 flex-1 overflow-hidden text-ellipsis whitespace-nowrap break-all text-left text-[12.5px] leading-3",children:t.name})]}),(d||u)&&(0,o.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,o.jsx)(eE,{handleClick:e=>{e.stopPropagation(),d?s(t.id):u&&v(),c(!1),m(!1)},children:(0,o.jsx)(et.Z,{size:18})}),(0,o.jsx)(eE,{handleClick:e=>{e.stopPropagation(),c(!1),m(!1)},children:(0,o.jsx)(eS.Z,{size:18})})]}),!d&&!u&&(0,o.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,o.jsx)(eE,{handleClick:e=>{e.stopPropagation(),m(!0),h(t.name)},children:(0,o.jsx)(eI.Z,{size:18})}),(0,o.jsx)(eE,{handleClick:e=>{e.stopPropagation(),c(!0)},children:(0,o.jsx)(ee.Z,{size:18})})]})]}),p?a:null]})};var e_=r(47447);let eP=(0,i.createContext)(void 0),eT=e=>{let{conversation:t}=e,{state:{selectedConversation:r,messageIsStreaming:l}
1,handleSelectConversation:a,handleUpdateConversation:s}=(0,i.useContext)(G),{handleDeleteConversation:n}=(0,i.useContext)(eP),[d,c]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),[x,h]=(0,i.useState)(""),p=e=>{"Enter"===e.key&&(e.preventDefault(),r&&f(r))},g=(e,t)=>{e.dataTransfer&&e.dataTransfer.setData("conversation",JSON.stringify(t))},f=e=>{x.trim().length>0&&(s(e,{key:"name",value:x}),h(""),m(!1))},v=e=>{e.stopPropagation(),d?n(t):u&&f(t),c(!1),m(!1)},b=e=>{e.stopPropagation(),c(!1),m(!1)},y=e=>{e.stopPropagation(),m(!0),r&&h(r.name)},w=e=>{e.stopPropagation(),c(!0)};return(0,i.useEffect)(()=>{u?c(!1):d&&m(!1)},[u,d]),(0,o.jsxs)("div",{className:"relative flex items-center",children:[u&&(null==r?void 0:r.id)===t.id?(0,o.jsxs)("div",{className:"flex w-full items-center gap-3 rounded-lg bg-[#343541]/90 p-3",children:[(0,o.jsx)(e_.Z,{size:18}),(0,o.jsx)("input",{className:"mr-12 flex-1 overflow-hidden overflow-ellipsis border-neutral-400 bg-transparent text-left text-[12.5px] leading-3 text-white outline-none focus:border-neutral-100",type:"text",value:x,onChange:e=>h(e.target.value),onKeyDown:p,autoFocus:!0})]}):(0,o.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-3 rounded-lg p-3 text-sm transition-colors duration-200 hover:bg-[#343541]/90 ".concat(l?"disabled:cursor-not-allowed":""," ").concat((null==r?void 0:r.id)===t.id?"bg-[#343541]/90":""),onClick:()=>a(t),disabled:l,draggable:"true",onDragStart:e=>g(e,t),children:[(0,o.jsx)(e_.Z,{size:18}),(0,o.jsx)("div",{className:"relative max-h-5 flex-1 overflow-hidden text-ellipsis whitespace-nowrap break-all text-left text-[12.5px] leading-3 ".concat((null==r?void 0:r.id)===t.id?"pr-12":"pr-1"),children:t.name})]}),(d||u)&&(null==r?void 0:r.id)===t.id&&(0,o.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,o.jsx)(eE,{handleClick:v,children:(0,o.jsx)(et.Z,{size:18})}),(0,o.jsx)(eE,{handleClick:b,children:(0,o.jsx)(eS.Z,{size:18})})]}),(null==r?void 0:r.id)===t.id&&!d&&!u&&(0,o.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,o.jsx)(eE,{handleClick:y,children:(0,o.jsx)(eI.Z,{size:18})}),(0,o.jsx)(eE,{handleClick:w,children:(0,o.jsx)(ee.Z,{size:18})})]})]})},eD=e=>{let{searchTerm:t}=e,{state:{folders:r,conversations:l},handleUpdateConversation:a}=(0,i.useContext)(G),s=(e,t)=>{if(e.dataTransfer){let r=JSON.parse(e.dataTransfer.getData("conversation"));a(r,{key:"folderId",value:t.id})}},n=e=>l&&l.filter(e=>e.folderId).map((t,r)=>{if(t.folderId===e.id)return(0,o.jsx)("div",{className:"ml-5 gap-2 border-l pl-2",children:(0,o.jsx)(eT,{conversation:t})},r)});return(0,o.jsx)("div",{className:"flex w-full flex-col pt-2",children:r.filter(e=>"chat"===e.type).sort((e,t)=>e.name.localeCompare(t.name)).map((e,r)=>(0,o.jsx)(eO,{searchTerm:t,currentFolder:e,handleDrop:s,folderComponent:n(e)},r))})},eL=e=>{let{text:t,icon:r,onClick:l}=e;return(0,o.jsxs)("button",{className:"flex w-full cursor-pointer select-none items-center gap-3 rounded-md py-3 px-3 text-[14px] leading-3 text-white transition-colors duration-200 hover:bg-gray-500/10",onClick:l,children:[(0,o.jsx)("div",{children:r}),(0,o.jsx)("span",{children:t})]})},eG=e=>{let{onClearConversations:t}=e,[r,l]=(0,i.useState)(!1),{t:a}=(0,c.$G)("sidebar"),s=()=>{t(),l(!1)};return r?(0,o.jsxs)("div",{className:"flex w-full cursor-pointer items-center rounded-lg py-3 px-3 hover:bg-gray-500/10",children:[(0,o.jsx)(ee.Z,{size:18}),(0,o.jsx)("div",{className:"ml-3 flex-1 text-left text-[12.5px] leading-3 text-white",children:a("Are you sure?")}),(0,o.jsxs)("div",{className:"flex w-[40px]",children:[(0,o.jsx)(et.Z,{className:"ml-auto mr-1 min-w-[20px] text-neutral-400 hover:text-neutral-100",size:18,onClick:e=>{e.stopPropagation(),s()}}),(0,o.jsx)(eS.Z,{className:"ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100",size:18,onClick:e=>{e.stopPropagation(),l(!1)}})]})]}):(0,o.jsx)(eL,{text:a("Clear conversations"),icon:(0,o.jsx)(ee.Z,{size:18}),onClick:()=>l(!0)})},eZ=()=>{let{t:e}=(0,c.$G)("sidebar"),[t,r]=(0,i.useState)(!1),{state:{apiKey:l,lightMode:a,serverSideApiKeyIsSet:s,serverSidePluginKeysSet:n,conversations:d},dispatch:u}=(0,i.useContext)(G),{handleClearConversations:m,handleImportConversations:x,handleExportData:h,handleApiKeyChange:p}=(0,i.useContext)(eP);return(0,o.jsx)("div",{className:"flex flex-col items-center space-y-1 border-t border-white/20 pt-1 text-sm",children:d.length>0?(0,o.jsx)(eG,{onClearConversations:m}):null})},ez=e=>{let{conversations:t}=e;return(0,o.jsx)("div",{className:"flex w-full flex-col gap-1",children:t.filter(e=>!e.folderId).slice().reverse().map((e,t)=>(0,o.jsx)(eT,{conversation:e},t))})};var eA=r(1177),eK=r(16745),eR=r(92005),eM=r(67421),eJ=r(98963),eH=r(89014);let eU=e=>{let{onClick:t,side:r}=e;return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{className:"fixed top-5 ".concat("right"===r?"right-[270px]":"left-[270px]"," z-50 h-7 w-7 hover:text-gray-400 dark:text-white dark:hover:text-gray-300 sm:top-0.5 sm:").concat("right"===r?"right-[270px]":"left-[270px]"," sm:h-8 sm:w-8 sm:text-neutral-700"),onClick:t,children:"right"===r?(0,o.jsx)(eJ.Z,{}):(0,o.jsx)(eH.Z,{})}),(0,o.jsx)("div",{onClick:t,className:"absolute top-0 left-0 z-10 h-full w-full bg-black opacity-70 sm:hidden"})]})},e$=e=>{let{onClick:t,side:r}=e;return(0,o.jsx)("button",{className:"fixed top-2.5 ".concat("right"===r?"right-2":"left-2"," z-50 h-7 w-7 text-white hover:text-gray-400 dark:text-white dark:hover:text-gray-300 sm:top-0.5 sm:").concat("right"===r?"right-2":"left-2"," sm:h-8 sm:w-8 sm:text-neutral-700"),onClick:t,children:"right"===r?(0,o.jsx)(eH.Z,{}):(0,o.jsx)(eJ.Z,{})})},eF=e=>{let{placeholder:t,searchTerm:r,onSearch:l}=e,{t:a}=(0,c.$G)("sidebar"),s=e=>{l(e.target.value)},n=()=>
1{l("")};return(0,o.jsxs)("div",{className:"relative flex items-center",children:[(0,o.jsx)("input",{className:"w-full flex-1 rounded-md border border-neutral-600 bg-[#202123] px-4 py-3 pr-10 text-[14px] leading-3 text-white",type:"text",placeholder:a(t)||"",value:r,onChange:s}),r&&(0,o.jsx)(eS.Z,{className:"absolute right-4 cursor-pointer text-neutral-300 hover:text-neutral-400",size:18,onClick:n})]})},eB=e=>{let{isOpen:t,addItemButtonTitle:r,side:l,items:a,itemComponent:s,folderComponent:n,footerComponent:i,searchTerm:d,handleSearchTerm:c,toggleOpen:u,handleCreateItem:m,handleCreateFolder:x,handleDrop:h}=e,{t:p}=(0,eM.$G)("promptbar"),g=e=>{e.preventDefault()},f=e=>{e.target.style.background="#343541"},v=e=>{e.target.style.background="none"};return t?(0,o.jsxs)("div",{children:[(0,o.jsxs)("div",{className:"fixed top-0 ".concat(l,"-0 z-40 flex h-full w-[260px] flex-none flex-col space-y-2 bg-[#202123] p-2 text-[14px] transition-all sm:relative sm:top-0"),children:[(0,o.jsxs)("div",{className:"flex items-center",children:[(0,o.jsxs)("button",{className:"text-sidebar flex w-[190px] flex-shrink-0 cursor-pointer select-none items-center gap-3 rounded-md border border-white/20 p-3 text-white transition-colors duration-200 hover:bg-gray-500/10",onClick:()=>{m(),c("")},children:[(0,o.jsx)(eA.Z,{size:16}),r]}),(0,o.jsx)("button",{className:"ml-2 flex flex-shrink-0 cursor-pointer items-center gap-3 rounded-md border border-white/20 p-3 text-sm text-white transition-colors duration-200 hover:bg-gray-500/10",onClick:x,children:(0,o.jsx)(eK.Z,{size:16})})]}),(0,o.jsx)(eF,{placeholder:p("Search...")||"",searchTerm:d,onSearch:c}),(0,o.jsxs)("div",{className:"flex-grow overflow-auto",children:[(null==a?void 0:a.length)>0&&(0,o.jsx)("div",{className:"flex border-b border-white/20 pb-2",children:n}),(null==a?void 0:a.length)>0?(0,o.jsx)("div",{className:"pt-2",onDrop:h,onDragOver:g,onDragEnter:f,onDragLeave:v,children:s}):(0,o.jsxs)("div",{className:"mt-8 select-none text-center text-white opacity-50",children:[(0,o.jsx)(eR.Z,{className:"mx-auto mb-3"}),(0,o.jsx)("span",{className:"text-[14px] leading-normal",children:p("No data.")})]})]}),i]}),(0,o.jsx)(eU,{onClick:u,side:l})]}):(0,o.jsx)(e$,{onClick:u,side:l})},eW={searchTerm:"",filteredConversations:[]};var eY=r(57632);let eq=()=>{let{t:e}=(0,c.$G)("sidebar"),t=x({initialState:eW}),{state:{conversations:r,showChatbar:l,defaultModelId:a,folders:s,pluginKeys:n},dispatch:d,handleCreateFolder:u,handleNewConversation:m,handleUpdateConversation:h}=(0,i.useContext)(G),{state:{searchTerm:p,filteredConversations:g},dispatch:v}=t,w=(0,i.useCallback)(e=>{d({field:"apiKey",value:e}),localStorage.setItem("apiKey",e)},[d]),j=e=>{if(n.some(t=>t.pluginId===e.pluginId)){let t=n.map(t=>t.pluginId===e.pluginId?e:t);d({field:"pluginKeys",value:t}),localStorage.setItem("pluginKeys",JSON.stringify(t))}else d({field:"pluginKeys",value:[...n,e]}),localStorage.setItem("pluginKeys",JSON.stringify([...n,e]))},k=e=>{let t=n.filter(t=>t.pluginId!==e.pluginId);if(0===t.length){d({field:"pluginKeys",value:[]}),localStorage.removeItem("pluginKeys");return}d({field:"pluginKeys",value:t}),localStorage.setItem("pluginKeys",JSON.stringify(t))},I=()=>{ej()},E=e=>{let{history:t,folders:r,prompts:l}=ek(e);d({field:"conversations",value:t}),d({field:"selectedConversation",value:t[t.length-1]}),d({field:"folders",value:r}),d({field:"prompts",value:l}),window.location.reload()},O=()=>{a&&d({field:"selectedConversation",value:{id:(0,eY.Z)(),name:e("New Conversation"),messages:[],model:f[a],prompt:b,temperature:y,folderId:null}}),d({field:"conversations",value:[]}),localStorage.removeItem("conversationHistory"),localStorage.removeItem("selectedConversation");let t=s.filter(e=>"chat"!==e.type);d({field:"folders",value:t}),S(t)},_=t=>{let l=r.filter(e=>e.id!==t.id);d({field:"conversations",value:l}),v({field:"searchTerm",value:""}),C(l),l.length>0?(d({field:"selectedConversation",value:l[l.length-1]}),N(l[l.length-1])):(a&&d({field:"selectedConversation",value:{id:(0,eY.Z)(),name:e("New Conversation"),messages:[],model:f[a],prompt:b,temperature:y,folderId:null}}),localStorage.removeItem("selectedConversation"))},P=()=>{d({field:"showChatbar",value:!l}),localStorage.setItem("showChatbar",JSON.stringify(!l))},T=e=>{if(e.dataTransfer){let t=JSON.parse(e.dataTransfer.getData("conversation"));h(t,{key:"folderId",value:0}),v({field:"searchTerm",value:""}),e.target.style.background="none"}};return(0,i.useEffect)(()=>{p?v({field:"filteredConversations",value:r.filter(e=>{let t=e.name.toLocaleLowerCase()+" "+e.messages.map(e=>e.content).join(" ");return t.toLowerCase().includes(p.toLowerCase())})}):v({field:"filteredConversations",value:r})},[p,r]),(0,o.jsx)(eP.Provider,{value:{...t,handleDeleteConversation:_,handleClearConversations:O,handleImportConversations:E,handleExportData:I,handlePluginKeyChange:j,handleClearPluginKey:k,handleApiKeyChange:w},children:(0,o.jsx)(eB,{side:"left",isOpen:l,addItemButtonTitle:e("New chat"),itemComponent:(0,o.jsx)(ez,{conversations:g}),folderComponent:(0,o.jsx)(eD,{searchTerm:p}),items:g,searchTerm:p,handleSearchTerm:e=>v({field:"searchTerm",value:e}),toggleOpen:P,handleCreateItem:m,handleCreateFolder:()=>u(e("New folder"),"chat"),handleDrop:T,footerComponent:(0,o.jsx)(eZ,{})})})},eV=e=>{let{selectedConversation:t,onNewConversation:r}=e;return(0,o.jsxs)("nav",{className:"flex w-full justify-between bg-[#202123] py-3 px-4",children:[(0,o.jsx)("div",{className:"mr-4"}),(0,o.jsx)("div",{className:"max-w-[240px] overflow-hidden text-ellipsis whitespace-nowrap",children:t.name}),(0,o.jsx)(eA.Z,{className:"cursor-pointer hover:text-neutral-400 mr-8",onClick:r})]})},eX={apiKey:"",loading:!1,pluginKeys:[],lightMode:"dark",messageIsStreaming:!1,modelError:null,models:[],folders:[],conversations:[],selectedConversation:void 0,currentMessage:void 0,prompts:[],temperature:1,showPromptbar:!0,showChatbar:!0,currentFolder:void 0,messageError:!1,searchTerm:"",defaultModelId:void 0,serverSideApiKeyIsSet:!1,serverSidePluginKeysSet:!1},eQ=e=>{let{serverSideApiKeyIsSet:t,serverSidePluginKeysSet:r,defaultModelId:l}=e,{t:a}=(0,c.$G)("chat"),{getModels:s}=g(),{getModelsError:n}=h(),[u,p]=(0,i.useState)(!0),v=x({initialState:eX}),{state:{apiKey:O,lightMode:_,folders:P,conversations:T,selectedConversation:D,prompts:L,temperature:Z},dispatch:z}=v,A=(0,i.useRef)(!1),{data:K,error:R,refetch:M}=(0,d.useQuery)(["GetModels",O,t],e=>{let{signal:r}=e;return O||t?s({key:O},r):null},{enabled:!0,refetchOnMount:!1});(0,i.useEffect)(()=>{K&&z({field:"models",value:K})},[K,z]),(0,i.useEffect)(()=>{z({field:"modelError",value:n(R)})},[z,R,n]);let J=e=>{z({field:"selectedConversation",value:e}),N(e)},H=(e,t)=>{let r={id:(0,eY.Z)(),name:e,type:t},l=[...P,r];z({field:"folders",value:l}),S(l)},U=e=>{let t=P.filter(t=>t.id!==e);z({field:"folders",value:t}),S(t);let r=T.map(t=>t.folderId===e?{...t,folderId:null}:t);z({field:"conversations",value:r}),C(r);let l=L.map(t=>t.folderId===e?{...t,folderId:null}:t);z({field:"prompts",value:l}),I(l)},$=(e,t)=>{let r=P.map(r=>r.id===e?{...r,name:t}:r);z({field:"folders",value:r}),S(r)},F=()=>{var e;let t=T[T.length-1],r={id:(0,eY.Z)(),name:a("New Conversation"),messages:[],model:(null==t?void 0:t.model)||{id:f[l].id,name:f[l].name,maxLength:f[l].maxLength,tokenLimit:f[l].tokenLimit},prompt:b,temperature:null!==(e=null==t?void 0:t.temperature)&&void 0!==e?e:y,folderId:null},s=[...T,r];z({field:"selectedConversation",value:r}),z({field:"conversations",value:s}),N(r),C(s),z({field:"loading",value:!1})},B=(e,t)=>{let r={...e,[t.key]:t.value},{single:l,all:a}=k(r,T);z({field:"selectedConversation",value:l}),z({field:"conversations",value:a})};return(0,i.useEffect)(()=>{window.innerWidth<640&&z({field:"showChatbar",value:!1})},[D]),(0,i.useEffect)(()=>{l&&z({field:"defaultModelId",value:l}),t&&z({field:"serverSideApiKeyIsSet",value:t}),r&&z({field:"serverSidePluginKeysSet",value:r})},[l,t,r]),(0,i.useEffect)(()=>{let e=E();e.theme&&z({field:"lightMode",value:e.theme});let s=localStorage.getItem("apiKey");t?(z({field:"apiKey",value:""}),localStorage.removeItem("apiKey")):s&&z({field:"apiKey",value:s});let n=localStorage.getItem("pluginKeys");r?(z({field:"pluginKeys",value:[]}),localStorage.removeItem("pluginKeys")):n&&z({field:"pluginKeys",value:n}),window.innerWidth<640&&(z({field:"showChatbar",value:!1}),z({field:"showPromptbar",value:!1}));let o=localStorage.getItem("showChatbar");o&&z({field:"showChatbar",value:"true"===o});let i=localStorage.getItem("showPromptbar");i&&z({field:"showPromptbar",value:"true"===i});let d=localStorage.getItem("folders");d&&z({field:"folders",value:JSON.parse(d)});let c=localStorage.getItem("prompts");c&&z({field:"prompts",value:JSON.parse(c)});let u=localStorage.getItem("conversationHistory");if(u){let e=JSON.parse(u),t=j(e);z({field:"conversations",value:t})}let m=localStorage.getItem("selectedConversation");if(m){let e=JSON.parse(m),t=w(e);z({field:"selectedConversation",value:t})}else{var x;let e=T[T.length-1];z({field:"selectedConversation",value:{id:(0,eY.Z)(),name:a("New Conversation"),messages:[],model:f[l],prompt:b,temperature:null!==(x=null==e?void 0:e.temperature)&&void 0!==x?x:y,folderId:null}})}},[l,z,t,r]),(0,o.jsxs)(G.Provider,{value:{...v,handleNewConversation:F,handleCreateFolder:H,handleDeleteFolder:U,handleUpdateFolder:$,handleSelectConversation:J,handleUpdate
1Conversation:B},children:[(0,o.jsxs)(m(),{children:[(0,o.jsx)("title",{children:"Chatbot UI"}),(0,o.jsx)("meta",{name:"description",content:"ChatGPT but better."}),(0,o.jsx)("meta",{name:"viewport",content:"height=device-height ,width=device-width, initial-scale=1, user-scalable=no"}),(0,o.jsx)("link",{rel:"icon",href:"/favicon.ico"})]}),D&&(0,o.jsxs)("main",{className:"flex h-screen w-screen flex-col text-sm text-white dark:text-white ".concat(_),children:[(0,o.jsx)("div",{className:"fixed top-0 w-full sm:hidden",children:(0,o.jsx)(eV,{selectedConversation:D,onNewConversation:F})}),(0,o.jsxs)("div",{className:"flex h-full w-full pt-[48px] sm:pt-0",children:[(0,o.jsx)(eq,{}),(0,o.jsx)("div",{className:"flex flex-1",children:(0,o.jsx)(ew,{stopConversationRef:A})})]})]})]})};var e0=eQ,e1=!0}},function(e){e.O(0,[879,873,774,888,179],function(){return e(e.s=48312)}),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.