You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 line
86 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9183,2386,4838],{24333:function(e,t,n){"use strict";var s,a,r=n(52846);function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}t.Z=function(e){return r.createElement("svg",i({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),s||(s=r.createElement("defs",null,r.createElement("path",{id:"clear_svg__a",d:"M0 0h16v16H0z"}))),r.createElement("g",null,a||(a=r.createElement("mask",{id:"clear_svg__b",fill:"#fff"},r.createElement("use",{xlinkHref:"#clear_svg__a"}))),r.createElement("g",{mask:"url(#clear_svg__b)"},r.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M1 9.67h8.67l1-9.67H0l1 9.67Z",transform:"translate(2.667 5)"}),r.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M0 0v3.33",transform:"translate(6.667 8.334)"}),r.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M0 0v3.33",transform:"translate(9.334 8.333)"}),r.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"m0 4 5.44-4L8 4",transform:"translate(4 1)"}))))}},49111:function(e,t,n){"use strict";var s,a,r=n(52846);function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}t.Z=function(e){return r.createElement("svg",i({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"#fff"},e),s||(s=r.createElement("rect",{width:"100%",height:"100%",fill:"none"})),a||(a=r.createElement("g",{className:"loading_svg__currentLayer"},r.createElement("circle",{cx:4,cy:8,r:1.926,fill:"#333"},r.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:2,repeatCount:"indefinite",to:2,values:"2;1.2;2"}),r.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:1,repeatCount:"indefinite",to:1,values:"1;.5;1"})),r.createElement("circle",{cx:8,cy:8,r:1.274,fill:"#333",fillOpacity:.3},r.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:1.2,repeatCount:"indefinite",to:1.2,values:"1.2;2;1.2"}),r.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:.5,repeatCount:"indefinite",to:.5,values:".5;1;.5"})),r.createElement("circle",{cx:12,cy:8,r:1.926,fill:"#333"},r.createElement("animate",{attributeName:"r",begin:"0s",calcMode:"linear",dur:"0.8s",from:2,repeatCount:"indefinite",to:2,values:"2;1.2;2"}),r.createElement("animate",{attributeName:"fill-opacity",begin:"0s",calcMode:"linear",dur:"0.8s",from:1,repeatCount:"indefinite",to:1,values:"1;.5;1"})))))}},73895:function(e,t,n){"use strict";var s,a=n(52846);function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}t.Z=function(e){return a.createElement("svg",r({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},e),s||(s=a.createElement("rect",{x:3,y:3,width:18,height:18,rx:2,ry:2})))}},76908:function(e,t,n){"use strict";var s,a,r=n(52846);function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}t.Z=function(e){return r.createElement("svg",i({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),s||(s=r.createElement("defs",null,r.createElement("path",{id:"return_svg__a",d:"M0 0h16v16H0z"}))),r.createElement("g",null,a||(a=r.createElement("mask",{id:"return_svg__b",fill:"#fff"},r.createElement("use",{xlinkHref:"#return_svg__a"}))),r.createElement("g",{mask:"url(#return_svg__b)"},r.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M2.33 0 0 2l2.33 2.33",transform:"translate(2 2.667)"}),r.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M0 0h7.66c2.3 0 4.25 1.87 4.34 4.17.09 2.42-1.91 4.5-4.34 4.5H2",transform:"translate(2 4.667)"}))))}},12637:function(e,t,n){"use strict";var s,a,r=n(52846);function i(){return(i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}t.Z=function(e){return r.createElement("svg",i({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),s||(s=r.createElement("defs",null,r.createElement("path",{id:"share_svg__a",d:"M0 0h16v16H0z"}))),r.createElement("g",null,a||(a=r.createElement("mask",{id:"share_svg__b",fill:"#fff"},r.createElement("use",{xlinkHref:"#share_svg__a"}))),r.createElement("g",{mask:"url(#share_svg__b)"},r.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M6.67 3.67C1.67 3.67 0 7.33 0 13c0 0 2-5 6.67-5v3.67l6-5.67-6-6v3.67Z",transform:"translate(2 1.333)"}))))}},32360:function(e,t,n){"use strict";n.d(t,{UK:function(){return l},YZ:function(){return i},x6:function(){return o}});var s=n(2265),a=n(90261),r=n(13894);function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,n]=(0,a.lr)();(0,s.useEffect)(()=>{let s=!1;t.forEach((n,a)=>{"function"==typeof e[a]&&(e[a](n),t.delete(a),s=!0)}),s&&n(t)},[t,e])}let o=/^[:]/;function l(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};function t(e){return e.match(o)?e.slice(1):e}return{match:function(n){let s=t(n),a="function"==typeof e[s];return{matched:a,invoke:()=>a&&e[s](n)}},search:function(n){let s=t(n),a=r.ZP.Chat.Commands;return Object.keys(e).filter(e=>e.startsWith(s)).map(e=>({title:a[e],content:":"+e}))}}}},54838:function(e,t,n){"use strict";let s,a;n.r(t),n.d(t,{Chat:function(){return t$},ChatAction:function(){return tG},ChatActions:function(){return tX},DeleteImageButton:function(){return tY},EditMessageModal:function(){return tq},PromptHints:function(){return tW},SessionConfigModel:function(){return tz},ShortcutKeyModal:function(){return tQ}});var r,i,o,l,c,d,u,h,m,p,g,f,v,x,w,y,_,k,j,C,b,E,S,N,M,P,O,Z,T,A,L,I,D,K,R,F,B,H,z,U,W,V,G,X=n(57437),q=n(38648),Y=n(2265),Q=n(52846);function J(){return(J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var $=function(e){return Q.createElement("svg",J({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),c||(c=Q.createElement("defs",null,Q.createElement("path",{id:"send-white_svg__a",d:"M0 0h16v16H0z"}))),Q.createElement("g",null,d||(d=Q.createElement("mask",{id:"send-white_svg__b",fill:"#fff"},Q.createElement("use",{xlinkHref:"#send-white_svg__a"}))),Q.createElement("g",{mask:"url(#send-white_svg__b)"},Q.createElement("path",{style:{stroke:"#fff",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M0 4.71 6.67 6l1.67 6.67L12.67 0 0 4.71Z",transform:"translate(1.333 2)"}),Q.createElement("path",{style:{stroke:"#fff",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M0 1.89 1.89 0",transform:"translate(8.003 6.117)"}))))};function ee(){return(ee=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var et=function(e){return Q.createElement("svg",ee({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),u||(u=Q.createElement("defs",null,Q.createElement("path",{id:"brain_svg__a",d:"M0 0h16v16H0z"}))),Q.createElement("g",null,h||(h=Q.createElement("mask",{id:"brain_svg__b",fill:"#fff"},Q.createElement("use",{xlinkHref:"#brain_svg__a"}))),Q.createElement("g",{mask:"url(#brain_svg__b)"},Q.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M5.01 13.33c-.32-1.06-.82-1.86-1.48-2.38-.98-.78-2.56-.3-3.14-1.11-.58-.8.41-2.29.76-3.17.34-.88-1.33-1.19-1.13-1.44.13-.16.97-.64 2.53-1.44C3 1.26 4.63 0 7.47 0c4.24 0 5.86 3.6 5.86 5.89 0 2.29-1.96 4.76-4.75 5.29-.25.37.11 1.08 1.08 2.15",transform:"translate(1.333 1.333)"}),Q.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M2.1 3.33c-.19 1.09.04 1.6.69 1.53.65-.07 1.05-.34 1.18-.81 1.02.28 1.57.04 1.66-.72.12-1.15-.5-2.07-.75-2.07s-.91-.03-.91-.38C3.97.52 3.2.33 2.5.33c-.69 0-.27-.47-1.23-.29C.64.17.26.44.13.88c-.22.84-.16 1.43.19 1.78.35.34.94.56 1.78.67Z",transform:"translate(6.374 3.957)"}),Q.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M1.97 0c-.34.21-.8.56-1 .83-.49.69-.88 1.1-.97 1.54",transform:"translate(8.193 8.5)"}))))};function en(){return(en=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var es=function(e){return Q.createElement("svg",en({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),m||(m=Q.createElement("defs",null,Q.createElement("path",{id:"rename_svg__a",d:"M0 0h16v16H0z"}))),Q.createElement("g",null,p||(p=Q.createElement("mask",{id:"rename_svg__b",fill:"#fff"},Q.createElement("use",{xlinkHref:"#rename_svg__a"}))),Q.createElement("g",{mask:"url(#rename_svg__b)"},Q.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M2.83 13.2 13.2 2.83 10.37 0 0 10.37v2.83h2.83Z",transform:"translate(1.775 1.3)"}),Q.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"m0 0 2.83 2.83",transform:"translate(9.317 4.13)"}))))},ea=n(12637),er=n(76908),ei=n(84193);function eo(){return(eo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var el=function(e){return Q.createElement("svg",eo({xmlns:"http://www.w3.org/2000/svg",fill:"none",width:16,height:16,viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"speak_svg__w-4 speak_svg__h-4"},e),g||(g=Q.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.114 5.636a9 9 0 0 1 0 12.728M16.463 8.288a5.25 5.25 0 0 1 0 7.424M6.75 8.25l4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.01 9.01 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25h2.24z"})))};function ec(){return(ec=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var ed=function(e){return Q.createElement("svg",ec({xmlns:"http://www.w3.org/2000/svg",fill:"none",width:16,height:16,viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"speak-stop_svg__w-4 speak-stop_svg__h-4"},e),f||(f=Q.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.25 9.75 19.5 12m0 0 2.25 2.25M19.5 12l2.25-2.25M19.5 12l-2.25 2.25m-10.5-6 4.72-4.72a.75.75 0 0 1 1.28.53v15.88a.75.75 0 0 1-1.28.53l-4.72-4.72H4.51c-.88 0-1.704-.507-1.938-1.354A9.009 9.009 0 0 1 2.25 12c0-.83.112-1.633.322-2.396C2.806 8.756 3.63 8.25 4.51 8.25h2.24Z"})))},eu=n(24053),eh=n(49111),em=n(14845),ep=n(68397),eg=n(98829);function ef(){return(ef=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var ev=function(e){return Q.createElement("svg",ef({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),Q.createElement("g",null,v||(v=Q.createElement("mask",{id:"chat-settings_svg__b",fill:"#fff"},Q.createElement("use",{xlinkHref:"#chat-settings_svg__a"}))),Q.createElement("g",{mask:"url(#chat-settings_svg__b)"},Q.createElement("path",{style:{fill:"#333",opacity:1},d:"M6.728 14.598a.665.665 0 0 1-.828.434 7.294 7.294 0 0 1-3.187-1.945.666.666 0 0 1-.026-.896c.207-.241.31-.527.31-.857 0-.37-.13-.685-.389-.944A1.286 1.286 0 0 0 1.663 10h-.08a.662.662 0 0 1-.665-.288.665.665 0 0 1-.098-.235 7.234 7.234 0 0 1 .188-3.675.662.662 0 0 1 .635-.465h.02c.37 0 .684-.13.944-.392.26-.26.39-.574.39-.942 0-.215-.045-.415-.134-.6a.666.666 0 0 1 .148-.78A7.292 7.292 0 0 1 6.034.932a.666.666 0 0 1 .774.34c.11.219.272.394.483.524.216.135.454.202.712.202.254 0 .488-.067.703-.201.211-.131.372-.306.483-.524a.666.666 0 0 1 .773-.34 7.404 7.404 0 0 1 3.03 1.688.664.664 0 0 1 .143.8c-.09.174-.135.368-.135.583 0 .366.13.68.392.941.262.262.575.393.941.393h.03a.664.664 0 0 1 .636.465c.22.695.331 1.43.331 2.201a7.34 7.34 0 0 1-.143 1.474.66.66 0 0 1-.27.411.666.666 0 0 1-.478.115 1 1 0 0 0-.106-.003c-.367 0-.681.13-.941.39-.261.26-.392.574-.392.943 0 .322.106.61.317.865a.662.662 0 0 1 .1.686.671.671 0 0 1-.133.202 7.294 7.294 0 0 1-3.187 1.945.674.674 0 0 1-.503-.047.659.659 0 0 1-.325-.387 1.311 1.311 0 0 0-.477-.667 1.288 1.288 0 0 0-.789-.26c-.297 0-.564.087-.798.26-.23.17-.389.393-.477.667zm3.52-1.032c.626-.253 1.191-.6 1.696-1.042a2.603 2.603 0 0 1-.277-1.19 2.642 2.642 0 0 1 .784-1.888 2.646 2.646 0 0 1 1.51-.753 6.393 6.393 0 0 0-.118-2.067 2.655 2.655 0 0 1-1.394-.738 2.656 2.656 0 0 1-.782-1.884c0-.239.029-.468.087-.687a6.05 6.05 0 0 0-1.693-.954c-.182.22-.398.41-.65.566-.431.268-.9.402-1.408.402-.511 0-.983-.134-1.414-.401a2.632 2.632 0 0 1-.653-.567 5.936 5.936 0 0 0-1.69.957 2.74 2.74 0 0 1-.125 1.72c-.134.319-.324.601-.57.847a2.641 2.641 0 0 1-1.389.738 5.903 5.903 0 0 0-.12 2.069 2.642 2.642 0 0 1 1.509.753 2.654 2.654 0 0 1 .779 1.888c0 .433-.091.831-.274 1.192.504.44 1.068.787 1.692 1.04.172-.272.393-.507.664-.707.47-.348 1-.522 1.591-.522.587 0 1.115.174 1.584.523.27.2.49.435.661.705z"}),Q.createElement("path",{style:{fill:"#333",opacity:1},d:"M10.122 10.122a2.987 2.987 0 0 1-2.125.881 2.969 2.969 0 0 1-2.122-.883 2.983 2.983 0 0 1-.64-.955A2.984 2.984 0 0 1 5 7.997a2.974 2.974 0 0 1 .876-2.12A2.974 2.974 0 0 1 7.996 5c.407 0 .797.078 1.169.235.36.151.678.364.955.64a2.969 2.969 0 0 1 .883 2.122 2.987 2.987 0 0 1-.881 2.125zM7.997 6.333c-.461 0-.854.162-1.178.486a1.603 1.603 0 0 0-.486 1.178c0 .462.163.857.488 1.183.324.327.716.49 1.176.49.46 0 .855-.164 1.182-.491.327-.327.491-.721.491-1.182 0-.46-.163-.852-.49-1.176a1.618 1.618 0 0 0-1.183-.488z"}))),x||(x=Q.createElement("defs",null,Q.createElement("path",{id:"chat-settings_svg__a",d:"M0 0h16v16H0z"}))))},ex=n(24333);function ew(){return(ew=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var ey=function(e){return Q.createElement("svg",ew({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),Q.createElement("g",null,w||(w=Q.createElement("mask",{id:"pin_svg__b",fill:"#fff"},Q.createElement("use",{xlinkHref:"#pin_svg__a"}))),Q.createElement("g",{mask:"url(#pin_svg__b)"},Q.createElement("path",{style:{fill:"#333",opacity:1},d:"m6.685 8.81-4 5.44-.537-.394-.397-.536 5.42-4.01a.666.666 0 0 1 .866.062l.532.528 2.07 2.063-.471.473-.472-.472c.3-.3.457-.62.472-.963.015-.353-.108-.798-.37-1.333a.665.665 0 0 1 .017-.616l2.36-4.25a.662.662 0 0 1 .679-.336l1.65.24-.096.66-.472.471-3.77-3.77.472-.471.66-.096.24 1.65a.664.664 0 0 1-.337.678l-4.25 2.36a.665.665 0 0 1-.646.001c-.479-.265-.903-.388-1.27-.369-.358.018-.69.18-.996.487l-.471-.471.471-.472 2.06 2.06.52.52a.665.665 0 0 1 .066.867zM5.61 8.02l.537.396-.472.471-.52-.52-2.06-2.06a.665.665 0 0 1 0-.943c.548-.548 1.172-.84 1.87-.875.622-.032 1.283.146 1.984.533l-.322.584-.324-.583 4.25-2.36.324.583-.66.096-.24-1.65a.664.664 0 0 1 .66-.763.665.665 0 0 1 .471.195l3.77 3.77a.666.666 0 0 1-.567 1.131l-1.65-.24.096-.66.583.324-2.36 4.25-.583-.323.599-.293c.36.738.527 1.396.503 1.974-.029.689-.316 1.305-.86 1.85a.664.664 0 0 1-.842.083.667.667 0 0 1-.101-.082l-2.068-2.062-.531-.527.47-.473.396.535-5.42 4.01a.663.663 0 0 1-.791.002.664.664 0 0 1-.142-.932z"}))),y||(y=Q.createElement("defs",null,Q.createElement("path",{id:"pin_svg__a",d:"M0 0h16v16H0z"}))))},e_=n(12402),ek=n(38669),ej=n(82985);function eC(){return(eC=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var eb=function(e){return Q.createElement("svg",eC({xmlns:"http://www.w3.org/2000/svg",fill:"none",height:16,width:16,xmlSpace:"preserve"},e),_||(_=Q.createElement("rect",{width:"100%",height:"100%"})),k||(k=Q.createElement("g",{className:"image_svg__currentLayer"},Q.createElement("g",{fill:"#333"},Q.createElement("path",{d:"M2.47 2.47h1.977v-.782H1.688v2.76h.781zM11.553 1.688v.781h1.978v1.978h.78V1.688zM13.53 13.53h-1.977v.782h2.759v-2.76h-.781zM2.47 11.553h-.782v2.759h2.76v-.781H2.468zM8.83 6.243c.682 0 1.237-.555 1.237-1.236S9.512 3.77 8.83 3.77a1.238 1.238 0 0 0 0 2.473zM3.77 12.23h8.46V9.71l-1.527-1.611-1.85 1.077-2.578-1.842L3.77 9.977z"})))))};function eE(){return(eE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var eS=function(e){return Q.createElement("svg",eE({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),j||(j=Q.createElement("defs",null,Q.createElement("path",{id:"bottom_svg__a",d:"M0 0h16v16H0z"}))),Q.createElement("g",null,C||(C=Q.createElement("mask",{id:"bottom_svg__b",fill:"#fff"},Q.createElement("use",{xlinkHref:"#bottom_svg__a"}))),Q.createElement("g",{mask:"url(#bottom_svg__b)"},Q.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M8 0 4 4 0 0",transform:"translate(4 4)"}),Q.createElement("path",{style:{stroke:"#333",strokeWidth:1.3333333333333333,strokeOpacity:1,strokeDasharray:"0 0"},d:"M8 0 4 4 0 0",transform:"translate(4 8)"}))))},eN=n(73895);function eM(){return(eM=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var eP=function(e){return Q.createElement("svg",eM({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),Q.createElement("g",null,b||(b=Q.createElement("mask",{id:"robot_svg__b",fill:"#fff"},Q.createElement("use",{xlinkHref:"#robot_svg__a"}))),Q.createElement("g",{mask:"url(#robot_svg__b)"},Q.createElement("path",{style:{fill:"#333",opacity:1},d:"M3.67 13.67h8.66c.002 0 .003-.001.003-.003V6.334H3.67c-.002 0-.003 0-.003.003v7.33c0 .002 0 .003.003.003zm0 1.333c-.37 0-.684-.13-.945-.391a1.288 1.288 0 0 1-.392-.945v-7.33c0-.37.13-.685.392-.946.26-.26.576-.391.945-.391h8.66c.37 0 .684.13.945.391.261.261.392.577.392.946v7.33c0 .369-.13.684-.392.945a1.288 1.288 0 0 1-.945.391z"}),Q.createElement("path",{style:{fill:"#333",opacity:1},d:"M9.819 6.127a.666.666 0 0 1-1.05-.81l1.67-2.67a.665.665 0 0 1 1.107-.034.663.663 0 0 1 .023.74l-1.67 2.67a.665.665 0 0 1-.08.104zM7.293 5.434a.665.665 0 0 1-1.01.779.665.665 0 0 1-.178-.19l-1.67-2.67a.665.665 0 0 1 .952-.896.665.665 0 0 1 .178.19l1.67 2.67a.665.665 0 0 1 .058.117z"}),Q.createElement("path",{style:{fill:"#333",opacity:1},d:"M11.337 2.333c-.003 0-.004.001-.004.004l-.001-.01a.007.007 0 0 0 .005.003h-.007v.007c0-.002 0-.004-.002-.005l.009.001zm0-1.333c.366 0 .679.131.939.394.258.261.387.575.387.943 0 .364-.13.676-.39.936s-.572.39-.936.39c-.368 0-.682-.129-.943-.388A1.273 1.273 0 0 1 10 2.337c0-.37.13-.685.391-.946.262-.26.577-.391.946-.391zM4.67 2.333c-.002 0-.003.001-.003.004 0-.005 0-.008-.002-.01a.007.007 0 0 0 .005.003h-.006v.007c0-.002-.001-.004-.003-.005l.009.001zM4.67 1c.366 0 .679.131.939.394.258.261.388.575.388.943 0 .364-.13.676-.39.936s-.573.39-.937.39c-.367 0-.681-.129-.943-.388a1.273 1.273 0 0 1-.394-.938c0-.37.13-.685.392-.946.26-.26.576-.391.945-.391zM6.663 10.003h2.67c.184 0 .34-.065.469-.194a.655.655 0 0 0 .195-.479.638.638 0 0 0-.196-.467.638.638 0 0 0-.468-.196h-2.67a.638.638 0 0 0-.467.196A.638.638 0 0 0 6 9.33c0 .188.065.347.195.479.128.13.284.194.468.194zm0 1.334a1.974 1.974 0 0 1-1.416-.59 2.001 2.001 0 0 1 1.416-3.413h2.67a1.99 1.99 0 0 1 1.41.587 1.99 1.99 0 0 1 .587 1.409 2.002 2.002 0 0 1-1.997 2.007zM2 10.663h1.003a.666.666 0 1 1 0 1.334h-1.67a.666.666 0 0 1-.666-.667V8a.665.665 0 0 1 .666-.667h1.67a.665.665 0 0 1 .555 1.037.665.665 0 0 1-.555.297H2zM14.8 7.346a.664.664 0 0 1 .537.654v3.33a.666.666 0 0 1-.667.667H13a.666.666 0 1 1 0-1.334h1.003V8.667H13a.665.665 0 0 1-.471-1.138.664.664 0 0 1 .471-.196h1.67c.044 0 .087.005.13.013z"}))),E||(E=Q.createElement("defs",null,Q.createElement("path",{id:"robot_svg__a",d:"M0 0h16v16H0z"}))))};function eO(){return(eO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var eZ=function(e){return Q.createElement("svg",eO({width:16,height:16,viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),S||(S=Q.createElement("path",{d:"M42 7H6a2 2 0 0 0-2 2v30a2 2 0 0 0 2 2h36a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2Z",stroke:"#333",strokeWidth:4})),N||(N=Q.createElement("path",{d:"M30 30V18l8 12V18M10 30V18l8 12V18",stroke:"#333",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round"})),M||(M=Q.createElement("path",{d:"M24 20v1M24 27v1",stroke:"#333",strokeWidth:4,strokeLinecap:"round"})))};function eT(){return(eT=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var eA=function(e){return Q.createElement("svg",eT({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"#333",className:"hd_svg__bi hd_svg__bi-badge-hd"},e),P||(P=Q.createElement("path",{d:"M7.396 11V5.001H6.209v2.44H3.687V5H2.5v6h1.187V8.43h2.522V11zM8.5 5.001V11h2.188c1.811 0 2.685-1.107 2.685-3.015 0-1.894-.86-2.984-2.684-2.984zm1.187.967h.843c1.112 0 1.622.686 1.622 2.04 0 1.353-.505 2.02-1.622 2.02h-.843z"})),O||(O=Q.createElement("path",{d:"M14 3a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM2 2a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2z"})))};function eL(){return(eL=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var eI=function(e){return Q.createElement("svg",eL({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"#333",className:"palette_svg__bi palette_svg__bi-palette"},e),Z||(Z=Q.createElement("path",{d:"M8 5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3m4 3a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3M5.5 7a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m.5 6a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3"})),T||(T=Q.createElement("path",{d:"M16 8c0 3.15-1.866 2.585-3.567 2.07C11.42 9.763 10.465 9.473 10 10c-.603.683-.475 1.819-.351 2.92C9.826 14.495 9.996 16 8 16a8 8 0 1 1 8-8m-8 7c.611 0 .654-.171.655-.176.078-.146.124-.464.07-1.119-.014-.168-.037-.37-.061-.591-.052-.464-.112-1.005-.118-1.462-.01-.707.083-1.61.704-2.314.369-.417.845-.578 1.272-.618.404-.038.812.026 1.16.104.343.077.702.186 1.025.284l.028.008c.346.105.658.199.953.266.653.148.904.083.991.024C14.717 9.38 15 9.161 15 8a7 7 0 1 0-7 7"})))};function eD(){return(eD=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var eK=function(e){return Q.createElement("svg",eD({xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:16,height:16,fill:"none"},e),Q.createElement("g",null,A||(A=Q.createElement("mask",{id:"plugin_svg__b",fill:"#fff"},Q.createElement("use",{xlinkHref:"#plugin_svg__a"}))),Q.createElement("g",{mask:"url(#plugin_svg__b)"},Q.createElement("path",{style:{fill:"#333",opacity:1},d:"M6.945 1.725c.261.26.392.576.392.945V6c0 .37-.13.684-.392.945A1.288 1.288 0 0 1 6 7.337H2.67c-.37 0-.684-.13-.945-.392A1.288 1.288 0 0 1 1.333 6V2.67c0-.37.13-.684.392-.945.26-.261.576-.392.945-.392H6c.37 0 .684.13.945.392zM2.667 6c0 .002 0 .003.003.003H6c.002 0 .003 0 .003-.003V2.67c0-.002 0-.003-.003-.003H2.67c-.002 0-.003 0-.003.003zM6.945 9.058c.261.261.392.576.392.945v3.33c0 .37-.13.685-.392.946A1.288 1.288 0 0 1 6 14.67H2.67c-.37 0-.684-.13-.945-.391a1.288 1.288 0 0 1-.392-.946v-3.33c0-.369.13-.684.392-.945.26-.26.576-.391.945-.391H6c.37 0 .684.13.945.391zm-4.278 4.275c0 .003 0 .004.003.004H6c.002 0 .003-.001.003-.004v-3.33c0-.002 0-.003-.003-.003H2.67c-.002 0-.003.001-.003.003zM13.789 6.455a2.987 2.987 0 0 1-2.126.882c-.407 0-.797-.08-1.169-.238a2.97 2.97 0 0 1-.952-.645 2.983 2.983 0 0 1-.64-.956 2.984 2.984 0 0 1-.235-1.168 2.974 2.974 0 0 1 .876-2.12 2.973 2.973 0 0 1 2.12-.877c.407 0 .796.079 1.169.235.36.151.678.365.955.64a2.97 2.97 0 0 1 .883 2.122 2.988 2.988 0 0 1-.882 2.125zm-2.126-3.788c-.46 0-.853.162-1.177.486A1.603 1.603 0 0 0 10 4.33c0 .462.162.857.487 1.184.325.326.717.49 1.176.49.461 0 .855-.164 1.183-.492.327-.327.49-.721.49-1.182 0-.46-.163-.851-.489-1.176a1.618 1.618 0 0 0-1.184-.487zM14.278 9.058c.261.261.392.576.392.945v3.33c0 .37-.13.685-.392.946a1.288 1.288 0 0 1-.945.391h-3.33c-.369 0-.684-.13-.945-.391a1.288 1.288 0 0 1-.391-.946v-3.33c0-.369.13-.684.391-.945.261-.26.576-.391.945-.391h3.33c.37 0 .684.13.945.391zM10 13.333c0 .003.001.004.003.004h3.33c.003 0 .004-.001.004-.004v-3.33c0-.002-.001-.003-.004-.003h-3.33c-.002 0-.003.001-.003.003z"}))),L||(L=Q.createElement("defs",null,Q.createElement("path",{id:"plugin_svg__a",d:"M0 0h16v16H0z"}))))};function eR(){return(eR=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var eF=function(e){return Q.createElement("svg",eR({width:16,height:16,viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),I||(I=Q.createElement("path",{d:"M4 28a2 2 0 0 1 2-2h4v12H6a2 2 0 0 1-2-2v-8ZM38 26h4a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-4V26Z"})),D||(D=Q.createElement("path",{d:"M10 36V24c0-7.732 6.268-14 14-14s14 6.268 14 14v12M10 26H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h4V26Zm28 0h4a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-4V26Z",stroke:"#333",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round"})),K||(K=Q.createElement("path",{d:"M16 32h4l2-6 4 12 2-6h4",stroke:"#333",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round"})))},eB=n(44922),eH=n(92944),ez=n(26757),eU=n(24232),eW=n(90684),eV=n(89570),eG=n(13894),eX=n(35499),eq=n(3109),eY=n.n(eq),eQ=n(65878),eJ=n(59208),e$=n(75591),e0=n(94008),e1=n(83921),e3=n(61643),e6=n(32360),e2=n(58669),e4=n(79296),e8=n.n(e4),e7=n(25640),e9={src:"/_next/static/media/bot.0c800005.png"},e5=n(72495),te=n(88809),tt=n.n(te),tn=n(75504);function ts(e){let t=(0,eB.aK)().currentSession(),n=e=>e.content&&!e.isError&&!e.streaming,s=(0,Y.useMemo)(()=>{var e;let n=Math.max(0,null!==(e=t.clearContextIndex)&&void 0!==e?e:0);return n===t.messages.length-1&&(n=0),t.messages.slice(n)},[t.messages,t.clearContextIndex]),a=(0,Y.useMemo)(()=>s.filter((e,t)=>e.id&&n(e)&&(t>=s.length-1||n(s[t+1]))),[s]),r=a.length,i=(0,eB.MG)(),[o,l]=(0,Y.useState)(""),[c,d]=(0,Y.useState)(new Set),u=e=>0===o.length||c.has(e),h=e=>{let t=new Set;e.length>0&&a.forEach(n=>(0,eH.YK)(n).includes(e)?t.add(n.id):null),d(t)},{startIndex:m,endIndex:p,onClickIndex:g}=function(){let[e,t]=(0,Y.useState)(),[n,s]=(0,Y.useState)(),[a,r]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let e=e=>{"Shift"===e.key&&r(!0)},n=e=>{"Shift"===e.key&&(r(!1),t(void 0),s(void 0))};return window.addEventListener("keyup",n),window.addEventListener("keydown",e),()=>{window.removeEventListener("keyup",n),window.removeEventListener("keydown",e)}},[]),{onClickIndex:n=>{a&&void 0!==e?s(n):(t(n),s(void 0))},startIndex:e,endIndex:n}}(),f=()=>{e.updateSelection(e=>a.forEach(t=>e.add(t.id)))};return(0,Y.useEffect)(()=>{e.defaultSelectAll&&f()},[]),(0,Y.useEffect)(()=>{if(void 0===m||void 0===p)return;let[t,n]=[m,p].sort((e,t)=>e-t);e.updateSelection(e=>{for(let r=t;r<=n;r+=1){var s;e.add(null!==(s=a[r].id)&&void 0!==s?s:r)}})},[m,p]),(0,X.jsxs)("div",{className:tt()["message-selector"],children:[(0,X.jsxs)("div",{className:tt()["message-filter"],children:[(0,X.jsx)("input",{type:"text",placeholder:eG.ZP.Select.Search,className:(0,tn.Z)(tt()["filter-item"],tt()["search-bar"]),value:o,onInput:e=>{l(e.currentTarget.value),h(e.currentTarget.value)}}),(0,X.jsxs)("div",{className:tt().actions,children:[(0,X.jsx)(eX.h,{text:eG.ZP.Select.All,bordered:!0,className:tt()["filter-item"],onClick:f}),(0,X.jsx)(eX.h,{text:eG.ZP.Select.Latest,bordered:!0,className:tt()["filter-item"],onClick:()=>e.updateSelection(e=>{e.clear(),a.slice(r-4).forEach(t=>e.add(t.id))})}),(0,X.jsx)(eX.h,{text:eG.ZP.Select.Clear,bordered:!0,className:tt()["filter-item"],onClick:()=>e.updateSelection(e=>e.clear())})]})]}),(0,X.jsx)("div",{className:tt().messages,children:a.map((n,s)=>{var a;if(!u(n.id))return null;let r=null!==(a=n.id)&&void 0!==a?a:s,o=e.selection.has(r);return(0,X.jsxs)("div",{className:(0,tn.Z)(tt().message,{[tt()["message-selected"]]:e.selection.has(n.id)}),onClick:()=>{e.updateSelection(e=>{e.has(r)?e.delete(r):e.add(r)}),g(s)},children:[(0,X.jsx)("div",{className:tt().avatar,children:"user"===n.role?(0,X.jsx)(e0.qE,{avatar:i.avatar}):(0,X.jsx)(e1.MaskAvatar,{avatar:t.mask.avatar,model:n.model||t.mask.modelConfig.model})}),(0,X.jsxs)("div",{className:tt().body,children:[(0,X.jsx)("div",{className:tt().date,children:new Date(n.date).toLocaleString()}),(0,X.jsx)("div",{className:(0,tn.Z)(tt().content,"one-line"),children:(0,eH.YK)(n)})]}),(0,X.jsx)("div",{className:tt().checkbox,children:(0,X.jsx)("input",{type:"checkbox",checked:o,readOnly:!0})})]},s)})})]})}var ta=n(20703),tr=n(99823),ti=n(94880),to=n(42882);let tl=(0,eU.default)(async()=>(await Promise.all([n.e(721),n.e(3954),n.e(6991),n.e(6303)]).then(n.bind(n,42896))).Markdown,{loadableGenerated:{webpack:()=>[42896]},loading:()=>(0,X.jsx)(eu.Z,{})});function tc(e){return(0,X.jsx)("div",{className:"modal-mask",children:(0,X.jsx)(eQ.u_,{title:eG.ZP.Export.Title,onClose:e.onClose,footer:(0,X.jsx)("div",{style:{width:"100%",textAlign:"center",fontSize:14,opacity:.5},children:eG.ZP.Exporter.Description.Title}),children:(0,X.jsx)("div",{style:{minHeight:"40vh"},children:(0,X.jsx)(tu,{})})})})}function td(e){let t=e.steps,n=t.length;return(0,X.jsxs)("div",{className:e8().steps,children:[(0,X.jsx)("div",{className:e8()["steps-progress"],children:(0,X.jsx)("div",{className:e8()["steps-progress-inner"],style:{width:"".concat((e.index+1)/n*100,"%")}})}),(0,X.jsx)("div",{className:e8()["steps-inner"],children:t.map((t,n)=>(0,X.jsxs)("div",{className:(0,tn.Z)("clickable",e8().step,{[e8()["step-finished"]]:n<=e.index,[e8()["step-current"]]:n===e.index}),onClick:()=>{var t;null===(t=e.onStepChange)||void 0===t||t.call(e,n)},role:"button",children:[(0,X.jsx)("span",{className:e8()["step-index"],children:n+1}),(0,X.jsx)("span",{className:e8()["step-name"],children:t.name})]},n))})]})}function tu(){let e=[{name:eG.ZP.Export.Steps.Select,value:"select"},{name:eG.ZP.Export.Steps.Preview,value:"preview"}],{currentStep:t,setCurrentStepIndex:n,currentStepIndex:s}=function(e){let t=e.length,[n,s]=(0,Y.useState)(0);return{currentStepIndex:n,setCurrentStepIndex:s,nextStep:()=>s((n+1)%t),prevStep:()=>s((n-1+t)%t),currentStep:e[n]}}(e),[a,r]=(0,Y.useState)({format:"image",includeContext:!0});function i(e){let t={...a};e(t),r(t)}let o=(0,eB.aK)().currentSession(),{selection:l,updateSelection:c}=function(){let[e,t]=(0,Y.useState)(new Set);return{selection:e,updateSelection:n=>{let s=new Set(e);n(s),t(s)}}}(),d=(0,Y.useMemo)(()=>{let e=[];return a.includeContext&&e.push(...o.mask.context),e.push(...o.messages.filter(e=>l.has(e.id))),e},[a.includeContext,o.messages,o.mask.context,l]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(td,{steps:e,index:s,onStepChange:n}),(0,X.jsxs)("div",{className:e8()["message-exporter-body"],style:"select"!==t.value?{display:"none"}:{},children:[(0,X.jsxs)(eQ.aV,{children:[(0,X.jsx)(eQ.HC,{title:eG.ZP.Export.Format.Title,subTitle:eG.ZP.Export.Format.SubTitle,children:(0,X.jsx)(eQ.Ph,{value:a.format,onChange:e=>i(t=>t.format=e.currentTarget.value),children:["text","image","json"].map(e=>(0,X.jsx)("option",{value:e,children:e},e))})}),(0,X.jsx)(eQ.HC,{title:eG.ZP.Export.IncludeContext.Title,subTitle:eG.ZP.Export.IncludeContext.SubTitle,children:(0,X.jsx)("input",{type:"checkbox",checked:a.includeContext,onChange:e=>{i(t=>t.includeContext=e.currentTarget.checked)}})})]}),(0,X.jsx)(ts,{selection:l,updateSelection:c,defaultSelectAll:!0})]}),"preview"===t.value&&(0,X.jsx)("div",{className:e8()["message-exporter-body"],children:"text"===a.format?(0,X.jsx)(tf,{messages:d,topic:o.topic}):"json"===a.format?(0,X.jsx)(tv,{messages:d,topic:o.topic}):(0,X.jsx)(tg,{messages:d,topic:o.topic})})]})}function th(e){let t=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(!t.current)return;let n=Array.from(t.current.getElementsByClassName(e$.yY));if(n.length!==e.messages.length)return;let s=n.map((e,t)=>{var n;let[s,a]=e.id.split(":");return{id:t.toString(),role:s,content:"user"===s?null!==(n=e.textContent)&&void 0!==n?n:"":e.innerHTML,date:""}});e.onRender(s)},[]),(0,X.jsx)("div",{ref:t,children:e.messages.map((e,t)=>(0,X.jsx)("div",{id:"".concat(e.role,":").concat(t),className:e$.yY,children:(0,X.jsx)(tl,{content:(0,eH.YK)(e),defaultShow:!0})},t))})}function tm(e){var t;let[n,s]=(0,Y.useState)(!1),[a,r]=(0,Y.useState)(!1),i=(0,eB.MG)(),o=async()=>{var t;(null===(t=e.messages)||void 0===t?void 0:t.length)&&(s(!0),r(!0))};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("div",{className:e8()["preview-actions"],children:[e.showCopy&&(0,X.jsx)(eX.h,{text:eG.ZP.Export.Copy,bordered:!0,shadow:!0,icon:(0,X.jsx)(ei.Z,{}),onClick:e.copy}),(0,X.jsx)(eX.h,{text:eG.ZP.Export.Download,bordered:!0,shadow:!0,icon:(0,X.jsx)(e5.Z,{}),onClick:e.download}),(0,X.jsx)(eX.h,{text:eG.ZP.Export.Share,bordered:!0,shadow:!0,icon:n?(0,X.jsx)(eu.Z,{}):(0,X.jsx)(ea.Z,{}),onClick:o})]}),(0,X.jsx)("div",{style:{position:"fixed",right:"200vw",pointerEvents:"none"},children:a&&(0,X.jsx)(th,{messages:null!==(t=e.messages)&&void 0!==t?t:[],onRender:e=>{r(!1),(0,to.Lw)(i.modelConfig.providerName).share(e).then(e=>{e&&((0,eQ.K4)({title:eG.ZP.Export.Share,children:[(0,X.jsx)("input",{type:"text",value:e,style:{width:"100%",maxWidth:"unset"},readOnly:!0,onClick:e=>e.currentTarget.select()},"input")],actions:[(0,X.jsx)(eX.h,{icon:(0,X.jsx)(ei.Z,{}),text:eG.ZP.Chat.Actions.Copy,onClick:()=>(0,eH.vQ)(e)},"copy")]}),setTimeout(()=>{window.open(e,"_blank")},800))}).catch(e=>{console.error("[Share]",e),(0,eQ.CF)((0,e2.B)(e))}).finally(()=>s(!1))}})})]})}function tp(e){return e.avatar===e3._G?(0,X.jsx)("img",{src:e9.src,width:30,height:30,alt:"bot",className:"user-avatar"}):(0,X.jsx)(e0.qE,{avatar:e.avatar})}function tg(e){var t,n;let s=(0,eB.aK)().currentSession(),a=s.mask,r=(0,eB.MG)(),i=(0,Y.useRef)(null),o=(0,eH.S0)(),l=async()=>{var t;(0,eQ.CF)(eG.ZP.Export.Image.Toast);let n=i.current;if(!n)return;let s=null===(t=(0,ti.Z)())||void 0===t?void 0:t.isApp;try{let t=await (0,tr.YM)(n);if(!t)return;if(o||s&&window.__TAURI__){if(s&&window.__TAURI__){let n=await window.__TAURI__.dialog.save({defaultPath:"".concat(e.topic,".png"),filters:[{name:"PNG Files",extensions:["png"]},{name:"All Files",extensions:["*"]}]});if(null!==n){let e=await fetch(t),s=await e.arrayBuffer(),a=new Uint8Array(s);await window.__TAURI__.fs.writeBinaryFile(n,a),(0,eQ.CF)(eG.ZP.Download.Success)}else(0,eQ.CF)(eG.ZP.Download.Failed)}else(0,eQ.vi)(t)}else{let n=document.createElement("a");n.download="".concat(e.topic,".png"),n.href=t,n.click(),c()}}catch(e){(0,eQ.CF)(eG.ZP.Download.Failed)}},c=()=>{let e=i.current;e&&(e.innerHTML=e.innerHTML)};return(0,X.jsxs)("div",{className:e8()["image-previewer"],children:[(0,X.jsx)(tm,{copy:()=>{(0,eQ.CF)(eG.ZP.Export.Image.Toast);let e=i.current;e&&(0,tr.SE)(e).then(e=>{if(e)try{navigator.clipboard.write([new ClipboardItem({"image/png":e})]).then(()=>{(0,eQ.CF)(eG.ZP.Copy.Success),c()})}catch(e){console.error("[Copy Image] ",e),(0,eQ.CF)(eG.ZP.Copy.Failed)}})},download:l,showCopy:!o,messages:e.messages}),(0,X.jsxs)("div",{className:(0,tn.Z)(e8()["preview-body"],e8()["default-theme"]),ref:i,children:[(0,X.jsxs)("div",{className:e8()["chat-info"],children:[(0,X.jsx)("div",{className:(0,tn.Z)(e8().logo,"no-dark"),children:(0,X.jsx)(ta.default,{src:e7.Z.src,alt:"logo",width:50,height:50})}),(0,X.jsxs)("div",{children:[(0,X.jsx)("div",{className:e8()["main-title"],children:"NextChat"}),(0,X.jsx)("div",{className:e8()["sub-title"],children:"github.com/ChatGPTNextWeb/ChatGPT-Next-Web"}),(0,X.jsxs)("div",{className:e8().icons,children:[(0,X.jsx)(tp,{avatar:r.avatar}),(0,X.jsx)("span",{className:e8()["icon-space"],children:"&"}),(0,X.jsx)(tp,{avatar:a.avatar})]})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("div",{className:e8()["chat-info-item"],children:[eG.ZP.Exporter.Model,": ",a.modelConfig.model]}),(0,X.jsxs)("div",{className:e8()["chat-info-item"],children:[eG.ZP.Exporter.Messages,": ",e.messages.length]}),(0,X.jsxs)("div",{className:e8()["chat-info-item"],children:[eG.ZP.Exporter.Topic,": ",s.topic]}),(0,X.jsxs)("div",{className:e8()["chat-info-item"],children:[eG.ZP.Exporter.Time,":"," ",new Date(null!==(n=null===(t=e.messages.at(-1))||void 0===t?void 0:t.date)&&void 0!==n?n:Date.now()).toLocaleString()]})]})]}),e.messages.map((e,t)=>(0,X.jsxs)("div",{className:(0,tn.Z)(e8().message,e8()["message-"+e.role]),children:[(0,X.jsx)("div",{className:e8().avatar,children:(0,X.jsx)(tp,{avatar:"user"===e.role?r.avatar:a.avatar})}),(0,X.jsxs)("div",{className:e8().body,children:[(0,X.jsx)(tl,{content:(0,eH.YK)(e),fontSize:r.fontSize,fontFamily:r.fontFamily,defaultShow:!0}),1==(0,eH.Bs)(e).length&&(0,X.jsx)("img",{src:(0,eH.Bs)(e)[0],alt:"message",className:e8()["message-image"]},t),(0,eH.Bs)(e).length>1&&(0,X.jsx)("div",{className:e8()["message-images"],style:{"--image-count":(0,eH.Bs)(e).length},children:(0,eH.Bs)(e).map((e,t)=>(0,X.jsx)("img",{src:e,alt:"message",className:e8()["message-image-multi"]},t))})]})]},t))]})]})}function tf(e){let t="# ".concat(e.topic,"\n\n")+e.messages.map(e=>"user"===e.role?"## ".concat(eG.ZP.Export.MessageFromYou,":\n").concat((0,eH.YK)(e)):"## ".concat(eG.ZP.Export.MessageFromChatGPT,":\n").concat((0,eH.YK)(e).trim())).join("\n\n");return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(tm,{copy:()=>{(0,eH.vQ)(t)},download:()=>{(0,eH.CP)(t,"".concat(e.topic,".md"))},showCopy:!0,messages:e.messages}),(0,X.jsx)("div",{className:"markdown-body",children:(0,X.jsx)("pre",{className:e8()["export-content"],children:t})})]})}function tv(e){let t={messages:[{role:"system",content:"".concat(eG.ZP.FineTuned.Sysmessage," ").concat(e.topic)},...e.messages.map(e=>({role:e.role,content:e.content}))]},n="```json\n"+JSON.stringify(t,null,2)+"\n```",s=JSON.stringify(t),a=()=>{(0,eH.vQ)(s)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(tm,{copy:a,download:()=>{(0,eH.CP)(JSON.stringify(t),"".concat(e.topic,".json"))},showCopy:!1,messages:e.messages}),(0,X.jsx)("div",{className:"markdown-body",onClick:a,children:(0,X.jsx)(tl,{content:n})})]})}var tx=n(20234),tw=n(8620),ty=n(27815),t_=n(37906);(r=R||(R={})).SILENT="silent",r.X_SOFT="x-soft",r.SOFT="soft",r.MEDIUM="medium",r.LOUD="loud",r.X_LOUD="x-LOUD",r.DEFAULT="default",(i=F||(F={})).X_SLOW="x-slow",i.SLOW="slow",i.MEDIUM="medium",i.FAST="fast",i.X_FAST="x-fast",i.DEFAULT="default",(o=B||(B={})).X_LOW="x-low",o.LOW="low",o.MEDIUM="medium",o.HIGH="high",o.X_HIGH="x-high",o.DEFAULT="default",(l=H||(H={})).AUDIO_24KHZ_48KBITRATE_MONO_MP3="audio-24khz-48kbitrate-mono-mp3",l.AUDIO_24KHZ_96KBITRATE_MONO_MP3="audio-24khz-96kbitrate-mono-mp3",l.WEBM_24KHZ_16BIT_MONO_OPUS="webm-24khz-16bit-mono-opus";class tk{constructor(){this.pitch="+0Hz",this.rate=1,this.volume=100}}class tj{_log(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];this._enableLogger&&console.log(...t)}async _send(e){for(let e=1;e<=3&&this._ws.readyState!==this._ws.OPEN;e++)1==e&&(this._startTime=Date.now()),this._log("connecting: ",e),await this._initClient();this._ws.send(e)}_initClient(){return this._ws=new WebSocket(tj.SYNTH_URL),this._ws.binaryType="arraybuffer",new Promise((e,t)=>{this._ws.onopen=()=>{this._log("Connected in",(Date.now()-this._startTime)/1e3,"seconds"),this._send('Content-Type:application/json; charset=utf-8\r\nPath:speech.config\r\n\r\n\n {\n "context": {\n "synthesis": {\n "audio": {\n "metadataoptions": {\n "sentenceBoundaryEnabled": "false",\n "wordBoundaryEnabled": "false"\n },\n "outputFormat": "'.concat(this._outputFormat,'" \n }\n }\n }\n }\n ')).then(e)},this._ws.onmessage=e=>{let t=tw.Buffer.from(e.data),n=t.toString(),s=/X-RequestId:(.*?)\r\n/gm.exec(n)[1];n.includes("Path:turn.start")||(n.includes("Path:turn.end")?this._streams[s].push(null):n.includes("Path:response")||(n.includes("Path:audio")&&e.data instanceof ArrayBuffer?this._pushAudioData(t,s):this._log("UNKNOWN MESSAGE",n)))},this._ws.onclose=()=>{for(let e in this._log("disconnected after:",(Date.now()-this._startTime)/1e3,"seconds"),this._streams)this._streams[e].push(null)},this._ws.onerror=function(e){t("Connect Error: "+e)}})}_pushAudioData(e,t){let n=e.indexOf(tj.BINARY_DELIM)+tj.BINARY_DELIM.length,s=e.subarray(n);this._streams[t].push(s),this._log("received audio chunk, size: ",null==s?void 0:s.length)}_SSMLTemplate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t={...new tk,...t},'<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="https://www.w3.org/2001/mstts" xml:lang="'.concat(this._voiceLocale,'">\n <voice name="').concat(this._voice,'">\n <prosody pitch="').concat(t.pitch,'" rate="').concat(t.rate,'" volume="').concat(t.volume,'">\n ').concat(e,"\n </prosody> \n </voice>\n </speak>")}getVoices(){return fetch(tj.VOICES_URL).then(e=>{if(!e.ok)throw Error("Network response was not ok");return e.json()}).then(e=>e).catch(e=>{throw e})}async setMetadata(e,t,n){let s=this._voice,a=this._voiceLocale,r=this._outputFormat;if(this._voice=e,this._voiceLocale=n,!this._voiceLocale){let e=tj.VOICE_LANG_REGEX.exec(this._voice);if(!e)throw Error("Could not infer voiceLocale from voiceName!");this._voiceLocale=e[0]}this._outputFormat=t,(s!==this._voice||a!==this._voiceLocale||r!==this._outputFormat||this._ws.readyState!==this._ws.OPEN)&&(this._startTime=Date.now(),await this._initClient())}_metadataCheck(){if(!this._ws)throw Error("Speech synthesis not configured yet. Run setMetadata before calling toStream or toFile.")}close(){this._ws.close()}toStream(e,t){let{stream:n}=this._rawSSMLRequest(this._SSMLTemplate(e,t));return n}toArrayBuffer(e,t){return new Promise((n,s)=>{let a=[],r=this.toStream(e,t);r.on("data",e=>{a.push(e)}),r.on("end",()=>{n(tw.Buffer.concat(a).buffer)}),r.on("error",e=>{s(e)})})}rawToStream(e){let{stream:t}=this._rawSSMLRequest(e);return t}_rawSSMLRequest(e){this._metadataCheck();let t=(0,ty.randomBytes)(16).toString("hex"),n="X-RequestId:".concat(t,"\r\nContent-Type:application/ssml+xml\r\nPath:ssml\r\n\r\n\n ")+e.trim(),s=this,a=new t_.Readable({read(){},destroy(e,n){delete s._streams[t],n(e)}});return this._streams[t]=a,this._send(n).then(),{stream:a,requestId:t}}constructor(e=!1){this._streams={},this._startTime=0,this._enableLogger=e}}tj.OUTPUT_FORMAT=H,tj.TRUSTED_CLIENT_TOKEN="6A5AA1D4EAFF4E9FB37E23D68491D6F4",tj.VOICES_URL="https://speech.platform.bing.com/consumer/speech/synthesize/readaloud/voices/list?trustedclienttoken=".concat(tj.TRUSTED_CLIENT_TOKEN),tj.SYNTH_URL="wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?TrustedClientToken=".concat(tj.TRUSTED_CLIENT_TOKEN),tj.BINARY_DELIM="Path:audio\r\n",tj.VOICE_LANG_REGEX=/\w{2}-\w{2}/;var tC=n(10307),tb=n(85564);function tE(){return(tE=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var tS=function(e){return Q.createElement("svg",tE({width:24,height:24,viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),z||(z=Q.createElement("rect",{x:17,y:4,width:14,height:27,rx:7,stroke:"#333",strokeWidth:4,strokeLinejoin:"round"})),U||(U=Q.createElement("path",{d:"M9 23c0 8.284 6.716 15 15 15 8.284 0 15-6.716 15-15M24 38v6",stroke:"#333",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round"})))};function tN(){return(tN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var tM=function(e){return Q.createElement("svg",tN({width:24,height:24,viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),W||(W=Q.createElement("path",{d:"M31 24V11a7 7 0 1 0-14 0v13a7 7 0 1 0 14 0Z",stroke:"#d0021b",strokeWidth:4,strokeLinejoin:"round"})),V||(V=Q.createElement("path",{d:"M9 23c0 8.284 6.716 15 15 15 1.753 0 3.436-.3 5-.853M39 23a14.95 14.95 0 0 1-1.248 6M24 38v6M42 42 6 6",stroke:"#d0021b",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round"})))};function tP(){return(tP=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e}).apply(this,arguments)}var tO=function(e){return Q.createElement("svg",tP({width:24,height:24,viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),G||(G=Q.createElement("path",{d:"M14.5 8a19.05 19.05 0 0 0-4.75 3.84C6.794 15.146 5 19.49 5 24.245 5 34.603 13.507 43 24 43s19-8.397 19-18.755c0-4.756-1.794-9.099-4.75-12.405A19.02 19.02 0 0 0 33.5 8M24 4v20",stroke:"#333",strokeWidth:4,strokeLinecap:"round",strokeLinejoin:"round"})))},tZ=n(2366),tT=n.n(tZ),tA=n(27130);class tL{getByteFrequencyData(){return this.analyser.getByteFrequencyData(this.analyserData),this.analyserData}async initialize(){await this.context.audioWorklet.addModule("/audio-processor.js")}async startRecording(e){try{this.workletNode||await this.initialize(),this.stream=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,sampleRate:this.sampleRate,echoCancellation:!0,noiseSuppression:!0}}),await this.context.resume(),this.source=this.context.createMediaStreamSource(this.stream),this.workletNode=new AudioWorkletNode(this.context,"audio-recorder-processor"),this.workletNode.port.onmessage=t=>{if("audio"===t.data.eventType){let n=t.data.audioData,s=new Int16Array(n.length);for(let e=0;e<n.length;e++){let t=Math.max(-1,Math.min(1,n[e]));s[e]=t<0?32768*t:32767*t}let a=new Uint8Array(s.buffer);e(a),this.recordBuffer.push.apply(this.recordBuffer,s)}},this.source.connect(this.workletNode),this.source.connect(this.mergeNode,0,0),this.workletNode.connect(this.context.destination),this.workletNode.port.postMessage({command:"START_RECORDING"})}catch(e){throw console.error("Error starting recording:",e),e}}stopRecording(){if(!this.workletNode||!this.source||!this.stream)throw Error("Recording not started");this.workletNode.port.postMessage({command:"STOP_RECORDING"}),this.workletNode.disconnect(),this.source.disconnect(),this.stream.getTracks().forEach(e=>e.stop())}startStreamingPlayback(){this.isPlaying=!0,this.nextPlayTime=this.context.currentTime}stopStreamingPlayback(){this.isPlaying=!1,this.playbackQueue.forEach(e=>e.stop()),this.playbackQueue=[],this.playBuffer=[]}playChunk(e){if(!this.isPlaying)return;let t=new Int16Array(e.buffer);this.playBuffer.push.apply(this.playBuffer,t);let n=new Float32Array(t.length);for(let e=0;e<t.length;e++)n[e]=t[e]/(t[e]<0?32768:32767);let s=this.context.createBuffer(1,n.length,this.sampleRate);s.getChannelData(0).set(n);let a=this.context.createBufferSource();a.buffer=s,a.connect(this.context.destination),a.connect(this.mergeNode,0,1);let r=s.length/this.sampleRate;a.start(this.nextPlayTime),this.playbackQueue.push(a),a.onended=()=>{let e=this.playbackQueue.indexOf(a);e>-1&&this.playbackQueue.splice(e,1)},this.nextPlayTime+=r,this.nextPlayTime<this.context.currentTime&&(this.nextPlayTime=this.context.currentTime)}_saveData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16,n=e.buffer.byteLength,s=new Uint8Array(44),a=new DataView(s.buffer);return a.setUint32(0,1380533830,!1),a.setUint32(4,36+n,!0),a.setUint32(8,1463899717,!1),a.setUint32(12,1718449184,!1),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,1,!0),a.setUint32(24,this.sampleRate,!0),a.setUint32(28,4*this.sampleRate,!0),a.setUint16(32,2,!0),a.setUint16(34,t,!0),a.setUint32(36,1684108385,!1),a.setUint32(40,n,!0),new Blob([a,e.buffer],{type:"audio/mpeg"})}savePlayFile(){return this._saveData(new Int16Array(this.playBuffer))}saveRecordFile(e,t){let n=e?Math.floor(e*this.sampleRate/1e3):0,s=t?Math.floor(t*this.sampleRate/1e3):this.recordBuffer.length;return this._saveData(new Int16Array(this.recordBuffer.slice(n,s)))}async close(){var e,t,n;this.recordBuffer=[],null===(e=this.workletNode)||void 0===e||e.disconnect(),null===(t=this.source)||void 0===t||t.disconnect(),null===(n=this.stream)||void 0===n||n.getTracks().forEach(e=>e.stop()),await this.context.close()}constructor(){this.workletNode=null,this.stream=null,this.source=null,this.recordBuffer=[],this.sampleRate=24e3,this.nextPlayTime=0,this.isPlaying=!1,this.playbackQueue=[],this.playBuffer=[],this.context=new AudioContext({sampleRate:this.sampleRate}),this.mergeNode=new ChannelMergerNode(this.context,{numberOfInputs:2}),this.analyser=new AnalyserNode(this.context,{fftSize:256}),this.analyserData=new Uint8Array(this.analyser.frequencyBinCount),this.mergeNode.connect(this.analyser)}}var tI=n(69927),tD=n.n(tI);function tK(e){let{frequencies:t,isActive:n}=e,s=(0,Y.useRef)(null),a=(0,Y.useRef)([]),r=(0,Y.useRef)(10),i=(0,Y.useRef)(),o=(0,Y.useCallback)(e=>{a.current.push(e),a.current.length>r.current&&a.current.shift()},[]);return(0,Y.useEffect)(()=>{let e=s.current;if(!e)return;let r=e.getContext("2d");if(!r)return;let l=window.devicePixelRatio||1;e.width=e.offsetWidth*l,e.height=e.offsetHeight*l,r.scale(l,l);let c=()=>{if(r.clearRect(0,0,e.width,e.height),!t||!n){a.current=[];return}o(Array.from(t));let s=[],l=e.height/2,d=e.width/(t.length-1);r.beginPath(),r.moveTo(0,l);for(let n=0;n<t.length;n++){let i=n*d,o=t[n];a.current.length>0&&(o=(o+a.current.map(e=>e[n]||0).reduce((e,t)=>e+t,0))/(a.current.length+1));let c=o/255,u=l+e.height/2*c*Math.sin(.2*n+.002*Date.now());if(s.push([i,u]),0===n)r.moveTo(i,u);else{let e=s[n-1],t=(e[0]+i)/2;r.quadraticCurveTo(e[0],e[1],t,(e[1]+u)/2)}}for(let e=s.length-1;e>=0;e--){let[t,n]=s[e],a=l-(n-l);if(e===s.length-1)r.lineTo(t,a);else{let a=s[e+1],i=(a[0]+t)/2;r.quadraticCurveTo(a[0],l-(a[1]-l),i,l-((a[1]+n)/2-l))}}r.closePath();let u=r.createLinearGradient(0,0,e.width,0);u.addColorStop(0,"rgba(100, 180, 255, 0.95)"),u.addColorStop(.5,"rgba(140, 200, 255, 0.9)"),u.addColorStop(1,"rgba(180, 220, 255, 0.95)"),r.fillStyle=u,r.fill(),i.current=requestAnimationFrame(c)};return c(),()=>{i.current&&cancelAnimationFrame(i.current)}},[t,n,o]),(0,X.jsx)("div",{className:tD()["voice-print"],children:(0,X.jsx)("canvas",{ref:s})})}function tR(e){let{onClose:t,onStartVoice:n,onPausedVoice:s}=e,a=(0,eB.aK)(),r=a.currentSession(),i=(0,eB.MG)(),[o,l]=(0,Y.useState)(""),[c,d]=(0,Y.useState)(!1),[u,h]=(0,Y.useState)(!1),[m,p]=(0,Y.useState)(!1),[g,f]=(0,Y.useState)("audio"),[v,x]=(0,Y.useState)(!0),[w,y]=(0,Y.useState)(),_=(0,Y.useRef)(null),k=(0,Y.useRef)(null),j=(0,Y.useRef)(!1),C=i.realtimeConfig.temperature,b=i.realtimeConfig.apiKey,E=i.realtimeConfig.model,S="Azure"===i.realtimeConfig.provider,N=i.realtimeConfig.azure.endpoint,M=i.realtimeConfig.azure.deployment,P=i.realtimeConfig.voice,O=async()=>{if(!m){if(u)await Z();else try{p(!0),_.current=S?new tA.G2(new URL(N),{key:b},{deployment:M}):new tA.G2({key:b},{model:E}),await _.current.configure({instructions:"",voice:P,input_audio_transcription:{model:"whisper-1"},turn_detection:v?{type:"server_vad"}:null,tools:[],temperature:C,modalities:"audio"===g?["text","audio"]:["text"]}),T(),h(!0)}catch(e){console.error("Connection failed:",e),l("Connection failed")}finally{p(!1)}}},Z=async()=>{if(_.current)try{await _.current.close(),_.current=null,h(!1)}catch(e){console.error("Disconnect failed:",e)}},T=async()=>{if(_.current)try{for await(let e of _.current.events())"response"===e.type?await A(e):"input_audio"===e.type&&await L(e)}catch(e){_.current&&console.error("Response iteration error:",e)}},A=async e=>{for await(let n of e)if("message"===n.type&&"assistant"===n.role){let e=(0,eB.tn)({role:n.role,content:""});a.updateTargetSession(r,t=>{t.messages=t.messages.concat([e])});let s=!1;for await(let t of n){if("text"===t.type)for await(let n of t.textChunks())e.content+=n;else if("audio"===t.type){let n=async()=>{for await(let n of t.transcriptChunks())e.content+=n},a=async()=>{var e,n;for await(let a of(null===(e=k.current)||void 0===e||e.startStreamingPlayback(),t.audioChunks()))s=!0,null===(n=k.current)||void 0===n||n.playChunk(a)};await Promise.all([n(),a()])}a.updateTargetSession(r,e=>{e.messages=e.messages.concat()})}if(s){var t;let n=null===(t=k.current)||void 0===t?void 0:t.savePlayFile();(0,ez.Ix)(n).then(t=>{e.audio_url=t,a.updateTargetSession(r,e=>{e.messages=e.messages.concat()})})}}},L=async e=>{var t,n;if(await e.waitForCompletion(),e.transcription){let t=(0,eB.tn)({role:"user",content:e.transcription});a.updateTargetSession(r,e=>{e.messages=e.messages.concat([t])});let{audioStartMillis:s,audioEndMillis:i}=e,o=null===(n=k.current)||void 0===n?void 0:n.saveRecordFile(s,i);(0,ez.Ix)(o).then(e=>{t.audio_url=e,a.updateTargetSession(r,e=>{e.messages=e.messages.concat()})})}null===(t=k.current)||void 0===t||t.stopStreamingPlayback()},I=async()=>{if(!c&&_.current)try{k.current||(k.current=new tL,await k.current.initialize()),await k.current.startRecording(async e=>{var t;await (null===(t=_.current)||void 0===t?void 0:t.sendAudio(e))}),d(!0)}catch(e){console.error("Failed to start recording:",e)}else if(k.current)try{if(k.current.stopRecording(),!v){var e,t;let n=await (null===(e=_.current)||void 0===e?void 0:e.commitAudio());await L(n),await (null===(t=_.current)||void 0===t?void 0:t.generateResponse())}d(!1)}catch(e){console.error("Failed to stop recording:",e)}};(0,Y.useEffect)(()=>{if(!j.current)return j.current=!0,(async()=>{let e=new tL;await e.initialize(),k.current=e,await O(),await I()})().catch(e=>{l(e),console.error(e)}),()=>{var e;c&&I(),null===(e=k.current)||void 0===e||e.close().catch(console.error),Z()}},[]),(0,Y.useEffect)(()=>{let e;if(u&&c){let t=()=>{k.current&&y(k.current.getByteFrequencyData()),e=requestAnimationFrame(t)};e=requestAnimationFrame(t)}else y(void 0);return()=>{e&&cancelAnimationFrame(e)}},[u,c]),(0,Y.useEffect)(()=>{var e;null===(e=_.current)||void 0===e||e.configure({voice:P})},[P]),(0,Y.useEffect)(()=>{var e;null===(e=_.current)||void 0===e||e.configure({temperature:C})},[C]);let D=async()=>{null==t||t(),c&&await I(),Z().catch(console.error)};return(0,X.jsxs)("div",{className:tT()["realtime-chat"],children:[(0,X.jsx)("div",{className:(0,tn.Z)(tT()["circle-mic"],{[tT().pulse]:c}),children:(0,X.jsx)(tK,{frequencies:w,isActive:c})}),(0,X.jsxs)("div",{className:tT()["bottom-icons"],children:[(0,X.jsx)("div",{children:(0,X.jsx)(eX.h,{icon:c?(0,X.jsx)(tS,{}):(0,X.jsx)(tM,{}),onClick:I,disabled:!u,shadow:!0,bordered:!0})}),(0,X.jsx)("div",{className:tT()["icon-center"],children:o}),(0,X.jsx)("div",{children:(0,X.jsx)(eX.h,{icon:(0,X.jsx)(tO,{}),onClick:D,shadow:!0,bordered:!0})})]})]})}n(94386);let tF=(0,eH.EN)(),tB=(s=null,a=null,{init:()=>{(s=new(window.AudioContext||window.webkitAudioContext)).suspend()},play:async(e,t)=>{a&&(a.stop(),a.disconnect());let n=await s.decodeAudioData(e);(a=s.createBufferSource()).buffer=n,a.connect(s.destination),s.resume().then(()=>{a.start()}),a.onended=t},stop:()=>{a&&(a.stop(),a.disconnect(),a=null),s&&(s.close(),s=null)}}),tH=(0,eU.default)(async()=>(await Promise.all([n.e(721),n.e(3954),n.e(6991),n.e(6303)]).then(n.bind(n,42896))).Markdown,{loadableGenerated:{webpack:()=>[42896]},loading:()=>(0,X.jsx)(eu.Z,{})});function tz(e){let t=(0,eB.aK)(),n=t.currentSession(),s=(0,e3.Zy)(),a=(0,eJ.s0)();return(0,X.jsx)("div",{className:"modal-mask",children:(0,X.jsx)(eQ.u_,{title:eG.ZP.Context.Edit,onClose:()=>e.onClose(),actions:[(0,X.jsx)(eX.h,{icon:(0,X.jsx)(eg.Z,{}),bordered:!0,text:eG.ZP.Chat.Config.Reset,onClick:async()=>{await (0,eQ.i0)(eG.ZP.Memory.ResetConfirm)&&t.updateTargetSession(n,e=>e.memoryPrompt="")}},"reset"),(0,X.jsx)(eX.h,{icon:(0,X.jsx)(ei.Z,{}),bordered:!0,text:eG.ZP.Chat.Config.SaveAs,onClick:()=>{a(e$.y$.Masks),setTimeout(()=>{s.create(n.mask)},500)}},"copy")],children:(0,X.jsx)(e1.MaskConfig,{mask:n.mask,updateMask:e=>{let s={...n.mask};e(s),t.updateTargetSession(n,e=>e.mask=s)},shouldSyncFromGlobal:!0,extraListItems:n.mask.modelConfig.sendMemory?(0,X.jsx)(eQ.HC,{className:"copyable",title:"".concat(eG.ZP.Memory.Title," (").concat(n.lastSummarizeIndex," of ").concat(n.messages.length,")"),subTitle:n.memoryPrompt||eG.ZP.Memory.EmptyContent}):(0,X.jsx)(X.Fragment,{})})})})}function tU(e){let t=(0,eB.aK)().currentSession().mask.context;return(0,X.jsxs)("div",{className:eY()["prompt-toast"],children:[e.showToast&&t.length>0&&(0,X.jsxs)("div",{className:(0,tn.Z)(eY()["prompt-toast-inner"],"clickable"),role:"button",onClick:()=>e.setShowModal(!0),children:[(0,X.jsx)(et,{}),(0,X.jsx)("span",{className:eY()["prompt-toast-content"],children:eG.ZP.Context.Toast(t.length)})]}),e.showModal&&(0,X.jsx)(tz,{onClose:()=>e.setShowModal(!1)})]},"prompt-toast")}function tW(e){let t=0===e.prompts.length,[n,s]=(0,Y.useState)(0),a=(0,Y.useRef)(null);return((0,Y.useEffect)(()=>{s(0)},[e.prompts.length]),(0,Y.useEffect)(()=>{let r=r=>{if(t||r.metaKey||r.altKey||r.ctrlKey)return;let i=t=>{var i;r.stopPropagation(),r.preventDefault(),s(Math.max(0,Math.min(e.prompts.length-1,n+t))),null===(i=a.current)||void 0===i||i.scrollIntoView({block:"center"})};if("ArrowUp"===r.key)i(1);else if("ArrowDown"===r.key)i(-1);else if("Enter"===r.key){let t=e.prompts.at(n);t&&e.onPromptSelect(t)}};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e.prompts.length,n]),t)?null:(0,X.jsx)("div",{className:eY()["prompt-hints"],children:e.prompts.map((t,r)=>(0,X.jsxs)("div",{ref:r===n?a:null,className:(0,tn.Z)(eY()["prompt-hint"],{[eY()["prompt-hint-selected"]]:r===n}),onClick:()=>e.onPromptSelect(t),onMouseEnter:()=>s(r),children:[(0,X.jsx)("div",{className:eY()["hint-title"],children:t.title}),(0,X.jsx)("div",{className:eY()["hint-content"],children:t.content})]},t.title+r.toString()))})}function tV(){let e=(0,eB.aK)(),t=e.currentSession();return(0,X.jsxs)("div",{className:eY()["clear-context"],onClick:()=>e.updateTargetSession(t,e=>e.clearContextIndex=void 0),children:[(0,X.jsx)("div",{className:eY()["clear-context-tips"],children:eG.ZP.Context.Clear}),(0,X.jsx)("div",{className:eY()["clear-context-revert-btn"],children:eG.ZP.Context.Revert})]})}function tG(e){let t=(0,Y.useRef)(null),n=(0,Y.useRef)(null),[s,a]=(0,Y.useState)({full:16,icon:16});function r(){if(!t.current||!n.current)return;let e=n.current.getBoundingClientRect().width,s=t.current.getBoundingClientRect().width;a({full:e+s,icon:s})}return(0,X.jsxs)("div",{className:(0,tn.Z)(eY()["chat-input-action"],"clickable"),onClick:()=>{e.onClick(),setTimeout(r,1)},onMouseEnter:r,onTouchStart:r,style:{"--icon-width":"".concat(s.icon,"px"),"--full-width":"".concat(s.full,"px")},children:[(0,X.jsx)("div",{ref:t,className:eY().icon,children:e.icon}),(0,X.jsx)("div",{className:eY().text,ref:n,children:e.text})]})}function tX(e){var t,n,s,a,r,i,o,l;let c=(0,eB.MG)(),d=(0,eJ.s0)(),u=(0,eB.aK)(),h=(0,eB.RQ)(),m=u.currentSession();c.theme;let p=eW.L.hasPending(),g=m.mask.modelConfig.model,f=(null===(t=m.mask.modelConfig)||void 0===t?void 0:t.providerName)||e$.UT.OpenAI,v=(0,tx.l)(),x=(0,Y.useMemo)(()=>{let e=v.filter(e=>e.available),t=e.find(e=>e.isDefault);return t?[t,...e.filter(e=>e!==t)]:e},[v]),w=(0,Y.useMemo)(()=>{var e;let t=x.find(e=>{var t;return e.name==g&&(null==e?void 0:null===(t=e.provider)||void 0===t?void 0:t.providerName)==f});return null!==(e=null==t?void 0:t.displayName)&&void 0!==e?e:""},[x,g,f]),[y,_]=(0,Y.useState)(!1),[k,j]=(0,Y.useState)(!1),[C,b]=(0,Y.useState)(!1),[E,S]=(0,Y.useState)(!1),[N,M]=(0,Y.useState)(!1),[P,O]=(0,Y.useState)(!1),Z=(0,eH.h1)(g),T=null!==(i=null===(n=m.mask.modelConfig)||void 0===n?void 0:n.size)&&void 0!==i?i:"1024x1024",A=null!==(o=null===(s=m.mask.modelConfig)||void 0===s?void 0:s.quality)&&void 0!==o?o:"standard",L=null!==(l=null===(a=m.mask.modelConfig)||void 0===a?void 0:a.style)&&void 0!==l?l:"vivid";return(0,eH.S0)(),(0,Y.useEffect)(()=>{let t=(0,eH.Xf)(g);if(b(t),t||(e.setAttachImages([]),e.setUploading(!1)),!x.some(e=>e.name===g)&&x.length>0){var n;let e=x.find(e=>e.isDefault)||x[0];u.updateTargetSession(m,t=>{var n;t.mask.modelConfig.model=e.name,t.mask.modelConfig.providerName=null==e?void 0:null===(n=e.provider)||void 0===n?void 0:n.providerName}),(0,eQ.CF)((null==e?void 0:null===(n=e.provider)||void 0===n?void 0:n.providerName)=="ByteDance"?e.displayName:e.name)}},[u,g,x,m]),(0,X.jsxs)("div",{className:eY()["chat-input-actions"],children:[(0,X.jsxs)(X.Fragment,{children:[p&&(0,X.jsx)(tG,{onClick:()=>eW.L.stopAll(),text:eG.ZP.Chat.InputActions.Stop,icon:(0,X.jsx)(eN.Z,{})}),!e.hitBottom&&(0,X.jsx)(tG,{onClick:e.scrollToBottom,text:eG.ZP.Chat.InputActions.ToBottom,icon:(0,X.jsx)(eS,{})}),e.hitBottom&&(0,X.jsx)(tG,{onClick:e.showPromptModal,text:eG.ZP.Chat.InputActions.Settings,icon:(0,X.jsx)(ev,{})}),C&&(0,X.jsx)(tG,{onClick:e.uploadImage,text:eG.ZP.Chat.InputActions.UploadImage,icon:e.uploading?(0,X.jsx)(eh.Z,{}):(0,X.jsx)(eb,{})}),(0,X.jsx)(tG,{onClick:()=>_(!0),text:w,icon:(0,X.jsx)(eP,{})}),y&&(0,X.jsx)(eQ.Qf,{defaultSelectedValue:"".concat(g,"@").concat(f),items:x.map(e=>{var t,n,s;return{title:"".concat(e.displayName).concat((null==e?void 0:null===(t=e.provider)||void 0===t?void 0:t.providerName)?" ("+(null==e?void 0:null===(n=e.provider)||void 0===n?void 0:n.providerName)+")":""),value:"".concat(e.name,"@").concat(null==e?void 0:null===(s=e.provider)||void 0===s?void 0:s.providerName)}}),onClose:()=>_(!1),onSelection:e=>{if(0===e.length)return;let[t,n]=(0,tb.En)(e[0]);if(u.updateTargetSession(m,e=>{e.mask.modelConfig.model=t,e.mask.modelConfig.providerName=n,e.mask.syncGlobalConfig=!1}),"ByteDance"==n){var s;let e=x.find(e=>{var s;return e.name==t&&(null==e?void 0:null===(s=e.provider)||void 0===s?void 0:s.providerName)==n});(0,eQ.CF)(null!==(s=null==e?void 0:e.displayName)&&void 0!==s?s:"")}else(0,eQ.CF)(t)}}),(0,eH.ZT)(g)&&(0,X.jsx)(tG,{onClick:()=>S(!0),text:T,icon:(0,X.jsx)(eZ,{})}),E&&(0,X.jsx)(eQ.Qf,{defaultSelectedValue:T,items:Z.map(e=>({title:e,value:e})),onClose:()=>S(!1),onSelection:e=>{if(0===e.length)return;let t=e[0];u.updateTargetSession(m,e=>{e.mask.modelConfig.size=t}),(0,eQ.CF)(t)}}),(0,eH.Wu)(g)&&(0,X.jsx)(tG,{onClick:()=>M(!0),text:A,icon:(0,X.jsx)(eA,{})}),N&&(0,X.jsx)(eQ.Qf,{defaultSelectedValue:A,items:["standard","hd"].map(e=>({title:e,value:e})),onClose:()=>M(!1),onSelection:e=>{if(0===e.length)return;let t=e[0];u.updateTargetSession(m,e=>{e.mask.modelConfig.quality=t}),(0,eQ.CF)(t)}}),(0,eH.Wu)(g)&&(0,X.jsx)(tG,{onClick:()=>O(!0),text:L,icon:(0,X.jsx)(eI,{})}),P&&(0,X.jsx)(eQ.Qf,{defaultSelectedValue:L,items:["vivid","natural"].map(e=>({title:e,value:e})),onClose:()=>O(!1),onSelection:e=>{if(0===e.length)return;let t=e[0];u.updateTargetSession(m,e=>{e.mask.modelConfig.style=t}),(0,eQ.CF)(t)}}),(0,eH.up)(f,g)&&(0,X.jsx)(tG,{onClick:()=>{0==h.getAll().length?d(e$.y$.Plugins):j(!0)},text:eG.ZP.Plugin.Name,icon:(0,X.jsx)(eK,{})}),k&&(0,X.jsx)(eQ.Qf,{multiple:!0,defaultSelectedValue:null===(r=u.currentSession().mask)||void 0===r?void 0:r.plugin,items:h.getAll().map(e=>({title:"".concat(null==e?void 0:e.title,"@").concat(null==e?void 0:e.version),value:null==e?void 0:e.id})),onClose:()=>j(!1),onSelection:e=>{u.updateTargetSession(m,t=>{t.mask.plugin=e})}})]}),(0,X.jsx)("div",{className:eY()["chat-input-actions-end"],children:c.realtimeConfig.enable&&(0,X.jsx)(tG,{onClick:()=>e.setShowChatSidePanel(!0),text:"Realtime Chat",icon:(0,X.jsx)(eF,{})})})]})}function tq(e){let t=(0,eB.aK)(),n=t.currentSession(),[s,a]=(0,Y.useState)(n.messages.slice());return(0,X.jsx)("div",{className:"modal-mask",children:(0,X.jsxs)(eQ.u_,{title:eG.ZP.Chat.EditMessage.Title,onClose:e.onClose,actions:[(0,X.jsx)(eX.h,{text:eG.ZP.UI.Cancel,icon:(0,X.jsx)(ej.Z,{}),onClick:()=>{e.onClose()}},"cancel"),(0,X.jsx)(eX.h,{type:"primary",text:eG.ZP.UI.Confirm,icon:(0,X.jsx)(e_.Z,{}),onClick:()=>{t.updateTargetSession(n,e=>e.messages=s),e.onClose()}},"ok")],children:[(0,X.jsx)(eQ.aV,{children:(0,X.jsx)(eQ.HC,{title:eG.ZP.Chat.EditMessage.Topic.Title,subTitle:eG.ZP.Chat.EditMessage.Topic.SubTitle,children:(0,X.jsx)("input",{type:"text",value:n.topic,onInput:e=>t.updateTargetSession(n,t=>t.topic=e.currentTarget.value)})})}),(0,X.jsx)(e1.ContextPrompts,{context:s,updateContext:e=>{let t=s.slice();e(t),a(t)}})]})})}function tY(e){return(0,X.jsx)("div",{className:eY()["delete-image"],onClick:e.deleteImage,children:(0,X.jsx)(ex.Z,{})})}function tQ(e){let t=navigator.platform.toUpperCase().indexOf("MAC")>=0,n=[{title:eG.ZP.Chat.ShortcutKey.newChat,keys:t?["⌘","Shift","O"]:["Ctrl","Shift","O"]},{title:eG.ZP.Chat.ShortcutKey.focusInput,keys:["Shift","Esc"]},{title:eG.ZP.Chat.ShortcutKey.copyLastCode,keys:t?["⌘","Shift",";"]:["Ctrl","Shift",";"]},{title:eG.ZP.Chat.ShortcutKey.copyLastMessage,keys:t?["⌘","Shift","C"]:["Ctrl","Shift","C"]},{title:eG.ZP.Chat.ShortcutKey.showShortcutKey,keys:t?["⌘","/"]:["Ctrl","/"]},{title:eG.ZP.Chat.ShortcutKey.clearContext,keys:t?["⌘","Shift","backspace"]:["Ctrl","Shift","backspace"]}];return(0,X.jsx)("div",{className:"modal-mask",children:(0,X.jsx)(eQ.u_,{title:eG.ZP.Chat.ShortcutKey.Title,onClose:e.onClose,actions:[(0,X.jsx)(eX.h,{type:"primary",text:eG.ZP.UI.Confirm,icon:(0,X.jsx)(e_.Z,{}),onClick:()=>{e.onClose()}},"ok")],children:(0,X.jsx)("div",{className:eY()["shortcut-key-container"],children:(0,X.jsx)("div",{className:eY()["shortcut-key-grid"],children:n.map((e,t)=>(0,X.jsxs)("div",{className:eY()["shortcut-key-item"],children:[(0,X.jsx)("div",{className:eY()["shortcut-key-title"],children:e.title}),(0,X.jsx)("div",{className:eY()["shortcut-key-keys"],children:e.keys.map((e,t)=>(0,X.jsx)("div",{className:eY()["shortcut-key"],children:(0,X.jsx)("span",{children:e})},t))})]},t))})})})})}function tJ(){var e,t,s;let a=(0,eB.aK)(),r=a.currentSession(),i=(0,eB.MG)(),o=i.fontSize,l=i.fontFamily,[c,d]=(0,Y.useState)(!1),u=(0,Y.useRef)(null),[h,m]=(0,Y.useState)(""),[p,g]=(0,Y.useState)(!1),{submitKey:f,shouldSubmit:v}=function(){let e=(0,eB.MG)(),t=e.submitKey,n=(0,Y.useRef)(!1);return(0,Y.useEffect)(()=>{let e=()=>{n.current=!0},t=()=>{n.current=!1};return window.addEventListener("compositionstart",e),window.addEventListener("compositionend",t),()=>{window.removeEventListener("compositionstart",e),window.removeEventListener("compositionend",t)}},[]),{submitKey:t,shouldSubmit:t=>229!=t.keyCode&&"Enter"===t.key&&("Enter"!==t.key||!t.nativeEvent.isComposing&&!n.current)&&(e.submitKey===eB.mQ.AltEnter&&t.altKey||e.submitKey===eB.mQ.CtrlEnter&&t.ctrlKey||e.submitKey===eB.mQ.ShiftEnter&&t.shiftKey||e.submitKey===eB.mQ.MetaEnter&&t.metaKey||e.submitKey===eB.mQ.Enter&&!t.altKey&&!t.ctrlKey&&!t.shiftKey&&!t.metaKey)}}(),x=(0,Y.useRef)(null),w=null!=x&&!!x.current&&1>=Math.abs(x.current.scrollHeight-(x.current.scrollTop+x.current.clientHeight)),y=(0,Y.useMemo)(()=>{var e;let t=null===(e=x.current)||void 0===e?void 0:e.lastElementChild;return null!=x&&!!x.current&&!!t&&t.getBoundingClientRect().top-x.current.getBoundingClientRect().top<100},[null==x?void 0:null===(e=x.current)||void 0===e?void 0:e.scrollHeight]),_=""!==h,{setAutoScroll:k,scrollDomToBottom:j}=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,[s,a]=(0,Y.useState)(!0),r=(0,Y.useCallback)(()=>{let t=e.current;t&&requestAnimationFrame(()=>{a(!0),t.scrollTo(0,t.scrollHeight)})},[e]);(0,Y.useEffect)(()=>{s&&!t&&r()});let i=(0,Y.useRef)(n.length);return(0,Y.useEffect)(()=>{n.length>i.current&&!t&&r(),i.current=n.length},[n.length,t,r]),{scrollRef:e,autoScroll:s,setAutoScroll:a,scrollDomToBottom:r}}(x,(w||y)&&!_,r.messages),[C,b]=(0,Y.useState)(!0),E=(0,eH.S0)(),S=(0,eJ.s0)(),[N,M]=(0,Y.useState)([]),[P,O]=(0,Y.useState)(!1),Z=(0,eV.f)(),[T,A]=(0,Y.useState)([]),L=(0,q.y1)(e=>{A(Z.search(e))},100,{leading:!0,trailing:!0}),[I,D]=(0,Y.useState)(2),K=(0,q.y1)(()=>{let e=u.current?(0,eH.lx)(u.current):1;D(Math.min(20,Math.max(2+Number(!E),e)))},100,{leading:!0,trailing:!0});(0,Y.useEffect)(K,[h]);let R=(0,e6.UK)({new:()=>a.newSession(),newm:()=>S(e$.y$.NewChat),prev:()=>a.nextSession(-1),next:()=>a.nextSession(1),clear:()=>a.updateTargetSession(r,e=>e.clearContextIndex=e.messages.length),fork:()=>a.forkSession(),del:()=>a.deleteSession(a.currentSessionIndex)}),F=e=>{m(e);let t=e.trim().length;0===t?A([]):e.match(e6.x6)?A(R.search(e)):!i.disablePromptHint&&t<30&&e.startsWith("/")&&L(e.slice(1))},B=e=>{var t;if(""===e.trim()&&(0,tC.Z)(N))return;let n=R.match(e);if(n.matched){m(""),A([]),n.invoke();return}g(!0),a.onUserInput(e,N).then(()=>g(!1)),M([]),a.setLastInput(e),m(""),A([]),E||null===(t=u.current)||void 0===t||t.focus(),k(!0)},z=e=>{eW.L.stop(r.id,e)};(0,Y.useEffect)(()=>{a.updateTargetSession(r,e=>{let t=Date.now()-e$.tb;e.messages.forEach(e=>{(e.isError||new Date(e.date).getTime()<t)&&(e.streaming&&(e.streaming=!1),0===e.content.length&&(e.isError=!0,e.content=(0,e2.B)({error:!0,message:"empty response"})))}),e.mask.syncGlobalConfig&&(console.log("[Mask] syncing from global, name = ",e.mask.name),e.mask.modelConfig={...i.modelConfig})})},[r]);let U=e=>{a.updateTargetSession(r,t=>t.messages=t.messages.filter(t=>t.id!==e))},W=e=>{U(e)},V=e=>{var t;let n,s;let i=r.messages.findIndex(t=>t.id===e.id);if(i<0||i>=r.messages.length){console.error("[Chat] failed to find resending message",e);return}if("assistant"===e.role){s=e;for(let e=i;e>=0;e-=1)if("user"===r.messages[e].role){n=r.messages[e];break}}else if("user"===e.role){n=e;for(let e=i;e<r.messages.length;e+=1)if("assistant"===r.messages[e].role){s=r.messages[e];break}}if(void 0===n){console.error("[Chat] failed to resend",e);return}U(n.id),U(null==s?void 0:s.id),g(!0);let o=(0,eH.YK)(n),l=(0,eH.Bs)(n);a.onUserInput(o,l).then(()=>g(!1)),null===(t=u.current)||void 0===t||t.focus()},G=e=>{a.updateTargetSession(r,t=>t.mask.context.push(e)),(0,eQ.CF)(eG.ZP.Chat.Actions.PinToastContent,{text:eG.ZP.Chat.Actions.PinToastAction,onClick:()=>{eM(!0)}})},Q=(0,eB._X)(),[J,ee]=(0,Y.useState)(!1),[et,en]=(0,Y.useState)(!1);async function eo(e){if(J)tB.stop(),ee(!1);else{var t;let s;t=new to.ti(e$.k8.GPT);let a=eB.MG.getState();en(!0),tB.init();let{markdownToTxt:r}=n(69549),i=r(e);if(a.ttsConfig.engine!==e$.Xu){let e=Q.edgeVoiceName(),t=new tj;await t.setMetadata(e,H.AUDIO_24KHZ_96KBITRATE_MONO_MP3),s=await t.toArrayBuffer(i)}else s=await t.llm.speech({model:a.ttsConfig.model,input:i,voice:a.ttsConfig.voice,speed:a.ttsConfig.speed});ee(!0),tB.play(s,()=>{ee(!1)}).catch(e=>{console.error("[OpenAI Speech]",e),(0,eQ.CF)((0,e2.B)(e)),ee(!1)}).finally(()=>en(!1))}}let ec=(0,Y.useMemo)(()=>r.mask.hideContext?[]:r.mask.context.slice(),[r.mask.context,r.mask.hideContext]);if(0===ec.length&&(null===(t=r.messages.at(0))||void 0===t?void 0:t.content)!==eB.ux.content){let e=Object.assign({},eB.ux);Q.isAuthorized()||(e.content=eG.ZP.Error.Unauthorized),ec.push(e)}let eu=(0,Y.useMemo)(()=>ec.concat(r.messages).concat(p?[{...(0,eB.tn)({role:"assistant",content:"……"}),preview:!0}]:[]).concat(h.length>0&&i.sendPreviewBubble?[{...(0,eB.tn)({role:"user",content:h}),preview:!0}]:[]),[i.sendPreviewBubble,ec,p,r.messages,h]),[ef,ev]=(0,Y.useState)(Math.max(0,eu.length-e$.nS));function ew(e){ev(e=Math.max(0,e=Math.min(eu.length-e$.nS,e)))}let ej=(0,Y.useMemo)(()=>{let e=Math.min(ef+3*e$.nS,eu.length);return eu.slice(ef,e)},[ef,eu]),eC=e=>{let t=e.scrollTop+e.clientHeight,n=e.clientHeight,s=e.scrollTop<=n,a=t>=e.scrollHeight-n,r=t>=e.scrollHeight-(E?4:10),i=ef-e$.nS,o=ef+e$.nS;s&&!a?ew(i):a&&ew(o),b(r),k(r)};function eb(){ew(eu.length-e$.nS),j()}let eE=(null!==(s=r.clearContextIndex)&&void 0!==s?s:-1)>=0?r.clearContextIndex+ec.length-ef:-1,[eS,eM]=(0,Y.useState)(!1),eP=(0,Y.useMemo)(()=>(0,ti.Z)(),[]),eO=!E,eZ=!E&&!(null==eP?void 0:eP.isApp);(0,e6.YZ)({fill:m,submit:e=>{B(e)},code:e=>{Q.disableFastLink||(console.log("[Command] got code from url: ",e),(0,eQ.i0)(eG.ZP.URLCommand.Code+"code = ".concat(e)).then(t=>{t&&Q.update(t=>t.accessCode=e)}))},settings:e=>{if(!Q.disableFastLink)try{let t=JSON.parse(e);console.log("[Command] got settings from url: ",t),(t.key||t.url)&&(0,eQ.i0)(eG.ZP.URLCommand.Settings+"\n".concat(JSON.stringify(t,null,4))).then(e=>{e&&(t.key&&Q.update(e=>e.openaiApiKey=t.key),t.url&&Q.update(e=>e.openaiUrl=t.url),Q.update(e=>e.useCustomConfig=!0))})}catch(t){console.error("[Command] failed to get settings from url: ",e)}}});let[eT,eA]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=(0,e$.AI)(r.id),t=tF.getItem(e);t&&0===h.length&&(m(t),tF.removeItem(e));let n=u.current;return()=>{var t;tF.setItem(e,null!==(t=null==n?void 0:n.value)&&void 0!==t?t:"")}},[]);let eL=(0,Y.useCallback)(async e=>{let t=a.currentSession().mask.modelConfig.model;if((0,eH.Xf)(t)){for(let t of(e.clipboardData||window.clipboardData).items)if("file"===t.kind&&t.type.startsWith("image/")){e.preventDefault();let n=t.getAsFile();if(n){let e=[];e.push(...N),e.push(...await new Promise((e,t)=>{O(!0);let s=[];(0,ez.Ix)(n).then(t=>{s.push(t),O(!1),e(s)}).catch(e=>{O(!1),t(e)})}));let t=e.length;t>3&&e.splice(3,t-3),M(e)}}}},[N,a]);async function eI(){let e=[];e.push(...N),e.push(...await new Promise((e,t)=>{let n=document.createElement("input");n.type="file",n.accept="image/png, image/jpeg, image/webp, image/heic, image/heif",n.multiple=!0,n.onchange=n=>{O(!0);let s=n.target.files,a=[];for(let r=0;r<s.length;r++){let i=n.target.files[r];(0,ez.Ix)(i).then(t=>{a.push(t),(3===a.length||a.length===s.length)&&(O(!1),e(a))}).catch(e=>{O(!1),t(e)})}},n.click()}));let t=e.length;t>3&&e.splice(3,t-3),M(e)}let[eD,eK]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"o"===e.key.toLowerCase())e.preventDefault(),setTimeout(()=>{a.newSession(),S(e$.y$.Chat)},10);else if(e.shiftKey&&"escape"===e.key.toLowerCase()){var t;e.preventDefault(),null===(t=u.current)||void 0===t||t.focus()}else if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"Semicolon"===e.code){e.preventDefault();let t=document.querySelectorAll(".copy-code-button");t.length>0&&t[t.length-1].click()}else if((e.metaKey||e.ctrlKey)&&e.shiftKey&&"c"===e.key.toLowerCase()){e.preventDefault();let t=ej.filter(e=>"user"!==e.role).pop();if(t){let e=(0,eH.YK)(t);(0,eH.vQ)(e)}}else(e.metaKey||e.ctrlKey)&&"/"===e.key?(e.preventDefault(),eK(!0)):(e.metaKey||e.ctrlKey)&&e.shiftKey&&"backspace"===e.key.toLowerCase()&&(e.preventDefault(),a.updateTargetSession(r,e=>{e.clearContextIndex===e.messages.length?e.clearContextIndex=void 0:(e.clearContextIndex=e.messages.length,e.memoryPrompt="")}))};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[ej,a,S,r]);let[eR,eF]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("div",{className:eY().chat,children:[(0,X.jsxs)("div",{className:"window-header","data-tauri-drag-region":!0,children:[E&&(0,X.jsx)("div",{className:"window-actions",children:(0,X.jsx)("div",{className:"window-action-button",children:(0,X.jsx)(eX.h,{icon:(0,X.jsx)(er.Z,{}),bordered:!0,title:eG.ZP.Chat.Actions.ChatList,onClick:()=>S(e$.y$.Home)})})}),(0,X.jsxs)("div",{className:(0,tn.Z)("window-header-title",eY()["chat-body-title"]),children:[(0,X.jsx)("div",{className:(0,tn.Z)("window-header-main-title",eY()["chat-body-main-title"]),onClickCapture:()=>eA(!0),children:r.topic?r.topic:eB.HX}),(0,X.jsx)("div",{className:"window-header-sub-title",children:eG.ZP.Chat.SubTitle(r.messages.length)})]}),(0,X.jsxs)("div",{className:"window-actions",children:[(0,X.jsx)("div",{className:"window-action-button",children:(0,X.jsx)(eX.h,{icon:(0,X.jsx)(eg.Z,{}),bordered:!0,title:eG.ZP.Chat.Actions.RefreshTitle,onClick:()=>{(0,eQ.CF)(eG.ZP.Chat.Actions.RefreshToast),a.summarizeSession(!0,r)}})}),!E&&(0,X.jsx)("div",{className:"window-action-button",children:(0,X.jsx)(eX.h,{icon:(0,X.jsx)(es,{}),bordered:!0,title:eG.ZP.Chat.EditMessage.Title,aria:eG.ZP.Chat.EditMessage.Title,onClick:()=>eA(!0)})}),(0,X.jsx)("div",{className:"window-action-button",children:(0,X.jsx)(eX.h,{icon:(0,X.jsx)(ea.Z,{}),bordered:!0,title:eG.ZP.Chat.Actions.Export,onClick:()=>{d(!0)}})}),eZ&&(0,X.jsx)("div",{className:"window-action-button",children:(0,X.jsx)(eX.h,{icon:i.tightBorder?(0,X.jsx)(ep.Z,{}):(0,X.jsx)(em.Z,{}),bordered:!0,title:eG.ZP.Chat.Actions.FullScreen,aria:eG.ZP.Chat.Actions.FullScreen,onClick:()=>{i.update(e=>e.tightBorder=!e.tightBorder)}})})]}),(0,X.jsx)(tU,{showToast:!C,showModal:eS,setShowModal:eM})]}),(0,X.jsxs)("div",{className:eY()["chat-main"],children:[(0,X.jsxs)("div",{className:eY()["chat-body-container"],children:[(0,X.jsx)("div",{className:eY()["chat-body"],ref:x,onScroll:e=>eC(e.currentTarget),onMouseDown:()=>{var e;return null===(e=u.current)||void 0===e?void 0:e.blur()},onTouchStart:()=>{var e;null===(e=u.current)||void 0===e||e.blur(),k(!1)},children:ej.map((e,t)=>{var n,s,c;let d="user"===e.role,u=t<ec.length,h=t>0&&!(e.preview||0===e.content.length)&&!u,p=e.preview||e.streaming;return(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)("div",{className:d?eY()["chat-message-user"]:eY()["chat-message"],children:(0,X.jsxs)("div",{className:eY()["chat-message-container"],children:[(0,X.jsxs)("div",{className:eY()["chat-message-header"],children:[(0,X.jsxs)("div",{className:eY()["chat-message-avatar"],children:[(0,X.jsx)("div",{className:eY()["chat-message-edit"],children:(0,X.jsx)(eX.h,{icon:(0,X.jsx)(es,{}),aria:eG.ZP.Chat.Actions.Edit,onClick:async()=>{let t=await (0,eQ.G5)(eG.ZP.Chat.Actions.Edit,(0,eH.YK)(e),10),n=t,s=(0,eH.Bs)(e);if(s.length>0){n=[{type:"text",text:t}];for(let e=0;e<s.length;e++)n.push({type:"image_url",image_url:{url:s[e]}})}a.updateTargetSession(r,t=>{let s=t.mask.context.concat(t.messages).find(t=>t.id===e.id);s&&(s.content=n)})}})}),d?(0,X.jsx)(e0.qE,{avatar:i.avatar}):(0,X.jsx)(X.Fragment,{children:["system"].includes(e.role)?(0,X.jsx)(e0.qE,{avatar:"2699-fe0f"}):(0,X.jsx)(e1.MaskAvatar,{avatar:r.mask.avatar,model:e.model||r.mask.modelConfig.model})})]}),!d&&(0,X.jsx)("div",{className:eY()["chat-model-name"],children:e.model}),h&&(0,X.jsx)("div",{className:eY()["chat-message-actions"],children:(0,X.jsx)("div",{className:eY()["chat-input-actions"],children:e.streaming?(0,X.jsx)(tG,{text:eG.ZP.Chat.Actions.Stop,icon:(0,X.jsx)(eN.Z,{}),onClick:()=>{var n;return z(null!==(n=e.id)&&void 0!==n?n:t)}}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(tG,{text:eG.ZP.Chat.Actions.Retry,icon:(0,X.jsx)(eg.Z,{}),onClick:()=>V(e)}),(0,X.jsx)(tG,{text:eG.ZP.Chat.Actions.Delete,icon:(0,X.jsx)(ex.Z,{}),onClick:()=>{var n;return W(null!==(n=e.id)&&void 0!==n?n:t)}}),(0,X.jsx)(tG,{text:eG.ZP.Chat.Actions.Pin,icon:(0,X.jsx)(ey,{}),onClick:()=>G(e)}),(0,X.jsx)(tG,{text:eG.ZP.Chat.Actions.Copy,icon:(0,X.jsx)(ei.Z,{}),onClick:()=>(0,eH.vQ)((0,eH.YK)(e))}),i.ttsConfig.enable&&(0,X.jsx)(tG,{text:J?eG.ZP.Chat.Actions.StopSpeech:eG.ZP.Chat.Actions.Speech,icon:J?(0,X.jsx)(ed,{}):(0,X.jsx)(el,{}),onClick:()=>eo((0,eH.YK)(e))})]})})})]}),(null==e?void 0:null===(n=e.tools)||void 0===n?void 0:n.length)==0&&p&&(0,X.jsx)("div",{className:eY()["chat-message-status"],children:eG.ZP.Chat.Typing}),(null==e?void 0:null===(s=e.tools)||void 0===s?void 0:s.length)>0&&(0,X.jsx)("div",{className:eY()["chat-message-tools"],children:null==e?void 0:null===(c=e.tools)||void 0===c?void 0:c.map(e=>{var t;return(0,X.jsxs)("div",{title:null==e?void 0:e.errorMsg,className:eY()["chat-message-tool"],children:[!1===e.isError?(0,X.jsx)(e_.Z,{}):!0===e.isError?(0,X.jsx)(ek.Z,{}):(0,X.jsx)(eh.Z,{}),(0,X.jsx)("span",{children:null==e?void 0:null===(t=e.function)||void 0===t?void 0:t.name})]},e.id)})}),(0,X.jsxs)("div",{className:eY()["chat-message-item"],children:[(0,X.jsx)(tH,{content:(0,eH.YK)(e),loading:(e.preview||e.streaming)&&0===e.content.length&&!d,onDoubleClickCapture:()=>{E&&m((0,eH.YK)(e))},fontSize:o,fontFamily:l,parentRef:x,defaultShow:t>=ej.length-6},e.streaming?"loading":"done"),1==(0,eH.Bs)(e).length&&(0,X.jsx)("img",{className:eY()["chat-message-item-image"],src:(0,eH.Bs)(e)[0],alt:""}),(0,eH.Bs)(e).length>1&&(0,X.jsx)("div",{className:eY()["chat-message-item-images"],style:{"--image-count":(0,eH.Bs)(e).length},children:(0,eH.Bs)(e).map((e,t)=>(0,X.jsx)("img",{className:eY()["chat-message-item-image-multi"],src:e,alt:""},t))})]}),(null==e?void 0:e.audio_url)&&(0,X.jsx)("div",{className:eY()["chat-message-audio"],children:(0,X.jsx)("audio",{src:e.audio_url,controls:!0})}),(0,X.jsx)("div",{className:eY()["chat-message-action-date"],children:u?eG.ZP.Chat.IsContext:e.date.toLocaleString()})]})}),t===eE-1&&(0,X.jsx)(tV,{})]},e.id)})}),(0,X.jsxs)("div",{className:eY()["chat-input-panel"],children:[(0,X.jsx)(tW,{prompts:T,onPromptSelect:e=>{setTimeout(()=>{var t;A([]);let n=R.match(e.content);n.matched?(n.invoke(),m("")):m(e.content),null===(t=u.current)||void 0===t||t.focus()},30)}}),(0,X.jsx)(tX,{uploadImage:eI,setAttachImages:M,setUploading:O,showPromptModal:()=>eM(!0),scrollToBottom:eb,hitBottom:C,uploading:P,showPromptHints:()=>{var e;if(T.length>0){A([]);return}null===(e=u.current)||void 0===e||e.focus(),m("/"),L("")},setShowShortcutKeyModal:eK,setUserInput:m,setShowChatSidePanel:eF}),(0,X.jsxs)("label",{className:(0,tn.Z)(eY()["chat-input-panel-inner"],{[eY()["chat-input-panel-inner-attach"]]:0!==N.length}),htmlFor:"chat-input",children:[(0,X.jsx)("textarea",{id:"chat-input",ref:u,className:eY()["chat-input"],placeholder:eG.ZP.Chat.Input(f),onInput:e=>F(e.currentTarget.value),value:h,onKeyDown:e=>{if("ArrowUp"===e.key&&h.length<=0&&!(e.metaKey||e.altKey||e.ctrlKey)){var t;m(null!==(t=a.lastInput)&&void 0!==t?t:""),e.preventDefault();return}v(e)&&0===T.length&&(B(h),e.preventDefault())},onFocus:eb,onClick:eb,onPaste:eL,rows:I,autoFocus:eO,style:{fontSize:i.fontSize,fontFamily:i.fontFamily}}),0!=N.length&&(0,X.jsx)("div",{className:eY()["attach-images"],children:N.map((e,t)=>(0,X.jsx)("div",{className:eY()["attach-image"],style:{backgroundImage:'url("'.concat(e,'")')},children:(0,X.jsx)("div",{className:eY()["attach-image-mask"],children:(0,X.jsx)(tY,{deleteImage:()=>{M(N.filter((e,n)=>n!==t))}})})},t))}),(0,X.jsx)(eX.h,{icon:(0,X.jsx)($,{}),text:eG.ZP.Chat.Send,className:eY()["chat-input-send"],type:"primary",onClick:()=>B(h)})]})]})]}),(0,X.jsx)("div",{className:(0,tn.Z)(eY()["chat-side-panel"],{[eY().mobile]:E,[eY()["chat-side-panel-show"]]:eR}),children:eR&&(0,X.jsx)(tR,{onClose:()=>{eF(!1)},onStartVoice:async()=>{console.log("start voice")}})})]})]},r.id),c&&(0,X.jsx)(tc,{onClose:()=>d(!1)}),eT&&(0,X.jsx)(tq,{onClose:()=>{eA(!1)}}),eD&&(0,X.jsx)(tQ,{onClose:()=>eK(!1)})]})}function t$(){let e=(0,eB.aK)().currentSession();return(0,X.jsx)(tJ,{},e.id)}},79296:function(e){e.exports={"message-exporter-body":"exporter_message-exporter-body__ieezO","export-content":"exporter_export-content__bLZvx",steps:"exporter_steps__6n3hv","steps-progress":"exporter_steps-progress__BaZCB","steps-progress-inner":"exporter_steps-progress-inner__Bx3Y4","steps-inner":"exporter_steps-inner__EVqvK",step:"exporter_step__WhCEO","step-finished":"exporter_step-finished__eBg9d","step-current":"exporter_step-current__oh5Mc","step-index":"exporter_step-index__bWRYR","step-name":"exporter_step-name__aj81m","preview-actions":"exporter_preview-actions__EdSLJ","image-previewer":"exporter_image-previewer__uKfNQ","preview-body":"exporter_preview-body__qK5Zf","chat-info":"exporter_chat-info__N_j5m",icons:"exporter_icons__7WRoV",logo:"exporter_logo__zu13e","main-title":"exporter_main-title__jjxAd","sub-title":"exporter_sub-title__p1RCl","icon-space":"exporter_icon-space__u_tMK","chat-info-item":"exporter_chat-info-item__3D12j",message:"exporter_message__3aahS",avatar:"exporter_avatar__fGOtt",body:"exporter_body__gcKIl","message-image":"exporter_message-image__ofOeC","message-images":"exporter_message-images__oJoIX","message-image-multi":"exporter_message-image-multi__jzQdX","message-assistant":"exporter_message-assistant__sDmHi","message-user":"exporter_message-user__2t254"}},88809:function(e){e.exports={"message-selector":"message-selector_message-selector__dOKbo","message-filter":"message-selector_message-filter__Q5XSd","search-bar":"message-selector_search-bar__4E5gq",actions:"message-selector_actions__MyZCT",messages:"message-selector_messages__GbOLr",message:"message-selector_message___TaV9","message-selected":"message-selector_message-selected__b3mDv",avatar:"message-selector_avatar__HCJ8t",body:"message-selector_body__rKEIZ",date:"message-selector_date__vc48w",content:"message-selector_content__Z9W8L",checkbox:"message-selector_checkbox__erPyd"}},2366:function(e){e.exports={"realtime-chat":"realtime-chat_realtime-chat__g_U_c","circle-mic":"realtime-chat_circle-mic__SfmZp","icon-center":"realtime-chat_icon-center__3JpXN","bottom-icons":"realtime-chat_bottom-icons__siVHg","icon-left":"realtime-chat_icon-left__O_fpx","icon-right":"realtime-chat_icon-right__3eC9i",mobile:"realtime-chat_mobile__WtJW9",pulse:"realtime-chat_pulse__DSlz2"}},69927:function(e){e.exports={"voice-print":"voice-print_voice-print__GHMDU"}}}]);