(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[642],{77592:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return aN}});var s,r,n=a(9268),l=a(16329);a(80293);var o=a(98422),i=a(84451),c=a(90592);o.ZP.use(c.Db).use(i.Z).init({fallbackLng:"en",resources:{"zh-CN":{translation:{"Shortcut to open this app":"打开ChatHub的快捷键",Settings:"设置","Startup page":"启动页面","Chat style":"会话风格","Change shortcut":"修改快捷键",Save:"保存",Saved:"已保存",Export:"导出",Import:"导入","Bot Name":"名称","Space URL":"空间地址","Export/Import All Data":"导出/导入数据","Data includes all your settings, chat histories, and local prompts":"数据包括所有设置、聊天记录和本地prompts",Edit:"编辑",Use:"使用",Send:"发送",Stop:"停止",Title:"标题",Content:"内容",Search:"搜索",Model:"模型",Cancel:"取消","Presale discount":"预售折扣","More bots in All-In-One mode":"在All-In-One模式下使用更多chatbot(三合一、四合一)","Chat history full-text search":"全文搜索聊天记录","Customize theme":"自定义主题","More features in the future":"享受未来所有功能更新","Support the development of ChatHub":"支持ChatHub的开发","Enjoy ChatHub? Give us a 5-star rating!":"喜欢ChatHub吗?给我们个5星好评吧!","Write review":"去评价","Activate license":"激活License","\uD83C\uDF89 License activated":"\uD83C\uDF89 License已激活","All-In-One Mode":"All-In-One模式","Two in one":"二合一","Three in one":"三合一","Four in one":"四合一","Activate up to 5 devices":"最多可激活5台设备",Deactivate:"反激活","Get premium license":"购买会员","Theme Settings":"主题设置","Theme Mode":"主题模式","Theme Color":"主题色","Follow Arc browser theme":"跟随Arc浏览器主题色","iFlytek Spark":"讯飞星火","You need to login to Poe first":"需要先登录Poe账号","Login at bing.com":"去 bing.com 登录","Login at poe.com":"去 poe.com 登录","Login at xfyun.cn":"登录讯飞账号","Lifetime license":"终身授权","Join the waitlist":"加入waitlist","GPT-4 models require ChatGPT Plus":"ChatGPT Plus账号可使用","Model used by ChatGPT iOS app, potentially faster":"ChatGPT iOS app使用的模型,可能更快","Poe subscribers only":"Poe订阅会员可用","Quick access in Chrome side bar":"在Chrome侧边栏快速访问","You have opened ChatHub {{openTimes}} times, consider unlock all features?":"哇!你已经打开ChatHub {{openTimes}}次了,是否要解锁全部功能呢?\uD83E\uDD7A","Open Prompt Library":"管理提示词","Use / to select prompts, Shift+Enter to add new line":"使用 / 选择提示词,Shift+Enter添加换行","Your Prompts":"你的提示词","Community Prompts":"提示词社区","Create new prompt":"创建提示词","Earlybird price":"早鸟价格","Share conversation":"分享会话","Clear conversation":"清空会话","View history":"查看历史消息","Premium Feature":"高级功能","Upgrade to unlock":"升级解锁","Please check your network connection":"请检查您的网络连接,中国用户可能需要科学上网","Display size":"显示大小","You’ve reached the daily free message limit for this model":"你已经达到了该模型今日免费消息上限","This is a limitation set by poe.com":"这是poe.com的限制",Feedback:"反馈",Theme:"主题","Add More":"更多模型",Premium:"付费会员",Chatbots:"聊天机器人","Manage order and devices":"管理订单与设备","Upgrade to premium to chat with more than two bots at once":"升级会员,同时和两个以上的机器人聊天",Upgrade:"升级","This usually mean you need to add a payment method to your OpenAI account, checkout: ":"这通常意味着您需要在OpenAI账户中添加付款方式,请查看:"}},de:{translation:{"Shortcut to open this app":"Tastenk\xfcrzel zum \xd6ffnen dieser App",Settings:"Einstellungen","Startup page":"Startseite","Conversation style":"Konversationsstil","Change shortcut":"Tastenk\xfcrzel \xe4ndern",Save:"Speichern",Export:"Exportieren",Import:"Importieren","Export/Import All Data":"Alle Daten exportieren/importieren","Data includes all your settings, chat histories, and local prompts":"Daten beinhalten alle Einstellungen, Chatverl\xe4ufe und lokale Prompts"}},es:{translation:{"Shortcut to open this app":"Acceso directo para abrir esta aplicaci\xf3n",Settings:"Configuraci\xf3n","Startup page":"P\xe1gina de inicio","Conversation style":"Estilo de conversaci\xf3n","Change shortcut":"Cambiar acceso directo",Save:"Guardar",Export:"Exportar",Import:"Importar","Export/Import All Data":"Exportar/Importar todos los datos","Data includes all your settings, chat histories, and local prompts":"Los datos incluyen todas tus configuraciones, historiales de chat y promociones locales"}},fr:{translation:{"Shortcut to open this app":"Raccourci pour ouvrir cette application",Settings:"Param\xe8tres","Startup page":"Page de d\xe9marrage","Conversation style":"Style de conversation","Change shortcut":"Modifier le raccourci",Save:"Enregistrer",Export:"Exporter",Import:"Importer","Export/Import All Data":"Exporter/Importer toutes les donn\xe9es","Data includes all your settings, chat histories, and local prompts":"Les donn\xe9es incluent tous vos param\xe8tres, historiques de chat et invitations locales"}},in:{translation:{"Shortcut to open this app":"Pintasan untuk membuka aplikasi ini",Settings:"Pengaturan","Startup page":"Halaman awal","Chat style":"Gaya percakapan","Change shortcut":"Ubah pintasan",Save:"Simpan",Saved:"Tersimpan",Export:"Ekspor",Import:"Impor","Export/Import All Data":"Ekspor/Impor Semua Data","Data includes all your settings, chat histories, and local prompts":"Data mencakup semua pengaturan, riwayat percakapan, dan prompt lokal Anda",Edit:"Edit",Use:"Gunakan",Send:"Kirim",Stop:"Berhenti",Title:"Judul",Content:"Konten",Search:"Cari",Model:"Model","Presale discount":"Diskon pra-penjualan","More bots in All-In-One mode":"Lebih banyak bot dalam mode All-In-One","Chat history full-text search":"Pencarian teks penuh riwayat percakapan","Customize theme":"Kustomisasi tema","More features in the future":"Lebih banyak fitur di masa depan","Support the development of ChatHub":"Dukung pengembangan ChatHub","Enjoy ChatHub? Give us a 5-star rating!":"Menikmati ChatHub? Beri kami rating 5 bintang!","Write review":"Tulis ulasan","Activate license":"Aktifkan lisensi","\uD83C\uDF89 License activated":"\uD83C\uDF89 Lisensi diaktifkan","All-In-One Mode":"Mode All-In-One","Two in one":"Dua dalam satu","Three in one":"Tiga dalam satu","Four in one":"Empat dalam satu","Activate up to 5 devices":"Aktifkan hingga 5 perangkat",Deactivate:"Nonaktifkan","Get premium license":"Dapatkan lisensi premium","Theme Settings":"Pengaturan tema","Theme Mode":"Mode tema","Theme Color":"Warna tema","Follow Arc browser theme":"Ikuti tema browser Arc","iFlytek Spark":"iFlytek Spark","You need to login to Poe first":"Anda perlu login ke Poe terlebih dahulu","Login at bing.com":"Login di bing.com","Login at poe.com":"Login di poe.com","Login at xfyun.cn":"Login di xfyun.cn","Lifetime license":"Lisensi seumur hidup","Join the waitlist":"Gabung dalam daftar tunggu","GPT-4 models require ChatGPT Plus":"Model GPT-4 membutuhkan ChatGPT Plus","Model used by ChatGPT iOS app, potentially faster":"Model yang digunakan oleh aplikasi ChatGPT iOS, mungkin lebih cepat","Poe subscribers only":"Hanya pelanggan Poe","Quick access in Chrome side bar":"Akses cepat di sisi bilah Chrome","You have opened ChatHub {{openTimes}} times, consider unlock all features?":"Wow! Anda telah membuka ChatHub sebanyak {{openTimes}} kali, pertimbangkan untuk membuka semua fitur?","Open Prompt Library":"Buka Perpustakaan Prompt","Use / to select prompts, Shift+Enter to add new line":"Gunakan / untuk memilih prompt, Shift+Enter untuk menambahkan baris baru","Your Prompts":"Prompt Anda","Community Prompts":"Prompt Komunitas","Create new prompt":"Buat prompt baru"}},ja:{translation:{"Shortcut to open this app":"このアプリを開くショートカット",Settings:"設定","Startup page":"スタートアップページ","Chat style":"チャットスタイル","Change shortcut":"ショートカットを変更する",Save:"保存",Saved:"保存されました",Export:"エクスポート",Import:"インポート","Export/Import All Data":"すべてのデータをエクスポート/インポート","Data includes all your settings, chat histories, and local prompts":"データはすべての設定、チャット履歴、およびローカルのプロンプトを含みます",Edit:"編集",Use:"使用",Send:"送信",Stop:"停止",Title:"タイトル",Content:"コンテンツ",Search:"検索",Model:"モデル",Cancel:"キャンセル","Presale discount":"プレセール割引","More bots in All-In-One mode":"オールインワンモードでより多くのボットを使用する","Chat history full-text search":"チャット履歴の全文検索","Customize theme":"テーマをカスタマイズ","More features in the future":"将来のさらなる機能","Support the development of ChatHub":"ChatHubの開発をサポート","Enjoy ChatHub? Give us a 5-star rating!":"ChatHubを楽しんでいますか?5つ星の評価をお願いします!","Write review":"レビューを書く","Activate license":"ライセンスを有効にする","\uD83C\uDF89 License activated":"\uD83C\uDF89 ライセンスが有効化されました","All-In-One Mode":"オールインワンモード","Two in one":"二つ一体","Three in one":"三つ一体","Four in one":"四つ一体","Activate up to 5 devices":"最大5台のデバイスを有効化する",Deactivate:"無効にする","Get premium license":"プレミアムライセンスを取得する","Theme Settings":"テーマ設定","Theme Mode":"テーマモード","Theme Color":"テーマカラー","Follow Arc browser theme":"Arcブラウザのテーマに従う","iFlytek Spark":"科大訳飛スパーク","You need to login to Poe first":"先にPoeにログインする必要があります","Login at bing.com":"bing.comでログイン","Login at poe.com":"poe.comでログイン","Login at xfyun.cn":"xfyun.cnでログインする","Lifetime license":"ライフタイムライセンス","Join the waitlist":"ウェイトリストに参加する","GPT-4 models require ChatGPT Plus":"GPT-4モデルはChatGPT Plusが必要","Model used by ChatGPT iOS app, potentially faster":"ChatGPT iOSアプリで使用されるモデル、おそらく速い","Poe subscribers only":"Poeの加入者のみ","Quick access in Chrome side bar":"Chromeサイドバーからのクイックアクセス","You have opened ChatHub {{openTimes}} times, consider unlock all features?":"ChatHubを{{openTimes}}回開きました。全機能を解放しますか?","Open Prompt Library":"プロンプトライブラリを開く","Use / to select prompts, Shift+Enter to add new line":"/ を使用してプロンプトを選択し、Shift+Enterで新しい行を追加します","Your Prompts":"あなたのプロンプト","Community Prompts":"コミュニティのプロンプト","Create new prompt":"新しいプロンプトを作成する","Earlybird price":"早期割引価格","Share conversation":"会話を共有する","Clear conversation":"会話をクリアする","View history":"履歴を表示する","Premium Feature":"プレミアム機能","Upgrade to unlock":"アンロックするためのアップグレード","Please check your network connection":"ネットワーク接続をご確認ください","Display size":"表示サイズ","You’ve reached the daily free message limit for this model":"このモデルの1日あたりの無料メッセージ上限に達しました","This is a limitation set by poe.com":"これはpoe.comによって設定された制限です",Feedback:"フィードバック",Theme:"テーマ",Premium:"プレミアム",Chatbots:"チャットボット","Manage order and devices":"注文とデバイスの管理","Upgrade to premium to chat with more than two bots at once":"一度に2つ以上のボットとチャットするためにプレミアムにアップグレードする",Upgrade:"アップグレード","This usually mean you need to add a payment method to your OpenAI account, checkout:":"これは通常、OpenAIアカウントに支払い方法を追加する必要があることを意味します。チェックアウト:"}},th:{translation:{"Shortcut to open this app":"ทางลัดเพื่อเปิดแอปนี้",Settings:"การตั้งค่า","Startup page":"หน้าเริ่มต้น","Conversation style":"สไตล์การสนทนา","Change shortcut":"เปลี่ยนทางลัด",Save:"บันทึก",Export:"ส่งออก",Import:"นำเข้า","Export/Import All Data":"ส่งออก/นำเข้าข้อมูลทั้งหมด","Data includes all your settings, chat histories, and local prompts":"ข้อมูลรวมถึงการตั้งค่าทั้งหมดของคุณ ประวัติการแชท และข้อความเตือนในเครื่อง"}},"zh-TW":{translation:{"Shortcut to open this app":"開啟此應用程式的快捷鍵",Settings:"設定","Startup page":"啟動頁面","Conversation style":"對話風格","Change shortcut":"變更快捷鍵",Save:"儲存",Export:"匯出",Import:"匯入","Export/Import All Data":"匯出/匯入所有資料","Data includes all your settings, chat histories, and local prompts":"資料包含所有設定、聊天紀錄和本地prompts"}}},interpolation:{escapeValue:!1}});var d=a(80884),m=a(65192),u=a(29541),p=a(42794);let x=e=>{console.log("url",e);let t=new URL(e),a=t.pathname.split("/"),s=a.length>3?a[3]:/[a-z]/i.test(t.hostname)&&t.hostname.split(".").length>2?t.hostname.split(".").at(-2):t.host;return s},h=p.spaces.map(e=>{let t=(null==e?void 0:e.url)||e;return{name:x(t),url:t,system:!0}});(s=r||(r={})).CONVERSATION_LIMIT="CONVERSATION_LIMIT",s.UNKOWN_ERROR="UNKOWN_ERROR",s.GRADIO_ERROR="GRADIO_ERROR",s.CHATGPT_CLOUDFLARE="CHATGPT_CLOUDFLARE",s.CHATGPT_UNAUTHORIZED="CHATGPT_UNAUTHORIZED",s.CHATGPT_AUTH="CHATGPT_AUTH",s.GPT4_MODEL_WAITLIST="GPT4_MODEL_WAITLIST",s.BING_UNAUTHORIZED="BING_UNAUTHORIZED",s.BING_FORBIDDEN="BING_FORBIDDEN",s.BING_CAPTCHA="BING_CAPTCHA",s.API_KEY_NOT_SET="API_KEY_NOT_SET",s.BARD_EMPTY_RESPONSE="BARD_EMPTY_RESPONSE",s.MISSING_POE_HOST_PERMISSION="MISSING_POE_HOST_PERMISSION",s.POE_UNAUTHORIZED="POE_UNAUTHORIZED",s.MISSING_HOST_PERMISSION="MISSING_HOST_PERMISSION",s.NETWORK_ERROR="NETWORK_ERROR",s.POE_MESSAGE_LIMIT="POE_MESSAGE_LIMIT",s.LMSYS_SESSION_EXPIRED="LMSYS_SESSION_EXPIRED",s.CHATGPT_INSUFFICIENT_QUOTA="CHATGPT_INSUFFICIENT_QUOTA";class g extends Error{constructor(e,t){super(e),this.code=t}}class f{async sendMessage(e){try{await this.doSendMessage(e)}catch(a){var t;a instanceof g?e.onEvent({type:"ERROR",error:a}):(null===(t=e.signal)||void 0===t?void 0:t.aborted)||e.onEvent({type:"ERROR",error:new g(a.message,r.UNKOWN_ERROR)})}}get name(){}}class b extends f{async doSendMessage(e){this.conversationContext||(this.conversationContext={sessionHash:(0,p.generateHash)(),chatbot:new p.GradioChatBot(this.model)}),await this.conversationContext.chatbot.chat(e.prompt,{onMessage:t=>{e.onEvent({type:"UPDATE_ANSWER",data:{text:t}})}}).catch(t=>{e.onEvent({type:"ERROR",error:new g(t,r.GRADIO_ERROR)})}),e.onEvent({type:"DONE"})}resetConversation(){this.conversationContext=void 0}constructor(e){super(),this.model=e}}var y=a(31405);let v="(prefers-color-scheme: dark)";function j(){document.documentElement.classList.remove("dark"),document.documentElement.classList.add("light")}function w(){document.documentElement.classList.remove("light"),document.documentElement.classList.add("dark")}function N(e){let t=e.matches?"dark":"light";"dark"===t?w():j()}var C=a(86462);function k(){return(0,C.Z)()}let S=(0,u.xu)(e=>(0,m.sn)({bot:function(e){let t=h.find(t=>t.name===e);return t||console.error("use defalt model"),new b(null==t?void 0:t.url)}(e.botName),messages:[],generatingMessageId:"",abortController:void 0,conversationId:k()}),(e,t)=>e.botName===t.botName&&e.page===t.page),E=(0,u.O4)("sidebarCollapsed",!1),T=(0,u.O4)("themeColor","#7EB8D4"),P=(0,u.O4)("followArcTheme",!1);(0,u.O4)("sidePanelBot","chatgpt");var I=a(8683),_=a.n(I),O=a(86006),R=a(76394),A=a.n(R),D={src:"./_next/static/media/all-in-one.76a3222a.svg",height:26,width:26,blurWidth:0,blurHeight:0},M={src:"./_next/static/media/collapse.fbb9d05e.svg",height:24,width:24,blurWidth:0,blurHeight:0},L={src:"./_next/static/media/feedback.47013dfe.svg",height:24,width:24,blurWidth:0,blurHeight:0},G={src:"./_next/static/media/github.7fb5de84.svg",height:1024,width:1024,blurWidth:0,blurHeight:0},H={src:"./_next/static/media/setting.0ee621f2.svg",height:22,width:20,blurWidth:0,blurHeight:0},F={src:"./_next/static/media/theme.e2c6e463.svg",height:24,width:24,blurWidth:0,blurHeight:0},U={src:"./_next/static/media/logo.e537bd1b.svg",height:312,width:512,blurWidth:0,blurHeight:0},B={src:"./_next/static/media/minimal-logo.75de5ebf.svg",height:256,width:256,blurWidth:0,blurHeight:0},z=a(89949),Z=a(23845),Y=a(22486);let W={async get(e){if(null===e)return null;"string"==typeof e&&(e=[e]);let t={},a=await (0,Y.yS)(e);return e.forEach((e,s)=>{t[e]=a[s]}),t},async set(e){for(let t of Object.keys(e))await (0,Y.t8)(t,e[t])},remove:async e=>(0,Y.IV)(e),clear:async()=>(0,Y.ZH)()},V=parseInt(getComputedStyle(document.documentElement).fontSize,10);var K={storage:{sync:W,local:W},runtime:{getURL:e=>e},tabs:{async getZoom(){let e=parseInt(getComputedStyle(document.documentElement).fontSize,10);return e/V},async setZoom(e){document.documentElement.style.fontSize=e*V+"px"}}};let $={startupPage:"all",enabledBots:h.slice(0,8).map(e=>e.name),allBots:h,useProxy:!1};async function J(){let e=await K.storage.sync.get(Object.keys($));return(0,Z.Z)(e,$)}async function Q(e){for(let[t,a]of(console.debug("update configs",e),await K.storage.sync.set(e),Object.entries(e)))void 0===a&&await K.storage.sync.remove(t)}function q(){let e=(0,z.Z)("enabled-bots",async()=>{let{enabledBots:e}=await J();return h.filter(t=>e.includes(t.name))});return e.data||[]}var X=a(28373),ee=a(87594),et=a(312),ea=a(18178);let es=et.fC;et.xz;let er=e=>{let{className:t,children:a,...s}=e;return(0,n.jsx)(et.h_,{className:_()(t),...s,children:(0,n.jsx)("div",{className:"fixed inset-0 z-50 flex items-start justify-center sm:items-center",children:a})})};er.displayName=et.h_.displayName;let en=O.forwardRef((e,t)=>{let{className:a,children:s,...r}=e;return(0,n.jsx)(et.aV,{className:_()("data-[state=closed]:animate-out data-[state=open]:fade-in data-[state=closed]:fade-out fixed inset-0 z-50 bg-black/50 backdrop-blur-sm transition-all duration-100",a),...r,ref:t})});en.displayName=et.aV.displayName;let el=O.forwardRef((e,t)=>{let{className:a,children:s,...r}=e;return(0,n.jsxs)(er,{children:[(0,n.jsx)(en,{}),(0,n.jsxs)(et.VY,{ref:t,className:_()("animate-in data-[state=open]:fade-in-90 data-[state=open]:slide-in-from-bottom-10 sm:zoom-in-90 data-[state=open]:sm:slide-in-from-bottom-0 fixed z-50 grid w-full gap-4 rounded-b-lg bg-white p-6 sm:max-w-lg sm:rounded-lg","dark:bg-slate-900",a),...r,children:[s,(0,n.jsxs)(et.x8,{className:"absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-slate-100 dark:focus:ring-slate-400 dark:focus:ring-offset-slate-900 dark:data-[state=open]:bg-slate-800",children:[(0,n.jsx)(ea.Z,{className:"h-4 w-4"}),(0,n.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});el.displayName=et.VY.displayName;let eo=O.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(et.Dx,{ref:t,className:_()("text-lg font-semibold text-slate-900","dark:text-slate-50",a),...s})});eo.displayName=et.Dx.displayName;let ei=O.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(et.dk,{ref:t,className:_()("text-sm text-slate-500","dark:text-slate-400",a),...s})});ei.displayName=et.dk.displayName;let ec=O.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(X.mY,{ref:t,className:_()("flex h-full w-full flex-col overflow-hidden rounded-lg bg-white dark:bg-slate-800",a),...s})});ec.displayName=X.mY.displayName;let ed=e=>{let{children:t,...a}=e;return(0,n.jsx)(es,{...a,children:(0,n.jsx)(el,{className:"overflow-hidden !p-0 shadow-2xl [&_[dialog-overlay]]:bg-red-100",children:(0,n.jsx)(ec,{className:"[&_[cmdk-group]]:px-2 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-slate-500 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-input]]:h-12 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5",children:t})})})},em=O.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsxs)("div",{className:"flex items-center border-b border-b-slate-100 px-4 dark:border-b-slate-700","cmdk-input-wrapper":"",children:[(0,n.jsx)(ee.Z,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,n.jsx)(X.mY.Input,{ref:t,className:_()("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-slate-400 disabled:cursor-not-allowed disabled:opacity-50 dark:text-slate-50",a),...s})]})});em.displayName=X.mY.Input.displayName;let eu=O.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(X.mY.List,{ref:t,className:_()("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...s})});eu.displayName=X.mY.List.displayName;let ep=O.forwardRef((e,t)=>(0,n.jsx)(X.mY.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));ep.displayName=X.mY.Empty.displayName;let ex=O.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(X.mY.Group,{ref:t,className:_()("overflow-hidden py-3 px-2 text-slate-700 dark:text-slate-400 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pb-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:text-slate-900 [&_[cmdk-group-heading]]:dark:text-slate-300",a),...s})});ex.displayName=X.mY.Group.displayName;let eh=O.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(X.mY.Separator,{ref:t,className:_()("-mx-1 h-px bg-slate-100 dark:bg-slate-700",a),...s})});eh.displayName=X.mY.Separator.displayName;let eg=O.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,n.jsx)(X.mY.Item,{ref:t,className:_()("relative flex cursor-default select-none items-center rounded-md py-1.5 px-2 text-sm font-medium outline-none aria-selected:bg-slate-100 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:aria-selected:bg-slate-700",a),...s})});eg.displayName=X.mY.Item.displayName;var ef=function(){let[e,t]=(0,O.useState)(!1),a=(0,l.useNavigate)();(0,O.useEffect)(()=>{let e=e=>{"k"===e.key&&e.metaKey&&t(e=>!e)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);let s=(0,O.useCallback)(e=>{e?a({to:"/chat/$name",params:{name:e}}):a({to:"/"}),t(!1)},[a]);return(0,n.jsxs)(ed,{open:e,onOpenChange:t,children:[(0,n.jsx)(em,{placeholder:"Type to search..."}),(0,n.jsxs)(eu,{children:[(0,n.jsx)(ep,{children:"No results found."}),(0,n.jsxs)(ex,{children:[(0,n.jsxs)(eg,{onSelect:()=>s(),children:[(0,n.jsx)(A(),{alt:"all in one",src:D,className:"w-5 h-5 mr-2"}),(0,n.jsx)("span",{children:"All-In-One"})]}),h.map(e=>(0,n.jsx)(eg,{onSelect:s,value:e.name,children:(0,n.jsx)("span",{children:e.name})},e.url))]})]})]})},eb=a(52982),ey=a(22940),ev={src:"./_next/static/media/close.34e62625.svg",height:20,width:20,blurWidth:0,blurHeight:0},ej=e=>(0,n.jsxs)(ey.V,{open:e.open,onClose:e.onClose,className:"relative z-50",children:[(0,n.jsx)("div",{className:"fixed inset-0 bg-black/30","aria-hidden":"true"}),(0,n.jsx)("div",{className:"fixed inset-0 flex items-center justify-center max-h-screen m-5",children:(0,n.jsxs)(ey.V.Panel,{className:_()("mx-auto rounded-3xl bg-primary-background shadow-2xl max-h-full overflow-hidden flex flex-col",e.className),children:[(0,n.jsxs)(ey.V.Title,{className:_()(!e.borderless&&"border-b","border-solid border-primary-border flex flex-row justify-center items-center py-4 px-5"),children:[(0,n.jsx)("span",{className:"ml-auto"}),(0,n.jsx)("span",{className:"font-bold text-primary-text text-base",children:e.title}),(0,n.jsx)(A(),{alt:"close",src:ev,className:"w-4 h-4 ml-auto mr-[10px] cursor-pointer",onClick:e.onClose})]}),e.children]})})]}),ew=a(3420),eN=a(59738),eC=a(8632),ek=a(10830),eS=function(e){let{options:t,value:a,onChange:s,size:r="normal",disabled:l}=e,o=(0,O.useMemo)(()=>t.find(e=>e.value===a).name,[t,a]);return(0,n.jsx)(ew.R,{value:a,onChange:s,disabled:l,children:e=>{let{open:a}=e;return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)(ew.R.Button,{className:_()("relative w-full cursor-default rounded-md bg-white pl-3 pr-10 text-left text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:outline-none leading-6","normal"===r?"text-sm py-1.5":"text-xs py-1",l&&"cursor-not-allowed opacity-50"),children:[(0,n.jsx)("span",{className:"block truncate",children:o}),(0,n.jsx)("span",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2",children:(0,n.jsx)(eC.Z,{className:"h-5 w-5 text-gray-400","aria-hidden":"true"})})]}),(0,n.jsx)(eN.u,{show:a,as:O.Fragment,leave:"transition ease-in duration-100",leaveFrom:"opacity-100",leaveTo:"opacity-0",children:(0,n.jsx)(ew.R.Options,{className:_()("absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none","normal"===r?"text-sm":"text-xs"),children:t.map(e=>(0,n.jsx)(ew.R.Option,{className:e=>{let{active:t}=e;return _()(t?"bg-primary-blue text-white":"text-[#303030]","relative cursor-default select-none py-2 pl-3 pr-9")},value:e.value,children:t=>{let{selected:a,active:s}=t;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:_()(a?"font-semibold":"font-normal","block truncate"),children:e.name}),a?(0,n.jsx)("span",{className:_()(s?"text-white":"text-[#303030]","absolute inset-y-0 right-0 flex items-center pr-4"),children:(0,n.jsx)(ek.Z,{className:"h-5 w-5","aria-hidden":"true"})}):null]})}},e.value))})})]})})}})};let eE=e=>{let{className:t,...a}=e;return(0,n.jsx)("button",{type:"button",className:_()("relative inline-flex items-center bg-primary-background px-3 py-2 text-sm font-semibold text-primary-text ring-1 ring-inset ring-gray-300 hover:opacity-80 focus:z-10",t),...a})},eT=["#7EB8D4","#FF6900","#7BDCB5","#00D084","#8ED1FC","#0693E3","#ABB8C3","#EB144C","#F78DA7","#555555"];var eP=e=>{let{t}=(0,c.$G)(),[a,s]=(0,d.KO)(T),[r,l]=(0,O.useState)((0,y.Dt)()),[o,i]=(0,d.KO)(P),[m,u]=(0,O.useState)(null);(0,O.useEffect)(()=>{K.tabs.getZoom().then(e=>u(e))},[]);let p=(0,O.useCallback)(e=>{if(!m)return;let t="+"===e?m+.1:m-.1;t<.7||t>1.2||(K.tabs.setZoom(t),u(t))},[m]),x=(0,O.useCallback)(e=>{(0,y.pQ)(e),l(e),function(e){if(e===y.hY.Light){j(),window.matchMedia(v).removeEventListener("change",N);return}if(e===y.hY.Dark){w(),window.matchMedia(v).removeEventListener("change",N);return}window.matchMedia(v).matches?w():j(),window.matchMedia(v).addEventListener("change",N)}(e)},[]),h=(0,O.useCallback)(e=>{s(e.hex),e.hex},[s]);return(0,n.jsx)(ej,{title:t("Theme Settings"),open:e.open,onClose:e.onClose,className:"rounded-xl w-[600px] min-h-[300px]",children:(0,n.jsxs)("div",{className:"p-5 pb-10 flex flex-col gap-5",children:[(0,n.jsxs)("div",{className:"w-[300px]",children:[(0,n.jsx)("p",{className:"font-bold text-lg mb-3",children:t("Theme Mode")}),(0,n.jsx)(eS,{options:[{name:t("Light"),value:y.hY.Light},{name:t("Dark"),value:y.hY.Dark}],value:r,onChange:x})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-bold text-lg mb-3",children:t("Theme Color")}),(0,n.jsxs)("div",{className:_()("flex flex-col gap-3"),children:[getComputedStyle(document.documentElement).getPropertyValue("--arc-palette-background")&&(0,n.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,n.jsx)("input",{type:"checkbox",id:"arc-theme-check",checked:o,onChange:e=>i(e.target.checked)}),(0,n.jsx)("label",{htmlFor:"arc-theme-check",children:t("Follow Arc browser theme")})]}),!o&&(0,n.jsx)(eb.e8,{colors:eT,color:a,onChange:h,triangle:"hide",width:"300px"})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-bold text-lg mb-3",children:t("Display size")}),(0,n.jsxs)("span",{className:"isolate inline-flex rounded-md shadow-sm",children:[(0,n.jsx)(eE,{className:"rounded-l-md",onClick:()=>p("-"),children:"-"}),(0,n.jsxs)(eE,{className:"-ml-px cursor-default",children:[null===m?"-":Math.floor(100*m),"%"]}),(0,n.jsx)(eE,{className:"-ml-px rounded-r-md",onClick:()=>p("+"),children:"+"})]})]})]})})},eI=a(22040),e_=e=>(0,n.jsx)(eI.zt,{delayDuration:1,children:(0,n.jsxs)(eI.fC,{children:[(0,n.jsx)(eI.xz,{asChild:!0,children:e.children}),(0,n.jsx)(eI.h_,{children:(0,n.jsx)(eI.VY,{className:"data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade select-none rounded-md bg-black text-white bg-opacity-90 px-[14px] py-2 text-sm leading-none shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] will-change-[transform,opacity]",sideOffset:5,children:e.content})})]})}),eO=function(e){let{text:t,icon:a,iconOnly:s,...r}=e;return(0,n.jsxs)(l.Link,{className:_()("rounded-[10px] w-full h-[45px] pl-3 flex flex-row gap-3 items-center shrink-0 break-all",s&&"justify-center"),activeOptions:{exact:!0},activeProps:{className:"bg-white text-primary-text dark:bg-primary-blue"},inactiveProps:{className:"bg-secondary bg-opacity-20 text-primary-text opacity-80 hover:opacity-100"},title:t,...r,children:[a?(0,n.jsx)(A(),{alt:"nav",src:a,className:"w-6 h-6 ml-1"}):(0,n.jsx)("div",{className:"relative inline-flex items-center justify-center min-w-[2rem] min-h-[2rem] overflow-hidden bg-gray-100 rounded-full dark:bg-gray-600",children:(0,n.jsx)("span",{className:"font-medium text-sm text-gray-600 dark:text-gray-300",children:t.slice(0,2).toUpperCase()})}),(0,n.jsx)("span",{className:"font-medium text-sm",children:s?"":t})]})},eR=e=>{let{text:t}=e;return(0,n.jsx)(l.Link,{to:"/setting",children:(0,n.jsx)("div",{className:"flex flex-row justify-center items-center gap-[10px] rounded-[10px] px-4 py-[6px] cursor-pointer",style:{background:"linear-gradient(275deg, rgb(var(--color-primary-purple)) 1.65%, rgb(var(--color-primary-blue)) 100%)"},children:!!t&&(0,n.jsx)("span",{className:"text-white font-semibold text-base",children:t})})})};function eA(e){return(0,n.jsx)("div",{className:"p-[6px] rounded-[10px] w-fit cursor-pointer hover:opacity-80 bg-secondary bg-opacity-20",onClick:e.onClick,children:(0,n.jsx)(A(),{alt:"button",src:e.icon,className:"w-6 h-6"})})}var eD=function(){let{t:e}=(0,c.$G)(),[t,a]=(0,d.KO)(E),[s,r]=(0,O.useState)(!1),o=q();return(0,n.jsxs)("aside",{className:_()("flex flex-col bg-primary-background bg-opacity-40 overflow-hidden",t?"items-center px-[15px]":"w-[230px] px-4"),children:[(0,n.jsx)(A(),{alt:"collapse",src:M,className:_()("w-6 h-6 cursor-pointer my-5",t?"rotate-180":"self-end"),onClick:()=>a(e=>!e)}),t?(0,n.jsx)(A(),{alt:"logo",src:B,className:"w-[30px]"}):(0,n.jsx)(A(),{alt:"logo",src:U,className:"w-[79px]"}),(0,n.jsxs)("div",{className:"flex flex-col gap-3 mt-2 overflow-y-auto scrollbar-none",children:[(0,n.jsx)(eO,{to:"/",text:"All-In-One",icon:D,iconOnly:t}),o.map(e=>(0,n.jsx)(eO,{to:"/chat/$name",params:{name:e.name},text:e.name,iconOnly:t},e.url))]}),(0,n.jsxs)("div",{className:"mt-auto pt-2",children:[!t&&(0,n.jsx)("hr",{className:"border-[#ffffff4d]"}),!t&&(0,n.jsx)("div",{className:"my-5",children:(0,n.jsx)(eR,{text:e("Add More")})}),(0,n.jsxs)("div",{className:_()("flex mt-5 gap-[10px] mb-4",t?"flex-col":"flex-row "),children:[!t&&(0,n.jsx)(e_,{content:e("GitHub"),children:(0,n.jsx)("a",{href:"https://github.com/weaigc/gradio-chatbot?utm_source=webui",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eA,{icon:G})})}),!t&&(0,n.jsx)(e_,{content:e("Feedback"),children:(0,n.jsx)("a",{href:"https://github.com/weaigc/gradio-chatbot/issues",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eA,{icon:L})})}),!t&&(0,n.jsx)(e_,{content:e("Theme"),children:(0,n.jsx)("a",{onClick:()=>r(!0),children:(0,n.jsx)(eA,{icon:F})})}),(0,n.jsx)(e_,{content:e("Settings"),children:(0,n.jsx)(l.Link,{to:"/setting",children:(0,n.jsx)(eA,{icon:H})})})]})]}),(0,n.jsx)(ef,{}),s&&(0,n.jsx)(eP,{open:!0,onClose:()=>r(!1)})]})},eM=a(62960),eL=a(50942),eG=e=>{let t=e.size||"normal",a=e.type||"button";return(0,n.jsx)("button",{type:a,className:_()("rounded-full","normal"===t?"text-base font-medium px-6 py-[5px]":"text-sm px-4 py-1","primary"===e.color?"text-white bg-primary-blue":"text-primary-text bg-secondary",e.className),onClick:e.onClick,children:e.isLoading?(0,n.jsx)(eL.Z,{size:"normal"===t?10:5,color:"primary"===e.color?"white":"#303030"}):(0,n.jsxs)("div",{className:"flex flex-row items-center gap-1 min-w-max",children:[e.icon,(0,n.jsx)("span",{children:e.text})]})})},eH=a(52134),eF=a(41778),eU=a(21828),eB=a(9735),ez=a(57797),eZ=a(95825);async function eY(){let{prompts:e}=await K.storage.local.get("prompts");return e||[]}async function eW(e){let t=await eY(),a=!1;for(let s of t)if(s.id===e.id){s.title=e.title,s.prompt=e.prompt,a=!0;break}return a||t.unshift(e),await K.storage.local.set({prompts:t}),a}async function eV(e){let t=await eY();await K.storage.local.set({prompts:t.filter(t=>t.id!==e)})}async function eK(){return(0,eZ.Wg)("https://chathub.gg/api/community-prompts",{params:{language:o.ZP.language,languages:o.ZP.languages}}).catch(e=>(console.error("Failed to load remote prompts",e),[]))}let e$={id:"PROMPT_LIBRARY",title:(0,o.t)("Open Prompt Library"),prompt:""},eJ=(0,O.createContext)({}),eQ=e=>{let{prompt:t}=e,a=(0,O.useContext)(eJ),{ref:s,index:r}=(0,eH.JA)(),l=r===a.activeIndex;return(0,n.jsx)("div",{ref:s,tabIndex:l?0:-1,className:_()("cursor-default select-none py-2 px-4",l?"bg-primary-blue text-white":"text-secondary-text"),...a.getItemProps({onClick:()=>{a.handleSelect(t)},onKeyDown:e=>{13===e.keyCode?(a.handleSelect(t),e.preventDefault()):("Backspace"===e.key||"Delete"===e.key)&&a.setIsComboboxOpen(!1)}}),children:t.title})};var eq=()=>{let e=(0,ez.ZP)("user-prompts",eY);return e.data?(0,n.jsxs)("div",{className:"overflow-auto rounded-md py-1 shadow-lg ring-1 ring-primary-border focus:outline-none text-sm min-w-[150px] bg-primary-background",children:[e.data.map(e=>(0,n.jsx)(eQ,{prompt:e},e.id)),e.data.length>0&&(0,n.jsx)("div",{className:"h-[1px] bg-primary-border"}),(0,n.jsx)(eQ,{prompt:e$},"PROMPT_LIBRARY")]}):null},eX=a(35036);let e0=e=>{let{className:t,...a}=e;return(0,n.jsx)("input",{className:_()("px-3 py-1.5 outline-none bg-white text-[#303030] text-sm block rounded-md border-0 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6",t),...a})},e1=e=>{let{className:t,...a}=e;return(0,n.jsx)(eX.Z,{className:_()("px-3 py-1.5 outline-none bg-white text-[#303030] text-sm block rounded-md border-0 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6",t),minRows:2,maxRows:5,...a})};var e2=e=>{let{tabs:t,renderTab:a}=e,[s,r]=(0,O.useState)(t[0].value);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("nav",{className:"w-full flex space-x-4 mb-3","aria-label":"Tabs",children:t.map(e=>(0,n.jsx)("a",{className:_()("rounded-md px-3 py-2 text-sm font-medium cursor-pointer",e.value===s?"bg-primary-blue text-white":"text-secondary-text hover:text-primary-text"),onClick:()=>r(e.value),children:e.name},e.name))}),a(s)]})};let e3=e=>(0,n.jsx)("a",{className:"inline-flex items-center rounded-full bg-white px-2.5 py-1 text-xs font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 cursor-pointer",onClick:e.onClick,children:e.text}),e5=e=>{let{t}=(0,c.$G)(),[a,s]=(0,O.useState)(!1),r=(0,O.useCallback)(()=>{var t;null===(t=e.copyToLocal)||void 0===t||t.call(e),s(!0)},[e]);return(0,n.jsxs)("div",{className:"group relative flex items-center space-x-3 rounded-lg border border-primary-border bg-primary-background px-5 py-4 shadow-sm hover:border-gray-400",children:[(0,n.jsx)("div",{className:"min-w-0 flex-1",children:(0,n.jsx)("p",{title:e.prompt,className:"truncate text-sm font-medium text-primary-text",children:e.title})}),(0,n.jsxs)("div",{className:"flex flex-row gap-1",children:[e.edit&&(0,n.jsx)(e3,{text:t("Edit"),onClick:e.edit}),e.copyToLocal&&(0,n.jsx)(e3,{text:t(a?"Saved":"Save"),onClick:r}),(0,n.jsx)(e3,{text:t("Use"),onClick:()=>e.insertPrompt(e.prompt)})]}),e.remove&&(0,n.jsx)(A(),{alt:"close",src:ev,className:"hidden group-hover:block absolute right-[-8px] top-[-8px] cursor-pointer w-4 h-4 rounded-full bg-primary-background",onClick:e.remove})]})};function e4(e){let{t}=(0,c.$G)(),a=(0,O.useCallback)(t=>{t.preventDefault(),t.stopPropagation();let a=new FormData(t.currentTarget),s=Object.fromEntries(a.entries());s.title&&s.prompt&&e.onSubmit({id:e.initialData.id,title:s.title,prompt:s.prompt})},[e]);return(0,n.jsxs)("form",{className:"flex flex-col gap-2 w-full",onSubmit:a,children:[(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsxs)("span",{className:"text-sm font-semibold block mb-1 text-primary-text",children:["Prompt ",t("Title")]}),(0,n.jsx)(e0,{className:"w-full",name:"title",defaultValue:e.initialData.title})]}),(0,n.jsxs)("div",{className:"w-full",children:[(0,n.jsxs)("span",{className:"text-sm font-semibold block mb-1 text-primary-text",children:["Prompt ",t("Content")]}),(0,n.jsx)(e1,{className:"w-full",name:"prompt",defaultValue:e.initialData.prompt})]}),(0,n.jsxs)("div",{className:"flex flex-row gap-2 mt-1",children:[(0,n.jsx)(eG,{color:"primary",text:t("Save"),className:"w-fit",size:"small",type:"submit"}),(0,n.jsx)(eG,{color:"flat",text:t("Cancel"),className:"w-fit",size:"small",onClick:e.onClose})]})]})}function e8(e){let{t}=(0,c.$G)(),[a,s]=(0,O.useState)(null),r=(0,ez.ZP)("local-prompts",()=>eY(),{suspense:!0}),l=(0,O.useCallback)(async e=>{await eW(e),r.mutate(),s(null)},[r]),o=(0,O.useCallback)(async e=>{await eV(e),r.mutate()},[r]),i=(0,O.useCallback)(()=>{s({id:k(),title:"",prompt:""})},[]);return(0,n.jsxs)(n.Fragment,{children:[r.data.length?(0,n.jsx)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 pt-2",children:r.data.map(t=>(0,n.jsx)(e5,{title:t.title,prompt:t.prompt,edit:()=>!a&&s(t),remove:()=>o(t.id),insertPrompt:e.insertPrompt},t.id))}):(0,n.jsx)("div",{className:"relative block w-full rounded-lg border-2 border-dashed border-gray-300 p-3 text-center text-sm mt-5 text-primary-text",children:"You have no prompts."}),(0,n.jsx)("div",{className:"mt-5",children:a?(0,n.jsx)(e4,{initialData:a,onSubmit:l,onClose:()=>s(null)}):(0,n.jsx)(eG,{text:t("Create new prompt"),size:"small",onClick:i})})]})}function e6(e){let t=(0,ez.ZP)("community-prompts",()=>eK(),{suspense:!0}),a=(0,O.useCallback)(async e=>{await eW({...e,id:k()})},[]);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 pt-2",children:t.data.map((t,s)=>(0,n.jsx)(e5,{title:t.title,prompt:t.prompt,insertPrompt:e.insertPrompt,copyToLocal:()=>a(t)},s))}),(0,n.jsxs)("span",{className:"text-sm mt-5 block text-primary-text",children:["Contribute on"," ",(0,n.jsx)("a",{href:"https://github.com/chathub-dev/community-prompts",target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub"})," ","or"," ",(0,n.jsx)("a",{href:"https://openprompt.co/?utm_source=chathub",target:"_blank",rel:"noreferrer",className:"underline",children:"OpenPrompt"})]})]})}var e9=e=>{let{t}=(0,c.$G)(),a=(0,O.useCallback)(t=>{e.insertPrompt(t)},[e]),s=(0,O.useMemo)(()=>[{name:t("Your Prompts"),value:"local"},{name:t("Community Prompts"),value:"community"}],[t]);return(0,n.jsx)(e2,{tabs:s,renderTab:e=>"local"===e?(0,n.jsx)(O.Suspense,{fallback:(0,n.jsx)(eL.Z,{size:10,className:"mt-5",color:"rgb(var(--primary-text))"}),children:(0,n.jsx)(e8,{insertPrompt:a})}):"community"===e?(0,n.jsx)(O.Suspense,{fallback:(0,n.jsx)(eL.Z,{size:10,className:"mt-5",color:"rgb(var(--primary-text))"}),children:(0,n.jsx)(e6,{insertPrompt:a})}):void 0})},e7=e=>(0,n.jsx)(ej,{title:"Prompt Library",open:e.isOpen,onClose:e.onClose,className:"w-[800px] min-h-[400px]",children:(0,n.jsx)("div",{className:"p-5 overflow-auto",children:(0,n.jsx)(e9,{insertPrompt:e.insertPrompt})})});let te=O.forwardRef((e,t)=>{let{className:a,value:s="",onValueChange:r,minRows:l=1,formref:o,disabled:i,...c}=e,d=(0,O.useRef)(null);(0,O.useImperativeHandle)(t,()=>d.current);let m=(0,O.useCallback)(e=>{if(13===e.keyCode){var t,a;if(e.preventDefault(),e.shiftKey){let e=(null===(t=d.current)||void 0===t?void 0:t.selectionStart)||0;r("".concat(s.slice(0,e),"\n").concat(s.slice(e))),setTimeout(()=>{d.current.setSelectionRange(e+1,e+1)},0)}else i||null==o||null===(a=o.current)||void 0===a||a.requestSubmit()}},[i,o,r,s]);return(0,n.jsx)(eX.Z,{ref:d,className:_()("resize-none overflow-x-hidden overflow-y-auto w-full outline-none text-sm text-primary-text bg-transparent scrollbar-thin",i&&"cursor-wait",a),onKeyDown:m,value:s,onChange:e=>r(e.target.value),autoComplete:"off",minRows:l,maxRows:5,...c})});te.displayName="TextInput";var tt=(0,O.memo)(e=>{let{t}=(0,c.$G)(),{placeholder:a=t("Use / to select prompts, Shift+Enter to add new line")}=e,[s,r]=(0,O.useState)(""),l=(0,O.useRef)(null),o=(0,O.useRef)(null),[i,d]=(0,O.useState)(!1),[m,u]=(0,O.useState)(null),[p,x]=(0,O.useState)(!1),{refs:h,floatingStyles:g,context:f}=(0,eH.YF)({whileElementsMounted:eF.Me,middleware:[(0,eU.cv)(15),(0,eU.RR)(),(0,eU.uY)()],placement:"top-start",open:p,onOpenChange:x}),b=(0,O.useRef)([]),y=(0,O.useCallback)(e=>{if("PROMPT_LIBRARY"===e.id)d(!0),x(!1);else{var t;r(e.prompt),x(!1),null===(t=o.current)||void 0===t||t.focus()}},[]),v=(0,eH.c0)(f,{listRef:b,activeIndex:m,onNavigate:u,loop:!0,focusItemOnOpen:!0,openOnArrowKeyDown:!1}),j=(0,eH.bQ)(f),w=(0,eH.qs)(f,{role:"listbox"}),{getReferenceProps:N,getFloatingProps:C,getItemProps:k}=(0,eH.NI)([w,j,v]),S=(0,O.useMemo)(()=>({activeIndex:m,getItemProps:k,handleSelect:y,setIsComboboxOpen:x}),[m,k,y]),E=(0,O.useCallback)(t=>{t.preventDefault(),s.trim()&&e.onSubmit(s),r("")},[e,s]),T=(0,O.useCallback)(e=>{r(e),x("/"===e)},[]);(0,O.useEffect)(()=>{},[p]);let P=(0,O.useCallback)(e=>{var t,a;let n=(null===(t=o.current)||void 0===t?void 0:t.selectionStart)||0,l=s.slice(0,n),i=s.slice(n);r("".concat(l).concat(e).concat(i)),d(!1),null===(a=o.current)||void 0===a||a.focus()},[s]),I=(0,O.useCallback)(()=>{d(!0)},[]);return(0,n.jsxs)("form",{className:_()("flex flex-row items-center gap-3",e.className),onSubmit:E,ref:l,children:["full"===e.mode&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eB.Zg$,{size:22,color:"#707070",className:"cursor-pointer",onClick:I}),i&&(0,n.jsx)(e7,{isOpen:!0,onClose:()=>d(!1),insertPrompt:P}),(0,n.jsx)(eJ.Provider,{value:S,children:p&&(0,n.jsx)(eH.wD,{context:f,modal:!1,initialFocus:-1,children:(0,n.jsx)("div",{ref:h.setFloating,style:{...g},...C(),children:(0,n.jsx)(eH.vs,{elementsRef:b,children:(0,n.jsx)(eq,{})})})})})]}),(0,n.jsx)("div",{className:"w-full flex flex-col justify-center",ref:h.setReference,...N(),children:(0,n.jsx)(te,{ref:o,formref:l,name:"input",disabled:e.disabled,placeholder:a,value:s,onValueChange:T,autoFocus:e.autoFocus})}),e.actionButton||(0,n.jsx)(eG,{text:"-",className:"invisible",size:"full"===e.mode?"normal":"small"})]})}),ta={src:"./_next/static/media/layout-four.e2ee4959.svg",height:32,width:32,blurWidth:0,blurHeight:0},ts={src:"./_next/static/media/layout-three.7c34ba13.svg",height:32,width:32,blurWidth:0,blurHeight:0},tr={src:"./_next/static/media/layout-two.e5adcdea.svg",height:32,width:32,blurWidth:0,blurHeight:0};let tn=e=>(0,n.jsx)("a",{className:_()(!!e.active&&"bg-[#00000014] dark:bg-[#ffffff26] rounded-[6px]"),onClick:e.onClick,children:(0,n.jsx)(A(),{alt:"item",src:e.icon,className:"w-8 h-8 cursor-pointer"})});var tl=e=>(0,n.jsxs)("div",{className:"flex flex-row items-center gap-2 bg-primary-background rounded-[15px] px-4",children:[(0,n.jsx)(tn,{icon:tr,active:2===e.layout,onClick:()=>e.onChange(2)}),(0,n.jsx)(tn,{icon:ts,active:3===e.layout,onClick:()=>e.onChange(3)}),(0,n.jsx)(tn,{icon:ta,active:4===e.layout,onClick:()=>e.onChange(4)})]}),to=a(31816);async function ti(e){let t="conversations:".concat(e),{[t]:a}=await K.storage.local.get(t);return a||[]}async function tc(e,t){let a=await ti(e),s=a.filter(e=>e.id!==t);await K.storage.local.set({["conversations:".concat(e)]:s})}async function td(e,t){let a="conversation:".concat(e,":").concat(t,":messages"),{[a]:s}=await K.storage.local.get(a);return s||[]}async function tm(e,t,a){let s=await ti(e);s.some(e=>e.id===t)||(s.unshift({id:t,createdAt:Date.now()}),await K.storage.local.set({["conversations:".concat(e)]:s}));let r="conversation:".concat(e,":").concat(t,":messages");await K.storage.local.set({[r]:a})}async function tu(e){let t=await ti(e),a=await Promise.all(t.map(t=>td(e,t.id)));return(0,to.Z)(t,a).map(e=>{let[t,a]=e;return{id:t.id,createdAt:t.createdAt,messages:a}})}async function tp(e,t,a){let s=await td(e,t),r=s.filter(e=>e.id!==a);await tm(e,t,r),r.length||await tc(e,t)}function tx(e){let t=(0,O.useMemo)(()=>S({botName:e,page:"singleton"}),[e]),[a,s]=(0,d.KO)(t),r=(0,O.useCallback)((e,t)=>{s(a=>{let s=a.messages.find(t=>t.id===e);s&&t(s)})},[s]),n=(0,O.useCallback)(async t=>{let n=k();s(a=>{a.messages.push({id:k(),text:t,author:"user"},{id:n,text:"",author:e})});let l=new AbortController;s(e=>{e.generatingMessageId=n,e.abortController=l}),await a.bot.sendMessage({prompt:t,signal:l.signal,onEvent(e){"UPDATE_ANSWER"===e.type?r(n,t=>{t.text=e.data.text}):"ERROR"===e.type?(console.error("sendMessage error",e.error.code,e.error),r(n,t=>{t.error=e.error}),s(e=>{e.abortController=void 0,e.generatingMessageId=""})):"DONE"===e.type&&s(e=>{e.abortController=void 0,e.generatingMessageId=""})}})},[e,a.bot,s,r]),l=(0,O.useCallback)(()=>{a.bot.resetConversation(),s(e=>{e.abortController=void 0,e.generatingMessageId="",e.messages=[],e.conversationId=k()})},[a.bot,s]),o=(0,O.useCallback)(()=>{var e;null===(e=a.abortController)||void 0===e||e.abort(),a.generatingMessageId&&r(a.generatingMessageId,e=>{e.text||e.error||(e.text="Cancelled")}),s(e=>{e.generatingMessageId=""})},[a.abortController,a.generatingMessageId,s,r]);(0,O.useEffect)(()=>{a.messages.length&&tm(e,a.conversationId,a.messages)},[e,a.conversationId,a.messages]);let i=(0,O.useMemo)(()=>({botName:e,bot:a.bot,messages:a.messages,sendMessage:n,resetConversation:l,generating:!!a.generatingMessageId,stopGenerating:o}),[e,a.bot,a.generatingMessageId,a.messages,l,n,o]);return i}var th={src:"./_next/static/media/clear.9ac809d8.svg",height:24,width:24,blurWidth:0,blurHeight:0},tg={src:"./_next/static/media/history.5070ff02.svg",height:24,width:24,blurWidth:0,blurHeight:0},tf={src:"./_next/static/media/share.249db2aa.svg",height:22,width:22,blurWidth:0,blurHeight:0};let tb=(0,O.createContext)(null);var ty=a(83393),tv=a(10184),tj=a(81025),tw=a(18160);a(81973);var tN=a(10688),tC=a(48136),tk=a(2851),tS=a(30458),tE=a(62701),tT=a(80809),tP=a(83765),tI=a(63681),t_=a(21725);function tO(e){let[t,a]=(0,O.useState)(!1),s=(0,O.useMemo)(()=>(0,tS.Z)(e.children),[e.children]);return(0,O.useEffect)(()=>{t&&setTimeout(()=>a(!1),1e3)},[t]),(0,n.jsxs)("div",{className:"flex flex-col",children:[(0,n.jsx)("div",{className:"bg-[#e6e7e8] dark:bg-[#444a5354] text-xs p-2",children:(0,n.jsx)(tN.CopyToClipboard,{text:s,onCopy:()=>a(!0),children:(0,n.jsxs)("div",{className:"flex flex-row items-center gap-2 cursor-pointer w-fit ml-1",children:[(0,n.jsx)(tC.etG,{}),(0,n.jsx)("span",{children:t?"copied":"copy code"})]})})}),(0,n.jsx)("code",{className:_()(e.className,"px-4"),children:e.children})]})}a(68405);var tR=e=>{let{children:t}=e;return(0,n.jsx)(tk.D,{remarkPlugins:[tI.Z,t_.Z,tT.Z,tP.Z],rehypePlugins:[[tE.Z,{detect:!0,ignoreMissing:!0}]],className:"markdown-body markdown-custom-styles !text-base font-normal",linkTarget:"_blank",components:{a:e=>{let{node:t,...a}=e;return a.title?(0,n.jsx)(e_,{content:a.title,children:(0,n.jsx)("a",{...a,title:void 0})}):(0,n.jsx)("a",{...a})},code:e=>{let{node:t,inline:a,className:s,children:r,...l}=e;return a?(0,n.jsx)("code",{className:s,...l,children:r}):(0,n.jsx)(tO,{className:s,children:r})}},children:t})},tA=(0,O.memo)(e=>{let{botName:t,message:a,conversationId:s}=e,{mutate:r}=(0,ez.kY)(),l=(0,O.useCallback)(async()=>{await tp(t,s,a.id),r("history:".concat(t))},[t,s,a.id,r]);return a.text?(0,n.jsxs)("div",{className:_()("group relative py-5 flex flex-col gap-1 px-5 text-primary-text","user"===a.author?"bg-secondary":"bg-primary-background"),children:[(0,n.jsxs)("div",{className:"flex flex-row justify-between",children:[(0,n.jsx)("span",{className:"text-xs text-secondary-tex",children:"user"===a.author?"You":t}),!!s&&(0,n.jsx)(ty.Ybf,{className:"invisible group-hover:visible cursor-pointer",onClick:l})]}),(0,n.jsx)(tR,{children:a.text})]}):null});let tD=(0,O.memo)(e=>(0,n.jsx)("span",{className:"text-secondary-text bg-secondary text-xs px-2 py-1 w-fit rounded",children:function(e){let t=new Date(e),a=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),n=String(t.getMinutes()).padStart(2,"0");return"".concat(a,"/").concat(s," ").concat(r,":").concat(n)}(e.timestamp)}));tD.displayName="Timestamp";var tM=e=>{let{botName:t,keyword:a}=e,s=(0,ez.ZP)("history:".concat(t),()=>tu(t),{suspense:!0}),r=(0,O.useRef)(null),l=(0,O.useMemo)(()=>new tv.Z((0,tj.Z)(s.data,e=>e.messages),{keys:["text"]}),[s.data]),o=(0,O.useMemo)(()=>{let e=[];for(let t of Array.from(s.data).reverse()){let a=t.messages.filter(e=>e.text);if(a.length)for(let s of(e.push({type:"conversation",createdAt:t.createdAt}),a))e.push({type:"message",message:s,conversationId:t.id})}return e},[s.data]),i=(0,O.useMemo)(()=>{if(!a)return[];let e=l.search(a);return e.map(e=>({type:"message",message:e.item,conversationId:""}))},[l,a]);return(0,n.jsx)("div",{className:"flex flex-col overflow-y-auto",ref:r,children:(0,n.jsx)(tw.b,{viewportRef:r,items:i.length?i:o,initialAlignToTop:!0,initialIndex:i.length||o.length,children:e=>"conversation"===e.type?(0,n.jsx)("div",{className:"text-center my-5",children:(0,n.jsx)(tD,{timestamp:e.createdAt})},e.createdAt):(0,n.jsx)(tA,{botName:t,message:e.message,conversationId:e.conversationId},e.message.id)})})},tL=e=>{let t=(0,O.useMemo)(()=>{var t;return null===(t=h.find(t=>t.name===e.botName))||void 0===t?void 0:t.name},[e.botName]),{t:a}=(0,c.$G)(),[s,r]=(0,O.useState)("");return(0,n.jsxs)(ej,{title:"History conversations with ".concat(t),open:e.open,onClose:e.onClose,className:"rounded-2xl w-[1000px] min-h-[400px]",borderless:!0,children:[(0,n.jsx)("div",{className:"border-b border-solid border-primary-border pb-[10px] mx-5",children:(0,n.jsxs)("div",{className:"rounded-[30px] bg-secondary h-9 flex flex-row items-center px-4",children:[(0,n.jsx)(ty.jRj,{size:18,className:"mr-[6px] opacity-30"}),(0,n.jsx)("input",{className:"bg-transparent w-full outline-none text-sm",placeholder:a("Search"),value:s,onChange:e=>r(e.target.value)})]})}),(0,n.jsx)(tM,{botName:e.botName,keyword:s})]})},tG=a(1033),tH=e=>{let{messages:t}=e,[a,s]=(0,O.useState)(!1),r=(0,O.useMemo)(()=>t.filter(e=>!!e.text).map(e=>"**".concat(e.author,"**: ")+e.text).join("\n\n"),[t]),l=(0,O.useCallback)(()=>{navigator.clipboard.writeText(r),s(!0),setTimeout(()=>s(!1),500)},[r]);return(0,n.jsxs)("div",{className:"px-5 pt-3 pb-4 overflow-hidden flex flex-col h-full",children:[(0,n.jsx)("div",{className:"mb-3",children:(0,n.jsx)(eG,{size:"small",text:a?"Copied!":"Copy",onClick:l})}),(0,n.jsx)("pre",{className:"text-sm whitespace-pre-wrap text-primary-text p-2 rounded-md overflow-auto h-full bg-secondary",children:r})]})},tF=a(49596),tU=a(41222),tB=a(61149),tz=a(11804);async function tZ(e){let t=await (0,tz.l)().use(tU.Z).use(t_.Z).use(tP.Z).use(tB.Z).use(tF.Z).process(e);return String(t)}async function tY(e){let t=[{from:"system",value:'
This conversation is shared from ChatHub
'}];for(let a of e)a.text&&t.push({from:"user"===a.author?"human":a.author,value:"user"===a.author?a.text:await tZ(a.text)});return t}async function tW(e){let t=await tY(e),a=await (0,eZ.Wg)("https://sharegpt.com/api/conversations",{method:"POST",body:{avatarUrl:"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 128 128' version='1.1' xmlns='http://www.w3.org/2000/svg' role='img' aria-label='xxlarge'%3E%3Cg%3E%3Ccircle cx='64' cy='64' r='64' fill='%23c1c7d0' /%3E%3Cg%3E%3Cpath fill='%23fff' d='M103,102.1388 C93.094,111.92 79.3504,118 64.1638,118 C48.8056,118 34.9294,111.768 25,101.7892 L25,95.2 C25,86.8096 31.981,80 40.6,80 L87.4,80 C96.019,80 103,86.8096 103,95.2 L103,102.1388 Z' /%3E%3Cpath fill='%23fff' d='M63.9961647,24 C51.2938136,24 41,34.2938136 41,46.9961647 C41,59.7061864 51.2938136,70 63.9961647,70 C76.6985159,70 87,59.7061864 87,46.9961647 C87,34.2938136 76.6985159,24 63.9961647,24' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E%0A",items:t}});return a.id}var tV=e=>{let{messages:t}=e,[a,s]=(0,O.useState)(!1),[r,l]=(0,O.useState)(void 0),[o,i]=(0,O.useState)(!1),c=(0,O.useCallback)(async()=>{s(!0);try{let e=await tW(t);l(e)}finally{s(!1)}},[t]),d=(0,O.useCallback)(()=>{navigator.clipboard.writeText("https://shareg.pt/".concat(r)),i(!0),setTimeout(()=>i(!1),500)},[r]);return(0,n.jsxs)("div",{className:"p-5 flex flex-col items-center justify-center gap-5 h-full",children:[(0,n.jsxs)("p",{className:"w-[400px] text-center text-primary-text",children:["This will upload this conversation to ",(0,n.jsx)("b",{children:"sharegpt.com"})," and generate a link to share ",(0,n.jsx)("b",{children:"publicly"}),"."]}),r?(0,n.jsxs)("div",{className:"flex flex-row items-center gap-3 w-[300px]",children:[(0,n.jsx)(e0,{value:"https://shareg.pt/".concat(r),readOnly:!0,className:"grow"}),(0,n.jsx)(eG,{size:"small",color:"primary",text:o?"Copied":"Copy",onClick:d})]}):(0,n.jsx)(eG,{text:"Share",color:"primary",onClick:c,isLoading:a})]})},tK=e=>{let[t,a]=(0,O.useState)();return(0,n.jsx)(ej,{title:"Share Chat",open:e.open,onClose:e.onClose,className:_()("rounded-xl",t?"w-[800px] h-[400px]":"w-[600px] h-[250px]"),children:"markdown"===t?(0,n.jsx)(tH,{messages:e.messages}):"sharegpt"===t?(0,n.jsx)(tV,{messages:e.messages}):(0,n.jsxs)("div",{className:"flex flex-col gap-5 justify-center items-center p-5 h-full",children:[(0,n.jsx)(eG,{text:"Markdown",color:"primary",icon:(0,n.jsx)(tG.$NG,{className:"mr-1"}),onClick:()=>a("markdown")}),(0,n.jsx)(eG,{text:"ShareGPT",color:"primary",icon:(0,n.jsx)(tG.y9X,{className:"mr-1"}),onClick:()=>a("sharegpt")})]})})},t$=a(40102),tJ={src:"./_next/static/media/dropdown.22b4c9c4.svg",height:20,width:20,blurWidth:0,blurHeight:0},tQ=e=>{let t=q(),a=(0,O.useCallback)(t=>{e.onChange(t)},[e]);return(0,n.jsxs)(t$.v,{as:"div",className:"relative inline-block text-left h-5",children:[(0,n.jsx)(t$.v.Button,{children:(0,n.jsx)(A(),{alt:"dropdown",src:tJ,className:"w-5 h-5"})}),(0,n.jsx)(eN.u,{as:O.Fragment,enter:"transition ease-out duration-100",enterFrom:"transform opacity-0 scale-95",enterTo:"transform opacity-100 scale-100",leave:"transition ease-in duration-75",leaveFrom:"transform opacity-100 scale-100",leaveTo:"transform opacity-0 scale-95",children:(0,n.jsx)(t$.v.Items,{className:"absolute left-0 z-10 mt-2 rounded-md bg-secondary shadow-lg focus:outline-none",children:t.map(t=>t.name===e.selectedBotName?null:(0,n.jsx)(t$.v.Item,{children:(0,n.jsx)("div",{className:"px-4 py-2 ui-active:bg-primary-blue ui-active:text-white ui-not-active:text-secondary-text cursor-pointer flex flex-row items-center gap-3 pr-8",onClick:()=>a(t.name),children:(0,n.jsx)("p",{className:"text-sm whitespace-nowrap",children:t.name})})},t.url))})})]})},tq=a(51859),tX=a(25372);let t0=()=>{let e=(0,O.useMemo)(()=>location.href.includes("sidepanel.html"),[]);return(0,n.jsx)("div",{className:"flex flex-row gap-2 items-center",children:(0,n.jsx)("a",{href:K.runtime.getURL("app.html#/setting"),target:e?"_blank":void 0,rel:"noreferrer",children:(0,n.jsx)(eG,{color:"primary",text:"Set api key",size:"small"})})})};var t1=e=>{let{error:t}=e,a=(0,O.useContext)(tb),{t:s}=(0,c.$G)();return t.code===r.BING_UNAUTHORIZED?(0,n.jsx)("a",{href:"https://bing.com",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eG,{color:"primary",text:s("Login at bing.com"),size:"small"})}):t.code===r.BING_FORBIDDEN?(0,n.jsx)("a",{href:"https://bing.com/new",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eG,{color:"primary",text:"Join new Bing waitlist",size:"small"})}):t.code===r.GPT4_MODEL_WAITLIST?(0,n.jsx)("a",{href:"https://openai.com/waitlist/gpt-4-api",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eG,{color:"primary",text:s("Join the waitlist"),size:"small"})}):t.code===r.CHATGPT_AUTH?(0,n.jsx)("a",{href:"https://chat.openai.com",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eG,{color:"primary",text:s("Login to ChatGPT"),size:"small"})}):t.code===r.CHATGPT_CLOUDFLARE||t.code===r.CHATGPT_UNAUTHORIZED?(0,n.jsx)(t0,{}):t.code===r.CONVERSATION_LIMIT?(0,n.jsx)(eG,{color:"primary",text:"Restart",size:"small",onClick:()=>null==a?void 0:a.reset()}):t.code===r.BARD_EMPTY_RESPONSE?(0,n.jsx)("a",{href:"https://bard.google.com",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eG,{color:"primary",text:"Visit bard.google.com",size:"small"})}):t.code===r.BING_CAPTCHA?(0,n.jsx)("a",{href:"https://www.bing.com/turing/captcha/challenge",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eG,{color:"primary",text:s("Verify"),size:"small"})}):t.code===r.LMSYS_SESSION_EXPIRED?(0,n.jsx)("a",{href:"https://chat.lmsys.org",target:"_blank",rel:"noreferrer",children:(0,n.jsx)(eG,{color:"primary",text:s("Refresh session"),size:"small"})}):t.code===r.CHATGPT_INSUFFICIENT_QUOTA?(0,n.jsxs)("p",{className:"ml-2 text-secondary-text text-sm",children:[s("This usually mean you need to add a payment method to your OpenAI account, checkout: "),(0,n.jsx)("a",{href:"https://platform.openai.com/account/billing/",target:"_blank",rel:"noreferrer",className:"underline",children:"OpenAI billing"})]}):t.code===r.NETWORK_ERROR||t.code===r.UNKOWN_ERROR&&t.message.includes("Failed to fetch")?(0,n.jsx)("p",{className:"ml-2 text-secondary-text text-sm",children:s("Please check your network connection")}):t.code===r.POE_MESSAGE_LIMIT?(0,n.jsx)("p",{className:"ml-2 text-secondary-text text-sm",children:s("This is a limitation set by poe.com")}):null},t2=e=>(0,n.jsx)("div",{className:_()("rounded-[15px] px-4 py-2","primary"===e.color?"bg-primary-blue text-white":"bg-secondary text-primary-text",e.className),children:e.children});let t3="self-top cursor-pointer invisible group-hover:visible mt-[12px] text-primary-text";var t5=(0,O.memo)(e=>{let{message:t,className:a}=e,[s,r]=(0,O.useState)(!1),l=(0,O.useMemo)(()=>t.text?t.text:t.error?t.error.message:void 0,[t.error,t.text]);return(0,O.useEffect)(()=>{s&&setTimeout(()=>r(!1),1e3)},[s]),(0,n.jsxs)("div",{className:_()("group flex gap-3 w-full","user"===t.author?"flex-row-reverse":"flex-row",a),children:[(0,n.jsxs)("div",{className:"flex flex-col w-11/12 max-w-fit items-start gap-2",children:[(0,n.jsxs)(t2,{color:"user"===t.author?"primary":"flat",children:[t.text?(0,n.jsx)(tR,{children:t.text}):!t.error&&(0,n.jsx)(eL.Z,{size:10,className:"leading-tight",color:"rgb(var(--primary-text))"}),!!t.error&&(0,n.jsx)("p",{className:"text-red-500",children:t.error.message})]}),!!t.error&&(0,n.jsx)(t1,{error:t.error})]}),!!l&&(0,n.jsx)(tN.CopyToClipboard,{text:l,onCopy:()=>r(!0),children:s?(0,n.jsx)(tX.VQF,{className:t3}):(0,n.jsx)(tX.mcF,{className:t3})})]})}),t4=e=>(0,n.jsx)(tq.ZP,{className:"overflow-auto h-full",children:(0,n.jsx)("div",{className:_()("flex flex-col gap-3 h-full",e.className),children:e.messages.map((e,t)=>(0,n.jsx)(t5,{message:e,className:0===t?"mt-5":void 0},e.id))})}),t8=e=>{let{t}=(0,c.$G)(),a=h.find(t=>t.name===e.botName),s=e.mode||"full",r="mx-5",[l,o]=(0,O.useState)(!1),[i,d]=(0,O.useState)(!1),m=(0,O.useMemo)(()=>({reset:e.resetConversation}),[e.resetConversation]),u=(0,O.useCallback)(async t=>{e.onUserSendMessage(t,e.botName)},[e]),p=(0,O.useCallback)(()=>{e.generating||e.resetConversation()},[e]),x=(0,O.useCallback)(()=>{o(!0),e.botName},[e.botName]),g=(0,O.useCallback)(()=>{d(!0),e.botName},[e.botName]);return(0,n.jsxs)(tb.Provider,{value:m,children:[(0,n.jsxs)("div",{className:_()("flex flex-col overflow-hidden bg-primary-background h-full rounded-[20px]"),children:[(0,n.jsxs)("div",{className:_()("border-b border-solid border-primary-border flex flex-row items-center justify-between gap-2 py-[10px]",r),children:[(0,n.jsxs)("div",{className:"flex flex-row items-center gap-2",children:[(0,n.jsx)(e_,{content:e.bot.name||(null==a?void 0:a.name)||"",children:(0,n.jsx)("span",{className:"font-semibold text-primary-text text-sm cursor-default",children:null==a?void 0:a.name})}),"compact"===s&&e.onSwitchBot&&(0,n.jsx)(tQ,{selectedBotName:e.botName,onChange:e.onSwitchBot})]}),(0,n.jsxs)("div",{className:"flex flex-row items-center gap-3",children:[(0,n.jsx)(e_,{content:t("Share conversation"),children:(0,n.jsx)(A(),{alt:"share",src:tf,className:"w-5 h-5 cursor-pointer",onClick:g})}),(0,n.jsx)(e_,{content:t("Clear conversation"),children:(0,n.jsx)(A(),{alt:"clear",src:th,className:_()("w-5 h-5",e.generating?"cursor-not-allowed":"cursor-pointer"),onClick:p})}),(0,n.jsx)(e_,{content:t("View history"),children:(0,n.jsx)(A(),{alt:"history",src:tg,className:"w-5 h-5 cursor-pointer",onClick:x})})]})]}),(0,n.jsx)(t4,{messages:e.messages,className:r}),(0,n.jsxs)("div",{className:_()("mt-3 flex flex-col",r,"full"===s?"mb-3":"mb-[5px]"),children:[(0,n.jsxs)("div",{className:_()("flex flex-row items-center gap-[5px]","full"===s?"mb-3":"mb-0"),children:["compact"===s&&(0,n.jsxs)("span",{className:"font-medium text-xs text-light-text",children:["Send to ",null==a?void 0:a.name]}),(0,n.jsx)("hr",{className:"grow border-primary-border"})]}),(0,n.jsx)(tt,{mode:s,disabled:e.generating,placeholder:"compact"===s?"":void 0,onSubmit:u,autoFocus:"full"===s,actionButton:e.generating?(0,n.jsx)(eG,{text:t("Stop"),color:"flat",size:"full"===s?"normal":"small",onClick:e.stopGenerating}):"full"===s&&(0,n.jsx)(eG,{text:t("Send"),color:"primary",type:"submit"})})]})]}),l&&(0,n.jsx)(tL,{botName:e.botName,open:!0,onClose:()=>o(!1)}),i&&(0,n.jsx)(tK,{open:!0,onClose:()=>d(!1),messages:e.messages})]})};let t6=(0,u.O4)("multiPanelLayout",2,void 0,{unstable_getOnInit:!0}),t9=(0,u.O4)("multiPanelBots:2",h.slice(0,2).map(e=>e.name)),t7=(0,u.O4)("multiPanelBots:3",h.slice(0,3).map(e=>e.name)),ae=(0,u.O4)("multiPanelBots:4",h.slice(0,4).map(e=>e.name)),at=e=>{let{chats:t,botsAtom:a}=e,{t:s}=(0,c.$G)(),r=(0,O.useMemo)(()=>t.some(e=>e.generating),[t]),l=(0,d.b9)(a),o=(0,d.b9)(t6),i=(0,O.useCallback)((e,a)=>{if(a){let s=t.find(e=>e.botName===a);null==s||s.sendMessage(e)}else(0,eM.Z)(t,e=>e.botName).forEach(t=>t.sendMessage(e));t.length},[t]),m=(0,O.useCallback)((e,a)=>{t.length,l(t=>{let s=[...t];return s[a]=e,s})},[t.length,l]),u=(0,O.useCallback)(e=>{o(e)},[o]);return(0,n.jsxs)("div",{className:"flex flex-col overflow-hidden h-full",children:[(0,n.jsx)("div",{className:_()("grid overflow-hidden grow auto-rows-fr gap-3 mb-3",3===t.length?"grid-cols-3":"grid-cols-2"),children:t.map((e,t)=>(0,n.jsx)(t8,{botName:e.botName,bot:e.bot,messages:e.messages,onUserSendMessage:i,generating:e.generating,stopGenerating:e.stopGenerating,mode:"compact",resetConversation:e.resetConversation,onSwitchBot:e=>m(e,t)},"".concat(e.botName,"-").concat(t)))}),(0,n.jsxs)("div",{className:"flex flex-row gap-3",children:[(0,n.jsx)(tl,{layout:t.length,onChange:u}),(0,n.jsx)(tt,{mode:"full",className:"rounded-[15px] bg-primary-background px-4 py-2 grow",disabled:r,onSubmit:i,actionButton:!r&&(0,n.jsx)(eG,{text:s("Send"),color:"primary",type:"submit"}),autoFocus:!0})]})]})},aa=()=>{let e=(0,d.Dv)(t9),t=tx(e[0]),a=tx(e[1]),s=(0,O.useMemo)(()=>[t,a],[t,a]);return(0,n.jsx)(at,{chats:s,botsAtom:t9})},as=()=>{let e=(0,d.Dv)(t7),t=tx(e[0]),a=tx(e[1]),s=tx(e[2]),r=(0,O.useMemo)(()=>[t,a,s],[t,a,s]);return(0,n.jsx)(at,{chats:r,botsAtom:t7})},ar=()=>{let e=(0,d.Dv)(ae),t=tx(e[0]),a=tx(e[1]),s=tx(e[2]),r=tx(e[3]),l=(0,O.useMemo)(()=>[t,a,s,r],[t,a,s,r]);return(0,n.jsx)(at,{chats:l,botsAtom:ae})},an=()=>{let e=(0,d.Dv)(t6);return 4===e?(0,n.jsx)(ar,{}):3===e?(0,n.jsx)(as,{}):(0,n.jsx)(aa,{})};var al=a(68919),ao=a(96758),ai=a(34199),ac=e=>{let{userConfig:t,updateConfigValue:a}=e,{t:s}=(0,c.$G)(),r=(0,O.useCallback)((e,s)=>{let r=new Set(t.enabledBots);if(s)r.add(e);else{if(1===r.size){alert("At least one bot should be enabled");return}r.delete(e)}a({enabledBots:Array.from(r)})},[a,t.enabledBots]);return(0,n.jsx)("div",{className:"flex flex-col gap-3 flex-wrap w-full",children:h.map(e=>{let a=t.enabledBots.includes(e.name);return(0,n.jsxs)("div",{className:"flex flex-row gap-[12px] w-full items-center",children:[(0,n.jsx)(ai.r,{id:"bot-checkbox-".concat(e.name),checked:a,className:"".concat(a?"bg-blue-600":"bg-gray-200"," relative inline-flex h-6 w-11 items-center rounded-full"),onChange:t=>r(e.name,t),children:(0,n.jsx)("span",{className:"".concat(a?"translate-x-6":"translate-x-1"," inline-block h-4 w-4 transform rounded-full bg-white transition")})}),(0,n.jsx)("span",{className:"text-sm font-semibold block ml-6",children:s("Bot Name")}),(0,n.jsx)(e0,{className:"w-1/6",name:"title",defaultValue:e.name}),(0,n.jsx)("span",{className:"text-sm font-semibold block ml-6",children:s("Space URL")}),(0,n.jsx)(e0,{className:"w-3/6",name:"title",defaultValue:e.url})]},e.name)})})},ad=a(91263);async function am(){let[e,t]=await Promise.all([K.storage.sync.get(null),K.storage.local.get(null)]),a={sync:e,local:t,localStorage:{...localStorage}},s=new Blob([JSON.stringify(a)],{type:"application/json"});await (0,ad.NL)(s,{fileName:"chathub.json"})}async function au(){let e=await (0,ad.I$)({extensions:[".json"]}),t=JSON.parse(await e.text());if(!t.sync||!t.local)throw Error("Invalid data");if(window.confirm("Are you sure you want to import data? This will overwrite your current data")){if(await K.storage.local.clear(),await K.storage.local.set(t.local),await K.storage.sync.clear(),await K.storage.sync.set(t.sync),t.localStorage)for(let[e,a]of Object.entries(t.localStorage))localStorage.setItem(e,a);alert("Imported data successfully"),location.reload()}}var ap=e=>(0,n.jsxs)("div",{className:"flex flex-col overflow-hidden bg-primary-background dark:text-primary-text rounded-[20px] h-full",children:[(0,n.jsx)("div",{className:"text-center border-b border-solid border-primary-border flex flex-col justify-center mx-10 py-3",children:(0,n.jsx)("span",{className:"font-semibold text-lg",children:e.title})}),(0,n.jsx)("div",{className:"px-10 h-full overflow-auto",children:e.children}),(0,n.jsx)("div",{className:"text-center border-t border-solid border-primary-border",children:e.footer})]}),ax=e=>{let{botName:t}=e,a=tx(t);return(0,n.jsx)("div",{className:"overflow-hidden h-full",children:(0,n.jsx)(t8,{botName:t,bot:a.bot,messages:a.messages,onUserSendMessage:a.sendMessage,generating:a.generating,stopGenerating:a.stopGenerating,resetConversation:a.resetConversation})})};let ah=new l.RootRoute,ag=new l.Route({getParentRoute:()=>ah,component:function(){let e=(0,d.Dv)(T),t=(0,d.Dv)(P);return(0,n.jsxs)("main",{className:"h-screen grid grid-cols-[auto_1fr]",style:{backgroundColor:t?"var(--arc-palette-foregroundPrimary)":e},children:[(0,n.jsx)(eD,{}),(0,n.jsx)("div",{className:"px-[15px] py-3 h-full overflow-hidden",children:(0,n.jsx)(l.Outlet,{})})]})},id:"layout"}),af=new l.Route({getParentRoute:()=>ag,path:"/",component:()=>(0,n.jsx)(O.Suspense,{children:(0,n.jsx)(an,{})})}),ab=new l.Route({getParentRoute:()=>ag,path:"chat/$name",component:function(){let{name:e}=(0,l.useParams)({from:ab.id}),t=h.find(t=>t.name===e);return(0,n.jsx)(ax,{botName:(null==t?void 0:t.name)||"all"})}}),ay=new l.Route({getParentRoute:()=>ag,path:"setting",component:function(){let{t:e}=(0,c.$G)(),[t,a]=(0,O.useState)(void 0),[s,r]=(0,O.useState)(!1);(0,O.useEffect)(()=>{J().then(e=>a(e))},[]);let l=(0,O.useCallback)(e=>{a({...t,...e}),r(!0)},[t]),o=(0,O.useCallback)(async()=>{await Q({...t}),al.ZP.success("Saved"),setTimeout(()=>location.reload(),500)},[t]);return t?(0,n.jsxs)(ap,{title:"".concat(e("Settings")," (v").concat("0.0.1",")"),footer:(0,n.jsx)(eG,{color:s?"primary":"flat",text:e("Save"),className:"w-fit my-8",onClick:o}),children:[(0,n.jsxs)("div",{className:"flex flex-col gap-5 mt-3",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-bold mb-1 text-lg",children:e("Export/Import All Data")}),(0,n.jsx)("p",{className:"mb-3 opacity-80",children:e("Data includes all your settings, chat histories, and local prompts")}),(0,n.jsxs)("div",{className:"flex flex-row gap-3",children:[(0,n.jsx)(eG,{size:"small",text:e("Export"),icon:(0,n.jsx)(ao.MUM,{}),onClick:am}),(0,n.jsx)(eG,{size:"small",text:e("Import"),icon:(0,n.jsx)(ao.MDG,{}),onClick:au})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{className:"font-bold mb-2 text-lg",children:e("Startup page")}),(0,n.jsx)("div",{className:"w-[200px]",children:(0,n.jsx)(eS,{options:[{name:"All-In-One",value:"all"},...h.map(e=>({name:e.name,value:e.url}))],value:t.startupPage,onChange:e=>l({startupPage:e})})})]}),(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsx)("p",{className:"font-bold text-lg flex items-center gap-2",children:e("Chatbots")}),(0,n.jsx)(ac,{userConfig:t,updateConfigValue:l})]})]}),(0,n.jsx)(al.x7,{position:"top-right"})]}):null}}),av=ah.addChildren([ag.addChildren([af,ab,ay])]),aj=(0,l.createHashHistory)(),aw=new l.ReactRouter({routeTree:av,history:aj});var aN=()=>(0,n.jsx)(l.RouterProvider,{router:aw})},68405:function(){}}]);