orbitchat 3.11.3 → 3.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ChartRenderer-BudJnfK_.js → ChartRenderer-CxUwc7kf.js} +1 -1
- package/dist/assets/{MermaidRenderer-p3vwh2B_.js → MermaidRenderer-CB1V6Xwf.js} +4 -4
- package/dist/assets/{MusicRenderer-DdKoocev.js → MusicRenderer-BUg6MwVn.js} +1 -1
- package/dist/assets/{SVGRenderer-C9KoOQsQ.js → SVGRenderer-TccFnPNu.js} +1 -1
- package/dist/assets/{architectureDiagram-3BPJPVTR-SWK-Lxn9.js → architectureDiagram-3BPJPVTR-h9nFgzDn.js} +1 -1
- package/dist/assets/{blockDiagram-GPEHLZMM-DpLhWNQq.js → blockDiagram-GPEHLZMM-Bt3BVrKK.js} +1 -1
- package/dist/assets/{c4Diagram-AAUBKEIU-lYHABZTN.js → c4Diagram-AAUBKEIU-CF2oNkcl.js} +1 -1
- package/dist/assets/channel-QEqJ8uFU.js +1 -0
- package/dist/assets/{chunk-2J33WTMH-Cb2g1hrK.js → chunk-2J33WTMH-Dtn_Hgpb.js} +1 -1
- package/dist/assets/{chunk-4BX2VUAB-CvQChHQi.js → chunk-4BX2VUAB-BdMFcrV2.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-CdCUvunJ.js → chunk-55IACEB6-DhM3j2P2.js} +1 -1
- package/dist/assets/{chunk-727SXJPM-D5kvAfLB.js → chunk-727SXJPM-BFbi_M_J.js} +1 -1
- package/dist/assets/{chunk-AQP2D5EJ-d0tLjb4w.js → chunk-AQP2D5EJ-BiliSNEB.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-D8AXicSl.js → chunk-FMBD7UC4-CNm2gwn9.js} +1 -1
- package/dist/assets/{chunk-ND2GUHAM-CjW4JHCI.js → chunk-ND2GUHAM-KuCSZUpr.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-D04tHykX.js → chunk-QZHKN3VN-jj0QUT3O.js} +1 -1
- package/dist/assets/classDiagram-4FO5ZUOK-BLPqNsv6.js +1 -0
- package/dist/assets/classDiagram-v2-Q7XG4LA2-BLPqNsv6.js +1 -0
- package/dist/assets/{cose-bilkent-S5V4N54A-9L0LaKgm.js → cose-bilkent-S5V4N54A-B8rNoYBW.js} +1 -1
- package/dist/assets/{dagre-BM42HDAG-95mV6vlx.js → dagre-BM42HDAG-CqJZdTJC.js} +1 -1
- package/dist/assets/{diagram-2AECGRRQ-C2aFcfh5.js → diagram-2AECGRRQ-DgzZxsLr.js} +1 -1
- package/dist/assets/{diagram-5GNKFQAL-D6Dtn5Ka.js → diagram-5GNKFQAL-CQ0FGFGn.js} +1 -1
- package/dist/assets/{diagram-KO2AKTUF-BPceNmp7.js → diagram-KO2AKTUF-DLcB9N5t.js} +1 -1
- package/dist/assets/{diagram-LMA3HP47-CyqU3Rv1.js → diagram-LMA3HP47-BgkAkfRF.js} +1 -1
- package/dist/assets/{diagram-OG6HWLK6-D-o7LDrK.js → diagram-OG6HWLK6-BGsoBhjO.js} +1 -1
- package/dist/assets/{erDiagram-TEJ5UH35-BxxV8ame.js → erDiagram-TEJ5UH35-NDUTpr2B.js} +1 -1
- package/dist/assets/{flowDiagram-I6XJVG4X-1WC1NcFz.js → flowDiagram-I6XJVG4X-D6MrcnU5.js} +1 -1
- package/dist/assets/{ganttDiagram-6RSMTGT7-CimGC-C3.js → ganttDiagram-6RSMTGT7-a4nXbZbD.js} +1 -1
- package/dist/assets/{gitGraphDiagram-PVQCEYII-7IvX09Ig.js → gitGraphDiagram-PVQCEYII-Dy5jvGB5.js} +1 -1
- package/dist/assets/index-DHAuvIGU.js +363 -0
- package/dist/assets/index-Du9vzYoW.css +1 -0
- package/dist/assets/{infoDiagram-5YYISTIA-uj1Q4MRB.js → infoDiagram-5YYISTIA-CL2td3Ty.js} +1 -1
- package/dist/assets/{ishikawaDiagram-YF4QCWOH-CuiKwBvc.js → ishikawaDiagram-YF4QCWOH-CTAU41X1.js} +1 -1
- package/dist/assets/{journeyDiagram-JHISSGLW-C817Jhfk.js → journeyDiagram-JHISSGLW-uLHPZsfT.js} +1 -1
- package/dist/assets/{kanban-definition-UN3LZRKU-Cb7khtgz.js → kanban-definition-UN3LZRKU-CPUPhSBC.js} +1 -1
- package/dist/assets/locales-DqtY0sVQ.js +1 -0
- package/dist/assets/{mindmap-definition-RKZ34NQL-1PtisgXr.js → mindmap-definition-RKZ34NQL-CI4qzHzI.js} +1 -1
- package/dist/assets/{pieDiagram-4H26LBE5-DFLlLn0D.js → pieDiagram-4H26LBE5-DkR6EJ_2.js} +1 -1
- package/dist/assets/{quadrantDiagram-W4KKPZXB-DRgRSAMd.js → quadrantDiagram-W4KKPZXB-CITY12XS.js} +1 -1
- package/dist/assets/{requirementDiagram-4Y6WPE33-DKjhL1ll.js → requirementDiagram-4Y6WPE33-aoX2W31y.js} +1 -1
- package/dist/assets/{sankeyDiagram-5OEKKPKP-CyOURlCh.js → sankeyDiagram-5OEKKPKP-BbU2IY-u.js} +1 -1
- package/dist/assets/{sequenceDiagram-3UESZ5HK-C8fpEkaS.js → sequenceDiagram-3UESZ5HK-Dkvk4z8c.js} +1 -1
- package/dist/assets/{stateDiagram-AJRCARHV-DP38m8VK.js → stateDiagram-AJRCARHV-CTcT-0iJ.js} +1 -1
- package/dist/assets/{stateDiagram-v2-BHNVJYJU-ouwS5dFo.js → stateDiagram-v2-BHNVJYJU-DUw_qPA2.js} +1 -1
- package/dist/assets/{timeline-definition-PNZ67QCA-CbhbVB53.js → timeline-definition-PNZ67QCA-D3gSlyLg.js} +1 -1
- package/dist/assets/{vennDiagram-CIIHVFJN-DXDR-Fad.js → vennDiagram-CIIHVFJN-BihF_eF_.js} +1 -1
- package/dist/assets/{wardleyDiagram-YWT4CUSO-C4FJ7L21.js → wardleyDiagram-YWT4CUSO-BCOMNb7v.js} +1 -1
- package/dist/assets/{xychartDiagram-2RQKCTM6-BZiNr-U2.js → xychartDiagram-2RQKCTM6-DjojC0e6.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/sitemap.xml +12 -0
- package/package.json +1 -1
- package/dist/assets/channel-DxSGRPuD.js +0 -1
- package/dist/assets/classDiagram-4FO5ZUOK-BAkNpxtD.js +0 -1
- package/dist/assets/classDiagram-v2-Q7XG4LA2-BAkNpxtD.js +0 -1
- package/dist/assets/index-B13Vcmfx.css +0 -1
- package/dist/assets/index-DSukxG7C.js +0 -355
- package/dist/assets/locales-CFRMukAJ.js +0 -1
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidRenderer-CB1V6Xwf.js","assets/vendor-react-BbEy7z12.js","assets/vendor-syntax-INF7-xC_.js","assets/purify.es-D6gMnemd.js","assets/isPrototype-DezZrpQP.js","assets/graphExportUtils-DrqBjeAI.js","assets/SVGRenderer-TccFnPNu.js","assets/locales-DqtY0sVQ.js","assets/vendor-markdown-Cy_-N5ZX.js","assets/vendor-markdown-dRWncRqa.css","assets/vendor-auth-aD_bwYde.js","assets/ChartRenderer-CxUwc7kf.js","assets/band-CquvqAHh.js","assets/init-Dmth1JHB.js","assets/ordinal-DILIJJjt.js","assets/linear-BGneeY6s.js","assets/defaultLocale-DX6XiGOO.js","assets/time-DJ0lCX4i.js","assets/MusicRenderer-BUg6MwVn.js","assets/papaparse.min-D13ujVVP.js","assets/docx-preview-DehBmhog.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var So=Object.defineProperty;var jo=(t,e,r)=>e in t?So(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Xe=(t,e,r)=>jo(t,typeof e!="symbol"?e+"":e,r);import{r as g,j as n,a as Co,R as St,b as Ls,d as No}from"./vendor-react-BbEy7z12.js";import{z as Ao,p as Io,j as Lo,f as Eo,e as _o,a as To,d as Mo}from"./locales-DqtY0sVQ.js";import{M as Fo,r as Za,a as $o,b as Po}from"./vendor-markdown-Cy_-N5ZX.js";import{_ as jt,h as Ro,v as Do,a as Oo}from"./vendor-syntax-INF7-xC_.js";import{u as ka,a as va,b as Uo,P as zo,M as Bo,A as Ho}from"./vendor-auth-aD_bwYde.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))a(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&a(o)}).observe(document,{childList:!0,subtree:!0});function r(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function a(s){if(s.ep)return;s.ep=!0;const i=r(s);fetch(s.href,i)}})();const oi=g.createContext(void 0);function Qa({children:t}){const[e,r]=g.useState(()=>{const o=localStorage.getItem("chat-theme");if(o){const l=JSON.parse(o);return{mode:l.mode||"dark",highContrast:!!l.highContrast}}return{mode:"dark",highContrast:!1}}),[a,s]=g.useState(!1);g.useEffect(()=>{const o=()=>{let l=!1;e.mode==="dark"?l=!0:e.mode==="light"?l=!1:l=window.matchMedia("(prefers-color-scheme: dark)").matches,s(l);const c=document.documentElement;l?c.classList.add("dark"):c.classList.remove("dark"),e.highContrast?c.classList.add("high-contrast"):c.classList.remove("high-contrast"),c.classList.remove("text-sm","text-lg"),c.classList.add("text-base")};if(o(),e.mode==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)"),c=()=>{o()};return l.addEventListener("change",c),()=>l.removeEventListener("change",c)}},[e]),g.useEffect(()=>{localStorage.setItem("chat-theme",JSON.stringify(e))},[e]);const i=o=>{r(l=>({...l,...o}))};return n.jsx(oi.Provider,{value:{theme:e,updateTheme:i,isDark:a},children:t})}function rr(){const t=g.useContext(oi);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}const li=g.createContext(void 0),Gs={voiceEnabled:!1,soundEnabled:!1,autoSend:!1};function Vo({children:t}){const[e,r]=g.useState(()=>{const s=localStorage.getItem("chat-settings");if(s)try{const i=JSON.parse(s);return{...Gs,...i,voiceEnabled:!1}}catch{return Gs}return Gs});g.useEffect(()=>{localStorage.setItem("chat-settings",JSON.stringify(e))},[e]);const a=s=>{r(i=>({...i,...s}))};return n.jsx(li.Provider,{value:{settings:e,updateSettings:a},children:t})}function Es(){const t=g.useContext(li);if(!t)throw new Error("useSettings must be used within SettingsProvider");return t}const he=t=>typeof t=="string",Ir=()=>{let t,e;const r=new Promise((a,s)=>{t=a,e=s});return r.resolve=t,r.reject=e,r},en=t=>t==null?"":String(t),qo=(t,e,r)=>{t.forEach(a=>{e[a]&&(r[a]=e[a])})},Wo=/###/g,tn=t=>t&&t.includes("###")?t.replace(Wo,"."):t,rn=t=>!t||he(t),Tr=(t,e,r)=>{const a=he(e)?e.split("."):e;let s=0;for(;s<a.length-1;){if(rn(t))return{};const i=tn(a[s]);!t[i]&&r&&(t[i]=new r),Object.prototype.hasOwnProperty.call(t,i)?t=t[i]:t={},++s}return rn(t)?{}:{obj:t,k:tn(a[s])}},sn=(t,e,r)=>{const{obj:a,k:s}=Tr(t,e,Object);if(a!==void 0||e.length===1){a[s]=r;return}let i=e[e.length-1],o=e.slice(0,e.length-1),l=Tr(t,o,Object);for(;l.obj===void 0&&o.length;)i=`${o[o.length-1]}.${i}`,o=o.slice(0,o.length-1),l=Tr(t,o,Object),l!=null&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=r},Ko=(t,e,r,a)=>{const{obj:s,k:i}=Tr(t,e,Object);s[i]=s[i]||[],s[i].push(r)},ys=(t,e)=>{const{obj:r,k:a}=Tr(t,e);if(r&&Object.prototype.hasOwnProperty.call(r,a))return r[a]},Go=(t,e,r)=>{const a=ys(t,r);return a!==void 0?a:ys(e,r)},ci=(t,e,r)=>{for(const a in e)a!=="__proto__"&&a!=="constructor"&&(Object.prototype.hasOwnProperty.call(t,a)?he(t[a])||t[a]instanceof String||he(e[a])||e[a]instanceof String?r&&(t[a]=e[a]):ci(t[a],e[a],r):t[a]=e[a]);return t},It=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),Xo={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"},Yo=t=>he(t)?t.replace(/[&<>"'\/]/g,e=>Xo[e]):t;class Jo{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){const r=this.regExpMap.get(e);if(r!==void 0)return r;const a=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,a),this.regExpQueue.push(e),a}}const Zo=[" ",",","?","!",";"],Qo=new Jo(20),el=(t,e,r)=>{e=e||"",r=r||"";const a=Zo.filter(o=>!e.includes(o)&&!r.includes(o));if(a.length===0)return!0;const s=Qo.getRegExp(`(${a.map(o=>o==="?"?"\\?":o).join("|")})`);let i=!s.test(t);if(!i){const o=t.indexOf(r);o>0&&!s.test(t.substring(0,o))&&(i=!0)}return i},oa=(t,e,r=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const a=e.split(r);let s=t;for(let i=0;i<a.length;){if(!s||typeof s!="object")return;let o,l="";for(let c=i;c<a.length;++c)if(c!==i&&(l+=r),l+=a[c],o=s[l],o!==void 0){if(["string","number","boolean"].includes(typeof o)&&c<a.length-1)continue;i+=c-i+1;break}s=o}return s},Pr=t=>t==null?void 0:t.replace(/_/g,"-"),tl={type:"logger",log(t){this.output("log",t)},warn(t){this.output("warn",t)},error(t){this.output("error",t)},output(t,e){var r,a;(a=(r=console==null?void 0:console[t])==null?void 0:r.apply)==null||a.call(r,console,e)}};class ws{constructor(e,r={}){this.init(e,r)}init(e,r={}){this.prefix=r.prefix||"i18next:",this.logger=e||tl,this.options=r,this.debug=r.debug}log(...e){return this.forward(e,"log","",!0)}warn(...e){return this.forward(e,"warn","",!0)}error(...e){return this.forward(e,"error","")}deprecate(...e){return this.forward(e,"warn","WARNING DEPRECATED: ",!0)}forward(e,r,a,s){return s&&!this.debug?null:(e=e.map(i=>he(i)?i.replace(/[\r\n\x00-\x1F\x7F]/g," "):i),he(e[0])&&(e[0]=`${a}${this.prefix} ${e[0]}`),this.logger[r](e))}create(e){return new ws(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new ws(this.logger,e)}}var Ct=new ws;class _s{constructor(){this.observers={}}on(e,r){return e.split(" ").forEach(a=>{this.observers[a]||(this.observers[a]=new Map);const s=this.observers[a].get(r)||0;this.observers[a].set(r,s+1)}),this}off(e,r){if(this.observers[e]){if(!r){delete this.observers[e];return}this.observers[e].delete(r)}}once(e,r){const a=(...s)=>{r(...s),this.off(e,a)};return this.on(e,a),this}emit(e,...r){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([s,i])=>{for(let o=0;o<i;o++)s(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([s,i])=>{for(let o=0;o<i;o++)s(e,...r)})}}class an extends _s{constructor(e,r={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){const r=this.options.ns.indexOf(e);r>-1&&this.options.ns.splice(r,1)}getResource(e,r,a,s={}){var d,u;const i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,o=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;e.includes(".")?l=e.split("."):(l=[e,r],a&&(Array.isArray(a)?l.push(...a):he(a)&&i?l.push(...a.split(i)):l.push(a)));const c=ys(this.data,l);return!c&&!r&&!a&&e.includes(".")&&(e=l[0],r=l[1],a=l.slice(2).join(".")),c||!o||!he(a)?c:oa((u=(d=this.data)==null?void 0:d[e])==null?void 0:u[r],a,i)}addResource(e,r,a,s,i={silent:!1}){const o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator;let l=[e,r];a&&(l=l.concat(o?a.split(o):a)),e.includes(".")&&(l=e.split("."),s=r,r=l[1]),this.addNamespaces(r),sn(this.data,l,s),i.silent||this.emit("added",e,r,a,s)}addResources(e,r,a,s={silent:!1}){for(const i in a)(he(a[i])||Array.isArray(a[i]))&&this.addResource(e,r,i,a[i],{silent:!0});s.silent||this.emit("added",e,r,a)}addResourceBundle(e,r,a,s,i,o={silent:!1,skipCopy:!1}){let l=[e,r];e.includes(".")&&(l=e.split("."),s=a,a=r,r=l[1]),this.addNamespaces(r);let c=ys(this.data,l)||{};o.skipCopy||(a=JSON.parse(JSON.stringify(a))),s?ci(c,a,i):c={...c,...a},sn(this.data,l,c),o.silent||this.emit("added",e,r,a)}removeResourceBundle(e,r){this.hasResourceBundle(e,r)&&delete this.data[e][r],this.removeNamespaces(r),this.emit("removed",e,r)}hasResourceBundle(e,r){return this.getResource(e,r)!==void 0}getResourceBundle(e,r){return r||(r=this.options.defaultNS),this.getResource(e,r)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){const r=this.getDataByLanguage(e);return!!(r&&Object.keys(r)||[]).find(s=>r[s]&&Object.keys(r[s]).length>0)}toJSON(){return this.data}}var di={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,r,a,s){return t.forEach(i=>{var o;e=((o=this.processors[i])==null?void 0:o.process(e,r,a,s))??e}),e}};const ui=Symbol("i18next/PATH_KEY");function rl(){const t=[],e=Object.create(null);let r;return e.get=(a,s)=>{var i;return(i=r==null?void 0:r.revoke)==null||i.call(r),s===ui?t:(t.push(s),r=Proxy.revocable(a,e),r.proxy)},Proxy.revocable(Object.create(null),e).proxy}function dr(t,e){const{[ui]:r}=t(rl()),a=(e==null?void 0:e.keySeparator)??".",s=(e==null?void 0:e.nsSeparator)??":",i=(e==null?void 0:e.enableSelector)==="strict";if(r.length>1&&s){const o=e==null?void 0:e.ns,l=i?Array.isArray(o)?o:o?[o]:null:Array.isArray(o)?o:null;if(l&&(i?l:l.length>1?l.slice(1):[]).includes(r[0]))return`${r[0]}${s}${r.slice(1).join(a)}`}return r.join(a)}const Xs=t=>!he(t)&&typeof t!="boolean"&&typeof t!="number";class ks extends _s{constructor(e,r={}){super(),qo(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=r,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ct.create("translator"),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,r={interpolation:{}}){const a={...r};if(e==null)return!1;const s=this.resolve(e,a);if((s==null?void 0:s.res)===void 0)return!1;const i=Xs(s.res);return!(a.returnObjects===!1&&i)}extractFromKey(e,r){let a=r.nsSeparator!==void 0?r.nsSeparator:this.options.nsSeparator;a===void 0&&(a=":");const s=r.keySeparator!==void 0?r.keySeparator:this.options.keySeparator;let i=r.ns||this.options.defaultNS||[];const o=a&&e.includes(a),l=!this.options.userDefinedKeySeparator&&!r.keySeparator&&!this.options.userDefinedNsSeparator&&!r.nsSeparator&&!el(e,a,s);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:he(i)?[i]:i};const d=e.split(a);(a!==s||a===s&&this.options.ns.includes(d[0]))&&(i=d.shift()),e=d.join(s)}return{key:e,namespaces:he(i)?[i]:i}}translate(e,r,a){let s=typeof r=="object"?{...r}:r;if(typeof s!="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),typeof s=="object"&&(s={...s}),s||(s={}),e==null)return"";typeof e=="function"&&(e=dr(e,{...this.options,...s})),Array.isArray(e)||(e=[String(e)]),e=e.map(F=>typeof F=="function"?dr(F,{...this.options,...s}):String(F));const i=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],s),d=c[c.length-1];let u=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;u===void 0&&(u=":");const f=s.lng||this.language,m=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if((f==null?void 0:f.toLowerCase())==="cimode")return m?i?{res:`${d}${u}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:`${d}${u}${l}`:i?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:d,usedParams:this.getUsedParamsDetails(s)}:l;const h=this.resolve(e,s);let p=h==null?void 0:h.res;const x=(h==null?void 0:h.usedKey)||l,y=(h==null?void 0:h.exactUsedKey)||l,k=["[object Number]","[object Function]","[object RegExp]"],N=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,A=!this.i18nFormat||this.i18nFormat.handleAsObject,v=s.count!==void 0&&!he(s.count),C=ks.hasDefaultValue(s),E=v?this.pluralResolver.getSuffix(f,s.count,s):"",P=s.ordinal&&v?this.pluralResolver.getSuffix(f,s.count,{ordinal:!1}):"",b=v&&!s.ordinal&&s.count===0,_=b&&s[`defaultValue${this.options.pluralSeparator}zero`]||s[`defaultValue${E}`]||s[`defaultValue${P}`]||s.defaultValue;let S=p;A&&!p&&C&&(S=_);const I=Xs(S),M=Object.prototype.toString.apply(S);if(A&&S&&I&&!k.includes(M)&&!(he(N)&&Array.isArray(S))){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const F=this.options.returnedObjectHandler?this.options.returnedObjectHandler(x,S,{...s,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return i?(h.res=F,h.usedParams=this.getUsedParamsDetails(s),h):F}if(o){const F=Array.isArray(S),z=F?[]:{},j=F?y:x;for(const L in S)if(Object.prototype.hasOwnProperty.call(S,L)){const R=`${j}${o}${L}`;C&&!p?z[L]=this.translate(R,{...s,defaultValue:Xs(_)?_[L]:void 0,joinArrays:!1,ns:c}):z[L]=this.translate(R,{...s,joinArrays:!1,ns:c}),z[L]===R&&(z[L]=S[L])}p=z}}else if(A&&he(N)&&Array.isArray(p))p=p.join(N),p&&(p=this.extendTranslation(p,e,s,a));else{let F=!1,z=!1;!this.isValidLookup(p)&&C&&(F=!0,p=_),this.isValidLookup(p)||(z=!0,p=l);const L=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&z?void 0:p,R=C&&_!==p&&this.options.updateMissing;if(z||F||R){if(this.logger.log(R?"updateKey":"missingKey",f,d,v&&!R?`${l}${this.pluralResolver.getSuffix(f,s.count,s)}`:l,R?_:p),o){const H=this.resolve(l,{...s,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let T=[];const K=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&K&&K[0])for(let H=0;H<K.length;H++)T.push(K[H]);else this.options.saveMissingTo==="all"?T=this.languageUtils.toResolveHierarchy(s.lng||this.language):T.push(s.lng||this.language);const G=(H,Z,fe)=>{var te;const U=C&&fe!==p?fe:L;this.options.missingKeyHandler?this.options.missingKeyHandler(H,d,Z,U,R,s):(te=this.backendConnector)!=null&&te.saveMissing&&this.backendConnector.saveMissing(H,d,Z,U,R,s),this.emit("missingKey",H,d,Z,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?T.forEach(H=>{const Z=this.pluralResolver.getSuffixes(H,s);b&&s[`defaultValue${this.options.pluralSeparator}zero`]&&!Z.includes(`${this.options.pluralSeparator}zero`)&&Z.push(`${this.options.pluralSeparator}zero`),Z.forEach(fe=>{G([H],l+fe,s[`defaultValue${fe}`]||_)})}):G(T,l,_))}p=this.extendTranslation(p,e,s,h,a),z&&p===l&&this.options.appendNamespaceToMissingKey&&(p=`${d}${u}${l}`),(z||F)&&this.options.parseMissingKeyHandler&&(p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${d}${u}${l}`:l,F?p:void 0,s))}return i?(h.res=p,h.usedParams=this.getUsedParamsDetails(s),h):p}extendTranslation(e,r,a,s,i){var c,d;if((c=this.i18nFormat)!=null&&c.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...a},a.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!a.skipInterpolation){a.interpolation&&this.interpolator.init({...a,interpolation:{...this.options.interpolation,...a.interpolation}});const u=he(e)&&(((d=a==null?void 0:a.interpolation)==null?void 0:d.skipOnVariables)!==void 0?a.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(u){const h=e.match(this.interpolator.nestingRegexp);f=h&&h.length}let m=a.replace&&!he(a.replace)?a.replace:a;if(this.options.interpolation.defaultVariables&&(m={...this.options.interpolation.defaultVariables,...m}),e=this.interpolator.interpolate(e,m,a.lng||this.language||s.usedLng,a),u){const h=e.match(this.interpolator.nestingRegexp),p=h&&h.length;f<p&&(a.nest=!1)}!a.lng&&s&&s.res&&(a.lng=this.language||s.usedLng),a.nest!==!1&&(e=this.interpolator.nest(e,(...h)=>(i==null?void 0:i[0])===h[0]&&!a.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${r[0]}`),null):this.translate(...h,r),a)),a.interpolation&&this.interpolator.reset()}const o=a.postProcess||this.options.postProcess,l=he(o)?[o]:o;return e!=null&&(l!=null&&l.length)&&a.applyPostProcessor!==!1&&(e=di.handle(l,e,r,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(a)},...a}:a,this)),e}resolve(e,r={}){let a,s,i,o,l;return he(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(c=>typeof c=="function"?dr(c,{...this.options,...r}):c)),e.forEach(c=>{if(this.isValidLookup(a))return;const d=this.extractFromKey(c,r),u=d.key;s=u;let f=d.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const m=r.count!==void 0&&!he(r.count),h=m&&!r.ordinal&&r.count===0,p=r.context!==void 0&&(he(r.context)||typeof r.context=="number")&&r.context!=="",x=r.lngs?r.lngs:this.languageUtils.toResolveHierarchy(r.lng||this.language,r.fallbackLng);f.forEach(y=>{var k,N;this.isValidLookup(a)||(l=y,!this.checkedLoadedFor[`${x[0]}-${y}`]&&((k=this.utils)!=null&&k.hasLoadedNamespace)&&!((N=this.utils)!=null&&N.hasLoadedNamespace(l))&&(this.checkedLoadedFor[`${x[0]}-${y}`]=!0,this.logger.warn(`key "${s}" for languages "${x.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),x.forEach(A=>{var E;if(this.isValidLookup(a))return;o=A;const v=[u];if((E=this.i18nFormat)!=null&&E.addLookupKeys)this.i18nFormat.addLookupKeys(v,u,A,y,r);else{let P;m&&(P=this.pluralResolver.getSuffix(A,r.count,r));const b=`${this.options.pluralSeparator}zero`,_=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(m&&(r.ordinal&&P.startsWith(_)&&v.push(u+P.replace(_,this.options.pluralSeparator)),v.push(u+P),h&&v.push(u+b)),p){const S=`${u}${this.options.contextSeparator||"_"}${r.context}`;v.push(S),m&&(r.ordinal&&P.startsWith(_)&&v.push(S+P.replace(_,this.options.pluralSeparator)),v.push(S+P),h&&v.push(S+b))}}let C;for(;C=v.pop();)this.isValidLookup(a)||(i=C,a=this.getResource(A,y,C,r))}))})}),{res:a,usedKey:s,exactUsedKey:i,usedLng:o,usedNS:l}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e==="")}getResource(e,r,a,s={}){var i;return(i=this.i18nFormat)!=null&&i.getResource?this.i18nFormat.getResource(e,r,a,s):this.resourceStore.getResource(e,r,a,s)}getUsedParamsDetails(e={}){const r=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],a=e.replace&&!he(e.replace);let s=a?e.replace:e;if(a&&typeof e.count<"u"&&(s.count=e.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!a){s={...s};for(const i of r)delete s[i]}return s}static hasDefaultValue(e){const r="defaultValue";for(const a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&a.startsWith(r)&&e[a]!==void 0)return!0;return!1}}class nn{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ct.create("languageUtils")}getScriptPartFromCode(e){if(e=Pr(e),!e||!e.includes("-"))return null;const r=e.split("-");return r.length===2||(r.pop(),r[r.length-1].toLowerCase()==="x")?null:this.formatLanguageCode(r.join("-"))}getLanguagePartFromCode(e){if(e=Pr(e),!e||!e.includes("-"))return e;const r=e.split("-");return this.formatLanguageCode(r[0])}formatLanguageCode(e){if(he(e)&&e.includes("-")){let r;try{r=Intl.getCanonicalLocales(e)[0]}catch{}return r&&this.options.lowerCaseLng&&(r=r.toLowerCase()),r||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let r;return e.forEach(a=>{if(r)return;const s=this.formatLanguageCode(a);(!this.options.supportedLngs||this.isSupportedCode(s))&&(r=s)}),!r&&this.options.supportedLngs&&e.forEach(a=>{if(r)return;const s=this.getScriptPartFromCode(a);if(this.isSupportedCode(s))return r=s;const i=this.getLanguagePartFromCode(a);if(this.isSupportedCode(i))return r=i;r=this.options.supportedLngs.find(o=>o===i?!0:!o.includes("-")&&!i.includes("-")?!1:!!(o.includes("-")&&!i.includes("-")&&o.slice(0,o.indexOf("-"))===i||o.startsWith(i)&&i.length>1))}),r||(r=this.getFallbackCodes(this.options.fallbackLng)[0]),r}getFallbackCodes(e,r){if(!e)return[];if(typeof e=="function"&&(e=e(r)),he(e)&&(e=[e]),Array.isArray(e))return e;if(!r)return e.default||[];let a=e[r];return a||(a=e[this.getScriptPartFromCode(r)]),a||(a=e[this.formatLanguageCode(r)]),a||(a=e[this.getLanguagePartFromCode(r)]),a||(a=e.default),a||[]}toResolveHierarchy(e,r){const a=this.getFallbackCodes((r===!1?[]:r)||this.options.fallbackLng||[],e),s=[],i=o=>{o&&(this.isSupportedCode(o)?s.push(o):this.logger.warn(`rejecting language code not found in supportedLngs: ${o}`))};return he(e)&&(e.includes("-")||e.includes("_"))?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(e))):he(e)&&i(this.formatLanguageCode(e)),a.forEach(o=>{s.includes(o)||i(this.formatLanguageCode(o))}),s}}const on={zero:0,one:1,two:2,few:3,many:4,other:5},ln={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class sl{constructor(e,r={}){this.languageUtils=e,this.options=r,this.logger=Ct.create("pluralResolver"),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,r={}){const a=Pr(e==="dev"?"en":e),s=r.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:a,type:s});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let o;try{o=new Intl.PluralRules(a,{type:s})}catch{if(typeof Intl>"u")return this.logger.error("No Intl support, please use an Intl polyfill!"),ln;if(!e.match(/-|_/))return ln;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,r)}return this.pluralRulesCache[i]=o,o}needsPlural(e,r={}){let a=this.getRule(e,r);return a||(a=this.getRule("dev",r)),(a==null?void 0:a.resolvedOptions().pluralCategories.length)>1}getPluralFormsOfKey(e,r,a={}){return this.getSuffixes(e,a).map(s=>`${r}${s}`)}getSuffixes(e,r={}){let a=this.getRule(e,r);return a||(a=this.getRule("dev",r)),a?a.resolvedOptions().pluralCategories.sort((s,i)=>on[s]-on[i]).map(s=>`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${s}`):[]}getSuffix(e,r,a={}){const s=this.getRule(e,a);return s?`${this.options.prepend}${a.ordinal?`ordinal${this.options.prepend}`:""}${s.select(r)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",r,a))}}const cn=(t,e,r,a=".",s=!0)=>{let i=Go(t,e,r);return!i&&s&&he(r)&&(i=oa(t,r,a),i===void 0&&(i=oa(e,r,a))),i},Ys=t=>t.replace(/\$/g,"$$$$");class dn{constructor(e={}){var r;this.logger=Ct.create("interpolator"),this.options=e,this.format=((r=e==null?void 0:e.interpolation)==null?void 0:r.format)||(a=>a),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:r,escapeValue:a,useRawValueToEscape:s,prefix:i,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:d,unescapeSuffix:u,unescapePrefix:f,nestingPrefix:m,nestingPrefixEscaped:h,nestingSuffix:p,nestingSuffixEscaped:x,nestingOptionsSeparator:y,maxReplaces:k,alwaysFormat:N}=e.interpolation;this.escape=r!==void 0?r:Yo,this.escapeValue=a!==void 0?a:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?It(i):o||"{{",this.suffix=l?It(l):c||"}}",this.formatSeparator=d||",",this.unescapePrefix=u?"":f?It(f):"-",this.unescapeSuffix=this.unescapePrefix?"":u?It(u):"",this.nestingPrefix=m?It(m):h||It("$t("),this.nestingSuffix=p?It(p):x||It(")"),this.nestingOptionsSeparator=y||",",this.maxReplaces=k||1e3,this.alwaysFormat=N!==void 0?N:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const e=(r,a)=>(r==null?void 0:r.source)===a?(r.lastIndex=0,r):new RegExp(a,"g");this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,r,a,s){var h;let i,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=p=>{if(!p.includes(this.formatSeparator)){const N=cn(r,c,p,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(N,void 0,a,{...s,...r,interpolationkey:p}):N}const x=p.split(this.formatSeparator),y=x.shift().trim(),k=x.join(this.formatSeparator).trim();return this.format(cn(r,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),k,a,{...s,...r,interpolationkey:y})};this.resetRegExp(),!this.escapeValue&&typeof e=="string"&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn("nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.");const u=(s==null?void 0:s.missingInterpolationHandler)||this.options.missingInterpolationHandler,f=((h=s==null?void 0:s.interpolation)==null?void 0:h.skipOnVariables)!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:p=>Ys(p)},{regex:this.regexp,safeValue:p=>this.escapeValue?Ys(this.escape(p)):Ys(p)}].forEach(p=>{for(l=0;i=p.regex.exec(e);){const x=i[1].trim();if(o=d(x),o===void 0)if(typeof u=="function"){const k=u(e,i,s);o=he(k)?k:""}else if(s&&Object.prototype.hasOwnProperty.call(s,x))o="";else if(f){o=i[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!he(o)&&!this.useRawValueToEscape&&(o=en(o));const y=p.safeValue(o);if(e=e.replace(i[0],y),f?(p.regex.lastIndex+=o.length,p.regex.lastIndex-=i[0].length):p.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,r,a={}){let s,i,o;const l=(c,d)=>{const u=this.nestingOptionsSeparator;if(!c.includes(u))return c;const f=c.split(new RegExp(`${It(u)}[ ]*{`));let m=`{${f[1]}`;c=f[0],m=this.interpolate(m,o);const h=m.match(/'/g),p=m.match(/"/g);(((h==null?void 0:h.length)??0)%2===0&&!p||((p==null?void 0:p.length)??0)%2!==0)&&(m=m.replace(/'/g,'"'));try{o=JSON.parse(m),d&&(o={...d,...o})}catch(x){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,x),`${c}${u}${m}`}return o.defaultValue&&o.defaultValue.includes(this.prefix)&&delete o.defaultValue,c};for(;s=this.nestingRegexp.exec(e);){let c=[];o={...a},o=o.replace&&!he(o.replace)?o.replace:o,o.applyPostProcessor=!1,delete o.defaultValue;const d=/{.*}/.test(s[1])?s[1].lastIndexOf("}")+1:s[1].indexOf(this.formatSeparator);if(d!==-1&&(c=s[1].slice(d).split(this.formatSeparator).map(u=>u.trim()).filter(Boolean),s[1]=s[1].slice(0,d)),i=r(l.call(this,s[1].trim(),o),o),i&&s[0]===e&&!he(i))return i;he(i)||(i=en(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`),i=""),c.length&&(i=c.reduce((u,f)=>this.format(u,f,a.lng,{...a,interpolationkey:s[1].trim()}),i.trim())),e=e.replace(s[0],i),this.regexp.lastIndex=0}return e}}const al=t=>{let e=t.toLowerCase().trim();const r={};if(t.includes("(")){const a=t.split("(");e=a[0].toLowerCase().trim();const s=a[1].slice(0,-1);e==="currency"&&!s.includes(":")?r.currency||(r.currency=s.trim()):e==="relativetime"&&!s.includes(":")?r.range||(r.range=s.trim()):s.split(";").forEach(o=>{if(o){const[l,...c]=o.split(":"),d=c.join(":").trim().replace(/^'+|'+$/g,""),u=l.trim();r[u]||(r[u]=d),d==="false"&&(r[u]=!1),d==="true"&&(r[u]=!0),isNaN(d)||(r[u]=parseInt(d,10))}})}return{formatName:e,formatOptions:r}},un=t=>{const e={};return(r,a,s)=>{let i=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(i={...i,[s.interpolationkey]:void 0});const o=a+JSON.stringify(i);let l=e[o];return l||(l=t(Pr(a),s),e[o]=l),l(r)}},nl=t=>(e,r,a)=>t(Pr(r),a)(e);class il{constructor(e={}){this.logger=Ct.create("formatter"),this.options=e,this.init(e)}init(e,r={interpolation:{}}){this.formatSeparator=r.interpolation.formatSeparator||",";const a=r.cacheInBuiltFormats?un:nl;this.formats={number:a((s,i)=>{const o=new Intl.NumberFormat(s,{...i});return l=>o.format(l)}),currency:a((s,i)=>{const o=new Intl.NumberFormat(s,{...i,style:"currency"});return l=>o.format(l)}),datetime:a((s,i)=>{const o=new Intl.DateTimeFormat(s,{...i});return l=>o.format(l)}),relativetime:a((s,i)=>{const o=new Intl.RelativeTimeFormat(s,{...i});return l=>o.format(l,i.range||"day")}),list:a((s,i)=>{const o=new Intl.ListFormat(s,{...i});return l=>o.format(l)})}}add(e,r){this.formats[e.toLowerCase().trim()]=r}addCached(e,r){this.formats[e.toLowerCase().trim()]=un(r)}format(e,r,a,s={}){if(!r||e==null)return e;const i=r.split(this.formatSeparator),o=[];for(let c=0;c<i.length;c++){let d=i[c];for(;d.indexOf("(")>-1&&!d.includes(")")&&c+1<i.length;)d=`${d}${this.formatSeparator}${i[++c]}`;o.push(d)}return o.reduce((c,d)=>{var m;const{formatName:u,formatOptions:f}=al(d);if(this.formats[u]){let h=c;try{const p=((m=s==null?void 0:s.formatParams)==null?void 0:m[s.interpolationkey])||{},x=p.locale||p.lng||s.locale||s.lng||a;h=this.formats[u](c,x,{...f,...s,...p})}catch(p){this.logger.warn(p)}return h}else this.logger.warn(`there was no format function for ${u}`);return c},e)}}const ol=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class ll extends _s{constructor(e,r,a,s={}){var i,o;super(),this.backend=e,this.store=r,this.services=a,this.languageUtils=a.languageUtils,this.options=s,this.logger=Ct.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=s.maxParallelReads||10,this.readingCalls=0,this.maxRetries=s.maxRetries>=0?s.maxRetries:5,this.retryTimeout=s.retryTimeout>=1?s.retryTimeout:350,this.state={},this.queue=[],(o=(i=this.backend)==null?void 0:i.init)==null||o.call(i,a,s.backend,s)}queueLoad(e,r,a,s){const i={},o={},l={},c={};return e.forEach(d=>{let u=!0;r.forEach(f=>{const m=`${d}|${f}`;!a.reload&&this.store.hasResourceBundle(d,f)?this.state[m]=2:this.state[m]<0||(this.state[m]===1?o[m]===void 0&&(o[m]=!0):(this.state[m]=1,u=!1,o[m]===void 0&&(o[m]=!0),i[m]===void 0&&(i[m]=!0),c[f]===void 0&&(c[f]=!0)))}),u||(l[d]=!0)}),(Object.keys(i).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(i),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,r,a){const s=e.split("|"),i=s[0],o=s[1];r&&this.emit("failedLoading",i,o,r),!r&&a&&this.store.addResourceBundle(i,o,a,void 0,void 0,{skipCopy:!0}),this.state[e]=r?-1:2,r&&a&&(this.state[e]=0);const l={};this.queue.forEach(c=>{Ko(c.loaded,[i],o),ol(c,e),r&&c.errors.push(r),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(d=>{l[d]||(l[d]={});const u=c.loaded[d];u.length&&u.forEach(f=>{l[d][f]===void 0&&(l[d][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,r,a,s=0,i=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:r,fcName:a,tried:s,wait:i,callback:o});return}this.readingCalls++;const l=(d,u)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(d&&u&&s<this.maxRetries){setTimeout(()=>{this.read(e,r,a,s+1,i*2,o)},i);return}o(d,u)},c=this.backend[a].bind(this.backend);if(c.length===2){try{const d=c(e,r);d&&typeof d.then=="function"?d.then(u=>l(null,u)).catch(l):l(null,d)}catch(d){l(d)}return}return c(e,r,l)}prepareLoading(e,r,a={},s){if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();he(e)&&(e=this.languageUtils.toResolveHierarchy(e)),he(r)&&(r=[r]);const i=this.queueLoad(e,r,a,s);if(!i.toLoad.length)return i.pending.length||s(),null;i.toLoad.forEach(o=>{this.loadOne(o)})}load(e,r,a){this.prepareLoading(e,r,{},a)}reload(e,r,a){this.prepareLoading(e,r,{reload:!0},a)}loadOne(e,r=""){const a=e.split("|"),s=a[0],i=a[1];this.read(s,i,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${r}loading namespace ${i} for language ${s} failed`,o),!o&&l&&this.logger.log(`${r}loaded namespace ${i} for language ${s}`,l),this.loaded(e,o,l)})}saveMissing(e,r,a,s,i,o={},l=()=>{}){var c,d,u,f,m;if((d=(c=this.services)==null?void 0:c.utils)!=null&&d.hasLoadedNamespace&&!((f=(u=this.services)==null?void 0:u.utils)!=null&&f.hasLoadedNamespace(r))){this.logger.warn(`did not save key "${a}" as the namespace "${r}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(a==null||a==="")){if((m=this.backend)!=null&&m.create){const h={...o,isUpdate:i},p=this.backend.create.bind(this.backend);if(p.length<6)try{let x;p.length===5?x=p(e,r,a,s,h):x=p(e,r,a,s),x&&typeof x.then=="function"?x.then(y=>l(null,y)).catch(l):l(null,x)}catch(x){l(x)}else p(e,r,a,s,l,h)}!e||!e[0]||this.store.addResource(e[0],r,a,s)}}}const Js=()=>({debug:!1,initAsync:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:t=>{let e={};if(typeof t[1]=="object"&&(e=t[1]),he(t[1])&&(e.defaultValue=t[1]),he(t[2])&&(e.tDescription=t[2]),typeof t[2]=="object"||typeof t[3]=="object"){const r=t[3]||t[2];Object.keys(r).forEach(a=>{e[a]=r[a]})}return e},interpolation:{escapeValue:!0,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),fn=t=>(he(t.ns)&&(t.ns=[t.ns]),he(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),he(t.fallbackNS)&&(t.fallbackNS=[t.fallbackNS]),t.supportedLngs&&!t.supportedLngs.includes("cimode")&&(t.supportedLngs=t.supportedLngs.concat(["cimode"])),t),rs=()=>{},cl=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(r=>{typeof t[r]=="function"&&(t[r]=t[r].bind(t))})};class Mr extends _s{constructor(e={},r){if(super(),this.options=fn(e),this.services={},this.logger=Ct,this.modules={external:[]},cl(this),r&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,r),this;setTimeout(()=>{this.init(e,r)},0)}}init(e={},r){this.isInitializing=!0,typeof e=="function"&&(r=e,e={}),e.defaultNS==null&&e.ns&&(he(e.ns)?e.defaultNS=e.ns:e.ns.includes("translation")||(e.defaultNS=e.ns[0]));const a=Js();this.options={...a,...this.options,...fn(e)},this.options.interpolation={...a.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!="function"&&(this.options.overloadTranslationOptionHandler=a.overloadTranslationOptionHandler);const s=d=>d?typeof d=="function"?new d:d:null;if(!this.options.isClone){this.modules.logger?Ct.init(s(this.modules.logger),this.options):Ct.init(null,this.options);let d;this.modules.formatter?d=this.modules.formatter:d=il;const u=new nn(this.options);this.store=new an(this.options.resources,this.options);const f=this.services;f.logger=Ct,f.resourceStore=this.store,f.languageUtils=u,f.pluralResolver=new sl(u,{prepend:this.options.pluralSeparator}),d&&(f.formatter=s(d),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new dn(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new ll(s(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(m,...h)=>{this.emit(m,...h)}),this.modules.languageDetector&&(f.languageDetector=s(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=s(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new ks(this.services,this.options),this.translator.on("*",(m,...h)=>{this.emit(m,...h)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,r||(r=rs),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const d=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);d.length>0&&d[0]!=="dev"&&(this.options.lng=d[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(d=>{this[d]=(...u)=>this.store[d](...u)}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(d=>{this[d]=(...u)=>(this.store[d](...u),this)});const l=Ir(),c=()=>{const d=(u,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),r(u,f)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return d(null,this.t.bind(this));this.changeLanguage(this.options.lng,d)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,r=rs){var i,o;let a=r;const s=he(e)?e:this.language;if(typeof e=="function"&&(a=e),!this.options.resources||this.options.partialBundledLanguages){if((s==null?void 0:s.toLowerCase())==="cimode"&&(!this.options.preload||this.options.preload.length===0))return a();const l=[],c=d=>{if(!d||d==="cimode")return;this.services.languageUtils.toResolveHierarchy(d).forEach(f=>{f!=="cimode"&&(l.includes(f)||l.push(f))})};s?c(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>c(u)),(o=(i=this.options.preload)==null?void 0:i.forEach)==null||o.call(i,d=>c(d)),this.services.backendConnector.load(l,this.options.ns,d=>{!d&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),a(d)})}else a(null)}reloadResources(e,r,a){const s=Ir();return typeof e=="function"&&(a=e,e=void 0),typeof r=="function"&&(a=r,r=void 0),e||(e=this.languages),r||(r=this.options.ns),a||(a=rs),this.services.backendConnector.reload(e,r,i=>{s.resolve(),a(i)}),s}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&di.addPostProcessor(e),e.type==="formatter"&&(this.modules.formatter=e),e.type==="3rdParty"&&this.modules.external.push(e),this}setResolvedLanguage(e){if(!(!e||!this.languages)&&!["cimode","dev"].includes(e)){for(let r=0;r<this.languages.length;r++){const a=this.languages[r];if(!["cimode","dev"].includes(a)&&this.store.hasLanguageSomeTranslations(a)){this.resolvedLanguage=a;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,r){this.isLanguageChangingTo=e;const a=Ir();this.emit("languageChanging",e);const s=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},i=(l,c)=>{c?this.isLanguageChangingTo===e&&(s(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,a.resolve((...d)=>this.t(...d)),r&&r(l,(...d)=>this.t(...d))},o=l=>{var u,f;!e&&!l&&this.services.languageDetector&&(l=[]);const c=he(l)?l:l&&l[0],d=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(he(l)?[l]:l);d&&(this.language||s(d),this.translator.language||this.translator.changeLanguage(d),(f=(u=this.services.languageDetector)==null?void 0:u.cacheUserLanguage)==null||f.call(u,d)),this.loadResources(d,m=>{i(m,d)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),a}getFixedT(e,r,a,s){const i=s==null?void 0:s.scopeNs,o=(l,c,...d)=>{let u;typeof c!="object"?u=this.options.overloadTranslationOptionHandler([l,c].concat(d)):u={...c},u.lng=u.lng||o.lng,u.lngs=u.lngs||o.lngs;const f=u.ns!==void 0&&u.ns!==null;u.ns=u.ns||o.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||a||o.keyPrefix);const m={...this.options,...u};Array.isArray(i)&&!f&&(m.ns=i),typeof u.keyPrefix=="function"&&(u.keyPrefix=dr(u.keyPrefix,m));const h=this.options.keySeparator||".";let p;return u.keyPrefix&&Array.isArray(l)?p=l.map(x=>(typeof x=="function"&&(x=dr(x,m)),`${u.keyPrefix}${h}${x}`)):(typeof l=="function"&&(l=dr(l,m)),p=u.keyPrefix?`${u.keyPrefix}${h}${l}`:l),this.t(p,u)};return he(e)?o.lng=e:o.lngs=e,o.ns=r,o.keyPrefix=a,o}t(...e){var r;return(r=this.translator)==null?void 0:r.translate(...e)}exists(...e){var r;return(r=this.translator)==null?void 0:r.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,r={}){if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const a=r.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(a.toLowerCase()==="cimode")return!0;const o=(l,c)=>{const d=this.services.backendConnector.state[`${l}|${c}`];return d===-1||d===0||d===2};if(r.precheck){const l=r.precheck(this,o);if(l!==void 0)return l}return!!(this.hasResourceBundle(a,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||o(a,e)&&(!s||o(i,e)))}loadNamespaces(e,r){const a=Ir();return this.options.ns?(he(e)&&(e=[e]),e.forEach(s=>{this.options.ns.includes(s)||this.options.ns.push(s)}),this.loadResources(s=>{a.resolve(),r&&r(s)}),a):(r&&r(),Promise.resolve())}loadLanguages(e,r){const a=Ir();he(e)&&(e=[e]);const s=this.options.preload||[],i=e.filter(o=>!s.includes(o)&&this.services.languageUtils.isSupportedCode(o));return i.length?(this.options.preload=s.concat(i),this.loadResources(o=>{a.resolve(),r&&r(o)}),a):(r&&r(),Promise.resolve())}dir(e){var s,i;if(e||(e=this.resolvedLanguage||(((s=this.languages)==null?void 0:s.length)>0?this.languages[0]:this.language)),!e)return"rtl";try{const o=new Intl.Locale(e);if(o&&o.getTextInfo){const l=o.getTextInfo();if(l&&l.direction)return l.direction}}catch{}const r=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],a=((i=this.services)==null?void 0:i.languageUtils)||new nn(Js());return e.toLowerCase().indexOf("-latn")>1?"ltr":r.includes(a.getLanguagePartFromCode(e))||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}static createInstance(e={},r){const a=new Mr(e,r);return a.createInstance=Mr.createInstance,a}cloneInstance(e={},r=rs){const a=e.forkResourceStore;a&&delete e.forkResourceStore;const s={...this.options,...e,isClone:!0},i=new Mr(s);if((e.debug!==void 0||e.prefix!==void 0)&&(i.logger=i.logger.clone(e)),["store","services","language"].forEach(l=>{i[l]=this[l]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},a){const l=Object.keys(this.store.data).reduce((c,d)=>(c[d]={...this.store.data[d]},c[d]=Object.keys(c[d]).reduce((u,f)=>(u[f]={...c[d][f]},u),c[d]),c),{});i.store=new an(l,s),i.services.resourceStore=i.store}if(e.interpolation){const c={...Js().interpolation,...this.options.interpolation,...e.interpolation},d={...s,interpolation:c};i.services.interpolator=new dn(d)}return i.translator=new ks(i.services,s),i.translator.on("*",(l,...c)=>{i.emit(l,...c)}),i.init(s,r),i.translator.options=s,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const qe=Mr.createInstance();qe.createInstance;qe.dir;qe.init;qe.loadResources;qe.reloadResources;qe.use;qe.changeLanguage;qe.getFixedT;qe.t;qe.exists;qe.setDefaultNamespace;qe.hasLoadedNamespace;qe.loadNamespaces;qe.loadLanguages;const dl=(t,e,r,a)=>{var i,o,l,c;const s=[r,{code:e,...a||{}}];if((o=(i=t==null?void 0:t.services)==null?void 0:i.logger)!=null&&o.forward)return t.services.logger.forward(s,"warn","react-i18next::",!0);tr(s[0])&&(s[0]=`react-i18next:: ${s[0]}`),(c=(l=t==null?void 0:t.services)==null?void 0:l.logger)!=null&&c.warn?t.services.logger.warn(...s):console!=null&&console.warn&&console.warn(...s)},gn={},la=(t,e,r,a)=>{tr(r)&&gn[r]||(tr(r)&&(gn[r]=new Date),dl(t,e,r,a))},fi=(t,e)=>()=>{if(t.isInitialized)e();else{const r=()=>{setTimeout(()=>{t.off("initialized",r)},0),e()};t.on("initialized",r)}},ca=(t,e,r)=>{t.loadNamespaces(e,fi(t,r))},hn=(t,e,r,a)=>{if(tr(r)&&(r=[r]),t.options.preload&&t.options.preload.indexOf(e)>-1)return ca(t,r,a);r.forEach(s=>{t.options.ns.indexOf(s)<0&&t.options.ns.push(s)}),t.loadLanguages(e,fi(t,a))},ul=(t,e,r={})=>!e.languages||!e.languages.length?(la(e,"NO_LANGUAGES","i18n.languages were undefined or empty",{languages:e.languages}),!0):e.hasLoadedNamespace(t,{lng:r.lng,precheck:(a,s)=>{if(r.bindI18n&&r.bindI18n.indexOf("languageChanging")>-1&&a.services.backendConnector.backend&&a.isLanguageChangingTo&&!s(a.isLanguageChangingTo,t))return!1}}),tr=t=>typeof t=="string",fl=t=>typeof t=="object"&&t!==null,gl=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,hl={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},ml=t=>hl[t],pl=t=>t.replace(gl,ml);let da={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:pl,transDefaultProps:void 0};const xl=(t={})=>{da={...da,...t}},bl=()=>da;let gi;const yl=t=>{gi=t},wl=()=>gi,kl={type:"3rdParty",init(t){xl(t.options.react),yl(t)}},vl=g.createContext();class Sl{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(r=>{this.usedNamespaces[r]||(this.usedNamespaces[r]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var Zs={exports:{}},Qs={};/**
|
|
3
|
+
* @license React
|
|
4
|
+
* use-sync-external-store-shim.production.js
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/var mn;function jl(){if(mn)return Qs;mn=1;var t=Co();function e(f,m){return f===m&&(f!==0||1/f===1/m)||f!==f&&m!==m}var r=typeof Object.is=="function"?Object.is:e,a=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function l(f,m){var h=m(),p=a({inst:{value:h,getSnapshot:m}}),x=p[0].inst,y=p[1];return i(function(){x.value=h,x.getSnapshot=m,c(x)&&y({inst:x})},[f,h,m]),s(function(){return c(x)&&y({inst:x}),f(function(){c(x)&&y({inst:x})})},[f]),o(h),h}function c(f){var m=f.getSnapshot;f=f.value;try{var h=m();return!r(f,h)}catch{return!0}}function d(f,m){return m()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:l;return Qs.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Qs}var pn;function Cl(){return pn||(pn=1,Zs.exports=jl()),Zs.exports}var Nl=Cl();const Al=(t,e)=>{if(tr(e))return e;if(fl(e)&&tr(e.defaultValue))return e.defaultValue;if(typeof t=="function")return"";if(Array.isArray(t)){const r=t[t.length-1];return typeof r=="function"?"":r}return t},Il={t:Al,ready:!1},Ll=()=>()=>{},Le=(t,e={})=>{var _,S,I;const{i18n:r}=e,{i18n:a,defaultNS:s}=g.useContext(vl)||{},i=r||a||wl();i&&!i.reportNamespaces&&(i.reportNamespaces=new Sl),i||la(i,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=g.useMemo(()=>{var M;return{...bl(),...(M=i==null?void 0:i.options)==null?void 0:M.react,...e}},[i,e]),{useSuspense:l,keyPrefix:c}=o,d=s||((_=i==null?void 0:i.options)==null?void 0:_.defaultNS),u=tr(d)?[d]:d||["translation"],f=g.useMemo(()=>u,u);(I=(S=i==null?void 0:i.reportNamespaces)==null?void 0:S.addUsedNamespaces)==null||I.call(S,f);const m=g.useRef(0),h=g.useCallback(M=>{if(!i)return Ll;const{bindI18n:F,bindI18nStore:z}=o,j=()=>{m.current+=1,M()};return F&&i.on(F,j),z&&i.store.on(z,j),()=>{F&&F.split(" ").forEach(L=>i.off(L,j)),z&&z.split(" ").forEach(L=>i.store.off(L,j))}},[i,o]),p=g.useRef(),x=g.useCallback(()=>{if(!i)return Il;const M=!!(i.isInitialized||i.initializedStoreOnce)&&f.every(T=>ul(T,i,o)),F=e.lng||i.language,z=m.current,j=p.current;if(j&&j.ready===M&&j.lng===F&&j.keyPrefix===c&&j.revision===z)return j;const R={t:i.getFixedT(F,o.nsMode==="fallback"?f:f[0],c,{scopeNs:f}),ready:M,lng:F,keyPrefix:c,revision:z};return p.current=R,R},[i,f,c,o,e.lng]),[y,k]=g.useState(0),{t:N,ready:A}=Nl.useSyncExternalStore(h,x,x);g.useEffect(()=>{if(i&&!A&&!l){const M=()=>k(F=>F+1);e.lng?hn(i,e.lng,f,M):ca(i,f,M)}},[i,e.lng,f,A,l,y]);const v=i||{},C=g.useRef(null),E=g.useRef(),P=M=>{const F=Object.getOwnPropertyDescriptors(M);F.__original&&delete F.__original;const z=Object.create(Object.getPrototypeOf(M),F);if(!Object.prototype.hasOwnProperty.call(z,"__original"))try{Object.defineProperty(z,"__original",{value:M,writable:!1,enumerable:!1,configurable:!1})}catch{}return z},b=g.useMemo(()=>{const M=v,F=M==null?void 0:M.language;let z=M;M&&(C.current&&C.current.__original===M?E.current!==F?(z=P(M),C.current=z,E.current=F):z=C.current:(z=P(M),C.current=z,E.current=F));const j=!A&&!l?(...R)=>(la(i,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),N(...R)):N,L=[j,z,A];return L.t=j,L.i18n=z,L.ready=A,L},[N,v,A,v.resolvedLanguage,v.language,v.languages]);if(i&&l&&!A)throw new Promise(M=>{const F=()=>M();e.lng?hn(i,e.lng,f,F):ca(i,f,F)});return b},El={de:{translation:Mo},en:{translation:To},es:{translation:_o},fr:{translation:Eo},ja:{translation:Lo},pt:{translation:Io},zh:{translation:Ao}};qe.use(kl).init({resources:El,lng:"en",fallbackLng:"en",interpolation:{escapeValue:!1},returnNull:!1});var _l={agentMode:{mode:"single",defaultAdapterId:"dialoga"},application:{name:"Dialoga",description:`Dialoga is a Canadian AI chatbot built to help people work, learn, and create with Canadian AI models.
|
|
11
|
+
|
|
12
|
+
Ask questions, analyze documents, draft content, and explore ideas while keeping your data in Canada.
|
|
13
|
+
|
|
14
|
+
Dialoga is designed for users and organizations that want a ChatGPT-like experience with Canadian infrastructure, Canadian data residency, and AI capabilities developed for Canada's needs.
|
|
15
|
+
|
|
16
|
+
By using this tool, you agree to the [Terms of Service](https://schmitech.ai/en/dialoga-terms).
|
|
17
|
+
`,inputPlaceholder:"Ask Dialoga anything...",settingsAboutMsg:"Dialoga is a Canadian AI chatbot using Canadian models while keeping your data in Canada.",locale:"en-US",favicon:"favicon.svg"},i18n:{activeLanguages:["en","fr"],defaultLanguage:"en"},seo:{includeSitemap:!0,siteUrl:"http://localhost:5173",alternateSiteUrls:["https://dialoga.ca"],exposeAgentNotes:!0},debug:{consoleDebug:!1},features:{enableUpload:!0,enableAudioOutput:!1,enableAudioInput:!0,enableFeedbackButtons:!0,enableConversationThreads:!1,enableAutocomplete:!1},voice:{silenceTimeoutMs:4e3,recognitionLanguage:""},limits:{files:{perConversation:5,maxSizeMB:50,totalFiles:100},conversations:{maxConversations:10,messagesPerConversation:1e3,messagesPerThread:1e3,totalMessages:1e4},messages:{maxLength:1e4}},guestLimits:{files:{perConversation:1,maxSizeMB:5,totalFiles:1},conversations:{maxConversations:2,messagesPerConversation:5,messagesPerThread:2,totalMessages:10},messages:{maxLength:500},rateLimit:{enabled:!0,windowMs:6e4,maxRequests:60,chat:{windowMs:6e4,maxRequests:10}}},auth:{enabled:!1,provider:"auth0"},header:{enabled:!1,logoUrl:"",logoUrlLight:"dialoga-light.png",logoUrlDark:"dialoga-dark.png",logoHeight:"4.5rem",logoWidth:"auto",bgColor:"",textColor:"",showBorder:!1,navLinks:[{label:"ORBIT",url:"https://schmitech.ca/orbit"},{label:"Contact",url:"https://schmitech.ca/contact"},{label:"Privacy",url:"https://schmitech.ca/privacy-policy"},{label:"Terms",url:"https://schmitech.ca/en/dialoga-terms"}]},footer:{enabled:!0,text:"Copyright © 2026 Schmitech Inc.",bgColor:"",textColor:"",showBorder:!1,layout:"stacked",align:"center",topPadding:"large",navLinks:[{label:"ORBIT",url:"https://schmitech.ca/orbit"},{label:"Contact",url:"https://schmitech.ca/contact"},{label:"Privacy",url:"https://schmitech.ca/privacy-policy"},{label:"Terms",url:"https://schmitech.ca/en/dialoga-terms"}]},adapters:[{id:"dialoga",name:"Welcome to Dialoga! / Bienvenue sur Dialoga!",apiUrl:"http://99.79.50.155:3000",description:"Chat, write, code, and analyze files while keeping your data in Canada. / Discutez, rédigez, codez et analysez des fichiers tout en gardant vos données au Canada.",inputPlaceholder:"Ask anything / Posez vos questions"}]};const ua="http://localhost:3000",Tl="/favicon.svg",Ml="/orbit-logo-light.png",Fl="/orbit-logo-dark.png",$l={agentMode:{mode:"multi",defaultAdapterId:""},i18n:{activeLanguages:["en"],defaultLanguage:"en"},application:{name:"ORBIT Chat",description:"Explore ideas with ORBIT's AI copilots, share context, and build together.",inputPlaceholder:"Message ORBIT...",settingsAboutMsg:"ORBIT Chat",locale:"en-US",favicon:""},debug:{consoleDebug:!1},seo:{includeSitemap:!1,siteUrl:"",alternateSiteUrls:[],hostPatterns:[],exposeAgentNotes:!0},features:{enableUpload:!1,enableAudioOutput:!1,enableAudioInput:!1,enableFeedbackButtons:!1,enableConversationThreads:!0,enableAutocomplete:!1},voice:{silenceTimeoutMs:4e3,recognitionLanguage:""},outOfServiceMessage:null,limits:{files:{perConversation:5,maxSizeMB:50,totalFiles:100},conversations:{maxConversations:10,messagesPerConversation:1e3,messagesPerThread:1e3,totalMessages:1e4},messages:{maxLength:1e3}},guestLimits:{files:{perConversation:1,maxSizeMB:10,totalFiles:2},conversations:{maxConversations:1,messagesPerConversation:10,messagesPerThread:10,totalMessages:10},messages:{maxLength:500}},auth:{enabled:!1,provider:"auth0",domain:"",clientId:"",audience:"",tenantId:"",scopes:[]},header:{enabled:!1,logoUrl:"",logoUrlLight:"",logoUrlDark:"",logoHeight:"",logoWidth:"",bgColor:"",textColor:"",showBorder:!0,navLinks:[]},footer:{enabled:!1,text:"",bgColor:"",textColor:"",showBorder:!1,layout:"stacked",align:"center",topPadding:"large",navLinks:[]},startupScripts:[],adapters:[]};function ss(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function fa(t,e){if(!ss(t)||!ss(e))return e;const r={...t};return Object.keys(e).forEach(a=>{if(a==="__proto__"||a==="constructor"||a==="prototype")return;const s=r[a],i=e[a];ss(s)&&ss(i)?r[a]=fa(s,i):i!==void 0&&(r[a]=i)}),r}function Pl(t){if(typeof t!="string")return null;const e=t.trim();if(!e)return null;const r=e.toLowerCase();return r==="false"||r==="0"||r==="off"||r==="disabled"?null:e}function Rl(t){return t==="single"?"single":"multi"}function Dl(t){const e=t.trim();if(e.startsWith("["))try{const r=JSON.parse(e);return Array.isArray(r)?r.filter(Boolean):[]}catch{return[]}return e.split(/\s+/).filter(Boolean)}function Ol(){const t=_l||{},e=typeof window<"u"&&window.ORBIT_CHAT_CONFIG||{},r=!!(typeof window<"u"&&window.ORBIT_CHAT_CONFIG);let a=fa($l,t);return a=fa(a,e),(!r||!a.auth.domain)&&(a.auth.domain="dev-3c4dpzhecz4gundm.us.auth0.com"),(!r||!a.auth.clientId)&&(a.auth.clientId="9JSe5xtoi5mLXRuov2K7FHYU10ojCQLH"),!r||a.auth.audience,!r||a.auth.provider,!r||a.auth.tenantId,(!r||a.auth.scopes.length===0)&&(a.auth.scopes=Dl("openid profile email User.Read")),a.outOfServiceMessage=Pl(a.outOfServiceMessage),a.agentMode.mode=Rl(a.agentMode.mode),a.agentMode.defaultAdapterId=typeof a.agentMode.defaultAdapterId=="string"?a.agentMode.defaultAdapterId.trim():"",a}const J=Ol();function $e(){var e;const t=J.adapters;if(Array.isArray(t)&&t.length>0){const r=(e=t[0].apiUrl)==null?void 0:e.trim();if(r)return r}return ua}function it(t){const e=t==null?void 0:t.trim();return e&&e.length>0?e:$e()}function Ul(){const t=J.adapters;return Array.isArray(t)&&t.length>0?t[0].id:"default-key"}function zl(){return J.agentMode.mode}function Ts(){return zl()==="single"}function Sa(){if(!Ts())return null;const t=J.agentMode.defaultAdapterId;return t&&J.adapters.some(r=>{var a;return((a=r==null?void 0:r.id)==null?void 0:a.trim())===t})?t:null}function hi(){const t=Array.isArray(J.i18n.activeLanguages)?J.i18n.activeLanguages.filter(e=>typeof e=="string"):[];return t.length>0?t:["en"]}function Bl(){var e;const t=(e=J.i18n.defaultLanguage)==null?void 0:e.trim();return t&&hi().includes(t)?t:"en"}function ja(){return J.application.name}function Ca(){return J.application.description}function mi(){return J.application.inputPlaceholder}function Hl(t){var s;const e=t==null?void 0:t.trim();if(!e)return null;const r=J.adapters.find(i=>{var o;return((o=i==null?void 0:i.id)==null?void 0:o.trim())===e});return((s=r==null?void 0:r.name)==null?void 0:s.trim())||null}function Vl(t){var s;const e=t==null?void 0:t.trim();if(!e)return null;const r=J.adapters.find(i=>{var o;return((o=i==null?void 0:i.id)==null?void 0:o.trim())===e});return((s=r==null?void 0:r.inputPlaceholder)==null?void 0:s.trim())||null}function pi(){return J.seo.siteUrl.trim()}function ql(){return Array.isArray(J.seo.alternateSiteUrls)?J.seo.alternateSiteUrls.filter(t=>typeof t=="string").map(t=>t.trim()).filter(Boolean):[]}function Wl(){return Array.isArray(J.seo.hostPatterns)?J.seo.hostPatterns.filter(t=>typeof t=="string").map(t=>t.trim()).filter(Boolean):[]}function Kl(){return J.seo.exposeAgentNotes}function Gl(){var e;return((e=J.application.favicon)==null?void 0:e.trim())||Tl}function Xl(){return J.features.enableUpload}function Yl(){return J.features.enableAudioOutput}function Jl(){return J.features.enableAudioInput}function xn(){return J.features.enableFeedbackButtons}function Zl(){return J.features.enableConversationThreads}function xi(){return J.features.enableAutocomplete}function Ql(){return Math.max(1e3,J.voice.silenceTimeoutMs)}function ec(){return J.voice.recognitionLanguage}function tc(){const t=Sa();if(t)return t;const e=J.adapters;if(Array.isArray(e)&&e.length>0)for(const r of e){const a=typeof(r==null?void 0:r.id)=="string"?r.id.trim():"";if(a)return a}return null}function rc(){return J.outOfServiceMessage}function Na(){return J.auth.enabled}function rt(){const{enabled:t,provider:e,domain:r,clientId:a,tenantId:s}=J.auth;return!t||!a?!1:e==="entra"?!!s:!!r}function sc(){return J.auth.domain}function bi(){return J.auth.clientId}function ac(){return J.auth.audience}function Ms(){return J.auth.provider}function nc(){return J.auth.tenantId}function Aa(){const t=J.auth.scopes;return t.length>0?t:["openid","profile","email"]}function ga(){return J.header.enabled}function ic(){return J.header.logoUrl}function oc(){var e;return((e=J.header.logoUrlLight)==null?void 0:e.trim())||Ml}function lc(){var e;return((e=J.header.logoUrlDark)==null?void 0:e.trim())||Fl}function cc(){var t;return((t=J.header.logoHeight)==null?void 0:t.trim())||""}function dc(){var t;return((t=J.header.logoWidth)==null?void 0:t.trim())||""}function uc(){return J.header.bgColor}function fc(){return J.header.textColor}function gc(){return J.header.showBorder}function yi(t){if(Array.isArray(t))return t;if(typeof t=="string")try{const e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}return[]}function wi(){return yi(J.header.navLinks)}function ki(){return J.footer.enabled}function hc(){return J.footer.text}function mc(){return J.footer.bgColor}function pc(){return J.footer.textColor}function xc(){return J.footer.showBorder}function bc(){return J.footer.layout==="inline"?"inline":"stacked"}function yc(){return J.footer.topPadding==="normal"?"normal":"large"}function wc(){const t=J.startupScripts;return Array.isArray(t)?t.filter(e=>!!(e&&typeof e=="object")).map(e=>{const r=typeof e.src=="string"?e.src.trim():"",a=typeof e.content=="string"?e.content.trim():"",s=typeof e.id=="string"?e.id.trim():"";return{...e,src:r||void 0,content:a||void 0,id:s||void 0}}).filter(e=>!!(e.src||e.content)):[]}function kc(){return yi(J.footer.navLinks)}const vi=["de","en","es","fr","ja","pt","zh"],as={de:"Deutsch",en:"English",es:"Español",fr:"Français",ja:"日本語",pt:"Português",zh:"中文"};function ms(t){return vi.includes(t)}const Si=g.createContext(void 0),ji="orbit-chat-language";function vc(){const t=hi().filter(ms);return t.length>0?t:["en"]}function Sc(t){const e=localStorage.getItem(ji);if(e&&ms(e)&&t.includes(e))return e;const r=[...navigator.languages||[],navigator.language].filter(Boolean);for(const s of r){const i=s.split("-")[0].toLowerCase();if(ms(i)&&t.includes(i))return i}const a=Bl();return ms(a)&&t.includes(a)?a:t[0]??"en"}function jc({children:t}){const[e]=g.useState(()=>vc()),[r,a]=g.useState(()=>Sc(e));g.useEffect(()=>{qe.changeLanguage(r)},[r]),g.useEffect(()=>{localStorage.setItem(ji,r)},[r]);const s=i=>{vi.includes(i)&&a(i)};return n.jsx(Si.Provider,{value:{currentLanguage:r,activeLanguages:e,setLanguage:s},children:t})}function Cc(){const t=g.useContext(Si);if(!t)throw new Error("useLanguage must be used within LanguageProvider");return t}/**
|
|
18
|
+
* @license lucide-react v0.469.0 - ISC
|
|
19
|
+
*
|
|
20
|
+
* This source code is licensed under the ISC license.
|
|
21
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
22
|
+
*/const Nc=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Ci=(...t)=>t.filter((e,r,a)=>!!e&&e.trim()!==""&&a.indexOf(e)===r).join(" ").trim();/**
|
|
23
|
+
* @license lucide-react v0.469.0 - ISC
|
|
24
|
+
*
|
|
25
|
+
* This source code is licensed under the ISC license.
|
|
26
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
27
|
+
*/var Ac={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
28
|
+
* @license lucide-react v0.469.0 - ISC
|
|
29
|
+
*
|
|
30
|
+
* This source code is licensed under the ISC license.
|
|
31
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
32
|
+
*/const Ic=g.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:r=2,absoluteStrokeWidth:a,className:s="",children:i,iconNode:o,...l},c)=>g.createElement("svg",{ref:c,...Ac,width:e,height:e,stroke:t,strokeWidth:a?Number(r)*24/Number(e):r,className:Ci("lucide",s),...l},[...o.map(([d,u])=>g.createElement(d,u)),...Array.isArray(i)?i:[i]]));/**
|
|
33
|
+
* @license lucide-react v0.469.0 - ISC
|
|
34
|
+
*
|
|
35
|
+
* This source code is licensed under the ISC license.
|
|
36
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
37
|
+
*/const ne=(t,e)=>{const r=g.forwardRef(({className:a,...s},i)=>g.createElement(Ic,{ref:i,iconNode:e,className:Ci(`lucide-${Nc(t)}`,a),...s}));return r.displayName=`${t}`,r};/**
|
|
38
|
+
* @license lucide-react v0.469.0 - ISC
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the ISC license.
|
|
41
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/const ha=ne("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
|
|
43
|
+
* @license lucide-react v0.469.0 - ISC
|
|
44
|
+
*
|
|
45
|
+
* This source code is licensed under the ISC license.
|
|
46
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
47
|
+
*/const ur=ne("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
48
|
+
* @license lucide-react v0.469.0 - ISC
|
|
49
|
+
*
|
|
50
|
+
* This source code is licensed under the ISC license.
|
|
51
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
52
|
+
*/const gr=ne("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
53
|
+
* @license lucide-react v0.469.0 - ISC
|
|
54
|
+
*
|
|
55
|
+
* This source code is licensed under the ISC license.
|
|
56
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
57
|
+
*/const bn=ne("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
|
|
58
|
+
* @license lucide-react v0.469.0 - ISC
|
|
59
|
+
*
|
|
60
|
+
* This source code is licensed under the ISC license.
|
|
61
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
+
*/const vs=ne("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
|
|
63
|
+
* @license lucide-react v0.469.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/const ps=ne("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
|
|
68
|
+
* @license lucide-react v0.469.0 - ISC
|
|
69
|
+
*
|
|
70
|
+
* This source code is licensed under the ISC license.
|
|
71
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
+
*/const Lc=ne("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
73
|
+
* @license lucide-react v0.469.0 - ISC
|
|
74
|
+
*
|
|
75
|
+
* This source code is licensed under the ISC license.
|
|
76
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
+
*/const yn=ne("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
78
|
+
* @license lucide-react v0.469.0 - ISC
|
|
79
|
+
*
|
|
80
|
+
* This source code is licensed under the ISC license.
|
|
81
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
+
*/const wn=ne("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
83
|
+
* @license lucide-react v0.469.0 - ISC
|
|
84
|
+
*
|
|
85
|
+
* This source code is licensed under the ISC license.
|
|
86
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
+
*/const Fs=ne("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
88
|
+
* @license lucide-react v0.469.0 - ISC
|
|
89
|
+
*
|
|
90
|
+
* This source code is licensed under the ISC license.
|
|
91
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
+
*/const Ec=ne("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
|
|
93
|
+
* @license lucide-react v0.469.0 - ISC
|
|
94
|
+
*
|
|
95
|
+
* This source code is licensed under the ISC license.
|
|
96
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
+
*/const _c=ne("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/**
|
|
98
|
+
* @license lucide-react v0.469.0 - ISC
|
|
99
|
+
*
|
|
100
|
+
* This source code is licensed under the ISC license.
|
|
101
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
+
*/const Tc=ne("FileSpreadsheet",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]]);/**
|
|
103
|
+
* @license lucide-react v0.469.0 - ISC
|
|
104
|
+
*
|
|
105
|
+
* This source code is licensed under the ISC license.
|
|
106
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
107
|
+
*/const Mc=ne("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
|
|
108
|
+
* @license lucide-react v0.469.0 - ISC
|
|
109
|
+
*
|
|
110
|
+
* This source code is licensed under the ISC license.
|
|
111
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
112
|
+
*/const Fc=ne("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
|
113
|
+
* @license lucide-react v0.469.0 - ISC
|
|
114
|
+
*
|
|
115
|
+
* This source code is licensed under the ISC license.
|
|
116
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
117
|
+
*/const $c=ne("Image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);/**
|
|
118
|
+
* @license lucide-react v0.469.0 - ISC
|
|
119
|
+
*
|
|
120
|
+
* This source code is licensed under the ISC license.
|
|
121
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
122
|
+
*/const Pc=ne("Languages",[["path",{d:"m5 8 6 6",key:"1wu5hv"}],["path",{d:"m4 14 6-6 2-3",key:"1k1g8d"}],["path",{d:"M2 5h12",key:"or177f"}],["path",{d:"M7 2h1",key:"1t2jsx"}],["path",{d:"m22 22-5-10-5 10",key:"don7ne"}],["path",{d:"M14 18h6",key:"1m8k6r"}]]);/**
|
|
123
|
+
* @license lucide-react v0.469.0 - ISC
|
|
124
|
+
*
|
|
125
|
+
* This source code is licensed under the ISC license.
|
|
126
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
127
|
+
*/const xs=ne("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
128
|
+
* @license lucide-react v0.469.0 - ISC
|
|
129
|
+
*
|
|
130
|
+
* This source code is licensed under the ISC license.
|
|
131
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
132
|
+
*/const Ni=ne("LogIn",[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]]);/**
|
|
133
|
+
* @license lucide-react v0.469.0 - ISC
|
|
134
|
+
*
|
|
135
|
+
* This source code is licensed under the ISC license.
|
|
136
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
+
*/const Rc=ne("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
|
|
138
|
+
* @license lucide-react v0.469.0 - ISC
|
|
139
|
+
*
|
|
140
|
+
* This source code is licensed under the ISC license.
|
|
141
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
+
*/const Dc=ne("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
143
|
+
* @license lucide-react v0.469.0 - ISC
|
|
144
|
+
*
|
|
145
|
+
* This source code is licensed under the ISC license.
|
|
146
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
147
|
+
*/const Oc=ne("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
|
|
148
|
+
* @license lucide-react v0.469.0 - ISC
|
|
149
|
+
*
|
|
150
|
+
* This source code is licensed under the ISC license.
|
|
151
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
152
|
+
*/const kn=ne("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]);/**
|
|
153
|
+
* @license lucide-react v0.469.0 - ISC
|
|
154
|
+
*
|
|
155
|
+
* This source code is licensed under the ISC license.
|
|
156
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
157
|
+
*/const Uc=ne("MicOff",[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
|
|
158
|
+
* @license lucide-react v0.469.0 - ISC
|
|
159
|
+
*
|
|
160
|
+
* This source code is licensed under the ISC license.
|
|
161
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
162
|
+
*/const zc=ne("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
|
|
163
|
+
* @license lucide-react v0.469.0 - ISC
|
|
164
|
+
*
|
|
165
|
+
* This source code is licensed under the ISC license.
|
|
166
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
167
|
+
*/const Bc=ne("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
|
|
168
|
+
* @license lucide-react v0.469.0 - ISC
|
|
169
|
+
*
|
|
170
|
+
* This source code is licensed under the ISC license.
|
|
171
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
172
|
+
*/const Hc=ne("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
173
|
+
* @license lucide-react v0.469.0 - ISC
|
|
174
|
+
*
|
|
175
|
+
* This source code is licensed under the ISC license.
|
|
176
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
177
|
+
*/const Vc=ne("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
|
|
178
|
+
* @license lucide-react v0.469.0 - ISC
|
|
179
|
+
*
|
|
180
|
+
* This source code is licensed under the ISC license.
|
|
181
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
182
|
+
*/const qc=ne("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
|
|
183
|
+
* @license lucide-react v0.469.0 - ISC
|
|
184
|
+
*
|
|
185
|
+
* This source code is licensed under the ISC license.
|
|
186
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
187
|
+
*/const Wc=ne("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/**
|
|
188
|
+
* @license lucide-react v0.469.0 - ISC
|
|
189
|
+
*
|
|
190
|
+
* This source code is licensed under the ISC license.
|
|
191
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
192
|
+
*/const Kc=ne("Paperclip",[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]]);/**
|
|
193
|
+
* @license lucide-react v0.469.0 - ISC
|
|
194
|
+
*
|
|
195
|
+
* This source code is licensed under the ISC license.
|
|
196
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
197
|
+
*/const Gc=ne("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
|
|
198
|
+
* @license lucide-react v0.469.0 - ISC
|
|
199
|
+
*
|
|
200
|
+
* This source code is licensed under the ISC license.
|
|
201
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
202
|
+
*/const Ai=ne("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/**
|
|
203
|
+
* @license lucide-react v0.469.0 - ISC
|
|
204
|
+
*
|
|
205
|
+
* This source code is licensed under the ISC license.
|
|
206
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
207
|
+
*/const Xc=ne("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
|
|
208
|
+
* @license lucide-react v0.469.0 - ISC
|
|
209
|
+
*
|
|
210
|
+
* This source code is licensed under the ISC license.
|
|
211
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
212
|
+
*/const Yc=ne("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
213
|
+
* @license lucide-react v0.469.0 - ISC
|
|
214
|
+
*
|
|
215
|
+
* This source code is licensed under the ISC license.
|
|
216
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
217
|
+
*/const Jc=ne("Presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]);/**
|
|
218
|
+
* @license lucide-react v0.469.0 - ISC
|
|
219
|
+
*
|
|
220
|
+
* This source code is licensed under the ISC license.
|
|
221
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
222
|
+
*/const Zc=ne("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
|
|
223
|
+
* @license lucide-react v0.469.0 - ISC
|
|
224
|
+
*
|
|
225
|
+
* This source code is licensed under the ISC license.
|
|
226
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
227
|
+
*/const Qc=ne("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
|
|
228
|
+
* @license lucide-react v0.469.0 - ISC
|
|
229
|
+
*
|
|
230
|
+
* This source code is licensed under the ISC license.
|
|
231
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
232
|
+
*/const Ia=ne("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
233
|
+
* @license lucide-react v0.469.0 - ISC
|
|
234
|
+
*
|
|
235
|
+
* This source code is licensed under the ISC license.
|
|
236
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
237
|
+
*/const vn=ne("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
238
|
+
* @license lucide-react v0.469.0 - ISC
|
|
239
|
+
*
|
|
240
|
+
* This source code is licensed under the ISC license.
|
|
241
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
242
|
+
*/const La=ne("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
|
|
243
|
+
* @license lucide-react v0.469.0 - ISC
|
|
244
|
+
*
|
|
245
|
+
* This source code is licensed under the ISC license.
|
|
246
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
247
|
+
*/const ed=ne("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
248
|
+
* @license lucide-react v0.469.0 - ISC
|
|
249
|
+
*
|
|
250
|
+
* This source code is licensed under the ISC license.
|
|
251
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
252
|
+
*/const td=ne("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
|
|
253
|
+
* @license lucide-react v0.469.0 - ISC
|
|
254
|
+
*
|
|
255
|
+
* This source code is licensed under the ISC license.
|
|
256
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
257
|
+
*/const Ii=ne("ThumbsDown",[["path",{d:"M17 14V2",key:"8ymqnk"}],["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}]]);/**
|
|
258
|
+
* @license lucide-react v0.469.0 - ISC
|
|
259
|
+
*
|
|
260
|
+
* This source code is licensed under the ISC license.
|
|
261
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
262
|
+
*/const Li=ne("ThumbsUp",[["path",{d:"M7 10v12",key:"1qc93n"}],["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}]]);/**
|
|
263
|
+
* @license lucide-react v0.469.0 - ISC
|
|
264
|
+
*
|
|
265
|
+
* This source code is licensed under the ISC license.
|
|
266
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
267
|
+
*/const Ei=ne("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
268
|
+
* @license lucide-react v0.469.0 - ISC
|
|
269
|
+
*
|
|
270
|
+
* This source code is licensed under the ISC license.
|
|
271
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
272
|
+
*/const rd=ne("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]]);/**
|
|
273
|
+
* @license lucide-react v0.469.0 - ISC
|
|
274
|
+
*
|
|
275
|
+
* This source code is licensed under the ISC license.
|
|
276
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
277
|
+
*/const Ea=ne("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
|
|
278
|
+
* @license lucide-react v0.469.0 - ISC
|
|
279
|
+
*
|
|
280
|
+
* This source code is licensed under the ISC license.
|
|
281
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
282
|
+
*/const sd=ne("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
|
|
283
|
+
* @license lucide-react v0.469.0 - ISC
|
|
284
|
+
*
|
|
285
|
+
* This source code is licensed under the ISC license.
|
|
286
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
287
|
+
*/const _a=ne("Volume2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]);/**
|
|
288
|
+
* @license lucide-react v0.469.0 - ISC
|
|
289
|
+
*
|
|
290
|
+
* This source code is licensed under the ISC license.
|
|
291
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
292
|
+
*/const ad=ne("VolumeX",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["line",{x1:"22",x2:"16",y1:"9",y2:"15",key:"1ewh16"}],["line",{x1:"16",x2:"22",y1:"9",y2:"15",key:"5ykzw1"}]]);/**
|
|
293
|
+
* @license lucide-react v0.469.0 - ISC
|
|
294
|
+
*
|
|
295
|
+
* This source code is licensed under the ISC license.
|
|
296
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
297
|
+
*/const Ye=ne("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
|
|
298
|
+
* @license lucide-react v0.469.0 - ISC
|
|
299
|
+
*
|
|
300
|
+
* This source code is licensed under the ISC license.
|
|
301
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
302
|
+
*/const nd=ne("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);/**
|
|
303
|
+
* @license lucide-react v0.469.0 - ISC
|
|
304
|
+
*
|
|
305
|
+
* This source code is licensed under the ISC license.
|
|
306
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
307
|
+
*/const id=ne("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);function od(t){const e=t.trim().split(`
|
|
308
|
+
`);if(e.length<2)return!1;const r=e[0].trim();if(!r.startsWith("|")||(r.match(/\|/g)||[]).length<2)return!1;const a=e[1].trim();if(!a.startsWith("|")||!/^[\s|:|-]+$/.test(a)||!a.includes("-"))return!1;for(let s=2;s<e.length;s++){const i=e[s].trim();if(i!==""&&!i.startsWith("|"))return!1}return!0}function ld(t){return t.replace(/(^|\n)(```|~~~)\s*\n([\s\S]*?)\n\2(\n|$)/g,(e,r,a,s,i)=>od(s)?`${r}
|
|
309
|
+
${s.trim()}
|
|
310
|
+
${i}`:e)}function cd(t){const e={};let r=0;return t=t.replace(/\$\$([\s\S]*?)\$\$/g,(a,s)=>{const i=`__DISPLAY_MATH_${r++}__`;return e[i]=`$$${s}$$`,i}),t=t.replace(/\\\[([\s\S]*?)\\\]/g,(a,s)=>{const i=`__DISPLAY_MATH_${r++}__`;return e[i]=`$$${s}$$`,i}),t=t.replace(/\\\(([\s\S]*?)\\\)/g,(a,s)=>{const i=`__INLINE_MATH_${r++}__`;return e[i]=`$${s}$`,i}),t=t.replace(/(^|\n)(```|~~~)([^\n]*)\n([\s\S]*?)\n\2(\n|$)/g,(a,s,i,o,l,c)=>{const d=`__FENCED_CODE_${r++}__`;return e[d]=`${s}${i}${o}
|
|
311
|
+
${l}
|
|
312
|
+
${i}${c}`,d}),t=t.replace(/`([^`]+)`/g,a=>{const s=`__INLINE_CODE_${r++}__`;return e[s]=a,s}),{masked:t,masks:e}}function dd(t){const e={};let r=0;return t=t.replace(new RegExp("(?<!\\$)\\$(?!\\$)([^$\\n]+?)(?<!\\$)\\$(?!\\$)","g"),(a,s)=>{const i=s.trim();if(/^-?\d{1,3}(?:,\d{3})*(?:\.\d+)?(?:\s?[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion)?$/.test(i))return a;const l=`__INLINE_MATH_${r++}__`;return e[l]=`$${s}$`,l}),{masked:t,masks:e}}const Sn=/\\(?:iiint|iint|oint|int|sum|prod|lim|frac|sqrt|sin|cos|tan|sec|csc|cot|arcsin|arccos|arctan|ln|log|exp|Delta|nabla|partial)\b/;function ud(t){const e=/(__INLINE_MATH_\d+__|__DISPLAY_MATH_\d+__|__CURRENCY_\d+__)/g,r=/^(__INLINE_MATH_\d+__|__DISPLAY_MATH_\d+__|__CURRENCY_\d+__)$/;return t.split(`
|
|
313
|
+
`).map(a=>Sn.test(a)?a.split(e).map(s=>!s||r.test(s)||!Sn.test(s)||s.includes("$")?s:s.replace(/\\(?:iiint|iint|oint|int|sum|prod|lim|frac|sqrt|sin|cos|tan|sec|csc|cot|arcsin|arccos|arctan|ln|log|exp|Delta|nabla|partial)\b[^\n]*/g,i=>{const o=i.trimEnd();return o?`$${o}$${i.slice(o.length)}`:i})).join(""):a).join(`
|
|
314
|
+
`)}function fd(t){return t.replace(/\$([^$\n]*?)\s*=\s*\$([^$\n]+)\$\s*([^$\n]*?)\$/g,(e,r,a,s)=>{const i=String(r).trimEnd(),o=String(a).trim(),l=String(s).trim(),c=[o,l].filter(Boolean).join(" ");return`$${i} = ${c}$`})}function gd(t){const e=t.split(`
|
|
315
|
+
`);for(let a=0;a<e.length-1;a++){const s=e[a],i=e[a+1]??"";if(!s||!i)continue;const o=i.trim();if(!(o.startsWith("|")&&o.includes("-")))continue;const c=s.indexOf("|");if(c<=0)continue;const d=s.slice(0,c);if(!d||d.trim()==="")continue;const u=d.trim(),f=u.replace(/\s+/g,""),m=f!==""&&/^[>]+$/.test(f),h=/^[-*+]\s*$/.test(u),p=/^\d+\.\s*$/.test(u);if(m||h||p)continue;const x=s.slice(c);if((x.match(/\|/g)||[]).length<2)continue;const k=d.replace(/\s+$/,""),N=x.replace(/^\s+/,"");k&&(e.splice(a,1,k,N),a++)}const r=[];for(let a=0;a<e.length;a++){const s=e[a],i=s.trim(),l=(e[a+1]??"").trim();i.startsWith("|")&&(i.match(/\|/g)||[]).length>=2&&l.startsWith("|")&&/^[\s|:-]+$/.test(l)&&l.includes("-")&&r.length>0&&r[r.length-1].trim()!==""&&r.push(""),r.push(s)}return r.join(`
|
|
316
|
+
`)}const jn=["aligned","align","align*","array","cases","pmatrix","bmatrix","vmatrix","Vmatrix","matrix","smallmatrix","gather","gather*","multline","multline*","split","flalign","flalign*","eqnarray","equation","equation*"];function hd(t,e){let r=0,a=`__${e}_${r}__`;for(;Object.prototype.hasOwnProperty.call(t,a);)r++,a=`__${e}_${r}__`;return a}function md(t,e){if(!jn.length)return t;const r=jn.join("|"),a=new RegExp(String.raw`\\begin\{(${r})\}([\s\S]*?)\\end\{\1\}`,"g");return t.replace(a,(s,i,o,l,c)=>{const d=c.slice(0,l),u=c.slice(l+s.length),f=/(\$\$|\\\[)\s*$/.test(d),m=/^\s*(\$\$|\\\])/.test(u);if(f&&m)return s;const h=d.lastIndexOf("\\["),p=d.lastIndexOf("\\]");if(h>p&&h!==-1&&/\\]/.test(u))return s;const y=/\$\$/g;let k=0;for(;y.exec(d)!==null;)k++;if(k%2===1&&/\$\$/.test(u))return s;if((d.replace(/\$\$/g,"__DD__").replace(/\\\$/g,"__ES__").match(/\$/g)||[]).length%2===1){const S=u.replace(/\$\$/g,"__DD__").replace(/\\\$/g,"__ES__");if(/^[^$]*\$(?!\$)/.test(S))return s}const P=hd(e,"LATEX_ENV"),b=s.trim();return e[P]=`
|
|
317
|
+
$$
|
|
318
|
+
${b}
|
|
319
|
+
$$
|
|
320
|
+
`,P})}function pd(t,e){for(const[r,a]of Object.entries(e)){const s=new RegExp(r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");t=t.replace(s,()=>a)}return t}const xd=t=>{if(!t||typeof t!="string")return"";try{let e=t.replace(/\r\n/g,`
|
|
321
|
+
`).replace(/\r/g,`
|
|
322
|
+
`);e=ld(e);const{masked:r,masks:a}=cd(e);e=r,e=e.replace(/<br\s*\/?>/gi,`
|
|
323
|
+
`),e=e.replace(/\\(ne|neq)\$(?=\s*[-+0-9A-Za-z(])/g,"\\$1"),e=fd(e),e=gd(e),e=md(e,a);const s=new Map;let i=0;const o=String.raw`-?\$\(?\d{1,3}(?:,\d{3})*(?:\.\d+)?\)?(?:\s?(?:[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion))?|\$-?\d+(?:\.\d+)?(?:\s?(?:[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion))?`,l=new RegExp(String.raw`(${o})(\s?[–-]\s?)(${o})`,"g");e=e.replace(l,(m,h,p,x)=>{const y=`__CURRENCY_${i++}__`,k=`__CURRENCY_${i++}__`;return s.set(y,h),s.set(k,x),`${y}${p}${k}`});const c=new RegExp(String.raw`-?\$\(?\d{1,3}(?:,\d{3})*(?:\.\d+)?\)?(?:\s?(?:[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion))?(?!\w)|\$-?\d+(?:\.\d+)?(?:\s?(?:[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion))?(?!\w)`,"g");e=e.replace(c,(m,h,p)=>{if(p.substring(h+m.length).match(/^[a-zA-Z]/)&&!m.match(/[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion$/))return m;const y=`__CURRENCY_${i++}__`;return s.set(y,m),y});const{masked:d,masks:u}=dd(e);return e=d,Object.assign(a,u),e=ud(e),[/(?:^|\s)([a-zA-Z0-9]+\s*[\^_]\s*[a-zA-Z0-9{}]+(?:\s*[+\-*/]\s*[a-zA-Z0-9]+\s*[\^_]\s*[a-zA-Z0-9{}]+)*\s*=\s*[^$\n]+)(?:\s|$)/g,/(?:^|\s)(\\frac\{[^}]+\}\{[^}]+\})(?:\s|$)/g,/(?:^|\s)(\\(?:sqrt|int|sum|prod|lim|log|ln|sin|cos|tan|exp)\b[^$\n]{0,50})(?:\s|$)/g,/(?:^|\s)([A-Z][a-z]?(?:\d+)?(?:\([A-Z][a-z]?(?:\d+)?\))?(?:\d+)?(?:[+-]\d*)?)+(?:\s|$)/g].forEach(m=>{e=e.replace(m,(h,p)=>{if(h.includes("$")||h.includes("__INLINE_MATH_")||h.includes("__DISPLAY_MATH_")||h.includes("__CURRENCY_"))return h;const x=String(p??"").trim();if(/^[A-Za-z]$/.test(x))return h;const y=/[\\^_+=<>]|\\b(?:frac|sqrt|sum|int|lim|log|ln|sin|cos|tan|exp)\b/.test(x),k=/\d/.test(x),N=/[()]/.test(x),A=(x.match(/[A-Z]/g)||[]).length,v=(x.match(/[a-z]/g)||[]).length,C=A>=2,E=k||N||C&&v>0;return!y&&!E?h:h.replace(p,`$${p}$`)})}),e=e.replace(new RegExp("(?<!\\\\)\\$(?!\\$)([^$\\n]*?)(?<!\\\\)\\$(?!\\$)","g"),(m,h)=>{if(m.includes("__CURRENCY_")||m.includes("__INLINE_MATH_")||m.includes("__DISPLAY_MATH_")||h.trim()==="")return m;const p=/^\d+(?:,\d{3})*(?:\.\d{2})?$/.test(h.trim()),x=/\\/.test(h),y=/[+\-*/=<>^_{}()]/.test(h),k=/[a-zA-Z].*\d|\d.*[a-zA-Z]/.test(h),N=/\\(?:alpha|beta|gamma|delta|epsilon|theta|lambda|mu|pi|sigma|omega)/.test(h),A=/\\(?:frac|sqrt|sum|int|lim|log|ln|sin|cos|tan|exp)/.test(h),v=/^[A-Za-z]$/.test(h.trim());return!p&&(x||y||k||N||A||v||h.length>1)?m:`\\$${h}\\$`}),e=e.split(`
|
|
324
|
+
`).map(m=>{const h=m.indexOf("$$");return h===-1||m.trim()==="$$"||m.indexOf("$$",h+2)!==-1?m:m.replace("$$","\\$\\$")}).join(`
|
|
325
|
+
`),s.forEach((m,h)=>{const p=m.replace(/\$/g,"$");e=e.replace(new RegExp(h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),p)}),e=e.replace(/\\$/g,"$"),e=pd(e,a),e=e.trimEnd()+`
|
|
326
|
+
`,e}catch(e){return console.warn("Error preprocessing markdown:",e),t}},bd=g.lazy(()=>jt(()=>import("./MermaidRenderer-CB1V6Xwf.js").then(t=>t.au),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.MermaidRenderer}))),yd=g.lazy(()=>jt(()=>import("./SVGRenderer-TccFnPNu.js"),__vite__mapDeps([6,1,3,5,7,8,9,2,10])).then(t=>({default:t.SVGRenderer}))),wd=g.lazy(()=>jt(()=>import("./ChartRenderer-CxUwc7kf.js"),__vite__mapDeps([11,1,5,4,12,13,14,15,16,17,7,8,9,2,10])).then(t=>({default:t.ChartRenderer}))),kd=g.lazy(()=>jt(()=>import("./MusicRenderer-BUg6MwVn.js"),__vite__mapDeps([18,2,1,5,7,8,9,10])).then(t=>({default:t.MusicRenderer}))),vd=t=>{var a,s;if(!t)return typeof window<"u"&&((a=window.matchMedia)!=null&&a.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light";const e=t.closest(".markdown-content");if(e){if(e.classList.contains("dark"))return"dark";if(e.classList.contains("light"))return"light"}if(t.closest(".dark"))return"dark";if(t.closest(".light"))return"light";const r=t.closest("[data-theme]");if(r){const i=r.getAttribute("data-theme");if(i==="dark")return"dark";if(i==="light")return"light"}return typeof window<"u"&&((s=window.matchMedia)!=null&&s.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},Sd=(t,e)=>{const[r,a]=g.useState("light"),s=g.useRef("light");return g.useEffect(()=>{var d,u,f;if(e||typeof window>"u"||typeof document>"u")return;const i=()=>{const m=vd(t.current);m!==s.current&&(s.current=m,a(m))};i();const o=((d=window.matchMedia)==null?void 0:d.call(window,"(prefers-color-scheme: dark)"))??null,l=()=>i();o==null||o.addEventListener("change",l);const c=typeof MutationObserver<"u"?new MutationObserver(()=>i()):null;if(c){const m=((f=(u=t.current)==null?void 0:u.closest)==null?void 0:f.call(u,".markdown-content"))??null;m&&c.observe(m,{attributes:!0,attributeFilter:["class","data-theme"]}),document.body&&c.observe(document.body,{attributes:!0,attributeFilter:["class","data-theme"]})}return()=>{o==null||o.removeEventListener("change",l),c==null||c.disconnect()}},[e,t]),e??r},jd={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"tsx",sh:"bash",shell:"bash",shellsession:"bash",yml:"yaml",yaml:"yaml",py:"python",rb:"ruby",kt:"kotlin",md:"markdown",csharp:"csharp","c#":"csharp","c++":"cpp",tf:"hcl",terraform:"hcl",docker:"dockerfile",dotenv:"env",env:"env",plaintext:"text",text:"text"},Cd=t=>{if(!t)return"";const e=t.match(/(?:^|\s)language-([^\s]+)/);if(!e)return"";const a=e[1].toLowerCase().split("{")[0].split("[")[0].split("<")[0].split(":")[0].trim().replace(/[^a-z0-9+#-]+$/g,"");return a?jd[a]??a:""},Nd=t=>St.Children.toArray(t).map(e=>typeof e=="string"||typeof e=="number"?String(e):"").join("").replace(/\n$/,""),Cn=({code:t})=>{const{t:e}=Le(),[r,a]=g.useState(!1),s=async()=>{try{await navigator.clipboard.writeText(t),a(!0),setTimeout(()=>a(!1),2e3)}catch{const i=document.createElement("textarea");i.value=t,i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select();try{document.execCommand("copy"),a(!0),setTimeout(()=>a(!1),2e3)}catch(o){console.error("Failed to copy code:",o)}document.body.removeChild(i)}};return n.jsxs("button",{className:"code-copy-button",onClick:s,title:e(r?"markdown.codeBlock.copied":"markdown.codeBlock.copyTitle"),"aria-label":e(r?"markdown.codeBlock.copied":"markdown.codeBlock.copyAriaLabel"),children:[r?n.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):n.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M5.5 4.5H3.5C2.94772 4.5 2.5 4.94772 2.5 5.5V12.5C2.5 13.0523 2.94772 13.5 3.5 13.5H10.5C11.0523 13.5 11.5 13.0523 11.5 12.5V10.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M6.5 2.5H12.5C13.0523 2.5 13.5 2.94772 13.5 3.5V9.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M9.5 6.5L13.5 2.5L9.5 2.5V6.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),n.jsx("span",{className:"code-copy-button-text",children:e(r?"markdown.codeBlock.copied":"markdown.codeBlock.copyLabel")})]})},Ad=({inline:t,className:e="",children:r,enableGraphs:a=!0,enableMermaid:s=!0,enableSVG:i=!0,enableCharts:o=!0,enableMusic:l=!0,enableSyntaxHighlighting:c=!0,syntaxTheme:d})=>{const{t:u}=Le(),f=g.useRef(null),m=Sd(f,d),h=n.jsx("div",{className:"markdown-code-block code-block-container",children:u("markdown.codeBlock.loadingRenderer")});if(t)return n.jsx("code",{className:e,children:r});const p=Cd(e),x=Nd(r);if(o&&(p==="chart"||p==="chart-json"||p==="chart-table"))return n.jsx("div",{ref:f,children:n.jsx(g.Suspense,{fallback:h,children:n.jsx(wd,{code:x,language:p})})});if(l&&(p==="abc"||p==="music"))return n.jsx("div",{ref:f,children:n.jsx(g.Suspense,{fallback:h,children:n.jsx(kd,{code:x})})});if(a){if(p==="mermaid"&&s)return n.jsx("div",{ref:f,children:n.jsx(g.Suspense,{fallback:h,children:n.jsx(bd,{code:x})})});if(p==="svg"&&i)return n.jsx("div",{ref:f,children:n.jsx(g.Suspense,{fallback:h,children:n.jsx(yd,{code:x})})})}if(c&&p){const y=m==="light"?Do:Oo;return n.jsxs("div",{ref:f,className:"syntax-highlighted-wrapper code-block-container",children:[n.jsx(Cn,{code:x}),n.jsx(Ro,{language:p,style:y,customStyle:{margin:"12px 0",borderRadius:"6px",fontSize:"0.9em"},showLineNumbers:!1,children:x})]})}return n.jsxs("div",{ref:f,className:`markdown-code-block code-block-container ${e}`.trim(),children:[n.jsx(Cn,{code:x}),n.jsx("pre",{style:{margin:0,padding:0,background:"transparent",border:"none"},children:n.jsx("code",{children:x})})]})},Nn=new Set(["div","pre","blockquote","ul","ol","table","thead","tbody","tr","td","th","h1","h2","h3","h4","h5","h6","section","article","figure"]),Id=({children:t,href:e="",className:r="",...a})=>{const s=St.Children.toArray(t).map(u=>typeof u=="string"?u:"").join("").trim(),i=/^https?:\/\//i.test(e),o=!!(i&&s&&An(s)===An(e)),l=i?Ld(e):null,c=!!(o&&l),d=["markdown-link",c?"markdown-link--card":"markdown-link--inline",r].filter(Boolean).join(" ");return n.jsxs("a",{...a,href:e,target:"_blank",rel:"noopener noreferrer",className:d,children:[n.jsx("span",{className:"markdown-link__content",children:c&&l?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"markdown-link__hostname",children:l.hostname}),l.path&&l.path!=="/"&&n.jsx("span",{className:"markdown-link__path",children:l.path})]}):t}),i&&n.jsx("span",{className:"markdown-link__icon","aria-hidden":"true",children:n.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("path",{d:"M8 16L16 8M16 8H9M16 8V15",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})};function An(t){return t.trim().replace(/\/$/,"")}function Ld(t){try{const e=new URL(t),r=e.hostname.replace(/^www\./i,""),a=`${e.pathname}${e.search}${e.hash}`||"/";return{hostname:r,path:a}}catch{return null}}const Et=({content:t,className:e="",disableMath:r=!1,enableGraphs:a=!0,enableMermaid:s=!0,enableSVG:i=!0,enableCharts:o=!0,enableMusic:l=!0,enableSyntaxHighlighting:c=!0,syntaxTheme:d="dark"})=>{const u=xd(t);if(!u)return null;const f=r?[Za]:[Za,[$o,{singleDollarTextMath:!0}]],m=[];r||m.push([Po,{throwOnError:!1,errorColor:"#cc0000",strict:!1,trust:!0,macros:{"\\RR":"\\mathbb{R}","\\NN":"\\mathbb{N}","\\ZZ":"\\mathbb{Z}","\\QQ":"\\mathbb{Q}","\\CC":"\\mathbb{C}","\\dx":"\\,dx","\\dy":"\\,dy","\\dt":"\\,dt","\\dz":"\\,dz"}}]);const h={table:({children:p,...x})=>n.jsx("div",{style:{overflowX:"auto",WebkitOverflowScrolling:"touch"},children:n.jsx("table",{...x,children:p})}),a:Id,code:p=>{const{className:x,children:y,...k}=p,N=x&&/language-/.test(x),A="inline"in p&&typeof p.inline=="boolean"&&p.inline||!N,v=N;return n.jsx(Ad,{inline:A,className:x,enableGraphs:a,enableMermaid:s,enableSVG:i,enableCharts:o,enableMusic:l,enableSyntaxHighlighting:c,syntaxTheme:d,"data-block-code":v?"true":void 0,...k,children:y})},p:({node:p,...x})=>{var A;const k=St.Children.toArray(x.children).filter(v=>!(typeof v=="string"&&v.trim()==="")).some(v=>{if(!St.isValidElement(v))return!1;const C=v.props;return(C==null?void 0:C["data-block-code"])==="true"?!0:typeof v.type=="string"?Nn.has(v.type):!1}),N=(A=p==null?void 0:p.children)==null?void 0:A.some(v=>{var C;if(v.type==="code")return!0;if(v.type==="element"){if(v.tagName&&Nn.has(v.tagName))return!0;if(v.tagName==="code"){const E=(C=v.properties)==null?void 0:C.className;return Array.isArray(E)?E.some(P=>typeof P=="string"&&P.startsWith("language-")):!0}}return!1});return k||N?n.jsx(n.Fragment,{children:x.children}):n.jsx("p",{...x})}};return n.jsx("div",{className:`markdown-content ${e}`,children:n.jsx(Fo,{remarkPlugins:f,rehypePlugins:m,components:h,children:u})})},Ta=()=>J.debug.consoleDebug,D=(...t)=>{Ta()&&console.log(...t)},pe=(...t)=>{Ta()&&console.warn(...t)},xe=(...t)=>{Ta()&&console.error(...t)},Oe=(...t)=>{console.error(...t)};function In(t){return t==="mp3"?"audio/mpeg":t==="wav"?"audio/wav":t==="ogg"?"audio/ogg":t==="opus"?"audio/opus":t==="webm"?"audio/webm":`audio/${t}`}function ns({audio:t,audioUrl:e,audioFormat:r="mp3",autoPlay:a=!1,maxSizeMB:s=10,downloadFilename:i}){const{t:o}=Le(),{isDark:l}=rr(),c=g.useRef(null),[d,u]=g.useState(!1),[f,m]=g.useState(0),[h,p]=g.useState(0),[x,y]=g.useState(!0),[k,N]=g.useState(null),[A,v]=g.useState(null),[C,E]=g.useState(null);g.useEffect(()=>{if(!t)return;let L=null,R=!0;return(async()=>{try{y(!0),N(null),v(null);const G=t.length*3/4/(1024*1024);if(G>s)throw new Error(o("audio.player.audioFileTooLargePlaceholder",{sizeMB:G.toFixed(1),maxMB:s}));if(G>2&&(v(o("audio.player.largeAudioWarning",{sizeMB:G.toFixed(1)})),D("[AudioPlayer] Large audio file detected",{sizeMB:G.toFixed(2)})),!/^[A-Za-z0-9+/=]+$/.test(t.replace(/\s/g,"")))throw new Error(o("audio.player.invalidBase64Error"));const H=atob(t),Z=new Uint8Array(H.length);for(let te=0;te<H.length;te++)Z[te]=H.charCodeAt(te);const fe=In(r),U=new Blob([Z],{type:fe});if(L=URL.createObjectURL(U),!R){L&&URL.revokeObjectURL(L);return}E(L),y(!1),D("[AudioPlayer] Audio loaded successfully",{format:r,mimeType:fe,size:U.size})}catch(K){xe("[AudioPlayer] Failed to load audio:",K),R&&(N(o("audio.player.loadFailureError")),y(!1))}})(),()=>{R=!1,L&&URL.revokeObjectURL(L)}},[t,r,s,o]),g.useEffect(()=>{if(t||!e)return;let L=null,R=!1;return(async()=>{try{y(!0),N(null);const K=typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null,G=await fetch(e,{headers:K?{"X-Adapter-Name":K}:{}});if(!G.ok)throw new Error(`Server returned ${G.status}`);if(R)return;const H=await G.arrayBuffer();if(R)return;const Z=new Blob([H],{type:In(r)});L=URL.createObjectURL(Z),E(L),y(!1)}catch(K){xe("[AudioPlayer] Failed to fetch audio from",e,K),R||(N(o("audio.player.loadFailureError")),y(!1))}})(),()=>{R=!0,L&&URL.revokeObjectURL(L)}},[t,e,r,o]),g.useEffect(()=>{a&&C&&c.current&&c.current.play().catch(L=>{xe("[AudioPlayer] Auto-play failed:",L)})},[a,C]);const P=()=>{c.current&&m(c.current.duration)},b=()=>{c.current&&p(c.current.currentTime)},_=()=>u(!0),S=()=>u(!1),I=()=>{u(!1),p(0)},M=()=>{c.current&&(d?c.current.pause():c.current.play().catch(L=>{xe("[AudioPlayer] Playback failed:",L),N(o("audio.player.playbackFailureError"))}))},F=L=>{if(!c.current)return;const R=parseFloat(L.target.value);c.current.currentTime=R,p(R)},z=()=>{if(!C)return;const L=document.createElement("a");L.href=C,L.download=i||`generated-audio.${r}`,L.click()},j=L=>{if(!isFinite(L))return"0:00";const R=Math.floor(L/60),T=Math.floor(L%60);return`${R}:${T.toString().padStart(2,"0")}`};return k?n.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-red-300 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-700 dark:bg-red-900/20 dark:text-red-400",children:[n.jsx(_a,{className:"h-4 w-4"}),n.jsx("span",{children:k})]}):n.jsxs("div",{className:"mt-3 flex flex-col gap-1",children:[A&&n.jsxs("div",{className:"text-xs text-amber-600 dark:text-amber-400 px-1",children:["⚠️ ",A]}),n.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-gray-200 bg-white/80 px-3 py-2 dark:border-[#3b3c49] dark:bg-white/5",children:[n.jsx("audio",{ref:c,src:C??void 0,onLoadedMetadata:P,onTimeUpdate:b,onPlay:_,onPause:S,onEnded:I}),n.jsx("button",{onClick:M,disabled:x,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 disabled:opacity-50 dark:bg-[#4a4b54] dark:hover:bg-[#565869]",title:o(d?"audio.player.pauseTitle":"audio.player.playTitle"),"aria-label":o(d?"audio.player.pauseAriaLabel":"audio.player.playAriaLabel"),children:x?n.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}):d?n.jsx(Gc,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"}):n.jsx(Xc,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"})}),n.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[n.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:j(h)}),n.jsx("input",{type:"range",min:"0",max:f||0,value:h,onChange:F,disabled:x||!f,className:"flex-1 cursor-pointer accent-gray-600 dark:accent-[#bfc2cd]",style:{background:(()=>{const L=l?"rgb(191 194 205)":"rgb(75 85 99)",R=l?"rgba(255 255 255 / 0.12)":"rgb(229 231 235)",T=f?h/f*100:0;return`linear-gradient(to right, ${L} 0%, ${L} ${T}%, ${R} ${T}%, ${R} 100%)`})()}}),n.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:j(f)})]}),i&&n.jsx("button",{onClick:z,disabled:x||!C,className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full bg-gray-200 hover:bg-gray-300 disabled:opacity-50 dark:bg-[#4a4b54] dark:hover:bg-[#565869]",title:o("audio.player.downloadAudioTooltip"),children:n.jsx(Fs,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"})})]})]})}function Ln({image:t,imageUrl:e,imageFormat:r="png",revisedPrompt:a}){const{t:s}=Le(),[i,o]=g.useState(!1),[l,c]=g.useState(!1),[d,u]=g.useState(null),f=g.useRef(null);g.useEffect(()=>{if(t||!e)return;let x=!1;return(async()=>{try{const y=typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null,k=await fetch(e,{headers:y?{"X-Adapter-Name":y}:{}});if(!k.ok){console.warn("[ImageDisplay] Server returned",k.status,"for",e);return}if(x)return;const N=await k.arrayBuffer();if(x)return;const A=new Blob([N],{type:`image/${r}`}),v=URL.createObjectURL(A);f.current=v,u(v)}catch(y){console.warn("[ImageDisplay] Failed to fetch image from",e,y)}})(),()=>{x=!0,f.current&&(URL.revokeObjectURL(f.current),f.current=null)}},[e,t,r]);const h=(t?`data:image/${r};base64,${t}`:null)??d;g.useEffect(()=>{if(!i)return;const x=y=>{y.key==="Escape"&&o(!1)};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[i]);const p=x=>{if(x.stopPropagation(),!h)return;const y=document.createElement("a");y.href=h,y.download=`generated-image.${r}`,y.click()};return h?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"generated-image-wrapper",style:{marginTop:"0.75rem"},children:[n.jsxs("div",{className:"generated-image-container",style:{position:"relative",display:"inline-block",cursor:"zoom-in",maxWidth:"100%"},onClick:()=>o(!0),title:a||s("imageDisplay.generatedImageTitle"),children:[n.jsx("img",{src:h,alt:a||s("imageDisplay.generatedImageAlt"),style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",objectFit:"contain"}}),n.jsxs("div",{style:{position:"absolute",bottom:"8px",right:"8px",display:"flex",gap:"6px"},children:[n.jsx("button",{onClick:p,title:s("imageDisplay.downloadImageTooltip"),style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:n.jsx(Fs,{size:14})}),n.jsx("button",{onClick:x=>{x.stopPropagation(),o(!0)},title:s("imageDisplay.viewFullSizeTooltip"),style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:n.jsx(id,{size:14})})]})]}),a&&n.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[n.jsxs("button",{type:"button",onClick:()=>c(x=>!x),style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:0,background:"transparent",border:"none",cursor:"pointer",fontSize:"0.75rem",fontWeight:500,opacity:.72},"aria-expanded":l,children:[l?n.jsx(vs,{size:14}):n.jsx(gr,{size:14}),s(l?"imageDisplay.hidePrompt":"imageDisplay.showPrompt")]}),l&&n.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[n.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:s("imageDisplay.promptLabel")}),n.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:a})]})]})]}),i&&typeof document<"u"&&Ls.createPortal(n.jsxs("div",{onClick:()=>o(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.85)",zIndex:9999,overflow:"auto",padding:"56px 24px 24px"},children:[n.jsx("button",{onClick:x=>{x.stopPropagation(),o(!1)},style:{position:"fixed",top:"16px",right:"16px",background:"rgba(255,255,255,0.15)",border:"none",borderRadius:"50%",padding:"8px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:n.jsx(Ye,{size:20})}),n.jsx("img",{src:h,alt:a||s("imageDisplay.generatedImageAlt"),style:{display:"block",width:"auto",height:"auto",maxWidth:"calc(100vw - 48px)",maxHeight:"calc(100vh - 80px)",objectFit:"contain",borderRadius:"8px",margin:"0 auto"},onClick:x=>x.stopPropagation()})]}),document.body)]}):null}const ea=[750,1500,3e3,5e3],Ed=new Set([403,404,409,425,429,500,502,503,504]),_d=t=>new Promise(e=>setTimeout(e,t));function En({video:t,videoUrl:e,videoFormat:r="mp4",revisedPrompt:a,adapterName:s}){const{t:i}=Le(),[o,l]=g.useState(!1),[c,d]=g.useState(!1),[u,f]=g.useState(null),m=g.useRef(null);g.useEffect(()=>{if(t||!e)return;let y=!1;return(async()=>{try{const k=s||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null);let N=null;for(let E=0;E<=ea.length&&(N=await fetch(e,{headers:k?{"X-Adapter-Name":k}:{}}),!(N.ok||!Ed.has(N.status)||E===ea.length));E+=1)if(await _d(ea[E]),y)return;if(!N||!N.ok){console.warn("[VideoDisplay] Server returned",N==null?void 0:N.status,"for",e);return}if(y)return;const A=await N.arrayBuffer();if(y)return;const v=new Blob([A],{type:`video/${r}`}),C=URL.createObjectURL(v);m.current=C,f(C)}catch(k){console.warn("[VideoDisplay] Failed to fetch video from",e,k)}})(),()=>{y=!0,m.current&&(URL.revokeObjectURL(m.current),m.current=null)}},[e,t,r,s]);const p=(t?`data:video/${r};base64,${t}`:null)??u;g.useEffect(()=>{if(!o)return;const y=k=>{k.key==="Escape"&&l(!1)};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[o]);const x=y=>{if(y.stopPropagation(),!p)return;const k=document.createElement("a");k.href=p,k.download=`generated-video.${r}`,k.click()};return p?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"generated-video-wrapper",style:{marginTop:"0.75rem"},children:[n.jsxs("div",{style:{position:"relative",display:"inline-block",maxWidth:"100%"},children:[n.jsx("video",{src:p,controls:!0,style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",backgroundColor:"#000"}}),n.jsxs("div",{style:{position:"absolute",bottom:"48px",right:"8px",display:"flex",gap:"6px"},children:[n.jsx("button",{onClick:x,title:i("videoDisplay.downloadVideoTooltip"),style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:n.jsx(Fs,{size:14})}),n.jsx("button",{onClick:y=>{y.stopPropagation(),l(!0)},title:i("videoDisplay.viewFullSizeTooltip"),style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:n.jsx(Dc,{size:14})})]})]}),a&&n.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[n.jsxs("button",{type:"button",onClick:()=>d(y=>!y),style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:0,background:"transparent",border:"none",cursor:"pointer",fontSize:"0.75rem",fontWeight:500,opacity:.72},"aria-expanded":c,children:[c?n.jsx(vs,{size:14}):n.jsx(gr,{size:14}),i(c?"videoDisplay.hidePrompt":"videoDisplay.showPrompt")]}),c&&n.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[n.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:i("videoDisplay.promptLabel")}),n.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:a})]})]})]}),o&&n.jsxs("div",{onClick:()=>l(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.9)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},children:[n.jsx("button",{onClick:y=>{y.stopPropagation(),l(!1)},style:{position:"fixed",top:"16px",right:"16px",background:"rgba(255,255,255,0.15)",border:"none",borderRadius:"50%",padding:"8px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:n.jsx(Ye,{size:20})}),n.jsx("video",{src:p,controls:!0,autoPlay:!0,style:{maxWidth:"92vw",maxHeight:"92vh",borderRadius:"8px"},onClick:y=>y.stopPropagation()})]})]}):null}let Ss=null;function _i(t){Ss=t}function $s(){Ss=null}async function Ma(){if(!Ss)return null;try{return await Ss()}catch{return null}}let ma=!1,Rr=null;const pa=new Set;function Ti(){pa.forEach(t=>t())}function xt(){return ma}function Td(){return Rr}function Ps(t){ma!==t&&(ma=t,!t&&Rr!==null&&(Rr=null),Ti())}function fr(t){const e=typeof t=="string"&&t.trim().length>0?t.trim():null;Rr!==e&&(Rr=e,Ti())}function Md(t){return pa.add(t),()=>{pa.delete(t)}}const _n="orbitchat-guest-user-id";function is(t){if(typeof t!="string")return null;const e=t.trim();return e.length>0?e:null}function Fd(t){const e=t.split(".");if(e.length<2)return null;try{const r=e[1].replace(/-/g,"+").replace(/_/g,"/"),a=r.padEnd(Math.ceil(r.length/4)*4,"="),s=atob(a);return JSON.parse(s)}catch{return null}}function $d(){const t=globalThis.crypto;if(t&&typeof t.randomUUID=="function")return`guest:orbitchat:${t.randomUUID()}`;if(!t||typeof t.getRandomValues!="function")throw new Error("Secure random number generation is unavailable");const e=new Uint8Array(16);return t.getRandomValues(e),`guest:orbitchat:${Array.from(e,a=>a.toString(16).padStart(2,"0")).join("")}`}function Pd(){if(typeof window>"u")return"guest:orbitchat:server";const t=window.localStorage.getItem(_n);if(t&&t.trim().length>0)return t;const e=$d();return window.localStorage.setItem(_n,e),e}async function Mi(){const t=Td();if(t)return t;const e=await Ma();if(e){const r=Fd(e),a=is(r==null?void 0:r.sub)||is(r==null?void 0:r.user_id)||is(r==null?void 0:r.preferred_username)||is(r==null?void 0:r.email);if(a)return a}return xt()?"authenticated:orbitchat:unknown":Pd()}const Rd={pdf:"application/pdf",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",md:"text/markdown",csv:"text/csv"},Tn={pdf:"PDF",docx:"Word document",xlsx:"Excel workbook",pptx:"PowerPoint deck",md:"Markdown document",csv:"CSV file"},bs=/[\uE000-\uF8FF]|\\[eE][0-9a-fA-F]{2,3}|\\[fF][0-8][0-9a-fA-F]{2,3}/,Dd=/((?:p\.)?generated-docx-preview-num-\d+-\d+:before\s*\{[^}]*?)content\s*:\s*"([^"]*)"\s*;([^}]*?\})/g;function Od(t){var r;return bs.test(t)?`•${((r=t.match(/(?:\\9|\t|\u00A0| )+$/))==null?void 0:r[0])||"\\9"}`:null}function Mn(t){Array.from(t.querySelectorAll("style")).forEach(a=>{const s=a.textContent;!s||!bs.test(s)||(a.textContent=s.replace(Dd,(i,o,l,c)=>{const d=Od(l);if(!d)return i;const u=c.replace(/\s*font-family\s*:\s*[^;{}]+;?/gi,"");return`${o}content: "${d}";${u}`}))}),Array.from(t.querySelectorAll('span[style*="font-family"]')).forEach(a=>{if(!/\b(symbol|wingdings|webdings)\b/i.test(a.style.fontFamily))return;const s=a.textContent||"";bs.test(s)&&(a.textContent=s.replace(bs,"•"),a.style.fontFamily="")})}function Ud(t){return(t||"pdf").toLowerCase().replace(/^\./,"")||"pdf"}function zd(t){const e=window.atob(t),r=new Uint8Array(e.length);for(let a=0;a<e.length;a+=1)r[a]=e.charCodeAt(a);return r.buffer}function Bd(t){return t==="xlsx"||t==="csv"?n.jsx(Tc,{className:"h-5 w-5"}):t==="pptx"?n.jsx(Jc,{className:"h-5 w-5"}):t==="md"?n.jsx(_c,{className:"h-5 w-5"}):n.jsx(Mc,{className:"h-5 w-5"})}function Fn({document:t,documentUrl:e,documentFormat:r="pdf",revisedPrompt:a,adapterName:s}){const{t:i}=Le(),o=Ud(r),[l,c]=g.useState(t||e?"loading":"idle"),[d,u]=g.useState(null),[f,m]=g.useState(null),[h,p]=g.useState([]),[x,y]=g.useState(""),[k,N]=g.useState(null),[A,v]=g.useState([]),[C,E]=g.useState(0),[P,b]=g.useState(!1),[_,S]=g.useState(null),I=g.useRef(null),M=g.useRef(null),F=g.useRef(null),z=a||Tn[o]||i("documentDisplay.generatedDocument"),j=g.useMemo(()=>`generated-document.${o}`,[o]),L=Rd[o]||"application/octet-stream";g.useEffect(()=>{if(!t&&!e)return;let G=!1;return(async()=>{c("loading"),S(null),p([]),y(""),N(null),v([]),E(0);try{const Z=t?zd(t):await(async()=>{const te=(s==null?void 0:s.trim())||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null),W={"X-User-ID":await Mi()};te&&(W["X-Adapter-Name"]=te);const Q=await Ma();Q&&(W.Authorization=`Bearer ${Q}`);const se=await fetch(e,{headers:W});if(!se.ok)throw new Error(`Server returned ${se.status}`);return se.arrayBuffer()})();if(G)return;const fe=new Blob([Z],{type:L}),U=URL.createObjectURL(fe);if(I.current&&URL.revokeObjectURL(I.current),I.current=U,u(U),m(Z.slice(0)),o==="xlsx"){const{default:te}=await jt(async()=>{const{default:se}=await import("./index-CZz_ECqk.js");return{default:se}},[]),Q=(await te(fe))[0];y((Q==null?void 0:Q.sheet)||"First sheet"),p(((Q==null?void 0:Q.data)||[]).slice(0,100).map(se=>se.slice(0,30).map(ge=>ge==null?"":String(ge))))}if(o==="md"&&N(new TextDecoder("utf-8").decode(Z)),o==="csv"){const te=new TextDecoder("utf-8").decode(Z),{default:W}=await jt(async()=>{const{default:se}=await import("./papaparse.min-D13ujVVP.js").then(ge=>ge.p);return{default:se}},__vite__mapDeps([19,1])),Q=W.parse(te,{skipEmptyLines:!0});E(Q.data.length),v(Q.data.slice(0,25))}c("ready")}catch(Z){if(G)return;console.warn("[DocumentDisplay] Failed to load document from",e,Z),S(Z instanceof Error?Z.message:"Unable to load document"),c("error")}})(),()=>{G=!0,I.current&&(URL.revokeObjectURL(I.current),I.current=null)}},[s,t,e,o,L]),g.useEffect(()=>{if(l!=="ready"||o!=="docx"||!f||!M.current)return;const G=M.current;G.replaceChildren(),jt(()=>import("./docx-preview-DehBmhog.js"),__vite__mapDeps([20,1])).then(async({renderAsync:H})=>{await H(f.slice(0),G,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),Mn(G)}).catch(H=>{console.warn("[DocumentDisplay] Failed to render DOCX preview",H),S("Unable to render document preview")})},[f,o,l]),g.useEffect(()=>{if(!P||o!=="docx"||!f||!F.current)return;const G=F.current;G.replaceChildren(),jt(()=>import("./docx-preview-DehBmhog.js"),__vite__mapDeps([20,1])).then(async({renderAsync:H})=>{await H(f.slice(0),G,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),Mn(G)}).catch(H=>{console.warn("[DocumentDisplay] Failed to render modal DOCX preview",H)})},[f,o,P]),g.useEffect(()=>{if(!P)return;const G=H=>{H.key==="Escape"&&b(!1)};return window.document.addEventListener("keydown",G),()=>window.document.removeEventListener("keydown",G)},[P]);const R=G=>{if(G==null||G.stopPropagation(),!d)return;const H=window.document.createElement("a");H.href=d,H.download=j,H.click()},T=l==="ready"&&(o==="pdf"||o==="docx"||o==="xlsx"||o==="md"||o==="csv"),K=T&&o!=="xlsx"&&o!=="csv";return l==="idle"?null:n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mt-3 max-w-full overflow-hidden rounded-lg border border-gray-200 bg-white shadow-sm dark:border-[#3b3c49] dark:bg-[#202123]",children:[n.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 px-3 py-2.5 dark:border-[#3b3c49]",children:[n.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-blue-50 text-blue-600 dark:bg-blue-500/10 dark:text-blue-300",children:Bd(o)}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:z}),n.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[Tn[o]||`${o.toUpperCase()} document`,l==="loading"?` · ${i("documentDisplay.loadingPreview")}`:"",l==="error"?` · ${_||i("documentDisplay.previewUnavailableShort")}`:""]})]}),K&&n.jsx("button",{type:"button",onClick:()=>b(!0),className:"rounded-md p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:i("documentDisplay.openPreviewTooltip"),"aria-label":i("documentDisplay.openPreviewTooltip"),children:n.jsx(Ec,{className:"h-4 w-4"})}),n.jsx("button",{type:"button",onClick:R,disabled:!d,className:"rounded-md p-2 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 disabled:cursor-not-allowed disabled:opacity-50 dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:i("documentDisplay.downloadDocumentTooltip"),"aria-label":i("documentDisplay.downloadDocumentTooltip"),children:n.jsx(Fs,{className:"h-4 w-4"})})]}),T&&n.jsxs("div",{className:"max-h-[460px] overflow-auto bg-gray-50 dark:bg-[#171717]",children:[o==="pdf"&&d&&n.jsx("iframe",{src:d,title:z,className:"block h-[460px] w-full border-0 bg-white"}),o==="docx"&&n.jsx("div",{ref:M,className:"min-h-[240px] bg-white p-5 text-sm text-[#111827] dark:bg-white dark:text-[#111827]"}),o==="xlsx"&&n.jsxs("div",{className:"p-3",children:[x&&n.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500 dark:text-[#bfc2cd]",children:x}),n.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:n.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:n.jsx("tbody",{children:h.length>0?h.map((G,H)=>n.jsx("tr",{className:H===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:G.map((Z,fe)=>n.jsx("td",{className:"max-w-[220px] truncate border-b border-r border-gray-100 px-2 py-1.5 text-[#353740] dark:border-[#3b3c49] dark:text-[#ececf1]",children:Z},fe))},H)):n.jsx("tr",{children:n.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:i("documentDisplay.noSheetDataFound")})})})})})]}),o==="md"&&k!==null&&n.jsx("div",{className:"bg-white p-5 text-sm text-[#111827] dark:bg-[#171717] dark:text-[#ececf1]",children:n.jsx(Et,{content:k,disableMath:!0})}),o==="csv"&&n.jsxs("div",{className:"p-3",children:[C>25&&n.jsx("p",{className:"mb-2 text-xs text-gray-500 dark:text-[#bfc2cd]",children:i("documentDisplay.csvRowsPreviewMessage",{count:C})}),n.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:n.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:n.jsx("tbody",{children:A.length>0?A.map((G,H)=>n.jsx("tr",{className:H===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:G.map((Z,fe)=>n.jsx("td",{className:"max-w-[220px] truncate border-b border-r border-gray-100 px-2 py-1.5 text-[#353740] dark:border-[#3b3c49] dark:text-[#ececf1]",children:Z},fe))},H)):n.jsx("tr",{children:n.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:i("documentDisplay.noDataFound")})})})})})]})]}),l==="ready"&&!T&&n.jsx("div",{className:"px-3 py-4 text-sm text-gray-600 dark:text-[#bfc2cd]",children:i("documentDisplay.previewUnavailable")})]}),P&&d&&n.jsxs("div",{onClick:()=>b(!1),className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/85 p-4",children:[n.jsx("button",{onClick:G=>{G.stopPropagation(),b(!1)},className:"fixed right-4 top-4 flex items-center rounded-full border-0 bg-white/15 p-2 text-white",title:i("common.close"),"aria-label":i("common.close"),children:n.jsx(Ye,{className:"h-5 w-5"})}),n.jsxs("div",{onClick:G=>G.stopPropagation(),className:"h-[92vh] w-[92vw] overflow-auto rounded-lg bg-white",children:[o==="pdf"&&n.jsx("iframe",{src:d,title:z,className:"h-full w-full border-0"}),o==="docx"&&n.jsx("div",{ref:F,className:"min-h-full bg-white p-8 text-[#111827]"}),o==="md"&&k!==null&&n.jsx("div",{className:"min-h-full bg-white p-8 text-sm text-[#111827]",children:n.jsx(Et,{content:k,disableMath:!0})})]})]})]})}const Hd=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed",'[contenteditable="true"]','[tabindex]:not([tabindex="-1"])'].join(",");function Dr(t,{enabled:e,onEscape:r}){g.useEffect(()=>{if(!e||!t.current)return;const a=t.current,s=document.activeElement,i=Array.from(a.querySelectorAll(Hd)).filter(d=>d.tabIndex!==-1),o=i[0]||a,l=i[i.length-1]||a;o.focus({preventScroll:!0});const c=d=>{if(d.key==="Escape"){r==null||r();return}if(d.key!=="Tab")return;if(i.length===0){d.preventDefault(),a.focus({preventScroll:!0});return}const u=document.activeElement;if(d.shiftKey){(!u||u===o||!a.contains(u))&&(d.preventDefault(),l.focus({preventScroll:!0}));return}(!u||u===l||!a.contains(u))&&(d.preventDefault(),o.focus({preventScroll:!0}))};return document.addEventListener("keydown",c),()=>{var d;document.removeEventListener("keydown",c),(d=s==null?void 0:s.focus)==null||d.call(s,{preventScroll:!0})}},[e,r,t])}function js({isOpen:t,onClose:e,onConfirm:r,title:a,message:s,confirmText:i,cancelText:o,type:l="danger",isLoading:c=!1}){const d=g.useRef(null);Dr(d,{enabled:t,onEscape:e});const{t:u}=Le(),f=i??u("common.confirm"),m=o??u("common.cancel");if(!t)return null;const h=()=>{c||r()},x=(()=>{switch(l){case"danger":return{icon:"text-red-500",iconBg:"bg-red-100 dark:bg-red-900/20",confirmButton:"bg-red-600 hover:bg-red-700 focus:ring-red-500",border:"border-red-200 dark:border-red-800"};case"warning":return{icon:"text-amber-500",iconBg:"bg-amber-100 dark:bg-amber-900/20",confirmButton:"bg-amber-600 hover:bg-amber-700 focus:ring-amber-500",border:"border-amber-200 dark:border-amber-800"};default:return{icon:"text-blue-500",iconBg:"bg-blue-100 dark:bg-blue-900/20",confirmButton:"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500",border:"border-blue-200 dark:border-blue-800"}}})(),y=n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-y-auto bg-black/60 p-4 backdrop-blur-sm animate-fadeIn",children:n.jsxs("div",{ref:d,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-title",tabIndex:-1,className:"w-full max-w-md max-h-[calc(100vh-2rem)] overflow-y-auto rounded-2xl bg-white shadow-2xl transform animate-fadeIn dark:bg-[#1a1b1e]",children:[n.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-[#2d2f39]",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:`w-10 h-10 rounded-full ${x.iconBg} flex items-center justify-center`,children:n.jsx(Ea,{className:`w-5 h-5 ${x.icon}`})}),n.jsx("h2",{id:"confirm-title",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:a})]}),n.jsx("button",{type:"button",onClick:e,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors","aria-label":u("common.close"),children:n.jsx(Ye,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),n.jsx("div",{className:"p-6",children:n.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:s})}),n.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-gray-200 dark:border-[#2d2f39] bg-gray-50 dark:bg-[#131416] rounded-b-2xl",children:[n.jsx("button",{type:"button",onClick:e,disabled:c,className:"px-4 py-3 md:py-2.5 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed",children:m}),n.jsx("button",{type:"button",onClick:h,disabled:c,className:`px-4 py-3 md:py-2.5 text-white rounded-lg transition-all font-medium shadow-sm hover:shadow-md transform hover:scale-105 active:scale-95 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-white dark:focus:ring-offset-gray-800 disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none ${x.confirmButton}`,children:c?n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),u("confirmationModal.loadingLabel")]}):f})]})]})});return typeof document>"u"?y:Ls.createPortal(y,document.body)}const Vd=["#","*","`","[","]","(",")","{","}","|","<",">"],Fi=t=>Vd.some(e=>t.includes(e));function $i(t){if(!t||t.length<1e3)return!1;const e=/^[A-Za-z0-9+/=]+$/,r=t.replace(/\s+/g,"");if(r.length>1e4&&e.test(r)){const a=/\b(the|and|for|are|but|not|you|all|can|function|const|let|var|class|return|import|export|async|await|if|else|while|true|false|null|undefined|http|https|www|error|data|response|request|api|json|xml|html|css|js|py|java|cpp|def|print|console|log)\b/i.test(t),s=Fi(t),i=/[-.,;:!?'"()]/.test(t);if(!a&&!s&&!i)return!0}return!!(r.length>5e4&&e.test(r)&&t.replace(/[A-Za-z0-9+/=\s]/g,"").length<10)}const qd=/(?:\u202F|\u2009|\u200A|\u200B|\u200C|\u200D|\uFEFF)/g;function Or(t){if(!t)return t;let e=t.replace(qd," ");if($i(e))return"";const r=/([A-Za-z0-9+/=]{10000,})/g;return e=e.replace(r,a=>{const s=a.replace(/\s+/g,"");if(s.length>1e4&&/^[A-Za-z0-9+/=]+$/.test(s)){const i=/\b(function|const|let|var|class|return|import|export|if|else|while|for|true|false|null|def|print)\b/i.test(a),o=Fi(a),l=/[-.,;:!?'"()]/.test(a);if(!i&&!o&&!l)return""}return a}),e}function xa(t,e=5e4){return!t||t.length<=e?t:$i(t)?"":t.substring(0,e)+`
|
|
327
|
+
|
|
328
|
+
... (content truncated due to length)`}const Wd={maxFilesPerConversation:J.limits.files.perConversation,maxFileSizeMB:J.limits.files.maxSizeMB,maxTotalFiles:J.limits.files.totalFiles,maxConversations:J.limits.conversations.maxConversations,maxMessagesPerConversation:J.limits.conversations.messagesPerConversation,maxMessagesPerThread:J.limits.conversations.messagesPerThread,maxTotalMessages:J.limits.conversations.totalMessages,maxMessageLength:J.limits.messages.maxLength};function Kd(t){const e=J.guestLimits;switch(t){case"maxConversations":return e.conversations.maxConversations;case"maxMessagesPerConversation":return e.conversations.messagesPerConversation;case"maxMessagesPerThread":return e.conversations.messagesPerThread;case"maxTotalMessages":return e.conversations.totalMessages;case"maxFilesPerConversation":return e.files.perConversation;case"maxTotalFiles":return e.files.totalFiles;case"maxMessageLength":return e.messages.maxLength;case"maxFileSizeMB":return e.files.maxSizeMB;default:return}}const le=new Proxy(Wd,{get(t,e){if(rt()&&!xt()){const r=Kd(e);if(r!==void 0)return r}return t[e]}});function hr(){return g.useSyncExternalStore(Md,xt,xt)}class Pi extends Error{constructor(r,a){super(r);Xe(this,"status");Xe(this,"statusText");this.name="ApiRequestError",this.status=a.status,this.statusText=a.statusText}}async function Re(t={}){const e={"X-User-ID":await Mi(),...t},r=await Ma();return r&&(e.Authorization=`Bearer ${r}`),e}function wt(t){return encodeURIComponent(t)}function Gd(t){return!t||t.length===0?"":`?file_ids=${t.map(encodeURIComponent).join(",")}`}async function Lr(t){const e=`API request failed: ${t.status} ${t.statusText}`;try{if((t.headers.get("content-type")||"").includes("application/json")){const a=await t.json(),s=typeof a.detail=="string"&&a.detail.trim()||typeof a.error=="string"&&a.error.trim()||typeof a.message=="string"&&a.message.trim();if(s)return`${e}: ${s}`}else{const a=(await t.text()).trim();if(a)return`${e}: ${a}`}}catch{}return e}function $n(t){if(!t.startsWith("data: "))return null;try{const e=JSON.parse(t.substring(6));return e.request_id&&!e.response&&!e.done?{text:"",done:!1,request_id:e.request_id}:{text:e.text||e.content||e.message||e.response||"",done:e.done||!1,request_id:e.request_id,audio:e.audio,audioFormat:e.audio_format||e.audioFormat,audio_chunk:e.audio_chunk,chunk_index:e.chunk_index,image:e.image,image_format:e.image_format,image_revised_prompt:e.image_revised_prompt,image_url:e.image_url,video:e.video,video_format:e.video_format,video_revised_prompt:e.video_revised_prompt,video_url:e.video_url,document:e.document,document_format:e.document_format,document_revised_prompt:e.document_revised_prompt,document_url:e.document_url,generated_audio_url:e.generated_audio_url,generated_audio_format:e.generated_audio_format,generated_audio_revised_prompt:e.generated_audio_revised_prompt,assistant_message_id:e.assistant_message_id,threading:e.threading}}catch{return null}}let os=null;function Xd(){let t=null,e=null;const r=(s,i,o)=>{t=i||null,e=o||null},a=(s,i)=>({async*streamChat(o,l,c,d,u,f,m,h,p,x,y,k,N,A){var E,P;const v={messages:[{role:"user",content:o}],stream:l!==!1};c&&c.length>0&&(v.file_ids=c),d&&(v.thread_id=d),u&&(v.audio_input=u),f&&(v.audio_format=f),m&&(v.language=m),h!==void 0&&(v.return_audio=h),p&&(v.tts_voice=p),x&&(v.source_language=x),y&&(v.target_language=y),k&&(v.model=k),N&&(v.skill=N),A&&(v.regenerate_of_message_id=A);const C=await fetch("/api/v1/chat",{method:"POST",headers:await Re({"Content-Type":"application/json","X-Adapter-Name":s,...i?{"X-Session-ID":i}:{}}),body:JSON.stringify(v)});if(!C.ok)throw new Error(await Lr(C));if((E=C.headers.get("content-type"))!=null&&E.includes("text/event-stream")){const b=(P=C.body)==null?void 0:P.getReader(),_=new TextDecoder;let S="";if(!b)throw new Error("Response body is not readable");for(;;){const{done:I,value:M}=await b.read();if(I)break;S+=_.decode(M,{stream:!0});const F=S.split(`
|
|
329
|
+
`);S=F.pop()||"";for(const z of F){const j=$n(z);j&&(yield j)}}if(S.trim())for(const I of S.split(`
|
|
330
|
+
`)){const M=$n(I);M&&(yield M)}}else{const b=await C.json();yield{text:b.message||b.response||"",done:!0,audio:b.audio,audioFormat:b.audio_format||b.audioFormat,image:b.image,image_format:b.image_format,image_revised_prompt:b.image_revised_prompt,image_url:b.image_url,video:b.video,video_format:b.video_format,video_revised_prompt:b.video_revised_prompt,video_url:b.video_url,document:b.document,document_format:b.document_format,document_revised_prompt:b.document_revised_prompt,document_url:b.document_url,generated_audio_url:b.generated_audio_url,generated_audio_format:b.generated_audio_format,generated_audio_revised_prompt:b.generated_audio_revised_prompt,assistant_message_id:b.assistant_message_id,threading:b.threading}}},async createThread(o,l){const c=await fetch("/api/threads",{method:"POST",headers:await Re({"Content-Type":"application/json","X-Adapter-Name":s,"X-Session-ID":l}),body:JSON.stringify({message_id:o,session_id:l})});if(!c.ok)throw new Error(`Failed to create thread: ${c.statusText}`);return c.json()},async getThreadInfo(o){const l=await fetch(`/api/threads/${wt(o)}`,{headers:await Re({"X-Adapter-Name":s})});if(!l.ok)throw new Error(`Failed to get thread info: ${l.statusText}`);return l.json()},async deleteThread(o){const l=await fetch(`/api/threads/${wt(o)}`,{method:"DELETE",headers:await Re({"X-Adapter-Name":s})});if(!l.ok)throw new Error(`Failed to delete thread: ${l.statusText}`);return l.json()},async submitFeedback(o,l,c){const d=await fetch("/api/feedback",{method:"POST",headers:await Re({"Content-Type":"application/json","X-Adapter-Name":s,"X-Session-ID":l}),body:JSON.stringify({message_id:o,session_id:l,feedback_type:c})});if(!d.ok)throw new Error(`Failed to submit feedback: ${d.statusText}`);return d.json()},async getSessionFeedback(o){const l=await fetch(`/api/feedback/${wt(o)}`,{headers:await Re({"X-Adapter-Name":s})});if(!l.ok)throw new Error(`Failed to get feedback: ${l.statusText}`);return l.json()},async clearConversationHistory(o){const l=o||i;if(!l)throw new Error("No session ID available for clearing conversation history");const c=await fetch(`/api/admin/chat-history/${wt(l)}`,{method:"DELETE",headers:await Re({"X-Adapter-Name":s})});if(!c.ok)throw new Error(`Failed to clear history: ${c.statusText}`);return c.json()},async getConversationHistory(o,l){const c=o||i;if(!c)throw new Error("No session ID available for conversation history");const d=typeof l=="number"&&Number.isFinite(l)&&l>0?`?limit=${Math.floor(l)}`:"",u=await fetch(`/api/admin/chat-history/${wt(c)}${d}`,{headers:await Re({"X-Adapter-Name":s})});if(!u.ok)throw new Error(`Failed to load history: ${u.statusText}`);return u.json()},async deleteConversationWithFiles(o,l){const c=o||i;if(!c)throw new Error("No session ID available for deleting conversation");const d=Gd(l),u=await fetch(`/api/admin/conversations/${wt(c)}${d}`,{method:"DELETE",headers:await Re({"X-Adapter-Name":s})});if(!u.ok)throw new Error(`Failed to delete conversation: ${u.statusText}`);return u.json()},getSessionId:()=>i,async uploadFile(o){const l=new FormData;l.append("file",o);const c=await fetch("/api/files/upload",{method:"POST",headers:await Re({"X-Adapter-Name":s}),body:l});if(!c.ok)throw new Error(`Failed to upload file: ${c.statusText}`);return c.json()},async listFiles(){const o=await fetch("/api/files",{headers:await Re({"X-Adapter-Name":s})});if(!o.ok)throw new Error(`Failed to list files: ${o.statusText}`);const l=await o.json();return Array.isArray(l)?l:l.files||[]},async getFileInfo(o){const l=await fetch(`/api/files/${wt(o)}`,{headers:await Re({"X-Adapter-Name":s})});if(!l.ok)throw new Error(`Failed to get file info: ${l.statusText}`);return l.json()},async queryFile(o,l,c){const d=await fetch(`/api/files/${wt(o)}/query`,{method:"POST",headers:await Re({"Content-Type":"application/json","X-Adapter-Name":s}),body:JSON.stringify({query:l,max_results:c})});if(!d.ok)throw new Error(`Failed to query file: ${d.statusText}`);return d.json()},async deleteFile(o){const l=await fetch(`/api/files/${wt(o)}`,{method:"DELETE",headers:await Re({"X-Adapter-Name":s})});if(!l.ok)throw new Error(`Failed to delete file: ${l.statusText}`);return l.json()},async validateApiKey(){const o=await fetch(`/api/admin/api-keys/${wt(s)}/status`,{headers:await Re({"X-Adapter-Name":s})});if(!o.ok)throw new Error(`Failed to validate API key: ${o.statusText}`);return o.json()},async getAdapterInfo(){const o="/api/admin/adapters/info",l=f=>{if(!f)return 0;const m=Number(f);if(Number.isFinite(m)&&m>0)return Math.min(m*1e3,3e4);const h=Date.parse(f);if(!Number.isNaN(h)){const p=h-Date.now();if(p>0)return Math.min(p,3e4)}return 0},c=f=>new Promise(m=>setTimeout(m,f)),d=async()=>fetch(o,{headers:await Re({"X-Adapter-Name":s})});let u=await d();if(u.status===429){const f=l(u.headers.get("Retry-After"));f>0&&(await c(f),u=await d())}if(!u.ok){const f=await u.text(),m=`${u.status} ${u.statusText}`.trim(),h=u.status===401?`Adapter info request was unauthorized for '${s}'. Verify the adapter exists and you have access.`:`Failed to load adapter info (${m}) for '${s}'.`;throw console.warn("[ProxyApi] Adapter info request failed",{adapter:s,status:u.status,statusText:u.statusText,details:f||void 0}),new Pi(h,u)}return u.json()},async stopChat(o,l){const c=await fetch("/api/v1/chat/stop",{method:"POST",headers:await Re({"Content-Type":"application/json","X-Adapter-Name":s}),body:JSON.stringify({session_id:o,request_id:l})});return c.ok?(await c.json()).status==="cancelled":(console.warn(`[ProxyApi] stopChat failed: ${c.status} ${c.statusText}`),!1)},async getAdapterModels(o){const l=await fetch(`/api/admin/adapters/${encodeURIComponent(o)}/models`,{headers:await Re({"X-Adapter-Name":s})});if(!l.ok)throw new Error(await Lr(l));return l.json()},async getAllModels(){const o=await fetch("/api/admin/models",{headers:await Re({"X-Adapter-Name":s})});if(!o.ok)throw new Error(await Lr(o));return o.json()},async getAdapterSkills(o){const l=await fetch(`/api/admin/adapters/${encodeURIComponent(o)}/skills`,{headers:await Re({"X-Adapter-Name":s})});if(!l.ok)throw new Error(await Lr(l));return l.json()},async getAllSkills(){const o=await fetch("/api/admin/skills",{headers:await Re({"X-Adapter-Name":s})});if(!o.ok)throw new Error(await Lr(o));return o.json()}});return{configureApi:r,streamChat:async function*(s,i,o,l,c,d,u,f,m,h,p,x,y,k){if(!e)throw new Error("Adapter name is required");yield*a(e,t).streamChat(s,i,o,l,c,d,u,f,m,h,p,x,y,k)},stopChat:async(s,i)=>{if(!e)throw new Error("Adapter name is required");return a(e,t).stopChat(s,i)},ApiClient:class{constructor(i){Xe(this,"client");const o=i.adapterName||null,l=i.sessionId||null;if(!o)throw new Error("Adapter name is required");this.client=a(o,l)}async*streamChat(...i){yield*this.client.streamChat(...i)}get createThread(){var i;return(i=this.client.createThread)==null?void 0:i.bind(this.client)}get getThreadInfo(){var i;return(i=this.client.getThreadInfo)==null?void 0:i.bind(this.client)}get deleteThread(){var i;return(i=this.client.deleteThread)==null?void 0:i.bind(this.client)}get submitFeedback(){var i;return(i=this.client.submitFeedback)==null?void 0:i.bind(this.client)}get getSessionFeedback(){var i;return(i=this.client.getSessionFeedback)==null?void 0:i.bind(this.client)}get clearConversationHistory(){var i;return(i=this.client.clearConversationHistory)==null?void 0:i.bind(this.client)}get getConversationHistory(){var i;return(i=this.client.getConversationHistory)==null?void 0:i.bind(this.client)}get deleteConversationWithFiles(){var i;return(i=this.client.deleteConversationWithFiles)==null?void 0:i.bind(this.client)}get getSessionId(){var i;return(i=this.client.getSessionId)==null?void 0:i.bind(this.client)}get uploadFile(){var i;return(i=this.client.uploadFile)==null?void 0:i.bind(this.client)}get listFiles(){var i;return(i=this.client.listFiles)==null?void 0:i.bind(this.client)}get getFileInfo(){var i;return(i=this.client.getFileInfo)==null?void 0:i.bind(this.client)}get queryFile(){var i;return(i=this.client.queryFile)==null?void 0:i.bind(this.client)}get deleteFile(){var i;return(i=this.client.deleteFile)==null?void 0:i.bind(this.client)}get validateApiKey(){var i;return(i=this.client.validateApiKey)==null?void 0:i.bind(this.client)}get getAdapterInfo(){var i;return(i=this.client.getAdapterInfo)==null?void 0:i.bind(this.client)}get stopChat(){var i;return(i=this.client.stopChat)==null?void 0:i.bind(this.client)}get getAdapterModels(){var i;return(i=this.client.getAdapterModels)==null?void 0:i.bind(this.client)}get getAllModels(){var i;return(i=this.client.getAllModels)==null?void 0:i.bind(this.client)}get getAdapterSkills(){var i;return(i=this.client.getAdapterSkills)==null?void 0:i.bind(this.client)}get getAllSkills(){var i;return(i=this.client.getAllSkills)==null?void 0:i.bind(this.client)}}}}async function Yd(){return os||(D("Loading API via Express proxy"),os=Xd(),D("API loaded successfully"),os)}async function Fe(){return await Yd()}class Pn{static async getAdapterSkills(e,r){const a=await Fe(),s=new a.ApiClient({apiUrl:"",adapterName:r});return s.getAdapterSkills?(await s.getAdapterSkills(e)).available_skills:[]}static async getAllSkills(e){const r=await Fe(),a=new r.ApiClient({apiUrl:"",adapterName:e});return a.getAllSkills?(await a.getAllSkills()).skills:[]}}const Jd=6e4;function Ri(t={}){const{adapterName:e,enabled:r=!0,selectionScopeKey:a,supportsThreading:s=!1}=t,i=r&&!!e&&!s,o=a??e??"__default__",[l,c]=g.useState([]),[d,u]=g.useState(!1),[f,m]=g.useState(null),[h,p]=g.useState({}),x=g.useRef(null),y=g.useRef(new Map),k=g.useCallback(async C=>{var b,_;const E=C,P=y.current.get(E);if(P&&P.expiresAt>Date.now()){c(P.skills),m(C);return}x.current&&x.current.abort(),x.current=new AbortController,u(!0);try{const[S,I]=await Promise.all([Pn.getAdapterSkills(C,C),Pn.getAllSkills(C)]);if((b=x.current)!=null&&b.signal.aborted)return;const M=I.filter(F=>S.includes(F.name)&&F.enabled);y.current.set(E,{skills:M,expiresAt:Date.now()+Jd}),c(M),m(C),D("[useSkills] Loaded",M.length,"skills for adapter",C)}catch(S){if(S instanceof Error&&S.name==="AbortError")return;pe("[useSkills] Failed to load skills:",S instanceof Error?S.message:String(S)),c([]),m(C)}finally{(_=x.current)!=null&&_.signal.aborted||u(!1)}},[]);g.useEffect(()=>{if(!i||!e)return;const C=window.setTimeout(()=>{k(e)},0);return()=>{var E;window.clearTimeout(C),(E=x.current)==null||E.abort()}},[i,e,k]);const N=g.useCallback(C=>{p(E=>{const P=E[o]??null;if(P===C||(P==null?void 0:P.name)===(C==null?void 0:C.name))return E;const b={...E};return C?b[o]=C:delete b[o],b})},[o]),A=g.useCallback(()=>{p(C=>{if(!C[o])return C;const E={...C};return delete E[o],E})},[o]),v=i?h[o]??null:null;return{skills:i&&f===e?l:[],isLoading:i?d||f!==e:!1,selectedSkill:v,selectSkill:N,clearSkill:A}}const Rn=t=>{let e;const r=new Set,a=(d,u)=>{const f=typeof d=="function"?d(e):d;if(!Object.is(f,e)){const m=e;e=u??(typeof f!="object"||f===null)?f:Object.assign({},e,f),r.forEach(h=>h(e,m))}},s=()=>e,l={setState:a,getState:s,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=e=t(a,s,l);return l},Zd=(t=>t?Rn(t):Rn),Qd=t=>t;function eu(t,e=Qd){const r=St.useSyncExternalStore(t.subscribe,St.useCallback(()=>e(t.getState()),[t,e]),St.useCallback(()=>e(t.getInitialState()),[t,e]));return St.useDebugValue(r),r}const Dn=t=>{const e=Zd(t),r=a=>eu(e,a);return Object.assign(r,e),r},Di=(t=>t?Dn(t):Dn),st=Di(t=>({showLoginPrompt:!1,promptMessage:"",openLoginPrompt:e=>t({showLoginPrompt:!0,promptMessage:e}),closeLoginPrompt:()=>t({showLoginPrompt:!1,promptMessage:""})})),ls=t=>{const e=t==null?void 0:t.trim();return e||(typeof window<"u"&&window.localStorage?localStorage.getItem("chat-adapter-name"):null)};class Ur{static async uploadFile(e,r,a,s,i){try{const o=le.maxFileSizeMB*1024*1024;if(e.size>o)throw new Error(`File size exceeds maximum limit of ${le.maxFileSizeMB}MB`);if(!(["application/pdf","text/plain","text/markdown","text/csv","application/json","text/html","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.ms-excel","application/vnd.ms-excel.sheet.macroEnabled.12","text/x-python","text/x-python-script","text/x-java-source","text/x-java","text/x-sql","text/javascript","application/javascript","text/typescript","application/typescript","text/x-c++src","text/x-csrc","text/x-c","text/x-go","text/x-rust","text/x-ruby","text/x-php","text/x-shellscript","text/x-sh","text/yaml","text/x-yaml","text/xml","application/xml","text/css","text/x-scss","text/x-sass","text/x-less","image/png","image/jpeg","image/tiff","image/webp","audio/wav","audio/mpeg","audio/mp3","audio/mp4","audio/ogg","audio/flac","audio/webm","audio/x-m4a","audio/aac","text/vtt"].includes(e.type)||/\.(pdf|txt|md|csv|json|html|docx|pptx|xlsx|py|java|sql|js|mjs|ts|tsx|cpp|cxx|cc|c|h|hpp|go|rs|rb|php|sh|bash|zsh|yaml|yml|xml|css|scss|sass|less|png|jpe?g|tiff?|webp|wav|mp3|mp4|ogg|flac|webm|m4a|aac|vtt)$/i.test(e.name)||(e.type==="application/x-zip-compressed"||e.type==="application/zip")&&/\.xlsx$/i.test(e.name)))throw new Error(`File type not supported: ${e.type||"unknown"}`);r&&r({filename:e.name,progress:0,status:"uploading"});const d=await Fe(),u=(s==null?void 0:s.trim())||$e(),f=ls(i);if(!f)throw new Error("Adapter not configured. Please select an adapter from the dropdown.");D(`Using adapter: ${f}`);const m=new d.ApiClient({apiUrl:u,sessionId:null,adapterName:f});if(!m.uploadFile)throw new Error("File upload is not available.");const h=await m.uploadFile(e);r&&r({filename:e.name,progress:75,status:"processing",fileId:h.file_id});let p;try{p=await this.pollFileStatus(h.file_id,30,2e3,void 0,u,f)}catch(x){const y=x instanceof Error?x.message:String(x);if(y.includes("was deleted"))throw new Error(`File ${h.file_id} was deleted during upload`);pe(`File status polling failed for ${h.file_id}:`,x);const k=y.includes("processing failed")||y.includes("timeout");p={file_id:h.file_id,filename:h.filename,mime_type:h.mime_type,file_size:h.file_size,processing_status:k?"failed":h.status||"processing",chunk_count:h.chunk_count,error_message:k?y:void 0}}return r&&r({filename:e.name,progress:100,status:p.processing_status==="completed"?"completed":"processing",fileId:h.file_id}),p}catch(o){let l=o instanceof Error?o.message:"Upload failed";throw l.includes("401")&&(l="Authentication failed. Please check your adapter configuration."),r&&r({filename:e.name,progress:0,status:"error",error:l}),new Error(l)}}static async uploadFiles(e,r){const s=[],i=[];for(let o=0;o<e.length;o+=3){const l=e.slice(o,o+3),c=await Promise.allSettled(l.map(async(d,u)=>{const f=o+u;return this.uploadFile(d,m=>{r&&r(f,m)})}));for(let d=0;d<c.length;d++){const u=c[d],f=o+d;u.status==="fulfilled"?s.push(u.value):(Oe(`Failed to upload file ${e[f].name}:`,u.reason),i.push({index:f,file:e[f].name,error:u.reason}))}}if(s.length===0&&i.length>0){const o=i[0].error;throw o instanceof Error?o:new Error(`All ${i.length} file uploads failed`)}return i.length>0&&pe(`[FileUploadService] ${i.length} of ${e.length} files failed to upload:`,i.map(o=>o.file)),s}static async listFiles(e,r,a){try{const s=await Fe(),i=(r==null?void 0:r.trim())||$e(),o=ls(a);if(!o)throw new Error("Adapter not configured");const l=new s.ApiClient({apiUrl:i,sessionId:null,adapterName:o});if(!l.listFiles)throw new Error("File listing is not available.");const c=await l.listFiles();return(Array.isArray(c)?c:Array.isArray(c.files)?c.files:[]).map(u=>({file_id:u.file_id,filename:u.filename,mime_type:u.mime_type,file_size:u.file_size,upload_timestamp:u.upload_timestamp,processing_status:u.processing_status,chunk_count:u.chunk_count,error_message:u.error_message}))}catch(s){Oe("Failed to list files:",s);const i=s instanceof Error?s.message:"Failed to list files";throw new Error(i)}}static async getFileInfo(e,r,a,s){try{const i=await Fe(),o=(a==null?void 0:a.trim())||$e(),l=ls(s);if(!l)throw new Error("Adapter not configured");const c=new i.ApiClient({apiUrl:o,sessionId:null,adapterName:l});if(!c.getFileInfo)throw new Error("File info retrieval is not available.");const d=await c.getFileInfo(e);return{file_id:d.file_id,filename:d.filename,mime_type:d.mime_type,file_size:d.file_size,upload_timestamp:d.upload_timestamp,processing_status:d.processing_status,chunk_count:d.chunk_count,error_message:d.error_message}}catch(i){if(i instanceof Error&&(i.message.includes("404")||i.message.includes("File not found")))throw new Error(`File ${e} was deleted`);Oe(`Failed to get file info for ${e}:`,i);const o=i instanceof Error?i.message:`Failed to get file info: ${e}`;throw new Error(o)}}static async pollFileStatus(e,r=30,a=2e3,s,i,o){for(let l=0;l<r;l++)try{if(s&&!s())throw new Error("Polling cancelled - component unmounted");const c=await this.getFileInfo(e,void 0,i,o);if(c.processing_status==="completed")return c;if(c.processing_status==="error"||c.processing_status==="failed"){const d=c.error_message;throw new Error(d||`File processing failed for ${e}`)}l<r-1&&await new Promise(d=>setTimeout(d,a))}catch(c){const d=c instanceof Error?c.message:String(c);if(d.includes("404")||d.includes("File not found")||d.includes("was deleted"))throw new Error(`File ${e} was deleted during upload`);if(d.includes("component unmounted")||d.includes("processing failed")||d.includes("processing_status")||d.includes("401")||d.includes("403")||d.includes("500")||d.includes("502")||d.includes("503")||d.includes("Authentication")||d.includes("Adapter not configured"))throw c;if(l<r-1){await new Promise(u=>setTimeout(u,a));continue}throw c}throw new Error(`File processing timeout: ${e} did not complete within ${r*a/1e3} seconds`)}static async deleteFile(e,r,a,s){try{const i=await Fe(),o=(a==null?void 0:a.trim())||$e(),l=ls(s);if(!l)throw new Error("Adapter not configured");const c=new i.ApiClient({apiUrl:o,sessionId:null,adapterName:l});if(!c.deleteFile)throw new Error("File deletion is not available.");return await c.deleteFile(e)}catch(i){if(i instanceof Error&&(i.message.includes("404")||i.message.includes("File not found")||i.message.includes("Not Found")))return D(`File ${e} was already deleted from server`),{message:"File already deleted",file_id:e};Oe(`Failed to delete file ${e}:`,i);const o=i instanceof Error?i.message:`Failed to delete file: ${e}`;throw new Error(o)}}}class tu{constructor(){Xe(this,"audioQueue",[]);Xe(this,"isPlaying",!1);Xe(this,"currentAudio",null);Xe(this,"audioContext",null);Xe(this,"isEnabled",!1);Xe(this,"onPlaybackStart",null);Xe(this,"onPlaybackEnd",null);Xe(this,"mimeTypeCache",new Map);Xe(this,"onChunkPlayed",null);Xe(this,"blobUrls",[]);Xe(this,"suppressPlaybackErrors",!1)}async enableAudio(){var e,r;try{if(!this.audioContext){const i=typeof AudioContext<"u"?AudioContext:typeof window<"u"&&window.webkitAudioContext||null;i&&(this.audioContext=new i)}const a=((e=this.audioContext)==null?void 0:e.state)==="suspended"?this.audioContext.resume():Promise.resolve();let s=Promise.resolve();try{const i=this.createSilentWavBlob(),o=URL.createObjectURL(i),l=new Audio;l.setAttribute("playsinline",""),l.setAttribute("webkit-playsinline",""),l.src=o,l.volume=0,s=l.play().then(()=>{l.pause()}).catch(()=>{D("[AudioStreamManager] HTMLAudioElement silent unlock failed (will retry on next gesture)")}).finally(()=>{URL.revokeObjectURL(o)})}catch{D("[AudioStreamManager] Could not create silent audio element")}if(await a,this.audioContext&&this.audioContext.state==="running"){const i=this.audioContext.createBuffer(1,1,22050),o=this.audioContext.createBufferSource();o.buffer=i,o.connect(this.audioContext.destination),o.start(0)}return await s,this.isEnabled=!0,D("[AudioStreamManager] Audio playback enabled",{audioContextState:(r=this.audioContext)==null?void 0:r.state}),!0}catch(a){return xe("[AudioStreamManager] Failed to enable audio:",a),!1}}createSilentWavBlob(){const o=new ArrayBuffer(844),l=new DataView(o),c=(d,u)=>{for(let f=0;f<u.length;f++)l.setUint8(d+f,u.charCodeAt(f))};return c(0,"RIFF"),l.setUint32(4,836,!0),c(8,"WAVE"),c(12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,1,!0),l.setUint16(22,1,!0),l.setUint32(24,8e3,!0),l.setUint32(28,8e3*2,!0),l.setUint16(32,2,!0),l.setUint16(34,16,!0),c(36,"data"),l.setUint32(40,800,!0),new Blob([o],{type:"audio/wav"})}disableAudio(){!this.isEnabled&&!this.isPlaying||(this.isEnabled=!1,this.stop(),D("[AudioStreamManager] Audio playback disabled"))}async ensureAudioContext(){var e;if(!this.audioContext){const r=typeof AudioContext<"u"?AudioContext:typeof window<"u"&&window.webkitAudioContext||null;if(r)try{this.audioContext=new r}catch(a){return xe("[AudioStreamManager] Failed to create AudioContext:",a),!1}}if(((e=this.audioContext)==null?void 0:e.state)==="suspended")try{await this.audioContext.resume()}catch(r){return D("[AudioStreamManager] AudioContext resume deferred",r),!1}return!0}resolveMimeType(e){const r=this.mimeTypeCache.get(e);if(r)return r;let a;switch(e){case"mp3":a="audio/mpeg";break;case"wav":a="audio/wav";break;case"webm":a="audio/webm";break;case"ogg":a="audio/ogg";break;case"opus":{const s=typeof document<"u"?document.createElement("audio"):null;s!=null&&s.canPlayType("audio/ogg; codecs=opus")?a="audio/ogg; codecs=opus":s!=null&&s.canPlayType("audio/webm; codecs=opus")?a="audio/webm; codecs=opus":a="audio/mp4";break}default:a=`audio/${e}`}return this.mimeTypeCache.set(e,a),D(`[AudioStreamManager] Resolved MIME type for "${e}": ${a}`),a}isAudioEnabled(){return this.isEnabled}setOnPlaybackStart(e){this.onPlaybackStart=e}setOnPlaybackEnd(e){this.onPlaybackEnd=e}setOnChunkPlayed(e){this.onChunkPlayed=e}async addChunk(e){if(!this.isEnabled){D(`[AudioStreamManager] Audio disabled, dropping chunk ${e.chunkIndex}`);return}D(`[AudioStreamManager] Adding chunk ${e.chunkIndex} to queue`),this.audioQueue.push(e),this.audioQueue.sort((r,a)=>r.chunkIndex-a.chunkIndex),this.isPlaying||this.playNextChunk().catch(r=>{xe("[AudioStreamManager] Playback chain error:",r)})}async playNextChunk(){var r,a;if(this.audioQueue.length===0){this.isPlaying=!1,D("[AudioStreamManager] Queue empty, playback complete"),this.onPlaybackEnd&&this.onPlaybackEnd();return}if(!this.isEnabled){D("[AudioStreamManager] Audio not enabled, skipping playback"),this.audioQueue=[],this.isPlaying=!1;return}this.suppressPlaybackErrors=!1,await this.ensureAudioContext(),this.isPlaying=!0;const e=this.audioQueue.shift();try{if(!this.isPlaying)return;if(this.onPlaybackStart&&e.chunkIndex===0&&this.onPlaybackStart(),D(`[AudioStreamManager] Playing chunk ${e.chunkIndex}`),!e.audio||e.audio.length===0)throw new Error(`Empty audio data for chunk ${e.chunkIndex}`);let s;try{s=atob(e.audio)}catch(f){throw new Error(`Failed to decode base64 audio for chunk ${e.chunkIndex}: ${f instanceof Error?f.message:String(f)}`)}if(s.length===0)throw new Error(`Decoded audio data is empty for chunk ${e.chunkIndex}`);const i=new Uint8Array(s.length);for(let f=0;f<s.length;f++)i[f]=s.charCodeAt(f);const o=this.resolveMimeType(e.audioFormat),l=new Blob([i],{type:o}),c=URL.createObjectURL(l);this.blobUrls.push(c);const d=()=>{if(this.currentAudio){try{this.currentAudio.pause()}catch{}this.currentAudio.removeAttribute("src"),this.currentAudio.load()}URL.revokeObjectURL(c),this.blobUrls=this.blobUrls.filter(f=>f!==c)};let u=!1;try{u=await this.playViaAudioElement(c,e,d)}catch{u=!1}if(!u&&!this.suppressPlaybackErrors&&this.audioContext){D(`[AudioStreamManager] HTMLAudioElement failed for chunk ${e.chunkIndex}, trying AudioContext fallback`);try{u=await this.playViaAudioContext(i.buffer,e.chunkIndex)}catch(f){xe(`[AudioStreamManager] AudioContext fallback also failed for chunk ${e.chunkIndex}:`,f)}d()}this.currentAudio=null,this.playNextChunk().catch(f=>{xe("[AudioStreamManager] Playback chain error:",f)})}catch(s){if(this.suppressPlaybackErrors){D("[AudioStreamManager] Playback stopped, suppressing audio error");return}const i=s instanceof Error?s.message:String(s);console.error(`[AudioStreamManager] Failed to play chunk ${e.chunkIndex}:`,i,s,{audioFormat:e.audioFormat,chunkIndex:e.chunkIndex,audioLength:(r=e.audio)==null?void 0:r.length,audioContextState:(a=this.audioContext)==null?void 0:a.state,isEnabled:this.isEnabled}),xe(`[AudioStreamManager] Failed to play chunk ${e.chunkIndex}:`,s),this.playNextChunk().catch(o=>{xe("[AudioStreamManager] Playback chain error after recovery:",o)})}}playViaAudioElement(e,r,a){return new Promise(s=>{const i=new Audio;i.setAttribute("playsinline",""),i.setAttribute("webkit-playsinline",""),i.src=e,this.currentAudio=i;let o=!1;const l=u=>{o||(o=!0,s(u))},c=()=>{if(this.suppressPlaybackErrors){a(),l(!0);return}const u=i.error;xe(`[AudioStreamManager] Media error on chunk ${r.chunkIndex}:`,u?{code:u.code,message:u.message,SRC_NOT_SUPPORTED:u.code===MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED}:"unknown"),a(),l(!1)};i.addEventListener("error",c,{once:!0});const d=async()=>{if(!o)try{i.addEventListener("ended",()=>{o||(D(`[AudioStreamManager] Chunk ${r.chunkIndex} finished`),this.onChunkPlayed&&this.onChunkPlayed(r.chunkIndex),a(),l(!0))},{once:!0}),await i.play()}catch(u){if(this.suppressPlaybackErrors){a(),l(!0);return}D(`[AudioStreamManager] audio.play() rejected for chunk ${r.chunkIndex}:`,u),a(),l(!1)}};i.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?d():i.addEventListener("canplay",()=>d(),{once:!0})})}playViaAudioContext(e,r){return new Promise((a,s)=>{if(!this.audioContext){s(new Error("No AudioContext"));return}const i=e.slice(0);this.audioContext.decodeAudioData(i,o=>{if(!this.audioContext||this.suppressPlaybackErrors){a(!0);return}const l=this.audioContext.createBufferSource();l.buffer=o,l.connect(this.audioContext.destination),l.onended=()=>{D(`[AudioStreamManager] Chunk ${r} finished (AudioContext path)`),this.onChunkPlayed&&this.onChunkPlayed(r),a(!0)},l.start(0)},o=>{s(o)})})}stop(){D("[AudioStreamManager] Stopping playback"),this.suppressPlaybackErrors=!0,this.isPlaying=!1,this.audioQueue=[],this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.src="",this.currentAudio=null),this.blobUrls.forEach(e=>URL.revokeObjectURL(e)),this.blobUrls=[]}reset(){this.stop(),D("[AudioStreamManager] Manager reset")}getQueueSize(){return this.audioQueue.length}isCurrentlyPlaying(){return this.isPlaying}}const Bt=new tu,ru=tc()||Ul(),Oi=()=>{if(Ts())return Sa()||void 0},Fr="",su=["New Chat","New Conversation"],au=t=>t&&!su.includes(t)?t:Fr,$r=(t,e,r)=>({id:t,sessionId:e,title:Fr,messages:[],createdAt:new Date,updatedAt:new Date,apiUrl:r,adapterName:Oi(),adapterLoadError:null}),Cs=()=>{const t=localStorage.getItem("chatbot-session-id");if(t)return t;const e=`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return localStorage.setItem("chatbot-session-id",e),e},nu=t=>{localStorage.setItem("chatbot-session-id",t)};let iu=0;const lr=t=>{const e=Date.now(),r=++iu,a=Math.random().toString(36).substr(2,9);return`msg_${e}_${r}_${a}_${t}`},Ht=()=>{const t=Date.now(),e=Math.random().toString(36).substr(2,9);return`session_${t}_${e}`},Ui=t=>{const e=new Set;let r=!1;const a=t.map(s=>{if(!e.has(s.id))return e.add(s.id),s;r=!0;const i={...s,id:lr(s.role)};return e.add(i.id),pe(`[chatStore] Re-keyed duplicate message id ${s.id}`),i});return r?a:t},On=t=>t.filter(e=>!e.isThreadMessage&&!(e.role==="assistant"&&e.isStreaming)).length,Un=t=>t.flatMap(r=>[r.imageUrl,r.videoUrl,r.documentUrl]).map(r=>{var a;return((a=r==null?void 0:r.match(/\/api\/files\/([^/]+)\/content/))==null?void 0:a[1])??null}).filter(r=>r!==null),ou=(t,e)=>{if(t instanceof Date)return new Date(t);if(typeof t=="number"&&Number.isFinite(t)){const r=new Date(t);if(!Number.isNaN(r.getTime()))return r}if(typeof t=="string"){const r=new Date(t);if(!Number.isNaN(r.getTime()))return r}return e?new Date(e):new Date},lu=(t,e)=>{const r=new Map;e.forEach((s,i)=>{s.databaseMessageId&&r.set(s.databaseMessageId,{message:s,index:i})});const a=new Set;return t.map((s,i)=>{var f;const o=s.role==="user"?"user":"assistant",l=typeof s.message_id=="string"&&s.message_id.length>0?s.message_id:void 0;let c;if(l&&r.has(l)){const m=r.get(l);c=m.message,a.add(m.index)}else{const m=i<e.length?i:0;if(!a.has(m)&&((f=e[m])==null?void 0:f.role)===o)c=e[m],a.add(m);else for(let h=1;h<e.length;h++){const p=(m+h)%e.length;if(!a.has(p)&&e[p].role===o){c=e[p],a.add(p);break}}}const d=s.timestamp?ou(s.timestamp,c==null?void 0:c.timestamp):c!=null&&c.timestamp?new Date(c.timestamp):new Date,u=c?{...c,content:s.content??c.content,timestamp:d}:{id:l?`srv_${l}`:lr(o),content:s.content||"",role:o,timestamp:d};if(u.isStreaming=!1,l&&(u.databaseMessageId=l),!u.supportsThreading&&s.metadata&&typeof s.metadata=="object"){const m=s.metadata,h=m==null?void 0:m.retrieved_docs;Array.isArray(h)&&h.length>0&&(u.supportsThreading=!0)}return u})},cu=(t,e)=>{if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++){const a=t[r],s=e[r];if(a.role!==s.role||a.content!==s.content||(a.databaseMessageId||null)!==(s.databaseMessageId||null)||+a.timestamp!=+s.timestamp)return!1}return!0},zi=t=>{var s,i,o,l,c,d;const e=((i=(s=t.adapterInfo)==null?void 0:s.adapter_name)==null?void 0:i.includes("voice"))||((l=(o=t.adapterInfo)==null?void 0:o.adapter_name)==null?void 0:l.includes("audio"))||((d=(c=t.adapterInfo)==null?void 0:c.adapter_name)==null?void 0:d.includes("multilingual"));let r=!1;try{const u=localStorage.getItem("chat-settings");u&&(r=JSON.parse(u).voiceEnabled===!0)}catch{pe("Failed to read global voice setting")}const a=t.audioSettings;return{returnAudio:(a==null?void 0:a.enabled)??r??!!e,ttsVoice:(a==null?void 0:a.ttsVoice)||void 0,language:(a==null?void 0:a.language)||"en-US",audioFormat:a==null?void 0:a.audioFormat}},du=300;let cs=null;const Ve=t=>{cs&&clearTimeout(cs),cs=setTimeout(()=>{cs=null;try{const e=t(),r=e.conversations.map(a=>({...a,messages:a.messages.map(s=>s.audio||s.image||s.video||s.document?Object.fromEntries(Object.entries(s).filter(([o])=>o!=="audio"&&o!=="image"&&o!=="video"&&o!=="document")):s)}));localStorage.setItem("chat-state",JSON.stringify({conversations:r,currentConversationId:e.currentConversationId}))}catch(e){e instanceof DOMException&&e.name==="QuotaExceededError"?pe("[chatStore] localStorage quota exceeded — skipping save"):Oe("[chatStore] Failed to save state to localStorage:",e)}},du)},uu=32,cr=new Map;let zt=null,ot=null,Lt=null,er=null;const ba=(t,e)=>{const r=cr.get(t);if(r){if(r.timeoutId&&(clearTimeout(r.timeoutId),r.timeoutId=null),r.content){const a=r.content,s=r.messageId;r.content="",e(i=>({conversations:i.conversations.map(o=>{if(o.id!==t)return o;const l=[...o.messages],c=s?l.findIndex(u=>u.id===s):l.length-1,d=c!==-1?l[c]:void 0;return d&&d.role==="assistant"&&d.isStreaming&&(l[c]={...d,content:d.content+a}),{...o,messages:l,updatedAt:new Date}})}))}cr.delete(t)}},vt=(t,e,r,a)=>({conversations:t.conversations.map(s=>{var l;if(s.id!==e)return s;const i=[...s.messages],o=a?i.findIndex(c=>c.id===a):i.length-1;return o!==-1&&((l=i[o])==null?void 0:l.role)==="assistant"&&(i[o]={...i[o],...r(i[o])}),{...s,messages:i,updatedAt:new Date}})});let Ns=!1,As="";async function Er(){if(Ns&&As)return!0;try{const t=await Fe(),e=localStorage.getItem("chat-api-url");e&&e===ua&&localStorage.removeItem("chat-api-url");const r=e&&e!==ua?e:$e(),a=Cs(),s=localStorage.getItem("chat-adapter-name")||ru;return t.configureApi(r,a,s),As=r,Ns=!0,!0}catch(t){return Oe("Failed to configure API:",t),!1}}async function zn(t,e,r,a,s,i,o,l,c){let d=!1;const u=new AbortController;zt=u,er=a,ot=null;try{const f=t().conversations.find(y=>y.id===a);if(!f)throw new Error("Conversation not found");if(!f.adapterName)throw new Error("Adapter not configured for this conversation. Please select an adapter first.");Lt=f.sessionId,f.sessionId&&(await Fe()).configureApi(it(f.apiUrl),f.sessionId,f.adapterName);const m=await Fe(),{returnAudio:h,ttsVoice:p,language:x}=zi(f);for await(const y of m.streamChat(s,!0,i.length>0?i:void 0,void 0,void 0,void 0,x,h,p,void 0,void 0,o,void 0,c)){if(y.request_id&&!ot&&(ot=y.request_id,D(`[chatStore] >>> CAPTURED request_id for ${l} stop: ${y.request_id}`)),y.text){const k=Or(y.text);k?(t().appendToLastMessage(k,a,r),d=!0):y.text.length>100&&pe("[chatStore] Filtered out potential base64 audio data from regenerated message content")}if(y.audio&&y.done&&e(k=>vt(k,a,()=>({audio:y.audio,audioFormat:y.audioFormat||"mp3"}),r)),y.image&&y.done&&(d=!0,e(k=>vt(k,a,()=>({image:y.image,imageFormat:y.image_format||"png",imageRevisedPrompt:y.image_revised_prompt,imageUrl:y.image_url}),r))),(y.video||y.video_url)&&y.done&&(d=!0,e(k=>vt(k,a,()=>({video:y.video,videoFormat:y.video_format||"mp4",videoRevisedPrompt:y.video_revised_prompt,videoUrl:y.video_url}),r))),(y.document||y.document_url)&&y.done&&(d=!0,e(k=>vt(k,a,()=>({document:y.document,documentFormat:y.document_format||"pdf",documentRevisedPrompt:y.document_revised_prompt,documentUrl:y.document_url}),r))),y.generated_audio_url&&y.done&&(d=!0,e(k=>vt(k,a,()=>({generatedAudioFormat:y.generated_audio_format||"mp3",generatedAudioRevisedPrompt:y.generated_audio_revised_prompt,generatedAudioUrl:y.generated_audio_url}),r))),y.done){const k=y.threading;k!=null&&k.supports_threading&&e(N=>({conversations:N.conversations.map(A=>A.id!==a?A:{...A,messages:A.messages.map(v=>v.id===r?{...v,supportsThreading:!0,databaseMessageId:k.message_id}:v),updatedAt:new Date})})),y.assistant_message_id&&e(N=>({conversations:N.conversations.map(A=>A.id!==a?A:{...A,messages:A.messages.map(v=>v.id===r&&!v.databaseMessageId?{...v,databaseMessageId:y.assistant_message_id}:v),updatedAt:new Date})}));break}}!d&&!u.signal.aborted&&t().appendToLastMessage("No response received from the server. Please try again later.",a,r)}catch(f){if(f instanceof Error&&(f.name==="AbortError"||f.message==="Stream cancelled by user"||f.message.includes("aborted")))D(`[chatStore] ${l==="edit-regenerate"?"Edit-regenerate":"Regeneration"} stream was cancelled by user`),d=!0;else{Oe(`${l==="edit-regenerate"?"Edit-regenerate":"Regenerate"} API error:`,f);let h="Sorry, there was an error regenerating the response.";f instanceof Error&&(f.message.startsWith("Server error:")?h=f.message.substring(14):(f.message.includes("Could not connect")||f.message.includes("timed out"))&&(h=f.message)),t().appendToLastMessage(h,a,r)}}zt=null,ot=null,Lt=null,er=null,ba(a,e),e(f=>{const m=f.conversations.map(p=>p.id===a?{...p,messages:p.messages.map(x=>x.id===r?{...x,isStreaming:!1}:x),updatedAt:new Date}:p),h=m.find(p=>p.id===f.currentConversationId);return{conversations:m,isLoading:h?h.messages.some(p=>p.role==="assistant"&&p.isStreaming):!1}})}const ke=Di((t,e)=>({conversations:[],currentConversationId:null,isLoading:!1,error:null,sessionId:Cs(),getSessionId:()=>e().sessionId,configureApiSettings:async(r,a,s)=>{const i=e(),o=i.conversations.find(c=>c.id===i.currentConversationId),l=(o==null?void 0:o.sessionId)||a||Cs();a&&nu(a),t({sessionId:l});try{const c=await Fe();if(!s||!s.trim())throw new Error("Adapter name is required");c.configureApi(r,l,s),As=r,Ns=!0;let d;try{const u=new c.ApiClient({apiUrl:r,sessionId:null,adapterName:s});typeof u.getAdapterInfo=="function"&&(d=await u.getAdapterInfo(),D("Adapter info loaded:",d))}catch(u){pe("Failed to load adapter info:",u)}if(o)t(u=>({conversations:u.conversations.map(f=>f.id===o.id?{...f,adapterName:s,apiUrl:r,adapterInfo:d,adapterLoadError:null,updatedAt:new Date}:f)}));else if(s&&s.trim()){const u=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,f=Ht();t(m=>({conversations:[...m.conversations,{id:u,sessionId:f,title:Fr,messages:[],createdAt:new Date,updatedAt:new Date,adapterName:s,apiUrl:r,adapterInfo:d,adapterLoadError:null}],currentConversationId:u}))}}catch(c){throw xe("Failed to configure API:",c),t({isLoading:!1}),c instanceof Error?c:new Error("Failed to configure API settings")}s?localStorage.setItem("chat-adapter-name",s):localStorage.removeItem("chat-adapter-name"),t({isLoading:!1})},createConversation:()=>{var u;const r=e(),a=le.maxConversations,s=r.conversations.length,i=r.currentConversationId?r.conversations.find(f=>f.id===r.currentConversationId):null;if(a!==null&&s>=a){if(rt()&&!xt()){const m=`You've reached the guest limit of ${a} conversation${a===1?"":"s"}. Sign in to unlock more conversations, or delete conversations to start over.`;throw t({error:m}),st.getState().openLoginPrompt(m),new Error("Guest conversation limit reached")}const f=`Maximum of ${a} conversations reached. Please delete an existing conversation before starting a new one.`;throw t({error:f}),new Error(f)}const o=!!i&&(i.messages.length>0||(((u=i.attachedFiles)==null?void 0:u.length)||0)>0);if(i&&!o){const f="Finish or delete the current conversation before starting a new one.";throw t({error:f}),new Error(f)}const l=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,c=Ht(),d={id:l,sessionId:c,title:Fr,messages:[],createdAt:new Date,updatedAt:new Date,apiUrl:$e(),adapterName:Oi(),adapterLoadError:null};return t(f=>({conversations:[d,...f.conversations],currentConversationId:l,sessionId:c,isLoading:!1})),Ve(e),l},selectConversation:async r=>{const a=e().conversations.find(s=>s.id===r);if(a){const s=a.messages.some(c=>c.role==="assistant"&&c.isStreaming);t({currentConversationId:r,sessionId:a.sessionId,isLoading:s});const i=a.apiUrl||$e(),o=a.adapterName;if(await Er()&&o){const c=await Fe();if(c.configureApi(i,a.sessionId,o),!a.adapterInfo)try{const d=new c.ApiClient({apiUrl:i,sessionId:null,adapterName:o});if(typeof d.getAdapterInfo=="function"){const u=await d.getAdapterInfo();D("Adapter info loaded for conversation:",u),t(f=>({conversations:f.conversations.map(m=>m.id===r?{...m,adapterInfo:u,adapterLoadError:null,updatedAt:new Date}:m)})),Ve(e)}}catch(d){pe("Failed to load adapter info for conversation:",d)}}e().loadFeedbackForConversation(a.sessionId).catch(()=>{})}Ve(e)},deleteConversation:async r=>{var i,o;const a=e(),s=a.conversations.find(l=>l.id===r);if(D(`🗑️ Deleting conversation ${r}:`,{conversationId:r,sessionId:s==null?void 0:s.sessionId,title:s==null?void 0:s.title,messageCount:s==null?void 0:s.messages.length,fileCount:((i=s==null?void 0:s.attachedFiles)==null?void 0:i.length)||0}),a.currentConversationId===r&&Bt.stop(),s!=null&&s.sessionId)try{if(!await Er())Oe("Failed to configure API for conversation deletion");else{const c=s.apiUrl||$e(),d=s.adapterName;d?D(`Using conversation's adapter for deletion: ${d} (conversation: ${r})`):pe(`Skipping server deletion for conversation ${r}: adapter not configured`);const u=await Fe(),f=new u.ApiClient({apiUrl:c,sessionId:s.sessionId,adapterName:d}),m=((o=s.attachedFiles)==null?void 0:o.map(x=>x.file_id))||[],h=Un(s.messages||[]),p=[...m,...h];if(D(`🔧 Calling deleteConversationWithFiles for session: ${s.sessionId}`),f.deleteConversationWithFiles){const x=await f.deleteConversationWithFiles(s.sessionId,p);D(`✅ Deleted conversation and files for session: ${s.sessionId}`,x),D(` - Deleted ${x.deleted_messages} messages`),D(` - Deleted ${x.deleted_files} files`),x.file_deletion_errors&&x.file_deletion_errors.length>0&&pe(` - Errors deleting files: ${x.file_deletion_errors.join(", ")}`)}else pe("⚠️ deleteConversationWithFiles method not available on API client")}}catch(l){Oe("Failed to clear conversation history from server:",l)}else pe(`⚠️ No session ID found for conversation ${r}, skipping server-side deletion`);t(l=>{var u;const c=l.conversations.filter(f=>f.id!==r),d=l.currentConversationId===r?((u=c[0])==null?void 0:u.id)||null:l.currentConversationId;if(c.length===0){const f=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,m=Ht(),h=$r(f,m,$e());return Ve(e),{conversations:[h],currentConversationId:f,sessionId:m}}return Ve(e),{conversations:c,currentConversationId:d}})},deleteAllConversations:async()=>{const a=[...e().conversations];D(`🗑️ Deleting all conversations (${a.length} total)`),Bt.stop();const s=a.map(async u=>{var f;if(u!=null&&u.sessionId)try{if(!await Er()){Oe("Failed to configure API for conversation deletion");return}const h=u.adapterName;if(!h){D(`Skipping server deletion for conversation ${u.id}: adapter not configured`);return}const p=await Fe(),x=new p.ApiClient({apiUrl:it(u.apiUrl),sessionId:u.sessionId,adapterName:h}),y=[...((f=u.attachedFiles)==null?void 0:f.map(k=>k.file_id))||[],...Un(u.messages||[])];x.deleteConversationWithFiles?(await x.deleteConversationWithFiles(u.sessionId,y),D(`✅ Deleted conversation ${u.id} and files`)):pe(`deleteConversationWithFiles not available for conversation ${u.id}`)}catch(m){Oe(`Failed to delete conversation ${u.id} from server:`,m)}}),o=(await Promise.allSettled(s)).filter(u=>u.status==="rejected");o.length>0&&Oe(`Some conversations failed to delete from server: ${o.length}`,o);const l=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,c=Ht(),d=$r(l,c,$e());t({conversations:[d],currentConversationId:l,sessionId:c}),Ve(e)},deleteThread:async(r,a,s)=>{const i=e().conversations.find(f=>f.id===r);if(!i)throw new Error("Conversation not found");if(!i.adapterName)throw new Error("Adapter not configured for this conversation");const o=i.messages.find(f=>f.id===a);if(!(o!=null&&o.threadInfo)||o.threadInfo.thread_id!==s)throw new Error("Thread not found for this message");const l=it(i.apiUrl||$e()),c=await Fe(),d=new c.ApiClient({apiUrl:l,sessionId:i.sessionId,adapterName:i.adapterName});await new(await jt(async()=>{const{ThreadService:f}=await import("./threadService-B9Db3n0J.js");return{ThreadService:f}},[])).ThreadService(d).deleteThread(s),t(f=>({conversations:f.conversations.map(m=>{var x;if(m.id!==r)return m;const h=m.messages.filter(y=>y.isThreadMessage?!(y.threadId===s||y.parentMessageId===a):!0).map(y=>y.id!==a?y:{...y,threadInfo:void 0,supportsThreading:!0}),p=m.currentThreadId===s||m.currentThreadSessionId===((x=o.threadInfo)==null?void 0:x.thread_session_id);return{...m,messages:h,currentThreadId:p?void 0:m.currentThreadId,currentThreadSessionId:p?void 0:m.currentThreadSessionId,updatedAt:new Date}})})),Ve(e)},sendMessage:async(r,a,s,i,o)=>{var c;let l=null;try{if(e().isLoading){pe("Another request is already in progress");return}if(!await Er())throw new Error("API not properly configured. Please configure API settings first.");let u=e().currentConversationId;u||(u=e().createConversation());const f=e().conversations.find(b=>b.id===u);if(!f)throw new Error("Conversation not found");const m=le.maxConversations;if(rt()&&!xt()&&m!==null&&e().conversations.length>m){st.getState().openLoginPrompt(`You've reached the guest limit of ${m} conversation${m===1?"":"s"}. Sign in to continue chatting.`),t({isLoading:!1});return}const h=a?a.map(b=>{var S;const _=(S=f==null?void 0:f.attachedFiles)==null?void 0:S.find(I=>I.file_id===b);return _||{file_id:b,filename:"",mime_type:"",file_size:0}}).filter(b=>b!==void 0):[];h.length>0&&h.forEach(b=>{e().addFileToConversation(u,b)});const p=s||null;let x,y=null;if(p){if(x=f.messages.find(b=>{var _;return((_=b.threadInfo)==null?void 0:_.thread_id)===p}),!x)throw new Error("Thread metadata not found. Please recreate the thread from this message.");if(y=((c=x.threadInfo)==null?void 0:c.thread_session_id)||null,!y)throw new Error("Thread session is missing. Please recreate the thread from this message.")}const k=On(f.messages),N=le.maxMessagesPerConversation;if(N!==null&&k>=N){rt()&&!xt()&&st.getState().openLoginPrompt(`You've reached the guest limit of ${N} messages per conversation. Sign in to send more messages, or delete conversations to start over.`),pe(`[chatStore] Conversation ${u} reached the message limit (${N}).`),t({isLoading:!1});return}const A=le.maxTotalMessages;if(A!==null&&e().conversations.reduce((_,S)=>_+On(S.messages),0)>=A){rt()&&!xt()&&st.getState().openLoginPrompt(`You've reached the guest limit of ${A} total messages. Sign in to continue chatting, or delete conversations to start over.`),pe(`[chatStore] Workspace reached the total message limit (${A}).`),t({isLoading:!1});return}const v={id:lr("user"),content:r,role:"user",timestamp:new Date,attachments:h.length>0?h:void 0},C=lr("assistant"),E={id:C,content:"",role:"assistant",timestamp:new Date,isStreaming:!0,model:i};if(p&&x){v.isThreadMessage=!0,v.threadId=p,v.parentMessageId=x.id,E.isThreadMessage=!0,E.threadId=p,E.parentMessageId=x.id;const b=le.maxMessagesPerThread;if(b!==null&&f.messages.filter(S=>S.isThreadMessage?(S.threadId===p||S.parentMessageId===x.id)&&!(S.role==="assistant"&&S.isStreaming):!1).length>=b){rt()&&!xt()&&st.getState().openLoginPrompt(`You've reached the guest limit of ${b} messages per thread. Sign in to continue this thread, or delete conversations to start over.`),pe(`[chatStore] Thread ${p} reached the message limit (${b}).`),t({isLoading:!1});return}}t(b=>{const _=b.conversations.find(I=>I.id===u),S=(_==null?void 0:_.messages.filter(I=>I.role==="assistant"&&I.isStreaming))||[];return S.length>0&&pe(`Cleaning up ${S.length} existing streaming messages`),{conversations:b.conversations.map(I=>{if(I.id!==u)return I;const M=I.messages.filter(F=>!(F.role==="assistant"&&F.isStreaming));return{...I,messages:[...M,v,E],updatedAt:new Date,title:I.messages.length===0?r.slice(0,50)+(r.length>50?"...":""):I.title}}),isLoading:!0,error:null}}),l=u;let P=!1;Bt.reset();try{const b=e().conversations.find(T=>T.id===l);if(!b)throw new Error("Conversation not found");if(!b.adapterName)throw new Error("Adapter not configured for this conversation. Please select an adapter first.");const _=it(b.apiUrl),S=b.adapterName,I=y||b.sessionId,M=await Fe();M.configureApi(_,I,S),p&&I!==b.sessionId&&D(`[chatStore] Thread mode: using thread session ${I} (original: ${b.sessionId})`);const{returnAudio:F,ttsVoice:z,language:j,audioFormat:L}=zi(b);D("[chatStore] Audio settings:",{returnAudio:F,ttsVoice:z,language:j,audioFormat:L});const R=new AbortController;zt=R,Lt=I,er=l,ot=null;for await(const T of M.streamChat(r,!0,a,p||void 0,void 0,void 0,j,F,z,void 0,void 0,i,o)){if(T.request_id&&!ot&&(ot=T.request_id,D(`[chatStore] >>> CAPTURED request_id for stop: ${T.request_id}`)),T.audio_chunk&&Bt.addChunk({audio:T.audio_chunk,audioFormat:T.audioFormat||"opus",chunkIndex:T.chunk_index??0}),T.text){const K=Or(T.text);K?(e().appendToLastMessage(K,l,C),P=!0):T.text.length>100&&pe("[chatStore] Filtered out potential base64 audio data from message content")}if(T.audio&&T.done&&t(K=>vt(K,l,()=>({audio:T.audio,audioFormat:T.audioFormat||"mp3"}),C)),T.image&&T.done&&(P=!0,t(K=>vt(K,l,()=>({image:T.image,imageFormat:T.image_format||"png",imageRevisedPrompt:T.image_revised_prompt,imageUrl:T.image_url}),C))),(T.video||T.video_url)&&T.done&&(P=!0,t(K=>vt(K,l,()=>({video:T.video,videoFormat:T.video_format||"mp4",videoRevisedPrompt:T.video_revised_prompt,videoUrl:T.video_url}),C))),(T.document||T.document_url)&&T.done&&(P=!0,t(K=>vt(K,l,()=>({document:T.document,documentFormat:T.document_format||"pdf",documentRevisedPrompt:T.document_revised_prompt,documentUrl:T.document_url}),C))),T.generated_audio_url&&T.done&&(P=!0,t(K=>vt(K,l,()=>({generatedAudioFormat:T.generated_audio_format||"mp3",generatedAudioRevisedPrompt:T.generated_audio_revised_prompt,generatedAudioUrl:T.generated_audio_url}),C))),T.done){D("[chatStore] Stream completed, receivedAnyText:",P);const K=T.threading;K!=null&&K.supports_threading&&t(G=>({conversations:G.conversations.map(H=>H.id!==l?H:{...H,messages:H.messages.map(Z=>Z.id===C?{...Z,supportsThreading:!0,databaseMessageId:K.message_id}:Z),updatedAt:new Date})})),T.assistant_message_id&&t(G=>({conversations:G.conversations.map(H=>H.id!==l?H:{...H,messages:H.messages.map(Z=>Z.id===C&&!Z.databaseMessageId?{...Z,databaseMessageId:T.assistant_message_id}:Z),updatedAt:new Date})}));break}}!P&&!R.signal.aborted&&e().appendToLastMessage("No response received from the server. Please try again later.",l,C)}catch(b){if(b instanceof Error&&(b.name==="AbortError"||b.message==="Stream cancelled by user"||b.message.includes("aborted")))D("[chatStore] Stream was cancelled by user"),P=!0;else{Oe("Chat API error:",b);let S="Sorry, there was an error processing your request.";b instanceof Error&&(b.message.startsWith("Server error:")?S=b.message.substring(14):(b.message.includes("Could not connect")||b.message.includes("timed out"))&&(S=b.message)),e().appendToLastMessage(S,l,C)}}zt=null,ot=null,Lt=null,er=null,ba(l,t),t(b=>{const _=b.conversations.map(I=>I.id===l?{...I,messages:I.messages.map(M=>M.id===C?{...M,isStreaming:!1}:M),updatedAt:new Date}:I),S=_.find(I=>I.id===b.currentConversationId);return{conversations:_,isLoading:S?S.messages.some(I=>I.role==="assistant"&&I.isStreaming):!1}}),Ve(e)}catch(d){Oe("Chat store error:",d),t(u=>({isLoading:!1,...u.currentConversationId===l&&{error:`Failed to send message: ${d instanceof Error?d.message:"Unknown error"}`}}))}},createThread:async(r,a)=>{try{const s=e().conversations.find(m=>m.sessionId===a);if(!s)throw new Error("Conversation not found for session");if(!s.adapterName)throw new Error("Adapter not configured for this conversation");const i=s.messages.find(m=>m.id===r);if(!i)throw new Error("Message not found");const o=i.databaseMessageId||r,l=it(s.apiUrl||$e()),c=await Fe(),d=new c.ApiClient({apiUrl:l,sessionId:a,adapterName:s.adapterName}),f=await new(await jt(async()=>{const{ThreadService:m}=await import("./threadService-B9Db3n0J.js");return{ThreadService:m}},[])).ThreadService(d).createThread(o,a);t(m=>({conversations:m.conversations.map(h=>h.sessionId!==a?h:{...h,messages:h.messages.map(p=>p.id===r?{...p,threadInfo:f,supportsThreading:!0}:p),currentThreadId:void 0,currentThreadSessionId:void 0})})),D(`[chatStore] Created thread ${f.thread_id} for message ${r}`)}catch(s){throw Oe("Failed to create thread:",s),s}},appendToLastMessage:(r,a,s)=>{const i=Or(r);if(!i&&r){pe("[chatStore] Filtered out base64 audio data from message content");return}const o=xa(i),l=a||e().currentConversationId;if(!l)return;const c=l,d=cr.get(c);d?(d.content+=o,d.messageId=s,d.timeoutId&&clearTimeout(d.timeoutId)):cr.set(c,{content:o,timeoutId:null,messageId:s});const u=()=>{const m=cr.get(c);if(!m||!m.content)return;const h=m.content,p=m.messageId;m.content="",m.timeoutId=null,t(x=>({conversations:x.conversations.map(y=>{if(y.id!==l)return y;const k=[...y.messages],N=p?k.findIndex(v=>v.id===p):k.length-1,A=N!==-1?k[N]:void 0;return A&&A.role==="assistant"&&A.isStreaming&&(k[N]={...A,content:A.content+h}),{...y,messages:k,updatedAt:new Date}})}))},f=cr.get(c);f.timeoutId=setTimeout(u,uu)},regenerateResponse:async(r,a)=>{let s=null;try{if(e().isLoading){pe("Another request is already in progress");return}if(!await Er())throw new Error("API not properly configured");const o=e(),l=o.conversations.find(h=>h.id===o.currentConversationId);if(!l)return;const c=l.messages.findIndex(h=>h.id===r);if(c===-1)return;const d=l.messages[c];if(!d||d.role!=="assistant")return;const u=l.messages[c-1];if(!u||u.role!=="user")return;const f=(u.attachments||[]).map(h=>h.file_id).filter(h=>typeof h=="string"&&h.length>0),m=lr("assistant");if(t(h=>({conversations:h.conversations.map(p=>p.id===h.currentConversationId?{...p,messages:[...p.messages.slice(0,c),{id:m,content:"",role:"assistant",timestamp:new Date,isStreaming:!0,model:a,supportsThreading:d.supportsThreading,databaseMessageId:d.databaseMessageId,threadInfo:d.threadInfo,threadId:d.threadId,parentMessageId:d.parentMessageId,isThreadMessage:d.isThreadMessage},...p.messages.slice(c+1)],updatedAt:new Date}:p),isLoading:!0,error:null})),s=o.currentConversationId,!s)throw new Error("No conversation selected");await zn(e,t,m,s,u.content,f,a,"regenerate",d.databaseMessageId)}catch(i){Oe("Regenerate error:",i),t(o=>({isLoading:!1,...o.currentConversationId===s&&{error:`Failed to regenerate response: ${i instanceof Error?i.message:"Unknown error"}`}}))}},editMessageAndRegenerate:async(r,a,s)=>{let i=null;try{if(e().isLoading){await e().stopStreaming();const x=e().currentConversationId;x&&ba(x,t)}const o=e(),l=o.conversations.find(x=>x.id===o.currentConversationId);if(!l)return;const c=l.messages.findIndex(x=>x.id===r);if(c===-1)return;const d=l.messages[c];if(d.role!=="user")return;const u=(d.attachments||[]).map(x=>x.file_id).filter(x=>typeof x=="string"&&x.length>0),f=lr("assistant"),m=l.messages[c+1],h=(m==null?void 0:m.role)==="assistant",p=h?c+2:c+1;if(t(x=>({conversations:x.conversations.map(y=>y.id===x.currentConversationId?{...y,messages:[...y.messages.slice(0,c),{...d,content:a,updatedAt:new Date},{id:f,content:"",role:"assistant",timestamp:new Date,isStreaming:!0,model:s,supportsThreading:h?m.supportsThreading:void 0,databaseMessageId:h?m.databaseMessageId:void 0,threadInfo:h?m.threadInfo:void 0,threadId:h?m.threadId:void 0,parentMessageId:h?m.parentMessageId:void 0,isThreadMessage:h?m.isThreadMessage:void 0},...y.messages.slice(p)],updatedAt:new Date}:y),isLoading:!0,error:null})),i=o.currentConversationId,!i)throw new Error("No conversation selected");await zn(e,t,f,i,a,u,s,"edit-regenerate",h?m.databaseMessageId:void 0),Ve(e)}catch(o){Oe("Edit & regenerate error:",o),t(l=>({isLoading:!1,...l.currentConversationId===i&&{error:`Failed to regenerate response: ${o instanceof Error?o.message:"Unknown error"}`}}))}},updateConversationTitle:(r,a)=>{t(s=>({conversations:s.conversations.map(i=>i.id===r?{...i,title:a,updatedAt:new Date}:i)})),Ve(e)},clearError:()=>t({error:null}),cleanupStreamingMessages:()=>{const r=er;t(a=>{let s=!1;return{conversations:a.conversations.map(o=>o.id===r?(o.messages.some(c=>c.role==="assistant"&&c.isStreaming)&&(s=!0),o):o.messages.some(c=>c.role==="assistant"&&c.isStreaming)?{...o,messages:o.messages.filter(c=>!(c.role==="assistant"&&c.isStreaming)),updatedAt:new Date}:o),isLoading:s}})},canCreateNewConversation:()=>{var o;const r=e(),a=le.maxConversations;if(!r.currentConversationId)return a===null||r.conversations.length<a;const s=r.conversations.find(l=>l.id===r.currentConversationId);return!!s&&(s.messages.length>0||(((o=s.attachedFiles)==null?void 0:o.length)||0)>0)?a===null||r.conversations.length<a:!1},getConversationCount:()=>e().conversations.length,addFileToConversation:(r,a)=>{D("[chatStore] addFileToConversation called",{conversationId:r,fileId:a.file_id,filename:a.filename}),t(s=>({conversations:s.conversations.map(i=>i.id===r?{...i,attachedFiles:[...(i.attachedFiles||[]).filter(o=>o.file_id!==a.file_id),a],updatedAt:new Date}:i)})),Ve(e)},removeFileFromConversation:async(r,a)=>{D("[chatStore] removeFileFromConversation called",{conversationId:r,fileId:a});try{const s=e().conversations.find(i=>i.id===r);if(!s)throw new Error("Conversation not found");if(!s.adapterName)throw new Error("Adapter not configured for this conversation. Cannot delete file.");await Ur.deleteFile(a,void 0,it(s.apiUrl),s.adapterName),D(`[chatStore] Successfully deleted file ${a} from server`)}catch(s){s instanceof Error&&(s.message.includes("404")||s.message.includes("File not found"))?D(`[chatStore] File ${a} was already deleted from server`):xe(`[chatStore] Failed to delete file ${a} from server:`,s)}t(s=>({conversations:s.conversations.map(i=>i.id===r?{...i,attachedFiles:(i.attachedFiles||[]).filter(o=>o.file_id!==a),updatedAt:new Date}:i)})),Ve(e)},loadConversationFiles:async r=>{try{const a=e().conversations.find(l=>l.id===r);if(!a)return;if(!a.adapterName){D(`Skipping file load for conversation ${r}: adapter not configured`);return}if(new Set((a.attachedFiles||[]).map(l=>l.file_id)).size===0){D(`No files to sync for conversation ${r}`);return}const i=await Ur.listFiles(void 0,it(a.apiUrl),a.adapterName),o=new Map(i.map(l=>[l.file_id,{file_id:l.file_id,filename:l.filename,mime_type:l.mime_type,file_size:l.file_size,upload_timestamp:l.upload_timestamp,processing_status:l.processing_status,chunk_count:l.chunk_count}]));t(l=>{const c=l.conversations.find(u=>u.id===r);if(!c)return l;const d=(c.attachedFiles||[]).map(u=>o.get(u.file_id)||u).filter(u=>o.has(u.file_id)||!u.processing_status||u.processing_status==="processing");return{conversations:l.conversations.map(u=>u.id===r?{...u,attachedFiles:d,updatedAt:new Date}:u)}}),Ve(e)}catch(a){Oe(`Failed to load files for conversation ${r}:`,a)}},syncConversationFiles:async r=>{await e().loadConversationFiles(r)},syncConversationsWithBackend:async()=>{try{const r=e();if(r.conversations.length===0)return;const a=await Fe(),s=le.maxMessagesPerConversation!==null&&le.maxMessagesPerConversation||void 0;let i=!1;const l=(await Promise.all(r.conversations.map(async c=>{var d;if(!c.sessionId)return null;if(!c.adapterName)return pe(`[chatStore] Skipping backend sync for conversation ${c.id} - adapter not configured`),null;try{const u=new a.ApiClient({apiUrl:it(c.apiUrl),sessionId:c.sessionId,adapterName:c.adapterName});if(typeof u.getConversationHistory!="function")return i||(i=!0,pe("[chatStore] Conversation history endpoint not supported by current API client")),null;const f=await u.getConversationHistory(c.sessionId,s),m=Array.isArray(f==null?void 0:f.messages)?f.messages:[];if(m.length===0)return c.messages.length===0?null:{id:c.id,sessionId:(f==null?void 0:f.session_id)||c.sessionId,messages:[],cleared:!0,updatedAt:new Date};const h=lu(m,c.messages),p=c.messages.filter(y=>y.isThreadMessage),x=Ui(p.length>0?[...h,...p]:h);return cu(c.messages,x)?null:{id:c.id,sessionId:(f==null?void 0:f.session_id)||c.sessionId,messages:x,cleared:!1,updatedAt:((d=h[h.length-1])==null?void 0:d.timestamp)||new Date}}catch(u){return pe(`[chatStore] Failed to sync session ${c.sessionId}:`,u),null}}))).filter(c=>!!c);if(l.length===0)return;t(c=>{const d=new Map(l.map(u=>[u.id,u]));return{conversations:c.conversations.map(u=>{const f=d.get(u.id);return f?f.cleared?{...u,sessionId:f.sessionId||u.sessionId,messages:[],attachedFiles:[],title:Fr,updatedAt:f.updatedAt,adapterLoadError:null}:{...u,sessionId:f.sessionId||u.sessionId,messages:f.messages,updatedAt:f.updatedAt,adapterLoadError:null}:u}),currentConversationId:c.currentConversationId}}),Ve(e)}catch(r){pe("Failed to synchronize conversations with backend:",r)}},stopStreaming:async()=>{var a;if(!e().isLoading){D("[chatStore] stopStreaming called but not currently loading");return}if(D("[chatStore] Stopping stream...",{hasAbortController:!!zt,requestId:ot,sessionId:Lt}),zt&&zt.abort(),ot&&Lt)try{const s=await Fe(),i=await((a=s.stopChat)==null?void 0:a.call(s,Lt,ot));D(`[chatStore] Server-side cancellation result: ${i}`)}catch(s){pe("[chatStore] Failed to cancel server-side stream:",s)}else pe(`[chatStore] Cannot call stopChat - missing IDs: requestId=${ot}, sessionId=${Lt}`);const r=er||e().currentConversationId;t(r?s=>({conversations:s.conversations.map(i=>i.id!==r?i:{...i,messages:i.messages.map(o=>o.isStreaming?{...o,isStreaming:!1}:o),updatedAt:new Date}),isLoading:!1}):{isLoading:!1}),zt=null,ot=null,Lt=null,er=null,D("[chatStore] Stream stopped successfully")},clearCurrentConversationAdapter:()=>{const r=e().currentConversationId;r&&(t(a=>({conversations:a.conversations.map(s=>s.id===r?{...s,adapterName:void 0,adapterInfo:void 0,adapterLoadError:null}:s)})),Ve(e))},submitFeedback:async(r,a)=>{const s=e(),i=s.conversations.find(l=>l.id===s.currentConversationId);if(!i)return;const o=i.messages.find(l=>l.id===r);if(!(o!=null&&o.databaseMessageId)){pe("[chatStore] Cannot submit feedback: no databaseMessageId on message");return}if(i.adapterName)try{const l=await Fe(),u=(await new l.ApiClient({apiUrl:it(i.apiUrl||$e()),sessionId:i.sessionId,adapterName:i.adapterName}).submitFeedback(o.databaseMessageId,i.sessionId,a)).feedback_type;t(f=>({conversations:f.conversations.map(m=>m.id!==s.currentConversationId?m:{...m,messages:m.messages.map(h=>h.id===r?{...h,feedback:u}:h),updatedAt:new Date})})),Ve(e)}catch(l){xe("[chatStore] Failed to submit feedback:",l)}},loadFeedbackForConversation:async r=>{var i;const s=e().conversations.find(o=>o.sessionId===r);if(s!=null&&s.adapterName)try{const o=await Fe(),l=new o.ApiClient({apiUrl:it(s.apiUrl||$e()),sessionId:s.sessionId,adapterName:s.adapterName}),c=new Set([r]);for(const f of s.messages)(i=f.threadInfo)!=null&&i.thread_session_id&&c.add(f.threadInfo.thread_session_id);const d=await Promise.all(Array.from(c).map(f=>l.getSessionFeedback(f).catch(()=>({feedbacks:[]})))),u=new Map;for(const f of d)if(f!=null&&f.feedbacks)for(const m of f.feedbacks)u.set(m.message_id,m.feedback_type);if(u.size===0)return;t(f=>({conversations:f.conversations.map(m=>m.sessionId!==r?m:{...m,messages:m.messages.map(h=>h.databaseMessageId&&u.has(h.databaseMessageId)?{...h,feedback:u.get(h.databaseMessageId)}:h)})}))}catch(o){xe("[chatStore] Failed to load feedback:",o)}}})),fu=async()=>{var c;const t=localStorage.getItem("chat-state"),e=$e(),r=!!localStorage.getItem("chat-api-url");let a=Cs(),s=!1;if(t)try{const d=JSON.parse(t),u=h=>{if(h instanceof Date)return h;const p=h?new Date(h):new Date;return Number.isNaN(p.getTime())?new Date:p},m=(Array.isArray(d.conversations)?d.conversations:[]).map(h=>{const x=(Array.isArray(h.messages)?h.messages:[]).filter(A=>!(A.role==="assistant"&&A.isStreaming)).map(A=>({...A,timestamp:u(A.timestamp),isStreaming:!1})),y=Ui(x),k={id:h.id,sessionId:h.sessionId||Ht(),title:au(h.title),messages:y,createdAt:u(h.createdAt),updatedAt:u(h.updatedAt),attachedFiles:h.attachedFiles||[],adapterName:h.adapterName,apiUrl:h.apiUrl,adapterInfo:h.adapterInfo,adapterLoadError:h.adapterLoadError||null,audioSettings:h.audioSettings,currentThreadId:void 0,currentThreadSessionId:void 0},N=k.messages.length===0&&!k.adapterName;return{...k,apiUrl:N&&!r?e:it(h.apiUrl)}});if(s=m.length>0,d.currentConversationId&&m.length>0){const h=m.find(p=>p.id===d.currentConversationId);h!=null&&h.sessionId&&(a=h.sessionId)}if(m.length===0){const h=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,p=Ht(),x=$r(h,p,$e());ke.setState({conversations:[x],currentConversationId:h,sessionId:p}),a=p}else ke.setState({conversations:m,currentConversationId:d.currentConversationId||((c=m[0])==null?void 0:c.id)||null,sessionId:a}),!d.currentConversationId&&m.length>0&&(ke.setState({currentConversationId:m[0].id,sessionId:m[0].sessionId||a}),a=m[0].sessionId||a);D("📋 Loaded conversations:",ke.getState().conversations.map(h=>{var p;return{id:h.id,title:h.title,sessionId:h.sessionId,messageCount:((p=h.messages)==null?void 0:p.length)||0}})),setTimeout(()=>ke.getState().cleanupStreamingMessages(),100)}catch(d){Oe("Failed to load chat state:",d);const u=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,f=Ht(),m=$r(u,f,$e());ke.setState({conversations:[m],currentConversationId:u,sessionId:f}),a=f}else{const d=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,u=Ht(),f=$r(d,u,$e());ke.setState({conversations:[f],currentConversationId:d,sessionId:u}),a=u}localStorage.removeItem("chat-api-key");const i=ke.getState(),o=i.currentConversationId?i.conversations.find(d=>d.id===i.currentConversationId):null,l=s&&(o!=null&&o.apiUrl)?o.apiUrl:$e();try{const d=await Fe(),u=o==null?void 0:o.adapterName;if(!u)D("No adapter selected yet. Waiting for user selection before configuring API.");else if(d.configureApi(l,a,u),As=l,Ns=!0,!(o!=null&&o.adapterInfo))try{const f=new d.ApiClient({apiUrl:l,sessionId:null,adapterName:u});if(typeof f.getAdapterInfo=="function"){const m=await f.getAdapterInfo();D("Adapter info loaded for existing adapter:",m);const h=ke.getState();h.currentConversationId&&(ke.setState({conversations:h.conversations.map(p=>p.id===h.currentConversationId?{...p,adapterInfo:m,adapterLoadError:null,updatedAt:new Date}:p)}),setTimeout(()=>{const p=ke.getState();localStorage.setItem("chat-state",JSON.stringify({conversations:p.conversations,currentConversationId:p.currentConversationId}))},0))}}catch(f){pe("Failed to load adapter info for existing adapter:",f)}}catch(d){Oe("Failed to initialize API:",d)}try{await ke.getState().syncConversationsWithBackend()}catch(d){pe("Conversation history sync skipped:",d)}};typeof window<"u"&&fu();function gu(t){return t.includes("image")?n.jsx($c,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"}):t.includes("video")||t.includes("audio")?n.jsx(nd,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"}):n.jsx(La,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"})}function hu(t){return t.replace(/-/g," ")}function Bi({skills:t,isLoading:e,selectedSkill:r,activeSkillName:a,query:s="",onSelect:i,onActiveSkillChange:o}){const{t:l}=Le(),c=St.useRef(null),d=s.toLowerCase().replace(/-/g," "),u=d?t.filter(f=>f.name.replace(/-/g," ").toLowerCase().includes(d)||f.description.toLowerCase().includes(d)):t;return St.useEffect(()=>{var m;const f=(m=c.current)==null?void 0:m.querySelector('[data-active="true"]');f==null||f.scrollIntoView({block:"nearest"})},[a,u.length]),!e&&t.length===0?n.jsx("div",{className:"w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg shadow-black/5 dark:border-[#242424] dark:bg-[#101010] dark:shadow-black/30",children:n.jsx("p",{className:"px-4 py-3 text-sm text-gray-500 dark:text-[#bfc2cd]",children:l("skillPicker.noSkillsAvailable")})}):n.jsx("div",{className:"w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-lg shadow-black/5 dark:border-[#242424] dark:bg-[#101010] dark:shadow-black/30",children:e?n.jsx("div",{className:"px-4 py-3.5",children:n.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-[#bfc2cd]",children:[n.jsx("div",{className:"h-3.5 w-3.5 rounded-full border-2 border-current border-t-transparent animate-spin","aria-hidden":"true"}),l("skillPicker.loadingLabel")]})}):u.length===0?n.jsx("div",{className:"px-4 py-3.5",children:n.jsx("p",{className:"text-sm text-gray-500 dark:text-[#bfc2cd]",children:d?l("skillPicker.noMatchingSkills",{query:s}):l("skillPicker.noMatchingSkillsGeneric")})}):n.jsx("div",{ref:c,role:"listbox","aria-label":l("skillPicker.listboxLabel"),className:"max-h-72 overflow-y-auto p-1.5",children:u.map((f,m)=>{const h=(r==null?void 0:r.name)===f.name,p=a===f.name||!a&&(h||!r&&m===0);return n.jsxs("button",{id:`skill-option-${f.name}`,type:"button",role:"option","aria-selected":p,"data-active":p?"true":void 0,onMouseEnter:()=>o==null?void 0:o(f),onClick:()=>i(f),className:`group flex w-full items-start gap-3 rounded-lg px-3 py-2.5 text-left transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-300 dark:focus-visible:ring-gray-600 ${p?"bg-gray-100 text-gray-950 dark:bg-[#242424] dark:text-white":"text-gray-900 hover:bg-gray-50 dark:text-gray-100 dark:hover:bg-[#1a1a1a]"}`,children:[n.jsx("div",{className:`mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center transition-colors ${p?"text-gray-900 dark:text-white":"text-gray-500 group-hover:text-gray-700 dark:text-[#bfc2cd] dark:group-hover:text-gray-200"}`,children:gu(f.name)}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("div",{className:"flex min-w-0 items-center gap-2",children:n.jsx("span",{className:"truncate text-sm font-medium capitalize leading-5 text-current",children:hu(f.name)})}),f.description&&n.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs leading-5 text-gray-500 dark:text-[#bfc2cd]",children:f.description})]}),h&&n.jsx("span",{className:"mt-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-gray-900 text-white dark:bg-white dark:text-gray-900",children:n.jsx(ur,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]},f.name)})})})}function Hi({availableModels:t,defaultModel:e,selectedModel:r,onSelect:a,wrapperClassName:s="relative hidden md:block",maxWidthClass:i="max-w-[200px]",triggerTitle:o,listboxLabel:l,staticPaddingClass:c="px-3 py-1.5",triggerPaddingClass:d="px-3 py-1.5"}){const{t:u}=Le(),f=o??u("modelPicker.selectModel"),m=l??u("modelPicker.selectModel"),[h,p]=g.useState(!1),[x,y]=g.useState(""),[k,N]=g.useState(null),A=g.useRef(null),v=g.useRef(null),C=g.useRef(null),E=g.useRef(null),P=r??e,b=x.trim()?t.filter(F=>F.name.toLowerCase().includes(x.trim().toLowerCase())):t,_=g.useCallback(()=>{if(!v.current)return;const F=v.current.getBoundingClientRect();N({bottom:window.innerHeight-F.top+8,right:window.innerWidth-F.right})},[]),S=g.useCallback(()=>{p(!1),y("")},[]),I=()=>{if(h){S();return}_(),p(!0)};if(g.useEffect(()=>{if(!h)return;const F=setTimeout(()=>{var R;return(R=C.current)==null?void 0:R.focus()},10),z=R=>{var H,Z;const T=R.target,K=((H=A.current)==null?void 0:H.contains(T))??!1,G=((Z=E.current)==null?void 0:Z.contains(T))??!1;!K&&!G&&S()},j=R=>{var T;R.key==="Escape"&&(R.preventDefault(),S(),(T=v.current)==null||T.focus())},L=new ResizeObserver(_);return v.current&&L.observe(v.current),window.addEventListener("resize",_,{passive:!0}),document.addEventListener("scroll",_,{capture:!0,passive:!0}),document.addEventListener("pointerdown",z),document.addEventListener("keydown",j),()=>{clearTimeout(F),L.disconnect(),window.removeEventListener("resize",_),document.removeEventListener("scroll",_,{capture:!0}),document.removeEventListener("pointerdown",z),document.removeEventListener("keydown",j)}},[S,h,_]),!e&&t.length===0)return null;const M=h&&k&&typeof document<"u"?Ls.createPortal(n.jsxs("div",{ref:E,style:{position:"fixed",bottom:k.bottom,right:k.right,width:288,zIndex:9999},className:"rounded-xl border border-gray-200 bg-white shadow-xl dark:border-[#2f303d] dark:bg-[#111111]",children:[n.jsx("div",{className:"p-2 border-b border-gray-100 dark:border-[#222222]",children:n.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-gray-50 px-3 py-1.5 dark:bg-[#1a1a1a]",children:[n.jsx(Ia,{className:"h-3.5 w-3.5 flex-shrink-0 text-gray-400 dark:text-[#6b6f7a]","aria-hidden":"true"}),n.jsx("input",{ref:C,type:"text",value:x,onChange:F=>y(F.target.value),placeholder:u("modelPicker.searchPlaceholder"),className:"flex-1 bg-transparent pl-1 text-xs text-gray-700 placeholder-gray-400 focus:outline-none dark:text-[#ececf1] dark:placeholder-[#6b6f7a]","aria-label":u("modelPicker.searchAriaLabel")})]})}),n.jsx("div",{role:"listbox","aria-label":m,className:"max-h-60 overflow-y-auto py-1",children:b.length===0?n.jsx("div",{className:"px-3 py-5 text-center text-xs text-gray-400 dark:text-[#6b6f7a]",children:u("modelPicker.noModelsMatch",{query:x})}):b.map(F=>{const z=P===F.name;return n.jsxs("button",{role:"option","aria-selected":z,type:"button",onClick:()=>{var j;a(F.name),S(),(j=v.current)==null||j.focus()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs transition-colors ${z?"bg-gray-100 text-gray-900 dark:bg-[#1f1f1f] dark:text-[#ececf1]":"text-gray-700 hover:bg-gray-50 dark:text-[#bfc2cd] dark:hover:bg-[#1a1a1a]"}`,children:[n.jsx("span",{className:`flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-full border ${z?"border-blue-500 bg-blue-500 dark:border-blue-400 dark:bg-blue-400":"border-gray-300 dark:border-[#5a5b65]"}`,children:z&&n.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-white"})}),n.jsx("span",{className:"truncate font-medium normal-case tracking-normal",children:F.name})]},F.name)})}),t.length>8&&n.jsx("div",{className:"border-t border-gray-100 px-3 py-1.5 dark:border-[#222222]",children:n.jsx("span",{className:"text-[10px] text-gray-400 dark:text-[#6b6f7a]",children:u("modelPicker.modelCountHint",{filtered:b.length,total:t.length})})})]}),document.body):null;return n.jsx("div",{ref:A,className:s,children:t.length>1?n.jsxs(n.Fragment,{children:[n.jsxs("button",{ref:v,type:"button",onClick:I,className:`inline-flex min-w-[100px] ${i} items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 ${d} text-xs font-medium text-gray-700 transition-colors hover:bg-gray-200 dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#bfc2cd] dark:hover:bg-[#3a3b48]`,"aria-haspopup":"listbox","aria-expanded":h,title:f,children:[n.jsx("span",{className:"truncate flex-1",children:P}),n.jsx(gr,{className:`h-3.5 w-3.5 flex-shrink-0 text-gray-400 transition-transform duration-150 dark:text-[#6b6f7a] ${h?"rotate-180":""}`,"aria-hidden":"true"})]}),M]}):n.jsx("div",{className:`inline-flex min-w-[100px] ${i} items-center rounded-full border border-gray-200 bg-gray-100 ${c} text-xs text-gray-500 dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#bfc2cd]`,title:P??void 0,children:n.jsx("span",{className:"truncate",children:P})})})}const mu=[],pu=(t="png")=>{const e=t.toLowerCase().replace(/^image\//,"");return e==="jpg"?"image/jpeg":`image/${e||"png"}`},xu=(t,e)=>{const r=atob(t),a=new Uint8Array(r.length);for(let s=0;s<r.length;s+=1)a[s]=r.charCodeAt(s);return new Blob([a],{type:e})},bu=async t=>{const e=URL.createObjectURL(t);try{const r=new Image;r.decoding="async";const a=new Promise((o,l)=>{r.onload=()=>o(r),r.onerror=()=>l(new Error("Failed to load generated image for clipboard copy"))});r.src=e,await a;const s=document.createElement("canvas");s.width=r.naturalWidth,s.height=r.naturalHeight;const i=s.getContext("2d");if(!i)throw new Error("Could not create canvas context for image clipboard copy");return i.drawImage(r,0,0),await new Promise((o,l)=>{s.toBlob(c=>{c?o(c):l(new Error("Could not encode generated image for clipboard copy"))},"image/png")})}finally{URL.revokeObjectURL(e)}},yu=async(t,e)=>{const r=pu(t.imageFormat);if(t.image)return xu(t.image,r);if(!t.imageUrl)return null;const a=await fetch(t.imageUrl,{headers:e?{"X-Adapter-Name":e}:{}});if(!a.ok)throw new Error(`Could not fetch generated image for clipboard copy: ${a.status}`);const s=await a.blob();return s.type?s:new Blob([s],{type:r})},wu=t=>t.imageUrl?new URL(t.imageUrl,window.location.origin).toString():t.imageRevisedPrompt||t.content;function Bn({size:t="md"}){const e=t==="sm"?"h-2 w-2":"h-2.5 w-2.5";return n.jsx("div",{className:"flex items-center gap-1.5 py-1",children:[0,150,300].map(r=>n.jsx("span",{className:`inline-block ${e} animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]`,style:{animationDelay:`${r}ms`}},r))})}function ku({reply:t}){const{t:e}=Le(),[r,a]=g.useState(!1),[s,i]=g.useState(!1),o=g.useRef(null),l=ke(d=>d.submitFeedback);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const c=async d=>{if(!t.databaseMessageId||r)return;const u=t.feedback!==d;a(!0);try{await l(t.id,d),u?(i(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i(!1),o.current=null},2e3)):i(!1)}catch(f){xe("Failed to submit thread reply feedback:",f)}finally{a(!1)}};return n.jsxs("div",{className:"mt-0.5 flex items-center gap-0.5 text-gray-400 dark:text-[#8e8ea0]",children:[n.jsx("button",{onClick:()=>c("up"),disabled:r,className:`rounded-md p-1.5 transition-colors ${r?"opacity-50 cursor-not-allowed":""} ${t.feedback==="up"?"text-green-600 dark:text-green-400":"hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]"}`,title:e("message.feedback.good"),"aria-label":e("message.feedback.good"),children:n.jsx(Li,{className:"h-4 w-4"})}),n.jsx("button",{onClick:()=>c("down"),disabled:r,className:`rounded-md p-1.5 transition-colors ${r?"opacity-50 cursor-not-allowed":""} ${t.feedback==="down"?"text-red-600 dark:text-red-400":"hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]"}`,title:e("message.feedback.poor"),"aria-label":e("message.feedback.poor"),children:n.jsx(Ii,{className:"h-4 w-4"})}),s&&n.jsxs("span",{className:"ml-1 inline-flex items-center gap-1.5 whitespace-nowrap rounded-lg bg-emerald-500 px-2.5 py-1 text-[11px] font-bold uppercase tracking-wider text-white shadow-sm animate-fadeIn dark:bg-emerald-600",children:[n.jsx(ur,{className:"h-3.5 w-3.5"}),e("message.feedback.thanks")]})]})}function vu({message:t,onRegenerate:e,onEdit:r,onStartThread:a,onClearThread:s,onSendThreadMessage:i,threadMessages:o,sessionId:l,isThreadSendDisabled:c,availableModels:d=[],defaultModel:u=null,selectedModel:f=null}){var kr,nr,vr;const{t:m}=Le(),[h,p]=g.useState(!1),[x,y]=g.useState(t.content||""),[k,N]=g.useState(!1),A=g.useRef(null),[v,C]=g.useState(!1),[E,P]=g.useState(!1),[b,_]=g.useState(!1),[S,I]=g.useState(""),[M,F]=g.useState(!1),[z,j]=g.useState(!1),[L,R]=g.useState(!1),[T,K]=g.useState(0),[G,H]=g.useState(!1),[Z,fe]=g.useState(!1),[U,te]=g.useState(()=>f??u),W=g.useRef(f),Q=g.useRef(((kr=t.threadInfo)==null?void 0:kr.thread_id)||null),se=g.useRef(null),ge=g.useRef(null),Ne=g.useRef(null),B=g.useRef(!1),X=g.useRef(0),ee=g.useRef(""),we=g.useRef(!1),ae=g.useRef(!0),Y=g.useRef(!1),de=g.useRef(null),ve=g.useRef(null),ce=t.role==="assistant",Pe=o??mu,Me=Pe.filter($=>!($.role==="assistant"&&$.isStreaming)).length,V=Pe.some($=>$.isStreaming),ie=hr(),ze=rt()&&!ie,be=ke($=>$.conversations.find(ye=>ye.id===$.currentConversationId)),Ae=!!((t.image||t.imageUrl)&&ce&&!t.isStreaming),_t=!!((t.video||t.videoUrl)&&ce&&!t.isStreaming),Ue=m(Ae?"message.copyImageLabel":"message.copyLabel"),Je=Zl(),mr=le.maxMessageLength,ut=le.maxMessagesPerThread,Tt=ut!==null&&Me>=ut,Vt=Tt?ze?m("message.thread.limitReachedGuest",{count:ut}):m("message.thread.limitReachedUser",{count:ut}):null,{theme:Ze,isDark:Mt}=rr(),qt=m("message.thread.placeholder"),Ce=`thread-input-${t.id}`,{skills:Qe,isLoading:ft,selectedSkill:ue,selectSkill:Se,clearSkill:_e}=Ri({adapterName:be==null?void 0:be.adapterName,enabled:Je&&!!t.threadInfo,selectionScopeKey:((nr=t.threadInfo)==null?void 0:nr.thread_id)||t.id}),re=S.startsWith("/")?S.slice(1):"",et=re.toLowerCase().replace(/-/g," "),Be=et?Qe.filter($=>$.name.replace(/-/g," ").toLowerCase().includes(et)||$.description.toLowerCase().includes(et)):Qe,pr=Be.length>0?Math.min(T,Be.length-1):0,at=Be[pr]??null,xr=(at==null?void 0:at.name.replace(/-/g," "))??"",zr=L&&at&&S.startsWith("/")&&xr.toLowerCase().startsWith(re.toLowerCase())&&xr.length>re.length?xr.slice(re.length):null,sr=Ze.mode==="dark"?"dark":Ze.mode==="light"?"light":"",tt=Mt?"dark":"light",Br=g.useMemo(()=>["message-markdown w-full min-w-0","prose prose-slate dark:prose-invert max-w-none",sr].filter(Boolean).join(" "),[sr]),Hr=g.useMemo(()=>["message-markdown w-full min-w-0","prose dark:prose-invert max-w-none",sr].filter(Boolean).join(" "),[sr]),ar=ce?Br:Hr,Wt=`${Br} text-sm leading-6`,br=`${Hr} text-sm leading-6`;g.useEffect(()=>{var $,ye;!Q.current&&(($=t.threadInfo)!=null&&$.thread_id)&&F(!0),Q.current=((ye=t.threadInfo)==null?void 0:ye.thread_id)||null},[(vr=t.threadInfo)==null?void 0:vr.thread_id]),g.useEffect(()=>{t.threadInfo||setTimeout(()=>{I(""),F(!1),j(!1),R(!1),_e()},0)},[t.threadInfo,_e]),g.useEffect(()=>{Me>0&&setTimeout(()=>{F(!0)},0)},[Me]),g.useEffect(()=>()=>{de.current&&clearTimeout(de.current),ve.current&&clearTimeout(ve.current)},[]),g.useEffect(()=>{if(!h||!A.current)return;const $=A.current;$.focus(),$.setSelectionRange($.value.length,$.value.length)},[h]),g.useEffect(()=>{if(!h||!A.current)return;const $=A.current;$.style.height="auto",$.style.height=`${$.scrollHeight}px`},[h,x]);const Ft=g.useCallback(()=>{const $=x.trim();if(!$||$===t.content){p(!1);return}r==null||r(t.id,$),p(!1)},[x,t.content,t.id,r]),lt=g.useCallback(()=>{requestAnimationFrame(()=>{Ne.current&&(Ne.current.scrollTop=Ne.current.scrollHeight)})},[]);g.useEffect(()=>{if(!M)return;const $=Pe.length,ye=$>X.current,q=Pe[Pe.length-1],je=(q==null?void 0:q.content)||"",ct=je!==ee.current,We=(q==null?void 0:q.isStreaming)??!1,Xt=we.current&&!We;ye||We&&ct||Xt?(lt(),ae.current=!0):ae.current&&ct&<(),X.current=$,ee.current=je,we.current=We},[M,Pe,lt]),g.useEffect(()=>{M&&(lt(),ae.current=!0)},[M,lt]);const $t=ce?"message-bubble message-bubble-assistant min-w-0 break-words leading-relaxed text-[#353740] dark:text-[#ececf1]":"message-bubble message-bubble-user inline-block min-w-0 break-words leading-relaxed rounded-[1.75rem] border border-black/[0.06] bg-[#f4f4f4] px-4 py-3 text-[#111827] shadow-[0_1px_2px_rgba(16,24,40,0.06)] dark:border-white/[0.08] dark:bg-[#2a2a2a] dark:text-[#f5f5f5] dark:shadow-[0_1px_3px_rgba(0,0,0,0.3)]",Rs="border-gray-200 bg-white/80 dark:border-[#3b3c49] dark:bg-white/5",yr=g.useCallback(()=>{C(!0),de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{C(!1),de.current=null},2e3)},[]),Pt=async()=>{try{if(Ae){if("ClipboardItem"in window&&navigator.clipboard.write)try{const ye=(be==null?void 0:be.adapterName)||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null),q=await yu(t,ye);if(q){const je=q.type==="image/png"?q:await bu(q);await navigator.clipboard.write([new ClipboardItem({[je.type||"image/png"]:je})]),yr();return}}catch(ye){xe("Failed to copy generated image, falling back to text:",ye)}const $=wu(t);if($){await navigator.clipboard.writeText($),yr();return}return}await navigator.clipboard.writeText(t.content),yr()}catch($){xe(Ae?"Failed to copy generated image:":"Failed to copy text:",$)}},Ds=ke($=>$.submitFeedback),He=async $=>{if(!t.databaseMessageId||E)return;const ye=t.feedback!==$;P(!0);try{await Ds(t.id,$),ye?(_(!0),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{_(!1),ve.current=null},2e3)):_(!1)}catch(q){xe("Failed to submit feedback:",q)}finally{P(!1)}},wr=async()=>{if(!i||!t.threadInfo||Tt)return;const $=S.trim();if(!$)return;const ye=S,q=ue,je=ue==null?void 0:ue.name;I(""),j(!0),R(!1),je&&_e();try{await i(t.threadInfo.thread_id,t.id,$,je,U??u??void 0),setTimeout(()=>{se.current&&se.current.focus()},100)}catch(ct){xe("Failed to send thread message:",ct),I(ye),q&&Se(q),setTimeout(()=>{se.current&&se.current.focus()},100)}finally{j(!1)}},Kt=g.useCallback($=>{var ye;Se($),R(!1),I(""),K(0),(ye=se.current)==null||ye.focus()},[Se]),Vr=g.useCallback(()=>{var $;R(!1),I(""),K(0),($=se.current)==null||$.focus()},[]),Rt=g.useCallback(()=>{var $;I("/"),R(!0),K(0),($=se.current)==null||$.focus()},[]),gt=$=>{if(L){if($.key==="ArrowDown"){$.preventDefault(),K(ye=>Be.length===0?0:(ye+1)%Be.length);return}if($.key==="ArrowUp"){$.preventDefault(),K(ye=>Be.length===0?0:(ye-1+Be.length)%Be.length);return}if($.key==="Home"){$.preventDefault(),K(0);return}if($.key==="End"){$.preventDefault(),K(Math.max(Be.length-1,0));return}if(($.key==="Enter"&&!$.shiftKey||$.key==="Tab")&&at){$.preventDefault(),Kt(at);return}if($.key==="Escape"){$.preventDefault(),Vr();return}}$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),wr())},Gt=!t.threadInfo||!i||c||V||z||Tt,Os=!!t.threadInfo&&!!s&&Me>0&&!V&&!z&&!c,Us=async()=>{if(!(!t.threadInfo||!s)){fe(!0);try{await s(t.id,t.threadInfo.thread_id),H(!1),F(!1),I("")}catch($){xe("Failed to clear thread:",$)}finally{fe(!1)}}};g.useEffect(()=>{W.current=f},[f]),g.useEffect(()=>{te(W.current??u)},[u]),g.useEffect(()=>{if(!M||Gt){Y.current=z;return}const $=se.current;if(!$){Y.current=z;return}if(!(B.current||Y.current)){Y.current=z;return}const q=requestAnimationFrame(()=>{var ct;B.current&&((ct=ge.current)==null||ct.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})),$.focus();const je=$.value.length;$.setSelectionRange(je,je),B.current=!1,Y.current=z});return()=>{cancelAnimationFrame(q),Y.current=z}},[M,Gt,z]),g.useEffect(()=>{if(se.current){const ye=se.current;ye.style.height="auto";const q=ye.scrollHeight;ye.style.height=`${Math.min(q,120)}px`,ye.style.overflowY=q>120?"auto":"hidden"}},[S]);const bt=g.useMemo(()=>{if(t.isStreaming&&(!t.content||t.content==="…"))return n.jsx("div",{className:ar,children:n.jsx(Bn,{})});const $=t.isStreaming&&ce?" streaming-cursor":"";return n.jsx("div",{className:$||void 0,children:n.jsx(Et,{content:xa(Or(t.content||"")),className:ar,syntaxTheme:tt})})},[ar,t.content,t.isStreaming,ce,tt]),qr=g.useMemo(()=>{const $=q=>q instanceof Date?q.getTime():new Date(q).getTime();return[...Pe].sort((q,je)=>$(q.timestamp)-$(je.timestamp)).map(q=>{const je=q.role==="assistant",ct=je?Wt:br,We=q.isStreaming&&je?" streaming-cursor":"",Xt=q.isStreaming&&(!q.content||q.content==="…")?n.jsx("div",{className:ct,children:n.jsx(Bn,{size:"sm"})}):n.jsx("div",{className:We||void 0,children:n.jsx(Et,{content:xa(Or(q.content||"")),className:ct,syntaxTheme:tt})});return n.jsx("div",{className:`min-w-0 flex ${je?"justify-start":"justify-end"}`,children:n.jsxs("div",{className:je?"min-w-0 w-full max-w-full":"min-w-0 max-w-[85%]",children:[n.jsxs("div",{className:je?"thread-markdown-wrapper overflow-x-visible text-sm text-[#353740] dark:text-[#ececf1]":"thread-markdown-wrapper overflow-x-visible text-sm rounded-[1.75rem] bg-[#f4f4f4] px-4 py-3 text-[#111827] dark:bg-[#2a2a2a] dark:text-[#f5f5f5]",children:[Xt,q.audio&&je&&!q.isStreaming&&n.jsx(ns,{audio:q.audio,audioFormat:q.audioFormat,autoPlay:!1}),(q.image||q.imageUrl)&&je&&!q.isStreaming&&n.jsx(Ln,{image:q.image,imageUrl:q.imageUrl,imageFormat:q.imageFormat,revisedPrompt:q.imageRevisedPrompt}),(q.video||q.videoUrl)&&je&&!q.isStreaming&&n.jsx(En,{video:q.video,videoUrl:q.videoUrl,videoFormat:q.videoFormat,revisedPrompt:q.videoRevisedPrompt,adapterName:be==null?void 0:be.adapterName}),(q.document||q.documentUrl)&&je&&!q.isStreaming&&n.jsx(Fn,{document:q.document,documentUrl:q.documentUrl,documentFormat:q.documentFormat,revisedPrompt:q.documentRevisedPrompt,adapterName:be==null?void 0:be.adapterName}),q.generatedAudioUrl&&je&&!q.isStreaming&&n.jsx(ns,{audioUrl:q.generatedAudioUrl,audioFormat:q.generatedAudioFormat,downloadFilename:`generated-audio.${q.generatedAudioFormat||"mp3"}`,autoPlay:!1})]}),je&&!q.isStreaming&&q.model&&n.jsx("div",{className:"px-1 pt-0.5 text-[11px] text-gray-400 dark:text-[#9a9ab0]",children:m("message.generatedBy",{model:q.model})}),je&&!q.isStreaming&&xn()&&n.jsx(ku,{reply:q})]})},q.id)})},[be==null?void 0:be.adapterName,tt,m,Wt,Pe,br]);return n.jsxs("div",{className:"group animate-fadeIn min-w-0 w-full px-0",children:[n.jsxs("div",{className:"min-w-0 space-y-1",children:[n.jsxs("div",{className:ce?void 0:"flex flex-col items-end",children:[n.jsxs("div",{className:$t,children:[h?n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsx("textarea",{ref:A,className:"w-full resize-none overflow-hidden bg-transparent outline-none text-[#111827] dark:text-[#f5f5f5] leading-relaxed",value:x,onChange:$=>y($.target.value),onCompositionStart:()=>N(!0),onCompositionEnd:()=>N(!1),onKeyDown:$=>{$.key==="Enter"&&!$.shiftKey&&!k&&($.preventDefault(),$.stopPropagation(),Ft()),$.key==="Escape"&&($.stopPropagation(),p(!1),y(t.content||""))},maxLength:le.maxMessageLength,rows:1,style:{minHeight:"24px"}}),n.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1",children:[n.jsx("span",{className:"text-xs text-gray-400 dark:text-[#6e6e80]",children:m("message.edit.willRegenerateHint")}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("button",{onClick:()=>{p(!1),y(t.content||"")},className:"px-3 py-1.5 text-xs font-medium rounded-full bg-gray-200 text-gray-700 hover:bg-gray-300 dark:bg-[#4a4b54] dark:text-gray-200 dark:hover:bg-[#565869] transition-colors",children:m("common.cancel")}),n.jsxs("button",{onClick:Ft,className:"px-3 py-1.5 text-xs font-medium rounded-full bg-blue-600 text-white hover:bg-blue-700 transition-colors flex items-center gap-1.5",children:[n.jsx(ha,{className:"w-3.5 h-3.5"}),m("common.send")]})]})]})]}):bt,t.attachments&&t.attachments.length>0&&n.jsx("div",{className:"mt-3 space-y-2",children:t.attachments.map($=>n.jsxs("div",{className:`flex items-center gap-3 rounded-xl border p-3 ${Rs}`,children:[n.jsx(Fc,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"}),n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:$.filename}),n.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[($.file_size/1024).toFixed(1)," KB"]})]})]},$.file_id))}),t.audio&&ce&&!t.isStreaming&&n.jsx(ns,{audio:t.audio,audioFormat:t.audioFormat,autoPlay:!1}),(t.image||t.imageUrl)&&ce&&!t.isStreaming&&n.jsx(Ln,{image:t.image,imageUrl:t.imageUrl,imageFormat:t.imageFormat,revisedPrompt:t.imageRevisedPrompt}),(t.video||t.videoUrl)&&ce&&!t.isStreaming&&n.jsx(En,{video:t.video,videoUrl:t.videoUrl,videoFormat:t.videoFormat,revisedPrompt:t.videoRevisedPrompt,adapterName:be==null?void 0:be.adapterName}),(t.document||t.documentUrl)&&ce&&!t.isStreaming&&n.jsx(Fn,{document:t.document,documentUrl:t.documentUrl,documentFormat:t.documentFormat,revisedPrompt:t.documentRevisedPrompt,adapterName:be==null?void 0:be.adapterName}),t.generatedAudioUrl&&ce&&!t.isStreaming&&n.jsx(ns,{audioUrl:t.generatedAudioUrl,audioFormat:t.generatedAudioFormat,downloadFilename:`generated-audio.${t.generatedAudioFormat||"mp3"}`,autoPlay:!1})]}),!ce&&!h&&n.jsxs("div",{className:"flex items-center gap-0.5 py-1 text-gray-400 dark:text-[#8e8ea0]",children:[n.jsx("button",{onClick:Pt,className:"rounded-md p-1.5 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:Ue,"aria-label":Ue,children:v?n.jsx(ur,{className:"h-4 w-4 text-emerald-500 dark:text-emerald-400"}):n.jsx(wn,{className:"h-4 w-4"})}),r&&n.jsx("button",{onClick:()=>{y(t.content||""),p(!0)},className:"rounded-md p-1.5 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:m("message.editAriaLabel"),"aria-label":m("message.editAriaLabel"),children:n.jsx(Ai,{className:"h-4 w-4"})})]})]}),ce&&!t.isStreaming&&t.model&&n.jsx("div",{className:"px-1 pt-0.5 text-[11px] text-gray-400 dark:text-[#9a9ab0]",children:m("message.generatedBy",{model:t.model})}),ce&&!t.isStreaming&&n.jsxs("div",{className:"py-1 flex flex-nowrap items-center gap-0.5 text-gray-400 dark:text-[#8e8ea0] transition-opacity",children:[!_t&&n.jsx("button",{onClick:Pt,className:"rounded-md p-1.5 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:Ue,"aria-label":Ue,children:v?n.jsx(ur,{className:"h-4 w-4 text-emerald-500 dark:text-emerald-400"}):n.jsx(wn,{className:"h-4 w-4"})}),xn()&&n.jsxs("div",{className:"relative flex items-center gap-0.5",children:[n.jsx("button",{onClick:()=>He("up"),disabled:E,className:`rounded-md p-1.5 transition-colors ${E?"opacity-50 cursor-not-allowed":""} ${t.feedback==="up"?"text-green-600 dark:text-green-400":"hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]"}`,title:m("message.feedback.good"),"aria-label":m("message.feedback.good"),children:n.jsx(Li,{className:"h-4 w-4"})}),n.jsx("button",{onClick:()=>He("down"),disabled:E,className:`rounded-md p-1.5 transition-colors ${E?"opacity-50 cursor-not-allowed":""} ${t.feedback==="down"?"text-red-600 dark:text-red-400":"hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]"}`,title:m("message.feedback.poor"),"aria-label":m("message.feedback.poor"),children:n.jsx(Ii,{className:"h-4 w-4"})}),b&&n.jsxs("div",{className:"absolute bottom-full left-1/2 mb-2 -translate-x-1/2 whitespace-nowrap rounded-lg bg-emerald-500 px-2.5 py-1 text-[11px] font-bold uppercase tracking-wider text-white shadow-sm animate-fadeIn dark:bg-emerald-600",children:[n.jsx("div",{className:"absolute left-1/2 top-full h-2.5 w-2.5 -translate-x-1/2 -translate-y-1/2 rotate-45 bg-emerald-500 dark:bg-emerald-600"}),n.jsxs("div",{className:"relative flex items-center gap-1.5",children:[n.jsx(ur,{className:"h-3.5 w-3.5"}),n.jsx("span",{children:m("message.feedback.thanks")})]})]})]}),e&&n.jsx("button",{onClick:()=>e(t.id),className:"rounded-md p-1.5 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]",title:m("message.regenerateTitle"),"aria-label":m("message.regenerateAriaLabel"),children:n.jsx(Qc,{className:"h-4 w-4"})}),Je&&t.supportsThreading&&!t.threadInfo&&a&&l&&n.jsxs("button",{type:"button",onClick:()=>{B.current=!0,F(!0),a(t.id,l)},className:"ml-1 inline-flex items-center gap-1.5 rounded-full border border-blue-200 bg-blue-50 px-2.5 py-1.5 text-xs text-blue-700 shadow-sm transition-all hover:border-blue-300 hover:bg-blue-100 hover:text-blue-800 hover:shadow-md dark:border-blue-500/30 dark:bg-blue-500/10 dark:text-blue-200 dark:hover:border-blue-400/50 dark:hover:bg-blue-500/20 dark:hover:text-blue-100 animate-follow-up-enter whitespace-nowrap",title:m("message.thread.continueDiscussionTitle"),"aria-label":m("message.thread.continueDiscussionAriaLabel"),children:[n.jsx(kn,{className:"h-3.5 w-3.5 shrink-0"}),n.jsx("span",{children:m("message.thread.continueLabel")})]}),Je&&t.threadInfo&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"w-px h-4 shrink-0 bg-gray-200 dark:bg-[#3c3f4a] mx-1"}),n.jsxs("button",{onClick:()=>F($=>!$),className:"inline-flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1.5 hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1] transition-colors text-xs",children:[n.jsx(kn,{className:"h-4 w-4"}),n.jsx("span",{className:"truncate",children:m("message.thread.replyCount",{count:Me})}),M?n.jsx(vs,{className:"h-3 w-3"}):n.jsx(gr,{className:"h-3 w-3"})]}),Os&&n.jsx("button",{type:"button",onClick:()=>H(!0),className:"inline-flex items-center rounded-md px-2 py-1 text-xs font-medium text-red-600 transition-colors hover:bg-red-50 dark:text-red-300 dark:hover:bg-red-900/30",title:m("message.thread.clearTitle"),"aria-label":m("message.thread.clearAriaLabel"),children:m("common.clear")})]})]}),Je&&t.threadInfo&&M&&n.jsxs("div",{className:"thread-panel mt-3 md:mt-3 border-l-2 border-gray-200 pl-3 sm:pl-4 dark:border-[#3b3c49]",children:[n.jsx("div",{ref:Ne,className:"thread-replies-scroll mt-2 space-y-2 pb-3",onScroll:()=>{if(!Ne.current)return;const{scrollTop:$,scrollHeight:ye,clientHeight:q}=Ne.current;ae.current=ye-$-q<100},children:Me>0?qr:null}),Vt&&n.jsxs("div",{className:"mt-3 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900 dark:border-amber-500/30 dark:bg-[#2f2410] dark:text-amber-100",children:[Vt,ze&&n.jsx("div",{className:"mt-2",children:n.jsx("button",{type:"button",onClick:()=>st.getState().openLoginPrompt(m("message.thread.signInPromptMessage")),className:"inline-flex items-center gap-1 rounded-md bg-blue-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600",children:m("message.thread.signInForHigherLimits")})})]}),n.jsxs("div",{ref:ge,className:"mt-1 w-full max-w-[64rem] bg-transparent pt-1",children:[n.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-gray-200 bg-gray-50 px-3 py-2 dark:border-[#242424] dark:bg-[#101010]",children:[ue&&n.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-1.5 self-center rounded-full border border-gray-300 bg-white px-2.5 text-xs text-gray-700 shadow-sm dark:border-[#3a3a3a] dark:bg-[#1a1a1a] dark:text-gray-200",children:[n.jsx(La,{className:"h-3.5 w-3.5 shrink-0 text-gray-500 dark:text-gray-400","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 truncate font-medium capitalize",children:ue.name.replace(/-/g," ")}),n.jsx("button",{type:"button",onClick:()=>_e(),className:"-mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-white/10 dark:hover:text-gray-100","aria-label":m("message.thread.removeSkillAriaLabel"),children:n.jsx(Ye,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),!ue&&Qe.length>0&&S.length===0&&!Gt&&n.jsxs("button",{type:"button",onClick:Rt,className:"flex h-8 shrink-0 items-center gap-1.5 self-center rounded-full border border-gray-300 bg-white px-2.5 text-xs font-medium text-gray-600 shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-300 dark:border-[#3a3a3a] dark:bg-[#1a1a1a] dark:text-gray-300 dark:hover:bg-white/10 dark:hover:text-gray-100 dark:focus-visible:ring-gray-600","aria-label":m("message.thread.skillsHintAriaLabel"),title:m("message.thread.skillsHint"),children:[n.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded bg-gray-200 font-mono text-[10px] leading-none text-gray-600 dark:bg-[#2a2a2a] dark:text-gray-300","aria-hidden":"true",children:"/"}),m("messageInput.skillsHint.text")]}),n.jsxs("div",{className:"relative flex min-h-8 flex-1 items-center min-w-0",children:[n.jsx("label",{htmlFor:Ce,className:"sr-only",children:m("message.thread.placeholder")}),zr&&n.jsxs("div",{className:"pointer-events-none absolute inset-0 whitespace-pre-wrap px-0 py-0 text-base leading-8 text-gray-400 dark:text-[#8e8ea0] sm:text-sm sm:leading-8","aria-hidden":"true",children:[n.jsx("span",{className:"invisible",children:S}),n.jsx("span",{children:zr})]}),n.jsx("textarea",{id:Ce,ref:se,className:"relative z-10 block h-8 w-full min-w-0 resize-none overflow-hidden bg-transparent px-0 py-0 text-base leading-8 text-[#353740] placeholder-slate-500 outline-none transition focus:outline-none disabled:opacity-60 dark:text-[#ececf1] dark:placeholder-[#70707c] sm:text-sm sm:leading-8",placeholder:qt,"aria-label":m("message.thread.placeholder"),value:S,onChange:$=>{const ye=$.target.value;I(ye),ye.startsWith("/")&&K(0),R(ye.startsWith("/"))},onKeyDown:gt,disabled:Gt,rows:1,maxLength:mr,style:{minHeight:"32px",maxHeight:"120px",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none"}})]}),n.jsxs("div",{className:"flex items-center justify-between sm:justify-end gap-2",children:[n.jsx(Hi,{availableModels:d,defaultModel:u,selectedModel:U,onSelect:te,maxWidthClass:"max-w-[120px]",triggerPaddingClass:"px-2 py-1",staticPaddingClass:"px-2 py-1",triggerTitle:m("message.thread.selectModelTitle"),listboxLabel:m("message.thread.selectModelTitle")}),S.trim().length>0&&n.jsx("button",{type:"button",onClick:wr,disabled:Gt||S.trim().length===0,className:"flex h-10 w-10 sm:h-8 sm:w-8 items-center justify-center rounded-full transition active:scale-95 bg-blue-600 text-white hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-400 disabled:cursor-not-allowed",title:m("message.thread.sendMessageTitle"),children:n.jsx(ha,{className:"h-5 w-5 sm:h-4 sm:w-4"})})]})]}),L&&n.jsx("div",{className:"w-full pt-1",children:n.jsx(Bi,{skills:Qe,isLoading:ft,selectedSkill:ue,activeSkillName:at==null?void 0:at.name,query:re,onActiveSkillChange:$=>{const ye=Be.findIndex(q=>q.name===$.name);ye>=0&&K(ye)},onSelect:Kt,onClose:Vr})})]}),Me>0&&n.jsx("div",{className:"mt-2 flex justify-end",children:n.jsxs("button",{type:"button",onClick:()=>F(!1),className:"inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-[#bfc2cd] dark:hover:bg-[#2f313a] dark:hover:text-white","aria-label":m("message.thread.hideRepliesAriaLabel"),children:[n.jsx(vs,{className:"h-3 w-3"}),n.jsx("span",{children:m("message.thread.hideRepliesLabel")})]})})]})]}),n.jsx(js,{isOpen:G,onClose:()=>{Z||H(!1)},onConfirm:Us,title:m("message.confirmation.clearRepliesTitle"),message:m("message.confirmation.clearRepliesMessage"),confirmText:m("common.clear"),cancelText:m("common.cancel"),type:"danger",isLoading:Z})]})}let or=null;function Su(){if(typeof window>"u")return null;const t=window.AudioContext??window.webkitAudioContext;return t?((!or||or.state==="closed")&&(or=new t),or.state==="suspended"&&or.resume(),or):(D("[SoundEffects] AudioContext not supported in this browser"),null)}function ju(t){const e=Su();if(!e)return;const r=e.currentTime;for(const a of t){const s=e.createOscillator(),i=e.createGain();s.connect(i),i.connect(e.destination),s.frequency.value=a.frequency,s.type=a.type;const o=r+a.startTime,l=o+a.duration;i.gain.setValueAtTime(.001,o),i.gain.linearRampToValueAtTime(a.gain,o+.008),i.gain.exponentialRampToValueAtTime(.001,l),s.start(o),s.stop(l+.01)}}const Cu={messageSent:[{frequency:1046,startTime:0,duration:.08,gain:.15,type:"sine"},{frequency:1397,startTime:.07,duration:.11,gain:.18,type:"sine"}],messageReceived:[{frequency:988,startTime:0,duration:.12,gain:.16,type:"sine"},{frequency:1319,startTime:.13,duration:.12,gain:.18,type:"sine"},{frequency:1568,startTime:.26,duration:.18,gain:.14,type:"sine"}],success:[{frequency:784,startTime:0,duration:.1,gain:.14,type:"sine"},{frequency:1175,startTime:.11,duration:.18,gain:.18,type:"sine"}],error:[{frequency:330,startTime:0,duration:.15,gain:.16,type:"sine"},{frequency:262,startTime:.18,duration:.22,gain:.13,type:"sine"}],notification:[{frequency:880,startTime:0,duration:.1,gain:.14,type:"sine"},{frequency:1109,startTime:.12,duration:.16,gain:.17,type:"sine"}]};function _r(t,e){if(!e)return;const r=Cu[t];if(!r){D(`[SoundEffects] Unknown sound effect type: ${t}`);return}try{ju(r),D(`[SoundEffects] Playing ${t} sound effect`)}catch(a){D(`[SoundEffects] Failed to play ${t} sound effect:`,a)}}function Nu({messages:t,onRegenerate:e,onEditMessage:r,onStartThread:a,onClearThread:s,onSendThreadMessage:i,sessionId:o,isLoading:l,contentMaxWidthClass:c="max-w-[64rem]",availableModels:d,defaultModel:u,selectedModel:f}){const m=g.useRef(null),h=g.useRef(null),p=g.useRef(t.length),x=g.useRef(""),y=g.useRef(l),k=g.useRef(!0),{settings:N}=Es(),{t:A}=Le(),{topLevelMessages:v,threadLookup:C}=g.useMemo(()=>{const b=new Map,_=[];return t.forEach(S=>{if(S.isThreadMessage&&S.parentMessageId){const I=b.get(S.parentMessageId)||[];b.set(S.parentMessageId,[...I,S]);return}_.push(S)}),{topLevelMessages:_,threadLookup:b}},[t]),E=()=>{if(!h.current)return;const{scrollTop:b,scrollHeight:_,clientHeight:S}=h.current,M=_-b-S<200;k.current=M},P=g.useCallback(()=>{requestAnimationFrame(()=>{h.current&&(h.current.scrollTop=h.current.scrollHeight)})},[]);return g.useEffect(()=>{const b=t.length,_=p.current,S=b>_,I=t[t.length-1],M=(I==null?void 0:I.content)||"",F=M!==x.current,z=(I==null?void 0:I.isStreaming)??!1;S||z&&F?(P(),k.current=!0):k.current&&F&&P(),p.current=b,x.current=M},[t,P]),g.useEffect(()=>{l&&(P(),k.current=!0)},[l,P]),g.useEffect(()=>{if(y.current&&!l){const b=t[t.length-1];(b==null?void 0:b.role)==="assistant"&&b.content&&_r("messageReceived",N.soundEnabled)}y.current=l},[l,t,N.soundEnabled]),v.length===0?n.jsx("div",{className:"flex-1 flex items-center justify-center px-4 sm:px-6",children:n.jsxs("div",{className:"text-center text-lg text-gray-500 dark:text-[#bfc2cd]",children:[n.jsx("p",{className:"text-xl",children:A("messageList.emptyStateHeading")}),n.jsx("p",{className:"mt-1 text-lg",children:A("messageList.emptyStateSubheading")})]})}):n.jsx("div",{ref:h,className:"message-list flex-1 overflow-y-auto pb-8 pt-4 sm:pt-6",onScroll:E,children:n.jsx("div",{className:"mx-auto w-full max-w-[96rem] px-3 sm:px-5 md:px-6 lg:px-8 xl:px-10",children:n.jsxs("div",{className:`message-list__rail mx-auto w-full space-y-7 ${c}`,children:[v.map(b=>n.jsx("div",{className:`flex w-full ${b.role==="user"?"justify-end":"justify-start"}`,style:{contentVisibility:"auto",containIntrinsicSize:"420px"},children:n.jsx(vu,{message:b,onRegenerate:e,onEdit:r,onStartThread:a,onClearThread:s,onSendThreadMessage:i,threadMessages:C.get(b.id),sessionId:o,isThreadSendDisabled:l,availableModels:d,defaultModel:u,selectedModel:f})},b.id)),n.jsx("div",{ref:m,className:"h-8"})]})})})}const Au=4e3;function Iu(t,e,r={}){var _;const{t:a}=Le(),[s,i]=g.useState(!1),[o,l]=g.useState(null),c=g.useRef(null),d=g.useRef(""),u=g.useRef(""),f=g.useRef(!1),m=g.useRef(null),h=typeof navigator<"u"?navigator.language:"en-US",p=Number.isFinite(r.silenceTimeoutMs)?Math.max(Math.floor(r.silenceTimeoutMs),1e3):Au,x=((_=r.language)==null?void 0:_.trim())||h||"en-US",y=g.useCallback(S=>S.replace(/\s+/g," ").trim(),[]),k=g.useCallback(S=>{const I=y(S);I&&I!==u.current&&(u.current=I,t(I))},[y,t]),N=g.useCallback(()=>{if(!d.current)return;const S=d.current;d.current="",k(S)},[k]),A=typeof window<"u"&&("webkitSpeechRecognition"in window||"SpeechRecognition"in window),v=g.useCallback(()=>{!e||f.current||(f.current=!0,e())},[e]),C=g.useCallback(()=>{m.current!==null&&(clearTimeout(m.current),m.current=null)},[]),E=g.useCallback(()=>{C(),m.current=setTimeout(()=>{D("Speech recognition silence threshold reached, stopping recording"),c.current?c.current.stop():v()},p)},[C,v,p]),P=g.useCallback(()=>{if(!A){l(a("voice.browserNotSupported"));return}if(!c.current)try{f.current=!1;const S=window.SpeechRecognition||window.webkitSpeechRecognition,I=new S;I.continuous=!0,I.interimResults=!0,I.lang=x,I.maxAlternatives=1,I.onstart=()=>{i(!0),l(null),d.current="",u.current="",D("Speech recognition started"),E()},I.onresult=M=>{let F="",z="";for(let j=M.resultIndex;j<M.results.length;j++){const L=M.results[j][0].transcript;M.results[j].isFinal?F+=L:z+=L}z&&(d.current=y(z)),F&&(d.current="",k(F)),E()},I.onend=()=>{C(),N(),i(!1),c.current=null,D("Speech recognition ended"),v()},I.onerror=M=>{switch(C(),xe("Speech recognition error:",M.error),i(!1),c.current=null,d.current="",v(),M.error){case"no-speech":l(a("voice.error.noSpeech"));break;case"audio-capture":l(a("voice.error.audioCapture"));break;case"not-allowed":l(a("voice.error.notAllowed"));break;case"network":l(a("voice.error.network"));break;default:l(a("voice.error.generic",{error:M.error}))}},I.start(),c.current=I}catch(S){xe("Failed to start speech recognition:",S),l(a("voice.error.startFailed")),i(!1)}},[A,N,v,E,C,x,y,k,a]),b=g.useCallback(()=>{if(D("Stopping speech recognition..."),c.current){const S=c.current;S.onstart=null,S.onerror=null;try{S.stop()}catch(I){D("Recognition already stopped or error stopping:",I),C(),N(),S.onend=null,S.onresult=null,c.current=null,i(!1),v()}}C(),i(!1),l(null),D("Speech recognition stopped, isListening set to false")},[C,N,v]);return{isListening:s,isSupported:A,startListening:P,stopListening:b,error:o}}const Lu=300,Hn=3,ds=5,Eu=6e4;function Vn(t){if(typeof t!="string")return null;const e=t.replace(/[\r\n\u2028\u2029]+/g," ").replace(/\s{2,}/g," ").trim();return e?{text:e}:null}function _u(t,e={}){const{enabled:r=xi(),adapterName:a,sessionId:s,adapterSupportsAutocomplete:i,skill:o,inputRef:l}=e,[c,d]=g.useState([]),[u,f]=g.useState(!1),[m,h]=g.useState(-1),p=g.useRef(null),x=g.useRef(null),y=g.useRef(null),k=g.useRef(null),N=g.useRef(null),A=g.useRef(0),v=g.useRef([]),C=g.useRef([]),E=g.useRef(new Map);g.useEffect(()=>{v.current=c},[c]);const P=g.useCallback(j=>{const L=E.current.get(j);return L?L<=Date.now()?(E.current.delete(j),!1):!0:!1},[]),b=g.useCallback((j,L=!0)=>{const R=j.toLowerCase().trim(),T=C.current.length>0?C.current:v.current;if(!R)return T.slice(0,ds);const K=T.filter(G=>G.text.toLowerCase().includes(R));return K.length>0?K.slice(0,ds):L?T.slice(0,ds):[]},[]),_=g.useCallback(async j=>{if(!r||j.length<Hn){d([]),C.current=[],x.current&&clearTimeout(x.current),y.current&&clearTimeout(y.current),f(!1);return}if(!a){d([]),C.current=[],x.current&&clearTimeout(x.current),f(!1);return}if(i===!1||P(a)){d([]),C.current=[],x.current&&clearTimeout(x.current),f(!1);return}k.current&&k.current.abort(),k.current=new AbortController;const L=A.current+1;A.current=L,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{L===A.current&&f(!0)},150);try{const R={"X-Adapter-Name":a};s&&(R["X-Session-ID"]=s);const T=new URLSearchParams;T.set("q",j),T.set("limit",String(ds)),o&&T.set("skill",o);const K=`/api/v1/autocomplete?${T.toString()}`,G=await fetch(K,{method:"GET",headers:R,signal:k.current.signal});if(!G.ok){pe("[useAutocomplete] Request failed:",G.status),[404,405,501].includes(G.status)?(E.current.set(a,Date.now()+Eu),d([]),C.current=[]):d(b(j));return}const H=await G.json(),Z=Array.isArray(H==null?void 0:H.suggestions)?H.suggestions.map(fe=>Vn(typeof fe=="string"?fe:fe==null?void 0:fe.text)).filter(fe=>fe!==null):[];if(L!==A.current)return;Z.length===0?d(b(j,!1)):(d(Z),C.current=Z),h(-1),D("[useAutocomplete] Received",Z.length,"suggestions")}catch(R){if(R instanceof Error&&R.name==="AbortError")return;pe("[useAutocomplete] Error:",R instanceof Error?R.message:String(R)),L===A.current&&d(b(j))}finally{L===A.current&&(x.current&&(clearTimeout(x.current),x.current=null),f(!1))}},[r,a,s,i,o,b,P]);g.useEffect(()=>{p.current&&clearTimeout(p.current);const j=()=>{k.current&&k.current.abort(),x.current&&clearTimeout(x.current),f(!1)},L=()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{y.current=null,d([]),j()},0)};if(!r||t.length<Hn||i===!1||a&&P(a)){L();return}if(N.current){if(t===N.current){L();return}N.current=null}return p.current=setTimeout(()=>{_(t)},Lu),()=>{p.current&&clearTimeout(p.current),y.current&&(clearTimeout(y.current),y.current=null)}},[t,_,r,a,i,P]),g.useEffect(()=>()=>{k.current&&k.current.abort(),x.current&&clearTimeout(x.current)},[]);const S=g.useCallback(()=>{h(j=>{const L=v.current.length;return L===0?-1:j<L-1?j+1:0})},[]),I=g.useCallback(()=>{h(j=>{const L=v.current.length;return L===0?-1:j>0?j-1:L-1})},[]),M=g.useCallback(()=>{d([]),C.current=[],h(-1),k.current&&k.current.abort(),x.current&&clearTimeout(x.current),f(!1)},[]),F=g.useCallback(j=>{if(!(l!=null&&l.current))return;const L=()=>{const R=l.current;if(!R)return;const T=typeof j=="string"?j.length:R.value.length;R.focus({preventScroll:!0}),typeof R.setSelectionRange=="function"&&R.setSelectionRange(T,T)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(L):setTimeout(L,0)},[l]),z=g.useCallback(j=>{N.current=j},[]);return{suggestions:c,isLoading:u,selectedIndex:m,setSelectedIndex:h,selectNext:S,selectPrevious:I,clearSuggestions:M,focusInputAfterSelection:F,suppressUntilQueryChange:z}}const Ot=new Map,Tu=new Map,Mu=new Map,Fu=new Set,$u=()=>{if(typeof window>"u")return null;try{return localStorage.getItem("chat-adapter-name")}catch{return null}},Vi=t=>typeof t=="object"&&t!==null&&"message"in t,Pu=t=>t instanceof Error?t.message:typeof t=="string"?t:Vi(t)?t.message??"Unknown error":"Unknown error";function Ru({conversationId:t,onFilesSelected:e,onUploadError:r,onClose:a,onUploadingChange:s,onUploadSuccess:i,maxFiles:o=le.maxFilesPerConversation,disabled:l=!1}){const{t:c}=Le(),[d,u]=g.useState(!1),[f,m]=g.useState(0),h=g.useRef(null),p=g.useRef(Mu),x=g.useRef(Fu),y=g.useRef(new Map),k=g.useRef(!0),N=g.useRef(Tu),A=g.useRef(t),v=ke(U=>U.conversations),C=g.useMemo(()=>{if(!t)return new Map;const U=Ot.get(t);return U?new Map(U):new Map},[t,f]),E=g.useCallback(U=>{if(!U){s==null||s(null,!1),m(se=>se+1);return}const te=Ot.get(U)||new Map,W=v.find(se=>se.id===U),Q=new Map(te);if(W!=null&&W.attachedFiles){const se=new Set(W.attachedFiles.filter(ge=>ge.processing_status==="completed"||ge.processing_status==="failed"||ge.processing_status==="error").map(ge=>ge.file_id));Q.forEach((ge,Ne)=>{ge.fileId&&se.has(ge.fileId)&&Q.delete(Ne)})}Q.size>0?(Ot.set(U,Q),s==null||s(U,!0)):(Ot.delete(U),s==null||s(U,!1)),m(se=>se+1)},[v,s]);g.useEffect(()=>{A.current=t,setTimeout(()=>{E(t)},0)},[t,E]),g.useEffect(()=>{t&&setTimeout(()=>{E(t)},0)},[v,t,E]);const P=g.useCallback((U,te)=>{if(!U)return;const W=Ot.get(U)||new Map,Q=te(new Map(W));Q.size>0?Ot.set(U,Q):Ot.delete(U),s==null||s(U,Q.size>0),m(se=>se+1)},[s]),b=g.useCallback((U,te)=>{if(!U)return;const W=N.current.get(U)||[],Q=te([...W||[]]),se=new Set(W.map(ge=>ge.file_id));if(N.current.set(U,Q),e(U,Q),i){const ge=Q.filter(Ne=>!se.has(Ne.file_id));ge.length>0&&i(U,ge)}m(ge=>ge+1)},[e,i]),_=ke(U=>U.removeFileFromConversation),S=ke(U=>U.addFileToConversation);g.useEffect(()=>(k.current=!0,()=>{k.current=!1}),[]);const I=g.useCallback(()=>{k.current=!1,new Map(y.current).forEach(te=>te.abort()),setTimeout(()=>{const te=ke.getState(),W=new Map(te.conversations.map(se=>[se.id,se])),Q=[];p.current.forEach((se,ge)=>{var Ne;if(se){const B=W.get(se);if(new Set(((Ne=B==null?void 0:B.attachedFiles)==null?void 0:Ne.map(ee=>ee.file_id))||[]).has(ge)){x.current.add(ge),p.current.delete(ge);return}}if(x.current.has(ge)){D(`[FileUpload] Skipping cleanup delete for ${ge}; file was previously attached and already handled`),p.current.delete(ge),x.current.delete(ge);return}Q.push({fileId:ge,conversationId:se||null})}),Q.length>0&&(a==null||a(),Q.forEach(async({fileId:se,conversationId:ge})=>{try{if(ge)await _(ge,se);else{const Ne=$u();await Ur.deleteFile(se,void 0,void 0,Ne??void 0)}}catch(Ne){if(Vi(Ne)){const B=Ne.message??"";!B.includes("404")&&!B.includes("File not found")&&pe(`Failed to cleanup file ${se} during component unmount:`,Ne)}else pe(`Failed to cleanup file ${se} during component unmount`,Ne)}}))},300)},[a,_]);g.useEffect(()=>I,[I]);const M=g.useCallback(async U=>{if(!U||U.length===0)return;const te=Array.from(U),W=ke.getState(),Q=t||W.currentConversationId;if(!Q){r==null||r(c("fileUpload.selectBeforeUpload"));return}const se=W.conversations.find(X=>X.id===Q);if(!se){r==null||r(c("fileUpload.conversationNotFound"));return}if((N.current.get(Q)||[]).length+te.length>o){const X=c("fileUpload.maxFilesPerConversationError",{count:o});rt()&&!xt()&&st.getState().openLoginPrompt(c("fileUpload.maxFilesGuestLimitMessage",{count:o})),r==null||r(X);return}if(le.maxTotalFiles!==null&&W.conversations.reduce((we,ae)=>{var Y;return we+(((Y=ae.attachedFiles)==null?void 0:Y.length)||0)},0)+te.length>le.maxTotalFiles){const we=c("fileUpload.maxTotalFilesError",{count:le.maxTotalFiles});rt()&&!xt()&&st.getState().openLoginPrompt(c("fileUpload.maxTotalFilesGuestLimitMessage",{count:le.maxTotalFiles})),r==null||r(we);return}if(!se.adapterName){r==null||r(c("fileUpload.adapterNotConfigured"));return}const Ne=se.adapterName,B=it(se.apiUrl);for(let X=0;X<te.length;X++){const ee=te[X],we=new AbortController;y.current.set(ee.name,we);const ae=`${Q}-${ee.name}-${Date.now()}-${X}`;let Y=null;try{const de=await Ur.uploadFile(ee,ve=>{if(P(Q,ce=>(ce.set(ae,ve),ce)),ve.fileId&&!Y){Y=ve.fileId,p.current.set(ve.fileId,Q),x.current.add(ve.fileId);const ce={file_id:ve.fileId,filename:ee.name,mime_type:ee.type||"application/octet-stream",file_size:ee.size,processing_status:ve.status==="uploading"?"uploading":ve.status==="processing"?"processing":ve.status==="completed"?"completed":void 0};D(`[FileUpload] Adding file ${ve.fileId} to conversation ${Q} immediately (status: ${ce.processing_status})`),S(Q,ce)}},void 0,B,Ne).catch(ve=>{if(ve.message&&ve.message.includes("was deleted")){Y&&p.current.delete(Y);const ce=ve.message.match(/File\s+([\w-]+)\s+was deleted/);return ce&&ce[1]&&p.current.delete(ce[1]),D(`File ${ee.name} was deleted during upload`),null}throw ve});de?(p.current.set(de.file_id,Q),x.current.add(de.file_id),D(`[FileUpload] Updating file ${de.file_id} in conversation ${Q} with final status`),S(Q,de),de.processing_status==="completed"||de.processing_status==="failed"||de.processing_status==="error"?P(Q,ce=>(ce.delete(ae),ce)):P(Q,ce=>{const Pe=ce.get(ae);return Pe&&ce.set(ae,{...Pe,progress:90,status:"processing",fileId:de.file_id}),ce}),b(Q,ce=>{if(new Set(ce.map(V=>V.file_id)).has(de.file_id))return ce;const Me=[...ce,de];return D(`[FileUpload] Updated uploadedFiles for ${Q}: ${Me.length} files`,Me),Me})):(pe(`Upload completed for ${ee.name} but uploadedAttachment is null`),P(Q,ve=>(ve.delete(ae),ve)))}catch(de){const ve=Pu(de);if(de instanceof DOMException&&de.name==="AbortError"||we.signal.aborted){D(`Upload cancelled for ${ee.name}`),Y&&p.current.delete(Y);continue}if(ve.includes("was deleted")){D(`File ${ee.name} was deleted during upload`),Y&&p.current.delete(Y);const Me=ve.match(/File\s+([\w-]+)\s+was deleted/);Me&&Me[1]&&p.current.delete(Me[1]);continue}k.current?(xe(`Failed to upload file ${ee.name}:`,de),xe(`File type: ${ee.type}, File name: ${ee.name}`),r==null||r(ve||`Failed to upload ${ee.name}`)):pe(`Upload error for ${ee.name} (component unmounted):`,ve),Y&&p.current.delete(Y);const ce=ae,Pe=Q;setTimeout(()=>{P(Pe,Me=>(Me.delete(ce),Me))},5e3)}finally{y.current.delete(ee.name)}}},[S,t,o,r,c,b,P]),F=g.useCallback(U=>{U.preventDefault(),U.stopPropagation(),l||u(!0)},[l]),z=g.useCallback(U=>{U.preventDefault(),U.stopPropagation(),u(!1)},[]),j=g.useCallback(U=>{if(U.preventDefault(),U.stopPropagation(),u(!1),l)return;const te=U.dataTransfer.files;M(te)},[l,M]),L=g.useCallback(U=>{const te=U.target.files;M(te),h.current&&(h.current.value="")},[M]),R=g.useCallback(()=>{!l&&h.current&&h.current.click()},[l]),T=g.useCallback(U=>{l||(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),R())},[l,R]),K=C.size>0,G=g.useMemo(()=>{const U=new Map;return v.forEach(te=>{U.set(te.id,te.title||c("chatInterface.newChatTitle"))}),U},[v,c]),H=g.useMemo(()=>{const U=[];return Ot.forEach((te,W)=>{W!==t&&te.size>0&&U.push({conversationId:W,uploads:Array.from(te.entries()).map(([Q,se])=>({key:Q,progress:se}))})}),U},[t,f]),Z=(U,te)=>{const W=U.status==="error";return n.jsxs("div",{className:`group relative w-full flex items-center gap-3 rounded-lg px-3 py-2.5 overflow-hidden transition-colors ${W?"border border-red-200 bg-red-50 dark:border-red-500/30 dark:bg-[#101010]":"border border-gray-200 bg-gray-50 dark:border-[#242424] dark:bg-[#101010]"}`,children:[!W&&n.jsx("div",{className:"absolute inset-0 bg-blue-50 dark:bg-white/[0.04] transition-all duration-500 ease-out rounded-lg",style:{width:`${U.progress}%`}}),n.jsxs("div",{className:"relative flex items-center gap-3 w-full min-w-0",children:[n.jsx("div",{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md ${W?"bg-red-100 dark:bg-red-500/15":"bg-blue-100 dark:bg-white/[0.06]"}`,children:W?n.jsx(ps,{className:"h-4 w-4 text-red-500 dark:text-red-400"}):n.jsx(xs,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 animate-spin"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium text-[#353740] dark:text-[#ececf1] truncate",children:U.filename}),W?n.jsx("p",{className:"mt-0.5 text-xs text-red-600 dark:text-red-400 truncate",children:U.error||c("fileUpload.processingFailedMessage")}):n.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[n.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-[#242424] rounded-full h-1",children:n.jsx("div",{className:"bg-blue-500 dark:bg-blue-400 h-1 rounded-full transition-all duration-500 ease-out",style:{width:`${U.progress}%`}})}),n.jsxs("span",{className:"text-[11px] tabular-nums text-gray-400 dark:text-[#8e8ea0] shrink-0",children:[Math.round(U.progress),"%"]})]})]}),n.jsx("span",{className:`text-xs font-medium shrink-0 ${W?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-[#bfc2cd]"}`,children:U.status==="uploading"?c("fileUpload.uploadingStatus"):U.status==="processing"?c("fileUpload.processingStatus"):U.status==="completed"?c("fileUpload.completedStatus"):c("fileUpload.failedStatus")})]})]},te)},fe=n.jsx("div",{className:"w-full max-w-full overflow-hidden space-y-1.5",role:"status","aria-live":"polite",children:Array.from(C.entries()).map(([U,te])=>Z(te,U))});return n.jsxs("div",{className:"w-full max-w-full overflow-hidden space-y-2",children:[K&&fe,!K&&n.jsxs("button",{type:"button",onClick:R,onKeyDown:T,onDragOver:F,onDragLeave:z,onDrop:j,disabled:l,className:`
|
|
331
|
+
group relative w-full max-w-full rounded-lg border p-4 transition-all duration-200 text-left overflow-hidden
|
|
332
|
+
${d?"border-blue-300 bg-blue-50 ring-2 ring-blue-400 ring-inset dark:border-blue-500/40 dark:bg-[#101010] dark:ring-blue-500":l?"border-gray-200 bg-gray-50 cursor-not-allowed opacity-50 dark:border-[#242424] dark:bg-[#101010]":"border-gray-200 bg-gray-50 hover:bg-gray-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/50 focus-visible:ring-inset dark:border-[#242424] dark:bg-[#101010] dark:hover:bg-[#1a1a1a]"}
|
|
333
|
+
`,"aria-label":c(l?"fileUpload.disabledAriaLabel":"fileUpload.enabledAriaLabel"),children:[n.jsx("input",{ref:h,type:"file",multiple:!0,onChange:L,className:"hidden",disabled:l,accept:".pdf,.doc,.docx,.txt,.md,.csv,.json,.html,.pptx,.xlsx,.py,.java,.sql,.js,.mjs,.ts,.tsx,.cpp,.cxx,.cc,.c,.h,.hpp,.go,.rs,.rb,.php,.sh,.bash,.zsh,.yaml,.yml,.xml,.css,.scss,.sass,.less,.png,.jpg,.jpeg,.tiff,.webp,.wav,.mp3,.mp4,.ogg,.flac,.webm,.m4a,.aac,.vtt"}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg transition-colors duration-200 ${d?"bg-blue-100 dark:bg-blue-500/15":"bg-gray-200/70 dark:bg-[#1a1a1a] group-hover:bg-blue-100 dark:group-hover:bg-[#242424]"}`,children:n.jsx(sd,{className:`h-5 w-5 transition-colors duration-200 ${d?"text-blue-600 dark:text-blue-400":"text-gray-400 dark:text-[#8e8ea0] group-hover:text-blue-500 dark:group-hover:text-blue-400"}`})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:`text-sm font-medium transition-colors duration-200 ${d?"text-blue-700 dark:text-blue-300":"text-[#353740] dark:text-[#ececf1]"}`,children:c(l?"fileUpload.disabledAriaLabel":d?"fileUpload.draggingText":"fileUpload.dragDropText")}),n.jsx("p",{className:"text-xs text-gray-400 dark:text-[#8e8ea0] mt-0.5",children:c("fileUpload.fileTypesAndLimit",{count:o})})]})]})]}),H.length>0&&n.jsxs("div",{className:"w-full max-w-full space-y-2 rounded-lg border border-gray-200 bg-gray-50 p-2.5 dark:border-[#242424] dark:bg-[#101010]",children:[n.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] px-1",children:c("fileUpload.otherConversationsLabel")}),H.map(({conversationId:U,uploads:te})=>n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("div",{className:"text-[11px] font-medium text-gray-400 dark:text-[#6b6f7a] px-1",children:G.get(U)||"Conversation"}),te.map(({key:W,progress:Q})=>Z(Q,W))]},U))]})]})}const qn={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"png","image/tiff":"tiff","image/tif":"tif","image/gif":"gif","image/webp":"webp","application/pdf":"pdf","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/msword":"doc","text/plain":"txt","text/markdown":"md","application/json":"json"},us=4,fs=3,Du=0,Ou=0,ta=2;function Uu(t){if(!t||typeof t!="object")return null;const e=t,r=["supportsAutocomplete","isAutocompleteSupported","autocompleteSupported"];for(const i of r)if(typeof e[i]=="boolean")return e[i];const a=["capabilities","features"],s=["autocomplete","supportsAutocomplete","autocomplete_supported"];for(const i of a){const o=e[i];if(!o||typeof o!="object")continue;const l=o;for(const c of s)if(typeof l[c]=="boolean")return l[c]}return null}function zu(t){if(!t)return"bin";if(qn[t])return qn[t];const e=t.split("/");return e.length===2&&e[1]?e[1]:"bin"}function Bu(t){return t.replace(/[^a-zA-Z0-9._-]/g,"_").replace(/_+/g,"_")||"pasted-file"}function Hu(t){const e=t.lastIndexOf(".");return e===-1||e===t.length-1?null:t.slice(e+1).toLowerCase()}function Vu(t){const e=t.lastIndexOf(".");return e===-1?t:t.slice(0,e)}function ra(t){return!t||t==="processing"||t==="uploading"}function qu(t,e){const r=Date.now(),a=t.name&&t.name.trim().length>0?t.name.trim():"pasted-file",s=Bu(Vu(a)),o=Hu(a)||zu(t.type),l=`${s}-${r}-${e}.${o}`;return new File([t],l,{type:t.type||"application/octet-stream"})}function Wn({onSend:t,disabled:e=!1,placeholder:r=mi(),autoFocusEnabled:a=!0,suppressMobileAutoFocus:s=!1,isCentered:i=!1,maxWidthClass:o="max-w-5xl",adapterNotes:l,skillState:c,availableModels:d=[],defaultModel:u=null,selectedModel:f=null,onSelectModel:m}){var Ya;const{t:h}=Le(),[p,x]=g.useState(""),[y,k]=g.useState(!1),[N,A]=g.useState(!1),[v,C]=g.useState(!1),[E,P]=g.useState(!1),[b,_]=g.useState([]),[S,I]=g.useState({}),[M,F]=g.useState(new Map),[z,j]=g.useState(!1),[L,R]=g.useState(!1),[T,K]=g.useState(null),[G,H]=g.useState(null),[Z,fe]=g.useState(null),[U,te]=g.useState({isOpen:!1,fileId:"",filename:"",isDeleting:!1}),W=g.useRef(null),Q=g.useRef(null),se=g.useRef(null),ge=g.useRef(null),Ne=g.useRef(null),B=g.useRef(new Set),X=g.useRef(""),ee=g.useRef(!1),we=g.useRef(0),ae=g.useRef(null),{settings:Y,updateSettings:de}=Es(),{theme:ve,isDark:ce}=rr(),Pe=ve.mode==="dark"?"dark":ve.mode==="light"?"light":"",Me=ce?"dark":"light";Dr(Q,{enabled:v,onEscape:()=>C(!1)});const V=g.useCallback((w,O)=>{w&&I(oe=>{if(oe[w]===O)return oe;const me={...oe};return O?me[w]=!0:delete me[w],me})},[]),[ie,ze]=g.useState(0),[be,Ae]=g.useState(!1),[_t,Ue]=g.useState(0),[Je,mr]=g.useState(()=>({top:us+fs,bottom:Math.max(us-fs,0)})),[ut,Tt]=g.useState(null),Vt=hr(),Ze=rt()&&!Vt,Mt=st(w=>w.showLoginPrompt),{createConversation:qt,currentConversationId:Ce,conversations:Qe,isLoading:ft,syncConversationFiles:ue,stopStreaming:Se,removeFileFromConversation:_e}=ke(),re=Qe.find(w=>w.id===Ce),et=re?re.messages.filter(w=>!(w.role==="assistant"&&w.isStreaming)).length:0,Be=Qe.reduce((w,O)=>w+O.messages.filter(oe=>!(oe.role==="assistant"&&oe.isStreaming)).length,0),pr=!!re&&le.maxMessagesPerConversation!==null&&et>=le.maxMessagesPerConversation,at=le.maxTotalMessages!==null&&Be>=le.maxTotalMessages,xr=g.useCallback(()=>{ze(w=>w+1)},[]),zr=Ql(),sr=ec(),{isListening:tt,isSupported:Br,startListening:Hr,stopListening:ar,error:Wt}=Iu(w=>{x(O=>{const oe=O.length>0&&!/\s$/.test(O)?" ":"",me=(O+oe+w).slice(0,le.maxMessageLength);return X.current=me,me})},xr,{silenceTimeoutMs:zr,language:sr||void 0}),br=Yl(),Ft=Jl(),lt=Ft&&Br,$t=Xl(),Rs=xi(),yr=Uu(re==null?void 0:re.adapterInfo),{skills:Pt,isLoading:Ds,selectedSkill:He,selectSkill:wr,clearSkill:Kt}=c,Vr=(re==null?void 0:re.adapterName)||null,{suggestions:Rt,selectedIndex:gt,setSelectedIndex:Gt,selectNext:Os,selectPrevious:Us,clearSuggestions:bt,focusInputAfterSelection:qr,suppressUntilQueryChange:kr}=_u(p,{enabled:Rs&&!tt,apiUrl:re==null?void 0:re.apiUrl,adapterName:Vr,sessionId:re==null?void 0:re.sessionId,adapterSupportsAutocomplete:yr,skill:(He==null?void 0:He.name)||null,inputRef:W}),nr=Rt.length>0,vr=!tt,$=vr&&nr&&!be,ye=p.startsWith("/")?p.slice(1):"",q=ye.toLowerCase().replace(/-/g," "),je=q?Pt.filter(w=>w.name.replace(/-/g," ").toLowerCase().includes(q)||w.description.toLowerCase().includes(q)):Pt,ct=je.length>0?Math.min(_t,je.length-1):0,We=je[ct]??null,Xt=(We==null?void 0:We.name.replace(/-/g," "))??"",to=be&&We&&p.startsWith("/")&&Xt.toLowerCase().startsWith(ye.toLowerCase())&&Xt.length>ye.length?Xt.slice(ye.length):null,ro=gt>=0?gt:0,Sr=nr?Rt[ro]:null,Ra=g.useMemo(()=>{if(!Sr)return null;const w=Sr.text||"";if(!p)return w;const O=p;return w.toLowerCase().startsWith(O.toLowerCase())&&w.length>O.length?w.slice(O.length):null},[Sr,p]),zs=to??Ra,so=p.trim().length===0&&!zs,ao=g.useCallback(w=>{if(!p)return n.jsx("span",{className:"line-clamp-1 text-current",children:w});if(!w.toLowerCase().startsWith(p.toLowerCase()))return n.jsx("span",{className:"line-clamp-1 text-current",children:w});const O=w.slice(0,p.length),oe=w.slice(p.length);return n.jsxs("span",{className:"line-clamp-1",children:[n.jsx("span",{className:"text-gray-500 dark:text-[#8e8ea0]",children:O}),n.jsx("span",{className:"font-semibold text-[#353740] dark:text-[#ececf1]",children:oe})]})},[p]),Da=g.useCallback(w=>{var O;wr(w),Ae(!1),x(""),bt(),Ue(0),(O=W.current)==null||O.focus()},[bt,wr]),no=g.useCallback(()=>{var w;x("/"),Ae(!0),Ue(0),(w=W.current)==null||w.focus()},[]),Oa=g.useCallback(()=>{var w;Ae(!1),x(""),Ue(0),(w=W.current)==null||w.focus()},[]),Yt=g.useCallback(()=>{const w=W.current;if(!w||typeof window>"u")return;const O=mt=>{const es=mt+fs,ts=Math.max(mt-fs,0);w.style.paddingTop=`${es}px`,w.style.paddingBottom=`${ts}px`,mr({top:es,bottom:ts})},oe=window.getComputedStyle(w),me=parseFloat(oe.lineHeight||"0");if(!Number.isNaN(me)&&me>0?Tt(mt=>mt===me?mt:me):Tt(mt=>mt===null?mt:null),!me||Number.isNaN(me)){O(us);return}const Ie=w.scrollHeight,Ke=w.clientHeight;if(Ie>me+2){O(us);return}const Ee=Math.max(Ke-me,0),Zt=Math.max(Ee/2,0);O(Zt)},[]),io=()=>{const w=W.current;return w?w.selectionStart===w.selectionEnd&&w.selectionStart===p.length:!1},Ua=(re==null?void 0:re.attachedFiles)||[],ir=Ce?Ua:b,oo=Qe.reduce((w,O)=>{var oe;return w+(((oe=O.attachedFiles)==null?void 0:oe.length)||0)},0),za=le.maxFilesPerConversation!==null&&le.maxFilesPerConversation>0&&Ua.length>=le.maxFilesPerConversation,Ba=le.maxTotalFiles!==null&&oo>=le.maxTotalFiles,jr=((Ya=re==null?void 0:re.adapterInfo)==null?void 0:Ya.isFileSupported)??!1,Bs=ir.some(w=>w.processing_status?w.processing_status!=="completed"&&w.processing_status!=="error"&&w.processing_status!=="failed":!0),ht=Ce?!!S[Ce]:!1,Wr=Object.values(S).some(Boolean),Hs=p.trim().length>0,Ha=pr||at,De=e||Bs||ht||Ha,Va=$t&&jr,Kr=za||Ba,Cr=!Va||De||Kr;g.useLayoutEffect(()=>{if(W.current){const w=W.current,O=120;w.style.height="auto";const oe=w.scrollHeight;w.style.height=`${Math.min(oe,O)}px`,w.style.overflowY=oe>O?"auto":"hidden",Yt()}},[p,Yt]),g.useEffect(()=>{if(typeof window>"u"||typeof ResizeObserver>"u")return;const w=W.current;if(!w)return;const O=new ResizeObserver(()=>{Yt()});return O.observe(w),()=>{O.disconnect()}},[Yt]);const qa=()=>{const w=document.activeElement;return w&&w.tagName==="TEXTAREA"},Gr=g.useCallback(()=>!s||typeof window>"u"?!1:window.matchMedia("(max-width: 767px)").matches,[s]);g.useEffect(()=>{Gr()||a&&!De&&W.current&&!qa()&&W.current.focus()},[a,De,s,Gr]);const Vs=g.useRef(ft);g.useEffect(()=>{if(Gr()){Vs.current=ft;return}a&&Vs.current&&!ft&&!De&&W.current&&setTimeout(()=>{W.current&&!qa()&&W.current.focus()},100),Vs.current=ft},[a,ft,De,s,Gr]),g.useEffect(()=>{if(!lt||(ie>we.current&&(ee.current=!0,we.current=ie),!ee.current||ie===0))return;const w=X.current.trim(),O=ke.getState();if(D("[MessageInput] Auto-send check after voice completion:",{hasMessage:!!w,isInputDisabled:De,isComposing:y,isLoading:O.isLoading}),ee.current=!1,!w)return;if(De||y){D("[MessageInput] Auto-send skipped because input is currently disabled or composing");return}const oe=O.conversations.find(Te=>Te.id===O.currentConversationId),Ie=((oe==null?void 0:oe.attachedFiles)||[]).map(Te=>Te.file_id),Ke=He==null?void 0:He.name;D("[MessageInput] Auto-sending voice message immediately:",w),t(w,Ie.length>0?Ie:void 0,void 0,Ke),Ke&&Kt(),setTimeout(()=>{Ae(!1)},0),bt(),setTimeout(()=>{x("")},0),X.current="",W.current&&(W.current.style.height="auto",W.current.style.overflowY="hidden",Yt())},[lt,ie,De,y,t,He,Kt,Yt,bt]),g.useEffect(()=>{ht&&E&&setTimeout(()=>{P(!1)},0)},[ht,E]);const Xr=g.useCallback((w,O)=>{setTimeout(()=>{let oe=ke.getState(),me=O||oe.currentConversationId;if(me||(me=qt(),oe=ke.getState(),me=oe.currentConversationId||me),!me){xe("[MessageInput] Unable to sync files: conversation ID missing");return}const Ie=new Set(w.map(Te=>Te.file_id)),Ke=[];B.current.forEach((Te,Ee)=>{const[,...Zt]=Ee.split("-"),mt=Zt.join("-");Ie.has(mt)||Ke.push(Ee)}),Ke.forEach(Te=>B.current.delete(Te)),w.forEach(Te=>{const Ee=`${me}-${Te.file_id}`;B.current.has(Ee)||(B.current.add(Ee),D(`[MessageInput] Adding file ${Te.file_id} to conversation ${me}`),oe.addFileToConversation(me,Te))})},0)},[qt]);g.useEffect(()=>{if(Ce!==ae.current)if(ae.current=Ce||null,Ce&&re){const w=re.attachedFiles||[];setTimeout(()=>{_(w.map(O=>({...O})))},0)}else setTimeout(()=>{_([])},0)},[Ce,re]),g.useEffect(()=>{if(Ce&&re){const w=re.attachedFiles||[];w.length>0?setTimeout(()=>{_(O=>{const oe=new Set(O.map(Ie=>Ie.file_id)),me=w.filter(Ie=>!oe.has(Ie.file_id));return me.length>0?(D(`[MessageInput] Syncing ${me.length} missing files from conversation to UI`),[...O,...me]):O})},0):w.length===0&&b.length>0&&setTimeout(()=>{_([])},0)}},[Ce,re,Qe,b.length]);const qs=g.useRef(null),Ws=g.useRef(""),Yr=(re==null?void 0:re.attachedFiles)||[],Jr=Yr.length>0?`${Yr.length}:${Yr.map(w=>w.file_id).join("|")}`:"",Wa=Yr.some(w=>ra(w.processing_status));g.useEffect(()=>{if(!Ce||!(re!=null&&re.adapterName))return;const w=Jr!=="";if(w&&(qs.current!==Ce||Ws.current!==Jr)?(D(`[MessageInput] Syncing files for conversation ${Ce}...`),qs.current=Ce,Ws.current=Jr,ue(Ce).catch(me=>{xe("[MessageInput] Failed to sync conversation files:",me)})):w||(qs.current=Ce,Ws.current=""),!Wa)return;D("[MessageInput] Files still processing, starting poll...");const oe=setInterval(async()=>{const Ie=ke.getState().conversations.find(Ee=>Ee.id===Ce);if(!Ie){clearInterval(oe);return}if((Ie.attachedFiles||[]).filter(Ee=>ra(Ee.processing_status)).length===0){D("[MessageInput] All files completed processing, stopping poll"),clearInterval(oe);return}try{await ue(Ce)}catch(Ee){xe("[MessageInput] Failed to poll file status:",Ee)}},3e3);return()=>{clearInterval(oe)}},[Ce,re==null?void 0:re.adapterName,Jr,Wa,ue]),g.useEffect(()=>{setTimeout(()=>{I(w=>{const O=new Set(Qe.map(Ie=>Ie.id));let oe=!1;const me={...w};return Object.keys(me).forEach(Ie=>{O.has(Ie)||(delete me[Ie],oe=!0)}),oe?me:w})},0)},[Qe]);const Ka=w=>{if(w.preventDefault(),Hs&&!De&&!y){tt&&ar();const oe=((re==null?void 0:re.attachedFiles)||[]).map(Ie=>Ie.file_id),me=He==null?void 0:He.name;t(p.trim(),oe.length>0?oe:void 0,void 0,me),me&&Kt(),Ae(!1),_r("messageSent",Y.soundEnabled),x(""),X.current="",_([]),P(!1),W.current&&(W.current.style.height="auto",W.current.style.overflowY="hidden",Yt())}},Zr=g.useCallback(w=>{if(!w||w.length===0)return;const O=w.length===1?h("messageInput.uploadSuccess.single",{filename:w[0].filename}):h("messageInput.uploadSuccess.multiple",{count:w.length});_r("success",Y.soundEnabled),H(O),setTimeout(()=>{H(null)},6e3)},[Y.soundEnabled,h]),lo=g.useCallback((w,O)=>{D(`[MessageInput] handleFilesSelected called with ${O.length} files for conversation ${w}:`,O),w&&(w===Ce&&_(O),Xr(O,w))},[Ce,Xr]),co=g.useCallback((w,O)=>{w===Ce&&Zr(O)},[Ce,Zr]),uo=g.useCallback(w=>{te({isOpen:!0,fileId:w.file_id,filename:w.filename,isDeleting:!1})},[]),fo=g.useCallback(()=>{te(w=>w.isDeleting?w:{isOpen:!1,fileId:"",filename:"",isDeleting:!1})},[]),go=g.useCallback(async()=>{if(!(!Ce||!U.fileId)){te(w=>({...w,isDeleting:!0}));try{await _e(Ce,U.fileId),_(w=>w.filter(O=>O.file_id!==U.fileId)),te({isOpen:!1,fileId:"",filename:"",isDeleting:!1})}catch(w){const O=w instanceof Error?w.message:h("messageInput.fileRemoveFailed");xe("[MessageInput] Failed to remove file:",w),fe(O),te({isOpen:!1,fileId:"",filename:"",isDeleting:!1})}}},[Ce,U.fileId,_e,h]),Ga=g.useCallback(w=>w.replace(/\s+/g," ").trim(),[]),Qr=g.useCallback(w=>{const O=Ga(w);x(O),bt(),kr(O),qr(O)},[bt,qr,Ga,kr]),Ks=g.useCallback(w=>{if(w<0)return;const O=Rt[w]||Rt[0];O&&Qr(O.text)},[Rt,Qr]),ho=w=>{if(be){if(w.key==="ArrowDown"){w.preventDefault(),Ue(O=>je.length===0?0:(O+1)%je.length);return}if(w.key==="ArrowUp"){w.preventDefault(),Ue(O=>je.length===0?0:(O-1+je.length)%je.length);return}if(w.key==="Home"){w.preventDefault(),Ue(0);return}if(w.key==="End"){w.preventDefault(),Ue(Math.max(je.length-1,0));return}if((w.key==="Enter"&&!w.shiftKey||w.key==="Tab")&&We){w.preventDefault(),Da(We);return}if(w.key==="Escape"){w.preventDefault(),Oa();return}}if(nr&&vr){if(w.key==="ArrowDown"){w.preventDefault(),Os();return}if(w.key==="ArrowUp"){w.preventDefault(),Us();return}if(w.key==="Tab"){w.preventDefault();const O=gt>=0?gt:0;Ks(O);return}if(w.key==="ArrowRight"&&io()){if(Ra&&Sr){w.preventDefault(),Qr(Sr.text);return}if(gt>=0){w.preventDefault(),Ks(gt);return}}if(w.key==="Enter"&>>=0){w.preventDefault(),Ks(gt);return}if(w.key==="Escape"){w.preventDefault(),bt();return}}w.key==="Enter"&&!w.shiftKey&&!y&&(w.preventDefault(),Ka(w))},mo=()=>{tt?ar():(bt(),Hr())},po=()=>{const w=!Y.voiceEnabled;de({voiceEnabled:w}),w&&Bt.enableAudio()},xo=g.useCallback(async w=>{if(!$t||!N||!jr||De)return;const O=w.clipboardData;if(!O||!O.items)return;const me=Array.from(O.items).filter(Te=>Te.kind==="file");if(me.length===0)return;const Ie=[];if(me.forEach((Te,Ee)=>{const Zt=Te.getAsFile();Zt&&Ie.push(qu(Zt,Ee))}),Ie.length===0)return;w.preventDefault(),K(null),H(null);let Ke=null;try{const Te=ke.getState(),Ee=Te.conversations.find(nt=>nt.id===Te.currentConversationId);if(((Ee==null?void 0:Ee.attachedFiles)||[]).length+Ie.length>le.maxFilesPerConversation)throw Ze&&st.getState().openLoginPrompt(h("fileUpload.maxFilesGuestLimitMessage",{count:le.maxFilesPerConversation})),new Error(h("fileUpload.maxFilesPerConversationError",{count:le.maxFilesPerConversation}));if(le.maxTotalFiles!==null&&Te.conversations.reduce((yt,At)=>{var Ge;return yt+(((Ge=At.attachedFiles)==null?void 0:Ge.length)||0)},0)+Ie.length>le.maxTotalFiles)throw Ze&&st.getState().openLoginPrompt(h("fileUpload.maxTotalFilesGuestLimitMessage",{count:le.maxTotalFiles})),new Error(h("fileUpload.maxTotalFilesError",{count:le.maxTotalFiles}));if(!Ee)throw new Error(h("messageInput.conversationNotFoundShort"));if(!Ee.adapterName)throw new Error(h("fileUpload.adapterNotConfigured"));const es=it(Ee.apiUrl),ts=Ee.adapterName;Ke=Ee.id,V(Ke,!0);const Nr=[],Ja=[];for(let nt=0;nt<Ie.length;nt++){const yt=Ie[nt],At=yt.name||`Clipboard file ${nt+1}`,Ge=`${At}-${Date.now()}-${nt}`;F(pt=>{const Dt=new Map(pt);return Dt.set(Ge,{filename:At,progress:0,status:"uploading"}),Dt});const wo=pt=>{F(Dt=>{const dt=new Map(Dt),Ar=dt.get(Ge);return Ar&&dt.set(Ge,{...Ar,filename:At,progress:pt.progress,status:pt.status,fileId:pt.fileId}),dt})},ko=()=>new Promise(pt=>{F(Dt=>{const dt=new Map(Dt),Ar=dt.get(Ge);return Ar&&dt.set(Ge,{...Ar,progress:100,status:"completed"}),dt}),setTimeout(()=>{F(Dt=>{const dt=new Map(Dt);return dt.delete(Ge),dt}),pt()},2500)});D(`[MessageInput] Pasting file: ${yt.name}, type: ${yt.type||"unknown"}, size: ${yt.size}`);const vo=await Ur.uploadFile(yt,pt=>{D(`[MessageInput] Paste upload progress for ${yt.name}: ${pt.progress}% - ${pt.status}`),wo(pt)},void 0,es,ts);Nr.push(vo),Ja.push(ko())}if(Nr.length>0){let nt=Nr;if(Ke&&Ke===Ce){const yt=new Set(b.map(Ge=>Ge.file_id)),At=Nr.filter(Ge=>!yt.has(Ge.file_id));At.length>0?(_(Ge=>[...Ge,...At]),nt=At):nt=[]}nt.length>0&&Xr(nt,Ke),await Promise.all(Ja),Zr(Nr)}}catch(Te){const Ee=Te instanceof Error?Te.message:"Failed to paste file";xe("[MessageInput] Paste error:",Te),_r("error",Y.soundEnabled),K(Ee),Ee.toLowerCase().includes("maximum")&&fe(Ee),setTimeout(()=>{K(null)},5e3),F(new Map)}finally{V(Ke,!1)}},[b,Ce,N,jr,Ze,De,V,Y.soundEnabled,Zr,Xr,$t,h]),Xa=Vl(re==null?void 0:re.adapterName);let Nt;at?Nt=Ze?h("messageInput.placeholder.guestLimitTotal",{count:le.maxTotalMessages}):h("messageInput.placeholder.workspaceLimitTotal",{count:le.maxTotalMessages}):pr?Nt=Ze?h("messageInput.placeholder.guestLimitPerConversation",{count:le.maxMessagesPerConversation}):h("messageInput.placeholder.conversationLimitReached",{count:le.maxMessagesPerConversation}):Bs||ht?Nt=h("messageInput.placeholder.filesUploading"):Xa?Nt=Xa:Va?Nt=h("messageInput.placeholder.messageOrbit"):Nt=r;const Jt=[];at&&le.maxTotalMessages!==null&&(Ze?Mt&&Jt.push(h("messageInput.limitWarning.guestTotalMessages",{count:le.maxTotalMessages})):Jt.push(h("messageInput.limitWarning.workspaceTotalMessages",{count:le.maxTotalMessages}))),pr&&le.maxMessagesPerConversation!==null&&(Ze?Mt&&Jt.push(h("messageInput.limitWarning.guestPerConversation",{count:le.maxMessagesPerConversation})):Jt.push(h("messageInput.limitWarning.conversationLimitReached",{count:le.maxMessagesPerConversation}))),Z&&Jt.push(Z),g.useEffect(()=>{!Ft||!Wt||_r("error",Y.soundEnabled)},[Ft,Y.soundEnabled,Wt]),g.useEffect(()=>{if(!Z)return;const w=setTimeout(()=>fe(null),5e3);return()=>clearTimeout(w)},[Z]),g.useEffect(()=>{var w;(E||ht||M.size>0||Wr)&&((w=se.current)==null||w.scrollIntoView({behavior:"smooth",block:"nearest"}))},[E,ht,M.size,Wr]),g.useEffect(()=>{var w;$&&((w=ge.current)==null||w.scrollIntoView({behavior:"smooth",block:"nearest"}))},[$]),g.useEffect(()=>{var w;be&&((w=Ne.current)==null||w.scrollIntoView({behavior:"smooth",block:"end"}))},[be,je.length]);const bo=o,yo=i?"flex justify-center":"";return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:`bg-transparent px-2 py-1.5 md:bg-transparent md:px-0 md:pt-4 md:pb-2 md:dark:bg-transparent sm:px-4 ${yo}`,children:n.jsxs("div",{className:`mx-auto w-full ${bo}`,children:[Wt&&Ft&&n.jsxs("div",{role:"alert","aria-live":"assertive",className:"mb-2.5 w-full flex items-start gap-2.5 rounded-lg bg-red-50 dark:bg-red-950/40 px-3.5 py-2.5 animate-fadeIn",children:[n.jsx(ps,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-red-500 dark:text-red-400"}),n.jsx("span",{className:"text-sm text-red-700 dark:text-red-300",children:Wt})]}),T&&n.jsxs("div",{role:"alert","aria-live":"assertive",className:"mb-2.5 w-full flex items-start gap-2.5 rounded-lg bg-red-50 dark:bg-red-950/40 px-3.5 py-2.5 animate-fadeIn",children:[n.jsx(ps,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-red-500 dark:text-red-400"}),n.jsx("span",{className:"text-sm text-red-700 dark:text-red-300",children:T})]}),G&&n.jsxs("div",{role:"status","aria-live":"polite",className:"mb-2.5 w-full flex items-center gap-2.5 rounded-lg bg-gray-50 dark:bg-[#1f1f24] px-3.5 py-2.5 animate-fadeIn",children:[n.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-emerald-100 dark:bg-emerald-900/40",children:n.jsx(Lc,{className:"h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400"})}),n.jsx("span",{className:"text-sm text-[#353740] dark:text-[#ececf1]",children:G})]}),Jt.length>0&&n.jsxs("div",{role:"status","aria-live":"polite",className:"mb-2.5 w-full flex items-start gap-2.5 rounded-lg bg-amber-50 dark:bg-amber-950/30 px-3.5 py-2.5 animate-fadeIn",children:[n.jsx(Ea,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-amber-500 dark:text-amber-400"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("ul",{className:"list-none space-y-0.5",children:Jt.map((w,O)=>n.jsx("li",{className:"text-sm text-amber-800 dark:text-amber-200",children:w},`${w}-${O}`))}),Ze&&(Ha||Kr)&&Mt&&n.jsx("button",{type:"button",onClick:()=>st.getState().openLoginPrompt(h("messageInput.signInPrompt.message")),className:"mt-2 inline-flex items-center gap-1.5 rounded-md bg-[#353740] px-3 py-1.5 text-xs font-medium text-white hover:bg-[#40414f] dark:bg-white dark:text-[#353740] dark:hover:bg-gray-200 transition-colors",children:h("messageInput.signInPrompt.button")})]})]}),n.jsxs("div",{className:"relative w-full",children:[n.jsxs("form",{onSubmit:Ka,className:"flex w-full flex-col gap-2 md:gap-3",children:[n.jsxs("div",{className:`flex flex-row items-center gap-1.5 md:gap-2 rounded-xl md:rounded-lg border px-2.5 py-1.5 md:px-4 md:py-3 shadow-sm transition-all ${N?"border-gray-400 shadow-md dark:border-[#3a3a3a] dark:shadow-lg":"border-gray-300 dark:border-[#242424]"} bg-gray-50 dark:bg-[#111111]`,children:[He&&n.jsxs("div",{className:"flex h-8 max-w-[45%] shrink-0 items-center gap-1.5 self-center rounded-full border border-gray-300 bg-white px-2.5 text-xs text-gray-700 shadow-sm dark:border-[#3a3a3a] dark:bg-[#1a1a1a] dark:text-gray-200 sm:max-w-[38%] md:max-w-[32%]",children:[n.jsx(La,{className:"h-3.5 w-3.5 shrink-0 text-gray-500 dark:text-gray-400","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 truncate font-medium capitalize",children:He.name.replace(/-/g," ")}),n.jsx("button",{type:"button",onClick:()=>{var w;Kt(),(w=W.current)==null||w.focus()},className:"-mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-300 dark:text-gray-400 dark:hover:bg-white/10 dark:hover:text-gray-100 dark:focus-visible:ring-gray-600","aria-label":h("messageInput.selectedSkill.removeAriaLabel"),children:n.jsx(Ye,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),!He&&Pt.length>0&&p.length===0&&!De&&n.jsxs("button",{type:"button",onClick:no,className:"flex h-8 shrink-0 items-center gap-1.5 self-center rounded-full border border-gray-300 bg-white px-2.5 text-xs font-medium text-gray-600 shadow-sm transition-colors hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-gray-300 dark:border-[#3a3a3a] dark:bg-[#1a1a1a] dark:text-gray-300 dark:hover:bg-white/10 dark:hover:text-gray-100 dark:focus-visible:ring-gray-600","aria-label":h("messageInput.skillsHint.ariaLabel"),title:h("messageInput.skillsHint.title"),children:[n.jsx("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded bg-gray-200 font-mono text-[10px] leading-none text-gray-600 dark:bg-[#2a2a2a] dark:text-gray-300","aria-hidden":"true",children:"/"}),h("messageInput.skillsHint.text")]}),n.jsxs("div",{className:"relative flex-1 w-full min-w-0",children:[so&&Nt&&n.jsx("div",{className:"pointer-events-none absolute inset-0 truncate whitespace-nowrap text-base md:text-sm text-gray-500 dark:text-[#8e8ea0]",style:{paddingTop:Math.max(Je.top-Du,0),paddingBottom:Je.bottom,paddingLeft:`${ta}px`,paddingRight:0,lineHeight:ut?`${ut}px`:void 0},"aria-hidden":"true",children:Nt}),zs&&N&&n.jsxs("div",{className:"pointer-events-none absolute inset-0 whitespace-pre-wrap text-base md:text-sm text-gray-400 dark:text-[#8e8ea0]",style:{paddingTop:Math.max(Je.top-Ou,0),paddingBottom:Je.bottom,paddingLeft:`${ta}px`,paddingRight:0,lineHeight:ut?`${ut}px`:void 0},"aria-hidden":"true",children:[n.jsx("span",{className:"invisible",children:p}),n.jsx("span",{children:zs})]}),n.jsx("textarea",{ref:W,"aria-label":h("messageInput.textarea.ariaLabel"),value:p,onChange:w=>{const O=w.target.value;x(O),O.startsWith("/")&&Ue(0),Ae(O.startsWith("/")&&Pt.length>0)},onKeyDown:ho,onPaste:xo,onCompositionStart:()=>k(!0),onCompositionEnd:()=>k(!1),onFocus:()=>A(!0),onBlur:()=>A(!1),placeholder:Nt,disabled:De,rows:1,maxLength:le.maxMessageLength,className:"relative z-10 flex-1 w-full min-w-0 resize-none bg-transparent py-0 text-base md:text-sm text-[#353740] placeholder-transparent focus:outline-none dark:text-[#ececf1] dark:placeholder-transparent",style:{minHeight:"24px",maxHeight:"120px",paddingTop:`${Je.top}px`,paddingBottom:`${Je.bottom}px`,paddingLeft:`${ta}px`,paddingRight:0,border:"none",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none",caretColor:p.trim()||N?"inherit":"transparent"}})]}),n.jsxs("div",{className:"flex items-center justify-end gap-1 md:gap-2 flex-shrink-0",children:[n.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[i&&!$t&&n.jsx("div",{className:"hidden md:block h-8 w-8 shrink-0","aria-hidden":"true"}),$t&&n.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),Cr||P(!E)},disabled:Cr,onMouseEnter:()=>j(!0),onMouseLeave:()=>j(!1),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${E||ir.length>0?"bg-gray-200 text-[#353740] dark:bg-[#565869] dark:text-[#ececf1]":Cr?"cursor-not-allowed text-gray-300 dark:text-[#6b6f7a]":"text-gray-500 hover:bg-gray-200 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#565869]"}`,title:jr?Kr&&za&&le.maxFilesPerConversation!==null?h("messageInput.fileUpload.titleLimitPerConversation",{count:le.maxFilesPerConversation}):Kr&&Ba&&le.maxTotalFiles!==null?h("messageInput.fileUpload.titleLimitWorkspace",{count:le.maxTotalFiles}):De?h("messageInput.fileUpload.titleUploading"):ir.length>0?h("messageInput.fileUpload.titleAttached",{count:ir.length}):h("messageInput.fileUpload.attachAriaLabel"):h("messageInput.fileUpload.titleNotSupported"),"aria-label":h("messageInput.fileUpload.attachAriaLabel"),children:Cr&&z?n.jsx(Ye,{className:"h-4 w-4"}):n.jsx(Kc,{className:"h-4 w-4"})}),p.length>0&&n.jsx("div",{className:"hidden md:block px-2 text-xs text-gray-500 dark:text-[#bfc2cd] md:min-w-[72px] md:text-right",children:n.jsxs("span",{className:p.length>=le.maxMessageLength?"text-red-600 font-semibold":"",children:[p.length,"/",le.maxMessageLength]})})]}),n.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[n.jsx(Hi,{availableModels:d,defaultModel:u,selectedModel:f,onSelect:w=>m==null?void 0:m(w)}),(br||Ft)&&n.jsxs(n.Fragment,{children:[br&&n.jsx("button",{type:"button",onClick:po,className:`hidden md:flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${Y.voiceEnabled?"bg-blue-100 text-blue-600 dark:bg-blue-900/40 dark:text-blue-300":"text-gray-500 hover:bg-gray-200 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#565869]"}`,title:Y.voiceEnabled?h("messageInput.voiceOutput.titleEnabled"):h("messageInput.voiceOutput.titleDisabled"),"aria-label":Y.voiceEnabled?h("messageInput.voiceOutput.ariaLabelEnabled"):h("messageInput.voiceOutput.ariaLabelDisabled"),children:Y.voiceEnabled?n.jsx(_a,{className:"h-5 w-5"}):n.jsx(ad,{className:"h-5 w-5"})}),lt&&n.jsx("button",{type:"button",onClick:mo,disabled:De,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),className:`hidden md:flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${tt?"!flex bg-red-100 text-red-600 dark:bg-red-900/40 dark:text-red-300":De?"cursor-not-allowed text-gray-300 dark:text-[#6b6f7a]":"text-gray-500 hover:bg-gray-200 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#565869]"}`,title:h(De?"messageInput.voiceInput.titleUploading":tt?"messageInput.voiceInput.titleListening":"messageInput.voiceInput.titleDisabled"),"aria-label":h(tt?"messageInput.voiceInput.ariaLabelListening":"messageInput.voiceInput.ariaLabelDisabled"),children:tt||De&&L?n.jsx(Uc,{className:"h-5 w-5"}):n.jsx(zc,{className:"h-5 w-5"})})]}),l&&n.jsx("button",{type:"button",onClick:()=>C(!0),className:"hidden md:flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 text-gray-500 hover:bg-gray-200 hover:text-[#353740] dark:text-[#bfc2cd] dark:hover:bg-[#565869]",title:h("messageInput.agentInfo.title"),"aria-label":h("messageInput.agentInfo.ariaLabel"),children:n.jsx(yn,{className:"h-5 w-5"})}),(Bs||ht)&&n.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center",children:n.jsx(xs,{className:"h-4 w-4 animate-spin text-gray-500 dark:text-[#bfc2cd]"})}),ft?n.jsx("button",{type:"button",onClick:w=>{w.preventDefault(),Se()},className:"flex h-9 w-9 md:h-8 md:w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 bg-red-500 text-white hover:bg-red-600 dark:bg-red-600 dark:hover:bg-red-700",title:h("messageInput.stop.title"),"aria-label":h("messageInput.stop.ariaLabel"),children:n.jsx(ed,{className:"h-4 w-4 md:h-3 md:w-3 fill-current"})}):n.jsx("button",{type:"submit",disabled:!Hs||De||y,className:`flex h-9 w-9 md:h-8 md:w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${Hs&&!De&&!y?"bg-black text-white hover:bg-gray-800 dark:bg-white dark:text-black dark:hover:bg-gray-200":"bg-gray-300 text-gray-500 dark:bg-[#565869] dark:text-[#6b6f7a]"}`,title:h("messageInput.submit.title"),"aria-label":h("messageInput.submit.ariaLabel"),children:n.jsx(ha,{className:"h-4 w-4"})})]})]})]}),ir.length>0&&n.jsx("div",{className:"flex flex-wrap gap-2",children:ir.map(w=>{const O=ra(w.processing_status),oe=w.processing_status==="failed"||w.processing_status==="error";return n.jsxs("div",{className:`flex items-center gap-2 rounded-md border px-2 py-1 text-xs ${oe?"border-red-200 bg-red-50 dark:border-red-800/50 dark:bg-red-950/30":"border-gray-200 bg-white dark:border-[#4a4b54] dark:bg-[#2d2f39]"}`,title:oe?w.error_message||h("messageInput.fileProcessingFailedTitle"):void 0,children:[O&&n.jsx(xs,{className:"h-3 w-3 animate-spin text-blue-500 dark:text-blue-400 flex-shrink-0"}),oe&&n.jsx(ps,{className:"h-3 w-3 text-red-500 dark:text-red-400 flex-shrink-0"}),n.jsx("span",{className:`truncate max-w-[150px] ${oe?"text-red-700 dark:text-red-300":"text-[#353740] dark:text-[#ececf1]"}`,children:w.filename}),O&&n.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:w.processing_status==="uploading"?h("messageInput.attachedFile.uploadingStatus"):h("messageInput.attachedFile.processingStatus")}),oe&&n.jsx("span",{className:"text-xs text-red-500 dark:text-red-400",children:h("messageInput.attachedFile.failedStatus")}),n.jsx("button",{type:"button",onClick:()=>{oe?(Ce&&_e(Ce,w.file_id),_(me=>me.filter(Ie=>Ie.file_id!==w.file_id))):uo(w)},className:"rounded p-2 md:p-0.5 text-gray-500 transition-colors hover:bg-red-50 hover:text-red-600 dark:text-[#bfc2cd] dark:hover:bg-red-900/30 dark:hover:text-red-300",title:h(oe?"messageInput.attachedFile.removeTitleFailed":"messageInput.attachedFile.removeTitleNormal"),children:n.jsx(Ye,{className:"h-4 w-4 md:h-3 md:w-3"})})]},w.file_id)})}),$t&&(jr||Wr)&&n.jsxs("div",{ref:se,className:`rounded-lg border border-gray-200/80 bg-white p-2.5 dark:border-[#3c3f4a] dark:bg-[#2a2b32] transition-all duration-200 ${!E&&!ht&&M.size===0&&!Wr?"hidden":""}`,children:[E&&n.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[n.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] uppercase tracking-wider",children:h("messageInput.uploadPanel.headingAttach")}),n.jsx("button",{type:"button",onClick:()=>P(!1),className:"flex h-6 w-6 items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:text-[#6b6f7a] dark:hover:bg-[#3c3f4a] dark:hover:text-[#bfc2cd] transition-colors",title:h("messageInput.uploadPanel.closeTitle"),children:n.jsx(Ye,{className:"h-3.5 w-3.5"})})]}),(ht||M.size>0)&&!E&&M.size===0&&n.jsx("div",{className:"mb-2 px-1",children:n.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] uppercase tracking-wider",children:h("messageInput.uploadPanel.headingUploading")})}),M.size>0&&n.jsx("div",{className:"mb-2 space-y-1.5",children:Array.from(M.entries()).map(([w,O])=>n.jsxs("div",{className:"group relative w-full flex items-center gap-3 rounded-lg px-3 py-2.5 bg-gray-50 dark:bg-[#1f1f24] overflow-hidden transition-colors",children:[n.jsx("div",{className:"absolute inset-0 bg-blue-50 dark:bg-blue-900/15 transition-all duration-500 ease-out rounded-lg",style:{width:`${O.progress??0}%`}}),n.jsxs("div",{className:"relative flex items-center gap-3 w-full min-w-0",children:[n.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-blue-100 dark:bg-blue-900/30",children:n.jsx(xs,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 animate-spin"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("p",{className:"text-sm font-medium text-[#353740] dark:text-[#ececf1] truncate",children:O.filename}),n.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[n.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-[#3c3f4a] rounded-full h-1",children:n.jsx("div",{className:"bg-blue-500 dark:bg-blue-400 h-1 rounded-full transition-all duration-500 ease-out",style:{width:`${O.progress??0}%`}})}),n.jsxs("span",{className:"text-[11px] tabular-nums text-gray-400 dark:text-[#8e8ea0] shrink-0",children:[Math.round(O.progress??0),"%"]})]})]}),n.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#bfc2cd] shrink-0",children:O.status==="uploading"?h("messageInput.uploadProgress.statusUploading"):O.status==="processing"?h("messageInput.uploadProgress.statusProcessing"):O.status==="completed"?h("messageInput.uploadProgress.statusCompleted"):h("messageInput.uploadProgress.statusPending")})]})]},w))}),n.jsx("div",{className:`${E||ht?"block max-h-[40vh] overflow-y-auto":"hidden"}`,"aria-hidden":!(E||ht),children:n.jsx(Ru,{conversationId:Ce,onFilesSelected:lo,onUploadError:w=>{xe("File upload error:",w),fe(w)},onUploadingChange:V,onUploadSuccess:co,maxFiles:le.maxFilesPerConversation,disabled:Cr})})]}),n.jsx("div",{className:"h-3 md:h-1",children:lt&&tt&&n.jsxs("span",{className:"flex items-center gap-2 text-sm md:text-xs text-gray-500 dark:text-[#bfc2cd]",children:[n.jsx("span",{className:"h-2.5 w-2.5 md:h-2 md:w-2 animate-pulse rounded-full bg-red-500"}),h("messageInput.listeningIndicator")]})})]}),be&&n.jsx("div",{ref:Ne,className:"w-full pt-1",children:n.jsx(Bi,{skills:Pt,isLoading:Ds,selectedSkill:He,activeSkillName:We==null?void 0:We.name,query:ye,onActiveSkillChange:w=>{const O=je.findIndex(oe=>oe.name===w.name);O>=0&&Ue(O)},onSelect:Da,onClose:Oa})}),$&&n.jsx("div",{ref:ge,role:"listbox","aria-label":h("messageInput.autocompletePanel.ariaLabel"),className:"w-full pt-1",children:Rt.map((w,O)=>{const oe=O===gt;return n.jsx("button",{type:"button",role:"option","aria-selected":oe,className:`flex w-full items-center gap-3 px-3 py-3 md:py-2.5 text-left text-[15px] md:text-sm transition-colors ${oe?"bg-gray-100 dark:bg-[#2d2f39]":"hover:bg-gray-50 dark:hover:bg-[#2d2f39]/60"}`,onClick:()=>Qr(w.text),onMouseEnter:()=>Gt(O),children:ao(w.text)},O)})}),n.jsx(js,{isOpen:U.isOpen,onClose:fo,onConfirm:go,title:h("messageInput.fileDelete.title"),message:h("messageInput.fileDelete.message",{filename:U.filename}),confirmText:h("messageInput.fileDelete.confirmText"),cancelText:h("common.cancel"),type:"danger",isLoading:U.isDeleting})]})]})}),v&&l&&typeof document<"u"&&Ls.createPortal(n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-y-auto bg-black/60 p-4 backdrop-blur-sm animate-fadeIn",children:n.jsxs("div",{ref:Q,role:"dialog","aria-modal":"true","aria-labelledby":"agent-info-title",tabIndex:-1,className:"w-full max-w-2xl max-h-[calc(100vh-2rem)] overflow-y-auto rounded-2xl bg-white shadow-2xl transform animate-fadeIn dark:bg-[#1a1b1e]",children:[n.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-[#2d2f39]",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/20 flex items-center justify-center",children:n.jsx(yn,{className:"w-5 h-5 text-blue-500"})}),n.jsx("h2",{id:"agent-info-title",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:h("messageInput.agentInfoModal.title")})]}),n.jsx("button",{type:"button",onClick:()=>C(!1),className:"p-2 hover:bg-gray-100 dark:hover:bg-[#25262f] rounded-lg transition-colors","aria-label":h("messageInput.agentInfoModal.closeAriaLabel"),children:n.jsx(Ye,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),n.jsx("div",{className:"p-6",children:n.jsx(Et,{content:l,className:`message-markdown w-full min-w-0 prose prose-slate dark:prose-invert max-w-none text-sm leading-relaxed text-[#434654] dark:text-[#d7dae3] [&>:first-child]:mt-0 [&>:last-child]:mb-0 ${Pe}`,syntaxTheme:Me})}),n.jsx("div",{className:"flex items-center justify-end p-6 border-t border-gray-200 dark:border-[#2d2f39] bg-gray-50 dark:bg-[#111113] rounded-b-2xl",children:n.jsx("button",{type:"button",onClick:()=>C(!1),className:"px-4 py-3 md:py-2.5 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium shadow-sm hover:shadow-md",children:h("messageInput.agentInfoModal.confirmButton")})})]})}),document.body)]})}function Kn({adapter:t,onSelect:e}){var l;const{t:r}=Le(),a=(l=t.description)==null?void 0:l.trim(),{isDark:s}=rr(),i=s?"dark":"light",o=()=>e(t);return n.jsxs("div",{tabIndex:0,role:"button","data-agent-card":"true",onClick:o,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),o())},className:"group relative flex w-full cursor-pointer flex-col rounded-2xl border border-slate-200 bg-white px-4 py-3.5 text-left shadow-sm transition-colors duration-150 hover:border-slate-300 hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/30 dark:border-[#242424] dark:bg-[#080808] dark:hover:border-[#333333] dark:hover:bg-[#111111] dark:focus-visible:ring-sky-400/30 md:px-5 md:py-4",children:[n.jsx("div",{className:"relative",children:n.jsx("div",{className:"min-w-0",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsxs("div",{className:"min-w-0 flex-1",children:[n.jsx("p",{className:"truncate text-[15px] font-semibold text-blue-700 dark:text-blue-300 md:text-base",children:t.name}),a?n.jsx("div",{className:"mt-1 text-sm leading-5 text-slate-600 dark:text-slate-300",children:n.jsx(Et,{content:a,className:"prose prose-slate max-w-none text-inherit dark:prose-invert [&>*]:mb-0 [&>*]:mt-0 [&_p]:overflow-hidden [&_p]:text-ellipsis [&_p]:[display:-webkit-box] [&_p]:[-webkit-box-orient:vertical] [&_p]:[-webkit-line-clamp:4]",syntaxTheme:i})}):n.jsx("p",{className:"mt-1 text-sm leading-5 text-slate-500 dark:text-slate-400",children:r("agentCard.configureMessage")})]}),n.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),o()},className:"hidden h-8 w-8 flex-shrink-0 items-center justify-center self-start rounded-full text-slate-700 transition-all duration-150 hover:bg-slate-100 group-hover:translate-x-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/30 dark:text-slate-200 dark:hover:bg-white/10 dark:focus-visible:ring-sky-400/30 md:inline-flex","aria-label":r("agentCard.startConversationAriaLabel",{name:t.name}),children:n.jsx(bn,{className:"h-4 w-4","aria-hidden":"true"})})]})})}),n.jsx("div",{className:"mt-3 flex items-center justify-end gap-3 border-t border-slate-200 pt-2.5 text-xs text-slate-500 dark:border-white/10 dark:text-slate-400 md:hidden",children:n.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),o()},className:"inline-flex h-8 w-8 items-center justify-center rounded-full text-slate-700 transition-all duration-150 hover:bg-slate-100 group-hover:translate-x-0.5 focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/30 dark:text-slate-200 dark:hover:bg-white/10 dark:focus-visible:ring-sky-400/30","aria-label":r("agentCard.startConversationAriaLabel",{name:t.name}),children:n.jsx(bn,{className:"h-4 w-4","aria-hidden":"true"})})})]})}const Qt=t=>{if(typeof t!="string")return;const e=t.trim();return e.length>0?e:void 0},Wu=t=>{if(!t||typeof t!="object")return null;const e=t,r=Qt(e.name);if(!r)return null;const a=Qt(e.id);if(!a)return console.warn(`[middlewareConfig] Adapter "${r}" is missing a required 'id' field — skipping.`),null;const s=Qt(e.apiUrl),i=Qt(e.model),o=Qt(e.inputPlaceholder),l=typeof e.notes=="string"?e.notes.trim():void 0;let c=Qt(e.description)||Qt(e.summary);if(!c&&typeof l=="string"){const u=l.split(/\r?\n/).find(f=>f.trim().length>0);c=u?u.trim():void 0}const d={id:a,name:r};return s&&(d.apiUrl=s),c&&(d.description=c),l&&(d.notes=l),i&&(d.model=i),o&&(d.inputPlaceholder=o),d},qi=t=>Array.isArray(t)?t.map(Wu).filter(e=>e!==null):[];let Ut=null,sa=0;const Ku=3e4;function Gu(){if(typeof window<"u"){const t=window.ORBIT_CHAT_CONFIG;if(t!=null&&t.adapters&&Array.isArray(t.adapters)){D("Loading adapters from window.ORBIT_CHAT_CONFIG");const e=qi(t.adapters);if(e.length===0)return null;const r=`{
|
|
334
|
+
"simple-chat": "default-key",
|
|
335
|
+
"dialoga": "orbit_PswAO5TJgX0yWEVdjOmuxwLLBpk0S74O",
|
|
336
|
+
"web-search": "orbit_XfxmYoTZgnp7zoMTKsIBfMBuYwj6U21P",
|
|
337
|
+
"chat-with-files": "multimodal",
|
|
338
|
+
"hr-db-chatbot": "human-resources",
|
|
339
|
+
"intent-sql-sqlite-classified": "classified",
|
|
340
|
+
"ecomm-analytics": "analytical",
|
|
341
|
+
"intent-duckdb-ev-population": "electric-vehicle",
|
|
342
|
+
"intent-http-jsonplaceholder": "rest-json-api",
|
|
343
|
+
"intent-http-paris-opendata": "paris-opendata",
|
|
344
|
+
"intent-mongodb-mflix": "mongodb-mflix",
|
|
345
|
+
"intent-graphql-spacex": "graphql-spacex",
|
|
346
|
+
"intent-sql-postgres": "postgres-customer-orders",
|
|
347
|
+
"open-ai-real-time-voice-chat": "open-ai-real-time-voice-chat",
|
|
348
|
+
"composite-multi-source-explorer": "composite-multi-source-explorer",
|
|
349
|
+
"math-teacher-quadratic": "math-teacher-trig-identities",
|
|
350
|
+
"qa-sql": "orbit_g6QuN5sPUh3fI2v0njoOJroXbAh1ILGP",
|
|
351
|
+
"qa-vector-chroma": "orbit_Rxm90sh85f8l5bzOLJpqpMUP9HcoNAX3",
|
|
352
|
+
"image-generator": "orbit_bZQ0h6kvpTphfCr9QgrCP13dkVclAsKQ",
|
|
353
|
+
"video-generator": "orbit_9P1vnx1GNMvVNyNCKF71VvVvcYx9duuo",
|
|
354
|
+
"intent-elasticsearch-log": "orbit_Ghpo8Q9mRdvVIODdw97ht7lBPpYBAzb6",
|
|
355
|
+
"audio-transcription": "orbit_RTBIwFoB6DA2mBuuHfnKf0xabwE6XKs2",
|
|
356
|
+
"voice-chat": "orbit_WjrkTqVjHE7mBa2ri8sAjENEVnLT9wbO",
|
|
357
|
+
"real-time-voice-chat": "orbit_xkvziKTXpZ1ufHWKg76pUDPbMDBRSRqC",
|
|
358
|
+
"tender-notices": "tender-notices",
|
|
359
|
+
"award-notices": "award-notices",
|
|
360
|
+
"contract-history": "contract-history",
|
|
361
|
+
"standing-offers": "standing-offers"
|
|
362
|
+
}`;if(!r.trim())return[];try{const a=JSON.parse(r),s=new Set(Object.entries(a).filter(([,i])=>{if(typeof i=="string")return i.trim().length>0;if(i&&typeof i=="object"){const o=i;if(typeof o.apiKey=="string"&&o.apiKey.trim().length>0||typeof o.key=="string"&&o.key.trim().length>0)return!0}return!1}).map(([i])=>i));return e.filter(i=>s.has(i.id))}catch{return[]}}}return null}async function Fa(){if(Ut&&Date.now()-sa<Ku)return Ut;try{const e=await fetch("/api/adapters?refresh=1",{cache:"no-store",headers:{"Cache-Control":"no-cache"}});if(e.ok){const r=await e.json(),a=qi(r.adapters);if(a.length>0)return Ut=a,sa=Date.now(),D("Fetched adapters from /api/adapters:",Ut),Ut;D("/api/adapters response did not contain valid adapters, trying fallback")}D(`/api/adapters returned ${e.status}, trying fallback`)}catch(e){D("Could not fetch from /api/adapters, trying fallback:",e)}const t=Gu();if(t&&t.length>0)return Ut=t,sa=Date.now(),D("Loaded adapters from config:",Ut),Ut;throw xe("No adapters available from API or config"),new Error("No adapters available. Define adapters in orbitchat.yaml and provide matching ids in VITE_ADAPTER_KEYS.")}const Xu="h-[96px]";function Yu({onAdapterSelect:t,className:e="",title:r="",subtitle:a="",eyebrow:s=""}){const{t:i}=Le(),[o,l]=g.useState([]),[c,d]=g.useState(!0),[u,f]=g.useState(null),m=g.useRef(null),h=g.useRef(null),[p,x]=g.useState(""),[y,k]=g.useState(!1),N=g.useCallback(()=>{const j=m.current;if(!j){k(!1);return}k(j.scrollHeight-j.scrollTop-j.clientHeight>20)},[]),A=()=>typeof window<"u"&&window.matchMedia("(min-width: 768px)").matches,v=()=>{var j;return Array.from(((j=m.current)==null?void 0:j.querySelectorAll('[data-agent-card="true"]'))??[])},C=j=>{const R=v()[j]??null;R&&(R.focus(),R.scrollIntoView({block:"nearest"}))},E=()=>{C(0)},P=()=>{const j=v();j.length!==0&&C(j.length-1)},b=j=>{if(!c&&!u&&I.length>0&&A()){if(j.key==="Tab"&&!j.shiftKey){j.preventDefault(),E();return}if(j.key==="ArrowDown"){j.preventDefault(),E();return}j.key==="ArrowUp"&&(j.preventDefault(),P())}},_=j=>{var K;if(!M||!A()||j.key!=="ArrowDown"&&j.key!=="ArrowUp")return;const L=document.activeElement;if(!(L instanceof HTMLElement)||L.dataset.agentCard!=="true")return;const R=v(),T=R.indexOf(L);if(T!==-1){if(j.preventDefault(),j.key==="ArrowDown"){C((T+1)%R.length);return}if(T===0){(K=h.current)==null||K.focus();return}C(T-1)}},S=p.trim().toLowerCase(),I=S?o.filter(j=>{var K,G;const L=j.name.toLowerCase().includes(S),R=((K=j.description)==null?void 0:K.toLowerCase().includes(S))??!1,T=((G=j.model)==null?void 0:G.toLowerCase().includes(S))??!1;return L||R||T}):o,M=p.trim().length>0,F=M||I.length===1;g.useEffect(()=>{const j=m.current;if(j)return N(),j.addEventListener("scroll",N,{passive:!0}),()=>j.removeEventListener("scroll",N)},[N,I]),g.useEffect(()=>{let j=!0;return(async()=>{try{d(!0),f(null);const T=(await Fa()).slice().sort((K,G)=>K.name.localeCompare(G.name,void 0,{sensitivity:"base"}));j&&l(T)}catch(R){xe("[AgentSelectionList] Failed to load adapters",R),j&&f(i("agentSelectionList.unableToLoad"))}finally{j&&d(!1)}})(),()=>{j=!1}},[i]),g.useEffect(()=>{var j;c||u||o.length===0||(j=h.current)==null||j.focus()},[c,u,o.length]);const z=()=>c?n.jsx("div",{className:"grid gap-4",children:Array.from({length:3}).map((j,L)=>n.jsx("div",{className:`${Xu} animate-pulse rounded-2xl border border-gray-200 bg-transparent dark:border-[#3b3c49]`},L))}):u?n.jsx("div",{className:"rounded-2xl border border-red-200 bg-transparent px-4 py-6 text-sm text-red-700 dark:border-red-900 dark:text-red-200",children:u}):o.length===0?n.jsx("div",{className:"rounded-2xl border border-gray-200 bg-transparent px-4 py-6 text-sm text-gray-600 dark:border-[#3b3c49] dark:text-gray-300",children:i("agentSelectionList.noAgentsAvailable")}):I.length===0?n.jsx("div",{className:"rounded-2xl border border-gray-200 bg-transparent px-4 py-6 text-sm text-gray-600 dark:border-[#3b3c49] dark:text-gray-300",children:i("agentSelectionList.noSearchResults")}):n.jsxs("div",{className:"relative flex flex-col h-full min-h-0",children:[n.jsx("div",{ref:m,onKeyDown:_,className:"agent-selection-scroll flex-1 min-h-0 overflow-y-auto pr-1 pb-2",children:F?n.jsx("div",{className:"mx-auto flex w-full max-w-xl flex-col gap-3 lg:max-w-2xl",children:I.map(j=>n.jsx(Kn,{adapter:j,onSelect:L=>t(L.id)},j.id))}):n.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:I.map(j=>n.jsx(Kn,{adapter:j,onSelect:L=>t(L.id)},j.id))})}),y&&n.jsx("div",{className:"pointer-events-none absolute bottom-0 left-0 right-0 h-12 md:hidden bg-gradient-to-t from-white dark:from-[#212121] to-transparent","aria-hidden":"true"})]});return n.jsxs("div",{className:`flex w-full flex-col gap-4 md:gap-6 ${e}`,children:[(s||r||a)&&n.jsxs("div",{className:"flex-shrink-0",children:[s&&n.jsx("p",{className:"text-sm font-semibold uppercase tracking-wide text-blue-600 dark:text-blue-300",children:s}),r&&n.jsx("h2",{className:"mt-2 text-2xl font-bold text-gray-900 dark:text-white",children:r}),a&&n.jsx("p",{className:"mt-2 text-base text-gray-600 dark:text-gray-300",children:a})]}),n.jsx("div",{className:"flex w-full flex-shrink-0 justify-center",children:n.jsx("div",{className:"w-full max-w-xl lg:max-w-2xl",children:n.jsxs("div",{className:"relative overflow-hidden rounded-[1.75rem] border border-slate-300/90 bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(248,250,252,0.94))] shadow-[0_10px_28px_rgba(15,23,42,0.05)] dark:border-white/20 dark:bg-[linear-gradient(180deg,rgba(37,39,49,0.95),rgba(29,31,39,0.92))] dark:shadow-[0_12px_30px_rgba(0,0,0,0.2)]",children:[n.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-[inherit] bg-[linear-gradient(180deg,rgba(255,255,255,0.45),rgba(255,255,255,0))] dark:bg-[linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0))]"}),n.jsx(Ia,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400 dark:text-slate-500"}),n.jsx("input",{ref:h,type:"text",placeholder:i("agentSelectionList.searchPlaceholder"),value:p,maxLength:100,disabled:c||!!u||o.length===0,onChange:j=>x(j.target.value),onKeyDown:b,className:"relative z-10 w-full bg-transparent py-3 pl-11 pr-11 text-sm font-medium text-slate-700 placeholder:font-normal placeholder:text-slate-400 focus:outline-none focus:ring-0 focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-60 dark:text-slate-100 dark:placeholder:text-slate-400"}),p&&n.jsx("button",{type:"button",onClick:()=>x(""),className:"absolute right-3 top-1/2 z-10 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-full border border-slate-200/80 bg-white/90 text-slate-400 transition-colors hover:border-slate-300 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-sky-200 dark:border-white/10 dark:bg-white/5 dark:text-slate-500 dark:hover:border-white/20 dark:hover:text-slate-200 dark:focus:ring-sky-500/20","aria-label":i("agentSelectionList.clearSearchAriaLabel"),children:n.jsx(Ye,{className:"h-3.5 w-3.5"})})]})})}),n.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:z()})]})}function ya(){return Na()?Ms()==="entra"?n.jsx(Zu,{}):n.jsx(Ju,{}):null}function Ju(){const{user:t,logout:e,loginWithRedirect:r}=va();if(!hr()||!t)return n.jsx(Wi,{onClick:()=>r()});const s=t.name||t.email||"User";return n.jsx(Ki,{displayName:s,onClick:()=>e({logoutParams:{returnTo:window.location.origin}})})}function Zu(){const{instance:t,accounts:e}=ka();if(!hr()||e.length===0)return n.jsx(Wi,{onClick:()=>t.loginRedirect({scopes:Aa()}).catch(()=>{})});const a=e[0],s=a.name||a.username||"User";return n.jsx(Ki,{displayName:s,onClick:()=>t.logoutRedirect({postLogoutRedirectUri:window.location.origin}).catch(()=>{})})}function Wi({onClick:t}){const{t:e}=Le();return n.jsxs("button",{onClick:t,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-blue-400/70 bg-blue-600 px-3 py-2 text-xs font-semibold text-white shadow-sm active:scale-[0.97] transition-all duration-150 hover:bg-blue-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-blue-500 dark:bg-blue-500 dark:hover:bg-blue-600",children:[n.jsx(Ni,{className:"h-4 w-4"}),n.jsx("span",{children:e("common.signIn")})]})}function Ki({displayName:t,onClick:e}){const{t:r}=Le();return n.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm text-gray-600 dark:text-[#bfc2cd]",children:[n.jsx("span",{className:"hidden max-w-[170px] truncate font-medium md:block",title:t,children:t}),n.jsxs("button",{onClick:e,className:"inline-flex min-h-10 items-center justify-center gap-1.5 rounded-lg border border-slate-200 px-3 py-2 text-xs font-semibold text-slate-600 shadow-sm transition-colors hover:border-red-200 hover:bg-red-50 hover:text-red-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-400 dark:border-[#454755] dark:text-[#c4c8d4] dark:hover:border-red-900/40 dark:hover:bg-red-900/20 dark:hover:text-red-300 md:rounded-full md:text-sm md:font-medium",title:r("authStatus.signOutButton.title"),"aria-label":r("authStatus.signOutButton.ariaLabel"),children:[n.jsx(Rc,{className:"h-4 w-4"}),n.jsx("span",{className:"hidden md:inline",children:r("common.logOut")})]})]})}function Gi({placement:t="default",compact:e=!1}){const{t:r}=Le();if(!ki())return null;const a=hc(),s=mc(),i=pc(),o=xc(),l=bc(),c=yc(),d=kc(),u=o?"border-t border-slate-200/80 dark:border-[#333645]":"",f=e?t==="sidebar"?"pt-4 pb-2":"pt-2 pb-2":c==="normal"?"pt-3 pb-3":"pt-5 pb-3",m=l==="inline"?"flex w-full flex-col gap-1 items-center justify-center text-center sm:flex-row sm:items-center sm:justify-center":"flex w-full flex-col items-center justify-center gap-1 text-center",h="justify-center",p=t==="sidebar"?"w-full px-2":"w-full px-3 sm:px-6",x=t==="sidebar"?"w-full":"mx-auto w-full max-w-7xl",y=e?"inline-flex min-h-8 items-center rounded px-1.5 text-xs font-medium transition-colors hover:bg-slate-100 hover:text-blue-700 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:hover:bg-[#2b2d39] dark:hover:text-blue-300":"inline-flex min-h-10 items-center rounded-md px-2.5 text-sm font-medium transition-colors hover:bg-slate-100 hover:text-blue-700 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:hover:bg-[#2b2d39] dark:hover:text-blue-300 sm:text-base";return n.jsx("footer",{className:`shrink-0 bg-white dark:bg-black text-sm ${f} ${u}`.trim(),style:{backgroundColor:s||void 0,color:i||void 0},children:n.jsx("div",{className:p,children:n.jsx("div",{className:x,children:n.jsxs("div",{className:m,children:[a&&n.jsx("p",{className:`${e?"text-xs leading-snug":"text-sm"} text-slate-700 dark:text-slate-200 ${t==="sidebar"?"pt-0.5":""}`.trim(),children:a}),d.length>0&&n.jsx("nav",{"aria-label":r("appFooter.navLinksAriaLabel"),children:n.jsx("ul",{className:`flex flex-wrap items-center ${h} ${e?"gap-1":"gap-1.5 sm:gap-2"}`,children:d.map((k,N)=>{const A=l==="inline"&&N>0;return n.jsxs("li",{className:"flex items-center",children:[A&&n.jsx("span",{className:"mr-1.5 text-slate-400 dark:text-slate-500","aria-hidden":"true",children:"·"}),n.jsx("a",{href:k.url,target:"_blank",rel:"noopener noreferrer",className:y,style:{color:i||void 0},children:k.label})]},k.url)})})})]})})})})}const Qu=60*1e3;let aa=null,Gn=0;const na=t=>{if(!t||t==="/")return"/";const e=t.trim();if(!e)return"/";const r=e.startsWith("/")?e:`/${e}`;return r==="/"?"/":r.endsWith("/")?r.slice(0,-1):r},Xi=()=>{if(typeof window>"u")return na("/");const t=na("/");if(typeof document>"u")return t;const e=document.querySelector("base[href]");if(!e)return t;try{const r=new URL(e.getAttribute("href")||"/",window.location.origin);return na(r.pathname||t)}catch{return t}},Is=t=>t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),ef=async()=>{const t=Date.now();if(aa&&t-Gn<Qu)return aa;let e=[];try{e=await Fa()}catch(a){pe("[agentRouting] Unable to load adapters for slug resolution",a)}const r=new Map;return e.forEach(a=>{const s=Is(a.name);s&&r.set(s,a.id);const i=Is(a.id);i&&i!==s&&r.set(i,a.id)}),aa=r,Gn=t,r},wa=t=>{var i;const e=Xi(),r=t.startsWith("/")?t:`/${t}`;let a=r;if(e!=="/"){if(!r.startsWith(e))return null;a=r.slice(e.length)}const s=a.split("/").filter(Boolean);return s.length===0?null:((i=s[0])==null?void 0:i.toLowerCase())||null},Yi=t=>{const e=Xi();if(!t)return e;const r=t.replace(/^\/+|\/+$/g,"");return e==="/"?r?`/${r}`:"/":`${e}/${r}`.replace(/\/{2,}/g,"/")},kt=t=>{if(typeof window>"u")return;const e=Yi(t),r=window.location.pathname;if(e===r)return;const a=window.location.search||"",s=window.location.hash||"";window.history.replaceState(window.history.state,"",`${e}${a}${s}`)},tf=()=>Yi(null),rf=async t=>{const e=t.trim().toLowerCase();return e&&(await ef()).get(e)||null};function sf({currentConversation:t,showEmptyState:e,createConversation:r,configureApiSettings:a,clearError:s,clearCurrentConversationAdapter:i}){var Ne;const{t:o}=Le(),l=o("agent.error.singleAdapterMissing"),[c,d]=g.useState(!1),[u,f]=g.useState(null),m=Ts(),h=Sa(),p=typeof window<"u"?wa(window.location.pathname):null,[x,y]=g.useState(p),[k,N]=g.useState(()=>!m&&e&&!p),A=g.useRef(null),v=g.useRef(new Map),C=g.useRef(0),E=3e4,P=!!t,b=(t==null?void 0:t.messages.length)??0,_=((Ne=t==null?void 0:t.attachedFiles)==null?void 0:Ne.length)??0,S=g.useMemo(()=>P&&(b>0||_>0),[_,b,P]),I=g.useCallback(()=>{Ve(()=>ke.getState())},[]),M=g.useCallback((B,X)=>{if(!B)return;const ee=X||o("agent.error.configurationFailed");let we=!1;ke.setState(ae=>{const Y=ae.conversations.find(de=>de.id===B);return!Y||Y.messages.length>0?ae:(we=!0,{conversations:ae.conversations.map(de=>de.id===B?{...de,adapterLoadError:ee}:de)})}),we&&I()},[I,o]),F=g.useCallback(B=>{if(!B)return;let X=!1;ke.setState(ee=>{const we=ee.conversations.find(ae=>ae.id===B);return!we||!we.adapterLoadError?ee:(X=!0,{conversations:ee.conversations.map(ae=>ae.id===B?{...ae,adapterLoadError:null}:ae)})}),X&&I()},[I]),z=g.useCallback(B=>B instanceof Pi?B.status===401?o("agent.error.authenticationFailed"):B.status===404?o("agent.error.notFound"):B.message:B instanceof Error?B.message:o("agent.error.loadFailed"),[o]),j=g.useCallback(()=>{const B=ke.getState(),X=B.currentConversationId?B.conversations.find(ee=>ee.id===B.currentConversationId):null;if(!X||X.messages.length>0)try{return r()}catch(ee){pe("Cannot create a new conversation for agent selection:",ee instanceof Error?ee.message:"Unknown error")}return(X==null?void 0:X.id)||null},[r]),L=g.useCallback(async B=>{if(!(B!=null&&B.adapterName))return{ok:!1};try{const X=await Fe(),ee=new X.ApiClient({apiUrl:B.apiUrl||$e(),sessionId:null,adapterName:B.adapterName});if(typeof ee.getAdapterInfo!="function")return{ok:!1};const we=await ee.getAdapterInfo();return ke.setState(ae=>({conversations:ae.conversations.map(Y=>Y.id===B.id?{...Y,adapterInfo:we,adapterLoadError:null,updatedAt:new Date}:Y)})),ke.getState().currentConversationId===B.id&&f(null),I(),{ok:!0}}catch(X){const ee=z(X),we=ke.getState();we.currentConversationId===B.id&&f({conversationId:B.id,message:ee});const ae=we.conversations.find(Y=>Y.id===B.id);return ae&&ae.messages.length===0&&M(B.id,ee),{ok:!1,error:X}}},[z,M,I]),R=g.useCallback(async B=>{if(!B)return;const X=ke.getState(),ee=X.currentConversationId?X.conversations.find(we=>we.id===X.currentConversationId):null;if(ee){d(!0),f(null),F(ee.id);try{const we=ee.apiUrl||$e();await a(we,void 0,B),s();const ae=ke.getState(),Y=ae.conversations.find(de=>de.id===ae.currentConversationId);if((Y==null?void 0:Y.adapterName)===B&&(!Y.adapterInfo||Y.adapterInfo.notes===void 0)){const de=await L(Y);!de.ok&&de.error&&xe("Failed to load adapter info after selecting adapter:",de.error)}}catch(we){xe("Failed to configure adapter from empty state:",we);const ae=z(we);f({conversationId:ee.id,message:ae}),M(ee.id,ae)}finally{d(!1)}}},[F,s,a,L,z,M]),T=g.useCallback(B=>{m||(j(),N(!1),kt(Is(B)),R(B))},[j,R,m]),K=g.useCallback(()=>{m||(i(),kt(null),N(!0))},[i,m]),G=g.useCallback(()=>{var we,ae;if(m){const Y=ke.getState(),de=Y.currentConversationId?Y.conversations.find(ce=>ce.id===Y.currentConversationId):null;if(!!de&&(de.messages.length>0||(((we=de.attachedFiles)==null?void 0:we.length)||0)>0))try{r()}catch(ce){pe("Cannot go home (new conversation):",ce instanceof Error?ce.message:"Unknown error")}kt(null),N(!1);return}y(null);const B=ke.getState(),X=B.currentConversationId?B.conversations.find(Y=>Y.id===B.currentConversationId):null;if(!!X&&(X.messages.length>0||(((ae=X.attachedFiles)==null?void 0:ae.length)||0)>0))try{r()}catch(Y){pe("Cannot go home (new conversation):",Y instanceof Error?Y.message:"Unknown error");return}else X!=null&&X.adapterName&&i();kt(null),N(!0)},[i,r,m]),Z=!m&&e&&!x&&!(t!=null&&t.adapterName)&&!S||!m&&e&&k&&!(t!=null&&t.adapterName)&&!S;g.useEffect(()=>{if(m){kt(null);return}if(!x){if(Z||!(t!=null&&t.adapterName)){kt(null);return}kt(Is(t.adapterName))}},[t==null?void 0:t.adapterName,m,x,Z]);const fe=g.useCallback(async()=>{if(typeof window>"u")return;const B=++C.current;if(m){kt(null),y(null);return}const X=wa(window.location.pathname);if(!X)return;const ee=await rf(X);if(B===C.current){if(!ee){j(),kt(null),i(),N(!0),y(null);return}j(),N(!1),kt(X),await R(ee),y(null)}},[i,j,R,m]),U=g.useRef(fe);g.useEffect(()=>{U.current=fe},[fe]),g.useEffect(()=>{const B=window.setTimeout(()=>{U.current()},0),X=()=>{U.current()};return window.addEventListener("popstate",X),()=>{window.clearTimeout(B),C.current+=1,window.removeEventListener("popstate",X)}},[]);const te=t==null?void 0:t.id,W=t==null?void 0:t.adapterName,Q=t==null?void 0:t.apiUrl,se=!!(t!=null&&t.adapterInfo);g.useEffect(()=>{if(!m||!h||!e||!te||S||c)return;const B=(W==null?void 0:W.trim())||h,X=(W==null?void 0:W.trim())!==B||!se;if(!B||!X)return;let ee=!1;return(async()=>{d(!0),f(null),F(te);try{const ae=Q||$e();await a(ae,void 0,B),s()}catch(ae){if(!ee){const Y=z(ae);f({conversationId:te,message:Y}),M(te,Y)}}finally{ee||d(!1)}})(),()=>{ee=!0}},[F,s,a,S,z,c,m,M,e,W,Q,se,te,h]),g.useEffect(()=>{(async()=>{var we;const X=t==null?void 0:t.adapterName;if(A.current===X)return;const ee=!(t!=null&&t.adapterInfo)||(t==null?void 0:t.adapterInfo)&&t.adapterInfo.notes===void 0;if(X&&ee){A.current=X,D("[ChatInterface] Loading adapter info - adapterName:",X,"reason:",t!=null&&t.adapterInfo?"notes undefined":"missing");const ae=await L(t);if(ae.ok)D("[ChatInterface] Adapter info loaded successfully");else{const Y=ae.error;xe("[ChatInterface] Failed to load adapter info:",Y);const de=Y instanceof Error?Y.message:String(Y);if((de.includes("429")||de.includes("Too Many Requests"))&&X){const ce=v.current.get(X);ce&&clearTimeout(ce);const Pe=setTimeout(()=>{A.current===X&&(A.current=null),v.current.delete(X)},E);v.current.set(X,Pe),pe(`[ChatInterface] Adapter info request rate-limited; retrying in ${E/1e3}s`)}else A.current=null}}else D("[ChatInterface] Skipping adapter info load:",{adapterName:X,hasAdapterInfo:!!(t!=null&&t.adapterInfo),hasNotes:((we=t==null?void 0:t.adapterInfo)==null?void 0:we.notes)!==void 0,refValue:A.current})})()},[L,t]),g.useEffect(()=>{const B=v.current;return()=>{B.forEach(X=>clearTimeout(X)),B.clear()}},[]);const ge=m&&!h?l:(t==null?void 0:t.adapterLoadError)??(u&&u.conversationId===(t==null?void 0:t.id)?u.message:null);return{adapterNotesError:ge,handleAgentCardSelection:T,handleChangeAgent:K,goToAgentSelectionHome:G,hasAdapterConfigurationError:!!ge,isAgentSelectionVisible:k,isConfiguringAdapter:c,isSingleAdapterMode:m,setIsAgentSelectionVisible:N,shouldShowAgentSelectionList:Z}}const Ji=g.createContext(null),af={registerGoHome:()=>{},goHome:()=>{}};function Zi(){return g.useContext(Ji)??af}function nf({adapter:t,syntaxTheme:e,forcedThemeClass:r=""}){var s;const a=(s=t.notes)==null?void 0:s.trim();return a?n.jsxs("section",{"aria-labelledby":"agent-seo-content-title",className:"mx-auto w-full max-w-[56rem] px-1 text-left sm:px-0",children:[n.jsx("h2",{id:"agent-seo-content-title",className:"sr-only",children:t.name}),n.jsx("div",{children:n.jsx(Et,{content:a,className:`message-markdown prose prose-slate dark:prose-invert max-w-none text-sm leading-relaxed text-[#434654] dark:text-[#d7dae3] [&>:first-child]:mt-0 [&>:last-child]:mb-0 ${r}`,syntaxTheme:e})})]}):null}const of='meta[name="description"]',lf='meta[property="og:title"]',cf='meta[property="og:description"]',df='meta[property="og:type"]',uf='link[rel="canonical"]';function Xn(t){return t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function ff(t){return t.replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/^>\s?/gm,"").replace(/[*_~]/g,"").replace(/\s+/g," ").trim()}function gf(t,e){const r=t==null?void 0:t.trim();if(r)return r;if(!e)return Ca();const a=ff(e);return a.length>160?`${a.slice(0,157).trimEnd()}...`:a}function hf(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function mf(t){const e=t.trim();if(!e)return null;try{return new URL(e).origin}catch{return null}}function pf(t){const e=t.trim();if(!e)return null;const r=`^${hf(e).replace(/\\\*/g,".*")}$`;try{return new RegExp(r,"i")}catch{return null}}function xf(t){return[pi(),...ql()].map(mf).filter(r=>!!r).includes(t)?!0:Wl().some(r=>{const a=pf(r);return a?a.test(t):!1})}function bf(t){var a,s,i;const e=t==null?void 0:t.trim();if(!e)return null;const r=J.adapters.find(o=>{var l;return((l=o==null?void 0:o.id)==null?void 0:l.trim())===e});return r?{id:r.id,name:((a=r.name)==null?void 0:a.trim())||r.id,description:((s=r.description)==null?void 0:s.trim())||void 0,notes:((i=r.notes)==null?void 0:i.trim())||void 0}:null}function yf(t){var a,s,i;if(typeof window>"u")return null;const e=wa(window.location.pathname);if(!e)return null;const r=J.adapters.find(o=>{const l=Xn(o.name||""),c=Xn(o.id||"");return e===l||e===c});return r?{id:r.id,name:((a=r.name)==null?void 0:a.trim())||r.id,description:((s=r.description)==null?void 0:s.trim())||void 0,notes:((i=r.notes)==null?void 0:i.trim())||void 0}:null}function gs(t,e,r){if(typeof document>"u")return null;const a=document.querySelector(t);if(a)return a;const s=document.createElement("meta");return s.setAttribute(e,r),document.head.appendChild(s),s}function wf(){if(typeof document>"u")return null;const t=document.querySelector(uf);if(t)return t;const e=document.createElement("link");return e.rel="canonical",document.head.appendChild(e),e}function Qi(t){if(typeof document>"u")return;const e=ja(),r=t?`${t.name} | ${e}`:e,a=t?gf(t.description,t.notes):Ca();document.title=r;const s=gs(of,"name","description");s&&(s.content=a);const i=gs(lf,"property","og:title");i&&(i.content=r);const o=gs(cf,"property","og:description");o&&(o.content=a);const l=gs(df,"property","og:type");l&&(l.content="website");const c=wf();if(c&&typeof window<"u"){const d=pi(),u=window.location.origin,f=d?new URL(d.endsWith("/")?d:`${d}/`).origin:"",h=`${u&&xf(u)?u:f||u}${window.location.pathname}`;c.href=h}}function kf(){return Kl()}class $a{static async getAdapterModels(e,r){const a=await Fe(),s=new a.ApiClient({apiUrl:"",adapterName:r});if(!s.getAdapterModels)throw new Error("getAdapterModels is not available on this API client");return s.getAdapterModels(e)}static async getAllModels(e){const r=await Fe(),a=new r.ApiClient({apiUrl:"",adapterName:e});if(!a.getAllModels)throw new Error("getAllModels is not available on this API client");return a.getAllModels()}static async listAdapterModels(e,r){return(await $a.getAdapterModels(e,r)).models}}const vf="rounded-t-[32px] border border-white/40 bg-transparent px-4 pb-4 pt-[max(env(safe-area-inset-top),1rem)] shadow-none backdrop-blur-0 dark:border-[#2f303d] dark:bg-transparent md:rounded-none md:border-0 md:bg-transparent md:px-0 md:pb-0 md:pt-3 md:shadow-none md:backdrop-blur-0 md:dark:bg-transparent md:dark:border-0",Sf="shrink-0 sticky bottom-[calc(var(--app-footer-height,0px)+0.25rem)] z-10 -mx-4 mt-auto overflow-visible bg-transparent pb-[max(env(safe-area-inset-bottom),0.5rem)] shadow-none backdrop-blur-0 transition-all duration-200 dark:bg-transparent md:bottom-[calc(var(--app-footer-height,0px)+0.5rem)] md:z-10 md:mx-0 md:mt-0 md:overflow-visible md:rounded-none md:border-0 md:bg-transparent md:pb-0 md:shadow-none md:backdrop-blur-0 md:dark:bg-transparent md:dark:border-0 [&>div]:bg-transparent md:[&>div]:rounded-none md:[&>div]:px-0",jf="relative z-20 shrink-0 -mx-4 px-4 pt-2 pb-2 bg-transparent border-b border-transparent dark:border-transparent dark:bg-transparent md:static md:mx-0 md:px-0 md:pt-6 md:pb-6 md:bg-transparent md:border-gray-200 md:dark:border-[#4a4b54] md:dark:bg-transparent";function Cf({onOpenSettings:t,onOpenSidebar:e}){var Vt,Ze,Mt,qt,Ce,Qe,ft;const{t:r}=Le(),{conversations:a,currentConversationId:s,createConversation:i,canCreateNewConversation:o,sendMessage:l,regenerateResponse:c,editMessageAndRegenerate:d,isLoading:u,configureApiSettings:f,error:m,clearError:h,createThread:p,clearCurrentConversationAdapter:x}=ke(),{settings:y}=Es(),k=hr(),N=rt()&&!k,{theme:A,isDark:v}=rr(),C=A.mode==="dark"?"dark":A.mode==="light"?"light":"",E=v?"dark":"light",P=["application-description agent-home-markdown prose prose-slate dark:prose-invert max-w-none text-sm md:text-base leading-relaxed","text-[#4a4c5a] dark:text-[#bfc2cd]","[&>:first-child]:mt-0 [&>:last-child]:mb-0",C].filter(Boolean).join(" "),b=a.find(ue=>ue.id===s),_=a.some(ue=>{var Se;return(ue.messages.length>0||(((Se=ue.attachedFiles)==null?void 0:Se.length)||0)>0)&&!ue.adapterLoadError}),S=!b||b.messages.length===0,I=((Vt=b==null?void 0:b.adapterInfo)==null?void 0:Vt.supportsThreading)===!0,M=!!(b!=null&&b.adapterName&&(b!=null&&b.adapterInfo))&&!I,F=Ri({adapterName:b==null?void 0:b.adapterName,enabled:M,selectionScopeKey:s,supportsThreading:I}),z=mi(),j=ja(),L=Ca().trim(),R=L.length>0,{registerGoHome:T}=Zi(),[K,G]=g.useState([]),[H,Z]=g.useState(null);g.useEffect(()=>{const ue=b==null?void 0:b.adapterName;let Se=!1;async function _e(){if(Z(null),!ue){G([]);return}try{const re=await $a.listAdapterModels(ue,ue);if(Se)return;G(re),Z(re.length>0?re[0].name:null)}catch{Se||(G([]),Z(null))}}return _e(),()=>{Se=!0}},[b==null?void 0:b.adapterName]);const{adapterNotesError:fe,handleAgentCardSelection:U,handleChangeAgent:te,goToAgentSelectionHome:W,hasAdapterConfigurationError:Q,isAgentSelectionVisible:se,isConfiguringAdapter:ge,isSingleAdapterMode:Ne,shouldShowAgentSelectionList:B}=sf({currentConversation:b,showEmptyState:S,createConversation:i,configureApiSettings:f,clearError:h,clearCurrentConversationAdapter:x});g.useLayoutEffect(()=>(T(()=>W()),()=>T(null)),[T,W]);const X="max-w-[96rem]",ee="max-w-[64rem]",we="max-w-[56rem]",ae=`mx-auto w-full ${X}`,Y=o(),de=!!(b!=null&&b.adapterName)&&((b==null?void 0:b.messages.length)||0)===0,ve=r(Y?"chatInterface.newConversation.tooltipCanStart":N?"chatInterface.newConversation.tooltipGuestLimited":"chatInterface.newConversation.tooltipCannotStart"),ce=!!(b&&!B),Pe=B?"border-transparent dark:border-transparent md:border-transparent md:dark:border-transparent":"",Me=!ga()&&B?"pt-0 pb-0 md:pt-0 md:pb-1":"",ie=`${jf} ${Pe} ${Me}`.trim(),ze=ki(),be=a.some(ue=>{var Se;return(ue.messages.length>0||(((Se=ue.attachedFiles)==null?void 0:Se.length)??0)>0)&&!ue.adapterLoadError}),Ae=ze&&!be,_t=B?"pt-0 md:pt-0":"pt-4 md:pt-6",Ue=g.useMemo(()=>{var re,et,Be;if(B)return null;const ue=bf(b==null?void 0:b.adapterName)||yf();if(!ue&&!(b!=null&&b.adapterName))return null;const Se=(re=b==null?void 0:b.adapterName)==null?void 0:re.trim(),_e=(Be=(et=b==null?void 0:b.adapterInfo)==null?void 0:et.notes)==null?void 0:Be.trim();return ue?{...ue,notes:_e||ue.notes}:Se?{id:Se,name:Se,notes:_e||void 0}:null},[(Ze=b==null?void 0:b.adapterInfo)==null?void 0:Ze.notes,b==null?void 0:b.adapterName,B]);g.useEffect(()=>{Qi(Ue)},[Ue]),g.useEffect(()=>{let ue=null;const Se=()=>{ue&&(ue(),ue=null)};if(y.voiceEnabled){if(Bt.isAudioEnabled())return D("[ChatInterface] Audio streaming already enabled"),Se;const _e=()=>{Se();const re=async()=>{Se(),await Bt.enableAudio()?D("[ChatInterface] Audio streaming enabled after user gesture"):(pe("[ChatInterface] User gesture did not enable audio streaming"),_e())};document.addEventListener("pointerdown",re,{once:!0}),document.addEventListener("keydown",re,{once:!0}),ue=()=>{document.removeEventListener("pointerdown",re),document.removeEventListener("keydown",re)},D("[ChatInterface] Waiting for user gesture to enable audio streaming")};return _e(),Se}return Se(),Bt.disableAudio(),D("[ChatInterface] Audio streaming disabled via settings"),Se},[y.voiceEnabled]);const Je=(ue,Se,_e,re)=>{var et;l(ue,Se,_e,H??((et=b==null?void 0:b.adapterInfo)==null?void 0:et.model)??void 0,re)},mr=async(ue,Se,_e,re,et)=>{var Be;await l(_e,void 0,ue,et??H??((Be=b==null?void 0:b.adapterInfo)==null?void 0:Be.model)??void 0,re)},ut=()=>{try{i()}catch(ue){pe("Cannot create new conversation:",ue instanceof Error?ue.message:"Unknown error")}},Tt=g.useCallback(async(ue,Se)=>{if(b)try{await ke.getState().deleteThread(b.id,ue,Se)}catch(_e){xe("Failed to clear thread:",_e)}},[b]);return n.jsx("main",{className:"flex-1 flex flex-col bg-transparent overflow-hidden","aria-label":r("chatInterface.workspace.ariaLabel"),children:n.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden px-3 sm:px-5 lg:px-8",children:n.jsxs("div",{className:`mx-auto flex h-full w-full ${X} flex-col overflow-hidden md:pb-4 ${vf}`,children:[m&&n.jsx("div",{role:"alert",className:"mt-6 rounded-md border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsx("p",{children:m}),n.jsx("button",{onClick:h,className:"ml-4 rounded p-1 text-red-500 hover:bg-red-100 hover:text-red-700 dark:text-red-200 dark:hover:bg-red-800/40","aria-label":r("chatInterface.error.dismissAriaLabel"),children:"×"})]})}),n.jsxs("div",{className:ie,children:[e&&n.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 md:hidden",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("button",{onClick:e,disabled:!_,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border px-3 py-2 text-xs font-semibold shadow-sm transition-all duration-150 ${_?"border-white/50 bg-white/80 text-gray-800 active:scale-[0.97] hover:bg-white dark:border-[#2f303d] dark:bg-[#232430] dark:text-[#ececf1]":"cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400 shadow-none dark:border-[#2f303d] dark:bg-[#181922] dark:text-[#6b6f7a]"}`,"aria-label":r("chatInterface.mobile.openChatsMenuAriaLabel"),children:[n.jsx(Oc,{className:"h-4 w-4"}),r("chatInterface.mobile.chatsButton")]}),n.jsxs("button",{onClick:t,className:"inline-flex items-center justify-center gap-1.5 rounded-lg border border-white/50 bg-[#11121a]/90 px-3 py-2 text-xs font-semibold text-white shadow-sm active:scale-[0.97] transition-all duration-150 hover:bg-[#0c0d14] dark:border-[#3b3c49] dark:bg-[#565869] dark:hover:bg-[#6b6f7a]","aria-label":r("chatInterface.mobile.openSettingsAriaLabel"),children:[n.jsx(vn,{className:"h-4 w-4"}),r("chatInterface.mobile.settingsButton")]})]}),n.jsx("div",{className:"ml-auto flex-shrink-0",children:n.jsx(ya,{})})]}),n.jsxs("div",{className:"flex flex-col gap-2 md:gap-4 sm:flex-row sm:items-end sm:justify-between",children:[n.jsx("div",{className:"min-w-0 flex-1",children:ce&&n.jsx("div",{className:"space-y-1.5 md:space-y-3",children:n.jsxs("div",{className:"md:space-y-1",children:[n.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[n.jsx("h1",{className:"min-w-0 truncate text-lg md:text-2xl font-semibold text-[#353740] dark:text-[#ececf1]",children:(b==null?void 0:b.title)||r("chatInterface.newChatTitle")}),b&&n.jsx("span",{className:"flex-shrink-0 text-xs md:hidden text-gray-500 dark:text-[#bfc2cd]",children:b.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),b&&n.jsx("div",{className:"hidden md:flex items-center text-sm text-gray-500 dark:text-[#bfc2cd]",children:n.jsx("span",{children:r("chatInterface.updatedAt",{time:b.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})})})]})})}),n.jsxs("div",{className:"flex w-full flex-wrap items-center gap-2 my-2 md:my-0 sm:w-auto md:justify-end md:gap-3",children:[n.jsx("div",{className:"hidden flex-shrink-0 items-center md:inline-flex",children:n.jsx("button",{onClick:t,className:"inline-flex h-[42px] w-[42px] items-center justify-center rounded-full border border-gray-200 text-gray-500 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:text-gray-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-400/50 dark:border-[#3c3f4a] dark:text-[#9aa1bc] dark:hover:border-[#4d5166] dark:hover:bg-[#2d2f39] dark:hover:text-[#ececf1]","aria-label":r("chatInterface.settings.ariaLabel"),title:r("chatInterface.settings.title"),children:n.jsx(vn,{className:"h-4 w-4"})})}),!Ne&&!B&&!!(b!=null&&b.adapterName)&&n.jsx("button",{type:"button",onClick:()=>{de&&te()},disabled:!de,className:`order-2 sm:order-1 inline-flex h-8 md:h-[42px] w-[calc(50%-0.25rem)] min-w-[140px] md:w-[190px] items-center justify-center gap-1 md:gap-2 rounded-full border px-2.5 md:px-3.5 py-1.5 md:py-2.5 text-[11px] md:text-[13px] font-medium tracking-[0.01em] transition-colors focus-visible:outline-none focus-visible:ring-2 ${de?"border-blue-300 text-blue-700 hover:bg-blue-50 hover:border-blue-400 focus-visible:ring-blue-500 dark:border-blue-500/40 dark:text-blue-300 dark:hover:bg-blue-900/20 dark:hover:border-blue-400/60 dark:focus-visible:ring-blue-400/60":"cursor-not-allowed border-gray-200 text-gray-400 bg-transparent dark:border-[#3c3f4a] dark:text-[#6b6f7a]"}`,title:r(de?"chatInterface.changeAgent.titleEnabled":"chatInterface.changeAgent.titleDisabled"),children:r("chatInterface.changeAgent.button")}),!B&&n.jsxs("button",{onClick:ut,disabled:!Y,className:`order-3 sm:order-2 inline-flex h-8 md:h-[42px] w-[calc(50%-0.25rem)] min-w-[160px] md:w-[220px] md:min-w-[220px] items-center justify-center gap-1 md:gap-2 rounded-full border px-2.5 md:px-3.5 py-1.5 md:py-2.5 text-[11px] md:text-[13px] font-medium tracking-[0.01em] whitespace-nowrap ${Y?"border-[#1f2937] bg-[#1f2937] text-white shadow-[0_2px_8px_rgba(15,23,42,0.12)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#1f2937]/40 dark:border-[#4b5568] dark:bg-[#2f3747] dark:text-[#e9edf8] dark:shadow-[0_2px_8px_rgba(0,0,0,0.25)] dark:focus-visible:ring-[#6f809f]/35":"cursor-not-allowed border-gray-200 text-gray-400 bg-white/40 dark:border-[#3c3f4a] dark:text-[#6b6f7a] dark:bg-transparent"}`,title:ve,children:[n.jsx(Yc,{className:"h-3.5 w-3.5"}),r("chatInterface.newConversation.button")]}),!ga()&&n.jsx("div",{className:"order-4 hidden flex-shrink-0 items-center md:inline-flex",children:n.jsx(ya,{})})]})]})]}),S?n.jsxs("div",{className:`flex flex-1 flex-col min-h-0 ${_t} ${B?"overflow-hidden":""}`,children:[B?n.jsx("div",{className:"flex-1 flex flex-col md:justify-start min-h-0 overflow-hidden",children:n.jsx("div",{className:"w-full flex flex-col min-h-0 overflow-hidden flex-1",children:n.jsxs("div",{className:"flex flex-col min-h-0 flex-1 gap-3 overflow-hidden md:gap-6",children:[n.jsx("div",{className:`${ae} flex-shrink-0 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:n.jsxs("div",{className:"flex-1",children:[n.jsx(Et,{content:j,className:"agent-home-markdown prose prose-slate dark:prose-invert max-w-none [&>:first-child]:mt-0 [&>:last-child]:mb-0 text-2xl font-semibold text-[#11111b] dark:text-white text-center md:text-left [&_p]:text-2xl [&_p]:font-semibold [&_p]:leading-tight [&_p]:m-0",syntaxTheme:E}),R&&n.jsx("div",{className:"mt-2",children:n.jsx(Et,{content:L,className:P,syntaxTheme:E})})]})}),n.jsx(Yu,{onAdapterSelect:U,className:`${ae} md:flex-1 md:min-h-0 md:overflow-hidden`})]})})}):n.jsx("div",{className:"flex flex-1 w-full min-h-0 flex-col overflow-y-auto pt-4 md:pt-6",children:n.jsxs("div",{className:`mx-auto flex w-full ${we} flex-col items-center gap-4 pb-8 md:gap-5 md:pb-12`,children:[fe?n.jsx("p",{className:"w-full text-center text-sm text-red-600 dark:text-red-400",children:fe}):b!=null&&b.adapterName?n.jsx("h2",{className:"w-full text-center text-xl font-semibold tracking-tight text-[#353740] dark:text-[#ececf1] md:text-2xl",style:{fontFamily:'-apple-system, "SF Pro Display", BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},children:Hl(b.adapterName)||b.adapterName}):ge?n.jsx("p",{className:"w-full text-center text-sm text-gray-500 dark:text-[#bfc2cd]",children:r("chatInterface.empty.configuringAgent")}):null,Ue&&kf()&&n.jsx(nf,{adapter:Ue,syntaxTheme:E,forcedThemeClass:C}),n.jsx("div",{className:"w-full min-w-0",children:n.jsx(Wn,{onSend:Je,disabled:u||!b||!(b!=null&&b.adapterName)||Q,autoFocusEnabled:!0,placeholder:z,isCentered:!0,maxWidthClass:we,adapterNotes:(Mt=b==null?void 0:b.adapterInfo)==null?void 0:Mt.notes,skillState:F,availableModels:K,defaultModel:((qt=b==null?void 0:b.adapterInfo)==null?void 0:qt.model)??null,selectedModel:H,onSelectModel:Z})})]})}),Ae&&n.jsx("div",{className:"shrink-0 pt-5 md:pt-6",children:n.jsx(Gi,{compact:!0})})]}):n.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[n.jsx(Nu,{messages:b.messages,onRegenerate:ue=>{var Se;return c(ue,H??((Se=b==null?void 0:b.adapterInfo)==null?void 0:Se.model)??void 0)},onEditMessage:(ue,Se)=>{var _e;return d(ue,Se,H??((_e=b==null?void 0:b.adapterInfo)==null?void 0:_e.model)??void 0)},onStartThread:async(ue,Se)=>{try{await p(ue,Se)}catch(_e){xe("Failed to create thread:",_e)}},onClearThread:Tt,onSendThreadMessage:mr,sessionId:b.sessionId,isLoading:u,contentMaxWidthClass:ee,availableModels:K,defaultModel:((Ce=b==null?void 0:b.adapterInfo)==null?void 0:Ce.model)??null,selectedModel:H}),n.jsx("div",{className:Sf,children:n.jsx("div",{className:"mx-auto w-full max-w-[96rem] px-3 sm:px-5 md:px-6 lg:px-8 xl:px-10",children:n.jsx(Wn,{onSend:Je,disabled:u||!b||!b.adapterName||se||Q,autoFocusEnabled:!0,placeholder:r("chatInterface.docked.placeholder"),maxWidthClass:ee,isCentered:!1,adapterNotes:(Qe=b==null?void 0:b.adapterInfo)==null?void 0:Qe.notes,skillState:F,availableModels:K,defaultModel:((ft=b==null?void 0:b.adapterInfo)==null?void 0:ft.model)??null,selectedModel:H,onSelectModel:Z})})})]})]})})})}function Nf({selectedAdapter:t,onAdapterChange:e,disabled:r,showDescriptions:a=!1,variant:s="sidebar",label:i,showLabel:o}){const{t:l}=Le(),[c,d]=g.useState([]),[u,f]=g.useState(!0),[m,h]=g.useState(null),[p,x]=g.useState(!1);g.useEffect(()=>{let _=!0;async function S(){try{f(!0),h(null);const I=await Fa();_&&d(I)}catch(I){xe("Failed to load adapters:",I),_&&h(l("adapterSelector.failedToLoad"))}finally{_&&f(!1)}}return S(),()=>{_=!1}},[l]);const y=c.find(_=>_.id===t),k=typeof o=="boolean"?o:s==="prominent",N=i||l(s==="prominent"?"adapterSelector.selectAnAgent":"adapterSelector.defaultLabel"),A=g.useMemo(()=>s==="prominent"?"relative w-full text-left":"relative w-full",[s]),v=g.useMemo(()=>{const _="w-full rounded-md border bg-white px-4 py-3 text-left text-sm text-[#353740] focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 dark:bg-[#343541] dark:text-[#ececf1]";return s==="prominent"?[_,"border-gray-300 shadow-sm transition-all duration-200 focus-visible:ring-blue-500 dark:border-[#4a4b54] dark:focus-visible:ring-blue-400"].join(" "):["w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-left text-sm text-[#353740] focus:border-gray-400 focus:outline-none dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#ececf1] dark:focus:border-[#6b6f7a]"].join(" ")},[s]),C=g.useMemo(()=>s==="prominent"?"absolute z-20 mt-2 w-full rounded-xl border border-gray-200 bg-white shadow-xl ring-1 ring-black/5 dark:border-[#4a4b54] dark:bg-[#1f2027]":"absolute z-20 mt-1 w-full rounded-md border border-gray-200 bg-white shadow-lg ring-1 ring-black/5 dark:border-[#4a4b54] dark:bg-[#1f2027]",[s]),b=k?`mb-2 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-[#bfc2cd] ${s==="prominent"?"!text-sm !font-semibold !text-gray-700 dark:!text-white":""}`:"sr-only";return n.jsxs("div",{className:A,children:[n.jsx("label",{className:b,children:N}),n.jsxs("div",{className:"relative",children:[n.jsx("button",{type:"button",onClick:()=>!r&&x(!p),disabled:r||u||c.length===0,className:`${v} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-label":N,children:n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsxs("div",{className:"flex flex-col min-w-0",children:[n.jsx("span",{className:`truncate font-medium ${y?"text-[#11121a] dark:text-white":"text-gray-500 dark:text-gray-400"}`,children:u?l("adapterSelector.loadingAgents"):m?l("adapterSelector.errorLoadingAgents"):y?y.name:c.length===0?l("adapterSelector.noAgentsAvailable"):l("adapterSelector.selectAnAgent")}),s==="prominent"&&(y==null?void 0:y.description)&&n.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:y.description})]}),n.jsx(gr,{className:`h-4 w-4 flex-shrink-0 transition-transform text-gray-400 dark:text-gray-300 ${p?"rotate-180":""}`})]})}),p&&!r&&c.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>x(!1)}),n.jsx("div",{className:C,children:n.jsx("div",{className:"max-h-72 overflow-auto py-2",children:c.map(_=>{const S=_.id===t;return n.jsx("button",{type:"button",onClick:()=>{S||e(_.id),x(!1)},className:`w-full px-4 py-3 text-left text-sm transition-colors ${S?"bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-200":"text-[#353740] hover:bg-gray-50 dark:text-[#ececf1] dark:hover:bg-[#2a2d35]"}`,children:n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("span",{className:"font-medium truncate",children:_.name}),a&&_.description&&n.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:_.description})]})},_.id)})})})]})]}),m&&n.jsx("p",{className:"mt-1 text-xs text-red-600 dark:text-red-400",children:m})]})}const hs=100;function Yn({onClick:t,label:e,hoverClassName:r,icon:a}){return n.jsx("button",{onClick:t,className:`rounded-lg p-1.5 text-slate-400 transition-colors dark:text-[#6b6f7a] ${r}`,"aria-label":e,children:a})}function Af(t,e){const r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),a=new Date(r);a.setDate(a.getDate()-1);const s=new Date(r);s.setDate(s.getDate()-r.getDay());const i=new Date(e.getFullYear(),e.getMonth(),1);return t>=r?"today":t>=a?"yesterday":t>=s?"thisWeek":t>=i?"thisMonth":"earlier"}function If(t){const e=new Date,r=["today","yesterday","thisWeek","thisMonth","earlier"],a=new Map;for(const s of t){const i=Af(s.updatedAt,e),o=a.get(i);o?o.push(s):a.set(i,[s])}return r.filter(s=>a.has(s)).map(s=>({label:s,conversations:a.get(s)}))}function Jn({onRequestClose:t,onToggleDesktopSidebar:e}){const{t:r}=Le(),a=Ts(),{conversations:s,currentConversationId:i,selectConversation:o,deleteConversation:l,deleteAllConversations:c,updateConversationTitle:d,getConversationCount:u,configureApiSettings:f,clearError:m}=ke(),h=s.find(V=>V.id===i),[p,x]=g.useState(""),[y,k]=g.useState(null),[N,A]=g.useState(""),[v,C]=g.useState({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1}),[E,P]=g.useState({isOpen:!1,isDeleting:!1}),[b,_]=g.useState(!1),[S,I]=g.useState(null),[M,F]=g.useState(!1),[z,j]=g.useState(null),L=g.useRef(null),R=g.useRef(null),T=g.useRef(null),K=!h||h.messages.length===0,G=(S==null?void 0:S.conversationId)===i?S.adapterName:(h==null?void 0:h.adapterName)??null,H=(z==null?void 0:z.conversationId)===i?z.message:null,Z=g.useMemo(()=>s.filter(V=>{var ie;return(V.messages.length>0||(((ie=V.attachedFiles)==null?void 0:ie.length)||0)>0)&&!V.adapterLoadError}),[s]),fe=g.useMemo(()=>{if(!p)return Z;const V=p.toLowerCase();return Z.filter(ie=>(ie.title||r("chatInterface.newChatTitle")).toLowerCase().includes(V)||ie.messages.some(ze=>ze.content.toLowerCase().includes(V))||(ie.attachedFiles||[]).some(ze=>ze.filename.toLowerCase().includes(V)))},[Z,p,r]),U=g.useMemo(()=>If(fe),[fe]),te=u(),W=p.length>0,Q=Z.length>0;g.useEffect(()=>{if(!i||!R.current)return;const V=R.current.querySelector('[aria-current="true"]');V&&V.scrollIntoView({block:"nearest",behavior:"smooth"})},[i]);const se=g.useCallback(V=>{var _t;if(V.key!=="ArrowDown"&&V.key!=="ArrowUp")return;V.preventDefault();const ie=(_t=R.current)==null?void 0:_t.querySelectorAll('[role="option"]');if(!ie||ie.length===0)return;const ze=document.activeElement,be=Array.from(ie).indexOf(ze);let Ae;V.key==="ArrowDown"?Ae=be<ie.length-1?be+1:0:Ae=be>0?be-1:ie.length-1,ie[Ae].focus()},[]),ge=async V=>{if(!(!K||!V)){I({conversationId:i??null,adapterName:V}),j(null),F(!0);try{const ie=(h==null?void 0:h.apiUrl)||$e();await f(ie,void 0,V),m(),_(!1)}catch(ie){xe("Failed to configure adapter:",ie),j({conversationId:i??null,message:ie instanceof Error?ie.message:r("sidebar.adapterConfigureFailed")})}finally{F(!1)}}},Ne=async V=>{try{await o(V),t==null||t()}catch(ie){xe("Failed to select conversation:",ie)}},B=(V,ie)=>{V.stopPropagation(),C({isOpen:!0,conversationId:ie.id,conversationTitle:ie.title||r("chatInterface.newChatTitle"),isDeleting:!1})},X=async()=>{C(V=>({...V,isDeleting:!0}));try{await l(v.conversationId)}catch(V){xe("Failed to delete conversation:",V)}C({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},ee=()=>{C({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},we=(V,ie)=>{V.stopPropagation(),k(ie.id),A((ie.title||r("chatInterface.newChatTitle")).slice(0,hs))},ae=V=>{const ie=N.slice(0,hs).trim();ie&&d(V,ie),k(null),A("")},Y=()=>{k(null),A("")},de=()=>{P({isOpen:!0,isDeleting:!1})},ve=async()=>{P(V=>({...V,isDeleting:!0}));try{await c()}catch(V){xe("Failed to clear all conversations:",V)}P({isOpen:!1,isDeleting:!1})},ce=()=>{P({isOpen:!1,isDeleting:!1})},Pe=V=>{var ie,ze,be;return(ie=V.adapterName)!=null&&ie.trim()?V.adapterName:(be=(ze=V.adapterInfo)==null?void 0:ze.adapter_name)!=null&&be.trim()?V.adapterInfo.adapter_name:null};Dr(L,{enabled:b,onEscape:()=>_(!1)});const Me=V=>{const ie=i===V.id,ze=a?null:Pe(V),be=V.title||r("chatInterface.newChatTitle");return n.jsxs("div",{role:"option","aria-selected":ie,tabIndex:0,onKeyDown:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),Ne(V.id))},onClick:()=>Ne(V.id),className:`group relative flex w-full cursor-pointer items-center overflow-hidden rounded-xl border px-3 py-2 text-left text-sm transition-all duration-150
|
|
363
|
+
${ie?"border-slate-200/70 bg-[linear-gradient(180deg,rgba(255,255,255,0.97),rgba(248,250,252,0.94))] shadow-[0_1px_2px_rgba(15,23,42,0.04),0_2px_10px_rgba(15,23,42,0.06)] dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(50,52,65,0.95),rgba(38,39,49,0.92))] dark:shadow-[0_2px_16px_rgba(0,0,0,0.32)]":"border-transparent hover:border-slate-200/60 hover:bg-slate-50 dark:hover:border-white/[0.05] dark:hover:bg-[#212228]"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/50 dark:focus-visible:ring-sky-400/40`,"aria-current":ie?"true":void 0,"aria-label":r("sidebar.conversationCard.openAriaLabel",{title:be}),children:[ie&&n.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-[linear-gradient(180deg,rgba(255,255,255,0.4),rgba(255,255,255,0))] dark:bg-[linear-gradient(180deg,rgba(255,255,255,0.045),rgba(255,255,255,0))]"}),n.jsx("span",{"aria-hidden":"true",className:`absolute inset-y-0 left-0 w-[3px] transition-opacity duration-150 ${ie?"bg-sky-500 opacity-100 dark:bg-sky-400":"opacity-0"}`}),y===V.id?n.jsx("input",{type:"text",value:N,onChange:Ae=>A(Ae.target.value.slice(0,hs)),onKeyDown:Ae=>{Ae.key==="Enter"&&ae(V.id),Ae.key==="Escape"&&Y(),Ae.stopPropagation()},onBlur:()=>ae(V.id),maxLength:hs,className:"relative z-10 flex-1 rounded-lg border border-sky-300 bg-white px-2 py-1 text-sm text-[#353740] focus:outline-none focus:ring-2 focus:ring-sky-400/50 dark:border-sky-500/40 dark:bg-[#1a1b1e] dark:text-[#ececf1]",autoFocus:!0,"aria-label":r("sidebar.conversationCard.editInputAriaLabel")}):n.jsxs("div",{className:"relative z-10 flex min-w-0 flex-1 flex-col gap-1",children:[n.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[n.jsx("h3",{className:`flex-1 truncate text-sm leading-snug tracking-[-0.006em] ${ie?"font-semibold text-slate-900 dark:text-[#ececf1]":"font-medium text-slate-700 dark:text-[#c5c8d6]"}`,children:be}),n.jsxs("div",{className:"ml-1 flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity duration-100 group-hover:opacity-100 group-focus-within:opacity-100",children:[n.jsx(Yn,{onClick:Ae=>we(Ae,V),label:r("sidebar.conversationCard.editAriaLabel",{title:be}),hoverClassName:"hover:bg-slate-200/80 hover:text-slate-600 dark:hover:bg-[#3c3f4a] dark:hover:text-[#c5c8d6]",icon:n.jsx(Ai,{className:"h-3.5 w-3.5"})}),n.jsx(Yn,{onClick:Ae=>B(Ae,V),label:r("sidebar.conversationCard.deleteAriaLabel",{title:be}),hoverClassName:"hover:bg-red-100/80 hover:text-red-600 dark:hover:bg-red-900/30 dark:hover:text-red-400",icon:n.jsx(Ei,{className:"h-3.5 w-3.5"})})]})]}),ze&&n.jsx("span",{className:"block max-w-full truncate text-left text-xs font-medium tracking-wide text-blue-700 dark:text-blue-300",children:ze})]})]},V.id)};return n.jsxs(n.Fragment,{children:[!a&&b&&n.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm px-4",children:n.jsxs("div",{ref:L,role:"dialog","aria-modal":"true","aria-labelledby":"select-agent-title",tabIndex:-1,className:"w-full max-w-md rounded-2xl border border-gray-200 bg-white p-6 shadow-2xl dark:border-[#3d4050] dark:bg-[#1a1b1e]",children:[n.jsx("h2",{id:"select-agent-title",className:"mb-4 text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:r("sidebar.selectAgent.title")}),n.jsxs("div",{className:"space-y-5",children:[n.jsx(Nf,{selectedAdapter:G,onAdapterChange:ge,disabled:M,variant:"prominent",showDescriptions:!0,showLabel:!1}),H&&n.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-600/40 dark:bg-red-900/30 dark:text-red-200",children:H}),n.jsx("div",{className:"flex justify-end gap-3 pt-2",children:n.jsx("button",{type:"button",onClick:()=>{j(null),_(!1)},className:"rounded-lg px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 dark:text-[#d1d5db] dark:hover:bg-[#2d2f39]",disabled:M,children:r("common.cancel")})})]})]})}),n.jsxs("nav",{"aria-label":r("sidebar.navAriaLabel"),className:"flex h-full md:h-[calc(100%-2rem)] md:mt-4 w-full md:w-72 flex-col border-r border-b border-gray-200 md:border-l md:border-t md:rounded-2xl md:overflow-hidden bg-transparent dark:border-[#2d2f39]",children:[n.jsxs("div",{className:"bg-transparent px-4 pb-4 pt-4 dark:border-[#2d2f39]",children:[n.jsxs("div",{className:"flex items-center gap-2 pb-3",children:[s.length>0&&s.some(V=>V.messages.length>0)&&n.jsxs("button",{onClick:de,className:"flex flex-1 items-center justify-center gap-2 rounded-lg border border-red-200 px-3 py-2 text-sm font-medium text-red-600 transition-all duration-150 hover:bg-red-50 hover:border-red-300 hover:shadow-sm dark:border-red-500/25 dark:text-red-400 dark:hover:bg-red-950/20 dark:hover:border-red-500/40",title:r("sidebar.deleteAllConversations.title"),children:[n.jsx(rd,{className:"h-4 w-4"}),r("sidebar.deleteAllConversations.button")]}),e&&n.jsx("button",{type:"button",onClick:e,className:"ml-auto hidden shrink-0 md:inline-flex h-9 w-9 items-center justify-center rounded-xl border border-slate-200/80 bg-white text-slate-600 transition-colors hover:border-slate-300 hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-[#333645] dark:bg-[#161616] dark:text-[#d1d5db] dark:hover:border-[#43465a] dark:hover:bg-[#202020] dark:hover:text-white","aria-label":r("sidebar.collapse.ariaLabel"),title:r("sidebar.collapse.title"),children:n.jsx(qc,{className:"h-4 w-4"})})]}),H&&!b&&n.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:H}),Q&&n.jsxs("div",{className:"border-t border-gray-200 pt-4 mt-4 dark:border-[#2d2f39]",children:[n.jsxs("div",{className:"relative overflow-hidden rounded-[1.75rem] border border-slate-200/85 bg-[linear-gradient(180deg,rgba(255,255,255,0.96),rgba(248,250,252,0.94))] shadow-[0_10px_28px_rgba(15,23,42,0.05)] transition-all duration-200 focus-within:border-sky-300/90 focus-within:shadow-[0_0_0_1px_rgba(125,211,252,0.55),0_10px_28px_rgba(15,23,42,0.05)] dark:border-white/10 dark:bg-[linear-gradient(180deg,rgba(37,39,49,0.95),rgba(29,31,39,0.92))] dark:shadow-[0_12px_30px_rgba(0,0,0,0.2)] dark:focus-within:border-sky-400/30 dark:focus-within:shadow-[0_0_0_1px_rgba(56,189,248,0.22),0_12px_30px_rgba(0,0,0,0.2)]",children:[n.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-[inherit] bg-[linear-gradient(180deg,rgba(255,255,255,0.45),rgba(255,255,255,0))] dark:bg-[linear-gradient(180deg,rgba(255,255,255,0.03),rgba(255,255,255,0))]"}),n.jsx(Ia,{className:"pointer-events-none absolute left-4 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400 dark:text-slate-500"}),n.jsx("input",{ref:T,type:"text",role:"searchbox","aria-label":r("sidebar.search.ariaLabel"),placeholder:r("sidebar.search.placeholder"),value:p,onChange:V=>x(V.target.value),className:"relative z-10 w-full bg-transparent py-3 pl-11 pr-11 text-sm font-medium text-slate-700 placeholder:font-normal placeholder:text-slate-400 focus:outline-none dark:text-slate-100 dark:placeholder:text-slate-500"}),p&&n.jsx("button",{type:"button",onClick:()=>{var V;x(""),(V=T.current)==null||V.focus()},className:"absolute right-3 top-1/2 z-10 inline-flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-full border border-slate-200/80 bg-white/90 text-slate-400 transition-colors hover:border-slate-300 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-sky-200 dark:border-white/10 dark:bg-white/5 dark:text-slate-500 dark:hover:border-white/20 dark:hover:text-slate-200 dark:focus:ring-sky-500/20","aria-label":r("sidebar.search.clearAriaLabel"),children:n.jsx(Ye,{className:"h-3.5 w-3.5"})})]}),W&&n.jsx("p",{"aria-live":"polite",className:"mt-2 text-center text-[11px] tabular-nums text-gray-400 dark:text-[#6e7490]",children:fe.length===0?r("sidebar.resultsNone"):r("sidebar.results",{count:fe.length})})]})]}),n.jsx("div",{ref:R,role:"listbox","aria-label":r("sidebar.conversations.ariaLabel"),onKeyDown:se,className:"flex-1 overflow-y-auto bg-transparent px-3 py-2",children:fe.length===0?null:W?n.jsx("div",{className:"space-y-1.5",children:fe.map(Me)}):n.jsx("div",{className:"space-y-4",children:U.map(V=>n.jsxs("section",{"aria-label":r(`sidebar.timeGroups.${V.label}`),children:[n.jsx("h4",{className:"sticky top-0 z-10 mb-1 bg-transparent px-1 pb-1 pt-0.5 text-[11px] font-semibold uppercase tracking-wider text-gray-400 backdrop-blur-sm dark:text-[#6e7490]",children:r(`sidebar.timeGroups.${V.label}`)}),n.jsx("div",{className:"space-y-1.5",children:V.conversations.map(Me)})]},V.label))})}),(()=>{const V=wi();return V.length===0?null:n.jsx("div",{className:"shrink-0 border-t border-gray-200/80 px-4 py-3 md:hidden dark:border-[#2d2f39]",children:n.jsx("nav",{"aria-label":r("appHeader.navLinksAriaLabel"),children:n.jsx("ul",{className:"flex flex-wrap gap-2",children:V.map(ie=>n.jsx("li",{children:n.jsx("a",{href:ie.url,className:"inline-flex items-center rounded-md px-2.5 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-100 dark:text-[#d1d5db] dark:hover:bg-[#2b2d39]",children:ie.label})},ie.url))})})})})(),n.jsx("div",{className:"shrink-0 border-t border-gray-200/80 dark:border-[#2d2f39]",children:n.jsx(Gi,{placement:"sidebar",compact:!0})})]}),n.jsx(js,{isOpen:v.isOpen,onClose:ee,onConfirm:X,title:r("sidebar.deleteConfirm.title"),message:r("sidebar.deleteConfirm.message",{title:v.conversationTitle}),confirmText:r("sidebar.deleteConfirm.confirmText"),cancelText:r("common.cancel"),type:"danger",isLoading:v.isDeleting}),n.jsx(js,{isOpen:E.isOpen,onClose:ce,onConfirm:ve,title:r("sidebar.clearAllConfirm.title"),message:r("sidebar.clearAllConfirm.message",{count:te}),confirmText:r("sidebar.clearAllConfirm.confirmText"),cancelText:r("common.cancel"),type:"danger",isLoading:E.isDeleting})]})}const Lf="3.11.5",Ef={version:Lf},Pa=Ef.version,_f=["@@auth0spajs@@","a0.spajs","auth0","com.auth0"];function Tf(t){const e=t.toLowerCase();return _f.some(r=>e.includes(r.toLowerCase()))}function Mf(t){const e=[];for(let r=0;r<t.length;r++){const a=t.key(r);a&&Tf(a)&&e.push(a)}e.forEach(r=>t.removeItem(r))}function Zn(t){try{Mf(t),t.clear()}catch(e){console.warn("[Settings] Failed to clear browser storage during reset.",e)}}function Ff(){if(typeof document>"u"||!document.cookie)return;const t=new Set([void 0]),e=window.location.hostname;e&&e!=="localhost"&&!/^\d{1,3}(?:\.\d{1,3}){3}$/.test(e)&&(t.add(e),t.add(`.${e}`)),document.cookie.split(";").forEach(a=>{const s=a.indexOf("="),i=(s>-1?a.slice(0,s):a).trim();i&&t.forEach(o=>{const l=o?`;domain=${o}`:"";document.cookie=`${i}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${l}`})})}function $f(){Zn(localStorage),Zn(sessionStorage),Ff()}function Pf({isOpen:t,onClose:e}){const{t:r}=Le(),{theme:a,updateTheme:s}=rr(),{settings:i,updateSettings:o}=Es(),{activeLanguages:l,currentLanguage:c,setLanguage:d}=Cc(),[u,f]=g.useState(!1),[m,h]=g.useState(!1),p=g.useRef(null),x=g.useRef(null),y=g.useMemo(()=>[...l].sort((E,P)=>as[E].localeCompare(as[P])),[l]);g.useEffect(()=>{if(!m)return;const E=P=>{P.key==="Escape"&&(P.stopPropagation(),h(!1))};return document.addEventListener("keydown",E,{capture:!0}),()=>document.removeEventListener("keydown",E,{capture:!0})},[m]);const k=E=>{s({mode:E})},N=()=>{o({soundEnabled:!i.soundEnabled})},A=()=>{f(!0)},v=()=>{f(!1)},C=()=>{v(),$s(),Ps(!1),fr(null),st.getState().closeLoginPrompt(),$f(),window.location.reload()};return Dr(p,{enabled:t&&!u,onEscape:e}),Dr(x,{enabled:u,onEscape:v}),t?n.jsxs("div",{className:"fixed inset-0 z-50 flex items-end md:items-center justify-center overflow-y-auto bg-black/50 p-0 md:p-4",children:[n.jsx("button",{type:"button",onClick:e,"aria-label":r("settings.dialog.closeOverlayAriaLabel"),className:"absolute inset-0"}),n.jsxs("div",{onClick:E=>E.stopPropagation(),ref:p,role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",tabIndex:-1,className:"relative flex h-[100dvh] w-full max-w-none flex-col overflow-hidden bg-white shadow-2xl dark:bg-[#1a1b1e] md:h-auto md:max-h-[90vh] md:max-w-md md:rounded-2xl",children:[n.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between border-b border-gray-200 px-6 pb-4 pt-[max(env(safe-area-inset-top),1rem)] dark:border-[#2d2f39] md:p-6",children:[n.jsx("h2",{id:"settings-title",className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:r("settings.dialog.title")}),n.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 dark:hover:bg-[#25262f] rounded-lg transition-colors","aria-label":r("settings.dialog.closeButtonAriaLabel"),children:n.jsx(Ye,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),n.jsxs("div",{className:"flex-1 min-h-0 space-y-6 overflow-y-auto px-6 pb-[max(env(safe-area-inset-bottom),1.25rem)] pt-6 md:p-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[n.jsx(Vc,{className:"w-5 h-5"}),r("settings.appearance.heading")]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:r("settings.appearance.themeLabel")}),n.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"light",label:r("settings.appearance.themeLight"),icon:td},{value:"dark",label:r("settings.appearance.themeDark"),icon:Hc},{value:"system",label:r("settings.appearance.themeSystem"),icon:Bc}].map(({value:E,label:P,icon:b})=>n.jsxs("button",{onClick:()=>k(E),className:`flex flex-col items-center gap-2 p-3 rounded-lg border-2 transition-all duration-200 ${a.mode===E?"border-blue-500 bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":"border-gray-200 dark:border-[#2d2f39] hover:border-gray-300 dark:hover:border-[#43465a] text-gray-700 dark:text-gray-300"}`,children:[n.jsx(b,{className:"w-5 h-5"}),n.jsx("span",{className:"text-sm font-medium",children:P})]},E))})]}),l.length>1&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 flex items-center gap-2",children:[n.jsx(Pc,{className:"w-4 h-4"}),r("settings.language.label")]}),n.jsxs("div",{className:"relative",children:[n.jsxs("button",{type:"button",onClick:()=>h(E=>!E),"aria-haspopup":"listbox","aria-expanded":m,className:`flex w-full items-center justify-between gap-2 rounded-lg border-2 px-3 py-2.5 text-left text-sm transition-colors duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/50 dark:focus-visible:ring-blue-400/40 ${m?"border-blue-500":"border-gray-200 dark:border-[#2d2f39] hover:border-gray-300 dark:hover:border-[#43465a]"}`,children:[n.jsx("span",{className:"font-medium text-gray-900 dark:text-gray-100",children:as[c]}),n.jsx(gr,{className:`h-4 w-4 flex-shrink-0 text-gray-400 transition-transform duration-200 dark:text-gray-500 ${m?"rotate-180":""}`})]}),m&&n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!1)}),n.jsx("div",{role:"listbox","aria-label":r("settings.language.label"),className:"absolute z-20 mt-2 max-h-60 w-full overflow-y-auto rounded-lg border border-gray-200 bg-white p-1 shadow-lg ring-1 ring-black/5 dark:border-[#2d2f39] dark:bg-[#1a1b1e] dark:ring-white/5",children:y.map(E=>{const P=E===c;return n.jsxs("button",{type:"button",role:"option","aria-selected":P,onClick:()=>{d(E),h(!1)},className:`flex w-full items-center justify-between gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors ${P?"bg-blue-50 font-medium text-blue-700 dark:bg-blue-900/20 dark:text-blue-300":"text-gray-700 hover:bg-gray-50 dark:text-gray-300 dark:hover:bg-[#25262f]"}`,children:[n.jsx("span",{className:"truncate",children:as[E]}),P&&n.jsx(ur,{className:"h-4 w-4 flex-shrink-0 text-blue-600 dark:text-blue-400"})]},E)})})]})]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:r("settings.chat.heading")}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(_a,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:r("settings.soundEffects.label")}),n.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:r("settings.soundEffects.description")})]})]}),n.jsx("button",{onClick:N,role:"switch","aria-checked":i.soundEnabled,"aria-label":r("settings.soundEffects.toggleAriaLabel"),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i.soundEnabled?"bg-blue-600":"bg-gray-200 dark:bg-[#3c3f4a]"}`,children:n.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i.soundEnabled?"translate-x-6":"translate-x-1"}`})})]})]}),n.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-[#2d2f39]",children:[n.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[n.jsx(Ei,{className:"w-5 h-5"}),r("settings.dataManagement.heading")]}),n.jsxs("div",{className:"space-y-3",children:[n.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("settings.dataManagement.description")}),n.jsx("button",{onClick:A,className:"w-full px-4 py-2 text-sm font-medium text-red-600 dark:text-red-400 border border-red-300 dark:border-red-700 rounded-lg hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors",children:r("settings.reset.button")})]})]}),n.jsxs("p",{className:"pt-2 text-center text-xs text-gray-400 dark:text-[#858999]",children:["v",Pa]})]}),u&&n.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/70 p-4",children:n.jsxs("div",{ref:x,role:"dialog","aria-modal":"true","aria-labelledby":"reset-dialog-title",tabIndex:-1,className:"max-h-[calc(100dvh-2rem)] w-full max-w-sm overflow-y-auto rounded-2xl border border-red-100 bg-white p-6 shadow-2xl dark:border-red-800/60 dark:bg-[#111113]",children:[n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx("div",{className:"mt-0.5 flex h-10 w-10 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/40",children:n.jsx(Ea,{className:"w-5 h-5 text-red-600 dark:text-red-400"})}),n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("p",{id:"reset-dialog-title",className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:r("settings.reset.confirmTitle")}),n.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:r("settings.reset.confirmMessage")})]})]}),n.jsxs("div",{className:"mt-4 flex gap-2 pt-2",children:[n.jsx("button",{onClick:v,className:"flex-1 px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 border border-gray-300 dark:border-[#2d2f39] rounded-lg hover:bg-gray-50 dark:hover:bg-[#1a1b1e] transition-colors",children:r("common.cancel")}),n.jsx("button",{onClick:C,className:"flex-1 px-4 py-2 text-sm font-semibold rounded-lg transition-colors bg-red-600 text-white hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-600",children:r("settings.reset.confirmButton")})]})]})})]})]}):null}function Rf({message:t}){const{t:e}=Le(),r=ja();return n.jsx("main",{className:"min-h-dvh bg-white px-4 py-6 text-slate-950 dark:bg-black dark:text-slate-100 sm:px-6 lg:px-8",children:n.jsxs("div",{className:"mx-auto flex min-h-[calc(100dvh-3rem)] w-full max-w-5xl flex-col",children:[n.jsxs("header",{className:"flex items-center justify-between gap-4",children:[n.jsx("p",{className:"min-w-0 truncate text-lg font-semibold tracking-tight sm:text-xl",children:r}),n.jsxs("span",{className:"shrink-0 text-xs font-medium text-slate-400 dark:text-[#858999]",children:["v",Pa]})]}),n.jsx("section",{className:"flex flex-1 items-center justify-center py-12",children:n.jsxs("div",{className:"w-full max-w-lg space-y-8",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("span",{className:"relative flex h-2.5 w-2.5 shrink-0",children:[n.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-60 dark:bg-amber-500"}),n.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-amber-500 dark:bg-amber-400"})]}),n.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-amber-700 dark:text-amber-400",children:e("outOfService.statusBadge")})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-slate-950 dark:text-white sm:text-4xl",children:e("outOfService.heading")}),n.jsx("p",{className:"max-w-md whitespace-pre-wrap text-base leading-relaxed text-slate-500 dark:text-slate-400",children:t})]}),n.jsx("div",{className:"border-t border-slate-200 dark:border-[#242424]"}),n.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[n.jsxs("button",{type:"button",onClick:()=>window.location.reload(),className:"inline-flex items-center justify-center gap-2 rounded-lg bg-slate-950 px-5 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:bg-white dark:text-slate-950 dark:hover:bg-slate-200",children:[n.jsx(Zc,{className:"h-4 w-4","aria-hidden":"true"}),e("outOfService.retryButton")]}),n.jsx("span",{className:"hidden text-slate-300 dark:text-slate-700 sm:block","aria-hidden":"true",children:"·"})]})]})})]})})}function Df({children:t}){const{instance:e,accounts:r}=ka(),a=Uo();return g.useEffect(()=>{Ps(a)},[a]),g.useEffect(()=>{if(!a||r.length===0){fr(null);return}const s=r[0];fr(s.username||s.name||s.localAccountId||null)},[a,r]),g.useEffect(()=>{if(!a||r.length===0)return;const s=r[0],i=Aa();return _i(async()=>(await e.acquireTokenSilent({scopes:i,account:s})).accessToken),()=>$s()},[a,r,e]),n.jsx(n.Fragment,{children:t})}function Of({children:t}){return n.jsx(Df,{children:t})}function Uf({children:t}){const{isLoading:e,isAuthenticated:r,getAccessTokenSilently:a,user:s}=va();return g.useEffect(()=>{Ps(r)},[r]),g.useEffect(()=>{if(!r){fr(null);return}const i=(s==null?void 0:s.sub)||(s==null?void 0:s.email)||(s==null?void 0:s.nickname)||(s==null?void 0:s.name)||null;fr(i)},[r,s]),g.useEffect(()=>(r&&_i(()=>a()),()=>$s()),[r,a]),e?n.jsx("div",{className:"flex items-center justify-center h-screen bg-white dark:bg-[#212121]",children:n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 dark:border-gray-100"})}):n.jsx(n.Fragment,{children:t})}function zf({children:t}){return g.useEffect(()=>{Ps(!1),fr(null),$s()},[]),n.jsx(n.Fragment,{children:t})}function Bf({children:t}){return rt()?Ms()==="entra"?n.jsx(Of,{children:t}):n.jsx(Uf,{children:t}):n.jsx(zf,{children:t})}function Hf(){const t=Na(),e=rt(),r=hr(),{showLoginPrompt:a,promptMessage:s,closeLoginPrompt:i}=st();return g.useEffect(()=>{a&&(!t||!e||r)&&i()},[a,t,e,r,i]),!t||!e||r||!a?null:Ms()==="entra"?n.jsx(qf,{message:s,onClose:i}):n.jsx(Vf,{message:s,onClose:i})}function Vf({message:t,onClose:e}){const{loginWithRedirect:r}=va();return n.jsx(eo,{message:t,onClose:e,onLogin:()=>r()})}function qf({message:t,onClose:e}){const{instance:r}=ka();return n.jsx(eo,{message:t,onClose:e,onLogin:()=>r.loginRedirect({scopes:Aa()}).catch(()=>{})})}function eo({message:t,onClose:e,onLogin:r}){const{t:a}=Le();return n.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[n.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:e,"aria-hidden":"true"}),n.jsxs("div",{className:"relative z-10 mx-4 w-full max-w-md rounded-2xl border border-gray-200 bg-white p-6 shadow-2xl dark:border-[#4a4b54] dark:bg-[#2d2f39]",children:[n.jsx("button",{onClick:e,className:"absolute right-3 top-3 rounded-full p-1.5 text-gray-400 hover:bg-gray-100 hover:text-gray-600 dark:hover:bg-[#3c3f4a] dark:hover:text-[#ececf1]","aria-label":a("common.close"),children:n.jsx(Ye,{className:"h-4 w-4"})}),n.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[n.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/40",children:n.jsx(Ni,{className:"h-5 w-5 text-blue-600 dark:text-blue-300"})}),n.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:a("loginPrompt.heading")})]}),n.jsx("p",{className:"mb-6 text-sm leading-relaxed text-gray-600 dark:text-[#bfc2cd]",children:t}),n.jsxs("div",{className:"flex gap-3",children:[n.jsx("button",{onClick:r,className:"flex-1 rounded-lg bg-blue-600 px-4 py-2.5 text-sm font-medium text-white shadow-sm hover:bg-blue-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:bg-blue-500 dark:hover:bg-blue-600",children:a("common.signIn")}),n.jsx("button",{onClick:e,className:"flex-1 rounded-lg border border-gray-300 bg-white px-4 py-2.5 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-400 dark:border-[#4a4b54] dark:bg-[#2d2f39] dark:text-[#bfc2cd] dark:hover:bg-[#3c3f4a]",children:a("common.cancel")})]})]})]})}function Wf(){const{t}=Le(),{goHome:e}=Zi(),{isDark:r}=rr(),a=tf(),s=g.useRef(!1),i=ic(),o=oc(),l=lc(),c=r?l:o,d=cc(),u=dc(),f=!!(d||u),m=uc(),h=fc(),p=gc(),x=wi(),y=p?"border-b border-slate-200/80 dark:border-[#333645]":"",k="inline-flex min-h-10 items-center rounded-md px-2.5 text-sm font-medium transition-colors hover:bg-slate-100 hover:text-blue-700 hover:no-underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:hover:bg-[#2b2d39] dark:hover:text-blue-300";return g.useEffect(()=>{s.current},[l,i,o]),ga()?n.jsx("header",{className:`relative z-30 shrink-0 bg-white px-3 pb-1 pt-2 dark:bg-black sm:px-5 sm:pb-2 sm:pt-3 lg:px-8 md:pt-5 ${y}`.trim(),style:{backgroundColor:m||void 0,color:h||void 0},children:n.jsxs("div",{className:"mx-auto flex w-full max-w-[96rem] items-center justify-between gap-3",children:[n.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-2 md:justify-start md:gap-3",children:n.jsx("a",{href:a,"aria-label":t("appHeader.homeLinkAriaLabel"),onClick:N=>{N.preventDefault(),e()},className:"inline-flex items-center rounded-sm px-1 py-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-300 dark:focus-visible:ring-offset-black md:-ml-1",children:n.jsx("img",{src:c,alt:t("appHeader.logoAlt"),draggable:!1,className:`block max-w-full flex-shrink-0 select-none ${f?"":"h-8 w-auto sm:h-10 md:h-11"}`.trim(),style:{WebkitUserDrag:"none",...d?{height:d}:{},...u?{width:u}:{}}})})}),n.jsxs("div",{className:"hidden min-w-0 flex-1 items-center justify-end gap-2 sm:gap-4 md:flex",children:[x.length>0&&n.jsx("nav",{"aria-label":t("appHeader.navLinksAriaLabel"),className:"hidden sm:block",children:n.jsx("ul",{className:"flex items-center gap-1.5 sm:gap-2",children:x.map(N=>n.jsx("li",{children:n.jsx("a",{href:N.url,target:"_blank",rel:"noopener noreferrer",className:k,style:{color:h||void 0},children:N.label})},N.url))})}),n.jsx(ya,{})]})]})}):null}function Kf({children:t}){const e=g.useRef(null),r=g.useCallback(s=>{e.current=s},[]),a=g.useCallback(()=>{var s;(s=e.current)==null||s.call(e)},[]);return n.jsx(Ji.Provider,{value:{registerGoHome:r,goHome:a},children:t})}function Gf(){const{t}=Le(),[e,r]=g.useState(!1),[a,s]=g.useState(!1),[i,o]=g.useState(()=>localStorage.getItem("desktop-sidebar-collapsed")==="true"),l=ke(u=>u.conversations),c=rc();if(g.useEffect(()=>{localStorage.setItem("desktop-sidebar-collapsed",String(i))},[i]),c)return n.jsx(Qa,{children:n.jsx(Rf,{message:c})});const d=l.some(u=>{var f;return(u.messages.length>0||(((f=u.attachedFiles)==null?void 0:f.length)??0)>0)&&!u.adapterLoadError});return n.jsx(Qa,{children:n.jsx(Vo,{children:n.jsx(jc,{children:n.jsx(Bf,{children:n.jsx(Kf,{children:n.jsxs("div",{className:"h-dvh flex flex-col bg-white dark:bg-black text-slate-900 dark:text-slate-100",children:[n.jsxs("div",{className:"flex-1 flex flex-col md:flex-row md:pl-4 min-h-0",children:[d&&(i?n.jsx("div",{className:"hidden md:flex md:w-16 md:h-full shrink-0 items-start justify-center pt-8",children:n.jsx("button",{type:"button",onClick:()=>o(!1),className:"inline-flex h-9 w-9 items-center justify-center rounded-xl border border-slate-200/80 bg-white text-slate-600 transition-colors hover:border-slate-300 hover:bg-slate-100 hover:text-slate-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 dark:border-[#333645] dark:bg-[#161616] dark:text-[#d1d5db] dark:hover:border-[#43465a] dark:hover:bg-[#202020] dark:hover:text-white","aria-label":t("app.sidebar.openAriaLabel"),title:t("app.sidebar.openTitle"),children:n.jsx(Wc,{className:"h-4 w-4"})})}):n.jsx("div",{className:"hidden md:h-full md:flex",children:n.jsx(Jn,{onToggleDesktopSidebar:()=>o(!0)})})),n.jsxs("div",{className:"flex-1 flex flex-col w-full min-h-0",children:[n.jsx(Wf,{}),n.jsx("div",{className:"flex-1 flex justify-center w-full min-h-0",children:n.jsx(Cf,{onOpenSettings:()=>r(!0),onOpenSidebar:()=>s(!0)})})]})]}),n.jsx(Hf,{}),n.jsx(Pf,{isOpen:e,onClose:()=>r(!1)}),a&&n.jsxs("div",{className:"fixed inset-0 z-50 flex md:hidden",children:[n.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>s(!1),"aria-hidden":"true"}),n.jsxs("div",{className:"relative z-10 h-full w-[min(20rem,90vw)] animate-slideIn bg-white dark:bg-black",children:[n.jsx(Jn,{onRequestClose:()=>s(!1)}),n.jsx("button",{onClick:()=>s(!1),className:"absolute -right-3 top-[max(env(safe-area-inset-top),0.75rem)] rounded-full bg-white/95 p-3 text-gray-600 shadow-lg active:scale-95 transition-transform dark:bg-[#2d2f39] dark:text-[#ececf1]","aria-label":t("app.menu.closeAriaLabel"),children:n.jsx(Ye,{className:"h-5 w-5"})})]})]})]})})})})})})}const ia=new zo({auth:{clientId:bi(),authority:`https://login.microsoftonline.com/${nc()}`,redirectUri:typeof window<"u"?window.location.origin:"/"},cache:{cacheLocation:"sessionStorage"}});function Xf({children:t}){const[e,r]=g.useState(!1);return g.useEffect(()=>{ia.initialize().then(()=>ia.handleRedirectPromise()).catch(a=>{console.error("[EntraAuth] Redirect processing failed:",a)}).finally(()=>r(!0))},[]),e?n.jsx(Bo,{instance:ia,children:t}):null}function Yf({children:t}){if(!Na()||!rt())return n.jsx(n.Fragment,{children:t});if(Ms()==="entra")return n.jsx(Xf,{children:t});const r=sc(),a=bi(),s=ac();return!r||!a?n.jsx(n.Fragment,{children:t}):n.jsx(Ho,{domain:r,clientId:a,authorizationParams:{redirect_uri:window.location.origin,...s?{audience:s}:{}},cacheLocation:"memory",children:t})}Qi(null);const Qn=Gl(),ei=document.querySelector('link[rel="icon"]');if(ei)ei.href=Qn;else{const t=document.createElement("link");t.rel="icon",t.href=Qn,document.head.appendChild(t)}const Jf=wc();var ti,ri,si,ai,ni,ii;for(const t of Jf){const e=((ti=t.src)==null?void 0:ti.trim())||"",r=((ri=t.content)==null?void 0:ri.trim())||"",a=((si=t.id)==null?void 0:si.trim())||"";if(!e&&!r||a&&document.querySelector(`script[data-orbitchat-startup-script-id="${a}"]`)||Array.from(document.querySelectorAll("script[data-orbitchat-startup-script]")).some(o=>{const l=e&&o.dataset.orbitchatStartupScriptSrc===e,c=r&&(o.textContent||"").trim()===r;return!!(l||c)}))continue;const i=document.createElement("script");e&&(i.src=e),r&&(i.text=r),i.async=t.async??!0,t.defer!==void 0&&(i.defer=t.defer),(ai=t.type)!=null&&ai.trim()&&(i.type=t.type.trim()),(ni=t.integrity)!=null&&ni.trim()&&(i.integrity=t.integrity.trim()),t.crossOrigin&&(i.crossOrigin=t.crossOrigin),(ii=t.referrerPolicy)!=null&&ii.trim()&&(i.referrerPolicy=t.referrerPolicy.trim()),i.dataset.orbitchatStartupScript="true",a&&(i.dataset.orbitchatStartupScriptId=a),e&&(i.dataset.orbitchatStartupScriptSrc=e),document.head.appendChild(i)}D("🚀 AI Chat Application started");D(`📱 App Version: v${Pa}`);No.createRoot(document.getElementById("root")).render(n.jsx(g.StrictMode,{children:n.jsx(Yf,{children:n.jsx(Gf,{})})}));export{Cl as r,Le as u};
|