(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(42603)}])},87766:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var a=r(85893);var l=e=>{let{handleClick:t,children:r}=e;return(0,a.jsx)("button",{className:"min-w-[20px] p-1 text-neutral-400 hover:text-neutral-100",onClick:t,children:r})}},5782:function(e,t,r){"use strict";r.a(e,(async function(e,a){try{r.d(t,{e:function(){return j}});var l=r(85893),n=r(33111),s=r(51668),o=r(67294),i=r(86501),d=r(61162),c=r(17172),u=r(62716),m=r(97450),x=r(88990),p=r(79408),h=r(39817),f=r(79420),g=r(84378),v=r(11085),b=r(11046),y=r(41347),k=r(10094),w=e([h]);h=(w.then?(await w)():w)[0];let j=(0,o.memo)((e=>{let{stopConversationRef:t}=e,{t:r}=(0,d.$G)("chat"),{state:{selectedConversation:a,conversations:w,models:j,apiKey:C,pluginKeys:N,serverSideApiKeyIsSet:S,messageIsStreaming:_,modelError:E,loading:I,prompts:P},handleUpdateConversation:O,dispatch:L}=(0,o.useContext)(x.Z),[G,T]=(0,o.useState)(),[Z,A]=(0,o.useState)(!0),[K,D]=(0,o.useState)(!1),[z,R]=(0,o.useState)(!1),M=(0,o.useRef)(null),U=(0,o.useRef)(null),F=(0,o.useRef)(null),H=(0,o.useCallback)((async function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,l=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(a){let m,x;if(r){let t=[...a.messages];for(let e=0;e"google-search"===e.pluginId)))||void 0===s?void 0:s.requiredKeys.find((e=>"GOOGLE_API_KEY"===e.key)))||void 0===n?void 0:n.value,googleCSEId:null===(o=null===(d=N.find((e=>"google-search"===e.pluginId)))||void 0===d?void 0:d.requiredKeys.find((e=>"GOOGLE_CSE_ID"===e.key)))||void 0===o?void 0:o.value});else x=JSON.stringify(p);let f=new AbortController,g=await fetch(h,{method:"POST",headers:{"Content-Type":"application/json"},signal:f.signal,body:x});if(!g.ok)return L({field:"loading",value:!1}),L({field:"messageIsStreaming",value:!1}),void i.ZP.error(g.statusText);let v=g.body;if(!v)return L({field:"loading",value:!1}),void L({field:"messageIsStreaming",value:!1});if(l){let{answer:e}=await g.json(),t=[...m.messages,{role:"assistant",content:e}];m={...m,messages:t},L({field:"selectedConversation",value:m}),(0,u.m7)(m);let r=w.map((e=>e.id===a.id?m:e));0===r.length&&r.push(m),L({field:"conversations",value:r}),(0,u.fB)(r),L({field:"loading",value:!1}),L({field:"messageIsStreaming",value:!1})}else{if(1===m.messages.length){let{content:t}=e,r=t.length>30?t.substring(0,30)+"...":t;m={...m,name:r}}L({field:"loading",value:!1});let r=v.getReader(),l=new TextDecoder,n=!1,s=!0,o="";for(;!n;){if(!0===t.current){f.abort(),n=!0;break}let{value:e,done:a}=await r.read();n=a;let i=l.decode(e);if(o+=i,s){s=!1;let e=[...m.messages,{role:"assistant",content:i}];m={...m,messages:e},L({field:"selectedConversation",value:m})}else{let e=m.messages.map(((e,t)=>t===m.messages.length-1?{...e,content:o}:e));m={...m,messages:e},L({field:"selectedConversation",value:m})}}(0,u.m7)(m);let i=w.map((e=>e.id===a.id?m:e));0===i.length&&i.push(m),L({field:"conversations",value:i}),(0,u.fB)(i),L({field:"messageIsStreaming",value:!1})}}}),[C,w,N,a,t]);(0,o.useCallback)((()=>{var e,t;Z&&(null===(e=M.current)||void 0===e||e.scrollIntoView({behavior:"smooth"}),null===(t=F.current)||void 0===t||t.focus())}),[Z]);let J=(0,m.P)((()=>{var e;Z&&(null===(e=M.current)||void 0===e||e.scrollIntoView(!0))}),250);return(0,o.useEffect)((()=>{J(),a&&T(a.messages[a.messages.length-2])}),[a,J]),(0,o.useEffect)((()=>{let e=new IntersectionObserver((e=>{let[t]=e;var r;(A(t.isIntersecting),t.isIntersecting)&&(null===(r=F.current)||void 0===r||r.focus())}),{root:null,threshold:.5}),t=M.current;return t&&e.observe(t),()=>{t&&e.unobserve(t)}}),[M]),(0,l.jsx)("div",{className:"relative flex-1 overflow-hidden bg-white dark:bg-[#343541]",children:C||S?E?(0,l.jsx)(g.Y,{error:E}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("div",{className:"max-h-full overflow-x-hidden",ref:U,onScroll:()=>{if(U.current){let{scrollTop:e,scrollHeight:t,clientHeight:r}=U.current;e+r0&&(0,l.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,l.jsx)(b.q,{}),(0,l.jsx)(y.r,{conversation:a,prompts:P,onChangePrompt:e=>O(a,{key:"prompt",value:e})}),(0,l.jsx)(k.$,{label:r("Temperature"),onChangeTemperature:e=>O(a,{key:"temperature",value:e})})]})]})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.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:[r("Model"),": ",null==a?void 0:a.model.name," | ",r("Temp"),": ",null==a?void 0:a.temperature," |",(0,l.jsx)("button",{className:"ml-2 cursor-pointer hover:opacity-50",onClick:()=>{D(!K)},children:(0,l.jsx)(n.Z,{size:18})}),(0,l.jsx)("button",{className:"ml-2 cursor-pointer hover:opacity-50",onClick:()=>{confirm(r("Are you sure you want to clear all messages?"))&&a&&O(a,{key:"messages",value:[]})},children:(0,l.jsx)(s.Z,{size:18})})]}),K&&(0,l.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,l.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,l.jsx)(b.q,{})})}),null==a?void 0:a.messages.map(((e,t)=>(0,l.jsx)(v.m,{message:e,messageIndex:t,onEdit:e=>{T(e),H(e,(null==a?void 0:a.messages.length)-t)}},t))),I&&(0,l.jsx)(f.G,{}),(0,l.jsx)("div",{className:"h-[162px] bg-white dark:bg-[#343541]",ref:M})]})}),(0,l.jsx)(h.x,{stopConversationRef:t,textareaRef:F,onSend:(e,t)=>{T(e),H(e,0,t)},onScrollDownClick:()=>{var e;null===(e=U.current)||void 0===e||e.scrollTo({top:U.current.scrollHeight,behavior:"smooth"})},onRegenerate:()=>{G&&H(G,2,null)},showScrollDownButton:z})]}):(0,l.jsxs)("div",{className:"mx-auto flex h-full w-[300px] flex-col justify-center space-y-6 sm:w-[600px]",children:[(0,l.jsx)("div",{className:"text-center text-4xl font-bold text-black dark:text-white",children:"Welcome to Chatbot UI"}),(0,l.jsxs)("div",{className:"text-center text-lg text-black dark:text-white",children:[(0,l.jsx)("div",{className:"mb-8",children:"Chatbot UI is an open source clone of OpenAI's ChatGPT UI."}),(0,l.jsx)("div",{className:"mb-2 font-bold",children:"Important: Chatbot UI is 100% unaffiliated with OpenAI."})]}),(0,l.jsxs)("div",{className:"text-center text-gray-500 dark:text-gray-400",children:[(0,l.jsx)("div",{className:"mb-2",children:"Chatbot UI allows you to plug in your API key to use this UI with their API."}),(0,l.jsxs)("div",{className:"mb-2",children:["It is ",(0,l.jsx)("span",{className:"italic",children:"only"})," used to communicate with their API."]}),(0,l.jsx)("div",{className:"mb-2",children:r("Please set your OpenAI API key in the bottom left of the sidebar.")}),(0,l.jsxs)("div",{children:[r("If you don't have an OpenAI API key, you can get one here: "),(0,l.jsx)("a",{href:"https://platform.openai.com/account/api-keys",target:"_blank",rel:"noreferrer",className:"text-blue-500 hover:underline",children:"openai.com"})]})]})]})})}));j.displayName="Chat",a()}catch(e){a(e)}}))},39817:function(e,t,r){"use strict";r.a(e,(async function(e,a){try{r.d(t,{x:function(){return b}});var l=r(85893),n=r(94568),s=r(21223),o=r(19695),i=r(59348),d=r(23461),c=r(63072),u=r(67294),m=r(61162),x=r(88990),p=r(84362),h=r(68452),f=r(9707),g=r(97939),v=e([p]);p=(v.then?(await v)():v)[0];let b=e=>{var t;let{onSend:r,onRegenerate:a,onScrollDownClick:v,stopConversationRef:b,textareaRef:y,showScrollDownButton:k}=e,{t:w}=(0,m.$G)("chat"),{state:{selectedConversation:j,messageIsStreaming:C,prompts:N},dispatch:S}=(0,u.useContext)(x.Z),[_,E]=(0,u.useState)(),[I,P]=(0,u.useState)(!1),[O,L]=(0,u.useState)(!1),[G,T]=(0,u.useState)(0),[Z,A]=(0,u.useState)(""),[K,D]=(0,u.useState)([]),[z,R]=(0,u.useState)(!1),[M,U]=(0,u.useState)(!1),[F,H]=(0,u.useState)(null),J=(0,u.useRef)(null),$=N.filter((e=>e.name.toLowerCase().includes(Z.toLowerCase()))),B=()=>{if(!C){if(!_)return void alert(w("Please enter a message"));r({role:"user",content:_},F),E(""),H(null),window.innerWidth<640&&y&&y.current&&y.current.blur()}},q=()=>{let e=$[G];e&&(E((t=>null==t?void 0:t.replace(/\/\w*$/,e.content))),V(e)),L(!1)},Y=(0,u.useCallback)((e=>{let t=e.match(/\/\w*$/);t?(L(!0),A(t[0].slice(1))):(L(!1),A(""))}),[]),V=e=>{let t=(e=>{let t,r=/{{(.*?)}}/g,a=[];for(;null!==(t=r.exec(e));)a.push(t[1]);return a})(e.content);D(t),t.length>0?R(!0):(E((t=>null==t?void 0:t.replace(/\/\w*$/,e.content))),Y(e.content))};return(0,u.useEffect)((()=>{J.current&&(J.current.scrollTop=30*G)}),[G]),(0,u.useEffect)((()=>{var e,t;y&&y.current&&(y.current.style.height="inherit",y.current.style.height="".concat(null===(e=y.current)||void 0===e?void 0:e.scrollHeight,"px"),y.current.style.overflow="".concat((null==y||null===(t=y.current)||void 0===t?void 0:t.scrollHeight)>400?"auto":"hidden"))}),[_]),(0,u.useEffect)((()=>{let e=e=>{J.current&&!J.current.contains(e.target)&&L(!1)};return window.addEventListener("click",e),()=>{window.removeEventListener("click",e)}}),[]),(0,l.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,l.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:[C&&(0,l.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:()=>{b.current=!0,setTimeout((()=>{b.current=!1}),1e3)},children:[(0,l.jsx)(n.Z,{size:16})," ",w("Stop Generating")]}),!C&&j&&j.messages.length>0&&(0,l.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:a,children:[(0,l.jsx)(s.Z,{size:16})," ",w("Regenerate response")]}),(0,l.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,l.jsx)("button",{className:"absolute p-1 rounded-sm left-2 top-2 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:()=>U(!M),onKeyDown:e=>{},children:F?(0,l.jsx)(o.Z,{size:20}):(0,l.jsx)(i.Z,{size:20})}),M&&(0,l.jsx)("div",{className:"absolute left-0 bottom-14 rounded bg-white dark:bg-[#343541]",children:(0,l.jsx)(h.V,{plugin:F,onKeyDown:e=>{var t;"Escape"===e.key&&(e.preventDefault(),U(!1),null===(t=y.current)||void 0===t||t.focus())},onPluginChange:e=>{H(e),U(!1),y&&y.current&&y.current.focus()}})}),(0,l.jsx)("div",{className:"absolute flex justify-center w-full mx-auto mb-12 pointer-events-none bottom-full md:mb-4 md:justify-end",children:(0,l.jsx)(p.s,{content:_})}),(0,l.jsx)("textarea",{ref:y,className:"w-full p-0 py-2 pl-10 pr-8 m-0 text-black bg-transparent border-0 resize-none dark:bg-transparent dark:text-white md:py-3 md:pl-10",style:{resize:"none",bottom:"".concat(null==y||null===(t=y.current)||void 0===t?void 0:t.scrollHeight,"px"),maxHeight:"400px",overflow:"".concat(y.current&&y.current.scrollHeight>400?"auto":"hidden")},placeholder:w('Type a message or type "/" to select a prompt...')||"",value:_,rows:1,onCompositionStart:()=>P(!0),onCompositionEnd:()=>P(!1),onChange:e=>{let t=e.target.value,r=null==j?void 0:j.model.maxLength;r&&t.length>r?alert(w("Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.",{maxLength:r,valueLength:t.length})):(E(t),Y(t))},onKeyDown:e=>{O?"ArrowDown"===e.key?(e.preventDefault(),T((e=>ee>0?e-1:e))):"Tab"===e.key?(e.preventDefault(),T((e=>e{let e=void 0===window.navigator?"":navigator.userAgent;return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(e)})()||e.shiftKey?"/"===e.key&&e.metaKey&&(e.preventDefault(),U(!M)):(e.preventDefault(),B())}}),(0,l.jsx)("button",{className:"absolute p-1 rounded-sm right-2 top-2 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:C?(0,l.jsx)("div",{className:"w-4 h-4 border-t-2 rounded-full animate-spin border-neutral-800 opacity-60 dark:border-neutral-100"}):(0,l.jsx)(d.Z,{size:18})}),k&&(0,l.jsx)("div",{className:"absolute right-0 bottom-12 lg:bottom-0 lg:-right-10",children:(0,l.jsx)("button",{className:"flex items-center justify-center text-gray-800 rounded-full shadow-md h-7 w-7 bg-neutral-300 hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-neutral-200",onClick:v,children:(0,l.jsx)(c.Z,{size:18})})}),O&&$.length>0&&(0,l.jsx)("div",{className:"absolute w-full bottom-12",children:(0,l.jsx)(f.t,{activePromptIndex:G,prompts:$,onSelect:q,onMouseOver:T,promptListRef:J})}),z&&(0,l.jsx)(g.g,{prompt:$[G],variables:K,onSubmit:e=>{let t=null==_?void 0:_.replace(/{{(.*?)}}/g,((t,r)=>{let a=K.indexOf(r);return e[a]}));E(t),y&&y.current&&y.current.focus()},onClose:()=>R(!1)})]})]}),(0,l.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,l.jsx)("a",{href:"https://aivvm.oss-cn-shanghai.aliyuncs.com/alipay.png",target:"_blank",rel:"noreferrer",className:"underline",children:"免费赞助"}),","," ",(0,l.jsx)("a",{href:"https://aivvm.oss-cn-shanghai.aliyuncs.com/ali-sc.png",target:"_blank",rel:"noreferrer",className:"underline",children:"支付宝免费领红包支持站长"}),","," ",w("日常免费使用是足够的,我不喜欢猫抓老鼠的游戏谢谢,已达成百万月活,十万用户,ST2023-02")]})]})};a()}catch(e){a(e)}}))},84362:function(e,t,r){"use strict";r.a(e,(async function(e,a){try{r.d(t,{s:function(){return x}});var l=r(85893),n=r(67294),s=r(67421),o=r(88990),i=r(60296),d=r(86574),c=r(70794),u=e([d]);d=(u.then?(await u)():u)[0];let m={sage:(0,c.Z)("0.002").div(1e3),"gpt-3.5-turbo":(0,c.Z)("0.002").div(1e3),"gpt-3.5-turbo-0301":(0,c.Z)("0.002").div(1e3),"gpt-3.5-turbo-0613":(0,c.Z)("0.002").div(1e3),"gpt-3.5-turbo-16k":(0,c.Z)("0.002").div(1e3),"gpt-3.5-turbo-16k-0613":(0,c.Z)("0.002").div(1e3),"gpt-4":(0,c.Z)("0.03").div(1e3),"gpt-4-0314":(0,c.Z)("0.03").div(1e3),"gpt-4-0613":(0,c.Z)("0.03").div(1e3),"gpt-4-32k":(0,c.Z)("0.03").div(1e3),"gpt-4-32k-0314":(0,c.Z)("0.03").div(1e3),"gpt-4-32k-0613":(0,c.Z)("0.03").div(1e3),"claude-instant":(0,c.Z)("0.002").div(1e3),"claude-2-100k":(0,c.Z)("0.002").div(1e3),"claude-instant-100k":(0,c.Z)("0.002").div(1e3),"google-palm":(0,c.Z)("0.002").div(1e3)};function x(e){var t,r,a;let{t:c}=(0,s.$G)("chat"),{state:{selectedConversation:u}}=(0,n.useContext)(o.Z),[x,p]=(0,n.useState)(null);(0,n.useEffect)((()=>{let e=new d.OU(i.Q1,{...i.YL,"<|im_start|>":100264,"<|im_end|>":100265,"<|im_sep|>":100266},i.er);return p(e),()=>null==e?void 0:e.free()}),[]);let h=[{role:"system",content:null!==(t=null==u?void 0:u.prompt)&&void 0!==t?t:""},...null!==(r=null==u?void 0:u.messages)&&void 0!==r?r:[],{role:"user",content:null!==(a=e.content)&&void 0!==a?a:""}],f=null==u?void 0:u.model.id.startsWith("gpt-3.5-turbo"),g=f?"\n":"",v=f?"\n":"<|im_sep|>",b=[h.map((e=>{let{role:t,content:r}=e;return"<|im_start|>".concat(t).concat(v).concat(r,"<|im_end|>")})).join(g),"<|im_start|>assistant".concat(v)].join(g),y=null==x?void 0:x.encode(b,"all").length,k=m[(null==u?void 0:u.model.id)||"gpt-3.5-turbo"];return null==k||null==y?null:(0,l.jsx)("div",{className:"px-2 py-1 rounded-full pointer-events-auto bg-opacity-10 bg-neutral-300 text-neutral-400",children:c("{{count}} tokens / ${{price}}",{count:y,price:k.multipliedBy(y).toFixed()})})}a()}catch(e){a(e)}}))},79420:function(e,t,r){"use strict";r.d(t,{G:function(){return n}});var a=r(85893),l=r(90553);let n=()=>(0,a.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,a.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,a.jsx)("div",{className:"min-w-[40px] items-end",children:(0,a.jsx)(l.Z,{size:30})}),(0,a.jsx)("span",{className:"animate-pulse cursor-default mt-1",children:"▍"})]})})},84378:function(e,t,r){"use strict";r.d(t,{Y:function(){return n}});var a=r(85893),l=r(58403);let n=e=>{let{error:t}=e;return(0,a.jsxs)("div",{className:"mx-6 flex h-full flex-col items-center justify-center text-red-500",children:[(0,a.jsx)("div",{className:"mb-5",children:(0,a.jsx)(l.Z,{size:36})}),(0,a.jsx)("div",{className:"mb-3 text-2xl font-medium",children:t.title}),t.messageLines.map(((e,t)=>(0,a.jsxs)("div",{className:"text-center",children:[" ",e," "]},t))),(0,a.jsx)("div",{className:"mt-4 text-xs opacity-50 dark:text-red-400",children:t.code?(0,a.jsxs)("i",{children:["Code: ",t.code]}):""})]})}},11085:function(e,t,r){"use strict";r.d(t,{m:function(){return S}});var a=r(67294),l=r(85893),n=r(90553),s=r(8861),o=r(21942),i=r(74075),d=r(88198),c=r(93625),u=r(61162),m=r(62716),x=r(88990),p=r(67828),h=r(80335),f=r(93179),g=r(84283);let v={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"},b=(0,a.memo)((e=>{let{language:t,value:r}=e,{t:n}=(0,u.$G)("markdown"),[s,o]=(0,a.useState)(!1);return(0,l.jsxs)("div",{className:"codeblock relative font-sans text-[16px]",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between py-1.5 px-4",children:[(0,l.jsx)("span",{className:"text-xs lowercase text-white",children:t}),(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsxs)("button",{className:"flex gap-1.5 items-center rounded bg-none p-1 text-xs text-white",onClick:()=>{navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(r).then((()=>{o(!0),setTimeout((()=>{o(!1)}),2e3)}))},children:[s?(0,l.jsx)(d.Z,{size:18}):(0,l.jsx)(p.Z,{size:18}),n(s?"Copied!":"Copy code")]}),(0,l.jsx)("button",{className:"flex items-center rounded bg-none p-1 text-xs text-white",onClick:()=>{let e=v[t]||".file",a="file-".concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="ABCDEFGHJKLMNPQRSTUVWXY3456789",a="";for(let t=0;te.children===t.children));var w=r(45884),j=r(29758),C=r(30399);let N=(0,a.memo)((e=>{var t;let{message:r,messageIndex:p,onEdit:h}=e,{t:f}=(0,u.$G)("chat"),{state:{selectedConversation:g,conversations:v,currentMessage:y,messageIsStreaming:N},dispatch:S}=(0,a.useContext)(x.Z),[_,E]=(0,a.useState)(!1),[I,P]=(0,a.useState)(!1),[O,L]=(0,a.useState)(r.content),[G,T]=(0,a.useState)(!1),Z=(0,a.useRef)(null),A=()=>{r.content!=O&&g&&h&&h({...r,content:O}),E(!1)};return(0,a.useEffect)((()=>{L(r.content)}),[r.content]),(0,a.useEffect)((()=>{Z.current&&(Z.current.style.height="inherit",Z.current.style.height="".concat(Z.current.scrollHeight,"px"))}),[_]),(0,l.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,l.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,l.jsx)("div",{className:"min-w-[40px] text-right font-bold",children:"assistant"===r.role?(0,l.jsx)(n.Z,{size:30}):(0,l.jsx)(s.Z,{size:30})}),(0,l.jsx)("div",{className:"prose mt-[-2px] w-full dark:prose-invert",children:"user"===r.role?(0,l.jsxs)("div",{className:"flex w-full",children:[_?(0,l.jsxs)("div",{className:"flex w-full flex-col",children:[(0,l.jsx)("textarea",{ref:Z,className:"w-full resize-none whitespace-pre-wrap border-none dark:bg-[#343541]",value:O,onChange:e=>{L(e.target.value),Z.current&&(Z.current.style.height="inherit",Z.current.style.height="".concat(Z.current.scrollHeight,"px"))},onKeyDown:e=>{"Enter"!==e.key||I||e.shiftKey||(e.preventDefault(),A())},onCompositionStart:()=>P(!0),onCompositionEnd:()=>P(!1),style:{fontFamily:"inherit",fontSize:"inherit",lineHeight:"inherit",padding:"0",margin:"0",overflow:"hidden"}}),(0,l.jsxs)("div",{className:"mt-10 flex justify-center space-x-4",children:[(0,l.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:A,disabled:O.trim().length<=0,children:f("Save & Submit")}),(0,l.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:()=>{L(r.content),E(!1)},children:f("Cancel")})]})]}):(0,l.jsx)("div",{className:"prose whitespace-pre-wrap dark:prose-invert flex-1",children:r.content}),!_&&(0,l.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,l.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:()=>{E(!_)},children:(0,l.jsx)(o.Z,{size:20})}),(0,l.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:()=>{if(!g)return;let{messages:e}=g,t=e.findIndex((e=>e===r));if(t<0)return;t{navigator.clipboard&&navigator.clipboard.writeText(r.content).then((()=>{T(!0),setTimeout((()=>{T(!1)}),2e3)}))},children:(0,l.jsx)(c.Z,{size:20})})})]})})]})})}));N.displayName="ChatMessage";let S=(0,a.memo)(N,((e,t)=>e.message.content===t.message.content))},11046:function(e,t,r){"use strict";r.d(t,{q:function(){return i}});var a=r(85893),l=r(93844),n=r(67294),s=r(61162),o=r(88990);let i=()=>{var e;let{t:t}=(0,s.$G)("chat"),{state:{selectedConversation:r,models:i,defaultModelId:d},handleUpdateConversation:c,dispatch:u}=(0,n.useContext)(o.Z);return(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"mb-2 text-left text-neutral-700 dark:text-neutral-400",children:t("Model")}),(0,a.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,a.jsx)("select",{className:"w-full bg-transparent p-2",placeholder:t("Select a model")||"",value:(null==r||null===(e=r.model)||void 0===e?void 0:e.id)||d,onChange:e=>{r&&c(r,{key:"model",value:i.find((t=>t.id===e.target.value))})},children:i.map((e=>(0,a.jsx)("option",{value:e.id,className:"dark:bg-[#343541] dark:text-white",children:e.id===d?"Default (".concat(e.name,")"):e.name},e.id)))})}),(0,a.jsx)("div",{className:"w-full mt-3 text-left text-neutral-700 dark:text-neutral-400 flex items-center",children:(0,a.jsxs)("a",{href:"https://platform.openai.com/account/usage",target:"_blank",className:"flex items-center",children:[(0,a.jsx)(l.Z,{size:18,className:"inline mr-1"}),t("View Account Usage")]})})]})}},68452:function(e,t,r){"use strict";r.d(t,{V:function(){return o}});var a=r(85893),l=r(67294),n=r(61162),s=r(2403);let o=e=>{let{plugin:t,onPluginChange:r,onKeyDown:o}=e,{t:i}=(0,n.$G)("chat"),d=(0,l.useRef)(null);return(0,l.useEffect)((()=>{d.current&&d.current.focus()}),[]),(0,a.jsx)("div",{className:"flex flex-col",children:(0,a.jsx)("div",{className:"mb-1 w-full rounded border border-neutral-200 bg-transparent pr-2 text-neutral-900 dark:border-neutral-600 dark:text-white",children:(0,a.jsxs)("select",{ref:d,className:"w-full cursor-pointer bg-transparent p-2",placeholder:i("Select a plugin")||"",value:(null==t?void 0:t.id)||"",onChange:e=>{r(s.xN.find((t=>t.id===e.target.value)))},onKeyDown:e=>{(e=>{let t=d.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(s.xN.find((e=>e.name===(null==t?void 0:t.selectedOptions[0].innerText))))):o(e)})(e)},children:[(0,a.jsx)("option",{value:"chatgpt",className:"dark:bg-[#343541] dark:text-white",children:"ChatGPT"},"chatgpt"),s.xN.map((e=>(0,a.jsx)("option",{value:e.id,className:"dark:bg-[#343541] dark:text-white",children:e.name},e.id)))]})})})}},9707:function(e,t,r){"use strict";r.d(t,{t:function(){return l}});var a=r(85893);let l=e=>{let{prompts:t,activePromptIndex:r,onSelect:l,onMouseOver:n,promptListRef:s}=e;return(0,a.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,a.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:()=>n(t),children:e.name},e.id)))})}},41347:function(e,t,r){"use strict";r.d(t,{r:function(){return d}});var a=r(85893),l=r(67294),n=r(61162),s=r(64689),o=r(9707),i=r(97939);let d=e=>{var t;let{conversation:r,prompts:d,onChangePrompt:c}=e,{t:u}=(0,n.$G)("chat"),[m,x]=(0,l.useState)(""),[p,h]=(0,l.useState)(0),[f,g]=(0,l.useState)(!1),[v,b]=(0,l.useState)(""),[y,k]=(0,l.useState)([]),[w,j]=(0,l.useState)(!1),C=(0,l.useRef)(null),N=(0,l.useRef)(null),S=d.filter((e=>e.name.toLowerCase().includes(v.toLowerCase()))),_=()=>{let e=S[p];x((t=>null==t?void 0:t.replace(/\/\w*$/,e.content))),I(e),g(!1)},E=(0,l.useCallback)((e=>{let t=e.match(/\/\w*$/);t?(g(!0),b(t[0].slice(1))):(g(!1),b(""))}),[]),I=e=>{let t=(e=>{let t,r=/{{(.*?)}}/g,a=[];for(;null!==(t=r.exec(e));)a.push(t[1]);return a})(e.content);if(k(t),t.length>0)j(!0);else{let t=null==m?void 0:m.replace(/\/\w*$/,e.content);x(t),c(t),E(e.content)}};return(0,l.useEffect)((()=>{var e;C&&C.current&&(C.current.style.height="inherit",C.current.style.height="".concat(null===(e=C.current)||void 0===e?void 0:e.scrollHeight,"px"))}),[m]),(0,l.useEffect)((()=>{r.prompt?x(r.prompt):x(s.cl)}),[r]),(0,l.useEffect)((()=>{let e=e=>{N.current&&!N.current.contains(e.target)&&g(!1)};return window.addEventListener("click",e),()=>{window.removeEventListener("click",e)}}),[]),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"mb-2 text-left text-neutral-700 dark:text-neutral-400",children:u("System Prompt")}),(0,a.jsx)("textarea",{ref:C,className:"w-full rounded-lg border border-neutral-200 bg-transparent px-4 py-3 text-neutral-900 dark:border-neutral-600 dark:text-neutral-100",style:{resize:"none",bottom:"".concat(null==C||null===(t=C.current)||void 0===t?void 0:t.scrollHeight,"px"),maxHeight:"300px",overflow:"".concat(C.current&&C.current.scrollHeight>400?"auto":"hidden")},placeholder:u('Enter a prompt or type "/" to select a prompt...')||"",value:u(m)||"",rows:1,onChange:e=>{let t=e.target.value,a=r.model.maxLength;t.length>a?alert(u("Prompt limit is {{maxLength}} characters. You have entered {{valueLength}} characters.",{maxLength:a,valueLength:t.length})):(x(t),E(t),t.length>0&&c(t))},onKeyDown:e=>{f&&("ArrowDown"===e.key?(e.preventDefault(),h((e=>ee>0?e-1:e))):"Tab"===e.key?(e.preventDefault(),h((e=>e0&&(0,a.jsx)("div",{children:(0,a.jsx)(o.t,{activePromptIndex:p,prompts:S,onSelect:_,onMouseOver:h,promptListRef:N})}),w&&(0,a.jsx)(i.g,{prompt:d[p],variables:y,onSubmit:e=>{let t=null==m?void 0:m.replace(/{{(.*?)}}/g,((t,r)=>{let a=y.indexOf(r);return e[a]}));x(t),c(t),C&&C.current&&C.current.focus()},onClose:()=>j(!1)})]})}},10094:function(e,t,r){"use strict";r.d(t,{$:function(){return i}});var a=r(85893),l=r(67294),n=r(61162),s=r(64689),o=r(88990);let i=e=>{var t;let{label:r,onChangeTemperature:i}=e,{state:{conversations:d}}=(0,l.useContext)(o.Z),c=d[d.length-1],[u,m]=(0,l.useState)(null!==(t=null==c?void 0:c.temperature)&&void 0!==t?t:s.Ar),{t:x}=(0,n.$G)("chat");return(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)("label",{className:"mb-2 text-left text-neutral-700 dark:text-neutral-400",children:r}),(0,a.jsx)("span",{className:"text-[12px] text-black/50 dark:text-white/50 text-sm",children:x("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,a.jsx)("span",{className:"mt-2 mb-1 text-center text-neutral-900 dark:text-neutral-100",children:u.toFixed(1)}),(0,a.jsx)("input",{className:"cursor-pointer",type:"range",min:0,max:1,step:.1,value:u,onChange:e=>{let t=parseFloat(e.target.value);m(t),i(t)}}),(0,a.jsxs)("ul",{className:"w mt-2 pb-8 flex justify-between px-[24px] text-neutral-900 dark:text-neutral-100",children:[(0,a.jsx)("li",{className:"flex justify-center",children:(0,a.jsx)("span",{className:"absolute",children:x("Precise")})}),(0,a.jsx)("li",{className:"flex justify-center",children:(0,a.jsx)("span",{className:"absolute",children:x("Neutral")})}),(0,a.jsx)("li",{className:"flex justify-center",children:(0,a.jsx)("span",{className:"absolute",children:x("Creative")})})]})]})}},97939:function(e,t,r){"use strict";r.d(t,{g:function(){return n}});var a=r(85893),l=r(67294);let n=e=>{let{prompt:t,variables:r,onSubmit:n,onClose:s}=e,[o,i]=(0,l.useState)(r.map((e=>({key:e,value:""}))).filter(((e,t,r)=>r.findIndex((t=>t.key===e.key))===t))),d=(0,l.useRef)(null),c=(0,l.useRef)(null),u=()=>{o.some((e=>""===e.value))?alert("Please fill out all variables"):(n(o.map((e=>e.value))),s())};return(0,l.useEffect)((()=>{let e=e=>{d.current&&!d.current.contains(e.target)&&s()};return window.addEventListener("click",e),()=>{window.removeEventListener("click",e)}}),[s]),(0,l.useEffect)((()=>{c.current&&c.current.focus()}),[]),(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-50",onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&s():(e.preventDefault(),u())},children:(0,a.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,a.jsx)("div",{className:"mb-4 text-xl font-bold text-black dark:text-neutral-200",children:t.name}),(0,a.jsx)("div",{className:"mb-4 text-sm italic text-black dark:text-neutral-200",children:t.description}),o.map(((e,t)=>(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsx)("div",{className:"mb-2 text-sm font-bold text-neutral-200",children:e.key}),(0,a.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=>((e,t)=>{i((r=>{let a=[...r];return a[e].value=t,a}))})(t,e.target.value),rows:3})]},t))),(0,a.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:u,children:"Submit"})]})})}},63845:function(e,t,r){"use strict";r.d(t,{W:function(){return U}});var a=r(85893),l=r(67294),n=r(61162),s=r(81058),o=r(64689),i=r(62716),d=r(76921),c=r(79913);let u=e=>{let{history:t,folders:r,prompts:a}=function(e){if(Array.isArray(e))return{version:4,history:(0,c.m)(e),folders:[],prompts:[]};if(!("version"in e)&&"folders"in e&&"history"in e)return{version:4,history:(0,c.m)(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),l=localStorage.getItem("conversationHistory"),n=[...l?JSON.parse(l):[],...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 s=localStorage.getItem("folders"),o=[...s?JSON.parse(s):[],...r].filter(((e,t,r)=>t===r.findIndex((t=>t.id===e.id))));localStorage.setItem("folders",JSON.stringify(o));let i=localStorage.getItem("prompts"),d=[...i?JSON.parse(i):[],...a].filter(((e,t,r)=>t===r.findIndex((t=>t.id===e.id))));return localStorage.setItem("prompts",JSON.stringify(d)),{version:4,history:n,folders:o,prompts:d}};var m=r(41910),x=r(88990),p=r(35887),h=r(47447),f=r(88198),g=r(97283),v=r(30471),b=r(74075),y=r(87766);let k=(0,l.createContext)(void 0),w=e=>{let{conversation:t}=e,{state:{selectedConversation:r,messageIsStreaming:n},handleSelectConversation:s,handleUpdateConversation:o}=(0,l.useContext)(x.Z),{handleDeleteConversation:i}=(0,l.useContext)(k),[d,c]=(0,l.useState)(!1),[u,m]=(0,l.useState)(!1),[p,w]=(0,l.useState)(""),j=e=>{p.trim().length>0&&(o(e,{key:"name",value:p}),w(""),m(!1))};return(0,l.useEffect)((()=>{u?c(!1):d&&m(!1)}),[u,d]),(0,a.jsxs)("div",{className:"relative flex items-center",children:[u&&(null==r?void 0:r.id)===t.id?(0,a.jsxs)("div",{className:"flex w-full items-center gap-3 rounded-lg bg-[#343541]/90 p-3",children:[(0,a.jsx)(h.Z,{size:18}),(0,a.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:p,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),r&&j(r))},autoFocus:!0})]}):(0,a.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(n?"disabled:cursor-not-allowed":""," ").concat((null==r?void 0:r.id)===t.id?"bg-[#343541]/90":""),onClick:()=>s(t),disabled:n,draggable:"true",onDragStart:e=>((e,t)=>{e.dataTransfer&&e.dataTransfer.setData("conversation",JSON.stringify(t))})(e,t),children:[(0,a.jsx)(h.Z,{size:18}),(0,a.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,a.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,a.jsx)(y.Z,{handleClick:e=>{e.stopPropagation(),d?i(t):u&&j(t),c(!1),m(!1)},children:(0,a.jsx)(f.Z,{size:18})}),(0,a.jsx)(y.Z,{handleClick:e=>{e.stopPropagation(),c(!1),m(!1)},children:(0,a.jsx)(g.Z,{size:18})})]}),(null==r?void 0:r.id)===t.id&&!d&&!u&&(0,a.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,a.jsx)(y.Z,{handleClick:e=>{e.stopPropagation(),m(!0),r&&w(r.name)},children:(0,a.jsx)(v.Z,{size:18})}),(0,a.jsx)(y.Z,{handleClick:e=>{e.stopPropagation(),c(!0)},children:(0,a.jsx)(b.Z,{size:18})})]})]})},j=e=>{let{searchTerm:t}=e,{state:{folders:r,conversations:n},handleUpdateConversation:s}=(0,l.useContext)(x.Z),o=(e,t)=>{if(e.dataTransfer){let r=JSON.parse(e.dataTransfer.getData("conversation"));s(r,{key:"folderId",value:t.id})}},i=e=>n&&n.filter((e=>e.folderId)).map(((t,r)=>{if(t.folderId===e.id)return(0,a.jsx)("div",{className:"ml-5 gap-2 border-l pl-2",children:(0,a.jsx)(w,{conversation:t})},r)}));return(0,a.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,a.jsx)(p.Z,{searchTerm:t,currentFolder:e,handleDrop:o,folderComponent:i(e)},r)))})};var C=r(75846),N=r(33111),S=r(49089);let _=e=>{let{open:t,onClose:r}=e,{t:o}=(0,n.$G)("settings"),i=(0,S.G)(),{state:d,dispatch:c}=(0,s.L)({initialState:i}),{dispatch:u}=(0,l.useContext)(x.Z),m=(0,l.useRef)(null);(0,l.useEffect)((()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&window.addEventListener("mouseup",t)},t=e=>{window.removeEventListener("mouseup",t),r()};return window.addEventListener("mousedown",e),()=>{window.removeEventListener("mousedown",e)}}),[r]);return t?(0,a.jsx)("div",{className:"fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50",children:(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-hidden",children:(0,a.jsxs)("div",{className:"flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"hidden sm:inline-block sm:h-screen sm:align-middle","aria-hidden":"true"}),(0,a.jsxs)("div",{ref:m,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,a.jsx)("div",{className:"text-lg pb-4 font-bold text-black dark:text-neutral-200",children:o("Settings")}),(0,a.jsx)("div",{className:"text-sm font-bold mb-2 text-black dark:text-neutral-200",children:o("Theme")}),(0,a.jsxs)("select",{className:"w-full cursor-pointer bg-transparent p-2 text-neutral-700 dark:text-neutral-200",value:d.theme,onChange:e=>c({field:"theme",value:e.target.value}),children:[(0,a.jsx)("option",{value:"dark",children:o("Dark mode")}),(0,a.jsx)("option",{value:"light",children:o("Light mode")})]}),(0,a.jsx)("button",{type:"button",className:"w-full px-4 py-2 mt-6 border rounded-lg shadow border-neutral-500 text-neutral-900 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:()=>{u({field:"lightMode",value:d.theme}),(0,S.z)(d),r()},children:o("Save")})]})]})})}):(0,a.jsx)(a.Fragment,{})};var E=r(52216);let I=e=>{let{text:t,icon:r,onClick:l}=e;return(0,a.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,a.jsx)("div",{children:r}),(0,a.jsx)("span",{children:t})]})},P=e=>{let{onImport:t}=e,{t:r}=(0,n.$G)("sidebar");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{id:"import-file",className:"sr-only",tabIndex:-1,type:"file",accept:".json",onChange:e=>{var r;if(!(null===(r=e.target.files)||void 0===r?void 0:r.length))return;let a=e.target.files[0],l=new FileReader;l.onload=e=>{var r;t(JSON.parse(null===(r=e.target)||void 0===r?void 0:r.result))},l.readAsText(a)}}),(0,a.jsx)(I,{text:r("Import data"),icon:(0,a.jsx)(E.Z,{size:18}),onClick:()=>{let e=document.querySelector("#import-file");e&&e.click()}})]})};var O=r(35336);let L=e=>{let{apiKey:t,onApiKeyChange:r}=e,{t:s}=(0,n.$G)("sidebar"),[o,i]=(0,l.useState)(!1),[d,c]=(0,l.useState)(t),u=(0,l.useRef)(null),m=e=>{r(e.trim()),i(!1)};return(0,l.useEffect)((()=>{var e;o&&(null===(e=u.current)||void 0===e||e.focus())}),[o]),o?(0,a.jsxs)("div",{className:"duration:200 flex w-full cursor-pointer items-center rounded-md py-3 px-3 transition-colors hover:bg-gray-500/10",children:[(0,a.jsx)(O.Z,{size:18}),(0,a.jsx)("input",{ref:u,className:"ml-2 h-[20px] flex-1 overflow-hidden overflow-ellipsis border-b border-neutral-400 bg-transparent pr-1 text-[12.5px] leading-3 text-left text-white outline-none focus:border-neutral-100",type:"password",value:d,onChange:e=>c(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),m(d))},placeholder:s("API Key")||"API Key"}),(0,a.jsxs)("div",{className:"flex w-[40px]",children:[(0,a.jsx)(f.Z,{className:"ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100",size:18,onClick:e=>{e.stopPropagation(),m(d)}}),(0,a.jsx)(g.Z,{className:"ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100",size:18,onClick:e=>{e.stopPropagation(),i(!1),c(t)}})]})]}):(0,a.jsx)(I,{text:s("OpenAI API Key"),icon:(0,a.jsx)(O.Z,{size:18}),onClick:()=>i(!0)})},G=e=>{let{onClearConversations:t}=e,[r,s]=(0,l.useState)(!1),{t:o}=(0,n.$G)("sidebar");return r?(0,a.jsxs)("div",{className:"flex w-full cursor-pointer items-center rounded-lg py-3 px-3 hover:bg-gray-500/10",children:[(0,a.jsx)(b.Z,{size:18}),(0,a.jsx)("div",{className:"ml-3 flex-1 text-left text-[12.5px] leading-3 text-white",children:o("Are you sure?")}),(0,a.jsxs)("div",{className:"flex w-[40px]",children:[(0,a.jsx)(f.Z,{className:"ml-auto mr-1 min-w-[20px] text-neutral-400 hover:text-neutral-100",size:18,onClick:e=>{e.stopPropagation(),t(),s(!1)}}),(0,a.jsx)(g.Z,{className:"ml-auto min-w-[20px] text-neutral-400 hover:text-neutral-100",size:18,onClick:e=>{e.stopPropagation(),s(!1)}})]})]}):(0,a.jsx)(I,{text:o("Clear conversations"),icon:(0,a.jsx)(b.Z,{size:18}),onClick:()=>s(!0)})};var T=r(67421),Z=r(2403);let A=()=>{var e,t,r,n;let{t:s}=(0,T.$G)("sidebar"),{state:{pluginKeys:o}}=(0,l.useContext)(x.Z),{handlePluginKeyChange:i,handleClearPluginKey:d}=(0,l.useContext)(k),[c,u]=(0,l.useState)(!1),m=(0,l.useRef)(null);return(0,l.useEffect)((()=>{let e=e=>{m.current&&!m.current.contains(e.target)&&window.addEventListener("mouseup",t)},t=e=>{window.removeEventListener("mouseup",t),u(!1)};return window.addEventListener("mousedown",e),()=>{window.removeEventListener("mousedown",e)}}),[]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(I,{text:s("Plugin Keys"),icon:(0,a.jsx)(O.Z,{size:18}),onClick:()=>u(!0)}),c&&(0,a.jsx)("div",{className:"z-100 fixed inset-0 flex items-center justify-center bg-black bg-opacity-50",onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),u(!1))},children:(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-hidden",children:(0,a.jsxs)("div",{className:"flex min-h-screen items-center justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"hidden sm:inline-block sm:h-screen sm:align-middle","aria-hidden":"true"}),(0,a.jsxs)("div",{ref:m,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,a.jsx)("div",{className:"mb-10 text-4xl",children:"Plugin Keys"}),(0,a.jsxs)("div",{className:"mt-6 rounded border p-4",children:[(0,a.jsx)("div",{className:"text-xl font-bold",children:"Google Search Plugin"}),(0,a.jsx)("div",{className:"mt-4 italic",children:"Please enter your Google API Key and Google CSE ID to enable the Google Search Plugin."}),(0,a.jsx)("div",{className:"mt-6 text-sm font-bold text-black dark:text-neutral-200",children:"Google API Key"}),(0,a.jsx)("input",{className:"mt-2 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",type:"password",value:null===(e=null===(t=o.find((e=>e.pluginId===Z.PO.GOOGLE_SEARCH)))||void 0===t?void 0:t.requiredKeys.find((e=>"GOOGLE_API_KEY"===e.key)))||void 0===e?void 0:e.value,onChange:e=>{let t=o.find((e=>e.pluginId===Z.PO.GOOGLE_SEARCH));if(t){let r=t.requiredKeys.find((e=>"GOOGLE_API_KEY"===e.key));if(r){let r={...t,requiredKeys:t.requiredKeys.map((t=>"GOOGLE_API_KEY"===t.key?{...t,value:e.target.value}:t))};i(r)}}else{let t={pluginId:Z.PO.GOOGLE_SEARCH,requiredKeys:[{key:"GOOGLE_API_KEY",value:e.target.value},{key:"GOOGLE_CSE_ID",value:""}]};i(t)}}}),(0,a.jsx)("div",{className:"mt-6 text-sm font-bold text-black dark:text-neutral-200",children:"Google CSE ID"}),(0,a.jsx)("input",{className:"mt-2 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",type:"password",value:null===(r=null===(n=o.find((e=>e.pluginId===Z.PO.GOOGLE_SEARCH)))||void 0===n?void 0:n.requiredKeys.find((e=>"GOOGLE_CSE_ID"===e.key)))||void 0===r?void 0:r.value,onChange:e=>{let t=o.find((e=>e.pluginId===Z.PO.GOOGLE_SEARCH));if(t){let r=t.requiredKeys.find((e=>"GOOGLE_CSE_ID"===e.key));if(r){let r={...t,requiredKeys:t.requiredKeys.map((t=>"GOOGLE_CSE_ID"===t.key?{...t,value:e.target.value}:t))};i(r)}}else{let t={pluginId:Z.PO.GOOGLE_SEARCH,requiredKeys:[{key:"GOOGLE_API_KEY",value:""},{key:"GOOGLE_CSE_ID",value:e.target.value}]};i(t)}}}),(0,a.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:()=>{let e=o.find((e=>e.pluginId===Z.PO.GOOGLE_SEARCH));e&&d(e)},children:"Clear Google Search Plugin Keys"})]}),(0,a.jsx)("button",{type:"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:()=>u(!1),children:s("Save")})]})]})})})]})},K=()=>{let{t:e}=(0,n.$G)("sidebar"),[t,r]=(0,l.useState)(!1),{state:{apiKey:s,lightMode:o,serverSideApiKeyIsSet:i,serverSidePluginKeysSet:d,conversations:c},dispatch:u}=(0,l.useContext)(x.Z),{handleClearConversations:m,handleImportConversations:p,handleExportData:h,handleApiKeyChange:f}=(0,l.useContext)(k);return(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-1 border-t border-white/20 pt-1 text-sm",children:[c.length>0?(0,a.jsx)(G,{onClearConversations:m}):null,(0,a.jsx)(P,{onImport:p}),(0,a.jsx)(I,{text:e("Export data"),icon:(0,a.jsx)(C.Z,{size:18}),onClick:()=>h()}),(0,a.jsx)(I,{text:e("Settings"),icon:(0,a.jsx)(N.Z,{size:18}),onClick:()=>r(!0)}),i?null:(0,a.jsx)(L,{apiKey:s,onApiKeyChange:f}),d?null:(0,a.jsx)(A,{}),(0,a.jsx)(_,{open:t,onClose:()=>{r(!1)}})]})},D=e=>{let{conversations:t}=e;return(0,a.jsx)("div",{className:"flex w-full flex-col gap-1",children:t.filter((e=>!e.folderId)).slice().reverse().map(((e,t)=>(0,a.jsx)(w,{conversation:e},t)))})};var z=r(27301);let R={searchTerm:"",filteredConversations:[]};var M=r(57632);let U=()=>{let{t:e}=(0,n.$G)("sidebar"),t=(0,s.L)({initialState:R}),{state:{conversations:r,showChatbar:c,defaultModelId:p,folders:h,pluginKeys:f},dispatch:g,handleCreateFolder:v,handleNewConversation:b,handleUpdateConversation:y}=(0,l.useContext)(x.Z),{state:{searchTerm:w,filteredConversations:C},dispatch:N}=t,S=(0,l.useCallback)((e=>{g({field:"apiKey",value:e}),localStorage.setItem("apiKey",e)}),[g]);return(0,l.useEffect)((()=>{N(w?{field:"filteredConversations",value:r.filter((e=>(e.name.toLocaleLowerCase()+" "+e.messages.map((e=>e.content)).join(" ")).toLowerCase().includes(w.toLowerCase())))}:{field:"filteredConversations",value:r})}),[w,r]),(0,a.jsx)(k.Provider,{value:{...t,handleDeleteConversation:t=>{let a=r.filter((e=>e.id!==t.id));g({field:"conversations",value:a}),N({field:"searchTerm",value:""}),(0,i.fB)(a),a.length>0?(g({field:"selectedConversation",value:a[a.length-1]}),(0,i.m7)(a[a.length-1])):(p&&g({field:"selectedConversation",value:{id:(0,M.Z)(),name:e("New Conversation"),messages:[],model:m.MU[p],prompt:o.cl,temperature:o.Ar,folderId:null}}),localStorage.removeItem("selectedConversation"))},handleClearConversations:()=>{p&&g({field:"selectedConversation",value:{id:(0,M.Z)(),name:e("New Conversation"),messages:[],model:m.MU[p],prompt:o.cl,temperature:o.Ar,folderId:null}}),g({field:"conversations",value:[]}),localStorage.removeItem("conversationHistory"),localStorage.removeItem("selectedConversation");let t=h.filter((e=>"chat"!==e.type));g({field:"folders",value:t}),(0,d._)(t)},handleImportConversations:e=>{let{history:t,folders:r,prompts:a}=u(e);g({field:"conversations",value:t}),g({field:"selectedConversation",value:t[t.length-1]}),g({field:"folders",value:r}),g({field:"prompts",value:a}),window.location.reload()},handleExportData:()=>{(()=>{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 a={version:4,history:e||[],folders:t||[],prompts:r||[]},l=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),n=URL.createObjectURL(l),s=document.createElement("a");s.download="chatbot_ui_history_".concat(function(){let e=new Date,t=e.getMonth()+1,r=e.getDate();return"".concat(t,"-").concat(r)}(),".json"),s.href=n,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(n)})()},handlePluginKeyChange:e=>{if(f.some((t=>t.pluginId===e.pluginId))){let t=f.map((t=>t.pluginId===e.pluginId?e:t));g({field:"pluginKeys",value:t}),localStorage.setItem("pluginKeys",JSON.stringify(t))}else g({field:"pluginKeys",value:[...f,e]}),localStorage.setItem("pluginKeys",JSON.stringify([...f,e]))},handleClearPluginKey:e=>{let t=f.filter((t=>t.pluginId!==e.pluginId));if(0===t.length)return g({field:"pluginKeys",value:[]}),void localStorage.removeItem("pluginKeys");g({field:"pluginKeys",value:t}),localStorage.setItem("pluginKeys",JSON.stringify(t))},handleApiKeyChange:S},children:(0,a.jsx)(z.Z,{side:"left",isOpen:c,addItemButtonTitle:e("New chat"),itemComponent:(0,a.jsx)(D,{conversations:C}),folderComponent:(0,a.jsx)(j,{searchTerm:w}),items:C,searchTerm:w,handleSearchTerm:e=>N({field:"searchTerm",value:e}),toggleOpen:()=>{g({field:"showChatbar",value:!c}),localStorage.setItem("showChatbar",JSON.stringify(!c))},handleCreateItem:b,handleCreateFolder:()=>v(e("New folder"),"chat"),handleDrop:e=>{if(e.dataTransfer){let t=JSON.parse(e.dataTransfer.getData("conversation"));y(t,{key:"folderId",value:0}),N({field:"searchTerm",value:""}),e.target.style.background="none"}},footerComponent:(0,a.jsx)(K,{})})})}},35887:function(e,t,r){"use strict";r.d(t,{Z:function(){return x}});var a=r(85893),l=r(87664),n=r(62577),s=r(88198),o=r(97283),i=r(30471),d=r(74075),c=r(67294),u=r(88990),m=r(87766);var x=e=>{let{currentFolder:t,searchTerm:r,handleDrop:x,folderComponent:p}=e,{handleDeleteFolder:h,handleUpdateFolder:f}=(0,c.useContext)(u.Z),[g,v]=(0,c.useState)(!1),[b,y]=(0,c.useState)(!1),[k,w]=(0,c.useState)(""),[j,C]=(0,c.useState)(!1),N=()=>{f(t.id,k),w(""),y(!1)};return(0,c.useEffect)((()=>{b?v(!1):g&&y(!1)}),[b,g]),(0,c.useEffect)((()=>{C(!!r)}),[r]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"relative flex items-center",children:[b?(0,a.jsxs)("div",{className:"flex w-full items-center gap-3 bg-[#343541]/90 p-3",children:[j?(0,a.jsx)(l.Z,{size:18}):(0,a.jsx)(n.Z,{size:18}),(0,a.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:k,onChange:e=>w(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),N())},autoFocus:!0})]}):(0,a.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:()=>C(!j),onDrop:e=>(e=>{e.dataTransfer&&(C(!0),x(e,t),e.target.style.background="none")})(e),onDragOver:e=>{e.preventDefault()},onDragEnter:e=>{e.target.style.background="#343541"},onDragLeave:e=>{e.target.style.background="none"},children:[j?(0,a.jsx)(l.Z,{size:18}):(0,a.jsx)(n.Z,{size:18}),(0,a.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})]}),(g||b)&&(0,a.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,a.jsx)(m.Z,{handleClick:e=>{e.stopPropagation(),g?h(t.id):b&&N(),v(!1),y(!1)},children:(0,a.jsx)(s.Z,{size:18})}),(0,a.jsx)(m.Z,{handleClick:e=>{e.stopPropagation(),v(!1),y(!1)},children:(0,a.jsx)(o.Z,{size:18})})]}),!g&&!b&&(0,a.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,a.jsx)(m.Z,{handleClick:e=>{e.stopPropagation(),y(!0),w(t.name)},children:(0,a.jsx)(i.Z,{size:18})}),(0,a.jsx)(m.Z,{handleClick:e=>{e.stopPropagation(),v(!0)},children:(0,a.jsx)(d.Z,{size:18})})]})]}),j?p:null]})}},76262:function(e,t,r){"use strict";r.d(t,{w:function(){return n}});var a=r(85893),l=r(1177);let n=e=>{let{selectedConversation:t,onNewConversation:r}=e;return(0,a.jsxs)("nav",{className:"flex w-full justify-between bg-[#202123] py-3 px-4",children:[(0,a.jsx)("div",{className:"mr-4"}),(0,a.jsx)("div",{className:"max-w-[240px] overflow-hidden text-ellipsis whitespace-nowrap",children:t.name}),(0,a.jsx)(l.Z,{className:"cursor-pointer hover:text-neutral-400 mr-8",onClick:r})]})}},70185:function(e,t,r){"use strict";r.d(t,{Z:function(){return N}});var a=r(85893),l=r(67294),n=r(67421),s=r(81058),o=r(36686),i=r(41910),d=r(88990),c=r(35887),u=r(12691),m=r(88198),x=r(97283),p=r(74075),h=r(87766);let f=(0,l.createContext)(void 0);var g=r(61162);let v=e=>{let{prompt:t,onClose:r,onUpdatePrompt:n}=e,{t:s}=(0,g.$G)("promptbar"),[o,i]=(0,l.useState)(t.name),[d,c]=(0,l.useState)(t.description),[u,m]=(0,l.useState)(t.content),x=(0,l.useRef)(null),p=(0,l.useRef)(null);return(0,l.useEffect)((()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&window.addEventListener("mouseup",t)},t=e=>{window.removeEventListener("mouseup",t),r()};return window.addEventListener("mousedown",e),()=>{window.removeEventListener("mousedown",e)}}),[r]),(0,l.useEffect)((()=>{var e;null===(e=p.current)||void 0===e||e.focus()}),[]),(0,a.jsx)("div",{className:"fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-50",onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(n({...t,name:o,description:d,content:u.trim()}),r())},children:(0,a.jsx)("div",{className:"fixed inset-0 z-10 overflow-hidden",children:(0,a.jsxs)("div",{className:"flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0",children:[(0,a.jsx)("div",{className:"hidden sm:inline-block sm:h-screen sm:align-middle","aria-hidden":"true"}),(0,a.jsxs)("div",{ref:x,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,a.jsx)("div",{className:"text-sm font-bold text-black dark:text-neutral-200",children:s("Name")}),(0,a.jsx)("input",{ref:p,className:"mt-2 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",placeholder:s("A name for your prompt.")||"",value:o,onChange:e=>i(e.target.value)}),(0,a.jsx)("div",{className:"mt-6 text-sm font-bold text-black dark:text-neutral-200",children:s("Description")}),(0,a.jsx)("textarea",{className:"mt-2 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:s("A description for your prompt.")||"",value:d,onChange:e=>c(e.target.value),rows:3}),(0,a.jsx)("div",{className:"mt-6 text-sm font-bold text-black dark:text-neutral-200",children:s("Prompt")}),(0,a.jsx)("textarea",{className:"mt-2 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:s("Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}")||"",value:u,onChange:e=>m(e.target.value),rows:10}),(0,a.jsx)("button",{type:"button",className:"w-full px-4 py-2 mt-6 border rounded-lg shadow border-neutral-500 text-neutral-900 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:()=>{let e={...t,name:o,description:d,content:u.trim()};n(e),r()},children:s("Save")})]})]})})})},b=e=>{let{prompt:t}=e,{dispatch:r,handleUpdatePrompt:n,handleDeletePrompt:s}=(0,l.useContext)(f),[o,i]=(0,l.useState)(!1),[d,c]=(0,l.useState)(!1),[g,b]=(0,l.useState)(!1),[y,k]=(0,l.useState)("");return(0,l.useEffect)((()=>{g?c(!1):d&&b(!1)}),[g,d]),(0,a.jsxs)("div",{className:"relative flex items-center",children:[(0,a.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",draggable:"true",onClick:e=>{e.stopPropagation(),i(!0)},onDragStart:e=>((e,t)=>{e.dataTransfer&&e.dataTransfer.setData("prompt",JSON.stringify(t))})(e,t),onMouseLeave:()=>{c(!1),b(!1),k("")},children:[(0,a.jsx)(u.Z,{size:18}),(0,a.jsx)("div",{className:"relative max-h-5 flex-1 overflow-hidden text-ellipsis whitespace-nowrap break-all pr-4 text-left text-[12.5px] leading-3",children:t.name})]}),(d||g)&&(0,a.jsxs)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:[(0,a.jsx)(h.Z,{handleClick:e=>{e.stopPropagation(),d&&(s(t),r({field:"searchTerm",value:""})),c(!1)},children:(0,a.jsx)(m.Z,{size:18})}),(0,a.jsx)(h.Z,{handleClick:e=>{e.stopPropagation(),c(!1)},children:(0,a.jsx)(x.Z,{size:18})})]}),!d&&!g&&(0,a.jsx)("div",{className:"absolute right-1 z-10 flex text-gray-300",children:(0,a.jsx)(h.Z,{handleClick:e=>{e.stopPropagation(),c(!0)},children:(0,a.jsx)(p.Z,{size:18})})}),o&&(0,a.jsx)(v,{prompt:t,onClose:()=>i(!1),onUpdatePrompt:e=>{n(e),r({field:"searchTerm",value:""})}})]})},y=()=>{let{state:{folders:e}}=(0,l.useContext)(d.Z),{state:{searchTerm:t,filteredPrompts:r},handleUpdatePrompt:n}=(0,l.useContext)(f),s=(e,t)=>{if(e.dataTransfer){let r={...JSON.parse(e.dataTransfer.getData("prompt")),folderId:t.id};n(r)}},o=e=>r.filter((e=>e.folderId)).map(((t,r)=>{if(t.folderId===e.id)return(0,a.jsx)("div",{className:"ml-5 gap-2 border-l pl-2",children:(0,a.jsx)(b,{prompt:t})},r)}));return(0,a.jsx)("div",{className:"flex w-full flex-col pt-2",children:e.filter((e=>"prompt"===e.type)).sort(((e,t)=>e.name.localeCompare(t.name))).map(((e,r)=>(0,a.jsx)(c.Z,{searchTerm:t,currentFolder:e,handleDrop:s,folderComponent:o(e)},r)))})},k=e=>{let{prompts:t}=e;return(0,a.jsx)("div",{className:"flex w-full flex-col gap-1",children:t.slice().reverse().map(((e,t)=>(0,a.jsx)(b,{prompt:e},t)))})};var w=r(27301);let j={searchTerm:"",filteredPrompts:[]};var C=r(57632);var N=()=>{let{t:e}=(0,n.$G)("promptbar"),t=(0,s.L)({initialState:j}),{state:{prompts:r,defaultModelId:c,showPromptbar:u},dispatch:m,handleCreateFolder:x}=(0,l.useContext)(d.Z),{state:{searchTerm:p,filteredPrompts:h},dispatch:g}=t,v=()=>{if(c){let e={id:(0,C.Z)(),name:"Prompt ".concat(r.length+1),description:"",content:"",model:i.MU[c],folderId:null},t=[...r,e];m({field:"prompts",value:t}),(0,o.V)(t)}},b=e=>{let t=r.map((t=>t.id===e.id?e:t));m({field:"prompts",value:t}),(0,o.V)(t)};return(0,l.useEffect)((()=>{g(p?{field:"filteredPrompts",value:r.filter((e=>(e.name.toLowerCase()+" "+e.description.toLowerCase()+" "+e.content.toLowerCase()).includes(p.toLowerCase())))}:{field:"filteredPrompts",value:r})}),[p,r]),(0,a.jsx)(f.Provider,{value:{...t,handleCreatePrompt:v,handleDeletePrompt:e=>{let t=r.filter((t=>t.id!==e.id));m({field:"prompts",value:t}),(0,o.V)(t)},handleUpdatePrompt:b},children:(0,a.jsx)(w.Z,{side:"right",isOpen:u,addItemButtonTitle:e("New prompt"),itemComponent:(0,a.jsx)(k,{prompts:h.filter((e=>!e.folderId))}),folderComponent:(0,a.jsx)(y,{}),items:h,searchTerm:p,handleSearchTerm:e=>g({field:"searchTerm",value:e}),toggleOpen:()=>{m({field:"showPromptbar",value:!u}),localStorage.setItem("showPromptbar",JSON.stringify(!u))},handleCreateItem:v,handleCreateFolder:()=>x(e("New folder"),"prompt"),handleDrop:e=>{if(e.dataTransfer){let t={...JSON.parse(e.dataTransfer.getData("prompt")),folderId:e.target.dataset.folderId};b(t),e.target.style.background="none"}}})})}},27301:function(e,t,r){"use strict";r.d(t,{Z:function(){return h}});var a=r(85893),l=r(1177),n=r(16745),s=r(92005),o=r(67421),i=r(98963),d=r(89014);let c=e=>{let{onClick:t,side:r}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.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,a.jsx)(i.Z,{}):(0,a.jsx)(d.Z,{})}),(0,a.jsx)("div",{onClick:t,className:"absolute top-0 left-0 z-10 h-full w-full bg-black opacity-70 sm:hidden"})]})},u=e=>{let{onClick:t,side:r}=e;return(0,a.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,a.jsx)(d.Z,{}):(0,a.jsx)(i.Z,{})})};var m=r(97283),x=r(61162);let p=e=>{let{placeholder:t,searchTerm:r,onSearch:l}=e,{t:n}=(0,x.$G)("sidebar");return(0,a.jsxs)("div",{className:"relative flex items-center",children:[(0,a.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:n(t)||"",value:r,onChange:e=>{l(e.target.value)}}),r&&(0,a.jsx)(m.Z,{className:"absolute right-4 cursor-pointer text-neutral-300 hover:text-neutral-400",size:18,onClick:()=>{l("")}})]})};var h=e=>{let{isOpen:t,addItemButtonTitle:r,side:i,items:d,itemComponent:m,folderComponent:x,footerComponent:h,searchTerm:f,handleSearchTerm:g,toggleOpen:v,handleCreateItem:b,handleCreateFolder:y,handleDrop:k}=e,{t:w}=(0,o.$G)("promptbar");return t?(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"fixed top-0 ".concat(i,"-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,a.jsxs)("div",{className:"flex items-center",children:[(0,a.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:()=>{b(),g("")},children:[(0,a.jsx)(l.Z,{size:16}),r]}),(0,a.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:y,children:(0,a.jsx)(n.Z,{size:16})})]}),(0,a.jsx)(p,{placeholder:w("Search...")||"",searchTerm:f,onSearch:g}),(0,a.jsxs)("div",{className:"flex-grow overflow-auto",children:[(null==d?void 0:d.length)>0&&(0,a.jsx)("div",{className:"flex border-b border-white/20 pb-2",children:x}),(null==d?void 0:d.length)>0?(0,a.jsx)("div",{className:"pt-2",onDrop:k,onDragOver:e=>{e.preventDefault()},onDragEnter:e=>{e.target.style.background="#343541"},onDragLeave:e=>{e.target.style.background="none"},children:m}):(0,a.jsxs)("div",{className:"mt-8 select-none text-center text-white opacity-50",children:[(0,a.jsx)(s.Z,{className:"mx-auto mb-3"}),(0,a.jsx)("span",{className:"text-[14px] leading-normal",children:w("No data.")})]})]}),h]}),(0,a.jsx)(c,{onClick:v,side:i})]}):(0,a.jsx)(u,{onClick:v,side:i})}},79408:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var a=r(85893);var l=e=>{let{size:t="1em",className:r=""}=e;return(0,a.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,a.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"6"}),(0,a.jsx)("line",{x1:"12",y1:"18",x2:"12",y2:"22"}),(0,a.jsx)("line",{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76"}),(0,a.jsx)("line",{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07"}),(0,a.jsx)("line",{x1:"2",y1:"12",x2:"6",y2:"12"}),(0,a.jsx)("line",{x1:"18",y1:"12",x2:"22",y2:"12"}),(0,a.jsx)("line",{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24"}),(0,a.jsx)("line",{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93"})]})}},81058:function(e,t,r){"use strict";r.d(t,{L:function(){return l}});var a=r(67294);let l=e=>{let{initialState:t}=e,[r,l]=(0,a.useReducer)(((e,r)=>{if(!r.type)return{...e,[r.field]:r.value};if("reset"===r.type)return t;throw Error()}),t);return(0,a.useMemo)((()=>({state:r,dispatch:l})),[r,l])}},88990:function(e,t,r){"use strict";let a=(0,r(67294).createContext)(void 0);t.Z=a},45928:function(e,t,r){"use strict";r.d(t,{E:function(){return a}});let a={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}},78600:function(e,t,r){"use strict";r.a(e,(async function(e,a){try{var l=r(85893),n=r(67294),s=r(88767),o=r(61162),i=r(9008),d=r.n(i),c=r(81058),u=r(96711),m=r(1652),x=r(79913),p=r(64689),h=r(62716),f=r(76921),g=r(36686),v=r(49089),b=r(41910),y=r(5782),k=r(63845),w=r(76262),j=r(70185),C=r(88990),N=r(45928),S=r(57632),_=e([y]);y=(_.then?(await _)():_)[0];let E=e=>{let{serverSideApiKeyIsSet:t,serverSidePluginKeysSet:r,defaultModelId:a}=e,{t:i}=(0,o.$G)("chat"),{getModels:_}=(0,m.Z)(),{getModelsError:E}=(0,u.Z)(),[I,P]=(0,n.useState)(!0),O=(0,c.L)({initialState:N.E}),{state:{apiKey:L,lightMode:G,folders:T,conversations:Z,selectedConversation:A,prompts:K,temperature:D},dispatch:z}=O,R=(0,n.useRef)(!1),{data:M,error:U,refetch:F}=(0,s.useQuery)(["GetModels",L,t],(e=>{let{signal:r}=e;return L||t?_({key:L},r):null}),{enabled:!0,refetchOnMount:!1});(0,n.useEffect)((()=>{M&&z({field:"models",value:M})}),[M,z]),(0,n.useEffect)((()=>{z({field:"modelError",value:E(U)})}),[z,U,E]);let H=()=>{var e;let t=Z[Z.length-1],r={id:(0,S.Z)(),name:i("New Conversation"),messages:[],model:(null==t?void 0:t.model)||{id:b.MU[a].id,name:b.MU[a].name,maxLength:b.MU[a].maxLength,tokenLimit:b.MU[a].tokenLimit},prompt:p.cl,temperature:null!==(e=null==t?void 0:t.temperature)&&void 0!==e?e:p.Ar,folderId:null},l=[...Z,r];z({field:"selectedConversation",value:r}),z({field:"conversations",value:l}),(0,h.m7)(r),(0,h.fB)(l),z({field:"loading",value:!1})};return(0,n.useEffect)((()=>{window.innerWidth<640&&z({field:"showChatbar",value:!1})}),[A]),(0,n.useEffect)((()=>{a&&z({field:"defaultModelId",value:a}),t&&z({field:"serverSideApiKeyIsSet",value:t}),r&&z({field:"serverSidePluginKeysSet",value:r})}),[a,t,r]),(0,n.useEffect)((()=>{let e=(0,v.G)();e.theme&&z({field:"lightMode",value:e.theme});let l=localStorage.getItem("apiKey");t?(z({field:"apiKey",value:""}),localStorage.removeItem("apiKey")):l&&z({field:"apiKey",value:l});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 s=localStorage.getItem("showChatbar");s&&z({field:"showChatbar",value:"true"===s});let o=localStorage.getItem("showPromptbar");o&&z({field:"showPromptbar",value:"true"===o});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=(0,x.m)(e);z({field:"conversations",value:t})}let m=localStorage.getItem("selectedConversation");if(m){let e=JSON.parse(m),t=(0,x.$)(e);z({field:"selectedConversation",value:t})}else{var h;let e=Z[Z.length-1];z({field:"selectedConversation",value:{id:(0,S.Z)(),name:i("New Conversation"),messages:[],model:b.MU[a],prompt:p.cl,temperature:null!==(h=null==e?void 0:e.temperature)&&void 0!==h?h:p.Ar,folderId:null}})}}),[a,z,t,r]),(0,l.jsxs)(C.Z.Provider,{value:{...O,handleNewConversation:H,handleCreateFolder:(e,t)=>{let r={id:(0,S.Z)(),name:e,type:t},a=[...T,r];z({field:"folders",value:a}),(0,f._)(a)},handleDeleteFolder:e=>{let t=T.filter((t=>t.id!==e));z({field:"folders",value:t}),(0,f._)(t);let r=Z.map((t=>t.folderId===e?{...t,folderId:null}:t));z({field:"conversations",value:r}),(0,h.fB)(r);let a=K.map((t=>t.folderId===e?{...t,folderId:null}:t));z({field:"prompts",value:a}),(0,g.V)(a)},handleUpdateFolder:(e,t)=>{let r=T.map((r=>r.id===e?{...r,name:t}:r));z({field:"folders",value:r}),(0,f._)(r)},handleSelectConversation:e=>{z({field:"selectedConversation",value:e}),(0,h.m7)(e)},handleUpdateConversation:(e,t)=>{let r={...e,[t.key]:t.value},{single:a,all:l}=(0,h.X1)(r,Z);z({field:"selectedConversation",value:a}),z({field:"conversations",value:l})}},children:[(0,l.jsxs)(d(),{children:[(0,l.jsx)("title",{children:"Chatbot UI"}),(0,l.jsx)("meta",{name:"description",content:"ChatGPT but better."}),(0,l.jsx)("meta",{name:"viewport",content:"height=device-height ,width=device-width, initial-scale=1, user-scalable=no"}),(0,l.jsx)("link",{rel:"icon",href:"/favicon.ico"})]}),A&&(0,l.jsxs)("main",{className:"flex h-screen w-screen flex-col text-sm text-white dark:text-white ".concat(G),children:[(0,l.jsx)("div",{className:"fixed top-0 w-full sm:hidden",children:(0,l.jsx)(w.w,{selectedConversation:A,onNewConversation:H})}),(0,l.jsxs)("div",{className:"flex h-full w-full pt-[48px] sm:pt-0",children:[(0,l.jsx)(k.W,{}),(0,l.jsx)("div",{className:"flex flex-1",children:(0,l.jsx)(y.e,{stopConversationRef:R})}),(0,l.jsx)(j.Z,{})]})]})]})};t.Z=E,a()}catch(e){a(e)}}))},74322:function(e,t,r){"use strict";r.a(e,(async function(e,a){try{r.d(t,{Z:function(){return l.Z}});var l=r(78600),n=e([l]);l=(n.then?(await n)():n)[0],a()}catch(e){a(e)}}))},42603:function(e,t,r){"use strict";r.a(e,(async function(e,a){try{r.r(t),r.d(t,{__N_SSP:function(){return s},default:function(){return l.Z}});var l=r(74322),n=e([l]);l=(n.then?(await n)():n)[0];var s=!0;a()}catch(e){a(e)}}))},96711:function(e,t,r){"use strict";var a=r(67294),l=r(61162);t.Z=()=>{let{t:e}=(0,l.$G)("chat");return{getModelsError:(0,a.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])}}},1652:function(e,t,r){"use strict";r.d(t,{Z:function(){return l}});var a=r(67294);var l=()=>{let e=(()=>{let e=async(e,t,r)=>{let a=(null==t?void 0:t.params)?"".concat(e).concat(t.params):e,l=(null==t?void 0:t.body)?t.body instanceof FormData?{...t,body:t.body}:{...t,body:JSON.stringify(t.body)}:t,n={...(null==t?void 0:t.headers)?t.headers:(null==t?void 0:t.body)&&t.body instanceof FormData?{}:{"Content-type":"application/json"}};return fetch(a,{...l,headers:n,signal:r}).then((e=>{if(!e.ok)throw e;let t=e.headers.get("content-type"),r=e.headers.get("content-disposition");return e.headers,!t||-1===(null==t?void 0:t.indexOf("application/json"))&&-1===(null==t?void 0:t.indexOf("text/plain"))?-1!==(null==r?void 0:r.indexOf("attachment"))?e.blob():e:e.json()})).catch((async e=>{let t=e.headers.get("content-type");throw t&&-1!==(null==t?void 0:t.indexOf("application/problem+json"))?await e.json():e}))};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"})}})(),t=(0,a.useCallback)(((t,r)=>e.post("/api/models",{body:{key:t.key},headers:{"Content-Type":"application/json"},signal:r})),[e]);return{getModels:t}}},41910:function(e,t,r){"use strict";var a,l;r.d(t,{MU:function(){return n},bm:function(){return a}}),(l=a||(a={})).GPT_3_5="gpt-3.5-turbo",l.GPT_3_5_POE="gpt-3.5-turbo-poe",l.GPT_3_5_0613="gpt-3.5-turbo-0613",l.GPT_3_5_16K="gpt-3.5-turbo-16k",l.GPT_3_5_16K_POE="gpt-3.5-turbo-16k-poe",l.GPT_3_5_16K_0613="gpt-3.5-turbo-16k-0613",l.GPT_4_0613="gpt-4-0613",l.GPT_4="gpt-4",l.GPT_4_POE="gpt-4-poe",l.GPT_4_32K_0613="gpt-4-32k-0613",l.GPT_4_32K="gpt-4-32k",l.GPT_4_32K_POE="gpt-4-32k-poe",l.CLAUDE_2_100K="claude-2-100k",l.CLAUDE_INSTANT_100K="claude-instant-100k",l.CLAUDE_INSTANT="claude-instant",l.BARD="bard",l.ASSISTANT="assistant",l.GOOGLE_PALM="google-palm",l.LLAMA_2_70b_chat="llama_2_70b_chat",a.GPT_3_5;let n={[a.GPT_3_5]:{id:a.GPT_3_5,name:"GPT-3.5",maxLength:12e3,tokenLimit:4096},[a.GPT_3_5_POE]:{id:a.GPT_3_5_POE,name:"GPT-3.5_POE",maxLength:12e3,tokenLimit:4096},[a.GPT_3_5_0613]:{id:a.GPT_3_5_0613,name:"GPT-3.5-0613",maxLength:12e3,tokenLimit:4096},[a.GPT_3_5_16K]:{id:a.GPT_3_5_16K,name:"GPT-3.5-16K",maxLength:48e3,tokenLimit:16384},[a.GPT_3_5_16K_POE]:{id:a.GPT_3_5_16K_POE,name:"GPT-3.5-16K-POE",maxLength:48e3,tokenLimit:16384},[a.GPT_3_5_16K_0613]:{id:a.GPT_3_5_16K_0613,name:"GPT-3.5-16K-0613",maxLength:48e3,tokenLimit:16384},[a.GPT_4_0613]:{id:a.GPT_4_0613,name:"GPT-4-0613",maxLength:24e3,tokenLimit:8192},[a.GPT_4]:{id:a.GPT_4,name:"GPT-4",maxLength:24e3,tokenLimit:8192},[a.GPT_4_POE]:{id:a.GPT_4_POE,name:"GPT-4-POE",maxLength:24e3,tokenLimit:8192},[a.GPT_4_32K_0613]:{id:a.GPT_4_32K_0613,name:"GPT-4-32K-0613",maxLength:96e3,tokenLimit:32768},[a.GPT_4_32K]:{id:a.GPT_4_32K,name:"GPT-4-32K",maxLength:96e3,tokenLimit:32768},[a.GPT_4_32K_POE]:{id:a.GPT_4_32K_POE,name:"GPT-4-32K-POE",maxLength:96e3,tokenLimit:32768},[a.CLAUDE_2_100K]:{id:a.CLAUDE_2_100K,name:"Claude-2-100K",maxLength:36e4,tokenLimit:102400},[a.CLAUDE_INSTANT_100K]:{id:a.CLAUDE_INSTANT_100K,name:"Claude-Instant-100K",maxLength:36e4,tokenLimit:102400},[a.CLAUDE_INSTANT]:{id:a.CLAUDE_INSTANT,name:"Claude-Instant",maxLength:36e3,tokenLimit:10240},[a.BARD]:{id:a.BARD,name:"BARD",maxLength:3e4,tokenLimit:1e4},[a.ASSISTANT]:{id:a.ASSISTANT,name:"ASSISTANT",maxLength:3e4,tokenLimit:1e4},[a.GOOGLE_PALM]:{id:a.GOOGLE_PALM,name:"GOOGLE-PALM",maxLength:3e4,tokenLimit:1e4},[a.LLAMA_2_70b_chat]:{id:a.LLAMA_2_70b_chat,name:"LLAMA_2_70b_chat",maxLength:3e4,tokenLimit:1e4}}},2403:function(e,t,r){"use strict";var a,l;r.d(t,{PO:function(){return a},xN:function(){return s}}),(a||(a={})).GOOGLE_SEARCH="google-search",(l||(l={})).GOOGLE_SEARCH="Google Search";let n={[a.GOOGLE_SEARCH]:{id:a.GOOGLE_SEARCH,name:l.GOOGLE_SEARCH,requiredKeys:[{key:"GOOGLE_API_KEY",value:""},{key:"GOOGLE_CSE_ID",value:""}]}},s=Object.values(n)},17172:function(e,t,r){"use strict";r.d(t,{O:function(){return l}});var a=r(2403);let l=e=>e&&e.id===a.PO.GOOGLE_SEARCH?"api/google":"api/chat"},79913:function(e,t,r){"use strict";r.d(t,{$:function(){return n},m:function(){return s}});var a=r(41910),l=r(64689);let n=e=>{let t=e;return t.model||(t={...t,model:t.model||a.MU[a.bm.GPT_3_5]}),t.prompt||(t={...t,prompt:t.prompt||l.cl}),t.temperature||(t={...t,temperature:t.temperature||l.Ar}),t.folderId||(t={...t,folderId:t.folderId||null}),t.messages||(t={...t,messages:t.messages||[]}),t},s=e=>Array.isArray(e)?e.reduce(((e,t)=>{try{t.model||(t.model=a.MU[a.bm.GPT_3_5]),t.prompt||(t.prompt=l.cl),t.temperature||(t.temperature=l.Ar),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."),[])},64689:function(e,t,r){"use strict";r.d(t,{Ar:function(){return n},cl:function(){return l}});var a=r(83454);let l=a.env.NEXT_PUBLIC_DEFAULT_SYSTEM_PROMPT||"You are ChatGPT, a large language model trained by OpenAI. Follow the user's instructions carefully. Respond using markdown.";a.env.OPENAI_API_HOST;let n=parseFloat(a.env.NEXT_PUBLIC_DEFAULT_TEMPERATURE||"0.7");a.env.OPENAI_API_TYPE,a.env.OPENAI_API_VERSION,a.env.OPENAI_ORGANIZATION,a.env.AZURE_DEPLOYMENT_ID,a.env.LOG_INCOMING_MESSAGES,a.env.LOG_TRIM_MESSAGES},62716:function(e,t,r){"use strict";r.d(t,{X1:function(){return a},fB:function(){return n},m7:function(){return l}});let a=(e,t)=>{let r=t.map((t=>t.id===e.id?e:t));return l(e),n(r),{single:e,all:r}},l=e=>{localStorage.setItem("selectedConversation",JSON.stringify(e))},n=e=>{localStorage.setItem("conversationHistory",JSON.stringify(e))}},76921:function(e,t,r){"use strict";r.d(t,{_:function(){return a}});let a=e=>{localStorage.setItem("folders",JSON.stringify(e))}},36686:function(e,t,r){"use strict";r.d(t,{V:function(){return a}});let a=e=>{localStorage.setItem("prompts",JSON.stringify(e))}},49089:function(e,t,r){"use strict";r.d(t,{G:function(){return l},z:function(){return n}});let a="settings",l=()=>{let e={theme:"dark"},t=localStorage.getItem(a);if(t)try{let r=JSON.parse(t);e=Object.assign(e,r)}catch(e){console.error(e)}return e},n=e=>{localStorage.setItem(a,JSON.stringify(e))}},97450:function(e,t,r){"use strict";function a(e,t){let r,a;return function(){for(var l=arguments.length,n=Array(l),s=0;s{Date.now()-a>=t&&(e(...n),a=Date.now())}),t-(Date.now()-a))):(e(...n),a=Date.now())}}r.d(t,{P:function(){return a}})}},function(e){e.O(0,[876,879,798,774,888,179],(function(){return e(e.s=48312)})),_N_E=e.O()}]);