orbitchat 3.10.5 → 3.10.6
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidRenderer-DNbuWll0.js","assets/vendor-markdown-CQ_RitqP.js","assets/vendor-syntax-Bg-E9hW_.js","assets/purify.es-D6gMnemd.js","assets/isPrototype-DezZrpQP.js","assets/SVGRenderer-DAIMVJgr.js","assets/ChartRenderer-
|
|
2
|
-
var fx=Object.defineProperty;var mx=(
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MermaidRenderer-DNbuWll0.js","assets/vendor-markdown-CQ_RitqP.js","assets/vendor-syntax-Bg-E9hW_.js","assets/purify.es-D6gMnemd.js","assets/isPrototype-DezZrpQP.js","assets/SVGRenderer-DAIMVJgr.js","assets/ChartRenderer-DyMx9C0M.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/vendor-react-C3O77mRn.js","assets/vendor-auth-CrXMNoGZ.js","assets/MusicRenderer-DW6lysGY.js","assets/papaparse.min-CdRM_ppG.js","assets/docx-preview-C0UevYcE.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var fx=Object.defineProperty;var mx=(s,l,i)=>l in s?fx(s,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[l]=i;var ca=(s,l,i)=>mx(s,typeof l!="symbol"?l+"":l,i);import{a as hx,r as g,j as u,k as fd,R as Tn,M as px,b as ap,d as gx,e as xx}from"./vendor-markdown-CQ_RitqP.js";import{r as Jp}from"./vendor-react-C3O77mRn.js";import{_ as En,h as bx}from"./vendor-syntax-Bg-E9hW_.js";import{u as md,a as hd,b as yx,P as vx,M as wx,A as Sx}from"./vendor-auth-CrXMNoGZ.js";(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const d of document.querySelectorAll('link[rel="modulepreload"]'))c(d);new MutationObserver(d=>{for(const f of d)if(f.type==="childList")for(const h of f.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&c(h)}).observe(document,{childList:!0,subtree:!0});function i(d){const f={};return d.integrity&&(f.integrity=d.integrity),d.referrerPolicy&&(f.referrerPolicy=d.referrerPolicy),d.crossOrigin==="use-credentials"?f.credentials="include":d.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function c(d){if(d.ep)return;d.ep=!0;const f=i(d);fetch(d.href,f)}})();var Qu={exports:{}},ai={},Zu={exports:{}},Ku={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* scheduler.production.js
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@ var fx=Object.defineProperty;var mx=(r,l,i)=>l in r?fx(r,l,{enumerable:!0,config
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var np;function kx(){return np||(np=1,(function(
|
|
10
|
+
*/var np;function kx(){return np||(np=1,(function(s){function l(E,V){var H=E.length;E.push(V);e:for(;0<H;){var P=H-1>>>1,ce=E[P];if(0<d(ce,V))E[P]=V,E[H]=ce,H=P;else break e}}function i(E){return E.length===0?null:E[0]}function c(E){if(E.length===0)return null;var V=E[0],H=E.pop();if(H!==V){E[0]=H;e:for(var P=0,ce=E.length,xe=ce>>>1;P<xe;){var pe=2*(P+1)-1,F=E[pe],me=pe+1,ue=E[me];if(0>d(F,H))me<ce&&0>d(ue,F)?(E[P]=ue,E[me]=H,P=me):(E[P]=F,E[pe]=H,P=pe);else if(me<ce&&0>d(ue,H))E[P]=ue,E[me]=H,P=me;else break e}}return V}function d(E,V){var H=E.sortIndex-V.sortIndex;return H!==0?H:E.id-V.id}if(s.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;s.unstable_now=function(){return f.now()}}else{var h=Date,p=h.now();s.unstable_now=function(){return h.now()-p}}var x=[],v=[],b=1,w=null,k=3,S=!1,j=!1,_=!1,z=!1,$=typeof setTimeout=="function"?setTimeout:null,ee=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;function R(E){for(var V=i(v);V!==null;){if(V.callback===null)c(v);else if(V.startTime<=E)c(v),V.sortIndex=V.expirationTime,l(x,V);else break;V=i(v)}}function q(E){if(_=!1,R(E),!j)if(i(x)!==null)j=!0,N||(N=!0,fe());else{var V=i(v);V!==null&&oe(q,V.startTime-E)}}var N=!1,X=-1,U=5,Q=-1;function I(){return z?!0:!(s.unstable_now()-Q<U)}function ae(){if(z=!1,N){var E=s.unstable_now();Q=E;var V=!0;try{e:{j=!1,_&&(_=!1,ee(X),X=-1),S=!0;var H=k;try{t:{for(R(E),w=i(x);w!==null&&!(w.expirationTime>E&&I());){var P=w.callback;if(typeof P=="function"){w.callback=null,k=w.priorityLevel;var ce=P(w.expirationTime<=E);if(E=s.unstable_now(),typeof ce=="function"){w.callback=ce,R(E),V=!0;break t}w===i(x)&&c(x),R(E)}else c(x);w=i(x)}if(w!==null)V=!0;else{var xe=i(v);xe!==null&&oe(q,xe.startTime-E),V=!1}}break e}finally{w=null,k=H,S=!1}V=void 0}}finally{V?fe():N=!1}}}var fe;if(typeof Y=="function")fe=function(){Y(ae)};else if(typeof MessageChannel<"u"){var Ce=new MessageChannel,te=Ce.port2;Ce.port1.onmessage=ae,fe=function(){te.postMessage(null)}}else fe=function(){$(ae,0)};function oe(E,V){X=$(function(){E(s.unstable_now())},V)}s.unstable_IdlePriority=5,s.unstable_ImmediatePriority=1,s.unstable_LowPriority=4,s.unstable_NormalPriority=3,s.unstable_Profiling=null,s.unstable_UserBlockingPriority=2,s.unstable_cancelCallback=function(E){E.callback=null},s.unstable_forceFrameRate=function(E){0>E||125<E?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):U=0<E?Math.floor(1e3/E):5},s.unstable_getCurrentPriorityLevel=function(){return k},s.unstable_next=function(E){switch(k){case 1:case 2:case 3:var V=3;break;default:V=k}var H=k;k=V;try{return E()}finally{k=H}},s.unstable_requestPaint=function(){z=!0},s.unstable_runWithPriority=function(E,V){switch(E){case 1:case 2:case 3:case 4:case 5:break;default:E=3}var H=k;k=E;try{return V()}finally{k=H}},s.unstable_scheduleCallback=function(E,V,H){var P=s.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?P+H:P):H=P,E){case 1:var ce=-1;break;case 2:ce=250;break;case 5:ce=1073741823;break;case 4:ce=1e4;break;default:ce=5e3}return ce=H+ce,E={id:b++,callback:V,priorityLevel:E,startTime:H,expirationTime:ce,sortIndex:-1},H>P?(E.sortIndex=H,l(v,E),i(x)===null&&E===i(v)&&(_?(ee(X),X=-1):_=!0,oe(q,H-P))):(E.sortIndex=ce,l(x,E),j||S||(j=!0,N||(N=!0,fe()))),E},s.unstable_shouldYield=I,s.unstable_wrapCallback=function(E){var V=k;return function(){var H=k;k=V;try{return E.apply(this,arguments)}finally{k=H}}}})(Ku)),Ku}var lp;function _x(){return lp||(lp=1,Zu.exports=kx()),Zu.exports}/**
|
|
11
11
|
* @license React
|
|
12
12
|
* react-dom-client.production.js
|
|
13
13
|
*
|
|
@@ -15,20 +15,20 @@ var fx=Object.defineProperty;var mx=(r,l,i)=>l in r?fx(r,l,{enumerable:!0,config
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var
|
|
18
|
+
*/var sp;function Ax(){if(sp)return ai;sp=1;var s=_x(),l=hx(),i=Jp();function c(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)t+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function d(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function f(e){var t=e,a=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(a=t.return),e=t.return;while(e)}return t.tag===3?a:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function x(e){if(f(e)!==e)throw Error(c(188))}function v(e){var t=e.alternate;if(!t){if(t=f(e),t===null)throw Error(c(188));return t!==e?null:e}for(var a=e,n=t;;){var r=a.return;if(r===null)break;var o=r.alternate;if(o===null){if(n=r.return,n!==null){a=n;continue}break}if(r.child===o.child){for(o=r.child;o;){if(o===a)return x(r),e;if(o===n)return x(r),t;o=o.sibling}throw Error(c(188))}if(a.return!==n.return)a=r,n=o;else{for(var m=!1,y=r.child;y;){if(y===a){m=!0,a=r,n=o;break}if(y===n){m=!0,n=r,a=o;break}y=y.sibling}if(!m){for(y=o.child;y;){if(y===a){m=!0,a=o,n=r;break}if(y===n){m=!0,n=o,a=r;break}y=y.sibling}if(!m)throw Error(c(189))}}if(a.alternate!==n)throw Error(c(190))}if(a.tag!==3)throw Error(c(188));return a.stateNode.current===a?e:t}function b(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=b(e),t!==null)return t;e=e.sibling}return null}var w=Object.assign,k=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),X=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),I=Symbol.for("react.memo_cache_sentinel"),ae=Symbol.iterator;function fe(e){return e===null||typeof e!="object"?null:(e=ae&&e[ae]||e["@@iterator"],typeof e=="function"?e:null)}var Ce=Symbol.for("react.client.reference");function te(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case _:return"Fragment";case $:return"Profiler";case z:return"StrictMode";case q:return"Suspense";case N:return"SuspenseList";case Q:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case Y:return e.displayName||"Context";case ee:return(e._context.displayName||"Context")+".Consumer";case R:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case X:return t=e.displayName||null,t!==null?t:te(e.type)||"Memo";case U:t=e._payload,e=e._init;try{return te(e(t))}catch{}}return null}var oe=Array.isArray,E=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,H={pending:!1,data:null,method:null,action:null},P=[],ce=-1;function xe(e){return{current:e}}function pe(e){0>ce||(e.current=P[ce],P[ce]=null,ce--)}function F(e,t){ce++,P[ce]=e.current,e.current=t}var me=xe(null),ue=xe(null),de=xe(null),we=xe(null);function W(e,t){switch(F(de,t),F(ue,e),F(me,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ah(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ah(t),e=Ch(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}pe(me),F(me,e)}function re(){pe(me),pe(ue),pe(de)}function be(e){e.memoizedState!==null&&F(we,e);var t=me.current,a=Ch(t,e.type);t!==a&&(F(ue,e),F(me,a))}function ke(e){ue.current===e&&(pe(me),pe(ue)),we.current===e&&(pe(we),Pr._currentValue=H)}var ge,ze;function Ue(e){if(ge===void 0)try{throw Error()}catch(a){var t=a.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||"",ze=-1<a.stack.indexOf(`
|
|
19
19
|
at`)?" (<anonymous>)":-1<a.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
20
|
-
`+ge+e+ze}var Fe=!1;function je(e,t){if(!e||Fe)return"";Fe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var n={DetermineComponentFrameRoot:function(){try{if(t){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(B){var O=B}Reflect.construct(e,[],K)}else{try{K.call()}catch(B){O=B}e.call(K.prototype)}}else{try{throw Error()}catch(B){O=B}(K=e())&&typeof K.catch=="function"&&K.catch(function(){})}}catch(B){if(B&&O&&typeof B.stack=="string")return[B.stack,O.stack]}return[null,null]}};n.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var
|
|
20
|
+
`+ge+e+ze}var Fe=!1;function je(e,t){if(!e||Fe)return"";Fe=!0;var a=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var n={DetermineComponentFrameRoot:function(){try{if(t){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(B){var O=B}Reflect.construct(e,[],K)}else{try{K.call()}catch(B){O=B}e.call(K.prototype)}}else{try{throw Error()}catch(B){O=B}(K=e())&&typeof K.catch=="function"&&K.catch(function(){})}}catch(B){if(B&&O&&typeof B.stack=="string")return[B.stack,O.stack]}return[null,null]}};n.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var r=Object.getOwnPropertyDescriptor(n.DetermineComponentFrameRoot,"name");r&&r.configurable&&Object.defineProperty(n.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var o=n.DetermineComponentFrameRoot(),m=o[0],y=o[1];if(m&&y){var A=m.split(`
|
|
21
21
|
`),L=y.split(`
|
|
22
|
-
`);for(
|
|
23
|
-
`+A[n].replace(" at new "," at ");return e.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",e.displayName)),G}while(1<=n&&0<=
|
|
22
|
+
`);for(r=n=0;n<A.length&&!A[n].includes("DetermineComponentFrameRoot");)n++;for(;r<L.length&&!L[r].includes("DetermineComponentFrameRoot");)r++;if(n===A.length||r===L.length)for(n=A.length-1,r=L.length-1;1<=n&&0<=r&&A[n]!==L[r];)r--;for(;1<=n&&0<=r;n--,r--)if(A[n]!==L[r]){if(n!==1||r!==1)do if(n--,r--,0>r||A[n]!==L[r]){var G=`
|
|
23
|
+
`+A[n].replace(" at new "," at ");return e.displayName&&G.includes("<anonymous>")&&(G=G.replace("<anonymous>",e.displayName)),G}while(1<=n&&0<=r);break}}}finally{Fe=!1,Error.prepareStackTrace=a}return(a=e?e.displayName||e.name:"")?Ue(a):""}function Xe(e,t){switch(e.tag){case 26:case 27:case 5:return Ue(e.type);case 16:return Ue("Lazy");case 13:return e.child!==t&&t!==null?Ue("Suspense Fallback"):Ue("Suspense");case 19:return Ue("SuspenseList");case 0:case 15:return je(e.type,!1);case 11:return je(e.type.render,!1);case 1:return je(e.type,!0);case 31:return Ue("Activity");default:return""}}function et(e){try{var t="",a=null;do t+=Xe(e,a),a=e,e=e.return;while(e);return t}catch(n){return`
|
|
24
24
|
Error generating stack: `+n.message+`
|
|
25
|
-
`+n.stack}}var Bt=Object.prototype.hasOwnProperty,xt=r.unstable_scheduleCallback,ie=r.unstable_cancelCallback,Ne=r.unstable_shouldYield,Nt=r.unstable_requestPaint,Oe=r.unstable_now,Vt=r.unstable_getCurrentPriorityLevel,da=r.unstable_ImmediatePriority,Xt=r.unstable_UserBlockingPriority,ea=r.unstable_NormalPriority,pn=r.unstable_LowPriority,en=r.unstable_IdlePriority,ta=r.log,gn=r.unstable_setDisableYieldValue,Tt=null,gt=null;function Ht(e){if(typeof ta=="function"&&gn(e),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(Tt,e)}catch{}}var _e=Math.clz32?Math.clz32:Ye,Sa=Math.log,Te=Math.LN2;function Ye(e){return e>>>=0,e===0?32:31-(Sa(e)/Te|0)|0}var bt=256,it=262144,Ae=4194304;function la(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Mn(e,t,a){var n=e.pendingLanes;if(n===0)return 0;var s=0,o=e.suspendedLanes,m=e.pingedLanes;e=e.warmLanes;var y=n&134217727;return y!==0?(n=y&~o,n!==0?s=la(n):(m&=y,m!==0?s=la(m):a||(a=y&~e,a!==0&&(s=la(a))))):(y=n&~o,y!==0?s=la(y):m!==0?s=la(m):a||(a=n&~e,a!==0&&(s=la(a)))),s===0?0:t!==0&&t!==s&&(t&o)===0&&(o=s&-s,a=t&-t,o>=a||o===32&&(a&4194048)!==0)?t:s}function ka(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function tl(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $l(){var e=Ae;return Ae<<=1,(Ae&62914560)===0&&(Ae=4194304),e}function _a(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function zn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Aa(e,t,a,n,s,o){var m=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var y=e.entanglements,A=e.expirationTimes,L=e.hiddenUpdates;for(a=m&~a;0<a;){var G=31-_e(a),K=1<<G;y[G]=0,A[G]=-1;var O=L[G];if(O!==null)for(L[G]=null,G=0;G<O.length;G++){var B=O[G];B!==null&&(B.lane&=-536870913)}a&=~K}n!==0&&al(e,n,0),o!==0&&s===0&&e.tag!==0&&(e.suspendedLanes|=o&~(m&~t))}function al(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var n=31-_e(t);e.entangledLanes|=t,e.entanglements[n]=e.entanglements[n]|1073741824|a&261930}function fr(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var n=31-_e(a),s=1<<n;s&t|e[n]&t&&(e[n]|=t),a&=~s}}function ql(e,t){var a=t&-t;return a=(a&42)!==0?1:tn(a),(a&(e.suspendedLanes|t))!==0?0:a}function tn(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Dn(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function an(){var e=V.p;return e!==0?e:(e=window.event,e===void 0?32:Zh(e.type))}function xn(e,t){var a=V.p;try{return V.p=e,t()}finally{V.p=a}}var Yt=Math.random().toString(36).slice(2),Et="__reactFiber$"+Yt,At="__reactProps$"+Yt,fa="__reactContainer$"+Yt,Bl="__reactEvents$"+Yt,Ft="__reactListeners$"+Yt,mr="__reactHandles$"+Yt,bn="__reactResources$"+Yt,yn="__reactMarker$"+Yt;function Ca(e){delete e[Et],delete e[At],delete e[Bl],delete e[Ft],delete e[mr]}function re(e){var t=e[Et];if(t)return t;for(var a=e.parentNode;a;){if(t=a[fa]||a[Et]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=Dh(e);e!==null;){if(a=e[Et])return a;e=Dh(e)}return t}e=a,a=e.parentNode}return null}function qe(e){if(e=e[Et]||e[fa]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function he(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(c(33))}function tt(e){var t=e[bn];return t||(t=e[bn]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Ke(e){e[yn]=!0}var nn=new Set,Ln={};function ln(e,t){Rn(e,t),Rn(e+"Capture",t)}function Rn(e,t){for(Ln[e]=t,e=0;e<t.length;e++)nn.add(t[e])}var os=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),nl={},hr={};function ja(e){return Bt.call(hr,e)?!0:Bt.call(nl,e)?!1:os.test(e)?hr[e]=!0:(nl[e]=!0,!1)}function pr(e,t,a){if(ja(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var n=t.toLowerCase().slice(0,5);if(n!=="data-"&&n!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function ma(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Na(e,t,a,n){if(n===null)e.removeAttribute(a);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+n)}}function ha(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function fi(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Hl(e,t,a){var n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(m){a=""+m,o.call(this,m)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return a},setValue:function(m){a=""+m},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function gr(e){if(!e._valueTracker){var t=fi(e)?"checked":"value";e._valueTracker=Hl(e,t,""+e[t])}}function xr(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),n="";return e&&(n=fi(e)?e.checked?"true":"false":e.value),e=n,e!==a?(t.setValue(e),!0):!1}function br(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Ko=/[\n"\\]/g;function ra(e){return e.replace(Ko,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function cs(e,t,a,n,s,o,m,y){e.name="",m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"?e.type=m:e.removeAttribute("type"),t!=null?m==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+ha(t)):e.value!==""+ha(t)&&(e.value=""+ha(t)):m!=="submit"&&m!=="reset"||e.removeAttribute("value"),t!=null?rn(e,m,ha(t)):a!=null?rn(e,m,ha(a)):n!=null&&e.removeAttribute("value"),s==null&&o!=null&&(e.defaultChecked=!!o),s!=null&&(e.checked=s&&typeof s!="function"&&typeof s!="symbol"),y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?e.name=""+ha(y):e.removeAttribute("name")}function us(e,t,a,n,s,o,m,y){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(e.type=o),t!=null||a!=null){if(!(o!=="submit"&&o!=="reset"||t!=null)){gr(e);return}a=a!=null?""+ha(a):"",t=t!=null?""+ha(t):a,y||t===e.value||(e.value=t),e.defaultValue=t}n=n??s,n=typeof n!="function"&&typeof n!="symbol"&&!!n,e.checked=y?e.checked:!!n,e.defaultChecked=!!n,m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(e.name=m),gr(e)}function rn(e,t,a){t==="number"&&br(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function ll(e,t,a,n){if(e=e.options,t){t={};for(var s=0;s<a.length;s++)t["$"+a[s]]=!0;for(a=0;a<e.length;a++)s=t.hasOwnProperty("$"+e[a].value),e[a].selected!==s&&(e[a].selected=s),s&&n&&(e[a].defaultSelected=!0)}else{for(a=""+ha(a),t=null,s=0;s<e.length;s++){if(e[s].value===a){e[s].selected=!0,n&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function ds(e,t,a){if(t!=null&&(t=""+ha(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+ha(a):""}function sn(e,t,a,n){if(t==null){if(n!=null){if(a!=null)throw Error(c(92));if(oe(n)){if(1<n.length)throw Error(c(93));n=n[0]}a=n}a==null&&(a=""),t=a}a=ha(t),e.defaultValue=a,n=e.textContent,n===a&&n!==""&&n!==null&&(e.value=n),gr(e)}function rl(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var mi=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function fs(e,t,a){var n=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?n?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":n?e.setProperty(t,a):typeof a!="number"||a===0||mi.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function sl(e,t,a){if(t!=null&&typeof t!="object")throw Error(c(62));if(e=e.style,a!=null){for(var n in a)!a.hasOwnProperty(n)||t!=null&&t.hasOwnProperty(n)||(n.indexOf("--")===0?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="");for(var s in t)n=t[s],t.hasOwnProperty(s)&&a[s]!==n&&fs(e,s,n)}else for(var o in t)t.hasOwnProperty(o)&&fs(e,o,t[o])}function Fl(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var sa=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),yr=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function il(e){return yr.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Fa(){}var wt=null;function vr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var on=null,Ia=null;function ms(e){var t=qe(e);if(t&&(e=t.stateNode)){var a=e[At]||null;e:switch(e=t.stateNode,t.type){case"input":if(cs(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+ra(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var n=a[t];if(n!==e&&n.form===e.form){var s=n[At]||null;if(!s)throw Error(c(90));cs(n,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name)}}for(t=0;t<a.length;t++)n=a[t],n.form===e.form&&xr(n)}break e;case"textarea":ds(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&ll(e,!!a.multiple,t,!1)}}}var ol=!1;function wr(e,t,a){if(ol)return e(t,a);ol=!0;try{var n=e(t);return n}finally{if(ol=!1,(on!==null||Ia!==null)&&(Pi(),on&&(t=on,e=Ia,Ia=on=null,ms(t),e)))for(t=0;t<e.length;t++)ms(e[t])}}function vn(e,t){var a=e.stateNode;if(a===null)return null;var n=a[At]||null;if(n===null)return null;a=n[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(e=e.type,n=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!n;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(c(231,t,typeof a));return a}var Ta=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Il=!1;if(Ta)try{var wn={};Object.defineProperty(wn,"passive",{get:function(){Il=!0}}),window.addEventListener("test",wn,wn),window.removeEventListener("test",wn,wn)}catch{Il=!1}var Ea=null,Sr=null,Gl=null;function Vl(){if(Gl)return Gl;var e,t=Sr,a=t.length,n,s="value"in Ea?Ea.value:Ea.textContent,o=s.length;for(e=0;e<a&&t[e]===s[e];e++);var m=a-e;for(n=1;n<=m&&t[a-n]===s[o-n];n++);return Gl=s.slice(e,1<n?1-n:void 0)}function kr(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function _r(){return!0}function hi(){return!1}function aa(e){function t(a,n,s,o,m){this._reactName=a,this._targetInst=s,this.type=n,this.nativeEvent=o,this.target=m,this.currentTarget=null;for(var y in e)e.hasOwnProperty(y)&&(a=e[y],this[y]=a?a(o):o[y]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?_r:hi,this.isPropagationStopped=hi,this}return w(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=_r)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=_r)},persist:function(){},isPersistent:_r}),t}var Un={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xl=aa(Un),Sn=w({},Un,{view:0,detail:0}),hs=aa(Sn),ps,gs,Yl,Ar=w({},Sn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:cn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Yl&&(Yl&&e.type==="mousemove"?(ps=e.screenX-Yl.screenX,gs=e.screenY-Yl.screenY):gs=ps=0,Yl=e),ps)},movementY:function(e){return"movementY"in e?e.movementY:gs}}),xs=aa(Ar),Td=w({},Ar,{dataTransfer:0}),bs=aa(Td),On=w({},Sn,{relatedTarget:0}),ys=aa(On),Jo=w({},Un,{animationName:0,elapsedTime:0,pseudoElement:0}),pi=aa(Jo),C=w({},Un,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ne=aa(C),Ee=w({},Un,{data:0}),$e=aa(Ee),rt={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Qt={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},ut={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function at(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ut[e])?!!t[e]:!1}function cn(){return at}var Ma=w({},Sn,{key:function(e){if(e.key){var t=rt[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=kr(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Qt[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:cn,charCode:function(e){return e.type==="keypress"?kr(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?kr(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Cr=aa(Ma),jr=w({},Ar,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cl=aa(jr),gi=w({},Sn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:cn}),ia=aa(gi),Ga=w({},Un,{propertyName:0,elapsedTime:0,pseudoElement:0}),un=aa(Ga),Zt=w({},Ar,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Po=aa(Zt),Wo=w({},Un,{newState:0,oldState:0}),ec=aa(Wo),za=[9,13,27,32],Va=Ta&&"CompositionEvent"in window,It=null;Ta&&"documentMode"in document&&(It=document.documentMode);var Ql=Ta&&"TextEvent"in window&&!It,Ed=Ta&&(!Va||It&&8<It&&11>=It),Md=" ",zd=!1;function Dd(e,t){switch(e){case"keyup":return za.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ld(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Nr=!1;function Ug(e,t){switch(e){case"compositionend":return Ld(t);case"keypress":return t.which!==32?null:(zd=!0,Md);case"textInput":return e=t.data,e===Md&&zd?null:e;default:return null}}function Og(e,t){if(Nr)return e==="compositionend"||!Va&&Dd(e,t)?(e=Vl(),Gl=Sr=Ea=null,Nr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ed&&t.locale!=="ko"?null:t.data;default:return null}}var $g={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Rd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!$g[e.type]:t==="textarea"}function Ud(e,t,a,n){on?Ia?Ia.push(n):Ia=[n]:on=n,t=ro(t,"onChange"),0<t.length&&(a=new Xl("onChange","change",null,a,n),e.push({event:a,listeners:t}))}var vs=null,ws=null;function qg(e){yh(e,0)}function xi(e){var t=he(e);if(xr(t))return e}function Od(e,t){if(e==="change")return t}var $d=!1;if(Ta){var tc;if(Ta){var ac="oninput"in document;if(!ac){var qd=document.createElement("div");qd.setAttribute("oninput","return;"),ac=typeof qd.oninput=="function"}tc=ac}else tc=!1;$d=tc&&(!document.documentMode||9<document.documentMode)}function Bd(){vs&&(vs.detachEvent("onpropertychange",Hd),ws=vs=null)}function Hd(e){if(e.propertyName==="value"&&xi(ws)){var t=[];Ud(t,ws,e,vr(e)),wr(qg,t)}}function Bg(e,t,a){e==="focusin"?(Bd(),vs=t,ws=a,vs.attachEvent("onpropertychange",Hd)):e==="focusout"&&Bd()}function Hg(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return xi(ws)}function Fg(e,t){if(e==="click")return xi(t)}function Ig(e,t){if(e==="input"||e==="change")return xi(t)}function Gg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Da=typeof Object.is=="function"?Object.is:Gg;function Ss(e,t){if(Da(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),n=Object.keys(t);if(a.length!==n.length)return!1;for(n=0;n<a.length;n++){var s=a[n];if(!Bt.call(t,s)||!Da(e[s],t[s]))return!1}return!0}function Fd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Id(e,t){var a=Fd(e);e=0;for(var n;a;){if(a.nodeType===3){if(n=e+a.textContent.length,e<=t&&n>=t)return{node:a,offset:t-e};e=n}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Fd(a)}}function Gd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Gd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=br(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=br(e.document)}return t}function nc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Vg=Ta&&"documentMode"in document&&11>=document.documentMode,Tr=null,lc=null,ks=null,rc=!1;function Xd(e,t,a){var n=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;rc||Tr==null||Tr!==br(n)||(n=Tr,"selectionStart"in n&&nc(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),ks&&Ss(ks,n)||(ks=n,n=ro(lc,"onSelect"),0<n.length&&(t=new Xl("onSelect","select",null,t,a),e.push({event:t,listeners:n}),t.target=Tr)))}function Zl(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var Er={animationend:Zl("Animation","AnimationEnd"),animationiteration:Zl("Animation","AnimationIteration"),animationstart:Zl("Animation","AnimationStart"),transitionrun:Zl("Transition","TransitionRun"),transitionstart:Zl("Transition","TransitionStart"),transitioncancel:Zl("Transition","TransitionCancel"),transitionend:Zl("Transition","TransitionEnd")},sc={},Yd={};Ta&&(Yd=document.createElement("div").style,"AnimationEvent"in window||(delete Er.animationend.animation,delete Er.animationiteration.animation,delete Er.animationstart.animation),"TransitionEvent"in window||delete Er.transitionend.transition);function Kl(e){if(sc[e])return sc[e];if(!Er[e])return e;var t=Er[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in Yd)return sc[e]=t[a];return e}var Qd=Kl("animationend"),Zd=Kl("animationiteration"),Kd=Kl("animationstart"),Xg=Kl("transitionrun"),Yg=Kl("transitionstart"),Qg=Kl("transitioncancel"),Jd=Kl("transitionend"),Pd=new Map,ic="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");ic.push("scrollEnd");function dn(e,t){Pd.set(e,t),ln(t,[e])}var bi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Xa=[],Mr=0,oc=0;function yi(){for(var e=Mr,t=oc=Mr=0;t<e;){var a=Xa[t];Xa[t++]=null;var n=Xa[t];Xa[t++]=null;var s=Xa[t];Xa[t++]=null;var o=Xa[t];if(Xa[t++]=null,n!==null&&s!==null){var m=n.pending;m===null?s.next=s:(s.next=m.next,m.next=s),n.pending=s}o!==0&&Wd(a,s,o)}}function vi(e,t,a,n){Xa[Mr++]=e,Xa[Mr++]=t,Xa[Mr++]=a,Xa[Mr++]=n,oc|=n,e.lanes|=n,e=e.alternate,e!==null&&(e.lanes|=n)}function cc(e,t,a,n){return vi(e,t,a,n),wi(e)}function Jl(e,t){return vi(e,null,null,t),wi(e)}function Wd(e,t,a){e.lanes|=a;var n=e.alternate;n!==null&&(n.lanes|=a);for(var s=!1,o=e.return;o!==null;)o.childLanes|=a,n=o.alternate,n!==null&&(n.childLanes|=a),o.tag===22&&(e=o.stateNode,e===null||e._visibility&1||(s=!0)),e=o,o=o.return;return e.tag===3?(o=e.stateNode,s&&t!==null&&(s=31-_e(a),e=o.hiddenUpdates,n=e[s],n===null?e[s]=[t]:n.push(t),t.lane=a|536870912),o):null}function wi(e){if(50<Vs)throw Vs=0,bu=null,Error(c(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var zr={};function Zg(e,t,a,n){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function La(e,t,a,n){return new Zg(e,t,a,n)}function uc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $n(e,t){var a=e.alternate;return a===null?(a=La(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function ef(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Si(e,t,a,n,s,o){var m=0;if(n=e,typeof e=="function")uc(e)&&(m=1);else if(typeof e=="string")m=ex(e,a,me.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Q:return e=La(31,a,t,s),e.elementType=Q,e.lanes=o,e;case _:return Pl(a.children,s,o,t);case z:m=8,s|=24;break;case $:return e=La(12,a,t,s|2),e.elementType=$,e.lanes=o,e;case q:return e=La(13,a,t,s),e.elementType=q,e.lanes=o,e;case N:return e=La(19,a,t,s),e.elementType=N,e.lanes=o,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Y:m=10;break e;case ee:m=9;break e;case R:m=11;break e;case X:m=14;break e;case U:m=16,n=null;break e}m=29,a=Error(c(130,e===null?"null":typeof e,"")),n=null}return t=La(m,a,t,s),t.elementType=e,t.type=n,t.lanes=o,t}function Pl(e,t,a,n){return e=La(7,e,n,t),e.lanes=a,e}function dc(e,t,a){return e=La(6,e,null,t),e.lanes=a,e}function tf(e){var t=La(18,null,null,0);return t.stateNode=e,t}function fc(e,t,a){return t=La(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var af=new WeakMap;function Ya(e,t){if(typeof e=="object"&&e!==null){var a=af.get(e);return a!==void 0?a:(t={value:e,source:t,stack:et(t)},af.set(e,t),t)}return{value:e,source:t,stack:et(t)}}var Dr=[],Lr=0,ki=null,_s=0,Qa=[],Za=0,ul=null,kn=1,_n="";function qn(e,t){Dr[Lr++]=_s,Dr[Lr++]=ki,ki=e,_s=t}function nf(e,t,a){Qa[Za++]=kn,Qa[Za++]=_n,Qa[Za++]=ul,ul=e;var n=kn;e=_n;var s=32-_e(n)-1;n&=~(1<<s),a+=1;var o=32-_e(t)+s;if(30<o){var m=s-s%5;o=(n&(1<<m)-1).toString(32),n>>=m,s-=m,kn=1<<32-_e(t)+s|a<<s|n,_n=o+e}else kn=1<<o|a<<s|n,_n=e}function mc(e){e.return!==null&&(qn(e,1),nf(e,1,0))}function hc(e){for(;e===ki;)ki=Dr[--Lr],Dr[Lr]=null,_s=Dr[--Lr],Dr[Lr]=null;for(;e===ul;)ul=Qa[--Za],Qa[Za]=null,_n=Qa[--Za],Qa[Za]=null,kn=Qa[--Za],Qa[Za]=null}function lf(e,t){Qa[Za++]=kn,Qa[Za++]=_n,Qa[Za++]=ul,kn=t.id,_n=t.overflow,ul=e}var Kt=null,yt=null,We=!1,dl=null,Ka=!1,pc=Error(c(519));function fl(e){var t=Error(c(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw As(Ya(t,e)),pc}function rf(e){var t=e.stateNode,a=e.type,n=e.memoizedProps;switch(t[Et]=e,t[At]=n,a){case"dialog":Ze("cancel",t),Ze("close",t);break;case"iframe":case"object":case"embed":Ze("load",t);break;case"video":case"audio":for(a=0;a<Ys.length;a++)Ze(Ys[a],t);break;case"source":Ze("error",t);break;case"img":case"image":case"link":Ze("error",t),Ze("load",t);break;case"details":Ze("toggle",t);break;case"input":Ze("invalid",t),us(t,n.value,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name,!0);break;case"select":Ze("invalid",t);break;case"textarea":Ze("invalid",t),sn(t,n.value,n.defaultValue,n.children)}a=n.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||n.suppressHydrationWarning===!0||kh(t.textContent,a)?(n.popover!=null&&(Ze("beforetoggle",t),Ze("toggle",t)),n.onScroll!=null&&Ze("scroll",t),n.onScrollEnd!=null&&Ze("scrollend",t),n.onClick!=null&&(t.onclick=Fa),t=!0):t=!1,t||fl(e,!0)}function sf(e){for(Kt=e.return;Kt;)switch(Kt.tag){case 5:case 31:case 13:Ka=!1;return;case 27:case 3:Ka=!0;return;default:Kt=Kt.return}}function Rr(e){if(e!==Kt)return!1;if(!We)return sf(e),We=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Du(e.type,e.memoizedProps)),a=!a),a&&yt&&fl(e),sf(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(c(317));yt=zh(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(c(317));yt=zh(e)}else t===27?(t=yt,Cl(e.type)?(e=$u,$u=null,yt=e):yt=t):yt=Kt?Pa(e.stateNode.nextSibling):null;return!0}function Wl(){yt=Kt=null,We=!1}function gc(){var e=dl;return e!==null&&(ba===null?ba=e:ba.push.apply(ba,e),dl=null),e}function As(e){dl===null?dl=[e]:dl.push(e)}var xc=xe(null),er=null,Bn=null;function ml(e,t,a){F(xc,t._currentValue),t._currentValue=a}function Hn(e){e._currentValue=xc.current,pe(xc)}function bc(e,t,a){for(;e!==null;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,n!==null&&(n.childLanes|=t)):n!==null&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===a)break;e=e.return}}function yc(e,t,a,n){var s=e.child;for(s!==null&&(s.return=e);s!==null;){var o=s.dependencies;if(o!==null){var m=s.child;o=o.firstContext;e:for(;o!==null;){var y=o;o=s;for(var A=0;A<t.length;A++)if(y.context===t[A]){o.lanes|=a,y=o.alternate,y!==null&&(y.lanes|=a),bc(o.return,a,e),n||(m=null);break e}o=y.next}}else if(s.tag===18){if(m=s.return,m===null)throw Error(c(341));m.lanes|=a,o=m.alternate,o!==null&&(o.lanes|=a),bc(m,a,e),m=null}else m=s.child;if(m!==null)m.return=s;else for(m=s;m!==null;){if(m===e){m=null;break}if(s=m.sibling,s!==null){s.return=m.return,m=s;break}m=m.return}s=m}}function Ur(e,t,a,n){e=null;for(var s=t,o=!1;s!==null;){if(!o){if((s.flags&524288)!==0)o=!0;else if((s.flags&262144)!==0)break}if(s.tag===10){var m=s.alternate;if(m===null)throw Error(c(387));if(m=m.memoizedProps,m!==null){var y=s.type;Da(s.pendingProps.value,m.value)||(e!==null?e.push(y):e=[y])}}else if(s===we.current){if(m=s.alternate,m===null)throw Error(c(387));m.memoizedState.memoizedState!==s.memoizedState.memoizedState&&(e!==null?e.push(Ps):e=[Ps])}s=s.return}e!==null&&yc(t,e,a,n),t.flags|=262144}function _i(e){for(e=e.firstContext;e!==null;){if(!Da(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function tr(e){er=e,Bn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Jt(e){return of(er,e)}function Ai(e,t){return er===null&&tr(e),of(e,t)}function of(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Bn===null){if(e===null)throw Error(c(308));Bn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Bn=Bn.next=t;return a}var Kg=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},Jg=r.unstable_scheduleCallback,Pg=r.unstable_NormalPriority,Lt={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function vc(){return{controller:new Kg,data:new Map,refCount:0}}function Cs(e){e.refCount--,e.refCount===0&&Jg(Pg,function(){e.controller.abort()})}var js=null,wc=0,Or=0,$r=null;function Wg(e,t){if(js===null){var a=js=[];wc=0,Or=_u(),$r={status:"pending",value:void 0,then:function(n){a.push(n)}}}return wc++,t.then(cf,cf),t}function cf(){if(--wc===0&&js!==null){$r!==null&&($r.status="fulfilled");var e=js;js=null,Or=0,$r=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function e0(e,t){var a=[],n={status:"pending",value:null,reason:null,then:function(s){a.push(s)}};return e.then(function(){n.status="fulfilled",n.value=t;for(var s=0;s<a.length;s++)(0,a[s])(t)},function(s){for(n.status="rejected",n.reason=s,s=0;s<a.length;s++)(0,a[s])(void 0)}),n}var uf=E.S;E.S=function(e,t){Ym=Oe(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Wg(e,t),uf!==null&&uf(e,t)};var ar=xe(null);function Sc(){var e=ar.current;return e!==null?e:ht.pooledCache}function Ci(e,t){t===null?F(ar,ar.current):F(ar,t.pool)}function df(){var e=Sc();return e===null?null:{parent:Lt._currentValue,pool:e}}var qr=Error(c(460)),kc=Error(c(474)),ji=Error(c(542)),Ni={then:function(){}};function ff(e){return e=e.status,e==="fulfilled"||e==="rejected"}function mf(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(Fa,Fa),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,pf(e),e;default:if(typeof t.status=="string")t.then(Fa,Fa);else{if(e=ht,e!==null&&100<e.shellSuspendCounter)throw Error(c(482));e=t,e.status="pending",e.then(function(n){if(t.status==="pending"){var s=t;s.status="fulfilled",s.value=n}},function(n){if(t.status==="pending"){var s=t;s.status="rejected",s.reason=n}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,pf(e),e}throw lr=t,qr}}function nr(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(lr=a,qr):a}}var lr=null;function hf(){if(lr===null)throw Error(c(459));var e=lr;return lr=null,e}function pf(e){if(e===qr||e===ji)throw Error(c(483))}var Br=null,Ns=0;function Ti(e){var t=Ns;return Ns+=1,Br===null&&(Br=[]),mf(Br,e,t)}function Ts(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ei(e,t){throw t.$$typeof===k?Error(c(525)):(e=Object.prototype.toString.call(t),Error(c(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function gf(e){function t(M,T){if(e){var D=M.deletions;D===null?(M.deletions=[T],M.flags|=16):D.push(T)}}function a(M,T){if(!e)return null;for(;T!==null;)t(M,T),T=T.sibling;return null}function n(M){for(var T=new Map;M!==null;)M.key!==null?T.set(M.key,M):T.set(M.index,M),M=M.sibling;return T}function s(M,T){return M=$n(M,T),M.index=0,M.sibling=null,M}function o(M,T,D){return M.index=D,e?(D=M.alternate,D!==null?(D=D.index,D<T?(M.flags|=67108866,T):D):(M.flags|=67108866,T)):(M.flags|=1048576,T)}function m(M){return e&&M.alternate===null&&(M.flags|=67108866),M}function y(M,T,D,Z){return T===null||T.tag!==6?(T=dc(D,M.mode,Z),T.return=M,T):(T=s(T,D),T.return=M,T)}function A(M,T,D,Z){var Me=D.type;return Me===_?G(M,T,D.props.children,Z,D.key):T!==null&&(T.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===U&&nr(Me)===T.type)?(T=s(T,D.props),Ts(T,D),T.return=M,T):(T=Si(D.type,D.key,D.props,null,M.mode,Z),Ts(T,D),T.return=M,T)}function L(M,T,D,Z){return T===null||T.tag!==4||T.stateNode.containerInfo!==D.containerInfo||T.stateNode.implementation!==D.implementation?(T=fc(D,M.mode,Z),T.return=M,T):(T=s(T,D.children||[]),T.return=M,T)}function G(M,T,D,Z,Me){return T===null||T.tag!==7?(T=Pl(D,M.mode,Z,Me),T.return=M,T):(T=s(T,D),T.return=M,T)}function K(M,T,D){if(typeof T=="string"&&T!==""||typeof T=="number"||typeof T=="bigint")return T=dc(""+T,M.mode,D),T.return=M,T;if(typeof T=="object"&&T!==null){switch(T.$$typeof){case S:return D=Si(T.type,T.key,T.props,null,M.mode,D),Ts(D,T),D.return=M,D;case j:return T=fc(T,M.mode,D),T.return=M,T;case U:return T=nr(T),K(M,T,D)}if(oe(T)||fe(T))return T=Pl(T,M.mode,D,null),T.return=M,T;if(typeof T.then=="function")return K(M,Ti(T),D);if(T.$$typeof===Y)return K(M,Ai(M,T),D);Ei(M,T)}return null}function O(M,T,D,Z){var Me=T!==null?T.key:null;if(typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint")return Me!==null?null:y(M,T,""+D,Z);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case S:return D.key===Me?A(M,T,D,Z):null;case j:return D.key===Me?L(M,T,D,Z):null;case U:return D=nr(D),O(M,T,D,Z)}if(oe(D)||fe(D))return Me!==null?null:G(M,T,D,Z,null);if(typeof D.then=="function")return O(M,T,Ti(D),Z);if(D.$$typeof===Y)return O(M,T,Ai(M,D),Z);Ei(M,D)}return null}function B(M,T,D,Z,Me){if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return M=M.get(D)||null,y(T,M,""+Z,Me);if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case S:return M=M.get(Z.key===null?D:Z.key)||null,A(T,M,Z,Me);case j:return M=M.get(Z.key===null?D:Z.key)||null,L(T,M,Z,Me);case U:return Z=nr(Z),B(M,T,D,Z,Me)}if(oe(Z)||fe(Z))return M=M.get(D)||null,G(T,M,Z,Me,null);if(typeof Z.then=="function")return B(M,T,D,Ti(Z),Me);if(Z.$$typeof===Y)return B(M,T,D,Ai(T,Z),Me);Ei(T,Z)}return null}function ve(M,T,D,Z){for(var Me=null,nt=null,Se=T,Ge=T=0,Pe=null;Se!==null&&Ge<D.length;Ge++){Se.index>Ge?(Pe=Se,Se=null):Pe=Se.sibling;var lt=O(M,Se,D[Ge],Z);if(lt===null){Se===null&&(Se=Pe);break}e&&Se&<.alternate===null&&t(M,Se),T=o(lt,T,Ge),nt===null?Me=lt:nt.sibling=lt,nt=lt,Se=Pe}if(Ge===D.length)return a(M,Se),We&&qn(M,Ge),Me;if(Se===null){for(;Ge<D.length;Ge++)Se=K(M,D[Ge],Z),Se!==null&&(T=o(Se,T,Ge),nt===null?Me=Se:nt.sibling=Se,nt=Se);return We&&qn(M,Ge),Me}for(Se=n(Se);Ge<D.length;Ge++)Pe=B(Se,M,Ge,D[Ge],Z),Pe!==null&&(e&&Pe.alternate!==null&&Se.delete(Pe.key===null?Ge:Pe.key),T=o(Pe,T,Ge),nt===null?Me=Pe:nt.sibling=Pe,nt=Pe);return e&&Se.forEach(function(Ml){return t(M,Ml)}),We&&qn(M,Ge),Me}function Re(M,T,D,Z){if(D==null)throw Error(c(151));for(var Me=null,nt=null,Se=T,Ge=T=0,Pe=null,lt=D.next();Se!==null&&!lt.done;Ge++,lt=D.next()){Se.index>Ge?(Pe=Se,Se=null):Pe=Se.sibling;var Ml=O(M,Se,lt.value,Z);if(Ml===null){Se===null&&(Se=Pe);break}e&&Se&&Ml.alternate===null&&t(M,Se),T=o(Ml,T,Ge),nt===null?Me=Ml:nt.sibling=Ml,nt=Ml,Se=Pe}if(lt.done)return a(M,Se),We&&qn(M,Ge),Me;if(Se===null){for(;!lt.done;Ge++,lt=D.next())lt=K(M,lt.value,Z),lt!==null&&(T=o(lt,T,Ge),nt===null?Me=lt:nt.sibling=lt,nt=lt);return We&&qn(M,Ge),Me}for(Se=n(Se);!lt.done;Ge++,lt=D.next())lt=B(Se,M,Ge,lt.value,Z),lt!==null&&(e&<.alternate!==null&&Se.delete(lt.key===null?Ge:lt.key),T=o(lt,T,Ge),nt===null?Me=lt:nt.sibling=lt,nt=lt);return e&&Se.forEach(function(dx){return t(M,dx)}),We&&qn(M,Ge),Me}function mt(M,T,D,Z){if(typeof D=="object"&&D!==null&&D.type===_&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case S:e:{for(var Me=D.key;T!==null;){if(T.key===Me){if(Me=D.type,Me===_){if(T.tag===7){a(M,T.sibling),Z=s(T,D.props.children),Z.return=M,M=Z;break e}}else if(T.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===U&&nr(Me)===T.type){a(M,T.sibling),Z=s(T,D.props),Ts(Z,D),Z.return=M,M=Z;break e}a(M,T);break}else t(M,T);T=T.sibling}D.type===_?(Z=Pl(D.props.children,M.mode,Z,D.key),Z.return=M,M=Z):(Z=Si(D.type,D.key,D.props,null,M.mode,Z),Ts(Z,D),Z.return=M,M=Z)}return m(M);case j:e:{for(Me=D.key;T!==null;){if(T.key===Me)if(T.tag===4&&T.stateNode.containerInfo===D.containerInfo&&T.stateNode.implementation===D.implementation){a(M,T.sibling),Z=s(T,D.children||[]),Z.return=M,M=Z;break e}else{a(M,T);break}else t(M,T);T=T.sibling}Z=fc(D,M.mode,Z),Z.return=M,M=Z}return m(M);case U:return D=nr(D),mt(M,T,D,Z)}if(oe(D))return ve(M,T,D,Z);if(fe(D)){if(Me=fe(D),typeof Me!="function")throw Error(c(150));return D=Me.call(D),Re(M,T,D,Z)}if(typeof D.then=="function")return mt(M,T,Ti(D),Z);if(D.$$typeof===Y)return mt(M,T,Ai(M,D),Z);Ei(M,D)}return typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint"?(D=""+D,T!==null&&T.tag===6?(a(M,T.sibling),Z=s(T,D),Z.return=M,M=Z):(a(M,T),Z=dc(D,M.mode,Z),Z.return=M,M=Z),m(M)):a(M,T)}return function(M,T,D,Z){try{Ns=0;var Me=mt(M,T,D,Z);return Br=null,Me}catch(Se){if(Se===qr||Se===ji)throw Se;var nt=La(29,Se,null,M.mode);return nt.lanes=Z,nt.return=M,nt}finally{}}}var rr=gf(!0),xf=gf(!1),hl=!1;function _c(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ac(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function pl(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function gl(e,t,a){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,(st&2)!==0){var s=n.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),n.pending=t,t=wi(e),Wd(e,null,a),t}return vi(e,n,t,a),wi(e)}function Es(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var n=t.lanes;n&=e.pendingLanes,a|=n,t.lanes=a,fr(e,a)}}function Cc(e,t){var a=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,a===n)){var s=null,o=null;if(a=a.firstBaseUpdate,a!==null){do{var m={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};o===null?s=o=m:o=o.next=m,a=a.next}while(a!==null);o===null?s=o=t:o=o.next=t}else s=o=t;a={baseState:n.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:n.shared,callbacks:n.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var jc=!1;function Ms(){if(jc){var e=$r;if(e!==null)throw e}}function zs(e,t,a,n){jc=!1;var s=e.updateQueue;hl=!1;var o=s.firstBaseUpdate,m=s.lastBaseUpdate,y=s.shared.pending;if(y!==null){s.shared.pending=null;var A=y,L=A.next;A.next=null,m===null?o=L:m.next=L,m=A;var G=e.alternate;G!==null&&(G=G.updateQueue,y=G.lastBaseUpdate,y!==m&&(y===null?G.firstBaseUpdate=L:y.next=L,G.lastBaseUpdate=A))}if(o!==null){var K=s.baseState;m=0,G=L=A=null,y=o;do{var O=y.lane&-536870913,B=O!==y.lane;if(B?(Je&O)===O:(n&O)===O){O!==0&&O===Or&&(jc=!0),G!==null&&(G=G.next={lane:0,tag:y.tag,payload:y.payload,callback:null,next:null});e:{var ve=e,Re=y;O=t;var mt=a;switch(Re.tag){case 1:if(ve=Re.payload,typeof ve=="function"){K=ve.call(mt,K,O);break e}K=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Re.payload,O=typeof ve=="function"?ve.call(mt,K,O):ve,O==null)break e;K=w({},K,O);break e;case 2:hl=!0}}O=y.callback,O!==null&&(e.flags|=64,B&&(e.flags|=8192),B=s.callbacks,B===null?s.callbacks=[O]:B.push(O))}else B={lane:O,tag:y.tag,payload:y.payload,callback:y.callback,next:null},G===null?(L=G=B,A=K):G=G.next=B,m|=O;if(y=y.next,y===null){if(y=s.shared.pending,y===null)break;B=y,y=B.next,B.next=null,s.lastBaseUpdate=B,s.shared.pending=null}}while(!0);G===null&&(A=K),s.baseState=A,s.firstBaseUpdate=L,s.lastBaseUpdate=G,o===null&&(s.shared.lanes=0),wl|=m,e.lanes=m,e.memoizedState=K}}function bf(e,t){if(typeof e!="function")throw Error(c(191,e));e.call(t)}function yf(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)bf(a[e],t)}var Hr=xe(null),Mi=xe(0);function vf(e,t){e=Kn,F(Mi,e),F(Hr,t),Kn=e|t.baseLanes}function Nc(){F(Mi,Kn),F(Hr,Hr.current)}function Tc(){Kn=Mi.current,pe(Hr),pe(Mi)}var Ra=xe(null),Ja=null;function xl(e){var t=e.alternate;F(Mt,Mt.current&1),F(Ra,e),Ja===null&&(t===null||Hr.current!==null||t.memoizedState!==null)&&(Ja=e)}function Ec(e){F(Mt,Mt.current),F(Ra,e),Ja===null&&(Ja=e)}function wf(e){e.tag===22?(F(Mt,Mt.current),F(Ra,e),Ja===null&&(Ja=e)):bl()}function bl(){F(Mt,Mt.current),F(Ra,Ra.current)}function Ua(e){pe(Ra),Ja===e&&(Ja=null),pe(Mt)}var Mt=xe(0);function zi(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Uu(a)||Ou(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Fn=0,Ie=null,dt=null,Rt=null,Di=!1,Fr=!1,sr=!1,Li=0,Ds=0,Ir=null,t0=0;function Ct(){throw Error(c(321))}function Mc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Da(e[a],t[a]))return!1;return!0}function zc(e,t,a,n,s,o){return Fn=o,Ie=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,E.H=e===null||e.memoizedState===null?lm:Yc,sr=!1,o=a(n,s),sr=!1,Fr&&(o=kf(t,a,n,s)),Sf(e),o}function Sf(e){E.H=Us;var t=dt!==null&&dt.next!==null;if(Fn=0,Rt=dt=Ie=null,Di=!1,Ds=0,Ir=null,t)throw Error(c(300));e===null||Ut||(e=e.dependencies,e!==null&&_i(e)&&(Ut=!0))}function kf(e,t,a,n){Ie=e;var s=0;do{if(Fr&&(Ir=null),Ds=0,Fr=!1,25<=s)throw Error(c(301));if(s+=1,Rt=dt=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}E.H=rm,o=t(a,n)}while(Fr);return o}function a0(){var e=E.H,t=e.useState()[0];return t=typeof t.then=="function"?Ls(t):t,e=e.useState()[0],(dt!==null?dt.memoizedState:null)!==e&&(Ie.flags|=1024),t}function Dc(){var e=Li!==0;return Li=0,e}function Lc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function Rc(e){if(Di){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Di=!1}Fn=0,Rt=dt=Ie=null,Fr=!1,Ds=Li=0,Ir=null}function oa(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Rt===null?Ie.memoizedState=Rt=e:Rt=Rt.next=e,Rt}function zt(){if(dt===null){var e=Ie.alternate;e=e!==null?e.memoizedState:null}else e=dt.next;var t=Rt===null?Ie.memoizedState:Rt.next;if(t!==null)Rt=t,dt=e;else{if(e===null)throw Ie.alternate===null?Error(c(467)):Error(c(310));dt=e,e={memoizedState:dt.memoizedState,baseState:dt.baseState,baseQueue:dt.baseQueue,queue:dt.queue,next:null},Rt===null?Ie.memoizedState=Rt=e:Rt=Rt.next=e}return Rt}function Ri(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ls(e){var t=Ds;return Ds+=1,Ir===null&&(Ir=[]),e=mf(Ir,e,t),t=Ie,(Rt===null?t.memoizedState:Rt.next)===null&&(t=t.alternate,E.H=t===null||t.memoizedState===null?lm:Yc),e}function Ui(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ls(e);if(e.$$typeof===Y)return Jt(e)}throw Error(c(438,String(e)))}function Uc(e){var t=null,a=Ie.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var n=Ie.alternate;n!==null&&(n=n.updateQueue,n!==null&&(n=n.memoCache,n!=null&&(t={data:n.data.map(function(s){return s.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=Ri(),Ie.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),n=0;n<e;n++)a[n]=I;return t.index++,a}function In(e,t){return typeof t=="function"?t(e):t}function Oi(e){var t=zt();return Oc(t,dt,e)}function Oc(e,t,a){var n=e.queue;if(n===null)throw Error(c(311));n.lastRenderedReducer=a;var s=e.baseQueue,o=n.pending;if(o!==null){if(s!==null){var m=s.next;s.next=o.next,o.next=m}t.baseQueue=s=o,n.pending=null}if(o=e.baseState,s===null)e.memoizedState=o;else{t=s.next;var y=m=null,A=null,L=t,G=!1;do{var K=L.lane&-536870913;if(K!==L.lane?(Je&K)===K:(Fn&K)===K){var O=L.revertLane;if(O===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),K===Or&&(G=!0);else if((Fn&O)===O){L=L.next,O===Or&&(G=!0);continue}else K={lane:0,revertLane:L.revertLane,gesture:null,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null},A===null?(y=A=K,m=o):A=A.next=K,Ie.lanes|=O,wl|=O;K=L.action,sr&&a(o,K),o=L.hasEagerState?L.eagerState:a(o,K)}else O={lane:K,revertLane:L.revertLane,gesture:L.gesture,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null},A===null?(y=A=O,m=o):A=A.next=O,Ie.lanes|=K,wl|=K;L=L.next}while(L!==null&&L!==t);if(A===null?m=o:A.next=y,!Da(o,e.memoizedState)&&(Ut=!0,G&&(a=$r,a!==null)))throw a;e.memoizedState=o,e.baseState=m,e.baseQueue=A,n.lastRenderedState=o}return s===null&&(n.lanes=0),[e.memoizedState,n.dispatch]}function $c(e){var t=zt(),a=t.queue;if(a===null)throw Error(c(311));a.lastRenderedReducer=e;var n=a.dispatch,s=a.pending,o=t.memoizedState;if(s!==null){a.pending=null;var m=s=s.next;do o=e(o,m.action),m=m.next;while(m!==s);Da(o,t.memoizedState)||(Ut=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),a.lastRenderedState=o}return[o,n]}function _f(e,t,a){var n=Ie,s=zt(),o=We;if(o){if(a===void 0)throw Error(c(407));a=a()}else a=t();var m=!Da((dt||s).memoizedState,a);if(m&&(s.memoizedState=a,Ut=!0),s=s.queue,Hc(jf.bind(null,n,s,e),[e]),s.getSnapshot!==t||m||Rt!==null&&Rt.memoizedState.tag&1){if(n.flags|=2048,Gr(9,{destroy:void 0},Cf.bind(null,n,s,a,t),null),ht===null)throw Error(c(349));o||(Fn&127)!==0||Af(n,t,a)}return a}function Af(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=Ie.updateQueue,t===null?(t=Ri(),Ie.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Cf(e,t,a,n){t.value=a,t.getSnapshot=n,Nf(t)&&Tf(e)}function jf(e,t,a){return a(function(){Nf(t)&&Tf(e)})}function Nf(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Da(e,a)}catch{return!0}}function Tf(e){var t=Jl(e,2);t!==null&&ya(t,e,2)}function qc(e){var t=oa();if(typeof e=="function"){var a=e;if(e=a(),sr){Ht(!0);try{a()}finally{Ht(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:In,lastRenderedState:e},t}function Ef(e,t,a,n){return e.baseState=a,Oc(e,dt,typeof n=="function"?n:In)}function n0(e,t,a,n,s){if(Bi(e))throw Error(c(485));if(e=t.action,e!==null){var o={payload:s,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(m){o.listeners.push(m)}};E.T!==null?a(!0):o.isTransition=!1,n(o),a=t.pending,a===null?(o.next=t.pending=o,Mf(t,o)):(o.next=a.next,t.pending=a.next=o)}}function Mf(e,t){var a=t.action,n=t.payload,s=e.state;if(t.isTransition){var o=E.T,m={};E.T=m;try{var y=a(s,n),A=E.S;A!==null&&A(m,y),zf(e,t,y)}catch(L){Bc(e,t,L)}finally{o!==null&&m.types!==null&&(o.types=m.types),E.T=o}}else try{o=a(s,n),zf(e,t,o)}catch(L){Bc(e,t,L)}}function zf(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(n){Df(e,t,n)},function(n){return Bc(e,t,n)}):Df(e,t,a)}function Df(e,t,a){t.status="fulfilled",t.value=a,Lf(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Mf(e,a)))}function Bc(e,t,a){var n=e.pending;if(e.pending=null,n!==null){n=n.next;do t.status="rejected",t.reason=a,Lf(t),t=t.next;while(t!==n)}e.action=null}function Lf(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Rf(e,t){return t}function Uf(e,t){if(We){var a=ht.formState;if(a!==null){e:{var n=Ie;if(We){if(yt){t:{for(var s=yt,o=Ka;s.nodeType!==8;){if(!o){s=null;break t}if(s=Pa(s.nextSibling),s===null){s=null;break t}}o=s.data,s=o==="F!"||o==="F"?s:null}if(s){yt=Pa(s.nextSibling),n=s.data==="F!";break e}}fl(n)}n=!1}n&&(t=a[0])}}return a=oa(),a.memoizedState=a.baseState=t,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rf,lastRenderedState:t},a.queue=n,a=tm.bind(null,Ie,n),n.dispatch=a,n=qc(!1),o=Xc.bind(null,Ie,!1,n.queue),n=oa(),s={state:t,dispatch:null,action:e,pending:null},n.queue=s,a=n0.bind(null,Ie,s,o,a),s.dispatch=a,n.memoizedState=e,[t,a,!1]}function Of(e){var t=zt();return $f(t,dt,e)}function $f(e,t,a){if(t=Oc(e,t,Rf)[0],e=Oi(In)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var n=Ls(t)}catch(m){throw m===qr?ji:m}else n=t;t=zt();var s=t.queue,o=s.dispatch;return a!==t.memoizedState&&(Ie.flags|=2048,Gr(9,{destroy:void 0},l0.bind(null,s,a),null)),[n,o,e]}function l0(e,t){e.action=t}function qf(e){var t=zt(),a=dt;if(a!==null)return $f(t,a,e);zt(),t=t.memoizedState,a=zt();var n=a.queue.dispatch;return a.memoizedState=e,[t,n,!1]}function Gr(e,t,a,n){return e={tag:e,create:a,deps:n,inst:t,next:null},t=Ie.updateQueue,t===null&&(t=Ri(),Ie.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(n=a.next,a.next=e,e.next=n,t.lastEffect=e),e}function Bf(){return zt().memoizedState}function $i(e,t,a,n){var s=oa();Ie.flags|=e,s.memoizedState=Gr(1|t,{destroy:void 0},a,n===void 0?null:n)}function qi(e,t,a,n){var s=zt();n=n===void 0?null:n;var o=s.memoizedState.inst;dt!==null&&n!==null&&Mc(n,dt.memoizedState.deps)?s.memoizedState=Gr(t,o,a,n):(Ie.flags|=e,s.memoizedState=Gr(1|t,o,a,n))}function Hf(e,t){$i(8390656,8,e,t)}function Hc(e,t){qi(2048,8,e,t)}function r0(e){Ie.flags|=4;var t=Ie.updateQueue;if(t===null)t=Ri(),Ie.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function Ff(e){var t=zt().memoizedState;return r0({ref:t,nextImpl:e}),function(){if((st&2)!==0)throw Error(c(440));return t.impl.apply(void 0,arguments)}}function If(e,t){return qi(4,2,e,t)}function Gf(e,t){return qi(4,4,e,t)}function Vf(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Xf(e,t,a){a=a!=null?a.concat([e]):null,qi(4,4,Vf.bind(null,t,e),a)}function Fc(){}function Yf(e,t){var a=zt();t=t===void 0?null:t;var n=a.memoizedState;return t!==null&&Mc(t,n[1])?n[0]:(a.memoizedState=[e,t],e)}function Qf(e,t){var a=zt();t=t===void 0?null:t;var n=a.memoizedState;if(t!==null&&Mc(t,n[1]))return n[0];if(n=e(),sr){Ht(!0);try{e()}finally{Ht(!1)}}return a.memoizedState=[n,t],n}function Ic(e,t,a){return a===void 0||(Fn&1073741824)!==0&&(Je&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=Zm(),Ie.lanes|=e,wl|=e,a)}function Zf(e,t,a,n){return Da(a,t)?a:Hr.current!==null?(e=Ic(e,a,n),Da(e,t)||(Ut=!0),e):(Fn&42)===0||(Fn&1073741824)!==0&&(Je&261930)===0?(Ut=!0,e.memoizedState=a):(e=Zm(),Ie.lanes|=e,wl|=e,t)}function Kf(e,t,a,n,s){var o=V.p;V.p=o!==0&&8>o?o:8;var m=E.T,y={};E.T=y,Xc(e,!1,t,a);try{var A=s(),L=E.S;if(L!==null&&L(y,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var G=e0(A,n);Rs(e,t,G,qa(e))}else Rs(e,t,n,qa(e))}catch(K){Rs(e,t,{then:function(){},status:"rejected",reason:K},qa())}finally{V.p=o,m!==null&&y.types!==null&&(m.types=y.types),E.T=m}}function s0(){}function Gc(e,t,a,n){if(e.tag!==5)throw Error(c(476));var s=Jf(e).queue;Kf(e,s,t,H,a===null?s0:function(){return Pf(e),a(n)})}function Jf(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:In,lastRenderedState:H},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:In,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Pf(e){var t=Jf(e);t.next===null&&(t=e.alternate.memoizedState),Rs(e,t.next.queue,{},qa())}function Vc(){return Jt(Ps)}function Wf(){return zt().memoizedState}function em(){return zt().memoizedState}function i0(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=qa();e=pl(a);var n=gl(t,e,a);n!==null&&(ya(n,t,a),Es(n,t,a)),t={cache:vc()},e.payload=t;return}t=t.return}}function o0(e,t,a){var n=qa();a={lane:n,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bi(e)?am(t,a):(a=cc(e,t,a,n),a!==null&&(ya(a,e,n),nm(a,t,n)))}function tm(e,t,a){var n=qa();Rs(e,t,a,n)}function Rs(e,t,a,n){var s={lane:n,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bi(e))am(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var m=t.lastRenderedState,y=o(m,a);if(s.hasEagerState=!0,s.eagerState=y,Da(y,m))return vi(e,t,s,0),ht===null&&yi(),!1}catch{}finally{}if(a=cc(e,t,s,n),a!==null)return ya(a,e,n),nm(a,t,n),!0}return!1}function Xc(e,t,a,n){if(n={lane:2,revertLane:_u(),gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Bi(e)){if(t)throw Error(c(479))}else t=cc(e,a,n,2),t!==null&&ya(t,e,2)}function Bi(e){var t=e.alternate;return e===Ie||t!==null&&t===Ie}function am(e,t){Fr=Di=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function nm(e,t,a){if((a&4194048)!==0){var n=t.lanes;n&=e.pendingLanes,a|=n,t.lanes=a,fr(e,a)}}var Us={readContext:Jt,use:Ui,useCallback:Ct,useContext:Ct,useEffect:Ct,useImperativeHandle:Ct,useLayoutEffect:Ct,useInsertionEffect:Ct,useMemo:Ct,useReducer:Ct,useRef:Ct,useState:Ct,useDebugValue:Ct,useDeferredValue:Ct,useTransition:Ct,useSyncExternalStore:Ct,useId:Ct,useHostTransitionStatus:Ct,useFormState:Ct,useActionState:Ct,useOptimistic:Ct,useMemoCache:Ct,useCacheRefresh:Ct};Us.useEffectEvent=Ct;var lm={readContext:Jt,use:Ui,useCallback:function(e,t){return oa().memoizedState=[e,t===void 0?null:t],e},useContext:Jt,useEffect:Hf,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,$i(4194308,4,Vf.bind(null,t,e),a)},useLayoutEffect:function(e,t){return $i(4194308,4,e,t)},useInsertionEffect:function(e,t){$i(4,2,e,t)},useMemo:function(e,t){var a=oa();t=t===void 0?null:t;var n=e();if(sr){Ht(!0);try{e()}finally{Ht(!1)}}return a.memoizedState=[n,t],n},useReducer:function(e,t,a){var n=oa();if(a!==void 0){var s=a(t);if(sr){Ht(!0);try{a(t)}finally{Ht(!1)}}}else s=t;return n.memoizedState=n.baseState=s,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:s},n.queue=e,e=e.dispatch=o0.bind(null,Ie,e),[n.memoizedState,e]},useRef:function(e){var t=oa();return e={current:e},t.memoizedState=e},useState:function(e){e=qc(e);var t=e.queue,a=tm.bind(null,Ie,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Fc,useDeferredValue:function(e,t){var a=oa();return Ic(a,e,t)},useTransition:function(){var e=qc(!1);return e=Kf.bind(null,Ie,e.queue,!0,!1),oa().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var n=Ie,s=oa();if(We){if(a===void 0)throw Error(c(407));a=a()}else{if(a=t(),ht===null)throw Error(c(349));(Je&127)!==0||Af(n,t,a)}s.memoizedState=a;var o={value:a,getSnapshot:t};return s.queue=o,Hf(jf.bind(null,n,o,e),[e]),n.flags|=2048,Gr(9,{destroy:void 0},Cf.bind(null,n,o,a,t),null),a},useId:function(){var e=oa(),t=ht.identifierPrefix;if(We){var a=_n,n=kn;a=(n&~(1<<32-_e(n)-1)).toString(32)+a,t="_"+t+"R_"+a,a=Li++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=t0++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Vc,useFormState:Uf,useActionState:Uf,useOptimistic:function(e){var t=oa();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Xc.bind(null,Ie,!0,a),a.dispatch=t,[e,t]},useMemoCache:Uc,useCacheRefresh:function(){return oa().memoizedState=i0.bind(null,Ie)},useEffectEvent:function(e){var t=oa(),a={impl:e};return t.memoizedState=a,function(){if((st&2)!==0)throw Error(c(440));return a.impl.apply(void 0,arguments)}}},Yc={readContext:Jt,use:Ui,useCallback:Yf,useContext:Jt,useEffect:Hc,useImperativeHandle:Xf,useInsertionEffect:If,useLayoutEffect:Gf,useMemo:Qf,useReducer:Oi,useRef:Bf,useState:function(){return Oi(In)},useDebugValue:Fc,useDeferredValue:function(e,t){var a=zt();return Zf(a,dt.memoizedState,e,t)},useTransition:function(){var e=Oi(In)[0],t=zt().memoizedState;return[typeof e=="boolean"?e:Ls(e),t]},useSyncExternalStore:_f,useId:Wf,useHostTransitionStatus:Vc,useFormState:Of,useActionState:Of,useOptimistic:function(e,t){var a=zt();return Ef(a,dt,e,t)},useMemoCache:Uc,useCacheRefresh:em};Yc.useEffectEvent=Ff;var rm={readContext:Jt,use:Ui,useCallback:Yf,useContext:Jt,useEffect:Hc,useImperativeHandle:Xf,useInsertionEffect:If,useLayoutEffect:Gf,useMemo:Qf,useReducer:$c,useRef:Bf,useState:function(){return $c(In)},useDebugValue:Fc,useDeferredValue:function(e,t){var a=zt();return dt===null?Ic(a,e,t):Zf(a,dt.memoizedState,e,t)},useTransition:function(){var e=$c(In)[0],t=zt().memoizedState;return[typeof e=="boolean"?e:Ls(e),t]},useSyncExternalStore:_f,useId:Wf,useHostTransitionStatus:Vc,useFormState:qf,useActionState:qf,useOptimistic:function(e,t){var a=zt();return dt!==null?Ef(a,dt,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Uc,useCacheRefresh:em};rm.useEffectEvent=Ff;function Qc(e,t,a,n){t=e.memoizedState,a=a(n,t),a=a==null?t:w({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Zc={enqueueSetState:function(e,t,a){e=e._reactInternals;var n=qa(),s=pl(n);s.payload=t,a!=null&&(s.callback=a),t=gl(e,s,n),t!==null&&(ya(t,e,n),Es(t,e,n))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var n=qa(),s=pl(n);s.tag=1,s.payload=t,a!=null&&(s.callback=a),t=gl(e,s,n),t!==null&&(ya(t,e,n),Es(t,e,n))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=qa(),n=pl(a);n.tag=2,t!=null&&(n.callback=t),t=gl(e,n,a),t!==null&&(ya(t,e,a),Es(t,e,a))}};function sm(e,t,a,n,s,o,m){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(n,o,m):t.prototype&&t.prototype.isPureReactComponent?!Ss(a,n)||!Ss(s,o):!0}function im(e,t,a,n){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,n),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,n),t.state!==e&&Zc.enqueueReplaceState(t,t.state,null)}function ir(e,t){var a=t;if("ref"in t){a={};for(var n in t)n!=="ref"&&(a[n]=t[n])}if(e=e.defaultProps){a===t&&(a=w({},a));for(var s in e)a[s]===void 0&&(a[s]=e[s])}return a}function om(e){bi(e)}function cm(e){console.error(e)}function um(e){bi(e)}function Hi(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function dm(e,t,a){try{var n=e.onCaughtError;n(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(s){setTimeout(function(){throw s})}}function Kc(e,t,a){return a=pl(a),a.tag=3,a.payload={element:null},a.callback=function(){Hi(e,t)},a}function fm(e){return e=pl(e),e.tag=3,e}function mm(e,t,a,n){var s=a.type.getDerivedStateFromError;if(typeof s=="function"){var o=n.value;e.payload=function(){return s(o)},e.callback=function(){dm(t,a,n)}}var m=a.stateNode;m!==null&&typeof m.componentDidCatch=="function"&&(e.callback=function(){dm(t,a,n),typeof s!="function"&&(Sl===null?Sl=new Set([this]):Sl.add(this));var y=n.stack;this.componentDidCatch(n.value,{componentStack:y!==null?y:""})})}function c0(e,t,a,n,s){if(a.flags|=32768,n!==null&&typeof n=="object"&&typeof n.then=="function"){if(t=a.alternate,t!==null&&Ur(t,a,s,!0),a=Ra.current,a!==null){switch(a.tag){case 31:case 13:return Ja===null?Wi():a.alternate===null&&jt===0&&(jt=3),a.flags&=-257,a.flags|=65536,a.lanes=s,n===Ni?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([n]):t.add(n),wu(e,n,s)),!1;case 22:return a.flags|=65536,n===Ni?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([n])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([n]):a.add(n)),wu(e,n,s)),!1}throw Error(c(435,a.tag))}return wu(e,n,s),Wi(),!1}if(We)return t=Ra.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=s,n!==pc&&(e=Error(c(422),{cause:n}),As(Ya(e,a)))):(n!==pc&&(t=Error(c(423),{cause:n}),As(Ya(t,a))),e=e.current.alternate,e.flags|=65536,s&=-s,e.lanes|=s,n=Ya(n,a),s=Kc(e.stateNode,n,s),Cc(e,s),jt!==4&&(jt=2)),!1;var o=Error(c(520),{cause:n});if(o=Ya(o,a),Gs===null?Gs=[o]:Gs.push(o),jt!==4&&(jt=2),t===null)return!0;n=Ya(n,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=s&-s,a.lanes|=e,e=Kc(a.stateNode,n,e),Cc(a,e),!1;case 1:if(t=a.type,o=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(Sl===null||!Sl.has(o))))return a.flags|=65536,s&=-s,a.lanes|=s,s=fm(s),mm(s,e,a,n),Cc(a,s),!1}a=a.return}while(a!==null);return!1}var Jc=Error(c(461)),Ut=!1;function Pt(e,t,a,n){t.child=e===null?xf(t,null,a,n):rr(t,e.child,a,n)}function hm(e,t,a,n,s){a=a.render;var o=t.ref;if("ref"in n){var m={};for(var y in n)y!=="ref"&&(m[y]=n[y])}else m=n;return tr(t),n=zc(e,t,a,m,o,s),y=Dc(),e!==null&&!Ut?(Lc(e,t,s),Gn(e,t,s)):(We&&y&&mc(t),t.flags|=1,Pt(e,t,n,s),t.child)}function pm(e,t,a,n,s){if(e===null){var o=a.type;return typeof o=="function"&&!uc(o)&&o.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=o,gm(e,t,o,n,s)):(e=Si(a.type,null,n,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!ru(e,s)){var m=o.memoizedProps;if(a=a.compare,a=a!==null?a:Ss,a(m,n)&&e.ref===t.ref)return Gn(e,t,s)}return t.flags|=1,e=$n(o,n),e.ref=t.ref,e.return=t,t.child=e}function gm(e,t,a,n,s){if(e!==null){var o=e.memoizedProps;if(Ss(o,n)&&e.ref===t.ref)if(Ut=!1,t.pendingProps=n=o,ru(e,s))(e.flags&131072)!==0&&(Ut=!0);else return t.lanes=e.lanes,Gn(e,t,s)}return Pc(e,t,a,n,s)}function xm(e,t,a,n){var s=n.children,o=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.mode==="hidden"){if((t.flags&128)!==0){if(o=o!==null?o.baseLanes|a:a,e!==null){for(n=t.child=e.child,s=0;n!==null;)s=s|n.lanes|n.childLanes,n=n.sibling;n=s&~o}else n=0,t.child=null;return bm(e,t,o,a,n)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ci(t,o!==null?o.cachePool:null),o!==null?vf(t,o):Nc(),wf(t);else return n=t.lanes=536870912,bm(e,t,o!==null?o.baseLanes|a:a,a,n)}else o!==null?(Ci(t,o.cachePool),vf(t,o),bl(),t.memoizedState=null):(e!==null&&Ci(t,null),Nc(),bl());return Pt(e,t,s,a),t.child}function Os(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function bm(e,t,a,n,s){var o=Sc();return o=o===null?null:{parent:Lt._currentValue,pool:o},t.memoizedState={baseLanes:a,cachePool:o},e!==null&&Ci(t,null),Nc(),wf(t),e!==null&&Ur(e,t,n,!0),t.childLanes=s,null}function Fi(e,t){return t=Gi({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ym(e,t,a){return rr(t,e.child,null,a),e=Fi(t,t.pendingProps),e.flags|=2,Ua(t),t.memoizedState=null,e}function u0(e,t,a){var n=t.pendingProps,s=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(We){if(n.mode==="hidden")return e=Fi(t,n),t.lanes=536870912,Os(null,e);if(Ec(t),(e=yt)?(e=Mh(e,Ka),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ul!==null?{id:kn,overflow:_n}:null,retryLane:536870912,hydrationErrors:null},a=tf(e),a.return=t,t.child=a,Kt=t,yt=null)):e=null,e===null)throw fl(t);return t.lanes=536870912,null}return Fi(t,n)}var o=e.memoizedState;if(o!==null){var m=o.dehydrated;if(Ec(t),s)if(t.flags&256)t.flags&=-257,t=ym(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(c(558));else if(Ut||Ur(e,t,a,!1),s=(a&e.childLanes)!==0,Ut||s){if(n=ht,n!==null&&(m=ql(n,a),m!==0&&m!==o.retryLane))throw o.retryLane=m,Jl(e,m),ya(n,e,m),Jc;Wi(),t=ym(e,t,a)}else e=o.treeContext,yt=Pa(m.nextSibling),Kt=t,We=!0,dl=null,Ka=!1,e!==null&&lf(t,e),t=Fi(t,n),t.flags|=4096;return t}return e=$n(e.child,{mode:n.mode,children:n.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Ii(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(c(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Pc(e,t,a,n,s){return tr(t),a=zc(e,t,a,n,void 0,s),n=Dc(),e!==null&&!Ut?(Lc(e,t,s),Gn(e,t,s)):(We&&n&&mc(t),t.flags|=1,Pt(e,t,a,s),t.child)}function vm(e,t,a,n,s,o){return tr(t),t.updateQueue=null,a=kf(t,n,a,s),Sf(e),n=Dc(),e!==null&&!Ut?(Lc(e,t,o),Gn(e,t,o)):(We&&n&&mc(t),t.flags|=1,Pt(e,t,a,o),t.child)}function wm(e,t,a,n,s){if(tr(t),t.stateNode===null){var o=zr,m=a.contextType;typeof m=="object"&&m!==null&&(o=Jt(m)),o=new a(n,o),t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=Zc,t.stateNode=o,o._reactInternals=t,o=t.stateNode,o.props=n,o.state=t.memoizedState,o.refs={},_c(t),m=a.contextType,o.context=typeof m=="object"&&m!==null?Jt(m):zr,o.state=t.memoizedState,m=a.getDerivedStateFromProps,typeof m=="function"&&(Qc(t,a,m,n),o.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(m=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),m!==o.state&&Zc.enqueueReplaceState(o,o.state,null),zs(t,n,o,s),Ms(),o.state=t.memoizedState),typeof o.componentDidMount=="function"&&(t.flags|=4194308),n=!0}else if(e===null){o=t.stateNode;var y=t.memoizedProps,A=ir(a,y);o.props=A;var L=o.context,G=a.contextType;m=zr,typeof G=="object"&&G!==null&&(m=Jt(G));var K=a.getDerivedStateFromProps;G=typeof K=="function"||typeof o.getSnapshotBeforeUpdate=="function",y=t.pendingProps!==y,G||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(y||L!==m)&&im(t,o,n,m),hl=!1;var O=t.memoizedState;o.state=O,zs(t,n,o,s),Ms(),L=t.memoizedState,y||O!==L||hl?(typeof K=="function"&&(Qc(t,a,K,n),L=t.memoizedState),(A=hl||sm(t,a,A,n,O,L,m))?(G||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=n,t.memoizedState=L),o.props=n,o.state=L,o.context=m,n=A):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),n=!1)}else{o=t.stateNode,Ac(e,t),m=t.memoizedProps,G=ir(a,m),o.props=G,K=t.pendingProps,O=o.context,L=a.contextType,A=zr,typeof L=="object"&&L!==null&&(A=Jt(L)),y=a.getDerivedStateFromProps,(L=typeof y=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(m!==K||O!==A)&&im(t,o,n,A),hl=!1,O=t.memoizedState,o.state=O,zs(t,n,o,s),Ms();var B=t.memoizedState;m!==K||O!==B||hl||e!==null&&e.dependencies!==null&&_i(e.dependencies)?(typeof y=="function"&&(Qc(t,a,y,n),B=t.memoizedState),(G=hl||sm(t,a,G,n,O,B,A)||e!==null&&e.dependencies!==null&&_i(e.dependencies))?(L||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(n,B,A),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(n,B,A)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||m===e.memoizedProps&&O===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||m===e.memoizedProps&&O===e.memoizedState||(t.flags|=1024),t.memoizedProps=n,t.memoizedState=B),o.props=n,o.state=B,o.context=A,n=G):(typeof o.componentDidUpdate!="function"||m===e.memoizedProps&&O===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||m===e.memoizedProps&&O===e.memoizedState||(t.flags|=1024),n=!1)}return o=n,Ii(e,t),n=(t.flags&128)!==0,o||n?(o=t.stateNode,a=n&&typeof a.getDerivedStateFromError!="function"?null:o.render(),t.flags|=1,e!==null&&n?(t.child=rr(t,e.child,null,s),t.child=rr(t,null,a,s)):Pt(e,t,a,s),t.memoizedState=o.state,e=t.child):e=Gn(e,t,s),e}function Sm(e,t,a,n){return Wl(),t.flags|=256,Pt(e,t,a,n),t.child}var Wc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function eu(e){return{baseLanes:e,cachePool:df()}}function tu(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=$a),e}function km(e,t,a){var n=t.pendingProps,s=!1,o=(t.flags&128)!==0,m;if((m=o)||(m=e!==null&&e.memoizedState===null?!1:(Mt.current&2)!==0),m&&(s=!0,t.flags&=-129),m=(t.flags&32)!==0,t.flags&=-33,e===null){if(We){if(s?xl(t):bl(),(e=yt)?(e=Mh(e,Ka),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ul!==null?{id:kn,overflow:_n}:null,retryLane:536870912,hydrationErrors:null},a=tf(e),a.return=t,t.child=a,Kt=t,yt=null)):e=null,e===null)throw fl(t);return Ou(e)?t.lanes=32:t.lanes=536870912,null}var y=n.children;return n=n.fallback,s?(bl(),s=t.mode,y=Gi({mode:"hidden",children:y},s),n=Pl(n,s,a,null),y.return=t,n.return=t,y.sibling=n,t.child=y,n=t.child,n.memoizedState=eu(a),n.childLanes=tu(e,m,a),t.memoizedState=Wc,Os(null,n)):(xl(t),au(t,y))}var A=e.memoizedState;if(A!==null&&(y=A.dehydrated,y!==null)){if(o)t.flags&256?(xl(t),t.flags&=-257,t=nu(e,t,a)):t.memoizedState!==null?(bl(),t.child=e.child,t.flags|=128,t=null):(bl(),y=n.fallback,s=t.mode,n=Gi({mode:"visible",children:n.children},s),y=Pl(y,s,a,null),y.flags|=2,n.return=t,y.return=t,n.sibling=y,t.child=n,rr(t,e.child,null,a),n=t.child,n.memoizedState=eu(a),n.childLanes=tu(e,m,a),t.memoizedState=Wc,t=Os(null,n));else if(xl(t),Ou(y)){if(m=y.nextSibling&&y.nextSibling.dataset,m)var L=m.dgst;m=L,n=Error(c(419)),n.stack="",n.digest=m,As({value:n,source:null,stack:null}),t=nu(e,t,a)}else if(Ut||Ur(e,t,a,!1),m=(a&e.childLanes)!==0,Ut||m){if(m=ht,m!==null&&(n=ql(m,a),n!==0&&n!==A.retryLane))throw A.retryLane=n,Jl(e,n),ya(m,e,n),Jc;Uu(y)||Wi(),t=nu(e,t,a)}else Uu(y)?(t.flags|=192,t.child=e.child,t=null):(e=A.treeContext,yt=Pa(y.nextSibling),Kt=t,We=!0,dl=null,Ka=!1,e!==null&&lf(t,e),t=au(t,n.children),t.flags|=4096);return t}return s?(bl(),y=n.fallback,s=t.mode,A=e.child,L=A.sibling,n=$n(A,{mode:"hidden",children:n.children}),n.subtreeFlags=A.subtreeFlags&65011712,L!==null?y=$n(L,y):(y=Pl(y,s,a,null),y.flags|=2),y.return=t,n.return=t,n.sibling=y,t.child=n,Os(null,n),n=t.child,y=e.child.memoizedState,y===null?y=eu(a):(s=y.cachePool,s!==null?(A=Lt._currentValue,s=s.parent!==A?{parent:A,pool:A}:s):s=df(),y={baseLanes:y.baseLanes|a,cachePool:s}),n.memoizedState=y,n.childLanes=tu(e,m,a),t.memoizedState=Wc,Os(e.child,n)):(xl(t),a=e.child,e=a.sibling,a=$n(a,{mode:"visible",children:n.children}),a.return=t,a.sibling=null,e!==null&&(m=t.deletions,m===null?(t.deletions=[e],t.flags|=16):m.push(e)),t.child=a,t.memoizedState=null,a)}function au(e,t){return t=Gi({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Gi(e,t){return e=La(22,e,null,t),e.lanes=0,e}function nu(e,t,a){return rr(t,e.child,null,a),e=au(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _m(e,t,a){e.lanes|=t;var n=e.alternate;n!==null&&(n.lanes|=t),bc(e.return,t,a)}function lu(e,t,a,n,s,o){var m=e.memoizedState;m===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:a,tailMode:s,treeForkCount:o}:(m.isBackwards=t,m.rendering=null,m.renderingStartTime=0,m.last=n,m.tail=a,m.tailMode=s,m.treeForkCount=o)}function Am(e,t,a){var n=t.pendingProps,s=n.revealOrder,o=n.tail;n=n.children;var m=Mt.current,y=(m&2)!==0;if(y?(m=m&1|2,t.flags|=128):m&=1,F(Mt,m),Pt(e,t,n,a),n=We?_s:0,!y&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&_m(e,a,t);else if(e.tag===19)_m(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(s){case"forwards":for(a=t.child,s=null;a!==null;)e=a.alternate,e!==null&&zi(e)===null&&(s=a),a=a.sibling;a=s,a===null?(s=t.child,t.child=null):(s=a.sibling,a.sibling=null),lu(t,!1,s,a,o,n);break;case"backwards":case"unstable_legacy-backwards":for(a=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&zi(e)===null){t.child=s;break}e=s.sibling,s.sibling=a,a=s,s=e}lu(t,!0,a,null,o,n);break;case"together":lu(t,!1,null,null,void 0,n);break;default:t.memoizedState=null}return t.child}function Gn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),wl|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Ur(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(c(153));if(t.child!==null){for(e=t.child,a=$n(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=$n(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function ru(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&_i(e)))}function d0(e,t,a){switch(t.tag){case 3:W(t,t.stateNode.containerInfo),ml(t,Lt,e.memoizedState.cache),Wl();break;case 27:case 5:be(t);break;case 4:W(t,t.stateNode.containerInfo);break;case 10:ml(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ec(t),null;break;case 13:var n=t.memoizedState;if(n!==null)return n.dehydrated!==null?(xl(t),t.flags|=128,null):(a&t.child.childLanes)!==0?km(e,t,a):(xl(t),e=Gn(e,t,a),e!==null?e.sibling:null);xl(t);break;case 19:var s=(e.flags&128)!==0;if(n=(a&t.childLanes)!==0,n||(Ur(e,t,a,!1),n=(a&t.childLanes)!==0),s){if(n)return Am(e,t,a);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),F(Mt,Mt.current),n)break;return null;case 22:return t.lanes=0,xm(e,t,a,t.pendingProps);case 24:ml(t,Lt,e.memoizedState.cache)}return Gn(e,t,a)}function Cm(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)Ut=!0;else{if(!ru(e,a)&&(t.flags&128)===0)return Ut=!1,d0(e,t,a);Ut=(e.flags&131072)!==0}else Ut=!1,We&&(t.flags&1048576)!==0&&nf(t,_s,t.index);switch(t.lanes=0,t.tag){case 16:e:{var n=t.pendingProps;if(e=nr(t.elementType),t.type=e,typeof e=="function")uc(e)?(n=ir(e,n),t.tag=1,t=wm(null,t,e,n,a)):(t.tag=0,t=Pc(null,t,e,n,a));else{if(e!=null){var s=e.$$typeof;if(s===R){t.tag=11,t=hm(null,t,e,n,a);break e}else if(s===X){t.tag=14,t=pm(null,t,e,n,a);break e}}throw t=te(e)||e,Error(c(306,t,""))}}return t;case 0:return Pc(e,t,t.type,t.pendingProps,a);case 1:return n=t.type,s=ir(n,t.pendingProps),wm(e,t,n,s,a);case 3:e:{if(W(t,t.stateNode.containerInfo),e===null)throw Error(c(387));n=t.pendingProps;var o=t.memoizedState;s=o.element,Ac(e,t),zs(t,n,null,a);var m=t.memoizedState;if(n=m.cache,ml(t,Lt,n),n!==o.cache&&yc(t,[Lt],a,!0),Ms(),n=m.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:m.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Sm(e,t,n,a);break e}else if(n!==s){s=Ya(Error(c(424)),t),As(s),t=Sm(e,t,n,a);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(yt=Pa(e.firstChild),Kt=t,We=!0,dl=null,Ka=!0,a=xf(t,null,n,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Wl(),n===s){t=Gn(e,t,a);break e}Pt(e,t,n,a)}t=t.child}return t;case 26:return Ii(e,t),e===null?(a=Oh(t.type,null,t.pendingProps,null))?t.memoizedState=a:We||(a=t.type,e=t.pendingProps,n=so(de.current).createElement(a),n[Et]=t,n[At]=e,Wt(n,a,e),Ke(n),t.stateNode=n):t.memoizedState=Oh(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return be(t),e===null&&We&&(n=t.stateNode=Lh(t.type,t.pendingProps,de.current),Kt=t,Ka=!0,s=yt,Cl(t.type)?($u=s,yt=Pa(n.firstChild)):yt=s),Pt(e,t,t.pendingProps.children,a),Ii(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&We&&((s=n=yt)&&(n=H0(n,t.type,t.pendingProps,Ka),n!==null?(t.stateNode=n,Kt=t,yt=Pa(n.firstChild),Ka=!1,s=!0):s=!1),s||fl(t)),be(t),s=t.type,o=t.pendingProps,m=e!==null?e.memoizedProps:null,n=o.children,Du(s,o)?n=null:m!==null&&Du(s,m)&&(t.flags|=32),t.memoizedState!==null&&(s=zc(e,t,a0,null,null,a),Ps._currentValue=s),Ii(e,t),Pt(e,t,n,a),t.child;case 6:return e===null&&We&&((e=a=yt)&&(a=F0(a,t.pendingProps,Ka),a!==null?(t.stateNode=a,Kt=t,yt=null,e=!0):e=!1),e||fl(t)),null;case 13:return km(e,t,a);case 4:return W(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=rr(t,null,n,a):Pt(e,t,n,a),t.child;case 11:return hm(e,t,t.type,t.pendingProps,a);case 7:return Pt(e,t,t.pendingProps,a),t.child;case 8:return Pt(e,t,t.pendingProps.children,a),t.child;case 12:return Pt(e,t,t.pendingProps.children,a),t.child;case 10:return n=t.pendingProps,ml(t,t.type,n.value),Pt(e,t,n.children,a),t.child;case 9:return s=t.type._context,n=t.pendingProps.children,tr(t),s=Jt(s),n=n(s),t.flags|=1,Pt(e,t,n,a),t.child;case 14:return pm(e,t,t.type,t.pendingProps,a);case 15:return gm(e,t,t.type,t.pendingProps,a);case 19:return Am(e,t,a);case 31:return u0(e,t,a);case 22:return xm(e,t,a,t.pendingProps);case 24:return tr(t),n=Jt(Lt),e===null?(s=Sc(),s===null&&(s=ht,o=vc(),s.pooledCache=o,o.refCount++,o!==null&&(s.pooledCacheLanes|=a),s=o),t.memoizedState={parent:n,cache:s},_c(t),ml(t,Lt,s)):((e.lanes&a)!==0&&(Ac(e,t),zs(t,null,null,a),Ms()),s=e.memoizedState,o=t.memoizedState,s.parent!==n?(s={parent:n,cache:n},t.memoizedState=s,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=s),ml(t,Lt,n)):(n=o.cache,ml(t,Lt,n),n!==s.cache&&yc(t,[Lt],a,!0))),Pt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(c(156,t.tag))}function Vn(e){e.flags|=4}function su(e,t,a,n,s){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(s&335544128)===s)if(e.stateNode.complete)e.flags|=8192;else if(Wm())e.flags|=8192;else throw lr=Ni,kc}else e.flags&=-16777217}function jm(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Fh(t))if(Wm())e.flags|=8192;else throw lr=Ni,kc}function Vi(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?$l():536870912,e.lanes|=t,Qr|=t)}function $s(e,t){if(!We)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var n=null;a!==null;)a.alternate!==null&&(n=a),a=a.sibling;n===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:n.sibling=null}}function vt(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,n=0;if(t)for(var s=e.child;s!==null;)a|=s.lanes|s.childLanes,n|=s.subtreeFlags&65011712,n|=s.flags&65011712,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)a|=s.lanes|s.childLanes,n|=s.subtreeFlags,n|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=n,e.childLanes=a,t}function f0(e,t,a){var n=t.pendingProps;switch(hc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return vt(t),null;case 1:return vt(t),null;case 3:return a=t.stateNode,n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Hn(Lt),se(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(Rr(t)?Vn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,gc())),vt(t),null;case 26:var s=t.type,o=t.memoizedState;return e===null?(Vn(t),o!==null?(vt(t),jm(t,o)):(vt(t),su(t,s,null,n,a))):o?o!==e.memoizedState?(Vn(t),vt(t),jm(t,o)):(vt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==n&&Vn(t),vt(t),su(t,s,e,n,a)),null;case 27:if(ke(t),a=de.current,s=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==n&&Vn(t);else{if(!n){if(t.stateNode===null)throw Error(c(166));return vt(t),null}e=me.current,Rr(t)?rf(t):(e=Lh(s,n,a),t.stateNode=e,Vn(t))}return vt(t),null;case 5:if(ke(t),s=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==n&&Vn(t);else{if(!n){if(t.stateNode===null)throw Error(c(166));return vt(t),null}if(o=me.current,Rr(t))rf(t);else{var m=so(de.current);switch(o){case 1:o=m.createElementNS("http://www.w3.org/2000/svg",s);break;case 2:o=m.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;default:switch(s){case"svg":o=m.createElementNS("http://www.w3.org/2000/svg",s);break;case"math":o=m.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;case"script":o=m.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof n.is=="string"?m.createElement("select",{is:n.is}):m.createElement("select"),n.multiple?o.multiple=!0:n.size&&(o.size=n.size);break;default:o=typeof n.is=="string"?m.createElement(s,{is:n.is}):m.createElement(s)}}o[Et]=t,o[At]=n;e:for(m=t.child;m!==null;){if(m.tag===5||m.tag===6)o.appendChild(m.stateNode);else if(m.tag!==4&&m.tag!==27&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===t)break e;for(;m.sibling===null;){if(m.return===null||m.return===t)break e;m=m.return}m.sibling.return=m.return,m=m.sibling}t.stateNode=o;e:switch(Wt(o,s,n),s){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}n&&Vn(t)}}return vt(t),su(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==n&&Vn(t);else{if(typeof n!="string"&&t.stateNode===null)throw Error(c(166));if(e=de.current,Rr(t)){if(e=t.stateNode,a=t.memoizedProps,n=null,s=Kt,s!==null)switch(s.tag){case 27:case 5:n=s.memoizedProps}e[Et]=t,e=!!(e.nodeValue===a||n!==null&&n.suppressHydrationWarning===!0||kh(e.nodeValue,a)),e||fl(t,!0)}else e=so(e).createTextNode(n),e[Et]=t,t.stateNode=e}return vt(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(n=Rr(t),a!==null){if(e===null){if(!n)throw Error(c(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(c(557));e[Et]=t}else Wl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;vt(t),e=!1}else a=gc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Ua(t),t):(Ua(t),null);if((t.flags&128)!==0)throw Error(c(558))}return vt(t),null;case 13:if(n=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(s=Rr(t),n!==null&&n.dehydrated!==null){if(e===null){if(!s)throw Error(c(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(c(317));s[Et]=t}else Wl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;vt(t),s=!1}else s=gc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),s=!0;if(!s)return t.flags&256?(Ua(t),t):(Ua(t),null)}return Ua(t),(t.flags&128)!==0?(t.lanes=a,t):(a=n!==null,e=e!==null&&e.memoizedState!==null,a&&(n=t.child,s=null,n.alternate!==null&&n.alternate.memoizedState!==null&&n.alternate.memoizedState.cachePool!==null&&(s=n.alternate.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==s&&(n.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),Vi(t,t.updateQueue),vt(t),null);case 4:return se(),e===null&&Nu(t.stateNode.containerInfo),vt(t),null;case 10:return Hn(t.type),vt(t),null;case 19:if(pe(Mt),n=t.memoizedState,n===null)return vt(t),null;if(s=(t.flags&128)!==0,o=n.rendering,o===null)if(s)$s(n,!1);else{if(jt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(o=zi(e),o!==null){for(t.flags|=128,$s(n,!1),e=o.updateQueue,t.updateQueue=e,Vi(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)ef(a,e),a=a.sibling;return F(Mt,Mt.current&1|2),We&&qn(t,n.treeForkCount),t.child}e=e.sibling}n.tail!==null&&Oe()>Ki&&(t.flags|=128,s=!0,$s(n,!1),t.lanes=4194304)}else{if(!s)if(e=zi(o),e!==null){if(t.flags|=128,s=!0,e=e.updateQueue,t.updateQueue=e,Vi(t,e),$s(n,!0),n.tail===null&&n.tailMode==="hidden"&&!o.alternate&&!We)return vt(t),null}else 2*Oe()-n.renderingStartTime>Ki&&a!==536870912&&(t.flags|=128,s=!0,$s(n,!1),t.lanes=4194304);n.isBackwards?(o.sibling=t.child,t.child=o):(e=n.last,e!==null?e.sibling=o:t.child=o,n.last=o)}return n.tail!==null?(e=n.tail,n.rendering=e,n.tail=e.sibling,n.renderingStartTime=Oe(),e.sibling=null,a=Mt.current,F(Mt,s?a&1|2:a&1),We&&qn(t,n.treeForkCount),e):(vt(t),null);case 22:case 23:return Ua(t),Tc(),n=t.memoizedState!==null,e!==null?e.memoizedState!==null!==n&&(t.flags|=8192):n&&(t.flags|=8192),n?(a&536870912)!==0&&(t.flags&128)===0&&(vt(t),t.subtreeFlags&6&&(t.flags|=8192)):vt(t),a=t.updateQueue,a!==null&&Vi(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),n=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(n=t.memoizedState.cachePool.pool),n!==a&&(t.flags|=2048),e!==null&&pe(ar),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Hn(Lt),vt(t),null;case 25:return null;case 30:return null}throw Error(c(156,t.tag))}function m0(e,t){switch(hc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Hn(Lt),se(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ke(t),null;case 31:if(t.memoizedState!==null){if(Ua(t),t.alternate===null)throw Error(c(340));Wl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ua(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(c(340));Wl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return pe(Mt),null;case 4:return se(),null;case 10:return Hn(t.type),null;case 22:case 23:return Ua(t),Tc(),e!==null&&pe(ar),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Hn(Lt),null;case 25:return null;default:return null}}function Nm(e,t){switch(hc(t),t.tag){case 3:Hn(Lt),se();break;case 26:case 27:case 5:ke(t);break;case 4:se();break;case 31:t.memoizedState!==null&&Ua(t);break;case 13:Ua(t);break;case 19:pe(Mt);break;case 10:Hn(t.type);break;case 22:case 23:Ua(t),Tc(),e!==null&&pe(ar);break;case 24:Hn(Lt)}}function qs(e,t){try{var a=t.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var s=n.next;a=s;do{if((a.tag&e)===e){n=void 0;var o=a.create,m=a.inst;n=o(),m.destroy=n}a=a.next}while(a!==s)}}catch(y){ct(t,t.return,y)}}function yl(e,t,a){try{var n=t.updateQueue,s=n!==null?n.lastEffect:null;if(s!==null){var o=s.next;n=o;do{if((n.tag&e)===e){var m=n.inst,y=m.destroy;if(y!==void 0){m.destroy=void 0,s=t;var A=a,L=y;try{L()}catch(G){ct(s,A,G)}}}n=n.next}while(n!==o)}}catch(G){ct(t,t.return,G)}}function Tm(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{yf(t,a)}catch(n){ct(e,e.return,n)}}}function Em(e,t,a){a.props=ir(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(n){ct(e,t,n)}}function Bs(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var n=e.stateNode;break;case 30:n=e.stateNode;break;default:n=e.stateNode}typeof a=="function"?e.refCleanup=a(n):a.current=n}}catch(s){ct(e,t,s)}}function An(e,t){var a=e.ref,n=e.refCleanup;if(a!==null)if(typeof n=="function")try{n()}catch(s){ct(e,t,s)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(s){ct(e,t,s)}else a.current=null}function Mm(e){var t=e.type,a=e.memoizedProps,n=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&n.focus();break e;case"img":a.src?n.src=a.src:a.srcSet&&(n.srcset=a.srcSet)}}catch(s){ct(e,e.return,s)}}function iu(e,t,a){try{var n=e.stateNode;R0(n,e.type,a,t),n[At]=t}catch(s){ct(e,e.return,s)}}function zm(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Cl(e.type)||e.tag===4}function ou(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||zm(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Cl(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function cu(e,t,a){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=Fa));else if(n!==4&&(n===27&&Cl(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(cu(e,t,a),e=e.sibling;e!==null;)cu(e,t,a),e=e.sibling}function Xi(e,t,a){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(n!==4&&(n===27&&Cl(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(Xi(e,t,a),e=e.sibling;e!==null;)Xi(e,t,a),e=e.sibling}function Dm(e){var t=e.stateNode,a=e.memoizedProps;try{for(var n=e.type,s=t.attributes;s.length;)t.removeAttributeNode(s[0]);Wt(t,n,a),t[Et]=e,t[At]=a}catch(o){ct(e,e.return,o)}}var Xn=!1,Ot=!1,uu=!1,Lm=typeof WeakSet=="function"?WeakSet:Set,Gt=null;function h0(e,t){if(e=e.containerInfo,Mu=ho,e=Vd(e),nc(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var n=a.getSelection&&a.getSelection();if(n&&n.rangeCount!==0){a=n.anchorNode;var s=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{a.nodeType,o.nodeType}catch{a=null;break e}var m=0,y=-1,A=-1,L=0,G=0,K=e,O=null;t:for(;;){for(var B;K!==a||s!==0&&K.nodeType!==3||(y=m+s),K!==o||n!==0&&K.nodeType!==3||(A=m+n),K.nodeType===3&&(m+=K.nodeValue.length),(B=K.firstChild)!==null;)O=K,K=B;for(;;){if(K===e)break t;if(O===a&&++L===s&&(y=m),O===o&&++G===n&&(A=m),(B=K.nextSibling)!==null)break;K=O,O=K.parentNode}K=B}a=y===-1||A===-1?null:{start:y,end:A}}else a=null}a=a||{start:0,end:0}}else a=null;for(zu={focusedElem:e,selectionRange:a},ho=!1,Gt=t;Gt!==null;)if(t=Gt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Gt=e;else for(;Gt!==null;){switch(t=Gt,o=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)s=e[a],s.ref.impl=s.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&o!==null){e=void 0,a=t,s=o.memoizedProps,o=o.memoizedState,n=a.stateNode;try{var ve=ir(a.type,s);e=n.getSnapshotBeforeUpdate(ve,o),n.__reactInternalSnapshotBeforeUpdate=e}catch(Re){ct(a,a.return,Re)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)Ru(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ru(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(c(163))}if(e=t.sibling,e!==null){e.return=t.return,Gt=e;break}Gt=t.return}}function Rm(e,t,a){var n=a.flags;switch(a.tag){case 0:case 11:case 15:Qn(e,a),n&4&&qs(5,a);break;case 1:if(Qn(e,a),n&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(m){ct(a,a.return,m)}else{var s=ir(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(s,t,e.__reactInternalSnapshotBeforeUpdate)}catch(m){ct(a,a.return,m)}}n&64&&Tm(a),n&512&&Bs(a,a.return);break;case 3:if(Qn(e,a),n&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{yf(e,t)}catch(m){ct(a,a.return,m)}}break;case 27:t===null&&n&4&&Dm(a);case 26:case 5:Qn(e,a),t===null&&n&4&&Mm(a),n&512&&Bs(a,a.return);break;case 12:Qn(e,a);break;case 31:Qn(e,a),n&4&&$m(e,a);break;case 13:Qn(e,a),n&4&&qm(e,a),n&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=k0.bind(null,a),I0(e,a))));break;case 22:if(n=a.memoizedState!==null||Xn,!n){t=t!==null&&t.memoizedState!==null||Ot,s=Xn;var o=Ot;Xn=n,(Ot=t)&&!o?Zn(e,a,(a.subtreeFlags&8772)!==0):Qn(e,a),Xn=s,Ot=o}break;case 30:break;default:Qn(e,a)}}function Um(e){var t=e.alternate;t!==null&&(e.alternate=null,Um(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Ca(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var St=null,pa=!1;function Yn(e,t,a){for(a=a.child;a!==null;)Om(e,t,a),a=a.sibling}function Om(e,t,a){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(Tt,a)}catch{}switch(a.tag){case 26:Ot||An(a,t),Yn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Ot||An(a,t);var n=St,s=pa;Cl(a.type)&&(St=a.stateNode,pa=!1),Yn(e,t,a),Zs(a.stateNode),St=n,pa=s;break;case 5:Ot||An(a,t);case 6:if(n=St,s=pa,St=null,Yn(e,t,a),St=n,pa=s,St!==null)if(pa)try{(St.nodeType===9?St.body:St.nodeName==="HTML"?St.ownerDocument.body:St).removeChild(a.stateNode)}catch(o){ct(a,t,o)}else try{St.removeChild(a.stateNode)}catch(o){ct(a,t,o)}break;case 18:St!==null&&(pa?(e=St,Th(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),as(e)):Th(St,a.stateNode));break;case 4:n=St,s=pa,St=a.stateNode.containerInfo,pa=!0,Yn(e,t,a),St=n,pa=s;break;case 0:case 11:case 14:case 15:yl(2,a,t),Ot||yl(4,a,t),Yn(e,t,a);break;case 1:Ot||(An(a,t),n=a.stateNode,typeof n.componentWillUnmount=="function"&&Em(a,t,n)),Yn(e,t,a);break;case 21:Yn(e,t,a);break;case 22:Ot=(n=Ot)||a.memoizedState!==null,Yn(e,t,a),Ot=n;break;default:Yn(e,t,a)}}function $m(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{as(e)}catch(a){ct(t,t.return,a)}}}function qm(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{as(e)}catch(a){ct(t,t.return,a)}}function p0(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Lm),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Lm),t;default:throw Error(c(435,e.tag))}}function Yi(e,t){var a=p0(e);t.forEach(function(n){if(!a.has(n)){a.add(n);var s=_0.bind(null,e,n);n.then(s,s)}})}function ga(e,t){var a=t.deletions;if(a!==null)for(var n=0;n<a.length;n++){var s=a[n],o=e,m=t,y=m;e:for(;y!==null;){switch(y.tag){case 27:if(Cl(y.type)){St=y.stateNode,pa=!1;break e}break;case 5:St=y.stateNode,pa=!1;break e;case 3:case 4:St=y.stateNode.containerInfo,pa=!0;break e}y=y.return}if(St===null)throw Error(c(160));Om(o,m,s),St=null,pa=!1,o=s.alternate,o!==null&&(o.return=null),s.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Bm(t,e),t=t.sibling}var fn=null;function Bm(e,t){var a=e.alternate,n=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ga(t,e),xa(e),n&4&&(yl(3,e,e.return),qs(3,e),yl(5,e,e.return));break;case 1:ga(t,e),xa(e),n&512&&(Ot||a===null||An(a,a.return)),n&64&&Xn&&(e=e.updateQueue,e!==null&&(n=e.callbacks,n!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?n:a.concat(n))));break;case 26:var s=fn;if(ga(t,e),xa(e),n&512&&(Ot||a===null||An(a,a.return)),n&4){var o=a!==null?a.memoizedState:null;if(n=e.memoizedState,a===null)if(n===null)if(e.stateNode===null){e:{n=e.type,a=e.memoizedProps,s=s.ownerDocument||s;t:switch(n){case"title":o=s.getElementsByTagName("title")[0],(!o||o[yn]||o[Et]||o.namespaceURI==="http://www.w3.org/2000/svg"||o.hasAttribute("itemprop"))&&(o=s.createElement(n),s.head.insertBefore(o,s.querySelector("head > title"))),Wt(o,n,a),o[Et]=e,Ke(o),n=o;break e;case"link":var m=Bh("link","href",s).get(n+(a.href||""));if(m){for(var y=0;y<m.length;y++)if(o=m[y],o.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&o.getAttribute("rel")===(a.rel==null?null:a.rel)&&o.getAttribute("title")===(a.title==null?null:a.title)&&o.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){m.splice(y,1);break t}}o=s.createElement(n),Wt(o,n,a),s.head.appendChild(o);break;case"meta":if(m=Bh("meta","content",s).get(n+(a.content||""))){for(y=0;y<m.length;y++)if(o=m[y],o.getAttribute("content")===(a.content==null?null:""+a.content)&&o.getAttribute("name")===(a.name==null?null:a.name)&&o.getAttribute("property")===(a.property==null?null:a.property)&&o.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&o.getAttribute("charset")===(a.charSet==null?null:a.charSet)){m.splice(y,1);break t}}o=s.createElement(n),Wt(o,n,a),s.head.appendChild(o);break;default:throw Error(c(468,n))}o[Et]=e,Ke(o),n=o}e.stateNode=n}else Hh(s,e.type,e.stateNode);else e.stateNode=qh(s,n,e.memoizedProps);else o!==n?(o===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):o.count--,n===null?Hh(s,e.type,e.stateNode):qh(s,n,e.memoizedProps)):n===null&&e.stateNode!==null&&iu(e,e.memoizedProps,a.memoizedProps)}break;case 27:ga(t,e),xa(e),n&512&&(Ot||a===null||An(a,a.return)),a!==null&&n&4&&iu(e,e.memoizedProps,a.memoizedProps);break;case 5:if(ga(t,e),xa(e),n&512&&(Ot||a===null||An(a,a.return)),e.flags&32){s=e.stateNode;try{rl(s,"")}catch(ve){ct(e,e.return,ve)}}n&4&&e.stateNode!=null&&(s=e.memoizedProps,iu(e,s,a!==null?a.memoizedProps:s)),n&1024&&(uu=!0);break;case 6:if(ga(t,e),xa(e),n&4){if(e.stateNode===null)throw Error(c(162));n=e.memoizedProps,a=e.stateNode;try{a.nodeValue=n}catch(ve){ct(e,e.return,ve)}}break;case 3:if(co=null,s=fn,fn=io(t.containerInfo),ga(t,e),fn=s,xa(e),n&4&&a!==null&&a.memoizedState.isDehydrated)try{as(t.containerInfo)}catch(ve){ct(e,e.return,ve)}uu&&(uu=!1,Hm(e));break;case 4:n=fn,fn=io(e.stateNode.containerInfo),ga(t,e),xa(e),fn=n;break;case 12:ga(t,e),xa(e);break;case 31:ga(t,e),xa(e),n&4&&(n=e.updateQueue,n!==null&&(e.updateQueue=null,Yi(e,n)));break;case 13:ga(t,e),xa(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Zi=Oe()),n&4&&(n=e.updateQueue,n!==null&&(e.updateQueue=null,Yi(e,n)));break;case 22:s=e.memoizedState!==null;var A=a!==null&&a.memoizedState!==null,L=Xn,G=Ot;if(Xn=L||s,Ot=G||A,ga(t,e),Ot=G,Xn=L,xa(e),n&8192)e:for(t=e.stateNode,t._visibility=s?t._visibility&-2:t._visibility|1,s&&(a===null||A||Xn||Ot||or(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){A=a=t;try{if(o=A.stateNode,s)m=o.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none";else{y=A.stateNode;var K=A.memoizedProps.style,O=K!=null&&K.hasOwnProperty("display")?K.display:null;y.style.display=O==null||typeof O=="boolean"?"":(""+O).trim()}}catch(ve){ct(A,A.return,ve)}}}else if(t.tag===6){if(a===null){A=t;try{A.stateNode.nodeValue=s?"":A.memoizedProps}catch(ve){ct(A,A.return,ve)}}}else if(t.tag===18){if(a===null){A=t;try{var B=A.stateNode;s?Eh(B,!0):Eh(A.stateNode,!1)}catch(ve){ct(A,A.return,ve)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}n&4&&(n=e.updateQueue,n!==null&&(a=n.retryQueue,a!==null&&(n.retryQueue=null,Yi(e,a))));break;case 19:ga(t,e),xa(e),n&4&&(n=e.updateQueue,n!==null&&(e.updateQueue=null,Yi(e,n)));break;case 30:break;case 21:break;default:ga(t,e),xa(e)}}function xa(e){var t=e.flags;if(t&2){try{for(var a,n=e.return;n!==null;){if(zm(n)){a=n;break}n=n.return}if(a==null)throw Error(c(160));switch(a.tag){case 27:var s=a.stateNode,o=ou(e);Xi(e,o,s);break;case 5:var m=a.stateNode;a.flags&32&&(rl(m,""),a.flags&=-33);var y=ou(e);Xi(e,y,m);break;case 3:case 4:var A=a.stateNode.containerInfo,L=ou(e);cu(e,L,A);break;default:throw Error(c(161))}}catch(G){ct(e,e.return,G)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Hm(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Hm(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Qn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Rm(e,t.alternate,t),t=t.sibling}function or(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:yl(4,t,t.return),or(t);break;case 1:An(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Em(t,t.return,a),or(t);break;case 27:Zs(t.stateNode);case 26:case 5:An(t,t.return),or(t);break;case 22:t.memoizedState===null&&or(t);break;case 30:or(t);break;default:or(t)}e=e.sibling}}function Zn(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var n=t.alternate,s=e,o=t,m=o.flags;switch(o.tag){case 0:case 11:case 15:Zn(s,o,a),qs(4,o);break;case 1:if(Zn(s,o,a),n=o,s=n.stateNode,typeof s.componentDidMount=="function")try{s.componentDidMount()}catch(L){ct(n,n.return,L)}if(n=o,s=n.updateQueue,s!==null){var y=n.stateNode;try{var A=s.shared.hiddenCallbacks;if(A!==null)for(s.shared.hiddenCallbacks=null,s=0;s<A.length;s++)bf(A[s],y)}catch(L){ct(n,n.return,L)}}a&&m&64&&Tm(o),Bs(o,o.return);break;case 27:Dm(o);case 26:case 5:Zn(s,o,a),a&&n===null&&m&4&&Mm(o),Bs(o,o.return);break;case 12:Zn(s,o,a);break;case 31:Zn(s,o,a),a&&m&4&&$m(s,o);break;case 13:Zn(s,o,a),a&&m&4&&qm(s,o);break;case 22:o.memoizedState===null&&Zn(s,o,a),Bs(o,o.return);break;case 30:break;default:Zn(s,o,a)}t=t.sibling}}function du(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Cs(a))}function fu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cs(e))}function mn(e,t,a,n){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Fm(e,t,a,n),t=t.sibling}function Fm(e,t,a,n){var s=t.flags;switch(t.tag){case 0:case 11:case 15:mn(e,t,a,n),s&2048&&qs(9,t);break;case 1:mn(e,t,a,n);break;case 3:mn(e,t,a,n),s&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cs(e)));break;case 12:if(s&2048){mn(e,t,a,n),e=t.stateNode;try{var o=t.memoizedProps,m=o.id,y=o.onPostCommit;typeof y=="function"&&y(m,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(A){ct(t,t.return,A)}}else mn(e,t,a,n);break;case 31:mn(e,t,a,n);break;case 13:mn(e,t,a,n);break;case 23:break;case 22:o=t.stateNode,m=t.alternate,t.memoizedState!==null?o._visibility&2?mn(e,t,a,n):Hs(e,t):o._visibility&2?mn(e,t,a,n):(o._visibility|=2,Vr(e,t,a,n,(t.subtreeFlags&10256)!==0||!1)),s&2048&&du(m,t);break;case 24:mn(e,t,a,n),s&2048&&fu(t.alternate,t);break;default:mn(e,t,a,n)}}function Vr(e,t,a,n,s){for(s=s&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var o=e,m=t,y=a,A=n,L=m.flags;switch(m.tag){case 0:case 11:case 15:Vr(o,m,y,A,s),qs(8,m);break;case 23:break;case 22:var G=m.stateNode;m.memoizedState!==null?G._visibility&2?Vr(o,m,y,A,s):Hs(o,m):(G._visibility|=2,Vr(o,m,y,A,s)),s&&L&2048&&du(m.alternate,m);break;case 24:Vr(o,m,y,A,s),s&&L&2048&&fu(m.alternate,m);break;default:Vr(o,m,y,A,s)}t=t.sibling}}function Hs(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,n=t,s=n.flags;switch(n.tag){case 22:Hs(a,n),s&2048&&du(n.alternate,n);break;case 24:Hs(a,n),s&2048&&fu(n.alternate,n);break;default:Hs(a,n)}t=t.sibling}}var Fs=8192;function Xr(e,t,a){if(e.subtreeFlags&Fs)for(e=e.child;e!==null;)Im(e,t,a),e=e.sibling}function Im(e,t,a){switch(e.tag){case 26:Xr(e,t,a),e.flags&Fs&&e.memoizedState!==null&&tx(a,fn,e.memoizedState,e.memoizedProps);break;case 5:Xr(e,t,a);break;case 3:case 4:var n=fn;fn=io(e.stateNode.containerInfo),Xr(e,t,a),fn=n;break;case 22:e.memoizedState===null&&(n=e.alternate,n!==null&&n.memoizedState!==null?(n=Fs,Fs=16777216,Xr(e,t,a),Fs=n):Xr(e,t,a));break;default:Xr(e,t,a)}}function Gm(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Is(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var n=t[a];Gt=n,Xm(n,e)}Gm(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Vm(e),e=e.sibling}function Vm(e){switch(e.tag){case 0:case 11:case 15:Is(e),e.flags&2048&&yl(9,e,e.return);break;case 3:Is(e);break;case 12:Is(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Qi(e)):Is(e);break;default:Is(e)}}function Qi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var n=t[a];Gt=n,Xm(n,e)}Gm(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:yl(8,t,t.return),Qi(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,Qi(t));break;default:Qi(t)}e=e.sibling}}function Xm(e,t){for(;Gt!==null;){var a=Gt;switch(a.tag){case 0:case 11:case 15:yl(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var n=a.memoizedState.cachePool.pool;n!=null&&n.refCount++}break;case 24:Cs(a.memoizedState.cache)}if(n=a.child,n!==null)n.return=a,Gt=n;else e:for(a=e;Gt!==null;){n=Gt;var s=n.sibling,o=n.return;if(Um(n),n===a){Gt=null;break e}if(s!==null){s.return=o,Gt=s;break e}Gt=o}}}var g0={getCacheForType:function(e){var t=Jt(Lt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return Jt(Lt).controller.signal}},x0=typeof WeakMap=="function"?WeakMap:Map,st=0,ht=null,Qe=null,Je=0,ot=0,Oa=null,vl=!1,Yr=!1,mu=!1,Kn=0,jt=0,wl=0,cr=0,hu=0,$a=0,Qr=0,Gs=null,ba=null,pu=!1,Zi=0,Ym=0,Ki=1/0,Ji=null,Sl=null,$t=0,kl=null,Zr=null,Jn=0,gu=0,xu=null,Qm=null,Vs=0,bu=null;function qa(){return(st&2)!==0&&Je!==0?Je&-Je:E.T!==null?_u():an()}function Zm(){if($a===0)if((Je&536870912)===0||We){var e=it;it<<=1,(it&3932160)===0&&(it=262144),$a=e}else $a=536870912;return e=Ra.current,e!==null&&(e.flags|=32),$a}function ya(e,t,a){(e===ht&&(ot===2||ot===9)||e.cancelPendingCommit!==null)&&(Kr(e,0),_l(e,Je,$a,!1)),zn(e,a),((st&2)===0||e!==ht)&&(e===ht&&((st&2)===0&&(cr|=a),jt===4&&_l(e,Je,$a,!1)),Cn(e))}function Km(e,t,a){if((st&6)!==0)throw Error(c(327));var n=!a&&(t&127)===0&&(t&e.expiredLanes)===0||ka(e,t),s=n?v0(e,t):vu(e,t,!0),o=n;do{if(s===0){Yr&&!n&&_l(e,t,0,!1);break}else{if(a=e.current.alternate,o&&!b0(a)){s=vu(e,t,!1),o=!1;continue}if(s===2){if(o=t,e.errorRecoveryDisabledLanes&o)var m=0;else m=e.pendingLanes&-536870913,m=m!==0?m:m&536870912?536870912:0;if(m!==0){t=m;e:{var y=e;s=Gs;var A=y.current.memoizedState.isDehydrated;if(A&&(Kr(y,m).flags|=256),m=vu(y,m,!1),m!==2){if(mu&&!A){y.errorRecoveryDisabledLanes|=o,cr|=o,s=4;break e}o=ba,ba=s,o!==null&&(ba===null?ba=o:ba.push.apply(ba,o))}s=m}if(o=!1,s!==2)continue}}if(s===1){Kr(e,0),_l(e,t,0,!0);break}e:{switch(n=e,o=s,o){case 0:case 1:throw Error(c(345));case 4:if((t&4194048)!==t)break;case 6:_l(n,t,$a,!vl);break e;case 2:ba=null;break;case 3:case 5:break;default:throw Error(c(329))}if((t&62914560)===t&&(s=Zi+300-Oe(),10<s)){if(_l(n,t,$a,!vl),Mn(n,0,!0)!==0)break e;Jn=t,n.timeoutHandle=jh(Jm.bind(null,n,a,ba,Ji,pu,t,$a,cr,Qr,vl,o,"Throttled",-0,0),s);break e}Jm(n,a,ba,Ji,pu,t,$a,cr,Qr,vl,o,null,-0,0)}}break}while(!0);Cn(e)}function Jm(e,t,a,n,s,o,m,y,A,L,G,K,O,B){if(e.timeoutHandle=-1,K=t.subtreeFlags,K&8192||(K&16785408)===16785408){K={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Fa},Im(t,o,K);var ve=(o&62914560)===o?Zi-Oe():(o&4194048)===o?Ym-Oe():0;if(ve=ax(K,ve),ve!==null){Jn=o,e.cancelPendingCommit=ve(rh.bind(null,e,t,o,a,n,s,m,y,A,G,K,null,O,B)),_l(e,o,m,!L);return}}rh(e,t,o,a,n,s,m,y,A)}function b0(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var n=0;n<a.length;n++){var s=a[n],o=s.getSnapshot;s=s.value;try{if(!Da(o(),s))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function _l(e,t,a,n){t&=~hu,t&=~cr,e.suspendedLanes|=t,e.pingedLanes&=~t,n&&(e.warmLanes|=t),n=e.expirationTimes;for(var s=t;0<s;){var o=31-_e(s),m=1<<o;n[o]=-1,s&=~m}a!==0&&al(e,a,t)}function Pi(){return(st&6)===0?(Xs(0),!1):!0}function yu(){if(Qe!==null){if(ot===0)var e=Qe.return;else e=Qe,Bn=er=null,Rc(e),Br=null,Ns=0,e=Qe;for(;e!==null;)Nm(e.alternate,e),e=e.return;Qe=null}}function Kr(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,$0(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),Jn=0,yu(),ht=e,Qe=a=$n(e.current,null),Je=t,ot=0,Oa=null,vl=!1,Yr=ka(e,t),mu=!1,Qr=$a=hu=cr=wl=jt=0,ba=Gs=null,pu=!1,(t&8)!==0&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var s=31-_e(n),o=1<<s;t|=e[s],n&=~o}return Kn=t,yi(),a}function Pm(e,t){Ie=null,E.H=Us,t===qr||t===ji?(t=hf(),ot=3):t===kc?(t=hf(),ot=4):ot=t===Jc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Oa=t,Qe===null&&(jt=1,Hi(e,Ya(t,e.current)))}function Wm(){var e=Ra.current;return e===null?!0:(Je&4194048)===Je?Ja===null:(Je&62914560)===Je||(Je&536870912)!==0?e===Ja:!1}function eh(){var e=E.H;return E.H=Us,e===null?Us:e}function th(){var e=E.A;return E.A=g0,e}function Wi(){jt=4,vl||(Je&4194048)!==Je&&Ra.current!==null||(Yr=!0),(wl&134217727)===0&&(cr&134217727)===0||ht===null||_l(ht,Je,$a,!1)}function vu(e,t,a){var n=st;st|=2;var s=eh(),o=th();(ht!==e||Je!==t)&&(Ji=null,Kr(e,t)),t=!1;var m=jt;e:do try{if(ot!==0&&Qe!==null){var y=Qe,A=Oa;switch(ot){case 8:yu(),m=6;break e;case 3:case 2:case 9:case 6:Ra.current===null&&(t=!0);var L=ot;if(ot=0,Oa=null,Jr(e,y,A,L),a&&Yr){m=0;break e}break;default:L=ot,ot=0,Oa=null,Jr(e,y,A,L)}}y0(),m=jt;break}catch(G){Pm(e,G)}while(!0);return t&&e.shellSuspendCounter++,Bn=er=null,st=n,E.H=s,E.A=o,Qe===null&&(ht=null,Je=0,yi()),m}function y0(){for(;Qe!==null;)ah(Qe)}function v0(e,t){var a=st;st|=2;var n=eh(),s=th();ht!==e||Je!==t?(Ji=null,Ki=Oe()+500,Kr(e,t)):Yr=ka(e,t);e:do try{if(ot!==0&&Qe!==null){t=Qe;var o=Oa;t:switch(ot){case 1:ot=0,Oa=null,Jr(e,t,o,1);break;case 2:case 9:if(ff(o)){ot=0,Oa=null,nh(t);break}t=function(){ot!==2&&ot!==9||ht!==e||(ot=7),Cn(e)},o.then(t,t);break e;case 3:ot=7;break e;case 4:ot=5;break e;case 7:ff(o)?(ot=0,Oa=null,nh(t)):(ot=0,Oa=null,Jr(e,t,o,7));break;case 5:var m=null;switch(Qe.tag){case 26:m=Qe.memoizedState;case 5:case 27:var y=Qe;if(m?Fh(m):y.stateNode.complete){ot=0,Oa=null;var A=y.sibling;if(A!==null)Qe=A;else{var L=y.return;L!==null?(Qe=L,eo(L)):Qe=null}break t}}ot=0,Oa=null,Jr(e,t,o,5);break;case 6:ot=0,Oa=null,Jr(e,t,o,6);break;case 8:yu(),jt=6;break e;default:throw Error(c(462))}}w0();break}catch(G){Pm(e,G)}while(!0);return Bn=er=null,E.H=n,E.A=s,st=a,Qe!==null?0:(ht=null,Je=0,yi(),jt)}function w0(){for(;Qe!==null&&!Ne();)ah(Qe)}function ah(e){var t=Cm(e.alternate,e,Kn);e.memoizedProps=e.pendingProps,t===null?eo(e):Qe=t}function nh(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=vm(a,t,t.pendingProps,t.type,void 0,Je);break;case 11:t=vm(a,t,t.pendingProps,t.type.render,t.ref,Je);break;case 5:Rc(t);default:Nm(a,t),t=Qe=ef(t,Kn),t=Cm(a,t,Kn)}e.memoizedProps=e.pendingProps,t===null?eo(e):Qe=t}function Jr(e,t,a,n){Bn=er=null,Rc(t),Br=null,Ns=0;var s=t.return;try{if(c0(e,s,t,a,Je)){jt=1,Hi(e,Ya(a,e.current)),Qe=null;return}}catch(o){if(s!==null)throw Qe=s,o;jt=1,Hi(e,Ya(a,e.current)),Qe=null;return}t.flags&32768?(We||n===1?e=!0:Yr||(Je&536870912)!==0?e=!1:(vl=e=!0,(n===2||n===9||n===3||n===6)&&(n=Ra.current,n!==null&&n.tag===13&&(n.flags|=16384))),lh(t,e)):eo(t)}function eo(e){var t=e;do{if((t.flags&32768)!==0){lh(t,vl);return}e=t.return;var a=f0(t.alternate,t,Kn);if(a!==null){Qe=a;return}if(t=t.sibling,t!==null){Qe=t;return}Qe=t=e}while(t!==null);jt===0&&(jt=5)}function lh(e,t){do{var a=m0(e.alternate,e);if(a!==null){a.flags&=32767,Qe=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){Qe=e;return}Qe=e=a}while(e!==null);jt=6,Qe=null}function rh(e,t,a,n,s,o,m,y,A){e.cancelPendingCommit=null;do to();while($t!==0);if((st&6)!==0)throw Error(c(327));if(t!==null){if(t===e.current)throw Error(c(177));if(o=t.lanes|t.childLanes,o|=oc,Aa(e,a,o,m,y,A),e===ht&&(Qe=ht=null,Je=0),Zr=t,kl=e,Jn=a,gu=o,xu=s,Qm=n,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,A0(ea,function(){return uh(),null})):(e.callbackNode=null,e.callbackPriority=0),n=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||n){n=E.T,E.T=null,s=V.p,V.p=2,m=st,st|=4;try{h0(e,t,a)}finally{st=m,V.p=s,E.T=n}}$t=1,sh(),ih(),oh()}}function sh(){if($t===1){$t=0;var e=kl,t=Zr,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=E.T,E.T=null;var n=V.p;V.p=2;var s=st;st|=4;try{Bm(t,e);var o=zu,m=Vd(e.containerInfo),y=o.focusedElem,A=o.selectionRange;if(m!==y&&y&&y.ownerDocument&&Gd(y.ownerDocument.documentElement,y)){if(A!==null&&nc(y)){var L=A.start,G=A.end;if(G===void 0&&(G=L),"selectionStart"in y)y.selectionStart=L,y.selectionEnd=Math.min(G,y.value.length);else{var K=y.ownerDocument||document,O=K&&K.defaultView||window;if(O.getSelection){var B=O.getSelection(),ve=y.textContent.length,Re=Math.min(A.start,ve),mt=A.end===void 0?Re:Math.min(A.end,ve);!B.extend&&Re>mt&&(m=mt,mt=Re,Re=m);var M=Id(y,Re),T=Id(y,mt);if(M&&T&&(B.rangeCount!==1||B.anchorNode!==M.node||B.anchorOffset!==M.offset||B.focusNode!==T.node||B.focusOffset!==T.offset)){var D=K.createRange();D.setStart(M.node,M.offset),B.removeAllRanges(),Re>mt?(B.addRange(D),B.extend(T.node,T.offset)):(D.setEnd(T.node,T.offset),B.addRange(D))}}}}for(K=[],B=y;B=B.parentNode;)B.nodeType===1&&K.push({element:B,left:B.scrollLeft,top:B.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<K.length;y++){var Z=K[y];Z.element.scrollLeft=Z.left,Z.element.scrollTop=Z.top}}ho=!!Mu,zu=Mu=null}finally{st=s,V.p=n,E.T=a}}e.current=t,$t=2}}function ih(){if($t===2){$t=0;var e=kl,t=Zr,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=E.T,E.T=null;var n=V.p;V.p=2;var s=st;st|=4;try{Rm(e,t.alternate,t)}finally{st=s,V.p=n,E.T=a}}$t=3}}function oh(){if($t===4||$t===3){$t=0,Nt();var e=kl,t=Zr,a=Jn,n=Qm;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?$t=5:($t=0,Zr=kl=null,ch(e,e.pendingLanes));var s=e.pendingLanes;if(s===0&&(Sl=null),Dn(a),t=t.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(Tt,t,void 0,(t.current.flags&128)===128)}catch{}if(n!==null){t=E.T,s=V.p,V.p=2,E.T=null;try{for(var o=e.onRecoverableError,m=0;m<n.length;m++){var y=n[m];o(y.value,{componentStack:y.stack})}}finally{E.T=t,V.p=s}}(Jn&3)!==0&&to(),Cn(e),s=e.pendingLanes,(a&261930)!==0&&(s&42)!==0?e===bu?Vs++:(Vs=0,bu=e):Vs=0,Xs(0)}}function ch(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Cs(t)))}function to(){return sh(),ih(),oh(),uh()}function uh(){if($t!==5)return!1;var e=kl,t=gu;gu=0;var a=Dn(Jn),n=E.T,s=V.p;try{V.p=32>a?32:a,E.T=null,a=xu,xu=null;var o=kl,m=Jn;if($t=0,Zr=kl=null,Jn=0,(st&6)!==0)throw Error(c(331));var y=st;if(st|=4,Vm(o.current),Fm(o,o.current,m,a),st=y,Xs(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(Tt,o)}catch{}return!0}finally{V.p=s,E.T=n,ch(e,t)}}function dh(e,t,a){t=Ya(a,t),t=Kc(e.stateNode,t,2),e=gl(e,t,2),e!==null&&(zn(e,2),Cn(e))}function ct(e,t,a){if(e.tag===3)dh(e,e,a);else for(;t!==null;){if(t.tag===3){dh(t,e,a);break}else if(t.tag===1){var n=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Sl===null||!Sl.has(n))){e=Ya(a,e),a=fm(2),n=gl(t,a,2),n!==null&&(mm(a,n,t,e),zn(n,2),Cn(n));break}}t=t.return}}function wu(e,t,a){var n=e.pingCache;if(n===null){n=e.pingCache=new x0;var s=new Set;n.set(t,s)}else s=n.get(t),s===void 0&&(s=new Set,n.set(t,s));s.has(a)||(mu=!0,s.add(a),e=S0.bind(null,e,t,a),t.then(e,e))}function S0(e,t,a){var n=e.pingCache;n!==null&&n.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,ht===e&&(Je&a)===a&&(jt===4||jt===3&&(Je&62914560)===Je&&300>Oe()-Zi?(st&2)===0&&Kr(e,0):hu|=a,Qr===Je&&(Qr=0)),Cn(e)}function fh(e,t){t===0&&(t=$l()),e=Jl(e,t),e!==null&&(zn(e,t),Cn(e))}function k0(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),fh(e,a)}function _0(e,t){var a=0;switch(e.tag){case 31:case 13:var n=e.stateNode,s=e.memoizedState;s!==null&&(a=s.retryLane);break;case 19:n=e.stateNode;break;case 22:n=e.stateNode._retryCache;break;default:throw Error(c(314))}n!==null&&n.delete(t),fh(e,a)}function A0(e,t){return xt(e,t)}var ao=null,Pr=null,Su=!1,no=!1,ku=!1,Al=0;function Cn(e){e!==Pr&&e.next===null&&(Pr===null?ao=Pr=e:Pr=Pr.next=e),no=!0,Su||(Su=!0,j0())}function Xs(e,t){if(!ku&&no){ku=!0;do for(var a=!1,n=ao;n!==null;){if(e!==0){var s=n.pendingLanes;if(s===0)var o=0;else{var m=n.suspendedLanes,y=n.pingedLanes;o=(1<<31-_e(42|e)+1)-1,o&=s&~(m&~y),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(a=!0,gh(n,o))}else o=Je,o=Mn(n,n===ht?o:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),(o&3)===0||ka(n,o)||(a=!0,gh(n,o));n=n.next}while(a);ku=!1}}function C0(){mh()}function mh(){no=Su=!1;var e=0;Al!==0&&O0()&&(e=Al);for(var t=Oe(),a=null,n=ao;n!==null;){var s=n.next,o=hh(n,t);o===0?(n.next=null,a===null?ao=s:a.next=s,s===null&&(Pr=a)):(a=n,(e!==0||(o&3)!==0)&&(no=!0)),n=s}$t!==0&&$t!==5||Xs(e),Al!==0&&(Al=0)}function hh(e,t){for(var a=e.suspendedLanes,n=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes&-62914561;0<o;){var m=31-_e(o),y=1<<m,A=s[m];A===-1?((y&a)===0||(y&n)!==0)&&(s[m]=tl(y,t)):A<=t&&(e.expiredLanes|=y),o&=~y}if(t=ht,a=Je,a=Mn(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),n=e.callbackNode,a===0||e===t&&(ot===2||ot===9)||e.cancelPendingCommit!==null)return n!==null&&n!==null&&ie(n),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||ka(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(n!==null&&ie(n),Dn(a)){case 2:case 8:a=Xt;break;case 32:a=ea;break;case 268435456:a=en;break;default:a=ea}return n=ph.bind(null,e),a=xt(a,n),e.callbackPriority=t,e.callbackNode=a,t}return n!==null&&n!==null&&ie(n),e.callbackPriority=2,e.callbackNode=null,2}function ph(e,t){if($t!==0&&$t!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(to()&&e.callbackNode!==a)return null;var n=Je;return n=Mn(e,e===ht?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),n===0?null:(Km(e,n,t),hh(e,Oe()),e.callbackNode!=null&&e.callbackNode===a?ph.bind(null,e):null)}function gh(e,t){if(to())return null;Km(e,t,!0)}function j0(){q0(function(){(st&6)!==0?xt(da,C0):mh()})}function _u(){if(Al===0){var e=Or;e===0&&(e=bt,bt<<=1,(bt&261888)===0&&(bt=256)),Al=e}return Al}function xh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:il(""+e)}function bh(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function N0(e,t,a,n,s){if(t==="submit"&&a&&a.stateNode===s){var o=xh((s[At]||null).action),m=n.submitter;m&&(t=(t=m[At]||null)?xh(t.formAction):m.getAttribute("formAction"),t!==null&&(o=t,m=null));var y=new Xl("action","action",null,n,s);e.push({event:y,listeners:[{instance:null,listener:function(){if(n.defaultPrevented){if(Al!==0){var A=m?bh(s,m):new FormData(s);Gc(a,{pending:!0,data:A,method:s.method,action:o},null,A)}}else typeof o=="function"&&(y.preventDefault(),A=m?bh(s,m):new FormData(s),Gc(a,{pending:!0,data:A,method:s.method,action:o},o,A))},currentTarget:s}]})}}for(var Au=0;Au<ic.length;Au++){var Cu=ic[Au],T0=Cu.toLowerCase(),E0=Cu[0].toUpperCase()+Cu.slice(1);dn(T0,"on"+E0)}dn(Qd,"onAnimationEnd"),dn(Zd,"onAnimationIteration"),dn(Kd,"onAnimationStart"),dn("dblclick","onDoubleClick"),dn("focusin","onFocus"),dn("focusout","onBlur"),dn(Xg,"onTransitionRun"),dn(Yg,"onTransitionStart"),dn(Qg,"onTransitionCancel"),dn(Jd,"onTransitionEnd"),Rn("onMouseEnter",["mouseout","mouseover"]),Rn("onMouseLeave",["mouseout","mouseover"]),Rn("onPointerEnter",["pointerout","pointerover"]),Rn("onPointerLeave",["pointerout","pointerover"]),ln("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ln("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ln("onBeforeInput",["compositionend","keypress","textInput","paste"]),ln("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ln("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ln("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Ys="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),M0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Ys));function yh(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var n=e[a],s=n.event;n=n.listeners;e:{var o=void 0;if(t)for(var m=n.length-1;0<=m;m--){var y=n[m],A=y.instance,L=y.currentTarget;if(y=y.listener,A!==o&&s.isPropagationStopped())break e;o=y,s.currentTarget=L;try{o(s)}catch(G){bi(G)}s.currentTarget=null,o=A}else for(m=0;m<n.length;m++){if(y=n[m],A=y.instance,L=y.currentTarget,y=y.listener,A!==o&&s.isPropagationStopped())break e;o=y,s.currentTarget=L;try{o(s)}catch(G){bi(G)}s.currentTarget=null,o=A}}}}function Ze(e,t){var a=t[Bl];a===void 0&&(a=t[Bl]=new Set);var n=e+"__bubble";a.has(n)||(vh(t,e,2,!1),a.add(n))}function ju(e,t,a){var n=0;t&&(n|=4),vh(a,e,n,t)}var lo="_reactListening"+Math.random().toString(36).slice(2);function Nu(e){if(!e[lo]){e[lo]=!0,nn.forEach(function(a){a!=="selectionchange"&&(M0.has(a)||ju(a,!1,e),ju(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[lo]||(t[lo]=!0,ju("selectionchange",!1,t))}}function vh(e,t,a,n){switch(Zh(t)){case 2:var s=rx;break;case 8:s=sx;break;default:s=Iu}a=s.bind(null,t,a,e),s=void 0,!Il||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),n?s!==void 0?e.addEventListener(t,a,{capture:!0,passive:s}):e.addEventListener(t,a,!0):s!==void 0?e.addEventListener(t,a,{passive:s}):e.addEventListener(t,a,!1)}function Tu(e,t,a,n,s){var o=n;if((t&1)===0&&(t&2)===0&&n!==null)e:for(;;){if(n===null)return;var m=n.tag;if(m===3||m===4){var y=n.stateNode.containerInfo;if(y===s)break;if(m===4)for(m=n.return;m!==null;){var A=m.tag;if((A===3||A===4)&&m.stateNode.containerInfo===s)return;m=m.return}for(;y!==null;){if(m=re(y),m===null)return;if(A=m.tag,A===5||A===6||A===26||A===27){n=o=m;continue e}y=y.parentNode}}n=n.return}wr(function(){var L=o,G=vr(a),K=[];e:{var O=Pd.get(e);if(O!==void 0){var B=Xl,ve=e;switch(e){case"keypress":if(kr(a)===0)break e;case"keydown":case"keyup":B=Cr;break;case"focusin":ve="focus",B=ys;break;case"focusout":ve="blur",B=ys;break;case"beforeblur":case"afterblur":B=ys;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":B=xs;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":B=bs;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":B=ia;break;case Qd:case Zd:case Kd:B=pi;break;case Jd:B=un;break;case"scroll":case"scrollend":B=hs;break;case"wheel":B=Po;break;case"copy":case"cut":case"paste":B=ne;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":B=cl;break;case"toggle":case"beforetoggle":B=ec}var Re=(t&4)!==0,mt=!Re&&(e==="scroll"||e==="scrollend"),M=Re?O!==null?O+"Capture":null:O;Re=[];for(var T=L,D;T!==null;){var Z=T;if(D=Z.stateNode,Z=Z.tag,Z!==5&&Z!==26&&Z!==27||D===null||M===null||(Z=vn(T,M),Z!=null&&Re.push(Qs(T,Z,D))),mt)break;T=T.return}0<Re.length&&(O=new B(O,ve,null,a,G),K.push({event:O,listeners:Re}))}}if((t&7)===0){e:{if(O=e==="mouseover"||e==="pointerover",B=e==="mouseout"||e==="pointerout",O&&a!==wt&&(ve=a.relatedTarget||a.fromElement)&&(re(ve)||ve[fa]))break e;if((B||O)&&(O=G.window===G?G:(O=G.ownerDocument)?O.defaultView||O.parentWindow:window,B?(ve=a.relatedTarget||a.toElement,B=L,ve=ve?re(ve):null,ve!==null&&(mt=f(ve),Re=ve.tag,ve!==mt||Re!==5&&Re!==27&&Re!==6)&&(ve=null)):(B=null,ve=L),B!==ve)){if(Re=xs,Z="onMouseLeave",M="onMouseEnter",T="mouse",(e==="pointerout"||e==="pointerover")&&(Re=cl,Z="onPointerLeave",M="onPointerEnter",T="pointer"),mt=B==null?O:he(B),D=ve==null?O:he(ve),O=new Re(Z,T+"leave",B,a,G),O.target=mt,O.relatedTarget=D,Z=null,re(G)===L&&(Re=new Re(M,T+"enter",ve,a,G),Re.target=D,Re.relatedTarget=mt,Z=Re),mt=Z,B&&ve)t:{for(Re=z0,M=B,T=ve,D=0,Z=M;Z;Z=Re(Z))D++;Z=0;for(var Me=T;Me;Me=Re(Me))Z++;for(;0<D-Z;)M=Re(M),D--;for(;0<Z-D;)T=Re(T),Z--;for(;D--;){if(M===T||T!==null&&M===T.alternate){Re=M;break t}M=Re(M),T=Re(T)}Re=null}else Re=null;B!==null&&wh(K,O,B,Re,!1),ve!==null&&mt!==null&&wh(K,mt,ve,Re,!0)}}e:{if(O=L?he(L):window,B=O.nodeName&&O.nodeName.toLowerCase(),B==="select"||B==="input"&&O.type==="file")var nt=Od;else if(Rd(O))if($d)nt=Ig;else{nt=Hg;var Se=Bg}else B=O.nodeName,!B||B.toLowerCase()!=="input"||O.type!=="checkbox"&&O.type!=="radio"?L&&Fl(L.elementType)&&(nt=Od):nt=Fg;if(nt&&(nt=nt(e,L))){Ud(K,nt,a,G);break e}Se&&Se(e,O,L),e==="focusout"&&L&&O.type==="number"&&L.memoizedProps.value!=null&&rn(O,"number",O.value)}switch(Se=L?he(L):window,e){case"focusin":(Rd(Se)||Se.contentEditable==="true")&&(Tr=Se,lc=L,ks=null);break;case"focusout":ks=lc=Tr=null;break;case"mousedown":rc=!0;break;case"contextmenu":case"mouseup":case"dragend":rc=!1,Xd(K,a,G);break;case"selectionchange":if(Vg)break;case"keydown":case"keyup":Xd(K,a,G)}var Ge;if(Va)e:{switch(e){case"compositionstart":var Pe="onCompositionStart";break e;case"compositionend":Pe="onCompositionEnd";break e;case"compositionupdate":Pe="onCompositionUpdate";break e}Pe=void 0}else Nr?Dd(e,a)&&(Pe="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Pe="onCompositionStart");Pe&&(Ed&&a.locale!=="ko"&&(Nr||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&Nr&&(Ge=Vl()):(Ea=G,Sr="value"in Ea?Ea.value:Ea.textContent,Nr=!0)),Se=ro(L,Pe),0<Se.length&&(Pe=new $e(Pe,e,null,a,G),K.push({event:Pe,listeners:Se}),Ge?Pe.data=Ge:(Ge=Ld(a),Ge!==null&&(Pe.data=Ge)))),(Ge=Ql?Ug(e,a):Og(e,a))&&(Pe=ro(L,"onBeforeInput"),0<Pe.length&&(Se=new $e("onBeforeInput","beforeinput",null,a,G),K.push({event:Se,listeners:Pe}),Se.data=Ge)),N0(K,e,L,a,G)}yh(K,t)})}function Qs(e,t,a){return{instance:e,listener:t,currentTarget:a}}function ro(e,t){for(var a=t+"Capture",n=[];e!==null;){var s=e,o=s.stateNode;if(s=s.tag,s!==5&&s!==26&&s!==27||o===null||(s=vn(e,a),s!=null&&n.unshift(Qs(e,s,o)),s=vn(e,t),s!=null&&n.push(Qs(e,s,o))),e.tag===3)return n;e=e.return}return[]}function z0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function wh(e,t,a,n,s){for(var o=t._reactName,m=[];a!==null&&a!==n;){var y=a,A=y.alternate,L=y.stateNode;if(y=y.tag,A!==null&&A===n)break;y!==5&&y!==26&&y!==27||L===null||(A=L,s?(L=vn(a,o),L!=null&&m.unshift(Qs(a,L,A))):s||(L=vn(a,o),L!=null&&m.push(Qs(a,L,A)))),a=a.return}m.length!==0&&e.push({event:t,listeners:m})}var D0=/\r\n?/g,L0=/\u0000|\uFFFD/g;function Sh(e){return(typeof e=="string"?e:""+e).replace(D0,`
|
|
26
|
-
`).replace(L0,"")}function kh(e,t){return t=Sh(t),Sh(e)===t}function ft(e,t,a,n,s,o){switch(a){case"children":typeof n=="string"?t==="body"||t==="textarea"&&n===""||rl(e,n):(typeof n=="number"||typeof n=="bigint")&&t!=="body"&&rl(e,""+n);break;case"className":ma(e,"class",n);break;case"tabIndex":ma(e,"tabindex",n);break;case"dir":case"role":case"viewBox":case"width":case"height":ma(e,a,n);break;case"style":sl(e,n,o);break;case"data":if(t!=="object"){ma(e,"data",n);break}case"src":case"href":if(n===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(n==null||typeof n=="function"||typeof n=="symbol"||typeof n=="boolean"){e.removeAttribute(a);break}n=il(""+n),e.setAttribute(a,n);break;case"action":case"formAction":if(typeof n=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof o=="function"&&(a==="formAction"?(t!=="input"&&ft(e,t,"name",s.name,s,null),ft(e,t,"formEncType",s.formEncType,s,null),ft(e,t,"formMethod",s.formMethod,s,null),ft(e,t,"formTarget",s.formTarget,s,null)):(ft(e,t,"encType",s.encType,s,null),ft(e,t,"method",s.method,s,null),ft(e,t,"target",s.target,s,null)));if(n==null||typeof n=="symbol"||typeof n=="boolean"){e.removeAttribute(a);break}n=il(""+n),e.setAttribute(a,n);break;case"onClick":n!=null&&(e.onclick=Fa);break;case"onScroll":n!=null&&Ze("scroll",e);break;case"onScrollEnd":n!=null&&Ze("scrollend",e);break;case"dangerouslySetInnerHTML":if(n!=null){if(typeof n!="object"||!("__html"in n))throw Error(c(61));if(a=n.__html,a!=null){if(s.children!=null)throw Error(c(60));e.innerHTML=a}}break;case"multiple":e.multiple=n&&typeof n!="function"&&typeof n!="symbol";break;case"muted":e.muted=n&&typeof n!="function"&&typeof n!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(n==null||typeof n=="function"||typeof n=="boolean"||typeof n=="symbol"){e.removeAttribute("xlink:href");break}a=il(""+n),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":n!=null&&typeof n!="function"&&typeof n!="symbol"?e.setAttribute(a,""+n):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":n&&typeof n!="function"&&typeof n!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":n===!0?e.setAttribute(a,""):n!==!1&&n!=null&&typeof n!="function"&&typeof n!="symbol"?e.setAttribute(a,n):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":n!=null&&typeof n!="function"&&typeof n!="symbol"&&!isNaN(n)&&1<=n?e.setAttribute(a,n):e.removeAttribute(a);break;case"rowSpan":case"start":n==null||typeof n=="function"||typeof n=="symbol"||isNaN(n)?e.removeAttribute(a):e.setAttribute(a,n);break;case"popover":Ze("beforetoggle",e),Ze("toggle",e),pr(e,"popover",n);break;case"xlinkActuate":Na(e,"http://www.w3.org/1999/xlink","xlink:actuate",n);break;case"xlinkArcrole":Na(e,"http://www.w3.org/1999/xlink","xlink:arcrole",n);break;case"xlinkRole":Na(e,"http://www.w3.org/1999/xlink","xlink:role",n);break;case"xlinkShow":Na(e,"http://www.w3.org/1999/xlink","xlink:show",n);break;case"xlinkTitle":Na(e,"http://www.w3.org/1999/xlink","xlink:title",n);break;case"xlinkType":Na(e,"http://www.w3.org/1999/xlink","xlink:type",n);break;case"xmlBase":Na(e,"http://www.w3.org/XML/1998/namespace","xml:base",n);break;case"xmlLang":Na(e,"http://www.w3.org/XML/1998/namespace","xml:lang",n);break;case"xmlSpace":Na(e,"http://www.w3.org/XML/1998/namespace","xml:space",n);break;case"is":pr(e,"is",n);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=sa.get(a)||a,pr(e,a,n))}}function Eu(e,t,a,n,s,o){switch(a){case"style":sl(e,n,o);break;case"dangerouslySetInnerHTML":if(n!=null){if(typeof n!="object"||!("__html"in n))throw Error(c(61));if(a=n.__html,a!=null){if(s.children!=null)throw Error(c(60));e.innerHTML=a}}break;case"children":typeof n=="string"?rl(e,n):(typeof n=="number"||typeof n=="bigint")&&rl(e,""+n);break;case"onScroll":n!=null&&Ze("scroll",e);break;case"onScrollEnd":n!=null&&Ze("scrollend",e);break;case"onClick":n!=null&&(e.onclick=Fa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ln.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(s=a.endsWith("Capture"),t=a.slice(2,s?a.length-7:void 0),o=e[At]||null,o=o!=null?o[a]:null,typeof o=="function"&&e.removeEventListener(t,o,s),typeof n=="function")){typeof o!="function"&&o!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,n,s);break e}a in e?e[a]=n:n===!0?e.setAttribute(a,""):pr(e,a,n)}}}function Wt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ze("error",e),Ze("load",e);var n=!1,s=!1,o;for(o in a)if(a.hasOwnProperty(o)){var m=a[o];if(m!=null)switch(o){case"src":n=!0;break;case"srcSet":s=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:ft(e,t,o,m,a,null)}}s&&ft(e,t,"srcSet",a.srcSet,a,null),n&&ft(e,t,"src",a.src,a,null);return;case"input":Ze("invalid",e);var y=o=m=s=null,A=null,L=null;for(n in a)if(a.hasOwnProperty(n)){var G=a[n];if(G!=null)switch(n){case"name":s=G;break;case"type":m=G;break;case"checked":A=G;break;case"defaultChecked":L=G;break;case"value":o=G;break;case"defaultValue":y=G;break;case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(c(137,t));break;default:ft(e,t,n,G,a,null)}}us(e,o,y,A,L,m,s,!1);return;case"select":Ze("invalid",e),n=m=o=null;for(s in a)if(a.hasOwnProperty(s)&&(y=a[s],y!=null))switch(s){case"value":o=y;break;case"defaultValue":m=y;break;case"multiple":n=y;default:ft(e,t,s,y,a,null)}t=o,a=m,e.multiple=!!n,t!=null?ll(e,!!n,t,!1):a!=null&&ll(e,!!n,a,!0);return;case"textarea":Ze("invalid",e),o=s=n=null;for(m in a)if(a.hasOwnProperty(m)&&(y=a[m],y!=null))switch(m){case"value":n=y;break;case"defaultValue":s=y;break;case"children":o=y;break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(c(91));break;default:ft(e,t,m,y,a,null)}sn(e,n,s,o);return;case"option":for(A in a)if(a.hasOwnProperty(A)&&(n=a[A],n!=null))switch(A){case"selected":e.selected=n&&typeof n!="function"&&typeof n!="symbol";break;default:ft(e,t,A,n,a,null)}return;case"dialog":Ze("beforetoggle",e),Ze("toggle",e),Ze("cancel",e),Ze("close",e);break;case"iframe":case"object":Ze("load",e);break;case"video":case"audio":for(n=0;n<Ys.length;n++)Ze(Ys[n],e);break;case"image":Ze("error",e),Ze("load",e);break;case"details":Ze("toggle",e);break;case"embed":case"source":case"link":Ze("error",e),Ze("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(L in a)if(a.hasOwnProperty(L)&&(n=a[L],n!=null))switch(L){case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:ft(e,t,L,n,a,null)}return;default:if(Fl(t)){for(G in a)a.hasOwnProperty(G)&&(n=a[G],n!==void 0&&Eu(e,t,G,n,a,void 0));return}}for(y in a)a.hasOwnProperty(y)&&(n=a[y],n!=null&&ft(e,t,y,n,a,null))}function R0(e,t,a,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var s=null,o=null,m=null,y=null,A=null,L=null,G=null;for(B in a){var K=a[B];if(a.hasOwnProperty(B)&&K!=null)switch(B){case"checked":break;case"value":break;case"defaultValue":A=K;default:n.hasOwnProperty(B)||ft(e,t,B,null,n,K)}}for(var O in n){var B=n[O];if(K=a[O],n.hasOwnProperty(O)&&(B!=null||K!=null))switch(O){case"type":o=B;break;case"name":s=B;break;case"checked":L=B;break;case"defaultChecked":G=B;break;case"value":m=B;break;case"defaultValue":y=B;break;case"children":case"dangerouslySetInnerHTML":if(B!=null)throw Error(c(137,t));break;default:B!==K&&ft(e,t,O,B,n,K)}}cs(e,m,y,A,L,G,o,s);return;case"select":B=m=y=O=null;for(o in a)if(A=a[o],a.hasOwnProperty(o)&&A!=null)switch(o){case"value":break;case"multiple":B=A;default:n.hasOwnProperty(o)||ft(e,t,o,null,n,A)}for(s in n)if(o=n[s],A=a[s],n.hasOwnProperty(s)&&(o!=null||A!=null))switch(s){case"value":O=o;break;case"defaultValue":y=o;break;case"multiple":m=o;default:o!==A&&ft(e,t,s,o,n,A)}t=y,a=m,n=B,O!=null?ll(e,!!a,O,!1):!!n!=!!a&&(t!=null?ll(e,!!a,t,!0):ll(e,!!a,a?[]:"",!1));return;case"textarea":B=O=null;for(y in a)if(s=a[y],a.hasOwnProperty(y)&&s!=null&&!n.hasOwnProperty(y))switch(y){case"value":break;case"children":break;default:ft(e,t,y,null,n,s)}for(m in n)if(s=n[m],o=a[m],n.hasOwnProperty(m)&&(s!=null||o!=null))switch(m){case"value":O=s;break;case"defaultValue":B=s;break;case"children":break;case"dangerouslySetInnerHTML":if(s!=null)throw Error(c(91));break;default:s!==o&&ft(e,t,m,s,n,o)}ds(e,O,B);return;case"option":for(var ve in a)if(O=a[ve],a.hasOwnProperty(ve)&&O!=null&&!n.hasOwnProperty(ve))switch(ve){case"selected":e.selected=!1;break;default:ft(e,t,ve,null,n,O)}for(A in n)if(O=n[A],B=a[A],n.hasOwnProperty(A)&&O!==B&&(O!=null||B!=null))switch(A){case"selected":e.selected=O&&typeof O!="function"&&typeof O!="symbol";break;default:ft(e,t,A,O,n,B)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Re in a)O=a[Re],a.hasOwnProperty(Re)&&O!=null&&!n.hasOwnProperty(Re)&&ft(e,t,Re,null,n,O);for(L in n)if(O=n[L],B=a[L],n.hasOwnProperty(L)&&O!==B&&(O!=null||B!=null))switch(L){case"children":case"dangerouslySetInnerHTML":if(O!=null)throw Error(c(137,t));break;default:ft(e,t,L,O,n,B)}return;default:if(Fl(t)){for(var mt in a)O=a[mt],a.hasOwnProperty(mt)&&O!==void 0&&!n.hasOwnProperty(mt)&&Eu(e,t,mt,void 0,n,O);for(G in n)O=n[G],B=a[G],!n.hasOwnProperty(G)||O===B||O===void 0&&B===void 0||Eu(e,t,G,O,n,B);return}}for(var M in a)O=a[M],a.hasOwnProperty(M)&&O!=null&&!n.hasOwnProperty(M)&&ft(e,t,M,null,n,O);for(K in n)O=n[K],B=a[K],!n.hasOwnProperty(K)||O===B||O==null&&B==null||ft(e,t,K,O,n,B)}function _h(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function U0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),n=0;n<a.length;n++){var s=a[n],o=s.transferSize,m=s.initiatorType,y=s.duration;if(o&&y&&_h(m)){for(m=0,y=s.responseEnd,n+=1;n<a.length;n++){var A=a[n],L=A.startTime;if(L>y)break;var G=A.transferSize,K=A.initiatorType;G&&_h(K)&&(A=A.responseEnd,m+=G*(A<y?1:(y-L)/(A-L)))}if(--n,t+=8*(o+m)/(s.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Mu=null,zu=null;function so(e){return e.nodeType===9?e:e.ownerDocument}function Ah(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Ch(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function Du(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Lu=null;function O0(){var e=window.event;return e&&e.type==="popstate"?e===Lu?!1:(Lu=e,!0):(Lu=null,!1)}var jh=typeof setTimeout=="function"?setTimeout:void 0,$0=typeof clearTimeout=="function"?clearTimeout:void 0,Nh=typeof Promise=="function"?Promise:void 0,q0=typeof queueMicrotask=="function"?queueMicrotask:typeof Nh<"u"?function(e){return Nh.resolve(null).then(e).catch(B0)}:jh;function B0(e){setTimeout(function(){throw e})}function Cl(e){return e==="head"}function Th(e,t){var a=t,n=0;do{var s=a.nextSibling;if(e.removeChild(a),s&&s.nodeType===8)if(a=s.data,a==="/$"||a==="/&"){if(n===0){e.removeChild(s),as(t);return}n--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")n++;else if(a==="html")Zs(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Zs(a);for(var o=a.firstChild;o;){var m=o.nextSibling,y=o.nodeName;o[yn]||y==="SCRIPT"||y==="STYLE"||y==="LINK"&&o.rel.toLowerCase()==="stylesheet"||a.removeChild(o),o=m}}else a==="body"&&Zs(e.ownerDocument.body);a=s}while(a);as(t)}function Eh(e,t){var a=e;e=0;do{var n=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),n&&n.nodeType===8)if(a=n.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=n}while(a)}function Ru(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Ru(a),Ca(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function H0(e,t,a,n){for(;e.nodeType===1;){var s=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!n&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(n){if(!e[yn])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(o=e.getAttribute("rel"),o==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(o!==s.rel||e.getAttribute("href")!==(s.href==null||s.href===""?null:s.href)||e.getAttribute("crossorigin")!==(s.crossOrigin==null?null:s.crossOrigin)||e.getAttribute("title")!==(s.title==null?null:s.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(o=e.getAttribute("src"),(o!==(s.src==null?null:s.src)||e.getAttribute("type")!==(s.type==null?null:s.type)||e.getAttribute("crossorigin")!==(s.crossOrigin==null?null:s.crossOrigin))&&o&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var o=s.name==null?null:""+s.name;if(s.type==="hidden"&&e.getAttribute("name")===o)return e}else return e;if(e=Pa(e.nextSibling),e===null)break}return null}function F0(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=Pa(e.nextSibling),e===null))return null;return e}function Mh(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Pa(e.nextSibling),e===null))return null;return e}function Uu(e){return e.data==="$?"||e.data==="$~"}function Ou(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function I0(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var n=function(){t(),a.removeEventListener("DOMContentLoaded",n)};a.addEventListener("DOMContentLoaded",n),e._reactRetry=n}}function Pa(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var $u=null;function zh(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return Pa(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function Dh(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return e;t--}else a!=="/$"&&a!=="/&"||t++}e=e.previousSibling}return null}function Lh(e,t,a){switch(t=so(a),e){case"html":if(e=t.documentElement,!e)throw Error(c(452));return e;case"head":if(e=t.head,!e)throw Error(c(453));return e;case"body":if(e=t.body,!e)throw Error(c(454));return e;default:throw Error(c(451))}}function Zs(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ca(e)}var Wa=new Map,Rh=new Set;function io(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Pn=V.d;V.d={f:G0,r:V0,D:X0,C:Y0,L:Q0,m:Z0,X:J0,S:K0,M:P0};function G0(){var e=Pn.f(),t=Pi();return e||t}function V0(e){var t=qe(e);t!==null&&t.tag===5&&t.type==="form"?Pf(t):Pn.r(e)}var Wr=typeof document>"u"?null:document;function Uh(e,t,a){var n=Wr;if(n&&typeof t=="string"&&t){var s=ra(t);s='link[rel="'+e+'"][href="'+s+'"]',typeof a=="string"&&(s+='[crossorigin="'+a+'"]'),Rh.has(s)||(Rh.add(s),e={rel:e,crossOrigin:a,href:t},n.querySelector(s)===null&&(t=n.createElement("link"),Wt(t,"link",e),Ke(t),n.head.appendChild(t)))}}function X0(e){Pn.D(e),Uh("dns-prefetch",e,null)}function Y0(e,t){Pn.C(e,t),Uh("preconnect",e,t)}function Q0(e,t,a){Pn.L(e,t,a);var n=Wr;if(n&&e&&t){var s='link[rel="preload"][as="'+ra(t)+'"]';t==="image"&&a&&a.imageSrcSet?(s+='[imagesrcset="'+ra(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(s+='[imagesizes="'+ra(a.imageSizes)+'"]')):s+='[href="'+ra(e)+'"]';var o=s;switch(t){case"style":o=es(e);break;case"script":o=ts(e)}Wa.has(o)||(e=w({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),Wa.set(o,e),n.querySelector(s)!==null||t==="style"&&n.querySelector(Ks(o))||t==="script"&&n.querySelector(Js(o))||(t=n.createElement("link"),Wt(t,"link",e),Ke(t),n.head.appendChild(t)))}}function Z0(e,t){Pn.m(e,t);var a=Wr;if(a&&e){var n=t&&typeof t.as=="string"?t.as:"script",s='link[rel="modulepreload"][as="'+ra(n)+'"][href="'+ra(e)+'"]',o=s;switch(n){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=ts(e)}if(!Wa.has(o)&&(e=w({rel:"modulepreload",href:e},t),Wa.set(o,e),a.querySelector(s)===null)){switch(n){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Js(o)))return}n=a.createElement("link"),Wt(n,"link",e),Ke(n),a.head.appendChild(n)}}}function K0(e,t,a){Pn.S(e,t,a);var n=Wr;if(n&&e){var s=tt(n).hoistableStyles,o=es(e);t=t||"default";var m=s.get(o);if(!m){var y={loading:0,preload:null};if(m=n.querySelector(Ks(o)))y.loading=5;else{e=w({rel:"stylesheet",href:e,"data-precedence":t},a),(a=Wa.get(o))&&qu(e,a);var A=m=n.createElement("link");Ke(A),Wt(A,"link",e),A._p=new Promise(function(L,G){A.onload=L,A.onerror=G}),A.addEventListener("load",function(){y.loading|=1}),A.addEventListener("error",function(){y.loading|=2}),y.loading|=4,oo(m,t,n)}m={type:"stylesheet",instance:m,count:1,state:y},s.set(o,m)}}}function J0(e,t){Pn.X(e,t);var a=Wr;if(a&&e){var n=tt(a).hoistableScripts,s=ts(e),o=n.get(s);o||(o=a.querySelector(Js(s)),o||(e=w({src:e,async:!0},t),(t=Wa.get(s))&&Bu(e,t),o=a.createElement("script"),Ke(o),Wt(o,"link",e),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},n.set(s,o))}}function P0(e,t){Pn.M(e,t);var a=Wr;if(a&&e){var n=tt(a).hoistableScripts,s=ts(e),o=n.get(s);o||(o=a.querySelector(Js(s)),o||(e=w({src:e,async:!0,type:"module"},t),(t=Wa.get(s))&&Bu(e,t),o=a.createElement("script"),Ke(o),Wt(o,"link",e),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},n.set(s,o))}}function Oh(e,t,a,n){var s=(s=de.current)?io(s):null;if(!s)throw Error(c(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=es(a.href),a=tt(s).hoistableStyles,n=a.get(t),n||(n={type:"style",instance:null,count:0,state:null},a.set(t,n)),n):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=es(a.href);var o=tt(s).hoistableStyles,m=o.get(e);if(m||(s=s.ownerDocument||s,m={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(e,m),(o=s.querySelector(Ks(e)))&&!o._p&&(m.instance=o,m.state.loading=5),Wa.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Wa.set(e,a),o||W0(s,e,a,m.state))),t&&n===null)throw Error(c(528,""));return m}if(t&&n!==null)throw Error(c(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=ts(a),a=tt(s).hoistableScripts,n=a.get(t),n||(n={type:"script",instance:null,count:0,state:null},a.set(t,n)),n):{type:"void",instance:null,count:0,state:null};default:throw Error(c(444,e))}}function es(e){return'href="'+ra(e)+'"'}function Ks(e){return'link[rel="stylesheet"]['+e+"]"}function $h(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function W0(e,t,a,n){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?n.loading=1:(t=e.createElement("link"),n.preload=t,t.addEventListener("load",function(){return n.loading|=1}),t.addEventListener("error",function(){return n.loading|=2}),Wt(t,"link",a),Ke(t),e.head.appendChild(t))}function ts(e){return'[src="'+ra(e)+'"]'}function Js(e){return"script[async]"+e}function qh(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var n=e.querySelector('style[data-href~="'+ra(a.href)+'"]');if(n)return t.instance=n,Ke(n),n;var s=w({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return n=(e.ownerDocument||e).createElement("style"),Ke(n),Wt(n,"style",s),oo(n,a.precedence,e),t.instance=n;case"stylesheet":s=es(a.href);var o=e.querySelector(Ks(s));if(o)return t.state.loading|=4,t.instance=o,Ke(o),o;n=$h(a),(s=Wa.get(s))&&qu(n,s),o=(e.ownerDocument||e).createElement("link"),Ke(o);var m=o;return m._p=new Promise(function(y,A){m.onload=y,m.onerror=A}),Wt(o,"link",n),t.state.loading|=4,oo(o,a.precedence,e),t.instance=o;case"script":return o=ts(a.src),(s=e.querySelector(Js(o)))?(t.instance=s,Ke(s),s):(n=a,(s=Wa.get(o))&&(n=w({},a),Bu(n,s)),e=e.ownerDocument||e,s=e.createElement("script"),Ke(s),Wt(s,"link",n),e.head.appendChild(s),t.instance=s);case"void":return null;default:throw Error(c(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(n=t.instance,t.state.loading|=4,oo(n,a.precedence,e));return t.instance}function oo(e,t,a){for(var n=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),s=n.length?n[n.length-1]:null,o=s,m=0;m<n.length;m++){var y=n[m];if(y.dataset.precedence===t)o=y;else if(o!==s)break}o?o.parentNode.insertBefore(e,o.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function qu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Bu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var co=null;function Bh(e,t,a){if(co===null){var n=new Map,s=co=new Map;s.set(a,n)}else s=co,n=s.get(a),n||(n=new Map,s.set(a,n));if(n.has(e))return n;for(n.set(e,null),a=a.getElementsByTagName(e),s=0;s<a.length;s++){var o=a[s];if(!(o[yn]||o[Et]||e==="link"&&o.getAttribute("rel")==="stylesheet")&&o.namespaceURI!=="http://www.w3.org/2000/svg"){var m=o.getAttribute(t)||"";m=e+m;var y=n.get(m);y?y.push(o):n.set(m,[o])}}return n}function Hh(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function ex(e,t,a){if(a===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Fh(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function tx(e,t,a,n){if(a.type==="stylesheet"&&(typeof n.media!="string"||matchMedia(n.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var s=es(n.href),o=t.querySelector(Ks(s));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=uo.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=o,Ke(o);return}o=t.ownerDocument||t,n=$h(n),(s=Wa.get(s))&&qu(n,s),o=o.createElement("link"),Ke(o);var m=o;m._p=new Promise(function(y,A){m.onload=y,m.onerror=A}),Wt(o,"link",n),a.instance=o}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=uo.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var Hu=0;function ax(e,t){return e.stylesheets&&e.count===0&&mo(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var n=setTimeout(function(){if(e.stylesheets&&mo(e,e.stylesheets),e.unsuspend){var o=e.unsuspend;e.unsuspend=null,o()}},6e4+t);0<e.imgBytes&&Hu===0&&(Hu=62500*U0());var s=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&mo(e,e.stylesheets),e.unsuspend)){var o=e.unsuspend;e.unsuspend=null,o()}},(e.imgBytes>Hu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(n),clearTimeout(s)}}:null}function uo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)mo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var fo=null;function mo(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,fo=new Map,t.forEach(nx,e),fo=null,uo.call(e))}function nx(e,t){if(!(t.state.loading&4)){var a=fo.get(e);if(a)var n=a.get(null);else{a=new Map,fo.set(e,a);for(var s=e.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o<s.length;o++){var m=s[o];(m.nodeName==="LINK"||m.getAttribute("media")!=="not all")&&(a.set(m.dataset.precedence,m),n=m)}n&&a.set(null,n)}s=t.instance,m=s.getAttribute("data-precedence"),o=a.get(m)||n,o===n&&a.set(null,s),a.set(m,s),this.count++,n=uo.bind(this),s.addEventListener("load",n),s.addEventListener("error",n),o?o.parentNode.insertBefore(s,o.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(s,e.firstChild)),t.state.loading|=4}}var Ps={$$typeof:Y,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function lx(e,t,a,n,s,o,m,y,A){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=_a(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_a(0),this.hiddenUpdates=_a(null),this.identifierPrefix=n,this.onUncaughtError=s,this.onCaughtError=o,this.onRecoverableError=m,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function Ih(e,t,a,n,s,o,m,y,A,L,G,K){return e=new lx(e,t,a,m,A,L,G,K,y),t=1,o===!0&&(t|=24),o=La(3,null,null,t),e.current=o,o.stateNode=e,t=vc(),t.refCount++,e.pooledCache=t,t.refCount++,o.memoizedState={element:n,isDehydrated:a,cache:t},_c(o),e}function Gh(e){return e?(e=zr,e):zr}function Vh(e,t,a,n,s,o){s=Gh(s),n.context===null?n.context=s:n.pendingContext=s,n=pl(t),n.payload={element:a},o=o===void 0?null:o,o!==null&&(n.callback=o),a=gl(e,n,t),a!==null&&(ya(a,e,t),Es(a,e,t))}function Xh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Fu(e,t){Xh(e,t),(e=e.alternate)&&Xh(e,t)}function Yh(e){if(e.tag===13||e.tag===31){var t=Jl(e,67108864);t!==null&&ya(t,e,67108864),Fu(e,67108864)}}function Qh(e){if(e.tag===13||e.tag===31){var t=qa();t=tn(t);var a=Jl(e,t);a!==null&&ya(a,e,t),Fu(e,t)}}var ho=!0;function rx(e,t,a,n){var s=E.T;E.T=null;var o=V.p;try{V.p=2,Iu(e,t,a,n)}finally{V.p=o,E.T=s}}function sx(e,t,a,n){var s=E.T;E.T=null;var o=V.p;try{V.p=8,Iu(e,t,a,n)}finally{V.p=o,E.T=s}}function Iu(e,t,a,n){if(ho){var s=Gu(n);if(s===null)Tu(e,t,n,po,a),Kh(e,n);else if(ox(s,e,t,a,n))n.stopPropagation();else if(Kh(e,n),t&4&&-1<ix.indexOf(e)){for(;s!==null;){var o=qe(s);if(o!==null)switch(o.tag){case 3:if(o=o.stateNode,o.current.memoizedState.isDehydrated){var m=la(o.pendingLanes);if(m!==0){var y=o;for(y.pendingLanes|=2,y.entangledLanes|=2;m;){var A=1<<31-_e(m);y.entanglements[1]|=A,m&=~A}Cn(o),(st&6)===0&&(Ki=Oe()+500,Xs(0))}}break;case 31:case 13:y=Jl(o,2),y!==null&&ya(y,o,2),Pi(),Fu(o,2)}if(o=Gu(n),o===null&&Tu(e,t,n,po,a),o===s)break;s=o}s!==null&&n.stopPropagation()}else Tu(e,t,n,null,a)}}function Gu(e){return e=vr(e),Vu(e)}var po=null;function Vu(e){if(po=null,e=re(e),e!==null){var t=f(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=h(t),e!==null)return e;e=null}else if(a===31){if(e=p(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return po=e,null}function Zh(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Vt()){case da:return 2;case Xt:return 8;case ea:case pn:return 32;case en:return 268435456;default:return 32}default:return 32}}var Xu=!1,jl=null,Nl=null,Tl=null,Ws=new Map,ei=new Map,El=[],ix="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Kh(e,t){switch(e){case"focusin":case"focusout":jl=null;break;case"dragenter":case"dragleave":Nl=null;break;case"mouseover":case"mouseout":Tl=null;break;case"pointerover":case"pointerout":Ws.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ei.delete(t.pointerId)}}function ti(e,t,a,n,s,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:a,eventSystemFlags:n,nativeEvent:o,targetContainers:[s]},t!==null&&(t=qe(t),t!==null&&Yh(t)),e):(e.eventSystemFlags|=n,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function ox(e,t,a,n,s){switch(t){case"focusin":return jl=ti(jl,e,t,a,n,s),!0;case"dragenter":return Nl=ti(Nl,e,t,a,n,s),!0;case"mouseover":return Tl=ti(Tl,e,t,a,n,s),!0;case"pointerover":var o=s.pointerId;return Ws.set(o,ti(Ws.get(o)||null,e,t,a,n,s)),!0;case"gotpointercapture":return o=s.pointerId,ei.set(o,ti(ei.get(o)||null,e,t,a,n,s)),!0}return!1}function Jh(e){var t=re(e.target);if(t!==null){var a=f(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){e.blockedOn=t,xn(e.priority,function(){Qh(a)});return}}else if(t===31){if(t=p(a),t!==null){e.blockedOn=t,xn(e.priority,function(){Qh(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function go(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Gu(e.nativeEvent);if(a===null){a=e.nativeEvent;var n=new a.constructor(a.type,a);wt=n,a.target.dispatchEvent(n),wt=null}else return t=qe(a),t!==null&&Yh(t),e.blockedOn=a,!1;t.shift()}return!0}function Ph(e,t,a){go(e)&&a.delete(t)}function cx(){Xu=!1,jl!==null&&go(jl)&&(jl=null),Nl!==null&&go(Nl)&&(Nl=null),Tl!==null&&go(Tl)&&(Tl=null),Ws.forEach(Ph),ei.forEach(Ph)}function xo(e,t){e.blockedOn===t&&(e.blockedOn=null,Xu||(Xu=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,cx)))}var bo=null;function Wh(e){bo!==e&&(bo=e,r.unstable_scheduleCallback(r.unstable_NormalPriority,function(){bo===e&&(bo=null);for(var t=0;t<e.length;t+=3){var a=e[t],n=e[t+1],s=e[t+2];if(typeof n!="function"){if(Vu(n||a)===null)continue;break}var o=qe(a);o!==null&&(e.splice(t,3),t-=3,Gc(o,{pending:!0,data:s,method:a.method,action:n},n,s))}}))}function as(e){function t(A){return xo(A,e)}jl!==null&&xo(jl,e),Nl!==null&&xo(Nl,e),Tl!==null&&xo(Tl,e),Ws.forEach(t),ei.forEach(t);for(var a=0;a<El.length;a++){var n=El[a];n.blockedOn===e&&(n.blockedOn=null)}for(;0<El.length&&(a=El[0],a.blockedOn===null);)Jh(a),a.blockedOn===null&&El.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(n=0;n<a.length;n+=3){var s=a[n],o=a[n+1],m=s[At]||null;if(typeof o=="function")m||Wh(a);else if(m){var y=null;if(o&&o.hasAttribute("formAction")){if(s=o,m=o[At]||null)y=m.formAction;else if(Vu(s)!==null)continue}else y=m.action;typeof y=="function"?a[n+1]=y:(a.splice(n,3),n-=3),Wh(a)}}}function ep(){function e(o){o.canIntercept&&o.info==="react-transition"&&o.intercept({handler:function(){return new Promise(function(m){return s=m})},focusReset:"manual",scroll:"manual"})}function t(){s!==null&&(s(),s=null),n||setTimeout(a,20)}function a(){if(!n&&!navigation.transition){var o=navigation.currentEntry;o&&o.url!=null&&navigation.navigate(o.url,{state:o.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var n=!1,s=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){n=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),s!==null&&(s(),s=null)}}}function Yu(e){this._internalRoot=e}yo.prototype.render=Yu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(c(409));var a=t.current,n=qa();Vh(a,n,e,t,null,null)},yo.prototype.unmount=Yu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Vh(e.current,2,null,e,null,null),Pi(),t[fa]=null}};function yo(e){this._internalRoot=e}yo.prototype.unstable_scheduleHydration=function(e){if(e){var t=an();e={blockedOn:null,target:e,priority:t};for(var a=0;a<El.length&&t!==0&&t<El[a].priority;a++);El.splice(a,0,e),a===0&&Jh(e)}};var tp=l.version;if(tp!=="19.2.7")throw Error(c(527,tp,"19.2.7"));V.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(c(188)):(e=Object.keys(e).join(","),Error(c(268,e)));return e=v(t),e=e!==null?b(e):null,e=e===null?null:e.stateNode,e};var ux={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:E,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var vo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!vo.isDisabled&&vo.supportsFiber)try{Tt=vo.inject(ux),gt=vo}catch{}}return ai.createRoot=function(e,t){if(!d(e))throw Error(c(299));var a=!1,n="",s=om,o=cm,m=um;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(n=t.identifierPrefix),t.onUncaughtError!==void 0&&(s=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(m=t.onRecoverableError)),t=Ih(e,1,!1,null,null,a,n,null,s,o,m,ep),e[fa]=t.current,Nu(e),new Yu(t)},ai.hydrateRoot=function(e,t,a){if(!d(e))throw Error(c(299));var n=!1,s="",o=om,m=cm,y=um,A=null;return a!=null&&(a.unstable_strictMode===!0&&(n=!0),a.identifierPrefix!==void 0&&(s=a.identifierPrefix),a.onUncaughtError!==void 0&&(o=a.onUncaughtError),a.onCaughtError!==void 0&&(m=a.onCaughtError),a.onRecoverableError!==void 0&&(y=a.onRecoverableError),a.formState!==void 0&&(A=a.formState)),t=Ih(e,1,!0,t,a??null,n,s,A,o,m,y,ep),t.context=Gh(null),a=t.current,n=qa(),n=tn(n),s=pl(n),s.callback=null,gl(a,s,n),a=n,t.current.lanes=a,zn(t,a),Cn(t),e[fa]=t.current,Nu(e),new yo(t)},ai.version="19.2.7",ai}var sp;function Cx(){if(sp)return Qu.exports;sp=1;function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(l){console.error(l)}}return r(),Qu.exports=Ax(),Qu.exports}var jx=Cx();const Pp=g.createContext(void 0);function ip({children:r}){const[l,i]=g.useState(()=>{const h=localStorage.getItem("chat-theme");if(h){const p=JSON.parse(h);return{mode:p.mode||"dark",highContrast:!!p.highContrast}}return{mode:"dark",highContrast:!1}}),[c,d]=g.useState(!1);g.useEffect(()=>{const h=()=>{let p=!1;l.mode==="dark"?p=!0:l.mode==="light"?p=!1:p=window.matchMedia("(prefers-color-scheme: dark)").matches,d(p);const x=document.documentElement;p?x.classList.add("dark"):x.classList.remove("dark"),l.highContrast?x.classList.add("high-contrast"):x.classList.remove("high-contrast"),x.classList.remove("text-sm","text-lg"),x.classList.add("text-base")};if(h(),l.mode==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),x=()=>{h()};return p.addEventListener("change",x),()=>p.removeEventListener("change",x)}},[l]),g.useEffect(()=>{localStorage.setItem("chat-theme",JSON.stringify(l))},[l]);const f=h=>{i(p=>({...p,...h}))};return u.jsx(Pp.Provider,{value:{theme:l,updateTheme:f,isDark:c},children:r})}function ss(){const r=g.useContext(Pp);if(!r)throw new Error("useTheme must be used within ThemeProvider");return r}const Wp=g.createContext(void 0),Ju={voiceEnabled:!1,soundEnabled:!1,autoSend:!1};function Nx({children:r}){const[l,i]=g.useState(()=>{const d=localStorage.getItem("chat-settings");if(d)try{const f=JSON.parse(d);return{...Ju,...f,voiceEnabled:!1}}catch{return Ju}return Ju});g.useEffect(()=>{localStorage.setItem("chat-settings",JSON.stringify(l))},[l]);const c=d=>{i(f=>({...f,...d}))};return u.jsx(Wp.Provider,{value:{settings:l,updateSettings:c},children:r})}function Go(){const r=g.useContext(Wp);if(!r)throw new Error("useSettings must be used within SettingsProvider");return r}/**
|
|
25
|
+
`+n.stack}}var Bt=Object.prototype.hasOwnProperty,xt=s.unstable_scheduleCallback,ie=s.unstable_cancelCallback,Ne=s.unstable_shouldYield,Tt=s.unstable_requestPaint,Oe=s.unstable_now,Vt=s.unstable_getCurrentPriorityLevel,da=s.unstable_ImmediatePriority,Xt=s.unstable_UserBlockingPriority,ea=s.unstable_NormalPriority,pn=s.unstable_LowPriority,en=s.unstable_IdlePriority,ta=s.log,gn=s.unstable_setDisableYieldValue,At=null,gt=null;function Ht(e){if(typeof ta=="function"&&gn(e),gt&&typeof gt.setStrictMode=="function")try{gt.setStrictMode(At,e)}catch{}}var _e=Math.clz32?Math.clz32:Qe,Sa=Math.log,Te=Math.LN2;function Qe(e){return e>>>=0,e===0?32:31-(Sa(e)/Te|0)|0}var bt=256,it=262144,Ae=4194304;function la(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Mn(e,t,a){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,m=e.pingedLanes;e=e.warmLanes;var y=n&134217727;return y!==0?(n=y&~o,n!==0?r=la(n):(m&=y,m!==0?r=la(m):a||(a=y&~e,a!==0&&(r=la(a))))):(y=n&~o,y!==0?r=la(y):m!==0?r=la(m):a||(a=n&~e,a!==0&&(r=la(a)))),r===0?0:t!==0&&t!==r&&(t&o)===0&&(o=r&-r,a=t&-t,o>=a||o===32&&(a&4194048)!==0)?t:r}function ka(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function tl(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function $l(){var e=Ae;return Ae<<=1,(Ae&62914560)===0&&(Ae=4194304),e}function _a(e){for(var t=[],a=0;31>a;a++)t.push(e);return t}function zn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Aa(e,t,a,n,r,o){var m=e.pendingLanes;e.pendingLanes=a,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=a,e.entangledLanes&=a,e.errorRecoveryDisabledLanes&=a,e.shellSuspendCounter=0;var y=e.entanglements,A=e.expirationTimes,L=e.hiddenUpdates;for(a=m&~a;0<a;){var G=31-_e(a),K=1<<G;y[G]=0,A[G]=-1;var O=L[G];if(O!==null)for(L[G]=null,G=0;G<O.length;G++){var B=O[G];B!==null&&(B.lane&=-536870913)}a&=~K}n!==0&&al(e,n,0),o!==0&&r===0&&e.tag!==0&&(e.suspendedLanes|=o&~(m&~t))}function al(e,t,a){e.pendingLanes|=t,e.suspendedLanes&=~t;var n=31-_e(t);e.entangledLanes|=t,e.entanglements[n]=e.entanglements[n]|1073741824|a&261930}function fs(e,t){var a=e.entangledLanes|=t;for(e=e.entanglements;a;){var n=31-_e(a),r=1<<n;r&t|e[n]&t&&(e[n]|=t),a&=~r}}function ql(e,t){var a=t&-t;return a=(a&42)!==0?1:tn(a),(a&(e.suspendedLanes|t))!==0?0:a}function tn(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Dn(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function an(){var e=V.p;return e!==0?e:(e=window.event,e===void 0?32:Zh(e.type))}function xn(e,t){var a=V.p;try{return V.p=e,t()}finally{V.p=a}}var Yt=Math.random().toString(36).slice(2),Et="__reactFiber$"+Yt,Ct="__reactProps$"+Yt,fa="__reactContainer$"+Yt,Bl="__reactEvents$"+Yt,Ft="__reactListeners$"+Yt,ms="__reactHandles$"+Yt,bn="__reactResources$"+Yt,yn="__reactMarker$"+Yt;function Ca(e){delete e[Et],delete e[Ct],delete e[Bl],delete e[Ft],delete e[ms]}function se(e){var t=e[Et];if(t)return t;for(var a=e.parentNode;a;){if(t=a[fa]||a[Et]){if(a=t.alternate,t.child!==null||a!==null&&a.child!==null)for(e=Dh(e);e!==null;){if(a=e[Et])return a;e=Dh(e)}return t}e=a,a=e.parentNode}return null}function qe(e){if(e=e[Et]||e[fa]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function he(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(c(33))}function tt(e){var t=e[bn];return t||(t=e[bn]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Ye(e){e[yn]=!0}var nn=new Set,Ln={};function ln(e,t){Rn(e,t),Rn(e+"Capture",t)}function Rn(e,t){for(Ln[e]=t,e=0;e<t.length;e++)nn.add(t[e])}var or=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),nl={},hs={};function ja(e){return Bt.call(hs,e)?!0:Bt.call(nl,e)?!1:or.test(e)?hs[e]=!0:(nl[e]=!0,!1)}function ps(e,t,a){if(ja(t))if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var n=t.toLowerCase().slice(0,5);if(n!=="data-"&&n!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+a)}}function ma(e,t,a){if(a===null)e.removeAttribute(t);else{switch(typeof a){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+a)}}function Na(e,t,a,n){if(n===null)e.removeAttribute(a);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(a);return}e.setAttributeNS(t,a,""+n)}}function ha(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function fi(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Hl(e,t,a){var n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var r=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return r.call(this)},set:function(m){a=""+m,o.call(this,m)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return a},setValue:function(m){a=""+m},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function gs(e){if(!e._valueTracker){var t=fi(e)?"checked":"value";e._valueTracker=Hl(e,t,""+e[t])}}function xs(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var a=t.getValue(),n="";return e&&(n=fi(e)?e.checked?"true":"false":e.value),e=n,e!==a?(t.setValue(e),!0):!1}function bs(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Ko=/[\n"\\]/g;function sa(e){return e.replace(Ko,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function cr(e,t,a,n,r,o,m,y){e.name="",m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"?e.type=m:e.removeAttribute("type"),t!=null?m==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+ha(t)):e.value!==""+ha(t)&&(e.value=""+ha(t)):m!=="submit"&&m!=="reset"||e.removeAttribute("value"),t!=null?sn(e,m,ha(t)):a!=null?sn(e,m,ha(a)):n!=null&&e.removeAttribute("value"),r==null&&o!=null&&(e.defaultChecked=!!o),r!=null&&(e.checked=r&&typeof r!="function"&&typeof r!="symbol"),y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"?e.name=""+ha(y):e.removeAttribute("name")}function ur(e,t,a,n,r,o,m,y){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(e.type=o),t!=null||a!=null){if(!(o!=="submit"&&o!=="reset"||t!=null)){gs(e);return}a=a!=null?""+ha(a):"",t=t!=null?""+ha(t):a,y||t===e.value||(e.value=t),e.defaultValue=t}n=n??r,n=typeof n!="function"&&typeof n!="symbol"&&!!n,e.checked=y?e.checked:!!n,e.defaultChecked=!!n,m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(e.name=m),gs(e)}function sn(e,t,a){t==="number"&&bs(e.ownerDocument)===e||e.defaultValue===""+a||(e.defaultValue=""+a)}function ll(e,t,a,n){if(e=e.options,t){t={};for(var r=0;r<a.length;r++)t["$"+a[r]]=!0;for(a=0;a<e.length;a++)r=t.hasOwnProperty("$"+e[a].value),e[a].selected!==r&&(e[a].selected=r),r&&n&&(e[a].defaultSelected=!0)}else{for(a=""+ha(a),t=null,r=0;r<e.length;r++){if(e[r].value===a){e[r].selected=!0,n&&(e[r].defaultSelected=!0);return}t!==null||e[r].disabled||(t=e[r])}t!==null&&(t.selected=!0)}}function dr(e,t,a){if(t!=null&&(t=""+ha(t),t!==e.value&&(e.value=t),a==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=a!=null?""+ha(a):""}function rn(e,t,a,n){if(t==null){if(n!=null){if(a!=null)throw Error(c(92));if(oe(n)){if(1<n.length)throw Error(c(93));n=n[0]}a=n}a==null&&(a=""),t=a}a=ha(t),e.defaultValue=a,n=e.textContent,n===a&&n!==""&&n!==null&&(e.value=n),gs(e)}function sl(e,t){if(t){var a=e.firstChild;if(a&&a===e.lastChild&&a.nodeType===3){a.nodeValue=t;return}}e.textContent=t}var mi=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function fr(e,t,a){var n=t.indexOf("--")===0;a==null||typeof a=="boolean"||a===""?n?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":n?e.setProperty(t,a):typeof a!="number"||a===0||mi.has(t)?t==="float"?e.cssFloat=a:e[t]=(""+a).trim():e[t]=a+"px"}function rl(e,t,a){if(t!=null&&typeof t!="object")throw Error(c(62));if(e=e.style,a!=null){for(var n in a)!a.hasOwnProperty(n)||t!=null&&t.hasOwnProperty(n)||(n.indexOf("--")===0?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="");for(var r in t)n=t[r],t.hasOwnProperty(r)&&a[r]!==n&&fr(e,r,n)}else for(var o in t)t.hasOwnProperty(o)&&fr(e,o,t[o])}function Fl(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ra=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ys=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function il(e){return ys.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Fa(){}var wt=null;function vs(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var on=null,Ia=null;function mr(e){var t=qe(e);if(t&&(e=t.stateNode)){var a=e[Ct]||null;e:switch(e=t.stateNode,t.type){case"input":if(cr(e,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name),t=a.name,a.type==="radio"&&t!=null){for(a=e;a.parentNode;)a=a.parentNode;for(a=a.querySelectorAll('input[name="'+sa(""+t)+'"][type="radio"]'),t=0;t<a.length;t++){var n=a[t];if(n!==e&&n.form===e.form){var r=n[Ct]||null;if(!r)throw Error(c(90));cr(n,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name)}}for(t=0;t<a.length;t++)n=a[t],n.form===e.form&&xs(n)}break e;case"textarea":dr(e,a.value,a.defaultValue);break e;case"select":t=a.value,t!=null&&ll(e,!!a.multiple,t,!1)}}}var ol=!1;function ws(e,t,a){if(ol)return e(t,a);ol=!0;try{var n=e(t);return n}finally{if(ol=!1,(on!==null||Ia!==null)&&(Pi(),on&&(t=on,e=Ia,Ia=on=null,mr(t),e)))for(t=0;t<e.length;t++)mr(e[t])}}function vn(e,t){var a=e.stateNode;if(a===null)return null;var n=a[Ct]||null;if(n===null)return null;a=n[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(e=e.type,n=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!n;break e;default:e=!1}if(e)return null;if(a&&typeof a!="function")throw Error(c(231,t,typeof a));return a}var Ta=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Il=!1;if(Ta)try{var wn={};Object.defineProperty(wn,"passive",{get:function(){Il=!0}}),window.addEventListener("test",wn,wn),window.removeEventListener("test",wn,wn)}catch{Il=!1}var Ea=null,Ss=null,Gl=null;function Vl(){if(Gl)return Gl;var e,t=Ss,a=t.length,n,r="value"in Ea?Ea.value:Ea.textContent,o=r.length;for(e=0;e<a&&t[e]===r[e];e++);var m=a-e;for(n=1;n<=m&&t[a-n]===r[o-n];n++);return Gl=r.slice(e,1<n?1-n:void 0)}function ks(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function _s(){return!0}function hi(){return!1}function aa(e){function t(a,n,r,o,m){this._reactName=a,this._targetInst=r,this.type=n,this.nativeEvent=o,this.target=m,this.currentTarget=null;for(var y in e)e.hasOwnProperty(y)&&(a=e[y],this[y]=a?a(o):o[y]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?_s:hi,this.isPropagationStopped=hi,this}return w(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var a=this.nativeEvent;a&&(a.preventDefault?a.preventDefault():typeof a.returnValue!="unknown"&&(a.returnValue=!1),this.isDefaultPrevented=_s)},stopPropagation:function(){var a=this.nativeEvent;a&&(a.stopPropagation?a.stopPropagation():typeof a.cancelBubble!="unknown"&&(a.cancelBubble=!0),this.isPropagationStopped=_s)},persist:function(){},isPersistent:_s}),t}var Un={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Xl=aa(Un),Sn=w({},Un,{view:0,detail:0}),hr=aa(Sn),pr,gr,Yl,As=w({},Sn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:cn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Yl&&(Yl&&e.type==="mousemove"?(pr=e.screenX-Yl.screenX,gr=e.screenY-Yl.screenY):gr=pr=0,Yl=e),pr)},movementY:function(e){return"movementY"in e?e.movementY:gr}}),xr=aa(As),Td=w({},As,{dataTransfer:0}),br=aa(Td),On=w({},Sn,{relatedTarget:0}),yr=aa(On),Jo=w({},Un,{animationName:0,elapsedTime:0,pseudoElement:0}),pi=aa(Jo),C=w({},Un,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ne=aa(C),Ee=w({},Un,{data:0}),$e=aa(Ee),st={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Qt={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},ut={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function at(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ut[e])?!!t[e]:!1}function cn(){return at}var Ma=w({},Sn,{key:function(e){if(e.key){var t=st[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ks(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Qt[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:cn,charCode:function(e){return e.type==="keypress"?ks(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ks(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Cs=aa(Ma),js=w({},As,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cl=aa(js),gi=w({},Sn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:cn}),ia=aa(gi),Ga=w({},Un,{propertyName:0,elapsedTime:0,pseudoElement:0}),un=aa(Ga),Zt=w({},As,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Po=aa(Zt),Wo=w({},Un,{newState:0,oldState:0}),ec=aa(Wo),za=[9,13,27,32],Va=Ta&&"CompositionEvent"in window,It=null;Ta&&"documentMode"in document&&(It=document.documentMode);var Ql=Ta&&"TextEvent"in window&&!It,Ed=Ta&&(!Va||It&&8<It&&11>=It),Md=" ",zd=!1;function Dd(e,t){switch(e){case"keyup":return za.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ld(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ns=!1;function Ug(e,t){switch(e){case"compositionend":return Ld(t);case"keypress":return t.which!==32?null:(zd=!0,Md);case"textInput":return e=t.data,e===Md&&zd?null:e;default:return null}}function Og(e,t){if(Ns)return e==="compositionend"||!Va&&Dd(e,t)?(e=Vl(),Gl=Ss=Ea=null,Ns=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Ed&&t.locale!=="ko"?null:t.data;default:return null}}var $g={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Rd(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!$g[e.type]:t==="textarea"}function Ud(e,t,a,n){on?Ia?Ia.push(n):Ia=[n]:on=n,t=so(t,"onChange"),0<t.length&&(a=new Xl("onChange","change",null,a,n),e.push({event:a,listeners:t}))}var vr=null,wr=null;function qg(e){yh(e,0)}function xi(e){var t=he(e);if(xs(t))return e}function Od(e,t){if(e==="change")return t}var $d=!1;if(Ta){var tc;if(Ta){var ac="oninput"in document;if(!ac){var qd=document.createElement("div");qd.setAttribute("oninput","return;"),ac=typeof qd.oninput=="function"}tc=ac}else tc=!1;$d=tc&&(!document.documentMode||9<document.documentMode)}function Bd(){vr&&(vr.detachEvent("onpropertychange",Hd),wr=vr=null)}function Hd(e){if(e.propertyName==="value"&&xi(wr)){var t=[];Ud(t,wr,e,vs(e)),ws(qg,t)}}function Bg(e,t,a){e==="focusin"?(Bd(),vr=t,wr=a,vr.attachEvent("onpropertychange",Hd)):e==="focusout"&&Bd()}function Hg(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return xi(wr)}function Fg(e,t){if(e==="click")return xi(t)}function Ig(e,t){if(e==="input"||e==="change")return xi(t)}function Gg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Da=typeof Object.is=="function"?Object.is:Gg;function Sr(e,t){if(Da(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var a=Object.keys(e),n=Object.keys(t);if(a.length!==n.length)return!1;for(n=0;n<a.length;n++){var r=a[n];if(!Bt.call(t,r)||!Da(e[r],t[r]))return!1}return!0}function Fd(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Id(e,t){var a=Fd(e);e=0;for(var n;a;){if(a.nodeType===3){if(n=e+a.textContent.length,e<=t&&n>=t)return{node:a,offset:t-e};e=n}e:{for(;a;){if(a.nextSibling){a=a.nextSibling;break e}a=a.parentNode}a=void 0}a=Fd(a)}}function Gd(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Gd(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vd(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=bs(e.document);t instanceof e.HTMLIFrameElement;){try{var a=typeof t.contentWindow.location.href=="string"}catch{a=!1}if(a)e=t.contentWindow;else break;t=bs(e.document)}return t}function nc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Vg=Ta&&"documentMode"in document&&11>=document.documentMode,Ts=null,lc=null,kr=null,sc=!1;function Xd(e,t,a){var n=a.window===a?a.document:a.nodeType===9?a:a.ownerDocument;sc||Ts==null||Ts!==bs(n)||(n=Ts,"selectionStart"in n&&nc(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),kr&&Sr(kr,n)||(kr=n,n=so(lc,"onSelect"),0<n.length&&(t=new Xl("onSelect","select",null,t,a),e.push({event:t,listeners:n}),t.target=Ts)))}function Zl(e,t){var a={};return a[e.toLowerCase()]=t.toLowerCase(),a["Webkit"+e]="webkit"+t,a["Moz"+e]="moz"+t,a}var Es={animationend:Zl("Animation","AnimationEnd"),animationiteration:Zl("Animation","AnimationIteration"),animationstart:Zl("Animation","AnimationStart"),transitionrun:Zl("Transition","TransitionRun"),transitionstart:Zl("Transition","TransitionStart"),transitioncancel:Zl("Transition","TransitionCancel"),transitionend:Zl("Transition","TransitionEnd")},rc={},Yd={};Ta&&(Yd=document.createElement("div").style,"AnimationEvent"in window||(delete Es.animationend.animation,delete Es.animationiteration.animation,delete Es.animationstart.animation),"TransitionEvent"in window||delete Es.transitionend.transition);function Kl(e){if(rc[e])return rc[e];if(!Es[e])return e;var t=Es[e],a;for(a in t)if(t.hasOwnProperty(a)&&a in Yd)return rc[e]=t[a];return e}var Qd=Kl("animationend"),Zd=Kl("animationiteration"),Kd=Kl("animationstart"),Xg=Kl("transitionrun"),Yg=Kl("transitionstart"),Qg=Kl("transitioncancel"),Jd=Kl("transitionend"),Pd=new Map,ic="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");ic.push("scrollEnd");function dn(e,t){Pd.set(e,t),ln(t,[e])}var bi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Xa=[],Ms=0,oc=0;function yi(){for(var e=Ms,t=oc=Ms=0;t<e;){var a=Xa[t];Xa[t++]=null;var n=Xa[t];Xa[t++]=null;var r=Xa[t];Xa[t++]=null;var o=Xa[t];if(Xa[t++]=null,n!==null&&r!==null){var m=n.pending;m===null?r.next=r:(r.next=m.next,m.next=r),n.pending=r}o!==0&&Wd(a,r,o)}}function vi(e,t,a,n){Xa[Ms++]=e,Xa[Ms++]=t,Xa[Ms++]=a,Xa[Ms++]=n,oc|=n,e.lanes|=n,e=e.alternate,e!==null&&(e.lanes|=n)}function cc(e,t,a,n){return vi(e,t,a,n),wi(e)}function Jl(e,t){return vi(e,null,null,t),wi(e)}function Wd(e,t,a){e.lanes|=a;var n=e.alternate;n!==null&&(n.lanes|=a);for(var r=!1,o=e.return;o!==null;)o.childLanes|=a,n=o.alternate,n!==null&&(n.childLanes|=a),o.tag===22&&(e=o.stateNode,e===null||e._visibility&1||(r=!0)),e=o,o=o.return;return e.tag===3?(o=e.stateNode,r&&t!==null&&(r=31-_e(a),e=o.hiddenUpdates,n=e[r],n===null?e[r]=[t]:n.push(t),t.lane=a|536870912),o):null}function wi(e){if(50<Vr)throw Vr=0,bu=null,Error(c(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var zs={};function Zg(e,t,a,n){this.tag=e,this.key=a,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function La(e,t,a,n){return new Zg(e,t,a,n)}function uc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $n(e,t){var a=e.alternate;return a===null?(a=La(e.tag,t,e.key,e.mode),a.elementType=e.elementType,a.type=e.type,a.stateNode=e.stateNode,a.alternate=e,e.alternate=a):(a.pendingProps=t,a.type=e.type,a.flags=0,a.subtreeFlags=0,a.deletions=null),a.flags=e.flags&65011712,a.childLanes=e.childLanes,a.lanes=e.lanes,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,t=e.dependencies,a.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},a.sibling=e.sibling,a.index=e.index,a.ref=e.ref,a.refCleanup=e.refCleanup,a}function ef(e,t){e.flags&=65011714;var a=e.alternate;return a===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=a.childLanes,e.lanes=a.lanes,e.child=a.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=a.memoizedProps,e.memoizedState=a.memoizedState,e.updateQueue=a.updateQueue,e.type=a.type,t=a.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Si(e,t,a,n,r,o){var m=0;if(n=e,typeof e=="function")uc(e)&&(m=1);else if(typeof e=="string")m=ex(e,a,me.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case Q:return e=La(31,a,t,r),e.elementType=Q,e.lanes=o,e;case _:return Pl(a.children,r,o,t);case z:m=8,r|=24;break;case $:return e=La(12,a,t,r|2),e.elementType=$,e.lanes=o,e;case q:return e=La(13,a,t,r),e.elementType=q,e.lanes=o,e;case N:return e=La(19,a,t,r),e.elementType=N,e.lanes=o,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Y:m=10;break e;case ee:m=9;break e;case R:m=11;break e;case X:m=14;break e;case U:m=16,n=null;break e}m=29,a=Error(c(130,e===null?"null":typeof e,"")),n=null}return t=La(m,a,t,r),t.elementType=e,t.type=n,t.lanes=o,t}function Pl(e,t,a,n){return e=La(7,e,n,t),e.lanes=a,e}function dc(e,t,a){return e=La(6,e,null,t),e.lanes=a,e}function tf(e){var t=La(18,null,null,0);return t.stateNode=e,t}function fc(e,t,a){return t=La(4,e.children!==null?e.children:[],e.key,t),t.lanes=a,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var af=new WeakMap;function Ya(e,t){if(typeof e=="object"&&e!==null){var a=af.get(e);return a!==void 0?a:(t={value:e,source:t,stack:et(t)},af.set(e,t),t)}return{value:e,source:t,stack:et(t)}}var Ds=[],Ls=0,ki=null,_r=0,Qa=[],Za=0,ul=null,kn=1,_n="";function qn(e,t){Ds[Ls++]=_r,Ds[Ls++]=ki,ki=e,_r=t}function nf(e,t,a){Qa[Za++]=kn,Qa[Za++]=_n,Qa[Za++]=ul,ul=e;var n=kn;e=_n;var r=32-_e(n)-1;n&=~(1<<r),a+=1;var o=32-_e(t)+r;if(30<o){var m=r-r%5;o=(n&(1<<m)-1).toString(32),n>>=m,r-=m,kn=1<<32-_e(t)+r|a<<r|n,_n=o+e}else kn=1<<o|a<<r|n,_n=e}function mc(e){e.return!==null&&(qn(e,1),nf(e,1,0))}function hc(e){for(;e===ki;)ki=Ds[--Ls],Ds[Ls]=null,_r=Ds[--Ls],Ds[Ls]=null;for(;e===ul;)ul=Qa[--Za],Qa[Za]=null,_n=Qa[--Za],Qa[Za]=null,kn=Qa[--Za],Qa[Za]=null}function lf(e,t){Qa[Za++]=kn,Qa[Za++]=_n,Qa[Za++]=ul,kn=t.id,_n=t.overflow,ul=e}var Kt=null,yt=null,We=!1,dl=null,Ka=!1,pc=Error(c(519));function fl(e){var t=Error(c(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ar(Ya(t,e)),pc}function sf(e){var t=e.stateNode,a=e.type,n=e.memoizedProps;switch(t[Et]=e,t[Ct]=n,a){case"dialog":Ke("cancel",t),Ke("close",t);break;case"iframe":case"object":case"embed":Ke("load",t);break;case"video":case"audio":for(a=0;a<Yr.length;a++)Ke(Yr[a],t);break;case"source":Ke("error",t);break;case"img":case"image":case"link":Ke("error",t),Ke("load",t);break;case"details":Ke("toggle",t);break;case"input":Ke("invalid",t),ur(t,n.value,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name,!0);break;case"select":Ke("invalid",t);break;case"textarea":Ke("invalid",t),rn(t,n.value,n.defaultValue,n.children)}a=n.children,typeof a!="string"&&typeof a!="number"&&typeof a!="bigint"||t.textContent===""+a||n.suppressHydrationWarning===!0||kh(t.textContent,a)?(n.popover!=null&&(Ke("beforetoggle",t),Ke("toggle",t)),n.onScroll!=null&&Ke("scroll",t),n.onScrollEnd!=null&&Ke("scrollend",t),n.onClick!=null&&(t.onclick=Fa),t=!0):t=!1,t||fl(e,!0)}function rf(e){for(Kt=e.return;Kt;)switch(Kt.tag){case 5:case 31:case 13:Ka=!1;return;case 27:case 3:Ka=!0;return;default:Kt=Kt.return}}function Rs(e){if(e!==Kt)return!1;if(!We)return rf(e),We=!0,!1;var t=e.tag,a;if((a=t!==3&&t!==27)&&((a=t===5)&&(a=e.type,a=!(a!=="form"&&a!=="button")||Du(e.type,e.memoizedProps)),a=!a),a&&yt&&fl(e),rf(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(c(317));yt=zh(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(c(317));yt=zh(e)}else t===27?(t=yt,Cl(e.type)?(e=$u,$u=null,yt=e):yt=t):yt=Kt?Pa(e.stateNode.nextSibling):null;return!0}function Wl(){yt=Kt=null,We=!1}function gc(){var e=dl;return e!==null&&(ba===null?ba=e:ba.push.apply(ba,e),dl=null),e}function Ar(e){dl===null?dl=[e]:dl.push(e)}var xc=xe(null),es=null,Bn=null;function ml(e,t,a){F(xc,t._currentValue),t._currentValue=a}function Hn(e){e._currentValue=xc.current,pe(xc)}function bc(e,t,a){for(;e!==null;){var n=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,n!==null&&(n.childLanes|=t)):n!==null&&(n.childLanes&t)!==t&&(n.childLanes|=t),e===a)break;e=e.return}}function yc(e,t,a,n){var r=e.child;for(r!==null&&(r.return=e);r!==null;){var o=r.dependencies;if(o!==null){var m=r.child;o=o.firstContext;e:for(;o!==null;){var y=o;o=r;for(var A=0;A<t.length;A++)if(y.context===t[A]){o.lanes|=a,y=o.alternate,y!==null&&(y.lanes|=a),bc(o.return,a,e),n||(m=null);break e}o=y.next}}else if(r.tag===18){if(m=r.return,m===null)throw Error(c(341));m.lanes|=a,o=m.alternate,o!==null&&(o.lanes|=a),bc(m,a,e),m=null}else m=r.child;if(m!==null)m.return=r;else for(m=r;m!==null;){if(m===e){m=null;break}if(r=m.sibling,r!==null){r.return=m.return,m=r;break}m=m.return}r=m}}function Us(e,t,a,n){e=null;for(var r=t,o=!1;r!==null;){if(!o){if((r.flags&524288)!==0)o=!0;else if((r.flags&262144)!==0)break}if(r.tag===10){var m=r.alternate;if(m===null)throw Error(c(387));if(m=m.memoizedProps,m!==null){var y=r.type;Da(r.pendingProps.value,m.value)||(e!==null?e.push(y):e=[y])}}else if(r===we.current){if(m=r.alternate,m===null)throw Error(c(387));m.memoizedState.memoizedState!==r.memoizedState.memoizedState&&(e!==null?e.push(Pr):e=[Pr])}r=r.return}e!==null&&yc(t,e,a,n),t.flags|=262144}function _i(e){for(e=e.firstContext;e!==null;){if(!Da(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function ts(e){es=e,Bn=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Jt(e){return of(es,e)}function Ai(e,t){return es===null&&ts(e),of(e,t)}function of(e,t){var a=t._currentValue;if(t={context:t,memoizedValue:a,next:null},Bn===null){if(e===null)throw Error(c(308));Bn=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Bn=Bn.next=t;return a}var Kg=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(a,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(a){return a()})}},Jg=s.unstable_scheduleCallback,Pg=s.unstable_NormalPriority,Lt={$$typeof:Y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function vc(){return{controller:new Kg,data:new Map,refCount:0}}function Cr(e){e.refCount--,e.refCount===0&&Jg(Pg,function(){e.controller.abort()})}var jr=null,wc=0,Os=0,$s=null;function Wg(e,t){if(jr===null){var a=jr=[];wc=0,Os=_u(),$s={status:"pending",value:void 0,then:function(n){a.push(n)}}}return wc++,t.then(cf,cf),t}function cf(){if(--wc===0&&jr!==null){$s!==null&&($s.status="fulfilled");var e=jr;jr=null,Os=0,$s=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function e0(e,t){var a=[],n={status:"pending",value:null,reason:null,then:function(r){a.push(r)}};return e.then(function(){n.status="fulfilled",n.value=t;for(var r=0;r<a.length;r++)(0,a[r])(t)},function(r){for(n.status="rejected",n.reason=r,r=0;r<a.length;r++)(0,a[r])(void 0)}),n}var uf=E.S;E.S=function(e,t){Ym=Oe(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Wg(e,t),uf!==null&&uf(e,t)};var as=xe(null);function Sc(){var e=as.current;return e!==null?e:ht.pooledCache}function Ci(e,t){t===null?F(as,as.current):F(as,t.pool)}function df(){var e=Sc();return e===null?null:{parent:Lt._currentValue,pool:e}}var qs=Error(c(460)),kc=Error(c(474)),ji=Error(c(542)),Ni={then:function(){}};function ff(e){return e=e.status,e==="fulfilled"||e==="rejected"}function mf(e,t,a){switch(a=e[a],a===void 0?e.push(t):a!==t&&(t.then(Fa,Fa),t=a),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,pf(e),e;default:if(typeof t.status=="string")t.then(Fa,Fa);else{if(e=ht,e!==null&&100<e.shellSuspendCounter)throw Error(c(482));e=t,e.status="pending",e.then(function(n){if(t.status==="pending"){var r=t;r.status="fulfilled",r.value=n}},function(n){if(t.status==="pending"){var r=t;r.status="rejected",r.reason=n}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,pf(e),e}throw ls=t,qs}}function ns(e){try{var t=e._init;return t(e._payload)}catch(a){throw a!==null&&typeof a=="object"&&typeof a.then=="function"?(ls=a,qs):a}}var ls=null;function hf(){if(ls===null)throw Error(c(459));var e=ls;return ls=null,e}function pf(e){if(e===qs||e===ji)throw Error(c(483))}var Bs=null,Nr=0;function Ti(e){var t=Nr;return Nr+=1,Bs===null&&(Bs=[]),mf(Bs,e,t)}function Tr(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ei(e,t){throw t.$$typeof===k?Error(c(525)):(e=Object.prototype.toString.call(t),Error(c(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function gf(e){function t(M,T){if(e){var D=M.deletions;D===null?(M.deletions=[T],M.flags|=16):D.push(T)}}function a(M,T){if(!e)return null;for(;T!==null;)t(M,T),T=T.sibling;return null}function n(M){for(var T=new Map;M!==null;)M.key!==null?T.set(M.key,M):T.set(M.index,M),M=M.sibling;return T}function r(M,T){return M=$n(M,T),M.index=0,M.sibling=null,M}function o(M,T,D){return M.index=D,e?(D=M.alternate,D!==null?(D=D.index,D<T?(M.flags|=67108866,T):D):(M.flags|=67108866,T)):(M.flags|=1048576,T)}function m(M){return e&&M.alternate===null&&(M.flags|=67108866),M}function y(M,T,D,Z){return T===null||T.tag!==6?(T=dc(D,M.mode,Z),T.return=M,T):(T=r(T,D),T.return=M,T)}function A(M,T,D,Z){var Me=D.type;return Me===_?G(M,T,D.props.children,Z,D.key):T!==null&&(T.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===U&&ns(Me)===T.type)?(T=r(T,D.props),Tr(T,D),T.return=M,T):(T=Si(D.type,D.key,D.props,null,M.mode,Z),Tr(T,D),T.return=M,T)}function L(M,T,D,Z){return T===null||T.tag!==4||T.stateNode.containerInfo!==D.containerInfo||T.stateNode.implementation!==D.implementation?(T=fc(D,M.mode,Z),T.return=M,T):(T=r(T,D.children||[]),T.return=M,T)}function G(M,T,D,Z,Me){return T===null||T.tag!==7?(T=Pl(D,M.mode,Z,Me),T.return=M,T):(T=r(T,D),T.return=M,T)}function K(M,T,D){if(typeof T=="string"&&T!==""||typeof T=="number"||typeof T=="bigint")return T=dc(""+T,M.mode,D),T.return=M,T;if(typeof T=="object"&&T!==null){switch(T.$$typeof){case S:return D=Si(T.type,T.key,T.props,null,M.mode,D),Tr(D,T),D.return=M,D;case j:return T=fc(T,M.mode,D),T.return=M,T;case U:return T=ns(T),K(M,T,D)}if(oe(T)||fe(T))return T=Pl(T,M.mode,D,null),T.return=M,T;if(typeof T.then=="function")return K(M,Ti(T),D);if(T.$$typeof===Y)return K(M,Ai(M,T),D);Ei(M,T)}return null}function O(M,T,D,Z){var Me=T!==null?T.key:null;if(typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint")return Me!==null?null:y(M,T,""+D,Z);if(typeof D=="object"&&D!==null){switch(D.$$typeof){case S:return D.key===Me?A(M,T,D,Z):null;case j:return D.key===Me?L(M,T,D,Z):null;case U:return D=ns(D),O(M,T,D,Z)}if(oe(D)||fe(D))return Me!==null?null:G(M,T,D,Z,null);if(typeof D.then=="function")return O(M,T,Ti(D),Z);if(D.$$typeof===Y)return O(M,T,Ai(M,D),Z);Ei(M,D)}return null}function B(M,T,D,Z,Me){if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return M=M.get(D)||null,y(T,M,""+Z,Me);if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case S:return M=M.get(Z.key===null?D:Z.key)||null,A(T,M,Z,Me);case j:return M=M.get(Z.key===null?D:Z.key)||null,L(T,M,Z,Me);case U:return Z=ns(Z),B(M,T,D,Z,Me)}if(oe(Z)||fe(Z))return M=M.get(D)||null,G(T,M,Z,Me,null);if(typeof Z.then=="function")return B(M,T,D,Ti(Z),Me);if(Z.$$typeof===Y)return B(M,T,D,Ai(T,Z),Me);Ei(T,Z)}return null}function ve(M,T,D,Z){for(var Me=null,nt=null,Se=T,Ge=T=0,Pe=null;Se!==null&&Ge<D.length;Ge++){Se.index>Ge?(Pe=Se,Se=null):Pe=Se.sibling;var lt=O(M,Se,D[Ge],Z);if(lt===null){Se===null&&(Se=Pe);break}e&&Se&<.alternate===null&&t(M,Se),T=o(lt,T,Ge),nt===null?Me=lt:nt.sibling=lt,nt=lt,Se=Pe}if(Ge===D.length)return a(M,Se),We&&qn(M,Ge),Me;if(Se===null){for(;Ge<D.length;Ge++)Se=K(M,D[Ge],Z),Se!==null&&(T=o(Se,T,Ge),nt===null?Me=Se:nt.sibling=Se,nt=Se);return We&&qn(M,Ge),Me}for(Se=n(Se);Ge<D.length;Ge++)Pe=B(Se,M,Ge,D[Ge],Z),Pe!==null&&(e&&Pe.alternate!==null&&Se.delete(Pe.key===null?Ge:Pe.key),T=o(Pe,T,Ge),nt===null?Me=Pe:nt.sibling=Pe,nt=Pe);return e&&Se.forEach(function(Ml){return t(M,Ml)}),We&&qn(M,Ge),Me}function Re(M,T,D,Z){if(D==null)throw Error(c(151));for(var Me=null,nt=null,Se=T,Ge=T=0,Pe=null,lt=D.next();Se!==null&&!lt.done;Ge++,lt=D.next()){Se.index>Ge?(Pe=Se,Se=null):Pe=Se.sibling;var Ml=O(M,Se,lt.value,Z);if(Ml===null){Se===null&&(Se=Pe);break}e&&Se&&Ml.alternate===null&&t(M,Se),T=o(Ml,T,Ge),nt===null?Me=Ml:nt.sibling=Ml,nt=Ml,Se=Pe}if(lt.done)return a(M,Se),We&&qn(M,Ge),Me;if(Se===null){for(;!lt.done;Ge++,lt=D.next())lt=K(M,lt.value,Z),lt!==null&&(T=o(lt,T,Ge),nt===null?Me=lt:nt.sibling=lt,nt=lt);return We&&qn(M,Ge),Me}for(Se=n(Se);!lt.done;Ge++,lt=D.next())lt=B(Se,M,Ge,lt.value,Z),lt!==null&&(e&<.alternate!==null&&Se.delete(lt.key===null?Ge:lt.key),T=o(lt,T,Ge),nt===null?Me=lt:nt.sibling=lt,nt=lt);return e&&Se.forEach(function(dx){return t(M,dx)}),We&&qn(M,Ge),Me}function mt(M,T,D,Z){if(typeof D=="object"&&D!==null&&D.type===_&&D.key===null&&(D=D.props.children),typeof D=="object"&&D!==null){switch(D.$$typeof){case S:e:{for(var Me=D.key;T!==null;){if(T.key===Me){if(Me=D.type,Me===_){if(T.tag===7){a(M,T.sibling),Z=r(T,D.props.children),Z.return=M,M=Z;break e}}else if(T.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===U&&ns(Me)===T.type){a(M,T.sibling),Z=r(T,D.props),Tr(Z,D),Z.return=M,M=Z;break e}a(M,T);break}else t(M,T);T=T.sibling}D.type===_?(Z=Pl(D.props.children,M.mode,Z,D.key),Z.return=M,M=Z):(Z=Si(D.type,D.key,D.props,null,M.mode,Z),Tr(Z,D),Z.return=M,M=Z)}return m(M);case j:e:{for(Me=D.key;T!==null;){if(T.key===Me)if(T.tag===4&&T.stateNode.containerInfo===D.containerInfo&&T.stateNode.implementation===D.implementation){a(M,T.sibling),Z=r(T,D.children||[]),Z.return=M,M=Z;break e}else{a(M,T);break}else t(M,T);T=T.sibling}Z=fc(D,M.mode,Z),Z.return=M,M=Z}return m(M);case U:return D=ns(D),mt(M,T,D,Z)}if(oe(D))return ve(M,T,D,Z);if(fe(D)){if(Me=fe(D),typeof Me!="function")throw Error(c(150));return D=Me.call(D),Re(M,T,D,Z)}if(typeof D.then=="function")return mt(M,T,Ti(D),Z);if(D.$$typeof===Y)return mt(M,T,Ai(M,D),Z);Ei(M,D)}return typeof D=="string"&&D!==""||typeof D=="number"||typeof D=="bigint"?(D=""+D,T!==null&&T.tag===6?(a(M,T.sibling),Z=r(T,D),Z.return=M,M=Z):(a(M,T),Z=dc(D,M.mode,Z),Z.return=M,M=Z),m(M)):a(M,T)}return function(M,T,D,Z){try{Nr=0;var Me=mt(M,T,D,Z);return Bs=null,Me}catch(Se){if(Se===qs||Se===ji)throw Se;var nt=La(29,Se,null,M.mode);return nt.lanes=Z,nt.return=M,nt}finally{}}}var ss=gf(!0),xf=gf(!1),hl=!1;function _c(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ac(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function pl(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function gl(e,t,a){var n=e.updateQueue;if(n===null)return null;if(n=n.shared,(rt&2)!==0){var r=n.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),n.pending=t,t=wi(e),Wd(e,null,a),t}return vi(e,n,t,a),wi(e)}function Er(e,t,a){if(t=t.updateQueue,t!==null&&(t=t.shared,(a&4194048)!==0)){var n=t.lanes;n&=e.pendingLanes,a|=n,t.lanes=a,fs(e,a)}}function Cc(e,t){var a=e.updateQueue,n=e.alternate;if(n!==null&&(n=n.updateQueue,a===n)){var r=null,o=null;if(a=a.firstBaseUpdate,a!==null){do{var m={lane:a.lane,tag:a.tag,payload:a.payload,callback:null,next:null};o===null?r=o=m:o=o.next=m,a=a.next}while(a!==null);o===null?r=o=t:o=o.next=t}else r=o=t;a={baseState:n.baseState,firstBaseUpdate:r,lastBaseUpdate:o,shared:n.shared,callbacks:n.callbacks},e.updateQueue=a;return}e=a.lastBaseUpdate,e===null?a.firstBaseUpdate=t:e.next=t,a.lastBaseUpdate=t}var jc=!1;function Mr(){if(jc){var e=$s;if(e!==null)throw e}}function zr(e,t,a,n){jc=!1;var r=e.updateQueue;hl=!1;var o=r.firstBaseUpdate,m=r.lastBaseUpdate,y=r.shared.pending;if(y!==null){r.shared.pending=null;var A=y,L=A.next;A.next=null,m===null?o=L:m.next=L,m=A;var G=e.alternate;G!==null&&(G=G.updateQueue,y=G.lastBaseUpdate,y!==m&&(y===null?G.firstBaseUpdate=L:y.next=L,G.lastBaseUpdate=A))}if(o!==null){var K=r.baseState;m=0,G=L=A=null,y=o;do{var O=y.lane&-536870913,B=O!==y.lane;if(B?(Je&O)===O:(n&O)===O){O!==0&&O===Os&&(jc=!0),G!==null&&(G=G.next={lane:0,tag:y.tag,payload:y.payload,callback:null,next:null});e:{var ve=e,Re=y;O=t;var mt=a;switch(Re.tag){case 1:if(ve=Re.payload,typeof ve=="function"){K=ve.call(mt,K,O);break e}K=ve;break e;case 3:ve.flags=ve.flags&-65537|128;case 0:if(ve=Re.payload,O=typeof ve=="function"?ve.call(mt,K,O):ve,O==null)break e;K=w({},K,O);break e;case 2:hl=!0}}O=y.callback,O!==null&&(e.flags|=64,B&&(e.flags|=8192),B=r.callbacks,B===null?r.callbacks=[O]:B.push(O))}else B={lane:O,tag:y.tag,payload:y.payload,callback:y.callback,next:null},G===null?(L=G=B,A=K):G=G.next=B,m|=O;if(y=y.next,y===null){if(y=r.shared.pending,y===null)break;B=y,y=B.next,B.next=null,r.lastBaseUpdate=B,r.shared.pending=null}}while(!0);G===null&&(A=K),r.baseState=A,r.firstBaseUpdate=L,r.lastBaseUpdate=G,o===null&&(r.shared.lanes=0),wl|=m,e.lanes=m,e.memoizedState=K}}function bf(e,t){if(typeof e!="function")throw Error(c(191,e));e.call(t)}function yf(e,t){var a=e.callbacks;if(a!==null)for(e.callbacks=null,e=0;e<a.length;e++)bf(a[e],t)}var Hs=xe(null),Mi=xe(0);function vf(e,t){e=Kn,F(Mi,e),F(Hs,t),Kn=e|t.baseLanes}function Nc(){F(Mi,Kn),F(Hs,Hs.current)}function Tc(){Kn=Mi.current,pe(Hs),pe(Mi)}var Ra=xe(null),Ja=null;function xl(e){var t=e.alternate;F(Mt,Mt.current&1),F(Ra,e),Ja===null&&(t===null||Hs.current!==null||t.memoizedState!==null)&&(Ja=e)}function Ec(e){F(Mt,Mt.current),F(Ra,e),Ja===null&&(Ja=e)}function wf(e){e.tag===22?(F(Mt,Mt.current),F(Ra,e),Ja===null&&(Ja=e)):bl()}function bl(){F(Mt,Mt.current),F(Ra,Ra.current)}function Ua(e){pe(Ra),Ja===e&&(Ja=null),pe(Mt)}var Mt=xe(0);function zi(e){for(var t=e;t!==null;){if(t.tag===13){var a=t.memoizedState;if(a!==null&&(a=a.dehydrated,a===null||Uu(a)||Ou(a)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Fn=0,Ie=null,dt=null,Rt=null,Di=!1,Fs=!1,rs=!1,Li=0,Dr=0,Is=null,t0=0;function jt(){throw Error(c(321))}function Mc(e,t){if(t===null)return!1;for(var a=0;a<t.length&&a<e.length;a++)if(!Da(e[a],t[a]))return!1;return!0}function zc(e,t,a,n,r,o){return Fn=o,Ie=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,E.H=e===null||e.memoizedState===null?lm:Yc,rs=!1,o=a(n,r),rs=!1,Fs&&(o=kf(t,a,n,r)),Sf(e),o}function Sf(e){E.H=Ur;var t=dt!==null&&dt.next!==null;if(Fn=0,Rt=dt=Ie=null,Di=!1,Dr=0,Is=null,t)throw Error(c(300));e===null||Ut||(e=e.dependencies,e!==null&&_i(e)&&(Ut=!0))}function kf(e,t,a,n){Ie=e;var r=0;do{if(Fs&&(Is=null),Dr=0,Fs=!1,25<=r)throw Error(c(301));if(r+=1,Rt=dt=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}E.H=sm,o=t(a,n)}while(Fs);return o}function a0(){var e=E.H,t=e.useState()[0];return t=typeof t.then=="function"?Lr(t):t,e=e.useState()[0],(dt!==null?dt.memoizedState:null)!==e&&(Ie.flags|=1024),t}function Dc(){var e=Li!==0;return Li=0,e}function Lc(e,t,a){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a}function Rc(e){if(Di){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Di=!1}Fn=0,Rt=dt=Ie=null,Fs=!1,Dr=Li=0,Is=null}function oa(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Rt===null?Ie.memoizedState=Rt=e:Rt=Rt.next=e,Rt}function zt(){if(dt===null){var e=Ie.alternate;e=e!==null?e.memoizedState:null}else e=dt.next;var t=Rt===null?Ie.memoizedState:Rt.next;if(t!==null)Rt=t,dt=e;else{if(e===null)throw Ie.alternate===null?Error(c(467)):Error(c(310));dt=e,e={memoizedState:dt.memoizedState,baseState:dt.baseState,baseQueue:dt.baseQueue,queue:dt.queue,next:null},Rt===null?Ie.memoizedState=Rt=e:Rt=Rt.next=e}return Rt}function Ri(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Lr(e){var t=Dr;return Dr+=1,Is===null&&(Is=[]),e=mf(Is,e,t),t=Ie,(Rt===null?t.memoizedState:Rt.next)===null&&(t=t.alternate,E.H=t===null||t.memoizedState===null?lm:Yc),e}function Ui(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Lr(e);if(e.$$typeof===Y)return Jt(e)}throw Error(c(438,String(e)))}function Uc(e){var t=null,a=Ie.updateQueue;if(a!==null&&(t=a.memoCache),t==null){var n=Ie.alternate;n!==null&&(n=n.updateQueue,n!==null&&(n=n.memoCache,n!=null&&(t={data:n.data.map(function(r){return r.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),a===null&&(a=Ri(),Ie.updateQueue=a),a.memoCache=t,a=t.data[t.index],a===void 0)for(a=t.data[t.index]=Array(e),n=0;n<e;n++)a[n]=I;return t.index++,a}function In(e,t){return typeof t=="function"?t(e):t}function Oi(e){var t=zt();return Oc(t,dt,e)}function Oc(e,t,a){var n=e.queue;if(n===null)throw Error(c(311));n.lastRenderedReducer=a;var r=e.baseQueue,o=n.pending;if(o!==null){if(r!==null){var m=r.next;r.next=o.next,o.next=m}t.baseQueue=r=o,n.pending=null}if(o=e.baseState,r===null)e.memoizedState=o;else{t=r.next;var y=m=null,A=null,L=t,G=!1;do{var K=L.lane&-536870913;if(K!==L.lane?(Je&K)===K:(Fn&K)===K){var O=L.revertLane;if(O===0)A!==null&&(A=A.next={lane:0,revertLane:0,gesture:null,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null}),K===Os&&(G=!0);else if((Fn&O)===O){L=L.next,O===Os&&(G=!0);continue}else K={lane:0,revertLane:L.revertLane,gesture:null,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null},A===null?(y=A=K,m=o):A=A.next=K,Ie.lanes|=O,wl|=O;K=L.action,rs&&a(o,K),o=L.hasEagerState?L.eagerState:a(o,K)}else O={lane:K,revertLane:L.revertLane,gesture:L.gesture,action:L.action,hasEagerState:L.hasEagerState,eagerState:L.eagerState,next:null},A===null?(y=A=O,m=o):A=A.next=O,Ie.lanes|=K,wl|=K;L=L.next}while(L!==null&&L!==t);if(A===null?m=o:A.next=y,!Da(o,e.memoizedState)&&(Ut=!0,G&&(a=$s,a!==null)))throw a;e.memoizedState=o,e.baseState=m,e.baseQueue=A,n.lastRenderedState=o}return r===null&&(n.lanes=0),[e.memoizedState,n.dispatch]}function $c(e){var t=zt(),a=t.queue;if(a===null)throw Error(c(311));a.lastRenderedReducer=e;var n=a.dispatch,r=a.pending,o=t.memoizedState;if(r!==null){a.pending=null;var m=r=r.next;do o=e(o,m.action),m=m.next;while(m!==r);Da(o,t.memoizedState)||(Ut=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),a.lastRenderedState=o}return[o,n]}function _f(e,t,a){var n=Ie,r=zt(),o=We;if(o){if(a===void 0)throw Error(c(407));a=a()}else a=t();var m=!Da((dt||r).memoizedState,a);if(m&&(r.memoizedState=a,Ut=!0),r=r.queue,Hc(jf.bind(null,n,r,e),[e]),r.getSnapshot!==t||m||Rt!==null&&Rt.memoizedState.tag&1){if(n.flags|=2048,Gs(9,{destroy:void 0},Cf.bind(null,n,r,a,t),null),ht===null)throw Error(c(349));o||(Fn&127)!==0||Af(n,t,a)}return a}function Af(e,t,a){e.flags|=16384,e={getSnapshot:t,value:a},t=Ie.updateQueue,t===null?(t=Ri(),Ie.updateQueue=t,t.stores=[e]):(a=t.stores,a===null?t.stores=[e]:a.push(e))}function Cf(e,t,a,n){t.value=a,t.getSnapshot=n,Nf(t)&&Tf(e)}function jf(e,t,a){return a(function(){Nf(t)&&Tf(e)})}function Nf(e){var t=e.getSnapshot;e=e.value;try{var a=t();return!Da(e,a)}catch{return!0}}function Tf(e){var t=Jl(e,2);t!==null&&ya(t,e,2)}function qc(e){var t=oa();if(typeof e=="function"){var a=e;if(e=a(),rs){Ht(!0);try{a()}finally{Ht(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:In,lastRenderedState:e},t}function Ef(e,t,a,n){return e.baseState=a,Oc(e,dt,typeof n=="function"?n:In)}function n0(e,t,a,n,r){if(Bi(e))throw Error(c(485));if(e=t.action,e!==null){var o={payload:r,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(m){o.listeners.push(m)}};E.T!==null?a(!0):o.isTransition=!1,n(o),a=t.pending,a===null?(o.next=t.pending=o,Mf(t,o)):(o.next=a.next,t.pending=a.next=o)}}function Mf(e,t){var a=t.action,n=t.payload,r=e.state;if(t.isTransition){var o=E.T,m={};E.T=m;try{var y=a(r,n),A=E.S;A!==null&&A(m,y),zf(e,t,y)}catch(L){Bc(e,t,L)}finally{o!==null&&m.types!==null&&(o.types=m.types),E.T=o}}else try{o=a(r,n),zf(e,t,o)}catch(L){Bc(e,t,L)}}function zf(e,t,a){a!==null&&typeof a=="object"&&typeof a.then=="function"?a.then(function(n){Df(e,t,n)},function(n){return Bc(e,t,n)}):Df(e,t,a)}function Df(e,t,a){t.status="fulfilled",t.value=a,Lf(t),e.state=a,t=e.pending,t!==null&&(a=t.next,a===t?e.pending=null:(a=a.next,t.next=a,Mf(e,a)))}function Bc(e,t,a){var n=e.pending;if(e.pending=null,n!==null){n=n.next;do t.status="rejected",t.reason=a,Lf(t),t=t.next;while(t!==n)}e.action=null}function Lf(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Rf(e,t){return t}function Uf(e,t){if(We){var a=ht.formState;if(a!==null){e:{var n=Ie;if(We){if(yt){t:{for(var r=yt,o=Ka;r.nodeType!==8;){if(!o){r=null;break t}if(r=Pa(r.nextSibling),r===null){r=null;break t}}o=r.data,r=o==="F!"||o==="F"?r:null}if(r){yt=Pa(r.nextSibling),n=r.data==="F!";break e}}fl(n)}n=!1}n&&(t=a[0])}}return a=oa(),a.memoizedState=a.baseState=t,n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rf,lastRenderedState:t},a.queue=n,a=tm.bind(null,Ie,n),n.dispatch=a,n=qc(!1),o=Xc.bind(null,Ie,!1,n.queue),n=oa(),r={state:t,dispatch:null,action:e,pending:null},n.queue=r,a=n0.bind(null,Ie,r,o,a),r.dispatch=a,n.memoizedState=e,[t,a,!1]}function Of(e){var t=zt();return $f(t,dt,e)}function $f(e,t,a){if(t=Oc(e,t,Rf)[0],e=Oi(In)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var n=Lr(t)}catch(m){throw m===qs?ji:m}else n=t;t=zt();var r=t.queue,o=r.dispatch;return a!==t.memoizedState&&(Ie.flags|=2048,Gs(9,{destroy:void 0},l0.bind(null,r,a),null)),[n,o,e]}function l0(e,t){e.action=t}function qf(e){var t=zt(),a=dt;if(a!==null)return $f(t,a,e);zt(),t=t.memoizedState,a=zt();var n=a.queue.dispatch;return a.memoizedState=e,[t,n,!1]}function Gs(e,t,a,n){return e={tag:e,create:a,deps:n,inst:t,next:null},t=Ie.updateQueue,t===null&&(t=Ri(),Ie.updateQueue=t),a=t.lastEffect,a===null?t.lastEffect=e.next=e:(n=a.next,a.next=e,e.next=n,t.lastEffect=e),e}function Bf(){return zt().memoizedState}function $i(e,t,a,n){var r=oa();Ie.flags|=e,r.memoizedState=Gs(1|t,{destroy:void 0},a,n===void 0?null:n)}function qi(e,t,a,n){var r=zt();n=n===void 0?null:n;var o=r.memoizedState.inst;dt!==null&&n!==null&&Mc(n,dt.memoizedState.deps)?r.memoizedState=Gs(t,o,a,n):(Ie.flags|=e,r.memoizedState=Gs(1|t,o,a,n))}function Hf(e,t){$i(8390656,8,e,t)}function Hc(e,t){qi(2048,8,e,t)}function s0(e){Ie.flags|=4;var t=Ie.updateQueue;if(t===null)t=Ri(),Ie.updateQueue=t,t.events=[e];else{var a=t.events;a===null?t.events=[e]:a.push(e)}}function Ff(e){var t=zt().memoizedState;return s0({ref:t,nextImpl:e}),function(){if((rt&2)!==0)throw Error(c(440));return t.impl.apply(void 0,arguments)}}function If(e,t){return qi(4,2,e,t)}function Gf(e,t){return qi(4,4,e,t)}function Vf(e,t){if(typeof t=="function"){e=e();var a=t(e);return function(){typeof a=="function"?a():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Xf(e,t,a){a=a!=null?a.concat([e]):null,qi(4,4,Vf.bind(null,t,e),a)}function Fc(){}function Yf(e,t){var a=zt();t=t===void 0?null:t;var n=a.memoizedState;return t!==null&&Mc(t,n[1])?n[0]:(a.memoizedState=[e,t],e)}function Qf(e,t){var a=zt();t=t===void 0?null:t;var n=a.memoizedState;if(t!==null&&Mc(t,n[1]))return n[0];if(n=e(),rs){Ht(!0);try{e()}finally{Ht(!1)}}return a.memoizedState=[n,t],n}function Ic(e,t,a){return a===void 0||(Fn&1073741824)!==0&&(Je&261930)===0?e.memoizedState=t:(e.memoizedState=a,e=Zm(),Ie.lanes|=e,wl|=e,a)}function Zf(e,t,a,n){return Da(a,t)?a:Hs.current!==null?(e=Ic(e,a,n),Da(e,t)||(Ut=!0),e):(Fn&42)===0||(Fn&1073741824)!==0&&(Je&261930)===0?(Ut=!0,e.memoizedState=a):(e=Zm(),Ie.lanes|=e,wl|=e,t)}function Kf(e,t,a,n,r){var o=V.p;V.p=o!==0&&8>o?o:8;var m=E.T,y={};E.T=y,Xc(e,!1,t,a);try{var A=r(),L=E.S;if(L!==null&&L(y,A),A!==null&&typeof A=="object"&&typeof A.then=="function"){var G=e0(A,n);Rr(e,t,G,qa(e))}else Rr(e,t,n,qa(e))}catch(K){Rr(e,t,{then:function(){},status:"rejected",reason:K},qa())}finally{V.p=o,m!==null&&y.types!==null&&(m.types=y.types),E.T=m}}function r0(){}function Gc(e,t,a,n){if(e.tag!==5)throw Error(c(476));var r=Jf(e).queue;Kf(e,r,t,H,a===null?r0:function(){return Pf(e),a(n)})}function Jf(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:H,baseState:H,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:In,lastRenderedState:H},next:null};var a={};return t.next={memoizedState:a,baseState:a,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:In,lastRenderedState:a},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Pf(e){var t=Jf(e);t.next===null&&(t=e.alternate.memoizedState),Rr(e,t.next.queue,{},qa())}function Vc(){return Jt(Pr)}function Wf(){return zt().memoizedState}function em(){return zt().memoizedState}function i0(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var a=qa();e=pl(a);var n=gl(t,e,a);n!==null&&(ya(n,t,a),Er(n,t,a)),t={cache:vc()},e.payload=t;return}t=t.return}}function o0(e,t,a){var n=qa();a={lane:n,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Bi(e)?am(t,a):(a=cc(e,t,a,n),a!==null&&(ya(a,e,n),nm(a,t,n)))}function tm(e,t,a){var n=qa();Rr(e,t,a,n)}function Rr(e,t,a,n){var r={lane:n,revertLane:0,gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null};if(Bi(e))am(t,r);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var m=t.lastRenderedState,y=o(m,a);if(r.hasEagerState=!0,r.eagerState=y,Da(y,m))return vi(e,t,r,0),ht===null&&yi(),!1}catch{}finally{}if(a=cc(e,t,r,n),a!==null)return ya(a,e,n),nm(a,t,n),!0}return!1}function Xc(e,t,a,n){if(n={lane:2,revertLane:_u(),gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Bi(e)){if(t)throw Error(c(479))}else t=cc(e,a,n,2),t!==null&&ya(t,e,2)}function Bi(e){var t=e.alternate;return e===Ie||t!==null&&t===Ie}function am(e,t){Fs=Di=!0;var a=e.pending;a===null?t.next=t:(t.next=a.next,a.next=t),e.pending=t}function nm(e,t,a){if((a&4194048)!==0){var n=t.lanes;n&=e.pendingLanes,a|=n,t.lanes=a,fs(e,a)}}var Ur={readContext:Jt,use:Ui,useCallback:jt,useContext:jt,useEffect:jt,useImperativeHandle:jt,useLayoutEffect:jt,useInsertionEffect:jt,useMemo:jt,useReducer:jt,useRef:jt,useState:jt,useDebugValue:jt,useDeferredValue:jt,useTransition:jt,useSyncExternalStore:jt,useId:jt,useHostTransitionStatus:jt,useFormState:jt,useActionState:jt,useOptimistic:jt,useMemoCache:jt,useCacheRefresh:jt};Ur.useEffectEvent=jt;var lm={readContext:Jt,use:Ui,useCallback:function(e,t){return oa().memoizedState=[e,t===void 0?null:t],e},useContext:Jt,useEffect:Hf,useImperativeHandle:function(e,t,a){a=a!=null?a.concat([e]):null,$i(4194308,4,Vf.bind(null,t,e),a)},useLayoutEffect:function(e,t){return $i(4194308,4,e,t)},useInsertionEffect:function(e,t){$i(4,2,e,t)},useMemo:function(e,t){var a=oa();t=t===void 0?null:t;var n=e();if(rs){Ht(!0);try{e()}finally{Ht(!1)}}return a.memoizedState=[n,t],n},useReducer:function(e,t,a){var n=oa();if(a!==void 0){var r=a(t);if(rs){Ht(!0);try{a(t)}finally{Ht(!1)}}}else r=t;return n.memoizedState=n.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},n.queue=e,e=e.dispatch=o0.bind(null,Ie,e),[n.memoizedState,e]},useRef:function(e){var t=oa();return e={current:e},t.memoizedState=e},useState:function(e){e=qc(e);var t=e.queue,a=tm.bind(null,Ie,t);return t.dispatch=a,[e.memoizedState,a]},useDebugValue:Fc,useDeferredValue:function(e,t){var a=oa();return Ic(a,e,t)},useTransition:function(){var e=qc(!1);return e=Kf.bind(null,Ie,e.queue,!0,!1),oa().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,a){var n=Ie,r=oa();if(We){if(a===void 0)throw Error(c(407));a=a()}else{if(a=t(),ht===null)throw Error(c(349));(Je&127)!==0||Af(n,t,a)}r.memoizedState=a;var o={value:a,getSnapshot:t};return r.queue=o,Hf(jf.bind(null,n,o,e),[e]),n.flags|=2048,Gs(9,{destroy:void 0},Cf.bind(null,n,o,a,t),null),a},useId:function(){var e=oa(),t=ht.identifierPrefix;if(We){var a=_n,n=kn;a=(n&~(1<<32-_e(n)-1)).toString(32)+a,t="_"+t+"R_"+a,a=Li++,0<a&&(t+="H"+a.toString(32)),t+="_"}else a=t0++,t="_"+t+"r_"+a.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Vc,useFormState:Uf,useActionState:Uf,useOptimistic:function(e){var t=oa();t.memoizedState=t.baseState=e;var a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=a,t=Xc.bind(null,Ie,!0,a),a.dispatch=t,[e,t]},useMemoCache:Uc,useCacheRefresh:function(){return oa().memoizedState=i0.bind(null,Ie)},useEffectEvent:function(e){var t=oa(),a={impl:e};return t.memoizedState=a,function(){if((rt&2)!==0)throw Error(c(440));return a.impl.apply(void 0,arguments)}}},Yc={readContext:Jt,use:Ui,useCallback:Yf,useContext:Jt,useEffect:Hc,useImperativeHandle:Xf,useInsertionEffect:If,useLayoutEffect:Gf,useMemo:Qf,useReducer:Oi,useRef:Bf,useState:function(){return Oi(In)},useDebugValue:Fc,useDeferredValue:function(e,t){var a=zt();return Zf(a,dt.memoizedState,e,t)},useTransition:function(){var e=Oi(In)[0],t=zt().memoizedState;return[typeof e=="boolean"?e:Lr(e),t]},useSyncExternalStore:_f,useId:Wf,useHostTransitionStatus:Vc,useFormState:Of,useActionState:Of,useOptimistic:function(e,t){var a=zt();return Ef(a,dt,e,t)},useMemoCache:Uc,useCacheRefresh:em};Yc.useEffectEvent=Ff;var sm={readContext:Jt,use:Ui,useCallback:Yf,useContext:Jt,useEffect:Hc,useImperativeHandle:Xf,useInsertionEffect:If,useLayoutEffect:Gf,useMemo:Qf,useReducer:$c,useRef:Bf,useState:function(){return $c(In)},useDebugValue:Fc,useDeferredValue:function(e,t){var a=zt();return dt===null?Ic(a,e,t):Zf(a,dt.memoizedState,e,t)},useTransition:function(){var e=$c(In)[0],t=zt().memoizedState;return[typeof e=="boolean"?e:Lr(e),t]},useSyncExternalStore:_f,useId:Wf,useHostTransitionStatus:Vc,useFormState:qf,useActionState:qf,useOptimistic:function(e,t){var a=zt();return dt!==null?Ef(a,dt,e,t):(a.baseState=e,[e,a.queue.dispatch])},useMemoCache:Uc,useCacheRefresh:em};sm.useEffectEvent=Ff;function Qc(e,t,a,n){t=e.memoizedState,a=a(n,t),a=a==null?t:w({},t,a),e.memoizedState=a,e.lanes===0&&(e.updateQueue.baseState=a)}var Zc={enqueueSetState:function(e,t,a){e=e._reactInternals;var n=qa(),r=pl(n);r.payload=t,a!=null&&(r.callback=a),t=gl(e,r,n),t!==null&&(ya(t,e,n),Er(t,e,n))},enqueueReplaceState:function(e,t,a){e=e._reactInternals;var n=qa(),r=pl(n);r.tag=1,r.payload=t,a!=null&&(r.callback=a),t=gl(e,r,n),t!==null&&(ya(t,e,n),Er(t,e,n))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var a=qa(),n=pl(a);n.tag=2,t!=null&&(n.callback=t),t=gl(e,n,a),t!==null&&(ya(t,e,a),Er(t,e,a))}};function rm(e,t,a,n,r,o,m){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(n,o,m):t.prototype&&t.prototype.isPureReactComponent?!Sr(a,n)||!Sr(r,o):!0}function im(e,t,a,n){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(a,n),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(a,n),t.state!==e&&Zc.enqueueReplaceState(t,t.state,null)}function is(e,t){var a=t;if("ref"in t){a={};for(var n in t)n!=="ref"&&(a[n]=t[n])}if(e=e.defaultProps){a===t&&(a=w({},a));for(var r in e)a[r]===void 0&&(a[r]=e[r])}return a}function om(e){bi(e)}function cm(e){console.error(e)}function um(e){bi(e)}function Hi(e,t){try{var a=e.onUncaughtError;a(t.value,{componentStack:t.stack})}catch(n){setTimeout(function(){throw n})}}function dm(e,t,a){try{var n=e.onCaughtError;n(a.value,{componentStack:a.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(r){setTimeout(function(){throw r})}}function Kc(e,t,a){return a=pl(a),a.tag=3,a.payload={element:null},a.callback=function(){Hi(e,t)},a}function fm(e){return e=pl(e),e.tag=3,e}function mm(e,t,a,n){var r=a.type.getDerivedStateFromError;if(typeof r=="function"){var o=n.value;e.payload=function(){return r(o)},e.callback=function(){dm(t,a,n)}}var m=a.stateNode;m!==null&&typeof m.componentDidCatch=="function"&&(e.callback=function(){dm(t,a,n),typeof r!="function"&&(Sl===null?Sl=new Set([this]):Sl.add(this));var y=n.stack;this.componentDidCatch(n.value,{componentStack:y!==null?y:""})})}function c0(e,t,a,n,r){if(a.flags|=32768,n!==null&&typeof n=="object"&&typeof n.then=="function"){if(t=a.alternate,t!==null&&Us(t,a,r,!0),a=Ra.current,a!==null){switch(a.tag){case 31:case 13:return Ja===null?Wi():a.alternate===null&&Nt===0&&(Nt=3),a.flags&=-257,a.flags|=65536,a.lanes=r,n===Ni?a.flags|=16384:(t=a.updateQueue,t===null?a.updateQueue=new Set([n]):t.add(n),wu(e,n,r)),!1;case 22:return a.flags|=65536,n===Ni?a.flags|=16384:(t=a.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([n])},a.updateQueue=t):(a=t.retryQueue,a===null?t.retryQueue=new Set([n]):a.add(n)),wu(e,n,r)),!1}throw Error(c(435,a.tag))}return wu(e,n,r),Wi(),!1}if(We)return t=Ra.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=r,n!==pc&&(e=Error(c(422),{cause:n}),Ar(Ya(e,a)))):(n!==pc&&(t=Error(c(423),{cause:n}),Ar(Ya(t,a))),e=e.current.alternate,e.flags|=65536,r&=-r,e.lanes|=r,n=Ya(n,a),r=Kc(e.stateNode,n,r),Cc(e,r),Nt!==4&&(Nt=2)),!1;var o=Error(c(520),{cause:n});if(o=Ya(o,a),Gr===null?Gr=[o]:Gr.push(o),Nt!==4&&(Nt=2),t===null)return!0;n=Ya(n,a),a=t;do{switch(a.tag){case 3:return a.flags|=65536,e=r&-r,a.lanes|=e,e=Kc(a.stateNode,n,e),Cc(a,e),!1;case 1:if(t=a.type,o=a.stateNode,(a.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(Sl===null||!Sl.has(o))))return a.flags|=65536,r&=-r,a.lanes|=r,r=fm(r),mm(r,e,a,n),Cc(a,r),!1}a=a.return}while(a!==null);return!1}var Jc=Error(c(461)),Ut=!1;function Pt(e,t,a,n){t.child=e===null?xf(t,null,a,n):ss(t,e.child,a,n)}function hm(e,t,a,n,r){a=a.render;var o=t.ref;if("ref"in n){var m={};for(var y in n)y!=="ref"&&(m[y]=n[y])}else m=n;return ts(t),n=zc(e,t,a,m,o,r),y=Dc(),e!==null&&!Ut?(Lc(e,t,r),Gn(e,t,r)):(We&&y&&mc(t),t.flags|=1,Pt(e,t,n,r),t.child)}function pm(e,t,a,n,r){if(e===null){var o=a.type;return typeof o=="function"&&!uc(o)&&o.defaultProps===void 0&&a.compare===null?(t.tag=15,t.type=o,gm(e,t,o,n,r)):(e=Si(a.type,null,n,t,t.mode,r),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!su(e,r)){var m=o.memoizedProps;if(a=a.compare,a=a!==null?a:Sr,a(m,n)&&e.ref===t.ref)return Gn(e,t,r)}return t.flags|=1,e=$n(o,n),e.ref=t.ref,e.return=t,t.child=e}function gm(e,t,a,n,r){if(e!==null){var o=e.memoizedProps;if(Sr(o,n)&&e.ref===t.ref)if(Ut=!1,t.pendingProps=n=o,su(e,r))(e.flags&131072)!==0&&(Ut=!0);else return t.lanes=e.lanes,Gn(e,t,r)}return Pc(e,t,a,n,r)}function xm(e,t,a,n){var r=n.children,o=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.mode==="hidden"){if((t.flags&128)!==0){if(o=o!==null?o.baseLanes|a:a,e!==null){for(n=t.child=e.child,r=0;n!==null;)r=r|n.lanes|n.childLanes,n=n.sibling;n=r&~o}else n=0,t.child=null;return bm(e,t,o,a,n)}if((a&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ci(t,o!==null?o.cachePool:null),o!==null?vf(t,o):Nc(),wf(t);else return n=t.lanes=536870912,bm(e,t,o!==null?o.baseLanes|a:a,a,n)}else o!==null?(Ci(t,o.cachePool),vf(t,o),bl(),t.memoizedState=null):(e!==null&&Ci(t,null),Nc(),bl());return Pt(e,t,r,a),t.child}function Or(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function bm(e,t,a,n,r){var o=Sc();return o=o===null?null:{parent:Lt._currentValue,pool:o},t.memoizedState={baseLanes:a,cachePool:o},e!==null&&Ci(t,null),Nc(),wf(t),e!==null&&Us(e,t,n,!0),t.childLanes=r,null}function Fi(e,t){return t=Gi({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ym(e,t,a){return ss(t,e.child,null,a),e=Fi(t,t.pendingProps),e.flags|=2,Ua(t),t.memoizedState=null,e}function u0(e,t,a){var n=t.pendingProps,r=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(We){if(n.mode==="hidden")return e=Fi(t,n),t.lanes=536870912,Or(null,e);if(Ec(t),(e=yt)?(e=Mh(e,Ka),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ul!==null?{id:kn,overflow:_n}:null,retryLane:536870912,hydrationErrors:null},a=tf(e),a.return=t,t.child=a,Kt=t,yt=null)):e=null,e===null)throw fl(t);return t.lanes=536870912,null}return Fi(t,n)}var o=e.memoizedState;if(o!==null){var m=o.dehydrated;if(Ec(t),r)if(t.flags&256)t.flags&=-257,t=ym(e,t,a);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(c(558));else if(Ut||Us(e,t,a,!1),r=(a&e.childLanes)!==0,Ut||r){if(n=ht,n!==null&&(m=ql(n,a),m!==0&&m!==o.retryLane))throw o.retryLane=m,Jl(e,m),ya(n,e,m),Jc;Wi(),t=ym(e,t,a)}else e=o.treeContext,yt=Pa(m.nextSibling),Kt=t,We=!0,dl=null,Ka=!1,e!==null&&lf(t,e),t=Fi(t,n),t.flags|=4096;return t}return e=$n(e.child,{mode:n.mode,children:n.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Ii(e,t){var a=t.ref;if(a===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof a!="function"&&typeof a!="object")throw Error(c(284));(e===null||e.ref!==a)&&(t.flags|=4194816)}}function Pc(e,t,a,n,r){return ts(t),a=zc(e,t,a,n,void 0,r),n=Dc(),e!==null&&!Ut?(Lc(e,t,r),Gn(e,t,r)):(We&&n&&mc(t),t.flags|=1,Pt(e,t,a,r),t.child)}function vm(e,t,a,n,r,o){return ts(t),t.updateQueue=null,a=kf(t,n,a,r),Sf(e),n=Dc(),e!==null&&!Ut?(Lc(e,t,o),Gn(e,t,o)):(We&&n&&mc(t),t.flags|=1,Pt(e,t,a,o),t.child)}function wm(e,t,a,n,r){if(ts(t),t.stateNode===null){var o=zs,m=a.contextType;typeof m=="object"&&m!==null&&(o=Jt(m)),o=new a(n,o),t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=Zc,t.stateNode=o,o._reactInternals=t,o=t.stateNode,o.props=n,o.state=t.memoizedState,o.refs={},_c(t),m=a.contextType,o.context=typeof m=="object"&&m!==null?Jt(m):zs,o.state=t.memoizedState,m=a.getDerivedStateFromProps,typeof m=="function"&&(Qc(t,a,m,n),o.state=t.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(m=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),m!==o.state&&Zc.enqueueReplaceState(o,o.state,null),zr(t,n,o,r),Mr(),o.state=t.memoizedState),typeof o.componentDidMount=="function"&&(t.flags|=4194308),n=!0}else if(e===null){o=t.stateNode;var y=t.memoizedProps,A=is(a,y);o.props=A;var L=o.context,G=a.contextType;m=zs,typeof G=="object"&&G!==null&&(m=Jt(G));var K=a.getDerivedStateFromProps;G=typeof K=="function"||typeof o.getSnapshotBeforeUpdate=="function",y=t.pendingProps!==y,G||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(y||L!==m)&&im(t,o,n,m),hl=!1;var O=t.memoizedState;o.state=O,zr(t,n,o,r),Mr(),L=t.memoizedState,y||O!==L||hl?(typeof K=="function"&&(Qc(t,a,K,n),L=t.memoizedState),(A=hl||rm(t,a,A,n,O,L,m))?(G||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=n,t.memoizedState=L),o.props=n,o.state=L,o.context=m,n=A):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),n=!1)}else{o=t.stateNode,Ac(e,t),m=t.memoizedProps,G=is(a,m),o.props=G,K=t.pendingProps,O=o.context,L=a.contextType,A=zs,typeof L=="object"&&L!==null&&(A=Jt(L)),y=a.getDerivedStateFromProps,(L=typeof y=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(m!==K||O!==A)&&im(t,o,n,A),hl=!1,O=t.memoizedState,o.state=O,zr(t,n,o,r),Mr();var B=t.memoizedState;m!==K||O!==B||hl||e!==null&&e.dependencies!==null&&_i(e.dependencies)?(typeof y=="function"&&(Qc(t,a,y,n),B=t.memoizedState),(G=hl||rm(t,a,G,n,O,B,A)||e!==null&&e.dependencies!==null&&_i(e.dependencies))?(L||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(n,B,A),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(n,B,A)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||m===e.memoizedProps&&O===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||m===e.memoizedProps&&O===e.memoizedState||(t.flags|=1024),t.memoizedProps=n,t.memoizedState=B),o.props=n,o.state=B,o.context=A,n=G):(typeof o.componentDidUpdate!="function"||m===e.memoizedProps&&O===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||m===e.memoizedProps&&O===e.memoizedState||(t.flags|=1024),n=!1)}return o=n,Ii(e,t),n=(t.flags&128)!==0,o||n?(o=t.stateNode,a=n&&typeof a.getDerivedStateFromError!="function"?null:o.render(),t.flags|=1,e!==null&&n?(t.child=ss(t,e.child,null,r),t.child=ss(t,null,a,r)):Pt(e,t,a,r),t.memoizedState=o.state,e=t.child):e=Gn(e,t,r),e}function Sm(e,t,a,n){return Wl(),t.flags|=256,Pt(e,t,a,n),t.child}var Wc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function eu(e){return{baseLanes:e,cachePool:df()}}function tu(e,t,a){return e=e!==null?e.childLanes&~a:0,t&&(e|=$a),e}function km(e,t,a){var n=t.pendingProps,r=!1,o=(t.flags&128)!==0,m;if((m=o)||(m=e!==null&&e.memoizedState===null?!1:(Mt.current&2)!==0),m&&(r=!0,t.flags&=-129),m=(t.flags&32)!==0,t.flags&=-33,e===null){if(We){if(r?xl(t):bl(),(e=yt)?(e=Mh(e,Ka),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ul!==null?{id:kn,overflow:_n}:null,retryLane:536870912,hydrationErrors:null},a=tf(e),a.return=t,t.child=a,Kt=t,yt=null)):e=null,e===null)throw fl(t);return Ou(e)?t.lanes=32:t.lanes=536870912,null}var y=n.children;return n=n.fallback,r?(bl(),r=t.mode,y=Gi({mode:"hidden",children:y},r),n=Pl(n,r,a,null),y.return=t,n.return=t,y.sibling=n,t.child=y,n=t.child,n.memoizedState=eu(a),n.childLanes=tu(e,m,a),t.memoizedState=Wc,Or(null,n)):(xl(t),au(t,y))}var A=e.memoizedState;if(A!==null&&(y=A.dehydrated,y!==null)){if(o)t.flags&256?(xl(t),t.flags&=-257,t=nu(e,t,a)):t.memoizedState!==null?(bl(),t.child=e.child,t.flags|=128,t=null):(bl(),y=n.fallback,r=t.mode,n=Gi({mode:"visible",children:n.children},r),y=Pl(y,r,a,null),y.flags|=2,n.return=t,y.return=t,n.sibling=y,t.child=n,ss(t,e.child,null,a),n=t.child,n.memoizedState=eu(a),n.childLanes=tu(e,m,a),t.memoizedState=Wc,t=Or(null,n));else if(xl(t),Ou(y)){if(m=y.nextSibling&&y.nextSibling.dataset,m)var L=m.dgst;m=L,n=Error(c(419)),n.stack="",n.digest=m,Ar({value:n,source:null,stack:null}),t=nu(e,t,a)}else if(Ut||Us(e,t,a,!1),m=(a&e.childLanes)!==0,Ut||m){if(m=ht,m!==null&&(n=ql(m,a),n!==0&&n!==A.retryLane))throw A.retryLane=n,Jl(e,n),ya(m,e,n),Jc;Uu(y)||Wi(),t=nu(e,t,a)}else Uu(y)?(t.flags|=192,t.child=e.child,t=null):(e=A.treeContext,yt=Pa(y.nextSibling),Kt=t,We=!0,dl=null,Ka=!1,e!==null&&lf(t,e),t=au(t,n.children),t.flags|=4096);return t}return r?(bl(),y=n.fallback,r=t.mode,A=e.child,L=A.sibling,n=$n(A,{mode:"hidden",children:n.children}),n.subtreeFlags=A.subtreeFlags&65011712,L!==null?y=$n(L,y):(y=Pl(y,r,a,null),y.flags|=2),y.return=t,n.return=t,n.sibling=y,t.child=n,Or(null,n),n=t.child,y=e.child.memoizedState,y===null?y=eu(a):(r=y.cachePool,r!==null?(A=Lt._currentValue,r=r.parent!==A?{parent:A,pool:A}:r):r=df(),y={baseLanes:y.baseLanes|a,cachePool:r}),n.memoizedState=y,n.childLanes=tu(e,m,a),t.memoizedState=Wc,Or(e.child,n)):(xl(t),a=e.child,e=a.sibling,a=$n(a,{mode:"visible",children:n.children}),a.return=t,a.sibling=null,e!==null&&(m=t.deletions,m===null?(t.deletions=[e],t.flags|=16):m.push(e)),t.child=a,t.memoizedState=null,a)}function au(e,t){return t=Gi({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Gi(e,t){return e=La(22,e,null,t),e.lanes=0,e}function nu(e,t,a){return ss(t,e.child,null,a),e=au(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _m(e,t,a){e.lanes|=t;var n=e.alternate;n!==null&&(n.lanes|=t),bc(e.return,t,a)}function lu(e,t,a,n,r,o){var m=e.memoizedState;m===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:a,tailMode:r,treeForkCount:o}:(m.isBackwards=t,m.rendering=null,m.renderingStartTime=0,m.last=n,m.tail=a,m.tailMode=r,m.treeForkCount=o)}function Am(e,t,a){var n=t.pendingProps,r=n.revealOrder,o=n.tail;n=n.children;var m=Mt.current,y=(m&2)!==0;if(y?(m=m&1|2,t.flags|=128):m&=1,F(Mt,m),Pt(e,t,n,a),n=We?_r:0,!y&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&_m(e,a,t);else if(e.tag===19)_m(e,a,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(r){case"forwards":for(a=t.child,r=null;a!==null;)e=a.alternate,e!==null&&zi(e)===null&&(r=a),a=a.sibling;a=r,a===null?(r=t.child,t.child=null):(r=a.sibling,a.sibling=null),lu(t,!1,r,a,o,n);break;case"backwards":case"unstable_legacy-backwards":for(a=null,r=t.child,t.child=null;r!==null;){if(e=r.alternate,e!==null&&zi(e)===null){t.child=r;break}e=r.sibling,r.sibling=a,a=r,r=e}lu(t,!0,a,null,o,n);break;case"together":lu(t,!1,null,null,void 0,n);break;default:t.memoizedState=null}return t.child}function Gn(e,t,a){if(e!==null&&(t.dependencies=e.dependencies),wl|=t.lanes,(a&t.childLanes)===0)if(e!==null){if(Us(e,t,a,!1),(a&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(c(153));if(t.child!==null){for(e=t.child,a=$n(e,e.pendingProps),t.child=a,a.return=t;e.sibling!==null;)e=e.sibling,a=a.sibling=$n(e,e.pendingProps),a.return=t;a.sibling=null}return t.child}function su(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&_i(e)))}function d0(e,t,a){switch(t.tag){case 3:W(t,t.stateNode.containerInfo),ml(t,Lt,e.memoizedState.cache),Wl();break;case 27:case 5:be(t);break;case 4:W(t,t.stateNode.containerInfo);break;case 10:ml(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Ec(t),null;break;case 13:var n=t.memoizedState;if(n!==null)return n.dehydrated!==null?(xl(t),t.flags|=128,null):(a&t.child.childLanes)!==0?km(e,t,a):(xl(t),e=Gn(e,t,a),e!==null?e.sibling:null);xl(t);break;case 19:var r=(e.flags&128)!==0;if(n=(a&t.childLanes)!==0,n||(Us(e,t,a,!1),n=(a&t.childLanes)!==0),r){if(n)return Am(e,t,a);t.flags|=128}if(r=t.memoizedState,r!==null&&(r.rendering=null,r.tail=null,r.lastEffect=null),F(Mt,Mt.current),n)break;return null;case 22:return t.lanes=0,xm(e,t,a,t.pendingProps);case 24:ml(t,Lt,e.memoizedState.cache)}return Gn(e,t,a)}function Cm(e,t,a){if(e!==null)if(e.memoizedProps!==t.pendingProps)Ut=!0;else{if(!su(e,a)&&(t.flags&128)===0)return Ut=!1,d0(e,t,a);Ut=(e.flags&131072)!==0}else Ut=!1,We&&(t.flags&1048576)!==0&&nf(t,_r,t.index);switch(t.lanes=0,t.tag){case 16:e:{var n=t.pendingProps;if(e=ns(t.elementType),t.type=e,typeof e=="function")uc(e)?(n=is(e,n),t.tag=1,t=wm(null,t,e,n,a)):(t.tag=0,t=Pc(null,t,e,n,a));else{if(e!=null){var r=e.$$typeof;if(r===R){t.tag=11,t=hm(null,t,e,n,a);break e}else if(r===X){t.tag=14,t=pm(null,t,e,n,a);break e}}throw t=te(e)||e,Error(c(306,t,""))}}return t;case 0:return Pc(e,t,t.type,t.pendingProps,a);case 1:return n=t.type,r=is(n,t.pendingProps),wm(e,t,n,r,a);case 3:e:{if(W(t,t.stateNode.containerInfo),e===null)throw Error(c(387));n=t.pendingProps;var o=t.memoizedState;r=o.element,Ac(e,t),zr(t,n,null,a);var m=t.memoizedState;if(n=m.cache,ml(t,Lt,n),n!==o.cache&&yc(t,[Lt],a,!0),Mr(),n=m.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:m.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Sm(e,t,n,a);break e}else if(n!==r){r=Ya(Error(c(424)),t),Ar(r),t=Sm(e,t,n,a);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(yt=Pa(e.firstChild),Kt=t,We=!0,dl=null,Ka=!0,a=xf(t,null,n,a),t.child=a;a;)a.flags=a.flags&-3|4096,a=a.sibling}else{if(Wl(),n===r){t=Gn(e,t,a);break e}Pt(e,t,n,a)}t=t.child}return t;case 26:return Ii(e,t),e===null?(a=Oh(t.type,null,t.pendingProps,null))?t.memoizedState=a:We||(a=t.type,e=t.pendingProps,n=ro(de.current).createElement(a),n[Et]=t,n[Ct]=e,Wt(n,a,e),Ye(n),t.stateNode=n):t.memoizedState=Oh(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return be(t),e===null&&We&&(n=t.stateNode=Lh(t.type,t.pendingProps,de.current),Kt=t,Ka=!0,r=yt,Cl(t.type)?($u=r,yt=Pa(n.firstChild)):yt=r),Pt(e,t,t.pendingProps.children,a),Ii(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&We&&((r=n=yt)&&(n=H0(n,t.type,t.pendingProps,Ka),n!==null?(t.stateNode=n,Kt=t,yt=Pa(n.firstChild),Ka=!1,r=!0):r=!1),r||fl(t)),be(t),r=t.type,o=t.pendingProps,m=e!==null?e.memoizedProps:null,n=o.children,Du(r,o)?n=null:m!==null&&Du(r,m)&&(t.flags|=32),t.memoizedState!==null&&(r=zc(e,t,a0,null,null,a),Pr._currentValue=r),Ii(e,t),Pt(e,t,n,a),t.child;case 6:return e===null&&We&&((e=a=yt)&&(a=F0(a,t.pendingProps,Ka),a!==null?(t.stateNode=a,Kt=t,yt=null,e=!0):e=!1),e||fl(t)),null;case 13:return km(e,t,a);case 4:return W(t,t.stateNode.containerInfo),n=t.pendingProps,e===null?t.child=ss(t,null,n,a):Pt(e,t,n,a),t.child;case 11:return hm(e,t,t.type,t.pendingProps,a);case 7:return Pt(e,t,t.pendingProps,a),t.child;case 8:return Pt(e,t,t.pendingProps.children,a),t.child;case 12:return Pt(e,t,t.pendingProps.children,a),t.child;case 10:return n=t.pendingProps,ml(t,t.type,n.value),Pt(e,t,n.children,a),t.child;case 9:return r=t.type._context,n=t.pendingProps.children,ts(t),r=Jt(r),n=n(r),t.flags|=1,Pt(e,t,n,a),t.child;case 14:return pm(e,t,t.type,t.pendingProps,a);case 15:return gm(e,t,t.type,t.pendingProps,a);case 19:return Am(e,t,a);case 31:return u0(e,t,a);case 22:return xm(e,t,a,t.pendingProps);case 24:return ts(t),n=Jt(Lt),e===null?(r=Sc(),r===null&&(r=ht,o=vc(),r.pooledCache=o,o.refCount++,o!==null&&(r.pooledCacheLanes|=a),r=o),t.memoizedState={parent:n,cache:r},_c(t),ml(t,Lt,r)):((e.lanes&a)!==0&&(Ac(e,t),zr(t,null,null,a),Mr()),r=e.memoizedState,o=t.memoizedState,r.parent!==n?(r={parent:n,cache:n},t.memoizedState=r,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=r),ml(t,Lt,n)):(n=o.cache,ml(t,Lt,n),n!==r.cache&&yc(t,[Lt],a,!0))),Pt(e,t,t.pendingProps.children,a),t.child;case 29:throw t.pendingProps}throw Error(c(156,t.tag))}function Vn(e){e.flags|=4}function ru(e,t,a,n,r){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(r&335544128)===r)if(e.stateNode.complete)e.flags|=8192;else if(Wm())e.flags|=8192;else throw ls=Ni,kc}else e.flags&=-16777217}function jm(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Fh(t))if(Wm())e.flags|=8192;else throw ls=Ni,kc}function Vi(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?$l():536870912,e.lanes|=t,Qs|=t)}function $r(e,t){if(!We)switch(e.tailMode){case"hidden":t=e.tail;for(var a=null;t!==null;)t.alternate!==null&&(a=t),t=t.sibling;a===null?e.tail=null:a.sibling=null;break;case"collapsed":a=e.tail;for(var n=null;a!==null;)a.alternate!==null&&(n=a),a=a.sibling;n===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:n.sibling=null}}function vt(e){var t=e.alternate!==null&&e.alternate.child===e.child,a=0,n=0;if(t)for(var r=e.child;r!==null;)a|=r.lanes|r.childLanes,n|=r.subtreeFlags&65011712,n|=r.flags&65011712,r.return=e,r=r.sibling;else for(r=e.child;r!==null;)a|=r.lanes|r.childLanes,n|=r.subtreeFlags,n|=r.flags,r.return=e,r=r.sibling;return e.subtreeFlags|=n,e.childLanes=a,t}function f0(e,t,a){var n=t.pendingProps;switch(hc(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return vt(t),null;case 1:return vt(t),null;case 3:return a=t.stateNode,n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Hn(Lt),re(),a.pendingContext&&(a.context=a.pendingContext,a.pendingContext=null),(e===null||e.child===null)&&(Rs(t)?Vn(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,gc())),vt(t),null;case 26:var r=t.type,o=t.memoizedState;return e===null?(Vn(t),o!==null?(vt(t),jm(t,o)):(vt(t),ru(t,r,null,n,a))):o?o!==e.memoizedState?(Vn(t),vt(t),jm(t,o)):(vt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==n&&Vn(t),vt(t),ru(t,r,e,n,a)),null;case 27:if(ke(t),a=de.current,r=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==n&&Vn(t);else{if(!n){if(t.stateNode===null)throw Error(c(166));return vt(t),null}e=me.current,Rs(t)?sf(t):(e=Lh(r,n,a),t.stateNode=e,Vn(t))}return vt(t),null;case 5:if(ke(t),r=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==n&&Vn(t);else{if(!n){if(t.stateNode===null)throw Error(c(166));return vt(t),null}if(o=me.current,Rs(t))sf(t);else{var m=ro(de.current);switch(o){case 1:o=m.createElementNS("http://www.w3.org/2000/svg",r);break;case 2:o=m.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;default:switch(r){case"svg":o=m.createElementNS("http://www.w3.org/2000/svg",r);break;case"math":o=m.createElementNS("http://www.w3.org/1998/Math/MathML",r);break;case"script":o=m.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof n.is=="string"?m.createElement("select",{is:n.is}):m.createElement("select"),n.multiple?o.multiple=!0:n.size&&(o.size=n.size);break;default:o=typeof n.is=="string"?m.createElement(r,{is:n.is}):m.createElement(r)}}o[Et]=t,o[Ct]=n;e:for(m=t.child;m!==null;){if(m.tag===5||m.tag===6)o.appendChild(m.stateNode);else if(m.tag!==4&&m.tag!==27&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===t)break e;for(;m.sibling===null;){if(m.return===null||m.return===t)break e;m=m.return}m.sibling.return=m.return,m=m.sibling}t.stateNode=o;e:switch(Wt(o,r,n),r){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}n&&Vn(t)}}return vt(t),ru(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,a),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==n&&Vn(t);else{if(typeof n!="string"&&t.stateNode===null)throw Error(c(166));if(e=de.current,Rs(t)){if(e=t.stateNode,a=t.memoizedProps,n=null,r=Kt,r!==null)switch(r.tag){case 27:case 5:n=r.memoizedProps}e[Et]=t,e=!!(e.nodeValue===a||n!==null&&n.suppressHydrationWarning===!0||kh(e.nodeValue,a)),e||fl(t,!0)}else e=ro(e).createTextNode(n),e[Et]=t,t.stateNode=e}return vt(t),null;case 31:if(a=t.memoizedState,e===null||e.memoizedState!==null){if(n=Rs(t),a!==null){if(e===null){if(!n)throw Error(c(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(c(557));e[Et]=t}else Wl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;vt(t),e=!1}else a=gc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),e=!0;if(!e)return t.flags&256?(Ua(t),t):(Ua(t),null);if((t.flags&128)!==0)throw Error(c(558))}return vt(t),null;case 13:if(n=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(r=Rs(t),n!==null&&n.dehydrated!==null){if(e===null){if(!r)throw Error(c(318));if(r=t.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(c(317));r[Et]=t}else Wl(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;vt(t),r=!1}else r=gc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),r=!0;if(!r)return t.flags&256?(Ua(t),t):(Ua(t),null)}return Ua(t),(t.flags&128)!==0?(t.lanes=a,t):(a=n!==null,e=e!==null&&e.memoizedState!==null,a&&(n=t.child,r=null,n.alternate!==null&&n.alternate.memoizedState!==null&&n.alternate.memoizedState.cachePool!==null&&(r=n.alternate.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==r&&(n.flags|=2048)),a!==e&&a&&(t.child.flags|=8192),Vi(t,t.updateQueue),vt(t),null);case 4:return re(),e===null&&Nu(t.stateNode.containerInfo),vt(t),null;case 10:return Hn(t.type),vt(t),null;case 19:if(pe(Mt),n=t.memoizedState,n===null)return vt(t),null;if(r=(t.flags&128)!==0,o=n.rendering,o===null)if(r)$r(n,!1);else{if(Nt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(o=zi(e),o!==null){for(t.flags|=128,$r(n,!1),e=o.updateQueue,t.updateQueue=e,Vi(t,e),t.subtreeFlags=0,e=a,a=t.child;a!==null;)ef(a,e),a=a.sibling;return F(Mt,Mt.current&1|2),We&&qn(t,n.treeForkCount),t.child}e=e.sibling}n.tail!==null&&Oe()>Ki&&(t.flags|=128,r=!0,$r(n,!1),t.lanes=4194304)}else{if(!r)if(e=zi(o),e!==null){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,Vi(t,e),$r(n,!0),n.tail===null&&n.tailMode==="hidden"&&!o.alternate&&!We)return vt(t),null}else 2*Oe()-n.renderingStartTime>Ki&&a!==536870912&&(t.flags|=128,r=!0,$r(n,!1),t.lanes=4194304);n.isBackwards?(o.sibling=t.child,t.child=o):(e=n.last,e!==null?e.sibling=o:t.child=o,n.last=o)}return n.tail!==null?(e=n.tail,n.rendering=e,n.tail=e.sibling,n.renderingStartTime=Oe(),e.sibling=null,a=Mt.current,F(Mt,r?a&1|2:a&1),We&&qn(t,n.treeForkCount),e):(vt(t),null);case 22:case 23:return Ua(t),Tc(),n=t.memoizedState!==null,e!==null?e.memoizedState!==null!==n&&(t.flags|=8192):n&&(t.flags|=8192),n?(a&536870912)!==0&&(t.flags&128)===0&&(vt(t),t.subtreeFlags&6&&(t.flags|=8192)):vt(t),a=t.updateQueue,a!==null&&Vi(t,a.retryQueue),a=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),n=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(n=t.memoizedState.cachePool.pool),n!==a&&(t.flags|=2048),e!==null&&pe(as),null;case 24:return a=null,e!==null&&(a=e.memoizedState.cache),t.memoizedState.cache!==a&&(t.flags|=2048),Hn(Lt),vt(t),null;case 25:return null;case 30:return null}throw Error(c(156,t.tag))}function m0(e,t){switch(hc(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Hn(Lt),re(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ke(t),null;case 31:if(t.memoizedState!==null){if(Ua(t),t.alternate===null)throw Error(c(340));Wl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ua(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(c(340));Wl()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return pe(Mt),null;case 4:return re(),null;case 10:return Hn(t.type),null;case 22:case 23:return Ua(t),Tc(),e!==null&&pe(as),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Hn(Lt),null;case 25:return null;default:return null}}function Nm(e,t){switch(hc(t),t.tag){case 3:Hn(Lt),re();break;case 26:case 27:case 5:ke(t);break;case 4:re();break;case 31:t.memoizedState!==null&&Ua(t);break;case 13:Ua(t);break;case 19:pe(Mt);break;case 10:Hn(t.type);break;case 22:case 23:Ua(t),Tc(),e!==null&&pe(as);break;case 24:Hn(Lt)}}function qr(e,t){try{var a=t.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var r=n.next;a=r;do{if((a.tag&e)===e){n=void 0;var o=a.create,m=a.inst;n=o(),m.destroy=n}a=a.next}while(a!==r)}}catch(y){ct(t,t.return,y)}}function yl(e,t,a){try{var n=t.updateQueue,r=n!==null?n.lastEffect:null;if(r!==null){var o=r.next;n=o;do{if((n.tag&e)===e){var m=n.inst,y=m.destroy;if(y!==void 0){m.destroy=void 0,r=t;var A=a,L=y;try{L()}catch(G){ct(r,A,G)}}}n=n.next}while(n!==o)}}catch(G){ct(t,t.return,G)}}function Tm(e){var t=e.updateQueue;if(t!==null){var a=e.stateNode;try{yf(t,a)}catch(n){ct(e,e.return,n)}}}function Em(e,t,a){a.props=is(e.type,e.memoizedProps),a.state=e.memoizedState;try{a.componentWillUnmount()}catch(n){ct(e,t,n)}}function Br(e,t){try{var a=e.ref;if(a!==null){switch(e.tag){case 26:case 27:case 5:var n=e.stateNode;break;case 30:n=e.stateNode;break;default:n=e.stateNode}typeof a=="function"?e.refCleanup=a(n):a.current=n}}catch(r){ct(e,t,r)}}function An(e,t){var a=e.ref,n=e.refCleanup;if(a!==null)if(typeof n=="function")try{n()}catch(r){ct(e,t,r)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof a=="function")try{a(null)}catch(r){ct(e,t,r)}else a.current=null}function Mm(e){var t=e.type,a=e.memoizedProps,n=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":a.autoFocus&&n.focus();break e;case"img":a.src?n.src=a.src:a.srcSet&&(n.srcset=a.srcSet)}}catch(r){ct(e,e.return,r)}}function iu(e,t,a){try{var n=e.stateNode;R0(n,e.type,a,t),n[Ct]=t}catch(r){ct(e,e.return,r)}}function zm(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Cl(e.type)||e.tag===4}function ou(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||zm(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Cl(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function cu(e,t,a){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a).insertBefore(e,t):(t=a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,t.appendChild(e),a=a._reactRootContainer,a!=null||t.onclick!==null||(t.onclick=Fa));else if(n!==4&&(n===27&&Cl(e.type)&&(a=e.stateNode,t=null),e=e.child,e!==null))for(cu(e,t,a),e=e.sibling;e!==null;)cu(e,t,a),e=e.sibling}function Xi(e,t,a){var n=e.tag;if(n===5||n===6)e=e.stateNode,t?a.insertBefore(e,t):a.appendChild(e);else if(n!==4&&(n===27&&Cl(e.type)&&(a=e.stateNode),e=e.child,e!==null))for(Xi(e,t,a),e=e.sibling;e!==null;)Xi(e,t,a),e=e.sibling}function Dm(e){var t=e.stateNode,a=e.memoizedProps;try{for(var n=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);Wt(t,n,a),t[Et]=e,t[Ct]=a}catch(o){ct(e,e.return,o)}}var Xn=!1,Ot=!1,uu=!1,Lm=typeof WeakSet=="function"?WeakSet:Set,Gt=null;function h0(e,t){if(e=e.containerInfo,Mu=ho,e=Vd(e),nc(e)){if("selectionStart"in e)var a={start:e.selectionStart,end:e.selectionEnd};else e:{a=(a=e.ownerDocument)&&a.defaultView||window;var n=a.getSelection&&a.getSelection();if(n&&n.rangeCount!==0){a=n.anchorNode;var r=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{a.nodeType,o.nodeType}catch{a=null;break e}var m=0,y=-1,A=-1,L=0,G=0,K=e,O=null;t:for(;;){for(var B;K!==a||r!==0&&K.nodeType!==3||(y=m+r),K!==o||n!==0&&K.nodeType!==3||(A=m+n),K.nodeType===3&&(m+=K.nodeValue.length),(B=K.firstChild)!==null;)O=K,K=B;for(;;){if(K===e)break t;if(O===a&&++L===r&&(y=m),O===o&&++G===n&&(A=m),(B=K.nextSibling)!==null)break;K=O,O=K.parentNode}K=B}a=y===-1||A===-1?null:{start:y,end:A}}else a=null}a=a||{start:0,end:0}}else a=null;for(zu={focusedElem:e,selectionRange:a},ho=!1,Gt=t;Gt!==null;)if(t=Gt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Gt=e;else for(;Gt!==null;){switch(t=Gt,o=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(a=0;a<e.length;a++)r=e[a],r.ref.impl=r.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&o!==null){e=void 0,a=t,r=o.memoizedProps,o=o.memoizedState,n=a.stateNode;try{var ve=is(a.type,r);e=n.getSnapshotBeforeUpdate(ve,o),n.__reactInternalSnapshotBeforeUpdate=e}catch(Re){ct(a,a.return,Re)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,a=e.nodeType,a===9)Ru(e);else if(a===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Ru(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(c(163))}if(e=t.sibling,e!==null){e.return=t.return,Gt=e;break}Gt=t.return}}function Rm(e,t,a){var n=a.flags;switch(a.tag){case 0:case 11:case 15:Qn(e,a),n&4&&qr(5,a);break;case 1:if(Qn(e,a),n&4)if(e=a.stateNode,t===null)try{e.componentDidMount()}catch(m){ct(a,a.return,m)}else{var r=is(a.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(r,t,e.__reactInternalSnapshotBeforeUpdate)}catch(m){ct(a,a.return,m)}}n&64&&Tm(a),n&512&&Br(a,a.return);break;case 3:if(Qn(e,a),n&64&&(e=a.updateQueue,e!==null)){if(t=null,a.child!==null)switch(a.child.tag){case 27:case 5:t=a.child.stateNode;break;case 1:t=a.child.stateNode}try{yf(e,t)}catch(m){ct(a,a.return,m)}}break;case 27:t===null&&n&4&&Dm(a);case 26:case 5:Qn(e,a),t===null&&n&4&&Mm(a),n&512&&Br(a,a.return);break;case 12:Qn(e,a);break;case 31:Qn(e,a),n&4&&$m(e,a);break;case 13:Qn(e,a),n&4&&qm(e,a),n&64&&(e=a.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(a=k0.bind(null,a),I0(e,a))));break;case 22:if(n=a.memoizedState!==null||Xn,!n){t=t!==null&&t.memoizedState!==null||Ot,r=Xn;var o=Ot;Xn=n,(Ot=t)&&!o?Zn(e,a,(a.subtreeFlags&8772)!==0):Qn(e,a),Xn=r,Ot=o}break;case 30:break;default:Qn(e,a)}}function Um(e){var t=e.alternate;t!==null&&(e.alternate=null,Um(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Ca(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var St=null,pa=!1;function Yn(e,t,a){for(a=a.child;a!==null;)Om(e,t,a),a=a.sibling}function Om(e,t,a){if(gt&&typeof gt.onCommitFiberUnmount=="function")try{gt.onCommitFiberUnmount(At,a)}catch{}switch(a.tag){case 26:Ot||An(a,t),Yn(e,t,a),a.memoizedState?a.memoizedState.count--:a.stateNode&&(a=a.stateNode,a.parentNode.removeChild(a));break;case 27:Ot||An(a,t);var n=St,r=pa;Cl(a.type)&&(St=a.stateNode,pa=!1),Yn(e,t,a),Zr(a.stateNode),St=n,pa=r;break;case 5:Ot||An(a,t);case 6:if(n=St,r=pa,St=null,Yn(e,t,a),St=n,pa=r,St!==null)if(pa)try{(St.nodeType===9?St.body:St.nodeName==="HTML"?St.ownerDocument.body:St).removeChild(a.stateNode)}catch(o){ct(a,t,o)}else try{St.removeChild(a.stateNode)}catch(o){ct(a,t,o)}break;case 18:St!==null&&(pa?(e=St,Th(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,a.stateNode),ar(e)):Th(St,a.stateNode));break;case 4:n=St,r=pa,St=a.stateNode.containerInfo,pa=!0,Yn(e,t,a),St=n,pa=r;break;case 0:case 11:case 14:case 15:yl(2,a,t),Ot||yl(4,a,t),Yn(e,t,a);break;case 1:Ot||(An(a,t),n=a.stateNode,typeof n.componentWillUnmount=="function"&&Em(a,t,n)),Yn(e,t,a);break;case 21:Yn(e,t,a);break;case 22:Ot=(n=Ot)||a.memoizedState!==null,Yn(e,t,a),Ot=n;break;default:Yn(e,t,a)}}function $m(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{ar(e)}catch(a){ct(t,t.return,a)}}}function qm(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{ar(e)}catch(a){ct(t,t.return,a)}}function p0(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Lm),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Lm),t;default:throw Error(c(435,e.tag))}}function Yi(e,t){var a=p0(e);t.forEach(function(n){if(!a.has(n)){a.add(n);var r=_0.bind(null,e,n);n.then(r,r)}})}function ga(e,t){var a=t.deletions;if(a!==null)for(var n=0;n<a.length;n++){var r=a[n],o=e,m=t,y=m;e:for(;y!==null;){switch(y.tag){case 27:if(Cl(y.type)){St=y.stateNode,pa=!1;break e}break;case 5:St=y.stateNode,pa=!1;break e;case 3:case 4:St=y.stateNode.containerInfo,pa=!0;break e}y=y.return}if(St===null)throw Error(c(160));Om(o,m,r),St=null,pa=!1,o=r.alternate,o!==null&&(o.return=null),r.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Bm(t,e),t=t.sibling}var fn=null;function Bm(e,t){var a=e.alternate,n=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ga(t,e),xa(e),n&4&&(yl(3,e,e.return),qr(3,e),yl(5,e,e.return));break;case 1:ga(t,e),xa(e),n&512&&(Ot||a===null||An(a,a.return)),n&64&&Xn&&(e=e.updateQueue,e!==null&&(n=e.callbacks,n!==null&&(a=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=a===null?n:a.concat(n))));break;case 26:var r=fn;if(ga(t,e),xa(e),n&512&&(Ot||a===null||An(a,a.return)),n&4){var o=a!==null?a.memoizedState:null;if(n=e.memoizedState,a===null)if(n===null)if(e.stateNode===null){e:{n=e.type,a=e.memoizedProps,r=r.ownerDocument||r;t:switch(n){case"title":o=r.getElementsByTagName("title")[0],(!o||o[yn]||o[Et]||o.namespaceURI==="http://www.w3.org/2000/svg"||o.hasAttribute("itemprop"))&&(o=r.createElement(n),r.head.insertBefore(o,r.querySelector("head > title"))),Wt(o,n,a),o[Et]=e,Ye(o),n=o;break e;case"link":var m=Bh("link","href",r).get(n+(a.href||""));if(m){for(var y=0;y<m.length;y++)if(o=m[y],o.getAttribute("href")===(a.href==null||a.href===""?null:a.href)&&o.getAttribute("rel")===(a.rel==null?null:a.rel)&&o.getAttribute("title")===(a.title==null?null:a.title)&&o.getAttribute("crossorigin")===(a.crossOrigin==null?null:a.crossOrigin)){m.splice(y,1);break t}}o=r.createElement(n),Wt(o,n,a),r.head.appendChild(o);break;case"meta":if(m=Bh("meta","content",r).get(n+(a.content||""))){for(y=0;y<m.length;y++)if(o=m[y],o.getAttribute("content")===(a.content==null?null:""+a.content)&&o.getAttribute("name")===(a.name==null?null:a.name)&&o.getAttribute("property")===(a.property==null?null:a.property)&&o.getAttribute("http-equiv")===(a.httpEquiv==null?null:a.httpEquiv)&&o.getAttribute("charset")===(a.charSet==null?null:a.charSet)){m.splice(y,1);break t}}o=r.createElement(n),Wt(o,n,a),r.head.appendChild(o);break;default:throw Error(c(468,n))}o[Et]=e,Ye(o),n=o}e.stateNode=n}else Hh(r,e.type,e.stateNode);else e.stateNode=qh(r,n,e.memoizedProps);else o!==n?(o===null?a.stateNode!==null&&(a=a.stateNode,a.parentNode.removeChild(a)):o.count--,n===null?Hh(r,e.type,e.stateNode):qh(r,n,e.memoizedProps)):n===null&&e.stateNode!==null&&iu(e,e.memoizedProps,a.memoizedProps)}break;case 27:ga(t,e),xa(e),n&512&&(Ot||a===null||An(a,a.return)),a!==null&&n&4&&iu(e,e.memoizedProps,a.memoizedProps);break;case 5:if(ga(t,e),xa(e),n&512&&(Ot||a===null||An(a,a.return)),e.flags&32){r=e.stateNode;try{sl(r,"")}catch(ve){ct(e,e.return,ve)}}n&4&&e.stateNode!=null&&(r=e.memoizedProps,iu(e,r,a!==null?a.memoizedProps:r)),n&1024&&(uu=!0);break;case 6:if(ga(t,e),xa(e),n&4){if(e.stateNode===null)throw Error(c(162));n=e.memoizedProps,a=e.stateNode;try{a.nodeValue=n}catch(ve){ct(e,e.return,ve)}}break;case 3:if(co=null,r=fn,fn=io(t.containerInfo),ga(t,e),fn=r,xa(e),n&4&&a!==null&&a.memoizedState.isDehydrated)try{ar(t.containerInfo)}catch(ve){ct(e,e.return,ve)}uu&&(uu=!1,Hm(e));break;case 4:n=fn,fn=io(e.stateNode.containerInfo),ga(t,e),xa(e),fn=n;break;case 12:ga(t,e),xa(e);break;case 31:ga(t,e),xa(e),n&4&&(n=e.updateQueue,n!==null&&(e.updateQueue=null,Yi(e,n)));break;case 13:ga(t,e),xa(e),e.child.flags&8192&&e.memoizedState!==null!=(a!==null&&a.memoizedState!==null)&&(Zi=Oe()),n&4&&(n=e.updateQueue,n!==null&&(e.updateQueue=null,Yi(e,n)));break;case 22:r=e.memoizedState!==null;var A=a!==null&&a.memoizedState!==null,L=Xn,G=Ot;if(Xn=L||r,Ot=G||A,ga(t,e),Ot=G,Xn=L,xa(e),n&8192)e:for(t=e.stateNode,t._visibility=r?t._visibility&-2:t._visibility|1,r&&(a===null||A||Xn||Ot||os(e)),a=null,t=e;;){if(t.tag===5||t.tag===26){if(a===null){A=a=t;try{if(o=A.stateNode,r)m=o.style,typeof m.setProperty=="function"?m.setProperty("display","none","important"):m.display="none";else{y=A.stateNode;var K=A.memoizedProps.style,O=K!=null&&K.hasOwnProperty("display")?K.display:null;y.style.display=O==null||typeof O=="boolean"?"":(""+O).trim()}}catch(ve){ct(A,A.return,ve)}}}else if(t.tag===6){if(a===null){A=t;try{A.stateNode.nodeValue=r?"":A.memoizedProps}catch(ve){ct(A,A.return,ve)}}}else if(t.tag===18){if(a===null){A=t;try{var B=A.stateNode;r?Eh(B,!0):Eh(A.stateNode,!1)}catch(ve){ct(A,A.return,ve)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;a===t&&(a=null),t=t.return}a===t&&(a=null),t.sibling.return=t.return,t=t.sibling}n&4&&(n=e.updateQueue,n!==null&&(a=n.retryQueue,a!==null&&(n.retryQueue=null,Yi(e,a))));break;case 19:ga(t,e),xa(e),n&4&&(n=e.updateQueue,n!==null&&(e.updateQueue=null,Yi(e,n)));break;case 30:break;case 21:break;default:ga(t,e),xa(e)}}function xa(e){var t=e.flags;if(t&2){try{for(var a,n=e.return;n!==null;){if(zm(n)){a=n;break}n=n.return}if(a==null)throw Error(c(160));switch(a.tag){case 27:var r=a.stateNode,o=ou(e);Xi(e,o,r);break;case 5:var m=a.stateNode;a.flags&32&&(sl(m,""),a.flags&=-33);var y=ou(e);Xi(e,y,m);break;case 3:case 4:var A=a.stateNode.containerInfo,L=ou(e);cu(e,L,A);break;default:throw Error(c(161))}}catch(G){ct(e,e.return,G)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Hm(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Hm(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Qn(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Rm(e,t.alternate,t),t=t.sibling}function os(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:yl(4,t,t.return),os(t);break;case 1:An(t,t.return);var a=t.stateNode;typeof a.componentWillUnmount=="function"&&Em(t,t.return,a),os(t);break;case 27:Zr(t.stateNode);case 26:case 5:An(t,t.return),os(t);break;case 22:t.memoizedState===null&&os(t);break;case 30:os(t);break;default:os(t)}e=e.sibling}}function Zn(e,t,a){for(a=a&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var n=t.alternate,r=e,o=t,m=o.flags;switch(o.tag){case 0:case 11:case 15:Zn(r,o,a),qr(4,o);break;case 1:if(Zn(r,o,a),n=o,r=n.stateNode,typeof r.componentDidMount=="function")try{r.componentDidMount()}catch(L){ct(n,n.return,L)}if(n=o,r=n.updateQueue,r!==null){var y=n.stateNode;try{var A=r.shared.hiddenCallbacks;if(A!==null)for(r.shared.hiddenCallbacks=null,r=0;r<A.length;r++)bf(A[r],y)}catch(L){ct(n,n.return,L)}}a&&m&64&&Tm(o),Br(o,o.return);break;case 27:Dm(o);case 26:case 5:Zn(r,o,a),a&&n===null&&m&4&&Mm(o),Br(o,o.return);break;case 12:Zn(r,o,a);break;case 31:Zn(r,o,a),a&&m&4&&$m(r,o);break;case 13:Zn(r,o,a),a&&m&4&&qm(r,o);break;case 22:o.memoizedState===null&&Zn(r,o,a),Br(o,o.return);break;case 30:break;default:Zn(r,o,a)}t=t.sibling}}function du(e,t){var a=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(a=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==a&&(e!=null&&e.refCount++,a!=null&&Cr(a))}function fu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cr(e))}function mn(e,t,a,n){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Fm(e,t,a,n),t=t.sibling}function Fm(e,t,a,n){var r=t.flags;switch(t.tag){case 0:case 11:case 15:mn(e,t,a,n),r&2048&&qr(9,t);break;case 1:mn(e,t,a,n);break;case 3:mn(e,t,a,n),r&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Cr(e)));break;case 12:if(r&2048){mn(e,t,a,n),e=t.stateNode;try{var o=t.memoizedProps,m=o.id,y=o.onPostCommit;typeof y=="function"&&y(m,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(A){ct(t,t.return,A)}}else mn(e,t,a,n);break;case 31:mn(e,t,a,n);break;case 13:mn(e,t,a,n);break;case 23:break;case 22:o=t.stateNode,m=t.alternate,t.memoizedState!==null?o._visibility&2?mn(e,t,a,n):Hr(e,t):o._visibility&2?mn(e,t,a,n):(o._visibility|=2,Vs(e,t,a,n,(t.subtreeFlags&10256)!==0||!1)),r&2048&&du(m,t);break;case 24:mn(e,t,a,n),r&2048&&fu(t.alternate,t);break;default:mn(e,t,a,n)}}function Vs(e,t,a,n,r){for(r=r&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var o=e,m=t,y=a,A=n,L=m.flags;switch(m.tag){case 0:case 11:case 15:Vs(o,m,y,A,r),qr(8,m);break;case 23:break;case 22:var G=m.stateNode;m.memoizedState!==null?G._visibility&2?Vs(o,m,y,A,r):Hr(o,m):(G._visibility|=2,Vs(o,m,y,A,r)),r&&L&2048&&du(m.alternate,m);break;case 24:Vs(o,m,y,A,r),r&&L&2048&&fu(m.alternate,m);break;default:Vs(o,m,y,A,r)}t=t.sibling}}function Hr(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var a=e,n=t,r=n.flags;switch(n.tag){case 22:Hr(a,n),r&2048&&du(n.alternate,n);break;case 24:Hr(a,n),r&2048&&fu(n.alternate,n);break;default:Hr(a,n)}t=t.sibling}}var Fr=8192;function Xs(e,t,a){if(e.subtreeFlags&Fr)for(e=e.child;e!==null;)Im(e,t,a),e=e.sibling}function Im(e,t,a){switch(e.tag){case 26:Xs(e,t,a),e.flags&Fr&&e.memoizedState!==null&&tx(a,fn,e.memoizedState,e.memoizedProps);break;case 5:Xs(e,t,a);break;case 3:case 4:var n=fn;fn=io(e.stateNode.containerInfo),Xs(e,t,a),fn=n;break;case 22:e.memoizedState===null&&(n=e.alternate,n!==null&&n.memoizedState!==null?(n=Fr,Fr=16777216,Xs(e,t,a),Fr=n):Xs(e,t,a));break;default:Xs(e,t,a)}}function Gm(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Ir(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var n=t[a];Gt=n,Xm(n,e)}Gm(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Vm(e),e=e.sibling}function Vm(e){switch(e.tag){case 0:case 11:case 15:Ir(e),e.flags&2048&&yl(9,e,e.return);break;case 3:Ir(e);break;case 12:Ir(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Qi(e)):Ir(e);break;default:Ir(e)}}function Qi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var a=0;a<t.length;a++){var n=t[a];Gt=n,Xm(n,e)}Gm(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:yl(8,t,t.return),Qi(t);break;case 22:a=t.stateNode,a._visibility&2&&(a._visibility&=-3,Qi(t));break;default:Qi(t)}e=e.sibling}}function Xm(e,t){for(;Gt!==null;){var a=Gt;switch(a.tag){case 0:case 11:case 15:yl(8,a,t);break;case 23:case 22:if(a.memoizedState!==null&&a.memoizedState.cachePool!==null){var n=a.memoizedState.cachePool.pool;n!=null&&n.refCount++}break;case 24:Cr(a.memoizedState.cache)}if(n=a.child,n!==null)n.return=a,Gt=n;else e:for(a=e;Gt!==null;){n=Gt;var r=n.sibling,o=n.return;if(Um(n),n===a){Gt=null;break e}if(r!==null){r.return=o,Gt=r;break e}Gt=o}}}var g0={getCacheForType:function(e){var t=Jt(Lt),a=t.data.get(e);return a===void 0&&(a=e(),t.data.set(e,a)),a},cacheSignal:function(){return Jt(Lt).controller.signal}},x0=typeof WeakMap=="function"?WeakMap:Map,rt=0,ht=null,Ze=null,Je=0,ot=0,Oa=null,vl=!1,Ys=!1,mu=!1,Kn=0,Nt=0,wl=0,cs=0,hu=0,$a=0,Qs=0,Gr=null,ba=null,pu=!1,Zi=0,Ym=0,Ki=1/0,Ji=null,Sl=null,$t=0,kl=null,Zs=null,Jn=0,gu=0,xu=null,Qm=null,Vr=0,bu=null;function qa(){return(rt&2)!==0&&Je!==0?Je&-Je:E.T!==null?_u():an()}function Zm(){if($a===0)if((Je&536870912)===0||We){var e=it;it<<=1,(it&3932160)===0&&(it=262144),$a=e}else $a=536870912;return e=Ra.current,e!==null&&(e.flags|=32),$a}function ya(e,t,a){(e===ht&&(ot===2||ot===9)||e.cancelPendingCommit!==null)&&(Ks(e,0),_l(e,Je,$a,!1)),zn(e,a),((rt&2)===0||e!==ht)&&(e===ht&&((rt&2)===0&&(cs|=a),Nt===4&&_l(e,Je,$a,!1)),Cn(e))}function Km(e,t,a){if((rt&6)!==0)throw Error(c(327));var n=!a&&(t&127)===0&&(t&e.expiredLanes)===0||ka(e,t),r=n?v0(e,t):vu(e,t,!0),o=n;do{if(r===0){Ys&&!n&&_l(e,t,0,!1);break}else{if(a=e.current.alternate,o&&!b0(a)){r=vu(e,t,!1),o=!1;continue}if(r===2){if(o=t,e.errorRecoveryDisabledLanes&o)var m=0;else m=e.pendingLanes&-536870913,m=m!==0?m:m&536870912?536870912:0;if(m!==0){t=m;e:{var y=e;r=Gr;var A=y.current.memoizedState.isDehydrated;if(A&&(Ks(y,m).flags|=256),m=vu(y,m,!1),m!==2){if(mu&&!A){y.errorRecoveryDisabledLanes|=o,cs|=o,r=4;break e}o=ba,ba=r,o!==null&&(ba===null?ba=o:ba.push.apply(ba,o))}r=m}if(o=!1,r!==2)continue}}if(r===1){Ks(e,0),_l(e,t,0,!0);break}e:{switch(n=e,o=r,o){case 0:case 1:throw Error(c(345));case 4:if((t&4194048)!==t)break;case 6:_l(n,t,$a,!vl);break e;case 2:ba=null;break;case 3:case 5:break;default:throw Error(c(329))}if((t&62914560)===t&&(r=Zi+300-Oe(),10<r)){if(_l(n,t,$a,!vl),Mn(n,0,!0)!==0)break e;Jn=t,n.timeoutHandle=jh(Jm.bind(null,n,a,ba,Ji,pu,t,$a,cs,Qs,vl,o,"Throttled",-0,0),r);break e}Jm(n,a,ba,Ji,pu,t,$a,cs,Qs,vl,o,null,-0,0)}}break}while(!0);Cn(e)}function Jm(e,t,a,n,r,o,m,y,A,L,G,K,O,B){if(e.timeoutHandle=-1,K=t.subtreeFlags,K&8192||(K&16785408)===16785408){K={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Fa},Im(t,o,K);var ve=(o&62914560)===o?Zi-Oe():(o&4194048)===o?Ym-Oe():0;if(ve=ax(K,ve),ve!==null){Jn=o,e.cancelPendingCommit=ve(sh.bind(null,e,t,o,a,n,r,m,y,A,G,K,null,O,B)),_l(e,o,m,!L);return}}sh(e,t,o,a,n,r,m,y,A)}function b0(e){for(var t=e;;){var a=t.tag;if((a===0||a===11||a===15)&&t.flags&16384&&(a=t.updateQueue,a!==null&&(a=a.stores,a!==null)))for(var n=0;n<a.length;n++){var r=a[n],o=r.getSnapshot;r=r.value;try{if(!Da(o(),r))return!1}catch{return!1}}if(a=t.child,t.subtreeFlags&16384&&a!==null)a.return=t,t=a;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function _l(e,t,a,n){t&=~hu,t&=~cs,e.suspendedLanes|=t,e.pingedLanes&=~t,n&&(e.warmLanes|=t),n=e.expirationTimes;for(var r=t;0<r;){var o=31-_e(r),m=1<<o;n[o]=-1,r&=~m}a!==0&&al(e,a,t)}function Pi(){return(rt&6)===0?(Xr(0),!1):!0}function yu(){if(Ze!==null){if(ot===0)var e=Ze.return;else e=Ze,Bn=es=null,Rc(e),Bs=null,Nr=0,e=Ze;for(;e!==null;)Nm(e.alternate,e),e=e.return;Ze=null}}function Ks(e,t){var a=e.timeoutHandle;a!==-1&&(e.timeoutHandle=-1,$0(a)),a=e.cancelPendingCommit,a!==null&&(e.cancelPendingCommit=null,a()),Jn=0,yu(),ht=e,Ze=a=$n(e.current,null),Je=t,ot=0,Oa=null,vl=!1,Ys=ka(e,t),mu=!1,Qs=$a=hu=cs=wl=Nt=0,ba=Gr=null,pu=!1,(t&8)!==0&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-_e(n),o=1<<r;t|=e[r],n&=~o}return Kn=t,yi(),a}function Pm(e,t){Ie=null,E.H=Ur,t===qs||t===ji?(t=hf(),ot=3):t===kc?(t=hf(),ot=4):ot=t===Jc?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Oa=t,Ze===null&&(Nt=1,Hi(e,Ya(t,e.current)))}function Wm(){var e=Ra.current;return e===null?!0:(Je&4194048)===Je?Ja===null:(Je&62914560)===Je||(Je&536870912)!==0?e===Ja:!1}function eh(){var e=E.H;return E.H=Ur,e===null?Ur:e}function th(){var e=E.A;return E.A=g0,e}function Wi(){Nt=4,vl||(Je&4194048)!==Je&&Ra.current!==null||(Ys=!0),(wl&134217727)===0&&(cs&134217727)===0||ht===null||_l(ht,Je,$a,!1)}function vu(e,t,a){var n=rt;rt|=2;var r=eh(),o=th();(ht!==e||Je!==t)&&(Ji=null,Ks(e,t)),t=!1;var m=Nt;e:do try{if(ot!==0&&Ze!==null){var y=Ze,A=Oa;switch(ot){case 8:yu(),m=6;break e;case 3:case 2:case 9:case 6:Ra.current===null&&(t=!0);var L=ot;if(ot=0,Oa=null,Js(e,y,A,L),a&&Ys){m=0;break e}break;default:L=ot,ot=0,Oa=null,Js(e,y,A,L)}}y0(),m=Nt;break}catch(G){Pm(e,G)}while(!0);return t&&e.shellSuspendCounter++,Bn=es=null,rt=n,E.H=r,E.A=o,Ze===null&&(ht=null,Je=0,yi()),m}function y0(){for(;Ze!==null;)ah(Ze)}function v0(e,t){var a=rt;rt|=2;var n=eh(),r=th();ht!==e||Je!==t?(Ji=null,Ki=Oe()+500,Ks(e,t)):Ys=ka(e,t);e:do try{if(ot!==0&&Ze!==null){t=Ze;var o=Oa;t:switch(ot){case 1:ot=0,Oa=null,Js(e,t,o,1);break;case 2:case 9:if(ff(o)){ot=0,Oa=null,nh(t);break}t=function(){ot!==2&&ot!==9||ht!==e||(ot=7),Cn(e)},o.then(t,t);break e;case 3:ot=7;break e;case 4:ot=5;break e;case 7:ff(o)?(ot=0,Oa=null,nh(t)):(ot=0,Oa=null,Js(e,t,o,7));break;case 5:var m=null;switch(Ze.tag){case 26:m=Ze.memoizedState;case 5:case 27:var y=Ze;if(m?Fh(m):y.stateNode.complete){ot=0,Oa=null;var A=y.sibling;if(A!==null)Ze=A;else{var L=y.return;L!==null?(Ze=L,eo(L)):Ze=null}break t}}ot=0,Oa=null,Js(e,t,o,5);break;case 6:ot=0,Oa=null,Js(e,t,o,6);break;case 8:yu(),Nt=6;break e;default:throw Error(c(462))}}w0();break}catch(G){Pm(e,G)}while(!0);return Bn=es=null,E.H=n,E.A=r,rt=a,Ze!==null?0:(ht=null,Je=0,yi(),Nt)}function w0(){for(;Ze!==null&&!Ne();)ah(Ze)}function ah(e){var t=Cm(e.alternate,e,Kn);e.memoizedProps=e.pendingProps,t===null?eo(e):Ze=t}function nh(e){var t=e,a=t.alternate;switch(t.tag){case 15:case 0:t=vm(a,t,t.pendingProps,t.type,void 0,Je);break;case 11:t=vm(a,t,t.pendingProps,t.type.render,t.ref,Je);break;case 5:Rc(t);default:Nm(a,t),t=Ze=ef(t,Kn),t=Cm(a,t,Kn)}e.memoizedProps=e.pendingProps,t===null?eo(e):Ze=t}function Js(e,t,a,n){Bn=es=null,Rc(t),Bs=null,Nr=0;var r=t.return;try{if(c0(e,r,t,a,Je)){Nt=1,Hi(e,Ya(a,e.current)),Ze=null;return}}catch(o){if(r!==null)throw Ze=r,o;Nt=1,Hi(e,Ya(a,e.current)),Ze=null;return}t.flags&32768?(We||n===1?e=!0:Ys||(Je&536870912)!==0?e=!1:(vl=e=!0,(n===2||n===9||n===3||n===6)&&(n=Ra.current,n!==null&&n.tag===13&&(n.flags|=16384))),lh(t,e)):eo(t)}function eo(e){var t=e;do{if((t.flags&32768)!==0){lh(t,vl);return}e=t.return;var a=f0(t.alternate,t,Kn);if(a!==null){Ze=a;return}if(t=t.sibling,t!==null){Ze=t;return}Ze=t=e}while(t!==null);Nt===0&&(Nt=5)}function lh(e,t){do{var a=m0(e.alternate,e);if(a!==null){a.flags&=32767,Ze=a;return}if(a=e.return,a!==null&&(a.flags|=32768,a.subtreeFlags=0,a.deletions=null),!t&&(e=e.sibling,e!==null)){Ze=e;return}Ze=e=a}while(e!==null);Nt=6,Ze=null}function sh(e,t,a,n,r,o,m,y,A){e.cancelPendingCommit=null;do to();while($t!==0);if((rt&6)!==0)throw Error(c(327));if(t!==null){if(t===e.current)throw Error(c(177));if(o=t.lanes|t.childLanes,o|=oc,Aa(e,a,o,m,y,A),e===ht&&(Ze=ht=null,Je=0),Zs=t,kl=e,Jn=a,gu=o,xu=r,Qm=n,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,A0(ea,function(){return uh(),null})):(e.callbackNode=null,e.callbackPriority=0),n=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||n){n=E.T,E.T=null,r=V.p,V.p=2,m=rt,rt|=4;try{h0(e,t,a)}finally{rt=m,V.p=r,E.T=n}}$t=1,rh(),ih(),oh()}}function rh(){if($t===1){$t=0;var e=kl,t=Zs,a=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||a){a=E.T,E.T=null;var n=V.p;V.p=2;var r=rt;rt|=4;try{Bm(t,e);var o=zu,m=Vd(e.containerInfo),y=o.focusedElem,A=o.selectionRange;if(m!==y&&y&&y.ownerDocument&&Gd(y.ownerDocument.documentElement,y)){if(A!==null&&nc(y)){var L=A.start,G=A.end;if(G===void 0&&(G=L),"selectionStart"in y)y.selectionStart=L,y.selectionEnd=Math.min(G,y.value.length);else{var K=y.ownerDocument||document,O=K&&K.defaultView||window;if(O.getSelection){var B=O.getSelection(),ve=y.textContent.length,Re=Math.min(A.start,ve),mt=A.end===void 0?Re:Math.min(A.end,ve);!B.extend&&Re>mt&&(m=mt,mt=Re,Re=m);var M=Id(y,Re),T=Id(y,mt);if(M&&T&&(B.rangeCount!==1||B.anchorNode!==M.node||B.anchorOffset!==M.offset||B.focusNode!==T.node||B.focusOffset!==T.offset)){var D=K.createRange();D.setStart(M.node,M.offset),B.removeAllRanges(),Re>mt?(B.addRange(D),B.extend(T.node,T.offset)):(D.setEnd(T.node,T.offset),B.addRange(D))}}}}for(K=[],B=y;B=B.parentNode;)B.nodeType===1&&K.push({element:B,left:B.scrollLeft,top:B.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<K.length;y++){var Z=K[y];Z.element.scrollLeft=Z.left,Z.element.scrollTop=Z.top}}ho=!!Mu,zu=Mu=null}finally{rt=r,V.p=n,E.T=a}}e.current=t,$t=2}}function ih(){if($t===2){$t=0;var e=kl,t=Zs,a=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||a){a=E.T,E.T=null;var n=V.p;V.p=2;var r=rt;rt|=4;try{Rm(e,t.alternate,t)}finally{rt=r,V.p=n,E.T=a}}$t=3}}function oh(){if($t===4||$t===3){$t=0,Tt();var e=kl,t=Zs,a=Jn,n=Qm;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?$t=5:($t=0,Zs=kl=null,ch(e,e.pendingLanes));var r=e.pendingLanes;if(r===0&&(Sl=null),Dn(a),t=t.stateNode,gt&&typeof gt.onCommitFiberRoot=="function")try{gt.onCommitFiberRoot(At,t,void 0,(t.current.flags&128)===128)}catch{}if(n!==null){t=E.T,r=V.p,V.p=2,E.T=null;try{for(var o=e.onRecoverableError,m=0;m<n.length;m++){var y=n[m];o(y.value,{componentStack:y.stack})}}finally{E.T=t,V.p=r}}(Jn&3)!==0&&to(),Cn(e),r=e.pendingLanes,(a&261930)!==0&&(r&42)!==0?e===bu?Vr++:(Vr=0,bu=e):Vr=0,Xr(0)}}function ch(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Cr(t)))}function to(){return rh(),ih(),oh(),uh()}function uh(){if($t!==5)return!1;var e=kl,t=gu;gu=0;var a=Dn(Jn),n=E.T,r=V.p;try{V.p=32>a?32:a,E.T=null,a=xu,xu=null;var o=kl,m=Jn;if($t=0,Zs=kl=null,Jn=0,(rt&6)!==0)throw Error(c(331));var y=rt;if(rt|=4,Vm(o.current),Fm(o,o.current,m,a),rt=y,Xr(0,!1),gt&&typeof gt.onPostCommitFiberRoot=="function")try{gt.onPostCommitFiberRoot(At,o)}catch{}return!0}finally{V.p=r,E.T=n,ch(e,t)}}function dh(e,t,a){t=Ya(a,t),t=Kc(e.stateNode,t,2),e=gl(e,t,2),e!==null&&(zn(e,2),Cn(e))}function ct(e,t,a){if(e.tag===3)dh(e,e,a);else for(;t!==null;){if(t.tag===3){dh(t,e,a);break}else if(t.tag===1){var n=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Sl===null||!Sl.has(n))){e=Ya(a,e),a=fm(2),n=gl(t,a,2),n!==null&&(mm(a,n,t,e),zn(n,2),Cn(n));break}}t=t.return}}function wu(e,t,a){var n=e.pingCache;if(n===null){n=e.pingCache=new x0;var r=new Set;n.set(t,r)}else r=n.get(t),r===void 0&&(r=new Set,n.set(t,r));r.has(a)||(mu=!0,r.add(a),e=S0.bind(null,e,t,a),t.then(e,e))}function S0(e,t,a){var n=e.pingCache;n!==null&&n.delete(t),e.pingedLanes|=e.suspendedLanes&a,e.warmLanes&=~a,ht===e&&(Je&a)===a&&(Nt===4||Nt===3&&(Je&62914560)===Je&&300>Oe()-Zi?(rt&2)===0&&Ks(e,0):hu|=a,Qs===Je&&(Qs=0)),Cn(e)}function fh(e,t){t===0&&(t=$l()),e=Jl(e,t),e!==null&&(zn(e,t),Cn(e))}function k0(e){var t=e.memoizedState,a=0;t!==null&&(a=t.retryLane),fh(e,a)}function _0(e,t){var a=0;switch(e.tag){case 31:case 13:var n=e.stateNode,r=e.memoizedState;r!==null&&(a=r.retryLane);break;case 19:n=e.stateNode;break;case 22:n=e.stateNode._retryCache;break;default:throw Error(c(314))}n!==null&&n.delete(t),fh(e,a)}function A0(e,t){return xt(e,t)}var ao=null,Ps=null,Su=!1,no=!1,ku=!1,Al=0;function Cn(e){e!==Ps&&e.next===null&&(Ps===null?ao=Ps=e:Ps=Ps.next=e),no=!0,Su||(Su=!0,j0())}function Xr(e,t){if(!ku&&no){ku=!0;do for(var a=!1,n=ao;n!==null;){if(e!==0){var r=n.pendingLanes;if(r===0)var o=0;else{var m=n.suspendedLanes,y=n.pingedLanes;o=(1<<31-_e(42|e)+1)-1,o&=r&~(m&~y),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(a=!0,gh(n,o))}else o=Je,o=Mn(n,n===ht?o:0,n.cancelPendingCommit!==null||n.timeoutHandle!==-1),(o&3)===0||ka(n,o)||(a=!0,gh(n,o));n=n.next}while(a);ku=!1}}function C0(){mh()}function mh(){no=Su=!1;var e=0;Al!==0&&O0()&&(e=Al);for(var t=Oe(),a=null,n=ao;n!==null;){var r=n.next,o=hh(n,t);o===0?(n.next=null,a===null?ao=r:a.next=r,r===null&&(Ps=a)):(a=n,(e!==0||(o&3)!==0)&&(no=!0)),n=r}$t!==0&&$t!==5||Xr(e),Al!==0&&(Al=0)}function hh(e,t){for(var a=e.suspendedLanes,n=e.pingedLanes,r=e.expirationTimes,o=e.pendingLanes&-62914561;0<o;){var m=31-_e(o),y=1<<m,A=r[m];A===-1?((y&a)===0||(y&n)!==0)&&(r[m]=tl(y,t)):A<=t&&(e.expiredLanes|=y),o&=~y}if(t=ht,a=Je,a=Mn(e,e===t?a:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),n=e.callbackNode,a===0||e===t&&(ot===2||ot===9)||e.cancelPendingCommit!==null)return n!==null&&n!==null&&ie(n),e.callbackNode=null,e.callbackPriority=0;if((a&3)===0||ka(e,a)){if(t=a&-a,t===e.callbackPriority)return t;switch(n!==null&&ie(n),Dn(a)){case 2:case 8:a=Xt;break;case 32:a=ea;break;case 268435456:a=en;break;default:a=ea}return n=ph.bind(null,e),a=xt(a,n),e.callbackPriority=t,e.callbackNode=a,t}return n!==null&&n!==null&&ie(n),e.callbackPriority=2,e.callbackNode=null,2}function ph(e,t){if($t!==0&&$t!==5)return e.callbackNode=null,e.callbackPriority=0,null;var a=e.callbackNode;if(to()&&e.callbackNode!==a)return null;var n=Je;return n=Mn(e,e===ht?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),n===0?null:(Km(e,n,t),hh(e,Oe()),e.callbackNode!=null&&e.callbackNode===a?ph.bind(null,e):null)}function gh(e,t){if(to())return null;Km(e,t,!0)}function j0(){q0(function(){(rt&6)!==0?xt(da,C0):mh()})}function _u(){if(Al===0){var e=Os;e===0&&(e=bt,bt<<=1,(bt&261888)===0&&(bt=256)),Al=e}return Al}function xh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:il(""+e)}function bh(e,t){var a=t.ownerDocument.createElement("input");return a.name=t.name,a.value=t.value,e.id&&a.setAttribute("form",e.id),t.parentNode.insertBefore(a,t),e=new FormData(e),a.parentNode.removeChild(a),e}function N0(e,t,a,n,r){if(t==="submit"&&a&&a.stateNode===r){var o=xh((r[Ct]||null).action),m=n.submitter;m&&(t=(t=m[Ct]||null)?xh(t.formAction):m.getAttribute("formAction"),t!==null&&(o=t,m=null));var y=new Xl("action","action",null,n,r);e.push({event:y,listeners:[{instance:null,listener:function(){if(n.defaultPrevented){if(Al!==0){var A=m?bh(r,m):new FormData(r);Gc(a,{pending:!0,data:A,method:r.method,action:o},null,A)}}else typeof o=="function"&&(y.preventDefault(),A=m?bh(r,m):new FormData(r),Gc(a,{pending:!0,data:A,method:r.method,action:o},o,A))},currentTarget:r}]})}}for(var Au=0;Au<ic.length;Au++){var Cu=ic[Au],T0=Cu.toLowerCase(),E0=Cu[0].toUpperCase()+Cu.slice(1);dn(T0,"on"+E0)}dn(Qd,"onAnimationEnd"),dn(Zd,"onAnimationIteration"),dn(Kd,"onAnimationStart"),dn("dblclick","onDoubleClick"),dn("focusin","onFocus"),dn("focusout","onBlur"),dn(Xg,"onTransitionRun"),dn(Yg,"onTransitionStart"),dn(Qg,"onTransitionCancel"),dn(Jd,"onTransitionEnd"),Rn("onMouseEnter",["mouseout","mouseover"]),Rn("onMouseLeave",["mouseout","mouseover"]),Rn("onPointerEnter",["pointerout","pointerover"]),Rn("onPointerLeave",["pointerout","pointerover"]),ln("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ln("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ln("onBeforeInput",["compositionend","keypress","textInput","paste"]),ln("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ln("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ln("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Yr="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),M0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Yr));function yh(e,t){t=(t&4)!==0;for(var a=0;a<e.length;a++){var n=e[a],r=n.event;n=n.listeners;e:{var o=void 0;if(t)for(var m=n.length-1;0<=m;m--){var y=n[m],A=y.instance,L=y.currentTarget;if(y=y.listener,A!==o&&r.isPropagationStopped())break e;o=y,r.currentTarget=L;try{o(r)}catch(G){bi(G)}r.currentTarget=null,o=A}else for(m=0;m<n.length;m++){if(y=n[m],A=y.instance,L=y.currentTarget,y=y.listener,A!==o&&r.isPropagationStopped())break e;o=y,r.currentTarget=L;try{o(r)}catch(G){bi(G)}r.currentTarget=null,o=A}}}}function Ke(e,t){var a=t[Bl];a===void 0&&(a=t[Bl]=new Set);var n=e+"__bubble";a.has(n)||(vh(t,e,2,!1),a.add(n))}function ju(e,t,a){var n=0;t&&(n|=4),vh(a,e,n,t)}var lo="_reactListening"+Math.random().toString(36).slice(2);function Nu(e){if(!e[lo]){e[lo]=!0,nn.forEach(function(a){a!=="selectionchange"&&(M0.has(a)||ju(a,!1,e),ju(a,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[lo]||(t[lo]=!0,ju("selectionchange",!1,t))}}function vh(e,t,a,n){switch(Zh(t)){case 2:var r=sx;break;case 8:r=rx;break;default:r=Iu}a=r.bind(null,t,a,e),r=void 0,!Il||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(r=!0),n?r!==void 0?e.addEventListener(t,a,{capture:!0,passive:r}):e.addEventListener(t,a,!0):r!==void 0?e.addEventListener(t,a,{passive:r}):e.addEventListener(t,a,!1)}function Tu(e,t,a,n,r){var o=n;if((t&1)===0&&(t&2)===0&&n!==null)e:for(;;){if(n===null)return;var m=n.tag;if(m===3||m===4){var y=n.stateNode.containerInfo;if(y===r)break;if(m===4)for(m=n.return;m!==null;){var A=m.tag;if((A===3||A===4)&&m.stateNode.containerInfo===r)return;m=m.return}for(;y!==null;){if(m=se(y),m===null)return;if(A=m.tag,A===5||A===6||A===26||A===27){n=o=m;continue e}y=y.parentNode}}n=n.return}ws(function(){var L=o,G=vs(a),K=[];e:{var O=Pd.get(e);if(O!==void 0){var B=Xl,ve=e;switch(e){case"keypress":if(ks(a)===0)break e;case"keydown":case"keyup":B=Cs;break;case"focusin":ve="focus",B=yr;break;case"focusout":ve="blur",B=yr;break;case"beforeblur":case"afterblur":B=yr;break;case"click":if(a.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":B=xr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":B=br;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":B=ia;break;case Qd:case Zd:case Kd:B=pi;break;case Jd:B=un;break;case"scroll":case"scrollend":B=hr;break;case"wheel":B=Po;break;case"copy":case"cut":case"paste":B=ne;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":B=cl;break;case"toggle":case"beforetoggle":B=ec}var Re=(t&4)!==0,mt=!Re&&(e==="scroll"||e==="scrollend"),M=Re?O!==null?O+"Capture":null:O;Re=[];for(var T=L,D;T!==null;){var Z=T;if(D=Z.stateNode,Z=Z.tag,Z!==5&&Z!==26&&Z!==27||D===null||M===null||(Z=vn(T,M),Z!=null&&Re.push(Qr(T,Z,D))),mt)break;T=T.return}0<Re.length&&(O=new B(O,ve,null,a,G),K.push({event:O,listeners:Re}))}}if((t&7)===0){e:{if(O=e==="mouseover"||e==="pointerover",B=e==="mouseout"||e==="pointerout",O&&a!==wt&&(ve=a.relatedTarget||a.fromElement)&&(se(ve)||ve[fa]))break e;if((B||O)&&(O=G.window===G?G:(O=G.ownerDocument)?O.defaultView||O.parentWindow:window,B?(ve=a.relatedTarget||a.toElement,B=L,ve=ve?se(ve):null,ve!==null&&(mt=f(ve),Re=ve.tag,ve!==mt||Re!==5&&Re!==27&&Re!==6)&&(ve=null)):(B=null,ve=L),B!==ve)){if(Re=xr,Z="onMouseLeave",M="onMouseEnter",T="mouse",(e==="pointerout"||e==="pointerover")&&(Re=cl,Z="onPointerLeave",M="onPointerEnter",T="pointer"),mt=B==null?O:he(B),D=ve==null?O:he(ve),O=new Re(Z,T+"leave",B,a,G),O.target=mt,O.relatedTarget=D,Z=null,se(G)===L&&(Re=new Re(M,T+"enter",ve,a,G),Re.target=D,Re.relatedTarget=mt,Z=Re),mt=Z,B&&ve)t:{for(Re=z0,M=B,T=ve,D=0,Z=M;Z;Z=Re(Z))D++;Z=0;for(var Me=T;Me;Me=Re(Me))Z++;for(;0<D-Z;)M=Re(M),D--;for(;0<Z-D;)T=Re(T),Z--;for(;D--;){if(M===T||T!==null&&M===T.alternate){Re=M;break t}M=Re(M),T=Re(T)}Re=null}else Re=null;B!==null&&wh(K,O,B,Re,!1),ve!==null&&mt!==null&&wh(K,mt,ve,Re,!0)}}e:{if(O=L?he(L):window,B=O.nodeName&&O.nodeName.toLowerCase(),B==="select"||B==="input"&&O.type==="file")var nt=Od;else if(Rd(O))if($d)nt=Ig;else{nt=Hg;var Se=Bg}else B=O.nodeName,!B||B.toLowerCase()!=="input"||O.type!=="checkbox"&&O.type!=="radio"?L&&Fl(L.elementType)&&(nt=Od):nt=Fg;if(nt&&(nt=nt(e,L))){Ud(K,nt,a,G);break e}Se&&Se(e,O,L),e==="focusout"&&L&&O.type==="number"&&L.memoizedProps.value!=null&&sn(O,"number",O.value)}switch(Se=L?he(L):window,e){case"focusin":(Rd(Se)||Se.contentEditable==="true")&&(Ts=Se,lc=L,kr=null);break;case"focusout":kr=lc=Ts=null;break;case"mousedown":sc=!0;break;case"contextmenu":case"mouseup":case"dragend":sc=!1,Xd(K,a,G);break;case"selectionchange":if(Vg)break;case"keydown":case"keyup":Xd(K,a,G)}var Ge;if(Va)e:{switch(e){case"compositionstart":var Pe="onCompositionStart";break e;case"compositionend":Pe="onCompositionEnd";break e;case"compositionupdate":Pe="onCompositionUpdate";break e}Pe=void 0}else Ns?Dd(e,a)&&(Pe="onCompositionEnd"):e==="keydown"&&a.keyCode===229&&(Pe="onCompositionStart");Pe&&(Ed&&a.locale!=="ko"&&(Ns||Pe!=="onCompositionStart"?Pe==="onCompositionEnd"&&Ns&&(Ge=Vl()):(Ea=G,Ss="value"in Ea?Ea.value:Ea.textContent,Ns=!0)),Se=so(L,Pe),0<Se.length&&(Pe=new $e(Pe,e,null,a,G),K.push({event:Pe,listeners:Se}),Ge?Pe.data=Ge:(Ge=Ld(a),Ge!==null&&(Pe.data=Ge)))),(Ge=Ql?Ug(e,a):Og(e,a))&&(Pe=so(L,"onBeforeInput"),0<Pe.length&&(Se=new $e("onBeforeInput","beforeinput",null,a,G),K.push({event:Se,listeners:Pe}),Se.data=Ge)),N0(K,e,L,a,G)}yh(K,t)})}function Qr(e,t,a){return{instance:e,listener:t,currentTarget:a}}function so(e,t){for(var a=t+"Capture",n=[];e!==null;){var r=e,o=r.stateNode;if(r=r.tag,r!==5&&r!==26&&r!==27||o===null||(r=vn(e,a),r!=null&&n.unshift(Qr(e,r,o)),r=vn(e,t),r!=null&&n.push(Qr(e,r,o))),e.tag===3)return n;e=e.return}return[]}function z0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function wh(e,t,a,n,r){for(var o=t._reactName,m=[];a!==null&&a!==n;){var y=a,A=y.alternate,L=y.stateNode;if(y=y.tag,A!==null&&A===n)break;y!==5&&y!==26&&y!==27||L===null||(A=L,r?(L=vn(a,o),L!=null&&m.unshift(Qr(a,L,A))):r||(L=vn(a,o),L!=null&&m.push(Qr(a,L,A)))),a=a.return}m.length!==0&&e.push({event:t,listeners:m})}var D0=/\r\n?/g,L0=/\u0000|\uFFFD/g;function Sh(e){return(typeof e=="string"?e:""+e).replace(D0,`
|
|
26
|
+
`).replace(L0,"")}function kh(e,t){return t=Sh(t),Sh(e)===t}function ft(e,t,a,n,r,o){switch(a){case"children":typeof n=="string"?t==="body"||t==="textarea"&&n===""||sl(e,n):(typeof n=="number"||typeof n=="bigint")&&t!=="body"&&sl(e,""+n);break;case"className":ma(e,"class",n);break;case"tabIndex":ma(e,"tabindex",n);break;case"dir":case"role":case"viewBox":case"width":case"height":ma(e,a,n);break;case"style":rl(e,n,o);break;case"data":if(t!=="object"){ma(e,"data",n);break}case"src":case"href":if(n===""&&(t!=="a"||a!=="href")){e.removeAttribute(a);break}if(n==null||typeof n=="function"||typeof n=="symbol"||typeof n=="boolean"){e.removeAttribute(a);break}n=il(""+n),e.setAttribute(a,n);break;case"action":case"formAction":if(typeof n=="function"){e.setAttribute(a,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof o=="function"&&(a==="formAction"?(t!=="input"&&ft(e,t,"name",r.name,r,null),ft(e,t,"formEncType",r.formEncType,r,null),ft(e,t,"formMethod",r.formMethod,r,null),ft(e,t,"formTarget",r.formTarget,r,null)):(ft(e,t,"encType",r.encType,r,null),ft(e,t,"method",r.method,r,null),ft(e,t,"target",r.target,r,null)));if(n==null||typeof n=="symbol"||typeof n=="boolean"){e.removeAttribute(a);break}n=il(""+n),e.setAttribute(a,n);break;case"onClick":n!=null&&(e.onclick=Fa);break;case"onScroll":n!=null&&Ke("scroll",e);break;case"onScrollEnd":n!=null&&Ke("scrollend",e);break;case"dangerouslySetInnerHTML":if(n!=null){if(typeof n!="object"||!("__html"in n))throw Error(c(61));if(a=n.__html,a!=null){if(r.children!=null)throw Error(c(60));e.innerHTML=a}}break;case"multiple":e.multiple=n&&typeof n!="function"&&typeof n!="symbol";break;case"muted":e.muted=n&&typeof n!="function"&&typeof n!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(n==null||typeof n=="function"||typeof n=="boolean"||typeof n=="symbol"){e.removeAttribute("xlink:href");break}a=il(""+n),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":n!=null&&typeof n!="function"&&typeof n!="symbol"?e.setAttribute(a,""+n):e.removeAttribute(a);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":n&&typeof n!="function"&&typeof n!="symbol"?e.setAttribute(a,""):e.removeAttribute(a);break;case"capture":case"download":n===!0?e.setAttribute(a,""):n!==!1&&n!=null&&typeof n!="function"&&typeof n!="symbol"?e.setAttribute(a,n):e.removeAttribute(a);break;case"cols":case"rows":case"size":case"span":n!=null&&typeof n!="function"&&typeof n!="symbol"&&!isNaN(n)&&1<=n?e.setAttribute(a,n):e.removeAttribute(a);break;case"rowSpan":case"start":n==null||typeof n=="function"||typeof n=="symbol"||isNaN(n)?e.removeAttribute(a):e.setAttribute(a,n);break;case"popover":Ke("beforetoggle",e),Ke("toggle",e),ps(e,"popover",n);break;case"xlinkActuate":Na(e,"http://www.w3.org/1999/xlink","xlink:actuate",n);break;case"xlinkArcrole":Na(e,"http://www.w3.org/1999/xlink","xlink:arcrole",n);break;case"xlinkRole":Na(e,"http://www.w3.org/1999/xlink","xlink:role",n);break;case"xlinkShow":Na(e,"http://www.w3.org/1999/xlink","xlink:show",n);break;case"xlinkTitle":Na(e,"http://www.w3.org/1999/xlink","xlink:title",n);break;case"xlinkType":Na(e,"http://www.w3.org/1999/xlink","xlink:type",n);break;case"xmlBase":Na(e,"http://www.w3.org/XML/1998/namespace","xml:base",n);break;case"xmlLang":Na(e,"http://www.w3.org/XML/1998/namespace","xml:lang",n);break;case"xmlSpace":Na(e,"http://www.w3.org/XML/1998/namespace","xml:space",n);break;case"is":ps(e,"is",n);break;case"innerText":case"textContent":break;default:(!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(a=ra.get(a)||a,ps(e,a,n))}}function Eu(e,t,a,n,r,o){switch(a){case"style":rl(e,n,o);break;case"dangerouslySetInnerHTML":if(n!=null){if(typeof n!="object"||!("__html"in n))throw Error(c(61));if(a=n.__html,a!=null){if(r.children!=null)throw Error(c(60));e.innerHTML=a}}break;case"children":typeof n=="string"?sl(e,n):(typeof n=="number"||typeof n=="bigint")&&sl(e,""+n);break;case"onScroll":n!=null&&Ke("scroll",e);break;case"onScrollEnd":n!=null&&Ke("scrollend",e);break;case"onClick":n!=null&&(e.onclick=Fa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Ln.hasOwnProperty(a))e:{if(a[0]==="o"&&a[1]==="n"&&(r=a.endsWith("Capture"),t=a.slice(2,r?a.length-7:void 0),o=e[Ct]||null,o=o!=null?o[a]:null,typeof o=="function"&&e.removeEventListener(t,o,r),typeof n=="function")){typeof o!="function"&&o!==null&&(a in e?e[a]=null:e.hasAttribute(a)&&e.removeAttribute(a)),e.addEventListener(t,n,r);break e}a in e?e[a]=n:n===!0?e.setAttribute(a,""):ps(e,a,n)}}}function Wt(e,t,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Ke("error",e),Ke("load",e);var n=!1,r=!1,o;for(o in a)if(a.hasOwnProperty(o)){var m=a[o];if(m!=null)switch(o){case"src":n=!0;break;case"srcSet":r=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:ft(e,t,o,m,a,null)}}r&&ft(e,t,"srcSet",a.srcSet,a,null),n&&ft(e,t,"src",a.src,a,null);return;case"input":Ke("invalid",e);var y=o=m=r=null,A=null,L=null;for(n in a)if(a.hasOwnProperty(n)){var G=a[n];if(G!=null)switch(n){case"name":r=G;break;case"type":m=G;break;case"checked":A=G;break;case"defaultChecked":L=G;break;case"value":o=G;break;case"defaultValue":y=G;break;case"children":case"dangerouslySetInnerHTML":if(G!=null)throw Error(c(137,t));break;default:ft(e,t,n,G,a,null)}}ur(e,o,y,A,L,m,r,!1);return;case"select":Ke("invalid",e),n=m=o=null;for(r in a)if(a.hasOwnProperty(r)&&(y=a[r],y!=null))switch(r){case"value":o=y;break;case"defaultValue":m=y;break;case"multiple":n=y;default:ft(e,t,r,y,a,null)}t=o,a=m,e.multiple=!!n,t!=null?ll(e,!!n,t,!1):a!=null&&ll(e,!!n,a,!0);return;case"textarea":Ke("invalid",e),o=r=n=null;for(m in a)if(a.hasOwnProperty(m)&&(y=a[m],y!=null))switch(m){case"value":n=y;break;case"defaultValue":r=y;break;case"children":o=y;break;case"dangerouslySetInnerHTML":if(y!=null)throw Error(c(91));break;default:ft(e,t,m,y,a,null)}rn(e,n,r,o);return;case"option":for(A in a)if(a.hasOwnProperty(A)&&(n=a[A],n!=null))switch(A){case"selected":e.selected=n&&typeof n!="function"&&typeof n!="symbol";break;default:ft(e,t,A,n,a,null)}return;case"dialog":Ke("beforetoggle",e),Ke("toggle",e),Ke("cancel",e),Ke("close",e);break;case"iframe":case"object":Ke("load",e);break;case"video":case"audio":for(n=0;n<Yr.length;n++)Ke(Yr[n],e);break;case"image":Ke("error",e),Ke("load",e);break;case"details":Ke("toggle",e);break;case"embed":case"source":case"link":Ke("error",e),Ke("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(L in a)if(a.hasOwnProperty(L)&&(n=a[L],n!=null))switch(L){case"children":case"dangerouslySetInnerHTML":throw Error(c(137,t));default:ft(e,t,L,n,a,null)}return;default:if(Fl(t)){for(G in a)a.hasOwnProperty(G)&&(n=a[G],n!==void 0&&Eu(e,t,G,n,a,void 0));return}}for(y in a)a.hasOwnProperty(y)&&(n=a[y],n!=null&&ft(e,t,y,n,a,null))}function R0(e,t,a,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var r=null,o=null,m=null,y=null,A=null,L=null,G=null;for(B in a){var K=a[B];if(a.hasOwnProperty(B)&&K!=null)switch(B){case"checked":break;case"value":break;case"defaultValue":A=K;default:n.hasOwnProperty(B)||ft(e,t,B,null,n,K)}}for(var O in n){var B=n[O];if(K=a[O],n.hasOwnProperty(O)&&(B!=null||K!=null))switch(O){case"type":o=B;break;case"name":r=B;break;case"checked":L=B;break;case"defaultChecked":G=B;break;case"value":m=B;break;case"defaultValue":y=B;break;case"children":case"dangerouslySetInnerHTML":if(B!=null)throw Error(c(137,t));break;default:B!==K&&ft(e,t,O,B,n,K)}}cr(e,m,y,A,L,G,o,r);return;case"select":B=m=y=O=null;for(o in a)if(A=a[o],a.hasOwnProperty(o)&&A!=null)switch(o){case"value":break;case"multiple":B=A;default:n.hasOwnProperty(o)||ft(e,t,o,null,n,A)}for(r in n)if(o=n[r],A=a[r],n.hasOwnProperty(r)&&(o!=null||A!=null))switch(r){case"value":O=o;break;case"defaultValue":y=o;break;case"multiple":m=o;default:o!==A&&ft(e,t,r,o,n,A)}t=y,a=m,n=B,O!=null?ll(e,!!a,O,!1):!!n!=!!a&&(t!=null?ll(e,!!a,t,!0):ll(e,!!a,a?[]:"",!1));return;case"textarea":B=O=null;for(y in a)if(r=a[y],a.hasOwnProperty(y)&&r!=null&&!n.hasOwnProperty(y))switch(y){case"value":break;case"children":break;default:ft(e,t,y,null,n,r)}for(m in n)if(r=n[m],o=a[m],n.hasOwnProperty(m)&&(r!=null||o!=null))switch(m){case"value":O=r;break;case"defaultValue":B=r;break;case"children":break;case"dangerouslySetInnerHTML":if(r!=null)throw Error(c(91));break;default:r!==o&&ft(e,t,m,r,n,o)}dr(e,O,B);return;case"option":for(var ve in a)if(O=a[ve],a.hasOwnProperty(ve)&&O!=null&&!n.hasOwnProperty(ve))switch(ve){case"selected":e.selected=!1;break;default:ft(e,t,ve,null,n,O)}for(A in n)if(O=n[A],B=a[A],n.hasOwnProperty(A)&&O!==B&&(O!=null||B!=null))switch(A){case"selected":e.selected=O&&typeof O!="function"&&typeof O!="symbol";break;default:ft(e,t,A,O,n,B)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Re in a)O=a[Re],a.hasOwnProperty(Re)&&O!=null&&!n.hasOwnProperty(Re)&&ft(e,t,Re,null,n,O);for(L in n)if(O=n[L],B=a[L],n.hasOwnProperty(L)&&O!==B&&(O!=null||B!=null))switch(L){case"children":case"dangerouslySetInnerHTML":if(O!=null)throw Error(c(137,t));break;default:ft(e,t,L,O,n,B)}return;default:if(Fl(t)){for(var mt in a)O=a[mt],a.hasOwnProperty(mt)&&O!==void 0&&!n.hasOwnProperty(mt)&&Eu(e,t,mt,void 0,n,O);for(G in n)O=n[G],B=a[G],!n.hasOwnProperty(G)||O===B||O===void 0&&B===void 0||Eu(e,t,G,O,n,B);return}}for(var M in a)O=a[M],a.hasOwnProperty(M)&&O!=null&&!n.hasOwnProperty(M)&&ft(e,t,M,null,n,O);for(K in n)O=n[K],B=a[K],!n.hasOwnProperty(K)||O===B||O==null&&B==null||ft(e,t,K,O,n,B)}function _h(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function U0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,a=performance.getEntriesByType("resource"),n=0;n<a.length;n++){var r=a[n],o=r.transferSize,m=r.initiatorType,y=r.duration;if(o&&y&&_h(m)){for(m=0,y=r.responseEnd,n+=1;n<a.length;n++){var A=a[n],L=A.startTime;if(L>y)break;var G=A.transferSize,K=A.initiatorType;G&&_h(K)&&(A=A.responseEnd,m+=G*(A<y?1:(y-L)/(A-L)))}if(--n,t+=8*(o+m)/(r.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Mu=null,zu=null;function ro(e){return e.nodeType===9?e:e.ownerDocument}function Ah(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Ch(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function Du(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Lu=null;function O0(){var e=window.event;return e&&e.type==="popstate"?e===Lu?!1:(Lu=e,!0):(Lu=null,!1)}var jh=typeof setTimeout=="function"?setTimeout:void 0,$0=typeof clearTimeout=="function"?clearTimeout:void 0,Nh=typeof Promise=="function"?Promise:void 0,q0=typeof queueMicrotask=="function"?queueMicrotask:typeof Nh<"u"?function(e){return Nh.resolve(null).then(e).catch(B0)}:jh;function B0(e){setTimeout(function(){throw e})}function Cl(e){return e==="head"}function Th(e,t){var a=t,n=0;do{var r=a.nextSibling;if(e.removeChild(a),r&&r.nodeType===8)if(a=r.data,a==="/$"||a==="/&"){if(n===0){e.removeChild(r),ar(t);return}n--}else if(a==="$"||a==="$?"||a==="$~"||a==="$!"||a==="&")n++;else if(a==="html")Zr(e.ownerDocument.documentElement);else if(a==="head"){a=e.ownerDocument.head,Zr(a);for(var o=a.firstChild;o;){var m=o.nextSibling,y=o.nodeName;o[yn]||y==="SCRIPT"||y==="STYLE"||y==="LINK"&&o.rel.toLowerCase()==="stylesheet"||a.removeChild(o),o=m}}else a==="body"&&Zr(e.ownerDocument.body);a=r}while(a);ar(t)}function Eh(e,t){var a=e;e=0;do{var n=a.nextSibling;if(a.nodeType===1?t?(a._stashedDisplay=a.style.display,a.style.display="none"):(a.style.display=a._stashedDisplay||"",a.getAttribute("style")===""&&a.removeAttribute("style")):a.nodeType===3&&(t?(a._stashedText=a.nodeValue,a.nodeValue=""):a.nodeValue=a._stashedText||""),n&&n.nodeType===8)if(a=n.data,a==="/$"){if(e===0)break;e--}else a!=="$"&&a!=="$?"&&a!=="$~"&&a!=="$!"||e++;a=n}while(a)}function Ru(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var a=t;switch(t=t.nextSibling,a.nodeName){case"HTML":case"HEAD":case"BODY":Ru(a),Ca(a);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(a.rel.toLowerCase()==="stylesheet")continue}e.removeChild(a)}}function H0(e,t,a,n){for(;e.nodeType===1;){var r=a;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!n&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(n){if(!e[yn])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(o=e.getAttribute("rel"),o==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(o!==r.rel||e.getAttribute("href")!==(r.href==null||r.href===""?null:r.href)||e.getAttribute("crossorigin")!==(r.crossOrigin==null?null:r.crossOrigin)||e.getAttribute("title")!==(r.title==null?null:r.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(o=e.getAttribute("src"),(o!==(r.src==null?null:r.src)||e.getAttribute("type")!==(r.type==null?null:r.type)||e.getAttribute("crossorigin")!==(r.crossOrigin==null?null:r.crossOrigin))&&o&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var o=r.name==null?null:""+r.name;if(r.type==="hidden"&&e.getAttribute("name")===o)return e}else return e;if(e=Pa(e.nextSibling),e===null)break}return null}function F0(e,t,a){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!a||(e=Pa(e.nextSibling),e===null))return null;return e}function Mh(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Pa(e.nextSibling),e===null))return null;return e}function Uu(e){return e.data==="$?"||e.data==="$~"}function Ou(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function I0(e,t){var a=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||a.readyState!=="loading")t();else{var n=function(){t(),a.removeEventListener("DOMContentLoaded",n)};a.addEventListener("DOMContentLoaded",n),e._reactRetry=n}}function Pa(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var $u=null;function zh(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="/$"||a==="/&"){if(t===0)return Pa(e.nextSibling);t--}else a!=="$"&&a!=="$!"&&a!=="$?"&&a!=="$~"&&a!=="&"||t++}e=e.nextSibling}return null}function Dh(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var a=e.data;if(a==="$"||a==="$!"||a==="$?"||a==="$~"||a==="&"){if(t===0)return e;t--}else a!=="/$"&&a!=="/&"||t++}e=e.previousSibling}return null}function Lh(e,t,a){switch(t=ro(a),e){case"html":if(e=t.documentElement,!e)throw Error(c(452));return e;case"head":if(e=t.head,!e)throw Error(c(453));return e;case"body":if(e=t.body,!e)throw Error(c(454));return e;default:throw Error(c(451))}}function Zr(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ca(e)}var Wa=new Map,Rh=new Set;function io(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Pn=V.d;V.d={f:G0,r:V0,D:X0,C:Y0,L:Q0,m:Z0,X:J0,S:K0,M:P0};function G0(){var e=Pn.f(),t=Pi();return e||t}function V0(e){var t=qe(e);t!==null&&t.tag===5&&t.type==="form"?Pf(t):Pn.r(e)}var Ws=typeof document>"u"?null:document;function Uh(e,t,a){var n=Ws;if(n&&typeof t=="string"&&t){var r=sa(t);r='link[rel="'+e+'"][href="'+r+'"]',typeof a=="string"&&(r+='[crossorigin="'+a+'"]'),Rh.has(r)||(Rh.add(r),e={rel:e,crossOrigin:a,href:t},n.querySelector(r)===null&&(t=n.createElement("link"),Wt(t,"link",e),Ye(t),n.head.appendChild(t)))}}function X0(e){Pn.D(e),Uh("dns-prefetch",e,null)}function Y0(e,t){Pn.C(e,t),Uh("preconnect",e,t)}function Q0(e,t,a){Pn.L(e,t,a);var n=Ws;if(n&&e&&t){var r='link[rel="preload"][as="'+sa(t)+'"]';t==="image"&&a&&a.imageSrcSet?(r+='[imagesrcset="'+sa(a.imageSrcSet)+'"]',typeof a.imageSizes=="string"&&(r+='[imagesizes="'+sa(a.imageSizes)+'"]')):r+='[href="'+sa(e)+'"]';var o=r;switch(t){case"style":o=er(e);break;case"script":o=tr(e)}Wa.has(o)||(e=w({rel:"preload",href:t==="image"&&a&&a.imageSrcSet?void 0:e,as:t},a),Wa.set(o,e),n.querySelector(r)!==null||t==="style"&&n.querySelector(Kr(o))||t==="script"&&n.querySelector(Jr(o))||(t=n.createElement("link"),Wt(t,"link",e),Ye(t),n.head.appendChild(t)))}}function Z0(e,t){Pn.m(e,t);var a=Ws;if(a&&e){var n=t&&typeof t.as=="string"?t.as:"script",r='link[rel="modulepreload"][as="'+sa(n)+'"][href="'+sa(e)+'"]',o=r;switch(n){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=tr(e)}if(!Wa.has(o)&&(e=w({rel:"modulepreload",href:e},t),Wa.set(o,e),a.querySelector(r)===null)){switch(n){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(a.querySelector(Jr(o)))return}n=a.createElement("link"),Wt(n,"link",e),Ye(n),a.head.appendChild(n)}}}function K0(e,t,a){Pn.S(e,t,a);var n=Ws;if(n&&e){var r=tt(n).hoistableStyles,o=er(e);t=t||"default";var m=r.get(o);if(!m){var y={loading:0,preload:null};if(m=n.querySelector(Kr(o)))y.loading=5;else{e=w({rel:"stylesheet",href:e,"data-precedence":t},a),(a=Wa.get(o))&&qu(e,a);var A=m=n.createElement("link");Ye(A),Wt(A,"link",e),A._p=new Promise(function(L,G){A.onload=L,A.onerror=G}),A.addEventListener("load",function(){y.loading|=1}),A.addEventListener("error",function(){y.loading|=2}),y.loading|=4,oo(m,t,n)}m={type:"stylesheet",instance:m,count:1,state:y},r.set(o,m)}}}function J0(e,t){Pn.X(e,t);var a=Ws;if(a&&e){var n=tt(a).hoistableScripts,r=tr(e),o=n.get(r);o||(o=a.querySelector(Jr(r)),o||(e=w({src:e,async:!0},t),(t=Wa.get(r))&&Bu(e,t),o=a.createElement("script"),Ye(o),Wt(o,"link",e),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},n.set(r,o))}}function P0(e,t){Pn.M(e,t);var a=Ws;if(a&&e){var n=tt(a).hoistableScripts,r=tr(e),o=n.get(r);o||(o=a.querySelector(Jr(r)),o||(e=w({src:e,async:!0,type:"module"},t),(t=Wa.get(r))&&Bu(e,t),o=a.createElement("script"),Ye(o),Wt(o,"link",e),a.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},n.set(r,o))}}function Oh(e,t,a,n){var r=(r=de.current)?io(r):null;if(!r)throw Error(c(446));switch(e){case"meta":case"title":return null;case"style":return typeof a.precedence=="string"&&typeof a.href=="string"?(t=er(a.href),a=tt(r).hoistableStyles,n=a.get(t),n||(n={type:"style",instance:null,count:0,state:null},a.set(t,n)),n):{type:"void",instance:null,count:0,state:null};case"link":if(a.rel==="stylesheet"&&typeof a.href=="string"&&typeof a.precedence=="string"){e=er(a.href);var o=tt(r).hoistableStyles,m=o.get(e);if(m||(r=r.ownerDocument||r,m={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(e,m),(o=r.querySelector(Kr(e)))&&!o._p&&(m.instance=o,m.state.loading=5),Wa.has(e)||(a={rel:"preload",as:"style",href:a.href,crossOrigin:a.crossOrigin,integrity:a.integrity,media:a.media,hrefLang:a.hrefLang,referrerPolicy:a.referrerPolicy},Wa.set(e,a),o||W0(r,e,a,m.state))),t&&n===null)throw Error(c(528,""));return m}if(t&&n!==null)throw Error(c(529,""));return null;case"script":return t=a.async,a=a.src,typeof a=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=tr(a),a=tt(r).hoistableScripts,n=a.get(t),n||(n={type:"script",instance:null,count:0,state:null},a.set(t,n)),n):{type:"void",instance:null,count:0,state:null};default:throw Error(c(444,e))}}function er(e){return'href="'+sa(e)+'"'}function Kr(e){return'link[rel="stylesheet"]['+e+"]"}function $h(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function W0(e,t,a,n){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?n.loading=1:(t=e.createElement("link"),n.preload=t,t.addEventListener("load",function(){return n.loading|=1}),t.addEventListener("error",function(){return n.loading|=2}),Wt(t,"link",a),Ye(t),e.head.appendChild(t))}function tr(e){return'[src="'+sa(e)+'"]'}function Jr(e){return"script[async]"+e}function qh(e,t,a){if(t.count++,t.instance===null)switch(t.type){case"style":var n=e.querySelector('style[data-href~="'+sa(a.href)+'"]');if(n)return t.instance=n,Ye(n),n;var r=w({},a,{"data-href":a.href,"data-precedence":a.precedence,href:null,precedence:null});return n=(e.ownerDocument||e).createElement("style"),Ye(n),Wt(n,"style",r),oo(n,a.precedence,e),t.instance=n;case"stylesheet":r=er(a.href);var o=e.querySelector(Kr(r));if(o)return t.state.loading|=4,t.instance=o,Ye(o),o;n=$h(a),(r=Wa.get(r))&&qu(n,r),o=(e.ownerDocument||e).createElement("link"),Ye(o);var m=o;return m._p=new Promise(function(y,A){m.onload=y,m.onerror=A}),Wt(o,"link",n),t.state.loading|=4,oo(o,a.precedence,e),t.instance=o;case"script":return o=tr(a.src),(r=e.querySelector(Jr(o)))?(t.instance=r,Ye(r),r):(n=a,(r=Wa.get(o))&&(n=w({},a),Bu(n,r)),e=e.ownerDocument||e,r=e.createElement("script"),Ye(r),Wt(r,"link",n),e.head.appendChild(r),t.instance=r);case"void":return null;default:throw Error(c(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(n=t.instance,t.state.loading|=4,oo(n,a.precedence,e));return t.instance}function oo(e,t,a){for(var n=a.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=n.length?n[n.length-1]:null,o=r,m=0;m<n.length;m++){var y=n[m];if(y.dataset.precedence===t)o=y;else if(o!==r)break}o?o.parentNode.insertBefore(e,o.nextSibling):(t=a.nodeType===9?a.head:a,t.insertBefore(e,t.firstChild))}function qu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Bu(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var co=null;function Bh(e,t,a){if(co===null){var n=new Map,r=co=new Map;r.set(a,n)}else r=co,n=r.get(a),n||(n=new Map,r.set(a,n));if(n.has(e))return n;for(n.set(e,null),a=a.getElementsByTagName(e),r=0;r<a.length;r++){var o=a[r];if(!(o[yn]||o[Et]||e==="link"&&o.getAttribute("rel")==="stylesheet")&&o.namespaceURI!=="http://www.w3.org/2000/svg"){var m=o.getAttribute(t)||"";m=e+m;var y=n.get(m);y?y.push(o):n.set(m,[o])}}return n}function Hh(e,t,a){e=e.ownerDocument||e,e.head.insertBefore(a,t==="title"?e.querySelector("head > title"):null)}function ex(e,t,a){if(a===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Fh(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function tx(e,t,a,n){if(a.type==="stylesheet"&&(typeof n.media!="string"||matchMedia(n.media).matches!==!1)&&(a.state.loading&4)===0){if(a.instance===null){var r=er(n.href),o=t.querySelector(Kr(r));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=uo.bind(e),t.then(e,e)),a.state.loading|=4,a.instance=o,Ye(o);return}o=t.ownerDocument||t,n=$h(n),(r=Wa.get(r))&&qu(n,r),o=o.createElement("link"),Ye(o);var m=o;m._p=new Promise(function(y,A){m.onload=y,m.onerror=A}),Wt(o,"link",n),a.instance=o}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(a,t),(t=a.state.preload)&&(a.state.loading&3)===0&&(e.count++,a=uo.bind(e),t.addEventListener("load",a),t.addEventListener("error",a))}}var Hu=0;function ax(e,t){return e.stylesheets&&e.count===0&&mo(e,e.stylesheets),0<e.count||0<e.imgCount?function(a){var n=setTimeout(function(){if(e.stylesheets&&mo(e,e.stylesheets),e.unsuspend){var o=e.unsuspend;e.unsuspend=null,o()}},6e4+t);0<e.imgBytes&&Hu===0&&(Hu=62500*U0());var r=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&mo(e,e.stylesheets),e.unsuspend)){var o=e.unsuspend;e.unsuspend=null,o()}},(e.imgBytes>Hu?50:800)+t);return e.unsuspend=a,function(){e.unsuspend=null,clearTimeout(n),clearTimeout(r)}}:null}function uo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)mo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var fo=null;function mo(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,fo=new Map,t.forEach(nx,e),fo=null,uo.call(e))}function nx(e,t){if(!(t.state.loading&4)){var a=fo.get(e);if(a)var n=a.get(null);else{a=new Map,fo.set(e,a);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o<r.length;o++){var m=r[o];(m.nodeName==="LINK"||m.getAttribute("media")!=="not all")&&(a.set(m.dataset.precedence,m),n=m)}n&&a.set(null,n)}r=t.instance,m=r.getAttribute("data-precedence"),o=a.get(m)||n,o===n&&a.set(null,r),a.set(m,r),this.count++,n=uo.bind(this),r.addEventListener("load",n),r.addEventListener("error",n),o?o.parentNode.insertBefore(r,o.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(r,e.firstChild)),t.state.loading|=4}}var Pr={$$typeof:Y,Provider:null,Consumer:null,_currentValue:H,_currentValue2:H,_threadCount:0};function lx(e,t,a,n,r,o,m,y,A){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=_a(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=_a(0),this.hiddenUpdates=_a(null),this.identifierPrefix=n,this.onUncaughtError=r,this.onCaughtError=o,this.onRecoverableError=m,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=A,this.incompleteTransitions=new Map}function Ih(e,t,a,n,r,o,m,y,A,L,G,K){return e=new lx(e,t,a,m,A,L,G,K,y),t=1,o===!0&&(t|=24),o=La(3,null,null,t),e.current=o,o.stateNode=e,t=vc(),t.refCount++,e.pooledCache=t,t.refCount++,o.memoizedState={element:n,isDehydrated:a,cache:t},_c(o),e}function Gh(e){return e?(e=zs,e):zs}function Vh(e,t,a,n,r,o){r=Gh(r),n.context===null?n.context=r:n.pendingContext=r,n=pl(t),n.payload={element:a},o=o===void 0?null:o,o!==null&&(n.callback=o),a=gl(e,n,t),a!==null&&(ya(a,e,t),Er(a,e,t))}function Xh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var a=e.retryLane;e.retryLane=a!==0&&a<t?a:t}}function Fu(e,t){Xh(e,t),(e=e.alternate)&&Xh(e,t)}function Yh(e){if(e.tag===13||e.tag===31){var t=Jl(e,67108864);t!==null&&ya(t,e,67108864),Fu(e,67108864)}}function Qh(e){if(e.tag===13||e.tag===31){var t=qa();t=tn(t);var a=Jl(e,t);a!==null&&ya(a,e,t),Fu(e,t)}}var ho=!0;function sx(e,t,a,n){var r=E.T;E.T=null;var o=V.p;try{V.p=2,Iu(e,t,a,n)}finally{V.p=o,E.T=r}}function rx(e,t,a,n){var r=E.T;E.T=null;var o=V.p;try{V.p=8,Iu(e,t,a,n)}finally{V.p=o,E.T=r}}function Iu(e,t,a,n){if(ho){var r=Gu(n);if(r===null)Tu(e,t,n,po,a),Kh(e,n);else if(ox(r,e,t,a,n))n.stopPropagation();else if(Kh(e,n),t&4&&-1<ix.indexOf(e)){for(;r!==null;){var o=qe(r);if(o!==null)switch(o.tag){case 3:if(o=o.stateNode,o.current.memoizedState.isDehydrated){var m=la(o.pendingLanes);if(m!==0){var y=o;for(y.pendingLanes|=2,y.entangledLanes|=2;m;){var A=1<<31-_e(m);y.entanglements[1]|=A,m&=~A}Cn(o),(rt&6)===0&&(Ki=Oe()+500,Xr(0))}}break;case 31:case 13:y=Jl(o,2),y!==null&&ya(y,o,2),Pi(),Fu(o,2)}if(o=Gu(n),o===null&&Tu(e,t,n,po,a),o===r)break;r=o}r!==null&&n.stopPropagation()}else Tu(e,t,n,null,a)}}function Gu(e){return e=vs(e),Vu(e)}var po=null;function Vu(e){if(po=null,e=se(e),e!==null){var t=f(e);if(t===null)e=null;else{var a=t.tag;if(a===13){if(e=h(t),e!==null)return e;e=null}else if(a===31){if(e=p(t),e!==null)return e;e=null}else if(a===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return po=e,null}function Zh(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Vt()){case da:return 2;case Xt:return 8;case ea:case pn:return 32;case en:return 268435456;default:return 32}default:return 32}}var Xu=!1,jl=null,Nl=null,Tl=null,Wr=new Map,ei=new Map,El=[],ix="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Kh(e,t){switch(e){case"focusin":case"focusout":jl=null;break;case"dragenter":case"dragleave":Nl=null;break;case"mouseover":case"mouseout":Tl=null;break;case"pointerover":case"pointerout":Wr.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":ei.delete(t.pointerId)}}function ti(e,t,a,n,r,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:a,eventSystemFlags:n,nativeEvent:o,targetContainers:[r]},t!==null&&(t=qe(t),t!==null&&Yh(t)),e):(e.eventSystemFlags|=n,t=e.targetContainers,r!==null&&t.indexOf(r)===-1&&t.push(r),e)}function ox(e,t,a,n,r){switch(t){case"focusin":return jl=ti(jl,e,t,a,n,r),!0;case"dragenter":return Nl=ti(Nl,e,t,a,n,r),!0;case"mouseover":return Tl=ti(Tl,e,t,a,n,r),!0;case"pointerover":var o=r.pointerId;return Wr.set(o,ti(Wr.get(o)||null,e,t,a,n,r)),!0;case"gotpointercapture":return o=r.pointerId,ei.set(o,ti(ei.get(o)||null,e,t,a,n,r)),!0}return!1}function Jh(e){var t=se(e.target);if(t!==null){var a=f(t);if(a!==null){if(t=a.tag,t===13){if(t=h(a),t!==null){e.blockedOn=t,xn(e.priority,function(){Qh(a)});return}}else if(t===31){if(t=p(a),t!==null){e.blockedOn=t,xn(e.priority,function(){Qh(a)});return}}else if(t===3&&a.stateNode.current.memoizedState.isDehydrated){e.blockedOn=a.tag===3?a.stateNode.containerInfo:null;return}}}e.blockedOn=null}function go(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var a=Gu(e.nativeEvent);if(a===null){a=e.nativeEvent;var n=new a.constructor(a.type,a);wt=n,a.target.dispatchEvent(n),wt=null}else return t=qe(a),t!==null&&Yh(t),e.blockedOn=a,!1;t.shift()}return!0}function Ph(e,t,a){go(e)&&a.delete(t)}function cx(){Xu=!1,jl!==null&&go(jl)&&(jl=null),Nl!==null&&go(Nl)&&(Nl=null),Tl!==null&&go(Tl)&&(Tl=null),Wr.forEach(Ph),ei.forEach(Ph)}function xo(e,t){e.blockedOn===t&&(e.blockedOn=null,Xu||(Xu=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,cx)))}var bo=null;function Wh(e){bo!==e&&(bo=e,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){bo===e&&(bo=null);for(var t=0;t<e.length;t+=3){var a=e[t],n=e[t+1],r=e[t+2];if(typeof n!="function"){if(Vu(n||a)===null)continue;break}var o=qe(a);o!==null&&(e.splice(t,3),t-=3,Gc(o,{pending:!0,data:r,method:a.method,action:n},n,r))}}))}function ar(e){function t(A){return xo(A,e)}jl!==null&&xo(jl,e),Nl!==null&&xo(Nl,e),Tl!==null&&xo(Tl,e),Wr.forEach(t),ei.forEach(t);for(var a=0;a<El.length;a++){var n=El[a];n.blockedOn===e&&(n.blockedOn=null)}for(;0<El.length&&(a=El[0],a.blockedOn===null);)Jh(a),a.blockedOn===null&&El.shift();if(a=(e.ownerDocument||e).$$reactFormReplay,a!=null)for(n=0;n<a.length;n+=3){var r=a[n],o=a[n+1],m=r[Ct]||null;if(typeof o=="function")m||Wh(a);else if(m){var y=null;if(o&&o.hasAttribute("formAction")){if(r=o,m=o[Ct]||null)y=m.formAction;else if(Vu(r)!==null)continue}else y=m.action;typeof y=="function"?a[n+1]=y:(a.splice(n,3),n-=3),Wh(a)}}}function ep(){function e(o){o.canIntercept&&o.info==="react-transition"&&o.intercept({handler:function(){return new Promise(function(m){return r=m})},focusReset:"manual",scroll:"manual"})}function t(){r!==null&&(r(),r=null),n||setTimeout(a,20)}function a(){if(!n&&!navigation.transition){var o=navigation.currentEntry;o&&o.url!=null&&navigation.navigate(o.url,{state:o.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var n=!1,r=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(a,100),function(){n=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),r!==null&&(r(),r=null)}}}function Yu(e){this._internalRoot=e}yo.prototype.render=Yu.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(c(409));var a=t.current,n=qa();Vh(a,n,e,t,null,null)},yo.prototype.unmount=Yu.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Vh(e.current,2,null,e,null,null),Pi(),t[fa]=null}};function yo(e){this._internalRoot=e}yo.prototype.unstable_scheduleHydration=function(e){if(e){var t=an();e={blockedOn:null,target:e,priority:t};for(var a=0;a<El.length&&t!==0&&t<El[a].priority;a++);El.splice(a,0,e),a===0&&Jh(e)}};var tp=l.version;if(tp!=="19.2.7")throw Error(c(527,tp,"19.2.7"));V.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(c(188)):(e=Object.keys(e).join(","),Error(c(268,e)));return e=v(t),e=e!==null?b(e):null,e=e===null?null:e.stateNode,e};var ux={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:E,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var vo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!vo.isDisabled&&vo.supportsFiber)try{At=vo.inject(ux),gt=vo}catch{}}return ai.createRoot=function(e,t){if(!d(e))throw Error(c(299));var a=!1,n="",r=om,o=cm,m=um;return t!=null&&(t.unstable_strictMode===!0&&(a=!0),t.identifierPrefix!==void 0&&(n=t.identifierPrefix),t.onUncaughtError!==void 0&&(r=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(m=t.onRecoverableError)),t=Ih(e,1,!1,null,null,a,n,null,r,o,m,ep),e[fa]=t.current,Nu(e),new Yu(t)},ai.hydrateRoot=function(e,t,a){if(!d(e))throw Error(c(299));var n=!1,r="",o=om,m=cm,y=um,A=null;return a!=null&&(a.unstable_strictMode===!0&&(n=!0),a.identifierPrefix!==void 0&&(r=a.identifierPrefix),a.onUncaughtError!==void 0&&(o=a.onUncaughtError),a.onCaughtError!==void 0&&(m=a.onCaughtError),a.onRecoverableError!==void 0&&(y=a.onRecoverableError),a.formState!==void 0&&(A=a.formState)),t=Ih(e,1,!0,t,a??null,n,r,A,o,m,y,ep),t.context=Gh(null),a=t.current,n=qa(),n=tn(n),r=pl(n),r.callback=null,gl(a,r,n),a=n,t.current.lanes=a,zn(t,a),Cn(t),e[fa]=t.current,Nu(e),new yo(t)},ai.version="19.2.7",ai}var rp;function Cx(){if(rp)return Qu.exports;rp=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(l){console.error(l)}}return s(),Qu.exports=Ax(),Qu.exports}var jx=Cx();const Pp=g.createContext(void 0);function ip({children:s}){const[l,i]=g.useState(()=>{const h=localStorage.getItem("chat-theme");if(h){const p=JSON.parse(h);return{mode:p.mode||"dark",highContrast:!!p.highContrast}}return{mode:"dark",highContrast:!1}}),[c,d]=g.useState(!1);g.useEffect(()=>{const h=()=>{let p=!1;l.mode==="dark"?p=!0:l.mode==="light"?p=!1:p=window.matchMedia("(prefers-color-scheme: dark)").matches,d(p);const x=document.documentElement;p?x.classList.add("dark"):x.classList.remove("dark"),l.highContrast?x.classList.add("high-contrast"):x.classList.remove("high-contrast"),x.classList.remove("text-sm","text-lg"),x.classList.add("text-base")};if(h(),l.mode==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),x=()=>{h()};return p.addEventListener("change",x),()=>p.removeEventListener("change",x)}},[l]),g.useEffect(()=>{localStorage.setItem("chat-theme",JSON.stringify(l))},[l]);const f=h=>{i(p=>({...p,...h}))};return u.jsx(Pp.Provider,{value:{theme:l,updateTheme:f,isDark:c},children:s})}function rr(){const s=g.useContext(Pp);if(!s)throw new Error("useTheme must be used within ThemeProvider");return s}const Wp=g.createContext(void 0),Ju={voiceEnabled:!1,soundEnabled:!1,autoSend:!1};function Nx({children:s}){const[l,i]=g.useState(()=>{const d=localStorage.getItem("chat-settings");if(d)try{const f=JSON.parse(d);return{...Ju,...f,voiceEnabled:!1}}catch{return Ju}return Ju});g.useEffect(()=>{localStorage.setItem("chat-settings",JSON.stringify(l))},[l]);const c=d=>{i(f=>({...f,...d}))};return u.jsx(Wp.Provider,{value:{settings:l,updateSettings:c},children:s})}function Go(){const s=g.useContext(Wp);if(!s)throw new Error("useSettings must be used within SettingsProvider");return s}/**
|
|
27
27
|
* @license lucide-react v0.469.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Tx=
|
|
31
|
+
*/const Tx=s=>s.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),eg=(...s)=>s.filter((l,i,c)=>!!l&&l.trim()!==""&&c.indexOf(l)===i).join(" ").trim();/**
|
|
32
32
|
* @license lucide-react v0.469.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
@@ -38,12 +38,12 @@ Error generating stack: `+n.message+`
|
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Mx=g.forwardRef(({color:
|
|
41
|
+
*/const Mx=g.forwardRef(({color:s="currentColor",size:l=24,strokeWidth:i=2,absoluteStrokeWidth:c,className:d="",children:f,iconNode:h,...p},x)=>g.createElement("svg",{ref:x,...Ex,width:l,height:l,stroke:s,strokeWidth:c?Number(i)*24/Number(l):i,className:eg("lucide",d),...p},[...h.map(([v,b])=>g.createElement(v,b)),...Array.isArray(f)?f:[f]]));/**
|
|
42
42
|
* @license lucide-react v0.469.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const De=(
|
|
46
|
+
*/const De=(s,l)=>{const i=g.forwardRef(({className:c,...d},f)=>g.createElement(Mx,{ref:f,iconNode:l,className:eg(`lucide-${Tx(s)}`,c),...d}));return i.displayName=`${s}`,i};/**
|
|
47
47
|
* @license lucide-react v0.469.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
@@ -253,7 +253,7 @@ Error generating stack: `+n.message+`
|
|
|
253
253
|
*
|
|
254
254
|
* This source code is licensed under the ISC license.
|
|
255
255
|
* See the LICENSE file in the root directory of this source tree.
|
|
256
|
-
*/const
|
|
256
|
+
*/const sb=De("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"}]]);/**
|
|
257
257
|
* @license lucide-react v0.469.0 - ISC
|
|
258
258
|
*
|
|
259
259
|
* This source code is licensed under the ISC license.
|
|
@@ -268,12 +268,12 @@ Error generating stack: `+n.message+`
|
|
|
268
268
|
*
|
|
269
269
|
* This source code is licensed under the ISC license.
|
|
270
270
|
* See the LICENSE file in the root directory of this source tree.
|
|
271
|
-
*/const
|
|
271
|
+
*/const sg=De("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"}]]);/**
|
|
272
272
|
* @license lucide-react v0.469.0 - ISC
|
|
273
273
|
*
|
|
274
274
|
* This source code is licensed under the ISC license.
|
|
275
275
|
* See the LICENSE file in the root directory of this source tree.
|
|
276
|
-
*/const
|
|
276
|
+
*/const rb=De("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"}]]);/**
|
|
277
277
|
* @license lucide-react v0.469.0 - ISC
|
|
278
278
|
*
|
|
279
279
|
* This source code is licensed under the ISC license.
|
|
@@ -308,33 +308,33 @@ Error generating stack: `+n.message+`
|
|
|
308
308
|
*
|
|
309
309
|
* This source code is licensed under the ISC license.
|
|
310
310
|
* See the LICENSE file in the root directory of this source tree.
|
|
311
|
-
*/const ub=De("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"}]]);fd.__defineMacro("\\ce",function(r){return sg(r.consumeArgs(1)[0],"ce")});fd.__defineMacro("\\pu",function(r){return sg(r.consumeArgs(1)[0],"pu")});fd.__defineMacro("\\tripledash","{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");var sg=function(l,i){for(var c="",d=l.length&&l[l.length-1].loc.start,f=l.length-1;f>=0;f--)l[f].loc.start>d&&(c+=" ",d=l[f].loc.start),c+=l[f].text,d+=l[f].text.length;var h=pt.go(J.go(c,i));return h},J={go:function(l,i){if(!l)return[];i===void 0&&(i="ce");var c="0",d={};d.parenthesisLevel=0,l=l.replace(/\n/g," "),l=l.replace(/[\u2212\u2013\u2014\u2010]/g,"-"),l=l.replace(/[\u2026]/g,"...");for(var f,h=10,p=[];;){f!==l?(h=10,f=l):h--;var x=J.stateMachines[i],v=x.transitions[c]||x.transitions["*"];e:for(var b=0;b<v.length;b++){var w=J.patterns.match_(v[b].pattern,l);if(w){for(var k=v[b].task,S=0;S<k.action_.length;S++){var j;if(x.actions[k.action_[S].type_])j=x.actions[k.action_[S].type_](d,w.match_,k.action_[S].option);else if(J.actions[k.action_[S].type_])j=J.actions[k.action_[S].type_](d,w.match_,k.action_[S].option);else throw["MhchemBugA","mhchem bug A. Please report. ("+k.action_[S].type_+")"];J.concatArray(p,j)}if(c=k.nextState||c,l.length>0){if(k.revisit||(l=w.remainder),!k.toContinue)break e}else return p}}if(h<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(l,i){if(i)if(Array.isArray(i))for(var c=0;c<i.length;c++)l.push(i[c]);else l.push(i)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(l){var i=l.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return i&&i[0]?{match_:i.splice(1),remainder:l.substr(i[0].length)}:null},"(-)(9)^(-9)":function(l){var i=l.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);return i&&i[0]?{match_:i.splice(1),remainder:l.substr(i[0].length)}:null},"state of aggregation $":function(l){var i=J.patterns.findObserveGroups(l,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(i&&i.remainder.match(/^($|[\s,;\)\]\}])/))return i;var c=l.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return c?{match_:c[0],remainder:l.substr(c[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". ":/^([.\u22C5\u00B7\u2022])\s*/,"...":/^\.\.\.(?=$|[^.])/,"* ":/^([*])\s*/,"^{(...)}":function(l){return J.patterns.findObserveGroups(l,"^{","","","}")},"^($...$)":function(l){return J.patterns.findObserveGroups(l,"^","$","$","")},"^a":/^\^([0-9]+|[^\\_])/,"^\\x{}{}":function(l){return J.patterns.findObserveGroups(l,"^",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"^\\x{}":function(l){return J.patterns.findObserveGroups(l,"^",/^\\[a-zA-Z]+\{/,"}","")},"^\\x":/^\^(\\[a-zA-Z]+)\s*/,"^(-1)":/^\^(-?\d+)/,"'":/^'/,"_{(...)}":function(l){return J.patterns.findObserveGroups(l,"_{","","","}")},"_($...$)":function(l){return J.patterns.findObserveGroups(l,"_","$","$","")},_9:/^_([+\-]?[0-9]+|[^\\])/,"_\\x{}{}":function(l){return J.patterns.findObserveGroups(l,"_",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"_\\x{}":function(l){return J.patterns.findObserveGroups(l,"_",/^\\[a-zA-Z]+\{/,"}","")},"_\\x":/^_(\\[a-zA-Z]+)\s*/,"^_":/^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,"{}":/^\{\}/,"{...}":function(l){return J.patterns.findObserveGroups(l,"","{","}","")},"{(...)}":function(l){return J.patterns.findObserveGroups(l,"{","","","}")},"$...$":function(l){return J.patterns.findObserveGroups(l,"","$","$","")},"${(...)}$":function(l){return J.patterns.findObserveGroups(l,"${","","","}$")},"$(...)$":function(l){return J.patterns.findObserveGroups(l,"$","","","$")},"=<>":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(l){return J.patterns.findObserveGroups(l,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(l){return J.patterns.findObserveGroups(l,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(l){return J.patterns.findObserveGroups(l,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(l){return J.patterns.findObserveGroups(l,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(l){return J.patterns.findObserveGroups(l,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(l){return J.patterns.findObserveGroups(l,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(l){var i;if(i=l.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/),i)return{match_:i[0],remainder:l.substr(i[0].length)};var c=J.patterns.findObserveGroups(l,"","$","$","");return c&&(i=c.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/),i)?{match_:i[0],remainder:l.substr(i[0].length)}:null},amount2:function(l){return this.amount(l)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(l){if(l.match(/^\([a-z]+\)$/))return null;var i=l.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return i?{match_:i[0],remainder:l.substr(i[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(l,i,c,d,f,h,p,x,v,b){var w=function(Y,R){if(typeof R=="string")return Y.indexOf(R)!==0?null:R;var q=Y.match(R);return q?q[0]:null},k=function(Y,R,q){for(var N=0;R<Y.length;){var X=Y.charAt(R),U=w(Y.substr(R),q);if(U!==null&&N===0)return{endMatchBegin:R,endMatchEnd:R+U.length};if(X==="{")N++;else if(X==="}"){if(N===0)throw["ExtraCloseMissingOpen","Extra close brace or missing open brace"];N--}R++}return N>0,null},S=w(l,i);if(S===null||(l=l.substr(S.length),S=w(l,c),S===null))return null;var j=k(l,S.length,d||f);if(j===null)return null;var _=l.substring(0,d?j.endMatchEnd:j.endMatchBegin);if(h||p){var z=this.findObserveGroups(l.substr(j.endMatchEnd),h,p,x,v);if(z===null)return null;var $=[_,z.match_];return{match_:b?$.join(""):$,remainder:z.remainder}}else return{match_:_,remainder:l.substr(j.endMatchEnd)}},match_:function(l,i){var c=J.patterns.patterns[l];if(c===void 0)throw["MhchemBugP","mhchem bug P. Please report. ("+l+")"];if(typeof c=="function")return J.patterns.patterns[l](i);var d=i.match(c);if(d){var f;return d[2]?f=[d[1],d[2]]:d[1]?f=d[1]:f=d[0],{match_:f,remainder:i.substr(d[0].length)}}return null}},actions:{"a=":function(l,i){l.a=(l.a||"")+i},"b=":function(l,i){l.b=(l.b||"")+i},"p=":function(l,i){l.p=(l.p||"")+i},"o=":function(l,i){l.o=(l.o||"")+i},"q=":function(l,i){l.q=(l.q||"")+i},"d=":function(l,i){l.d=(l.d||"")+i},"rm=":function(l,i){l.rm=(l.rm||"")+i},"text=":function(l,i){l.text_=(l.text_||"")+i},insert:function(l,i,c){return{type_:c}},"insert+p1":function(l,i,c){return{type_:c,p1:i}},"insert+p1+p2":function(l,i,c){return{type_:c,p1:i[0],p2:i[1]}},copy:function(l,i){return i},rm:function(l,i){return{type_:"rm",p1:i||""}},text:function(l,i){return J.go(i,"text")},"{text}":function(l,i){var c=["{"];return J.concatArray(c,J.go(i,"text")),c.push("}"),c},"tex-math":function(l,i){return J.go(i,"tex-math")},"tex-math tight":function(l,i){return J.go(i,"tex-math tight")},bond:function(l,i,c){return{type_:"bond",kind_:c||i}},"color0-output":function(l,i){return{type_:"color0",color:i[0]}},ce:function(l,i){return J.go(i)},"1/2":function(l,i){var c=[];i.match(/^[+\-]/)&&(c.push(i.substr(0,1)),i=i.substr(1));var d=i.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);return d[1]=d[1].replace(/\$/g,""),c.push({type_:"frac",p1:d[1],p2:d[2]}),d[3]&&(d[3]=d[3].replace(/\$/g,""),c.push({type_:"tex-math",p1:d[3]})),c},"9,9":function(l,i){return J.go(i,"9,9")}},createTransitions:function(l){var i,c,d,f,h={};for(i in l)for(c in l[i])for(d=c.split("|"),l[i][c].stateArray=d,f=0;f<d.length;f++)h[d[f]]=[];for(i in l)for(c in l[i])for(d=l[i][c].stateArray||[],f=0;f<d.length;f++){var p=l[i][c];if(p.action_){p.action_=[].concat(p.action_);for(var x=0;x<p.action_.length;x++)typeof p.action_[x]=="string"&&(p.action_[x]={type_:p.action_[x]})}else p.action_=[];for(var v=i.split("|"),b=0;b<v.length;b++)if(d[f]==="*")for(var w in h)h[w].push({pattern:v[b],task:p});else h[d[f]].push({pattern:v[b],task:p})}return h},stateMachines:{}};J.stateMachines={ce:{transitions:J.createTransitions({empty:{"*":{action_:"output"}},else:{"0|1|2":{action_:"beginsWithBond=false",revisit:!0,toContinue:!0}},oxidation$:{0:{action_:"oxidation-output"}},CMT:{r:{action_:"rdt=",nextState:"rt"},rd:{action_:"rqt=",nextState:"rdt"}},arrowUpDown:{"0|1|2|as":{action_:["sb=false","output","operator"],nextState:"1"}},uprightEntities:{"0|1|2":{action_:["o=","output"],nextState:"1"}},orbital:{"0|1|2|3":{action_:"o=",nextState:"o"}},"->":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(l,i){var c;if((l.d||"").match(/^[0-9]+$/)){var d=l.d;l.d=void 0,c=this.output(l),l.b=d}else c=this.output(l);return J.actions["o="](l,i),c},"d= kv":function(l,i){l.d=i,l.dType="kv"},"charge or bond":function(l,i){if(l.beginsWithBond){var c=[];return J.concatArray(c,this.output(l)),J.concatArray(c,J.actions.bond(l,i,"-")),c}else l.d=i},"- after o/d":function(l,i,c){var d=J.patterns.match_("orbital",l.o||""),f=J.patterns.match_("one lowercase greek letter $",l.o||""),h=J.patterns.match_("one lowercase latin letter $",l.o||""),p=J.patterns.match_("$one lowercase latin letter$ $",l.o||""),x=i==="-"&&(d&&d.remainder===""||f||h||p);x&&!l.a&&!l.b&&!l.p&&!l.d&&!l.q&&!d&&h&&(l.o="$"+l.o+"$");var v=[];return x?(J.concatArray(v,this.output(l)),v.push({type_:"hyphen"})):(d=J.patterns.match_("digits",l.d||""),c&&d&&d.remainder===""?(J.concatArray(v,J.actions["d="](l,i)),J.concatArray(v,this.output(l))):(J.concatArray(v,this.output(l)),J.concatArray(v,J.actions.bond(l,i,"-")))),v},"a to o":function(l){l.o=l.a,l.a=void 0},"sb=true":function(l){l.sb=!0},"sb=false":function(l){l.sb=!1},"beginsWithBond=true":function(l){l.beginsWithBond=!0},"beginsWithBond=false":function(l){l.beginsWithBond=!1},"parenthesisLevel++":function(l){l.parenthesisLevel++},"parenthesisLevel--":function(l){l.parenthesisLevel--},"state of aggregation":function(l,i){return{type_:"state of aggregation",p1:J.go(i,"o")}},comma:function(l,i){var c=i.replace(/\s*$/,""),d=c!==i;return d&&l.parenthesisLevel===0?{type_:"comma enumeration L",p1:c}:{type_:"comma enumeration M",p1:c}},output:function(l,i,c){var d;if(!l.r)d=[],!l.a&&!l.b&&!l.p&&!l.o&&!l.q&&!l.d&&!c||(l.sb&&d.push({type_:"entitySkip"}),!l.o&&!l.q&&!l.d&&!l.b&&!l.p&&c!==2?(l.o=l.a,l.a=void 0):!l.o&&!l.q&&!l.d&&(l.b||l.p)?(l.o=l.a,l.d=l.b,l.q=l.p,l.a=l.b=l.p=void 0):l.o&&l.dType==="kv"&&J.patterns.match_("d-oxidation$",l.d||"")?l.dType="oxidation":l.o&&l.dType==="kv"&&!l.q&&(l.dType=void 0),d.push({type_:"chemfive",a:J.go(l.a,"a"),b:J.go(l.b,"bd"),p:J.go(l.p,"pq"),o:J.go(l.o,"o"),q:J.go(l.q,"pq"),d:J.go(l.d,l.dType==="oxidation"?"oxidation":"bd"),dType:l.dType}));else{var f;l.rdt==="M"?f=J.go(l.rd,"tex-math"):l.rdt==="T"?f=[{type_:"text",p1:l.rd||""}]:f=J.go(l.rd);var h;l.rqt==="M"?h=J.go(l.rq,"tex-math"):l.rqt==="T"?h=[{type_:"text",p1:l.rq||""}]:h=J.go(l.rq),d={type_:"arrow",r:l.r,rd:f,rq:h}}for(var p in l)p!=="parenthesisLevel"&&p!=="beginsWithBond"&&delete l[p];return d},"oxidation-output":function(l,i){var c=["{"];return J.concatArray(c,J.go(i,"oxidation")),c.push("}"),c},"frac-output":function(l,i){return{type_:"frac-ce",p1:J.go(i[0]),p2:J.go(i[1])}},"overset-output":function(l,i){return{type_:"overset",p1:J.go(i[0]),p2:J.go(i[1])}},"underset-output":function(l,i){return{type_:"underset",p1:J.go(i[0]),p2:J.go(i[1])}},"underbrace-output":function(l,i){return{type_:"underbrace",p1:J.go(i[0]),p2:J.go(i[1])}},"color-output":function(l,i){return{type_:"color",color1:i[0],color2:J.go(i[1])}},"r=":function(l,i){l.r=i},"rdt=":function(l,i){l.rdt=i},"rd=":function(l,i){l.rd=i},"rqt=":function(l,i){l.rqt=i},"rq=":function(l,i){l.rq=i},operator:function(l,i,c){return{type_:"operator",kind_:c||i}}}},a:{transitions:J.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:J.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:J.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(l){if(l.text_){var i={type_:"text",p1:l.text_};for(var c in l)delete l[c];return i}}}},pq:{transitions:J.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(l,i){return{type_:"state of aggregation subscript",p1:J.go(i,"o")}},"color-output":function(l,i){return{type_:"color",color1:i[0],color2:J.go(i[1],"pq")}}}},bd:{transitions:J.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(l,i){return{type_:"color",color1:i[0],color2:J.go(i[1],"bd")}}}},oxidation:{transitions:J.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(l,i){return{type_:"roman numeral",p1:i||""}}}},"tex-math":{transitions:J.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(l){if(l.o){var i={type_:"tex-math",p1:l.o};for(var c in l)delete l[c];return i}}}},"tex-math tight":{transitions:J.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(l,i){l.o=(l.o||"")+"{"+i+"}"},output:function(l){if(l.o){var i={type_:"tex-math",p1:l.o};for(var c in l)delete l[c];return i}}}},"9,9":{transitions:J.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:J.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(l,i){var c=[];return i[0]==="+-"||i[0]==="+/-"?c.push("\\pm "):i[0]&&c.push(i[0]),i[1]&&(J.concatArray(c,J.go(i[1],"pu-9,9")),i[2]&&(i[2].match(/[,.]/)?J.concatArray(c,J.go(i[2],"pu-9,9")):c.push(i[2])),i[3]=i[4]||i[3],i[3]&&(i[3]=i[3].trim(),i[3]==="e"||i[3].substr(0,1)==="*"?c.push({type_:"cdot"}):c.push({type_:"times"}))),i[3]&&c.push("10^{"+i[5]+"}"),c},"number^":function(l,i){var c=[];return i[0]==="+-"||i[0]==="+/-"?c.push("\\pm "):i[0]&&c.push(i[0]),J.concatArray(c,J.go(i[1],"pu-9,9")),c.push("^{"+i[2]+"}"),c},operator:function(l,i,c){return{type_:"operator",kind_:c||i}},space:function(){return{type_:"pu-space-1"}},output:function(l){var i,c=J.patterns.match_("{(...)}",l.d||"");c&&c.remainder===""&&(l.d=c.match_);var d=J.patterns.match_("{(...)}",l.q||"");if(d&&d.remainder===""&&(l.q=d.match_),l.d&&(l.d=l.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),l.d=l.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),l.q){l.q=l.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),l.q=l.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var f={d:J.go(l.d,"pu"),q:J.go(l.q,"pu")};l.o==="//"?i={type_:"pu-frac",p1:f.d,p2:f.q}:(i=f.d,f.d.length>1||f.q.length>1?i.push({type_:" / "}):i.push({type_:"/"}),J.concatArray(i,f.q))}else i=J.go(l.d,"pu-2");for(var h in l)delete l[h];return i}}},"pu-2":{transitions:J.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(l,i){l.rm+="^{"+i+"}"},space:function(){return{type_:"pu-space-2"}},output:function(l){var i=[];if(l.rm){var c=J.patterns.match_("{(...)}",l.rm||"");c&&c.remainder===""?i=J.go(c.match_,"pu"):i={type_:"rm",p1:l.rm}}for(var d in l)delete l[d];return i}}},"pu-9,9":{transitions:J.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(l){var i=[];if(l.text_=l.text_||"",l.text_.length>4){var c=l.text_.length%3;c===0&&(c=3);for(var d=l.text_.length-3;d>0;d-=3)i.push(l.text_.substr(d,3)),i.push({type_:"1000 separator"});i.push(l.text_.substr(0,c)),i.reverse()}else i.push(l.text_);for(var f in l)delete l[f];return i},"output-o":function(l){var i=[];if(l.text_=l.text_||"",l.text_.length>4){for(var c=l.text_.length-3,d=0;d<c;d+=3)i.push(l.text_.substr(d,3)),i.push({type_:"1000 separator"});i.push(l.text_.substr(d))}else i.push(l.text_);for(var f in l)delete l[f];return i}}}};var pt={go:function(l,i){if(!l)return"";for(var c="",d=!1,f=0;f<l.length;f++){var h=l[f];typeof h=="string"?c+=h:(c+=pt._go2(h),h.type_==="1st-level escape"&&(d=!0))}return!i&&!d&&c&&(c="{"+c+"}"),c},_goInner:function(l){return l&&pt.go(l,!0)},_go2:function(l){var i;switch(l.type_){case"chemfive":i="";var c={a:pt._goInner(l.a),b:pt._goInner(l.b),p:pt._goInner(l.p),o:pt._goInner(l.o),q:pt._goInner(l.q),d:pt._goInner(l.d)};c.a&&(c.a.match(/^[+\-]/)&&(c.a="{"+c.a+"}"),i+=c.a+"\\,"),(c.b||c.p)&&(i+="{\\vphantom{X}}",i+="^{\\hphantom{"+(c.b||"")+"}}_{\\hphantom{"+(c.p||"")+"}}",i+="{\\vphantom{X}}",i+="^{\\smash[t]{\\vphantom{2}}\\mathllap{"+(c.b||"")+"}}",i+="_{\\vphantom{2}\\mathllap{\\smash[t]{"+(c.p||"")+"}}}"),c.o&&(c.o.match(/^[+\-]/)&&(c.o="{"+c.o+"}"),i+=c.o),l.dType==="kv"?((c.d||c.q)&&(i+="{\\vphantom{X}}"),c.d&&(i+="^{"+c.d+"}"),c.q&&(i+="_{\\smash[t]{"+c.q+"}}")):l.dType==="oxidation"?(c.d&&(i+="{\\vphantom{X}}",i+="^{"+c.d+"}"),c.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+c.q+"}}")):(c.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+c.q+"}}"),c.d&&(i+="{\\vphantom{X}}",i+="^{"+c.d+"}"));break;case"rm":i="\\mathrm{"+l.p1+"}";break;case"text":l.p1.match(/[\^_]/)?(l.p1=l.p1.replace(" ","~").replace("-","\\text{-}"),i="\\mathrm{"+l.p1+"}"):i="\\text{"+l.p1+"}";break;case"roman numeral":i="\\mathrm{"+l.p1+"}";break;case"state of aggregation":i="\\mskip2mu "+pt._goInner(l.p1);break;case"state of aggregation subscript":i="\\mskip1mu "+pt._goInner(l.p1);break;case"bond":if(i=pt._getBond(l.kind_),!i)throw["MhchemErrorBond","mhchem Error. Unknown bond type ("+l.kind_+")"];break;case"frac":var d="\\frac{"+l.p1+"}{"+l.p2+"}";i="\\mathchoice{\\textstyle"+d+"}{"+d+"}{"+d+"}{"+d+"}";break;case"pu-frac":var f="\\frac{"+pt._goInner(l.p1)+"}{"+pt._goInner(l.p2)+"}";i="\\mathchoice{\\textstyle"+f+"}{"+f+"}{"+f+"}{"+f+"}";break;case"tex-math":i=l.p1+" ";break;case"frac-ce":i="\\frac{"+pt._goInner(l.p1)+"}{"+pt._goInner(l.p2)+"}";break;case"overset":i="\\overset{"+pt._goInner(l.p1)+"}{"+pt._goInner(l.p2)+"}";break;case"underset":i="\\underset{"+pt._goInner(l.p1)+"}{"+pt._goInner(l.p2)+"}";break;case"underbrace":i="\\underbrace{"+pt._goInner(l.p1)+"}_{"+pt._goInner(l.p2)+"}";break;case"color":i="{\\color{"+l.color1+"}{"+pt._goInner(l.color2)+"}}";break;case"color0":i="\\color{"+l.color+"}";break;case"arrow":var h={rd:pt._goInner(l.rd),rq:pt._goInner(l.rq)},p="\\x"+pt._getArrow(l.r);h.rq&&(p+="[{"+h.rq+"}]"),h.rd?p+="{"+h.rd+"}":p+="{}",i=p;break;case"operator":i=pt._getOperator(l.kind_);break;case"1st-level escape":i=l.p1+" ";break;case"space":i=" ";break;case"entitySkip":i="~";break;case"pu-space-1":i="~";break;case"pu-space-2":i="\\mkern3mu ";break;case"1000 separator":i="\\mkern2mu ";break;case"commaDecimal":i="{,}";break;case"comma enumeration L":i="{"+l.p1+"}\\mkern6mu ";break;case"comma enumeration M":i="{"+l.p1+"}\\mkern3mu ";break;case"comma enumeration S":i="{"+l.p1+"}\\mkern1mu ";break;case"hyphen":i="\\text{-}";break;case"addition compound":i="\\,{\\cdot}\\,";break;case"electron dot":i="\\mkern1mu \\bullet\\mkern1mu ";break;case"KV x":i="{\\times}";break;case"prime":i="\\prime ";break;case"cdot":i="\\cdot ";break;case"tight cdot":i="\\mkern1mu{\\cdot}\\mkern1mu ";break;case"times":i="\\times ";break;case"circa":i="{\\sim}";break;case"^":i="uparrow";break;case"v":i="downarrow";break;case"ellipsis":i="\\ldots ";break;case"/":i="/";break;case" / ":i="\\,/\\,";break;default:throw["MhchemBugT","mhchem bug T. Please report."]}return i},_getArrow:function(l){switch(l){case"->":return"rightarrow";case"→":return"rightarrow";case"⟶":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<-->":return"rightleftarrows";case"<=>":return"rightleftharpoons";case"⇌":return"rightleftharpoons";case"<=>>":return"rightequilibrium";case"<<=>":return"leftequilibrium";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(l){switch(l){case"-":return"{-}";case"1":return"{-}";case"=":return"{=}";case"2":return"{=}";case"#":return"{\\equiv}";case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}";case"~=":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";case"~--":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";case"-~-":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(l){switch(l){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":return" {}\\approx{} ";case"$\\approx$":return" {}\\approx{} ";case"v":return" \\downarrow{} ";case"(v)":return" \\downarrow{} ";case"^":return" \\uparrow{} ";case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}};function db(r){const l=r.trim().split(`
|
|
312
|
-
`);if(l.length<2)return!1;const i=l[0].trim();if(!i.startsWith("|")||(i.match(/\|/g)||[]).length<2)return!1;const c=l[1].trim();if(!c.startsWith("|")||!/^[\s|:|-]+$/.test(c)||!c.includes("-"))return!1;for(let d=2;d<l.length;d++){const f=l[d].trim();if(f!==""&&!f.startsWith("|"))return!1}return!0}function fb(
|
|
311
|
+
*/const ub=De("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"}]]);fd.__defineMacro("\\ce",function(s){return rg(s.consumeArgs(1)[0],"ce")});fd.__defineMacro("\\pu",function(s){return rg(s.consumeArgs(1)[0],"pu")});fd.__defineMacro("\\tripledash","{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");var rg=function(l,i){for(var c="",d=l.length&&l[l.length-1].loc.start,f=l.length-1;f>=0;f--)l[f].loc.start>d&&(c+=" ",d=l[f].loc.start),c+=l[f].text,d+=l[f].text.length;var h=pt.go(J.go(c,i));return h},J={go:function(l,i){if(!l)return[];i===void 0&&(i="ce");var c="0",d={};d.parenthesisLevel=0,l=l.replace(/\n/g," "),l=l.replace(/[\u2212\u2013\u2014\u2010]/g,"-"),l=l.replace(/[\u2026]/g,"...");for(var f,h=10,p=[];;){f!==l?(h=10,f=l):h--;var x=J.stateMachines[i],v=x.transitions[c]||x.transitions["*"];e:for(var b=0;b<v.length;b++){var w=J.patterns.match_(v[b].pattern,l);if(w){for(var k=v[b].task,S=0;S<k.action_.length;S++){var j;if(x.actions[k.action_[S].type_])j=x.actions[k.action_[S].type_](d,w.match_,k.action_[S].option);else if(J.actions[k.action_[S].type_])j=J.actions[k.action_[S].type_](d,w.match_,k.action_[S].option);else throw["MhchemBugA","mhchem bug A. Please report. ("+k.action_[S].type_+")"];J.concatArray(p,j)}if(c=k.nextState||c,l.length>0){if(k.revisit||(l=w.remainder),!k.toContinue)break e}else return p}}if(h<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(l,i){if(i)if(Array.isArray(i))for(var c=0;c<i.length;c++)l.push(i[c]);else l.push(i)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(l){var i=l.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return i&&i[0]?{match_:i.splice(1),remainder:l.substr(i[0].length)}:null},"(-)(9)^(-9)":function(l){var i=l.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);return i&&i[0]?{match_:i.splice(1),remainder:l.substr(i[0].length)}:null},"state of aggregation $":function(l){var i=J.patterns.findObserveGroups(l,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(i&&i.remainder.match(/^($|[\s,;\)\]\}])/))return i;var c=l.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return c?{match_:c[0],remainder:l.substr(c[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". ":/^([.\u22C5\u00B7\u2022])\s*/,"...":/^\.\.\.(?=$|[^.])/,"* ":/^([*])\s*/,"^{(...)}":function(l){return J.patterns.findObserveGroups(l,"^{","","","}")},"^($...$)":function(l){return J.patterns.findObserveGroups(l,"^","$","$","")},"^a":/^\^([0-9]+|[^\\_])/,"^\\x{}{}":function(l){return J.patterns.findObserveGroups(l,"^",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"^\\x{}":function(l){return J.patterns.findObserveGroups(l,"^",/^\\[a-zA-Z]+\{/,"}","")},"^\\x":/^\^(\\[a-zA-Z]+)\s*/,"^(-1)":/^\^(-?\d+)/,"'":/^'/,"_{(...)}":function(l){return J.patterns.findObserveGroups(l,"_{","","","}")},"_($...$)":function(l){return J.patterns.findObserveGroups(l,"_","$","$","")},_9:/^_([+\-]?[0-9]+|[^\\])/,"_\\x{}{}":function(l){return J.patterns.findObserveGroups(l,"_",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"_\\x{}":function(l){return J.patterns.findObserveGroups(l,"_",/^\\[a-zA-Z]+\{/,"}","")},"_\\x":/^_(\\[a-zA-Z]+)\s*/,"^_":/^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,"{}":/^\{\}/,"{...}":function(l){return J.patterns.findObserveGroups(l,"","{","}","")},"{(...)}":function(l){return J.patterns.findObserveGroups(l,"{","","","}")},"$...$":function(l){return J.patterns.findObserveGroups(l,"","$","$","")},"${(...)}$":function(l){return J.patterns.findObserveGroups(l,"${","","","}$")},"$(...)$":function(l){return J.patterns.findObserveGroups(l,"$","","","$")},"=<>":/^[=<>]/,"#":/^[#\u2261]/,"+":/^\+/,"-$":/^-(?=[\s_},;\]/]|$|\([a-z]+\))/,"-9":/^-(?=[0-9])/,"- orbital overlap":/^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,"-":/^-/,"pm-operator":/^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,operator:/^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,arrowUpDown:/^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,"\\bond{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\bond{","","","}")},"->":/^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,CMT:/^[CMT](?=\[)/,"[(...)]":function(l){return J.patterns.findObserveGroups(l,"[","","","]")},"1st-level escape":/^(&|\\\\|\\hline)\s*/,"\\,":/^(?:\\[,\ ;:])/,"\\x{}{}":function(l){return J.patterns.findObserveGroups(l,"",/^\\[a-zA-Z]+\{/,"}","","","{","}","",!0)},"\\x{}":function(l){return J.patterns.findObserveGroups(l,"",/^\\[a-zA-Z]+\{/,"}","")},"\\ca":/^\\ca(?:\s+|(?![a-zA-Z]))/,"\\x":/^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,orbital:/^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,others:/^[\/~|]/,"\\frac{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\frac{","","","}","{","","","}")},"\\overset{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\overset{","","","}","{","","","}")},"\\underset{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\underset{","","","}","{","","","}")},"\\underbrace{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\underbrace{","","","}_","{","","","}")},"\\color{(...)}0":function(l){return J.patterns.findObserveGroups(l,"\\color{","","","}")},"\\color{(...)}{(...)}1":function(l){return J.patterns.findObserveGroups(l,"\\color{","","","}","{","","","}")},"\\color(...){(...)}2":function(l){return J.patterns.findObserveGroups(l,"\\color","\\","",/^(?=\{)/,"{","","","}")},"\\ce{(...)}":function(l){return J.patterns.findObserveGroups(l,"\\ce{","","","}")},oxidation$:/^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"d-oxidation$":/^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,"roman numeral":/^[IVX]+/,"1/2$":/^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,amount:function(l){var i;if(i=l.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/),i)return{match_:i[0],remainder:l.substr(i[0].length)};var c=J.patterns.findObserveGroups(l,"","$","$","");return c&&(i=c.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/),i)?{match_:i[0],remainder:l.substr(i[0].length)}:null},amount2:function(l){return this.amount(l)},"(KV letters),":/^(?:[A-Z][a-z]{0,2}|i)(?=,)/,formula$:function(l){if(l.match(/^\([a-z]+\)$/))return null;var i=l.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);return i?{match_:i[0],remainder:l.substr(i[0].length)}:null},uprightEntities:/^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,"/":/^\s*(\/)\s*/,"//":/^\s*(\/\/)\s*/,"*":/^\s*[*.]\s*/},findObserveGroups:function(l,i,c,d,f,h,p,x,v,b){var w=function(Y,R){if(typeof R=="string")return Y.indexOf(R)!==0?null:R;var q=Y.match(R);return q?q[0]:null},k=function(Y,R,q){for(var N=0;R<Y.length;){var X=Y.charAt(R),U=w(Y.substr(R),q);if(U!==null&&N===0)return{endMatchBegin:R,endMatchEnd:R+U.length};if(X==="{")N++;else if(X==="}"){if(N===0)throw["ExtraCloseMissingOpen","Extra close brace or missing open brace"];N--}R++}return N>0,null},S=w(l,i);if(S===null||(l=l.substr(S.length),S=w(l,c),S===null))return null;var j=k(l,S.length,d||f);if(j===null)return null;var _=l.substring(0,d?j.endMatchEnd:j.endMatchBegin);if(h||p){var z=this.findObserveGroups(l.substr(j.endMatchEnd),h,p,x,v);if(z===null)return null;var $=[_,z.match_];return{match_:b?$.join(""):$,remainder:z.remainder}}else return{match_:_,remainder:l.substr(j.endMatchEnd)}},match_:function(l,i){var c=J.patterns.patterns[l];if(c===void 0)throw["MhchemBugP","mhchem bug P. Please report. ("+l+")"];if(typeof c=="function")return J.patterns.patterns[l](i);var d=i.match(c);if(d){var f;return d[2]?f=[d[1],d[2]]:d[1]?f=d[1]:f=d[0],{match_:f,remainder:i.substr(d[0].length)}}return null}},actions:{"a=":function(l,i){l.a=(l.a||"")+i},"b=":function(l,i){l.b=(l.b||"")+i},"p=":function(l,i){l.p=(l.p||"")+i},"o=":function(l,i){l.o=(l.o||"")+i},"q=":function(l,i){l.q=(l.q||"")+i},"d=":function(l,i){l.d=(l.d||"")+i},"rm=":function(l,i){l.rm=(l.rm||"")+i},"text=":function(l,i){l.text_=(l.text_||"")+i},insert:function(l,i,c){return{type_:c}},"insert+p1":function(l,i,c){return{type_:c,p1:i}},"insert+p1+p2":function(l,i,c){return{type_:c,p1:i[0],p2:i[1]}},copy:function(l,i){return i},rm:function(l,i){return{type_:"rm",p1:i||""}},text:function(l,i){return J.go(i,"text")},"{text}":function(l,i){var c=["{"];return J.concatArray(c,J.go(i,"text")),c.push("}"),c},"tex-math":function(l,i){return J.go(i,"tex-math")},"tex-math tight":function(l,i){return J.go(i,"tex-math tight")},bond:function(l,i,c){return{type_:"bond",kind_:c||i}},"color0-output":function(l,i){return{type_:"color0",color:i[0]}},ce:function(l,i){return J.go(i)},"1/2":function(l,i){var c=[];i.match(/^[+\-]/)&&(c.push(i.substr(0,1)),i=i.substr(1));var d=i.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);return d[1]=d[1].replace(/\$/g,""),c.push({type_:"frac",p1:d[1],p2:d[2]}),d[3]&&(d[3]=d[3].replace(/\$/g,""),c.push({type_:"tex-math",p1:d[3]})),c},"9,9":function(l,i){return J.go(i,"9,9")}},createTransitions:function(l){var i,c,d,f,h={};for(i in l)for(c in l[i])for(d=c.split("|"),l[i][c].stateArray=d,f=0;f<d.length;f++)h[d[f]]=[];for(i in l)for(c in l[i])for(d=l[i][c].stateArray||[],f=0;f<d.length;f++){var p=l[i][c];if(p.action_){p.action_=[].concat(p.action_);for(var x=0;x<p.action_.length;x++)typeof p.action_[x]=="string"&&(p.action_[x]={type_:p.action_[x]})}else p.action_=[];for(var v=i.split("|"),b=0;b<v.length;b++)if(d[f]==="*")for(var w in h)h[w].push({pattern:v[b],task:p});else h[d[f]].push({pattern:v[b],task:p})}return h},stateMachines:{}};J.stateMachines={ce:{transitions:J.createTransitions({empty:{"*":{action_:"output"}},else:{"0|1|2":{action_:"beginsWithBond=false",revisit:!0,toContinue:!0}},oxidation$:{0:{action_:"oxidation-output"}},CMT:{r:{action_:"rdt=",nextState:"rt"},rd:{action_:"rqt=",nextState:"rdt"}},arrowUpDown:{"0|1|2|as":{action_:["sb=false","output","operator"],nextState:"1"}},uprightEntities:{"0|1|2":{action_:["o=","output"],nextState:"1"}},orbital:{"0|1|2|3":{action_:"o=",nextState:"o"}},"->":{"0|1|2|3":{action_:"r=",nextState:"r"},"a|as":{action_:["output","r="],nextState:"r"},"*":{action_:["output","r="],nextState:"r"}},"+":{o:{action_:"d= kv",nextState:"d"},"d|D":{action_:"d=",nextState:"d"},q:{action_:"d=",nextState:"qd"},"qd|qD":{action_:"d=",nextState:"qd"},dq:{action_:["output","d="],nextState:"d"},3:{action_:["sb=false","output","operator"],nextState:"0"}},amount:{"0|2":{action_:"a=",nextState:"a"}},"pm-operator":{"0|1|2|a|as":{action_:["sb=false","output",{type_:"operator",option:"\\pm"}],nextState:"0"}},operator:{"0|1|2|a|as":{action_:["sb=false","output","operator"],nextState:"0"}},"-$":{"o|q":{action_:["charge or bond","output"],nextState:"qd"},d:{action_:"d=",nextState:"d"},D:{action_:["output",{type_:"bond",option:"-"}],nextState:"3"},q:{action_:"d=",nextState:"qd"},qd:{action_:"d=",nextState:"qd"},"qD|dq":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},"-9":{"3|o":{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"3"}},"- orbital overlap":{o:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},d:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"}},"-":{"0|1|2":{action_:[{type_:"output",option:1},"beginsWithBond=true",{type_:"bond",option:"-"}],nextState:"3"},3:{action_:{type_:"bond",option:"-"}},a:{action_:["output",{type_:"insert",option:"hyphen"}],nextState:"2"},as:{action_:[{type_:"output",option:2},{type_:"bond",option:"-"}],nextState:"3"},b:{action_:"b="},o:{action_:{type_:"- after o/d",option:!1},nextState:"2"},q:{action_:{type_:"- after o/d",option:!1},nextState:"2"},"d|qd|dq":{action_:{type_:"- after o/d",option:!0},nextState:"2"},"D|qD|p":{action_:["output",{type_:"bond",option:"-"}],nextState:"3"}},amount2:{"1|3":{action_:"a=",nextState:"a"}},letters:{"0|1|2|3|a|as|b|p|bp|o":{action_:"o=",nextState:"o"},"q|dq":{action_:["output","o="],nextState:"o"},"d|D|qd|qD":{action_:"o after d",nextState:"o"}},digits:{o:{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},q:{action_:["output","o="],nextState:"o"},a:{action_:"o=",nextState:"o"}},"space A":{"b|p|bp":{}},space:{a:{nextState:"as"},0:{action_:"sb=false"},"1|2":{action_:"sb=true"},"r|rt|rd|rdt|rdq":{action_:"output",nextState:"0"},"*":{action_:["output","sb=true"],nextState:"1"}},"1st-level escape":{"1|2":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}]},"*":{action_:["output",{type_:"insert+p1",option:"1st-level escape"}],nextState:"0"}},"[(...)]":{"r|rt":{action_:"rd=",nextState:"rd"},"rd|rdt":{action_:"rq=",nextState:"rdq"}},"...":{"o|d|D|dq|qd|qD":{action_:["output",{type_:"bond",option:"..."}],nextState:"3"},"*":{action_:[{type_:"output",option:1},{type_:"insert",option:"ellipsis"}],nextState:"1"}},". |* ":{"*":{action_:["output",{type_:"insert",option:"addition compound"}],nextState:"1"}},"state of aggregation $":{"*":{action_:["output","state of aggregation"],nextState:"1"}},"{[(":{"a|as|o":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"0|1|2|3":{action_:["o=","output","parenthesisLevel++"],nextState:"2"},"*":{action_:["output","o=","output","parenthesisLevel++"],nextState:"2"}},")]}":{"0|1|2|3|b|p|bp|o":{action_:["o=","parenthesisLevel--"],nextState:"o"},"a|as|d|D|q|qd|qD|dq":{action_:["output","o=","parenthesisLevel--"],nextState:"o"}},", ":{"*":{action_:["output","comma"],nextState:"0"}},"^_":{"*":{}},"^{(...)}|^($...$)":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"D"},q:{action_:"d=",nextState:"qD"},"d|D|qd|qD|dq":{action_:["output","d="],nextState:"D"}},"^a|^\\x{}{}|^\\x{}|^\\x|'":{"0|1|2|as":{action_:"b=",nextState:"b"},p:{action_:"b=",nextState:"bp"},"3|o":{action_:"d= kv",nextState:"d"},q:{action_:"d=",nextState:"qd"},"d|qd|D|qD":{action_:"d="},dq:{action_:["output","d="],nextState:"d"}},"_{(state of aggregation)}$":{"d|D|q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x":{"0|1|2|as":{action_:"p=",nextState:"p"},b:{action_:"p=",nextState:"bp"},"3|o":{action_:"q=",nextState:"q"},"d|D":{action_:"q=",nextState:"dq"},"q|qd|qD|dq":{action_:["output","q="],nextState:"q"}},"=<>":{"0|1|2|3|a|as|o|q|d|D|qd|qD|dq":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"#":{"0|1|2|3|a|as|o":{action_:[{type_:"output",option:2},{type_:"bond",option:"#"}],nextState:"3"}},"{}":{"*":{action_:{type_:"output",option:1},nextState:"1"}},"{...}":{"0|1|2|3|a|as|b|p|bp":{action_:"o=",nextState:"o"},"o|d|D|q|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"$...$":{a:{action_:"a="},"0|1|2|3|as|b|p|bp|o":{action_:"o=",nextState:"o"},"as|o":{action_:"o="},"q|d|D|qd|qD|dq":{action_:["output","o="],nextState:"o"}},"\\bond{(...)}":{"*":{action_:[{type_:"output",option:2},"bond"],nextState:"3"}},"\\frac{(...)}":{"*":{action_:[{type_:"output",option:1},"frac-output"],nextState:"3"}},"\\overset{(...)}":{"*":{action_:[{type_:"output",option:2},"overset-output"],nextState:"3"}},"\\underset{(...)}":{"*":{action_:[{type_:"output",option:2},"underset-output"],nextState:"3"}},"\\underbrace{(...)}":{"*":{action_:[{type_:"output",option:2},"underbrace-output"],nextState:"3"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:[{type_:"output",option:2},"color-output"],nextState:"3"}},"\\color{(...)}0":{"*":{action_:[{type_:"output",option:2},"color0-output"]}},"\\ce{(...)}":{"*":{action_:[{type_:"output",option:2},"ce"],nextState:"3"}},"\\,":{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"1"}},"\\x{}{}|\\x{}|\\x":{"0|1|2|3|a|as|b|p|bp|o|c0":{action_:["o=","output"],nextState:"3"},"*":{action_:["output","o=","output"],nextState:"3"}},others:{"*":{action_:[{type_:"output",option:1},"copy"],nextState:"3"}},else2:{a:{action_:"a to o",nextState:"o",revisit:!0},as:{action_:["output","sb=true"],nextState:"1",revisit:!0},"r|rt|rd|rdt|rdq":{action_:["output"],nextState:"0",revisit:!0},"*":{action_:["output","copy"],nextState:"3"}}}),actions:{"o after d":function(l,i){var c;if((l.d||"").match(/^[0-9]+$/)){var d=l.d;l.d=void 0,c=this.output(l),l.b=d}else c=this.output(l);return J.actions["o="](l,i),c},"d= kv":function(l,i){l.d=i,l.dType="kv"},"charge or bond":function(l,i){if(l.beginsWithBond){var c=[];return J.concatArray(c,this.output(l)),J.concatArray(c,J.actions.bond(l,i,"-")),c}else l.d=i},"- after o/d":function(l,i,c){var d=J.patterns.match_("orbital",l.o||""),f=J.patterns.match_("one lowercase greek letter $",l.o||""),h=J.patterns.match_("one lowercase latin letter $",l.o||""),p=J.patterns.match_("$one lowercase latin letter$ $",l.o||""),x=i==="-"&&(d&&d.remainder===""||f||h||p);x&&!l.a&&!l.b&&!l.p&&!l.d&&!l.q&&!d&&h&&(l.o="$"+l.o+"$");var v=[];return x?(J.concatArray(v,this.output(l)),v.push({type_:"hyphen"})):(d=J.patterns.match_("digits",l.d||""),c&&d&&d.remainder===""?(J.concatArray(v,J.actions["d="](l,i)),J.concatArray(v,this.output(l))):(J.concatArray(v,this.output(l)),J.concatArray(v,J.actions.bond(l,i,"-")))),v},"a to o":function(l){l.o=l.a,l.a=void 0},"sb=true":function(l){l.sb=!0},"sb=false":function(l){l.sb=!1},"beginsWithBond=true":function(l){l.beginsWithBond=!0},"beginsWithBond=false":function(l){l.beginsWithBond=!1},"parenthesisLevel++":function(l){l.parenthesisLevel++},"parenthesisLevel--":function(l){l.parenthesisLevel--},"state of aggregation":function(l,i){return{type_:"state of aggregation",p1:J.go(i,"o")}},comma:function(l,i){var c=i.replace(/\s*$/,""),d=c!==i;return d&&l.parenthesisLevel===0?{type_:"comma enumeration L",p1:c}:{type_:"comma enumeration M",p1:c}},output:function(l,i,c){var d;if(!l.r)d=[],!l.a&&!l.b&&!l.p&&!l.o&&!l.q&&!l.d&&!c||(l.sb&&d.push({type_:"entitySkip"}),!l.o&&!l.q&&!l.d&&!l.b&&!l.p&&c!==2?(l.o=l.a,l.a=void 0):!l.o&&!l.q&&!l.d&&(l.b||l.p)?(l.o=l.a,l.d=l.b,l.q=l.p,l.a=l.b=l.p=void 0):l.o&&l.dType==="kv"&&J.patterns.match_("d-oxidation$",l.d||"")?l.dType="oxidation":l.o&&l.dType==="kv"&&!l.q&&(l.dType=void 0),d.push({type_:"chemfive",a:J.go(l.a,"a"),b:J.go(l.b,"bd"),p:J.go(l.p,"pq"),o:J.go(l.o,"o"),q:J.go(l.q,"pq"),d:J.go(l.d,l.dType==="oxidation"?"oxidation":"bd"),dType:l.dType}));else{var f;l.rdt==="M"?f=J.go(l.rd,"tex-math"):l.rdt==="T"?f=[{type_:"text",p1:l.rd||""}]:f=J.go(l.rd);var h;l.rqt==="M"?h=J.go(l.rq,"tex-math"):l.rqt==="T"?h=[{type_:"text",p1:l.rq||""}]:h=J.go(l.rq),d={type_:"arrow",r:l.r,rd:f,rq:h}}for(var p in l)p!=="parenthesisLevel"&&p!=="beginsWithBond"&&delete l[p];return d},"oxidation-output":function(l,i){var c=["{"];return J.concatArray(c,J.go(i,"oxidation")),c.push("}"),c},"frac-output":function(l,i){return{type_:"frac-ce",p1:J.go(i[0]),p2:J.go(i[1])}},"overset-output":function(l,i){return{type_:"overset",p1:J.go(i[0]),p2:J.go(i[1])}},"underset-output":function(l,i){return{type_:"underset",p1:J.go(i[0]),p2:J.go(i[1])}},"underbrace-output":function(l,i){return{type_:"underbrace",p1:J.go(i[0]),p2:J.go(i[1])}},"color-output":function(l,i){return{type_:"color",color1:i[0],color2:J.go(i[1])}},"r=":function(l,i){l.r=i},"rdt=":function(l,i){l.rdt=i},"rd=":function(l,i){l.rd=i},"rqt=":function(l,i){l.rqt=i},"rq=":function(l,i){l.rq=i},operator:function(l,i,c){return{type_:"operator",kind_:c||i}}}},a:{transitions:J.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},"$(...)$":{"*":{action_:"tex-math tight",nextState:"1"}},",":{"*":{action_:{type_:"insert",option:"commaDecimal"}}},else2:{"*":{action_:"copy"}}}),actions:{}},o:{transitions:J.createTransitions({empty:{"*":{}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"1",revisit:!0}},letters:{"*":{action_:"rm"}},"\\ca":{"*":{action_:{type_:"insert",option:"circa"}}},"\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"{text}"}},else2:{"*":{action_:"copy"}}}),actions:{}},text:{transitions:J.createTransitions({empty:{"*":{action_:"output"}},"{...}":{"*":{action_:"text="}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"\\greek":{"*":{action_:["output","rm"]}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:["output","copy"]}},else:{"*":{action_:"text="}}}),actions:{output:function(l){if(l.text_){var i={type_:"text",p1:l.text_};for(var c in l)delete l[c];return i}}}},pq:{transitions:J.createTransitions({empty:{"*":{}},"state of aggregation $":{"*":{action_:"state of aggregation"}},i$:{0:{nextState:"!f",revisit:!0}},"(KV letters),":{0:{action_:"rm",nextState:"0"}},formula$:{0:{nextState:"f",revisit:!0}},"1/2$":{0:{action_:"1/2"}},else:{0:{nextState:"!f",revisit:!0}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"a-z":{f:{action_:"tex-math"}},letters:{"*":{action_:"rm"}},"-9.,9":{"*":{action_:"9,9"}},",":{"*":{action_:{type_:"insert+p1",option:"comma enumeration S"}}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"state of aggregation":function(l,i){return{type_:"state of aggregation subscript",p1:J.go(i,"o")}},"color-output":function(l,i){return{type_:"color",color1:i[0],color2:J.go(i[1],"pq")}}}},bd:{transitions:J.createTransitions({empty:{"*":{}},x$:{0:{nextState:"!f",revisit:!0}},formula$:{0:{nextState:"f",revisit:!0}},else:{0:{nextState:"!f",revisit:!0}},"-9.,9 no missing 0":{"*":{action_:"9,9"}},".":{"*":{action_:{type_:"insert",option:"electron dot"}}},"a-z":{f:{action_:"tex-math"}},x:{"*":{action_:{type_:"insert",option:"KV x"}}},letters:{"*":{action_:"rm"}},"'":{"*":{action_:{type_:"insert",option:"prime"}}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},"{(...)}":{"*":{action_:"text"}},"\\color{(...)}{(...)}1|\\color(...){(...)}2":{"*":{action_:"color-output"}},"\\color{(...)}0":{"*":{action_:"color0-output"}},"\\ce{(...)}":{"*":{action_:"ce"}},"\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"copy"}},else2:{"*":{action_:"copy"}}}),actions:{"color-output":function(l,i){return{type_:"color",color1:i[0],color2:J.go(i[1],"bd")}}}},oxidation:{transitions:J.createTransitions({empty:{"*":{}},"roman numeral":{"*":{action_:"roman-numeral"}},"${(...)}$|$(...)$":{"*":{action_:"tex-math"}},else:{"*":{action_:"copy"}}}),actions:{"roman-numeral":function(l,i){return{type_:"roman numeral",p1:i||""}}}},"tex-math":{transitions:J.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},else:{"*":{action_:"o="}}}),actions:{output:function(l){if(l.o){var i={type_:"tex-math",p1:l.o};for(var c in l)delete l[c];return i}}}},"tex-math tight":{transitions:J.createTransitions({empty:{"*":{action_:"output"}},"\\ce{(...)}":{"*":{action_:["output","ce"]}},"{...}|\\,|\\x{}{}|\\x{}|\\x":{"*":{action_:"o="}},"-|+":{"*":{action_:"tight operator"}},else:{"*":{action_:"o="}}}),actions:{"tight operator":function(l,i){l.o=(l.o||"")+"{"+i+"}"},output:function(l){if(l.o){var i={type_:"tex-math",p1:l.o};for(var c in l)delete l[c];return i}}}},"9,9":{transitions:J.createTransitions({empty:{"*":{}},",":{"*":{action_:"comma"}},else:{"*":{action_:"copy"}}}),actions:{comma:function(){return{type_:"commaDecimal"}}}},pu:{transitions:J.createTransitions({empty:{"*":{action_:"output"}},space$:{"*":{action_:["output","space"]}},"{[(|)]}":{"0|a":{action_:"copy"}},"(-)(9)^(-9)":{0:{action_:"number^",nextState:"a"}},"(-)(9.,9)(e)(99)":{0:{action_:"enumber",nextState:"a"}},space:{"0|a":{}},"pm-operator":{"0|a":{action_:{type_:"operator",option:"\\pm"},nextState:"0"}},operator:{"0|a":{action_:"copy",nextState:"0"}},"//":{d:{action_:"o=",nextState:"/"}},"/":{d:{action_:"o=",nextState:"/"}},"{...}|else":{"0|d":{action_:"d=",nextState:"d"},a:{action_:["space","d="],nextState:"d"},"/|q":{action_:"q=",nextState:"q"}}}),actions:{enumber:function(l,i){var c=[];return i[0]==="+-"||i[0]==="+/-"?c.push("\\pm "):i[0]&&c.push(i[0]),i[1]&&(J.concatArray(c,J.go(i[1],"pu-9,9")),i[2]&&(i[2].match(/[,.]/)?J.concatArray(c,J.go(i[2],"pu-9,9")):c.push(i[2])),i[3]=i[4]||i[3],i[3]&&(i[3]=i[3].trim(),i[3]==="e"||i[3].substr(0,1)==="*"?c.push({type_:"cdot"}):c.push({type_:"times"}))),i[3]&&c.push("10^{"+i[5]+"}"),c},"number^":function(l,i){var c=[];return i[0]==="+-"||i[0]==="+/-"?c.push("\\pm "):i[0]&&c.push(i[0]),J.concatArray(c,J.go(i[1],"pu-9,9")),c.push("^{"+i[2]+"}"),c},operator:function(l,i,c){return{type_:"operator",kind_:c||i}},space:function(){return{type_:"pu-space-1"}},output:function(l){var i,c=J.patterns.match_("{(...)}",l.d||"");c&&c.remainder===""&&(l.d=c.match_);var d=J.patterns.match_("{(...)}",l.q||"");if(d&&d.remainder===""&&(l.q=d.match_),l.d&&(l.d=l.d.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),l.d=l.d.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F")),l.q){l.q=l.q.replace(/\u00B0C|\^oC|\^{o}C/g,"{}^{\\circ}C"),l.q=l.q.replace(/\u00B0F|\^oF|\^{o}F/g,"{}^{\\circ}F");var f={d:J.go(l.d,"pu"),q:J.go(l.q,"pu")};l.o==="//"?i={type_:"pu-frac",p1:f.d,p2:f.q}:(i=f.d,f.d.length>1||f.q.length>1?i.push({type_:" / "}):i.push({type_:"/"}),J.concatArray(i,f.q))}else i=J.go(l.d,"pu-2");for(var h in l)delete l[h];return i}}},"pu-2":{transitions:J.createTransitions({empty:{"*":{action_:"output"}},"*":{"*":{action_:["output","cdot"],nextState:"0"}},"\\x":{"*":{action_:"rm="}},space:{"*":{action_:["output","space"],nextState:"0"}},"^{(...)}|^(-1)":{1:{action_:"^(-1)"}},"-9.,9":{0:{action_:"rm=",nextState:"0"},1:{action_:"^(-1)",nextState:"0"}},"{...}|else":{"*":{action_:"rm=",nextState:"1"}}}),actions:{cdot:function(){return{type_:"tight cdot"}},"^(-1)":function(l,i){l.rm+="^{"+i+"}"},space:function(){return{type_:"pu-space-2"}},output:function(l){var i=[];if(l.rm){var c=J.patterns.match_("{(...)}",l.rm||"");c&&c.remainder===""?i=J.go(c.match_,"pu"):i={type_:"rm",p1:l.rm}}for(var d in l)delete l[d];return i}}},"pu-9,9":{transitions:J.createTransitions({empty:{0:{action_:"output-0"},o:{action_:"output-o"}},",":{0:{action_:["output-0","comma"],nextState:"o"}},".":{0:{action_:["output-0","copy"],nextState:"o"}},else:{"*":{action_:"text="}}}),actions:{comma:function(){return{type_:"commaDecimal"}},"output-0":function(l){var i=[];if(l.text_=l.text_||"",l.text_.length>4){var c=l.text_.length%3;c===0&&(c=3);for(var d=l.text_.length-3;d>0;d-=3)i.push(l.text_.substr(d,3)),i.push({type_:"1000 separator"});i.push(l.text_.substr(0,c)),i.reverse()}else i.push(l.text_);for(var f in l)delete l[f];return i},"output-o":function(l){var i=[];if(l.text_=l.text_||"",l.text_.length>4){for(var c=l.text_.length-3,d=0;d<c;d+=3)i.push(l.text_.substr(d,3)),i.push({type_:"1000 separator"});i.push(l.text_.substr(d))}else i.push(l.text_);for(var f in l)delete l[f];return i}}}};var pt={go:function(l,i){if(!l)return"";for(var c="",d=!1,f=0;f<l.length;f++){var h=l[f];typeof h=="string"?c+=h:(c+=pt._go2(h),h.type_==="1st-level escape"&&(d=!0))}return!i&&!d&&c&&(c="{"+c+"}"),c},_goInner:function(l){return l&&pt.go(l,!0)},_go2:function(l){var i;switch(l.type_){case"chemfive":i="";var c={a:pt._goInner(l.a),b:pt._goInner(l.b),p:pt._goInner(l.p),o:pt._goInner(l.o),q:pt._goInner(l.q),d:pt._goInner(l.d)};c.a&&(c.a.match(/^[+\-]/)&&(c.a="{"+c.a+"}"),i+=c.a+"\\,"),(c.b||c.p)&&(i+="{\\vphantom{X}}",i+="^{\\hphantom{"+(c.b||"")+"}}_{\\hphantom{"+(c.p||"")+"}}",i+="{\\vphantom{X}}",i+="^{\\smash[t]{\\vphantom{2}}\\mathllap{"+(c.b||"")+"}}",i+="_{\\vphantom{2}\\mathllap{\\smash[t]{"+(c.p||"")+"}}}"),c.o&&(c.o.match(/^[+\-]/)&&(c.o="{"+c.o+"}"),i+=c.o),l.dType==="kv"?((c.d||c.q)&&(i+="{\\vphantom{X}}"),c.d&&(i+="^{"+c.d+"}"),c.q&&(i+="_{\\smash[t]{"+c.q+"}}")):l.dType==="oxidation"?(c.d&&(i+="{\\vphantom{X}}",i+="^{"+c.d+"}"),c.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+c.q+"}}")):(c.q&&(i+="{\\vphantom{X}}",i+="_{\\smash[t]{"+c.q+"}}"),c.d&&(i+="{\\vphantom{X}}",i+="^{"+c.d+"}"));break;case"rm":i="\\mathrm{"+l.p1+"}";break;case"text":l.p1.match(/[\^_]/)?(l.p1=l.p1.replace(" ","~").replace("-","\\text{-}"),i="\\mathrm{"+l.p1+"}"):i="\\text{"+l.p1+"}";break;case"roman numeral":i="\\mathrm{"+l.p1+"}";break;case"state of aggregation":i="\\mskip2mu "+pt._goInner(l.p1);break;case"state of aggregation subscript":i="\\mskip1mu "+pt._goInner(l.p1);break;case"bond":if(i=pt._getBond(l.kind_),!i)throw["MhchemErrorBond","mhchem Error. Unknown bond type ("+l.kind_+")"];break;case"frac":var d="\\frac{"+l.p1+"}{"+l.p2+"}";i="\\mathchoice{\\textstyle"+d+"}{"+d+"}{"+d+"}{"+d+"}";break;case"pu-frac":var f="\\frac{"+pt._goInner(l.p1)+"}{"+pt._goInner(l.p2)+"}";i="\\mathchoice{\\textstyle"+f+"}{"+f+"}{"+f+"}{"+f+"}";break;case"tex-math":i=l.p1+" ";break;case"frac-ce":i="\\frac{"+pt._goInner(l.p1)+"}{"+pt._goInner(l.p2)+"}";break;case"overset":i="\\overset{"+pt._goInner(l.p1)+"}{"+pt._goInner(l.p2)+"}";break;case"underset":i="\\underset{"+pt._goInner(l.p1)+"}{"+pt._goInner(l.p2)+"}";break;case"underbrace":i="\\underbrace{"+pt._goInner(l.p1)+"}_{"+pt._goInner(l.p2)+"}";break;case"color":i="{\\color{"+l.color1+"}{"+pt._goInner(l.color2)+"}}";break;case"color0":i="\\color{"+l.color+"}";break;case"arrow":var h={rd:pt._goInner(l.rd),rq:pt._goInner(l.rq)},p="\\x"+pt._getArrow(l.r);h.rq&&(p+="[{"+h.rq+"}]"),h.rd?p+="{"+h.rd+"}":p+="{}",i=p;break;case"operator":i=pt._getOperator(l.kind_);break;case"1st-level escape":i=l.p1+" ";break;case"space":i=" ";break;case"entitySkip":i="~";break;case"pu-space-1":i="~";break;case"pu-space-2":i="\\mkern3mu ";break;case"1000 separator":i="\\mkern2mu ";break;case"commaDecimal":i="{,}";break;case"comma enumeration L":i="{"+l.p1+"}\\mkern6mu ";break;case"comma enumeration M":i="{"+l.p1+"}\\mkern3mu ";break;case"comma enumeration S":i="{"+l.p1+"}\\mkern1mu ";break;case"hyphen":i="\\text{-}";break;case"addition compound":i="\\,{\\cdot}\\,";break;case"electron dot":i="\\mkern1mu \\bullet\\mkern1mu ";break;case"KV x":i="{\\times}";break;case"prime":i="\\prime ";break;case"cdot":i="\\cdot ";break;case"tight cdot":i="\\mkern1mu{\\cdot}\\mkern1mu ";break;case"times":i="\\times ";break;case"circa":i="{\\sim}";break;case"^":i="uparrow";break;case"v":i="downarrow";break;case"ellipsis":i="\\ldots ";break;case"/":i="/";break;case" / ":i="\\,/\\,";break;default:throw["MhchemBugT","mhchem bug T. Please report."]}return i},_getArrow:function(l){switch(l){case"->":return"rightarrow";case"→":return"rightarrow";case"⟶":return"rightarrow";case"<-":return"leftarrow";case"<->":return"leftrightarrow";case"<-->":return"rightleftarrows";case"<=>":return"rightleftharpoons";case"⇌":return"rightleftharpoons";case"<=>>":return"rightequilibrium";case"<<=>":return"leftequilibrium";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getBond:function(l){switch(l){case"-":return"{-}";case"1":return"{-}";case"=":return"{=}";case"2":return"{=}";case"#":return"{\\equiv}";case"3":return"{\\equiv}";case"~":return"{\\tripledash}";case"~-":return"{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}";case"~=":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";case"~--":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";case"-~-":return"{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}";case"...":return"{{\\cdot}{\\cdot}{\\cdot}}";case"....":return"{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";case"->":return"{\\rightarrow}";case"<-":return"{\\leftarrow}";case"<":return"{<}";case">":return"{>}";default:throw["MhchemBugT","mhchem bug T. Please report."]}},_getOperator:function(l){switch(l){case"+":return" {}+{} ";case"-":return" {}-{} ";case"=":return" {}={} ";case"<":return" {}<{} ";case">":return" {}>{} ";case"<<":return" {}\\ll{} ";case">>":return" {}\\gg{} ";case"\\pm":return" {}\\pm{} ";case"\\approx":return" {}\\approx{} ";case"$\\approx$":return" {}\\approx{} ";case"v":return" \\downarrow{} ";case"(v)":return" \\downarrow{} ";case"^":return" \\uparrow{} ";case"(^)":return" \\uparrow{} ";default:throw["MhchemBugT","mhchem bug T. Please report."]}}};function db(s){const l=s.trim().split(`
|
|
312
|
+
`);if(l.length<2)return!1;const i=l[0].trim();if(!i.startsWith("|")||(i.match(/\|/g)||[]).length<2)return!1;const c=l[1].trim();if(!c.startsWith("|")||!/^[\s|:|-]+$/.test(c)||!c.includes("-"))return!1;for(let d=2;d<l.length;d++){const f=l[d].trim();if(f!==""&&!f.startsWith("|"))return!1}return!0}function fb(s){return s.replace(/(^|\n)(```|~~~)\s*\n([\s\S]*?)\n\2(\n|$)/g,(l,i,c,d,f)=>db(d)?`${i}
|
|
313
313
|
${d.trim()}
|
|
314
|
-
${f}`:l)}function mb(
|
|
314
|
+
${f}`:l)}function mb(s){const l={};let i=0;return s=s.replace(/\$\$([\s\S]*?)\$\$/g,(c,d)=>{const f=`__DISPLAY_MATH_${i++}__`;return l[f]=`$$${d}$$`,f}),s=s.replace(/\\\[([\s\S]*?)\\\]/g,(c,d)=>{const f=`__DISPLAY_MATH_${i++}__`;return l[f]=`$$${d}$$`,f}),s=s.replace(/\\\(([\s\S]*?)\\\)/g,(c,d)=>{const f=`__INLINE_MATH_${i++}__`;return l[f]=`$${d}$`,f}),s=s.replace(/(^|\n)(```|~~~)([^\n]*)\n([\s\S]*?)\n\2(\n|$)/g,(c,d,f,h,p,x)=>{const v=`__FENCED_CODE_${i++}__`;return l[v]=`${d}${f}${h}
|
|
315
315
|
${p}
|
|
316
|
-
${f}${x}`,v}),
|
|
316
|
+
${f}${x}`,v}),s=s.replace(/`([^`]+)`/g,c=>{const d=`__INLINE_CODE_${i++}__`;return l[d]=c,d}),{masked:s,masks:l}}function hb(s){const l={};let i=0;return s=s.replace(new RegExp("(?<!\\$)\\$(?!\\$)([^$\\n]+?)(?<!\\$)\\$(?!\\$)","g"),(c,d)=>{const f=d.trim();if(/^-?\d{1,3}(?:,\d{3})*(?:\.\d+)?(?:\s?[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion)?$/.test(f))return c;const p=`__INLINE_MATH_${i++}__`;return l[p]=`$${d}$`,p}),{masked:s,masks:l}}const fp=/\\(?: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 pb(s){const l=/(__INLINE_MATH_\d+__|__DISPLAY_MATH_\d+__|__CURRENCY_\d+__)/g,i=/^(__INLINE_MATH_\d+__|__DISPLAY_MATH_\d+__|__CURRENCY_\d+__)$/;return s.split(`
|
|
317
317
|
`).map(c=>fp.test(c)?c.split(l).map(d=>!d||i.test(d)||!fp.test(d)||d.includes("$")?d:d.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,f=>{const h=f.trimEnd();return h?`$${h}$${f.slice(h.length)}`:f})).join(""):c).join(`
|
|
318
|
-
`)}function gb(
|
|
318
|
+
`)}function gb(s){return s.replace(/\$([^$\n]*?)\s*=\s*\$([^$\n]+)\$\s*([^$\n]*?)\$/g,(l,i,c,d)=>{const f=String(i).trimEnd(),h=String(c).trim(),p=String(d).trim(),x=[h,p].filter(Boolean).join(" ");return`$${f} = ${x}$`})}function xb(s){const l=s.split(`
|
|
319
319
|
`);for(let c=0;c<l.length-1;c++){const d=l[c],f=l[c+1]??"";if(!d||!f)continue;const h=f.trim();if(!(h.startsWith("|")&&h.includes("-")))continue;const x=d.indexOf("|");if(x<=0)continue;const v=d.slice(0,x);if(!v||v.trim()==="")continue;const b=v.trim(),w=b.replace(/\s+/g,""),k=w!==""&&/^[>]+$/.test(w),S=/^[-*+]\s*$/.test(b),j=/^\d+\.\s*$/.test(b);if(k||S||j)continue;const _=d.slice(x);if((_.match(/\|/g)||[]).length<2)continue;const $=v.replace(/\s+$/,""),ee=_.replace(/^\s+/,"");$&&(l.splice(c,1,$,ee),c++)}const i=[];for(let c=0;c<l.length;c++){const d=l[c],f=d.trim(),p=(l[c+1]??"").trim();f.startsWith("|")&&(f.match(/\|/g)||[]).length>=2&&p.startsWith("|")&&/^[\s|:-]+$/.test(p)&&p.includes("-")&&i.length>0&&i[i.length-1].trim()!==""&&i.push(""),i.push(d)}return i.join(`
|
|
320
|
-
`)}const mp=["aligned","align","align*","array","cases","pmatrix","bmatrix","vmatrix","Vmatrix","matrix","smallmatrix","gather","gather*","multline","multline*","split","flalign","flalign*","eqnarray","equation","equation*"];function bb(
|
|
320
|
+
`)}const mp=["aligned","align","align*","array","cases","pmatrix","bmatrix","vmatrix","Vmatrix","matrix","smallmatrix","gather","gather*","multline","multline*","split","flalign","flalign*","eqnarray","equation","equation*"];function bb(s,l){let i=0,c=`__${l}_${i}__`;for(;Object.prototype.hasOwnProperty.call(s,c);)i++,c=`__${l}_${i}__`;return c}function yb(s,l){if(!mp.length)return s;const i=mp.join("|"),c=new RegExp(String.raw`\\begin\{(${i})\}([\s\S]*?)\\end\{\1\}`,"g");return s.replace(c,(d,f,h,p,x)=>{const v=x.slice(0,p),b=x.slice(p+d.length),w=/(\$\$|\\\[)\s*$/.test(v),k=/^\s*(\$\$|\\\])/.test(b);if(w&&k)return d;const S=v.lastIndexOf("\\["),j=v.lastIndexOf("\\]");if(S>j&&S!==-1&&/\\]/.test(b))return d;const z=/\$\$/g;let $=0;for(;z.exec(v)!==null;)$++;if($%2===1&&/\$\$/.test(b))return d;if((v.replace(/\$\$/g,"__DD__").replace(/\\\$/g,"__ES__").match(/\$/g)||[]).length%2===1){const I=b.replace(/\$\$/g,"__DD__").replace(/\\\$/g,"__ES__");if(/^[^$]*\$(?!\$)/.test(I))return d}const X=bb(l,"LATEX_ENV"),U=d.trim();return l[X]=`
|
|
321
321
|
$$
|
|
322
322
|
${U}
|
|
323
323
|
$$
|
|
324
|
-
`,X})}function vb(
|
|
324
|
+
`,X})}function vb(s,l){for(const[i,c]of Object.entries(l)){const d=new RegExp(i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");s=s.replace(d,()=>c)}return s}const wb=s=>{if(!s||typeof s!="string")return"";try{let l=s.replace(/\r\n/g,`
|
|
325
325
|
`).replace(/\r/g,`
|
|
326
326
|
`);l=fb(l);const{masked:i,masks:c}=mb(l);l=i,l=l.replace(/<br\s*\/?>/gi,`
|
|
327
327
|
`),l=l.replace(/\\(ne|neq)\$(?=\s*[-+0-9A-Za-z(])/g,"\\$1"),l=gb(l),l=xb(l),l=yb(l,c);const d=new Map;let f=0;const h=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))?`,p=new RegExp(String.raw`(${h})(\s?[–-]\s?)(${h})`,"g");l=l.replace(p,(k,S,j,_)=>{const z=`__CURRENCY_${f++}__`,$=`__CURRENCY_${f++}__`;return d.set(z,S),d.set($,_),`${z}${j}${$}`});const x=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");l=l.replace(x,(k,S,j)=>{if(j.substring(S+k.length).match(/^[a-zA-Z]/)&&!k.match(/[KMBkmb]|[Kk]ilo|[Mm]illion|[Bb]illion$/))return k;const z=`__CURRENCY_${f++}__`;return d.set(z,k),z});const{masked:v,masks:b}=hb(l);return l=v,Object.assign(c,b),l=pb(l),[/(?:^|\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(k=>{l=l.replace(k,(S,j)=>{if(S.includes("$")||S.includes("__INLINE_MATH_")||S.includes("__DISPLAY_MATH_")||S.includes("__CURRENCY_"))return S;const _=String(j??"").trim();if(/^[A-Za-z]$/.test(_))return S;const z=/[\\^_+=<>]|\\b(?:frac|sqrt|sum|int|lim|log|ln|sin|cos|tan|exp)\b/.test(_),$=/\d/.test(_),ee=/[()]/.test(_),Y=(_.match(/[A-Z]/g)||[]).length,R=(_.match(/[a-z]/g)||[]).length,q=Y>=2,N=$||ee||q&&R>0;return!z&&!N?S:S.replace(j,`$${j}$`)})}),l=l.replace(new RegExp("(?<!\\\\)\\$(?!\\$)([^$\\n]*?)(?<!\\\\)\\$(?!\\$)","g"),(k,S)=>{if(k.includes("__CURRENCY_")||k.includes("__INLINE_MATH_")||k.includes("__DISPLAY_MATH_")||S.trim()==="")return k;const j=/^\d+(?:,\d{3})*(?:\.\d{2})?$/.test(S.trim()),_=/\\/.test(S),z=/[+\-*/=<>^_{}()]/.test(S),$=/[a-zA-Z].*\d|\d.*[a-zA-Z]/.test(S),ee=/\\(?:alpha|beta|gamma|delta|epsilon|theta|lambda|mu|pi|sigma|omega)/.test(S),Y=/\\(?:frac|sqrt|sum|int|lim|log|ln|sin|cos|tan|exp)/.test(S),R=/^[A-Za-z]$/.test(S.trim());return!j&&(_||z||$||ee||Y||R||S.length>1)?k:`\\$${S}\\$`}),l=l.split(`
|
|
328
328
|
`).map(k=>{const S=k.indexOf("$$");return S===-1||k.trim()==="$$"||k.indexOf("$$",S+2)!==-1?k:k.replace("$$","\\$\\$")}).join(`
|
|
329
329
|
`),d.forEach((k,S)=>{const j=k.replace(/\$/g,"$");l=l.replace(new RegExp(S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),j)}),l=l.replace(/\\$/g,"$"),l=vb(l,c),l=l.trimEnd()+`
|
|
330
|
-
`,l}catch(l){return console.warn("Error preprocessing markdown:",l),r}},Sb={'code[class*="language-"]':{color:"#393A34",fontFamily:'"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",fontSize:".9em",lineHeight:"1.2em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#393A34",fontFamily:'"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",fontSize:".9em",lineHeight:"1.2em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",border:"1px solid #dddddd",backgroundColor:"white"},'pre > code[class*="language-"]':{fontSize:"1em"},'pre[class*="language-"]::-moz-selection':{background:"#C1DEF1"},'pre[class*="language-"] ::-moz-selection':{background:"#C1DEF1"},'code[class*="language-"]::-moz-selection':{background:"#C1DEF1"},'code[class*="language-"] ::-moz-selection':{background:"#C1DEF1"},'pre[class*="language-"]::selection':{background:"#C1DEF1"},'pre[class*="language-"] ::selection':{background:"#C1DEF1"},'code[class*="language-"]::selection':{background:"#C1DEF1"},'code[class*="language-"] ::selection':{background:"#C1DEF1"},':not(pre) > code[class*="language-"]':{padding:".2em",paddingTop:"1px",paddingBottom:"1px",background:"#f8f8f8",border:"1px solid #dddddd"},comment:{color:"#008000",fontStyle:"italic"},prolog:{color:"#008000",fontStyle:"italic"},doctype:{color:"#008000",fontStyle:"italic"},cdata:{color:"#008000",fontStyle:"italic"},namespace:{Opacity:".7"},string:{color:"#A31515"},punctuation:{color:"#393A34"},operator:{color:"#393A34"},url:{color:"#36acaa"},symbol:{color:"#36acaa"},number:{color:"#36acaa"},boolean:{color:"#36acaa"},variable:{color:"#36acaa"},constant:{color:"#36acaa"},inserted:{color:"#36acaa"},atrule:{color:"#0000ff"},keyword:{color:"#0000ff"},"attr-value":{color:"#0000ff"},".language-autohotkey .token.selector":{color:"#0000ff"},".language-json .token.boolean":{color:"#0000ff"},".language-json .token.number":{color:"#0000ff"},'code[class*="language-css"]':{color:"#0000ff"},function:{color:"#393A34"},deleted:{color:"#9a050f"},".language-autohotkey .token.tag":{color:"#9a050f"},selector:{color:"#800000"},".language-autohotkey .token.keyword":{color:"#00009f"},important:{color:"#e90",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},"class-name":{color:"#2B91AF"},".language-json .token.property":{color:"#2B91AF"},tag:{color:"#800000"},"attr-name":{color:"#ff0000"},property:{color:"#ff0000"},regex:{color:"#ff0000"},entity:{color:"#ff0000"},"directive.tag.tag":{background:"#ffff00",color:"#393A34"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"#a5a5a5"},".line-numbers .line-numbers-rows > span:before":{color:"#2B91AF"},".line-highlight.line-highlight":{background:"linear-gradient(to right, rgba(193, 222, 241, 0.2) 70%, rgba(221, 222, 241, 0))"}},kb={'pre[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",background:"#1e1e1e"},'code[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'pre[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},':not(pre) > code[class*="language-"]':{padding:".1em .3em",borderRadius:".3em",color:"#db4c69",background:"#1e1e1e"},".namespace":{Opacity:".7"},"doctype.doctype-tag":{color:"#569CD6"},"doctype.name":{color:"#9cdcfe"},comment:{color:"#6a9955"},prolog:{color:"#6a9955"},punctuation:{color:"#d4d4d4"},".language-html .language-css .token.punctuation":{color:"#d4d4d4"},".language-html .language-javascript .token.punctuation":{color:"#d4d4d4"},property:{color:"#9cdcfe"},tag:{color:"#569cd6"},boolean:{color:"#569cd6"},number:{color:"#b5cea8"},constant:{color:"#9cdcfe"},symbol:{color:"#b5cea8"},inserted:{color:"#b5cea8"},unit:{color:"#b5cea8"},selector:{color:"#d7ba7d"},"attr-name":{color:"#9cdcfe"},string:{color:"#ce9178"},char:{color:"#ce9178"},builtin:{color:"#ce9178"},deleted:{color:"#ce9178"},".language-css .token.string.url":{textDecoration:"underline"},operator:{color:"#d4d4d4"},entity:{color:"#569cd6"},"operator.arrow":{color:"#569CD6"},atrule:{color:"#ce9178"},"atrule.rule":{color:"#c586c0"},"atrule.url":{color:"#9cdcfe"},"atrule.url.function":{color:"#dcdcaa"},"atrule.url.punctuation":{color:"#d4d4d4"},keyword:{color:"#569CD6"},"keyword.module":{color:"#c586c0"},"keyword.control-flow":{color:"#c586c0"},function:{color:"#dcdcaa"},"function.maybe-class-name":{color:"#dcdcaa"},regex:{color:"#d16969"},important:{color:"#569cd6"},italic:{fontStyle:"italic"},"class-name":{color:"#4ec9b0"},"maybe-class-name":{color:"#4ec9b0"},console:{color:"#9cdcfe"},parameter:{color:"#9cdcfe"},interpolation:{color:"#9cdcfe"},"punctuation.interpolation-punctuation":{color:"#569cd6"},variable:{color:"#9cdcfe"},"imports.maybe-class-name":{color:"#9cdcfe"},"exports.maybe-class-name":{color:"#9cdcfe"},escape:{color:"#d7ba7d"},"tag.punctuation":{color:"#808080"},cdata:{color:"#808080"},"attr-value":{color:"#ce9178"},"attr-value.punctuation":{color:"#ce9178"},"attr-value.punctuation.attr-equals":{color:"#d4d4d4"},namespace:{color:"#4ec9b0"},'pre[class*="language-javascript"]':{color:"#9cdcfe"},'code[class*="language-javascript"]':{color:"#9cdcfe"},'pre[class*="language-jsx"]':{color:"#9cdcfe"},'code[class*="language-jsx"]':{color:"#9cdcfe"},'pre[class*="language-typescript"]':{color:"#9cdcfe"},'code[class*="language-typescript"]':{color:"#9cdcfe"},'pre[class*="language-tsx"]':{color:"#9cdcfe"},'code[class*="language-tsx"]':{color:"#9cdcfe"},'pre[class*="language-css"]':{color:"#ce9178"},'code[class*="language-css"]':{color:"#ce9178"},'pre[class*="language-html"]':{color:"#d4d4d4"},'code[class*="language-html"]':{color:"#d4d4d4"},".language-regex .token.anchor":{color:"#dcdcaa"},".language-html .token.punctuation":{color:"#808080"},'pre[class*="language-"] > code[class*="language-"]':{position:"relative",zIndex:"1"},".line-highlight.line-highlight":{background:"#f7ebc6",boxShadow:"inset 5px 0 0 #f7d87c",zIndex:"0"}},_b=g.lazy(()=>En(()=>import("./MermaidRenderer-DNbuWll0.js").then(r=>r.au),__vite__mapDeps([0,1,2,3,4])).then(r=>({default:r.MermaidRenderer}))),Ab=g.lazy(()=>En(()=>import("./SVGRenderer-DAIMVJgr.js"),__vite__mapDeps([5,1,3])).then(r=>({default:r.SVGRenderer}))),Cb=g.lazy(()=>En(()=>import("./ChartRenderer-CFvbvH-N.js"),__vite__mapDeps([6,1,4,7,8,9,10,11,12,13,2,14])).then(r=>({default:r.ChartRenderer}))),jb=g.lazy(()=>En(()=>import("./MusicRenderer-DW6lysGY.js"),__vite__mapDeps([15,2,1])).then(r=>({default:r.MusicRenderer}))),Nb=r=>{var c,d;if(!r)return typeof window<"u"&&((c=window.matchMedia)!=null&&c.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light";const l=r.closest(".markdown-content");if(l){if(l.classList.contains("dark"))return"dark";if(l.classList.contains("light"))return"light"}if(r.closest(".dark"))return"dark";if(r.closest(".light"))return"light";const i=r.closest("[data-theme]");if(i){const f=i.getAttribute("data-theme");if(f==="dark")return"dark";if(f==="light")return"light"}return typeof window<"u"&&((d=window.matchMedia)!=null&&d.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},Tb=(r,l)=>{const[i,c]=g.useState("light"),d=g.useRef("light");return g.useEffect(()=>{var v,b,w;if(l||typeof window>"u"||typeof document>"u")return;const f=()=>{const k=Nb(r.current);k!==d.current&&(d.current=k,c(k))};f();const h=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-color-scheme: dark)"))??null,p=()=>f();h==null||h.addEventListener("change",p);const x=typeof MutationObserver<"u"?new MutationObserver(()=>f()):null;if(x){const k=((w=(b=r.current)==null?void 0:b.closest)==null?void 0:w.call(b,".markdown-content"))??null;k&&x.observe(k,{attributes:!0,attributeFilter:["class","data-theme"]}),document.body&&x.observe(document.body,{attributes:!0,attributeFilter:["class","data-theme"]})}return()=>{h==null||h.removeEventListener("change",p),x==null||x.disconnect()}},[l,r]),l??i},Eb={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"},Mb=r=>{if(!r)return"";const l=r.match(/(?:^|\s)language-([^\s]+)/);if(!l)return"";const c=l[1].toLowerCase().split("{")[0].split("[")[0].split("<")[0].split(":")[0].trim().replace(/[^a-z0-9+#-]+$/g,"");return c?Eb[c]??c:""},zb=r=>Tn.Children.toArray(r).map(l=>typeof l=="string"||typeof l=="number"?String(l):"").join("").replace(/\n$/,""),hp=({code:r})=>{const[l,i]=g.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(r),i(!0),setTimeout(()=>i(!1),2e3)}catch{const d=document.createElement("textarea");d.value=r,d.style.position="fixed",d.style.opacity="0",document.body.appendChild(d),d.select();try{document.execCommand("copy"),i(!0),setTimeout(()=>i(!1),2e3)}catch(f){console.error("Failed to copy code:",f)}document.body.removeChild(d)}};return u.jsxs("button",{className:"code-copy-button",onClick:c,title:l?"Copied!":"Copy code","aria-label":l?"Copied!":"Copy code to clipboard",children:[l?u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.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"}),u.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"}),u.jsx("path",{d:"M9.5 6.5L13.5 2.5L9.5 2.5V6.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{className:"code-copy-button-text",children:l?"Copied!":"Copy"})]})},Db=({inline:r,className:l="",children:i,enableGraphs:c=!0,enableMermaid:d=!0,enableSVG:f=!0,enableCharts:h=!0,enableMusic:p=!0,enableSyntaxHighlighting:x=!0,syntaxTheme:v})=>{const b=g.useRef(null),w=Tb(b,v),k=u.jsx("div",{className:"markdown-code-block code-block-container",children:"Loading renderer..."});if(r)return u.jsx("code",{className:l,children:i});const S=Mb(l),j=zb(i);if(h&&(S==="chart"||S==="chart-json"||S==="chart-table"))return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Cb,{code:j,language:S})})});if(p&&(S==="abc"||S==="music"))return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(jb,{code:j})})});if(c){if(S==="mermaid"&&d)return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(_b,{code:j})})});if(S==="svg"&&f)return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Ab,{code:j})})})}if(x&&S){const _=w==="light"?Sb:kb;return u.jsxs("div",{ref:b,className:"syntax-highlighted-wrapper code-block-container",children:[u.jsx(hp,{code:j}),u.jsx(bx,{language:S,style:_,customStyle:{margin:"12px 0",borderRadius:"6px",fontSize:"0.9em"},showLineNumbers:!1,children:j})]})}return u.jsxs("div",{ref:b,className:`markdown-code-block code-block-container ${l}`.trim(),children:[u.jsx(hp,{code:j}),u.jsx("pre",{style:{margin:0,padding:0,background:"transparent",border:"none"},children:u.jsx("code",{children:j})})]})},pp=new Set(["div","pre","blockquote","ul","ol","table","thead","tbody","tr","td","th","h1","h2","h3","h4","h5","h6","section","article","figure"]),Lb=({children:r,href:l="",className:i="",...c})=>{const d=Tn.Children.toArray(r).map(b=>typeof b=="string"?b:"").join("").trim(),f=/^https?:\/\//i.test(l),h=!!(f&&d&&gp(d)===gp(l)),p=f?Rb(l):null,x=!!(h&&p),v=["markdown-link",x?"markdown-link--card":"markdown-link--inline",i].filter(Boolean).join(" ");return u.jsxs("a",{...c,href:l,target:"_blank",rel:"noopener noreferrer",className:v,children:[u.jsx("span",{className:"markdown-link__content",children:x&&p?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"markdown-link__hostname",children:p.hostname}),p.path&&p.path!=="/"&&u.jsx("span",{className:"markdown-link__path",children:p.path})]}):r}),f&&u.jsx("span",{className:"markdown-link__icon","aria-hidden":"true",children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M8 16L16 8M16 8H9M16 8V15",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})};function gp(r){return r.trim().replace(/\/$/,"")}function Rb(r){try{const l=new URL(r),i=l.hostname.replace(/^www\./i,""),c=`${l.pathname}${l.search}${l.hash}`||"/";return{hostname:i,path:c}}catch{return null}}const el=({content:r,className:l="",disableMath:i=!1,enableGraphs:c=!0,enableMermaid:d=!0,enableSVG:f=!0,enableCharts:h=!0,enableMusic:p=!0,enableSyntaxHighlighting:x=!0,syntaxTheme:v="dark"})=>{const b=wb(r);if(!b)return null;const w=i?[ap]:[ap,[gx,{singleDollarTextMath:!0}]],k=[];i||k.push([xx,{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 S={table:({children:j,..._})=>u.jsx("div",{style:{overflowX:"auto",WebkitOverflowScrolling:"touch"},children:u.jsx("table",{..._,children:j})}),a:Lb,code:j=>{const{className:_,children:z,...$}=j,ee=_&&/language-/.test(_),Y="inline"in j&&typeof j.inline=="boolean"&&j.inline||!ee,R=ee;return u.jsx(Db,{inline:Y,className:_,enableGraphs:c,enableMermaid:d,enableSVG:f,enableCharts:h,enableMusic:p,enableSyntaxHighlighting:x,syntaxTheme:v,"data-block-code":R?"true":void 0,...$,children:z})},p:({node:j,..._})=>{var Y;const $=Tn.Children.toArray(_.children).filter(R=>!(typeof R=="string"&&R.trim()==="")).some(R=>{if(!Tn.isValidElement(R))return!1;const q=R.props;return(q==null?void 0:q["data-block-code"])==="true"?!0:typeof R.type=="string"?pp.has(R.type):!1}),ee=(Y=j==null?void 0:j.children)==null?void 0:Y.some(R=>{var q;if(R.type==="code")return!0;if(R.type==="element"){if(R.tagName&&pp.has(R.tagName))return!0;if(R.tagName==="code"){const N=(q=R.properties)==null?void 0:q.className;return Array.isArray(N)?N.some(X=>typeof X=="string"&&X.startsWith("language-")):!0}}return!1});return $||ee?u.jsx(u.Fragment,{children:_.children}):u.jsx("p",{..._})}};return u.jsx("div",{className:`markdown-content ${l}`,children:u.jsx(px,{remarkPlugins:w,rehypePlugins:k,components:S,children:b})})};var Ub={agentMode:{mode:"multi",defaultAdapterId:"chat-with-files"},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:null},seo:{includeSitemap:!1,siteUrl:"http://localhost:5173",exposeAgentNotes:!0},debug:{consoleDebug:!1},features:{enableUpload:!0,enableAudioOutput:!0,enableAudioInput:!0,enableFeedbackButtons:!0,enableConversationThreads:!0,enableAutocomplete:!0},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: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:!0,provider:"auth0"},header:{enabled:!1,logoUrl:"",logoUrlLight:"",logoUrlDark:"",logoHeight:"3.5rem",logoWidth:"auto",bgColor:"",textColor:"",showBorder:!1,navLinks:[{label:"Docs",url:"/"},{label:"About",url:"/about"}]},footer:{enabled:!0,text:"Copyright © 2025 Schmitech Inc.",bgColor:"",textColor:"",showBorder:!1,layout:"stacked",align:"center",topPadding:"large",navLinks:[{label:"Support",url:"/"},{label:"Privacy",url:"/about"}]},adapters:[{id:"simple-chat",name:"Simple AI Chat",apiUrl:"http://99.79.50.155:3000",description:"Basic chat interface using the default conversational agent (Similar to ChatGPT - no files).",inputPlaceholder:"Simple chat, ask anything..."},{id:"web-search",name:"Simple AI Chat (Web Search)",apiUrl:"http://99.79.50.155:3000",description:"Basic chat interface using the default conversational agent with web search supports.",inputPlaceholder:"Simple chat, ask anything..."},{id:"chat-with-files",name:"Simple AI Chat (Multimodal)",apiUrl:"http://99.79.50.155:3000",description:"Extract knowledge from PDF, Images, Word, etc. (Similar to ChatGPT Multimodal)",inputPlaceholder:"Files chat, ask anything..."},{id:"image-generator",name:"AI Image Generator",apiUrl:"http://99.79.50.155:3000",description:"Generate images from text descriptions using DALL-E 3 or Imagen 3.",inputPlaceholder:"Describe the image you want to create..."},{id:"video-generator",name:"AI Video Generator",apiUrl:"http://99.79.50.155:3000",description:"Generate videos from text descriptions.",inputPlaceholder:"Describe the video you want to create..."},{id:"qa-sql",name:"City FAQ Assistant (SQLite)",apiUrl:"http://99.79.50.155:3000",description:"Quick-test QA assistant over the sample city Q&A SQLite database.",inputPlaceholder:"Ask a city services question..."},{id:"qa-vector-chroma",name:"City FAQ Assistant (Chroma)",apiUrl:"http://99.79.50.155:3000",description:"Quick-test semantic QA assistant over the sample city Q&A Chroma collection.",inputPlaceholder:"Ask a city services question..."},{id:"hr-db-chatbot",name:"HR System Assistant",apiUrl:"http://99.79.50.155:3000",description:"HR database assistant: natural language queries over SQLite HR data via intent templates.",inputPlaceholder:"Ask HR questions..."},{id:"intent-sql-postgres",name:"Customer Orders Assistant",apiUrl:"http://99.79.50.155:3000",description:"Customer orders assistant: natural language queries over PostgreSQL customer orders data."},{id:"ecomm-analytics",name:"Business Analytics Assistant",apiUrl:"http://99.79.50.155:3000",description:"DuckDB analytics assistant: natural language analytics queries over the analytics demo. This agent is the perfect example of how to use something like OLAP to quickly discover insigths."},{id:"intent-http-jsonplaceholder",name:"REST API Chat",apiUrl:"http://99.79.50.155:3000",description:"Natural language queries over the fake REST API."},{id:"intent-http-paris-opendata",name:"City of Paris Chat",apiUrl:"http://99.79.50.155:3000",description:"Paris open data: events and activities (Que Faire à Paris) via natural language."},{id:"intent-mongodb-mflix",name:"Chat With Movies DB",apiUrl:"http://99.79.50.155:3000",description:"MFlix movies assistant: query the sample_mflix MongoDB database via intent templates."},{id:"intent-graphql-spacex",name:"GraphQL Chatbot",apiUrl:"http://99.79.50.155:3000",description:"SpaceX GraphQL assistant: natural language queries over the SpaceX API.",inputPlaceholder:"Ask SpaceX questions..."},{id:"audio-transcription",name:"Audio Transcription",apiUrl:"http://99.79.50.155:3000",description:"Audio Transcription Test.",inputPlaceholder:"Use the microphone for voice..."},{id:"voice-chat",name:"Voice Chat",apiUrl:"http://99.79.50.155:3000",description:"Voice chat adapter test.",inputPlaceholder:"Use the microphone for voice..."},{id:"real-time-voice-chat",name:"Real-Time Voice Chat",apiUrl:"http://99.79.50.155:3000",description:"Real-time voice chat adapter test (websocket).",inputPlaceholder:"Use the microphone for voice..."}]};const ld="http://localhost:3000",Ob="/favicon.svg",$b="/orbit-logo-light.png",qb="/orbit-logo-dark.png",Bb={agentMode:{mode:"multi",defaultAdapterId:""},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 wo(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function rd(r,l){if(!wo(r)||!wo(l))return l;const i={...r};return Object.keys(l).forEach(c=>{if(c==="__proto__"||c==="constructor"||c==="prototype")return;const d=i[c],f=l[c];wo(d)&&wo(f)?i[c]=rd(d,f):f!==void 0&&(i[c]=f)}),i}function Hb(r){if(typeof r!="string")return null;const l=r.trim();if(!l)return null;const i=l.toLowerCase();return i==="false"||i==="0"||i==="off"||i==="disabled"?null:l}function Fb(r){return r==="single"?"single":"multi"}function Ib(r){const l=r.trim();if(l.startsWith("["))try{const i=JSON.parse(l);return Array.isArray(i)?i.filter(Boolean):[]}catch{return[]}return l.split(/\s+/).filter(Boolean)}function Gb(){const r=Ub||{},l=typeof window<"u"&&window.ORBIT_CHAT_CONFIG||{},i=!!(typeof window<"u"&&window.ORBIT_CHAT_CONFIG);let c=rd(Bb,r);return c=rd(c,l),(!i||!c.auth.domain)&&(c.auth.domain="dev-3c4dpzhecz4gundm.us.auth0.com"),(!i||!c.auth.clientId)&&(c.auth.clientId="9JSe5xtoi5mLXRuov2K7FHYU10ojCQLH"),!i||c.auth.audience,!i||c.auth.provider,!i||c.auth.tenantId,(!i||c.auth.scopes.length===0)&&(c.auth.scopes=Ib("openid profile email User.Read")),c.outOfServiceMessage=Hb(c.outOfServiceMessage),c.agentMode.mode=Fb(c.agentMode.mode),c.agentMode.defaultAdapterId=typeof c.agentMode.defaultAdapterId=="string"?c.agentMode.defaultAdapterId.trim():"",c}const ye=Gb();function _t(){var l;const r=ye.adapters;if(Array.isArray(r)&&r.length>0){const i=(l=r[0].apiUrl)==null?void 0:l.trim();if(i)return i}return ld}function Ha(r){const l=r==null?void 0:r.trim();return l&&l.length>0?l:_t()}function Vb(){const r=ye.adapters;return Array.isArray(r)&&r.length>0?r[0].id:"default-key"}function Xb(){return ye.agentMode.mode}function Vo(){return Xb()==="single"}function yd(){if(!Vo())return null;const r=ye.agentMode.defaultAdapterId;return r&&ye.adapters.some(i=>{var c;return((c=i==null?void 0:i.id)==null?void 0:c.trim())===r})?r:null}function vd(){return ye.application.name}function wd(){return ye.application.description}function ig(){return ye.application.inputPlaceholder}function Yb(r){var d;const l=r==null?void 0:r.trim();if(!l)return null;const i=ye.adapters.find(f=>{var h;return((h=f==null?void 0:f.id)==null?void 0:h.trim())===l});return((d=i==null?void 0:i.name)==null?void 0:d.trim())||null}function Qb(r){var d;const l=r==null?void 0:r.trim();if(!l)return null;const i=ye.adapters.find(f=>{var h;return((h=f==null?void 0:f.id)==null?void 0:h.trim())===l});return((d=i==null?void 0:i.inputPlaceholder)==null?void 0:d.trim())||null}function og(){return ye.seo.siteUrl.trim()}function Zb(){return Array.isArray(ye.seo.alternateSiteUrls)?ye.seo.alternateSiteUrls.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):[]}function Kb(){return Array.isArray(ye.seo.hostPatterns)?ye.seo.hostPatterns.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean):[]}function Jb(){return ye.seo.exposeAgentNotes}function Pb(){var l;return((l=ye.application.favicon)==null?void 0:l.trim())||Ob}function Wb(){return ye.features.enableUpload}function ey(){return ye.features.enableAudioOutput}function ty(){return ye.features.enableAudioInput}function xp(){return ye.features.enableFeedbackButtons}function ay(){return ye.features.enableConversationThreads}function cg(){return ye.features.enableAutocomplete}function ny(){return Math.max(1e3,ye.voice.silenceTimeoutMs)}function ly(){return ye.voice.recognitionLanguage}function ry(){const r=yd();if(r)return r;const l=ye.adapters;if(Array.isArray(l)&&l.length>0)for(const i of l){const c=typeof(i==null?void 0:i.id)=="string"?i.id.trim():"";if(c)return c}return null}function sy(){return ye.outOfServiceMessage}function Sd(){return ye.auth.enabled}function va(){const{enabled:r,provider:l,domain:i,clientId:c,tenantId:d}=ye.auth;return!r||!c?!1:l==="entra"?!!d:!!i}function iy(){return ye.auth.domain}function ug(){return ye.auth.clientId}function oy(){return ye.auth.audience}function Xo(){return ye.auth.provider}function cy(){return ye.auth.tenantId}function kd(){const r=ye.auth.scopes;return r.length>0?r:["openid","profile","email"]}function sd(){return ye.header.enabled}function uy(){return ye.header.logoUrl}function dy(){var l;return((l=ye.header.logoUrlLight)==null?void 0:l.trim())||$b}function fy(){var l;return((l=ye.header.logoUrlDark)==null?void 0:l.trim())||qb}function my(){var r;return((r=ye.header.logoHeight)==null?void 0:r.trim())||""}function hy(){var r;return((r=ye.header.logoWidth)==null?void 0:r.trim())||""}function py(){return ye.header.bgColor}function gy(){return ye.header.textColor}function xy(){return ye.header.showBorder}function dg(r){if(Array.isArray(r))return r;if(typeof r=="string")try{const l=JSON.parse(r);return Array.isArray(l)?l:[]}catch{return[]}return[]}function fg(){return dg(ye.header.navLinks)}function mg(){return ye.footer.enabled}function by(){return ye.footer.text}function yy(){return ye.footer.bgColor}function vy(){return ye.footer.textColor}function wy(){return ye.footer.showBorder}function Sy(){return ye.footer.layout==="inline"?"inline":"stacked"}function ky(){return ye.footer.topPadding==="normal"?"normal":"large"}function _y(){const r=ye.startupScripts;return Array.isArray(r)?r.filter(l=>!!(l&&typeof l=="object")).map(l=>{const i=typeof l.src=="string"?l.src.trim():"",c=typeof l.content=="string"?l.content.trim():"",d=typeof l.id=="string"?l.id.trim():"";return{...l,src:i||void 0,content:c||void 0,id:d||void 0}}).filter(l=>!!(l.src||l.content)):[]}function Ay(){return dg(ye.footer.navLinks)}const _d=()=>ye.debug.consoleDebug,le=(...r)=>{_d()&&console.log(...r)},Be=(...r)=>{_d()&&console.warn(...r)},He=(...r)=>{_d()&&console.error(...r)},qt=(...r)=>{console.error(...r)};function bp({audio:r,audioFormat:l="mp3",autoPlay:i=!1,maxSizeMB:c=10}){const d=g.useRef(null),[f,h]=g.useState(!1),[p,x]=g.useState(0),[v,b]=g.useState(0),[w,k]=g.useState(!0),[S,j]=g.useState(null),[_,z]=g.useState(null);g.useEffect(()=>{if(!r)return;let Q=null,I=!0;return(async()=>{try{k(!0),j(null),z(null);const Ce=r.length*3/4/(1024*1024);if(Ce>c)throw new Error(`Audio file too large (${Ce.toFixed(1)}MB > ${c}MB limit)`);if(Ce>2&&(z(`Large audio file (${Ce.toFixed(1)}MB) - may take time to load`),le("[AudioPlayer] Large audio file detected",{sizeMB:Ce.toFixed(2)})),!/^[A-Za-z0-9+/=]+$/.test(r.replace(/\s/g,"")))throw new Error("Invalid base64 audio data");const te=atob(r),oe=new Uint8Array(te.length);for(let H=0;H<te.length;H++)oe[H]=te.charCodeAt(H);const E=l==="mp3"?"audio/mpeg":l==="wav"?"audio/wav":l==="ogg"?"audio/ogg":l==="opus"?"audio/opus":l==="webm"?"audio/webm":`audio/${l}`,V=new Blob([oe],{type:E});if(Q=URL.createObjectURL(V),!I||!d.current){Q&&URL.revokeObjectURL(Q);return}d.current.src=Q,k(!1),le("[AudioPlayer] Audio loaded successfully",{format:l,mimeType:E,size:V.size}),i&&d.current&&d.current.play().catch(H=>{He("[AudioPlayer] Auto-play failed:",H)})}catch(fe){He("[AudioPlayer] Failed to load audio:",fe),I&&(j("Failed to load audio"),k(!1))}})(),()=>{I=!1,Q&&URL.revokeObjectURL(Q)}},[r,l,i,c]);const $=()=>{d.current&&x(d.current.duration)},ee=()=>{d.current&&b(d.current.currentTime)},Y=()=>h(!0),R=()=>h(!1),q=()=>{h(!1),b(0)},N=()=>{d.current&&(f?d.current.pause():d.current.play().catch(Q=>{He("[AudioPlayer] Playback failed:",Q),j("Playback failed")}))},X=Q=>{if(!d.current)return;const I=parseFloat(Q.target.value);d.current.currentTime=I,b(I)},U=Q=>{if(!isFinite(Q))return"0:00";const I=Math.floor(Q/60),ae=Math.floor(Q%60);return`${I}:${ae.toString().padStart(2,"0")}`};return S?u.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:[u.jsx(Oo,{className:"h-4 w-4"}),u.jsx("span",{children:S})]}):u.jsxs("div",{className:"mt-3 flex flex-col gap-1",children:[_&&u.jsxs("div",{className:"text-xs text-amber-600 dark:text-amber-400 px-1",children:["⚠️ ",_]}),u.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-gray-300 bg-white px-3 py-2 dark:border-[#4a4b54] dark:bg-[#343541]",children:[u.jsx("audio",{ref:d,onLoadedMetadata:$,onTimeUpdate:ee,onPlay:Y,onPause:R,onEnded:q}),u.jsx("button",{onClick:N,disabled:w,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:f?"Pause":"Play","aria-label":f?"Pause audio":"Play audio",children:w?u.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}):f?u.jsx(Jx,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"}):u.jsx(Wx,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"})}),u.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:U(v)}),u.jsx("input",{type:"range",min:"0",max:p||0,value:v,onChange:X,disabled:w||!p,className:"flex-1 cursor-pointer accent-gray-600 dark:accent-[#bfc2cd]",style:{background:p?`linear-gradient(to right, rgb(75 85 99) 0%, rgb(75 85 99) ${v/p*100}%, rgb(229 231 235) ${v/p*100}%, rgb(229 231 235) 100%)`:"rgb(229 231 235)"}}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:U(p)})]}),u.jsx(Oo,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"})]})]})}var Yo=Jp();function yp({image:r,imageUrl:l,imageFormat:i="png",revisedPrompt:c}){const[d,f]=g.useState(!1),[h,p]=g.useState(!1),[x,v]=g.useState(null),b=g.useRef(null);g.useEffect(()=>{if(r||!l)return;let j=!1;return(async()=>{try{const _=typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null,z=await fetch(l,{headers:_?{"X-Adapter-Name":_}:{}});if(!z.ok){console.warn("[ImageDisplay] Server returned",z.status,"for",l);return}if(j)return;const $=await z.arrayBuffer();if(j)return;const ee=new Blob([$],{type:`image/${i}`}),Y=URL.createObjectURL(ee);b.current=Y,v(Y)}catch(_){console.warn("[ImageDisplay] Failed to fetch image from",l,_)}})(),()=>{j=!0,b.current&&(URL.revokeObjectURL(b.current),b.current=null)}},[l,r,i]);const k=(r?`data:image/${i};base64,${r}`:null)??x;g.useEffect(()=>{if(!d)return;const j=_=>{_.key==="Escape"&&f(!1)};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[d]);const S=j=>{if(j.stopPropagation(),!k)return;const _=document.createElement("a");_.href=k,_.download=`generated-image.${i}`,_.click()};return k?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"generated-image-wrapper",style:{marginTop:"0.75rem"},children:[u.jsxs("div",{className:"generated-image-container",style:{position:"relative",display:"inline-block",cursor:"zoom-in",maxWidth:"100%"},onClick:()=>f(!0),title:c||"Generated image — click to enlarge",children:[u.jsx("img",{src:k,alt:c||"Generated image",style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",objectFit:"contain"}}),u.jsxs("div",{style:{position:"absolute",bottom:"8px",right:"8px",display:"flex",gap:"6px"},children:[u.jsx("button",{onClick:S,title:"Download image",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(pd,{size:14})}),u.jsx("button",{onClick:j=>{j.stopPropagation(),f(!0)},title:"View full size",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(ub,{size:14})})]})]}),c&&u.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[u.jsxs("button",{type:"button",onClick:()=>p(j=>!j),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":h,children:[h?u.jsx(Uo,{size:14}):u.jsx(di,{size:14}),h?"Hide prompt":"Show prompt"]}),h&&u.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[u.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:"Prompt"}),u.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:c})]})]})]}),d&&typeof document<"u"&&Yo.createPortal(u.jsxs("div",{onClick:()=>f(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.85)",zIndex:9999,overflow:"auto",padding:"56px 24px 24px"},children:[u.jsx("button",{onClick:j=>{j.stopPropagation(),f(!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:u.jsx(ua,{size:20})}),u.jsx("img",{src:k,alt:c||"Generated image",style:{display:"block",width:"auto",height:"auto",maxWidth:"calc(100vw - 48px)",maxHeight:"calc(100vh - 80px)",objectFit:"contain",borderRadius:"8px",margin:"0 auto"},onClick:j=>j.stopPropagation()})]}),document.body)]}):null}const Pu=[750,1500,3e3,5e3],Cy=new Set([403,404,409,425,429,500,502,503,504]),jy=r=>new Promise(l=>setTimeout(l,r));function vp({video:r,videoUrl:l,videoFormat:i="mp4",revisedPrompt:c,adapterName:d}){const[f,h]=g.useState(!1),[p,x]=g.useState(!1),[v,b]=g.useState(null),w=g.useRef(null);g.useEffect(()=>{if(r||!l)return;let _=!1;return(async()=>{try{const z=d||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null);let $=null;for(let q=0;q<=Pu.length&&($=await fetch(l,{headers:z?{"X-Adapter-Name":z}:{}}),!($.ok||!Cy.has($.status)||q===Pu.length));q+=1)if(await jy(Pu[q]),_)return;if(!($!=null&&$.ok)){console.warn("[VideoDisplay] Server returned",$.status,"for",l);return}if(_)return;const ee=await $.arrayBuffer();if(_)return;const Y=new Blob([ee],{type:`video/${i}`}),R=URL.createObjectURL(Y);w.current=R,b(R)}catch(z){console.warn("[VideoDisplay] Failed to fetch video from",l,z)}})(),()=>{_=!0,w.current&&(URL.revokeObjectURL(w.current),w.current=null)}},[l,r,i,d]);const S=(r?`data:video/${i};base64,${r}`:null)??v;g.useEffect(()=>{if(!f)return;const _=z=>{z.key==="Escape"&&h(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[f]);const j=_=>{if(_.stopPropagation(),!S)return;const z=document.createElement("a");z.href=S,z.download=`generated-video.${i}`,z.click()};return S?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"generated-video-wrapper",style:{marginTop:"0.75rem"},children:[u.jsxs("div",{style:{position:"relative",display:"inline-block",maxWidth:"100%"},children:[u.jsx("video",{src:S,controls:!0,style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",backgroundColor:"#000"}}),u.jsxs("div",{style:{position:"absolute",bottom:"48px",right:"8px",display:"flex",gap:"6px"},children:[u.jsx("button",{onClick:j,title:"Download video",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(pd,{size:14})}),u.jsx("button",{onClick:_=>{_.stopPropagation(),h(!0)},title:"View full size",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(Hx,{size:14})})]})]}),c&&u.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[u.jsxs("button",{type:"button",onClick:()=>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":p,children:[p?u.jsx(Uo,{size:14}):u.jsx(di,{size:14}),p?"Hide prompt":"Show prompt"]}),p&&u.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[u.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:"Prompt"}),u.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:c})]})]})]}),f&&u.jsxs("div",{onClick:()=>h(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.9)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},children:[u.jsx("button",{onClick:_=>{_.stopPropagation(),h(!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:u.jsx(ua,{size:20})}),u.jsx("video",{src:S,controls:!0,autoPlay:!0,style:{maxWidth:"92vw",maxHeight:"92vh",borderRadius:"8px"},onClick:_=>_.stopPropagation()})]})]}):null}let $o=null;function hg(r){$o=r}function Qo(){$o=null}async function Ad(){if(!$o)return null;try{return await $o()}catch{return null}}let id=!1,oi=null;const od=new Set;function pg(){od.forEach(r=>r())}function hn(){return id}function Ny(){return oi}function Zo(r){id!==r&&(id=r,!r&&oi!==null&&(oi=null),pg())}function rs(r){const l=typeof r=="string"&&r.trim().length>0?r.trim():null;oi!==l&&(oi=l,pg())}function Ty(r){return od.add(r),()=>{od.delete(r)}}const wp="orbitchat-guest-user-id";function So(r){if(typeof r!="string")return null;const l=r.trim();return l.length>0?l:null}function Ey(r){const l=r.split(".");if(l.length<2)return null;try{const i=l[1].replace(/-/g,"+").replace(/_/g,"/"),c=i.padEnd(Math.ceil(i.length/4)*4,"="),d=atob(c);return JSON.parse(d)}catch{return null}}function My(){const r=globalThis.crypto;if(r&&typeof r.randomUUID=="function")return`guest:orbitchat:${r.randomUUID()}`;if(!r||typeof r.getRandomValues!="function")throw new Error("Secure random number generation is unavailable");const l=new Uint8Array(16);return r.getRandomValues(l),`guest:orbitchat:${Array.from(l,c=>c.toString(16).padStart(2,"0")).join("")}`}function zy(){if(typeof window>"u")return"guest:orbitchat:server";const r=window.localStorage.getItem(wp);if(r&&r.trim().length>0)return r;const l=My();return window.localStorage.setItem(wp,l),l}async function gg(){const r=Ny();if(r)return r;const l=await Ad();if(l){const i=Ey(l),c=So(i==null?void 0:i.sub)||So(i==null?void 0:i.user_id)||So(i==null?void 0:i.preferred_username)||So(i==null?void 0:i.email);if(c)return c}return hn()?"authenticated:orbitchat:unknown":zy()}const Dy={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"},Sp={pdf:"PDF",docx:"Word document",xlsx:"Excel workbook",pptx:"PowerPoint deck",md:"Markdown document",csv:"CSV file"},Do=/[\uE000-\uF8FF]|\\[eE][0-9a-fA-F]{2,3}|\\[fF][0-8][0-9a-fA-F]{2,3}/,Ly=/((?:p\.)?generated-docx-preview-num-\d+-\d+:before\s*\{[^}]*?)content\s*:\s*"([^"]*)"\s*;([^}]*?\})/g;function Ry(r){var i;return Do.test(r)?`•${((i=r.match(/(?:\\9|\t|\u00A0| )+$/))==null?void 0:i[0])||"\\9"}`:null}function kp(r){Array.from(r.querySelectorAll("style")).forEach(c=>{const d=c.textContent;!d||!Do.test(d)||(c.textContent=d.replace(Ly,(f,h,p,x)=>{const v=Ry(p);if(!v)return f;const b=x.replace(/\s*font-family\s*:\s*[^;{}]+;?/gi,"");return`${h}content: "${v}";${b}`}))}),Array.from(r.querySelectorAll('span[style*="font-family"]')).forEach(c=>{if(!/\b(symbol|wingdings|webdings)\b/i.test(c.style.fontFamily))return;const d=c.textContent||"";Do.test(d)&&(c.textContent=d.replace(Do,"•"),c.style.fontFamily="")})}function Uy(r){return(r||"pdf").toLowerCase().replace(/^\./,"")||"pdf"}function Oy(r){const l=window.atob(r),i=new Uint8Array(l.length);for(let c=0;c<l.length;c+=1)i[c]=l.charCodeAt(c);return i.buffer}function $y(r){return r==="xlsx"||r==="csv"?u.jsx(Ux,{className:"h-5 w-5"}):r==="pptx"?u.jsx(tb,{className:"h-5 w-5"}):r==="md"?u.jsx(Rx,{className:"h-5 w-5"}):u.jsx(Ox,{className:"h-5 w-5"})}function _p({document:r,documentUrl:l,documentFormat:i="pdf",revisedPrompt:c,adapterName:d}){const f=Uy(i),[h,p]=g.useState(r||l?"loading":"idle"),[x,v]=g.useState(null),[b,w]=g.useState(null),[k,S]=g.useState([]),[j,_]=g.useState(""),[z,$]=g.useState(null),[ee,Y]=g.useState([]),[R,q]=g.useState(0),[N,X]=g.useState(!1),[U,Q]=g.useState(null),I=g.useRef(null),ae=g.useRef(null),fe=g.useRef(null),Ce=c||Sp[f]||"Generated document",te=g.useMemo(()=>`generated-document.${f}`,[f]),oe=Dy[f]||"application/octet-stream";g.useEffect(()=>{if(!r&&!l)return;let P=!1;return(async()=>{p("loading"),Q(null),S([]),_(""),$(null),Y([]),q(0);try{const xe=r?Oy(r):await(async()=>{const me=(d==null?void 0:d.trim())||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null),ue={"X-User-ID":await gg()};me&&(ue["X-Adapter-Name"]=me);const de=await Ad();de&&(ue.Authorization=`Bearer ${de}`);const we=await fetch(l,{headers:ue});if(!we.ok)throw new Error(`Server returned ${we.status}`);return we.arrayBuffer()})();if(P)return;const pe=new Blob([xe],{type:oe}),F=URL.createObjectURL(pe);if(I.current&&URL.revokeObjectURL(I.current),I.current=F,v(F),w(xe.slice(0)),f==="xlsx"){const{default:me}=await En(async()=>{const{default:we}=await import("./index-CZz_ECqk.js");return{default:we}},[]),de=(await me(pe))[0];_((de==null?void 0:de.sheet)||"First sheet"),S(((de==null?void 0:de.data)||[]).slice(0,100).map(we=>we.slice(0,30).map(W=>W==null?"":String(W))))}if(f==="md"&&$(new TextDecoder("utf-8").decode(xe)),f==="csv"){const me=new TextDecoder("utf-8").decode(xe),{default:ue}=await En(async()=>{const{default:we}=await import("./papaparse.min-CdRM_ppG.js").then(W=>W.p);return{default:we}},__vite__mapDeps([16,1])),de=ue.parse(me,{skipEmptyLines:!0});q(de.data.length),Y(de.data.slice(0,25))}p("ready")}catch(xe){if(P)return;console.warn("[DocumentDisplay] Failed to load document from",l,xe),Q(xe instanceof Error?xe.message:"Unable to load document"),p("error")}})(),()=>{P=!0,I.current&&(URL.revokeObjectURL(I.current),I.current=null)}},[d,r,l,f,oe]),g.useEffect(()=>{if(h!=="ready"||f!=="docx"||!b||!ae.current)return;const P=ae.current;P.replaceChildren(),En(()=>import("./docx-preview-C0UevYcE.js"),__vite__mapDeps([17,1])).then(async({renderAsync:ce})=>{await ce(b.slice(0),P,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),kp(P)}).catch(ce=>{console.warn("[DocumentDisplay] Failed to render DOCX preview",ce),Q("Unable to render document preview")})},[b,f,h]),g.useEffect(()=>{if(!N||f!=="docx"||!b||!fe.current)return;const P=fe.current;P.replaceChildren(),En(()=>import("./docx-preview-C0UevYcE.js"),__vite__mapDeps([17,1])).then(async({renderAsync:ce})=>{await ce(b.slice(0),P,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),kp(P)}).catch(ce=>{console.warn("[DocumentDisplay] Failed to render modal DOCX preview",ce)})},[b,f,N]),g.useEffect(()=>{if(!N)return;const P=ce=>{ce.key==="Escape"&&X(!1)};return window.document.addEventListener("keydown",P),()=>window.document.removeEventListener("keydown",P)},[N]);const E=P=>{if(P==null||P.stopPropagation(),!x)return;const ce=window.document.createElement("a");ce.href=x,ce.download=te,ce.click()},V=h==="ready"&&(f==="pdf"||f==="docx"||f==="xlsx"||f==="md"||f==="csv"),H=V&&f!=="xlsx"&&f!=="csv";return h==="idle"?null:u.jsxs(u.Fragment,{children:[u.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:[u.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 px-3 py-2.5 dark:border-[#3b3c49]",children:[u.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:$y(f)}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:Ce}),u.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[Sp[f]||`${f.toUpperCase()} document`,h==="loading"?" · Loading preview...":"",h==="error"?` · ${U||"Preview unavailable"}`:""]})]}),H&&u.jsx("button",{type:"button",onClick:()=>X(!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:"Open preview","aria-label":"Open preview",children:u.jsx(Lx,{className:"h-4 w-4"})}),u.jsx("button",{type:"button",onClick:E,disabled:!x,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:"Download document","aria-label":"Download document",children:u.jsx(pd,{className:"h-4 w-4"})})]}),V&&u.jsxs("div",{className:"max-h-[460px] overflow-auto bg-gray-50 dark:bg-[#171717]",children:[f==="pdf"&&x&&u.jsx("iframe",{src:x,title:Ce,className:"block h-[460px] w-full border-0 bg-white"}),f==="docx"&&u.jsx("div",{ref:ae,className:"min-h-[240px] bg-white p-5 text-sm text-[#111827] dark:bg-white dark:text-[#111827]"}),f==="xlsx"&&u.jsxs("div",{className:"p-3",children:[j&&u.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500 dark:text-[#bfc2cd]",children:j}),u.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:u.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:u.jsx("tbody",{children:k.length>0?k.map((P,ce)=>u.jsx("tr",{className:ce===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:P.map((xe,pe)=>u.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:xe},pe))},ce)):u.jsx("tr",{children:u.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No sheet data found."})})})})})]}),f==="md"&&z!==null&&u.jsx("div",{className:"bg-white p-5 text-sm text-[#111827] dark:bg-[#171717] dark:text-[#ececf1]",children:u.jsx(el,{content:z,disableMath:!0})}),f==="csv"&&u.jsxs("div",{className:"p-3",children:[R>25&&u.jsxs("p",{className:"mb-2 text-xs text-gray-500 dark:text-[#bfc2cd]",children:["Showing first 25 of ",R," rows — download for the full file."]}),u.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:u.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:u.jsx("tbody",{children:ee.length>0?ee.map((P,ce)=>u.jsx("tr",{className:ce===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:P.map((xe,pe)=>u.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:xe},pe))},ce)):u.jsx("tr",{children:u.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No data found."})})})})})]})]}),h==="ready"&&!V&&u.jsx("div",{className:"px-3 py-4 text-sm text-gray-600 dark:text-[#bfc2cd]",children:"Preview is not available for this format. Use download to open it locally."})]}),N&&x&&u.jsxs("div",{onClick:()=>X(!1),className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/85 p-4",children:[u.jsx("button",{onClick:P=>{P.stopPropagation(),X(!1)},className:"fixed right-4 top-4 flex items-center rounded-full border-0 bg-white/15 p-2 text-white",title:"Close preview","aria-label":"Close preview",children:u.jsx(ua,{className:"h-5 w-5"})}),u.jsxs("div",{onClick:P=>P.stopPropagation(),className:"h-[92vh] w-[92vw] overflow-auto rounded-lg bg-white",children:[f==="pdf"&&u.jsx("iframe",{src:x,title:Ce,className:"h-full w-full border-0"}),f==="docx"&&u.jsx("div",{ref:fe,className:"min-h-full bg-white p-8 text-[#111827]"}),f==="md"&&z!==null&&u.jsx("div",{className:"min-h-full bg-white p-8 text-sm text-[#111827]",children:u.jsx(el,{content:z,disableMath:!0})})]})]})]})}const qy=["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 ci(r,{enabled:l,onEscape:i}){g.useEffect(()=>{if(!l||!r.current)return;const c=r.current,d=document.activeElement,f=Array.from(c.querySelectorAll(qy)).filter(v=>v.tabIndex!==-1),h=f[0]||c,p=f[f.length-1]||c;h.focus({preventScroll:!0});const x=v=>{if(v.key==="Escape"){i==null||i();return}if(v.key!=="Tab")return;if(f.length===0){v.preventDefault(),c.focus({preventScroll:!0});return}const b=document.activeElement;if(v.shiftKey){(!b||b===h||!c.contains(b))&&(v.preventDefault(),p.focus({preventScroll:!0}));return}(!b||b===p||!c.contains(b))&&(v.preventDefault(),h.focus({preventScroll:!0}))};return document.addEventListener("keydown",x),()=>{var v;document.removeEventListener("keydown",x),(v=d==null?void 0:d.focus)==null||v.call(d,{preventScroll:!0})}},[l,i,r])}function qo({isOpen:r,onClose:l,onConfirm:i,title:c,message:d,confirmText:f="Confirm",cancelText:h="Cancel",type:p="danger",isLoading:x=!1}){const v=g.useRef(null);if(ci(v,{enabled:r,onEscape:l}),!r)return null;const b=()=>{x||i()},k=(()=>{switch(p){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"}}})(),S=u.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:u.jsxs("div",{ref:v,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:[u.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`w-10 h-10 rounded-full ${k.iconBg} flex items-center justify-center`,children:u.jsx(bd,{className:`w-5 h-5 ${k.icon}`})}),u.jsx("h2",{id:"confirm-title",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:c})]}),u.jsx("button",{type:"button",onClick:l,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors","aria-label":"Close",children:u.jsx(ua,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.jsx("div",{className:"p-6",children:u.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:d})}),u.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:[u.jsx("button",{type:"button",onClick:l,disabled:x,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:h}),u.jsx("button",{type:"button",onClick:b,disabled:x,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 ${k.confirmButton}`,children:x?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Clearing..."]}):f})]})]})});return typeof document>"u"?S:Yo.createPortal(S,document.body)}const By=["#","*","`","[","]","(",")","{","}","|","<",">"],xg=r=>By.some(l=>r.includes(l));function bg(r){if(!r||r.length<1e3)return!1;const l=/^[A-Za-z0-9+/=]+$/,i=r.replace(/\s+/g,"");if(i.length>1e4&&l.test(i)){const c=/\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(r),d=xg(r),f=/[-.,;:!?'"()]/.test(r);if(!c&&!d&&!f)return!0}return!!(i.length>5e4&&l.test(i)&&r.replace(/[A-Za-z0-9+/=\s]/g,"").length<10)}const Hy=/(?:\u202F|\u2009|\u200A|\u200B|\u200C|\u200D|\uFEFF)/g;function si(r){if(!r)return r;let l=r.replace(Hy," ");if(bg(l))return"";const i=/([A-Za-z0-9+/=]{10000,})/g;return l=l.replace(i,c=>{const d=c.replace(/\s+/g,"");if(d.length>1e4&&/^[A-Za-z0-9+/=]+$/.test(d)){const f=/\b(function|const|let|var|class|return|import|export|if|else|while|for|true|false|null|def|print)\b/i.test(c),h=xg(c),p=/[-.,;:!?'"()]/.test(c);if(!f&&!h&&!p)return""}return c}),l}function cd(r,l=5e4){return!r||r.length<=l?r:bg(r)?"":r.substring(0,l)+`
|
|
330
|
+
`,l}catch(l){return console.warn("Error preprocessing markdown:",l),s}},Sb={'code[class*="language-"]':{color:"#393A34",fontFamily:'"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",fontSize:".9em",lineHeight:"1.2em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]':{color:"#393A34",fontFamily:'"Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",fontSize:".9em",lineHeight:"1.2em",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",border:"1px solid #dddddd",backgroundColor:"white"},'pre > code[class*="language-"]':{fontSize:"1em"},'pre[class*="language-"]::-moz-selection':{background:"#C1DEF1"},'pre[class*="language-"] ::-moz-selection':{background:"#C1DEF1"},'code[class*="language-"]::-moz-selection':{background:"#C1DEF1"},'code[class*="language-"] ::-moz-selection':{background:"#C1DEF1"},'pre[class*="language-"]::selection':{background:"#C1DEF1"},'pre[class*="language-"] ::selection':{background:"#C1DEF1"},'code[class*="language-"]::selection':{background:"#C1DEF1"},'code[class*="language-"] ::selection':{background:"#C1DEF1"},':not(pre) > code[class*="language-"]':{padding:".2em",paddingTop:"1px",paddingBottom:"1px",background:"#f8f8f8",border:"1px solid #dddddd"},comment:{color:"#008000",fontStyle:"italic"},prolog:{color:"#008000",fontStyle:"italic"},doctype:{color:"#008000",fontStyle:"italic"},cdata:{color:"#008000",fontStyle:"italic"},namespace:{Opacity:".7"},string:{color:"#A31515"},punctuation:{color:"#393A34"},operator:{color:"#393A34"},url:{color:"#36acaa"},symbol:{color:"#36acaa"},number:{color:"#36acaa"},boolean:{color:"#36acaa"},variable:{color:"#36acaa"},constant:{color:"#36acaa"},inserted:{color:"#36acaa"},atrule:{color:"#0000ff"},keyword:{color:"#0000ff"},"attr-value":{color:"#0000ff"},".language-autohotkey .token.selector":{color:"#0000ff"},".language-json .token.boolean":{color:"#0000ff"},".language-json .token.number":{color:"#0000ff"},'code[class*="language-css"]':{color:"#0000ff"},function:{color:"#393A34"},deleted:{color:"#9a050f"},".language-autohotkey .token.tag":{color:"#9a050f"},selector:{color:"#800000"},".language-autohotkey .token.keyword":{color:"#00009f"},important:{color:"#e90",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"},"class-name":{color:"#2B91AF"},".language-json .token.property":{color:"#2B91AF"},tag:{color:"#800000"},"attr-name":{color:"#ff0000"},property:{color:"#ff0000"},regex:{color:"#ff0000"},entity:{color:"#ff0000"},"directive.tag.tag":{background:"#ffff00",color:"#393A34"},".line-numbers.line-numbers .line-numbers-rows":{borderRightColor:"#a5a5a5"},".line-numbers .line-numbers-rows > span:before":{color:"#2B91AF"},".line-highlight.line-highlight":{background:"linear-gradient(to right, rgba(193, 222, 241, 0.2) 70%, rgba(221, 222, 241, 0))"}},kb={'pre[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",margin:".5em 0",overflow:"auto",background:"#1e1e1e"},'code[class*="language-"]':{color:"#d4d4d4",fontSize:"13px",textShadow:"none",fontFamily:'Menlo, Monaco, Consolas, "Andale Mono", "Ubuntu Mono", "Courier New", monospace',direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"},'pre[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"]::selection':{textShadow:"none",background:"#264F78"},'pre[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},'code[class*="language-"] *::selection':{textShadow:"none",background:"#264F78"},':not(pre) > code[class*="language-"]':{padding:".1em .3em",borderRadius:".3em",color:"#db4c69",background:"#1e1e1e"},".namespace":{Opacity:".7"},"doctype.doctype-tag":{color:"#569CD6"},"doctype.name":{color:"#9cdcfe"},comment:{color:"#6a9955"},prolog:{color:"#6a9955"},punctuation:{color:"#d4d4d4"},".language-html .language-css .token.punctuation":{color:"#d4d4d4"},".language-html .language-javascript .token.punctuation":{color:"#d4d4d4"},property:{color:"#9cdcfe"},tag:{color:"#569cd6"},boolean:{color:"#569cd6"},number:{color:"#b5cea8"},constant:{color:"#9cdcfe"},symbol:{color:"#b5cea8"},inserted:{color:"#b5cea8"},unit:{color:"#b5cea8"},selector:{color:"#d7ba7d"},"attr-name":{color:"#9cdcfe"},string:{color:"#ce9178"},char:{color:"#ce9178"},builtin:{color:"#ce9178"},deleted:{color:"#ce9178"},".language-css .token.string.url":{textDecoration:"underline"},operator:{color:"#d4d4d4"},entity:{color:"#569cd6"},"operator.arrow":{color:"#569CD6"},atrule:{color:"#ce9178"},"atrule.rule":{color:"#c586c0"},"atrule.url":{color:"#9cdcfe"},"atrule.url.function":{color:"#dcdcaa"},"atrule.url.punctuation":{color:"#d4d4d4"},keyword:{color:"#569CD6"},"keyword.module":{color:"#c586c0"},"keyword.control-flow":{color:"#c586c0"},function:{color:"#dcdcaa"},"function.maybe-class-name":{color:"#dcdcaa"},regex:{color:"#d16969"},important:{color:"#569cd6"},italic:{fontStyle:"italic"},"class-name":{color:"#4ec9b0"},"maybe-class-name":{color:"#4ec9b0"},console:{color:"#9cdcfe"},parameter:{color:"#9cdcfe"},interpolation:{color:"#9cdcfe"},"punctuation.interpolation-punctuation":{color:"#569cd6"},variable:{color:"#9cdcfe"},"imports.maybe-class-name":{color:"#9cdcfe"},"exports.maybe-class-name":{color:"#9cdcfe"},escape:{color:"#d7ba7d"},"tag.punctuation":{color:"#808080"},cdata:{color:"#808080"},"attr-value":{color:"#ce9178"},"attr-value.punctuation":{color:"#ce9178"},"attr-value.punctuation.attr-equals":{color:"#d4d4d4"},namespace:{color:"#4ec9b0"},'pre[class*="language-javascript"]':{color:"#9cdcfe"},'code[class*="language-javascript"]':{color:"#9cdcfe"},'pre[class*="language-jsx"]':{color:"#9cdcfe"},'code[class*="language-jsx"]':{color:"#9cdcfe"},'pre[class*="language-typescript"]':{color:"#9cdcfe"},'code[class*="language-typescript"]':{color:"#9cdcfe"},'pre[class*="language-tsx"]':{color:"#9cdcfe"},'code[class*="language-tsx"]':{color:"#9cdcfe"},'pre[class*="language-css"]':{color:"#ce9178"},'code[class*="language-css"]':{color:"#ce9178"},'pre[class*="language-html"]':{color:"#d4d4d4"},'code[class*="language-html"]':{color:"#d4d4d4"},".language-regex .token.anchor":{color:"#dcdcaa"},".language-html .token.punctuation":{color:"#808080"},'pre[class*="language-"] > code[class*="language-"]':{position:"relative",zIndex:"1"},".line-highlight.line-highlight":{background:"#f7ebc6",boxShadow:"inset 5px 0 0 #f7d87c",zIndex:"0"}},_b=g.lazy(()=>En(()=>import("./MermaidRenderer-DNbuWll0.js").then(s=>s.au),__vite__mapDeps([0,1,2,3,4])).then(s=>({default:s.MermaidRenderer}))),Ab=g.lazy(()=>En(()=>import("./SVGRenderer-DAIMVJgr.js"),__vite__mapDeps([5,1,3])).then(s=>({default:s.SVGRenderer}))),Cb=g.lazy(()=>En(()=>import("./ChartRenderer-DyMx9C0M.js"),__vite__mapDeps([6,1,4,7,8,9,10,11,12,13,2,14])).then(s=>({default:s.ChartRenderer}))),jb=g.lazy(()=>En(()=>import("./MusicRenderer-DW6lysGY.js"),__vite__mapDeps([15,2,1])).then(s=>({default:s.MusicRenderer}))),Nb=s=>{var c,d;if(!s)return typeof window<"u"&&((c=window.matchMedia)!=null&&c.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light";const l=s.closest(".markdown-content");if(l){if(l.classList.contains("dark"))return"dark";if(l.classList.contains("light"))return"light"}if(s.closest(".dark"))return"dark";if(s.closest(".light"))return"light";const i=s.closest("[data-theme]");if(i){const f=i.getAttribute("data-theme");if(f==="dark")return"dark";if(f==="light")return"light"}return typeof window<"u"&&((d=window.matchMedia)!=null&&d.call(window,"(prefers-color-scheme: dark)").matches)?"dark":"light"},Tb=(s,l)=>{const[i,c]=g.useState("light"),d=g.useRef("light");return g.useEffect(()=>{var v,b,w;if(l||typeof window>"u"||typeof document>"u")return;const f=()=>{const k=Nb(s.current);k!==d.current&&(d.current=k,c(k))};f();const h=((v=window.matchMedia)==null?void 0:v.call(window,"(prefers-color-scheme: dark)"))??null,p=()=>f();h==null||h.addEventListener("change",p);const x=typeof MutationObserver<"u"?new MutationObserver(()=>f()):null;if(x){const k=((w=(b=s.current)==null?void 0:b.closest)==null?void 0:w.call(b,".markdown-content"))??null;k&&x.observe(k,{attributes:!0,attributeFilter:["class","data-theme"]}),document.body&&x.observe(document.body,{attributes:!0,attributeFilter:["class","data-theme"]})}return()=>{h==null||h.removeEventListener("change",p),x==null||x.disconnect()}},[l,s]),l??i},Eb={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"},Mb=s=>{if(!s)return"";const l=s.match(/(?:^|\s)language-([^\s]+)/);if(!l)return"";const c=l[1].toLowerCase().split("{")[0].split("[")[0].split("<")[0].split(":")[0].trim().replace(/[^a-z0-9+#-]+$/g,"");return c?Eb[c]??c:""},zb=s=>Tn.Children.toArray(s).map(l=>typeof l=="string"||typeof l=="number"?String(l):"").join("").replace(/\n$/,""),hp=({code:s})=>{const[l,i]=g.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(s),i(!0),setTimeout(()=>i(!1),2e3)}catch{const d=document.createElement("textarea");d.value=s,d.style.position="fixed",d.style.opacity="0",document.body.appendChild(d),d.select();try{document.execCommand("copy"),i(!0),setTimeout(()=>i(!1),2e3)}catch(f){console.error("Failed to copy code:",f)}document.body.removeChild(d)}};return u.jsxs("button",{className:"code-copy-button",onClick:c,title:l?"Copied!":"Copy code","aria-label":l?"Copied!":"Copy code to clipboard",children:[l?u.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M13.5 4.5L6 12L2.5 8.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}):u.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[u.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"}),u.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"}),u.jsx("path",{d:"M9.5 6.5L13.5 2.5L9.5 2.5V6.5Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),u.jsx("span",{className:"code-copy-button-text",children:l?"Copied!":"Copy"})]})},Db=({inline:s,className:l="",children:i,enableGraphs:c=!0,enableMermaid:d=!0,enableSVG:f=!0,enableCharts:h=!0,enableMusic:p=!0,enableSyntaxHighlighting:x=!0,syntaxTheme:v})=>{const b=g.useRef(null),w=Tb(b,v),k=u.jsx("div",{className:"markdown-code-block code-block-container",children:"Loading renderer..."});if(s)return u.jsx("code",{className:l,children:i});const S=Mb(l),j=zb(i);if(h&&(S==="chart"||S==="chart-json"||S==="chart-table"))return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Cb,{code:j,language:S})})});if(p&&(S==="abc"||S==="music"))return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(jb,{code:j})})});if(c){if(S==="mermaid"&&d)return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(_b,{code:j})})});if(S==="svg"&&f)return u.jsx("div",{ref:b,children:u.jsx(g.Suspense,{fallback:k,children:u.jsx(Ab,{code:j})})})}if(x&&S){const _=w==="light"?Sb:kb;return u.jsxs("div",{ref:b,className:"syntax-highlighted-wrapper code-block-container",children:[u.jsx(hp,{code:j}),u.jsx(bx,{language:S,style:_,customStyle:{margin:"12px 0",borderRadius:"6px",fontSize:"0.9em"},showLineNumbers:!1,children:j})]})}return u.jsxs("div",{ref:b,className:`markdown-code-block code-block-container ${l}`.trim(),children:[u.jsx(hp,{code:j}),u.jsx("pre",{style:{margin:0,padding:0,background:"transparent",border:"none"},children:u.jsx("code",{children:j})})]})},pp=new Set(["div","pre","blockquote","ul","ol","table","thead","tbody","tr","td","th","h1","h2","h3","h4","h5","h6","section","article","figure"]),Lb=({children:s,href:l="",className:i="",...c})=>{const d=Tn.Children.toArray(s).map(b=>typeof b=="string"?b:"").join("").trim(),f=/^https?:\/\//i.test(l),h=!!(f&&d&&gp(d)===gp(l)),p=f?Rb(l):null,x=!!(h&&p),v=["markdown-link",x?"markdown-link--card":"markdown-link--inline",i].filter(Boolean).join(" ");return u.jsxs("a",{...c,href:l,target:"_blank",rel:"noopener noreferrer",className:v,children:[u.jsx("span",{className:"markdown-link__content",children:x&&p?u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"markdown-link__hostname",children:p.hostname}),p.path&&p.path!=="/"&&u.jsx("span",{className:"markdown-link__path",children:p.path})]}):s}),f&&u.jsx("span",{className:"markdown-link__icon","aria-hidden":"true",children:u.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:u.jsx("path",{d:"M8 16L16 8M16 8H9M16 8V15",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})})]})};function gp(s){return s.trim().replace(/\/$/,"")}function Rb(s){try{const l=new URL(s),i=l.hostname.replace(/^www\./i,""),c=`${l.pathname}${l.search}${l.hash}`||"/";return{hostname:i,path:c}}catch{return null}}const el=({content:s,className:l="",disableMath:i=!1,enableGraphs:c=!0,enableMermaid:d=!0,enableSVG:f=!0,enableCharts:h=!0,enableMusic:p=!0,enableSyntaxHighlighting:x=!0,syntaxTheme:v="dark"})=>{const b=wb(s);if(!b)return null;const w=i?[ap]:[ap,[gx,{singleDollarTextMath:!0}]],k=[];i||k.push([xx,{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 S={table:({children:j,..._})=>u.jsx("div",{style:{overflowX:"auto",WebkitOverflowScrolling:"touch"},children:u.jsx("table",{..._,children:j})}),a:Lb,code:j=>{const{className:_,children:z,...$}=j,ee=_&&/language-/.test(_),Y="inline"in j&&typeof j.inline=="boolean"&&j.inline||!ee,R=ee;return u.jsx(Db,{inline:Y,className:_,enableGraphs:c,enableMermaid:d,enableSVG:f,enableCharts:h,enableMusic:p,enableSyntaxHighlighting:x,syntaxTheme:v,"data-block-code":R?"true":void 0,...$,children:z})},p:({node:j,..._})=>{var Y;const $=Tn.Children.toArray(_.children).filter(R=>!(typeof R=="string"&&R.trim()==="")).some(R=>{if(!Tn.isValidElement(R))return!1;const q=R.props;return(q==null?void 0:q["data-block-code"])==="true"?!0:typeof R.type=="string"?pp.has(R.type):!1}),ee=(Y=j==null?void 0:j.children)==null?void 0:Y.some(R=>{var q;if(R.type==="code")return!0;if(R.type==="element"){if(R.tagName&&pp.has(R.tagName))return!0;if(R.tagName==="code"){const N=(q=R.properties)==null?void 0:q.className;return Array.isArray(N)?N.some(X=>typeof X=="string"&&X.startsWith("language-")):!0}}return!1});return $||ee?u.jsx(u.Fragment,{children:_.children}):u.jsx("p",{..._})}};return u.jsx("div",{className:`markdown-content ${l}`,children:u.jsx(px,{remarkPlugins:w,rehypePlugins:k,components:S,children:b})})};var Ub={agentMode:{mode:"multi",defaultAdapterId:"chat-with-files"},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:null},seo:{includeSitemap:!1,siteUrl:"http://localhost:5173",exposeAgentNotes:!0},debug:{consoleDebug:!1},features:{enableUpload:!0,enableAudioOutput:!0,enableAudioInput:!0,enableFeedbackButtons:!0,enableConversationThreads:!0,enableAutocomplete:!0},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:!0,provider:"auth0"},header:{enabled:!0,logoUrl:"",logoUrlLight:"",logoUrlDark:"",logoHeight:"3.5rem",logoWidth:"auto",bgColor:"",textColor:"",showBorder:!1,navLinks:[{label:"Docs",url:"/"},{label:"About",url:"/about"}]},footer:{enabled:!0,text:"Copyright © 2025 Schmitech Inc.",bgColor:"",textColor:"",showBorder:!1,layout:"stacked",align:"center",topPadding:"large",navLinks:[{label:"Support",url:"/"},{label:"Privacy",url:"/about"}]},adapters:[{id:"simple-chat",name:"Simple AI Chat",apiUrl:"http://localhost:3000",description:"Basic chat interface using the default conversational agent (Similar to ChatGPT - no files).",inputPlaceholder:"Simple chat, ask anything..."},{id:"web-search",name:"Simple AI Chat (Web Search)",apiUrl:"http://localhost:3000",description:"Basic chat interface using the default conversational agent with web search supports.",inputPlaceholder:"Simple chat, ask anything..."},{id:"chat-with-files",name:"Simple AI Chat (Multimodal)",apiUrl:"http://localhost:3000",description:"Extract knowledge from PDF, Images, Word, etc. (Similar to ChatGPT Multimodal)",inputPlaceholder:"Files chat, ask anything..."},{id:"image-generator",name:"AI Image Generator",apiUrl:"http://localhost:3000",description:"Generate images from text descriptions using DALL-E 3 or Imagen 3.",inputPlaceholder:"Describe the image you want to create..."},{id:"video-generator",name:"AI Video Generator",apiUrl:"http://localhost:3000",description:"Generate videos from text descriptions.",inputPlaceholder:"Describe the video you want to create..."},{id:"qa-sql",name:"City FAQ Assistant (SQLite)",apiUrl:"http://localhost:3000",description:"Quick-test QA assistant over the sample city Q&A SQLite database.",inputPlaceholder:"Ask a city services question..."},{id:"qa-vector-chroma",name:"City FAQ Assistant (Chroma)",apiUrl:"http://localhost:3000",description:"Quick-test semantic QA assistant over the sample city Q&A Chroma collection.",inputPlaceholder:"Ask a city services question..."},{id:"hr-db-chatbot",name:"HR System Assistant",apiUrl:"http://localhost:3000",description:"HR database assistant: natural language queries over SQLite HR data via intent templates.",inputPlaceholder:"Ask HR questions..."},{id:"intent-sql-postgres",name:"Customer Orders Assistant",apiUrl:"http://localhost:3000",description:"Customer orders assistant: natural language queries over PostgreSQL customer orders data."},{id:"ecomm-analytics",name:"Business Analytics Assistant",apiUrl:"http://localhost:3000",description:"DuckDB analytics assistant: natural language analytics queries over the analytics demo. This agent is the perfect example of how to use something like OLAP to quickly discover insigths."},{id:"intent-http-jsonplaceholder",name:"REST API Chat",apiUrl:"http://localhost:3000",description:"Natural language queries over the fake REST API."},{id:"intent-http-paris-opendata",name:"City of Paris Chat",apiUrl:"http://localhost:3000",description:"Paris open data: events and activities (Que Faire à Paris) via natural language."},{id:"intent-mongodb-mflix",name:"Chat With Movies DB",apiUrl:"http://localhost:3000",description:"MFlix movies assistant: query the sample_mflix MongoDB database via intent templates."},{id:"intent-graphql-spacex",name:"GraphQL Chatbot",apiUrl:"http://localhost:3000",description:"SpaceX GraphQL assistant: natural language queries over the SpaceX API.",inputPlaceholder:"Ask SpaceX questions..."},{id:"audio-transcription",name:"Audio Transcription",apiUrl:"http://localhost:3000",description:"Audio Transcription Test.",inputPlaceholder:"Use the microphone for voice..."},{id:"voice-chat",name:"Voice Chat",apiUrl:"http://localhost:3000",description:"Voice chat adapter test.",inputPlaceholder:"Use the microphone for voice..."},{id:"real-time-voice-chat",name:"Real-Time Voice Chat",apiUrl:"http://localhost:3000",description:"Real-time voice chat adapter test (websocket).",inputPlaceholder:"Use the microphone for voice..."},{id:"intent-elasticsearch-log",name:"Log Analysis Assistant",apiUrl:"http://localhost:3000"}]};const ld="http://localhost:3000",Ob="/favicon.svg",$b="/orbit-logo-light.png",qb="/orbit-logo-dark.png",Bb={agentMode:{mode:"multi",defaultAdapterId:""},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 wo(s){return typeof s=="object"&&s!==null&&!Array.isArray(s)}function sd(s,l){if(!wo(s)||!wo(l))return l;const i={...s};return Object.keys(l).forEach(c=>{if(c==="__proto__"||c==="constructor"||c==="prototype")return;const d=i[c],f=l[c];wo(d)&&wo(f)?i[c]=sd(d,f):f!==void 0&&(i[c]=f)}),i}function Hb(s){if(typeof s!="string")return null;const l=s.trim();if(!l)return null;const i=l.toLowerCase();return i==="false"||i==="0"||i==="off"||i==="disabled"?null:l}function Fb(s){return s==="single"?"single":"multi"}function Ib(s){const l=s.trim();if(l.startsWith("["))try{const i=JSON.parse(l);return Array.isArray(i)?i.filter(Boolean):[]}catch{return[]}return l.split(/\s+/).filter(Boolean)}function Gb(){const s=Ub||{},l=typeof window<"u"&&window.ORBIT_CHAT_CONFIG||{},i=!!(typeof window<"u"&&window.ORBIT_CHAT_CONFIG);let c=sd(Bb,s);return c=sd(c,l),(!i||!c.auth.domain)&&(c.auth.domain="dev-3c4dpzhecz4gundm.us.auth0.com"),(!i||!c.auth.clientId)&&(c.auth.clientId="9JSe5xtoi5mLXRuov2K7FHYU10ojCQLH"),!i||c.auth.audience,!i||c.auth.provider,!i||c.auth.tenantId,(!i||c.auth.scopes.length===0)&&(c.auth.scopes=Ib("openid profile email User.Read")),c.outOfServiceMessage=Hb(c.outOfServiceMessage),c.agentMode.mode=Fb(c.agentMode.mode),c.agentMode.defaultAdapterId=typeof c.agentMode.defaultAdapterId=="string"?c.agentMode.defaultAdapterId.trim():"",c}const ye=Gb();function _t(){var l;const s=ye.adapters;if(Array.isArray(s)&&s.length>0){const i=(l=s[0].apiUrl)==null?void 0:l.trim();if(i)return i}return ld}function Ha(s){const l=s==null?void 0:s.trim();return l&&l.length>0?l:_t()}function Vb(){const s=ye.adapters;return Array.isArray(s)&&s.length>0?s[0].id:"default-key"}function Xb(){return ye.agentMode.mode}function Vo(){return Xb()==="single"}function yd(){if(!Vo())return null;const s=ye.agentMode.defaultAdapterId;return s&&ye.adapters.some(i=>{var c;return((c=i==null?void 0:i.id)==null?void 0:c.trim())===s})?s:null}function vd(){return ye.application.name}function wd(){return ye.application.description}function ig(){return ye.application.inputPlaceholder}function Yb(s){var d;const l=s==null?void 0:s.trim();if(!l)return null;const i=ye.adapters.find(f=>{var h;return((h=f==null?void 0:f.id)==null?void 0:h.trim())===l});return((d=i==null?void 0:i.name)==null?void 0:d.trim())||null}function Qb(s){var d;const l=s==null?void 0:s.trim();if(!l)return null;const i=ye.adapters.find(f=>{var h;return((h=f==null?void 0:f.id)==null?void 0:h.trim())===l});return((d=i==null?void 0:i.inputPlaceholder)==null?void 0:d.trim())||null}function og(){return ye.seo.siteUrl.trim()}function Zb(){return Array.isArray(ye.seo.alternateSiteUrls)?ye.seo.alternateSiteUrls.filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean):[]}function Kb(){return Array.isArray(ye.seo.hostPatterns)?ye.seo.hostPatterns.filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean):[]}function Jb(){return ye.seo.exposeAgentNotes}function Pb(){var l;return((l=ye.application.favicon)==null?void 0:l.trim())||Ob}function Wb(){return ye.features.enableUpload}function ey(){return ye.features.enableAudioOutput}function ty(){return ye.features.enableAudioInput}function xp(){return ye.features.enableFeedbackButtons}function ay(){return ye.features.enableConversationThreads}function cg(){return ye.features.enableAutocomplete}function ny(){return Math.max(1e3,ye.voice.silenceTimeoutMs)}function ly(){return ye.voice.recognitionLanguage}function sy(){const s=yd();if(s)return s;const l=ye.adapters;if(Array.isArray(l)&&l.length>0)for(const i of l){const c=typeof(i==null?void 0:i.id)=="string"?i.id.trim():"";if(c)return c}return null}function ry(){return ye.outOfServiceMessage}function Sd(){return ye.auth.enabled}function va(){const{enabled:s,provider:l,domain:i,clientId:c,tenantId:d}=ye.auth;return!s||!c?!1:l==="entra"?!!d:!!i}function iy(){return ye.auth.domain}function ug(){return ye.auth.clientId}function oy(){return ye.auth.audience}function Xo(){return ye.auth.provider}function cy(){return ye.auth.tenantId}function kd(){const s=ye.auth.scopes;return s.length>0?s:["openid","profile","email"]}function rd(){return ye.header.enabled}function uy(){return ye.header.logoUrl}function dy(){var l;return((l=ye.header.logoUrlLight)==null?void 0:l.trim())||$b}function fy(){var l;return((l=ye.header.logoUrlDark)==null?void 0:l.trim())||qb}function my(){var s;return((s=ye.header.logoHeight)==null?void 0:s.trim())||""}function hy(){var s;return((s=ye.header.logoWidth)==null?void 0:s.trim())||""}function py(){return ye.header.bgColor}function gy(){return ye.header.textColor}function xy(){return ye.header.showBorder}function dg(s){if(Array.isArray(s))return s;if(typeof s=="string")try{const l=JSON.parse(s);return Array.isArray(l)?l:[]}catch{return[]}return[]}function fg(){return dg(ye.header.navLinks)}function mg(){return ye.footer.enabled}function by(){return ye.footer.text}function yy(){return ye.footer.bgColor}function vy(){return ye.footer.textColor}function wy(){return ye.footer.showBorder}function Sy(){return ye.footer.layout==="inline"?"inline":"stacked"}function ky(){return ye.footer.topPadding==="normal"?"normal":"large"}function _y(){const s=ye.startupScripts;return Array.isArray(s)?s.filter(l=>!!(l&&typeof l=="object")).map(l=>{const i=typeof l.src=="string"?l.src.trim():"",c=typeof l.content=="string"?l.content.trim():"",d=typeof l.id=="string"?l.id.trim():"";return{...l,src:i||void 0,content:c||void 0,id:d||void 0}}).filter(l=>!!(l.src||l.content)):[]}function Ay(){return dg(ye.footer.navLinks)}const _d=()=>ye.debug.consoleDebug,le=(...s)=>{_d()&&console.log(...s)},Be=(...s)=>{_d()&&console.warn(...s)},He=(...s)=>{_d()&&console.error(...s)},qt=(...s)=>{console.error(...s)};function bp({audio:s,audioFormat:l="mp3",autoPlay:i=!1,maxSizeMB:c=10}){const d=g.useRef(null),[f,h]=g.useState(!1),[p,x]=g.useState(0),[v,b]=g.useState(0),[w,k]=g.useState(!0),[S,j]=g.useState(null),[_,z]=g.useState(null);g.useEffect(()=>{if(!s)return;let Q=null,I=!0;return(async()=>{try{k(!0),j(null),z(null);const Ce=s.length*3/4/(1024*1024);if(Ce>c)throw new Error(`Audio file too large (${Ce.toFixed(1)}MB > ${c}MB limit)`);if(Ce>2&&(z(`Large audio file (${Ce.toFixed(1)}MB) - may take time to load`),le("[AudioPlayer] Large audio file detected",{sizeMB:Ce.toFixed(2)})),!/^[A-Za-z0-9+/=]+$/.test(s.replace(/\s/g,"")))throw new Error("Invalid base64 audio data");const te=atob(s),oe=new Uint8Array(te.length);for(let H=0;H<te.length;H++)oe[H]=te.charCodeAt(H);const E=l==="mp3"?"audio/mpeg":l==="wav"?"audio/wav":l==="ogg"?"audio/ogg":l==="opus"?"audio/opus":l==="webm"?"audio/webm":`audio/${l}`,V=new Blob([oe],{type:E});if(Q=URL.createObjectURL(V),!I||!d.current){Q&&URL.revokeObjectURL(Q);return}d.current.src=Q,k(!1),le("[AudioPlayer] Audio loaded successfully",{format:l,mimeType:E,size:V.size}),i&&d.current&&d.current.play().catch(H=>{He("[AudioPlayer] Auto-play failed:",H)})}catch(fe){He("[AudioPlayer] Failed to load audio:",fe),I&&(j("Failed to load audio"),k(!1))}})(),()=>{I=!1,Q&&URL.revokeObjectURL(Q)}},[s,l,i,c]);const $=()=>{d.current&&x(d.current.duration)},ee=()=>{d.current&&b(d.current.currentTime)},Y=()=>h(!0),R=()=>h(!1),q=()=>{h(!1),b(0)},N=()=>{d.current&&(f?d.current.pause():d.current.play().catch(Q=>{He("[AudioPlayer] Playback failed:",Q),j("Playback failed")}))},X=Q=>{if(!d.current)return;const I=parseFloat(Q.target.value);d.current.currentTime=I,b(I)},U=Q=>{if(!isFinite(Q))return"0:00";const I=Math.floor(Q/60),ae=Math.floor(Q%60);return`${I}:${ae.toString().padStart(2,"0")}`};return S?u.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:[u.jsx(Oo,{className:"h-4 w-4"}),u.jsx("span",{children:S})]}):u.jsxs("div",{className:"mt-3 flex flex-col gap-1",children:[_&&u.jsxs("div",{className:"text-xs text-amber-600 dark:text-amber-400 px-1",children:["⚠️ ",_]}),u.jsxs("div",{className:"flex items-center gap-3 rounded-md border border-gray-300 bg-white px-3 py-2 dark:border-[#4a4b54] dark:bg-[#343541]",children:[u.jsx("audio",{ref:d,onLoadedMetadata:$,onTimeUpdate:ee,onPlay:Y,onPause:R,onEnded:q}),u.jsx("button",{onClick:N,disabled:w,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:f?"Pause":"Play","aria-label":f?"Pause audio":"Play audio",children:w?u.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-gray-400 border-t-transparent"}):f?u.jsx(Jx,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"}):u.jsx(Wx,{className:"h-4 w-4 text-gray-700 dark:text-[#ececf1]"})}),u.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:U(v)}),u.jsx("input",{type:"range",min:"0",max:p||0,value:v,onChange:X,disabled:w||!p,className:"flex-1 cursor-pointer accent-gray-600 dark:accent-[#bfc2cd]",style:{background:p?`linear-gradient(to right, rgb(75 85 99) 0%, rgb(75 85 99) ${v/p*100}%, rgb(229 231 235) ${v/p*100}%, rgb(229 231 235) 100%)`:"rgb(229 231 235)"}}),u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:U(p)})]}),u.jsx(Oo,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"})]})]})}var Yo=Jp();function yp({image:s,imageUrl:l,imageFormat:i="png",revisedPrompt:c}){const[d,f]=g.useState(!1),[h,p]=g.useState(!1),[x,v]=g.useState(null),b=g.useRef(null);g.useEffect(()=>{if(s||!l)return;let j=!1;return(async()=>{try{const _=typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null,z=await fetch(l,{headers:_?{"X-Adapter-Name":_}:{}});if(!z.ok){console.warn("[ImageDisplay] Server returned",z.status,"for",l);return}if(j)return;const $=await z.arrayBuffer();if(j)return;const ee=new Blob([$],{type:`image/${i}`}),Y=URL.createObjectURL(ee);b.current=Y,v(Y)}catch(_){console.warn("[ImageDisplay] Failed to fetch image from",l,_)}})(),()=>{j=!0,b.current&&(URL.revokeObjectURL(b.current),b.current=null)}},[l,s,i]);const k=(s?`data:image/${i};base64,${s}`:null)??x;g.useEffect(()=>{if(!d)return;const j=_=>{_.key==="Escape"&&f(!1)};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[d]);const S=j=>{if(j.stopPropagation(),!k)return;const _=document.createElement("a");_.href=k,_.download=`generated-image.${i}`,_.click()};return k?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"generated-image-wrapper",style:{marginTop:"0.75rem"},children:[u.jsxs("div",{className:"generated-image-container",style:{position:"relative",display:"inline-block",cursor:"zoom-in",maxWidth:"100%"},onClick:()=>f(!0),title:c||"Generated image — click to enlarge",children:[u.jsx("img",{src:k,alt:c||"Generated image",style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",objectFit:"contain"}}),u.jsxs("div",{style:{position:"absolute",bottom:"8px",right:"8px",display:"flex",gap:"6px"},children:[u.jsx("button",{onClick:S,title:"Download image",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(pd,{size:14})}),u.jsx("button",{onClick:j=>{j.stopPropagation(),f(!0)},title:"View full size",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(ub,{size:14})})]})]}),c&&u.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[u.jsxs("button",{type:"button",onClick:()=>p(j=>!j),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":h,children:[h?u.jsx(Uo,{size:14}):u.jsx(di,{size:14}),h?"Hide prompt":"Show prompt"]}),h&&u.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[u.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:"Prompt"}),u.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:c})]})]})]}),d&&typeof document<"u"&&Yo.createPortal(u.jsxs("div",{onClick:()=>f(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.85)",zIndex:9999,overflow:"auto",padding:"56px 24px 24px"},children:[u.jsx("button",{onClick:j=>{j.stopPropagation(),f(!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:u.jsx(ua,{size:20})}),u.jsx("img",{src:k,alt:c||"Generated image",style:{display:"block",width:"auto",height:"auto",maxWidth:"calc(100vw - 48px)",maxHeight:"calc(100vh - 80px)",objectFit:"contain",borderRadius:"8px",margin:"0 auto"},onClick:j=>j.stopPropagation()})]}),document.body)]}):null}const Pu=[750,1500,3e3,5e3],Cy=new Set([403,404,409,425,429,500,502,503,504]),jy=s=>new Promise(l=>setTimeout(l,s));function vp({video:s,videoUrl:l,videoFormat:i="mp4",revisedPrompt:c,adapterName:d}){const[f,h]=g.useState(!1),[p,x]=g.useState(!1),[v,b]=g.useState(null),w=g.useRef(null);g.useEffect(()=>{if(s||!l)return;let _=!1;return(async()=>{try{const z=d||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null);let $=null;for(let q=0;q<=Pu.length&&($=await fetch(l,{headers:z?{"X-Adapter-Name":z}:{}}),!($.ok||!Cy.has($.status)||q===Pu.length));q+=1)if(await jy(Pu[q]),_)return;if(!($!=null&&$.ok)){console.warn("[VideoDisplay] Server returned",$.status,"for",l);return}if(_)return;const ee=await $.arrayBuffer();if(_)return;const Y=new Blob([ee],{type:`video/${i}`}),R=URL.createObjectURL(Y);w.current=R,b(R)}catch(z){console.warn("[VideoDisplay] Failed to fetch video from",l,z)}})(),()=>{_=!0,w.current&&(URL.revokeObjectURL(w.current),w.current=null)}},[l,s,i,d]);const S=(s?`data:video/${i};base64,${s}`:null)??v;g.useEffect(()=>{if(!f)return;const _=z=>{z.key==="Escape"&&h(!1)};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[f]);const j=_=>{if(_.stopPropagation(),!S)return;const z=document.createElement("a");z.href=S,z.download=`generated-video.${i}`,z.click()};return S?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"generated-video-wrapper",style:{marginTop:"0.75rem"},children:[u.jsxs("div",{style:{position:"relative",display:"inline-block",maxWidth:"100%"},children:[u.jsx("video",{src:S,controls:!0,style:{maxWidth:"100%",maxHeight:"480px",borderRadius:"8px",display:"block",backgroundColor:"#000"}}),u.jsxs("div",{style:{position:"absolute",bottom:"48px",right:"8px",display:"flex",gap:"6px"},children:[u.jsx("button",{onClick:j,title:"Download video",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(pd,{size:14})}),u.jsx("button",{onClick:_=>{_.stopPropagation(),h(!0)},title:"View full size",style:{background:"rgba(0,0,0,0.55)",border:"none",borderRadius:"6px",padding:"5px",cursor:"pointer",color:"#fff",display:"flex",alignItems:"center"},children:u.jsx(Hx,{size:14})})]})]}),c&&u.jsxs("div",{style:{marginTop:"8px",maxWidth:"480px"},children:[u.jsxs("button",{type:"button",onClick:()=>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":p,children:[p?u.jsx(Uo,{size:14}):u.jsx(di,{size:14}),p?"Hide prompt":"Show prompt"]}),p&&u.jsxs("div",{style:{marginTop:"8px",padding:"8px 10px",background:"rgba(128,128,128,0.08)",borderRadius:"6px"},children:[u.jsx("span",{style:{display:"block",fontSize:"0.65rem",fontWeight:600,opacity:.5,textTransform:"uppercase",letterSpacing:"0.06em",marginBottom:"3px"},children:"Prompt"}),u.jsx("span",{style:{fontSize:"0.8rem",lineHeight:1.45,opacity:.85},children:c})]})]})]}),f&&u.jsxs("div",{onClick:()=>h(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.9)",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center"},children:[u.jsx("button",{onClick:_=>{_.stopPropagation(),h(!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:u.jsx(ua,{size:20})}),u.jsx("video",{src:S,controls:!0,autoPlay:!0,style:{maxWidth:"92vw",maxHeight:"92vh",borderRadius:"8px"},onClick:_=>_.stopPropagation()})]})]}):null}let $o=null;function hg(s){$o=s}function Qo(){$o=null}async function Ad(){if(!$o)return null;try{return await $o()}catch{return null}}let id=!1,oi=null;const od=new Set;function pg(){od.forEach(s=>s())}function hn(){return id}function Ny(){return oi}function Zo(s){id!==s&&(id=s,!s&&oi!==null&&(oi=null),pg())}function sr(s){const l=typeof s=="string"&&s.trim().length>0?s.trim():null;oi!==l&&(oi=l,pg())}function Ty(s){return od.add(s),()=>{od.delete(s)}}const wp="orbitchat-guest-user-id";function So(s){if(typeof s!="string")return null;const l=s.trim();return l.length>0?l:null}function Ey(s){const l=s.split(".");if(l.length<2)return null;try{const i=l[1].replace(/-/g,"+").replace(/_/g,"/"),c=i.padEnd(Math.ceil(i.length/4)*4,"="),d=atob(c);return JSON.parse(d)}catch{return null}}function My(){const s=globalThis.crypto;if(s&&typeof s.randomUUID=="function")return`guest:orbitchat:${s.randomUUID()}`;if(!s||typeof s.getRandomValues!="function")throw new Error("Secure random number generation is unavailable");const l=new Uint8Array(16);return s.getRandomValues(l),`guest:orbitchat:${Array.from(l,c=>c.toString(16).padStart(2,"0")).join("")}`}function zy(){if(typeof window>"u")return"guest:orbitchat:server";const s=window.localStorage.getItem(wp);if(s&&s.trim().length>0)return s;const l=My();return window.localStorage.setItem(wp,l),l}async function gg(){const s=Ny();if(s)return s;const l=await Ad();if(l){const i=Ey(l),c=So(i==null?void 0:i.sub)||So(i==null?void 0:i.user_id)||So(i==null?void 0:i.preferred_username)||So(i==null?void 0:i.email);if(c)return c}return hn()?"authenticated:orbitchat:unknown":zy()}const Dy={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"},Sp={pdf:"PDF",docx:"Word document",xlsx:"Excel workbook",pptx:"PowerPoint deck",md:"Markdown document",csv:"CSV file"},Do=/[\uE000-\uF8FF]|\\[eE][0-9a-fA-F]{2,3}|\\[fF][0-8][0-9a-fA-F]{2,3}/,Ly=/((?:p\.)?generated-docx-preview-num-\d+-\d+:before\s*\{[^}]*?)content\s*:\s*"([^"]*)"\s*;([^}]*?\})/g;function Ry(s){var i;return Do.test(s)?`•${((i=s.match(/(?:\\9|\t|\u00A0| )+$/))==null?void 0:i[0])||"\\9"}`:null}function kp(s){Array.from(s.querySelectorAll("style")).forEach(c=>{const d=c.textContent;!d||!Do.test(d)||(c.textContent=d.replace(Ly,(f,h,p,x)=>{const v=Ry(p);if(!v)return f;const b=x.replace(/\s*font-family\s*:\s*[^;{}]+;?/gi,"");return`${h}content: "${v}";${b}`}))}),Array.from(s.querySelectorAll('span[style*="font-family"]')).forEach(c=>{if(!/\b(symbol|wingdings|webdings)\b/i.test(c.style.fontFamily))return;const d=c.textContent||"";Do.test(d)&&(c.textContent=d.replace(Do,"•"),c.style.fontFamily="")})}function Uy(s){return(s||"pdf").toLowerCase().replace(/^\./,"")||"pdf"}function Oy(s){const l=window.atob(s),i=new Uint8Array(l.length);for(let c=0;c<l.length;c+=1)i[c]=l.charCodeAt(c);return i.buffer}function $y(s){return s==="xlsx"||s==="csv"?u.jsx(Ux,{className:"h-5 w-5"}):s==="pptx"?u.jsx(tb,{className:"h-5 w-5"}):s==="md"?u.jsx(Rx,{className:"h-5 w-5"}):u.jsx(Ox,{className:"h-5 w-5"})}function _p({document:s,documentUrl:l,documentFormat:i="pdf",revisedPrompt:c,adapterName:d}){const f=Uy(i),[h,p]=g.useState(s||l?"loading":"idle"),[x,v]=g.useState(null),[b,w]=g.useState(null),[k,S]=g.useState([]),[j,_]=g.useState(""),[z,$]=g.useState(null),[ee,Y]=g.useState([]),[R,q]=g.useState(0),[N,X]=g.useState(!1),[U,Q]=g.useState(null),I=g.useRef(null),ae=g.useRef(null),fe=g.useRef(null),Ce=c||Sp[f]||"Generated document",te=g.useMemo(()=>`generated-document.${f}`,[f]),oe=Dy[f]||"application/octet-stream";g.useEffect(()=>{if(!s&&!l)return;let P=!1;return(async()=>{p("loading"),Q(null),S([]),_(""),$(null),Y([]),q(0);try{const xe=s?Oy(s):await(async()=>{const me=(d==null?void 0:d.trim())||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null),ue={"X-User-ID":await gg()};me&&(ue["X-Adapter-Name"]=me);const de=await Ad();de&&(ue.Authorization=`Bearer ${de}`);const we=await fetch(l,{headers:ue});if(!we.ok)throw new Error(`Server returned ${we.status}`);return we.arrayBuffer()})();if(P)return;const pe=new Blob([xe],{type:oe}),F=URL.createObjectURL(pe);if(I.current&&URL.revokeObjectURL(I.current),I.current=F,v(F),w(xe.slice(0)),f==="xlsx"){const{default:me}=await En(async()=>{const{default:we}=await import("./index-CZz_ECqk.js");return{default:we}},[]),de=(await me(pe))[0];_((de==null?void 0:de.sheet)||"First sheet"),S(((de==null?void 0:de.data)||[]).slice(0,100).map(we=>we.slice(0,30).map(W=>W==null?"":String(W))))}if(f==="md"&&$(new TextDecoder("utf-8").decode(xe)),f==="csv"){const me=new TextDecoder("utf-8").decode(xe),{default:ue}=await En(async()=>{const{default:we}=await import("./papaparse.min-CdRM_ppG.js").then(W=>W.p);return{default:we}},__vite__mapDeps([16,1])),de=ue.parse(me,{skipEmptyLines:!0});q(de.data.length),Y(de.data.slice(0,25))}p("ready")}catch(xe){if(P)return;console.warn("[DocumentDisplay] Failed to load document from",l,xe),Q(xe instanceof Error?xe.message:"Unable to load document"),p("error")}})(),()=>{P=!0,I.current&&(URL.revokeObjectURL(I.current),I.current=null)}},[d,s,l,f,oe]),g.useEffect(()=>{if(h!=="ready"||f!=="docx"||!b||!ae.current)return;const P=ae.current;P.replaceChildren(),En(()=>import("./docx-preview-C0UevYcE.js"),__vite__mapDeps([17,1])).then(async({renderAsync:ce})=>{await ce(b.slice(0),P,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),kp(P)}).catch(ce=>{console.warn("[DocumentDisplay] Failed to render DOCX preview",ce),Q("Unable to render document preview")})},[b,f,h]),g.useEffect(()=>{if(!N||f!=="docx"||!b||!fe.current)return;const P=fe.current;P.replaceChildren(),En(()=>import("./docx-preview-C0UevYcE.js"),__vite__mapDeps([17,1])).then(async({renderAsync:ce})=>{await ce(b.slice(0),P,void 0,{className:"generated-docx-preview",inWrapper:!1,ignoreWidth:!0,ignoreHeight:!0}),kp(P)}).catch(ce=>{console.warn("[DocumentDisplay] Failed to render modal DOCX preview",ce)})},[b,f,N]),g.useEffect(()=>{if(!N)return;const P=ce=>{ce.key==="Escape"&&X(!1)};return window.document.addEventListener("keydown",P),()=>window.document.removeEventListener("keydown",P)},[N]);const E=P=>{if(P==null||P.stopPropagation(),!x)return;const ce=window.document.createElement("a");ce.href=x,ce.download=te,ce.click()},V=h==="ready"&&(f==="pdf"||f==="docx"||f==="xlsx"||f==="md"||f==="csv"),H=V&&f!=="xlsx"&&f!=="csv";return h==="idle"?null:u.jsxs(u.Fragment,{children:[u.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:[u.jsxs("div",{className:"flex items-center gap-3 border-b border-gray-100 px-3 py-2.5 dark:border-[#3b3c49]",children:[u.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:$y(f)}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:Ce}),u.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[Sp[f]||`${f.toUpperCase()} document`,h==="loading"?" · Loading preview...":"",h==="error"?` · ${U||"Preview unavailable"}`:""]})]}),H&&u.jsx("button",{type:"button",onClick:()=>X(!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:"Open preview","aria-label":"Open preview",children:u.jsx(Lx,{className:"h-4 w-4"})}),u.jsx("button",{type:"button",onClick:E,disabled:!x,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:"Download document","aria-label":"Download document",children:u.jsx(pd,{className:"h-4 w-4"})})]}),V&&u.jsxs("div",{className:"max-h-[460px] overflow-auto bg-gray-50 dark:bg-[#171717]",children:[f==="pdf"&&x&&u.jsx("iframe",{src:x,title:Ce,className:"block h-[460px] w-full border-0 bg-white"}),f==="docx"&&u.jsx("div",{ref:ae,className:"min-h-[240px] bg-white p-5 text-sm text-[#111827] dark:bg-white dark:text-[#111827]"}),f==="xlsx"&&u.jsxs("div",{className:"p-3",children:[j&&u.jsx("p",{className:"mb-2 text-xs font-medium text-gray-500 dark:text-[#bfc2cd]",children:j}),u.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:u.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:u.jsx("tbody",{children:k.length>0?k.map((P,ce)=>u.jsx("tr",{className:ce===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:P.map((xe,pe)=>u.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:xe},pe))},ce)):u.jsx("tr",{children:u.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No sheet data found."})})})})})]}),f==="md"&&z!==null&&u.jsx("div",{className:"bg-white p-5 text-sm text-[#111827] dark:bg-[#171717] dark:text-[#ececf1]",children:u.jsx(el,{content:z,disableMath:!0})}),f==="csv"&&u.jsxs("div",{className:"p-3",children:[R>25&&u.jsxs("p",{className:"mb-2 text-xs text-gray-500 dark:text-[#bfc2cd]",children:["Showing first 25 of ",R," rows — download for the full file."]}),u.jsx("div",{className:"overflow-auto rounded-md border border-gray-200 bg-white dark:border-[#3b3c49] dark:bg-[#202123]",children:u.jsx("table",{className:"min-w-full border-collapse text-left text-xs",children:u.jsx("tbody",{children:ee.length>0?ee.map((P,ce)=>u.jsx("tr",{className:ce===0?"bg-gray-50 font-medium dark:bg-white/5":void 0,children:P.map((xe,pe)=>u.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:xe},pe))},ce)):u.jsx("tr",{children:u.jsx("td",{className:"px-3 py-4 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No data found."})})})})})]})]}),h==="ready"&&!V&&u.jsx("div",{className:"px-3 py-4 text-sm text-gray-600 dark:text-[#bfc2cd]",children:"Preview is not available for this format. Use download to open it locally."})]}),N&&x&&u.jsxs("div",{onClick:()=>X(!1),className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/85 p-4",children:[u.jsx("button",{onClick:P=>{P.stopPropagation(),X(!1)},className:"fixed right-4 top-4 flex items-center rounded-full border-0 bg-white/15 p-2 text-white",title:"Close preview","aria-label":"Close preview",children:u.jsx(ua,{className:"h-5 w-5"})}),u.jsxs("div",{onClick:P=>P.stopPropagation(),className:"h-[92vh] w-[92vw] overflow-auto rounded-lg bg-white",children:[f==="pdf"&&u.jsx("iframe",{src:x,title:Ce,className:"h-full w-full border-0"}),f==="docx"&&u.jsx("div",{ref:fe,className:"min-h-full bg-white p-8 text-[#111827]"}),f==="md"&&z!==null&&u.jsx("div",{className:"min-h-full bg-white p-8 text-sm text-[#111827]",children:u.jsx(el,{content:z,disableMath:!0})})]})]})]})}const qy=["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 ci(s,{enabled:l,onEscape:i}){g.useEffect(()=>{if(!l||!s.current)return;const c=s.current,d=document.activeElement,f=Array.from(c.querySelectorAll(qy)).filter(v=>v.tabIndex!==-1),h=f[0]||c,p=f[f.length-1]||c;h.focus({preventScroll:!0});const x=v=>{if(v.key==="Escape"){i==null||i();return}if(v.key!=="Tab")return;if(f.length===0){v.preventDefault(),c.focus({preventScroll:!0});return}const b=document.activeElement;if(v.shiftKey){(!b||b===h||!c.contains(b))&&(v.preventDefault(),p.focus({preventScroll:!0}));return}(!b||b===p||!c.contains(b))&&(v.preventDefault(),h.focus({preventScroll:!0}))};return document.addEventListener("keydown",x),()=>{var v;document.removeEventListener("keydown",x),(v=d==null?void 0:d.focus)==null||v.call(d,{preventScroll:!0})}},[l,i,s])}function qo({isOpen:s,onClose:l,onConfirm:i,title:c,message:d,confirmText:f="Confirm",cancelText:h="Cancel",type:p="danger",isLoading:x=!1}){const v=g.useRef(null);if(ci(v,{enabled:s,onEscape:l}),!s)return null;const b=()=>{x||i()},k=(()=>{switch(p){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"}}})(),S=u.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:u.jsxs("div",{ref:v,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:[u.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`w-10 h-10 rounded-full ${k.iconBg} flex items-center justify-center`,children:u.jsx(bd,{className:`w-5 h-5 ${k.icon}`})}),u.jsx("h2",{id:"confirm-title",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:c})]}),u.jsx("button",{type:"button",onClick:l,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors","aria-label":"Close",children:u.jsx(ua,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.jsx("div",{className:"p-6",children:u.jsx("p",{className:"text-gray-600 dark:text-gray-300 leading-relaxed",children:d})}),u.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:[u.jsx("button",{type:"button",onClick:l,disabled:x,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:h}),u.jsx("button",{type:"button",onClick:b,disabled:x,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 ${k.confirmButton}`,children:x?u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Clearing..."]}):f})]})]})});return typeof document>"u"?S:Yo.createPortal(S,document.body)}const By=["#","*","`","[","]","(",")","{","}","|","<",">"],xg=s=>By.some(l=>s.includes(l));function bg(s){if(!s||s.length<1e3)return!1;const l=/^[A-Za-z0-9+/=]+$/,i=s.replace(/\s+/g,"");if(i.length>1e4&&l.test(i)){const c=/\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(s),d=xg(s),f=/[-.,;:!?'"()]/.test(s);if(!c&&!d&&!f)return!0}return!!(i.length>5e4&&l.test(i)&&s.replace(/[A-Za-z0-9+/=\s]/g,"").length<10)}const Hy=/(?:\u202F|\u2009|\u200A|\u200B|\u200C|\u200D|\uFEFF)/g;function ri(s){if(!s)return s;let l=s.replace(Hy," ");if(bg(l))return"";const i=/([A-Za-z0-9+/=]{10000,})/g;return l=l.replace(i,c=>{const d=c.replace(/\s+/g,"");if(d.length>1e4&&/^[A-Za-z0-9+/=]+$/.test(d)){const f=/\b(function|const|let|var|class|return|import|export|if|else|while|for|true|false|null|def|print)\b/i.test(c),h=xg(c),p=/[-.,;:!?'"()]/.test(c);if(!f&&!h&&!p)return""}return c}),l}function cd(s,l=5e4){return!s||s.length<=l?s:bg(s)?"":s.substring(0,l)+`
|
|
331
331
|
|
|
332
|
-
... (content truncated due to length)`}const Fy={maxFilesPerConversation:ye.limits.files.perConversation,maxFileSizeMB:ye.limits.files.maxSizeMB,maxTotalFiles:ye.limits.files.totalFiles,maxConversations:ye.limits.conversations.maxConversations,maxMessagesPerConversation:ye.limits.conversations.maxMessagesPerConversation,maxMessagesPerThread:ye.limits.conversations.maxMessagesPerThread,maxTotalMessages:ye.limits.conversations.totalMessages,maxMessageLength:ye.limits.messages.maxLength};function Iy(
|
|
332
|
+
... (content truncated due to length)`}const Fy={maxFilesPerConversation:ye.limits.files.perConversation,maxFileSizeMB:ye.limits.files.maxSizeMB,maxTotalFiles:ye.limits.files.totalFiles,maxConversations:ye.limits.conversations.maxConversations,maxMessagesPerConversation:ye.limits.conversations.maxMessagesPerConversation,maxMessagesPerThread:ye.limits.conversations.maxMessagesPerThread,maxTotalMessages:ye.limits.conversations.totalMessages,maxMessageLength:ye.limits.messages.maxLength};function Iy(s){const l=ye.guestLimits;switch(s){case"maxConversations":return l.conversations.maxConversations;case"maxMessagesPerConversation":return l.conversations.messagesPerConversation;case"maxMessagesPerThread":return l.conversations.messagesPerThread;case"maxTotalMessages":return l.conversations.totalMessages;case"maxFilesPerConversation":return l.files.perConversation;case"maxTotalFiles":return l.files.totalFiles;case"maxMessageLength":return l.messages.maxLength;case"maxFileSizeMB":return l.files.maxSizeMB;default:return}}const Le=new Proxy(Fy,{get(s,l){if(va()&&!hn()){const i=Iy(l);if(i!==void 0)return i}return s[l]}});function ir(){return g.useSyncExternalStore(Ty,hn,hn)}class yg extends Error{constructor(i,c){super(i);ca(this,"status");ca(this,"statusText");this.name="ApiRequestError",this.status=c.status,this.statusText=c.statusText}}async function Dt(s={}){const l={"X-User-ID":await gg(),...s},i=await Ad();return i&&(l.Authorization=`Bearer ${i}`),l}function jn(s){return encodeURIComponent(s)}function Gy(s){return!s||s.length===0?"":`?file_ids=${s.map(encodeURIComponent).join(",")}`}async function ni(s){const l=`API request failed: ${s.status} ${s.statusText}`;try{if((s.headers.get("content-type")||"").includes("application/json")){const c=await s.json(),d=typeof c.detail=="string"&&c.detail.trim()||typeof c.error=="string"&&c.error.trim()||typeof c.message=="string"&&c.message.trim();if(d)return`${l}: ${d}`}else{const c=(await s.text()).trim();if(c)return`${l}: ${c}`}}catch{}return l}function Ap(s){if(!s.startsWith("data: "))return null;try{const l=JSON.parse(s.substring(6));return l.request_id&&!l.response&&!l.done?{text:"",done:!1,request_id:l.request_id}:{text:l.text||l.content||l.message||l.response||"",done:l.done||!1,request_id:l.request_id,audio:l.audio,audioFormat:l.audio_format||l.audioFormat,audio_chunk:l.audio_chunk,chunk_index:l.chunk_index,image:l.image,image_format:l.image_format,image_revised_prompt:l.image_revised_prompt,image_url:l.image_url,video:l.video,video_format:l.video_format,video_revised_prompt:l.video_revised_prompt,video_url:l.video_url,document:l.document,document_format:l.document_format,document_revised_prompt:l.document_revised_prompt,document_url:l.document_url,assistant_message_id:l.assistant_message_id,threading:l.threading}}catch{return null}}let ko=null;function Vy(){let s=null,l=null;const i=(d,f,h)=>{s=f||null,l=h||null},c=(d,f)=>({async*streamChat(h,p,x,v,b,w,k,S,j,_,z,$,ee){var q,N;const Y={messages:[{role:"user",content:h}],stream:p!==!1};x&&x.length>0&&(Y.file_ids=x),v&&(Y.thread_id=v),b&&(Y.audio_input=b),w&&(Y.audio_format=w),k&&(Y.language=k),S!==void 0&&(Y.return_audio=S),j&&(Y.tts_voice=j),_&&(Y.source_language=_),z&&(Y.target_language=z),$&&(Y.model=$),ee&&(Y.skill=ee);const R=await fetch("/api/v1/chat",{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d,...f?{"X-Session-ID":f}:{}}),body:JSON.stringify(Y)});if(!R.ok)throw new Error(await ni(R));if((q=R.headers.get("content-type"))!=null&&q.includes("text/event-stream")){const X=(N=R.body)==null?void 0:N.getReader(),U=new TextDecoder;let Q="";if(!X)throw new Error("Response body is not readable");for(;;){const{done:I,value:ae}=await X.read();if(I)break;Q+=U.decode(ae,{stream:!0});const fe=Q.split(`
|
|
333
333
|
`);Q=fe.pop()||"";for(const Ce of fe){const te=Ap(Ce);te&&(yield te)}}if(Q.trim())for(const I of Q.split(`
|
|
334
|
-
`)){const ae=Ap(I);ae&&(yield ae)}}else{const X=await R.json();yield{text:X.message||X.response||"",done:!0,audio:X.audio,audioFormat:X.audio_format||X.audioFormat,image:X.image,image_format:X.image_format,image_revised_prompt:X.image_revised_prompt,image_url:X.image_url,video:X.video,video_format:X.video_format,video_revised_prompt:X.video_revised_prompt,video_url:X.video_url,document:X.document,document_format:X.document_format,document_revised_prompt:X.document_revised_prompt,document_url:X.document_url,assistant_message_id:X.assistant_message_id,threading:X.threading}}},async createThread(h,p){const x=await fetch("/api/threads",{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d,"X-Session-ID":p}),body:JSON.stringify({message_id:h,session_id:p})});if(!x.ok)throw new Error(`Failed to create thread: ${x.statusText}`);return x.json()},async getThreadInfo(h){const p=await fetch(`/api/threads/${jn(h)}`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to get thread info: ${p.statusText}`);return p.json()},async deleteThread(h){const p=await fetch(`/api/threads/${jn(h)}`,{method:"DELETE",headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to delete thread: ${p.statusText}`);return p.json()},async submitFeedback(h,p,x){const v=await fetch("/api/feedback",{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d,"X-Session-ID":p}),body:JSON.stringify({message_id:h,session_id:p,feedback_type:x})});if(!v.ok)throw new Error(`Failed to submit feedback: ${v.statusText}`);return v.json()},async getSessionFeedback(h){const p=await fetch(`/api/feedback/${jn(h)}`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to get feedback: ${p.statusText}`);return p.json()},async clearConversationHistory(h){const p=h||f;if(!p)throw new Error("No session ID available for clearing conversation history");const x=await fetch(`/api/admin/chat-history/${jn(p)}`,{method:"DELETE",headers:await Dt({"X-Adapter-Name":d})});if(!x.ok)throw new Error(`Failed to clear history: ${x.statusText}`);return x.json()},async getConversationHistory(h,p){const x=h||f;if(!x)throw new Error("No session ID available for conversation history");const v=typeof p=="number"&&Number.isFinite(p)&&p>0?`?limit=${Math.floor(p)}`:"",b=await fetch(`/api/admin/chat-history/${jn(x)}${v}`,{headers:await Dt({"X-Adapter-Name":d})});if(!b.ok)throw new Error(`Failed to load history: ${b.statusText}`);return b.json()},async deleteConversationWithFiles(h,p){const x=h||f;if(!x)throw new Error("No session ID available for deleting conversation");const v=Gy(p),b=await fetch(`/api/admin/conversations/${jn(x)}${v}`,{method:"DELETE",headers:await Dt({"X-Adapter-Name":d})});if(!b.ok)throw new Error(`Failed to delete conversation: ${b.statusText}`);return b.json()},getSessionId:()=>f,async uploadFile(h){const p=new FormData;p.append("file",h);const x=await fetch("/api/files/upload",{method:"POST",headers:await Dt({"X-Adapter-Name":d}),body:p});if(!x.ok)throw new Error(`Failed to upload file: ${x.statusText}`);return x.json()},async listFiles(){const h=await fetch("/api/files",{headers:await Dt({"X-Adapter-Name":d})});if(!h.ok)throw new Error(`Failed to list files: ${h.statusText}`);const p=await h.json();return Array.isArray(p)?p:p.files||[]},async getFileInfo(h){const p=await fetch(`/api/files/${jn(h)}`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to get file info: ${p.statusText}`);return p.json()},async queryFile(h,p,x){const v=await fetch(`/api/files/${jn(h)}/query`,{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d}),body:JSON.stringify({query:p,max_results:x})});if(!v.ok)throw new Error(`Failed to query file: ${v.statusText}`);return v.json()},async deleteFile(h){const p=await fetch(`/api/files/${jn(h)}`,{method:"DELETE",headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to delete file: ${p.statusText}`);return p.json()},async validateApiKey(){const h=await fetch(`/api/admin/api-keys/${jn(d)}/status`,{headers:await Dt({"X-Adapter-Name":d})});if(!h.ok)throw new Error(`Failed to validate API key: ${h.statusText}`);return h.json()},async getAdapterInfo(){const h="/api/admin/adapters/info",p=w=>{if(!w)return 0;const k=Number(w);if(Number.isFinite(k)&&k>0)return Math.min(k*1e3,3e4);const S=Date.parse(w);if(!Number.isNaN(S)){const j=S-Date.now();if(j>0)return Math.min(j,3e4)}return 0},x=w=>new Promise(k=>setTimeout(k,w)),v=async()=>fetch(h,{headers:await Dt({"X-Adapter-Name":d})});let b=await v();if(b.status===429){const w=p(b.headers.get("Retry-After"));w>0&&(await x(w),b=await v())}if(!b.ok){const w=await b.text(),k=`${b.status} ${b.statusText}`.trim(),S=b.status===401?`Adapter info request was unauthorized for '${d}'. Verify the adapter exists and you have access.`:`Failed to load adapter info (${k}) for '${d}'.`;throw console.warn("[ProxyApi] Adapter info request failed",{adapter:d,status:b.status,statusText:b.statusText,details:w||void 0}),new yg(S,b)}return b.json()},async stopChat(h,p){const x=await fetch("/api/v1/chat/stop",{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d}),body:JSON.stringify({session_id:h,request_id:p})});return x.ok?(await x.json()).status==="cancelled":(console.warn(`[ProxyApi] stopChat failed: ${x.status} ${x.statusText}`),!1)},async getAdapterModels(h){const p=await fetch(`/api/admin/adapters/${encodeURIComponent(h)}/models`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(await ni(p));return p.json()},async getAllModels(){const h=await fetch("/api/admin/models",{headers:await Dt({"X-Adapter-Name":d})});if(!h.ok)throw new Error(await ni(h));return h.json()},async getAdapterSkills(h){const p=await fetch(`/api/admin/adapters/${encodeURIComponent(h)}/skills`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(await ni(p));return p.json()},async getAllSkills(){const h=await fetch("/api/admin/skills",{headers:await Dt({"X-Adapter-Name":d})});if(!h.ok)throw new Error(await ni(h));return h.json()}});return{configureApi:i,streamChat:async function*(d,f,h,p,x,v,b,w,k,S,j,_,z){if(!l)throw new Error("Adapter name is required");yield*c(l,r).streamChat(d,f,h,p,x,v,b,w,k,S,j,_,z)},stopChat:async(d,f)=>{if(!l)throw new Error("Adapter name is required");return c(l,r).stopChat(d,f)},ApiClient:class{constructor(f){ca(this,"client");const h=f.adapterName||null,p=f.sessionId||null;if(!h)throw new Error("Adapter name is required");this.client=c(h,p)}async*streamChat(...f){yield*this.client.streamChat(...f)}get createThread(){var f;return(f=this.client.createThread)==null?void 0:f.bind(this.client)}get getThreadInfo(){var f;return(f=this.client.getThreadInfo)==null?void 0:f.bind(this.client)}get deleteThread(){var f;return(f=this.client.deleteThread)==null?void 0:f.bind(this.client)}get submitFeedback(){var f;return(f=this.client.submitFeedback)==null?void 0:f.bind(this.client)}get getSessionFeedback(){var f;return(f=this.client.getSessionFeedback)==null?void 0:f.bind(this.client)}get clearConversationHistory(){var f;return(f=this.client.clearConversationHistory)==null?void 0:f.bind(this.client)}get getConversationHistory(){var f;return(f=this.client.getConversationHistory)==null?void 0:f.bind(this.client)}get deleteConversationWithFiles(){var f;return(f=this.client.deleteConversationWithFiles)==null?void 0:f.bind(this.client)}get getSessionId(){var f;return(f=this.client.getSessionId)==null?void 0:f.bind(this.client)}get uploadFile(){var f;return(f=this.client.uploadFile)==null?void 0:f.bind(this.client)}get listFiles(){var f;return(f=this.client.listFiles)==null?void 0:f.bind(this.client)}get getFileInfo(){var f;return(f=this.client.getFileInfo)==null?void 0:f.bind(this.client)}get queryFile(){var f;return(f=this.client.queryFile)==null?void 0:f.bind(this.client)}get deleteFile(){var f;return(f=this.client.deleteFile)==null?void 0:f.bind(this.client)}get validateApiKey(){var f;return(f=this.client.validateApiKey)==null?void 0:f.bind(this.client)}get getAdapterInfo(){var f;return(f=this.client.getAdapterInfo)==null?void 0:f.bind(this.client)}get stopChat(){var f;return(f=this.client.stopChat)==null?void 0:f.bind(this.client)}get getAdapterModels(){var f;return(f=this.client.getAdapterModels)==null?void 0:f.bind(this.client)}get getAllModels(){var f;return(f=this.client.getAllModels)==null?void 0:f.bind(this.client)}get getAdapterSkills(){var f;return(f=this.client.getAdapterSkills)==null?void 0:f.bind(this.client)}get getAllSkills(){var f;return(f=this.client.getAllSkills)==null?void 0:f.bind(this.client)}}}}async function Xy(){return ko||(le("Loading API via Express proxy"),ko=Vy(),le("API loaded successfully"),ko)}async function kt(){return await Xy()}class Cp{static async getAdapterSkills(l,i){const c=await kt(),d=new c.ApiClient({apiUrl:"",adapterName:i});return d.getAdapterSkills?(await d.getAdapterSkills(l)).available_skills:[]}static async getAllSkills(l){const i=await kt(),c=new i.ApiClient({apiUrl:"",adapterName:l});return c.getAllSkills?(await c.getAllSkills()).skills:[]}}const Yy=6e4;function vg(r={}){const{adapterName:l,enabled:i=!0,selectionScopeKey:c,supportsThreading:d=!1}=r,f=i&&!!l&&!d,h=c??l??"__default__",[p,x]=g.useState([]),[v,b]=g.useState(!1),[w,k]=g.useState(null),[S,j]=g.useState({}),_=g.useRef(null),z=g.useRef(new Map),$=g.useCallback(async q=>{var U,Q;const N=q,X=z.current.get(N);if(X&&X.expiresAt>Date.now()){x(X.skills),k(q);return}_.current&&_.current.abort(),_.current=new AbortController,b(!0);try{const[I,ae]=await Promise.all([Cp.getAdapterSkills(q,q),Cp.getAllSkills(q)]);if((U=_.current)!=null&&U.signal.aborted)return;const fe=ae.filter(Ce=>I.includes(Ce.name)&&Ce.enabled);z.current.set(N,{skills:fe,expiresAt:Date.now()+Yy}),x(fe),k(q),le("[useSkills] Loaded",fe.length,"skills for adapter",q)}catch(I){if(I instanceof Error&&I.name==="AbortError")return;Be("[useSkills] Failed to load skills:",I instanceof Error?I.message:String(I)),x([]),k(q)}finally{(Q=_.current)!=null&&Q.signal.aborted||b(!1)}},[]);g.useEffect(()=>{if(!f||!l)return;const q=window.setTimeout(()=>{$(l)},0);return()=>{var N;window.clearTimeout(q),(N=_.current)==null||N.abort()}},[f,l,$]);const ee=g.useCallback(q=>{j(N=>{const X=N[h]??null;if(X===q||(X==null?void 0:X.name)===(q==null?void 0:q.name))return N;const U={...N};return q?U[h]=q:delete U[h],U})},[h]),Y=g.useCallback(()=>{j(q=>{if(!q[h])return q;const N={...q};return delete N[h],N})},[h]),R=f?S[h]??null:null;return{skills:f&&w===l?p:[],isLoading:f?v||w!==l:!1,selectedSkill:R,selectSkill:ee,clearSkill:Y}}const jp=r=>{let l;const i=new Set,c=(v,b)=>{const w=typeof v=="function"?v(l):v;if(!Object.is(w,l)){const k=l;l=b??(typeof w!="object"||w===null)?w:Object.assign({},l,w),i.forEach(S=>S(l,k))}},d=()=>l,p={setState:c,getState:d,getInitialState:()=>x,subscribe:v=>(i.add(v),()=>i.delete(v))},x=l=r(c,d,p);return p},Qy=(r=>r?jp(r):jp),Zy=r=>r;function Ky(r,l=Zy){const i=Tn.useSyncExternalStore(r.subscribe,Tn.useCallback(()=>l(r.getState()),[r,l]),Tn.useCallback(()=>l(r.getInitialState()),[r,l]));return Tn.useDebugValue(i),i}const Np=r=>{const l=Qy(r),i=c=>Ky(l,c);return Object.assign(i,l),i},wg=(r=>r?Np(r):Np),wa=wg(r=>({showLoginPrompt:!1,promptMessage:"",openLoginPrompt:l=>r({showLoginPrompt:!0,promptMessage:l}),closeLoginPrompt:()=>r({showLoginPrompt:!1,promptMessage:""})})),_o=r=>{const l=r==null?void 0:r.trim();return l||(typeof window<"u"&&window.localStorage?localStorage.getItem("chat-adapter-name"):null)};class ui{static async uploadFile(l,i,c,d,f){try{const h=Le.maxFileSizeMB*1024*1024;if(l.size>h)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(l.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(l.name)||(l.type==="application/x-zip-compressed"||l.type==="application/zip")&&/\.xlsx$/i.test(l.name)))throw new Error(`File type not supported: ${l.type||"unknown"}`);i&&i({filename:l.name,progress:0,status:"uploading"});const v=await kt(),b=(d==null?void 0:d.trim())||_t(),w=_o(f);if(!w)throw new Error("Adapter not configured. Please select an adapter from the dropdown.");le(`Using adapter: ${w}`);const k=new v.ApiClient({apiUrl:b,sessionId:null,adapterName:w});if(!k.uploadFile)throw new Error("File upload is not available.");const S=await k.uploadFile(l);i&&i({filename:l.name,progress:75,status:"processing",fileId:S.file_id});let j;try{j=await this.pollFileStatus(S.file_id,30,2e3,void 0,b,w)}catch(_){const z=_ instanceof Error?_.message:String(_);if(z.includes("was deleted"))throw new Error(`File ${S.file_id} was deleted during upload`);Be(`File status polling failed for ${S.file_id}:`,_);const $=z.includes("processing failed")||z.includes("timeout");j={file_id:S.file_id,filename:S.filename,mime_type:S.mime_type,file_size:S.file_size,processing_status:$?"failed":S.status||"processing",chunk_count:S.chunk_count,error_message:$?z:void 0}}return i&&i({filename:l.name,progress:100,status:j.processing_status==="completed"?"completed":"processing",fileId:S.file_id}),j}catch(h){let p=h instanceof Error?h.message:"Upload failed";throw p.includes("401")&&(p="Authentication failed. Please check your adapter configuration."),i&&i({filename:l.name,progress:0,status:"error",error:p}),new Error(p)}}static async uploadFiles(l,i){const d=[],f=[];for(let h=0;h<l.length;h+=3){const p=l.slice(h,h+3),x=await Promise.allSettled(p.map(async(v,b)=>{const w=h+b;return this.uploadFile(v,k=>{i&&i(w,k)})}));for(let v=0;v<x.length;v++){const b=x[v],w=h+v;b.status==="fulfilled"?d.push(b.value):(qt(`Failed to upload file ${l[w].name}:`,b.reason),f.push({index:w,file:l[w].name,error:b.reason}))}}if(d.length===0&&f.length>0){const h=f[0].error;throw h instanceof Error?h:new Error(`All ${f.length} file uploads failed`)}return f.length>0&&Be(`[FileUploadService] ${f.length} of ${l.length} files failed to upload:`,f.map(h=>h.file)),d}static async listFiles(l,i,c){try{const d=await kt(),f=(i==null?void 0:i.trim())||_t(),h=_o(c);if(!h)throw new Error("Adapter not configured");const p=new d.ApiClient({apiUrl:f,sessionId:null,adapterName:h});if(!p.listFiles)throw new Error("File listing is not available.");const x=await p.listFiles();return(Array.isArray(x)?x:Array.isArray(x.files)?x.files:[]).map(b=>({file_id:b.file_id,filename:b.filename,mime_type:b.mime_type,file_size:b.file_size,upload_timestamp:b.upload_timestamp,processing_status:b.processing_status,chunk_count:b.chunk_count,error_message:b.error_message}))}catch(d){qt("Failed to list files:",d);const f=d instanceof Error?d.message:"Failed to list files";throw new Error(f)}}static async getFileInfo(l,i,c,d){try{const f=await kt(),h=(c==null?void 0:c.trim())||_t(),p=_o(d);if(!p)throw new Error("Adapter not configured");const x=new f.ApiClient({apiUrl:h,sessionId:null,adapterName:p});if(!x.getFileInfo)throw new Error("File info retrieval is not available.");const v=await x.getFileInfo(l);return{file_id:v.file_id,filename:v.filename,mime_type:v.mime_type,file_size:v.file_size,upload_timestamp:v.upload_timestamp,processing_status:v.processing_status,chunk_count:v.chunk_count,error_message:v.error_message}}catch(f){if(f instanceof Error&&(f.message.includes("404")||f.message.includes("File not found")))throw new Error(`File ${l} was deleted`);qt(`Failed to get file info for ${l}:`,f);const h=f instanceof Error?f.message:`Failed to get file info: ${l}`;throw new Error(h)}}static async pollFileStatus(l,i=30,c=2e3,d,f,h){for(let p=0;p<i;p++)try{if(d&&!d())throw new Error("Polling cancelled - component unmounted");const x=await this.getFileInfo(l,void 0,f,h);if(x.processing_status==="completed")return x;if(x.processing_status==="error"||x.processing_status==="failed"){const v=x.error_message;throw new Error(v||`File processing failed for ${l}`)}p<i-1&&await new Promise(v=>setTimeout(v,c))}catch(x){const v=x instanceof Error?x.message:String(x);if(v.includes("404")||v.includes("File not found")||v.includes("was deleted"))throw new Error(`File ${l} was deleted during upload`);if(v.includes("component unmounted")||v.includes("processing failed")||v.includes("processing_status")||v.includes("401")||v.includes("403")||v.includes("500")||v.includes("502")||v.includes("503")||v.includes("Authentication")||v.includes("Adapter not configured"))throw x;if(p<i-1){await new Promise(b=>setTimeout(b,c));continue}throw x}throw new Error(`File processing timeout: ${l} did not complete within ${i*c/1e3} seconds`)}static async deleteFile(l,i,c,d){try{const f=await kt(),h=(c==null?void 0:c.trim())||_t(),p=_o(d);if(!p)throw new Error("Adapter not configured");const x=new f.ApiClient({apiUrl:h,sessionId:null,adapterName:p});if(!x.deleteFile)throw new Error("File deletion is not available.");return await x.deleteFile(l)}catch(f){if(f instanceof Error&&(f.message.includes("404")||f.message.includes("File not found")||f.message.includes("Not Found")))return le(`File ${l} was already deleted from server`),{message:"File already deleted",file_id:l};qt(`Failed to delete file ${l}:`,f);const h=f instanceof Error?f.message:`Failed to delete file: ${l}`;throw new Error(h)}}}class Jy{constructor(){ca(this,"audioQueue",[]);ca(this,"isPlaying",!1);ca(this,"currentAudio",null);ca(this,"audioContext",null);ca(this,"isEnabled",!1);ca(this,"onPlaybackStart",null);ca(this,"onPlaybackEnd",null);ca(this,"mimeTypeCache",new Map);ca(this,"onChunkPlayed",null);ca(this,"blobUrls",[]);ca(this,"suppressPlaybackErrors",!1)}async enableAudio(){var l,i;try{if(!this.audioContext){const f=typeof AudioContext<"u"?AudioContext:typeof window<"u"&&window.webkitAudioContext||null;f&&(this.audioContext=new f)}const c=((l=this.audioContext)==null?void 0:l.state)==="suspended"?this.audioContext.resume():Promise.resolve();let d=Promise.resolve();try{const f=this.createSilentWavBlob(),h=URL.createObjectURL(f),p=new Audio;p.setAttribute("playsinline",""),p.setAttribute("webkit-playsinline",""),p.src=h,p.volume=0,d=p.play().then(()=>{p.pause()}).catch(()=>{le("[AudioStreamManager] HTMLAudioElement silent unlock failed (will retry on next gesture)")}).finally(()=>{URL.revokeObjectURL(h)})}catch{le("[AudioStreamManager] Could not create silent audio element")}if(await c,this.audioContext&&this.audioContext.state==="running"){const f=this.audioContext.createBuffer(1,1,22050),h=this.audioContext.createBufferSource();h.buffer=f,h.connect(this.audioContext.destination),h.start(0)}return await d,this.isEnabled=!0,le("[AudioStreamManager] Audio playback enabled",{audioContextState:(i=this.audioContext)==null?void 0:i.state}),!0}catch(c){return He("[AudioStreamManager] Failed to enable audio:",c),!1}}createSilentWavBlob(){const h=new ArrayBuffer(844),p=new DataView(h),x=(v,b)=>{for(let w=0;w<b.length;w++)p.setUint8(v+w,b.charCodeAt(w))};return x(0,"RIFF"),p.setUint32(4,836,!0),x(8,"WAVE"),x(12,"fmt "),p.setUint32(16,16,!0),p.setUint16(20,1,!0),p.setUint16(22,1,!0),p.setUint32(24,8e3,!0),p.setUint32(28,8e3*2,!0),p.setUint16(32,2,!0),p.setUint16(34,16,!0),x(36,"data"),p.setUint32(40,800,!0),new Blob([h],{type:"audio/wav"})}disableAudio(){!this.isEnabled&&!this.isPlaying||(this.isEnabled=!1,this.stop(),le("[AudioStreamManager] Audio playback disabled"))}async ensureAudioContext(){var l;if(!this.audioContext){const i=typeof AudioContext<"u"?AudioContext:typeof window<"u"&&window.webkitAudioContext||null;if(i)try{this.audioContext=new i}catch(c){return He("[AudioStreamManager] Failed to create AudioContext:",c),!1}}if(((l=this.audioContext)==null?void 0:l.state)==="suspended")try{await this.audioContext.resume()}catch(i){return le("[AudioStreamManager] AudioContext resume deferred",i),!1}return!0}resolveMimeType(l){const i=this.mimeTypeCache.get(l);if(i)return i;let c;switch(l){case"mp3":c="audio/mpeg";break;case"wav":c="audio/wav";break;case"webm":c="audio/webm";break;case"ogg":c="audio/ogg";break;case"opus":{const d=typeof document<"u"?document.createElement("audio"):null;d!=null&&d.canPlayType("audio/ogg; codecs=opus")?c="audio/ogg; codecs=opus":d!=null&&d.canPlayType("audio/webm; codecs=opus")?c="audio/webm; codecs=opus":c="audio/mp4";break}default:c=`audio/${l}`}return this.mimeTypeCache.set(l,c),le(`[AudioStreamManager] Resolved MIME type for "${l}": ${c}`),c}isAudioEnabled(){return this.isEnabled}setOnPlaybackStart(l){this.onPlaybackStart=l}setOnPlaybackEnd(l){this.onPlaybackEnd=l}setOnChunkPlayed(l){this.onChunkPlayed=l}async addChunk(l){if(!this.isEnabled){le(`[AudioStreamManager] Audio disabled, dropping chunk ${l.chunkIndex}`);return}le(`[AudioStreamManager] Adding chunk ${l.chunkIndex} to queue`),this.audioQueue.push(l),this.audioQueue.sort((i,c)=>i.chunkIndex-c.chunkIndex),this.isPlaying||this.playNextChunk().catch(i=>{He("[AudioStreamManager] Playback chain error:",i)})}async playNextChunk(){var i,c;if(this.audioQueue.length===0){this.isPlaying=!1,le("[AudioStreamManager] Queue empty, playback complete"),this.onPlaybackEnd&&this.onPlaybackEnd();return}if(!this.isEnabled){le("[AudioStreamManager] Audio not enabled, skipping playback"),this.audioQueue=[],this.isPlaying=!1;return}this.suppressPlaybackErrors=!1,await this.ensureAudioContext(),this.isPlaying=!0;const l=this.audioQueue.shift();try{if(!this.isPlaying)return;if(this.onPlaybackStart&&l.chunkIndex===0&&this.onPlaybackStart(),le(`[AudioStreamManager] Playing chunk ${l.chunkIndex}`),!l.audio||l.audio.length===0)throw new Error(`Empty audio data for chunk ${l.chunkIndex}`);let d;try{d=atob(l.audio)}catch(w){throw new Error(`Failed to decode base64 audio for chunk ${l.chunkIndex}: ${w instanceof Error?w.message:String(w)}`)}if(d.length===0)throw new Error(`Decoded audio data is empty for chunk ${l.chunkIndex}`);const f=new Uint8Array(d.length);for(let w=0;w<d.length;w++)f[w]=d.charCodeAt(w);const h=this.resolveMimeType(l.audioFormat),p=new Blob([f],{type:h}),x=URL.createObjectURL(p);this.blobUrls.push(x);const v=()=>{if(this.currentAudio){try{this.currentAudio.pause()}catch{}this.currentAudio.removeAttribute("src"),this.currentAudio.load()}URL.revokeObjectURL(x),this.blobUrls=this.blobUrls.filter(w=>w!==x)};let b=!1;try{b=await this.playViaAudioElement(x,l,h,v)}catch{b=!1}if(!b&&!this.suppressPlaybackErrors&&this.audioContext){le(`[AudioStreamManager] HTMLAudioElement failed for chunk ${l.chunkIndex}, trying AudioContext fallback`);try{b=await this.playViaAudioContext(f.buffer,l.chunkIndex)}catch(w){He(`[AudioStreamManager] AudioContext fallback also failed for chunk ${l.chunkIndex}:`,w)}v()}this.currentAudio=null,this.playNextChunk().catch(w=>{He("[AudioStreamManager] Playback chain error:",w)})}catch(d){if(this.suppressPlaybackErrors){le("[AudioStreamManager] Playback stopped, suppressing audio error");return}const f=d instanceof Error?d.message:String(d);console.error(`[AudioStreamManager] Failed to play chunk ${l.chunkIndex}:`,f,d,{audioFormat:l.audioFormat,chunkIndex:l.chunkIndex,audioLength:(i=l.audio)==null?void 0:i.length,audioContextState:(c=this.audioContext)==null?void 0:c.state,isEnabled:this.isEnabled}),He(`[AudioStreamManager] Failed to play chunk ${l.chunkIndex}:`,d),this.playNextChunk().catch(h=>{He("[AudioStreamManager] Playback chain error after recovery:",h)})}}playViaAudioElement(l,i,c,d){return new Promise(f=>{const h=new Audio;h.setAttribute("playsinline",""),h.setAttribute("webkit-playsinline",""),h.src=l,this.currentAudio=h;let p=!1;const x=w=>{p||(p=!0,f(w))},v=()=>{if(this.suppressPlaybackErrors){d(),x(!0);return}const w=h.error;He(`[AudioStreamManager] Media error on chunk ${i.chunkIndex}:`,w?{code:w.code,message:w.message,SRC_NOT_SUPPORTED:w.code===MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED}:"unknown"),d(),x(!1)};h.addEventListener("error",v,{once:!0});const b=async()=>{if(!p)try{h.addEventListener("ended",()=>{p||(le(`[AudioStreamManager] Chunk ${i.chunkIndex} finished`),this.onChunkPlayed&&this.onChunkPlayed(i.chunkIndex),d(),x(!0))},{once:!0}),await h.play()}catch(w){if(this.suppressPlaybackErrors){d(),x(!0);return}le(`[AudioStreamManager] audio.play() rejected for chunk ${i.chunkIndex}:`,w),d(),x(!1)}};h.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?b():h.addEventListener("canplay",()=>b(),{once:!0})})}playViaAudioContext(l,i){return new Promise((c,d)=>{if(!this.audioContext){d(new Error("No AudioContext"));return}const f=l.slice(0);this.audioContext.decodeAudioData(f,h=>{if(!this.audioContext||this.suppressPlaybackErrors){c(!0);return}const p=this.audioContext.createBufferSource();p.buffer=h,p.connect(this.audioContext.destination),p.onended=()=>{le(`[AudioStreamManager] Chunk ${i} finished (AudioContext path)`),this.onChunkPlayed&&this.onChunkPlayed(i),c(!0)},p.start(0)},h=>{d(h)})})}stop(){le("[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(l=>URL.revokeObjectURL(l)),this.blobUrls=[]}reset(){this.stop(),le("[AudioStreamManager] Manager reset")}getQueueSize(){return this.audioQueue.length}isCurrentlyPlaying(){return this.isPlaying}}const Ul=new Jy,Py=ry()||Vb(),Sg=()=>{if(Vo())return yd()||void 0},ii=(r,l,i)=>({id:r,sessionId:l,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiUrl:i,adapterName:Sg(),adapterLoadError:null}),Bo=()=>{const r=localStorage.getItem("chatbot-session-id");if(r)return r;const l=`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return localStorage.setItem("chatbot-session-id",l),l},Wy=r=>{localStorage.setItem("chatbot-session-id",r)};let ev=0;const Lo=r=>{const l=Date.now(),i=++ev,c=Math.random().toString(36).substr(2,9);return`msg_${l}_${i}_${c}_${r}`},Ol=()=>{const r=Date.now(),l=Math.random().toString(36).substr(2,9);return`session_${r}_${l}`},Tp=r=>r.filter(l=>!l.isThreadMessage&&!(l.role==="assistant"&&l.isStreaming)).length,Ep=r=>r.flatMap(i=>[i.imageUrl,i.videoUrl,i.documentUrl]).map(i=>{var c;return((c=i==null?void 0:i.match(/\/api\/files\/([^/]+)\/content/))==null?void 0:c[1])??null}).filter(i=>i!==null),tv=(r,l)=>{if(r instanceof Date)return new Date(r);if(typeof r=="number"&&Number.isFinite(r)){const i=new Date(r);if(!Number.isNaN(i.getTime()))return i}if(typeof r=="string"){const i=new Date(r);if(!Number.isNaN(i.getTime()))return i}return l?new Date(l):new Date},av=(r,l)=>{const i=new Map;l.forEach((d,f)=>{d.databaseMessageId&&i.set(d.databaseMessageId,{message:d,index:f})});const c=new Set;return r.map((d,f)=>{var w;const h=d.role==="user"?"user":"assistant",p=typeof d.message_id=="string"&&d.message_id.length>0?d.message_id:void 0;let x;if(p&&i.has(p)){const k=i.get(p);x=k.message,c.add(k.index)}else{const k=f<l.length?f:0;if(!c.has(k)&&((w=l[k])==null?void 0:w.role)===h)x=l[k],c.add(k);else for(let S=1;S<l.length;S++){const j=(k+S)%l.length;if(!c.has(j)&&l[j].role===h){x=l[j],c.add(j);break}}}const v=d.timestamp?tv(d.timestamp,x==null?void 0:x.timestamp):x!=null&&x.timestamp?new Date(x.timestamp):new Date,b=x?{...x,content:d.content??x.content,timestamp:v}:{id:p?`srv_${p}`:Lo(h),content:d.content||"",role:h,timestamp:v};if(b.isStreaming=!1,p&&(b.databaseMessageId=p),!b.supportsThreading&&d.metadata&&typeof d.metadata=="object"){const k=d.metadata,S=k==null?void 0:k.retrieved_docs;Array.isArray(S)&&S.length>0&&(b.supportsThreading=!0)}return b})},nv=(r,l)=>{if(r.length!==l.length)return!1;for(let i=0;i<r.length;i++){const c=r[i],d=l[i];if(c.role!==d.role||c.content!==d.content||(c.databaseMessageId||null)!==(d.databaseMessageId||null)||+c.timestamp!=+d.timestamp)return!1}return!0},Mp=r=>{var d,f,h,p,x,v;const l=((f=(d=r.adapterInfo)==null?void 0:d.adapter_name)==null?void 0:f.includes("voice"))||((p=(h=r.adapterInfo)==null?void 0:h.adapter_name)==null?void 0:p.includes("audio"))||((v=(x=r.adapterInfo)==null?void 0:x.adapter_name)==null?void 0:v.includes("multilingual"));let i=!1;try{const b=localStorage.getItem("chat-settings");b&&(i=JSON.parse(b).voiceEnabled===!0)}catch{Be("Failed to read global voice setting")}const c=r.audioSettings;return{returnAudio:(c==null?void 0:c.enabled)??i??!!l,ttsVoice:(c==null?void 0:c.ttsVoice)||void 0,language:(c==null?void 0:c.language)||"en-US",audioFormat:c==null?void 0:c.audioFormat}},lv=300;let Ao=null;const na=r=>{Ao&&clearTimeout(Ao),Ao=setTimeout(()=>{Ao=null;try{const l=r(),i=l.conversations.map(c=>({...c,messages:c.messages.map(d=>d.audio||d.image||d.video||d.document?Object.fromEntries(Object.entries(d).filter(([h])=>h!=="audio"&&h!=="image"&&h!=="video"&&h!=="document")):d)}));localStorage.setItem("chat-state",JSON.stringify({conversations:i,currentConversationId:l.currentConversationId}))}catch(l){l instanceof DOMException&&l.name==="QuotaExceededError"?Be("[chatStore] localStorage quota exceeded — skipping save"):qt("[chatStore] Failed to save state to localStorage:",l)}},lv)},rv=32,ls=new Map;let zl=null,Ba=null,Wn=null,ur=null;const zp=(r,l)=>{const i=ls.get(r);if(i){if(i.timeoutId&&(clearTimeout(i.timeoutId),i.timeoutId=null),i.content){const c=i.content;i.content="",l(d=>({conversations:d.conversations.map(f=>{if(f.id!==r)return f;const h=[...f.messages],p=h[h.length-1];return p&&p.role==="assistant"&&p.isStreaming&&(h[h.length-1]={...p,content:p.content+c}),{...f,messages:h,updatedAt:new Date}})}))}ls.delete(r)}},Dl=(r,l,i)=>({conversations:r.conversations.map(c=>{var h;if(c.id!==l)return c;const d=[...c.messages],f=d.length-1;return((h=d[f])==null?void 0:h.role)==="assistant"&&(d[f]={...d[f],...i(d[f])}),{...c,messages:d,updatedAt:new Date}})});let Ho=!1,Fo="";async function li(){if(Ho&&Fo)return!0;try{const r=await kt(),l=localStorage.getItem("chat-api-url");l&&l===ld&&localStorage.removeItem("chat-api-url");const i=l&&l!==ld?l:_t(),c=Bo(),d=localStorage.getItem("chat-adapter-name")||Py;return r.configureApi(i,c,d),Fo=i,Ho=!0,!0}catch(r){return qt("Failed to configure API:",r),!1}}const Ve=wg((r,l)=>({conversations:[],currentConversationId:null,isLoading:!1,error:null,sessionId:Bo(),getSessionId:()=>l().sessionId,configureApiSettings:async(i,c,d)=>{const f=l(),h=f.conversations.find(x=>x.id===f.currentConversationId),p=(h==null?void 0:h.sessionId)||c||Bo();c&&Wy(c),r({sessionId:p});try{const x=await kt();if(!d||!d.trim())throw new Error("Adapter name is required");x.configureApi(i,p,d),Fo=i,Ho=!0;let v;try{const b=new x.ApiClient({apiUrl:i,sessionId:null,adapterName:d});typeof b.getAdapterInfo=="function"&&(v=await b.getAdapterInfo(),le("Adapter info loaded:",v))}catch(b){Be("Failed to load adapter info:",b)}if(h)r(b=>({conversations:b.conversations.map(w=>w.id===h.id?{...w,adapterName:d,apiUrl:i,adapterInfo:v,adapterLoadError:null,updatedAt:new Date}:w)}));else if(d&&d.trim()){const b=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=Ol();r(k=>({conversations:[...k.conversations,{id:b,sessionId:w,title:"New Conversation",messages:[],createdAt:new Date,updatedAt:new Date,adapterName:d,apiUrl:i,adapterInfo:v,adapterLoadError:null}],currentConversationId:b}))}}catch(x){throw He("Failed to configure API:",x),r({isLoading:!1}),x instanceof Error?x:new Error("Failed to configure API settings")}d?localStorage.setItem("chat-adapter-name",d):localStorage.removeItem("chat-adapter-name"),r({isLoading:!1})},createConversation:()=>{var b;const i=l(),c=Le.maxConversations,d=i.conversations.length,f=i.currentConversationId?i.conversations.find(w=>w.id===i.currentConversationId):null;if(c!==null&&d>=c){if(va()&&!hn()){const k=`You've reached the guest limit of ${c} conversation${c===1?"":"s"}. Sign in to unlock more conversations, or delete conversations to start over.`;throw r({error:k}),wa.getState().openLoginPrompt(k),new Error("Guest conversation limit reached")}const w=`Maximum of ${c} conversations reached. Please delete an existing conversation before starting a new one.`;throw r({error:w}),new Error(w)}const h=!!f&&(f.messages.length>0||(((b=f.attachedFiles)==null?void 0:b.length)||0)>0);if(f&&!h){const w="Finish or delete the current conversation before starting a new one.";throw r({error:w}),new Error(w)}const p=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,x=Ol(),v={id:p,sessionId:x,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiUrl:_t(),adapterName:Sg(),adapterLoadError:null};return r(w=>({conversations:[v,...w.conversations],currentConversationId:p,sessionId:x,isLoading:!1})),na(l),p},selectConversation:async i=>{const c=l().conversations.find(d=>d.id===i);if(c){const d=c.messages.some(x=>x.role==="assistant"&&x.isStreaming);r({currentConversationId:i,sessionId:c.sessionId,isLoading:d});const f=c.apiUrl||_t(),h=c.adapterName;if(await li()&&h){const x=await kt();if(x.configureApi(f,c.sessionId,h),!c.adapterInfo)try{const v=new x.ApiClient({apiUrl:f,sessionId:null,adapterName:h});if(typeof v.getAdapterInfo=="function"){const b=await v.getAdapterInfo();le("Adapter info loaded for conversation:",b),r(w=>({conversations:w.conversations.map(k=>k.id===i?{...k,adapterInfo:b,adapterLoadError:null,updatedAt:new Date}:k)})),na(l)}}catch(v){Be("Failed to load adapter info for conversation:",v)}}l().loadFeedbackForConversation(c.sessionId).catch(()=>{})}na(l)},deleteConversation:async i=>{var f,h;const c=l(),d=c.conversations.find(p=>p.id===i);if(le(`🗑️ Deleting conversation ${i}:`,{conversationId:i,sessionId:d==null?void 0:d.sessionId,title:d==null?void 0:d.title,messageCount:d==null?void 0:d.messages.length,fileCount:((f=d==null?void 0:d.attachedFiles)==null?void 0:f.length)||0}),c.currentConversationId===i&&Ul.stop(),d!=null&&d.sessionId)try{if(!await li())qt("Failed to configure API for conversation deletion");else{const x=d.apiUrl||_t(),v=d.adapterName;v?le(`Using conversation's adapter for deletion: ${v} (conversation: ${i})`):Be(`Skipping server deletion for conversation ${i}: adapter not configured`);const b=await kt(),w=new b.ApiClient({apiUrl:x,sessionId:d.sessionId,adapterName:v}),k=((h=d.attachedFiles)==null?void 0:h.map(_=>_.file_id))||[],S=Ep(d.messages||[]),j=[...k,...S];if(le(`🔧 Calling deleteConversationWithFiles for session: ${d.sessionId}`),w.deleteConversationWithFiles){const _=await w.deleteConversationWithFiles(d.sessionId,j);le(`✅ Deleted conversation and files for session: ${d.sessionId}`,_),le(` - Deleted ${_.deleted_messages} messages`),le(` - Deleted ${_.deleted_files} files`),_.file_deletion_errors&&_.file_deletion_errors.length>0&&Be(` - Errors deleting files: ${_.file_deletion_errors.join(", ")}`)}else Be("⚠️ deleteConversationWithFiles method not available on API client")}}catch(p){qt("Failed to clear conversation history from server:",p)}else Be(`⚠️ No session ID found for conversation ${i}, skipping server-side deletion`);r(p=>{var b;const x=p.conversations.filter(w=>w.id!==i),v=p.currentConversationId===i?((b=x[0])==null?void 0:b.id)||null:p.currentConversationId;if(x.length===0){const w=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,k=Ol(),S=ii(w,k,_t());return na(l),{conversations:[S],currentConversationId:w,sessionId:k}}return na(l),{conversations:x,currentConversationId:v}})},deleteAllConversations:async()=>{const c=[...l().conversations];le(`🗑️ Deleting all conversations (${c.length} total)`),Ul.stop();const d=c.map(async b=>{var w;if(b!=null&&b.sessionId)try{if(!await li()){qt("Failed to configure API for conversation deletion");return}const S=b.adapterName;if(!S){le(`Skipping server deletion for conversation ${b.id}: adapter not configured`);return}const j=await kt(),_=new j.ApiClient({apiUrl:Ha(b.apiUrl),sessionId:b.sessionId,adapterName:S}),z=[...((w=b.attachedFiles)==null?void 0:w.map($=>$.file_id))||[],...Ep(b.messages||[])];_.deleteConversationWithFiles?(await _.deleteConversationWithFiles(b.sessionId,z),le(`✅ Deleted conversation ${b.id} and files`)):Be(`deleteConversationWithFiles not available for conversation ${b.id}`)}catch(k){qt(`Failed to delete conversation ${b.id} from server:`,k)}}),h=(await Promise.allSettled(d)).filter(b=>b.status==="rejected");h.length>0&&qt(`Some conversations failed to delete from server: ${h.length}`,h);const p=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,x=Ol(),v=ii(p,x,_t());r({conversations:[v],currentConversationId:p,sessionId:x}),na(l)},deleteThread:async(i,c,d)=>{const f=l().conversations.find(w=>w.id===i);if(!f)throw new Error("Conversation not found");if(!f.adapterName)throw new Error("Adapter not configured for this conversation");const h=f.messages.find(w=>w.id===c);if(!(h!=null&&h.threadInfo)||h.threadInfo.thread_id!==d)throw new Error("Thread not found for this message");const p=Ha(f.apiUrl||_t()),x=await kt(),v=new x.ApiClient({apiUrl:p,sessionId:f.sessionId,adapterName:f.adapterName});await new(await En(async()=>{const{ThreadService:w}=await import("./threadService-B9Db3n0J.js");return{ThreadService:w}},[])).ThreadService(v).deleteThread(d),r(w=>({conversations:w.conversations.map(k=>{var _;if(k.id!==i)return k;const S=k.messages.filter(z=>z.isThreadMessage?!(z.threadId===d||z.parentMessageId===c):!0).map(z=>z.id!==c?z:{...z,threadInfo:void 0,supportsThreading:!0}),j=k.currentThreadId===d||k.currentThreadSessionId===((_=h.threadInfo)==null?void 0:_.thread_session_id);return{...k,messages:S,currentThreadId:j?void 0:k.currentThreadId,currentThreadSessionId:j?void 0:k.currentThreadSessionId,updatedAt:new Date}})})),na(l)},sendMessage:async(i,c,d,f,h)=>{var x;let p=null;try{if(l().isLoading){Be("Another request is already in progress");return}if(!await li())throw new Error("API not properly configured. Please configure API settings first.");let b=l().currentConversationId;b||(b=l().createConversation());const w=l().conversations.find(U=>U.id===b);if(!w)throw new Error("Conversation not found");const k=Le.maxConversations;if(va()&&!hn()&&k!==null&&l().conversations.length>k){wa.getState().openLoginPrompt(`You've reached the guest limit of ${k} conversation${k===1?"":"s"}. Sign in to continue chatting.`),r({isLoading:!1});return}const S=c?c.map(U=>{var I;const Q=(I=w==null?void 0:w.attachedFiles)==null?void 0:I.find(ae=>ae.file_id===U);return Q||{file_id:U,filename:"",mime_type:"",file_size:0}}).filter(U=>U!==void 0):[];S.length>0&&S.forEach(U=>{l().addFileToConversation(b,U)});const j=d||null;let _,z=null;if(j){if(_=w.messages.find(U=>{var Q;return((Q=U.threadInfo)==null?void 0:Q.thread_id)===j}),!_)throw new Error("Thread metadata not found. Please recreate the thread from this message.");if(z=((x=_.threadInfo)==null?void 0:x.thread_session_id)||null,!z)throw new Error("Thread session is missing. Please recreate the thread from this message.")}const $=Tp(w.messages),ee=Le.maxMessagesPerConversation;if(ee!==null&&$>=ee){va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${ee} messages per conversation. Sign in to send more messages, or delete conversations to start over.`),Be(`[chatStore] Conversation ${b} reached the message limit (${ee}).`),r({isLoading:!1});return}const Y=Le.maxTotalMessages;if(Y!==null&&l().conversations.reduce((Q,I)=>Q+Tp(I.messages),0)>=Y){va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${Y} total messages. Sign in to continue chatting, or delete conversations to start over.`),Be(`[chatStore] Workspace reached the total message limit (${Y}).`),r({isLoading:!1});return}const R={id:Lo("user"),content:i,role:"user",timestamp:new Date,attachments:S.length>0?S:void 0},q=Lo("assistant"),N={id:q,content:"",role:"assistant",timestamp:new Date,isStreaming:!0};if(j&&_){R.isThreadMessage=!0,R.threadId=j,R.parentMessageId=_.id,N.isThreadMessage=!0,N.threadId=j,N.parentMessageId=_.id;const U=Le.maxMessagesPerThread;if(U!==null&&w.messages.filter(I=>I.isThreadMessage?(I.threadId===j||I.parentMessageId===_.id)&&!(I.role==="assistant"&&I.isStreaming):!1).length>=U){va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${U} messages per thread. Sign in to continue this thread, or delete conversations to start over.`),Be(`[chatStore] Thread ${j} reached the message limit (${U}).`),r({isLoading:!1});return}}r(U=>{const Q=U.conversations.find(ae=>ae.id===b),I=(Q==null?void 0:Q.messages.filter(ae=>ae.role==="assistant"&&ae.isStreaming))||[];return I.length>0&&Be(`Cleaning up ${I.length} existing streaming messages`),{conversations:U.conversations.map(ae=>{if(ae.id!==b)return ae;const fe=ae.messages.filter(Ce=>!(Ce.role==="assistant"&&Ce.isStreaming));return{...ae,messages:[...fe,R,N],updatedAt:new Date,title:ae.messages.length===0?i.slice(0,50)+(i.length>50?"...":""):ae.title}}),isLoading:!0,error:null}}),p=b;let X=!1;Ul.reset();try{const U=l().conversations.find(H=>H.id===p);if(!U)throw new Error("Conversation not found");if(!U.adapterName)throw new Error("Adapter not configured for this conversation. Please select an adapter first.");const Q=Ha(U.apiUrl),I=U.adapterName,ae=z||U.sessionId,fe=await kt();fe.configureApi(Q,ae,I),j&&ae!==U.sessionId&&le(`[chatStore] Thread mode: using thread session ${ae} (original: ${U.sessionId})`);const{returnAudio:Ce,ttsVoice:te,language:oe,audioFormat:E}=Mp(U);le("[chatStore] Audio settings:",{returnAudio:Ce,ttsVoice:te,language:oe,audioFormat:E});const V=new AbortController;zl=V,Wn=ae,ur=p,Ba=null;for await(const H of fe.streamChat(i,!0,c,j||void 0,void 0,void 0,oe,Ce,te,void 0,void 0,f,h)){if(H.request_id&&!Ba&&(Ba=H.request_id,le(`[chatStore] >>> CAPTURED request_id for stop: ${H.request_id}`)),H.audio_chunk&&Ul.addChunk({audio:H.audio_chunk,audioFormat:H.audioFormat||"opus",chunkIndex:H.chunk_index??0}),H.text){const P=si(H.text);P?(l().appendToLastMessage(P,p),X=!0):H.text.length>100&&Be("[chatStore] Filtered out potential base64 audio data from message content")}if(H.audio&&H.done&&r(P=>Dl(P,p,()=>({audio:H.audio,audioFormat:H.audioFormat||"mp3"}))),H.image&&H.done&&(X=!0,r(P=>Dl(P,p,()=>({image:H.image,imageFormat:H.image_format||"png",imageRevisedPrompt:H.image_revised_prompt,imageUrl:H.image_url})))),(H.video||H.video_url)&&H.done&&(X=!0,r(P=>Dl(P,p,()=>({video:H.video,videoFormat:H.video_format||"mp4",videoRevisedPrompt:H.video_revised_prompt,videoUrl:H.video_url})))),(H.document||H.document_url)&&H.done&&(X=!0,r(P=>Dl(P,p,()=>({document:H.document,documentFormat:H.document_format||"pdf",documentRevisedPrompt:H.document_revised_prompt,documentUrl:H.document_url})))),H.done){le("[chatStore] Stream completed, receivedAnyText:",X);const P=H.threading;P!=null&&P.supports_threading&&r(ce=>({conversations:ce.conversations.map(xe=>xe.id!==p?xe:{...xe,messages:xe.messages.map(pe=>pe.id===q?{...pe,supportsThreading:!0,databaseMessageId:P.message_id}:pe),updatedAt:new Date})})),H.assistant_message_id&&r(ce=>({conversations:ce.conversations.map(xe=>xe.id!==p?xe:{...xe,messages:xe.messages.map(pe=>pe.id===q&&!pe.databaseMessageId?{...pe,databaseMessageId:H.assistant_message_id}:pe),updatedAt:new Date})}));break}}!X&&!V.signal.aborted&&l().appendToLastMessage("No response received from the server. Please try again later.",p)}catch(U){if(U instanceof Error&&(U.name==="AbortError"||U.message==="Stream cancelled by user"||U.message.includes("aborted")))le("[chatStore] Stream was cancelled by user"),X=!0;else{qt("Chat API error:",U);let I="Sorry, there was an error processing your request.";U instanceof Error&&(U.message.startsWith("Server error:")?I=U.message.substring(14):(U.message.includes("Could not connect")||U.message.includes("timed out"))&&(I=U.message)),l().appendToLastMessage(I,p)}}zl=null,Ba=null,Wn=null,ur=null,zp(p,r),r(U=>{const Q=U.conversations.map(ae=>ae.id===p?{...ae,messages:ae.messages.map(fe=>fe.id===q?{...fe,isStreaming:!1}:fe),updatedAt:new Date}:ae),I=Q.find(ae=>ae.id===U.currentConversationId);return{conversations:Q,isLoading:I?I.messages.some(ae=>ae.role==="assistant"&&ae.isStreaming):!1}}),na(l)}catch(v){qt("Chat store error:",v),r(b=>({isLoading:!1,...b.currentConversationId===p&&{error:`Failed to send message: ${v instanceof Error?v.message:"Unknown error"}`}}))}},createThread:async(i,c)=>{try{const d=l().conversations.find(k=>k.sessionId===c);if(!d)throw new Error("Conversation not found for session");if(!d.adapterName)throw new Error("Adapter not configured for this conversation");const f=d.messages.find(k=>k.id===i);if(!f)throw new Error("Message not found");const h=f.databaseMessageId||i,p=Ha(d.apiUrl||_t()),x=await kt(),v=new x.ApiClient({apiUrl:p,sessionId:c,adapterName:d.adapterName}),w=await new(await En(async()=>{const{ThreadService:k}=await import("./threadService-B9Db3n0J.js");return{ThreadService:k}},[])).ThreadService(v).createThread(h,c);r(k=>({conversations:k.conversations.map(S=>S.sessionId!==c?S:{...S,messages:S.messages.map(j=>j.id===i?{...j,threadInfo:w,supportsThreading:!0}:j),currentThreadId:void 0,currentThreadSessionId:void 0})})),le(`[chatStore] Created thread ${w.thread_id} for message ${i}`)}catch(d){throw qt("Failed to create thread:",d),d}},appendToLastMessage:(i,c)=>{const d=si(i);if(!d&&i){Be("[chatStore] Filtered out base64 audio data from message content");return}const f=cd(d),h=c||l().currentConversationId;if(!h)return;const p=h,x=ls.get(p);x?(x.content+=f,x.timeoutId&&clearTimeout(x.timeoutId)):ls.set(p,{content:f,timeoutId:null});const v=()=>{const w=ls.get(p);if(!w||!w.content)return;const k=w.content;w.content="",w.timeoutId=null,r(S=>({conversations:S.conversations.map(j=>{if(j.id!==h)return j;const _=[...j.messages],z=_[_.length-1];return z&&z.role==="assistant"&&z.isStreaming&&(_[_.length-1]={...z,content:z.content+k}),{...j,messages:_,updatedAt:new Date}})}))},b=ls.get(p);b.timeoutId=setTimeout(v,rv)},regenerateResponse:async(i,c)=>{let d=null;try{if(l().isLoading){Be("Another request is already in progress");return}if(!await li())throw new Error("API not properly configured");const h=l(),p=h.conversations.find(_=>_.id===h.currentConversationId);if(!p)return;const x=p.messages.findIndex(_=>_.id===i);if(x===-1)return;const v=p.messages[x];if(!v||v.role!=="assistant")return;const b=p.messages[x-1];if(!b||b.role!=="user")return;const w=(b.attachments||[]).map(_=>_.file_id).filter(_=>typeof _=="string"&&_.length>0),k=Lo("assistant");if(r(_=>({conversations:_.conversations.map(z=>z.id===_.currentConversationId?{...z,messages:[...z.messages.slice(0,x),{id:k,content:"",role:"assistant",timestamp:new Date,isStreaming:!0,supportsThreading:v.supportsThreading,databaseMessageId:v.databaseMessageId,threadInfo:v.threadInfo,threadId:v.threadId,parentMessageId:v.parentMessageId,isThreadMessage:v.isThreadMessage},...z.messages.slice(x+1)],updatedAt:new Date}:z),isLoading:!0,error:null})),d=h.currentConversationId,!d)throw new Error("No conversation selected");let S=!1;const j=new AbortController;zl=j,ur=d,Ba=null;try{const _=l().conversations.find(R=>R.id===d);if(!_)throw new Error("Conversation not found");if(!_.adapterName)throw new Error("Adapter not configured for this conversation. Please select an adapter first.");Wn=_.sessionId,_.sessionId&&(await kt()).configureApi(Ha(_.apiUrl),_.sessionId,_.adapterName);const z=await kt(),{returnAudio:$,ttsVoice:ee,language:Y}=Mp(_);for await(const R of z.streamChat(b.content,!0,w.length>0?w:void 0,void 0,void 0,void 0,Y,$,ee,void 0,void 0,c)){if(R.request_id&&!Ba&&(Ba=R.request_id,le(`[chatStore] >>> CAPTURED request_id for regenerate stop: ${R.request_id}`)),R.text){const q=si(R.text);q?(l().appendToLastMessage(q,d),S=!0):R.text.length>100&&Be("[chatStore] Filtered out potential base64 audio data from regenerated message content")}if(R.audio&&R.done&&r(q=>Dl(q,d,()=>({audio:R.audio,audioFormat:R.audioFormat||"mp3"}))),R.image&&R.done&&(S=!0,r(q=>Dl(q,d,()=>({image:R.image,imageFormat:R.image_format||"png",imageRevisedPrompt:R.image_revised_prompt,imageUrl:R.image_url})))),(R.video||R.video_url)&&R.done&&(S=!0,r(q=>Dl(q,d,()=>({video:R.video,videoFormat:R.video_format||"mp4",videoRevisedPrompt:R.video_revised_prompt,videoUrl:R.video_url})))),(R.document||R.document_url)&&R.done&&(S=!0,r(q=>Dl(q,d,()=>({document:R.document,documentFormat:R.document_format||"pdf",documentRevisedPrompt:R.document_revised_prompt,documentUrl:R.document_url})))),R.done){const q=R.threading;q!=null&&q.supports_threading&&r(N=>({conversations:N.conversations.map(X=>X.id!==d?X:{...X,messages:X.messages.map(U=>U.id===k?{...U,supportsThreading:!0,databaseMessageId:q.message_id}:U),updatedAt:new Date})})),R.assistant_message_id&&r(N=>({conversations:N.conversations.map(X=>X.id!==d?X:{...X,messages:X.messages.map(U=>U.id===k&&!U.databaseMessageId?{...U,databaseMessageId:R.assistant_message_id}:U),updatedAt:new Date})}));break}}!S&&!j.signal.aborted&&l().appendToLastMessage("No response received from the server. Please try again later.",d)}catch(_){if(_ instanceof Error&&(_.name==="AbortError"||_.message==="Stream cancelled by user"||_.message.includes("aborted")))le("[chatStore] Regeneration stream was cancelled by user"),S=!0;else{qt("Regenerate API error:",_);let $="Sorry, there was an error regenerating the response.";_ instanceof Error&&(_.message.startsWith("Server error:")?$=_.message.substring(14):(_.message.includes("Could not connect")||_.message.includes("timed out"))&&($=_.message)),l().appendToLastMessage($,d)}}zl=null,Ba=null,Wn=null,ur=null,zp(d,r),r(_=>{const z=_.conversations.map(ee=>ee.id===d?{...ee,messages:ee.messages.map(Y=>Y.id===k?{...Y,isStreaming:!1}:Y),updatedAt:new Date}:ee),$=z.find(ee=>ee.id===_.currentConversationId);return{conversations:z,isLoading:$?$.messages.some(ee=>ee.role==="assistant"&&ee.isStreaming):!1}})}catch(f){qt("Regenerate error:",f),r(h=>({isLoading:!1,...h.currentConversationId===d&&{error:`Failed to regenerate response: ${f instanceof Error?f.message:"Unknown error"}`}}))}},updateConversationTitle:(i,c)=>{r(d=>({conversations:d.conversations.map(f=>f.id===i?{...f,title:c,updatedAt:new Date}:f)})),na(l)},clearError:()=>r({error:null}),cleanupStreamingMessages:()=>{const i=ur;r(c=>{let d=!1;return{conversations:c.conversations.map(h=>h.id===i?(h.messages.some(x=>x.role==="assistant"&&x.isStreaming)&&(d=!0),h):h.messages.some(x=>x.role==="assistant"&&x.isStreaming)?{...h,messages:h.messages.filter(x=>!(x.role==="assistant"&&x.isStreaming)),updatedAt:new Date}:h),isLoading:d}})},canCreateNewConversation:()=>{var h;const i=l(),c=Le.maxConversations;if(!i.currentConversationId)return c===null||i.conversations.length<c;const d=i.conversations.find(p=>p.id===i.currentConversationId);return!!d&&(d.messages.length>0||(((h=d.attachedFiles)==null?void 0:h.length)||0)>0)?c===null||i.conversations.length<c:!1},getConversationCount:()=>l().conversations.length,addFileToConversation:(i,c)=>{le("[chatStore] addFileToConversation called",{conversationId:i,fileId:c.file_id,filename:c.filename}),r(d=>({conversations:d.conversations.map(f=>f.id===i?{...f,attachedFiles:[...(f.attachedFiles||[]).filter(h=>h.file_id!==c.file_id),c],updatedAt:new Date}:f)})),na(l)},removeFileFromConversation:async(i,c)=>{le("[chatStore] removeFileFromConversation called",{conversationId:i,fileId:c});try{const d=l().conversations.find(f=>f.id===i);if(!d)throw new Error("Conversation not found");if(!d.adapterName)throw new Error("Adapter not configured for this conversation. Cannot delete file.");await ui.deleteFile(c,void 0,Ha(d.apiUrl),d.adapterName),le(`[chatStore] Successfully deleted file ${c} from server`)}catch(d){d instanceof Error&&(d.message.includes("404")||d.message.includes("File not found"))?le(`[chatStore] File ${c} was already deleted from server`):He(`[chatStore] Failed to delete file ${c} from server:`,d)}r(d=>({conversations:d.conversations.map(f=>f.id===i?{...f,attachedFiles:(f.attachedFiles||[]).filter(h=>h.file_id!==c),updatedAt:new Date}:f)})),na(l)},loadConversationFiles:async i=>{try{const c=l().conversations.find(p=>p.id===i);if(!c)return;if(!c.adapterName){le(`Skipping file load for conversation ${i}: adapter not configured`);return}if(new Set((c.attachedFiles||[]).map(p=>p.file_id)).size===0){le(`No files to sync for conversation ${i}`);return}const f=await ui.listFiles(void 0,Ha(c.apiUrl),c.adapterName),h=new Map(f.map(p=>[p.file_id,{file_id:p.file_id,filename:p.filename,mime_type:p.mime_type,file_size:p.file_size,upload_timestamp:p.upload_timestamp,processing_status:p.processing_status,chunk_count:p.chunk_count}]));r(p=>{const x=p.conversations.find(b=>b.id===i);if(!x)return p;const v=(x.attachedFiles||[]).map(b=>h.get(b.file_id)||b).filter(b=>h.has(b.file_id)||!b.processing_status||b.processing_status==="processing");return{conversations:p.conversations.map(b=>b.id===i?{...b,attachedFiles:v,updatedAt:new Date}:b)}}),na(l)}catch(c){qt(`Failed to load files for conversation ${i}:`,c)}},syncConversationFiles:async i=>{await l().loadConversationFiles(i)},syncConversationsWithBackend:async()=>{try{const i=l();if(i.conversations.length===0)return;const c=await kt(),d=Le.maxMessagesPerConversation!==null&&Le.maxMessagesPerConversation||void 0;let f=!1;const p=(await Promise.all(i.conversations.map(async x=>{var v;if(!x.sessionId)return null;if(!x.adapterName)return Be(`[chatStore] Skipping backend sync for conversation ${x.id} - adapter not configured`),null;try{const b=new c.ApiClient({apiUrl:Ha(x.apiUrl),sessionId:x.sessionId,adapterName:x.adapterName});if(typeof b.getConversationHistory!="function")return f||(f=!0,Be("[chatStore] Conversation history endpoint not supported by current API client")),null;const w=await b.getConversationHistory(x.sessionId,d),k=Array.isArray(w==null?void 0:w.messages)?w.messages:[];if(k.length===0)return x.messages.length===0?null:{id:x.id,sessionId:(w==null?void 0:w.session_id)||x.sessionId,messages:[],cleared:!0,updatedAt:new Date};const S=av(k,x.messages),j=x.messages.filter(z=>z.isThreadMessage),_=j.length>0?[...S,...j]:S;return nv(x.messages,_)?null:{id:x.id,sessionId:(w==null?void 0:w.session_id)||x.sessionId,messages:_,cleared:!1,updatedAt:((v=S[S.length-1])==null?void 0:v.timestamp)||new Date}}catch(b){return Be(`[chatStore] Failed to sync session ${x.sessionId}:`,b),null}}))).filter(x=>!!x);if(p.length===0)return;r(x=>{const v=new Map(p.map(b=>[b.id,b]));return{conversations:x.conversations.map(b=>{const w=v.get(b.id);return w?w.cleared?{...b,sessionId:w.sessionId||b.sessionId,messages:[],attachedFiles:[],title:"New Chat",updatedAt:w.updatedAt,adapterLoadError:null}:{...b,sessionId:w.sessionId||b.sessionId,messages:w.messages,updatedAt:w.updatedAt,adapterLoadError:null}:b}),currentConversationId:x.currentConversationId}}),na(l)}catch(i){Be("Failed to synchronize conversations with backend:",i)}},stopStreaming:async()=>{var c;if(!l().isLoading){le("[chatStore] stopStreaming called but not currently loading");return}if(le("[chatStore] Stopping stream...",{hasAbortController:!!zl,requestId:Ba,sessionId:Wn}),zl&&zl.abort(),Ba&&Wn)try{const d=await kt(),f=await((c=d.stopChat)==null?void 0:c.call(d,Wn,Ba));le(`[chatStore] Server-side cancellation result: ${f}`)}catch(d){Be("[chatStore] Failed to cancel server-side stream:",d)}else Be(`[chatStore] Cannot call stopChat - missing IDs: requestId=${Ba}, sessionId=${Wn}`);const i=ur||l().currentConversationId;r(i?d=>({conversations:d.conversations.map(f=>f.id!==i?f:{...f,messages:f.messages.map(h=>h.isStreaming?{...h,isStreaming:!1}:h),updatedAt:new Date}),isLoading:!1}):{isLoading:!1}),zl=null,Ba=null,Wn=null,ur=null,le("[chatStore] Stream stopped successfully")},clearCurrentConversationAdapter:()=>{const i=l().currentConversationId;i&&(r(c=>({conversations:c.conversations.map(d=>d.id===i?{...d,adapterName:void 0,adapterInfo:void 0,adapterLoadError:null}:d)})),na(l))},submitFeedback:async(i,c)=>{const d=l(),f=d.conversations.find(p=>p.id===d.currentConversationId);if(!f)return;const h=f.messages.find(p=>p.id===i);if(!(h!=null&&h.databaseMessageId)){Be("[chatStore] Cannot submit feedback: no databaseMessageId on message");return}if(f.adapterName)try{const p=await kt(),b=(await new p.ApiClient({apiUrl:Ha(f.apiUrl||_t()),sessionId:f.sessionId,adapterName:f.adapterName}).submitFeedback(h.databaseMessageId,f.sessionId,c)).feedback_type;r(w=>({conversations:w.conversations.map(k=>k.id!==d.currentConversationId?k:{...k,messages:k.messages.map(S=>S.id===i?{...S,feedback:b}:S),updatedAt:new Date})})),na(l)}catch(p){He("[chatStore] Failed to submit feedback:",p)}},loadFeedbackForConversation:async i=>{var f;const d=l().conversations.find(h=>h.sessionId===i);if(d!=null&&d.adapterName)try{const h=await kt(),p=new h.ApiClient({apiUrl:Ha(d.apiUrl||_t()),sessionId:d.sessionId,adapterName:d.adapterName}),x=new Set([i]);for(const w of d.messages)(f=w.threadInfo)!=null&&f.thread_session_id&&x.add(w.threadInfo.thread_session_id);const v=await Promise.all(Array.from(x).map(w=>p.getSessionFeedback(w).catch(()=>({feedbacks:[]})))),b=new Map;for(const w of v)if(w!=null&&w.feedbacks)for(const k of w.feedbacks)b.set(k.message_id,k.feedback_type);if(b.size===0)return;r(w=>({conversations:w.conversations.map(k=>k.sessionId!==i?k:{...k,messages:k.messages.map(S=>S.databaseMessageId&&b.has(S.databaseMessageId)?{...S,feedback:b.get(S.databaseMessageId)}:S)})}))}catch(h){He("[chatStore] Failed to load feedback:",h)}}})),sv=async()=>{var x;const r=localStorage.getItem("chat-state"),l=_t(),i=!!localStorage.getItem("chat-api-url");let c=Bo(),d=!1;if(r)try{const v=JSON.parse(r),b=S=>{if(S instanceof Date)return S;const j=S?new Date(S):new Date;return Number.isNaN(j.getTime())?new Date:j},k=(Array.isArray(v.conversations)?v.conversations:[]).map(S=>{const _=(Array.isArray(S.messages)?S.messages:[]).filter(ee=>!(ee.role==="assistant"&&ee.isStreaming)).map(ee=>({...ee,timestamp:b(ee.timestamp),isStreaming:!1})),z={id:S.id,sessionId:S.sessionId||Ol(),title:S.title||"New Chat",messages:_,createdAt:b(S.createdAt),updatedAt:b(S.updatedAt),attachedFiles:S.attachedFiles||[],adapterName:S.adapterName,apiUrl:S.apiUrl,adapterInfo:S.adapterInfo,adapterLoadError:S.adapterLoadError||null,audioSettings:S.audioSettings,currentThreadId:void 0,currentThreadSessionId:void 0},$=z.messages.length===0&&!z.adapterName;return{...z,apiUrl:$&&!i?l:Ha(S.apiUrl)}});if(d=k.length>0,v.currentConversationId&&k.length>0){const S=k.find(j=>j.id===v.currentConversationId);S!=null&&S.sessionId&&(c=S.sessionId)}if(k.length===0){const S=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,j=Ol(),_=ii(S,j,_t());Ve.setState({conversations:[_],currentConversationId:S,sessionId:j}),c=j}else Ve.setState({conversations:k,currentConversationId:v.currentConversationId||((x=k[0])==null?void 0:x.id)||null,sessionId:c}),!v.currentConversationId&&k.length>0&&(Ve.setState({currentConversationId:k[0].id,sessionId:k[0].sessionId||c}),c=k[0].sessionId||c);le("📋 Loaded conversations:",Ve.getState().conversations.map(S=>{var j;return{id:S.id,title:S.title,sessionId:S.sessionId,messageCount:((j=S.messages)==null?void 0:j.length)||0}})),setTimeout(()=>Ve.getState().cleanupStreamingMessages(),100)}catch(v){qt("Failed to load chat state:",v);const b=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=Ol(),k=ii(b,w,_t());Ve.setState({conversations:[k],currentConversationId:b,sessionId:w}),c=w}else{const v=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,b=Ol(),w=ii(v,b,_t());Ve.setState({conversations:[w],currentConversationId:v,sessionId:b}),c=b}localStorage.removeItem("chat-api-key");const f=Ve.getState(),h=f.currentConversationId?f.conversations.find(v=>v.id===f.currentConversationId):null,p=d&&(h!=null&&h.apiUrl)?h.apiUrl:_t();try{const v=await kt(),b=h==null?void 0:h.adapterName;if(!b)le("No adapter selected yet. Waiting for user selection before configuring API.");else if(v.configureApi(p,c,b),Fo=p,Ho=!0,!(h!=null&&h.adapterInfo))try{const w=new v.ApiClient({apiUrl:p,sessionId:null,adapterName:b});if(typeof w.getAdapterInfo=="function"){const k=await w.getAdapterInfo();le("Adapter info loaded for existing adapter:",k);const S=Ve.getState();S.currentConversationId&&(Ve.setState({conversations:S.conversations.map(j=>j.id===S.currentConversationId?{...j,adapterInfo:k,adapterLoadError:null,updatedAt:new Date}:j)}),setTimeout(()=>{const j=Ve.getState();localStorage.setItem("chat-state",JSON.stringify({conversations:j.conversations,currentConversationId:j.currentConversationId}))},0))}}catch(w){Be("Failed to load adapter info for existing adapter:",w)}}catch(v){qt("Failed to initialize API:",v)}try{await Ve.getState().syncConversationsWithBackend()}catch(v){Be("Conversation history sync skipped:",v)}};typeof window<"u"&&sv();function iv(r){return r.includes("image")?u.jsx(qx,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"}):r.includes("video")||r.includes("audio")?u.jsx(cb,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"}):u.jsx(xd,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"})}function ov(r){return r.replace(/-/g," ")}function kg({skills:r,isLoading:l,selectedSkill:i,activeSkillName:c,query:d="",onSelect:f,onActiveSkillChange:h}){const p=Tn.useRef(null),x=d.toLowerCase().replace(/-/g," "),v=x?r.filter(b=>b.name.replace(/-/g," ").toLowerCase().includes(x)||b.description.toLowerCase().includes(x)):r;return Tn.useEffect(()=>{var w;const b=(w=p.current)==null?void 0:w.querySelector('[data-active="true"]');b==null||b.scrollIntoView({block:"nearest"})},[c,v.length]),!l&&r.length===0?u.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:u.jsx("p",{className:"px-4 py-3 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No skills available for this adapter."})}):u.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:l?u.jsx("div",{className:"px-4 py-3.5",children:u.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-[#bfc2cd]",children:[u.jsx("div",{className:"h-3.5 w-3.5 rounded-full border-2 border-current border-t-transparent animate-spin","aria-hidden":"true"}),"Loading skills..."]})}):v.length===0?u.jsx("div",{className:"px-4 py-3.5",children:u.jsx("p",{className:"text-sm text-gray-500 dark:text-[#bfc2cd]",children:x?`No matching skills for "${d}".`:"No matching skills."})}):u.jsx("div",{ref:p,role:"listbox","aria-label":"Available skills",className:"max-h-72 overflow-y-auto p-1.5",children:v.map((b,w)=>{const k=(i==null?void 0:i.name)===b.name,S=c===b.name||!c&&(k||!i&&w===0);return u.jsxs("button",{id:`skill-option-${b.name}`,type:"button",role:"option","aria-selected":S,"data-active":S?"true":void 0,onMouseEnter:()=>h==null?void 0:h(b),onClick:()=>f(b),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 ${S?"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:[u.jsx("div",{className:`mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center transition-colors ${S?"text-gray-900 dark:text-white":"text-gray-500 group-hover:text-gray-700 dark:text-[#bfc2cd] dark:group-hover:text-gray-200"}`,children:iv(b.name)}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"flex min-w-0 items-center gap-2",children:u.jsx("span",{className:"truncate text-sm font-medium capitalize leading-5 text-current",children:ov(b.name)})}),b.description&&u.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs leading-5 text-gray-500 dark:text-[#bfc2cd]",children:b.description})]}),k&&u.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:u.jsx(Ro,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]},b.name)})})})}function _g({availableModels:r,defaultModel:l,selectedModel:i,onSelect:c,wrapperClassName:d="relative hidden md:block",maxWidthClass:f="max-w-[200px]",triggerTitle:h="Select model",listboxLabel:p="Select model",staticPaddingClass:x="px-3 py-1.5",triggerPaddingClass:v="px-3 py-1.5"}){const[b,w]=g.useState(!1),[k,S]=g.useState(""),[j,_]=g.useState(null),z=g.useRef(null),$=g.useRef(null),ee=g.useRef(null),Y=g.useRef(null),R=i??l,q=k.trim()?r.filter(I=>I.name.toLowerCase().includes(k.trim().toLowerCase())):r,N=g.useCallback(()=>{if(!$.current)return;const I=$.current.getBoundingClientRect();_({bottom:window.innerHeight-I.top+8,right:window.innerWidth-I.right})},[]),X=g.useCallback(()=>{w(!1),S("")},[]),U=()=>{if(b){X();return}N(),w(!0)};if(g.useEffect(()=>{if(!b)return;const I=setTimeout(()=>{var te;return(te=ee.current)==null?void 0:te.focus()},10),ae=te=>{var H,P;const oe=te.target,E=((H=z.current)==null?void 0:H.contains(oe))??!1,V=((P=Y.current)==null?void 0:P.contains(oe))??!1;!E&&!V&&X()},fe=te=>{var oe;te.key==="Escape"&&(te.preventDefault(),X(),(oe=$.current)==null||oe.focus())},Ce=new ResizeObserver(N);return $.current&&Ce.observe($.current),window.addEventListener("resize",N,{passive:!0}),document.addEventListener("scroll",N,{capture:!0,passive:!0}),document.addEventListener("pointerdown",ae),document.addEventListener("keydown",fe),()=>{clearTimeout(I),Ce.disconnect(),window.removeEventListener("resize",N),document.removeEventListener("scroll",N,{capture:!0}),document.removeEventListener("pointerdown",ae),document.removeEventListener("keydown",fe)}},[X,b,N]),!l&&r.length===0)return null;const Q=b&&j&&typeof document<"u"?Yo.createPortal(u.jsxs("div",{ref:Y,style:{position:"fixed",bottom:j.bottom,right:j.right,width:288,zIndex:9999},className:"rounded-xl border border-gray-200 bg-white shadow-xl dark:border-[#2f303d] dark:bg-[#111111]",children:[u.jsx("div",{className:"p-2 border-b border-gray-100 dark:border-[#222222]",children:u.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-gray-50 px-3 py-1.5 dark:bg-[#1a1a1a]",children:[u.jsx(gd,{className:"h-3.5 w-3.5 flex-shrink-0 text-gray-400 dark:text-[#6b6f7a]","aria-hidden":"true"}),u.jsx("input",{ref:ee,type:"text",value:k,onChange:I=>S(I.target.value),placeholder:"Search models…",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":"Search models"})]})}),u.jsx("div",{role:"listbox","aria-label":p,className:"max-h-60 overflow-y-auto py-1",children:q.length===0?u.jsxs("div",{className:"px-3 py-5 text-center text-xs text-gray-400 dark:text-[#6b6f7a]",children:["No models match “",k,"”"]}):q.map(I=>{const ae=R===I.name;return u.jsxs("button",{role:"option","aria-selected":ae,type:"button",onClick:()=>{var fe;c(I.name),X(),(fe=$.current)==null||fe.focus()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs transition-colors ${ae?"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:[u.jsx("span",{className:`flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-full border ${ae?"border-blue-500 bg-blue-500 dark:border-blue-400 dark:bg-blue-400":"border-gray-300 dark:border-[#5a5b65]"}`,children:ae&&u.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-white"})}),u.jsx("span",{className:"truncate font-medium normal-case tracking-normal",children:I.name})]},I.name)})}),r.length>8&&u.jsx("div",{className:"border-t border-gray-100 px-3 py-1.5 dark:border-[#222222]",children:u.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-[#6b6f7a]",children:[q.length," of ",r.length," models"]})})]}),document.body):null;return u.jsx("div",{ref:z,className:d,children:r.length>1?u.jsxs(u.Fragment,{children:[u.jsxs("button",{ref:$,type:"button",onClick:U,className:`inline-flex min-w-[100px] ${f} items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 ${v} 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":b,title:h,children:[u.jsx("span",{className:"truncate flex-1",children:R}),u.jsx(di,{className:`h-3.5 w-3.5 flex-shrink-0 text-gray-400 transition-transform duration-150 dark:text-[#6b6f7a] ${b?"rotate-180":""}`,"aria-hidden":"true"})]}),Q]}):u.jsx("div",{className:`inline-flex min-w-[100px] ${f} items-center rounded-full border border-gray-200 bg-gray-100 ${x} text-xs text-gray-500 dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#bfc2cd]`,title:R??void 0,children:u.jsx("span",{className:"truncate",children:R})})})}const cv=[],uv=(r="png")=>{const l=r.toLowerCase().replace(/^image\//,"");return l==="jpg"?"image/jpeg":`image/${l||"png"}`},dv=(r,l)=>{const i=atob(r),c=new Uint8Array(i.length);for(let d=0;d<i.length;d+=1)c[d]=i.charCodeAt(d);return new Blob([c],{type:l})},fv=async r=>{const l=URL.createObjectURL(r);try{const i=new Image;i.decoding="async";const c=new Promise((h,p)=>{i.onload=()=>h(i),i.onerror=()=>p(new Error("Failed to load generated image for clipboard copy"))});i.src=l,await c;const d=document.createElement("canvas");d.width=i.naturalWidth,d.height=i.naturalHeight;const f=d.getContext("2d");if(!f)throw new Error("Could not create canvas context for image clipboard copy");return f.drawImage(i,0,0),await new Promise((h,p)=>{d.toBlob(x=>{x?h(x):p(new Error("Could not encode generated image for clipboard copy"))},"image/png")})}finally{URL.revokeObjectURL(l)}},mv=async(r,l)=>{const i=uv(r.imageFormat);if(r.image)return dv(r.image,i);if(!r.imageUrl)return null;const c=await fetch(r.imageUrl,{headers:l?{"X-Adapter-Name":l}:{}});if(!c.ok)throw new Error(`Could not fetch generated image for clipboard copy: ${c.status}`);const d=await c.blob();return d.type?d:new Blob([d],{type:i})},hv=r=>r.imageUrl?new URL(r.imageUrl,window.location.origin).toString():r.imageRevisedPrompt||r.content;function Dp({size:r="md"}){const l=r==="sm"?"h-2 w-2":"h-2.5 w-2.5";return u.jsx("div",{className:"flex items-center gap-1.5 py-1",children:[0,150,300].map(i=>u.jsx("span",{className:`inline-block ${l} animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]`,style:{animationDelay:`${i}ms`}},i))})}function pv({reply:r}){const[l,i]=g.useState(!1),[c,d]=g.useState(!1),f=g.useRef(null),h=Ve(x=>x.submitFeedback);g.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const p=async x=>{if(!r.databaseMessageId||l)return;const v=r.feedback!==x;i(!0);try{await h(r.id,x),v?(d(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{d(!1),f.current=null},2e3)):d(!1)}catch(b){He("Failed to submit thread reply feedback:",b)}finally{i(!1)}};return u.jsxs("div",{className:"flex items-center gap-0.5 mt-0.5",children:[u.jsx("button",{onClick:()=>p("up"),disabled:l,className:`rounded-md p-1.5 hover:bg-gray-100 dark:hover:bg-[#3c3f4a] transition-colors ${l?"opacity-50 cursor-not-allowed":""} ${r.feedback==="up"?"text-green-600 dark:text-green-400":"text-gray-400 dark:text-[#6e6e80] hover:text-gray-700 dark:hover:text-[#ececf1]"}`,title:"Good response","aria-label":"Good response",children:u.jsx(lg,{className:"h-3.5 w-3.5"})}),u.jsx("button",{onClick:()=>p("down"),disabled:l,className:`rounded-md p-1.5 hover:bg-gray-100 dark:hover:bg-[#3c3f4a] transition-colors ${l?"opacity-50 cursor-not-allowed":""} ${r.feedback==="down"?"text-red-600 dark:text-red-400":"text-gray-400 dark:text-[#6e6e80] hover:text-gray-700 dark:hover:text-[#ececf1]"}`,title:"Poor response","aria-label":"Poor response",children:u.jsx(ng,{className:"h-3.5 w-3.5"})}),c&&u.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 animate-fadeIn dark:bg-emerald-500/15 dark:text-emerald-300",children:[u.jsx(Ro,{className:"h-3 w-3"}),"Thanks!"]})]})}function gv({message:r,onRegenerate:l,onStartThread:i,onClearThread:c,onSendThreadMessage:d,threadMessages:f,sessionId:h,isThreadSendDisabled:p,availableModels:x=[],defaultModel:v=null,selectedModel:b=null}){var bn,yn,Ca;const[w,k]=g.useState(!1),[S,j]=g.useState(!1),[_,z]=g.useState(!1),[$,ee]=g.useState(""),[Y,R]=g.useState(!1),[q,N]=g.useState(!1),[X,U]=g.useState(!1),[Q,I]=g.useState(0),[ae,fe]=g.useState(!1),[Ce,te]=g.useState(!1),[oe,E]=g.useState(()=>b??v),V=g.useRef(b),H=g.useRef(((bn=r.threadInfo)==null?void 0:bn.thread_id)||null),P=g.useRef(null),ce=g.useRef(null),xe=g.useRef(null),pe=g.useRef(!1),F=g.useRef(0),me=g.useRef(""),ue=g.useRef(!1),de=g.useRef(!0),we=g.useRef(!1),W=g.useRef(null),se=g.useRef(null),be=r.role==="assistant",ke=f??cv,ge=ke.filter(re=>!(re.role==="assistant"&&re.isStreaming)).length,ze=ke.some(re=>re.isStreaming),Ue=is(),Fe=va()&&!Ue,je=Ve(re=>re.conversations.find(qe=>qe.id===re.currentConversationId)),Xe=!!((r.image||r.imageUrl)&&be&&!r.isStreaming),et=!!((r.video||r.videoUrl)&&be&&!r.isStreaming),Bt=Xe?"Copy image to clipboard":"Copy to clipboard",xt=ay(),ie=Le.maxMessageLength,Ne=Le.maxMessagesPerThread,Nt=Ne!==null&&ge>=Ne,Oe=Nt?Fe?`You've reached the guest limit of ${Ne} messages per thread. Sign in to continue this thread.`:`This thread reached the ${Ne} message limit. Start a new conversation for more follow-ups.`:null,{theme:Vt,isDark:da}=ss(),Xt="Reply in thread...",ea=`thread-input-${r.id}`,{skills:pn,isLoading:en,selectedSkill:ta,selectSkill:gn,clearSkill:Tt}=vg({adapterName:je==null?void 0:je.adapterName,enabled:xt&&!!r.threadInfo,selectionScopeKey:((yn=r.threadInfo)==null?void 0:yn.thread_id)||r.id}),gt=$.startsWith("/")?$.slice(1):"",Ht=gt.toLowerCase().replace(/-/g," "),_e=Ht?pn.filter(re=>re.name.replace(/-/g," ").toLowerCase().includes(Ht)||re.description.toLowerCase().includes(Ht)):pn,Sa=_e.length>0?Math.min(Q,_e.length-1):0,Te=_e[Sa]??null,Ye=(Te==null?void 0:Te.name.replace(/-/g," "))??"",bt=X&&Te&&$.startsWith("/")&&Ye.toLowerCase().startsWith(gt.toLowerCase())&&Ye.length>gt.length?Ye.slice(gt.length):null,it=Vt.mode==="dark"?"dark":Vt.mode==="light"?"light":"",Ae=da?"dark":"light",la=g.useMemo(()=>["message-markdown w-full min-w-0","prose prose-slate dark:prose-invert max-w-none",it].filter(Boolean).join(" "),[it]),Mn=g.useMemo(()=>["message-markdown w-full min-w-0","prose dark:prose-invert max-w-none",it].filter(Boolean).join(" "),[it]),ka=be?la:Mn,tl=`${la} text-sm leading-6`,$l=`${Mn} text-sm leading-6`;g.useEffect(()=>{var re,qe;!H.current&&((re=r.threadInfo)!=null&&re.thread_id)&&R(!0),H.current=((qe=r.threadInfo)==null?void 0:qe.thread_id)||null},[(Ca=r.threadInfo)==null?void 0:Ca.thread_id]),g.useEffect(()=>{r.threadInfo||setTimeout(()=>{ee(""),R(!1),N(!1),U(!1),Tt()},0)},[r.threadInfo,Tt]),g.useEffect(()=>{ge>0&&setTimeout(()=>{R(!0)},0)},[ge]),g.useEffect(()=>()=>{W.current&&clearTimeout(W.current),se.current&&clearTimeout(se.current)},[]);const _a=g.useCallback(()=>{requestAnimationFrame(()=>{xe.current&&(xe.current.scrollTop=xe.current.scrollHeight)})},[]);g.useEffect(()=>{if(!Y)return;const re=ke.length,qe=re>F.current,he=ke[ke.length-1],tt=(he==null?void 0:he.content)||"",Ke=tt!==me.current,nn=(he==null?void 0:he.isStreaming)??!1,Ln=ue.current&&!nn;qe||nn&&Ke||Ln?(_a(),de.current=!0):de.current&&Ke&&_a(),F.current=re,me.current=tt,ue.current=nn},[Y,ke,_a]),g.useEffect(()=>{Y&&(_a(),de.current=!0)},[Y,_a]);const zn=be?"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] bg-[#f4f4f4] px-4 py-3 text-[#111827] dark:bg-[#303030] dark:text-[#f5f5f5]",Aa="border-gray-200 bg-white/80 dark:border-[#3b3c49] dark:bg-white/5",al=g.useCallback(()=>{k(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{k(!1),W.current=null},2e3)},[]),fr=async()=>{try{if(Xe){if("ClipboardItem"in window&&navigator.clipboard.write)try{const qe=(je==null?void 0:je.adapterName)||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null),he=await mv(r,qe);if(he){const tt=he.type==="image/png"?he:await fv(he);await navigator.clipboard.write([new ClipboardItem({[tt.type||"image/png"]:tt})]),al();return}}catch(qe){He("Failed to copy generated image, falling back to text:",qe)}const re=hv(r);if(re){await navigator.clipboard.writeText(re),al();return}return}await navigator.clipboard.writeText(r.content),al()}catch(re){He(Xe?"Failed to copy generated image:":"Failed to copy text:",re)}},ql=Ve(re=>re.submitFeedback),tn=async re=>{if(!r.databaseMessageId||S)return;const qe=r.feedback!==re;j(!0);try{await ql(r.id,re),qe?(z(!0),se.current&&clearTimeout(se.current),se.current=setTimeout(()=>{z(!1),se.current=null},2e3)):z(!1)}catch(he){He("Failed to submit feedback:",he)}finally{j(!1)}},Dn=async()=>{if(!d||!r.threadInfo||Nt)return;const re=$.trim();if(!re)return;const qe=$,he=ta;ee(""),N(!0),U(!1);try{await d(r.threadInfo.thread_id,r.id,re,ta==null?void 0:ta.name,oe??v??void 0),setTimeout(()=>{P.current&&P.current.focus()},100)}catch(tt){He("Failed to send thread message:",tt),ee(qe),he&&gn(he),setTimeout(()=>{P.current&&P.current.focus()},100)}finally{N(!1)}},an=g.useCallback(re=>{var qe;gn(re),U(!1),ee(""),I(0),(qe=P.current)==null||qe.focus()},[gn]),xn=g.useCallback(()=>{var re;U(!1),ee(""),I(0),(re=P.current)==null||re.focus()},[]),Yt=g.useCallback(()=>{var re;ee("/"),U(!0),I(0),(re=P.current)==null||re.focus()},[]),Et=re=>{if(X){if(re.key==="ArrowDown"){re.preventDefault(),I(qe=>_e.length===0?0:(qe+1)%_e.length);return}if(re.key==="ArrowUp"){re.preventDefault(),I(qe=>_e.length===0?0:(qe-1+_e.length)%_e.length);return}if(re.key==="Home"){re.preventDefault(),I(0);return}if(re.key==="End"){re.preventDefault(),I(Math.max(_e.length-1,0));return}if((re.key==="Enter"&&!re.shiftKey||re.key==="Tab")&&Te){re.preventDefault(),an(Te);return}if(re.key==="Escape"){re.preventDefault(),xn();return}}re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),Dn())},At=!r.threadInfo||!d||p||ze||q||Nt,fa=!!r.threadInfo&&!!c&&ge>0&&!ze&&!q&&!p,Bl=async()=>{if(!(!r.threadInfo||!c)){te(!0);try{await c(r.id,r.threadInfo.thread_id),fe(!1),R(!1),ee("")}catch(re){He("Failed to clear thread:",re)}finally{te(!1)}}};g.useEffect(()=>{V.current=b},[b]),g.useEffect(()=>{E(V.current??v)},[v]),g.useEffect(()=>{if(!Y||At){we.current=q;return}const re=P.current;if(!re){we.current=q;return}if(!(pe.current||we.current)){we.current=q;return}const he=requestAnimationFrame(()=>{var Ke;pe.current&&((Ke=ce.current)==null||Ke.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})),re.focus();const tt=re.value.length;re.setSelectionRange(tt,tt),pe.current=!1,we.current=q});return()=>{cancelAnimationFrame(he),we.current=q}},[Y,At,q]),g.useEffect(()=>{if(P.current){const qe=P.current;qe.style.height="auto";const he=qe.scrollHeight;qe.style.height=`${Math.min(he,120)}px`,qe.style.overflowY=he>120?"auto":"hidden"}},[$]);const Ft=g.useMemo(()=>{if(r.isStreaming&&(!r.content||r.content==="…"))return u.jsx("div",{className:ka,children:u.jsx(Dp,{})});const re=r.isStreaming&&be?" streaming-cursor":"";return u.jsx("div",{className:re||void 0,children:u.jsx(el,{content:cd(si(r.content||"")),className:ka,syntaxTheme:Ae})})},[ka,r.content,r.isStreaming,be,Ae]),mr=g.useMemo(()=>{const re=he=>he instanceof Date?he.getTime():new Date(he).getTime();return[...ke].sort((he,tt)=>re(he.timestamp)-re(tt.timestamp)).map(he=>{const tt=he.role==="assistant",Ke=tt?tl:$l,nn=he.isStreaming&&tt?" streaming-cursor":"",Ln=he.isStreaming&&(!he.content||he.content==="…")?u.jsx("div",{className:Ke,children:u.jsx(Dp,{size:"sm"})}):u.jsx("div",{className:nn||void 0,children:u.jsx(el,{content:cd(si(he.content||"")),className:Ke,syntaxTheme:Ae})});return u.jsx("div",{className:`min-w-0 flex ${tt?"justify-start":"justify-end"}`,children:u.jsxs("div",{className:tt?"min-w-0 w-full max-w-full":"min-w-0 max-w-[85%]",children:[u.jsxs("div",{className:tt?"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-[#303030] dark:text-[#f5f5f5]",children:[Ln,he.audio&&tt&&!he.isStreaming&&u.jsx(bp,{audio:he.audio,audioFormat:he.audioFormat,autoPlay:!1}),(he.image||he.imageUrl)&&tt&&!he.isStreaming&&u.jsx(yp,{image:he.image,imageUrl:he.imageUrl,imageFormat:he.imageFormat,revisedPrompt:he.imageRevisedPrompt}),(he.video||he.videoUrl)&&tt&&!he.isStreaming&&u.jsx(vp,{video:he.video,videoUrl:he.videoUrl,videoFormat:he.videoFormat,revisedPrompt:he.videoRevisedPrompt,adapterName:je==null?void 0:je.adapterName}),(he.document||he.documentUrl)&&tt&&!he.isStreaming&&u.jsx(_p,{document:he.document,documentUrl:he.documentUrl,documentFormat:he.documentFormat,revisedPrompt:he.documentRevisedPrompt,adapterName:je==null?void 0:je.adapterName})]}),tt&&!he.isStreaming&&xp()&&u.jsx(pv,{reply:he})]})},he.id)})},[je==null?void 0:je.adapterName,Ae,tl,ke,$l]);return u.jsxs("div",{className:"group animate-fadeIn min-w-0 w-full px-0",children:[u.jsxs("div",{className:"min-w-0 space-y-1",children:[u.jsxs("div",{className:zn,children:[Ft,r.attachments&&r.attachments.length>0&&u.jsx("div",{className:"mt-3 space-y-2",children:r.attachments.map(re=>u.jsxs("div",{className:`flex items-center gap-3 rounded-xl border p-3 ${Aa}`,children:[u.jsx($x,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:re.filename}),u.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[(re.file_size/1024).toFixed(1)," KB"]})]})]},re.file_id))}),r.audio&&be&&!r.isStreaming&&u.jsx(bp,{audio:r.audio,audioFormat:r.audioFormat,autoPlay:!1}),(r.image||r.imageUrl)&&be&&!r.isStreaming&&u.jsx(yp,{image:r.image,imageUrl:r.imageUrl,imageFormat:r.imageFormat,revisedPrompt:r.imageRevisedPrompt}),(r.video||r.videoUrl)&&be&&!r.isStreaming&&u.jsx(vp,{video:r.video,videoUrl:r.videoUrl,videoFormat:r.videoFormat,revisedPrompt:r.videoRevisedPrompt,adapterName:je==null?void 0:je.adapterName}),(r.document||r.documentUrl)&&be&&!r.isStreaming&&u.jsx(_p,{document:r.document,documentUrl:r.documentUrl,documentFormat:r.documentFormat,revisedPrompt:r.documentRevisedPrompt,adapterName:je==null?void 0:je.adapterName})]}),be&&!r.isStreaming&&u.jsxs("div",{className:"py-1 flex flex-nowrap items-center gap-0.5 text-gray-400 dark:text-[#8e8ea0] transition-opacity",children:[!et&&u.jsx("button",{onClick:fr,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:Bt,"aria-label":Bt,children:w?u.jsx(Ro,{className:"h-4 w-4 text-emerald-500 dark:text-emerald-400"}):u.jsx(Dx,{className:"h-4 w-4"})}),xp()&&u.jsxs("div",{className:"relative flex items-center gap-0.5",children:[u.jsx("button",{onClick:()=>tn("up"),disabled:S,className:`rounded-md p-1.5 transition-colors ${S?"opacity-50 cursor-not-allowed":""} ${r.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:"Good response","aria-label":"Good response",children:u.jsx(lg,{className:"h-4 w-4"})}),u.jsx("button",{onClick:()=>tn("down"),disabled:S,className:`rounded-md p-1.5 transition-colors ${S?"opacity-50 cursor-not-allowed":""} ${r.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:"Poor response","aria-label":"Poor response",children:u.jsx(ng,{className:"h-4 w-4"})}),_&&u.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:[u.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"}),u.jsxs("div",{className:"relative flex items-center gap-1.5",children:[u.jsx(Ro,{className:"h-3.5 w-3.5"}),u.jsx("span",{children:"Thanks!"})]})]})]}),l&&u.jsx("button",{onClick:()=>l(r.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:"Regenerate response","aria-label":"Regenerate response",children:u.jsx(nb,{className:"h-4 w-4"})}),xt&&r.supportsThreading&&!r.threadInfo&&i&&h&&u.jsxs("button",{type:"button",onClick:()=>{pe.current=!0,R(!0),i(r.id,h)},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:"Continue this discussion with the current answer's context","aria-label":"Continue this discussion with the current answer's context",children:[u.jsx(up,{className:"h-3.5 w-3.5 shrink-0"}),u.jsx("span",{children:"Continue"})]}),xt&&r.threadInfo&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"w-px h-4 shrink-0 bg-gray-200 dark:bg-[#3c3f4a] mx-1"}),u.jsxs("button",{onClick:()=>R(re=>!re),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:[u.jsx(up,{className:"h-4 w-4"}),u.jsxs("span",{className:"truncate",children:[ge," ",ge===1?"reply":"replies"]}),Y?u.jsx(Uo,{className:"h-3 w-3"}):u.jsx(di,{className:"h-3 w-3"})]}),fa&&u.jsx("button",{type:"button",onClick:()=>fe(!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:"Clear replies","aria-label":"Clear replies",children:"Clear"})]})]}),xt&&r.threadInfo&&Y&&u.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:[u.jsx("div",{ref:xe,className:"thread-replies-scroll mt-2 space-y-2 pb-3",onScroll:()=>{if(!xe.current)return;const{scrollTop:re,scrollHeight:qe,clientHeight:he}=xe.current;de.current=qe-re-he<100},children:ge>0?mr:null}),Oe&&u.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:[Oe,Fe&&u.jsx("div",{className:"mt-2",children:u.jsx("button",{type:"button",onClick:()=>wa.getState().openLoginPrompt("Sign in to unlock higher message limits and continue this thread."),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:"Sign in for higher limits"})})]}),u.jsxs("div",{ref:ce,className:"mt-1 w-full max-w-[64rem] bg-transparent pt-1",children:[u.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:[ta&&u.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:[u.jsx(xd,{className:"h-3.5 w-3.5 shrink-0 text-gray-500 dark:text-gray-400","aria-hidden":"true"}),u.jsx("span",{className:"min-w-0 truncate font-medium capitalize",children:ta.name.replace(/-/g," ")}),u.jsx("button",{type:"button",onClick:()=>Tt(),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":"Remove thread skill",children:u.jsx(ua,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),!ta&&pn.length>0&&$.length===0&&!At&&u.jsxs("button",{type:"button",onClick:Yt,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":"Show available skills (or type a forward slash)",title:"Use a skill",children:[u.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:"/"}),"Skills"]}),u.jsxs("div",{className:"relative flex min-h-8 flex-1 items-center min-w-0",children:[u.jsx("label",{htmlFor:ea,className:"sr-only",children:"Reply in thread"}),bt&&u.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:[u.jsx("span",{className:"invisible",children:$}),u.jsx("span",{children:bt})]}),u.jsx("textarea",{id:ea,ref:P,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:Xt,"aria-label":"Reply in thread",value:$,onChange:re=>{const qe=re.target.value;ee(qe),qe.startsWith("/")&&I(0),U(qe.startsWith("/"))},onKeyDown:Et,disabled:At,rows:1,maxLength:ie,style:{minHeight:"32px",maxHeight:"120px",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none"}})]}),u.jsxs("div",{className:"flex items-center justify-between sm:justify-end gap-2",children:[u.jsx(_g,{availableModels:x,defaultModel:v,selectedModel:oe,onSelect:E,maxWidthClass:"max-w-[120px]",triggerPaddingClass:"px-2 py-1",staticPaddingClass:"px-2 py-1",triggerTitle:"Select model for this thread",listboxLabel:"Select model for this thread"}),$.trim().length>0&&u.jsx("button",{type:"button",onClick:Dn,disabled:At||$.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:"Send thread message",children:u.jsx(tg,{className:"h-5 w-5 sm:h-4 sm:w-4"})})]})]}),X&&u.jsx("div",{className:"w-full pt-1",children:u.jsx(kg,{skills:pn,isLoading:en,selectedSkill:ta,activeSkillName:Te==null?void 0:Te.name,query:gt,onActiveSkillChange:re=>{const qe=_e.findIndex(he=>he.name===re.name);qe>=0&&I(qe)},onSelect:an,onClose:xn})})]}),ge>0&&u.jsx("div",{className:"mt-2 flex justify-end",children:u.jsxs("button",{type:"button",onClick:()=>R(!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":"Hide replies",children:[u.jsx(Uo,{className:"h-3 w-3"}),u.jsx("span",{children:"Hide replies"})]})})]})]}),u.jsx(qo,{isOpen:ae,onClose:()=>{Ce||fe(!1)},onConfirm:Bl,title:"Clear Replies",message:"Are you sure you want to clear these replies? This removes the child thread from the backend without deleting the main conversation.",confirmText:"Clear",cancelText:"Cancel",type:"danger",isLoading:Ce})]})}let ns=null;function xv(){if(typeof window>"u")return null;const r=window.AudioContext??window.webkitAudioContext;return r?((!ns||ns.state==="closed")&&(ns=new r),ns.state==="suspended"&&ns.resume(),ns):(le("[SoundEffects] AudioContext not supported in this browser"),null)}function bv(r){const l=xv();if(!l)return;const i=l.currentTime;for(const c of r){const d=l.createOscillator(),f=l.createGain();d.connect(f),f.connect(l.destination),d.frequency.value=c.frequency,d.type=c.type;const h=i+c.startTime,p=h+c.duration;f.gain.setValueAtTime(.001,h),f.gain.linearRampToValueAtTime(c.gain,h+.008),f.gain.exponentialRampToValueAtTime(.001,p),d.start(h),d.stop(p+.01)}}const yv={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 ri(r,l){if(!l)return;const i=yv[r];if(!i){le(`[SoundEffects] Unknown sound effect type: ${r}`);return}try{bv(i),le(`[SoundEffects] Playing ${r} sound effect`)}catch(c){le(`[SoundEffects] Failed to play ${r} sound effect:`,c)}}function vv({messages:r,onRegenerate:l,onStartThread:i,onClearThread:c,onSendThreadMessage:d,sessionId:f,isLoading:h,contentMaxWidthClass:p="max-w-[64rem]",availableModels:x,defaultModel:v,selectedModel:b}){const w=g.useRef(null),k=g.useRef(null),S=g.useRef(r.length),j=g.useRef(""),_=g.useRef(h),z=g.useRef(!0),{settings:$}=Go(),{topLevelMessages:ee,threadLookup:Y}=g.useMemo(()=>{const N=new Map,X=[];return r.forEach(U=>{if(U.isThreadMessage&&U.parentMessageId){const Q=N.get(U.parentMessageId)||[];N.set(U.parentMessageId,[...Q,U]);return}X.push(U)}),{topLevelMessages:X,threadLookup:N}},[r]),R=()=>{if(!k.current)return;const{scrollTop:N,scrollHeight:X,clientHeight:U}=k.current,I=X-N-U<200;z.current=I},q=g.useCallback(()=>{requestAnimationFrame(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)})},[]);return g.useEffect(()=>{const N=r.length,X=S.current,U=N>X,Q=r[r.length-1],I=(Q==null?void 0:Q.content)||"",ae=I!==j.current,fe=(Q==null?void 0:Q.isStreaming)??!1;U||fe&&ae?(q(),z.current=!0):z.current&&ae&&q(),S.current=N,j.current=I},[r,q]),g.useEffect(()=>{h&&(q(),z.current=!0)},[h,q]),g.useEffect(()=>{if(_.current&&!h){const N=r[r.length-1];(N==null?void 0:N.role)==="assistant"&&N.content&&ri("messageReceived",$.soundEnabled)}_.current=h},[h,r,$.soundEnabled]),ee.length===0?u.jsx("div",{className:"flex-1 flex items-center justify-center px-4 sm:px-6",children:u.jsxs("div",{className:"text-center text-lg text-gray-500 dark:text-[#bfc2cd]",children:[u.jsx("p",{className:"text-xl",children:"Your messages will appear here."}),u.jsx("p",{className:"mt-1 text-lg",children:"Start the conversation by sending a prompt below."})]})}):u.jsx("div",{ref:k,className:"message-list flex-1 overflow-y-auto pb-8 pt-4 sm:pt-6",onScroll:R,children:u.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:u.jsxs("div",{className:`message-list__rail mx-auto w-full space-y-7 ${p}`,children:[ee.map(N=>u.jsx("div",{className:`flex w-full ${N.role==="user"?"justify-end":"justify-start"}`,style:{contentVisibility:"auto",containIntrinsicSize:"420px"},children:u.jsx(gv,{message:N,onRegenerate:l,onStartThread:i,onClearThread:c,onSendThreadMessage:d,threadMessages:Y.get(N.id),sessionId:f,isThreadSendDisabled:h,availableModels:x,defaultModel:v,selectedModel:b})},N.id)),u.jsx("div",{ref:w,className:"h-8"})]})})})}const wv=4e3;function Sv(r,l,i={}){var U;const[c,d]=g.useState(!1),[f,h]=g.useState(null),p=g.useRef(null),x=g.useRef(""),v=g.useRef(""),b=g.useRef(!1),w=g.useRef(null),k=typeof navigator<"u"?navigator.language:"en-US",S=Number.isFinite(i.silenceTimeoutMs)?Math.max(Math.floor(i.silenceTimeoutMs),1e3):wv,j=((U=i.language)==null?void 0:U.trim())||k||"en-US",_=g.useCallback(Q=>Q.replace(/\s+/g," ").trim(),[]),z=g.useCallback(Q=>{const I=_(Q);I&&I!==v.current&&(v.current=I,r(I))},[_,r]),$=g.useCallback(()=>{if(!x.current)return;const Q=x.current;x.current="",z(Q)},[z]),ee=typeof window<"u"&&("webkitSpeechRecognition"in window||"SpeechRecognition"in window),Y=g.useCallback(()=>{!l||b.current||(b.current=!0,l())},[l]),R=g.useCallback(()=>{w.current!==null&&(clearTimeout(w.current),w.current=null)},[]),q=g.useCallback(()=>{R(),w.current=setTimeout(()=>{le("Speech recognition silence threshold reached, stopping recording"),p.current?p.current.stop():Y()},S)},[R,Y,S]),N=g.useCallback(()=>{if(!ee){h("Speech recognition is not supported in this browser. Please try Chrome, Edge, or Safari.");return}if(!p.current)try{b.current=!1;const Q=window.SpeechRecognition||window.webkitSpeechRecognition,I=new Q;I.continuous=!0,I.interimResults=!0,I.lang=j,I.maxAlternatives=1,I.onstart=()=>{d(!0),h(null),x.current="",v.current="",le("Speech recognition started"),q()},I.onresult=ae=>{let fe="",Ce="";for(let te=ae.resultIndex;te<ae.results.length;te++){const oe=ae.results[te][0].transcript;ae.results[te].isFinal?fe+=oe:Ce+=oe}Ce&&(x.current=_(Ce)),fe&&(x.current="",z(fe)),q()},I.onend=()=>{R(),$(),d(!1),p.current=null,le("Speech recognition ended"),Y()},I.onerror=ae=>{switch(R(),He("Speech recognition error:",ae.error),d(!1),p.current=null,x.current="",Y(),ae.error){case"no-speech":h("No speech detected. Please try again.");break;case"audio-capture":h("Microphone access denied. Please allow microphone access and try again.");break;case"not-allowed":h("Microphone access not allowed. Please enable microphone permissions.");break;case"network":h("Network error occurred. Please check your connection.");break;default:h(`Speech recognition error: ${ae.error}`)}},I.start(),p.current=I}catch(Q){He("Failed to start speech recognition:",Q),h("Failed to start speech recognition. Please try again."),d(!1)}},[ee,$,Y,q,R,j,_,z]),X=g.useCallback(()=>{if(le("Stopping speech recognition..."),p.current){const Q=p.current;Q.onstart=null,Q.onerror=null;try{Q.stop()}catch(I){le("Recognition already stopped or error stopping:",I),R(),$(),Q.onend=null,Q.onresult=null,p.current=null,d(!1),Y()}}R(),d(!1),h(null),le("Speech recognition stopped, isListening set to false")},[R,$,Y]);return{isListening:c,isSupported:ee,startListening:N,stopListening:X,error:f}}const kv=300,Lp=3,Co=5,_v=6e4;function Rp(r){if(typeof r!="string")return null;const l=r.replace(/[\r\n\u2028\u2029]+/g," ").replace(/\s{2,}/g," ").trim();return l?{text:l}:null}function Av(r,l={}){const{enabled:i=cg(),adapterName:c,sessionId:d,adapterSupportsAutocomplete:f,skill:h,inputRef:p}=l,[x,v]=g.useState([]),[b,w]=g.useState(!1),[k,S]=g.useState(-1),j=g.useRef(null),_=g.useRef(null),z=g.useRef(null),$=g.useRef(null),ee=g.useRef(null),Y=g.useRef(0),R=g.useRef([]),q=g.useRef([]),N=g.useRef(new Map);g.useEffect(()=>{R.current=x},[x]);const X=g.useCallback(oe=>{const E=N.current.get(oe);return E?E<=Date.now()?(N.current.delete(oe),!1):!0:!1},[]),U=g.useCallback((oe,E=!0)=>{const V=oe.toLowerCase().trim(),H=q.current.length>0?q.current:R.current;if(!V)return H.slice(0,Co);const P=H.filter(ce=>ce.text.toLowerCase().includes(V));return P.length>0?P.slice(0,Co):E?H.slice(0,Co):[]},[]),Q=g.useCallback(async oe=>{if(!i||oe.length<Lp){v([]),q.current=[],_.current&&clearTimeout(_.current),z.current&&clearTimeout(z.current),w(!1);return}if(!c){v([]),q.current=[],_.current&&clearTimeout(_.current),w(!1);return}if(f===!1||X(c)){v([]),q.current=[],_.current&&clearTimeout(_.current),w(!1);return}$.current&&$.current.abort(),$.current=new AbortController;const E=Y.current+1;Y.current=E,_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{E===Y.current&&w(!0)},150);try{const V={"X-Adapter-Name":c};d&&(V["X-Session-ID"]=d);const H=new URLSearchParams;H.set("q",oe),H.set("limit",String(Co)),h&&H.set("skill",h);const P=`/api/v1/autocomplete?${H.toString()}`,ce=await fetch(P,{method:"GET",headers:V,signal:$.current.signal});if(!ce.ok){Be("[useAutocomplete] Request failed:",ce.status),[404,405,501].includes(ce.status)?(N.current.set(c,Date.now()+_v),v([]),q.current=[]):v(U(oe));return}const xe=await ce.json(),pe=Array.isArray(xe==null?void 0:xe.suggestions)?xe.suggestions.map(F=>Rp(typeof F=="string"?F:F==null?void 0:F.text)).filter(F=>F!==null):[];if(E!==Y.current)return;pe.length===0?v(U(oe,!1)):(v(pe),q.current=pe),S(-1),le("[useAutocomplete] Received",pe.length,"suggestions")}catch(V){if(V instanceof Error&&V.name==="AbortError")return;Be("[useAutocomplete] Error:",V instanceof Error?V.message:String(V)),E===Y.current&&v(U(oe))}finally{E===Y.current&&(_.current&&(clearTimeout(_.current),_.current=null),w(!1))}},[i,c,d,f,h,U,X]);g.useEffect(()=>{j.current&&clearTimeout(j.current);const oe=()=>{$.current&&$.current.abort(),_.current&&clearTimeout(_.current),w(!1)},E=()=>{z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{z.current=null,v([]),oe()},0)};if(!i||r.length<Lp||f===!1||c&&X(c)){E();return}if(ee.current){if(r===ee.current){E();return}ee.current=null}return j.current=setTimeout(()=>{Q(r)},kv),()=>{j.current&&clearTimeout(j.current),z.current&&(clearTimeout(z.current),z.current=null)}},[r,Q,i,c,f,X]),g.useEffect(()=>()=>{$.current&&$.current.abort(),_.current&&clearTimeout(_.current)},[]);const I=g.useCallback(()=>{S(oe=>{const E=R.current.length;return E===0?-1:oe<E-1?oe+1:0})},[]),ae=g.useCallback(()=>{S(oe=>{const E=R.current.length;return E===0?-1:oe>0?oe-1:E-1})},[]),fe=g.useCallback(()=>{v([]),q.current=[],S(-1),$.current&&$.current.abort(),_.current&&clearTimeout(_.current),w(!1)},[]),Ce=g.useCallback(oe=>{if(!(p!=null&&p.current))return;const E=()=>{const V=p.current;if(!V)return;const H=typeof oe=="string"?oe.length:V.value.length;V.focus({preventScroll:!0}),typeof V.setSelectionRange=="function"&&V.setSelectionRange(H,H)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(E):setTimeout(E,0)},[p]),te=g.useCallback(oe=>{ee.current=oe},[]);return{suggestions:x,isLoading:b,selectedIndex:k,setSelectedIndex:S,selectNext:I,selectPrevious:ae,clearSuggestions:fe,focusInputAfterSelection:Ce,suppressUntilQueryChange:te}}const Ll=new Map,Cv=new Map,jv=new Map,Nv=new Set,Tv=()=>{if(typeof window>"u")return null;try{return localStorage.getItem("chat-adapter-name")}catch{return null}},Ag=r=>typeof r=="object"&&r!==null&&"message"in r,Ev=r=>r instanceof Error?r.message:typeof r=="string"?r:Ag(r)?r.message??"Unknown error":"Unknown error";function Mv({conversationId:r,onFilesSelected:l,onUploadError:i,onClose:c,onUploadingChange:d,onUploadSuccess:f,maxFiles:h=Le.maxFilesPerConversation,disabled:p=!1}){const[x,v]=g.useState(!1),[b,w]=g.useState(0),k=g.useRef(null),S=g.useRef(jv),j=g.useRef(Nv),_=g.useRef(new Map),z=g.useRef(!0),$=g.useRef(Cv),ee=g.useRef(r),Y=Ve(F=>F.conversations),R=g.useMemo(()=>{if(!r)return new Map;const F=Ll.get(r);return F?new Map(F):new Map},[r,b]),q=g.useCallback(F=>{if(!F){d==null||d(null,!1),w(we=>we+1);return}const me=Ll.get(F)||new Map,ue=Y.find(we=>we.id===F),de=new Map(me);if(ue!=null&&ue.attachedFiles){const we=new Set(ue.attachedFiles.filter(W=>W.processing_status==="completed"||W.processing_status==="failed"||W.processing_status==="error").map(W=>W.file_id));de.forEach((W,se)=>{W.fileId&&we.has(W.fileId)&&de.delete(se)})}de.size>0?(Ll.set(F,de),d==null||d(F,!0)):(Ll.delete(F),d==null||d(F,!1)),w(we=>we+1)},[Y,d]);g.useEffect(()=>{ee.current=r,setTimeout(()=>{q(r)},0)},[r,q]),g.useEffect(()=>{r&&setTimeout(()=>{q(r)},0)},[Y,r,q]);const N=g.useCallback((F,me)=>{if(!F)return;const ue=Ll.get(F)||new Map,de=me(new Map(ue));de.size>0?Ll.set(F,de):Ll.delete(F),d==null||d(F,de.size>0),w(we=>we+1)},[d]),X=g.useCallback((F,me)=>{if(!F)return;const ue=$.current.get(F)||[],de=me([...ue||[]]),we=new Set(ue.map(W=>W.file_id));if($.current.set(F,de),l(F,de),f){const W=de.filter(se=>!we.has(se.file_id));W.length>0&&f(F,W)}w(W=>W+1)},[l,f]),U=Ve(F=>F.removeFileFromConversation),Q=Ve(F=>F.addFileToConversation);g.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]);const I=g.useCallback(()=>{z.current=!1,new Map(_.current).forEach(me=>me.abort()),setTimeout(()=>{const me=Ve.getState(),ue=new Map(me.conversations.map(we=>[we.id,we])),de=[];S.current.forEach((we,W)=>{var se;if(we){const be=ue.get(we);if(new Set(((se=be==null?void 0:be.attachedFiles)==null?void 0:se.map(ge=>ge.file_id))||[]).has(W)){j.current.add(W),S.current.delete(W);return}}if(j.current.has(W)){le(`[FileUpload] Skipping cleanup delete for ${W}; file was previously attached and already handled`),S.current.delete(W),j.current.delete(W);return}de.push({fileId:W,conversationId:we||null})}),de.length>0&&(c==null||c(),de.forEach(async({fileId:we,conversationId:W})=>{try{if(W)await U(W,we);else{const se=Tv();await ui.deleteFile(we,void 0,void 0,se??void 0)}}catch(se){if(Ag(se)){const be=se.message??"";!be.includes("404")&&!be.includes("File not found")&&Be(`Failed to cleanup file ${we} during component unmount:`,se)}else Be(`Failed to cleanup file ${we} during component unmount`,se)}}))},300)},[c,U]);g.useEffect(()=>I,[I]);const ae=g.useCallback(async F=>{if(!F||F.length===0)return;const me=Array.from(F),ue=Ve.getState(),de=r||ue.currentConversationId;if(!de){i==null||i("Please select or create a conversation before uploading files.");return}const we=ue.conversations.find(ke=>ke.id===de);if(!we){i==null||i("Conversation not found. Please try again.");return}if(($.current.get(de)||[]).length+me.length>h){const ke=`Maximum ${h} files allowed per conversation. Please remove some files first.`;va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${h} files per conversation. Sign in to upload more files.`),i==null||i(ke);return}if(Le.maxTotalFiles!==null&&ue.conversations.reduce((ze,Ue)=>{var Fe;return ze+(((Fe=Ue.attachedFiles)==null?void 0:Fe.length)||0)},0)+me.length>Le.maxTotalFiles){const ze=`Maximum ${Le.maxTotalFiles} total files allowed across all conversations. Please remove some files from other conversations first.`;va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${Le.maxTotalFiles} total files. Sign in to upload more files.`),i==null||i(ze);return}if(!we.adapterName){i==null||i("Adapter not configured for this conversation. Please select an adapter first.");return}const se=we.adapterName,be=Ha(we.apiUrl);for(let ke=0;ke<me.length;ke++){const ge=me[ke],ze=new AbortController;_.current.set(ge.name,ze);const Ue=`${de}-${ge.name}-${Date.now()}-${ke}`;let Fe=null;try{const je=await ui.uploadFile(ge,Xe=>{if(N(de,et=>(et.set(Ue,Xe),et)),Xe.fileId&&!Fe){Fe=Xe.fileId,S.current.set(Xe.fileId,de),j.current.add(Xe.fileId);const et={file_id:Xe.fileId,filename:ge.name,mime_type:ge.type||"application/octet-stream",file_size:ge.size,processing_status:Xe.status==="uploading"?"uploading":Xe.status==="processing"?"processing":Xe.status==="completed"?"completed":void 0};le(`[FileUpload] Adding file ${Xe.fileId} to conversation ${de} immediately (status: ${et.processing_status})`),Q(de,et)}},void 0,be,se).catch(Xe=>{if(Xe.message&&Xe.message.includes("was deleted")){Fe&&S.current.delete(Fe);const et=Xe.message.match(/File\s+([\w-]+)\s+was deleted/);return et&&et[1]&&S.current.delete(et[1]),le(`File ${ge.name} was deleted during upload`),null}throw Xe});je?(S.current.set(je.file_id,de),j.current.add(je.file_id),le(`[FileUpload] Updating file ${je.file_id} in conversation ${de} with final status`),Q(de,je),je.processing_status==="completed"||je.processing_status==="failed"||je.processing_status==="error"?N(de,et=>(et.delete(Ue),et)):N(de,et=>{const Bt=et.get(Ue);return Bt&&et.set(Ue,{...Bt,progress:90,status:"processing",fileId:je.file_id}),et}),X(de,et=>{if(new Set(et.map(ie=>ie.file_id)).has(je.file_id))return et;const xt=[...et,je];return le(`[FileUpload] Updated uploadedFiles for ${de}: ${xt.length} files`,xt),xt})):(Be(`Upload completed for ${ge.name} but uploadedAttachment is null`),N(de,Xe=>(Xe.delete(Ue),Xe)))}catch(je){const Xe=Ev(je);if(je instanceof DOMException&&je.name==="AbortError"||ze.signal.aborted){le(`Upload cancelled for ${ge.name}`),Fe&&S.current.delete(Fe);continue}if(Xe.includes("was deleted")){le(`File ${ge.name} was deleted during upload`),Fe&&S.current.delete(Fe);const xt=Xe.match(/File\s+([\w-]+)\s+was deleted/);xt&&xt[1]&&S.current.delete(xt[1]);continue}z.current?(He(`Failed to upload file ${ge.name}:`,je),He(`File type: ${ge.type}, File name: ${ge.name}`),i==null||i(Xe||`Failed to upload ${ge.name}`)):Be(`Upload error for ${ge.name} (component unmounted):`,Xe),Fe&&S.current.delete(Fe);const et=Ue,Bt=de;setTimeout(()=>{N(Bt,xt=>(xt.delete(et),xt))},5e3)}finally{_.current.delete(ge.name)}}},[Q,r,h,i,X,N]),fe=g.useCallback(F=>{F.preventDefault(),F.stopPropagation(),p||v(!0)},[p]),Ce=g.useCallback(F=>{F.preventDefault(),F.stopPropagation(),v(!1)},[]),te=g.useCallback(F=>{if(F.preventDefault(),F.stopPropagation(),v(!1),p)return;const me=F.dataTransfer.files;ae(me)},[p,ae]),oe=g.useCallback(F=>{const me=F.target.files;ae(me),k.current&&(k.current.value="")},[ae]),E=g.useCallback(()=>{!p&&k.current&&k.current.click()},[p]),V=g.useCallback(F=>{p||(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),E())},[p,E]),H=R.size>0,P=g.useMemo(()=>{const F=new Map;return Y.forEach(me=>{F.set(me.id,me.title||"Conversation")}),F},[Y]),ce=g.useMemo(()=>{const F=[];return Ll.forEach((me,ue)=>{ue!==r&&me.size>0&&F.push({conversationId:ue,uploads:Array.from(me.entries()).map(([de,we])=>({key:de,progress:we}))})}),F},[r,b]),xe=(F,me)=>{const ue=F.status==="error";return u.jsxs("div",{className:`group relative w-full flex items-center gap-3 rounded-lg px-3 py-2.5 overflow-hidden transition-colors ${ue?"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:[!ue&&u.jsx("div",{className:"absolute inset-0 bg-blue-50 dark:bg-white/[0.04] transition-all duration-500 ease-out rounded-lg",style:{width:`${F.progress}%`}}),u.jsxs("div",{className:"relative flex items-center gap-3 w-full min-w-0",children:[u.jsx("div",{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md ${ue?"bg-red-100 dark:bg-red-500/15":"bg-blue-100 dark:bg-white/[0.06]"}`,children:ue?u.jsx(Mo,{className:"h-4 w-4 text-red-500 dark:text-red-400"}):u.jsx(zo,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 animate-spin"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-sm font-medium text-[#353740] dark:text-[#ececf1] truncate",children:F.filename}),ue?u.jsx("p",{className:"mt-0.5 text-xs text-red-600 dark:text-red-400 truncate",children:F.error||"Processing failed"}):u.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[u.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-[#242424] rounded-full h-1",children:u.jsx("div",{className:"bg-blue-500 dark:bg-blue-400 h-1 rounded-full transition-all duration-500 ease-out",style:{width:`${F.progress}%`}})}),u.jsxs("span",{className:"text-[11px] tabular-nums text-gray-400 dark:text-[#8e8ea0] shrink-0",children:[Math.round(F.progress),"%"]})]})]}),u.jsx("span",{className:`text-xs font-medium shrink-0 ${ue?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-[#bfc2cd]"}`,children:F.status==="uploading"?"Uploading":F.status==="processing"?"Processing":F.status==="completed"?"Done":"Failed"})]})]},me)},pe=u.jsx("div",{className:"w-full max-w-full overflow-hidden space-y-1.5",role:"status","aria-live":"polite",children:Array.from(R.entries()).map(([F,me])=>xe(me,F))});return u.jsxs("div",{className:"w-full max-w-full overflow-hidden space-y-2",children:[H&&pe,!H&&u.jsxs("button",{type:"button",onClick:E,onKeyDown:V,onDragOver:fe,onDragLeave:Ce,onDrop:te,disabled:p,className:`
|
|
334
|
+
`)){const ae=Ap(I);ae&&(yield ae)}}else{const X=await R.json();yield{text:X.message||X.response||"",done:!0,audio:X.audio,audioFormat:X.audio_format||X.audioFormat,image:X.image,image_format:X.image_format,image_revised_prompt:X.image_revised_prompt,image_url:X.image_url,video:X.video,video_format:X.video_format,video_revised_prompt:X.video_revised_prompt,video_url:X.video_url,document:X.document,document_format:X.document_format,document_revised_prompt:X.document_revised_prompt,document_url:X.document_url,assistant_message_id:X.assistant_message_id,threading:X.threading}}},async createThread(h,p){const x=await fetch("/api/threads",{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d,"X-Session-ID":p}),body:JSON.stringify({message_id:h,session_id:p})});if(!x.ok)throw new Error(`Failed to create thread: ${x.statusText}`);return x.json()},async getThreadInfo(h){const p=await fetch(`/api/threads/${jn(h)}`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to get thread info: ${p.statusText}`);return p.json()},async deleteThread(h){const p=await fetch(`/api/threads/${jn(h)}`,{method:"DELETE",headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to delete thread: ${p.statusText}`);return p.json()},async submitFeedback(h,p,x){const v=await fetch("/api/feedback",{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d,"X-Session-ID":p}),body:JSON.stringify({message_id:h,session_id:p,feedback_type:x})});if(!v.ok)throw new Error(`Failed to submit feedback: ${v.statusText}`);return v.json()},async getSessionFeedback(h){const p=await fetch(`/api/feedback/${jn(h)}`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to get feedback: ${p.statusText}`);return p.json()},async clearConversationHistory(h){const p=h||f;if(!p)throw new Error("No session ID available for clearing conversation history");const x=await fetch(`/api/admin/chat-history/${jn(p)}`,{method:"DELETE",headers:await Dt({"X-Adapter-Name":d})});if(!x.ok)throw new Error(`Failed to clear history: ${x.statusText}`);return x.json()},async getConversationHistory(h,p){const x=h||f;if(!x)throw new Error("No session ID available for conversation history");const v=typeof p=="number"&&Number.isFinite(p)&&p>0?`?limit=${Math.floor(p)}`:"",b=await fetch(`/api/admin/chat-history/${jn(x)}${v}`,{headers:await Dt({"X-Adapter-Name":d})});if(!b.ok)throw new Error(`Failed to load history: ${b.statusText}`);return b.json()},async deleteConversationWithFiles(h,p){const x=h||f;if(!x)throw new Error("No session ID available for deleting conversation");const v=Gy(p),b=await fetch(`/api/admin/conversations/${jn(x)}${v}`,{method:"DELETE",headers:await Dt({"X-Adapter-Name":d})});if(!b.ok)throw new Error(`Failed to delete conversation: ${b.statusText}`);return b.json()},getSessionId:()=>f,async uploadFile(h){const p=new FormData;p.append("file",h);const x=await fetch("/api/files/upload",{method:"POST",headers:await Dt({"X-Adapter-Name":d}),body:p});if(!x.ok)throw new Error(`Failed to upload file: ${x.statusText}`);return x.json()},async listFiles(){const h=await fetch("/api/files",{headers:await Dt({"X-Adapter-Name":d})});if(!h.ok)throw new Error(`Failed to list files: ${h.statusText}`);const p=await h.json();return Array.isArray(p)?p:p.files||[]},async getFileInfo(h){const p=await fetch(`/api/files/${jn(h)}`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to get file info: ${p.statusText}`);return p.json()},async queryFile(h,p,x){const v=await fetch(`/api/files/${jn(h)}/query`,{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d}),body:JSON.stringify({query:p,max_results:x})});if(!v.ok)throw new Error(`Failed to query file: ${v.statusText}`);return v.json()},async deleteFile(h){const p=await fetch(`/api/files/${jn(h)}`,{method:"DELETE",headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(`Failed to delete file: ${p.statusText}`);return p.json()},async validateApiKey(){const h=await fetch(`/api/admin/api-keys/${jn(d)}/status`,{headers:await Dt({"X-Adapter-Name":d})});if(!h.ok)throw new Error(`Failed to validate API key: ${h.statusText}`);return h.json()},async getAdapterInfo(){const h="/api/admin/adapters/info",p=w=>{if(!w)return 0;const k=Number(w);if(Number.isFinite(k)&&k>0)return Math.min(k*1e3,3e4);const S=Date.parse(w);if(!Number.isNaN(S)){const j=S-Date.now();if(j>0)return Math.min(j,3e4)}return 0},x=w=>new Promise(k=>setTimeout(k,w)),v=async()=>fetch(h,{headers:await Dt({"X-Adapter-Name":d})});let b=await v();if(b.status===429){const w=p(b.headers.get("Retry-After"));w>0&&(await x(w),b=await v())}if(!b.ok){const w=await b.text(),k=`${b.status} ${b.statusText}`.trim(),S=b.status===401?`Adapter info request was unauthorized for '${d}'. Verify the adapter exists and you have access.`:`Failed to load adapter info (${k}) for '${d}'.`;throw console.warn("[ProxyApi] Adapter info request failed",{adapter:d,status:b.status,statusText:b.statusText,details:w||void 0}),new yg(S,b)}return b.json()},async stopChat(h,p){const x=await fetch("/api/v1/chat/stop",{method:"POST",headers:await Dt({"Content-Type":"application/json","X-Adapter-Name":d}),body:JSON.stringify({session_id:h,request_id:p})});return x.ok?(await x.json()).status==="cancelled":(console.warn(`[ProxyApi] stopChat failed: ${x.status} ${x.statusText}`),!1)},async getAdapterModels(h){const p=await fetch(`/api/admin/adapters/${encodeURIComponent(h)}/models`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(await ni(p));return p.json()},async getAllModels(){const h=await fetch("/api/admin/models",{headers:await Dt({"X-Adapter-Name":d})});if(!h.ok)throw new Error(await ni(h));return h.json()},async getAdapterSkills(h){const p=await fetch(`/api/admin/adapters/${encodeURIComponent(h)}/skills`,{headers:await Dt({"X-Adapter-Name":d})});if(!p.ok)throw new Error(await ni(p));return p.json()},async getAllSkills(){const h=await fetch("/api/admin/skills",{headers:await Dt({"X-Adapter-Name":d})});if(!h.ok)throw new Error(await ni(h));return h.json()}});return{configureApi:i,streamChat:async function*(d,f,h,p,x,v,b,w,k,S,j,_,z){if(!l)throw new Error("Adapter name is required");yield*c(l,s).streamChat(d,f,h,p,x,v,b,w,k,S,j,_,z)},stopChat:async(d,f)=>{if(!l)throw new Error("Adapter name is required");return c(l,s).stopChat(d,f)},ApiClient:class{constructor(f){ca(this,"client");const h=f.adapterName||null,p=f.sessionId||null;if(!h)throw new Error("Adapter name is required");this.client=c(h,p)}async*streamChat(...f){yield*this.client.streamChat(...f)}get createThread(){var f;return(f=this.client.createThread)==null?void 0:f.bind(this.client)}get getThreadInfo(){var f;return(f=this.client.getThreadInfo)==null?void 0:f.bind(this.client)}get deleteThread(){var f;return(f=this.client.deleteThread)==null?void 0:f.bind(this.client)}get submitFeedback(){var f;return(f=this.client.submitFeedback)==null?void 0:f.bind(this.client)}get getSessionFeedback(){var f;return(f=this.client.getSessionFeedback)==null?void 0:f.bind(this.client)}get clearConversationHistory(){var f;return(f=this.client.clearConversationHistory)==null?void 0:f.bind(this.client)}get getConversationHistory(){var f;return(f=this.client.getConversationHistory)==null?void 0:f.bind(this.client)}get deleteConversationWithFiles(){var f;return(f=this.client.deleteConversationWithFiles)==null?void 0:f.bind(this.client)}get getSessionId(){var f;return(f=this.client.getSessionId)==null?void 0:f.bind(this.client)}get uploadFile(){var f;return(f=this.client.uploadFile)==null?void 0:f.bind(this.client)}get listFiles(){var f;return(f=this.client.listFiles)==null?void 0:f.bind(this.client)}get getFileInfo(){var f;return(f=this.client.getFileInfo)==null?void 0:f.bind(this.client)}get queryFile(){var f;return(f=this.client.queryFile)==null?void 0:f.bind(this.client)}get deleteFile(){var f;return(f=this.client.deleteFile)==null?void 0:f.bind(this.client)}get validateApiKey(){var f;return(f=this.client.validateApiKey)==null?void 0:f.bind(this.client)}get getAdapterInfo(){var f;return(f=this.client.getAdapterInfo)==null?void 0:f.bind(this.client)}get stopChat(){var f;return(f=this.client.stopChat)==null?void 0:f.bind(this.client)}get getAdapterModels(){var f;return(f=this.client.getAdapterModels)==null?void 0:f.bind(this.client)}get getAllModels(){var f;return(f=this.client.getAllModels)==null?void 0:f.bind(this.client)}get getAdapterSkills(){var f;return(f=this.client.getAdapterSkills)==null?void 0:f.bind(this.client)}get getAllSkills(){var f;return(f=this.client.getAllSkills)==null?void 0:f.bind(this.client)}}}}async function Xy(){return ko||(le("Loading API via Express proxy"),ko=Vy(),le("API loaded successfully"),ko)}async function kt(){return await Xy()}class Cp{static async getAdapterSkills(l,i){const c=await kt(),d=new c.ApiClient({apiUrl:"",adapterName:i});return d.getAdapterSkills?(await d.getAdapterSkills(l)).available_skills:[]}static async getAllSkills(l){const i=await kt(),c=new i.ApiClient({apiUrl:"",adapterName:l});return c.getAllSkills?(await c.getAllSkills()).skills:[]}}const Yy=6e4;function vg(s={}){const{adapterName:l,enabled:i=!0,selectionScopeKey:c,supportsThreading:d=!1}=s,f=i&&!!l&&!d,h=c??l??"__default__",[p,x]=g.useState([]),[v,b]=g.useState(!1),[w,k]=g.useState(null),[S,j]=g.useState({}),_=g.useRef(null),z=g.useRef(new Map),$=g.useCallback(async q=>{var U,Q;const N=q,X=z.current.get(N);if(X&&X.expiresAt>Date.now()){x(X.skills),k(q);return}_.current&&_.current.abort(),_.current=new AbortController,b(!0);try{const[I,ae]=await Promise.all([Cp.getAdapterSkills(q,q),Cp.getAllSkills(q)]);if((U=_.current)!=null&&U.signal.aborted)return;const fe=ae.filter(Ce=>I.includes(Ce.name)&&Ce.enabled);z.current.set(N,{skills:fe,expiresAt:Date.now()+Yy}),x(fe),k(q),le("[useSkills] Loaded",fe.length,"skills for adapter",q)}catch(I){if(I instanceof Error&&I.name==="AbortError")return;Be("[useSkills] Failed to load skills:",I instanceof Error?I.message:String(I)),x([]),k(q)}finally{(Q=_.current)!=null&&Q.signal.aborted||b(!1)}},[]);g.useEffect(()=>{if(!f||!l)return;const q=window.setTimeout(()=>{$(l)},0);return()=>{var N;window.clearTimeout(q),(N=_.current)==null||N.abort()}},[f,l,$]);const ee=g.useCallback(q=>{j(N=>{const X=N[h]??null;if(X===q||(X==null?void 0:X.name)===(q==null?void 0:q.name))return N;const U={...N};return q?U[h]=q:delete U[h],U})},[h]),Y=g.useCallback(()=>{j(q=>{if(!q[h])return q;const N={...q};return delete N[h],N})},[h]),R=f?S[h]??null:null;return{skills:f&&w===l?p:[],isLoading:f?v||w!==l:!1,selectedSkill:R,selectSkill:ee,clearSkill:Y}}const jp=s=>{let l;const i=new Set,c=(v,b)=>{const w=typeof v=="function"?v(l):v;if(!Object.is(w,l)){const k=l;l=b??(typeof w!="object"||w===null)?w:Object.assign({},l,w),i.forEach(S=>S(l,k))}},d=()=>l,p={setState:c,getState:d,getInitialState:()=>x,subscribe:v=>(i.add(v),()=>i.delete(v))},x=l=s(c,d,p);return p},Qy=(s=>s?jp(s):jp),Zy=s=>s;function Ky(s,l=Zy){const i=Tn.useSyncExternalStore(s.subscribe,Tn.useCallback(()=>l(s.getState()),[s,l]),Tn.useCallback(()=>l(s.getInitialState()),[s,l]));return Tn.useDebugValue(i),i}const Np=s=>{const l=Qy(s),i=c=>Ky(l,c);return Object.assign(i,l),i},wg=(s=>s?Np(s):Np),wa=wg(s=>({showLoginPrompt:!1,promptMessage:"",openLoginPrompt:l=>s({showLoginPrompt:!0,promptMessage:l}),closeLoginPrompt:()=>s({showLoginPrompt:!1,promptMessage:""})})),_o=s=>{const l=s==null?void 0:s.trim();return l||(typeof window<"u"&&window.localStorage?localStorage.getItem("chat-adapter-name"):null)};class ui{static async uploadFile(l,i,c,d,f){try{const h=Le.maxFileSizeMB*1024*1024;if(l.size>h)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(l.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(l.name)||(l.type==="application/x-zip-compressed"||l.type==="application/zip")&&/\.xlsx$/i.test(l.name)))throw new Error(`File type not supported: ${l.type||"unknown"}`);i&&i({filename:l.name,progress:0,status:"uploading"});const v=await kt(),b=(d==null?void 0:d.trim())||_t(),w=_o(f);if(!w)throw new Error("Adapter not configured. Please select an adapter from the dropdown.");le(`Using adapter: ${w}`);const k=new v.ApiClient({apiUrl:b,sessionId:null,adapterName:w});if(!k.uploadFile)throw new Error("File upload is not available.");const S=await k.uploadFile(l);i&&i({filename:l.name,progress:75,status:"processing",fileId:S.file_id});let j;try{j=await this.pollFileStatus(S.file_id,30,2e3,void 0,b,w)}catch(_){const z=_ instanceof Error?_.message:String(_);if(z.includes("was deleted"))throw new Error(`File ${S.file_id} was deleted during upload`);Be(`File status polling failed for ${S.file_id}:`,_);const $=z.includes("processing failed")||z.includes("timeout");j={file_id:S.file_id,filename:S.filename,mime_type:S.mime_type,file_size:S.file_size,processing_status:$?"failed":S.status||"processing",chunk_count:S.chunk_count,error_message:$?z:void 0}}return i&&i({filename:l.name,progress:100,status:j.processing_status==="completed"?"completed":"processing",fileId:S.file_id}),j}catch(h){let p=h instanceof Error?h.message:"Upload failed";throw p.includes("401")&&(p="Authentication failed. Please check your adapter configuration."),i&&i({filename:l.name,progress:0,status:"error",error:p}),new Error(p)}}static async uploadFiles(l,i){const d=[],f=[];for(let h=0;h<l.length;h+=3){const p=l.slice(h,h+3),x=await Promise.allSettled(p.map(async(v,b)=>{const w=h+b;return this.uploadFile(v,k=>{i&&i(w,k)})}));for(let v=0;v<x.length;v++){const b=x[v],w=h+v;b.status==="fulfilled"?d.push(b.value):(qt(`Failed to upload file ${l[w].name}:`,b.reason),f.push({index:w,file:l[w].name,error:b.reason}))}}if(d.length===0&&f.length>0){const h=f[0].error;throw h instanceof Error?h:new Error(`All ${f.length} file uploads failed`)}return f.length>0&&Be(`[FileUploadService] ${f.length} of ${l.length} files failed to upload:`,f.map(h=>h.file)),d}static async listFiles(l,i,c){try{const d=await kt(),f=(i==null?void 0:i.trim())||_t(),h=_o(c);if(!h)throw new Error("Adapter not configured");const p=new d.ApiClient({apiUrl:f,sessionId:null,adapterName:h});if(!p.listFiles)throw new Error("File listing is not available.");const x=await p.listFiles();return(Array.isArray(x)?x:Array.isArray(x.files)?x.files:[]).map(b=>({file_id:b.file_id,filename:b.filename,mime_type:b.mime_type,file_size:b.file_size,upload_timestamp:b.upload_timestamp,processing_status:b.processing_status,chunk_count:b.chunk_count,error_message:b.error_message}))}catch(d){qt("Failed to list files:",d);const f=d instanceof Error?d.message:"Failed to list files";throw new Error(f)}}static async getFileInfo(l,i,c,d){try{const f=await kt(),h=(c==null?void 0:c.trim())||_t(),p=_o(d);if(!p)throw new Error("Adapter not configured");const x=new f.ApiClient({apiUrl:h,sessionId:null,adapterName:p});if(!x.getFileInfo)throw new Error("File info retrieval is not available.");const v=await x.getFileInfo(l);return{file_id:v.file_id,filename:v.filename,mime_type:v.mime_type,file_size:v.file_size,upload_timestamp:v.upload_timestamp,processing_status:v.processing_status,chunk_count:v.chunk_count,error_message:v.error_message}}catch(f){if(f instanceof Error&&(f.message.includes("404")||f.message.includes("File not found")))throw new Error(`File ${l} was deleted`);qt(`Failed to get file info for ${l}:`,f);const h=f instanceof Error?f.message:`Failed to get file info: ${l}`;throw new Error(h)}}static async pollFileStatus(l,i=30,c=2e3,d,f,h){for(let p=0;p<i;p++)try{if(d&&!d())throw new Error("Polling cancelled - component unmounted");const x=await this.getFileInfo(l,void 0,f,h);if(x.processing_status==="completed")return x;if(x.processing_status==="error"||x.processing_status==="failed"){const v=x.error_message;throw new Error(v||`File processing failed for ${l}`)}p<i-1&&await new Promise(v=>setTimeout(v,c))}catch(x){const v=x instanceof Error?x.message:String(x);if(v.includes("404")||v.includes("File not found")||v.includes("was deleted"))throw new Error(`File ${l} was deleted during upload`);if(v.includes("component unmounted")||v.includes("processing failed")||v.includes("processing_status")||v.includes("401")||v.includes("403")||v.includes("500")||v.includes("502")||v.includes("503")||v.includes("Authentication")||v.includes("Adapter not configured"))throw x;if(p<i-1){await new Promise(b=>setTimeout(b,c));continue}throw x}throw new Error(`File processing timeout: ${l} did not complete within ${i*c/1e3} seconds`)}static async deleteFile(l,i,c,d){try{const f=await kt(),h=(c==null?void 0:c.trim())||_t(),p=_o(d);if(!p)throw new Error("Adapter not configured");const x=new f.ApiClient({apiUrl:h,sessionId:null,adapterName:p});if(!x.deleteFile)throw new Error("File deletion is not available.");return await x.deleteFile(l)}catch(f){if(f instanceof Error&&(f.message.includes("404")||f.message.includes("File not found")||f.message.includes("Not Found")))return le(`File ${l} was already deleted from server`),{message:"File already deleted",file_id:l};qt(`Failed to delete file ${l}:`,f);const h=f instanceof Error?f.message:`Failed to delete file: ${l}`;throw new Error(h)}}}class Jy{constructor(){ca(this,"audioQueue",[]);ca(this,"isPlaying",!1);ca(this,"currentAudio",null);ca(this,"audioContext",null);ca(this,"isEnabled",!1);ca(this,"onPlaybackStart",null);ca(this,"onPlaybackEnd",null);ca(this,"mimeTypeCache",new Map);ca(this,"onChunkPlayed",null);ca(this,"blobUrls",[]);ca(this,"suppressPlaybackErrors",!1)}async enableAudio(){var l,i;try{if(!this.audioContext){const f=typeof AudioContext<"u"?AudioContext:typeof window<"u"&&window.webkitAudioContext||null;f&&(this.audioContext=new f)}const c=((l=this.audioContext)==null?void 0:l.state)==="suspended"?this.audioContext.resume():Promise.resolve();let d=Promise.resolve();try{const f=this.createSilentWavBlob(),h=URL.createObjectURL(f),p=new Audio;p.setAttribute("playsinline",""),p.setAttribute("webkit-playsinline",""),p.src=h,p.volume=0,d=p.play().then(()=>{p.pause()}).catch(()=>{le("[AudioStreamManager] HTMLAudioElement silent unlock failed (will retry on next gesture)")}).finally(()=>{URL.revokeObjectURL(h)})}catch{le("[AudioStreamManager] Could not create silent audio element")}if(await c,this.audioContext&&this.audioContext.state==="running"){const f=this.audioContext.createBuffer(1,1,22050),h=this.audioContext.createBufferSource();h.buffer=f,h.connect(this.audioContext.destination),h.start(0)}return await d,this.isEnabled=!0,le("[AudioStreamManager] Audio playback enabled",{audioContextState:(i=this.audioContext)==null?void 0:i.state}),!0}catch(c){return He("[AudioStreamManager] Failed to enable audio:",c),!1}}createSilentWavBlob(){const h=new ArrayBuffer(844),p=new DataView(h),x=(v,b)=>{for(let w=0;w<b.length;w++)p.setUint8(v+w,b.charCodeAt(w))};return x(0,"RIFF"),p.setUint32(4,836,!0),x(8,"WAVE"),x(12,"fmt "),p.setUint32(16,16,!0),p.setUint16(20,1,!0),p.setUint16(22,1,!0),p.setUint32(24,8e3,!0),p.setUint32(28,8e3*2,!0),p.setUint16(32,2,!0),p.setUint16(34,16,!0),x(36,"data"),p.setUint32(40,800,!0),new Blob([h],{type:"audio/wav"})}disableAudio(){!this.isEnabled&&!this.isPlaying||(this.isEnabled=!1,this.stop(),le("[AudioStreamManager] Audio playback disabled"))}async ensureAudioContext(){var l;if(!this.audioContext){const i=typeof AudioContext<"u"?AudioContext:typeof window<"u"&&window.webkitAudioContext||null;if(i)try{this.audioContext=new i}catch(c){return He("[AudioStreamManager] Failed to create AudioContext:",c),!1}}if(((l=this.audioContext)==null?void 0:l.state)==="suspended")try{await this.audioContext.resume()}catch(i){return le("[AudioStreamManager] AudioContext resume deferred",i),!1}return!0}resolveMimeType(l){const i=this.mimeTypeCache.get(l);if(i)return i;let c;switch(l){case"mp3":c="audio/mpeg";break;case"wav":c="audio/wav";break;case"webm":c="audio/webm";break;case"ogg":c="audio/ogg";break;case"opus":{const d=typeof document<"u"?document.createElement("audio"):null;d!=null&&d.canPlayType("audio/ogg; codecs=opus")?c="audio/ogg; codecs=opus":d!=null&&d.canPlayType("audio/webm; codecs=opus")?c="audio/webm; codecs=opus":c="audio/mp4";break}default:c=`audio/${l}`}return this.mimeTypeCache.set(l,c),le(`[AudioStreamManager] Resolved MIME type for "${l}": ${c}`),c}isAudioEnabled(){return this.isEnabled}setOnPlaybackStart(l){this.onPlaybackStart=l}setOnPlaybackEnd(l){this.onPlaybackEnd=l}setOnChunkPlayed(l){this.onChunkPlayed=l}async addChunk(l){if(!this.isEnabled){le(`[AudioStreamManager] Audio disabled, dropping chunk ${l.chunkIndex}`);return}le(`[AudioStreamManager] Adding chunk ${l.chunkIndex} to queue`),this.audioQueue.push(l),this.audioQueue.sort((i,c)=>i.chunkIndex-c.chunkIndex),this.isPlaying||this.playNextChunk().catch(i=>{He("[AudioStreamManager] Playback chain error:",i)})}async playNextChunk(){var i,c;if(this.audioQueue.length===0){this.isPlaying=!1,le("[AudioStreamManager] Queue empty, playback complete"),this.onPlaybackEnd&&this.onPlaybackEnd();return}if(!this.isEnabled){le("[AudioStreamManager] Audio not enabled, skipping playback"),this.audioQueue=[],this.isPlaying=!1;return}this.suppressPlaybackErrors=!1,await this.ensureAudioContext(),this.isPlaying=!0;const l=this.audioQueue.shift();try{if(!this.isPlaying)return;if(this.onPlaybackStart&&l.chunkIndex===0&&this.onPlaybackStart(),le(`[AudioStreamManager] Playing chunk ${l.chunkIndex}`),!l.audio||l.audio.length===0)throw new Error(`Empty audio data for chunk ${l.chunkIndex}`);let d;try{d=atob(l.audio)}catch(w){throw new Error(`Failed to decode base64 audio for chunk ${l.chunkIndex}: ${w instanceof Error?w.message:String(w)}`)}if(d.length===0)throw new Error(`Decoded audio data is empty for chunk ${l.chunkIndex}`);const f=new Uint8Array(d.length);for(let w=0;w<d.length;w++)f[w]=d.charCodeAt(w);const h=this.resolveMimeType(l.audioFormat),p=new Blob([f],{type:h}),x=URL.createObjectURL(p);this.blobUrls.push(x);const v=()=>{if(this.currentAudio){try{this.currentAudio.pause()}catch{}this.currentAudio.removeAttribute("src"),this.currentAudio.load()}URL.revokeObjectURL(x),this.blobUrls=this.blobUrls.filter(w=>w!==x)};let b=!1;try{b=await this.playViaAudioElement(x,l,h,v)}catch{b=!1}if(!b&&!this.suppressPlaybackErrors&&this.audioContext){le(`[AudioStreamManager] HTMLAudioElement failed for chunk ${l.chunkIndex}, trying AudioContext fallback`);try{b=await this.playViaAudioContext(f.buffer,l.chunkIndex)}catch(w){He(`[AudioStreamManager] AudioContext fallback also failed for chunk ${l.chunkIndex}:`,w)}v()}this.currentAudio=null,this.playNextChunk().catch(w=>{He("[AudioStreamManager] Playback chain error:",w)})}catch(d){if(this.suppressPlaybackErrors){le("[AudioStreamManager] Playback stopped, suppressing audio error");return}const f=d instanceof Error?d.message:String(d);console.error(`[AudioStreamManager] Failed to play chunk ${l.chunkIndex}:`,f,d,{audioFormat:l.audioFormat,chunkIndex:l.chunkIndex,audioLength:(i=l.audio)==null?void 0:i.length,audioContextState:(c=this.audioContext)==null?void 0:c.state,isEnabled:this.isEnabled}),He(`[AudioStreamManager] Failed to play chunk ${l.chunkIndex}:`,d),this.playNextChunk().catch(h=>{He("[AudioStreamManager] Playback chain error after recovery:",h)})}}playViaAudioElement(l,i,c,d){return new Promise(f=>{const h=new Audio;h.setAttribute("playsinline",""),h.setAttribute("webkit-playsinline",""),h.src=l,this.currentAudio=h;let p=!1;const x=w=>{p||(p=!0,f(w))},v=()=>{if(this.suppressPlaybackErrors){d(),x(!0);return}const w=h.error;He(`[AudioStreamManager] Media error on chunk ${i.chunkIndex}:`,w?{code:w.code,message:w.message,SRC_NOT_SUPPORTED:w.code===MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED}:"unknown"),d(),x(!1)};h.addEventListener("error",v,{once:!0});const b=async()=>{if(!p)try{h.addEventListener("ended",()=>{p||(le(`[AudioStreamManager] Chunk ${i.chunkIndex} finished`),this.onChunkPlayed&&this.onChunkPlayed(i.chunkIndex),d(),x(!0))},{once:!0}),await h.play()}catch(w){if(this.suppressPlaybackErrors){d(),x(!0);return}le(`[AudioStreamManager] audio.play() rejected for chunk ${i.chunkIndex}:`,w),d(),x(!1)}};h.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA?b():h.addEventListener("canplay",()=>b(),{once:!0})})}playViaAudioContext(l,i){return new Promise((c,d)=>{if(!this.audioContext){d(new Error("No AudioContext"));return}const f=l.slice(0);this.audioContext.decodeAudioData(f,h=>{if(!this.audioContext||this.suppressPlaybackErrors){c(!0);return}const p=this.audioContext.createBufferSource();p.buffer=h,p.connect(this.audioContext.destination),p.onended=()=>{le(`[AudioStreamManager] Chunk ${i} finished (AudioContext path)`),this.onChunkPlayed&&this.onChunkPlayed(i),c(!0)},p.start(0)},h=>{d(h)})})}stop(){le("[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(l=>URL.revokeObjectURL(l)),this.blobUrls=[]}reset(){this.stop(),le("[AudioStreamManager] Manager reset")}getQueueSize(){return this.audioQueue.length}isCurrentlyPlaying(){return this.isPlaying}}const Ul=new Jy,Py=sy()||Vb(),Sg=()=>{if(Vo())return yd()||void 0},ii=(s,l,i)=>({id:s,sessionId:l,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiUrl:i,adapterName:Sg(),adapterLoadError:null}),Bo=()=>{const s=localStorage.getItem("chatbot-session-id");if(s)return s;const l=`session_${Date.now()}_${Math.random().toString(36).substr(2,9)}`;return localStorage.setItem("chatbot-session-id",l),l},Wy=s=>{localStorage.setItem("chatbot-session-id",s)};let ev=0;const Lo=s=>{const l=Date.now(),i=++ev,c=Math.random().toString(36).substr(2,9);return`msg_${l}_${i}_${c}_${s}`},Ol=()=>{const s=Date.now(),l=Math.random().toString(36).substr(2,9);return`session_${s}_${l}`},Tp=s=>s.filter(l=>!l.isThreadMessage&&!(l.role==="assistant"&&l.isStreaming)).length,Ep=s=>s.flatMap(i=>[i.imageUrl,i.videoUrl,i.documentUrl]).map(i=>{var c;return((c=i==null?void 0:i.match(/\/api\/files\/([^/]+)\/content/))==null?void 0:c[1])??null}).filter(i=>i!==null),tv=(s,l)=>{if(s instanceof Date)return new Date(s);if(typeof s=="number"&&Number.isFinite(s)){const i=new Date(s);if(!Number.isNaN(i.getTime()))return i}if(typeof s=="string"){const i=new Date(s);if(!Number.isNaN(i.getTime()))return i}return l?new Date(l):new Date},av=(s,l)=>{const i=new Map;l.forEach((d,f)=>{d.databaseMessageId&&i.set(d.databaseMessageId,{message:d,index:f})});const c=new Set;return s.map((d,f)=>{var w;const h=d.role==="user"?"user":"assistant",p=typeof d.message_id=="string"&&d.message_id.length>0?d.message_id:void 0;let x;if(p&&i.has(p)){const k=i.get(p);x=k.message,c.add(k.index)}else{const k=f<l.length?f:0;if(!c.has(k)&&((w=l[k])==null?void 0:w.role)===h)x=l[k],c.add(k);else for(let S=1;S<l.length;S++){const j=(k+S)%l.length;if(!c.has(j)&&l[j].role===h){x=l[j],c.add(j);break}}}const v=d.timestamp?tv(d.timestamp,x==null?void 0:x.timestamp):x!=null&&x.timestamp?new Date(x.timestamp):new Date,b=x?{...x,content:d.content??x.content,timestamp:v}:{id:p?`srv_${p}`:Lo(h),content:d.content||"",role:h,timestamp:v};if(b.isStreaming=!1,p&&(b.databaseMessageId=p),!b.supportsThreading&&d.metadata&&typeof d.metadata=="object"){const k=d.metadata,S=k==null?void 0:k.retrieved_docs;Array.isArray(S)&&S.length>0&&(b.supportsThreading=!0)}return b})},nv=(s,l)=>{if(s.length!==l.length)return!1;for(let i=0;i<s.length;i++){const c=s[i],d=l[i];if(c.role!==d.role||c.content!==d.content||(c.databaseMessageId||null)!==(d.databaseMessageId||null)||+c.timestamp!=+d.timestamp)return!1}return!0},Mp=s=>{var d,f,h,p,x,v;const l=((f=(d=s.adapterInfo)==null?void 0:d.adapter_name)==null?void 0:f.includes("voice"))||((p=(h=s.adapterInfo)==null?void 0:h.adapter_name)==null?void 0:p.includes("audio"))||((v=(x=s.adapterInfo)==null?void 0:x.adapter_name)==null?void 0:v.includes("multilingual"));let i=!1;try{const b=localStorage.getItem("chat-settings");b&&(i=JSON.parse(b).voiceEnabled===!0)}catch{Be("Failed to read global voice setting")}const c=s.audioSettings;return{returnAudio:(c==null?void 0:c.enabled)??i??!!l,ttsVoice:(c==null?void 0:c.ttsVoice)||void 0,language:(c==null?void 0:c.language)||"en-US",audioFormat:c==null?void 0:c.audioFormat}},lv=300;let Ao=null;const na=s=>{Ao&&clearTimeout(Ao),Ao=setTimeout(()=>{Ao=null;try{const l=s(),i=l.conversations.map(c=>({...c,messages:c.messages.map(d=>d.audio||d.image||d.video||d.document?Object.fromEntries(Object.entries(d).filter(([h])=>h!=="audio"&&h!=="image"&&h!=="video"&&h!=="document")):d)}));localStorage.setItem("chat-state",JSON.stringify({conversations:i,currentConversationId:l.currentConversationId}))}catch(l){l instanceof DOMException&&l.name==="QuotaExceededError"?Be("[chatStore] localStorage quota exceeded — skipping save"):qt("[chatStore] Failed to save state to localStorage:",l)}},lv)},sv=32,lr=new Map;let zl=null,Ba=null,Wn=null,us=null;const zp=(s,l)=>{const i=lr.get(s);if(i){if(i.timeoutId&&(clearTimeout(i.timeoutId),i.timeoutId=null),i.content){const c=i.content;i.content="",l(d=>({conversations:d.conversations.map(f=>{if(f.id!==s)return f;const h=[...f.messages],p=h[h.length-1];return p&&p.role==="assistant"&&p.isStreaming&&(h[h.length-1]={...p,content:p.content+c}),{...f,messages:h,updatedAt:new Date}})}))}lr.delete(s)}},Dl=(s,l,i)=>({conversations:s.conversations.map(c=>{var h;if(c.id!==l)return c;const d=[...c.messages],f=d.length-1;return((h=d[f])==null?void 0:h.role)==="assistant"&&(d[f]={...d[f],...i(d[f])}),{...c,messages:d,updatedAt:new Date}})});let Ho=!1,Fo="";async function li(){if(Ho&&Fo)return!0;try{const s=await kt(),l=localStorage.getItem("chat-api-url");l&&l===ld&&localStorage.removeItem("chat-api-url");const i=l&&l!==ld?l:_t(),c=Bo(),d=localStorage.getItem("chat-adapter-name")||Py;return s.configureApi(i,c,d),Fo=i,Ho=!0,!0}catch(s){return qt("Failed to configure API:",s),!1}}const Ve=wg((s,l)=>({conversations:[],currentConversationId:null,isLoading:!1,error:null,sessionId:Bo(),getSessionId:()=>l().sessionId,configureApiSettings:async(i,c,d)=>{const f=l(),h=f.conversations.find(x=>x.id===f.currentConversationId),p=(h==null?void 0:h.sessionId)||c||Bo();c&&Wy(c),s({sessionId:p});try{const x=await kt();if(!d||!d.trim())throw new Error("Adapter name is required");x.configureApi(i,p,d),Fo=i,Ho=!0;let v;try{const b=new x.ApiClient({apiUrl:i,sessionId:null,adapterName:d});typeof b.getAdapterInfo=="function"&&(v=await b.getAdapterInfo(),le("Adapter info loaded:",v))}catch(b){Be("Failed to load adapter info:",b)}if(h)s(b=>({conversations:b.conversations.map(w=>w.id===h.id?{...w,adapterName:d,apiUrl:i,adapterInfo:v,adapterLoadError:null,updatedAt:new Date}:w)}));else if(d&&d.trim()){const b=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=Ol();s(k=>({conversations:[...k.conversations,{id:b,sessionId:w,title:"New Conversation",messages:[],createdAt:new Date,updatedAt:new Date,adapterName:d,apiUrl:i,adapterInfo:v,adapterLoadError:null}],currentConversationId:b}))}}catch(x){throw He("Failed to configure API:",x),s({isLoading:!1}),x instanceof Error?x:new Error("Failed to configure API settings")}d?localStorage.setItem("chat-adapter-name",d):localStorage.removeItem("chat-adapter-name"),s({isLoading:!1})},createConversation:()=>{var b;const i=l(),c=Le.maxConversations,d=i.conversations.length,f=i.currentConversationId?i.conversations.find(w=>w.id===i.currentConversationId):null;if(c!==null&&d>=c){if(va()&&!hn()){const k=`You've reached the guest limit of ${c} conversation${c===1?"":"s"}. Sign in to unlock more conversations, or delete conversations to start over.`;throw s({error:k}),wa.getState().openLoginPrompt(k),new Error("Guest conversation limit reached")}const w=`Maximum of ${c} conversations reached. Please delete an existing conversation before starting a new one.`;throw s({error:w}),new Error(w)}const h=!!f&&(f.messages.length>0||(((b=f.attachedFiles)==null?void 0:b.length)||0)>0);if(f&&!h){const w="Finish or delete the current conversation before starting a new one.";throw s({error:w}),new Error(w)}const p=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,x=Ol(),v={id:p,sessionId:x,title:"New Chat",messages:[],createdAt:new Date,updatedAt:new Date,apiUrl:_t(),adapterName:Sg(),adapterLoadError:null};return s(w=>({conversations:[v,...w.conversations],currentConversationId:p,sessionId:x,isLoading:!1})),na(l),p},selectConversation:async i=>{const c=l().conversations.find(d=>d.id===i);if(c){const d=c.messages.some(x=>x.role==="assistant"&&x.isStreaming);s({currentConversationId:i,sessionId:c.sessionId,isLoading:d});const f=c.apiUrl||_t(),h=c.adapterName;if(await li()&&h){const x=await kt();if(x.configureApi(f,c.sessionId,h),!c.adapterInfo)try{const v=new x.ApiClient({apiUrl:f,sessionId:null,adapterName:h});if(typeof v.getAdapterInfo=="function"){const b=await v.getAdapterInfo();le("Adapter info loaded for conversation:",b),s(w=>({conversations:w.conversations.map(k=>k.id===i?{...k,adapterInfo:b,adapterLoadError:null,updatedAt:new Date}:k)})),na(l)}}catch(v){Be("Failed to load adapter info for conversation:",v)}}l().loadFeedbackForConversation(c.sessionId).catch(()=>{})}na(l)},deleteConversation:async i=>{var f,h;const c=l(),d=c.conversations.find(p=>p.id===i);if(le(`🗑️ Deleting conversation ${i}:`,{conversationId:i,sessionId:d==null?void 0:d.sessionId,title:d==null?void 0:d.title,messageCount:d==null?void 0:d.messages.length,fileCount:((f=d==null?void 0:d.attachedFiles)==null?void 0:f.length)||0}),c.currentConversationId===i&&Ul.stop(),d!=null&&d.sessionId)try{if(!await li())qt("Failed to configure API for conversation deletion");else{const x=d.apiUrl||_t(),v=d.adapterName;v?le(`Using conversation's adapter for deletion: ${v} (conversation: ${i})`):Be(`Skipping server deletion for conversation ${i}: adapter not configured`);const b=await kt(),w=new b.ApiClient({apiUrl:x,sessionId:d.sessionId,adapterName:v}),k=((h=d.attachedFiles)==null?void 0:h.map(_=>_.file_id))||[],S=Ep(d.messages||[]),j=[...k,...S];if(le(`🔧 Calling deleteConversationWithFiles for session: ${d.sessionId}`),w.deleteConversationWithFiles){const _=await w.deleteConversationWithFiles(d.sessionId,j);le(`✅ Deleted conversation and files for session: ${d.sessionId}`,_),le(` - Deleted ${_.deleted_messages} messages`),le(` - Deleted ${_.deleted_files} files`),_.file_deletion_errors&&_.file_deletion_errors.length>0&&Be(` - Errors deleting files: ${_.file_deletion_errors.join(", ")}`)}else Be("⚠️ deleteConversationWithFiles method not available on API client")}}catch(p){qt("Failed to clear conversation history from server:",p)}else Be(`⚠️ No session ID found for conversation ${i}, skipping server-side deletion`);s(p=>{var b;const x=p.conversations.filter(w=>w.id!==i),v=p.currentConversationId===i?((b=x[0])==null?void 0:b.id)||null:p.currentConversationId;if(x.length===0){const w=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,k=Ol(),S=ii(w,k,_t());return na(l),{conversations:[S],currentConversationId:w,sessionId:k}}return na(l),{conversations:x,currentConversationId:v}})},deleteAllConversations:async()=>{const c=[...l().conversations];le(`🗑️ Deleting all conversations (${c.length} total)`),Ul.stop();const d=c.map(async b=>{var w;if(b!=null&&b.sessionId)try{if(!await li()){qt("Failed to configure API for conversation deletion");return}const S=b.adapterName;if(!S){le(`Skipping server deletion for conversation ${b.id}: adapter not configured`);return}const j=await kt(),_=new j.ApiClient({apiUrl:Ha(b.apiUrl),sessionId:b.sessionId,adapterName:S}),z=[...((w=b.attachedFiles)==null?void 0:w.map($=>$.file_id))||[],...Ep(b.messages||[])];_.deleteConversationWithFiles?(await _.deleteConversationWithFiles(b.sessionId,z),le(`✅ Deleted conversation ${b.id} and files`)):Be(`deleteConversationWithFiles not available for conversation ${b.id}`)}catch(k){qt(`Failed to delete conversation ${b.id} from server:`,k)}}),h=(await Promise.allSettled(d)).filter(b=>b.status==="rejected");h.length>0&&qt(`Some conversations failed to delete from server: ${h.length}`,h);const p=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,x=Ol(),v=ii(p,x,_t());s({conversations:[v],currentConversationId:p,sessionId:x}),na(l)},deleteThread:async(i,c,d)=>{const f=l().conversations.find(w=>w.id===i);if(!f)throw new Error("Conversation not found");if(!f.adapterName)throw new Error("Adapter not configured for this conversation");const h=f.messages.find(w=>w.id===c);if(!(h!=null&&h.threadInfo)||h.threadInfo.thread_id!==d)throw new Error("Thread not found for this message");const p=Ha(f.apiUrl||_t()),x=await kt(),v=new x.ApiClient({apiUrl:p,sessionId:f.sessionId,adapterName:f.adapterName});await new(await En(async()=>{const{ThreadService:w}=await import("./threadService-B9Db3n0J.js");return{ThreadService:w}},[])).ThreadService(v).deleteThread(d),s(w=>({conversations:w.conversations.map(k=>{var _;if(k.id!==i)return k;const S=k.messages.filter(z=>z.isThreadMessage?!(z.threadId===d||z.parentMessageId===c):!0).map(z=>z.id!==c?z:{...z,threadInfo:void 0,supportsThreading:!0}),j=k.currentThreadId===d||k.currentThreadSessionId===((_=h.threadInfo)==null?void 0:_.thread_session_id);return{...k,messages:S,currentThreadId:j?void 0:k.currentThreadId,currentThreadSessionId:j?void 0:k.currentThreadSessionId,updatedAt:new Date}})})),na(l)},sendMessage:async(i,c,d,f,h)=>{var x;let p=null;try{if(l().isLoading){Be("Another request is already in progress");return}if(!await li())throw new Error("API not properly configured. Please configure API settings first.");let b=l().currentConversationId;b||(b=l().createConversation());const w=l().conversations.find(U=>U.id===b);if(!w)throw new Error("Conversation not found");const k=Le.maxConversations;if(va()&&!hn()&&k!==null&&l().conversations.length>k){wa.getState().openLoginPrompt(`You've reached the guest limit of ${k} conversation${k===1?"":"s"}. Sign in to continue chatting.`),s({isLoading:!1});return}const S=c?c.map(U=>{var I;const Q=(I=w==null?void 0:w.attachedFiles)==null?void 0:I.find(ae=>ae.file_id===U);return Q||{file_id:U,filename:"",mime_type:"",file_size:0}}).filter(U=>U!==void 0):[];S.length>0&&S.forEach(U=>{l().addFileToConversation(b,U)});const j=d||null;let _,z=null;if(j){if(_=w.messages.find(U=>{var Q;return((Q=U.threadInfo)==null?void 0:Q.thread_id)===j}),!_)throw new Error("Thread metadata not found. Please recreate the thread from this message.");if(z=((x=_.threadInfo)==null?void 0:x.thread_session_id)||null,!z)throw new Error("Thread session is missing. Please recreate the thread from this message.")}const $=Tp(w.messages),ee=Le.maxMessagesPerConversation;if(ee!==null&&$>=ee){va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${ee} messages per conversation. Sign in to send more messages, or delete conversations to start over.`),Be(`[chatStore] Conversation ${b} reached the message limit (${ee}).`),s({isLoading:!1});return}const Y=Le.maxTotalMessages;if(Y!==null&&l().conversations.reduce((Q,I)=>Q+Tp(I.messages),0)>=Y){va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${Y} total messages. Sign in to continue chatting, or delete conversations to start over.`),Be(`[chatStore] Workspace reached the total message limit (${Y}).`),s({isLoading:!1});return}const R={id:Lo("user"),content:i,role:"user",timestamp:new Date,attachments:S.length>0?S:void 0},q=Lo("assistant"),N={id:q,content:"",role:"assistant",timestamp:new Date,isStreaming:!0};if(j&&_){R.isThreadMessage=!0,R.threadId=j,R.parentMessageId=_.id,N.isThreadMessage=!0,N.threadId=j,N.parentMessageId=_.id;const U=Le.maxMessagesPerThread;if(U!==null&&w.messages.filter(I=>I.isThreadMessage?(I.threadId===j||I.parentMessageId===_.id)&&!(I.role==="assistant"&&I.isStreaming):!1).length>=U){va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${U} messages per thread. Sign in to continue this thread, or delete conversations to start over.`),Be(`[chatStore] Thread ${j} reached the message limit (${U}).`),s({isLoading:!1});return}}s(U=>{const Q=U.conversations.find(ae=>ae.id===b),I=(Q==null?void 0:Q.messages.filter(ae=>ae.role==="assistant"&&ae.isStreaming))||[];return I.length>0&&Be(`Cleaning up ${I.length} existing streaming messages`),{conversations:U.conversations.map(ae=>{if(ae.id!==b)return ae;const fe=ae.messages.filter(Ce=>!(Ce.role==="assistant"&&Ce.isStreaming));return{...ae,messages:[...fe,R,N],updatedAt:new Date,title:ae.messages.length===0?i.slice(0,50)+(i.length>50?"...":""):ae.title}}),isLoading:!0,error:null}}),p=b;let X=!1;Ul.reset();try{const U=l().conversations.find(H=>H.id===p);if(!U)throw new Error("Conversation not found");if(!U.adapterName)throw new Error("Adapter not configured for this conversation. Please select an adapter first.");const Q=Ha(U.apiUrl),I=U.adapterName,ae=z||U.sessionId,fe=await kt();fe.configureApi(Q,ae,I),j&&ae!==U.sessionId&&le(`[chatStore] Thread mode: using thread session ${ae} (original: ${U.sessionId})`);const{returnAudio:Ce,ttsVoice:te,language:oe,audioFormat:E}=Mp(U);le("[chatStore] Audio settings:",{returnAudio:Ce,ttsVoice:te,language:oe,audioFormat:E});const V=new AbortController;zl=V,Wn=ae,us=p,Ba=null;for await(const H of fe.streamChat(i,!0,c,j||void 0,void 0,void 0,oe,Ce,te,void 0,void 0,f,h)){if(H.request_id&&!Ba&&(Ba=H.request_id,le(`[chatStore] >>> CAPTURED request_id for stop: ${H.request_id}`)),H.audio_chunk&&Ul.addChunk({audio:H.audio_chunk,audioFormat:H.audioFormat||"opus",chunkIndex:H.chunk_index??0}),H.text){const P=ri(H.text);P?(l().appendToLastMessage(P,p),X=!0):H.text.length>100&&Be("[chatStore] Filtered out potential base64 audio data from message content")}if(H.audio&&H.done&&s(P=>Dl(P,p,()=>({audio:H.audio,audioFormat:H.audioFormat||"mp3"}))),H.image&&H.done&&(X=!0,s(P=>Dl(P,p,()=>({image:H.image,imageFormat:H.image_format||"png",imageRevisedPrompt:H.image_revised_prompt,imageUrl:H.image_url})))),(H.video||H.video_url)&&H.done&&(X=!0,s(P=>Dl(P,p,()=>({video:H.video,videoFormat:H.video_format||"mp4",videoRevisedPrompt:H.video_revised_prompt,videoUrl:H.video_url})))),(H.document||H.document_url)&&H.done&&(X=!0,s(P=>Dl(P,p,()=>({document:H.document,documentFormat:H.document_format||"pdf",documentRevisedPrompt:H.document_revised_prompt,documentUrl:H.document_url})))),H.done){le("[chatStore] Stream completed, receivedAnyText:",X);const P=H.threading;P!=null&&P.supports_threading&&s(ce=>({conversations:ce.conversations.map(xe=>xe.id!==p?xe:{...xe,messages:xe.messages.map(pe=>pe.id===q?{...pe,supportsThreading:!0,databaseMessageId:P.message_id}:pe),updatedAt:new Date})})),H.assistant_message_id&&s(ce=>({conversations:ce.conversations.map(xe=>xe.id!==p?xe:{...xe,messages:xe.messages.map(pe=>pe.id===q&&!pe.databaseMessageId?{...pe,databaseMessageId:H.assistant_message_id}:pe),updatedAt:new Date})}));break}}!X&&!V.signal.aborted&&l().appendToLastMessage("No response received from the server. Please try again later.",p)}catch(U){if(U instanceof Error&&(U.name==="AbortError"||U.message==="Stream cancelled by user"||U.message.includes("aborted")))le("[chatStore] Stream was cancelled by user"),X=!0;else{qt("Chat API error:",U);let I="Sorry, there was an error processing your request.";U instanceof Error&&(U.message.startsWith("Server error:")?I=U.message.substring(14):(U.message.includes("Could not connect")||U.message.includes("timed out"))&&(I=U.message)),l().appendToLastMessage(I,p)}}zl=null,Ba=null,Wn=null,us=null,zp(p,s),s(U=>{const Q=U.conversations.map(ae=>ae.id===p?{...ae,messages:ae.messages.map(fe=>fe.id===q?{...fe,isStreaming:!1}:fe),updatedAt:new Date}:ae),I=Q.find(ae=>ae.id===U.currentConversationId);return{conversations:Q,isLoading:I?I.messages.some(ae=>ae.role==="assistant"&&ae.isStreaming):!1}}),na(l)}catch(v){qt("Chat store error:",v),s(b=>({isLoading:!1,...b.currentConversationId===p&&{error:`Failed to send message: ${v instanceof Error?v.message:"Unknown error"}`}}))}},createThread:async(i,c)=>{try{const d=l().conversations.find(k=>k.sessionId===c);if(!d)throw new Error("Conversation not found for session");if(!d.adapterName)throw new Error("Adapter not configured for this conversation");const f=d.messages.find(k=>k.id===i);if(!f)throw new Error("Message not found");const h=f.databaseMessageId||i,p=Ha(d.apiUrl||_t()),x=await kt(),v=new x.ApiClient({apiUrl:p,sessionId:c,adapterName:d.adapterName}),w=await new(await En(async()=>{const{ThreadService:k}=await import("./threadService-B9Db3n0J.js");return{ThreadService:k}},[])).ThreadService(v).createThread(h,c);s(k=>({conversations:k.conversations.map(S=>S.sessionId!==c?S:{...S,messages:S.messages.map(j=>j.id===i?{...j,threadInfo:w,supportsThreading:!0}:j),currentThreadId:void 0,currentThreadSessionId:void 0})})),le(`[chatStore] Created thread ${w.thread_id} for message ${i}`)}catch(d){throw qt("Failed to create thread:",d),d}},appendToLastMessage:(i,c)=>{const d=ri(i);if(!d&&i){Be("[chatStore] Filtered out base64 audio data from message content");return}const f=cd(d),h=c||l().currentConversationId;if(!h)return;const p=h,x=lr.get(p);x?(x.content+=f,x.timeoutId&&clearTimeout(x.timeoutId)):lr.set(p,{content:f,timeoutId:null});const v=()=>{const w=lr.get(p);if(!w||!w.content)return;const k=w.content;w.content="",w.timeoutId=null,s(S=>({conversations:S.conversations.map(j=>{if(j.id!==h)return j;const _=[...j.messages],z=_[_.length-1];return z&&z.role==="assistant"&&z.isStreaming&&(_[_.length-1]={...z,content:z.content+k}),{...j,messages:_,updatedAt:new Date}})}))},b=lr.get(p);b.timeoutId=setTimeout(v,sv)},regenerateResponse:async(i,c)=>{let d=null;try{if(l().isLoading){Be("Another request is already in progress");return}if(!await li())throw new Error("API not properly configured");const h=l(),p=h.conversations.find(_=>_.id===h.currentConversationId);if(!p)return;const x=p.messages.findIndex(_=>_.id===i);if(x===-1)return;const v=p.messages[x];if(!v||v.role!=="assistant")return;const b=p.messages[x-1];if(!b||b.role!=="user")return;const w=(b.attachments||[]).map(_=>_.file_id).filter(_=>typeof _=="string"&&_.length>0),k=Lo("assistant");if(s(_=>({conversations:_.conversations.map(z=>z.id===_.currentConversationId?{...z,messages:[...z.messages.slice(0,x),{id:k,content:"",role:"assistant",timestamp:new Date,isStreaming:!0,supportsThreading:v.supportsThreading,databaseMessageId:v.databaseMessageId,threadInfo:v.threadInfo,threadId:v.threadId,parentMessageId:v.parentMessageId,isThreadMessage:v.isThreadMessage},...z.messages.slice(x+1)],updatedAt:new Date}:z),isLoading:!0,error:null})),d=h.currentConversationId,!d)throw new Error("No conversation selected");let S=!1;const j=new AbortController;zl=j,us=d,Ba=null;try{const _=l().conversations.find(R=>R.id===d);if(!_)throw new Error("Conversation not found");if(!_.adapterName)throw new Error("Adapter not configured for this conversation. Please select an adapter first.");Wn=_.sessionId,_.sessionId&&(await kt()).configureApi(Ha(_.apiUrl),_.sessionId,_.adapterName);const z=await kt(),{returnAudio:$,ttsVoice:ee,language:Y}=Mp(_);for await(const R of z.streamChat(b.content,!0,w.length>0?w:void 0,void 0,void 0,void 0,Y,$,ee,void 0,void 0,c)){if(R.request_id&&!Ba&&(Ba=R.request_id,le(`[chatStore] >>> CAPTURED request_id for regenerate stop: ${R.request_id}`)),R.text){const q=ri(R.text);q?(l().appendToLastMessage(q,d),S=!0):R.text.length>100&&Be("[chatStore] Filtered out potential base64 audio data from regenerated message content")}if(R.audio&&R.done&&s(q=>Dl(q,d,()=>({audio:R.audio,audioFormat:R.audioFormat||"mp3"}))),R.image&&R.done&&(S=!0,s(q=>Dl(q,d,()=>({image:R.image,imageFormat:R.image_format||"png",imageRevisedPrompt:R.image_revised_prompt,imageUrl:R.image_url})))),(R.video||R.video_url)&&R.done&&(S=!0,s(q=>Dl(q,d,()=>({video:R.video,videoFormat:R.video_format||"mp4",videoRevisedPrompt:R.video_revised_prompt,videoUrl:R.video_url})))),(R.document||R.document_url)&&R.done&&(S=!0,s(q=>Dl(q,d,()=>({document:R.document,documentFormat:R.document_format||"pdf",documentRevisedPrompt:R.document_revised_prompt,documentUrl:R.document_url})))),R.done){const q=R.threading;q!=null&&q.supports_threading&&s(N=>({conversations:N.conversations.map(X=>X.id!==d?X:{...X,messages:X.messages.map(U=>U.id===k?{...U,supportsThreading:!0,databaseMessageId:q.message_id}:U),updatedAt:new Date})})),R.assistant_message_id&&s(N=>({conversations:N.conversations.map(X=>X.id!==d?X:{...X,messages:X.messages.map(U=>U.id===k&&!U.databaseMessageId?{...U,databaseMessageId:R.assistant_message_id}:U),updatedAt:new Date})}));break}}!S&&!j.signal.aborted&&l().appendToLastMessage("No response received from the server. Please try again later.",d)}catch(_){if(_ instanceof Error&&(_.name==="AbortError"||_.message==="Stream cancelled by user"||_.message.includes("aborted")))le("[chatStore] Regeneration stream was cancelled by user"),S=!0;else{qt("Regenerate API error:",_);let $="Sorry, there was an error regenerating the response.";_ instanceof Error&&(_.message.startsWith("Server error:")?$=_.message.substring(14):(_.message.includes("Could not connect")||_.message.includes("timed out"))&&($=_.message)),l().appendToLastMessage($,d)}}zl=null,Ba=null,Wn=null,us=null,zp(d,s),s(_=>{const z=_.conversations.map(ee=>ee.id===d?{...ee,messages:ee.messages.map(Y=>Y.id===k?{...Y,isStreaming:!1}:Y),updatedAt:new Date}:ee),$=z.find(ee=>ee.id===_.currentConversationId);return{conversations:z,isLoading:$?$.messages.some(ee=>ee.role==="assistant"&&ee.isStreaming):!1}})}catch(f){qt("Regenerate error:",f),s(h=>({isLoading:!1,...h.currentConversationId===d&&{error:`Failed to regenerate response: ${f instanceof Error?f.message:"Unknown error"}`}}))}},updateConversationTitle:(i,c)=>{s(d=>({conversations:d.conversations.map(f=>f.id===i?{...f,title:c,updatedAt:new Date}:f)})),na(l)},clearError:()=>s({error:null}),cleanupStreamingMessages:()=>{const i=us;s(c=>{let d=!1;return{conversations:c.conversations.map(h=>h.id===i?(h.messages.some(x=>x.role==="assistant"&&x.isStreaming)&&(d=!0),h):h.messages.some(x=>x.role==="assistant"&&x.isStreaming)?{...h,messages:h.messages.filter(x=>!(x.role==="assistant"&&x.isStreaming)),updatedAt:new Date}:h),isLoading:d}})},canCreateNewConversation:()=>{var h;const i=l(),c=Le.maxConversations;if(!i.currentConversationId)return c===null||i.conversations.length<c;const d=i.conversations.find(p=>p.id===i.currentConversationId);return!!d&&(d.messages.length>0||(((h=d.attachedFiles)==null?void 0:h.length)||0)>0)?c===null||i.conversations.length<c:!1},getConversationCount:()=>l().conversations.length,addFileToConversation:(i,c)=>{le("[chatStore] addFileToConversation called",{conversationId:i,fileId:c.file_id,filename:c.filename}),s(d=>({conversations:d.conversations.map(f=>f.id===i?{...f,attachedFiles:[...(f.attachedFiles||[]).filter(h=>h.file_id!==c.file_id),c],updatedAt:new Date}:f)})),na(l)},removeFileFromConversation:async(i,c)=>{le("[chatStore] removeFileFromConversation called",{conversationId:i,fileId:c});try{const d=l().conversations.find(f=>f.id===i);if(!d)throw new Error("Conversation not found");if(!d.adapterName)throw new Error("Adapter not configured for this conversation. Cannot delete file.");await ui.deleteFile(c,void 0,Ha(d.apiUrl),d.adapterName),le(`[chatStore] Successfully deleted file ${c} from server`)}catch(d){d instanceof Error&&(d.message.includes("404")||d.message.includes("File not found"))?le(`[chatStore] File ${c} was already deleted from server`):He(`[chatStore] Failed to delete file ${c} from server:`,d)}s(d=>({conversations:d.conversations.map(f=>f.id===i?{...f,attachedFiles:(f.attachedFiles||[]).filter(h=>h.file_id!==c),updatedAt:new Date}:f)})),na(l)},loadConversationFiles:async i=>{try{const c=l().conversations.find(p=>p.id===i);if(!c)return;if(!c.adapterName){le(`Skipping file load for conversation ${i}: adapter not configured`);return}if(new Set((c.attachedFiles||[]).map(p=>p.file_id)).size===0){le(`No files to sync for conversation ${i}`);return}const f=await ui.listFiles(void 0,Ha(c.apiUrl),c.adapterName),h=new Map(f.map(p=>[p.file_id,{file_id:p.file_id,filename:p.filename,mime_type:p.mime_type,file_size:p.file_size,upload_timestamp:p.upload_timestamp,processing_status:p.processing_status,chunk_count:p.chunk_count}]));s(p=>{const x=p.conversations.find(b=>b.id===i);if(!x)return p;const v=(x.attachedFiles||[]).map(b=>h.get(b.file_id)||b).filter(b=>h.has(b.file_id)||!b.processing_status||b.processing_status==="processing");return{conversations:p.conversations.map(b=>b.id===i?{...b,attachedFiles:v,updatedAt:new Date}:b)}}),na(l)}catch(c){qt(`Failed to load files for conversation ${i}:`,c)}},syncConversationFiles:async i=>{await l().loadConversationFiles(i)},syncConversationsWithBackend:async()=>{try{const i=l();if(i.conversations.length===0)return;const c=await kt(),d=Le.maxMessagesPerConversation!==null&&Le.maxMessagesPerConversation||void 0;let f=!1;const p=(await Promise.all(i.conversations.map(async x=>{var v;if(!x.sessionId)return null;if(!x.adapterName)return Be(`[chatStore] Skipping backend sync for conversation ${x.id} - adapter not configured`),null;try{const b=new c.ApiClient({apiUrl:Ha(x.apiUrl),sessionId:x.sessionId,adapterName:x.adapterName});if(typeof b.getConversationHistory!="function")return f||(f=!0,Be("[chatStore] Conversation history endpoint not supported by current API client")),null;const w=await b.getConversationHistory(x.sessionId,d),k=Array.isArray(w==null?void 0:w.messages)?w.messages:[];if(k.length===0)return x.messages.length===0?null:{id:x.id,sessionId:(w==null?void 0:w.session_id)||x.sessionId,messages:[],cleared:!0,updatedAt:new Date};const S=av(k,x.messages),j=x.messages.filter(z=>z.isThreadMessage),_=j.length>0?[...S,...j]:S;return nv(x.messages,_)?null:{id:x.id,sessionId:(w==null?void 0:w.session_id)||x.sessionId,messages:_,cleared:!1,updatedAt:((v=S[S.length-1])==null?void 0:v.timestamp)||new Date}}catch(b){return Be(`[chatStore] Failed to sync session ${x.sessionId}:`,b),null}}))).filter(x=>!!x);if(p.length===0)return;s(x=>{const v=new Map(p.map(b=>[b.id,b]));return{conversations:x.conversations.map(b=>{const w=v.get(b.id);return w?w.cleared?{...b,sessionId:w.sessionId||b.sessionId,messages:[],attachedFiles:[],title:"New Chat",updatedAt:w.updatedAt,adapterLoadError:null}:{...b,sessionId:w.sessionId||b.sessionId,messages:w.messages,updatedAt:w.updatedAt,adapterLoadError:null}:b}),currentConversationId:x.currentConversationId}}),na(l)}catch(i){Be("Failed to synchronize conversations with backend:",i)}},stopStreaming:async()=>{var c;if(!l().isLoading){le("[chatStore] stopStreaming called but not currently loading");return}if(le("[chatStore] Stopping stream...",{hasAbortController:!!zl,requestId:Ba,sessionId:Wn}),zl&&zl.abort(),Ba&&Wn)try{const d=await kt(),f=await((c=d.stopChat)==null?void 0:c.call(d,Wn,Ba));le(`[chatStore] Server-side cancellation result: ${f}`)}catch(d){Be("[chatStore] Failed to cancel server-side stream:",d)}else Be(`[chatStore] Cannot call stopChat - missing IDs: requestId=${Ba}, sessionId=${Wn}`);const i=us||l().currentConversationId;s(i?d=>({conversations:d.conversations.map(f=>f.id!==i?f:{...f,messages:f.messages.map(h=>h.isStreaming?{...h,isStreaming:!1}:h),updatedAt:new Date}),isLoading:!1}):{isLoading:!1}),zl=null,Ba=null,Wn=null,us=null,le("[chatStore] Stream stopped successfully")},clearCurrentConversationAdapter:()=>{const i=l().currentConversationId;i&&(s(c=>({conversations:c.conversations.map(d=>d.id===i?{...d,adapterName:void 0,adapterInfo:void 0,adapterLoadError:null}:d)})),na(l))},submitFeedback:async(i,c)=>{const d=l(),f=d.conversations.find(p=>p.id===d.currentConversationId);if(!f)return;const h=f.messages.find(p=>p.id===i);if(!(h!=null&&h.databaseMessageId)){Be("[chatStore] Cannot submit feedback: no databaseMessageId on message");return}if(f.adapterName)try{const p=await kt(),b=(await new p.ApiClient({apiUrl:Ha(f.apiUrl||_t()),sessionId:f.sessionId,adapterName:f.adapterName}).submitFeedback(h.databaseMessageId,f.sessionId,c)).feedback_type;s(w=>({conversations:w.conversations.map(k=>k.id!==d.currentConversationId?k:{...k,messages:k.messages.map(S=>S.id===i?{...S,feedback:b}:S),updatedAt:new Date})})),na(l)}catch(p){He("[chatStore] Failed to submit feedback:",p)}},loadFeedbackForConversation:async i=>{var f;const d=l().conversations.find(h=>h.sessionId===i);if(d!=null&&d.adapterName)try{const h=await kt(),p=new h.ApiClient({apiUrl:Ha(d.apiUrl||_t()),sessionId:d.sessionId,adapterName:d.adapterName}),x=new Set([i]);for(const w of d.messages)(f=w.threadInfo)!=null&&f.thread_session_id&&x.add(w.threadInfo.thread_session_id);const v=await Promise.all(Array.from(x).map(w=>p.getSessionFeedback(w).catch(()=>({feedbacks:[]})))),b=new Map;for(const w of v)if(w!=null&&w.feedbacks)for(const k of w.feedbacks)b.set(k.message_id,k.feedback_type);if(b.size===0)return;s(w=>({conversations:w.conversations.map(k=>k.sessionId!==i?k:{...k,messages:k.messages.map(S=>S.databaseMessageId&&b.has(S.databaseMessageId)?{...S,feedback:b.get(S.databaseMessageId)}:S)})}))}catch(h){He("[chatStore] Failed to load feedback:",h)}}})),rv=async()=>{var x;const s=localStorage.getItem("chat-state"),l=_t(),i=!!localStorage.getItem("chat-api-url");let c=Bo(),d=!1;if(s)try{const v=JSON.parse(s),b=S=>{if(S instanceof Date)return S;const j=S?new Date(S):new Date;return Number.isNaN(j.getTime())?new Date:j},k=(Array.isArray(v.conversations)?v.conversations:[]).map(S=>{const _=(Array.isArray(S.messages)?S.messages:[]).filter(ee=>!(ee.role==="assistant"&&ee.isStreaming)).map(ee=>({...ee,timestamp:b(ee.timestamp),isStreaming:!1})),z={id:S.id,sessionId:S.sessionId||Ol(),title:S.title||"New Chat",messages:_,createdAt:b(S.createdAt),updatedAt:b(S.updatedAt),attachedFiles:S.attachedFiles||[],adapterName:S.adapterName,apiUrl:S.apiUrl,adapterInfo:S.adapterInfo,adapterLoadError:S.adapterLoadError||null,audioSettings:S.audioSettings,currentThreadId:void 0,currentThreadSessionId:void 0},$=z.messages.length===0&&!z.adapterName;return{...z,apiUrl:$&&!i?l:Ha(S.apiUrl)}});if(d=k.length>0,v.currentConversationId&&k.length>0){const S=k.find(j=>j.id===v.currentConversationId);S!=null&&S.sessionId&&(c=S.sessionId)}if(k.length===0){const S=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,j=Ol(),_=ii(S,j,_t());Ve.setState({conversations:[_],currentConversationId:S,sessionId:j}),c=j}else Ve.setState({conversations:k,currentConversationId:v.currentConversationId||((x=k[0])==null?void 0:x.id)||null,sessionId:c}),!v.currentConversationId&&k.length>0&&(Ve.setState({currentConversationId:k[0].id,sessionId:k[0].sessionId||c}),c=k[0].sessionId||c);le("📋 Loaded conversations:",Ve.getState().conversations.map(S=>{var j;return{id:S.id,title:S.title,sessionId:S.sessionId,messageCount:((j=S.messages)==null?void 0:j.length)||0}})),setTimeout(()=>Ve.getState().cleanupStreamingMessages(),100)}catch(v){qt("Failed to load chat state:",v);const b=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,w=Ol(),k=ii(b,w,_t());Ve.setState({conversations:[k],currentConversationId:b,sessionId:w}),c=w}else{const v=`conv_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,b=Ol(),w=ii(v,b,_t());Ve.setState({conversations:[w],currentConversationId:v,sessionId:b}),c=b}localStorage.removeItem("chat-api-key");const f=Ve.getState(),h=f.currentConversationId?f.conversations.find(v=>v.id===f.currentConversationId):null,p=d&&(h!=null&&h.apiUrl)?h.apiUrl:_t();try{const v=await kt(),b=h==null?void 0:h.adapterName;if(!b)le("No adapter selected yet. Waiting for user selection before configuring API.");else if(v.configureApi(p,c,b),Fo=p,Ho=!0,!(h!=null&&h.adapterInfo))try{const w=new v.ApiClient({apiUrl:p,sessionId:null,adapterName:b});if(typeof w.getAdapterInfo=="function"){const k=await w.getAdapterInfo();le("Adapter info loaded for existing adapter:",k);const S=Ve.getState();S.currentConversationId&&(Ve.setState({conversations:S.conversations.map(j=>j.id===S.currentConversationId?{...j,adapterInfo:k,adapterLoadError:null,updatedAt:new Date}:j)}),setTimeout(()=>{const j=Ve.getState();localStorage.setItem("chat-state",JSON.stringify({conversations:j.conversations,currentConversationId:j.currentConversationId}))},0))}}catch(w){Be("Failed to load adapter info for existing adapter:",w)}}catch(v){qt("Failed to initialize API:",v)}try{await Ve.getState().syncConversationsWithBackend()}catch(v){Be("Conversation history sync skipped:",v)}};typeof window<"u"&&rv();function iv(s){return s.includes("image")?u.jsx(qx,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"}):s.includes("video")||s.includes("audio")?u.jsx(cb,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"}):u.jsx(xd,{className:"h-4 w-4 flex-shrink-0","aria-hidden":"true"})}function ov(s){return s.replace(/-/g," ")}function kg({skills:s,isLoading:l,selectedSkill:i,activeSkillName:c,query:d="",onSelect:f,onActiveSkillChange:h}){const p=Tn.useRef(null),x=d.toLowerCase().replace(/-/g," "),v=x?s.filter(b=>b.name.replace(/-/g," ").toLowerCase().includes(x)||b.description.toLowerCase().includes(x)):s;return Tn.useEffect(()=>{var w;const b=(w=p.current)==null?void 0:w.querySelector('[data-active="true"]');b==null||b.scrollIntoView({block:"nearest"})},[c,v.length]),!l&&s.length===0?u.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:u.jsx("p",{className:"px-4 py-3 text-sm text-gray-500 dark:text-[#bfc2cd]",children:"No skills available for this adapter."})}):u.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:l?u.jsx("div",{className:"px-4 py-3.5",children:u.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-500 dark:text-[#bfc2cd]",children:[u.jsx("div",{className:"h-3.5 w-3.5 rounded-full border-2 border-current border-t-transparent animate-spin","aria-hidden":"true"}),"Loading skills..."]})}):v.length===0?u.jsx("div",{className:"px-4 py-3.5",children:u.jsx("p",{className:"text-sm text-gray-500 dark:text-[#bfc2cd]",children:x?`No matching skills for "${d}".`:"No matching skills."})}):u.jsx("div",{ref:p,role:"listbox","aria-label":"Available skills",className:"max-h-72 overflow-y-auto p-1.5",children:v.map((b,w)=>{const k=(i==null?void 0:i.name)===b.name,S=c===b.name||!c&&(k||!i&&w===0);return u.jsxs("button",{id:`skill-option-${b.name}`,type:"button",role:"option","aria-selected":S,"data-active":S?"true":void 0,onMouseEnter:()=>h==null?void 0:h(b),onClick:()=>f(b),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 ${S?"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:[u.jsx("div",{className:`mt-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center transition-colors ${S?"text-gray-900 dark:text-white":"text-gray-500 group-hover:text-gray-700 dark:text-[#bfc2cd] dark:group-hover:text-gray-200"}`,children:iv(b.name)}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("div",{className:"flex min-w-0 items-center gap-2",children:u.jsx("span",{className:"truncate text-sm font-medium capitalize leading-5 text-current",children:ov(b.name)})}),b.description&&u.jsx("p",{className:"mt-0.5 line-clamp-2 text-xs leading-5 text-gray-500 dark:text-[#bfc2cd]",children:b.description})]}),k&&u.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:u.jsx(Ro,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]},b.name)})})})}function _g({availableModels:s,defaultModel:l,selectedModel:i,onSelect:c,wrapperClassName:d="relative hidden md:block",maxWidthClass:f="max-w-[200px]",triggerTitle:h="Select model",listboxLabel:p="Select model",staticPaddingClass:x="px-3 py-1.5",triggerPaddingClass:v="px-3 py-1.5"}){const[b,w]=g.useState(!1),[k,S]=g.useState(""),[j,_]=g.useState(null),z=g.useRef(null),$=g.useRef(null),ee=g.useRef(null),Y=g.useRef(null),R=i??l,q=k.trim()?s.filter(I=>I.name.toLowerCase().includes(k.trim().toLowerCase())):s,N=g.useCallback(()=>{if(!$.current)return;const I=$.current.getBoundingClientRect();_({bottom:window.innerHeight-I.top+8,right:window.innerWidth-I.right})},[]),X=g.useCallback(()=>{w(!1),S("")},[]),U=()=>{if(b){X();return}N(),w(!0)};if(g.useEffect(()=>{if(!b)return;const I=setTimeout(()=>{var te;return(te=ee.current)==null?void 0:te.focus()},10),ae=te=>{var H,P;const oe=te.target,E=((H=z.current)==null?void 0:H.contains(oe))??!1,V=((P=Y.current)==null?void 0:P.contains(oe))??!1;!E&&!V&&X()},fe=te=>{var oe;te.key==="Escape"&&(te.preventDefault(),X(),(oe=$.current)==null||oe.focus())},Ce=new ResizeObserver(N);return $.current&&Ce.observe($.current),window.addEventListener("resize",N,{passive:!0}),document.addEventListener("scroll",N,{capture:!0,passive:!0}),document.addEventListener("pointerdown",ae),document.addEventListener("keydown",fe),()=>{clearTimeout(I),Ce.disconnect(),window.removeEventListener("resize",N),document.removeEventListener("scroll",N,{capture:!0}),document.removeEventListener("pointerdown",ae),document.removeEventListener("keydown",fe)}},[X,b,N]),!l&&s.length===0)return null;const Q=b&&j&&typeof document<"u"?Yo.createPortal(u.jsxs("div",{ref:Y,style:{position:"fixed",bottom:j.bottom,right:j.right,width:288,zIndex:9999},className:"rounded-xl border border-gray-200 bg-white shadow-xl dark:border-[#2f303d] dark:bg-[#111111]",children:[u.jsx("div",{className:"p-2 border-b border-gray-100 dark:border-[#222222]",children:u.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-gray-50 px-3 py-1.5 dark:bg-[#1a1a1a]",children:[u.jsx(gd,{className:"h-3.5 w-3.5 flex-shrink-0 text-gray-400 dark:text-[#6b6f7a]","aria-hidden":"true"}),u.jsx("input",{ref:ee,type:"text",value:k,onChange:I=>S(I.target.value),placeholder:"Search models…",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":"Search models"})]})}),u.jsx("div",{role:"listbox","aria-label":p,className:"max-h-60 overflow-y-auto py-1",children:q.length===0?u.jsxs("div",{className:"px-3 py-5 text-center text-xs text-gray-400 dark:text-[#6b6f7a]",children:["No models match “",k,"”"]}):q.map(I=>{const ae=R===I.name;return u.jsxs("button",{role:"option","aria-selected":ae,type:"button",onClick:()=>{var fe;c(I.name),X(),(fe=$.current)==null||fe.focus()},className:`flex w-full items-center gap-2.5 px-3 py-2 text-left text-xs transition-colors ${ae?"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:[u.jsx("span",{className:`flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded-full border ${ae?"border-blue-500 bg-blue-500 dark:border-blue-400 dark:bg-blue-400":"border-gray-300 dark:border-[#5a5b65]"}`,children:ae&&u.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-white"})}),u.jsx("span",{className:"truncate font-medium normal-case tracking-normal",children:I.name})]},I.name)})}),s.length>8&&u.jsx("div",{className:"border-t border-gray-100 px-3 py-1.5 dark:border-[#222222]",children:u.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-[#6b6f7a]",children:[q.length," of ",s.length," models"]})})]}),document.body):null;return u.jsx("div",{ref:z,className:d,children:s.length>1?u.jsxs(u.Fragment,{children:[u.jsxs("button",{ref:$,type:"button",onClick:U,className:`inline-flex min-w-[100px] ${f} items-center gap-1.5 rounded-full border border-gray-200 bg-gray-100 ${v} 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":b,title:h,children:[u.jsx("span",{className:"truncate flex-1",children:R}),u.jsx(di,{className:`h-3.5 w-3.5 flex-shrink-0 text-gray-400 transition-transform duration-150 dark:text-[#6b6f7a] ${b?"rotate-180":""}`,"aria-hidden":"true"})]}),Q]}):u.jsx("div",{className:`inline-flex min-w-[100px] ${f} items-center rounded-full border border-gray-200 bg-gray-100 ${x} text-xs text-gray-500 dark:border-[#4a4b54] dark:bg-[#343541] dark:text-[#bfc2cd]`,title:R??void 0,children:u.jsx("span",{className:"truncate",children:R})})})}const cv=[],uv=(s="png")=>{const l=s.toLowerCase().replace(/^image\//,"");return l==="jpg"?"image/jpeg":`image/${l||"png"}`},dv=(s,l)=>{const i=atob(s),c=new Uint8Array(i.length);for(let d=0;d<i.length;d+=1)c[d]=i.charCodeAt(d);return new Blob([c],{type:l})},fv=async s=>{const l=URL.createObjectURL(s);try{const i=new Image;i.decoding="async";const c=new Promise((h,p)=>{i.onload=()=>h(i),i.onerror=()=>p(new Error("Failed to load generated image for clipboard copy"))});i.src=l,await c;const d=document.createElement("canvas");d.width=i.naturalWidth,d.height=i.naturalHeight;const f=d.getContext("2d");if(!f)throw new Error("Could not create canvas context for image clipboard copy");return f.drawImage(i,0,0),await new Promise((h,p)=>{d.toBlob(x=>{x?h(x):p(new Error("Could not encode generated image for clipboard copy"))},"image/png")})}finally{URL.revokeObjectURL(l)}},mv=async(s,l)=>{const i=uv(s.imageFormat);if(s.image)return dv(s.image,i);if(!s.imageUrl)return null;const c=await fetch(s.imageUrl,{headers:l?{"X-Adapter-Name":l}:{}});if(!c.ok)throw new Error(`Could not fetch generated image for clipboard copy: ${c.status}`);const d=await c.blob();return d.type?d:new Blob([d],{type:i})},hv=s=>s.imageUrl?new URL(s.imageUrl,window.location.origin).toString():s.imageRevisedPrompt||s.content;function Dp({size:s="md"}){const l=s==="sm"?"h-2 w-2":"h-2.5 w-2.5";return u.jsx("div",{className:"flex items-center gap-1.5 py-1",children:[0,150,300].map(i=>u.jsx("span",{className:`inline-block ${l} animate-bounce rounded-full bg-gray-400 dark:bg-[#bfc2cd]`,style:{animationDelay:`${i}ms`}},i))})}function pv({reply:s}){const[l,i]=g.useState(!1),[c,d]=g.useState(!1),f=g.useRef(null),h=Ve(x=>x.submitFeedback);g.useEffect(()=>()=>{f.current&&clearTimeout(f.current)},[]);const p=async x=>{if(!s.databaseMessageId||l)return;const v=s.feedback!==x;i(!0);try{await h(s.id,x),v?(d(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{d(!1),f.current=null},2e3)):d(!1)}catch(b){He("Failed to submit thread reply feedback:",b)}finally{i(!1)}};return u.jsxs("div",{className:"flex items-center gap-0.5 mt-0.5",children:[u.jsx("button",{onClick:()=>p("up"),disabled:l,className:`rounded-md p-1.5 hover:bg-gray-100 dark:hover:bg-[#3c3f4a] transition-colors ${l?"opacity-50 cursor-not-allowed":""} ${s.feedback==="up"?"text-green-600 dark:text-green-400":"text-gray-400 dark:text-[#6e6e80] hover:text-gray-700 dark:hover:text-[#ececf1]"}`,title:"Good response","aria-label":"Good response",children:u.jsx(lg,{className:"h-3.5 w-3.5"})}),u.jsx("button",{onClick:()=>p("down"),disabled:l,className:`rounded-md p-1.5 hover:bg-gray-100 dark:hover:bg-[#3c3f4a] transition-colors ${l?"opacity-50 cursor-not-allowed":""} ${s.feedback==="down"?"text-red-600 dark:text-red-400":"text-gray-400 dark:text-[#6e6e80] hover:text-gray-700 dark:hover:text-[#ececf1]"}`,title:"Poor response","aria-label":"Poor response",children:u.jsx(ng,{className:"h-3.5 w-3.5"})}),c&&u.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 rounded-md bg-emerald-500/10 px-1.5 py-0.5 text-[10px] font-medium text-emerald-700 animate-fadeIn dark:bg-emerald-500/15 dark:text-emerald-300",children:[u.jsx(Ro,{className:"h-3 w-3"}),"Thanks!"]})]})}function gv({message:s,onRegenerate:l,onStartThread:i,onClearThread:c,onSendThreadMessage:d,threadMessages:f,sessionId:h,isThreadSendDisabled:p,availableModels:x=[],defaultModel:v=null,selectedModel:b=null}){var bn,yn,Ca;const[w,k]=g.useState(!1),[S,j]=g.useState(!1),[_,z]=g.useState(!1),[$,ee]=g.useState(""),[Y,R]=g.useState(!1),[q,N]=g.useState(!1),[X,U]=g.useState(!1),[Q,I]=g.useState(0),[ae,fe]=g.useState(!1),[Ce,te]=g.useState(!1),[oe,E]=g.useState(()=>b??v),V=g.useRef(b),H=g.useRef(((bn=s.threadInfo)==null?void 0:bn.thread_id)||null),P=g.useRef(null),ce=g.useRef(null),xe=g.useRef(null),pe=g.useRef(!1),F=g.useRef(0),me=g.useRef(""),ue=g.useRef(!1),de=g.useRef(!0),we=g.useRef(!1),W=g.useRef(null),re=g.useRef(null),be=s.role==="assistant",ke=f??cv,ge=ke.filter(se=>!(se.role==="assistant"&&se.isStreaming)).length,ze=ke.some(se=>se.isStreaming),Ue=ir(),Fe=va()&&!Ue,je=Ve(se=>se.conversations.find(qe=>qe.id===se.currentConversationId)),Xe=!!((s.image||s.imageUrl)&&be&&!s.isStreaming),et=!!((s.video||s.videoUrl)&&be&&!s.isStreaming),Bt=Xe?"Copy image to clipboard":"Copy to clipboard",xt=ay(),ie=Le.maxMessageLength,Ne=Le.maxMessagesPerThread,Tt=Ne!==null&&ge>=Ne,Oe=Tt?Fe?`You've reached the guest limit of ${Ne} messages per thread. Sign in to continue this thread.`:`This thread reached the ${Ne} message limit. Start a new conversation for more follow-ups.`:null,{theme:Vt,isDark:da}=rr(),Xt="Reply in thread...",ea=`thread-input-${s.id}`,{skills:pn,isLoading:en,selectedSkill:ta,selectSkill:gn,clearSkill:At}=vg({adapterName:je==null?void 0:je.adapterName,enabled:xt&&!!s.threadInfo,selectionScopeKey:((yn=s.threadInfo)==null?void 0:yn.thread_id)||s.id}),gt=$.startsWith("/")?$.slice(1):"",Ht=gt.toLowerCase().replace(/-/g," "),_e=Ht?pn.filter(se=>se.name.replace(/-/g," ").toLowerCase().includes(Ht)||se.description.toLowerCase().includes(Ht)):pn,Sa=_e.length>0?Math.min(Q,_e.length-1):0,Te=_e[Sa]??null,Qe=(Te==null?void 0:Te.name.replace(/-/g," "))??"",bt=X&&Te&&$.startsWith("/")&&Qe.toLowerCase().startsWith(gt.toLowerCase())&&Qe.length>gt.length?Qe.slice(gt.length):null,it=Vt.mode==="dark"?"dark":Vt.mode==="light"?"light":"",Ae=da?"dark":"light",la=g.useMemo(()=>["message-markdown w-full min-w-0","prose prose-slate dark:prose-invert max-w-none",it].filter(Boolean).join(" "),[it]),Mn=g.useMemo(()=>["message-markdown w-full min-w-0","prose dark:prose-invert max-w-none",it].filter(Boolean).join(" "),[it]),ka=be?la:Mn,tl=`${la} text-sm leading-6`,$l=`${Mn} text-sm leading-6`;g.useEffect(()=>{var se,qe;!H.current&&((se=s.threadInfo)!=null&&se.thread_id)&&R(!0),H.current=((qe=s.threadInfo)==null?void 0:qe.thread_id)||null},[(Ca=s.threadInfo)==null?void 0:Ca.thread_id]),g.useEffect(()=>{s.threadInfo||setTimeout(()=>{ee(""),R(!1),N(!1),U(!1),At()},0)},[s.threadInfo,At]),g.useEffect(()=>{ge>0&&setTimeout(()=>{R(!0)},0)},[ge]),g.useEffect(()=>()=>{W.current&&clearTimeout(W.current),re.current&&clearTimeout(re.current)},[]);const _a=g.useCallback(()=>{requestAnimationFrame(()=>{xe.current&&(xe.current.scrollTop=xe.current.scrollHeight)})},[]);g.useEffect(()=>{if(!Y)return;const se=ke.length,qe=se>F.current,he=ke[ke.length-1],tt=(he==null?void 0:he.content)||"",Ye=tt!==me.current,nn=(he==null?void 0:he.isStreaming)??!1,Ln=ue.current&&!nn;qe||nn&&Ye||Ln?(_a(),de.current=!0):de.current&&Ye&&_a(),F.current=se,me.current=tt,ue.current=nn},[Y,ke,_a]),g.useEffect(()=>{Y&&(_a(),de.current=!0)},[Y,_a]);const zn=be?"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] bg-[#f4f4f4] px-4 py-3 text-[#111827] dark:bg-[#303030] dark:text-[#f5f5f5]",Aa="border-gray-200 bg-white/80 dark:border-[#3b3c49] dark:bg-white/5",al=g.useCallback(()=>{k(!0),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{k(!1),W.current=null},2e3)},[]),fs=async()=>{try{if(Xe){if("ClipboardItem"in window&&navigator.clipboard.write)try{const qe=(je==null?void 0:je.adapterName)||(typeof window<"u"?window.localStorage.getItem("chat-adapter-name"):null),he=await mv(s,qe);if(he){const tt=he.type==="image/png"?he:await fv(he);await navigator.clipboard.write([new ClipboardItem({[tt.type||"image/png"]:tt})]),al();return}}catch(qe){He("Failed to copy generated image, falling back to text:",qe)}const se=hv(s);if(se){await navigator.clipboard.writeText(se),al();return}return}await navigator.clipboard.writeText(s.content),al()}catch(se){He(Xe?"Failed to copy generated image:":"Failed to copy text:",se)}},ql=Ve(se=>se.submitFeedback),tn=async se=>{if(!s.databaseMessageId||S)return;const qe=s.feedback!==se;j(!0);try{await ql(s.id,se),qe?(z(!0),re.current&&clearTimeout(re.current),re.current=setTimeout(()=>{z(!1),re.current=null},2e3)):z(!1)}catch(he){He("Failed to submit feedback:",he)}finally{j(!1)}},Dn=async()=>{if(!d||!s.threadInfo||Tt)return;const se=$.trim();if(!se)return;const qe=$,he=ta,tt=ta==null?void 0:ta.name;ee(""),N(!0),U(!1),tt&&At();try{await d(s.threadInfo.thread_id,s.id,se,tt,oe??v??void 0),setTimeout(()=>{P.current&&P.current.focus()},100)}catch(Ye){He("Failed to send thread message:",Ye),ee(qe),he&&gn(he),setTimeout(()=>{P.current&&P.current.focus()},100)}finally{N(!1)}},an=g.useCallback(se=>{var qe;gn(se),U(!1),ee(""),I(0),(qe=P.current)==null||qe.focus()},[gn]),xn=g.useCallback(()=>{var se;U(!1),ee(""),I(0),(se=P.current)==null||se.focus()},[]),Yt=g.useCallback(()=>{var se;ee("/"),U(!0),I(0),(se=P.current)==null||se.focus()},[]),Et=se=>{if(X){if(se.key==="ArrowDown"){se.preventDefault(),I(qe=>_e.length===0?0:(qe+1)%_e.length);return}if(se.key==="ArrowUp"){se.preventDefault(),I(qe=>_e.length===0?0:(qe-1+_e.length)%_e.length);return}if(se.key==="Home"){se.preventDefault(),I(0);return}if(se.key==="End"){se.preventDefault(),I(Math.max(_e.length-1,0));return}if((se.key==="Enter"&&!se.shiftKey||se.key==="Tab")&&Te){se.preventDefault(),an(Te);return}if(se.key==="Escape"){se.preventDefault(),xn();return}}se.key==="Enter"&&!se.shiftKey&&(se.preventDefault(),Dn())},Ct=!s.threadInfo||!d||p||ze||q||Tt,fa=!!s.threadInfo&&!!c&&ge>0&&!ze&&!q&&!p,Bl=async()=>{if(!(!s.threadInfo||!c)){te(!0);try{await c(s.id,s.threadInfo.thread_id),fe(!1),R(!1),ee("")}catch(se){He("Failed to clear thread:",se)}finally{te(!1)}}};g.useEffect(()=>{V.current=b},[b]),g.useEffect(()=>{E(V.current??v)},[v]),g.useEffect(()=>{if(!Y||Ct){we.current=q;return}const se=P.current;if(!se){we.current=q;return}if(!(pe.current||we.current)){we.current=q;return}const he=requestAnimationFrame(()=>{var Ye;pe.current&&((Ye=ce.current)==null||Ye.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"})),se.focus();const tt=se.value.length;se.setSelectionRange(tt,tt),pe.current=!1,we.current=q});return()=>{cancelAnimationFrame(he),we.current=q}},[Y,Ct,q]),g.useEffect(()=>{if(P.current){const qe=P.current;qe.style.height="auto";const he=qe.scrollHeight;qe.style.height=`${Math.min(he,120)}px`,qe.style.overflowY=he>120?"auto":"hidden"}},[$]);const Ft=g.useMemo(()=>{if(s.isStreaming&&(!s.content||s.content==="…"))return u.jsx("div",{className:ka,children:u.jsx(Dp,{})});const se=s.isStreaming&&be?" streaming-cursor":"";return u.jsx("div",{className:se||void 0,children:u.jsx(el,{content:cd(ri(s.content||"")),className:ka,syntaxTheme:Ae})})},[ka,s.content,s.isStreaming,be,Ae]),ms=g.useMemo(()=>{const se=he=>he instanceof Date?he.getTime():new Date(he).getTime();return[...ke].sort((he,tt)=>se(he.timestamp)-se(tt.timestamp)).map(he=>{const tt=he.role==="assistant",Ye=tt?tl:$l,nn=he.isStreaming&&tt?" streaming-cursor":"",Ln=he.isStreaming&&(!he.content||he.content==="…")?u.jsx("div",{className:Ye,children:u.jsx(Dp,{size:"sm"})}):u.jsx("div",{className:nn||void 0,children:u.jsx(el,{content:cd(ri(he.content||"")),className:Ye,syntaxTheme:Ae})});return u.jsx("div",{className:`min-w-0 flex ${tt?"justify-start":"justify-end"}`,children:u.jsxs("div",{className:tt?"min-w-0 w-full max-w-full":"min-w-0 max-w-[85%]",children:[u.jsxs("div",{className:tt?"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-[#303030] dark:text-[#f5f5f5]",children:[Ln,he.audio&&tt&&!he.isStreaming&&u.jsx(bp,{audio:he.audio,audioFormat:he.audioFormat,autoPlay:!1}),(he.image||he.imageUrl)&&tt&&!he.isStreaming&&u.jsx(yp,{image:he.image,imageUrl:he.imageUrl,imageFormat:he.imageFormat,revisedPrompt:he.imageRevisedPrompt}),(he.video||he.videoUrl)&&tt&&!he.isStreaming&&u.jsx(vp,{video:he.video,videoUrl:he.videoUrl,videoFormat:he.videoFormat,revisedPrompt:he.videoRevisedPrompt,adapterName:je==null?void 0:je.adapterName}),(he.document||he.documentUrl)&&tt&&!he.isStreaming&&u.jsx(_p,{document:he.document,documentUrl:he.documentUrl,documentFormat:he.documentFormat,revisedPrompt:he.documentRevisedPrompt,adapterName:je==null?void 0:je.adapterName})]}),tt&&!he.isStreaming&&xp()&&u.jsx(pv,{reply:he})]})},he.id)})},[je==null?void 0:je.adapterName,Ae,tl,ke,$l]);return u.jsxs("div",{className:"group animate-fadeIn min-w-0 w-full px-0",children:[u.jsxs("div",{className:"min-w-0 space-y-1",children:[u.jsxs("div",{className:zn,children:[Ft,s.attachments&&s.attachments.length>0&&u.jsx("div",{className:"mt-3 space-y-2",children:s.attachments.map(se=>u.jsxs("div",{className:`flex items-center gap-3 rounded-xl border p-3 ${Aa}`,children:[u.jsx($x,{className:"h-4 w-4 text-gray-500 dark:text-[#bfc2cd]"}),u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"truncate text-sm font-medium text-[#353740] dark:text-[#ececf1]",children:se.filename}),u.jsxs("p",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:[(se.file_size/1024).toFixed(1)," KB"]})]})]},se.file_id))}),s.audio&&be&&!s.isStreaming&&u.jsx(bp,{audio:s.audio,audioFormat:s.audioFormat,autoPlay:!1}),(s.image||s.imageUrl)&&be&&!s.isStreaming&&u.jsx(yp,{image:s.image,imageUrl:s.imageUrl,imageFormat:s.imageFormat,revisedPrompt:s.imageRevisedPrompt}),(s.video||s.videoUrl)&&be&&!s.isStreaming&&u.jsx(vp,{video:s.video,videoUrl:s.videoUrl,videoFormat:s.videoFormat,revisedPrompt:s.videoRevisedPrompt,adapterName:je==null?void 0:je.adapterName}),(s.document||s.documentUrl)&&be&&!s.isStreaming&&u.jsx(_p,{document:s.document,documentUrl:s.documentUrl,documentFormat:s.documentFormat,revisedPrompt:s.documentRevisedPrompt,adapterName:je==null?void 0:je.adapterName})]}),be&&!s.isStreaming&&u.jsxs("div",{className:"py-1 flex flex-nowrap items-center gap-0.5 text-gray-400 dark:text-[#8e8ea0] transition-opacity",children:[!et&&u.jsx("button",{onClick:fs,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:Bt,"aria-label":Bt,children:w?u.jsx(Ro,{className:"h-4 w-4 text-emerald-500 dark:text-emerald-400"}):u.jsx(Dx,{className:"h-4 w-4"})}),xp()&&u.jsxs("div",{className:"relative flex items-center gap-0.5",children:[u.jsx("button",{onClick:()=>tn("up"),disabled:S,className:`rounded-md p-1.5 transition-colors ${S?"opacity-50 cursor-not-allowed":""} ${s.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:"Good response","aria-label":"Good response",children:u.jsx(lg,{className:"h-4 w-4"})}),u.jsx("button",{onClick:()=>tn("down"),disabled:S,className:`rounded-md p-1.5 transition-colors ${S?"opacity-50 cursor-not-allowed":""} ${s.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:"Poor response","aria-label":"Poor response",children:u.jsx(ng,{className:"h-4 w-4"})}),_&&u.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:[u.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"}),u.jsxs("div",{className:"relative flex items-center gap-1.5",children:[u.jsx(Ro,{className:"h-3.5 w-3.5"}),u.jsx("span",{children:"Thanks!"})]})]})]}),l&&u.jsx("button",{onClick:()=>l(s.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:"Regenerate response","aria-label":"Regenerate response",children:u.jsx(nb,{className:"h-4 w-4"})}),xt&&s.supportsThreading&&!s.threadInfo&&i&&h&&u.jsxs("button",{type:"button",onClick:()=>{pe.current=!0,R(!0),i(s.id,h)},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:"Continue this discussion with the current answer's context","aria-label":"Continue this discussion with the current answer's context",children:[u.jsx(up,{className:"h-3.5 w-3.5 shrink-0"}),u.jsx("span",{children:"Continue"})]}),xt&&s.threadInfo&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"w-px h-4 shrink-0 bg-gray-200 dark:bg-[#3c3f4a] mx-1"}),u.jsxs("button",{onClick:()=>R(se=>!se),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:[u.jsx(up,{className:"h-4 w-4"}),u.jsxs("span",{className:"truncate",children:[ge," ",ge===1?"reply":"replies"]}),Y?u.jsx(Uo,{className:"h-3 w-3"}):u.jsx(di,{className:"h-3 w-3"})]}),fa&&u.jsx("button",{type:"button",onClick:()=>fe(!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:"Clear replies","aria-label":"Clear replies",children:"Clear"})]})]}),xt&&s.threadInfo&&Y&&u.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:[u.jsx("div",{ref:xe,className:"thread-replies-scroll mt-2 space-y-2 pb-3",onScroll:()=>{if(!xe.current)return;const{scrollTop:se,scrollHeight:qe,clientHeight:he}=xe.current;de.current=qe-se-he<100},children:ge>0?ms:null}),Oe&&u.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:[Oe,Fe&&u.jsx("div",{className:"mt-2",children:u.jsx("button",{type:"button",onClick:()=>wa.getState().openLoginPrompt("Sign in to unlock higher message limits and continue this thread."),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:"Sign in for higher limits"})})]}),u.jsxs("div",{ref:ce,className:"mt-1 w-full max-w-[64rem] bg-transparent pt-1",children:[u.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:[ta&&u.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:[u.jsx(xd,{className:"h-3.5 w-3.5 shrink-0 text-gray-500 dark:text-gray-400","aria-hidden":"true"}),u.jsx("span",{className:"min-w-0 truncate font-medium capitalize",children:ta.name.replace(/-/g," ")}),u.jsx("button",{type:"button",onClick:()=>At(),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":"Remove thread skill",children:u.jsx(ua,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),!ta&&pn.length>0&&$.length===0&&!Ct&&u.jsxs("button",{type:"button",onClick:Yt,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":"Show available skills (or type a forward slash)",title:"Use a skill",children:[u.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:"/"}),"Skills"]}),u.jsxs("div",{className:"relative flex min-h-8 flex-1 items-center min-w-0",children:[u.jsx("label",{htmlFor:ea,className:"sr-only",children:"Reply in thread"}),bt&&u.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:[u.jsx("span",{className:"invisible",children:$}),u.jsx("span",{children:bt})]}),u.jsx("textarea",{id:ea,ref:P,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:Xt,"aria-label":"Reply in thread",value:$,onChange:se=>{const qe=se.target.value;ee(qe),qe.startsWith("/")&&I(0),U(qe.startsWith("/"))},onKeyDown:Et,disabled:Ct,rows:1,maxLength:ie,style:{minHeight:"32px",maxHeight:"120px",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none"}})]}),u.jsxs("div",{className:"flex items-center justify-between sm:justify-end gap-2",children:[u.jsx(_g,{availableModels:x,defaultModel:v,selectedModel:oe,onSelect:E,maxWidthClass:"max-w-[120px]",triggerPaddingClass:"px-2 py-1",staticPaddingClass:"px-2 py-1",triggerTitle:"Select model for this thread",listboxLabel:"Select model for this thread"}),$.trim().length>0&&u.jsx("button",{type:"button",onClick:Dn,disabled:Ct||$.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:"Send thread message",children:u.jsx(tg,{className:"h-5 w-5 sm:h-4 sm:w-4"})})]})]}),X&&u.jsx("div",{className:"w-full pt-1",children:u.jsx(kg,{skills:pn,isLoading:en,selectedSkill:ta,activeSkillName:Te==null?void 0:Te.name,query:gt,onActiveSkillChange:se=>{const qe=_e.findIndex(he=>he.name===se.name);qe>=0&&I(qe)},onSelect:an,onClose:xn})})]}),ge>0&&u.jsx("div",{className:"mt-2 flex justify-end",children:u.jsxs("button",{type:"button",onClick:()=>R(!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":"Hide replies",children:[u.jsx(Uo,{className:"h-3 w-3"}),u.jsx("span",{children:"Hide replies"})]})})]})]}),u.jsx(qo,{isOpen:ae,onClose:()=>{Ce||fe(!1)},onConfirm:Bl,title:"Clear Replies",message:"Are you sure you want to clear these replies? This removes the child thread from the backend without deleting the main conversation.",confirmText:"Clear",cancelText:"Cancel",type:"danger",isLoading:Ce})]})}let nr=null;function xv(){if(typeof window>"u")return null;const s=window.AudioContext??window.webkitAudioContext;return s?((!nr||nr.state==="closed")&&(nr=new s),nr.state==="suspended"&&nr.resume(),nr):(le("[SoundEffects] AudioContext not supported in this browser"),null)}function bv(s){const l=xv();if(!l)return;const i=l.currentTime;for(const c of s){const d=l.createOscillator(),f=l.createGain();d.connect(f),f.connect(l.destination),d.frequency.value=c.frequency,d.type=c.type;const h=i+c.startTime,p=h+c.duration;f.gain.setValueAtTime(.001,h),f.gain.linearRampToValueAtTime(c.gain,h+.008),f.gain.exponentialRampToValueAtTime(.001,p),d.start(h),d.stop(p+.01)}}const yv={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 si(s,l){if(!l)return;const i=yv[s];if(!i){le(`[SoundEffects] Unknown sound effect type: ${s}`);return}try{bv(i),le(`[SoundEffects] Playing ${s} sound effect`)}catch(c){le(`[SoundEffects] Failed to play ${s} sound effect:`,c)}}function vv({messages:s,onRegenerate:l,onStartThread:i,onClearThread:c,onSendThreadMessage:d,sessionId:f,isLoading:h,contentMaxWidthClass:p="max-w-[64rem]",availableModels:x,defaultModel:v,selectedModel:b}){const w=g.useRef(null),k=g.useRef(null),S=g.useRef(s.length),j=g.useRef(""),_=g.useRef(h),z=g.useRef(!0),{settings:$}=Go(),{topLevelMessages:ee,threadLookup:Y}=g.useMemo(()=>{const N=new Map,X=[];return s.forEach(U=>{if(U.isThreadMessage&&U.parentMessageId){const Q=N.get(U.parentMessageId)||[];N.set(U.parentMessageId,[...Q,U]);return}X.push(U)}),{topLevelMessages:X,threadLookup:N}},[s]),R=()=>{if(!k.current)return;const{scrollTop:N,scrollHeight:X,clientHeight:U}=k.current,I=X-N-U<200;z.current=I},q=g.useCallback(()=>{requestAnimationFrame(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)})},[]);return g.useEffect(()=>{const N=s.length,X=S.current,U=N>X,Q=s[s.length-1],I=(Q==null?void 0:Q.content)||"",ae=I!==j.current,fe=(Q==null?void 0:Q.isStreaming)??!1;U||fe&&ae?(q(),z.current=!0):z.current&&ae&&q(),S.current=N,j.current=I},[s,q]),g.useEffect(()=>{h&&(q(),z.current=!0)},[h,q]),g.useEffect(()=>{if(_.current&&!h){const N=s[s.length-1];(N==null?void 0:N.role)==="assistant"&&N.content&&si("messageReceived",$.soundEnabled)}_.current=h},[h,s,$.soundEnabled]),ee.length===0?u.jsx("div",{className:"flex-1 flex items-center justify-center px-4 sm:px-6",children:u.jsxs("div",{className:"text-center text-lg text-gray-500 dark:text-[#bfc2cd]",children:[u.jsx("p",{className:"text-xl",children:"Your messages will appear here."}),u.jsx("p",{className:"mt-1 text-lg",children:"Start the conversation by sending a prompt below."})]})}):u.jsx("div",{ref:k,className:"message-list flex-1 overflow-y-auto pb-8 pt-4 sm:pt-6",onScroll:R,children:u.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:u.jsxs("div",{className:`message-list__rail mx-auto w-full space-y-7 ${p}`,children:[ee.map(N=>u.jsx("div",{className:`flex w-full ${N.role==="user"?"justify-end":"justify-start"}`,style:{contentVisibility:"auto",containIntrinsicSize:"420px"},children:u.jsx(gv,{message:N,onRegenerate:l,onStartThread:i,onClearThread:c,onSendThreadMessage:d,threadMessages:Y.get(N.id),sessionId:f,isThreadSendDisabled:h,availableModels:x,defaultModel:v,selectedModel:b})},N.id)),u.jsx("div",{ref:w,className:"h-8"})]})})})}const wv=4e3;function Sv(s,l,i={}){var U;const[c,d]=g.useState(!1),[f,h]=g.useState(null),p=g.useRef(null),x=g.useRef(""),v=g.useRef(""),b=g.useRef(!1),w=g.useRef(null),k=typeof navigator<"u"?navigator.language:"en-US",S=Number.isFinite(i.silenceTimeoutMs)?Math.max(Math.floor(i.silenceTimeoutMs),1e3):wv,j=((U=i.language)==null?void 0:U.trim())||k||"en-US",_=g.useCallback(Q=>Q.replace(/\s+/g," ").trim(),[]),z=g.useCallback(Q=>{const I=_(Q);I&&I!==v.current&&(v.current=I,s(I))},[_,s]),$=g.useCallback(()=>{if(!x.current)return;const Q=x.current;x.current="",z(Q)},[z]),ee=typeof window<"u"&&("webkitSpeechRecognition"in window||"SpeechRecognition"in window),Y=g.useCallback(()=>{!l||b.current||(b.current=!0,l())},[l]),R=g.useCallback(()=>{w.current!==null&&(clearTimeout(w.current),w.current=null)},[]),q=g.useCallback(()=>{R(),w.current=setTimeout(()=>{le("Speech recognition silence threshold reached, stopping recording"),p.current?p.current.stop():Y()},S)},[R,Y,S]),N=g.useCallback(()=>{if(!ee){h("Speech recognition is not supported in this browser. Please try Chrome, Edge, or Safari.");return}if(!p.current)try{b.current=!1;const Q=window.SpeechRecognition||window.webkitSpeechRecognition,I=new Q;I.continuous=!0,I.interimResults=!0,I.lang=j,I.maxAlternatives=1,I.onstart=()=>{d(!0),h(null),x.current="",v.current="",le("Speech recognition started"),q()},I.onresult=ae=>{let fe="",Ce="";for(let te=ae.resultIndex;te<ae.results.length;te++){const oe=ae.results[te][0].transcript;ae.results[te].isFinal?fe+=oe:Ce+=oe}Ce&&(x.current=_(Ce)),fe&&(x.current="",z(fe)),q()},I.onend=()=>{R(),$(),d(!1),p.current=null,le("Speech recognition ended"),Y()},I.onerror=ae=>{switch(R(),He("Speech recognition error:",ae.error),d(!1),p.current=null,x.current="",Y(),ae.error){case"no-speech":h("No speech detected. Please try again.");break;case"audio-capture":h("Microphone access denied. Please allow microphone access and try again.");break;case"not-allowed":h("Microphone access not allowed. Please enable microphone permissions.");break;case"network":h("Network error occurred. Please check your connection.");break;default:h(`Speech recognition error: ${ae.error}`)}},I.start(),p.current=I}catch(Q){He("Failed to start speech recognition:",Q),h("Failed to start speech recognition. Please try again."),d(!1)}},[ee,$,Y,q,R,j,_,z]),X=g.useCallback(()=>{if(le("Stopping speech recognition..."),p.current){const Q=p.current;Q.onstart=null,Q.onerror=null;try{Q.stop()}catch(I){le("Recognition already stopped or error stopping:",I),R(),$(),Q.onend=null,Q.onresult=null,p.current=null,d(!1),Y()}}R(),d(!1),h(null),le("Speech recognition stopped, isListening set to false")},[R,$,Y]);return{isListening:c,isSupported:ee,startListening:N,stopListening:X,error:f}}const kv=300,Lp=3,Co=5,_v=6e4;function Rp(s){if(typeof s!="string")return null;const l=s.replace(/[\r\n\u2028\u2029]+/g," ").replace(/\s{2,}/g," ").trim();return l?{text:l}:null}function Av(s,l={}){const{enabled:i=cg(),adapterName:c,sessionId:d,adapterSupportsAutocomplete:f,skill:h,inputRef:p}=l,[x,v]=g.useState([]),[b,w]=g.useState(!1),[k,S]=g.useState(-1),j=g.useRef(null),_=g.useRef(null),z=g.useRef(null),$=g.useRef(null),ee=g.useRef(null),Y=g.useRef(0),R=g.useRef([]),q=g.useRef([]),N=g.useRef(new Map);g.useEffect(()=>{R.current=x},[x]);const X=g.useCallback(oe=>{const E=N.current.get(oe);return E?E<=Date.now()?(N.current.delete(oe),!1):!0:!1},[]),U=g.useCallback((oe,E=!0)=>{const V=oe.toLowerCase().trim(),H=q.current.length>0?q.current:R.current;if(!V)return H.slice(0,Co);const P=H.filter(ce=>ce.text.toLowerCase().includes(V));return P.length>0?P.slice(0,Co):E?H.slice(0,Co):[]},[]),Q=g.useCallback(async oe=>{if(!i||oe.length<Lp){v([]),q.current=[],_.current&&clearTimeout(_.current),z.current&&clearTimeout(z.current),w(!1);return}if(!c){v([]),q.current=[],_.current&&clearTimeout(_.current),w(!1);return}if(f===!1||X(c)){v([]),q.current=[],_.current&&clearTimeout(_.current),w(!1);return}$.current&&$.current.abort(),$.current=new AbortController;const E=Y.current+1;Y.current=E,_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{E===Y.current&&w(!0)},150);try{const V={"X-Adapter-Name":c};d&&(V["X-Session-ID"]=d);const H=new URLSearchParams;H.set("q",oe),H.set("limit",String(Co)),h&&H.set("skill",h);const P=`/api/v1/autocomplete?${H.toString()}`,ce=await fetch(P,{method:"GET",headers:V,signal:$.current.signal});if(!ce.ok){Be("[useAutocomplete] Request failed:",ce.status),[404,405,501].includes(ce.status)?(N.current.set(c,Date.now()+_v),v([]),q.current=[]):v(U(oe));return}const xe=await ce.json(),pe=Array.isArray(xe==null?void 0:xe.suggestions)?xe.suggestions.map(F=>Rp(typeof F=="string"?F:F==null?void 0:F.text)).filter(F=>F!==null):[];if(E!==Y.current)return;pe.length===0?v(U(oe,!1)):(v(pe),q.current=pe),S(-1),le("[useAutocomplete] Received",pe.length,"suggestions")}catch(V){if(V instanceof Error&&V.name==="AbortError")return;Be("[useAutocomplete] Error:",V instanceof Error?V.message:String(V)),E===Y.current&&v(U(oe))}finally{E===Y.current&&(_.current&&(clearTimeout(_.current),_.current=null),w(!1))}},[i,c,d,f,h,U,X]);g.useEffect(()=>{j.current&&clearTimeout(j.current);const oe=()=>{$.current&&$.current.abort(),_.current&&clearTimeout(_.current),w(!1)},E=()=>{z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{z.current=null,v([]),oe()},0)};if(!i||s.length<Lp||f===!1||c&&X(c)){E();return}if(ee.current){if(s===ee.current){E();return}ee.current=null}return j.current=setTimeout(()=>{Q(s)},kv),()=>{j.current&&clearTimeout(j.current),z.current&&(clearTimeout(z.current),z.current=null)}},[s,Q,i,c,f,X]),g.useEffect(()=>()=>{$.current&&$.current.abort(),_.current&&clearTimeout(_.current)},[]);const I=g.useCallback(()=>{S(oe=>{const E=R.current.length;return E===0?-1:oe<E-1?oe+1:0})},[]),ae=g.useCallback(()=>{S(oe=>{const E=R.current.length;return E===0?-1:oe>0?oe-1:E-1})},[]),fe=g.useCallback(()=>{v([]),q.current=[],S(-1),$.current&&$.current.abort(),_.current&&clearTimeout(_.current),w(!1)},[]),Ce=g.useCallback(oe=>{if(!(p!=null&&p.current))return;const E=()=>{const V=p.current;if(!V)return;const H=typeof oe=="string"?oe.length:V.value.length;V.focus({preventScroll:!0}),typeof V.setSelectionRange=="function"&&V.setSelectionRange(H,H)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(E):setTimeout(E,0)},[p]),te=g.useCallback(oe=>{ee.current=oe},[]);return{suggestions:x,isLoading:b,selectedIndex:k,setSelectedIndex:S,selectNext:I,selectPrevious:ae,clearSuggestions:fe,focusInputAfterSelection:Ce,suppressUntilQueryChange:te}}const Ll=new Map,Cv=new Map,jv=new Map,Nv=new Set,Tv=()=>{if(typeof window>"u")return null;try{return localStorage.getItem("chat-adapter-name")}catch{return null}},Ag=s=>typeof s=="object"&&s!==null&&"message"in s,Ev=s=>s instanceof Error?s.message:typeof s=="string"?s:Ag(s)?s.message??"Unknown error":"Unknown error";function Mv({conversationId:s,onFilesSelected:l,onUploadError:i,onClose:c,onUploadingChange:d,onUploadSuccess:f,maxFiles:h=Le.maxFilesPerConversation,disabled:p=!1}){const[x,v]=g.useState(!1),[b,w]=g.useState(0),k=g.useRef(null),S=g.useRef(jv),j=g.useRef(Nv),_=g.useRef(new Map),z=g.useRef(!0),$=g.useRef(Cv),ee=g.useRef(s),Y=Ve(F=>F.conversations),R=g.useMemo(()=>{if(!s)return new Map;const F=Ll.get(s);return F?new Map(F):new Map},[s,b]),q=g.useCallback(F=>{if(!F){d==null||d(null,!1),w(we=>we+1);return}const me=Ll.get(F)||new Map,ue=Y.find(we=>we.id===F),de=new Map(me);if(ue!=null&&ue.attachedFiles){const we=new Set(ue.attachedFiles.filter(W=>W.processing_status==="completed"||W.processing_status==="failed"||W.processing_status==="error").map(W=>W.file_id));de.forEach((W,re)=>{W.fileId&&we.has(W.fileId)&&de.delete(re)})}de.size>0?(Ll.set(F,de),d==null||d(F,!0)):(Ll.delete(F),d==null||d(F,!1)),w(we=>we+1)},[Y,d]);g.useEffect(()=>{ee.current=s,setTimeout(()=>{q(s)},0)},[s,q]),g.useEffect(()=>{s&&setTimeout(()=>{q(s)},0)},[Y,s,q]);const N=g.useCallback((F,me)=>{if(!F)return;const ue=Ll.get(F)||new Map,de=me(new Map(ue));de.size>0?Ll.set(F,de):Ll.delete(F),d==null||d(F,de.size>0),w(we=>we+1)},[d]),X=g.useCallback((F,me)=>{if(!F)return;const ue=$.current.get(F)||[],de=me([...ue||[]]),we=new Set(ue.map(W=>W.file_id));if($.current.set(F,de),l(F,de),f){const W=de.filter(re=>!we.has(re.file_id));W.length>0&&f(F,W)}w(W=>W+1)},[l,f]),U=Ve(F=>F.removeFileFromConversation),Q=Ve(F=>F.addFileToConversation);g.useEffect(()=>(z.current=!0,()=>{z.current=!1}),[]);const I=g.useCallback(()=>{z.current=!1,new Map(_.current).forEach(me=>me.abort()),setTimeout(()=>{const me=Ve.getState(),ue=new Map(me.conversations.map(we=>[we.id,we])),de=[];S.current.forEach((we,W)=>{var re;if(we){const be=ue.get(we);if(new Set(((re=be==null?void 0:be.attachedFiles)==null?void 0:re.map(ge=>ge.file_id))||[]).has(W)){j.current.add(W),S.current.delete(W);return}}if(j.current.has(W)){le(`[FileUpload] Skipping cleanup delete for ${W}; file was previously attached and already handled`),S.current.delete(W),j.current.delete(W);return}de.push({fileId:W,conversationId:we||null})}),de.length>0&&(c==null||c(),de.forEach(async({fileId:we,conversationId:W})=>{try{if(W)await U(W,we);else{const re=Tv();await ui.deleteFile(we,void 0,void 0,re??void 0)}}catch(re){if(Ag(re)){const be=re.message??"";!be.includes("404")&&!be.includes("File not found")&&Be(`Failed to cleanup file ${we} during component unmount:`,re)}else Be(`Failed to cleanup file ${we} during component unmount`,re)}}))},300)},[c,U]);g.useEffect(()=>I,[I]);const ae=g.useCallback(async F=>{if(!F||F.length===0)return;const me=Array.from(F),ue=Ve.getState(),de=s||ue.currentConversationId;if(!de){i==null||i("Please select or create a conversation before uploading files.");return}const we=ue.conversations.find(ke=>ke.id===de);if(!we){i==null||i("Conversation not found. Please try again.");return}if(($.current.get(de)||[]).length+me.length>h){const ke=`Maximum ${h} files allowed per conversation. Please remove some files first.`;va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${h} files per conversation. Sign in to upload more files.`),i==null||i(ke);return}if(Le.maxTotalFiles!==null&&ue.conversations.reduce((ze,Ue)=>{var Fe;return ze+(((Fe=Ue.attachedFiles)==null?void 0:Fe.length)||0)},0)+me.length>Le.maxTotalFiles){const ze=`Maximum ${Le.maxTotalFiles} total files allowed across all conversations. Please remove some files from other conversations first.`;va()&&!hn()&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${Le.maxTotalFiles} total files. Sign in to upload more files.`),i==null||i(ze);return}if(!we.adapterName){i==null||i("Adapter not configured for this conversation. Please select an adapter first.");return}const re=we.adapterName,be=Ha(we.apiUrl);for(let ke=0;ke<me.length;ke++){const ge=me[ke],ze=new AbortController;_.current.set(ge.name,ze);const Ue=`${de}-${ge.name}-${Date.now()}-${ke}`;let Fe=null;try{const je=await ui.uploadFile(ge,Xe=>{if(N(de,et=>(et.set(Ue,Xe),et)),Xe.fileId&&!Fe){Fe=Xe.fileId,S.current.set(Xe.fileId,de),j.current.add(Xe.fileId);const et={file_id:Xe.fileId,filename:ge.name,mime_type:ge.type||"application/octet-stream",file_size:ge.size,processing_status:Xe.status==="uploading"?"uploading":Xe.status==="processing"?"processing":Xe.status==="completed"?"completed":void 0};le(`[FileUpload] Adding file ${Xe.fileId} to conversation ${de} immediately (status: ${et.processing_status})`),Q(de,et)}},void 0,be,re).catch(Xe=>{if(Xe.message&&Xe.message.includes("was deleted")){Fe&&S.current.delete(Fe);const et=Xe.message.match(/File\s+([\w-]+)\s+was deleted/);return et&&et[1]&&S.current.delete(et[1]),le(`File ${ge.name} was deleted during upload`),null}throw Xe});je?(S.current.set(je.file_id,de),j.current.add(je.file_id),le(`[FileUpload] Updating file ${je.file_id} in conversation ${de} with final status`),Q(de,je),je.processing_status==="completed"||je.processing_status==="failed"||je.processing_status==="error"?N(de,et=>(et.delete(Ue),et)):N(de,et=>{const Bt=et.get(Ue);return Bt&&et.set(Ue,{...Bt,progress:90,status:"processing",fileId:je.file_id}),et}),X(de,et=>{if(new Set(et.map(ie=>ie.file_id)).has(je.file_id))return et;const xt=[...et,je];return le(`[FileUpload] Updated uploadedFiles for ${de}: ${xt.length} files`,xt),xt})):(Be(`Upload completed for ${ge.name} but uploadedAttachment is null`),N(de,Xe=>(Xe.delete(Ue),Xe)))}catch(je){const Xe=Ev(je);if(je instanceof DOMException&&je.name==="AbortError"||ze.signal.aborted){le(`Upload cancelled for ${ge.name}`),Fe&&S.current.delete(Fe);continue}if(Xe.includes("was deleted")){le(`File ${ge.name} was deleted during upload`),Fe&&S.current.delete(Fe);const xt=Xe.match(/File\s+([\w-]+)\s+was deleted/);xt&&xt[1]&&S.current.delete(xt[1]);continue}z.current?(He(`Failed to upload file ${ge.name}:`,je),He(`File type: ${ge.type}, File name: ${ge.name}`),i==null||i(Xe||`Failed to upload ${ge.name}`)):Be(`Upload error for ${ge.name} (component unmounted):`,Xe),Fe&&S.current.delete(Fe);const et=Ue,Bt=de;setTimeout(()=>{N(Bt,xt=>(xt.delete(et),xt))},5e3)}finally{_.current.delete(ge.name)}}},[Q,s,h,i,X,N]),fe=g.useCallback(F=>{F.preventDefault(),F.stopPropagation(),p||v(!0)},[p]),Ce=g.useCallback(F=>{F.preventDefault(),F.stopPropagation(),v(!1)},[]),te=g.useCallback(F=>{if(F.preventDefault(),F.stopPropagation(),v(!1),p)return;const me=F.dataTransfer.files;ae(me)},[p,ae]),oe=g.useCallback(F=>{const me=F.target.files;ae(me),k.current&&(k.current.value="")},[ae]),E=g.useCallback(()=>{!p&&k.current&&k.current.click()},[p]),V=g.useCallback(F=>{p||(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),E())},[p,E]),H=R.size>0,P=g.useMemo(()=>{const F=new Map;return Y.forEach(me=>{F.set(me.id,me.title||"Conversation")}),F},[Y]),ce=g.useMemo(()=>{const F=[];return Ll.forEach((me,ue)=>{ue!==s&&me.size>0&&F.push({conversationId:ue,uploads:Array.from(me.entries()).map(([de,we])=>({key:de,progress:we}))})}),F},[s,b]),xe=(F,me)=>{const ue=F.status==="error";return u.jsxs("div",{className:`group relative w-full flex items-center gap-3 rounded-lg px-3 py-2.5 overflow-hidden transition-colors ${ue?"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:[!ue&&u.jsx("div",{className:"absolute inset-0 bg-blue-50 dark:bg-white/[0.04] transition-all duration-500 ease-out rounded-lg",style:{width:`${F.progress}%`}}),u.jsxs("div",{className:"relative flex items-center gap-3 w-full min-w-0",children:[u.jsx("div",{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md ${ue?"bg-red-100 dark:bg-red-500/15":"bg-blue-100 dark:bg-white/[0.06]"}`,children:ue?u.jsx(Mo,{className:"h-4 w-4 text-red-500 dark:text-red-400"}):u.jsx(zo,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 animate-spin"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-sm font-medium text-[#353740] dark:text-[#ececf1] truncate",children:F.filename}),ue?u.jsx("p",{className:"mt-0.5 text-xs text-red-600 dark:text-red-400 truncate",children:F.error||"Processing failed"}):u.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[u.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-[#242424] rounded-full h-1",children:u.jsx("div",{className:"bg-blue-500 dark:bg-blue-400 h-1 rounded-full transition-all duration-500 ease-out",style:{width:`${F.progress}%`}})}),u.jsxs("span",{className:"text-[11px] tabular-nums text-gray-400 dark:text-[#8e8ea0] shrink-0",children:[Math.round(F.progress),"%"]})]})]}),u.jsx("span",{className:`text-xs font-medium shrink-0 ${ue?"text-red-500 dark:text-red-400":"text-gray-500 dark:text-[#bfc2cd]"}`,children:F.status==="uploading"?"Uploading":F.status==="processing"?"Processing":F.status==="completed"?"Done":"Failed"})]})]},me)},pe=u.jsx("div",{className:"w-full max-w-full overflow-hidden space-y-1.5",role:"status","aria-live":"polite",children:Array.from(R.entries()).map(([F,me])=>xe(me,F))});return u.jsxs("div",{className:"w-full max-w-full overflow-hidden space-y-2",children:[H&&pe,!H&&u.jsxs("button",{type:"button",onClick:E,onKeyDown:V,onDragOver:fe,onDragLeave:Ce,onDrop:te,disabled:p,className:`
|
|
335
335
|
group relative w-full max-w-full rounded-lg border p-4 transition-all duration-200 text-left overflow-hidden
|
|
336
336
|
${x?"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":p?"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]"}
|
|
337
|
-
`,"aria-label":p?"File upload disabled":"Upload files",children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:oe,className:"hidden",disabled:p,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"}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg transition-colors duration-200 ${x?"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:u.jsx(ib,{className:`h-5 w-5 transition-colors duration-200 ${x?"text-blue-600 dark:text-blue-400":"text-gray-400 dark:text-[#8e8ea0] group-hover:text-blue-500 dark:group-hover:text-blue-400"}`})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:`text-sm font-medium transition-colors duration-200 ${x?"text-blue-700 dark:text-blue-300":"text-[#353740] dark:text-[#ececf1]"}`,children:p?"File upload disabled":x?"Drop files here":"Drop files or click to browse"}),u.jsxs("p",{className:"text-xs text-gray-400 dark:text-[#8e8ea0] mt-0.5",children:["PDF, DOCX, TXT, CSV, code files, images, audio · max ",h," files"]})]})]})]}),ce.length>0&&u.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:[u.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] px-1",children:"Other conversations"}),ce.map(({conversationId:F,uploads:me})=>u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("div",{className:"text-[11px] font-medium text-gray-400 dark:text-[#6b6f7a] px-1",children:P.get(F)||"Conversation"}),me.map(({key:ue,progress:de})=>xe(de,ue))]},F))]})]})}const Up={"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"},jo=4,No=3,zv=0,Dv=0,Wu=2;function Lv(r){if(!r||typeof r!="object")return null;const l=r,i=["supportsAutocomplete","isAutocompleteSupported","autocompleteSupported"];for(const f of i)if(typeof l[f]=="boolean")return l[f];const c=["capabilities","features"],d=["autocomplete","supportsAutocomplete","autocomplete_supported"];for(const f of c){const h=l[f];if(!h||typeof h!="object")continue;const p=h;for(const x of d)if(typeof p[x]=="boolean")return p[x]}return null}function Rv(r){if(!r)return"bin";if(Up[r])return Up[r];const l=r.split("/");return l.length===2&&l[1]?l[1]:"bin"}function Uv(r){return r.replace(/[^a-zA-Z0-9._-]/g,"_").replace(/_+/g,"_")||"pasted-file"}function Ov(r){const l=r.lastIndexOf(".");return l===-1||l===r.length-1?null:r.slice(l+1).toLowerCase()}function $v(r){const l=r.lastIndexOf(".");return l===-1?r:r.slice(0,l)}function qv(r,l){const i=Date.now(),c=r.name&&r.name.trim().length>0?r.name.trim():"pasted-file",d=Uv($v(c)),h=Ov(c)||Rv(r.type),p=`${d}-${i}-${l}.${h}`;return new File([r],p,{type:r.type||"application/octet-stream"})}function Op({onSend:r,disabled:l=!1,placeholder:i=ig(),autoFocusEnabled:c=!0,suppressMobileAutoFocus:d=!1,isCentered:f=!1,maxWidthClass:h="max-w-5xl",adapterNotes:p,skillState:x,availableModels:v=[],defaultModel:b=null,selectedModel:w=null,onSelectModel:k}){var pi;const[S,j]=g.useState(""),[_,z]=g.useState(!1),[$,ee]=g.useState(!1),[Y,R]=g.useState(!1),[q,N]=g.useState(!1),[X,U]=g.useState([]),[Q,I]=g.useState({}),[ae,fe]=g.useState(new Map),[Ce,te]=g.useState(!1),[oe,E]=g.useState(!1),[V,H]=g.useState(null),[P,ce]=g.useState(null),[xe,pe]=g.useState(null),[F,me]=g.useState({isOpen:!1,fileId:"",filename:"",isDeleting:!1}),ue=g.useRef(null),de=g.useRef(null),we=g.useRef(null),W=g.useRef(null),se=g.useRef(null),be=g.useRef(new Set),ke=g.useRef(""),ge=g.useRef(!1),ze=g.useRef(0),Ue=g.useRef(null),{settings:Fe,updateSettings:je}=Go(),{theme:Xe,isDark:et}=ss(),Bt=Xe.mode==="dark"?"dark":Xe.mode==="light"?"light":"",xt=et?"dark":"light";ci(de,{enabled:Y,onEscape:()=>R(!1)});const ie=g.useCallback((C,ne)=>{C&&I(Ee=>{if(Ee[C]===ne)return Ee;const $e={...Ee};return ne?$e[C]=!0:delete $e[C],$e})},[]),[Ne,Nt]=g.useState(0),[Oe,Vt]=g.useState(!1),[da,Xt]=g.useState(0),[ea,pn]=g.useState(()=>({top:jo+No,bottom:Math.max(jo-No,0)})),[en,ta]=g.useState(null),gn=is(),Tt=va()&&!gn,gt=wa(C=>C.showLoginPrompt),{createConversation:Ht,currentConversationId:_e,conversations:Sa,isLoading:Te,syncConversationFiles:Ye,stopStreaming:bt,removeFileFromConversation:it}=Ve(),Ae=Sa.find(C=>C.id===_e),la=Ae?Ae.messages.filter(C=>!(C.role==="assistant"&&C.isStreaming)).length:0,Mn=Sa.reduce((C,ne)=>C+ne.messages.filter(Ee=>!(Ee.role==="assistant"&&Ee.isStreaming)).length,0),ka=!!Ae&&Le.maxMessagesPerConversation!==null&&la>=Le.maxMessagesPerConversation,tl=Le.maxTotalMessages!==null&&Mn>=Le.maxTotalMessages,$l=g.useCallback(()=>{Nt(C=>C+1)},[]),_a=ny(),zn=ly(),{isListening:Aa,isSupported:al,startListening:fr,stopListening:ql,error:tn}=Sv(C=>{j(ne=>{const Ee=ne.length>0&&!/\s$/.test(ne)?" ":"",$e=(ne+Ee+C).slice(0,Le.maxMessageLength);return ke.current=$e,$e})},$l,{silenceTimeoutMs:_a,language:zn||void 0}),Dn=ey(),an=ty(),xn=an&&al,Yt=Wb(),Et=cg(),At=Lv(Ae==null?void 0:Ae.adapterInfo),{skills:fa,isLoading:Bl,selectedSkill:Ft,selectSkill:mr,clearSkill:bn}=x,yn=(Ae==null?void 0:Ae.adapterName)||null,{suggestions:Ca,selectedIndex:re,setSelectedIndex:qe,selectNext:he,selectPrevious:tt,clearSuggestions:Ke,focusInputAfterSelection:nn,suppressUntilQueryChange:Ln}=Av(S,{enabled:Et&&!Aa,apiUrl:Ae==null?void 0:Ae.apiUrl,adapterName:yn,sessionId:Ae==null?void 0:Ae.sessionId,adapterSupportsAutocomplete:At,skill:(Ft==null?void 0:Ft.name)||null,inputRef:ue}),ln=Ca.length>0,Rn=!Aa,os=Rn&&ln&&!Oe,nl=S.startsWith("/")?S.slice(1):"",hr=nl.toLowerCase().replace(/-/g," "),ja=hr?fa.filter(C=>C.name.replace(/-/g," ").toLowerCase().includes(hr)||C.description.toLowerCase().includes(hr)):fa,pr=ja.length>0?Math.min(da,ja.length-1):0,ma=ja[pr]??null,Na=(ma==null?void 0:ma.name.replace(/-/g," "))??"",ha=Oe&&ma&&S.startsWith("/")&&Na.toLowerCase().startsWith(nl.toLowerCase())&&Na.length>nl.length?Na.slice(nl.length):null,fi=re>=0?re:0,Hl=ln?Ca[fi]:null,gr=g.useMemo(()=>{if(!Hl)return null;const C=Hl.text||"";if(!S)return C;const ne=S;return C.toLowerCase().startsWith(ne.toLowerCase())&&C.length>ne.length?C.slice(ne.length):null},[Hl,S]),xr=ha??gr,br=S.trim().length===0&&!xr,Ko=g.useCallback(C=>{if(!S)return u.jsx("span",{className:"line-clamp-1 text-current",children:C});if(!C.toLowerCase().startsWith(S.toLowerCase()))return u.jsx("span",{className:"line-clamp-1 text-current",children:C});const ne=C.slice(0,S.length),Ee=C.slice(S.length);return u.jsxs("span",{className:"line-clamp-1",children:[u.jsx("span",{className:"text-gray-500 dark:text-[#8e8ea0]",children:ne}),u.jsx("span",{className:"font-semibold text-[#353740] dark:text-[#ececf1]",children:Ee})]})},[S]),ra=g.useCallback(C=>{var ne;mr(C),Vt(!1),j(""),Ke(),Xt(0),(ne=ue.current)==null||ne.focus()},[Ke,mr]),cs=g.useCallback(()=>{var C;j("/"),Vt(!0),Xt(0),(C=ue.current)==null||C.focus()},[]),us=g.useCallback(()=>{var C;Vt(!1),j(""),Xt(0),(C=ue.current)==null||C.focus()},[]),rn=g.useCallback(()=>{const C=ue.current;if(!C||typeof window>"u")return;const ne=Ma=>{const Cr=Ma+No,jr=Math.max(Ma-No,0);C.style.paddingTop=`${Cr}px`,C.style.paddingBottom=`${jr}px`,pn({top:Cr,bottom:jr})},Ee=window.getComputedStyle(C),$e=parseFloat(Ee.lineHeight||"0");if(!Number.isNaN($e)&&$e>0?ta(Ma=>Ma===$e?Ma:$e):ta(Ma=>Ma===null?Ma:null),!$e||Number.isNaN($e)){ne(jo);return}const rt=C.scrollHeight,Qt=C.clientHeight;if(rt>$e+2){ne(jo);return}const at=Math.max(Qt-$e,0),cn=Math.max(at/2,0);ne(cn)},[]),ll=()=>{const C=ue.current;return C?C.selectionStart===C.selectionEnd&&C.selectionStart===S.length:!1},ds=(Ae==null?void 0:Ae.attachedFiles)||[],sn=_e?ds:X,rl=Sa.reduce((C,ne)=>{var Ee;return C+(((Ee=ne.attachedFiles)==null?void 0:Ee.length)||0)},0),mi=Le.maxFilesPerConversation!==null&&Le.maxFilesPerConversation>0&&ds.length>=Le.maxFilesPerConversation,fs=Le.maxTotalFiles!==null&&rl>=Le.maxTotalFiles,sl=((pi=Ae==null?void 0:Ae.adapterInfo)==null?void 0:pi.isFileSupported)??!1,Fl=sn.some(C=>C.processing_status?C.processing_status!=="completed"&&C.processing_status!=="error"&&C.processing_status!=="failed":!0),sa=_e?!!Q[_e]:!1,yr=Object.values(Q).some(Boolean),il=S.trim().length>0,Fa=ka||tl,wt=l||Fl||sa||Fa,vr=Yt&&sl,on=mi||fs,Ia=!vr||wt||on;g.useLayoutEffect(()=>{if(ue.current){const C=ue.current,ne=120;C.style.height="auto";const Ee=C.scrollHeight;C.style.height=`${Math.min(Ee,ne)}px`,C.style.overflowY=Ee>ne?"auto":"hidden",rn()}},[S,rn]),g.useEffect(()=>{if(typeof window>"u"||typeof ResizeObserver>"u")return;const C=ue.current;if(!C)return;const ne=new ResizeObserver(()=>{rn()});return ne.observe(C),()=>{ne.disconnect()}},[rn]);const ms=()=>{const C=document.activeElement;return C&&C.tagName==="TEXTAREA"},ol=g.useCallback(()=>!d||typeof window>"u"?!1:window.matchMedia("(max-width: 767px)").matches,[d]);g.useEffect(()=>{ol()||c&&!wt&&ue.current&&!ms()&&ue.current.focus()},[c,wt,d,ol]);const wr=g.useRef(Te);g.useEffect(()=>{if(ol()){wr.current=Te;return}c&&wr.current&&!Te&&!wt&&ue.current&&setTimeout(()=>{ue.current&&!ms()&&ue.current.focus()},100),wr.current=Te},[c,Te,wt,d,ol]),g.useEffect(()=>{if(!xn||(Ne>ze.current&&(ge.current=!0,ze.current=Ne),!ge.current||Ne===0))return;const C=ke.current.trim(),ne=Ve.getState();if(le("[MessageInput] Auto-send check after voice completion:",{hasMessage:!!C,isInputDisabled:wt,isComposing:_,isLoading:ne.isLoading}),ge.current=!1,!C)return;if(wt||_){le("[MessageInput] Auto-send skipped because input is currently disabled or composing");return}const Ee=ne.conversations.find(ut=>ut.id===ne.currentConversationId),rt=((Ee==null?void 0:Ee.attachedFiles)||[]).map(ut=>ut.file_id),Qt=Ft==null?void 0:Ft.name;le("[MessageInput] Auto-sending voice message immediately:",C),r(C,rt.length>0?rt:void 0,void 0,Qt),Qt&&bn(),setTimeout(()=>{Vt(!1)},0),Ke(),setTimeout(()=>{j("")},0),ke.current="",ue.current&&(ue.current.style.height="auto",ue.current.style.overflowY="hidden",rn())},[xn,Ne,wt,_,r,Ft,bn,rn,Ke]),g.useEffect(()=>{sa&&q&&setTimeout(()=>{N(!1)},0)},[sa,q]),g.useEffect(()=>{!sa&&sn.length},[sa,q,sn.length]);const vn=g.useCallback((C,ne)=>{setTimeout(()=>{let Ee=Ve.getState(),$e=ne||Ee.currentConversationId;if($e||($e=Ht(),Ee=Ve.getState(),$e=Ee.currentConversationId||$e),!$e){He("[MessageInput] Unable to sync files: conversation ID missing");return}const rt=new Set(C.map(ut=>ut.file_id)),Qt=[];be.current.forEach((ut,at)=>{const[,...cn]=at.split("-"),Ma=cn.join("-");rt.has(Ma)||Qt.push(at)}),Qt.forEach(ut=>be.current.delete(ut)),C.forEach(ut=>{const at=`${$e}-${ut.file_id}`;be.current.has(at)||(be.current.add(at),le(`[MessageInput] Adding file ${ut.file_id} to conversation ${$e}`),Ee.addFileToConversation($e,ut))})},0)},[Ht]);g.useEffect(()=>{if(_e!==Ue.current)if(Ue.current=_e||null,_e&&Ae){const C=Ae.attachedFiles||[];setTimeout(()=>{U(C.map(ne=>({...ne})))},0)}else setTimeout(()=>{U([])},0)},[_e,Ae]),g.useEffect(()=>{if(_e&&Ae){const C=Ae.attachedFiles||[];C.length>0?setTimeout(()=>{U(ne=>{const Ee=new Set(ne.map(rt=>rt.file_id)),$e=C.filter(rt=>!Ee.has(rt.file_id));return $e.length>0?(le(`[MessageInput] Syncing ${$e.length} missing files from conversation to UI`),[...ne,...$e]):ne})},0):C.length===0&&X.length>0&&setTimeout(()=>{U([])},0)}},[_e,Ae,Sa,X.length]);const Ta=g.useRef(null),Il=g.useRef(""),wn=(Ae==null?void 0:Ae.attachedFiles)||[],Ea=wn.length>0?`${wn.length}:${wn.map(C=>C.file_id).join("|")}`:"",Sr=wn.some(C=>!C.processing_status||C.processing_status==="processing"||C.processing_status==="uploading");g.useEffect(()=>{if(!_e||!(Ae!=null&&Ae.adapterName))return;const C=Ea!=="";if(C&&(Ta.current!==_e||Il.current!==Ea)?(le(`[MessageInput] Syncing files for conversation ${_e}...`),Ta.current=_e,Il.current=Ea,Ye(_e).catch($e=>{He("[MessageInput] Failed to sync conversation files:",$e)})):C||(Ta.current=_e,Il.current=""),!Sr)return;le("[MessageInput] Files still processing, starting poll...");const Ee=setInterval(async()=>{const rt=Ve.getState().conversations.find(at=>at.id===_e);if(!rt){clearInterval(Ee);return}if((rt.attachedFiles||[]).filter(at=>!at.processing_status||at.processing_status==="processing"||at.processing_status==="uploading").length===0){le("[MessageInput] All files completed processing, stopping poll"),clearInterval(Ee);return}try{await Ye(_e)}catch(at){He("[MessageInput] Failed to poll file status:",at)}},3e3);return()=>{clearInterval(Ee)}},[_e,Ae==null?void 0:Ae.adapterName,Ea,Sr,Ye]),g.useEffect(()=>{setTimeout(()=>{I(C=>{const ne=new Set(Sa.map(rt=>rt.id));let Ee=!1;const $e={...C};return Object.keys($e).forEach(rt=>{ne.has(rt)||(delete $e[rt],Ee=!0)}),Ee?$e:C})},0)},[Sa]);const Gl=C=>{if(C.preventDefault(),il&&!wt&&!_){Aa&&ql();const Ee=((Ae==null?void 0:Ae.attachedFiles)||[]).map(rt=>rt.file_id),$e=Ft==null?void 0:Ft.name;r(S.trim(),Ee.length>0?Ee:void 0,void 0,$e),$e&&bn(),Vt(!1),ri("messageSent",Fe.soundEnabled),j(""),ke.current="",U([]),N(!1),ue.current&&(ue.current.style.height="auto",ue.current.style.overflowY="hidden",rn())}},Vl=g.useCallback(C=>{if(!C||C.length===0)return;const ne=C.length===1?`File "${C[0].filename}" uploaded successfully`:`${C.length} files uploaded successfully`;ri("success",Fe.soundEnabled),ce(ne),setTimeout(()=>{ce(null)},6e3)},[Fe.soundEnabled]),kr=g.useCallback((C,ne)=>{le(`[MessageInput] handleFilesSelected called with ${ne.length} files for conversation ${C}:`,ne),C&&(C===_e&&U(ne),vn(ne,C))},[_e,vn]),_r=g.useCallback((C,ne)=>{C===_e&&Vl(ne)},[_e,Vl]),hi=g.useCallback(C=>{me({isOpen:!0,fileId:C.file_id,filename:C.filename,isDeleting:!1})},[]),aa=g.useCallback(()=>{me(C=>C.isDeleting?C:{isOpen:!1,fileId:"",filename:"",isDeleting:!1})},[]),Un=g.useCallback(async()=>{if(!(!_e||!F.fileId)){me(C=>({...C,isDeleting:!0}));try{await it(_e,F.fileId),U(C=>C.filter(ne=>ne.file_id!==F.fileId)),me({isOpen:!1,fileId:"",filename:"",isDeleting:!1})}catch(C){const ne=C instanceof Error?C.message:"Failed to remove file";He("[MessageInput] Failed to remove file:",C),pe(ne),me({isOpen:!1,fileId:"",filename:"",isDeleting:!1})}}},[_e,F.fileId,it]),Xl=g.useCallback(C=>C.replace(/\s+/g," ").trim(),[]),Sn=g.useCallback(C=>{const ne=Xl(C);j(ne),Ke(),Ln(ne),nn(ne)},[Ke,nn,Xl,Ln]),hs=g.useCallback(C=>{if(C<0)return;const ne=Ca[C]||Ca[0];ne&&Sn(ne.text)},[Ca,Sn]),ps=C=>{if(Oe){if(C.key==="ArrowDown"){C.preventDefault(),Xt(ne=>ja.length===0?0:(ne+1)%ja.length);return}if(C.key==="ArrowUp"){C.preventDefault(),Xt(ne=>ja.length===0?0:(ne-1+ja.length)%ja.length);return}if(C.key==="Home"){C.preventDefault(),Xt(0);return}if(C.key==="End"){C.preventDefault(),Xt(Math.max(ja.length-1,0));return}if((C.key==="Enter"&&!C.shiftKey||C.key==="Tab")&&ma){C.preventDefault(),ra(ma);return}if(C.key==="Escape"){C.preventDefault(),us();return}}if(ln&&Rn){if(C.key==="ArrowDown"){C.preventDefault(),he();return}if(C.key==="ArrowUp"){C.preventDefault(),tt();return}if(C.key==="Tab"){C.preventDefault();const ne=re>=0?re:0;hs(ne);return}if(C.key==="ArrowRight"&&ll()){if(gr&&Hl){C.preventDefault(),Sn(Hl.text);return}if(re>=0){C.preventDefault(),hs(re);return}}if(C.key==="Enter"&&re>=0){C.preventDefault(),hs(re);return}if(C.key==="Escape"){C.preventDefault(),Ke();return}}C.key==="Enter"&&!C.shiftKey&&!_&&(C.preventDefault(),Gl(C))},gs=()=>{Aa?ql():(Ke(),fr())},Yl=()=>{const C=!Fe.voiceEnabled;je({voiceEnabled:C}),C&&Ul.enableAudio()},Ar=g.useCallback(async C=>{if(!Yt||!$||!sl||wt)return;const ne=C.clipboardData;if(!ne||!ne.items)return;const $e=Array.from(ne.items).filter(ut=>ut.kind==="file");if($e.length===0)return;const rt=[];if($e.forEach((ut,at)=>{const cn=ut.getAsFile();cn&&rt.push(qv(cn,at))}),rt.length===0)return;C.preventDefault(),H(null),ce(null);let Qt=null;try{const ut=Ve.getState(),at=ut.conversations.find(ia=>ia.id===ut.currentConversationId);if(((at==null?void 0:at.attachedFiles)||[]).length+rt.length>Le.maxFilesPerConversation)throw Tt&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${Le.maxFilesPerConversation} files per conversation. Sign in to upload more files.`),new Error(`Maximum ${Le.maxFilesPerConversation} files allowed per conversation. Please remove some files first.`);if(Le.maxTotalFiles!==null&&ut.conversations.reduce((Ga,un)=>{var Zt;return Ga+(((Zt=un.attachedFiles)==null?void 0:Zt.length)||0)},0)+rt.length>Le.maxTotalFiles)throw Tt&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${Le.maxTotalFiles} total files. Sign in to upload more files.`),new Error(`Maximum ${Le.maxTotalFiles} total files allowed across all conversations. Please remove some files from other conversations first.`);if(!at)throw new Error("Conversation not found. Please select a conversation first.");if(!at.adapterName)throw new Error("Adapter not configured for this conversation. Please select an adapter first.");const Cr=Ha(at.apiUrl),jr=at.adapterName;Qt=at.id,ie(Qt,!0);const cl=[],gi=[];for(let ia=0;ia<rt.length;ia++){const Ga=rt[ia],un=Ga.name||`Clipboard file ${ia+1}`,Zt=`${un}-${Date.now()}-${ia}`;fe(za=>{const Va=new Map(za);return Va.set(Zt,{filename:un,progress:0,status:"uploading"}),Va});const Po=za=>{fe(Va=>{const It=new Map(Va),Ql=It.get(Zt);return Ql&&It.set(Zt,{...Ql,filename:un,progress:za.progress,status:za.status,fileId:za.fileId}),It})},Wo=()=>new Promise(za=>{fe(Va=>{const It=new Map(Va),Ql=It.get(Zt);return Ql&&It.set(Zt,{...Ql,progress:100,status:"completed"}),It}),setTimeout(()=>{fe(Va=>{const It=new Map(Va);return It.delete(Zt),It}),za()},2500)});le(`[MessageInput] Pasting file: ${Ga.name}, type: ${Ga.type||"unknown"}, size: ${Ga.size}`);const ec=await ui.uploadFile(Ga,za=>{le(`[MessageInput] Paste upload progress for ${Ga.name}: ${za.progress}% - ${za.status}`),Po(za)},void 0,Cr,jr);cl.push(ec),gi.push(Wo())}if(cl.length>0){let ia=cl;if(Qt&&Qt===_e){const Ga=new Set(X.map(Zt=>Zt.file_id)),un=cl.filter(Zt=>!Ga.has(Zt.file_id));un.length>0?(U(Zt=>[...Zt,...un]),ia=un):ia=[]}ia.length>0&&vn(ia,Qt),await Promise.all(gi),Vl(cl)}}catch(ut){const at=ut instanceof Error?ut.message:"Failed to paste file";He("[MessageInput] Paste error:",ut),ri("error",Fe.soundEnabled),H(at),at.toLowerCase().includes("maximum")&&pe(at),setTimeout(()=>{H(null)},5e3),fe(new Map)}finally{ie(Qt,!1)}},[X,_e,$,sl,Tt,wt,ie,Fe.soundEnabled,Vl,vn,Yt]),xs=Qb(Ae==null?void 0:Ae.adapterName),bs=tl?Tt?`Guest limit of ${Le.maxTotalMessages} messages reached. Sign in for higher limits.`:`Workspace limit of ${Le.maxTotalMessages} messages reached. Delete or archive old conversations to continue.`:ka?Tt?`Guest limit of ${Le.maxMessagesPerConversation} messages reached. Sign in for higher limits.`:`This chat hit the ${Le.maxMessagesPerConversation} message limit. Start a new conversation to continue.`:Fl||sa?"Files are uploading, please wait...":xs||(vr?"Message ORBIT or drop files here":i),On=[];tl&&Le.maxTotalMessages!==null&&(Tt?gt&&On.push(`Guest limit of ${Le.maxTotalMessages} total messages reached. Sign in for higher limits, or delete conversations to start over.`):On.push(`Workspace limit of ${Le.maxTotalMessages} total messages reached. Delete or export older conversations to continue.`)),ka&&Le.maxMessagesPerConversation!==null&&(Tt?gt&&On.push(`Guest limit of ${Le.maxMessagesPerConversation} messages per conversation reached. Sign in for higher limits, or delete conversations to start over.`):On.push(`This conversation reached the ${Le.maxMessagesPerConversation} message limit. Start a new conversation to keep chatting.`)),xe&&On.push(xe),g.useEffect(()=>{!an||!tn||ri("error",Fe.soundEnabled)},[an,Fe.soundEnabled,tn]),g.useEffect(()=>{if(!xe)return;const C=setTimeout(()=>pe(null),5e3);return()=>clearTimeout(C)},[xe]),g.useEffect(()=>{var C;(q||sa||ae.size>0||yr)&&((C=we.current)==null||C.scrollIntoView({behavior:"smooth",block:"nearest"}))},[q,sa,ae.size,yr]),g.useEffect(()=>{var C;os&&((C=W.current)==null||C.scrollIntoView({behavior:"smooth",block:"nearest"}))},[os]),g.useEffect(()=>{var C;Oe&&((C=se.current)==null||C.scrollIntoView({behavior:"smooth",block:"end"}))},[Oe,ja.length]);const ys=h,Jo=f?"flex justify-center":"";return u.jsxs(u.Fragment,{children:[u.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 ${Jo}`,children:u.jsxs("div",{className:`mx-auto w-full ${ys}`,children:[tn&&an&&u.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:[u.jsx(Mo,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-red-500 dark:text-red-400"}),u.jsx("span",{className:"text-sm text-red-700 dark:text-red-300",children:tn})]}),V&&u.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:[u.jsx(Mo,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-red-500 dark:text-red-400"}),u.jsx("span",{className:"text-sm text-red-700 dark:text-red-300",children:V})]}),P&&u.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:[u.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:u.jsx(zx,{className:"h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400"})}),u.jsx("span",{className:"text-sm text-[#353740] dark:text-[#ececf1]",children:P})]}),On.length>0&&u.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:[u.jsx(bd,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-amber-500 dark:text-amber-400"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("ul",{className:"list-none space-y-0.5",children:On.map((C,ne)=>u.jsx("li",{className:"text-sm text-amber-800 dark:text-amber-200",children:C},`${C}-${ne}`))}),Tt&&(Fa||on)&>&&u.jsx("button",{type:"button",onClick:()=>wa.getState().openLoginPrompt("Sign in to unlock higher message limits and more conversations."),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:"Sign in for higher limits"})]})]}),u.jsxs("div",{className:"relative w-full",children:[u.jsxs("form",{onSubmit:Gl,className:"flex w-full flex-col gap-2 md:gap-3",children:[u.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 ${$?"border-gray-400 shadow-md dark:border-[#3a3a3a] dark:shadow-lg":"border-gray-300 dark:border-[#242424]"} bg-gray-50 dark:bg-[#111111]`,children:[Ft&&u.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:[u.jsx(xd,{className:"h-3.5 w-3.5 shrink-0 text-gray-500 dark:text-gray-400","aria-hidden":"true"}),u.jsx("span",{className:"min-w-0 truncate font-medium capitalize",children:Ft.name.replace(/-/g," ")}),u.jsx("button",{type:"button",onClick:()=>{var C;bn(),(C=ue.current)==null||C.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":"Remove skill",children:u.jsx(ua,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),!Ft&&fa.length>0&&S.length===0&&!wt&&u.jsxs("button",{type:"button",onClick:cs,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":"Show available skills (or type a forward slash)",title:"Use a skill",children:[u.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:"/"}),"Skills"]}),u.jsxs("div",{className:"relative flex-1 w-full min-w-0",children:[br&&bs&&u.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(ea.top-zv,0),paddingBottom:ea.bottom,paddingLeft:`${Wu}px`,paddingRight:0,lineHeight:en?`${en}px`:void 0},"aria-hidden":"true",children:bs}),xr&&$&&u.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(ea.top-Dv,0),paddingBottom:ea.bottom,paddingLeft:`${Wu}px`,paddingRight:0,lineHeight:en?`${en}px`:void 0},"aria-hidden":"true",children:[u.jsx("span",{className:"invisible",children:S}),u.jsx("span",{children:xr})]}),u.jsx("textarea",{ref:ue,"aria-label":"Message input",value:S,onChange:C=>{const ne=C.target.value;j(ne),ne.startsWith("/")&&Xt(0),Vt(ne.startsWith("/")&&fa.length>0)},onKeyDown:ps,onPaste:Ar,onCompositionStart:()=>z(!0),onCompositionEnd:()=>z(!1),onFocus:()=>ee(!0),onBlur:()=>ee(!1),placeholder:bs,disabled:wt,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:`${ea.top}px`,paddingBottom:`${ea.bottom}px`,paddingLeft:`${Wu}px`,paddingRight:0,border:"none",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none",caretColor:S.trim()||$?"inherit":"transparent"}})]}),u.jsxs("div",{className:"flex items-center justify-end gap-1 md:gap-2 flex-shrink-0",children:[u.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[f&&!Yt&&u.jsx("div",{className:"hidden md:block h-8 w-8 shrink-0","aria-hidden":"true"}),Yt&&u.jsx("button",{type:"button",onClick:C=>{C.preventDefault(),Ia||N(!q)},disabled:Ia,onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${q||sn.length>0?"bg-gray-200 text-[#353740] dark:bg-[#565869] dark:text-[#ececf1]":Ia?"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:sl?on&&mi&&Le.maxFilesPerConversation!==null?`Maximum of ${Le.maxFilesPerConversation} files reached in this conversation. Start a new chat to upload more.`:on&&fs&&Le.maxTotalFiles!==null?`Workspace limit of ${Le.maxTotalFiles} total files reached. Remove files from other conversations first.`:wt?"Files are uploading. Please wait...":sn.length>0?`${sn.length} file(s) attached`:"Attach files":"File upload not supported by this adapter","aria-label":"Attach files",children:Ia&&Ce?u.jsx(ua,{className:"h-4 w-4"}):u.jsx(Kx,{className:"h-4 w-4"})}),S.length>0&&u.jsx("div",{className:"hidden md:block px-2 text-xs text-gray-500 dark:text-[#bfc2cd] md:min-w-[72px] md:text-right",children:u.jsxs("span",{className:S.length>=Le.maxMessageLength?"text-red-600 font-semibold":"",children:[S.length,"/",Le.maxMessageLength]})})]}),u.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[u.jsx(_g,{availableModels:v,defaultModel:b,selectedModel:w,onSelect:C=>k==null?void 0:k(C)}),(Dn||an)&&u.jsxs(u.Fragment,{children:[Dn&&u.jsx("button",{type:"button",onClick:Yl,className:`hidden md:flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${Fe.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:Fe.voiceEnabled?"Voice responses enabled - Click to disable":"Enable voice responses (text-to-speech)","aria-label":Fe.voiceEnabled?"Disable voice responses":"Enable voice responses",children:Fe.voiceEnabled?u.jsx(Oo,{className:"h-5 w-5"}):u.jsx(ob,{className:"h-5 w-5"})}),xn&&u.jsx("button",{type:"button",onClick:gs,disabled:wt,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),className:`hidden md:flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${Aa?"!flex bg-red-100 text-red-600 dark:bg-red-900/40 dark:text-red-300":wt?"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:wt?"Files are uploading. Please wait...":Aa?"Stop recording":"Start voice input","aria-label":Aa?"Stop recording":"Start voice input",children:Aa||wt&&oe?u.jsx(Ix,{className:"h-5 w-5"}):u.jsx(Gx,{className:"h-5 w-5"})})]}),p&&u.jsx("button",{type:"button",onClick:()=>R(!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:"About this agent","aria-label":"About this agent",children:u.jsx(cp,{className:"h-5 w-5"})}),(Fl||sa)&&u.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center",children:u.jsx(zo,{className:"h-4 w-4 animate-spin text-gray-500 dark:text-[#bfc2cd]"})}),Te?u.jsx("button",{type:"button",onClick:C=>{C.preventDefault(),bt()},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:"Stop generating","aria-label":"Stop generating",children:u.jsx(lb,{className:"h-4 w-4 md:h-3 md:w-3 fill-current"})}):u.jsx("button",{type:"submit",disabled:!il||wt||_,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 ${il&&!wt&&!_?"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:"Send message","aria-label":"Send message",children:u.jsx(tg,{className:"h-4 w-4"})})]})]})]}),sn.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:sn.map(C=>{const ne=!C.processing_status||C.processing_status==="processing"||C.processing_status==="uploading",Ee=C.processing_status==="failed"||C.processing_status==="error";return u.jsxs("div",{className:`flex items-center gap-2 rounded-md border px-2 py-1 text-xs ${Ee?"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:Ee?C.error_message||"File processing failed":void 0,children:[ne&&u.jsx(zo,{className:"h-3 w-3 animate-spin text-blue-500 dark:text-blue-400 flex-shrink-0"}),Ee&&u.jsx(Mo,{className:"h-3 w-3 text-red-500 dark:text-red-400 flex-shrink-0"}),u.jsx("span",{className:`truncate max-w-[150px] ${Ee?"text-red-700 dark:text-red-300":"text-[#353740] dark:text-[#ececf1]"}`,children:C.filename}),ne&&u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:C.processing_status==="uploading"?"Uploading...":"Processing..."}),Ee&&u.jsx("span",{className:"text-xs text-red-500 dark:text-red-400",children:"Failed"}),u.jsx("button",{type:"button",onClick:()=>{Ee?(_e&&it(_e,C.file_id),U($e=>$e.filter(rt=>rt.file_id!==C.file_id))):hi(C)},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:Ee?"Dismiss":"Remove file",children:u.jsx(ua,{className:"h-4 w-4 md:h-3 md:w-3"})})]},C.file_id)})}),Yt&&(sl||yr)&&u.jsxs("div",{ref:we,className:`rounded-lg border border-gray-200/80 bg-white p-2.5 dark:border-[#3c3f4a] dark:bg-[#2a2b32] transition-all duration-200 ${!q&&!sa&&ae.size===0&&!yr?"hidden":""}`,children:[q&&u.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[u.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] uppercase tracking-wider",children:"Attach files"}),u.jsx("button",{type:"button",onClick:()=>N(!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:"Close",children:u.jsx(ua,{className:"h-3.5 w-3.5"})})]}),(sa||ae.size>0)&&!q&&ae.size===0&&u.jsx("div",{className:"mb-2 px-1",children:u.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] uppercase tracking-wider",children:"Uploading files"})}),ae.size>0&&u.jsx("div",{className:"mb-2 space-y-1.5",children:Array.from(ae.entries()).map(([C,ne])=>u.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:[u.jsx("div",{className:"absolute inset-0 bg-blue-50 dark:bg-blue-900/15 transition-all duration-500 ease-out rounded-lg",style:{width:`${ne.progress??0}%`}}),u.jsxs("div",{className:"relative flex items-center gap-3 w-full min-w-0",children:[u.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:u.jsx(zo,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 animate-spin"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-sm font-medium text-[#353740] dark:text-[#ececf1] truncate",children:ne.filename}),u.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[u.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-[#3c3f4a] rounded-full h-1",children:u.jsx("div",{className:"bg-blue-500 dark:bg-blue-400 h-1 rounded-full transition-all duration-500 ease-out",style:{width:`${ne.progress??0}%`}})}),u.jsxs("span",{className:"text-[11px] tabular-nums text-gray-400 dark:text-[#8e8ea0] shrink-0",children:[Math.round(ne.progress??0),"%"]})]})]}),u.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#bfc2cd] shrink-0",children:ne.status==="uploading"?"Uploading":ne.status==="processing"?"Processing":ne.status==="completed"?"Done":"Pending"})]})]},C))}),u.jsx("div",{className:`${q||sa?"block max-h-[40vh] overflow-y-auto":"hidden"}`,"aria-hidden":!(q||sa),children:u.jsx(Mv,{conversationId:_e,onFilesSelected:kr,onUploadError:C=>{He("File upload error:",C),pe(C)},onUploadingChange:ie,onUploadSuccess:_r,maxFiles:Le.maxFilesPerConversation,disabled:Ia})})]}),u.jsx("div",{className:"h-3 md:h-1",children:xn&&Aa&&u.jsxs("span",{className:"flex items-center gap-2 text-sm md:text-xs text-gray-500 dark:text-[#bfc2cd]",children:[u.jsx("span",{className:"h-2.5 w-2.5 md:h-2 md:w-2 animate-pulse rounded-full bg-red-500"}),"Listening..."]})})]}),Oe&&u.jsx("div",{ref:se,className:"w-full pt-1",children:u.jsx(kg,{skills:fa,isLoading:Bl,selectedSkill:Ft,activeSkillName:ma==null?void 0:ma.name,query:nl,onActiveSkillChange:C=>{const ne=ja.findIndex(Ee=>Ee.name===C.name);ne>=0&&Xt(ne)},onSelect:ra,onClose:us})}),os&&u.jsx("div",{ref:W,role:"listbox","aria-label":"Autocomplete suggestions",className:"w-full pt-1",children:Ca.map((C,ne)=>{const Ee=ne===re;return u.jsx("button",{type:"button",role:"option","aria-selected":Ee,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 ${Ee?"bg-gray-100 dark:bg-[#2d2f39]":"hover:bg-gray-50 dark:hover:bg-[#2d2f39]/60"}`,onClick:()=>Sn(C.text),onMouseEnter:()=>qe(ne),children:Ko(C.text)},ne)})}),u.jsx(qo,{isOpen:F.isOpen,onClose:aa,onConfirm:Un,title:"Remove File",message:`Are you sure you want to remove "${F.filename}"? This will delete the file from both the server and this conversation. This action cannot be undone.`,confirmText:"Remove",cancelText:"Cancel",type:"danger",isLoading:F.isDeleting})]})]})}),Y&&p&&typeof document<"u"&&Yo.createPortal(u.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:u.jsxs("div",{ref:de,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:[u.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/20 flex items-center justify-center",children:u.jsx(cp,{className:"w-5 h-5 text-blue-500"})}),u.jsx("h2",{id:"agent-info-title",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"About this agent"})]}),u.jsx("button",{type:"button",onClick:()=>R(!1),className:"p-2 hover:bg-gray-100 dark:hover:bg-[#25262f] rounded-lg transition-colors","aria-label":"Close",children:u.jsx(ua,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.jsx("div",{className:"p-6",children:u.jsx(el,{content:p,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 ${Bt}`,syntaxTheme:xt})}),u.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:u.jsx("button",{type:"button",onClick:()=>R(!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:"Got it"})})]})}),document.body)]})}function $p({adapter:r,onSelect:l}){var h;const i=(h=r.description)==null?void 0:h.trim(),{isDark:c}=ss(),d=c?"dark":"light",f=()=>l(r);return u.jsxs("div",{tabIndex:0,role:"button","data-agent-card":"true",onClick:f,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),f())},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:[u.jsx("div",{className:"relative",children:u.jsx("div",{className:"min-w-0",children:u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"truncate text-[15px] font-semibold text-sky-900 dark:text-sky-300 md:text-base",children:r.name}),i?u.jsx("div",{className:"mt-1 text-sm leading-5 text-slate-600 dark:text-slate-300",children:u.jsx(el,{content:i,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:d})}):u.jsx("p",{className:"mt-1 text-sm leading-5 text-slate-500 dark:text-slate-400",children:"Configure this agent to see its capabilities."})]}),u.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),f()},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":`Start conversation with ${r.name}`,children:u.jsx(op,{className:"h-4 w-4","aria-hidden":"true"})})]})})}),u.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:u.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),f()},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":`Start conversation with ${r.name}`,children:u.jsx(op,{className:"h-4 w-4","aria-hidden":"true"})})})]})}const dr=r=>{if(typeof r!="string")return;const l=r.trim();return l.length>0?l:void 0},Bv=r=>{if(!r||typeof r!="object")return null;const l=r,i=dr(l.name);if(!i)return null;const c=dr(l.id);if(!c)return console.warn(`[middlewareConfig] Adapter "${i}" is missing a required 'id' field — skipping.`),null;const d=dr(l.apiUrl),f=dr(l.model),h=dr(l.inputPlaceholder),p=typeof l.notes=="string"?l.notes.trim():void 0;let x=dr(l.description)||dr(l.summary);if(!x&&typeof p=="string"){const b=p.split(/\r?\n/).find(w=>w.trim().length>0);x=b?b.trim():void 0}const v={id:c,name:i};return d&&(v.apiUrl=d),x&&(v.description=x),p&&(v.notes=p),f&&(v.model=f),h&&(v.inputPlaceholder=h),v},Cg=r=>Array.isArray(r)?r.map(Bv).filter(l=>l!==null):[];let Rl=null,ed=0;const Hv=3e4;function Fv(){if(typeof window<"u"){const r=window.ORBIT_CHAT_CONFIG;if(r!=null&&r.adapters&&Array.isArray(r.adapters)){le("Loading adapters from window.ORBIT_CHAT_CONFIG");const l=Cg(r.adapters);if(l.length===0)return null;const i=`{
|
|
337
|
+
`,"aria-label":p?"File upload disabled":"Upload files",children:[u.jsx("input",{ref:k,type:"file",multiple:!0,onChange:oe,className:"hidden",disabled:p,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"}),u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg transition-colors duration-200 ${x?"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:u.jsx(ib,{className:`h-5 w-5 transition-colors duration-200 ${x?"text-blue-600 dark:text-blue-400":"text-gray-400 dark:text-[#8e8ea0] group-hover:text-blue-500 dark:group-hover:text-blue-400"}`})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:`text-sm font-medium transition-colors duration-200 ${x?"text-blue-700 dark:text-blue-300":"text-[#353740] dark:text-[#ececf1]"}`,children:p?"File upload disabled":x?"Drop files here":"Drop files or click to browse"}),u.jsxs("p",{className:"text-xs text-gray-400 dark:text-[#8e8ea0] mt-0.5",children:["PDF, DOCX, TXT, CSV, code files, images, audio · max ",h," files"]})]})]})]}),ce.length>0&&u.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:[u.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] px-1",children:"Other conversations"}),ce.map(({conversationId:F,uploads:me})=>u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("div",{className:"text-[11px] font-medium text-gray-400 dark:text-[#6b6f7a] px-1",children:P.get(F)||"Conversation"}),me.map(({key:ue,progress:de})=>xe(de,ue))]},F))]})]})}const Up={"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"},jo=4,No=3,zv=0,Dv=0,Wu=2;function Lv(s){if(!s||typeof s!="object")return null;const l=s,i=["supportsAutocomplete","isAutocompleteSupported","autocompleteSupported"];for(const f of i)if(typeof l[f]=="boolean")return l[f];const c=["capabilities","features"],d=["autocomplete","supportsAutocomplete","autocomplete_supported"];for(const f of c){const h=l[f];if(!h||typeof h!="object")continue;const p=h;for(const x of d)if(typeof p[x]=="boolean")return p[x]}return null}function Rv(s){if(!s)return"bin";if(Up[s])return Up[s];const l=s.split("/");return l.length===2&&l[1]?l[1]:"bin"}function Uv(s){return s.replace(/[^a-zA-Z0-9._-]/g,"_").replace(/_+/g,"_")||"pasted-file"}function Ov(s){const l=s.lastIndexOf(".");return l===-1||l===s.length-1?null:s.slice(l+1).toLowerCase()}function $v(s){const l=s.lastIndexOf(".");return l===-1?s:s.slice(0,l)}function qv(s,l){const i=Date.now(),c=s.name&&s.name.trim().length>0?s.name.trim():"pasted-file",d=Uv($v(c)),h=Ov(c)||Rv(s.type),p=`${d}-${i}-${l}.${h}`;return new File([s],p,{type:s.type||"application/octet-stream"})}function Op({onSend:s,disabled:l=!1,placeholder:i=ig(),autoFocusEnabled:c=!0,suppressMobileAutoFocus:d=!1,isCentered:f=!1,maxWidthClass:h="max-w-5xl",adapterNotes:p,skillState:x,availableModels:v=[],defaultModel:b=null,selectedModel:w=null,onSelectModel:k}){var pi;const[S,j]=g.useState(""),[_,z]=g.useState(!1),[$,ee]=g.useState(!1),[Y,R]=g.useState(!1),[q,N]=g.useState(!1),[X,U]=g.useState([]),[Q,I]=g.useState({}),[ae,fe]=g.useState(new Map),[Ce,te]=g.useState(!1),[oe,E]=g.useState(!1),[V,H]=g.useState(null),[P,ce]=g.useState(null),[xe,pe]=g.useState(null),[F,me]=g.useState({isOpen:!1,fileId:"",filename:"",isDeleting:!1}),ue=g.useRef(null),de=g.useRef(null),we=g.useRef(null),W=g.useRef(null),re=g.useRef(null),be=g.useRef(new Set),ke=g.useRef(""),ge=g.useRef(!1),ze=g.useRef(0),Ue=g.useRef(null),{settings:Fe,updateSettings:je}=Go(),{theme:Xe,isDark:et}=rr(),Bt=Xe.mode==="dark"?"dark":Xe.mode==="light"?"light":"",xt=et?"dark":"light";ci(de,{enabled:Y,onEscape:()=>R(!1)});const ie=g.useCallback((C,ne)=>{C&&I(Ee=>{if(Ee[C]===ne)return Ee;const $e={...Ee};return ne?$e[C]=!0:delete $e[C],$e})},[]),[Ne,Tt]=g.useState(0),[Oe,Vt]=g.useState(!1),[da,Xt]=g.useState(0),[ea,pn]=g.useState(()=>({top:jo+No,bottom:Math.max(jo-No,0)})),[en,ta]=g.useState(null),gn=ir(),At=va()&&!gn,gt=wa(C=>C.showLoginPrompt),{createConversation:Ht,currentConversationId:_e,conversations:Sa,isLoading:Te,syncConversationFiles:Qe,stopStreaming:bt,removeFileFromConversation:it}=Ve(),Ae=Sa.find(C=>C.id===_e),la=Ae?Ae.messages.filter(C=>!(C.role==="assistant"&&C.isStreaming)).length:0,Mn=Sa.reduce((C,ne)=>C+ne.messages.filter(Ee=>!(Ee.role==="assistant"&&Ee.isStreaming)).length,0),ka=!!Ae&&Le.maxMessagesPerConversation!==null&&la>=Le.maxMessagesPerConversation,tl=Le.maxTotalMessages!==null&&Mn>=Le.maxTotalMessages,$l=g.useCallback(()=>{Tt(C=>C+1)},[]),_a=ny(),zn=ly(),{isListening:Aa,isSupported:al,startListening:fs,stopListening:ql,error:tn}=Sv(C=>{j(ne=>{const Ee=ne.length>0&&!/\s$/.test(ne)?" ":"",$e=(ne+Ee+C).slice(0,Le.maxMessageLength);return ke.current=$e,$e})},$l,{silenceTimeoutMs:_a,language:zn||void 0}),Dn=ey(),an=ty(),xn=an&&al,Yt=Wb(),Et=cg(),Ct=Lv(Ae==null?void 0:Ae.adapterInfo),{skills:fa,isLoading:Bl,selectedSkill:Ft,selectSkill:ms,clearSkill:bn}=x,yn=(Ae==null?void 0:Ae.adapterName)||null,{suggestions:Ca,selectedIndex:se,setSelectedIndex:qe,selectNext:he,selectPrevious:tt,clearSuggestions:Ye,focusInputAfterSelection:nn,suppressUntilQueryChange:Ln}=Av(S,{enabled:Et&&!Aa,apiUrl:Ae==null?void 0:Ae.apiUrl,adapterName:yn,sessionId:Ae==null?void 0:Ae.sessionId,adapterSupportsAutocomplete:Ct,skill:(Ft==null?void 0:Ft.name)||null,inputRef:ue}),ln=Ca.length>0,Rn=!Aa,or=Rn&&ln&&!Oe,nl=S.startsWith("/")?S.slice(1):"",hs=nl.toLowerCase().replace(/-/g," "),ja=hs?fa.filter(C=>C.name.replace(/-/g," ").toLowerCase().includes(hs)||C.description.toLowerCase().includes(hs)):fa,ps=ja.length>0?Math.min(da,ja.length-1):0,ma=ja[ps]??null,Na=(ma==null?void 0:ma.name.replace(/-/g," "))??"",ha=Oe&&ma&&S.startsWith("/")&&Na.toLowerCase().startsWith(nl.toLowerCase())&&Na.length>nl.length?Na.slice(nl.length):null,fi=se>=0?se:0,Hl=ln?Ca[fi]:null,gs=g.useMemo(()=>{if(!Hl)return null;const C=Hl.text||"";if(!S)return C;const ne=S;return C.toLowerCase().startsWith(ne.toLowerCase())&&C.length>ne.length?C.slice(ne.length):null},[Hl,S]),xs=ha??gs,bs=S.trim().length===0&&!xs,Ko=g.useCallback(C=>{if(!S)return u.jsx("span",{className:"line-clamp-1 text-current",children:C});if(!C.toLowerCase().startsWith(S.toLowerCase()))return u.jsx("span",{className:"line-clamp-1 text-current",children:C});const ne=C.slice(0,S.length),Ee=C.slice(S.length);return u.jsxs("span",{className:"line-clamp-1",children:[u.jsx("span",{className:"text-gray-500 dark:text-[#8e8ea0]",children:ne}),u.jsx("span",{className:"font-semibold text-[#353740] dark:text-[#ececf1]",children:Ee})]})},[S]),sa=g.useCallback(C=>{var ne;ms(C),Vt(!1),j(""),Ye(),Xt(0),(ne=ue.current)==null||ne.focus()},[Ye,ms]),cr=g.useCallback(()=>{var C;j("/"),Vt(!0),Xt(0),(C=ue.current)==null||C.focus()},[]),ur=g.useCallback(()=>{var C;Vt(!1),j(""),Xt(0),(C=ue.current)==null||C.focus()},[]),sn=g.useCallback(()=>{const C=ue.current;if(!C||typeof window>"u")return;const ne=Ma=>{const Cs=Ma+No,js=Math.max(Ma-No,0);C.style.paddingTop=`${Cs}px`,C.style.paddingBottom=`${js}px`,pn({top:Cs,bottom:js})},Ee=window.getComputedStyle(C),$e=parseFloat(Ee.lineHeight||"0");if(!Number.isNaN($e)&&$e>0?ta(Ma=>Ma===$e?Ma:$e):ta(Ma=>Ma===null?Ma:null),!$e||Number.isNaN($e)){ne(jo);return}const st=C.scrollHeight,Qt=C.clientHeight;if(st>$e+2){ne(jo);return}const at=Math.max(Qt-$e,0),cn=Math.max(at/2,0);ne(cn)},[]),ll=()=>{const C=ue.current;return C?C.selectionStart===C.selectionEnd&&C.selectionStart===S.length:!1},dr=(Ae==null?void 0:Ae.attachedFiles)||[],rn=_e?dr:X,sl=Sa.reduce((C,ne)=>{var Ee;return C+(((Ee=ne.attachedFiles)==null?void 0:Ee.length)||0)},0),mi=Le.maxFilesPerConversation!==null&&Le.maxFilesPerConversation>0&&dr.length>=Le.maxFilesPerConversation,fr=Le.maxTotalFiles!==null&&sl>=Le.maxTotalFiles,rl=((pi=Ae==null?void 0:Ae.adapterInfo)==null?void 0:pi.isFileSupported)??!1,Fl=rn.some(C=>C.processing_status?C.processing_status!=="completed"&&C.processing_status!=="error"&&C.processing_status!=="failed":!0),ra=_e?!!Q[_e]:!1,ys=Object.values(Q).some(Boolean),il=S.trim().length>0,Fa=ka||tl,wt=l||Fl||ra||Fa,vs=Yt&&rl,on=mi||fr,Ia=!vs||wt||on;g.useLayoutEffect(()=>{if(ue.current){const C=ue.current,ne=120;C.style.height="auto";const Ee=C.scrollHeight;C.style.height=`${Math.min(Ee,ne)}px`,C.style.overflowY=Ee>ne?"auto":"hidden",sn()}},[S,sn]),g.useEffect(()=>{if(typeof window>"u"||typeof ResizeObserver>"u")return;const C=ue.current;if(!C)return;const ne=new ResizeObserver(()=>{sn()});return ne.observe(C),()=>{ne.disconnect()}},[sn]);const mr=()=>{const C=document.activeElement;return C&&C.tagName==="TEXTAREA"},ol=g.useCallback(()=>!d||typeof window>"u"?!1:window.matchMedia("(max-width: 767px)").matches,[d]);g.useEffect(()=>{ol()||c&&!wt&&ue.current&&!mr()&&ue.current.focus()},[c,wt,d,ol]);const ws=g.useRef(Te);g.useEffect(()=>{if(ol()){ws.current=Te;return}c&&ws.current&&!Te&&!wt&&ue.current&&setTimeout(()=>{ue.current&&!mr()&&ue.current.focus()},100),ws.current=Te},[c,Te,wt,d,ol]),g.useEffect(()=>{if(!xn||(Ne>ze.current&&(ge.current=!0,ze.current=Ne),!ge.current||Ne===0))return;const C=ke.current.trim(),ne=Ve.getState();if(le("[MessageInput] Auto-send check after voice completion:",{hasMessage:!!C,isInputDisabled:wt,isComposing:_,isLoading:ne.isLoading}),ge.current=!1,!C)return;if(wt||_){le("[MessageInput] Auto-send skipped because input is currently disabled or composing");return}const Ee=ne.conversations.find(ut=>ut.id===ne.currentConversationId),st=((Ee==null?void 0:Ee.attachedFiles)||[]).map(ut=>ut.file_id),Qt=Ft==null?void 0:Ft.name;le("[MessageInput] Auto-sending voice message immediately:",C),s(C,st.length>0?st:void 0,void 0,Qt),Qt&&bn(),setTimeout(()=>{Vt(!1)},0),Ye(),setTimeout(()=>{j("")},0),ke.current="",ue.current&&(ue.current.style.height="auto",ue.current.style.overflowY="hidden",sn())},[xn,Ne,wt,_,s,Ft,bn,sn,Ye]),g.useEffect(()=>{ra&&q&&setTimeout(()=>{N(!1)},0)},[ra,q]),g.useEffect(()=>{!ra&&rn.length},[ra,q,rn.length]);const vn=g.useCallback((C,ne)=>{setTimeout(()=>{let Ee=Ve.getState(),$e=ne||Ee.currentConversationId;if($e||($e=Ht(),Ee=Ve.getState(),$e=Ee.currentConversationId||$e),!$e){He("[MessageInput] Unable to sync files: conversation ID missing");return}const st=new Set(C.map(ut=>ut.file_id)),Qt=[];be.current.forEach((ut,at)=>{const[,...cn]=at.split("-"),Ma=cn.join("-");st.has(Ma)||Qt.push(at)}),Qt.forEach(ut=>be.current.delete(ut)),C.forEach(ut=>{const at=`${$e}-${ut.file_id}`;be.current.has(at)||(be.current.add(at),le(`[MessageInput] Adding file ${ut.file_id} to conversation ${$e}`),Ee.addFileToConversation($e,ut))})},0)},[Ht]);g.useEffect(()=>{if(_e!==Ue.current)if(Ue.current=_e||null,_e&&Ae){const C=Ae.attachedFiles||[];setTimeout(()=>{U(C.map(ne=>({...ne})))},0)}else setTimeout(()=>{U([])},0)},[_e,Ae]),g.useEffect(()=>{if(_e&&Ae){const C=Ae.attachedFiles||[];C.length>0?setTimeout(()=>{U(ne=>{const Ee=new Set(ne.map(st=>st.file_id)),$e=C.filter(st=>!Ee.has(st.file_id));return $e.length>0?(le(`[MessageInput] Syncing ${$e.length} missing files from conversation to UI`),[...ne,...$e]):ne})},0):C.length===0&&X.length>0&&setTimeout(()=>{U([])},0)}},[_e,Ae,Sa,X.length]);const Ta=g.useRef(null),Il=g.useRef(""),wn=(Ae==null?void 0:Ae.attachedFiles)||[],Ea=wn.length>0?`${wn.length}:${wn.map(C=>C.file_id).join("|")}`:"",Ss=wn.some(C=>!C.processing_status||C.processing_status==="processing"||C.processing_status==="uploading");g.useEffect(()=>{if(!_e||!(Ae!=null&&Ae.adapterName))return;const C=Ea!=="";if(C&&(Ta.current!==_e||Il.current!==Ea)?(le(`[MessageInput] Syncing files for conversation ${_e}...`),Ta.current=_e,Il.current=Ea,Qe(_e).catch($e=>{He("[MessageInput] Failed to sync conversation files:",$e)})):C||(Ta.current=_e,Il.current=""),!Ss)return;le("[MessageInput] Files still processing, starting poll...");const Ee=setInterval(async()=>{const st=Ve.getState().conversations.find(at=>at.id===_e);if(!st){clearInterval(Ee);return}if((st.attachedFiles||[]).filter(at=>!at.processing_status||at.processing_status==="processing"||at.processing_status==="uploading").length===0){le("[MessageInput] All files completed processing, stopping poll"),clearInterval(Ee);return}try{await Qe(_e)}catch(at){He("[MessageInput] Failed to poll file status:",at)}},3e3);return()=>{clearInterval(Ee)}},[_e,Ae==null?void 0:Ae.adapterName,Ea,Ss,Qe]),g.useEffect(()=>{setTimeout(()=>{I(C=>{const ne=new Set(Sa.map(st=>st.id));let Ee=!1;const $e={...C};return Object.keys($e).forEach(st=>{ne.has(st)||(delete $e[st],Ee=!0)}),Ee?$e:C})},0)},[Sa]);const Gl=C=>{if(C.preventDefault(),il&&!wt&&!_){Aa&&ql();const Ee=((Ae==null?void 0:Ae.attachedFiles)||[]).map(st=>st.file_id),$e=Ft==null?void 0:Ft.name;s(S.trim(),Ee.length>0?Ee:void 0,void 0,$e),$e&&bn(),Vt(!1),si("messageSent",Fe.soundEnabled),j(""),ke.current="",U([]),N(!1),ue.current&&(ue.current.style.height="auto",ue.current.style.overflowY="hidden",sn())}},Vl=g.useCallback(C=>{if(!C||C.length===0)return;const ne=C.length===1?`File "${C[0].filename}" uploaded successfully`:`${C.length} files uploaded successfully`;si("success",Fe.soundEnabled),ce(ne),setTimeout(()=>{ce(null)},6e3)},[Fe.soundEnabled]),ks=g.useCallback((C,ne)=>{le(`[MessageInput] handleFilesSelected called with ${ne.length} files for conversation ${C}:`,ne),C&&(C===_e&&U(ne),vn(ne,C))},[_e,vn]),_s=g.useCallback((C,ne)=>{C===_e&&Vl(ne)},[_e,Vl]),hi=g.useCallback(C=>{me({isOpen:!0,fileId:C.file_id,filename:C.filename,isDeleting:!1})},[]),aa=g.useCallback(()=>{me(C=>C.isDeleting?C:{isOpen:!1,fileId:"",filename:"",isDeleting:!1})},[]),Un=g.useCallback(async()=>{if(!(!_e||!F.fileId)){me(C=>({...C,isDeleting:!0}));try{await it(_e,F.fileId),U(C=>C.filter(ne=>ne.file_id!==F.fileId)),me({isOpen:!1,fileId:"",filename:"",isDeleting:!1})}catch(C){const ne=C instanceof Error?C.message:"Failed to remove file";He("[MessageInput] Failed to remove file:",C),pe(ne),me({isOpen:!1,fileId:"",filename:"",isDeleting:!1})}}},[_e,F.fileId,it]),Xl=g.useCallback(C=>C.replace(/\s+/g," ").trim(),[]),Sn=g.useCallback(C=>{const ne=Xl(C);j(ne),Ye(),Ln(ne),nn(ne)},[Ye,nn,Xl,Ln]),hr=g.useCallback(C=>{if(C<0)return;const ne=Ca[C]||Ca[0];ne&&Sn(ne.text)},[Ca,Sn]),pr=C=>{if(Oe){if(C.key==="ArrowDown"){C.preventDefault(),Xt(ne=>ja.length===0?0:(ne+1)%ja.length);return}if(C.key==="ArrowUp"){C.preventDefault(),Xt(ne=>ja.length===0?0:(ne-1+ja.length)%ja.length);return}if(C.key==="Home"){C.preventDefault(),Xt(0);return}if(C.key==="End"){C.preventDefault(),Xt(Math.max(ja.length-1,0));return}if((C.key==="Enter"&&!C.shiftKey||C.key==="Tab")&&ma){C.preventDefault(),sa(ma);return}if(C.key==="Escape"){C.preventDefault(),ur();return}}if(ln&&Rn){if(C.key==="ArrowDown"){C.preventDefault(),he();return}if(C.key==="ArrowUp"){C.preventDefault(),tt();return}if(C.key==="Tab"){C.preventDefault();const ne=se>=0?se:0;hr(ne);return}if(C.key==="ArrowRight"&&ll()){if(gs&&Hl){C.preventDefault(),Sn(Hl.text);return}if(se>=0){C.preventDefault(),hr(se);return}}if(C.key==="Enter"&&se>=0){C.preventDefault(),hr(se);return}if(C.key==="Escape"){C.preventDefault(),Ye();return}}C.key==="Enter"&&!C.shiftKey&&!_&&(C.preventDefault(),Gl(C))},gr=()=>{Aa?ql():(Ye(),fs())},Yl=()=>{const C=!Fe.voiceEnabled;je({voiceEnabled:C}),C&&Ul.enableAudio()},As=g.useCallback(async C=>{if(!Yt||!$||!rl||wt)return;const ne=C.clipboardData;if(!ne||!ne.items)return;const $e=Array.from(ne.items).filter(ut=>ut.kind==="file");if($e.length===0)return;const st=[];if($e.forEach((ut,at)=>{const cn=ut.getAsFile();cn&&st.push(qv(cn,at))}),st.length===0)return;C.preventDefault(),H(null),ce(null);let Qt=null;try{const ut=Ve.getState(),at=ut.conversations.find(ia=>ia.id===ut.currentConversationId);if(((at==null?void 0:at.attachedFiles)||[]).length+st.length>Le.maxFilesPerConversation)throw At&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${Le.maxFilesPerConversation} files per conversation. Sign in to upload more files.`),new Error(`Maximum ${Le.maxFilesPerConversation} files allowed per conversation. Please remove some files first.`);if(Le.maxTotalFiles!==null&&ut.conversations.reduce((Ga,un)=>{var Zt;return Ga+(((Zt=un.attachedFiles)==null?void 0:Zt.length)||0)},0)+st.length>Le.maxTotalFiles)throw At&&wa.getState().openLoginPrompt(`You've reached the guest limit of ${Le.maxTotalFiles} total files. Sign in to upload more files.`),new Error(`Maximum ${Le.maxTotalFiles} total files allowed across all conversations. Please remove some files from other conversations first.`);if(!at)throw new Error("Conversation not found. Please select a conversation first.");if(!at.adapterName)throw new Error("Adapter not configured for this conversation. Please select an adapter first.");const Cs=Ha(at.apiUrl),js=at.adapterName;Qt=at.id,ie(Qt,!0);const cl=[],gi=[];for(let ia=0;ia<st.length;ia++){const Ga=st[ia],un=Ga.name||`Clipboard file ${ia+1}`,Zt=`${un}-${Date.now()}-${ia}`;fe(za=>{const Va=new Map(za);return Va.set(Zt,{filename:un,progress:0,status:"uploading"}),Va});const Po=za=>{fe(Va=>{const It=new Map(Va),Ql=It.get(Zt);return Ql&&It.set(Zt,{...Ql,filename:un,progress:za.progress,status:za.status,fileId:za.fileId}),It})},Wo=()=>new Promise(za=>{fe(Va=>{const It=new Map(Va),Ql=It.get(Zt);return Ql&&It.set(Zt,{...Ql,progress:100,status:"completed"}),It}),setTimeout(()=>{fe(Va=>{const It=new Map(Va);return It.delete(Zt),It}),za()},2500)});le(`[MessageInput] Pasting file: ${Ga.name}, type: ${Ga.type||"unknown"}, size: ${Ga.size}`);const ec=await ui.uploadFile(Ga,za=>{le(`[MessageInput] Paste upload progress for ${Ga.name}: ${za.progress}% - ${za.status}`),Po(za)},void 0,Cs,js);cl.push(ec),gi.push(Wo())}if(cl.length>0){let ia=cl;if(Qt&&Qt===_e){const Ga=new Set(X.map(Zt=>Zt.file_id)),un=cl.filter(Zt=>!Ga.has(Zt.file_id));un.length>0?(U(Zt=>[...Zt,...un]),ia=un):ia=[]}ia.length>0&&vn(ia,Qt),await Promise.all(gi),Vl(cl)}}catch(ut){const at=ut instanceof Error?ut.message:"Failed to paste file";He("[MessageInput] Paste error:",ut),si("error",Fe.soundEnabled),H(at),at.toLowerCase().includes("maximum")&&pe(at),setTimeout(()=>{H(null)},5e3),fe(new Map)}finally{ie(Qt,!1)}},[X,_e,$,rl,At,wt,ie,Fe.soundEnabled,Vl,vn,Yt]),xr=Qb(Ae==null?void 0:Ae.adapterName),br=tl?At?`Guest limit of ${Le.maxTotalMessages} messages reached. Sign in for higher limits.`:`Workspace limit of ${Le.maxTotalMessages} messages reached. Delete or archive old conversations to continue.`:ka?At?`Guest limit of ${Le.maxMessagesPerConversation} messages reached. Sign in for higher limits.`:`This chat hit the ${Le.maxMessagesPerConversation} message limit. Start a new conversation to continue.`:Fl||ra?"Files are uploading, please wait...":xr||(vs?"Message ORBIT or drop files here":i),On=[];tl&&Le.maxTotalMessages!==null&&(At?gt&&On.push(`Guest limit of ${Le.maxTotalMessages} total messages reached. Sign in for higher limits, or delete conversations to start over.`):On.push(`Workspace limit of ${Le.maxTotalMessages} total messages reached. Delete or export older conversations to continue.`)),ka&&Le.maxMessagesPerConversation!==null&&(At?gt&&On.push(`Guest limit of ${Le.maxMessagesPerConversation} messages per conversation reached. Sign in for higher limits, or delete conversations to start over.`):On.push(`This conversation reached the ${Le.maxMessagesPerConversation} message limit. Start a new conversation to keep chatting.`)),xe&&On.push(xe),g.useEffect(()=>{!an||!tn||si("error",Fe.soundEnabled)},[an,Fe.soundEnabled,tn]),g.useEffect(()=>{if(!xe)return;const C=setTimeout(()=>pe(null),5e3);return()=>clearTimeout(C)},[xe]),g.useEffect(()=>{var C;(q||ra||ae.size>0||ys)&&((C=we.current)==null||C.scrollIntoView({behavior:"smooth",block:"nearest"}))},[q,ra,ae.size,ys]),g.useEffect(()=>{var C;or&&((C=W.current)==null||C.scrollIntoView({behavior:"smooth",block:"nearest"}))},[or]),g.useEffect(()=>{var C;Oe&&((C=re.current)==null||C.scrollIntoView({behavior:"smooth",block:"end"}))},[Oe,ja.length]);const yr=h,Jo=f?"flex justify-center":"";return u.jsxs(u.Fragment,{children:[u.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 ${Jo}`,children:u.jsxs("div",{className:`mx-auto w-full ${yr}`,children:[tn&&an&&u.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:[u.jsx(Mo,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-red-500 dark:text-red-400"}),u.jsx("span",{className:"text-sm text-red-700 dark:text-red-300",children:tn})]}),V&&u.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:[u.jsx(Mo,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-red-500 dark:text-red-400"}),u.jsx("span",{className:"text-sm text-red-700 dark:text-red-300",children:V})]}),P&&u.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:[u.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:u.jsx(zx,{className:"h-3.5 w-3.5 text-emerald-600 dark:text-emerald-400"})}),u.jsx("span",{className:"text-sm text-[#353740] dark:text-[#ececf1]",children:P})]}),On.length>0&&u.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:[u.jsx(bd,{className:"h-4 w-4 mt-0.5 flex-shrink-0 text-amber-500 dark:text-amber-400"}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("ul",{className:"list-none space-y-0.5",children:On.map((C,ne)=>u.jsx("li",{className:"text-sm text-amber-800 dark:text-amber-200",children:C},`${C}-${ne}`))}),At&&(Fa||on)&>&&u.jsx("button",{type:"button",onClick:()=>wa.getState().openLoginPrompt("Sign in to unlock higher message limits and more conversations."),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:"Sign in for higher limits"})]})]}),u.jsxs("div",{className:"relative w-full",children:[u.jsxs("form",{onSubmit:Gl,className:"flex w-full flex-col gap-2 md:gap-3",children:[u.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 ${$?"border-gray-400 shadow-md dark:border-[#3a3a3a] dark:shadow-lg":"border-gray-300 dark:border-[#242424]"} bg-gray-50 dark:bg-[#111111]`,children:[Ft&&u.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:[u.jsx(xd,{className:"h-3.5 w-3.5 shrink-0 text-gray-500 dark:text-gray-400","aria-hidden":"true"}),u.jsx("span",{className:"min-w-0 truncate font-medium capitalize",children:Ft.name.replace(/-/g," ")}),u.jsx("button",{type:"button",onClick:()=>{var C;bn(),(C=ue.current)==null||C.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":"Remove skill",children:u.jsx(ua,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),!Ft&&fa.length>0&&S.length===0&&!wt&&u.jsxs("button",{type:"button",onClick:cr,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":"Show available skills (or type a forward slash)",title:"Use a skill",children:[u.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:"/"}),"Skills"]}),u.jsxs("div",{className:"relative flex-1 w-full min-w-0",children:[bs&&br&&u.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(ea.top-zv,0),paddingBottom:ea.bottom,paddingLeft:`${Wu}px`,paddingRight:0,lineHeight:en?`${en}px`:void 0},"aria-hidden":"true",children:br}),xs&&$&&u.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(ea.top-Dv,0),paddingBottom:ea.bottom,paddingLeft:`${Wu}px`,paddingRight:0,lineHeight:en?`${en}px`:void 0},"aria-hidden":"true",children:[u.jsx("span",{className:"invisible",children:S}),u.jsx("span",{children:xs})]}),u.jsx("textarea",{ref:ue,"aria-label":"Message input",value:S,onChange:C=>{const ne=C.target.value;j(ne),ne.startsWith("/")&&Xt(0),Vt(ne.startsWith("/")&&fa.length>0)},onKeyDown:pr,onPaste:As,onCompositionStart:()=>z(!0),onCompositionEnd:()=>z(!1),onFocus:()=>ee(!0),onBlur:()=>ee(!1),placeholder:br,disabled:wt,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:`${ea.top}px`,paddingBottom:`${ea.bottom}px`,paddingLeft:`${Wu}px`,paddingRight:0,border:"none",outline:"none",boxShadow:"none",WebkitAppearance:"none",MozAppearance:"none",appearance:"none",caretColor:S.trim()||$?"inherit":"transparent"}})]}),u.jsxs("div",{className:"flex items-center justify-end gap-1 md:gap-2 flex-shrink-0",children:[u.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[f&&!Yt&&u.jsx("div",{className:"hidden md:block h-8 w-8 shrink-0","aria-hidden":"true"}),Yt&&u.jsx("button",{type:"button",onClick:C=>{C.preventDefault(),Ia||N(!q)},disabled:Ia,onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${q||rn.length>0?"bg-gray-200 text-[#353740] dark:bg-[#565869] dark:text-[#ececf1]":Ia?"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:rl?on&&mi&&Le.maxFilesPerConversation!==null?`Maximum of ${Le.maxFilesPerConversation} files reached in this conversation. Start a new chat to upload more.`:on&&fr&&Le.maxTotalFiles!==null?`Workspace limit of ${Le.maxTotalFiles} total files reached. Remove files from other conversations first.`:wt?"Files are uploading. Please wait...":rn.length>0?`${rn.length} file(s) attached`:"Attach files":"File upload not supported by this adapter","aria-label":"Attach files",children:Ia&&Ce?u.jsx(ua,{className:"h-4 w-4"}):u.jsx(Kx,{className:"h-4 w-4"})}),S.length>0&&u.jsx("div",{className:"hidden md:block px-2 text-xs text-gray-500 dark:text-[#bfc2cd] md:min-w-[72px] md:text-right",children:u.jsxs("span",{className:S.length>=Le.maxMessageLength?"text-red-600 font-semibold":"",children:[S.length,"/",Le.maxMessageLength]})})]}),u.jsxs("div",{className:"flex items-center gap-1 md:gap-2",children:[u.jsx(_g,{availableModels:v,defaultModel:b,selectedModel:w,onSelect:C=>k==null?void 0:k(C)}),(Dn||an)&&u.jsxs(u.Fragment,{children:[Dn&&u.jsx("button",{type:"button",onClick:Yl,className:`hidden md:flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${Fe.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:Fe.voiceEnabled?"Voice responses enabled - Click to disable":"Enable voice responses (text-to-speech)","aria-label":Fe.voiceEnabled?"Disable voice responses":"Enable voice responses",children:Fe.voiceEnabled?u.jsx(Oo,{className:"h-5 w-5"}):u.jsx(ob,{className:"h-5 w-5"})}),xn&&u.jsx("button",{type:"button",onClick:gr,disabled:wt,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),className:`hidden md:flex h-8 w-8 shrink-0 items-center justify-center rounded-full transition-all active:scale-95 ${Aa?"!flex bg-red-100 text-red-600 dark:bg-red-900/40 dark:text-red-300":wt?"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:wt?"Files are uploading. Please wait...":Aa?"Stop recording":"Start voice input","aria-label":Aa?"Stop recording":"Start voice input",children:Aa||wt&&oe?u.jsx(Ix,{className:"h-5 w-5"}):u.jsx(Gx,{className:"h-5 w-5"})})]}),p&&u.jsx("button",{type:"button",onClick:()=>R(!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:"About this agent","aria-label":"About this agent",children:u.jsx(cp,{className:"h-5 w-5"})}),(Fl||ra)&&u.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center",children:u.jsx(zo,{className:"h-4 w-4 animate-spin text-gray-500 dark:text-[#bfc2cd]"})}),Te?u.jsx("button",{type:"button",onClick:C=>{C.preventDefault(),bt()},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:"Stop generating","aria-label":"Stop generating",children:u.jsx(lb,{className:"h-4 w-4 md:h-3 md:w-3 fill-current"})}):u.jsx("button",{type:"submit",disabled:!il||wt||_,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 ${il&&!wt&&!_?"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:"Send message","aria-label":"Send message",children:u.jsx(tg,{className:"h-4 w-4"})})]})]})]}),rn.length>0&&u.jsx("div",{className:"flex flex-wrap gap-2",children:rn.map(C=>{const ne=!C.processing_status||C.processing_status==="processing"||C.processing_status==="uploading",Ee=C.processing_status==="failed"||C.processing_status==="error";return u.jsxs("div",{className:`flex items-center gap-2 rounded-md border px-2 py-1 text-xs ${Ee?"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:Ee?C.error_message||"File processing failed":void 0,children:[ne&&u.jsx(zo,{className:"h-3 w-3 animate-spin text-blue-500 dark:text-blue-400 flex-shrink-0"}),Ee&&u.jsx(Mo,{className:"h-3 w-3 text-red-500 dark:text-red-400 flex-shrink-0"}),u.jsx("span",{className:`truncate max-w-[150px] ${Ee?"text-red-700 dark:text-red-300":"text-[#353740] dark:text-[#ececf1]"}`,children:C.filename}),ne&&u.jsx("span",{className:"text-xs text-gray-500 dark:text-[#bfc2cd]",children:C.processing_status==="uploading"?"Uploading...":"Processing..."}),Ee&&u.jsx("span",{className:"text-xs text-red-500 dark:text-red-400",children:"Failed"}),u.jsx("button",{type:"button",onClick:()=>{Ee?(_e&&it(_e,C.file_id),U($e=>$e.filter(st=>st.file_id!==C.file_id))):hi(C)},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:Ee?"Dismiss":"Remove file",children:u.jsx(ua,{className:"h-4 w-4 md:h-3 md:w-3"})})]},C.file_id)})}),Yt&&(rl||ys)&&u.jsxs("div",{ref:we,className:`rounded-lg border border-gray-200/80 bg-white p-2.5 dark:border-[#3c3f4a] dark:bg-[#2a2b32] transition-all duration-200 ${!q&&!ra&&ae.size===0&&!ys?"hidden":""}`,children:[q&&u.jsxs("div",{className:"mb-2 flex items-center justify-between px-1",children:[u.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] uppercase tracking-wider",children:"Attach files"}),u.jsx("button",{type:"button",onClick:()=>N(!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:"Close",children:u.jsx(ua,{className:"h-3.5 w-3.5"})})]}),(ra||ae.size>0)&&!q&&ae.size===0&&u.jsx("div",{className:"mb-2 px-1",children:u.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#8e8ea0] uppercase tracking-wider",children:"Uploading files"})}),ae.size>0&&u.jsx("div",{className:"mb-2 space-y-1.5",children:Array.from(ae.entries()).map(([C,ne])=>u.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:[u.jsx("div",{className:"absolute inset-0 bg-blue-50 dark:bg-blue-900/15 transition-all duration-500 ease-out rounded-lg",style:{width:`${ne.progress??0}%`}}),u.jsxs("div",{className:"relative flex items-center gap-3 w-full min-w-0",children:[u.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:u.jsx(zo,{className:"h-4 w-4 text-blue-600 dark:text-blue-400 animate-spin"})}),u.jsxs("div",{className:"flex-1 min-w-0",children:[u.jsx("p",{className:"text-sm font-medium text-[#353740] dark:text-[#ececf1] truncate",children:ne.filename}),u.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[u.jsx("div",{className:"flex-1 bg-gray-200 dark:bg-[#3c3f4a] rounded-full h-1",children:u.jsx("div",{className:"bg-blue-500 dark:bg-blue-400 h-1 rounded-full transition-all duration-500 ease-out",style:{width:`${ne.progress??0}%`}})}),u.jsxs("span",{className:"text-[11px] tabular-nums text-gray-400 dark:text-[#8e8ea0] shrink-0",children:[Math.round(ne.progress??0),"%"]})]})]}),u.jsx("span",{className:"text-xs font-medium text-gray-500 dark:text-[#bfc2cd] shrink-0",children:ne.status==="uploading"?"Uploading":ne.status==="processing"?"Processing":ne.status==="completed"?"Done":"Pending"})]})]},C))}),u.jsx("div",{className:`${q||ra?"block max-h-[40vh] overflow-y-auto":"hidden"}`,"aria-hidden":!(q||ra),children:u.jsx(Mv,{conversationId:_e,onFilesSelected:ks,onUploadError:C=>{He("File upload error:",C),pe(C)},onUploadingChange:ie,onUploadSuccess:_s,maxFiles:Le.maxFilesPerConversation,disabled:Ia})})]}),u.jsx("div",{className:"h-3 md:h-1",children:xn&&Aa&&u.jsxs("span",{className:"flex items-center gap-2 text-sm md:text-xs text-gray-500 dark:text-[#bfc2cd]",children:[u.jsx("span",{className:"h-2.5 w-2.5 md:h-2 md:w-2 animate-pulse rounded-full bg-red-500"}),"Listening..."]})})]}),Oe&&u.jsx("div",{ref:re,className:"w-full pt-1",children:u.jsx(kg,{skills:fa,isLoading:Bl,selectedSkill:Ft,activeSkillName:ma==null?void 0:ma.name,query:nl,onActiveSkillChange:C=>{const ne=ja.findIndex(Ee=>Ee.name===C.name);ne>=0&&Xt(ne)},onSelect:sa,onClose:ur})}),or&&u.jsx("div",{ref:W,role:"listbox","aria-label":"Autocomplete suggestions",className:"w-full pt-1",children:Ca.map((C,ne)=>{const Ee=ne===se;return u.jsx("button",{type:"button",role:"option","aria-selected":Ee,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 ${Ee?"bg-gray-100 dark:bg-[#2d2f39]":"hover:bg-gray-50 dark:hover:bg-[#2d2f39]/60"}`,onClick:()=>Sn(C.text),onMouseEnter:()=>qe(ne),children:Ko(C.text)},ne)})}),u.jsx(qo,{isOpen:F.isOpen,onClose:aa,onConfirm:Un,title:"Remove File",message:`Are you sure you want to remove "${F.filename}"? This will delete the file from both the server and this conversation. This action cannot be undone.`,confirmText:"Remove",cancelText:"Cancel",type:"danger",isLoading:F.isDeleting})]})]})}),Y&&p&&typeof document<"u"&&Yo.createPortal(u.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:u.jsxs("div",{ref:de,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:[u.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsx("div",{className:"w-10 h-10 rounded-full bg-blue-100 dark:bg-blue-900/20 flex items-center justify-center",children:u.jsx(cp,{className:"w-5 h-5 text-blue-500"})}),u.jsx("h2",{id:"agent-info-title",className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"About this agent"})]}),u.jsx("button",{type:"button",onClick:()=>R(!1),className:"p-2 hover:bg-gray-100 dark:hover:bg-[#25262f] rounded-lg transition-colors","aria-label":"Close",children:u.jsx(ua,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.jsx("div",{className:"p-6",children:u.jsx(el,{content:p,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 ${Bt}`,syntaxTheme:xt})}),u.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:u.jsx("button",{type:"button",onClick:()=>R(!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:"Got it"})})]})}),document.body)]})}function $p({adapter:s,onSelect:l}){var h;const i=(h=s.description)==null?void 0:h.trim(),{isDark:c}=rr(),d=c?"dark":"light",f=()=>l(s);return u.jsxs("div",{tabIndex:0,role:"button","data-agent-card":"true",onClick:f,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),f())},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:[u.jsx("div",{className:"relative",children:u.jsx("div",{className:"min-w-0",children:u.jsxs("div",{className:"flex items-start gap-3",children:[u.jsxs("div",{className:"min-w-0 flex-1",children:[u.jsx("p",{className:"truncate text-[15px] font-semibold text-sky-900 dark:text-sky-300 md:text-base",children:s.name}),i?u.jsx("div",{className:"mt-1 text-sm leading-5 text-slate-600 dark:text-slate-300",children:u.jsx(el,{content:i,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:d})}):u.jsx("p",{className:"mt-1 text-sm leading-5 text-slate-500 dark:text-slate-400",children:"Configure this agent to see its capabilities."})]}),u.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),f()},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":`Start conversation with ${s.name}`,children:u.jsx(op,{className:"h-4 w-4","aria-hidden":"true"})})]})})}),u.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:u.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),f()},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":`Start conversation with ${s.name}`,children:u.jsx(op,{className:"h-4 w-4","aria-hidden":"true"})})})]})}const ds=s=>{if(typeof s!="string")return;const l=s.trim();return l.length>0?l:void 0},Bv=s=>{if(!s||typeof s!="object")return null;const l=s,i=ds(l.name);if(!i)return null;const c=ds(l.id);if(!c)return console.warn(`[middlewareConfig] Adapter "${i}" is missing a required 'id' field — skipping.`),null;const d=ds(l.apiUrl),f=ds(l.model),h=ds(l.inputPlaceholder),p=typeof l.notes=="string"?l.notes.trim():void 0;let x=ds(l.description)||ds(l.summary);if(!x&&typeof p=="string"){const b=p.split(/\r?\n/).find(w=>w.trim().length>0);x=b?b.trim():void 0}const v={id:c,name:i};return d&&(v.apiUrl=d),x&&(v.description=x),p&&(v.notes=p),f&&(v.model=f),h&&(v.inputPlaceholder=h),v},Cg=s=>Array.isArray(s)?s.map(Bv).filter(l=>l!==null):[];let Rl=null,ed=0;const Hv=3e4;function Fv(){if(typeof window<"u"){const s=window.ORBIT_CHAT_CONFIG;if(s!=null&&s.adapters&&Array.isArray(s.adapters)){le("Loading adapters from window.ORBIT_CHAT_CONFIG");const l=Cg(s.adapters);if(l.length===0)return null;const i=`{
|
|
338
338
|
"simple-chat": "default-key",
|
|
339
339
|
"web-search": "orbit_XfxmYoTZgnp7zoMTKsIBfMBuYwj6U21P",
|
|
340
340
|
"chat-with-files": "multimodal",
|
|
@@ -362,5 +362,5 @@ $$
|
|
|
362
362
|
"award-notices": "award-notices",
|
|
363
363
|
"contract-history": "contract-history",
|
|
364
364
|
"standing-offers": "standing-offers"
|
|
365
|
-
}`;if(!i.trim())return[];try{const c=JSON.parse(i),d=new Set(Object.entries(c).filter(([,f])=>{if(typeof f=="string")return f.trim().length>0;if(f&&typeof f=="object"){const h=f;if(typeof h.apiKey=="string"&&h.apiKey.trim().length>0||typeof h.key=="string"&&h.key.trim().length>0)return!0}return!1}).map(([f])=>f));return l.filter(f=>d.has(f.id))}catch{return[]}}}return null}async function Cd(){if(Rl&&Date.now()-ed<Hv)return Rl;try{const l=await fetch("/api/adapters?refresh=1",{cache:"no-store",headers:{"Cache-Control":"no-cache"}});if(l.ok){const i=await l.json(),c=Cg(i.adapters);if(c.length>0)return Rl=c,ed=Date.now(),le("Fetched adapters from /api/adapters:",Rl),Rl;le("/api/adapters response did not contain valid adapters, trying fallback")}le(`/api/adapters returned ${l.status}, trying fallback`)}catch(l){le("Could not fetch from /api/adapters, trying fallback:",l)}const r=Fv();if(r&&r.length>0)return Rl=r,ed=Date.now(),le("Loaded adapters from config:",Rl),Rl;throw He("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 Iv="h-[96px]";function Gv({onAdapterSelect:r,className:l="",title:i="",subtitle:c="",eyebrow:d=""}){const[f,h]=g.useState([]),[p,x]=g.useState(!0),[v,b]=g.useState(null),w=g.useRef(null),k=g.useRef(null),[S,j]=g.useState(""),[_,z]=g.useState(!1),$=g.useCallback(()=>{const te=w.current;if(!te){z(!1);return}z(te.scrollHeight-te.scrollTop-te.clientHeight>20)},[]),ee=()=>typeof window<"u"&&window.matchMedia("(min-width: 768px)").matches,Y=()=>{var te;return Array.from(((te=w.current)==null?void 0:te.querySelectorAll('[data-agent-card="true"]'))??[])},R=te=>{const E=Y()[te]??null;E&&(E.focus(),E.scrollIntoView({block:"nearest"}))},q=()=>{R(0)},N=()=>{const te=Y();te.length!==0&&R(te.length-1)},X=te=>{if(!p&&!v&&I.length>0&&ee()){if(te.key==="Tab"&&!te.shiftKey){te.preventDefault(),q();return}if(te.key==="ArrowDown"){te.preventDefault(),q();return}te.key==="ArrowUp"&&(te.preventDefault(),N())}},U=te=>{var H;if(!ae||!ee()||te.key!=="ArrowDown"&&te.key!=="ArrowUp")return;const oe=document.activeElement;if(!(oe instanceof HTMLElement)||oe.dataset.agentCard!=="true")return;const E=Y(),V=E.indexOf(oe);if(V!==-1){if(te.preventDefault(),te.key==="ArrowDown"){R((V+1)%E.length);return}if(V===0){(H=k.current)==null||H.focus();return}R(V-1)}},Q=S.trim().toLowerCase(),I=Q?f.filter(te=>{var H,P;const oe=te.name.toLowerCase().includes(Q),E=((H=te.description)==null?void 0:H.toLowerCase().includes(Q))??!1,V=((P=te.model)==null?void 0:P.toLowerCase().includes(Q))??!1;return oe||E||V}):f,ae=S.trim().length>0,fe=ae||I.length===1;g.useEffect(()=>{const te=w.current;if(te)return $(),te.addEventListener("scroll",$,{passive:!0}),()=>te.removeEventListener("scroll",$)},[$,I]),g.useEffect(()=>{let te=!0;return(async()=>{try{x(!0),b(null);const V=(await Cd()).slice().sort((H,P)=>H.name.localeCompare(P.name,void 0,{sensitivity:"base"}));te&&h(V)}catch(E){He("[AgentSelectionList] Failed to load adapters",E),te&&b("Unable to load agents right now.")}finally{te&&x(!1)}})(),()=>{te=!1}},[]),g.useEffect(()=>{var te;p||v||f.length===0||(te=k.current)==null||te.focus()},[p,v,f.length]);const Ce=()=>p?u.jsx("div",{className:"grid gap-4",children:Array.from({length:3}).map((te,oe)=>u.jsx("div",{className:`${Iv} animate-pulse rounded-2xl border border-gray-200 bg-transparent dark:border-[#3b3c49]`},oe))}):v?u.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:v}):f.length===0?u.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:"No agents are available yet. Configure adapters in your middleware settings to continue."}):I.length===0?u.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:"No agents match your search."}):u.jsxs("div",{className:"relative flex flex-col h-full min-h-0",children:[u.jsx("div",{ref:w,onKeyDown:U,className:"agent-selection-scroll flex-1 min-h-0 overflow-y-auto pr-1 pb-2",children:fe?u.jsx("div",{className:"mx-auto flex w-full max-w-xl flex-col gap-3 lg:max-w-2xl",children:I.map(te=>u.jsx($p,{adapter:te,onSelect:oe=>r(oe.id)},te.id))}):u.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:I.map(te=>u.jsx($p,{adapter:te,onSelect:oe=>r(oe.id)},te.id))})}),_&&u.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 u.jsxs("div",{className:`flex w-full flex-col gap-4 md:gap-6 ${l}`,children:[(d||i||c)&&u.jsxs("div",{className:"flex-shrink-0",children:[d&&u.jsx("p",{className:"text-sm font-semibold uppercase tracking-wide text-blue-600 dark:text-blue-300",children:d}),i&&u.jsx("h2",{className:"mt-2 text-2xl font-bold text-gray-900 dark:text-white",children:i}),c&&u.jsx("p",{className:"mt-2 text-base text-gray-600 dark:text-gray-300",children:c})]}),u.jsx("div",{className:"flex w-full flex-shrink-0 justify-center",children:u.jsx("div",{className:"w-full max-w-xl lg:max-w-2xl",children:u.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:[u.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))]"}),u.jsx(gd,{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"}),u.jsx("input",{ref:k,type:"text",placeholder:"Search agents",value:S,maxLength:100,disabled:p||!!v||f.length===0,onChange:te=>j(te.target.value),onKeyDown:X,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"}),S&&u.jsx("button",{type:"button",onClick:()=>j(""),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":"Clear search",children:u.jsx(ua,{className:"h-3.5 w-3.5"})})]})})}),u.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:Ce()})]})}function ud(){return Sd()?Xo()==="entra"?u.jsx(Xv,{}):u.jsx(Vv,{}):null}function Vv(){const{user:r,logout:l,loginWithRedirect:i}=hd();if(!is()||!r)return u.jsx(jg,{onClick:()=>i()});const d=r.name||r.email||"User";return u.jsx(Ng,{displayName:d,onClick:()=>l({logoutParams:{returnTo:window.location.origin}})})}function Xv(){const{instance:r,accounts:l}=md();if(!is()||l.length===0)return u.jsx(jg,{onClick:()=>r.loginRedirect({scopes:kd()}).catch(()=>{})});const c=l[0],d=c.name||c.username||"User";return u.jsx(Ng,{displayName:d,onClick:()=>r.logoutRedirect({postLogoutRedirectUri:window.location.origin}).catch(()=>{})})}function jg({onClick:r}){return u.jsxs("button",{onClick:r,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:[u.jsx(ag,{className:"h-4 w-4"}),u.jsx("span",{children:"Sign in"})]})}function Ng({displayName:r,onClick:l}){return u.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm text-gray-600 dark:text-[#bfc2cd]",children:[u.jsx("span",{className:"hidden max-w-[170px] truncate font-medium md:block",title:r,children:r}),u.jsxs("button",{onClick:l,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:"Log out","aria-label":"Log out",children:[u.jsx(Bx,{className:"h-4 w-4"}),u.jsx("span",{className:"hidden md:inline",children:"Log out"})]})]})}function Tg({placement:r="default",compact:l=!1}){if(!mg())return null;const i=by(),c=yy(),d=vy(),f=wy(),h=Sy(),p=ky(),x=Ay(),v=f?"border-t border-slate-200/80 dark:border-[#333645]":"",b=l?r==="sidebar"?"pt-4 pb-2":"pt-2 pb-2":p==="normal"?"pt-3 pb-3":"pt-5 pb-3",w=h==="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",k="justify-center",S=r==="sidebar"?"w-full px-2":"w-full px-3 sm:px-6",j=r==="sidebar"?"w-full":"mx-auto w-full max-w-7xl",_=l?"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 u.jsx("footer",{className:`shrink-0 bg-white dark:bg-black text-sm ${b} ${v}`.trim(),style:{backgroundColor:c||void 0,color:d||void 0},children:u.jsx("div",{className:S,children:u.jsx("div",{className:j,children:u.jsxs("div",{className:w,children:[i&&u.jsx("p",{className:`${l?"text-xs leading-snug":"text-sm"} text-slate-700 dark:text-slate-200 ${r==="sidebar"?"pt-0.5":""}`.trim(),children:i}),x.length>0&&u.jsx("nav",{"aria-label":"Footer links",children:u.jsx("ul",{className:`flex flex-wrap items-center ${k} ${l?"gap-1":"gap-1.5 sm:gap-2"}`,children:x.map((z,$)=>{const ee=h==="inline"&&$>0;return u.jsxs("li",{className:"flex items-center",children:[ee&&u.jsx("span",{className:"mr-1.5 text-slate-400 dark:text-slate-500","aria-hidden":"true",children:"·"}),u.jsx("a",{href:z.url,target:"_blank",rel:"noopener noreferrer",className:_,style:{color:d||void 0},children:z.label})]},z.url)})})})]})})})})}const Yv=60*1e3;let td=null,qp=0;const ad=r=>{if(!r||r==="/")return"/";const l=r.trim();if(!l)return"/";const i=l.startsWith("/")?l:`/${l}`;return i==="/"?"/":i.endsWith("/")?i.slice(0,-1):i},Eg=()=>{if(typeof window>"u")return ad("/");const r=ad("/");if(typeof document>"u")return r;const l=document.querySelector("base[href]");if(!l)return r;try{const i=new URL(l.getAttribute("href")||"/",window.location.origin);return ad(i.pathname||r)}catch{return r}},Io=r=>r.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Qv=async()=>{const r=Date.now();if(td&&r-qp<Yv)return td;let l=[];try{l=await Cd()}catch(c){Be("[agentRouting] Unable to load adapters for slug resolution",c)}const i=new Map;return l.forEach(c=>{const d=Io(c.name);d&&i.set(d,c.id);const f=Io(c.id);f&&f!==d&&i.set(f,c.id)}),td=i,qp=r,i},dd=r=>{var f;const l=Eg(),i=r.startsWith("/")?r:`/${r}`;let c=i;if(l!=="/"){if(!i.startsWith(l))return null;c=i.slice(l.length)}const d=c.split("/").filter(Boolean);return d.length===0?null:((f=d[0])==null?void 0:f.toLowerCase())||null},Mg=r=>{const l=Eg();if(!r)return l;const i=r.replace(/^\/+|\/+$/g,"");return l==="/"?i?`/${i}`:"/":`${l}/${i}`.replace(/\/{2,}/g,"/")},Nn=r=>{if(typeof window>"u")return;const l=Mg(r),i=window.location.pathname;if(l===i)return;const c=window.location.search||"",d=window.location.hash||"";window.history.replaceState(window.history.state,"",`${l}${c}${d}`)},Zv=()=>Mg(null),Kv=async r=>{const l=r.trim().toLowerCase();return l&&(await Qv()).get(l)||null},Jv="Single adapter mode requires agentMode.defaultAdapterId to match an adapter id in orbitchat.yaml.";function Pv({currentConversation:r,showEmptyState:l,createConversation:i,configureApiSettings:c,clearError:d,clearCurrentConversationAdapter:f}){var we;const[h,p]=g.useState(!1),[x,v]=g.useState(null),b=Vo(),w=yd(),k=typeof window<"u"?dd(window.location.pathname):null,[S,j]=g.useState(k),[_,z]=g.useState(()=>!b&&l&&!k),$=g.useRef(null),ee=g.useRef(new Map),Y=g.useRef(0),R=3e4,q=!!r,N=(r==null?void 0:r.messages.length)??0,X=((we=r==null?void 0:r.attachedFiles)==null?void 0:we.length)??0,U=g.useMemo(()=>q&&(N>0||X>0),[X,N,q]),Q=g.useCallback(()=>{na(()=>Ve.getState())},[]),I=g.useCallback((W,se)=>{if(!W)return;const be=se||"Unable to configure this agent.";let ke=!1;Ve.setState(ge=>{const ze=ge.conversations.find(Ue=>Ue.id===W);return!ze||ze.messages.length>0?ge:(ke=!0,{conversations:ge.conversations.map(Ue=>Ue.id===W?{...Ue,adapterLoadError:be}:Ue)})}),ke&&Q()},[Q]),ae=g.useCallback(W=>{if(!W)return;let se=!1;Ve.setState(be=>{const ke=be.conversations.find(ge=>ge.id===W);return!ke||!ke.adapterLoadError?be:(se=!0,{conversations:be.conversations.map(ge=>ge.id===W?{...ge,adapterLoadError:null}:ge)})}),se&&Q()},[Q]),fe=g.useCallback(W=>W instanceof yg?W.status===401?"We couldn’t load this agent. It may not exist or you might not have access to it.":W.status===404?"This agent was not found on the server. Please pick another agent.":W.message:W instanceof Error?W.message:"Unable to load agent overview right now.",[]),Ce=g.useCallback(()=>{const W=Ve.getState(),se=W.currentConversationId?W.conversations.find(be=>be.id===W.currentConversationId):null;if(!se||se.messages.length>0)try{return i()}catch(be){Be("Cannot create a new conversation for agent selection:",be instanceof Error?be.message:"Unknown error")}return(se==null?void 0:se.id)||null},[i]),te=g.useCallback(async W=>{if(!(W!=null&&W.adapterName))return{ok:!1};try{const se=await kt(),be=new se.ApiClient({apiUrl:W.apiUrl||_t(),sessionId:null,adapterName:W.adapterName});if(typeof be.getAdapterInfo!="function")return{ok:!1};const ke=await be.getAdapterInfo();return Ve.setState(ge=>({conversations:ge.conversations.map(ze=>ze.id===W.id?{...ze,adapterInfo:ke,adapterLoadError:null,updatedAt:new Date}:ze)})),Ve.getState().currentConversationId===W.id&&v(null),Q(),{ok:!0}}catch(se){const be=fe(se),ke=Ve.getState();ke.currentConversationId===W.id&&v({conversationId:W.id,message:be});const ge=ke.conversations.find(ze=>ze.id===W.id);return ge&&ge.messages.length===0&&I(W.id,be),{ok:!1,error:se}}},[fe,I,Q]),oe=g.useCallback(async W=>{if(!W)return;const se=Ve.getState(),be=se.currentConversationId?se.conversations.find(ke=>ke.id===se.currentConversationId):null;if(be){p(!0),v(null),ae(be.id);try{const ke=be.apiUrl||_t();await c(ke,void 0,W),d();const ge=Ve.getState(),ze=ge.conversations.find(Ue=>Ue.id===ge.currentConversationId);if((ze==null?void 0:ze.adapterName)===W&&(!ze.adapterInfo||ze.adapterInfo.notes===void 0)){const Ue=await te(ze);!Ue.ok&&Ue.error&&He("Failed to load adapter info after selecting adapter:",Ue.error)}}catch(ke){He("Failed to configure adapter from empty state:",ke);const ge=fe(ke);v({conversationId:be.id,message:ge}),I(be.id,ge)}finally{p(!1)}}},[ae,d,c,te,fe,I]),E=g.useCallback(W=>{b||(Ce(),z(!1),Nn(Io(W)),oe(W))},[Ce,oe,b]),V=g.useCallback(()=>{b||(f(),Nn(null),z(!0))},[f,b]),H=g.useCallback(()=>{var ke,ge;if(b){const ze=Ve.getState(),Ue=ze.currentConversationId?ze.conversations.find(je=>je.id===ze.currentConversationId):null;if(!!Ue&&(Ue.messages.length>0||(((ke=Ue.attachedFiles)==null?void 0:ke.length)||0)>0))try{i()}catch(je){Be("Cannot go home (new conversation):",je instanceof Error?je.message:"Unknown error")}Nn(null),z(!1);return}j(null);const W=Ve.getState(),se=W.currentConversationId?W.conversations.find(ze=>ze.id===W.currentConversationId):null;if(!!se&&(se.messages.length>0||(((ge=se.attachedFiles)==null?void 0:ge.length)||0)>0))try{i()}catch(ze){Be("Cannot go home (new conversation):",ze instanceof Error?ze.message:"Unknown error");return}else se!=null&&se.adapterName&&f();Nn(null),z(!0)},[f,i,b]),ce=!b&&l&&!S&&!(r!=null&&r.adapterName)&&!U||!b&&l&&_&&!(r!=null&&r.adapterName)&&!U;g.useEffect(()=>{if(b){Nn(null);return}if(!S){if(ce||!(r!=null&&r.adapterName)){Nn(null);return}Nn(Io(r.adapterName))}},[r==null?void 0:r.adapterName,b,S,ce]);const xe=g.useCallback(async()=>{if(typeof window>"u")return;const W=++Y.current;if(b){Nn(null),j(null);return}const se=dd(window.location.pathname);if(!se)return;const be=await Kv(se);if(W===Y.current){if(!be){Ce(),Nn(null),f(),z(!0),j(null);return}Ce(),z(!1),Nn(se),await oe(be),j(null)}},[f,Ce,oe,b]);g.useEffect(()=>{const W=window.setTimeout(()=>{xe()},0),se=()=>{xe()};return window.addEventListener("popstate",se),()=>{window.clearTimeout(W),Y.current+=1,window.removeEventListener("popstate",se)}},[xe]);const pe=r==null?void 0:r.id,F=r==null?void 0:r.adapterName,me=r==null?void 0:r.apiUrl,ue=!!(r!=null&&r.adapterInfo);g.useEffect(()=>{if(!b||!w||!l||!pe||U||h)return;const W=(F==null?void 0:F.trim())||w,se=(F==null?void 0:F.trim())!==W||!ue;if(!W||!se)return;let be=!1;return(async()=>{p(!0),v(null),ae(pe);try{const ge=me||_t();await c(ge,void 0,W),d()}catch(ge){if(!be){const ze=fe(ge);v({conversationId:pe,message:ze}),I(pe,ze)}}finally{be||p(!1)}})(),()=>{be=!0}},[ae,d,c,U,fe,h,b,I,l,F,me,ue,pe,w]),g.useEffect(()=>{(async()=>{var ke;const se=r==null?void 0:r.adapterName;if($.current===se)return;const be=!(r!=null&&r.adapterInfo)||(r==null?void 0:r.adapterInfo)&&r.adapterInfo.notes===void 0;if(se&&be){$.current=se,le("[ChatInterface] Loading adapter info - adapterName:",se,"reason:",r!=null&&r.adapterInfo?"notes undefined":"missing");const ge=await te(r);if(ge.ok)le("[ChatInterface] Adapter info loaded successfully");else{const ze=ge.error;He("[ChatInterface] Failed to load adapter info:",ze);const Ue=ze instanceof Error?ze.message:String(ze);if((Ue.includes("429")||Ue.includes("Too Many Requests"))&&se){const je=ee.current.get(se);je&&clearTimeout(je);const Xe=setTimeout(()=>{$.current===se&&($.current=null),ee.current.delete(se)},R);ee.current.set(se,Xe),Be(`[ChatInterface] Adapter info request rate-limited; retrying in ${R/1e3}s`)}else $.current=null}}else le("[ChatInterface] Skipping adapter info load:",{adapterName:se,hasAdapterInfo:!!(r!=null&&r.adapterInfo),hasNotes:((ke=r==null?void 0:r.adapterInfo)==null?void 0:ke.notes)!==void 0,refValue:$.current})})()},[te,r]),g.useEffect(()=>{const W=ee.current;return()=>{W.forEach(se=>clearTimeout(se)),W.clear()}},[]);const de=b&&!w?Jv:(r==null?void 0:r.adapterLoadError)??((x==null?void 0:x.conversationId)===(r==null?void 0:r.id)?x.message:null);return{adapterNotesError:de,handleAgentCardSelection:E,handleChangeAgent:V,goToAgentSelectionHome:H,hasAdapterConfigurationError:!!de,isAgentSelectionVisible:_,isConfiguringAdapter:h,isSingleAdapterMode:b,setIsAgentSelectionVisible:z,shouldShowAgentSelectionList:ce}}const zg=g.createContext(null),Wv={registerGoHome:()=>{},goHome:()=>{}};function Dg(){return g.useContext(zg)??Wv}function e1({adapter:r,syntaxTheme:l,forcedThemeClass:i=""}){var d;const c=(d=r.notes)==null?void 0:d.trim();return c?u.jsxs("section",{"aria-labelledby":"agent-seo-content-title",className:"mx-auto w-full max-w-[56rem] px-1 text-left sm:px-0",children:[u.jsx("h2",{id:"agent-seo-content-title",className:"sr-only",children:r.name}),u.jsx("div",{children:u.jsx(el,{content:c,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 ${i}`,syntaxTheme:l})})]}):null}const t1='meta[name="description"]',a1='meta[property="og:title"]',n1='meta[property="og:description"]',l1='meta[property="og:type"]',r1='link[rel="canonical"]';function Bp(r){return r.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function s1(r){return r.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 i1(r,l){const i=r==null?void 0:r.trim();if(i)return i;if(!l)return wd();const c=s1(l);return c.length>160?`${c.slice(0,157).trimEnd()}...`:c}function o1(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function c1(r){const l=r.trim();if(!l)return null;try{return new URL(l).origin}catch{return null}}function u1(r){const l=r.trim();if(!l)return null;const i=`^${o1(l).replace(/\\\*/g,".*")}$`;try{return new RegExp(i,"i")}catch{return null}}function d1(r){return[og(),...Zb()].map(c1).filter(i=>!!i).includes(r)?!0:Kb().some(i=>{const c=u1(i);return c?c.test(r):!1})}function f1(r){var c,d,f;const l=r==null?void 0:r.trim();if(!l)return null;const i=ye.adapters.find(h=>{var p;return((p=h==null?void 0:h.id)==null?void 0:p.trim())===l});return i?{id:i.id,name:((c=i.name)==null?void 0:c.trim())||i.id,description:((d=i.description)==null?void 0:d.trim())||void 0,notes:((f=i.notes)==null?void 0:f.trim())||void 0}:null}function m1(r){var c,d,f;if(typeof window>"u")return null;const l=dd(window.location.pathname);if(!l)return null;const i=ye.adapters.find(h=>{const p=Bp(h.name||""),x=Bp(h.id||"");return l===p||l===x});return i?{id:i.id,name:((c=i.name)==null?void 0:c.trim())||i.id,description:((d=i.description)==null?void 0:d.trim())||void 0,notes:((f=i.notes)==null?void 0:f.trim())||void 0}:null}function To(r,l,i){if(typeof document>"u")return null;const c=document.querySelector(r);if(c)return c;const d=document.createElement("meta");return d.setAttribute(l,i),document.head.appendChild(d),d}function h1(){if(typeof document>"u")return null;const r=document.querySelector(r1);if(r)return r;const l=document.createElement("link");return l.rel="canonical",document.head.appendChild(l),l}function Lg(r){if(typeof document>"u")return;const l=vd(),i=r?`${r.name} | ${l}`:l,c=r?i1(r.description,r.notes):wd();document.title=i;const d=To(t1,"name","description");d&&(d.content=c);const f=To(a1,"property","og:title");f&&(f.content=i);const h=To(n1,"property","og:description");h&&(h.content=c);const p=To(l1,"property","og:type");p&&(p.content="website");const x=h1();if(x&&typeof window<"u"){const v=og(),b=window.location.origin,w=v?new URL(v.endsWith("/")?v:`${v}/`).origin:"",S=`${b&&d1(b)?b:w||b}${window.location.pathname}`;x.href=S}}function p1(){return Jb()}class jd{static async getAdapterModels(l,i){const c=await kt(),d=new c.ApiClient({apiUrl:"",adapterName:i});if(!d.getAdapterModels)throw new Error("getAdapterModels is not available on this API client");return d.getAdapterModels(l)}static async getAllModels(l){const i=await kt(),c=new i.ApiClient({apiUrl:"",adapterName:l});if(!c.getAllModels)throw new Error("getAllModels is not available on this API client");return c.getAllModels()}static async listAdapterModels(l,i){return(await jd.getAdapterModels(l,i)).models}}const g1="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",x1="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",b1="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 y1({onOpenSettings:r,onOpenSidebar:l}){var ta,gn,Tt,gt,Ht,_e,Sa;const{conversations:i,currentConversationId:c,createConversation:d,canCreateNewConversation:f,sendMessage:h,regenerateResponse:p,isLoading:x,configureApiSettings:v,error:b,clearError:w,createThread:k,clearCurrentConversationAdapter:S}=Ve(),{settings:j}=Go(),_=is(),z=va()&&!_,{theme:$,isDark:ee}=ss(),Y=$.mode==="dark"?"dark":$.mode==="light"?"light":"",R=ee?"dark":"light",q=["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",Y].filter(Boolean).join(" "),N=i.find(Te=>Te.id===c),X=i.some(Te=>{var Ye;return(Te.messages.length>0||(((Ye=Te.attachedFiles)==null?void 0:Ye.length)||0)>0)&&!Te.adapterLoadError}),U=!N||N.messages.length===0,Q=((ta=N==null?void 0:N.adapterInfo)==null?void 0:ta.supportsThreading)===!0,I=!!(N!=null&&N.adapterName&&(N!=null&&N.adapterInfo))&&!Q,ae=vg({adapterName:N==null?void 0:N.adapterName,enabled:I,selectionScopeKey:c,supportsThreading:Q}),fe=ig(),Ce=vd(),te=wd().trim(),oe=te.length>0,{registerGoHome:E}=Dg(),[V,H]=g.useState([]),[P,ce]=g.useState(null);g.useEffect(()=>{const Te=N==null?void 0:N.adapterName;let Ye=!1;async function bt(){if(ce(null),!Te){H([]);return}try{const it=await jd.listAdapterModels(Te,Te);if(Ye)return;H(it),ce(it.length>0?it[0].name:null)}catch{Ye||(H([]),ce(null))}}return bt(),()=>{Ye=!0}},[N==null?void 0:N.adapterName]);const{adapterNotesError:xe,handleAgentCardSelection:pe,handleChangeAgent:F,goToAgentSelectionHome:me,hasAdapterConfigurationError:ue,isAgentSelectionVisible:de,isConfiguringAdapter:we,isSingleAdapterMode:W,shouldShowAgentSelectionList:se}=Pv({currentConversation:N,showEmptyState:U,createConversation:d,configureApiSettings:v,clearError:w,clearCurrentConversationAdapter:S});g.useLayoutEffect(()=>(E(()=>me()),()=>E(null)),[E,me]);const be="max-w-[96rem]",ke="max-w-[64rem]",ge="max-w-[56rem]",ze=`mx-auto w-full ${be}`,Ue=f(),Fe=!!(N!=null&&N.adapterName)&&((N==null?void 0:N.messages.length)||0)===0,je=Ue?"Start a new conversation":z?"Guest conversation limit reached. Sign in for more conversations.":"Finish your current conversation before starting a new one.",Xe=!!(N&&!se),et=se?"border-transparent dark:border-transparent md:border-transparent md:dark:border-transparent":"",Bt=!sd()&&se?"pt-0 pb-0 md:pt-0 md:pb-1":"",ie=`${b1} ${et} ${Bt}`.trim(),Ne=mg(),Nt=i.some(Te=>{var Ye;return(Te.messages.length>0||(((Ye=Te.attachedFiles)==null?void 0:Ye.length)??0)>0)&&!Te.adapterLoadError}),Oe=Ne&&!Nt,Vt=se?"pt-0 md:pt-0":"pt-4 md:pt-6",da=g.useMemo(()=>{var it,Ae,la;if(se)return null;const Te=f1(N==null?void 0:N.adapterName)||m1();if(!Te&&!(N!=null&&N.adapterName))return null;const Ye=(it=N==null?void 0:N.adapterName)==null?void 0:it.trim(),bt=(la=(Ae=N==null?void 0:N.adapterInfo)==null?void 0:Ae.notes)==null?void 0:la.trim();return Te?{...Te,notes:bt||Te.notes}:Ye?{id:Ye,name:Ye,notes:bt||void 0}:null},[(gn=N==null?void 0:N.adapterInfo)==null?void 0:gn.notes,N==null?void 0:N.adapterName,se]);g.useEffect(()=>{Lg(da)},[da]),g.useEffect(()=>{let Te=null;const Ye=()=>{Te&&(Te(),Te=null)};if(j.voiceEnabled){if(Ul.isAudioEnabled())return le("[ChatInterface] Audio streaming already enabled"),Ye;const bt=()=>{Ye();const it=async()=>{Ye(),await Ul.enableAudio()?le("[ChatInterface] Audio streaming enabled after user gesture"):(Be("[ChatInterface] User gesture did not enable audio streaming"),bt())};document.addEventListener("pointerdown",it,{once:!0}),document.addEventListener("keydown",it,{once:!0}),Te=()=>{document.removeEventListener("pointerdown",it),document.removeEventListener("keydown",it)},le("[ChatInterface] Waiting for user gesture to enable audio streaming")};return bt(),Ye}return Ye(),Ul.disableAudio(),le("[ChatInterface] Audio streaming disabled via settings"),Ye},[j.voiceEnabled]);const Xt=(Te,Ye,bt,it)=>{h(Te,Ye,bt,P??void 0,it)},ea=async(Te,Ye,bt,it,Ae)=>{await h(bt,void 0,Te,Ae??P??void 0,it)},pn=()=>{try{d()}catch(Te){Be("Cannot create new conversation:",Te instanceof Error?Te.message:"Unknown error")}},en=g.useCallback(async(Te,Ye)=>{if(N)try{await Ve.getState().deleteThread(N.id,Te,Ye)}catch(bt){He("Failed to clear thread:",bt)}},[N]);return u.jsx("main",{className:"flex-1 flex flex-col bg-transparent overflow-hidden","aria-label":"Chat workspace",children:u.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden px-3 sm:px-5 lg:px-8",children:u.jsxs("div",{className:`mx-auto flex h-full w-full ${be} flex-col overflow-hidden md:pb-4 ${g1}`,children:[b&&u.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:u.jsxs("div",{className:"flex items-start justify-between",children:[u.jsx("p",{children:b}),u.jsx("button",{onClick:w,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":"Dismiss error",children:"×"})]})}),u.jsxs("div",{className:ie,children:[l&&u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 md:hidden",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("button",{onClick:l,disabled:!X,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 ${X?"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":"Open conversations menu",children:[u.jsx(Fx,{className:"h-4 w-4"}),"Chats"]}),u.jsxs("button",{onClick:r,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":"Open settings",children:[u.jsx(dp,{className:"h-4 w-4"}),"Settings"]})]}),u.jsx("div",{className:"ml-auto flex-shrink-0",children:u.jsx(ud,{})})]}),u.jsxs("div",{className:"flex flex-col gap-2 md:gap-4 sm:flex-row sm:items-end sm:justify-between",children:[u.jsx("div",{className:"min-w-0 flex-1",children:Xe&&u.jsx("div",{className:"space-y-1.5 md:space-y-3",children:u.jsxs("div",{className:"md:space-y-1",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("h1",{className:"min-w-0 truncate text-lg md:text-2xl font-semibold text-[#353740] dark:text-[#ececf1]",children:(N==null?void 0:N.title)||"New Chat"}),N&&u.jsx("span",{className:"flex-shrink-0 text-xs md:hidden text-gray-500 dark:text-[#bfc2cd]",children:N.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),N&&u.jsx("div",{className:"hidden md:flex items-center text-sm text-gray-500 dark:text-[#bfc2cd]",children:u.jsxs("span",{children:["Updated ",N.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})})]})})}),u.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:[u.jsx("div",{className:"hidden flex-shrink-0 items-center md:inline-flex",children:u.jsx("button",{onClick:r,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":"Settings",title:"Settings",children:u.jsx(dp,{className:"h-4 w-4"})})}),!W&&!se&&!!(N!=null&&N.adapterName)&&u.jsx("button",{type:"button",onClick:()=>{Fe&&F()},disabled:!Fe,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 ${Fe?"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:Fe?"Switch to a different agent before starting this conversation":"Agent cannot be changed after the conversation has started",children:"Change Agent"}),!se&&u.jsxs("button",{onClick:pn,disabled:!Ue,className:`order-3 sm:order-2 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] ${Ue?"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:je,children:[u.jsx(eb,{className:"h-3.5 w-3.5"}),"New Conversation"]}),!sd()&&u.jsx("div",{className:"order-4 hidden flex-shrink-0 items-center md:inline-flex",children:u.jsx(ud,{})})]})]})]}),U?u.jsxs("div",{className:`flex flex-1 flex-col min-h-0 ${Vt} ${se?"overflow-hidden":""}`,children:[se?u.jsx("div",{className:"flex-1 flex flex-col md:justify-start min-h-0 overflow-hidden",children:u.jsx("div",{className:"w-full flex flex-col min-h-0 overflow-hidden flex-1",children:u.jsxs("div",{className:"flex flex-col min-h-0 flex-1 gap-3 overflow-hidden md:gap-6",children:[u.jsx("div",{className:`${ze} flex-shrink-0 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:u.jsxs("div",{className:"flex-1",children:[u.jsx(el,{content:Ce,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:R}),oe&&u.jsx("div",{className:"mt-2",children:u.jsx(el,{content:te,className:q,syntaxTheme:R})})]})}),u.jsx(Gv,{onAdapterSelect:pe,className:`${ze} md:flex-1 md:min-h-0 md:overflow-hidden`})]})})}):u.jsx("div",{className:"flex flex-1 w-full min-h-0 flex-col overflow-y-auto pt-4 md:pt-6",children:u.jsxs("div",{className:`mx-auto flex w-full ${ge} flex-col items-center gap-4 pb-8 md:gap-5 md:pb-12`,children:[xe?u.jsx("p",{className:"w-full text-center text-sm text-red-600 dark:text-red-400",children:xe}):N!=null&&N.adapterName?u.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:Yb(N.adapterName)||N.adapterName}):we?u.jsx("p",{className:"w-full text-center text-sm text-gray-500 dark:text-[#bfc2cd]",children:"Configuring your agent…"}):null,da&&p1()&&u.jsx(e1,{adapter:da,syntaxTheme:R,forcedThemeClass:Y}),u.jsx("div",{className:"w-full min-w-0",children:u.jsx(Op,{onSend:Xt,disabled:x||!N||!(N!=null&&N.adapterName)||ue,autoFocusEnabled:!0,placeholder:fe,isCentered:!0,maxWidthClass:ge,adapterNotes:(Tt=N==null?void 0:N.adapterInfo)==null?void 0:Tt.notes,skillState:ae,availableModels:V,defaultModel:((gt=N==null?void 0:N.adapterInfo)==null?void 0:gt.model)??null,selectedModel:P,onSelectModel:ce})})]})}),Oe&&u.jsx("div",{className:"shrink-0 pt-5 md:pt-6",children:u.jsx(Tg,{compact:!0})})]}):u.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[u.jsx(vv,{messages:N.messages,onRegenerate:Te=>p(Te,P??void 0),onStartThread:async(Te,Ye)=>{try{await k(Te,Ye)}catch(bt){He("Failed to create thread:",bt)}},onClearThread:en,onSendThreadMessage:ea,sessionId:N.sessionId,isLoading:x,contentMaxWidthClass:ke,availableModels:V,defaultModel:((Ht=N==null?void 0:N.adapterInfo)==null?void 0:Ht.model)??null,selectedModel:P}),u.jsx("div",{className:x1,children:u.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:u.jsx(Op,{onSend:Xt,disabled:x||!N||!N.adapterName||de||ue,autoFocusEnabled:!0,placeholder:"Start a new topic...",maxWidthClass:ke,isCentered:!1,adapterNotes:(_e=N==null?void 0:N.adapterInfo)==null?void 0:_e.notes,skillState:ae,availableModels:V,defaultModel:((Sa=N==null?void 0:N.adapterInfo)==null?void 0:Sa.model)??null,selectedModel:P,onSelectModel:ce})})})]})]})})})}function v1({selectedAdapter:r,onAdapterChange:l,disabled:i,showDescriptions:c=!1,variant:d="sidebar",label:f,showLabel:h}){const[p,x]=g.useState([]),[v,b]=g.useState(!0),[w,k]=g.useState(null),[S,j]=g.useState(!1);g.useEffect(()=>{let U=!0;async function Q(){try{b(!0),k(null);const I=await Cd();U&&x(I)}catch(I){He("Failed to load adapters:",I),U&&k("Failed to load adapters. Please check your connection.")}finally{U&&b(!1)}}return Q(),()=>{U=!1}},[]);const _=p.find(U=>U.id===r),z=typeof h=="boolean"?h:d==="prominent",$=f||(d==="prominent"?"Select an agent":"Adapter"),ee=g.useMemo(()=>d==="prominent"?"relative w-full text-left":"relative w-full",[d]),Y=g.useMemo(()=>{const U="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 d==="prominent"?[U,"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(" ")},[d]),R=g.useMemo(()=>d==="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]",[d]),X=z?`mb-2 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-[#bfc2cd] ${d==="prominent"?"!text-sm !font-semibold !text-gray-700 dark:!text-white":""}`:"sr-only";return u.jsxs("div",{className:ee,children:[u.jsx("label",{className:X,children:$}),u.jsxs("div",{className:"relative",children:[u.jsx("button",{type:"button",onClick:()=>!i&&j(!S),disabled:i||v||p.length===0,className:`${Y} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-label":$,children:u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsxs("div",{className:"flex flex-col min-w-0",children:[u.jsx("span",{className:`truncate font-medium ${_?"text-[#11121a] dark:text-white":"text-gray-500 dark:text-gray-400"}`,children:v?"Loading agents…":w?"Error loading agents":_?_.name:p.length===0?"No agents available":"Select an agent"}),d==="prominent"&&(_==null?void 0:_.description)&&u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:_.description})]}),u.jsx(di,{className:`h-4 w-4 flex-shrink-0 transition-transform text-gray-400 dark:text-gray-300 ${S?"rotate-180":""}`})]})}),S&&!i&&p.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>j(!1)}),u.jsx("div",{className:R,children:u.jsx("div",{className:"max-h-72 overflow-auto py-2",children:p.map(U=>{const Q=U.id===r;return u.jsx("button",{type:"button",onClick:()=>{Q||l(U.id),j(!1)},className:`w-full px-4 py-3 text-left text-sm transition-colors ${Q?"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:u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"font-medium truncate",children:U.name}),c&&U.description&&u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:U.description})]})},U.id)})})})]})]}),w&&u.jsx("p",{className:"mt-1 text-xs text-red-600 dark:text-red-400",children:w})]})}const Eo=100;function w1(r,l){const i=new Date(l.getFullYear(),l.getMonth(),l.getDate()),c=new Date(i);c.setDate(c.getDate()-1);const d=new Date(i);d.setDate(d.getDate()-i.getDay());const f=new Date(l.getFullYear(),l.getMonth(),1);return r>=i?"Today":r>=c?"Yesterday":r>=d?"This Week":r>=f?"This Month":"Earlier"}function S1(r){const l=new Date,i=["Today","Yesterday","This Week","This Month","Earlier"],c=new Map;for(const d of r){const f=w1(d.updatedAt,l),h=c.get(f);h?h.push(d):c.set(f,[d])}return i.filter(d=>c.has(d)).map(d=>({label:d,conversations:c.get(d)}))}function Hp({onRequestClose:r,onToggleDesktopSidebar:l}){const i=Vo(),{conversations:c,currentConversationId:d,selectConversation:f,deleteConversation:h,deleteAllConversations:p,updateConversationTitle:x,getConversationCount:v,configureApiSettings:b,clearError:w}=Ve(),k=c.find(ie=>ie.id===d),[S,j]=g.useState(""),[_,z]=g.useState(null),[$,ee]=g.useState(""),[Y,R]=g.useState({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1}),[q,N]=g.useState({isOpen:!1,isDeleting:!1}),[X,U]=g.useState(!1),[Q,I]=g.useState(null),[ae,fe]=g.useState(!1),[Ce,te]=g.useState(null),oe=g.useRef(null),E=g.useRef(null),V=g.useRef(null),H=!k||k.messages.length===0,P=(Q==null?void 0:Q.conversationId)===d?Q.adapterName:(k==null?void 0:k.adapterName)??null,ce=(Ce==null?void 0:Ce.conversationId)===d?Ce.message:null,xe=g.useMemo(()=>c.filter(ie=>{var Ne;return(ie.messages.length>0||(((Ne=ie.attachedFiles)==null?void 0:Ne.length)||0)>0)&&!ie.adapterLoadError}),[c]),pe=g.useMemo(()=>{if(!S)return xe;const ie=S.toLowerCase();return xe.filter(Ne=>Ne.title.toLowerCase().includes(ie)||Ne.messages.some(Nt=>Nt.content.toLowerCase().includes(ie))||(Ne.attachedFiles||[]).some(Nt=>Nt.filename.toLowerCase().includes(ie)))},[xe,S]),F=g.useMemo(()=>S1(pe),[pe]),me=v(),ue=S.length>0,de=xe.length>0;g.useEffect(()=>{if(!d||!E.current)return;const ie=E.current.querySelector('[aria-current="true"]');ie&&ie.scrollIntoView({block:"nearest",behavior:"smooth"})},[d]);const we=g.useCallback(ie=>{var da;if(ie.key!=="ArrowDown"&&ie.key!=="ArrowUp")return;ie.preventDefault();const Ne=(da=E.current)==null?void 0:da.querySelectorAll('[role="option"]');if(!Ne||Ne.length===0)return;const Nt=document.activeElement,Oe=Array.from(Ne).indexOf(Nt);let Vt;ie.key==="ArrowDown"?Vt=Oe<Ne.length-1?Oe+1:0:Vt=Oe>0?Oe-1:Ne.length-1,Ne[Vt].focus()},[]),W=async ie=>{if(!(!H||!ie)){I({conversationId:d??null,adapterName:ie}),te(null),fe(!0);try{const Ne=(k==null?void 0:k.apiUrl)||_t();await b(Ne,void 0,ie),w(),U(!1)}catch(Ne){He("Failed to configure adapter:",Ne),te({conversationId:d??null,message:Ne instanceof Error?Ne.message:"Failed to configure adapter"})}finally{fe(!1)}}},se=async ie=>{try{await f(ie),r==null||r()}catch(Ne){He("Failed to select conversation:",Ne)}},be=(ie,Ne)=>{ie.stopPropagation(),R({isOpen:!0,conversationId:Ne.id,conversationTitle:Ne.title,isDeleting:!1})},ke=async()=>{R(ie=>({...ie,isDeleting:!0}));try{await h(Y.conversationId)}catch(ie){He("Failed to delete conversation:",ie)}R({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},ge=()=>{R({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},ze=(ie,Ne)=>{ie.stopPropagation(),z(Ne.id),ee(Ne.title.slice(0,Eo))},Ue=ie=>{const Ne=$.slice(0,Eo).trim();Ne&&x(ie,Ne),z(null),ee("")},Fe=()=>{z(null),ee("")},je=()=>{N({isOpen:!0,isDeleting:!1})},Xe=async()=>{N(ie=>({...ie,isDeleting:!0}));try{await p()}catch(ie){He("Failed to clear all conversations:",ie)}N({isOpen:!1,isDeleting:!1})},et=()=>{N({isOpen:!1,isDeleting:!1})},Bt=ie=>{var Ne,Nt,Oe;return(Ne=ie.adapterName)!=null&&Ne.trim()?ie.adapterName:(Oe=(Nt=ie.adapterInfo)==null?void 0:Nt.adapter_name)!=null&&Oe.trim()?ie.adapterInfo.adapter_name:null};ci(oe,{enabled:X,onEscape:()=>U(!1)});const xt=ie=>{const Ne=d===ie.id,Nt=Bt(ie);return u.jsx("div",{role:"option","aria-selected":Ne,tabIndex:0,onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),se(ie.id))},onClick:()=>se(ie.id),className:`group relative flex w-full cursor-pointer items-center rounded-lg px-3 py-2 text-left text-sm transition-colors duration-100
|
|
366
|
-
${Ne?"bg-slate-100 dark:bg-[#2a2b36]":"hover:bg-slate-100/70 dark:hover:bg-[#25262f]"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/50 dark:focus-visible:ring-sky-400/40`,"aria-current":Ne?"true":void 0,"aria-label":`Open conversation: ${ie.title}`,children:_===ie.id?u.jsx("input",{type:"text",value:$,onChange:Oe=>ee(Oe.target.value.slice(0,Eo)),onKeyDown:Oe=>{Oe.key==="Enter"&&Ue(ie.id),Oe.key==="Escape"&&Fe(),Oe.stopPropagation()},onBlur:()=>Ue(ie.id),maxLength:Eo,className:"flex-1 rounded border border-sky-300 bg-white px-2 py-0.5 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":"Edit conversation title"}):u.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[u.jsx("h3",{className:`flex-1 truncate text-sm leading-snug ${Ne?"font-medium text-slate-900 dark:text-[#ececf1]":"font-normal text-slate-700 dark:text-[#c5c8d6]"}`,children:ie.title}),u.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:[u.jsx("button",{onClick:Oe=>ze(Oe,ie),className:"rounded p-1 text-slate-400 transition-colors hover:bg-slate-200/80 hover:text-slate-600 dark:text-[#6b6f7a] dark:hover:bg-[#3c3f4a] dark:hover:text-[#c5c8d6]","aria-label":`Rename conversation: ${ie.title}`,children:u.jsx(Px,{className:"h-3 w-3"})}),u.jsx("button",{onClick:Oe=>be(Oe,ie),className:"rounded p-1 text-slate-400 transition-colors hover:bg-red-100/80 hover:text-red-600 dark:text-[#6b6f7a] dark:hover:bg-red-900/30 dark:hover:text-red-400","aria-label":`Delete conversation: ${ie.title}`,children:u.jsx(rg,{className:"h-3 w-3"})})]})]}),Nt&&u.jsx("span",{className:"truncate text-[11px] leading-none text-slate-400 dark:text-[#6b6f7a]",children:Nt})]})},ie.id)};return u.jsxs(u.Fragment,{children:[!i&&X&&u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm px-4",children:u.jsxs("div",{ref:oe,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:[u.jsx("h2",{id:"select-agent-title",className:"mb-4 text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:"Select an Agent"}),u.jsxs("div",{className:"space-y-5",children:[u.jsx(v1,{selectedAdapter:P,onAdapterChange:W,disabled:ae,variant:"prominent",showDescriptions:!0,showLabel:!1}),ce&&u.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:ce}),u.jsx("div",{className:"flex justify-end gap-3 pt-2",children:u.jsx("button",{type:"button",onClick:()=>{te(null),U(!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:ae,children:"Cancel"})})]})]})}),u.jsxs("nav",{"aria-label":"Conversation sidebar",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:[u.jsxs("div",{className:"bg-transparent px-4 pb-4 pt-4 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-2 pb-3",children:[c.length>0&&c.some(ie=>ie.messages.length>0)&&u.jsxs("button",{onClick:je,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:"Delete all conversations",children:[u.jsx(sb,{className:"h-4 w-4"}),"Delete Conversations"]}),l&&u.jsx("button",{type:"button",onClick:l,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":"Close sidebar",title:"Close sidebar",children:u.jsx(Qx,{className:"h-4 w-4"})})]}),ce&&!X&&u.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:ce}),de&&u.jsxs("div",{className:"border-t border-gray-200 pt-4 mt-4 dark:border-[#2d2f39]",children:[u.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:[u.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))]"}),u.jsx(gd,{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"}),u.jsx("input",{ref:V,type:"text",role:"searchbox","aria-label":"Search conversations",placeholder:"Search Conversations",value:S,onChange:ie=>j(ie.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"}),S&&u.jsx("button",{type:"button",onClick:()=>{var ie;j(""),(ie=V.current)==null||ie.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":"Clear search",children:u.jsx(ua,{className:"h-3.5 w-3.5"})})]}),ue&&u.jsx("p",{"aria-live":"polite",className:"mt-2 text-center text-[11px] tabular-nums text-gray-400 dark:text-[#6e7490]",children:pe.length===0?"No results":`${pe.length} ${pe.length===1?"result":"results"}`})]})]}),u.jsx("div",{ref:E,role:"listbox","aria-label":"Conversations",onKeyDown:we,className:"flex-1 overflow-y-auto bg-transparent px-3 py-2",children:pe.length===0?null:ue?u.jsx("div",{className:"space-y-1",children:pe.map(xt)}):u.jsx("div",{className:"space-y-4",children:F.map(ie=>u.jsxs("section",{"aria-label":ie.label,children:[u.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:ie.label}),u.jsx("div",{className:"space-y-1",children:ie.conversations.map(xt)})]},ie.label))})}),(()=>{const ie=fg();return ie.length===0?null:u.jsx("div",{className:"shrink-0 border-t border-gray-200/80 px-4 py-3 md:hidden dark:border-[#2d2f39]",children:u.jsx("nav",{"aria-label":"Header links",children:u.jsx("ul",{className:"flex flex-wrap gap-2",children:ie.map(Ne=>u.jsx("li",{children:u.jsx("a",{href:Ne.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:Ne.label})},Ne.url))})})})})(),u.jsx("div",{className:"shrink-0 border-t border-gray-200/80 dark:border-[#2d2f39]",children:u.jsx(Tg,{placement:"sidebar",compact:!0})})]}),u.jsx(qo,{isOpen:Y.isOpen,onClose:ge,onConfirm:ke,title:"Delete Conversation",message:`Are you sure you want to delete "${Y.conversationTitle}"? This will clear the conversation history.`,confirmText:"Delete",cancelText:"Cancel",type:"danger",isLoading:Y.isDeleting}),u.jsx(qo,{isOpen:q.isOpen,onClose:et,onConfirm:Xe,title:"Clear All Conversations",message:me===1?"Are you sure you want to delete this conversation? This will clear all conversation history.":`Are you sure you want to delete all ${me} conversations? This will clear all conversation history.`,confirmText:"Clear All",cancelText:"Cancel",type:"danger",isLoading:q.isDeleting})]})}const k1="3.10.5",_1={version:k1},Nd=_1.version,A1=["@@auth0spajs@@","a0.spajs","auth0","com.auth0"];function C1(r){const l=r.toLowerCase();return A1.some(i=>l.includes(i.toLowerCase()))}function j1(r){const l=[];for(let i=0;i<r.length;i++){const c=r.key(i);c&&C1(c)&&l.push(c)}l.forEach(i=>r.removeItem(i))}function Fp(r){try{j1(r),r.clear()}catch(l){console.warn("[Settings] Failed to clear browser storage during reset.",l)}}function N1(){if(typeof document>"u"||!document.cookie)return;const r=new Set([void 0]),l=window.location.hostname;l&&l!=="localhost"&&!/^\d{1,3}(?:\.\d{1,3}){3}$/.test(l)&&(r.add(l),r.add(`.${l}`)),document.cookie.split(";").forEach(c=>{const d=c.indexOf("="),f=(d>-1?c.slice(0,d):c).trim();f&&r.forEach(h=>{const p=h?`;domain=${h}`:"";document.cookie=`${f}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${p}`})})}function T1(){Fp(localStorage),Fp(sessionStorage),N1()}function E1({isOpen:r,onClose:l}){const{theme:i,updateTheme:c}=ss(),{settings:d,updateSettings:f}=Go(),[h,p]=g.useState(!1),x=g.useRef(null),v=g.useRef(null),b=_=>{c({mode:_})},w=()=>{f({soundEnabled:!d.soundEnabled})},k=()=>{p(!0)},S=()=>{p(!1)},j=()=>{S(),Qo(),Zo(!1),rs(null),wa.getState().closeLoginPrompt(),T1(),window.location.reload()};return ci(x,{enabled:r&&!h,onEscape:l}),ci(v,{enabled:h,onEscape:S}),r?u.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:[u.jsx("button",{type:"button",onClick:l,"aria-label":"Close settings overlay",className:"absolute inset-0"}),u.jsxs("div",{onClick:_=>_.stopPropagation(),ref:x,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:[u.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:[u.jsx("h2",{id:"settings-title",className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Settings"}),u.jsx("button",{onClick:l,className:"p-2 hover:bg-gray-100 dark:hover:bg-[#25262f] rounded-lg transition-colors","aria-label":"Close settings",children:u.jsx(ua,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.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:[u.jsxs("div",{className:"space-y-4",children:[u.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[u.jsx(Yx,{className:"w-5 h-5"}),"Appearance"]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Theme"}),u.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"light",label:"Light",icon:rb},{value:"dark",label:"Dark",icon:Xx},{value:"system",label:"System",icon:Vx}].map(({value:_,label:z,icon:$})=>u.jsxs("button",{onClick:()=>b(_),className:`flex flex-col items-center gap-2 p-3 rounded-lg border-2 transition-all duration-200 ${i.mode===_?"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:[u.jsx($,{className:"w-5 h-5"}),u.jsx("span",{className:"text-sm font-medium",children:z})]},_))})]})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Chat Preferences"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Oo,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}),u.jsxs("div",{children:[u.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Sound Effects"}),u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Play sounds for notifications and events"})]})]}),u.jsx("button",{onClick:w,role:"switch","aria-checked":d.soundEnabled,"aria-label":"Toggle sound effects",className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${d.soundEnabled?"bg-blue-600":"bg-gray-200 dark:bg-[#3c3f4a]"}`,children:u.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d.soundEnabled?"translate-x-6":"translate-x-1"}`})})]})]}),u.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[u.jsx(rg,{className:"w-5 h-5"}),"Data Management"]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Clear all application data including conversations, and personalized settings."}),u.jsx("button",{onClick:k,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:"Reset Application"})]})]}),u.jsxs("p",{className:"pt-2 text-center text-xs text-gray-400 dark:text-[#858999]",children:["v",Nd]})]}),h&&u.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/70 p-4",children:u.jsxs("div",{ref:v,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:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.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:u.jsx(bd,{className:"w-5 h-5 text-red-600 dark:text-red-400"})}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("p",{id:"reset-dialog-title",className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Reset application data?"}),u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"This removes everything stored on this device and reloads the app."})]})]}),u.jsxs("div",{className:"mt-4 flex gap-2 pt-2",children:[u.jsx("button",{onClick:S,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:"Cancel"}),u.jsx("button",{onClick:j,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:"Reset"})]})]})})]})]}):null}function M1({message:r}){const l=vd();return u.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:u.jsxs("div",{className:"mx-auto flex min-h-[calc(100dvh-3rem)] w-full max-w-5xl flex-col",children:[u.jsxs("header",{className:"flex items-center justify-between gap-4",children:[u.jsx("p",{className:"min-w-0 truncate text-lg font-semibold tracking-tight sm:text-xl",children:l}),u.jsxs("span",{className:"shrink-0 text-xs font-medium text-slate-400 dark:text-[#858999]",children:["v",Nd]})]}),u.jsx("section",{className:"flex flex-1 items-center justify-center py-12",children:u.jsxs("div",{className:"w-full max-w-lg space-y-8",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("span",{className:"relative flex h-2.5 w-2.5 shrink-0",children:[u.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-60 dark:bg-amber-500"}),u.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-amber-500 dark:bg-amber-400"})]}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-amber-700 dark:text-amber-400",children:"Service paused"})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-slate-950 dark:text-white sm:text-4xl",children:"Temporarily unavailable"}),u.jsx("p",{className:"max-w-md whitespace-pre-wrap text-base leading-relaxed text-slate-500 dark:text-slate-400",children:r})]}),u.jsx("div",{className:"border-t border-slate-200 dark:border-[#242424]"}),u.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[u.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:[u.jsx(ab,{className:"h-4 w-4","aria-hidden":"true"}),"Try again"]}),u.jsx("span",{className:"hidden text-slate-300 dark:text-slate-700 sm:block","aria-hidden":"true",children:"·"})]})]})})]})})}function z1({children:r}){const{instance:l,accounts:i}=md(),c=yx();return g.useEffect(()=>{Zo(c)},[c]),g.useEffect(()=>{if(!c||i.length===0){rs(null);return}const d=i[0];rs(d.username||d.name||d.localAccountId||null)},[c,i]),g.useEffect(()=>{if(!c||i.length===0)return;const d=i[0],f=kd();return hg(async()=>(await l.acquireTokenSilent({scopes:f,account:d})).accessToken),()=>Qo()},[c,i,l]),u.jsx(u.Fragment,{children:r})}function D1({children:r}){return u.jsx(z1,{children:r})}function L1({children:r}){const{isLoading:l,isAuthenticated:i,getAccessTokenSilently:c,user:d}=hd();return g.useEffect(()=>{Zo(i)},[i]),g.useEffect(()=>{if(!i){rs(null);return}const f=(d==null?void 0:d.sub)||(d==null?void 0:d.email)||(d==null?void 0:d.nickname)||(d==null?void 0:d.name)||null;rs(f)},[i,d]),g.useEffect(()=>(i&&hg(()=>c()),()=>Qo()),[i,c]),l?u.jsx("div",{className:"flex items-center justify-center h-screen bg-white dark:bg-[#212121]",children:u.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 dark:border-gray-100"})}):u.jsx(u.Fragment,{children:r})}function R1({children:r}){return g.useEffect(()=>{Zo(!1),rs(null),Qo()},[]),u.jsx(u.Fragment,{children:r})}function U1({children:r}){return va()?Xo()==="entra"?u.jsx(D1,{children:r}):u.jsx(L1,{children:r}):u.jsx(R1,{children:r})}function O1(){const r=Sd(),l=va(),i=is(),{showLoginPrompt:c,promptMessage:d,closeLoginPrompt:f}=wa();return g.useEffect(()=>{c&&(!r||!l||i)&&f()},[c,r,l,i,f]),!r||!l||i||!c?null:Xo()==="entra"?u.jsx(q1,{message:d,onClose:f}):u.jsx($1,{message:d,onClose:f})}function $1({message:r,onClose:l}){const{loginWithRedirect:i}=hd();return u.jsx(Rg,{message:r,onClose:l,onLogin:()=>i()})}function q1({message:r,onClose:l}){const{instance:i}=md();return u.jsx(Rg,{message:r,onClose:l,onLogin:()=>i.loginRedirect({scopes:kd()}).catch(()=>{})})}function Rg({message:r,onClose:l,onLogin:i}){return u.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[u.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:l,"aria-hidden":"true"}),u.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:[u.jsx("button",{onClick:l,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":"Close",children:u.jsx(ua,{className:"h-4 w-4"})}),u.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[u.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/40",children:u.jsx(ag,{className:"h-5 w-5 text-blue-600 dark:text-blue-300"})}),u.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:"Sign in for more"})]}),u.jsx("p",{className:"mb-6 text-sm leading-relaxed text-gray-600 dark:text-[#bfc2cd]",children:r}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx("button",{onClick:i,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:"Sign in"}),u.jsx("button",{onClick:l,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:"Cancel"})]})]})]})}function B1(){const{goHome:r}=Dg(),{isDark:l}=ss(),i=Zv(),c=g.useRef(!1),d=uy(),f=dy(),h=fy(),p=l?h:f,x=my(),v=hy(),b=!!(x||v),w=py(),k=gy(),S=xy(),j=fg(),_=S?"border-b border-slate-200/80 dark:border-[#333645]":"",z="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(()=>{c.current},[h,d,f]),sd()?u.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 ${_}`.trim(),style:{backgroundColor:w||void 0,color:k||void 0},children:u.jsxs("div",{className:"mx-auto flex w-full max-w-[96rem] items-center justify-between gap-3",children:[u.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-2 md:justify-start md:gap-3",children:u.jsx("a",{href:i,"aria-label":"Go to home page",onClick:$=>{$.preventDefault(),r()},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:u.jsx("img",{src:p,alt:"Logo",draggable:!1,className:`block max-w-full flex-shrink-0 select-none ${b?"":"h-8 w-auto sm:h-10 md:h-11"}`.trim(),style:{WebkitUserDrag:"none",...x?{height:x}:{},...v?{width:v}:{}}})})}),u.jsxs("div",{className:"hidden min-w-0 flex-1 items-center justify-end gap-2 sm:gap-4 md:flex",children:[j.length>0&&u.jsx("nav",{"aria-label":"Header links",className:"hidden sm:block",children:u.jsx("ul",{className:"flex items-center gap-1.5 sm:gap-2",children:j.map($=>u.jsx("li",{children:u.jsx("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",className:z,style:{color:k||void 0},children:$.label})},$.url))})}),u.jsx(ud,{})]})]})}):null}function H1({children:r}){const l=g.useRef(null),i=g.useCallback(d=>{l.current=d},[]),c=g.useCallback(()=>{var d;(d=l.current)==null||d.call(l)},[]);return u.jsx(zg.Provider,{value:{registerGoHome:i,goHome:c},children:r})}function F1(){const[r,l]=g.useState(!1),[i,c]=g.useState(!1),[d,f]=g.useState(()=>localStorage.getItem("desktop-sidebar-collapsed")==="true"),h=Ve(v=>v.conversations),p=sy();if(g.useEffect(()=>{localStorage.setItem("desktop-sidebar-collapsed",String(d))},[d]),p)return u.jsx(ip,{children:u.jsx(M1,{message:p})});const x=h.some(v=>{var b;return(v.messages.length>0||(((b=v.attachedFiles)==null?void 0:b.length)??0)>0)&&!v.adapterLoadError});return u.jsx(ip,{children:u.jsx(Nx,{children:u.jsx(U1,{children:u.jsx(H1,{children:u.jsxs("div",{className:"h-dvh flex flex-col bg-white dark:bg-black text-slate-900 dark:text-slate-100",children:[u.jsxs("div",{className:"flex-1 flex flex-col md:flex-row md:pl-4 min-h-0",children:[x&&(d?u.jsx("div",{className:"hidden md:flex md:w-16 md:h-full shrink-0 items-start justify-center pt-8",children:u.jsx("button",{type:"button",onClick:()=>f(!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":"Open sidebar",title:"Open sidebar",children:u.jsx(Zx,{className:"h-4 w-4"})})}):u.jsx("div",{className:"hidden md:h-full md:flex",children:u.jsx(Hp,{onToggleDesktopSidebar:()=>f(!0)})})),u.jsxs("div",{className:"flex-1 flex flex-col w-full min-h-0",children:[u.jsx(B1,{}),u.jsx("div",{className:"flex-1 flex justify-center w-full min-h-0",children:u.jsx(y1,{onOpenSettings:()=>l(!0),onOpenSidebar:()=>c(!0)})})]})]}),u.jsx(O1,{}),u.jsx(E1,{isOpen:r,onClose:()=>l(!1)}),i&&u.jsxs("div",{className:"fixed inset-0 z-50 flex md:hidden",children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>c(!1),"aria-hidden":"true"}),u.jsxs("div",{className:"relative z-10 h-full w-[min(20rem,90vw)] animate-slideIn bg-white dark:bg-black",children:[u.jsx(Hp,{onRequestClose:()=>c(!1)}),u.jsx("button",{onClick:()=>c(!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":"Close menu",children:u.jsx(ua,{className:"h-5 w-5"})})]})]})]})})})})})}const nd=new vx({auth:{clientId:ug(),authority:`https://login.microsoftonline.com/${cy()}`,redirectUri:typeof window<"u"?window.location.origin:"/"},cache:{cacheLocation:"sessionStorage"}});function I1({children:r}){const[l,i]=g.useState(!1);return g.useEffect(()=>{nd.initialize().then(()=>nd.handleRedirectPromise()).catch(c=>{console.error("[EntraAuth] Redirect processing failed:",c)}).finally(()=>i(!0))},[]),l?u.jsx(wx,{instance:nd,children:r}):null}function G1({children:r}){if(!Sd()||!va())return u.jsx(u.Fragment,{children:r});if(Xo()==="entra")return u.jsx(I1,{children:r});const i=iy(),c=ug(),d=oy();return!i||!c?u.jsx(u.Fragment,{children:r}):u.jsx(Sx,{domain:i,clientId:c,authorizationParams:{redirect_uri:window.location.origin,...d?{audience:d}:{}},cacheLocation:"memory",children:r})}Lg(null);const Ip=Pb(),Gp=document.querySelector('link[rel="icon"]');if(Gp)Gp.href=Ip;else{const r=document.createElement("link");r.rel="icon",r.href=Ip,document.head.appendChild(r)}const V1=_y();var Vp,Xp,Yp,Qp,Zp,Kp;for(const r of V1){const l=((Vp=r.src)==null?void 0:Vp.trim())||"",i=((Xp=r.content)==null?void 0:Xp.trim())||"",c=((Yp=r.id)==null?void 0:Yp.trim())||"";if(!l&&!i||c&&document.querySelector(`script[data-orbitchat-startup-script-id="${c}"]`)||Array.from(document.querySelectorAll("script[data-orbitchat-startup-script]")).some(h=>{const p=l&&h.dataset.orbitchatStartupScriptSrc===l,x=i&&(h.textContent||"").trim()===i;return!!(p||x)}))continue;const f=document.createElement("script");l&&(f.src=l),i&&(f.text=i),f.async=r.async??!0,r.defer!==void 0&&(f.defer=r.defer),(Qp=r.type)!=null&&Qp.trim()&&(f.type=r.type.trim()),(Zp=r.integrity)!=null&&Zp.trim()&&(f.integrity=r.integrity.trim()),r.crossOrigin&&(f.crossOrigin=r.crossOrigin),(Kp=r.referrerPolicy)!=null&&Kp.trim()&&(f.referrerPolicy=r.referrerPolicy.trim()),f.dataset.orbitchatStartupScript="true",c&&(f.dataset.orbitchatStartupScriptId=c),l&&(f.dataset.orbitchatStartupScriptSrc=l),document.head.appendChild(f)}le("🚀 AI Chat Application started");le(`📱 App Version: v${Nd}`);jx.createRoot(document.getElementById("root")).render(u.jsx(g.StrictMode,{children:u.jsx(G1,{children:u.jsx(F1,{})})}));export{Yo as r};
|
|
365
|
+
}`;if(!i.trim())return[];try{const c=JSON.parse(i),d=new Set(Object.entries(c).filter(([,f])=>{if(typeof f=="string")return f.trim().length>0;if(f&&typeof f=="object"){const h=f;if(typeof h.apiKey=="string"&&h.apiKey.trim().length>0||typeof h.key=="string"&&h.key.trim().length>0)return!0}return!1}).map(([f])=>f));return l.filter(f=>d.has(f.id))}catch{return[]}}}return null}async function Cd(){if(Rl&&Date.now()-ed<Hv)return Rl;try{const l=await fetch("/api/adapters?refresh=1",{cache:"no-store",headers:{"Cache-Control":"no-cache"}});if(l.ok){const i=await l.json(),c=Cg(i.adapters);if(c.length>0)return Rl=c,ed=Date.now(),le("Fetched adapters from /api/adapters:",Rl),Rl;le("/api/adapters response did not contain valid adapters, trying fallback")}le(`/api/adapters returned ${l.status}, trying fallback`)}catch(l){le("Could not fetch from /api/adapters, trying fallback:",l)}const s=Fv();if(s&&s.length>0)return Rl=s,ed=Date.now(),le("Loaded adapters from config:",Rl),Rl;throw He("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 Iv="h-[96px]";function Gv({onAdapterSelect:s,className:l="",title:i="",subtitle:c="",eyebrow:d=""}){const[f,h]=g.useState([]),[p,x]=g.useState(!0),[v,b]=g.useState(null),w=g.useRef(null),k=g.useRef(null),[S,j]=g.useState(""),[_,z]=g.useState(!1),$=g.useCallback(()=>{const te=w.current;if(!te){z(!1);return}z(te.scrollHeight-te.scrollTop-te.clientHeight>20)},[]),ee=()=>typeof window<"u"&&window.matchMedia("(min-width: 768px)").matches,Y=()=>{var te;return Array.from(((te=w.current)==null?void 0:te.querySelectorAll('[data-agent-card="true"]'))??[])},R=te=>{const E=Y()[te]??null;E&&(E.focus(),E.scrollIntoView({block:"nearest"}))},q=()=>{R(0)},N=()=>{const te=Y();te.length!==0&&R(te.length-1)},X=te=>{if(!p&&!v&&I.length>0&&ee()){if(te.key==="Tab"&&!te.shiftKey){te.preventDefault(),q();return}if(te.key==="ArrowDown"){te.preventDefault(),q();return}te.key==="ArrowUp"&&(te.preventDefault(),N())}},U=te=>{var H;if(!ae||!ee()||te.key!=="ArrowDown"&&te.key!=="ArrowUp")return;const oe=document.activeElement;if(!(oe instanceof HTMLElement)||oe.dataset.agentCard!=="true")return;const E=Y(),V=E.indexOf(oe);if(V!==-1){if(te.preventDefault(),te.key==="ArrowDown"){R((V+1)%E.length);return}if(V===0){(H=k.current)==null||H.focus();return}R(V-1)}},Q=S.trim().toLowerCase(),I=Q?f.filter(te=>{var H,P;const oe=te.name.toLowerCase().includes(Q),E=((H=te.description)==null?void 0:H.toLowerCase().includes(Q))??!1,V=((P=te.model)==null?void 0:P.toLowerCase().includes(Q))??!1;return oe||E||V}):f,ae=S.trim().length>0,fe=ae||I.length===1;g.useEffect(()=>{const te=w.current;if(te)return $(),te.addEventListener("scroll",$,{passive:!0}),()=>te.removeEventListener("scroll",$)},[$,I]),g.useEffect(()=>{let te=!0;return(async()=>{try{x(!0),b(null);const V=(await Cd()).slice().sort((H,P)=>H.name.localeCompare(P.name,void 0,{sensitivity:"base"}));te&&h(V)}catch(E){He("[AgentSelectionList] Failed to load adapters",E),te&&b("Unable to load agents right now.")}finally{te&&x(!1)}})(),()=>{te=!1}},[]),g.useEffect(()=>{var te;p||v||f.length===0||(te=k.current)==null||te.focus()},[p,v,f.length]);const Ce=()=>p?u.jsx("div",{className:"grid gap-4",children:Array.from({length:3}).map((te,oe)=>u.jsx("div",{className:`${Iv} animate-pulse rounded-2xl border border-gray-200 bg-transparent dark:border-[#3b3c49]`},oe))}):v?u.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:v}):f.length===0?u.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:"No agents are available yet. Configure adapters in your middleware settings to continue."}):I.length===0?u.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:"No agents match your search."}):u.jsxs("div",{className:"relative flex flex-col h-full min-h-0",children:[u.jsx("div",{ref:w,onKeyDown:U,className:"agent-selection-scroll flex-1 min-h-0 overflow-y-auto pr-1 pb-2",children:fe?u.jsx("div",{className:"mx-auto flex w-full max-w-xl flex-col gap-3 lg:max-w-2xl",children:I.map(te=>u.jsx($p,{adapter:te,onSelect:oe=>s(oe.id)},te.id))}):u.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:I.map(te=>u.jsx($p,{adapter:te,onSelect:oe=>s(oe.id)},te.id))})}),_&&u.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 u.jsxs("div",{className:`flex w-full flex-col gap-4 md:gap-6 ${l}`,children:[(d||i||c)&&u.jsxs("div",{className:"flex-shrink-0",children:[d&&u.jsx("p",{className:"text-sm font-semibold uppercase tracking-wide text-blue-600 dark:text-blue-300",children:d}),i&&u.jsx("h2",{className:"mt-2 text-2xl font-bold text-gray-900 dark:text-white",children:i}),c&&u.jsx("p",{className:"mt-2 text-base text-gray-600 dark:text-gray-300",children:c})]}),u.jsx("div",{className:"flex w-full flex-shrink-0 justify-center",children:u.jsx("div",{className:"w-full max-w-xl lg:max-w-2xl",children:u.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:[u.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))]"}),u.jsx(gd,{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"}),u.jsx("input",{ref:k,type:"text",placeholder:"Search agents",value:S,maxLength:100,disabled:p||!!v||f.length===0,onChange:te=>j(te.target.value),onKeyDown:X,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"}),S&&u.jsx("button",{type:"button",onClick:()=>j(""),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":"Clear search",children:u.jsx(ua,{className:"h-3.5 w-3.5"})})]})})}),u.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:Ce()})]})}function ud(){return Sd()?Xo()==="entra"?u.jsx(Xv,{}):u.jsx(Vv,{}):null}function Vv(){const{user:s,logout:l,loginWithRedirect:i}=hd();if(!ir()||!s)return u.jsx(jg,{onClick:()=>i()});const d=s.name||s.email||"User";return u.jsx(Ng,{displayName:d,onClick:()=>l({logoutParams:{returnTo:window.location.origin}})})}function Xv(){const{instance:s,accounts:l}=md();if(!ir()||l.length===0)return u.jsx(jg,{onClick:()=>s.loginRedirect({scopes:kd()}).catch(()=>{})});const c=l[0],d=c.name||c.username||"User";return u.jsx(Ng,{displayName:d,onClick:()=>s.logoutRedirect({postLogoutRedirectUri:window.location.origin}).catch(()=>{})})}function jg({onClick:s}){return u.jsxs("button",{onClick:s,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:[u.jsx(ag,{className:"h-4 w-4"}),u.jsx("span",{children:"Sign in"})]})}function Ng({displayName:s,onClick:l}){return u.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm text-gray-600 dark:text-[#bfc2cd]",children:[u.jsx("span",{className:"hidden max-w-[170px] truncate font-medium md:block",title:s,children:s}),u.jsxs("button",{onClick:l,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:"Log out","aria-label":"Log out",children:[u.jsx(Bx,{className:"h-4 w-4"}),u.jsx("span",{className:"hidden md:inline",children:"Log out"})]})]})}function Tg({placement:s="default",compact:l=!1}){if(!mg())return null;const i=by(),c=yy(),d=vy(),f=wy(),h=Sy(),p=ky(),x=Ay(),v=f?"border-t border-slate-200/80 dark:border-[#333645]":"",b=l?s==="sidebar"?"pt-4 pb-2":"pt-2 pb-2":p==="normal"?"pt-3 pb-3":"pt-5 pb-3",w=h==="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",k="justify-center",S=s==="sidebar"?"w-full px-2":"w-full px-3 sm:px-6",j=s==="sidebar"?"w-full":"mx-auto w-full max-w-7xl",_=l?"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 u.jsx("footer",{className:`shrink-0 bg-white dark:bg-black text-sm ${b} ${v}`.trim(),style:{backgroundColor:c||void 0,color:d||void 0},children:u.jsx("div",{className:S,children:u.jsx("div",{className:j,children:u.jsxs("div",{className:w,children:[i&&u.jsx("p",{className:`${l?"text-xs leading-snug":"text-sm"} text-slate-700 dark:text-slate-200 ${s==="sidebar"?"pt-0.5":""}`.trim(),children:i}),x.length>0&&u.jsx("nav",{"aria-label":"Footer links",children:u.jsx("ul",{className:`flex flex-wrap items-center ${k} ${l?"gap-1":"gap-1.5 sm:gap-2"}`,children:x.map((z,$)=>{const ee=h==="inline"&&$>0;return u.jsxs("li",{className:"flex items-center",children:[ee&&u.jsx("span",{className:"mr-1.5 text-slate-400 dark:text-slate-500","aria-hidden":"true",children:"·"}),u.jsx("a",{href:z.url,target:"_blank",rel:"noopener noreferrer",className:_,style:{color:d||void 0},children:z.label})]},z.url)})})})]})})})})}const Yv=60*1e3;let td=null,qp=0;const ad=s=>{if(!s||s==="/")return"/";const l=s.trim();if(!l)return"/";const i=l.startsWith("/")?l:`/${l}`;return i==="/"?"/":i.endsWith("/")?i.slice(0,-1):i},Eg=()=>{if(typeof window>"u")return ad("/");const s=ad("/");if(typeof document>"u")return s;const l=document.querySelector("base[href]");if(!l)return s;try{const i=new URL(l.getAttribute("href")||"/",window.location.origin);return ad(i.pathname||s)}catch{return s}},Io=s=>s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),Qv=async()=>{const s=Date.now();if(td&&s-qp<Yv)return td;let l=[];try{l=await Cd()}catch(c){Be("[agentRouting] Unable to load adapters for slug resolution",c)}const i=new Map;return l.forEach(c=>{const d=Io(c.name);d&&i.set(d,c.id);const f=Io(c.id);f&&f!==d&&i.set(f,c.id)}),td=i,qp=s,i},dd=s=>{var f;const l=Eg(),i=s.startsWith("/")?s:`/${s}`;let c=i;if(l!=="/"){if(!i.startsWith(l))return null;c=i.slice(l.length)}const d=c.split("/").filter(Boolean);return d.length===0?null:((f=d[0])==null?void 0:f.toLowerCase())||null},Mg=s=>{const l=Eg();if(!s)return l;const i=s.replace(/^\/+|\/+$/g,"");return l==="/"?i?`/${i}`:"/":`${l}/${i}`.replace(/\/{2,}/g,"/")},Nn=s=>{if(typeof window>"u")return;const l=Mg(s),i=window.location.pathname;if(l===i)return;const c=window.location.search||"",d=window.location.hash||"";window.history.replaceState(window.history.state,"",`${l}${c}${d}`)},Zv=()=>Mg(null),Kv=async s=>{const l=s.trim().toLowerCase();return l&&(await Qv()).get(l)||null},Jv="Single adapter mode requires agentMode.defaultAdapterId to match an adapter id in orbitchat.yaml.";function Pv({currentConversation:s,showEmptyState:l,createConversation:i,configureApiSettings:c,clearError:d,clearCurrentConversationAdapter:f}){var we;const[h,p]=g.useState(!1),[x,v]=g.useState(null),b=Vo(),w=yd(),k=typeof window<"u"?dd(window.location.pathname):null,[S,j]=g.useState(k),[_,z]=g.useState(()=>!b&&l&&!k),$=g.useRef(null),ee=g.useRef(new Map),Y=g.useRef(0),R=3e4,q=!!s,N=(s==null?void 0:s.messages.length)??0,X=((we=s==null?void 0:s.attachedFiles)==null?void 0:we.length)??0,U=g.useMemo(()=>q&&(N>0||X>0),[X,N,q]),Q=g.useCallback(()=>{na(()=>Ve.getState())},[]),I=g.useCallback((W,re)=>{if(!W)return;const be=re||"Unable to configure this agent.";let ke=!1;Ve.setState(ge=>{const ze=ge.conversations.find(Ue=>Ue.id===W);return!ze||ze.messages.length>0?ge:(ke=!0,{conversations:ge.conversations.map(Ue=>Ue.id===W?{...Ue,adapterLoadError:be}:Ue)})}),ke&&Q()},[Q]),ae=g.useCallback(W=>{if(!W)return;let re=!1;Ve.setState(be=>{const ke=be.conversations.find(ge=>ge.id===W);return!ke||!ke.adapterLoadError?be:(re=!0,{conversations:be.conversations.map(ge=>ge.id===W?{...ge,adapterLoadError:null}:ge)})}),re&&Q()},[Q]),fe=g.useCallback(W=>W instanceof yg?W.status===401?"We couldn’t load this agent. It may not exist or you might not have access to it.":W.status===404?"This agent was not found on the server. Please pick another agent.":W.message:W instanceof Error?W.message:"Unable to load agent overview right now.",[]),Ce=g.useCallback(()=>{const W=Ve.getState(),re=W.currentConversationId?W.conversations.find(be=>be.id===W.currentConversationId):null;if(!re||re.messages.length>0)try{return i()}catch(be){Be("Cannot create a new conversation for agent selection:",be instanceof Error?be.message:"Unknown error")}return(re==null?void 0:re.id)||null},[i]),te=g.useCallback(async W=>{if(!(W!=null&&W.adapterName))return{ok:!1};try{const re=await kt(),be=new re.ApiClient({apiUrl:W.apiUrl||_t(),sessionId:null,adapterName:W.adapterName});if(typeof be.getAdapterInfo!="function")return{ok:!1};const ke=await be.getAdapterInfo();return Ve.setState(ge=>({conversations:ge.conversations.map(ze=>ze.id===W.id?{...ze,adapterInfo:ke,adapterLoadError:null,updatedAt:new Date}:ze)})),Ve.getState().currentConversationId===W.id&&v(null),Q(),{ok:!0}}catch(re){const be=fe(re),ke=Ve.getState();ke.currentConversationId===W.id&&v({conversationId:W.id,message:be});const ge=ke.conversations.find(ze=>ze.id===W.id);return ge&&ge.messages.length===0&&I(W.id,be),{ok:!1,error:re}}},[fe,I,Q]),oe=g.useCallback(async W=>{if(!W)return;const re=Ve.getState(),be=re.currentConversationId?re.conversations.find(ke=>ke.id===re.currentConversationId):null;if(be){p(!0),v(null),ae(be.id);try{const ke=be.apiUrl||_t();await c(ke,void 0,W),d();const ge=Ve.getState(),ze=ge.conversations.find(Ue=>Ue.id===ge.currentConversationId);if((ze==null?void 0:ze.adapterName)===W&&(!ze.adapterInfo||ze.adapterInfo.notes===void 0)){const Ue=await te(ze);!Ue.ok&&Ue.error&&He("Failed to load adapter info after selecting adapter:",Ue.error)}}catch(ke){He("Failed to configure adapter from empty state:",ke);const ge=fe(ke);v({conversationId:be.id,message:ge}),I(be.id,ge)}finally{p(!1)}}},[ae,d,c,te,fe,I]),E=g.useCallback(W=>{b||(Ce(),z(!1),Nn(Io(W)),oe(W))},[Ce,oe,b]),V=g.useCallback(()=>{b||(f(),Nn(null),z(!0))},[f,b]),H=g.useCallback(()=>{var ke,ge;if(b){const ze=Ve.getState(),Ue=ze.currentConversationId?ze.conversations.find(je=>je.id===ze.currentConversationId):null;if(!!Ue&&(Ue.messages.length>0||(((ke=Ue.attachedFiles)==null?void 0:ke.length)||0)>0))try{i()}catch(je){Be("Cannot go home (new conversation):",je instanceof Error?je.message:"Unknown error")}Nn(null),z(!1);return}j(null);const W=Ve.getState(),re=W.currentConversationId?W.conversations.find(ze=>ze.id===W.currentConversationId):null;if(!!re&&(re.messages.length>0||(((ge=re.attachedFiles)==null?void 0:ge.length)||0)>0))try{i()}catch(ze){Be("Cannot go home (new conversation):",ze instanceof Error?ze.message:"Unknown error");return}else re!=null&&re.adapterName&&f();Nn(null),z(!0)},[f,i,b]),ce=!b&&l&&!S&&!(s!=null&&s.adapterName)&&!U||!b&&l&&_&&!(s!=null&&s.adapterName)&&!U;g.useEffect(()=>{if(b){Nn(null);return}if(!S){if(ce||!(s!=null&&s.adapterName)){Nn(null);return}Nn(Io(s.adapterName))}},[s==null?void 0:s.adapterName,b,S,ce]);const xe=g.useCallback(async()=>{if(typeof window>"u")return;const W=++Y.current;if(b){Nn(null),j(null);return}const re=dd(window.location.pathname);if(!re)return;const be=await Kv(re);if(W===Y.current){if(!be){Ce(),Nn(null),f(),z(!0),j(null);return}Ce(),z(!1),Nn(re),await oe(be),j(null)}},[f,Ce,oe,b]);g.useEffect(()=>{const W=window.setTimeout(()=>{xe()},0),re=()=>{xe()};return window.addEventListener("popstate",re),()=>{window.clearTimeout(W),Y.current+=1,window.removeEventListener("popstate",re)}},[xe]);const pe=s==null?void 0:s.id,F=s==null?void 0:s.adapterName,me=s==null?void 0:s.apiUrl,ue=!!(s!=null&&s.adapterInfo);g.useEffect(()=>{if(!b||!w||!l||!pe||U||h)return;const W=(F==null?void 0:F.trim())||w,re=(F==null?void 0:F.trim())!==W||!ue;if(!W||!re)return;let be=!1;return(async()=>{p(!0),v(null),ae(pe);try{const ge=me||_t();await c(ge,void 0,W),d()}catch(ge){if(!be){const ze=fe(ge);v({conversationId:pe,message:ze}),I(pe,ze)}}finally{be||p(!1)}})(),()=>{be=!0}},[ae,d,c,U,fe,h,b,I,l,F,me,ue,pe,w]),g.useEffect(()=>{(async()=>{var ke;const re=s==null?void 0:s.adapterName;if($.current===re)return;const be=!(s!=null&&s.adapterInfo)||(s==null?void 0:s.adapterInfo)&&s.adapterInfo.notes===void 0;if(re&&be){$.current=re,le("[ChatInterface] Loading adapter info - adapterName:",re,"reason:",s!=null&&s.adapterInfo?"notes undefined":"missing");const ge=await te(s);if(ge.ok)le("[ChatInterface] Adapter info loaded successfully");else{const ze=ge.error;He("[ChatInterface] Failed to load adapter info:",ze);const Ue=ze instanceof Error?ze.message:String(ze);if((Ue.includes("429")||Ue.includes("Too Many Requests"))&&re){const je=ee.current.get(re);je&&clearTimeout(je);const Xe=setTimeout(()=>{$.current===re&&($.current=null),ee.current.delete(re)},R);ee.current.set(re,Xe),Be(`[ChatInterface] Adapter info request rate-limited; retrying in ${R/1e3}s`)}else $.current=null}}else le("[ChatInterface] Skipping adapter info load:",{adapterName:re,hasAdapterInfo:!!(s!=null&&s.adapterInfo),hasNotes:((ke=s==null?void 0:s.adapterInfo)==null?void 0:ke.notes)!==void 0,refValue:$.current})})()},[te,s]),g.useEffect(()=>{const W=ee.current;return()=>{W.forEach(re=>clearTimeout(re)),W.clear()}},[]);const de=b&&!w?Jv:(s==null?void 0:s.adapterLoadError)??((x==null?void 0:x.conversationId)===(s==null?void 0:s.id)?x.message:null);return{adapterNotesError:de,handleAgentCardSelection:E,handleChangeAgent:V,goToAgentSelectionHome:H,hasAdapterConfigurationError:!!de,isAgentSelectionVisible:_,isConfiguringAdapter:h,isSingleAdapterMode:b,setIsAgentSelectionVisible:z,shouldShowAgentSelectionList:ce}}const zg=g.createContext(null),Wv={registerGoHome:()=>{},goHome:()=>{}};function Dg(){return g.useContext(zg)??Wv}function e1({adapter:s,syntaxTheme:l,forcedThemeClass:i=""}){var d;const c=(d=s.notes)==null?void 0:d.trim();return c?u.jsxs("section",{"aria-labelledby":"agent-seo-content-title",className:"mx-auto w-full max-w-[56rem] px-1 text-left sm:px-0",children:[u.jsx("h2",{id:"agent-seo-content-title",className:"sr-only",children:s.name}),u.jsx("div",{children:u.jsx(el,{content:c,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 ${i}`,syntaxTheme:l})})]}):null}const t1='meta[name="description"]',a1='meta[property="og:title"]',n1='meta[property="og:description"]',l1='meta[property="og:type"]',s1='link[rel="canonical"]';function Bp(s){return s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function r1(s){return s.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 i1(s,l){const i=s==null?void 0:s.trim();if(i)return i;if(!l)return wd();const c=r1(l);return c.length>160?`${c.slice(0,157).trimEnd()}...`:c}function o1(s){return s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function c1(s){const l=s.trim();if(!l)return null;try{return new URL(l).origin}catch{return null}}function u1(s){const l=s.trim();if(!l)return null;const i=`^${o1(l).replace(/\\\*/g,".*")}$`;try{return new RegExp(i,"i")}catch{return null}}function d1(s){return[og(),...Zb()].map(c1).filter(i=>!!i).includes(s)?!0:Kb().some(i=>{const c=u1(i);return c?c.test(s):!1})}function f1(s){var c,d,f;const l=s==null?void 0:s.trim();if(!l)return null;const i=ye.adapters.find(h=>{var p;return((p=h==null?void 0:h.id)==null?void 0:p.trim())===l});return i?{id:i.id,name:((c=i.name)==null?void 0:c.trim())||i.id,description:((d=i.description)==null?void 0:d.trim())||void 0,notes:((f=i.notes)==null?void 0:f.trim())||void 0}:null}function m1(s){var c,d,f;if(typeof window>"u")return null;const l=dd(window.location.pathname);if(!l)return null;const i=ye.adapters.find(h=>{const p=Bp(h.name||""),x=Bp(h.id||"");return l===p||l===x});return i?{id:i.id,name:((c=i.name)==null?void 0:c.trim())||i.id,description:((d=i.description)==null?void 0:d.trim())||void 0,notes:((f=i.notes)==null?void 0:f.trim())||void 0}:null}function To(s,l,i){if(typeof document>"u")return null;const c=document.querySelector(s);if(c)return c;const d=document.createElement("meta");return d.setAttribute(l,i),document.head.appendChild(d),d}function h1(){if(typeof document>"u")return null;const s=document.querySelector(s1);if(s)return s;const l=document.createElement("link");return l.rel="canonical",document.head.appendChild(l),l}function Lg(s){if(typeof document>"u")return;const l=vd(),i=s?`${s.name} | ${l}`:l,c=s?i1(s.description,s.notes):wd();document.title=i;const d=To(t1,"name","description");d&&(d.content=c);const f=To(a1,"property","og:title");f&&(f.content=i);const h=To(n1,"property","og:description");h&&(h.content=c);const p=To(l1,"property","og:type");p&&(p.content="website");const x=h1();if(x&&typeof window<"u"){const v=og(),b=window.location.origin,w=v?new URL(v.endsWith("/")?v:`${v}/`).origin:"",S=`${b&&d1(b)?b:w||b}${window.location.pathname}`;x.href=S}}function p1(){return Jb()}class jd{static async getAdapterModels(l,i){const c=await kt(),d=new c.ApiClient({apiUrl:"",adapterName:i});if(!d.getAdapterModels)throw new Error("getAdapterModels is not available on this API client");return d.getAdapterModels(l)}static async getAllModels(l){const i=await kt(),c=new i.ApiClient({apiUrl:"",adapterName:l});if(!c.getAllModels)throw new Error("getAllModels is not available on this API client");return c.getAllModels()}static async listAdapterModels(l,i){return(await jd.getAdapterModels(l,i)).models}}const g1="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",x1="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",b1="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 y1({onOpenSettings:s,onOpenSidebar:l}){var ta,gn,At,gt,Ht,_e,Sa;const{conversations:i,currentConversationId:c,createConversation:d,canCreateNewConversation:f,sendMessage:h,regenerateResponse:p,isLoading:x,configureApiSettings:v,error:b,clearError:w,createThread:k,clearCurrentConversationAdapter:S}=Ve(),{settings:j}=Go(),_=ir(),z=va()&&!_,{theme:$,isDark:ee}=rr(),Y=$.mode==="dark"?"dark":$.mode==="light"?"light":"",R=ee?"dark":"light",q=["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",Y].filter(Boolean).join(" "),N=i.find(Te=>Te.id===c),X=i.some(Te=>{var Qe;return(Te.messages.length>0||(((Qe=Te.attachedFiles)==null?void 0:Qe.length)||0)>0)&&!Te.adapterLoadError}),U=!N||N.messages.length===0,Q=((ta=N==null?void 0:N.adapterInfo)==null?void 0:ta.supportsThreading)===!0,I=!!(N!=null&&N.adapterName&&(N!=null&&N.adapterInfo))&&!Q,ae=vg({adapterName:N==null?void 0:N.adapterName,enabled:I,selectionScopeKey:c,supportsThreading:Q}),fe=ig(),Ce=vd(),te=wd().trim(),oe=te.length>0,{registerGoHome:E}=Dg(),[V,H]=g.useState([]),[P,ce]=g.useState(null);g.useEffect(()=>{const Te=N==null?void 0:N.adapterName;let Qe=!1;async function bt(){if(ce(null),!Te){H([]);return}try{const it=await jd.listAdapterModels(Te,Te);if(Qe)return;H(it),ce(it.length>0?it[0].name:null)}catch{Qe||(H([]),ce(null))}}return bt(),()=>{Qe=!0}},[N==null?void 0:N.adapterName]);const{adapterNotesError:xe,handleAgentCardSelection:pe,handleChangeAgent:F,goToAgentSelectionHome:me,hasAdapterConfigurationError:ue,isAgentSelectionVisible:de,isConfiguringAdapter:we,isSingleAdapterMode:W,shouldShowAgentSelectionList:re}=Pv({currentConversation:N,showEmptyState:U,createConversation:d,configureApiSettings:v,clearError:w,clearCurrentConversationAdapter:S});g.useLayoutEffect(()=>(E(()=>me()),()=>E(null)),[E,me]);const be="max-w-[96rem]",ke="max-w-[64rem]",ge="max-w-[56rem]",ze=`mx-auto w-full ${be}`,Ue=f(),Fe=!!(N!=null&&N.adapterName)&&((N==null?void 0:N.messages.length)||0)===0,je=Ue?"Start a new conversation":z?"Guest conversation limit reached. Sign in for more conversations.":"Finish your current conversation before starting a new one.",Xe=!!(N&&!re),et=re?"border-transparent dark:border-transparent md:border-transparent md:dark:border-transparent":"",Bt=!rd()&&re?"pt-0 pb-0 md:pt-0 md:pb-1":"",ie=`${b1} ${et} ${Bt}`.trim(),Ne=mg(),Tt=i.some(Te=>{var Qe;return(Te.messages.length>0||(((Qe=Te.attachedFiles)==null?void 0:Qe.length)??0)>0)&&!Te.adapterLoadError}),Oe=Ne&&!Tt,Vt=re?"pt-0 md:pt-0":"pt-4 md:pt-6",da=g.useMemo(()=>{var it,Ae,la;if(re)return null;const Te=f1(N==null?void 0:N.adapterName)||m1();if(!Te&&!(N!=null&&N.adapterName))return null;const Qe=(it=N==null?void 0:N.adapterName)==null?void 0:it.trim(),bt=(la=(Ae=N==null?void 0:N.adapterInfo)==null?void 0:Ae.notes)==null?void 0:la.trim();return Te?{...Te,notes:bt||Te.notes}:Qe?{id:Qe,name:Qe,notes:bt||void 0}:null},[(gn=N==null?void 0:N.adapterInfo)==null?void 0:gn.notes,N==null?void 0:N.adapterName,re]);g.useEffect(()=>{Lg(da)},[da]),g.useEffect(()=>{let Te=null;const Qe=()=>{Te&&(Te(),Te=null)};if(j.voiceEnabled){if(Ul.isAudioEnabled())return le("[ChatInterface] Audio streaming already enabled"),Qe;const bt=()=>{Qe();const it=async()=>{Qe(),await Ul.enableAudio()?le("[ChatInterface] Audio streaming enabled after user gesture"):(Be("[ChatInterface] User gesture did not enable audio streaming"),bt())};document.addEventListener("pointerdown",it,{once:!0}),document.addEventListener("keydown",it,{once:!0}),Te=()=>{document.removeEventListener("pointerdown",it),document.removeEventListener("keydown",it)},le("[ChatInterface] Waiting for user gesture to enable audio streaming")};return bt(),Qe}return Qe(),Ul.disableAudio(),le("[ChatInterface] Audio streaming disabled via settings"),Qe},[j.voiceEnabled]);const Xt=(Te,Qe,bt,it)=>{h(Te,Qe,bt,P??void 0,it)},ea=async(Te,Qe,bt,it,Ae)=>{await h(bt,void 0,Te,Ae??P??void 0,it)},pn=()=>{try{d()}catch(Te){Be("Cannot create new conversation:",Te instanceof Error?Te.message:"Unknown error")}},en=g.useCallback(async(Te,Qe)=>{if(N)try{await Ve.getState().deleteThread(N.id,Te,Qe)}catch(bt){He("Failed to clear thread:",bt)}},[N]);return u.jsx("main",{className:"flex-1 flex flex-col bg-transparent overflow-hidden","aria-label":"Chat workspace",children:u.jsx("div",{className:"flex h-full w-full flex-col overflow-hidden px-3 sm:px-5 lg:px-8",children:u.jsxs("div",{className:`mx-auto flex h-full w-full ${be} flex-col overflow-hidden md:pb-4 ${g1}`,children:[b&&u.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:u.jsxs("div",{className:"flex items-start justify-between",children:[u.jsx("p",{children:b}),u.jsx("button",{onClick:w,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":"Dismiss error",children:"×"})]})}),u.jsxs("div",{className:ie,children:[l&&u.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2 md:hidden",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsxs("button",{onClick:l,disabled:!X,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 ${X?"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":"Open conversations menu",children:[u.jsx(Fx,{className:"h-4 w-4"}),"Chats"]}),u.jsxs("button",{onClick:s,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":"Open settings",children:[u.jsx(dp,{className:"h-4 w-4"}),"Settings"]})]}),u.jsx("div",{className:"ml-auto flex-shrink-0",children:u.jsx(ud,{})})]}),u.jsxs("div",{className:"flex flex-col gap-2 md:gap-4 sm:flex-row sm:items-end sm:justify-between",children:[u.jsx("div",{className:"min-w-0 flex-1",children:Xe&&u.jsx("div",{className:"space-y-1.5 md:space-y-3",children:u.jsxs("div",{className:"md:space-y-1",children:[u.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[u.jsx("h1",{className:"min-w-0 truncate text-lg md:text-2xl font-semibold text-[#353740] dark:text-[#ececf1]",children:(N==null?void 0:N.title)||"New Chat"}),N&&u.jsx("span",{className:"flex-shrink-0 text-xs md:hidden text-gray-500 dark:text-[#bfc2cd]",children:N.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),N&&u.jsx("div",{className:"hidden md:flex items-center text-sm text-gray-500 dark:text-[#bfc2cd]",children:u.jsxs("span",{children:["Updated ",N.updatedAt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})})]})})}),u.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:[u.jsx("div",{className:"hidden flex-shrink-0 items-center md:inline-flex",children:u.jsx("button",{onClick:s,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":"Settings",title:"Settings",children:u.jsx(dp,{className:"h-4 w-4"})})}),!W&&!re&&!!(N!=null&&N.adapterName)&&u.jsx("button",{type:"button",onClick:()=>{Fe&&F()},disabled:!Fe,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 ${Fe?"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:Fe?"Switch to a different agent before starting this conversation":"Agent cannot be changed after the conversation has started",children:"Change Agent"}),!re&&u.jsxs("button",{onClick:pn,disabled:!Ue,className:`order-3 sm:order-2 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] ${Ue?"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:je,children:[u.jsx(eb,{className:"h-3.5 w-3.5"}),"New Conversation"]}),!rd()&&u.jsx("div",{className:"order-4 hidden flex-shrink-0 items-center md:inline-flex",children:u.jsx(ud,{})})]})]})]}),U?u.jsxs("div",{className:`flex flex-1 flex-col min-h-0 ${Vt} ${re?"overflow-hidden":""}`,children:[re?u.jsx("div",{className:"flex-1 flex flex-col md:justify-start min-h-0 overflow-hidden",children:u.jsx("div",{className:"w-full flex flex-col min-h-0 overflow-hidden flex-1",children:u.jsxs("div",{className:"flex flex-col min-h-0 flex-1 gap-3 overflow-hidden md:gap-6",children:[u.jsx("div",{className:`${ze} flex-shrink-0 flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:u.jsxs("div",{className:"flex-1",children:[u.jsx(el,{content:Ce,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:R}),oe&&u.jsx("div",{className:"mt-2",children:u.jsx(el,{content:te,className:q,syntaxTheme:R})})]})}),u.jsx(Gv,{onAdapterSelect:pe,className:`${ze} md:flex-1 md:min-h-0 md:overflow-hidden`})]})})}):u.jsx("div",{className:"flex flex-1 w-full min-h-0 flex-col overflow-y-auto pt-4 md:pt-6",children:u.jsxs("div",{className:`mx-auto flex w-full ${ge} flex-col items-center gap-4 pb-8 md:gap-5 md:pb-12`,children:[xe?u.jsx("p",{className:"w-full text-center text-sm text-red-600 dark:text-red-400",children:xe}):N!=null&&N.adapterName?u.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:Yb(N.adapterName)||N.adapterName}):we?u.jsx("p",{className:"w-full text-center text-sm text-gray-500 dark:text-[#bfc2cd]",children:"Configuring your agent…"}):null,da&&p1()&&u.jsx(e1,{adapter:da,syntaxTheme:R,forcedThemeClass:Y}),u.jsx("div",{className:"w-full min-w-0",children:u.jsx(Op,{onSend:Xt,disabled:x||!N||!(N!=null&&N.adapterName)||ue,autoFocusEnabled:!0,placeholder:fe,isCentered:!0,maxWidthClass:ge,adapterNotes:(At=N==null?void 0:N.adapterInfo)==null?void 0:At.notes,skillState:ae,availableModels:V,defaultModel:((gt=N==null?void 0:N.adapterInfo)==null?void 0:gt.model)??null,selectedModel:P,onSelectModel:ce})})]})}),Oe&&u.jsx("div",{className:"shrink-0 pt-5 md:pt-6",children:u.jsx(Tg,{compact:!0})})]}):u.jsxs("div",{className:"flex flex-1 flex-col min-h-0",children:[u.jsx(vv,{messages:N.messages,onRegenerate:Te=>p(Te,P??void 0),onStartThread:async(Te,Qe)=>{try{await k(Te,Qe)}catch(bt){He("Failed to create thread:",bt)}},onClearThread:en,onSendThreadMessage:ea,sessionId:N.sessionId,isLoading:x,contentMaxWidthClass:ke,availableModels:V,defaultModel:((Ht=N==null?void 0:N.adapterInfo)==null?void 0:Ht.model)??null,selectedModel:P}),u.jsx("div",{className:x1,children:u.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:u.jsx(Op,{onSend:Xt,disabled:x||!N||!N.adapterName||de||ue,autoFocusEnabled:!0,placeholder:"Start a new topic...",maxWidthClass:ke,isCentered:!1,adapterNotes:(_e=N==null?void 0:N.adapterInfo)==null?void 0:_e.notes,skillState:ae,availableModels:V,defaultModel:((Sa=N==null?void 0:N.adapterInfo)==null?void 0:Sa.model)??null,selectedModel:P,onSelectModel:ce})})})]})]})})})}function v1({selectedAdapter:s,onAdapterChange:l,disabled:i,showDescriptions:c=!1,variant:d="sidebar",label:f,showLabel:h}){const[p,x]=g.useState([]),[v,b]=g.useState(!0),[w,k]=g.useState(null),[S,j]=g.useState(!1);g.useEffect(()=>{let U=!0;async function Q(){try{b(!0),k(null);const I=await Cd();U&&x(I)}catch(I){He("Failed to load adapters:",I),U&&k("Failed to load adapters. Please check your connection.")}finally{U&&b(!1)}}return Q(),()=>{U=!1}},[]);const _=p.find(U=>U.id===s),z=typeof h=="boolean"?h:d==="prominent",$=f||(d==="prominent"?"Select an agent":"Adapter"),ee=g.useMemo(()=>d==="prominent"?"relative w-full text-left":"relative w-full",[d]),Y=g.useMemo(()=>{const U="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 d==="prominent"?[U,"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(" ")},[d]),R=g.useMemo(()=>d==="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]",[d]),X=z?`mb-2 block text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-[#bfc2cd] ${d==="prominent"?"!text-sm !font-semibold !text-gray-700 dark:!text-white":""}`:"sr-only";return u.jsxs("div",{className:ee,children:[u.jsx("label",{className:X,children:$}),u.jsxs("div",{className:"relative",children:[u.jsx("button",{type:"button",onClick:()=>!i&&j(!S),disabled:i||v||p.length===0,className:`${Y} disabled:opacity-50 disabled:cursor-not-allowed`,"aria-label":$,children:u.jsxs("div",{className:"flex items-center justify-between gap-2",children:[u.jsxs("div",{className:"flex flex-col min-w-0",children:[u.jsx("span",{className:`truncate font-medium ${_?"text-[#11121a] dark:text-white":"text-gray-500 dark:text-gray-400"}`,children:v?"Loading agents…":w?"Error loading agents":_?_.name:p.length===0?"No agents available":"Select an agent"}),d==="prominent"&&(_==null?void 0:_.description)&&u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:_.description})]}),u.jsx(di,{className:`h-4 w-4 flex-shrink-0 transition-transform text-gray-400 dark:text-gray-300 ${S?"rotate-180":""}`})]})}),S&&!i&&p.length>0&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>j(!1)}),u.jsx("div",{className:R,children:u.jsx("div",{className:"max-h-72 overflow-auto py-2",children:p.map(U=>{const Q=U.id===s;return u.jsx("button",{type:"button",onClick:()=>{Q||l(U.id),j(!1)},className:`w-full px-4 py-3 text-left text-sm transition-colors ${Q?"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:u.jsxs("div",{className:"flex flex-col gap-1",children:[u.jsx("span",{className:"font-medium truncate",children:U.name}),c&&U.description&&u.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",style:{display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:U.description})]})},U.id)})})})]})]}),w&&u.jsx("p",{className:"mt-1 text-xs text-red-600 dark:text-red-400",children:w})]})}const Eo=100;function w1(s,l){const i=new Date(l.getFullYear(),l.getMonth(),l.getDate()),c=new Date(i);c.setDate(c.getDate()-1);const d=new Date(i);d.setDate(d.getDate()-i.getDay());const f=new Date(l.getFullYear(),l.getMonth(),1);return s>=i?"Today":s>=c?"Yesterday":s>=d?"This Week":s>=f?"This Month":"Earlier"}function S1(s){const l=new Date,i=["Today","Yesterday","This Week","This Month","Earlier"],c=new Map;for(const d of s){const f=w1(d.updatedAt,l),h=c.get(f);h?h.push(d):c.set(f,[d])}return i.filter(d=>c.has(d)).map(d=>({label:d,conversations:c.get(d)}))}function Hp({onRequestClose:s,onToggleDesktopSidebar:l}){const i=Vo(),{conversations:c,currentConversationId:d,selectConversation:f,deleteConversation:h,deleteAllConversations:p,updateConversationTitle:x,getConversationCount:v,configureApiSettings:b,clearError:w}=Ve(),k=c.find(ie=>ie.id===d),[S,j]=g.useState(""),[_,z]=g.useState(null),[$,ee]=g.useState(""),[Y,R]=g.useState({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1}),[q,N]=g.useState({isOpen:!1,isDeleting:!1}),[X,U]=g.useState(!1),[Q,I]=g.useState(null),[ae,fe]=g.useState(!1),[Ce,te]=g.useState(null),oe=g.useRef(null),E=g.useRef(null),V=g.useRef(null),H=!k||k.messages.length===0,P=(Q==null?void 0:Q.conversationId)===d?Q.adapterName:(k==null?void 0:k.adapterName)??null,ce=(Ce==null?void 0:Ce.conversationId)===d?Ce.message:null,xe=g.useMemo(()=>c.filter(ie=>{var Ne;return(ie.messages.length>0||(((Ne=ie.attachedFiles)==null?void 0:Ne.length)||0)>0)&&!ie.adapterLoadError}),[c]),pe=g.useMemo(()=>{if(!S)return xe;const ie=S.toLowerCase();return xe.filter(Ne=>Ne.title.toLowerCase().includes(ie)||Ne.messages.some(Tt=>Tt.content.toLowerCase().includes(ie))||(Ne.attachedFiles||[]).some(Tt=>Tt.filename.toLowerCase().includes(ie)))},[xe,S]),F=g.useMemo(()=>S1(pe),[pe]),me=v(),ue=S.length>0,de=xe.length>0;g.useEffect(()=>{if(!d||!E.current)return;const ie=E.current.querySelector('[aria-current="true"]');ie&&ie.scrollIntoView({block:"nearest",behavior:"smooth"})},[d]);const we=g.useCallback(ie=>{var da;if(ie.key!=="ArrowDown"&&ie.key!=="ArrowUp")return;ie.preventDefault();const Ne=(da=E.current)==null?void 0:da.querySelectorAll('[role="option"]');if(!Ne||Ne.length===0)return;const Tt=document.activeElement,Oe=Array.from(Ne).indexOf(Tt);let Vt;ie.key==="ArrowDown"?Vt=Oe<Ne.length-1?Oe+1:0:Vt=Oe>0?Oe-1:Ne.length-1,Ne[Vt].focus()},[]),W=async ie=>{if(!(!H||!ie)){I({conversationId:d??null,adapterName:ie}),te(null),fe(!0);try{const Ne=(k==null?void 0:k.apiUrl)||_t();await b(Ne,void 0,ie),w(),U(!1)}catch(Ne){He("Failed to configure adapter:",Ne),te({conversationId:d??null,message:Ne instanceof Error?Ne.message:"Failed to configure adapter"})}finally{fe(!1)}}},re=async ie=>{try{await f(ie),s==null||s()}catch(Ne){He("Failed to select conversation:",Ne)}},be=(ie,Ne)=>{ie.stopPropagation(),R({isOpen:!0,conversationId:Ne.id,conversationTitle:Ne.title,isDeleting:!1})},ke=async()=>{R(ie=>({...ie,isDeleting:!0}));try{await h(Y.conversationId)}catch(ie){He("Failed to delete conversation:",ie)}R({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},ge=()=>{R({isOpen:!1,conversationId:"",conversationTitle:"",isDeleting:!1})},ze=(ie,Ne)=>{ie.stopPropagation(),z(Ne.id),ee(Ne.title.slice(0,Eo))},Ue=ie=>{const Ne=$.slice(0,Eo).trim();Ne&&x(ie,Ne),z(null),ee("")},Fe=()=>{z(null),ee("")},je=()=>{N({isOpen:!0,isDeleting:!1})},Xe=async()=>{N(ie=>({...ie,isDeleting:!0}));try{await p()}catch(ie){He("Failed to clear all conversations:",ie)}N({isOpen:!1,isDeleting:!1})},et=()=>{N({isOpen:!1,isDeleting:!1})},Bt=ie=>{var Ne,Tt,Oe;return(Ne=ie.adapterName)!=null&&Ne.trim()?ie.adapterName:(Oe=(Tt=ie.adapterInfo)==null?void 0:Tt.adapter_name)!=null&&Oe.trim()?ie.adapterInfo.adapter_name:null};ci(oe,{enabled:X,onEscape:()=>U(!1)});const xt=ie=>{const Ne=d===ie.id,Tt=Bt(ie);return u.jsx("div",{role:"option","aria-selected":Ne,tabIndex:0,onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),re(ie.id))},onClick:()=>re(ie.id),className:`group relative flex w-full cursor-pointer items-center rounded-lg px-3 py-2 text-left text-sm transition-colors duration-100
|
|
366
|
+
${Ne?"bg-slate-100 dark:bg-[#2a2b36]":"hover:bg-slate-100/70 dark:hover:bg-[#25262f]"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-sky-500/50 dark:focus-visible:ring-sky-400/40`,"aria-current":Ne?"true":void 0,"aria-label":`Open conversation: ${ie.title}`,children:_===ie.id?u.jsx("input",{type:"text",value:$,onChange:Oe=>ee(Oe.target.value.slice(0,Eo)),onKeyDown:Oe=>{Oe.key==="Enter"&&Ue(ie.id),Oe.key==="Escape"&&Fe(),Oe.stopPropagation()},onBlur:()=>Ue(ie.id),maxLength:Eo,className:"flex-1 rounded border border-sky-300 bg-white px-2 py-0.5 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":"Edit conversation title"}):u.jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5",children:[u.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[u.jsx("h3",{className:`flex-1 truncate text-sm leading-snug ${Ne?"font-medium text-slate-900 dark:text-[#ececf1]":"font-normal text-slate-700 dark:text-[#c5c8d6]"}`,children:ie.title}),u.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:[u.jsx("button",{onClick:Oe=>ze(Oe,ie),className:"rounded p-1 text-slate-400 transition-colors hover:bg-slate-200/80 hover:text-slate-600 dark:text-[#6b6f7a] dark:hover:bg-[#3c3f4a] dark:hover:text-[#c5c8d6]","aria-label":`Rename conversation: ${ie.title}`,children:u.jsx(Px,{className:"h-3 w-3"})}),u.jsx("button",{onClick:Oe=>be(Oe,ie),className:"rounded p-1 text-slate-400 transition-colors hover:bg-red-100/80 hover:text-red-600 dark:text-[#6b6f7a] dark:hover:bg-red-900/30 dark:hover:text-red-400","aria-label":`Delete conversation: ${ie.title}`,children:u.jsx(sg,{className:"h-3 w-3"})})]})]}),Tt&&u.jsx("span",{className:"truncate text-[11px] leading-none text-slate-400 dark:text-[#6b6f7a]",children:Tt})]})},ie.id)};return u.jsxs(u.Fragment,{children:[!i&&X&&u.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm px-4",children:u.jsxs("div",{ref:oe,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:[u.jsx("h2",{id:"select-agent-title",className:"mb-4 text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:"Select an Agent"}),u.jsxs("div",{className:"space-y-5",children:[u.jsx(v1,{selectedAdapter:P,onAdapterChange:W,disabled:ae,variant:"prominent",showDescriptions:!0,showLabel:!1}),ce&&u.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:ce}),u.jsx("div",{className:"flex justify-end gap-3 pt-2",children:u.jsx("button",{type:"button",onClick:()=>{te(null),U(!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:ae,children:"Cancel"})})]})]})}),u.jsxs("nav",{"aria-label":"Conversation sidebar",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:[u.jsxs("div",{className:"bg-transparent px-4 pb-4 pt-4 dark:border-[#2d2f39]",children:[u.jsxs("div",{className:"flex items-center gap-2 pb-3",children:[c.length>0&&c.some(ie=>ie.messages.length>0)&&u.jsxs("button",{onClick:je,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:"Delete all conversations",children:[u.jsx(rb,{className:"h-4 w-4"}),"Delete Conversations"]}),l&&u.jsx("button",{type:"button",onClick:l,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":"Close sidebar",title:"Close sidebar",children:u.jsx(Qx,{className:"h-4 w-4"})})]}),ce&&!X&&u.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-600 dark:text-red-400",children:ce}),de&&u.jsxs("div",{className:"border-t border-gray-200 pt-4 mt-4 dark:border-[#2d2f39]",children:[u.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:[u.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))]"}),u.jsx(gd,{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"}),u.jsx("input",{ref:V,type:"text",role:"searchbox","aria-label":"Search conversations",placeholder:"Search Conversations",value:S,onChange:ie=>j(ie.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"}),S&&u.jsx("button",{type:"button",onClick:()=>{var ie;j(""),(ie=V.current)==null||ie.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":"Clear search",children:u.jsx(ua,{className:"h-3.5 w-3.5"})})]}),ue&&u.jsx("p",{"aria-live":"polite",className:"mt-2 text-center text-[11px] tabular-nums text-gray-400 dark:text-[#6e7490]",children:pe.length===0?"No results":`${pe.length} ${pe.length===1?"result":"results"}`})]})]}),u.jsx("div",{ref:E,role:"listbox","aria-label":"Conversations",onKeyDown:we,className:"flex-1 overflow-y-auto bg-transparent px-3 py-2",children:pe.length===0?null:ue?u.jsx("div",{className:"space-y-1",children:pe.map(xt)}):u.jsx("div",{className:"space-y-4",children:F.map(ie=>u.jsxs("section",{"aria-label":ie.label,children:[u.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:ie.label}),u.jsx("div",{className:"space-y-1",children:ie.conversations.map(xt)})]},ie.label))})}),(()=>{const ie=fg();return ie.length===0?null:u.jsx("div",{className:"shrink-0 border-t border-gray-200/80 px-4 py-3 md:hidden dark:border-[#2d2f39]",children:u.jsx("nav",{"aria-label":"Header links",children:u.jsx("ul",{className:"flex flex-wrap gap-2",children:ie.map(Ne=>u.jsx("li",{children:u.jsx("a",{href:Ne.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:Ne.label})},Ne.url))})})})})(),u.jsx("div",{className:"shrink-0 border-t border-gray-200/80 dark:border-[#2d2f39]",children:u.jsx(Tg,{placement:"sidebar",compact:!0})})]}),u.jsx(qo,{isOpen:Y.isOpen,onClose:ge,onConfirm:ke,title:"Delete Conversation",message:`Are you sure you want to delete "${Y.conversationTitle}"? This will clear the conversation history.`,confirmText:"Delete",cancelText:"Cancel",type:"danger",isLoading:Y.isDeleting}),u.jsx(qo,{isOpen:q.isOpen,onClose:et,onConfirm:Xe,title:"Clear All Conversations",message:me===1?"Are you sure you want to delete this conversation? This will clear all conversation history.":`Are you sure you want to delete all ${me} conversations? This will clear all conversation history.`,confirmText:"Clear All",cancelText:"Cancel",type:"danger",isLoading:q.isDeleting})]})}const k1="3.10.6",_1={version:k1},Nd=_1.version,A1=["@@auth0spajs@@","a0.spajs","auth0","com.auth0"];function C1(s){const l=s.toLowerCase();return A1.some(i=>l.includes(i.toLowerCase()))}function j1(s){const l=[];for(let i=0;i<s.length;i++){const c=s.key(i);c&&C1(c)&&l.push(c)}l.forEach(i=>s.removeItem(i))}function Fp(s){try{j1(s),s.clear()}catch(l){console.warn("[Settings] Failed to clear browser storage during reset.",l)}}function N1(){if(typeof document>"u"||!document.cookie)return;const s=new Set([void 0]),l=window.location.hostname;l&&l!=="localhost"&&!/^\d{1,3}(?:\.\d{1,3}){3}$/.test(l)&&(s.add(l),s.add(`.${l}`)),document.cookie.split(";").forEach(c=>{const d=c.indexOf("="),f=(d>-1?c.slice(0,d):c).trim();f&&s.forEach(h=>{const p=h?`;domain=${h}`:"";document.cookie=`${f}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/${p}`})})}function T1(){Fp(localStorage),Fp(sessionStorage),N1()}function E1({isOpen:s,onClose:l}){const{theme:i,updateTheme:c}=rr(),{settings:d,updateSettings:f}=Go(),[h,p]=g.useState(!1),x=g.useRef(null),v=g.useRef(null),b=_=>{c({mode:_})},w=()=>{f({soundEnabled:!d.soundEnabled})},k=()=>{p(!0)},S=()=>{p(!1)},j=()=>{S(),Qo(),Zo(!1),sr(null),wa.getState().closeLoginPrompt(),T1(),window.location.reload()};return ci(x,{enabled:s&&!h,onEscape:l}),ci(v,{enabled:h,onEscape:S}),s?u.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:[u.jsx("button",{type:"button",onClick:l,"aria-label":"Close settings overlay",className:"absolute inset-0"}),u.jsxs("div",{onClick:_=>_.stopPropagation(),ref:x,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:[u.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:[u.jsx("h2",{id:"settings-title",className:"text-xl font-semibold text-gray-900 dark:text-gray-100",children:"Settings"}),u.jsx("button",{onClick:l,className:"p-2 hover:bg-gray-100 dark:hover:bg-[#25262f] rounded-lg transition-colors","aria-label":"Close settings",children:u.jsx(ua,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),u.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:[u.jsxs("div",{className:"space-y-4",children:[u.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[u.jsx(Yx,{className:"w-5 h-5"}),"Appearance"]}),u.jsxs("div",{className:"space-y-2",children:[u.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Theme"}),u.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"light",label:"Light",icon:sb},{value:"dark",label:"Dark",icon:Xx},{value:"system",label:"System",icon:Vx}].map(({value:_,label:z,icon:$})=>u.jsxs("button",{onClick:()=>b(_),className:`flex flex-col items-center gap-2 p-3 rounded-lg border-2 transition-all duration-200 ${i.mode===_?"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:[u.jsx($,{className:"w-5 h-5"}),u.jsx("span",{className:"text-sm font-medium",children:z})]},_))})]})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100",children:"Chat Preferences"}),u.jsxs("div",{className:"flex items-center justify-between",children:[u.jsxs("div",{className:"flex items-center gap-2",children:[u.jsx(Oo,{className:"w-4 h-4 text-gray-600 dark:text-gray-400"}),u.jsxs("div",{children:[u.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Sound Effects"}),u.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Play sounds for notifications and events"})]})]}),u.jsx("button",{onClick:w,role:"switch","aria-checked":d.soundEnabled,"aria-label":"Toggle sound effects",className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${d.soundEnabled?"bg-blue-600":"bg-gray-200 dark:bg-[#3c3f4a]"}`,children:u.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d.soundEnabled?"translate-x-6":"translate-x-1"}`})})]})]}),u.jsxs("div",{className:"space-y-4 pt-4 border-t border-gray-200 dark:border-[#2d2f39]",children:[u.jsxs("h3",{className:"text-lg font-medium text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[u.jsx(sg,{className:"w-5 h-5"}),"Data Management"]}),u.jsxs("div",{className:"space-y-3",children:[u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Clear all application data including conversations, and personalized settings."}),u.jsx("button",{onClick:k,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:"Reset Application"})]})]}),u.jsxs("p",{className:"pt-2 text-center text-xs text-gray-400 dark:text-[#858999]",children:["v",Nd]})]}),h&&u.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-black/70 p-4",children:u.jsxs("div",{ref:v,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:[u.jsxs("div",{className:"flex items-start gap-3",children:[u.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:u.jsx(bd,{className:"w-5 h-5 text-red-600 dark:text-red-400"})}),u.jsxs("div",{className:"space-y-1.5",children:[u.jsx("p",{id:"reset-dialog-title",className:"text-base font-semibold text-gray-900 dark:text-gray-100",children:"Reset application data?"}),u.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"This removes everything stored on this device and reloads the app."})]})]}),u.jsxs("div",{className:"mt-4 flex gap-2 pt-2",children:[u.jsx("button",{onClick:S,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:"Cancel"}),u.jsx("button",{onClick:j,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:"Reset"})]})]})})]})]}):null}function M1({message:s}){const l=vd();return u.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:u.jsxs("div",{className:"mx-auto flex min-h-[calc(100dvh-3rem)] w-full max-w-5xl flex-col",children:[u.jsxs("header",{className:"flex items-center justify-between gap-4",children:[u.jsx("p",{className:"min-w-0 truncate text-lg font-semibold tracking-tight sm:text-xl",children:l}),u.jsxs("span",{className:"shrink-0 text-xs font-medium text-slate-400 dark:text-[#858999]",children:["v",Nd]})]}),u.jsx("section",{className:"flex flex-1 items-center justify-center py-12",children:u.jsxs("div",{className:"w-full max-w-lg space-y-8",children:[u.jsxs("div",{className:"flex items-center gap-3",children:[u.jsxs("span",{className:"relative flex h-2.5 w-2.5 shrink-0",children:[u.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-60 dark:bg-amber-500"}),u.jsx("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full bg-amber-500 dark:bg-amber-400"})]}),u.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-amber-700 dark:text-amber-400",children:"Service paused"})]}),u.jsxs("div",{className:"space-y-4",children:[u.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-slate-950 dark:text-white sm:text-4xl",children:"Temporarily unavailable"}),u.jsx("p",{className:"max-w-md whitespace-pre-wrap text-base leading-relaxed text-slate-500 dark:text-slate-400",children:s})]}),u.jsx("div",{className:"border-t border-slate-200 dark:border-[#242424]"}),u.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[u.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:[u.jsx(ab,{className:"h-4 w-4","aria-hidden":"true"}),"Try again"]}),u.jsx("span",{className:"hidden text-slate-300 dark:text-slate-700 sm:block","aria-hidden":"true",children:"·"})]})]})})]})})}function z1({children:s}){const{instance:l,accounts:i}=md(),c=yx();return g.useEffect(()=>{Zo(c)},[c]),g.useEffect(()=>{if(!c||i.length===0){sr(null);return}const d=i[0];sr(d.username||d.name||d.localAccountId||null)},[c,i]),g.useEffect(()=>{if(!c||i.length===0)return;const d=i[0],f=kd();return hg(async()=>(await l.acquireTokenSilent({scopes:f,account:d})).accessToken),()=>Qo()},[c,i,l]),u.jsx(u.Fragment,{children:s})}function D1({children:s}){return u.jsx(z1,{children:s})}function L1({children:s}){const{isLoading:l,isAuthenticated:i,getAccessTokenSilently:c,user:d}=hd();return g.useEffect(()=>{Zo(i)},[i]),g.useEffect(()=>{if(!i){sr(null);return}const f=(d==null?void 0:d.sub)||(d==null?void 0:d.email)||(d==null?void 0:d.nickname)||(d==null?void 0:d.name)||null;sr(f)},[i,d]),g.useEffect(()=>(i&&hg(()=>c()),()=>Qo()),[i,c]),l?u.jsx("div",{className:"flex items-center justify-center h-screen bg-white dark:bg-[#212121]",children:u.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 dark:border-gray-100"})}):u.jsx(u.Fragment,{children:s})}function R1({children:s}){return g.useEffect(()=>{Zo(!1),sr(null),Qo()},[]),u.jsx(u.Fragment,{children:s})}function U1({children:s}){return va()?Xo()==="entra"?u.jsx(D1,{children:s}):u.jsx(L1,{children:s}):u.jsx(R1,{children:s})}function O1(){const s=Sd(),l=va(),i=ir(),{showLoginPrompt:c,promptMessage:d,closeLoginPrompt:f}=wa();return g.useEffect(()=>{c&&(!s||!l||i)&&f()},[c,s,l,i,f]),!s||!l||i||!c?null:Xo()==="entra"?u.jsx(q1,{message:d,onClose:f}):u.jsx($1,{message:d,onClose:f})}function $1({message:s,onClose:l}){const{loginWithRedirect:i}=hd();return u.jsx(Rg,{message:s,onClose:l,onLogin:()=>i()})}function q1({message:s,onClose:l}){const{instance:i}=md();return u.jsx(Rg,{message:s,onClose:l,onLogin:()=>i.loginRedirect({scopes:kd()}).catch(()=>{})})}function Rg({message:s,onClose:l,onLogin:i}){return u.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center",children:[u.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm",onClick:l,"aria-hidden":"true"}),u.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:[u.jsx("button",{onClick:l,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":"Close",children:u.jsx(ua,{className:"h-4 w-4"})}),u.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[u.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/40",children:u.jsx(ag,{className:"h-5 w-5 text-blue-600 dark:text-blue-300"})}),u.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-[#ececf1]",children:"Sign in for more"})]}),u.jsx("p",{className:"mb-6 text-sm leading-relaxed text-gray-600 dark:text-[#bfc2cd]",children:s}),u.jsxs("div",{className:"flex gap-3",children:[u.jsx("button",{onClick:i,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:"Sign in"}),u.jsx("button",{onClick:l,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:"Cancel"})]})]})]})}function B1(){const{goHome:s}=Dg(),{isDark:l}=rr(),i=Zv(),c=g.useRef(!1),d=uy(),f=dy(),h=fy(),p=l?h:f,x=my(),v=hy(),b=!!(x||v),w=py(),k=gy(),S=xy(),j=fg(),_=S?"border-b border-slate-200/80 dark:border-[#333645]":"",z="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(()=>{c.current},[h,d,f]),rd()?u.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 ${_}`.trim(),style:{backgroundColor:w||void 0,color:k||void 0},children:u.jsxs("div",{className:"mx-auto flex w-full max-w-[96rem] items-center justify-between gap-3",children:[u.jsx("div",{className:"flex min-w-0 flex-1 items-center justify-center gap-2 md:justify-start md:gap-3",children:u.jsx("a",{href:i,"aria-label":"Go to home page",onClick:$=>{$.preventDefault(),s()},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:u.jsx("img",{src:p,alt:"Logo",draggable:!1,className:`block max-w-full flex-shrink-0 select-none ${b?"":"h-8 w-auto sm:h-10 md:h-11"}`.trim(),style:{WebkitUserDrag:"none",...x?{height:x}:{},...v?{width:v}:{}}})})}),u.jsxs("div",{className:"hidden min-w-0 flex-1 items-center justify-end gap-2 sm:gap-4 md:flex",children:[j.length>0&&u.jsx("nav",{"aria-label":"Header links",className:"hidden sm:block",children:u.jsx("ul",{className:"flex items-center gap-1.5 sm:gap-2",children:j.map($=>u.jsx("li",{children:u.jsx("a",{href:$.url,target:"_blank",rel:"noopener noreferrer",className:z,style:{color:k||void 0},children:$.label})},$.url))})}),u.jsx(ud,{})]})]})}):null}function H1({children:s}){const l=g.useRef(null),i=g.useCallback(d=>{l.current=d},[]),c=g.useCallback(()=>{var d;(d=l.current)==null||d.call(l)},[]);return u.jsx(zg.Provider,{value:{registerGoHome:i,goHome:c},children:s})}function F1(){const[s,l]=g.useState(!1),[i,c]=g.useState(!1),[d,f]=g.useState(()=>localStorage.getItem("desktop-sidebar-collapsed")==="true"),h=Ve(v=>v.conversations),p=ry();if(g.useEffect(()=>{localStorage.setItem("desktop-sidebar-collapsed",String(d))},[d]),p)return u.jsx(ip,{children:u.jsx(M1,{message:p})});const x=h.some(v=>{var b;return(v.messages.length>0||(((b=v.attachedFiles)==null?void 0:b.length)??0)>0)&&!v.adapterLoadError});return u.jsx(ip,{children:u.jsx(Nx,{children:u.jsx(U1,{children:u.jsx(H1,{children:u.jsxs("div",{className:"h-dvh flex flex-col bg-white dark:bg-black text-slate-900 dark:text-slate-100",children:[u.jsxs("div",{className:"flex-1 flex flex-col md:flex-row md:pl-4 min-h-0",children:[x&&(d?u.jsx("div",{className:"hidden md:flex md:w-16 md:h-full shrink-0 items-start justify-center pt-8",children:u.jsx("button",{type:"button",onClick:()=>f(!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":"Open sidebar",title:"Open sidebar",children:u.jsx(Zx,{className:"h-4 w-4"})})}):u.jsx("div",{className:"hidden md:h-full md:flex",children:u.jsx(Hp,{onToggleDesktopSidebar:()=>f(!0)})})),u.jsxs("div",{className:"flex-1 flex flex-col w-full min-h-0",children:[u.jsx(B1,{}),u.jsx("div",{className:"flex-1 flex justify-center w-full min-h-0",children:u.jsx(y1,{onOpenSettings:()=>l(!0),onOpenSidebar:()=>c(!0)})})]})]}),u.jsx(O1,{}),u.jsx(E1,{isOpen:s,onClose:()=>l(!1)}),i&&u.jsxs("div",{className:"fixed inset-0 z-50 flex md:hidden",children:[u.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>c(!1),"aria-hidden":"true"}),u.jsxs("div",{className:"relative z-10 h-full w-[min(20rem,90vw)] animate-slideIn bg-white dark:bg-black",children:[u.jsx(Hp,{onRequestClose:()=>c(!1)}),u.jsx("button",{onClick:()=>c(!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":"Close menu",children:u.jsx(ua,{className:"h-5 w-5"})})]})]})]})})})})})}const nd=new vx({auth:{clientId:ug(),authority:`https://login.microsoftonline.com/${cy()}`,redirectUri:typeof window<"u"?window.location.origin:"/"},cache:{cacheLocation:"sessionStorage"}});function I1({children:s}){const[l,i]=g.useState(!1);return g.useEffect(()=>{nd.initialize().then(()=>nd.handleRedirectPromise()).catch(c=>{console.error("[EntraAuth] Redirect processing failed:",c)}).finally(()=>i(!0))},[]),l?u.jsx(wx,{instance:nd,children:s}):null}function G1({children:s}){if(!Sd()||!va())return u.jsx(u.Fragment,{children:s});if(Xo()==="entra")return u.jsx(I1,{children:s});const i=iy(),c=ug(),d=oy();return!i||!c?u.jsx(u.Fragment,{children:s}):u.jsx(Sx,{domain:i,clientId:c,authorizationParams:{redirect_uri:window.location.origin,...d?{audience:d}:{}},cacheLocation:"memory",children:s})}Lg(null);const Ip=Pb(),Gp=document.querySelector('link[rel="icon"]');if(Gp)Gp.href=Ip;else{const s=document.createElement("link");s.rel="icon",s.href=Ip,document.head.appendChild(s)}const V1=_y();var Vp,Xp,Yp,Qp,Zp,Kp;for(const s of V1){const l=((Vp=s.src)==null?void 0:Vp.trim())||"",i=((Xp=s.content)==null?void 0:Xp.trim())||"",c=((Yp=s.id)==null?void 0:Yp.trim())||"";if(!l&&!i||c&&document.querySelector(`script[data-orbitchat-startup-script-id="${c}"]`)||Array.from(document.querySelectorAll("script[data-orbitchat-startup-script]")).some(h=>{const p=l&&h.dataset.orbitchatStartupScriptSrc===l,x=i&&(h.textContent||"").trim()===i;return!!(p||x)}))continue;const f=document.createElement("script");l&&(f.src=l),i&&(f.text=i),f.async=s.async??!0,s.defer!==void 0&&(f.defer=s.defer),(Qp=s.type)!=null&&Qp.trim()&&(f.type=s.type.trim()),(Zp=s.integrity)!=null&&Zp.trim()&&(f.integrity=s.integrity.trim()),s.crossOrigin&&(f.crossOrigin=s.crossOrigin),(Kp=s.referrerPolicy)!=null&&Kp.trim()&&(f.referrerPolicy=s.referrerPolicy.trim()),f.dataset.orbitchatStartupScript="true",c&&(f.dataset.orbitchatStartupScriptId=c),l&&(f.dataset.orbitchatStartupScriptSrc=l),document.head.appendChild(f)}le("🚀 AI Chat Application started");le(`📱 App Version: v${Nd}`);jx.createRoot(document.getElementById("root")).render(u.jsx(g.StrictMode,{children:u.jsx(G1,{children:u.jsx(F1,{})})}));export{Yo as r};
|