diff --git a/dist/assets/index-CeOPmacy.js b/dist/assets/index-CeOPmacy.js deleted file mode 100644 index 9f9fab8..0000000 --- a/dist/assets/index-CeOPmacy.js +++ /dev/null @@ -1,88 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(l){if(l.ep)return;l.ep=!0;const o=n(l);fetch(l.href,o)}})();function xm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vd={exports:{}},ki={},Kd={exports:{}},G={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Yl=Symbol.for("react.element"),km=Symbol.for("react.portal"),Em=Symbol.for("react.fragment"),Cm=Symbol.for("react.strict_mode"),Nm=Symbol.for("react.profiler"),_m=Symbol.for("react.provider"),Rm=Symbol.for("react.context"),Lm=Symbol.for("react.forward_ref"),jm=Symbol.for("react.suspense"),Tm=Symbol.for("react.memo"),Pm=Symbol.for("react.lazy"),sc=Symbol.iterator;function Mm(e){return e===null||typeof e!="object"?null:(e=sc&&e[sc]||e["@@iterator"],typeof e=="function"?e:null)}var Qd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yd=Object.assign,Gd={};function Vr(e,t,n){this.props=e,this.context=t,this.refs=Gd,this.updater=n||Qd}Vr.prototype.isReactComponent={};Vr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Vr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Jd(){}Jd.prototype=Vr.prototype;function Oa(e,t,n){this.props=e,this.context=t,this.refs=Gd,this.updater=n||Qd}var Da=Oa.prototype=new Jd;Da.constructor=Oa;Yd(Da,Vr.prototype);Da.isPureReactComponent=!0;var ac=Array.isArray,Xd=Object.prototype.hasOwnProperty,Fa={current:null},qd={key:!0,ref:!0,__self:!0,__source:!0};function Zd(e,t,n){var r,l={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)Xd.call(t,r)&&!qd.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,se=A[Z];if(0>>1;Zl(ot,H))Oel(Pe,ot)?(A[Z]=Pe,A[Oe]=H,Z=Oe):(A[Z]=ot,A[Je]=H,Z=Je);else if(Oel(Pe,H))A[Z]=Pe,A[Oe]=H,Z=Oe;else break e}}return b}function l(A,b){var H=A.sortIndex-b.sortIndex;return H!==0?H:A.id-b.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,s=i.now();e.unstable_now=function(){return i.now()-s}}var a=[],c=[],g=1,y=null,w=3,k=!1,E=!1,N=!1,R=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function m(A){for(var b=n(c);b!==null;){if(b.callback===null)r(c);else if(b.startTime<=A)r(c),b.sortIndex=b.expirationTime,t(a,b);else break;b=n(c)}}function C(A){if(N=!1,m(A),!E)if(n(a)!==null)E=!0,B(j);else{var b=n(c);b!==null&&q(C,b.startTime-A)}}function j(A,b){E=!1,N&&(N=!1,v(D),D=-1),k=!0;var H=w;try{for(m(b),y=n(a);y!==null&&(!(y.expirationTime>b)||A&&!ne());){var Z=y.callback;if(typeof Z=="function"){y.callback=null,w=y.priorityLevel;var se=Z(y.expirationTime<=b);b=e.unstable_now(),typeof se=="function"?y.callback=se:y===n(a)&&r(a),m(b)}else r(a);y=n(a)}if(y!==null)var lt=!0;else{var Je=n(c);Je!==null&&q(C,Je.startTime-b),lt=!1}return lt}finally{y=null,w=H,k=!1}}var $=!1,O=null,D=-1,V=5,U=-1;function ne(){return!(e.unstable_now()-UA||125Z?(A.sortIndex=H,t(c,A),n(a)===null&&A===n(c)&&(N?(v(D),D=-1):N=!0,q(C,H-Z))):(A.sortIndex=se,t(a,A),E||k||(E=!0,B(j))),A},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(A){var b=w;return function(){var H=w;w=b;try{return A.apply(this,arguments)}finally{w=H}}}})(lf);rf.exports=lf;var Hm=rf.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Wm=f,ct=Hm;function L(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ds=Object.prototype.hasOwnProperty,Vm=/^[: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]*$/,cc={},dc={};function Km(e){return Ds.call(dc,e)?!0:Ds.call(cc,e)?!1:Vm.test(e)?dc[e]=!0:(cc[e]=!0,!1)}function Qm(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Ym(e,t,n,r){if(t===null||typeof t>"u"||Qm(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ge(e,t,n,r,l,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var $e={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){$e[e]=new Ge(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];$e[t]=new Ge(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){$e[e]=new Ge(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){$e[e]=new Ge(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){$e[e]=new Ge(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){$e[e]=new Ge(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){$e[e]=new Ge(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){$e[e]=new Ge(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){$e[e]=new Ge(e,5,!1,e.toLowerCase(),null,!1,!1)});var ba=/[\-:]([a-z])/g;function Ua(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(ba,Ua);$e[t]=new Ge(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(ba,Ua);$e[t]=new Ge(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(ba,Ua);$e[t]=new Ge(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){$e[e]=new Ge(e,1,!1,e.toLowerCase(),null,!1,!1)});$e.xlinkHref=new Ge("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){$e[e]=new Ge(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ba(e,t,n,r){var l=$e.hasOwnProperty(t)?$e[t]:null;(l!==null?l.type!==0:r||!(2s||l[i]!==o[s]){var a=` -`+l[i].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=i&&0<=s);break}}}finally{os=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?gl(e):""}function Gm(e){switch(e.tag){case 5:return gl(e.type);case 16:return gl("Lazy");case 13:return gl("Suspense");case 19:return gl("SuspenseList");case 0:case 2:case 15:return e=is(e.type,!1),e;case 11:return e=is(e.type.render,!1),e;case 1:return e=is(e.type,!0),e;default:return""}}function Us(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case xr:return"Fragment";case Sr:return"Portal";case Fs:return"Profiler";case Ha:return"StrictMode";case zs:return"Suspense";case bs:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case af:return(e.displayName||"Context")+".Consumer";case sf:return(e._context.displayName||"Context")+".Provider";case Wa:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Va:return t=e.displayName||null,t!==null?t:Us(e.type)||"Memo";case pn:t=e._payload,e=e._init;try{return Us(e(t))}catch{}}return null}function Jm(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Us(t);case 8:return t===Ha?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Rn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function cf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Xm(e){var t=cf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function vo(e){e._valueTracker||(e._valueTracker=Xm(e))}function df(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=cf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Jo(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}}function Bs(e,t){var n=t.checked;return ye({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function pc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Rn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function ff(e,t){t=t.checked,t!=null&&Ba(e,"checked",t,!1)}function Hs(e,t){ff(e,t);var n=Rn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ws(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ws(e,t.type,Rn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function hc(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ws(e,t,n){(t!=="number"||Jo(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var vl=Array.isArray;function Mr(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=yo.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Tl(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Sl={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},qm=["Webkit","ms","Moz","O"];Object.keys(Sl).forEach(function(e){qm.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Sl[t]=Sl[e]})});function gf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Sl.hasOwnProperty(e)&&Sl[e]?(""+t).trim():t+"px"}function vf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=gf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Zm=ye({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Qs(e,t){if(t){if(Zm[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(L(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(L(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(L(61))}if(t.style!=null&&typeof t.style!="object")throw Error(L(62))}}function Ys(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";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 Gs=null;function Ka(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Js=null,Ir=null,Ar=null;function vc(e){if(e=Xl(e)){if(typeof Js!="function")throw Error(L(280));var t=e.stateNode;t&&(t=Ri(t),Js(e.stateNode,e.type,t))}}function yf(e){Ir?Ar?Ar.push(e):Ar=[e]:Ir=e}function wf(){if(Ir){var e=Ir,t=Ar;if(Ar=Ir=null,vc(e),t)for(e=0;e>>=0,e===0?32:31-(cg(e)/dg|0)|0}var wo=64,So=4194304;function yl(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ei(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var s=i&~l;s!==0?r=yl(s):(o&=i,o!==0&&(r=yl(o)))}else i=n&~l,i!==0?r=yl(i):o!==0&&(r=yl(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Gl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Lt(t),e[t]=n}function mg(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=kl),_c=" ",Rc=!1;function zf(e,t){switch(e){case"keyup":return Hg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function bf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var kr=!1;function Vg(e,t){switch(e){case"compositionend":return bf(t);case"keypress":return t.which!==32?null:(Rc=!0,_c);case"textInput":return e=t.data,e===_c&&Rc?null:e;default:return null}}function Kg(e,t){if(kr)return e==="compositionend"||!eu&&zf(e,t)?(e=Df(),Fo=Xa=vn=null,kr=!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)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Pc(n)}}function Wf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vf(){for(var e=window,t=Jo();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Jo(e.document)}return t}function tu(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")}function tv(e){var t=Vf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Wf(n.ownerDocument.documentElement,n)){if(r!==null&&tu(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=Mc(n,o);var i=Mc(n,r);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Er=null,na=null,Cl=null,ra=!1;function Ic(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ra||Er==null||Er!==Jo(r)||(r=Er,"selectionStart"in r&&tu(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Cl&&Ol(Cl,r)||(Cl=r,r=ri(na,"onSelect"),0_r||(e.current=ua[_r],ua[_r]=null,_r--)}function ie(e,t){_r++,ua[_r]=e.current,e.current=t}var Ln={},Ue=Tn(Ln),tt=Tn(!1),Kn=Ln;function zr(e,t){var n=e.type.contextTypes;if(!n)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function nt(e){return e=e.childContextTypes,e!=null}function oi(){ce(tt),ce(Ue)}function bc(e,t,n){if(Ue.current!==Ln)throw Error(L(168));ie(Ue,t),ie(tt,n)}function ep(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(L(108,Jm(e)||"Unknown",l));return ye({},n,r)}function ii(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,Kn=Ue.current,ie(Ue,e),ie(tt,tt.current),!0}function Uc(e,t,n){var r=e.stateNode;if(!r)throw Error(L(169));n?(e=ep(e,t,Kn),r.__reactInternalMemoizedMergedChildContext=e,ce(tt),ce(Ue),ie(Ue,e)):ce(tt),ie(tt,n)}var Qt=null,Li=!1,Ss=!1;function tp(e){Qt===null?Qt=[e]:Qt.push(e)}function pv(e){Li=!0,tp(e)}function Pn(){if(!Ss&&Qt!==null){Ss=!0;var e=0,t=le;try{var n=Qt;for(le=1;e>=i,l-=i,Yt=1<<32-Lt(t)+l|n<D?(V=O,O=null):V=O.sibling;var U=w(v,O,m[D],C);if(U===null){O===null&&(O=V);break}e&&O&&U.alternate===null&&t(v,O),h=o(U,h,D),$===null?j=U:$.sibling=U,$=U,O=V}if(D===m.length)return n(v,O),fe&&zn(v,D),j;if(O===null){for(;DD?(V=O,O=null):V=O.sibling;var ne=w(v,O,U.value,C);if(ne===null){O===null&&(O=V);break}e&&O&&ne.alternate===null&&t(v,O),h=o(ne,h,D),$===null?j=ne:$.sibling=ne,$=ne,O=V}if(U.done)return n(v,O),fe&&zn(v,D),j;if(O===null){for(;!U.done;D++,U=m.next())U=y(v,U.value,C),U!==null&&(h=o(U,h,D),$===null?j=U:$.sibling=U,$=U);return fe&&zn(v,D),j}for(O=r(v,O);!U.done;D++,U=m.next())U=k(O,v,D,U.value,C),U!==null&&(e&&U.alternate!==null&&O.delete(U.key===null?D:U.key),h=o(U,h,D),$===null?j=U:$.sibling=U,$=U);return e&&O.forEach(function(Ne){return t(v,Ne)}),fe&&zn(v,D),j}function R(v,h,m,C){if(typeof m=="object"&&m!==null&&m.type===xr&&m.key===null&&(m=m.props.children),typeof m=="object"&&m!==null){switch(m.$$typeof){case go:e:{for(var j=m.key,$=h;$!==null;){if($.key===j){if(j=m.type,j===xr){if($.tag===7){n(v,$.sibling),h=l($,m.props.children),h.return=v,v=h;break e}}else if($.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===pn&&Wc(j)===$.type){n(v,$.sibling),h=l($,m.props),h.ref=dl(v,$,m),h.return=v,v=h;break e}n(v,$);break}else t(v,$);$=$.sibling}m.type===xr?(h=Vn(m.props.children,v.mode,C,m.key),h.return=v,v=h):(C=Ko(m.type,m.key,m.props,null,v.mode,C),C.ref=dl(v,h,m),C.return=v,v=C)}return i(v);case Sr:e:{for($=m.key;h!==null;){if(h.key===$)if(h.tag===4&&h.stateNode.containerInfo===m.containerInfo&&h.stateNode.implementation===m.implementation){n(v,h.sibling),h=l(h,m.children||[]),h.return=v,v=h;break e}else{n(v,h);break}else t(v,h);h=h.sibling}h=Ls(m,v.mode,C),h.return=v,v=h}return i(v);case pn:return $=m._init,R(v,h,$(m._payload),C)}if(vl(m))return E(v,h,m,C);if(il(m))return N(v,h,m,C);Ro(v,m)}return typeof m=="string"&&m!==""||typeof m=="number"?(m=""+m,h!==null&&h.tag===6?(n(v,h.sibling),h=l(h,m),h.return=v,v=h):(n(v,h),h=Rs(m,v.mode,C),h.return=v,v=h),i(v)):n(v,h)}return R}var Ur=op(!0),ip=op(!1),ui=Tn(null),ci=null,jr=null,ou=null;function iu(){ou=jr=ci=null}function su(e){var t=ui.current;ce(ui),e._currentValue=t}function fa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Or(e,t){ci=e,ou=jr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(et=!0),e.firstContext=null)}function wt(e){var t=e._currentValue;if(ou!==e)if(e={context:e,memoizedValue:t,next:null},jr===null){if(ci===null)throw Error(L(308));jr=e,ci.dependencies={lanes:0,firstContext:e}}else jr=jr.next=e;return t}var Bn=null;function au(e){Bn===null?Bn=[e]:Bn.push(e)}function sp(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,au(t)):(n.next=l.next,l.next=n),t.interleaved=n,en(e,r)}function en(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var hn=!1;function uu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ap(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Jt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function En(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,X&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,en(e,n)}return l=r.interleaved,l===null?(t.next=t,au(r)):(t.next=l.next,l.next=t),r.interleaved=t,en(e,n)}function bo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ya(e,n)}}function Vc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?l=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?l=o=t:o=o.next=t}else l=o=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function di(e,t,n,r){var l=e.updateQueue;hn=!1;var o=l.firstBaseUpdate,i=l.lastBaseUpdate,s=l.shared.pending;if(s!==null){l.shared.pending=null;var a=s,c=a.next;a.next=null,i===null?o=c:i.next=c,i=a;var g=e.alternate;g!==null&&(g=g.updateQueue,s=g.lastBaseUpdate,s!==i&&(s===null?g.firstBaseUpdate=c:s.next=c,g.lastBaseUpdate=a))}if(o!==null){var y=l.baseState;i=0,g=c=a=null,s=o;do{var w=s.lane,k=s.eventTime;if((r&w)===w){g!==null&&(g=g.next={eventTime:k,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var E=e,N=s;switch(w=t,k=n,N.tag){case 1:if(E=N.payload,typeof E=="function"){y=E.call(k,y,w);break e}y=E;break e;case 3:E.flags=E.flags&-65537|128;case 0:if(E=N.payload,w=typeof E=="function"?E.call(k,y,w):E,w==null)break e;y=ye({},y,w);break e;case 2:hn=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,w=l.effects,w===null?l.effects=[s]:w.push(s))}else k={eventTime:k,lane:w,tag:s.tag,payload:s.payload,callback:s.callback,next:null},g===null?(c=g=k,a=y):g=g.next=k,i|=w;if(s=s.next,s===null){if(s=l.shared.pending,s===null)break;w=s,s=w.next,w.next=null,l.lastBaseUpdate=w,l.shared.pending=null}}while(!0);if(g===null&&(a=y),l.baseState=a,l.firstBaseUpdate=c,l.lastBaseUpdate=g,t=l.shared.interleaved,t!==null){l=t;do i|=l.lane,l=l.next;while(l!==t)}else o===null&&(l.shared.lanes=0);Gn|=i,e.lanes=i,e.memoizedState=y}}function Kc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ks.transition;ks.transition={};try{e(!1),t()}finally{le=n,ks.transition=r}}function Np(){return St().memoizedState}function vv(e,t,n){var r=Nn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},_p(e))Rp(t,n);else if(n=sp(e,t,n,r),n!==null){var l=Qe();jt(n,e,r,l),Lp(n,t,r)}}function yv(e,t,n){var r=Nn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(_p(e))Rp(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,s=o(i,n);if(l.hasEagerState=!0,l.eagerState=s,Tt(s,i)){var a=t.interleaved;a===null?(l.next=l,au(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=sp(e,t,l,r),n!==null&&(l=Qe(),jt(n,e,r,l),Lp(n,t,r))}}function _p(e){var t=e.alternate;return e===ge||t!==null&&t===ge}function Rp(e,t){Nl=pi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Lp(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ya(e,n)}}var hi={readContext:wt,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useInsertionEffect:Fe,useLayoutEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useMutableSource:Fe,useSyncExternalStore:Fe,useId:Fe,unstable_isNewReconciler:!1},wv={readContext:wt,useCallback:function(e,t){return Ft().memoizedState=[e,t===void 0?null:t],e},useContext:wt,useEffect:Yc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Bo(4194308,4,Sp.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Bo(4,2,e,t)},useMemo:function(e,t){var n=Ft();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ft();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=vv.bind(null,ge,e),[r.memoizedState,e]},useRef:function(e){var t=Ft();return e={current:e},t.memoizedState=e},useState:Qc,useDebugValue:vu,useDeferredValue:function(e){return Ft().memoizedState=e},useTransition:function(){var e=Qc(!1),t=e[0];return e=gv.bind(null,e[1]),Ft().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ge,l=Ft();if(fe){if(n===void 0)throw Error(L(407));n=n()}else{if(n=t(),Te===null)throw Error(L(349));Yn&30||fp(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Yc(hp.bind(null,r,o,e),[e]),r.flags|=2048,Wl(9,pp.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Ft(),t=Te.identifierPrefix;if(fe){var n=Gt,r=Yt;n=(r&~(1<<32-Lt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Bl++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[zt]=t,e[zl]=r,Fp(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ys(n,r),n){case"dialog":ue("cancel",e),ue("close",e),l=r;break;case"iframe":case"object":case"embed":ue("load",e),l=r;break;case"video":case"audio":for(l=0;lWr&&(t.flags|=128,r=!0,fl(o,!1),t.lanes=4194304)}else{if(!r)if(e=fi(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),fl(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!fe)return ze(t),null}else 2*xe()-o.renderingStartTime>Wr&&n!==1073741824&&(t.flags|=128,r=!0,fl(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=xe(),t.sibling=null,n=me.current,ie(me,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return Eu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?st&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(L(156,t.tag))}function Rv(e,t){switch(ru(t),t.tag){case 1:return nt(t.type)&&oi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Br(),ce(tt),ce(Ue),fu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return du(t),null;case 13:if(ce(me),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(L(340));br()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ce(me),null;case 4:return Br(),null;case 10:return su(t.type._context),null;case 22:case 23:return Eu(),null;case 24:return null;default:return null}}var jo=!1,be=!1,Lv=typeof WeakSet=="function"?WeakSet:Set,F=null;function Tr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){we(e,t,r)}else n.current=null}function xa(e,t,n){try{n()}catch(r){we(e,t,r)}}var od=!1;function jv(e,t){if(la=ti,e=Vf(),tu(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,s=-1,a=-1,c=0,g=0,y=e,w=null;t:for(;;){for(var k;y!==n||l!==0&&y.nodeType!==3||(s=i+l),y!==o||r!==0&&y.nodeType!==3||(a=i+r),y.nodeType===3&&(i+=y.nodeValue.length),(k=y.firstChild)!==null;)w=y,y=k;for(;;){if(y===e)break t;if(w===n&&++c===l&&(s=i),w===o&&++g===r&&(a=i),(k=y.nextSibling)!==null)break;y=w,w=y.parentNode}y=k}n=s===-1||a===-1?null:{start:s,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(oa={focusedElem:e,selectionRange:n},ti=!1,F=t;F!==null;)if(t=F,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,F=e;else for(;F!==null;){t=F;try{var E=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(E!==null){var N=E.memoizedProps,R=E.memoizedState,v=t.stateNode,h=v.getSnapshotBeforeUpdate(t.elementType===t.type?N:Nt(t.type,N),R);v.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var m=t.stateNode.containerInfo;m.nodeType===1?m.textContent="":m.nodeType===9&&m.documentElement&&m.removeChild(m.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(L(163))}}catch(C){we(t,t.return,C)}if(e=t.sibling,e!==null){e.return=t.return,F=e;break}F=t.return}return E=od,od=!1,E}function _l(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,o!==void 0&&xa(t,n,o)}l=l.next}while(l!==r)}}function Pi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ka(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Up(e){var t=e.alternate;t!==null&&(e.alternate=null,Up(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[zt],delete t[zl],delete t[aa],delete t[dv],delete t[fv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Bp(e){return e.tag===5||e.tag===3||e.tag===4}function id(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Bp(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.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 Ea(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=li));else if(r!==4&&(e=e.child,e!==null))for(Ea(e,t,n),e=e.sibling;e!==null;)Ea(e,t,n),e=e.sibling}function Ca(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ca(e,t,n),e=e.sibling;e!==null;)Ca(e,t,n),e=e.sibling}var Ie=null,_t=!1;function fn(e,t,n){for(n=n.child;n!==null;)Hp(e,t,n),n=n.sibling}function Hp(e,t,n){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(Ei,n)}catch{}switch(n.tag){case 5:be||Tr(n,t);case 6:var r=Ie,l=_t;Ie=null,fn(e,t,n),Ie=r,_t=l,Ie!==null&&(_t?(e=Ie,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ie.removeChild(n.stateNode));break;case 18:Ie!==null&&(_t?(e=Ie,n=n.stateNode,e.nodeType===8?ws(e.parentNode,n):e.nodeType===1&&ws(e,n),Al(e)):ws(Ie,n.stateNode));break;case 4:r=Ie,l=_t,Ie=n.stateNode.containerInfo,_t=!0,fn(e,t,n),Ie=r,_t=l;break;case 0:case 11:case 14:case 15:if(!be&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&xa(n,t,i),l=l.next}while(l!==r)}fn(e,t,n);break;case 1:if(!be&&(Tr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){we(n,t,s)}fn(e,t,n);break;case 21:fn(e,t,n);break;case 22:n.mode&1?(be=(r=be)||n.memoizedState!==null,fn(e,t,n),be=r):fn(e,t,n);break;default:fn(e,t,n)}}function sd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Lv),t.forEach(function(r){var l=Fv.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Ct(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=xe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Pv(r/1960))-r,10e?16:e,yn===null)var r=!1;else{if(e=yn,yn=null,vi=0,X&6)throw Error(L(331));var l=X;for(X|=4,F=e.current;F!==null;){var o=F,i=o.child;if(F.flags&16){var s=o.deletions;if(s!==null){for(var a=0;axe()-xu?Wn(e,0):Su|=n),rt(e,t)}function Xp(e,t){t===0&&(e.mode&1?(t=So,So<<=1,!(So&130023424)&&(So=4194304)):t=1);var n=Qe();e=en(e,t),e!==null&&(Gl(e,t,n),rt(e,n))}function Dv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Xp(e,n)}function Fv(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(L(314))}r!==null&&r.delete(t),Xp(e,n)}var qp;qp=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||tt.current)et=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return et=!1,Nv(e,t,n);et=!!(e.flags&131072)}else et=!1,fe&&t.flags&1048576&&np(t,ai,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ho(e,t),e=t.pendingProps;var l=zr(t,Ue.current);Or(t,n),l=hu(null,t,r,e,l,n);var o=mu();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,nt(r)?(o=!0,ii(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,uu(t),l.updater=Ti,t.stateNode=l,l._reactInternals=t,ha(t,r,e,n),t=va(null,t,r,!0,o,n)):(t.tag=0,fe&&o&&nu(t),Ke(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ho(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=bv(r),e=Nt(r,e),l){case 0:t=ga(null,t,r,e,n);break e;case 1:t=nd(null,t,r,e,n);break e;case 11:t=ed(null,t,r,e,n);break e;case 14:t=td(null,t,r,Nt(r.type,e),n);break e}throw Error(L(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Nt(r,l),ga(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Nt(r,l),nd(e,t,r,l,n);case 3:e:{if($p(t),e===null)throw Error(L(387));r=t.pendingProps,o=t.memoizedState,l=o.element,ap(e,t),di(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=Hr(Error(L(423)),t),t=rd(e,t,r,n,l);break e}else if(r!==l){l=Hr(Error(L(424)),t),t=rd(e,t,r,n,l);break e}else for(at=kn(t.stateNode.containerInfo.firstChild),ut=t,fe=!0,Rt=null,n=ip(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(br(),r===l){t=tn(e,t,n);break e}Ke(e,t,r,n)}t=t.child}return t;case 5:return up(t),e===null&&da(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,ia(r,l)?i=null:o!==null&&ia(r,o)&&(t.flags|=32),Ap(e,t),Ke(e,t,i,n),t.child;case 6:return e===null&&da(t),null;case 13:return Op(e,t,n);case 4:return cu(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ur(t,null,r,n):Ke(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Nt(r,l),ed(e,t,r,l,n);case 7:return Ke(e,t,t.pendingProps,n),t.child;case 8:return Ke(e,t,t.pendingProps.children,n),t.child;case 12:return Ke(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,i=l.value,ie(ui,r._currentValue),r._currentValue=i,o!==null)if(Tt(o.value,i)){if(o.children===l.children&&!tt.current){t=tn(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var s=o.dependencies;if(s!==null){i=o.child;for(var a=s.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=Jt(-1,n&-n),a.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var g=c.pending;g===null?a.next=a:(a.next=g.next,g.next=a),c.pending=a}}o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),fa(o.return,n,t),s.lanes|=n;break}a=a.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(L(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),fa(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Ke(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,Or(t,n),l=wt(l),r=r(l),t.flags|=1,Ke(e,t,r,n),t.child;case 14:return r=t.type,l=Nt(r,t.pendingProps),l=Nt(r.type,l),td(e,t,r,l,n);case 15:return Mp(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Nt(r,l),Ho(e,t),t.tag=1,nt(r)?(e=!0,ii(t)):e=!1,Or(t,n),jp(t,r,l),ha(t,r,l,n),va(null,t,r,!0,e,n);case 19:return Dp(e,t,n);case 22:return Ip(e,t,n)}throw Error(L(156,t.tag))};function Zp(e,t){return _f(e,t)}function zv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vt(e,t,n,r){return new zv(e,t,n,r)}function Nu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function bv(e){if(typeof e=="function")return Nu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Wa)return 11;if(e===Va)return 14}return 2}function _n(e,t){var n=e.alternate;return n===null?(n=vt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ko(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")Nu(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case xr:return Vn(n.children,l,o,t);case Ha:i=8,l|=8;break;case Fs:return e=vt(12,n,t,l|2),e.elementType=Fs,e.lanes=o,e;case zs:return e=vt(13,n,t,l),e.elementType=zs,e.lanes=o,e;case bs:return e=vt(19,n,t,l),e.elementType=bs,e.lanes=o,e;case uf:return Ii(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case sf:i=10;break e;case af:i=9;break e;case Wa:i=11;break e;case Va:i=14;break e;case pn:i=16,r=null;break e}throw Error(L(130,e==null?e:typeof e,""))}return t=vt(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Vn(e,t,n,r){return e=vt(7,e,r,t),e.lanes=n,e}function Ii(e,t,n,r){return e=vt(22,e,r,t),e.elementType=uf,e.lanes=n,e.stateNode={isHidden:!1},e}function Rs(e,t,n){return e=vt(6,e,null,t),e.lanes=n,e}function Ls(e,t,n){return t=vt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Uv(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=as(0),this.expirationTimes=as(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=as(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function _u(e,t,n,r,l,o,i,s,a){return e=new Uv(e,t,n,s,a),t===1?(t=1,o===!0&&(t|=8)):t=0,o=vt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},uu(o),e}function Bv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rh)}catch(e){console.error(e)}}rh(),nf.exports=dt;var lh=nf.exports,oh,md=lh;oh=md.createRoot,md.hydrateRoot;/** - * react-router v7.8.2 - * - * Copyright (c) Remix Software Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE.md file in the root directory of this source tree. - * - * @license MIT - */var gd="popstate";function Qv(e={}){function t(l,o){let{pathname:i="/",search:s="",hash:a=""}=Zn(l.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),ja("",{pathname:i,search:s,hash:a},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(l,o){let i=l.document.querySelector("base"),s="";if(i&&i.getAttribute("href")){let a=l.location.href,c=a.indexOf("#");s=c===-1?a:a.slice(0,c)}return s+"#"+(typeof o=="string"?o:Kl(o))}function r(l,o){Pt(l.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Gv(t,n,r,e)}function ve(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Pt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Yv(){return Math.random().toString(36).substring(2,10)}function vd(e,t){return{usr:e.state,key:e.key,idx:t}}function ja(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Zn(t):t,state:n,key:t&&t.key||r||Yv()}}function Kl({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Zn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Gv(e,t,n,r={}){let{window:l=document.defaultView,v5Compat:o=!1}=r,i=l.history,s="POP",a=null,c=g();c==null&&(c=0,i.replaceState({...i.state,idx:c},""));function g(){return(i.state||{idx:null}).idx}function y(){s="POP";let R=g(),v=R==null?null:R-c;c=R,a&&a({action:s,location:N.location,delta:v})}function w(R,v){s="PUSH";let h=ja(N.location,R,v);n&&n(h,R),c=g()+1;let m=vd(h,c),C=N.createHref(h);try{i.pushState(m,"",C)}catch(j){if(j instanceof DOMException&&j.name==="DataCloneError")throw j;l.location.assign(C)}o&&a&&a({action:s,location:N.location,delta:1})}function k(R,v){s="REPLACE";let h=ja(N.location,R,v);n&&n(h,R),c=g();let m=vd(h,c),C=N.createHref(h);i.replaceState(m,"",C),o&&a&&a({action:s,location:N.location,delta:0})}function E(R){return Jv(R)}let N={get action(){return s},get location(){return e(l,i)},listen(R){if(a)throw new Error("A history only accepts one active listener");return l.addEventListener(gd,y),a=R,()=>{l.removeEventListener(gd,y),a=null}},createHref(R){return t(l,R)},createURL:E,encodeLocation(R){let v=E(R);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:w,replace:k,go(R){return i.go(R)}};return N}function Jv(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ve(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Kl(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function ih(e,t,n="/"){return Xv(e,t,n,!1)}function Xv(e,t,n,r){let l=typeof t=="string"?Zn(t):t,o=nn(l.pathname||"/",n);if(o==null)return null;let i=sh(e);qv(i);let s=null;for(let a=0;s==null&&a{let g={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(g.relativePath.startsWith("/")){if(!g.relativePath.startsWith(r)&&a)return;ve(g.relativePath.startsWith(r),`Absolute route path "${g.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),g.relativePath=g.relativePath.slice(r.length)}let y=Xt([r,g.relativePath]),w=n.concat(g);i.children&&i.children.length>0&&(ve(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),sh(i.children,t,w,y,a)),!(i.path==null&&!i.index)&&t.push({path:y,score:oy(y,i.index),routesMeta:w})};return e.forEach((i,s)=>{var a;if(i.path===""||!((a=i.path)!=null&&a.includes("?")))o(i,s);else for(let c of ah(i.path))o(i,s,!0,c)}),t}function ah(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,l=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return l?[o,""]:[o];let i=ah(r.join("/")),s=[];return s.push(...i.map(a=>a===""?o:[o,a].join("/"))),l&&s.push(...i),s.map(a=>e.startsWith("/")&&a===""?"/":a)}function qv(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:iy(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Zv=/^:[\w-]+$/,ey=3,ty=2,ny=1,ry=10,ly=-2,yd=e=>e==="*";function oy(e,t){let n=e.split("/"),r=n.length;return n.some(yd)&&(r+=ly),t&&(r+=ty),n.filter(l=>!yd(l)).reduce((l,o)=>l+(Zv.test(o)?ey:o===""?ny:ry),r)}function iy(e,t){return e.length===t.length&&e.slice(0,-1).every((r,l)=>r===t[l])?e[e.length-1]-t[t.length-1]:0}function sy(e,t,n=!1){let{routesMeta:r}=e,l={},o="/",i=[];for(let s=0;s{if(g==="*"){let E=s[w]||"";i=o.slice(0,o.length-E.length).replace(/(.)\/+$/,"$1")}const k=s[w];return y&&!k?c[g]=void 0:c[g]=(k||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:i,pattern:e}}function ay(e,t=!1,n=!0){Pt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,s,a)=>(r.push({paramName:s,isOptional:a!=null}),a?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),r]}function uy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Pt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function nn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function cy(e,t="/"){let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?Zn(e):e;return{pathname:n?n.startsWith("/")?n:dy(n,t):t,search:hy(r),hash:my(l)}}function dy(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?n.length>1&&n.pop():l!=="."&&n.push(l)}),n.length>1?n.join("/"):"/"}function js(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function fy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function uh(e){let t=fy(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ch(e,t,n,r=!1){let l;typeof e=="string"?l=Zn(e):(l={...e},ve(!l.pathname||!l.pathname.includes("?"),js("?","pathname","search",l)),ve(!l.pathname||!l.pathname.includes("#"),js("#","pathname","hash",l)),ve(!l.search||!l.search.includes("#"),js("#","search","hash",l)));let o=e===""||l.pathname==="",i=o?"/":l.pathname,s;if(i==null)s=n;else{let y=t.length-1;if(!r&&i.startsWith("..")){let w=i.split("/");for(;w[0]==="..";)w.shift(),y-=1;l.pathname=w.join("/")}s=y>=0?t[y]:"/"}let a=cy(l,s),c=i&&i!=="/"&&i.endsWith("/"),g=(o||i===".")&&n.endsWith("/");return!a.pathname.endsWith("/")&&(c||g)&&(a.pathname+="/"),a}var Xt=e=>e.join("/").replace(/\/\/+/g,"/"),py=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),hy=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,my=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function gy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var dh=["POST","PUT","PATCH","DELETE"];new Set(dh);var vy=["GET",...dh];new Set(vy);var Yr=f.createContext(null);Yr.displayName="DataRouter";var Fi=f.createContext(null);Fi.displayName="DataRouterState";f.createContext(!1);var fh=f.createContext({isTransitioning:!1});fh.displayName="ViewTransition";var yy=f.createContext(new Map);yy.displayName="Fetchers";var wy=f.createContext(null);wy.displayName="Await";var Bt=f.createContext(null);Bt.displayName="Navigation";var Zl=f.createContext(null);Zl.displayName="Location";var ln=f.createContext({outlet:null,matches:[],isDataRoute:!1});ln.displayName="Route";var Tu=f.createContext(null);Tu.displayName="RouteError";function Sy(e,{relative:t}={}){ve(eo(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=f.useContext(Bt),{hash:l,pathname:o,search:i}=to(e,{relative:t}),s=o;return n!=="/"&&(s=o==="/"?n:Xt([n,o])),r.createHref({pathname:s,search:i,hash:l})}function eo(){return f.useContext(Zl)!=null}function er(){return ve(eo(),"useLocation() may be used only in the context of a component."),f.useContext(Zl).location}var ph="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function hh(e){f.useContext(Bt).static||f.useLayoutEffect(e)}function xy(){let{isDataRoute:e}=f.useContext(ln);return e?Ay():ky()}function ky(){ve(eo(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(Yr),{basename:t,navigator:n}=f.useContext(Bt),{matches:r}=f.useContext(ln),{pathname:l}=er(),o=JSON.stringify(uh(r)),i=f.useRef(!1);return hh(()=>{i.current=!0}),f.useCallback((a,c={})=>{if(Pt(i.current,ph),!i.current)return;if(typeof a=="number"){n.go(a);return}let g=ch(a,JSON.parse(o),l,c.relative==="path");e==null&&t!=="/"&&(g.pathname=g.pathname==="/"?t:Xt([t,g.pathname])),(c.replace?n.replace:n.push)(g,c.state,c)},[t,n,o,l,e])}f.createContext(null);function to(e,{relative:t}={}){let{matches:n}=f.useContext(ln),{pathname:r}=er(),l=JSON.stringify(uh(n));return f.useMemo(()=>ch(e,JSON.parse(l),r,t==="path"),[e,l,r,t])}function Ey(e,t){return mh(e,t)}function mh(e,t,n,r,l){var h;ve(eo(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext(Bt),{matches:i}=f.useContext(ln),s=i[i.length-1],a=s?s.params:{},c=s?s.pathname:"/",g=s?s.pathnameBase:"/",y=s&&s.route;{let m=y&&y.path||"";gh(c,!y||m.endsWith("*")||m.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${c}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. - -Please change the parent to .`)}let w=er(),k;if(t){let m=typeof t=="string"?Zn(t):t;ve(g==="/"||((h=m.pathname)==null?void 0:h.startsWith(g)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${g}" but pathname "${m.pathname}" was given in the \`location\` prop.`),k=m}else k=w;let E=k.pathname||"/",N=E;if(g!=="/"){let m=g.replace(/^\//,"").split("/");N="/"+E.replace(/^\//,"").split("/").slice(m.length).join("/")}let R=ih(e,{pathname:N});Pt(y||R!=null,`No routes matched location "${k.pathname}${k.search}${k.hash}" `),Pt(R==null||R[R.length-1].route.element!==void 0||R[R.length-1].route.Component!==void 0||R[R.length-1].route.lazy!==void 0,`Matched leaf route at location "${k.pathname}${k.search}${k.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let v=Ly(R&&R.map(m=>Object.assign({},m,{params:Object.assign({},a,m.params),pathname:Xt([g,o.encodeLocation?o.encodeLocation(m.pathname).pathname:m.pathname]),pathnameBase:m.pathnameBase==="/"?g:Xt([g,o.encodeLocation?o.encodeLocation(m.pathnameBase).pathname:m.pathnameBase])})),i,n,r,l);return t&&v?f.createElement(Zl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...k},navigationType:"POP"}},v):v}function Cy(){let e=Iy(),t=gy(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:o},"ErrorBoundary")," or"," ",f.createElement("code",{style:o},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},t),n?f.createElement("pre",{style:l},n):null,i)}var Ny=f.createElement(Cy,null),_y=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?f.createElement(ln.Provider,{value:this.props.routeContext},f.createElement(Tu.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function Ry({routeContext:e,match:t,children:n}){let r=f.useContext(Yr);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),f.createElement(ln.Provider,{value:e},n)}function Ly(e,t=[],n=null,r=null,l=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,i=n==null?void 0:n.errors;if(i!=null){let c=o.findIndex(g=>g.route.id&&(i==null?void 0:i[g.route.id])!==void 0);ve(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let s=!1,a=-1;if(n)for(let c=0;c=0?o=o.slice(0,a+1):o=[o[0]];break}}}return o.reduceRight((c,g,y)=>{let w,k=!1,E=null,N=null;n&&(w=i&&g.route.id?i[g.route.id]:void 0,E=g.route.errorElement||Ny,s&&(a<0&&y===0?(gh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,N=null):a===y&&(k=!0,N=g.route.hydrateFallbackElement||null)));let R=t.concat(o.slice(0,y+1)),v=()=>{let h;return w?h=E:k?h=N:g.route.Component?h=f.createElement(g.route.Component,null):g.route.element?h=g.route.element:h=c,f.createElement(Ry,{match:g,routeContext:{outlet:c,matches:R,isDataRoute:n!=null},children:h})};return n&&(g.route.ErrorBoundary||g.route.errorElement||y===0)?f.createElement(_y,{location:n.location,revalidation:n.revalidation,component:E,error:w,children:v(),routeContext:{outlet:null,matches:R,isDataRoute:!0},unstable_onError:r}):v()},null)}function Pu(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function jy(e){let t=f.useContext(Yr);return ve(t,Pu(e)),t}function Ty(e){let t=f.useContext(Fi);return ve(t,Pu(e)),t}function Py(e){let t=f.useContext(ln);return ve(t,Pu(e)),t}function Mu(e){let t=Py(e),n=t.matches[t.matches.length-1];return ve(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function My(){return Mu("useRouteId")}function Iy(){var r;let e=f.useContext(Tu),t=Ty("useRouteError"),n=Mu("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Ay(){let{router:e}=jy("useNavigate"),t=Mu("useNavigate"),n=f.useRef(!1);return hh(()=>{n.current=!0}),f.useCallback(async(l,o={})=>{Pt(n.current,ph),n.current&&(typeof l=="number"?e.navigate(l):await e.navigate(l,{fromRouteId:t,...o}))},[e,t])}var wd={};function gh(e,t,n){!t&&!wd[e]&&(wd[e]=!0,Pt(!1,n))}f.memo($y);function $y({routes:e,future:t,state:n,unstable_onError:r}){return mh(e,void 0,n,r,t)}function vh(e){ve(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function Oy({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:l,static:o=!1}){ve(!eo(),"You cannot render a inside another . You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),s=f.useMemo(()=>({basename:i,navigator:l,static:o,future:{}}),[i,l,o]);typeof n=="string"&&(n=Zn(n));let{pathname:a="/",search:c="",hash:g="",state:y=null,key:w="default"}=n,k=f.useMemo(()=>{let E=nn(a,i);return E==null?null:{location:{pathname:E,search:c,hash:g,state:y,key:w},navigationType:r}},[i,a,c,g,y,w,r]);return Pt(k!=null,` is not able to match the URL "${a}${c}${g}" because it does not start with the basename, so the won't render anything.`),k==null?null:f.createElement(Bt.Provider,{value:s},f.createElement(Zl.Provider,{children:t,value:k}))}function Dy({children:e,location:t}){return Ey(Ta(e),t)}function Ta(e,t=[]){let n=[];return f.Children.forEach(e,(r,l)=>{if(!f.isValidElement(r))return;let o=[...t,l];if(r.type===f.Fragment){n.push.apply(n,Ta(r.props.children,o));return}ve(r.type===vh,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),ve(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=Ta(r.props.children,o)),n.push(i)}),n}var Qo="get",Yo="application/x-www-form-urlencoded";function zi(e){return e!=null&&typeof e.tagName=="string"}function Fy(e){return zi(e)&&e.tagName.toLowerCase()==="button"}function zy(e){return zi(e)&&e.tagName.toLowerCase()==="form"}function by(e){return zi(e)&&e.tagName.toLowerCase()==="input"}function Uy(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function By(e,t){return e.button===0&&(!t||t==="_self")&&!Uy(e)}var Mo=null;function Hy(){if(Mo===null)try{new FormData(document.createElement("form"),0),Mo=!1}catch{Mo=!0}return Mo}var Wy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ts(e){return e!=null&&!Wy.has(e)?(Pt(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Yo}"`),null):e}function Vy(e,t){let n,r,l,o,i;if(zy(e)){let s=e.getAttribute("action");r=s?nn(s,t):null,n=e.getAttribute("method")||Qo,l=Ts(e.getAttribute("enctype"))||Yo,o=new FormData(e)}else if(Fy(e)||by(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a `,E=`
${w}
`;return`
${k}${E}
`}),i=i.replace(/
\s*(?=
]*>[\s\S]*?<\/div>)\s*
/g,"$1"),i}function rw(e){const t=e.split(/\r?\n/);let n=null;for(let r=0;r[\s\S]*?<\/think(?:ing)?>/gi,"").replace(/[*#]/g,"").replace(/\s+/g," ").trim()}function wr(e,t,n){return e.includes(t)?e:`${e} - -${n}`}function ow(e){const t=String(e||""),n=t.trim();if(!n)return t;const r=n.toLowerCase();return r.startsWith("error:")||r.startsWith("ollama error:")||r.includes("client error '")||r.includes("server error '")||r.includes("http")&&r.includes("error")||r.includes("unknown model architecture")||r.includes("out of memory")?r.includes("unknown model architecture")?wr(t,"[ERROR - Unsupported Model]",`[ERROR - Unsupported Model] -This Ollama version does not support the model. -Update Ollama.`):r.includes("out of memory")?wr(t,"[ERROR - Out of Memory]",`[ERROR - Out of Memory] -The model is too large for available memory. -Use a smaller or quantized model.`):r.includes("502")?wr(t,"[ERROR 502 - Bad Gateway]",`[ERROR 502 - Bad Gateway] -Ollama did not return a valid response. -Try restarting or updating Ollama.`):r.includes("500")?wr(t,"[ERROR 500 - Internal Server Error]",`[ERROR 500 - Internal Server Error] -Ollama crashed while processing the request. -Check 'ollama logs' and memory usage.`):r.includes("404")?wr(t,"[ERROR 404 - Not Found]",`[ERROR 404 - Not Found] -The model or endpoint was not found. -Check the model name or run 'ollama pull '.`):r.includes("400")?wr(t,"[ERROR 400 - Bad Request]",`[ERROR 400 - Bad Request] -The request sent to Ollama was invalid. -Check parameters or payload format.`):t:t}function Lh(e){if(!e)return{think:null,answer:""};const t=//i,n=/<\/think(?:ing)?>/i,r=e.match(t);if(!r)return{think:null,answer:e};const l=r.index,o=r[0].length,i=e.substring(0,l).trim();let s=e.substring(l+o);const a=s.match(n);let c=null,g=i;return a?(c=s.substring(0,a.index).trim(),g+=s.substring(a.index+a[0].length)):c=s.trim(),{think:c||null,answer:g.trim()}}function iw({content:e,streamOutput:t,sources:n}){const r=ow(e||""),{think:l,answer:o}=Lh(r),[i,s]=Ve.useState(!1),a=!!l;return d.jsxs("div",{className:"assistant-message",children:[a&&d.jsxs("div",{className:"assistant-thoughts",children:[d.jsxs("button",{className:"think-toggle",onClick:()=>s(c=>!c),"aria-expanded":i?"true":"false","aria-controls":"think-content",children:[d.jsx("span",{className:"think-toggle-icon","aria-hidden":"true",children:i?"▾":"▸"}),"Thoughts"]}),i&&d.jsx("div",{id:"think-content",className:"think-content",dangerouslySetInnerHTML:{__html:Fd(l)}})]}),d.jsx("div",{className:"msg-content",dangerouslySetInnerHTML:{__html:Fd(o||r||"")}}),Array.isArray(n)&&n.length>0&&d.jsx("div",{className:"msg-sources chips",children:n.map((c,g)=>{let y=c,w=!1;try{const k=new URL(c);if(k.protocol==="file:"){w=!0;const E=k.pathname.split("/").filter(Boolean);y=decodeURIComponent(E[E.length-1]||c)}else y=(k.hostname||c).replace(/^www\./i,"")}catch{}return d.jsx("a",{className:"chip",href:c,target:"_blank",rel:"noreferrer",title:c,onClick:k=>{var E,N;if(w){k.preventDefault();try{const R=new URL(c);(N=(E=window.electronAPI)==null?void 0:E.openPath)==null||N.call(E,decodeURIComponent(R.pathname))}catch{}}},children:y},c+g)})})]})}function As({attachments:e,className:t="",removable:n=!1,onRemove:r}){return!Array.isArray(e)||e.length===0?null:d.jsx("div",{className:`image-attachment-strip ${t}`.trim(),children:e.map((l,o)=>{const i=l==null?void 0:l.data_url;if(!i)return null;const s=l.id||`${l.name||"image"}-${o}-${i.length}`;return d.jsxs("div",{className:"image-attachment-card",children:[n&&d.jsx("button",{type:"button",className:"image-attachment-remove",onClick:()=>r==null?void 0:r(l.id),"aria-label":`Remove ${l.name||"image"}`,title:"Remove image",children:"×"}),d.jsx("img",{className:"image-attachment-thumb",src:i,alt:l.name||`Attachment ${o+1}`,loading:"lazy"})]},s)})})}const zd="websearch.searxUrl",bd="websearch.engines",Ud="chat.libraryBySession",Bd="http://127.0.0.1:8888",$s=6,Os=20*1024*1024,sw=5*60*1e3,aw=200;let jh="http://127.0.0.1:8000";const uw=48,cw=24;function dw(e){return e.backendApiUrl||e.ollamaApiUrl||jh}function fw(e){const t=typeof e=="string"?e.trim():"";return!t||t==="http://localhost:8888"?Bd:t}function Ao(e){var n;return Array.from(((n=e==null?void 0:e.dataTransfer)==null?void 0:n.types)||[]).includes("Files")}function $a(e){return e?typeof e.type=="string"&&e.type.toLowerCase().startsWith("image/")?!0:/\.(png|jpe?g|gif|bmp|webp|tiff?|heic|avif)$/i.test(e.name||""):!1}function Hd(e){var r,l;const t=Array.from(((r=e==null?void 0:e.dataTransfer)==null?void 0:r.items)||[]);return t.length>0?t.some(o=>{var i;return o.kind==="file"&&$a((i=o.getAsFile)==null?void 0:i.call(o))}):Array.from(((l=e==null?void 0:e.dataTransfer)==null?void 0:l.files)||[]).some($a)}function Wd(e){return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(r.error||new Error(`Failed to read ${(e==null?void 0:e.name)||"image"}`)),r.onload=()=>t(String(r.result||"")),r.readAsDataURL(e)})}function pw(e,t){const n=String(t||"").trim();if(!n)return e||"";const r=String(e||"");if(!r.trim())return n;const l=/[\s\n]$/.test(r)?"":` -`;return`${r}${l}${n}`}function hw(e){const t=Math.max(0,Math.floor(Number(e||0)/1e3)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`}function mw(){var ic;const[e,t]=f.useState([]),[n,r]=f.useState(null),[l,o]=f.useState("chats"),i=f.useRef(l),[s,a]=f.useState("General"),[c,g]=f.useState(null),[y,w]=f.useState(null),[k,E]=f.useState([]),[N,R]=f.useState([]),[v,h]=f.useState(null),[m,C]=f.useState(()=>{try{const u=localStorage.getItem(Ud);return u?JSON.parse(u):{}}catch{return{}}}),[j,$]=f.useState(!1),[O,D]=f.useState(""),[V,U]=f.useState(""),[ne,Ne]=f.useState(!1),[de,pt]=f.useState(""),[P,B]=f.useState(""),[q,A]=f.useState("base"),[b,H]=f.useState(!1),[Z,se]=f.useState(""),[lt,Je]=f.useState([]),[ot,Oe]=f.useState(!1),Pe=f.useRef(null),Mt=f.useRef(null),tr=f.useRef(null),ht=f.useRef(null),Le=f.useRef(0),[on,Gr]=f.useState(!1),[no,Jr]=f.useState(""),[ro,nr]=f.useState(""),[It,Xe]=f.useState(!0),[lo,At]=f.useState(""),[pe,xt]=f.useState(!1),[it,oo]=f.useState(!1),[Ui,Xr]=f.useState(0),rr=f.useRef(null),Mn=f.useRef(null),lr=f.useRef([]),qr=f.useRef(null),In=f.useRef(""),or=f.useRef(null),ir=f.useRef(null),Zr=f.useRef(0),sr=f.useRef(null),[K,ar]=f.useState(jh),[Bi,Hi]=f.useState("Default"),[ur,sn]=f.useState(!1),[el,an]=f.useState(""),[io,cr]=f.useState(!1),[un,_]=f.useState(()=>fw(localStorage.getItem(zd))),[M,he]=f.useState(()=>tw(localStorage.getItem(bd)));f.useEffect(()=>{localStorage.setItem(zd,un||"")},[un]),f.useEffect(()=>{try{localStorage.setItem(bd,JSON.stringify(xi(M)))}catch{}},[M]);const[Be,Wi]=f.useState(!1),[kt,Vi]=f.useState(!1),[Ou,Ki]=f.useState(!0),[Th,dr]=f.useState([]),[so,Du]=f.useState({}),[Fu,Ph]=f.useState(!1),zu=f.useRef(!1),[Mh,Qi]=f.useState(null),[Yi,ao]=f.useState("");function Ih(u){const p=u.content||"";if(u.role==="assistant")try{const{answer:S}=Lh(p);return(S||p).trim()}catch{return p.trim()}return p}async function bu(u){try{await navigator.clipboard.writeText(Ih(u))}catch(p){console.error("Failed to copy message:",p)}}function An(u,p,S,x={}){const{removeIfEmpty:T=!1}=x;t(I=>I.map(z=>{if(z.session_id!==u)return z;const W=[];for(const J of z.messages||[]){if(J.id!==p){W.push(J);continue}T&&!S||W.push({...J,content:S})}return{...z,messages:W}}))}function $t(u){return(u==null?void 0:u.name)==="AbortError"}function Ah(u){return Array.isArray(u==null?void 0:u.attachments)&&u.attachments.length>0}function $h(u=[]){return Array.isArray(u)&&u.length>0&&P||de}function Ht(u){return u instanceof Error&&u.message?u.message:String(u)}async function uo(u){const p=await u.text().catch(()=>"");if(p){try{const S=JSON.parse(p);if(typeof(S==null?void 0:S.detail)=="string"&&S.detail.trim())return S.detail.trim();if(typeof(S==null?void 0:S.message)=="string"&&S.message.trim())return S.message.trim()}catch{}return p.trim()}return`HTTP ${u.status}`}async function tl(u){const p=await u.json().catch(()=>null);if(u.ok)return p;const S=typeof(p==null?void 0:p.detail)=="string"?p.detail:typeof(p==null?void 0:p.message)=="string"?p.message:"";throw new Error(S||`HTTP ${u.status}`)}async function Oh(u,p){const S=await fetch(`${K}/models/capabilities?name=${encodeURIComponent(u)}`,{signal:p});return tl(S)}async function Dh(){const u=await fetch(`${K}/ollama/startup-status`);return tl(u)}async function Fh(){const u=await fetch(`${K}/startup/prepare-models`,{method:"POST"});return tl(u)}function Uu(u){if(!!(u!=null&&u.whisper_model_available)){Xe(!0),At("");return}const S=(u==null?void 0:u.whisper_model)||"base",x=String((u==null?void 0:u.whisper_error)||"").trim();Xe(!1),At(x||`Whisper ${S} is not available.`)}async function Bu(u,p,S){if(!u)return{contextBlock:null,sources:[]};const T=await(await fetch(`${K}/libraries/${u}/context`,{method:"POST",headers:{"Content-Type":"application/json"},signal:S,body:JSON.stringify({prompt:p,top_k:5})})).json();return{contextBlock:typeof(T==null?void 0:T.context_block)=="string"&&T.context_block.trim()?T.context_block.trim():null,sources:Array.isArray(T==null?void 0:T.sources)?T.sources:[]}}async function Hu(u){const p=Array.from(u||[]).filter($a);if(!p.length||!b)return;const S=Math.max(0,$s-lt.length);if(S<=0){window.alert(`You can attach up to ${$s} images per message.`);return}const x=p.slice(0,S),T=x.filter(z=>Number(z.size)>Os),I=x.filter(z=>Number(z.size)<=Os);if(T.length>0&&window.alert(`Images must be ${Math.round(Os/(1024*1024))} MB or smaller.`),!!I.length)try{const z=await Promise.all(I.map(async(W,J)=>({id:`attachment-${Date.now()}-${J}-${Math.random().toString(36).slice(2)}`,name:W.name||"image",mime_type:W.type||"image/*",data_url:await Wd(W)})));Je(W=>[...W,...z]),p.length>S&&window.alert(`Only the first ${$s} images can be attached.`)}catch(z){console.error("Failed to load image attachments",z),window.alert(`Image import failed: ${Ht(z)}`)}}function zh(u){Je(p=>p.filter(S=>S.id!==u))}function bh(){var u;b&&((u=ht.current)==null||u.click())}function Gi(){or.current&&(window.clearInterval(or.current),or.current=null),ir.current&&(window.clearTimeout(ir.current),ir.current=null)}function Ji(u=Mn.current){Gi(),Ma(u),Mn.current===u&&(Mn.current=null),rr.current=null}async function Uh(u,p){if(!K)throw new Error("The Heimgeist backend is not configured.");const S=new AbortController;sr.current=S,oo(!0);try{const x=await Wd(u),T=x.indexOf(",");if(T<=5)throw new Error("Recorded audio could not be encoded for upload.");const I=x.slice(0,T),z=x.slice(T+1);if(!/^data:[^,]+;base64$/i.test(I)||!z)throw new Error("Recorded audio could not be encoded for upload.");const W=I.slice(5).replace(/;base64$/i,"").trim(),J=await fetch(`${K}/audio/transcribe`,{method:"POST",headers:{"Content-Type":"application/json"},signal:S.signal,body:JSON.stringify({mime_type:p||W||"audio/webm",audio_base64:z,model:q||null,language:ro||null})}),ke=await tl(J),ee=String((ke==null?void 0:ke.text)||"").trim();if(!ee){window.alert("No speech was detected. Try again and speak closer to the selected microphone.");return}se(re=>pw(re,ee)),requestAnimationFrame(()=>{var re;return(re=Mt.current)==null?void 0:re.focus()})}catch(x){if($t(x))return;throw x}finally{sr.current===S&&(sr.current=null),oo(!1)}}async function nl(u={}){const{shouldTranscribe:p=!0}=u,S=rr.current,x=qr.current,T=In.current||(S==null?void 0:S.mimeType)||"audio/webm";if(!(!S||!x)){xt(!1),Gi();try{S.state!=="inactive"&&S.stop();const I=await x;if(!p)return;if(!I||I.size<=0)throw new Error("Recorded audio was empty.");await Uh(I,T)}catch(I){p&&(console.error("Failed to stop microphone recording",I),window.alert(`Microphone transcription failed: ${Ht(I)}`))}finally{qr.current=null,lr.current=[],In.current="",Zr.current=0,Xr(0)}}}async function Bh(){if(!on||!It||pe||it||kt)return;if(!bi()){window.alert("Microphone capture is not available in this environment.");return}let u=null;try{u=await navigator.mediaDevices.getUserMedia(D0(no))}catch(x){console.error("Failed to access microphone",x),window.alert(`Microphone access failed: ${Ht(x)}`);return}const p=z0();let S=null;try{S=p?new MediaRecorder(u,{mimeType:p}):new MediaRecorder(u)}catch(x){Ji(u),console.error("Failed to create audio recorder",x),window.alert(`Microphone recording is not available: ${Ht(x)}`);return}Mn.current=u,rr.current=S,lr.current=[],In.current=S.mimeType||p||"audio/webm",Zr.current=Date.now(),Xr(0),xt(!0),S.ondataavailable=x=>{x.data&&x.data.size>0&&lr.current.push(x.data)},qr.current=new Promise((x,T)=>{S.onstop=()=>{const I=new Blob(lr.current,{type:S.mimeType||In.current||"audio/webm"});Ji(u),x(I)},S.onerror=I=>{Ji(u),T((I==null?void 0:I.error)||new Error("Audio recording failed."))}}),or.current=window.setInterval(()=>{Xr(Date.now()-Zr.current)},aw),ir.current=window.setTimeout(()=>{nl()},sw),S.start()}async function Hh(){if(!it){if(pe){await nl();return}await Bh()}}async function Wh(u){var S;const p=(S=u.target)==null?void 0:S.files;try{await Hu(p)}finally{u.target&&(u.target.value="")}}function Vh(u,p){Qi(u),ao(p||"")}function co(){Qi(null),ao("")}async function Kh(u){var I;const p=(((I=mr[u])==null?void 0:I.content)||"").trim(),x=(Yi??"").trim();if(x.length===0){co();return}if(x===p){co();return}const T=n;if(T){t(z=>z.map(W=>{if(W.session_id!==T)return W;const ke=(W.messages||[]).slice(0,u+1).map((ee,re)=>re===u?{...ee,content:x}:ee);return{...W,messages:ke}})),Qi(null),ao(""),requestAnimationFrame(()=>ts("auto",T));try{const z=await fetch(`${K}/sessions/${T}/messages/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:x})});if(!z.ok)throw new Error(`HTTP ${z.status}`)}catch(z){console.error("Failed to update message:",z),t(W=>W.map(J=>{if(J.session_id!==T)return J;const ee=(J.messages||[]).map((re,He)=>He===u?{...re,content:p}:re);return{...J,messages:ee}}));return}await Wu(u,x)}}async function Wu(u,p=null){var re,He,qe,Dn,Q,Se;const S=n;if(kt||!S||typeof u!="number")return;const x=((re=e.find(te=>te.session_id===S))==null?void 0:re.messages)||[];let T=u;for(let te=u;te>=0;te--)if(((He=x[te])==null?void 0:He.role)==="user"){T=te;break}t(te=>te.map(oe=>oe.session_id===S?{...oe,messages:(oe.messages||[]).slice(0,T+1)}:oe));const I=x.slice(0,T+1).some(Ah),z=I&&P||de;if(I&&!b){window.alert("The selected vision model does not support image inputs.");return}const W=Ju(S);let J=p??(((qe=x[T])==null?void 0:qe.content)||""),ke=[];const ee=[];try{const te=ec(S),oe=p??(((Dn=x[T])==null?void 0:Dn.content)||""),Me=!!(oe||"").trim();if(Me&&((Q=te==null?void 0:te.states)!=null&&Q.is_indexed))try{const Y=await Bu(te.slug,oe,W.signal);Y.contextBlock&&ee.push(Y.contextBlock),Array.isArray(Y.sources)&&ke.push(...Y.sources)}catch(Y){if($t(Y))throw Y;console.warn("local library enrichment (regenerate) failed",Y)}if(Me&&Be)try{const Y=x.slice(Math.max(0,T-7),T+1).map(Ee=>({role:Ee.role,content:Ee.content||""}));Y.length>0&&(Y[Y.length-1]={role:"user",content:oe});const ae=await(await fetch(`${K}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:W.signal,body:JSON.stringify({prompt:oe,model:de,messages:Y,history_limit:8,searx_url:un||null,engines:Array.isArray(M)?M:null})})).json();ae&&typeof ae.context_block=="string"&&ae.context_block.trim()&&ee.push(ae.context_block.trim()),Array.isArray(ae==null?void 0:ae.sources)&&ke.push(...ae.sources)}catch(Y){if($t(Y))throw Y;console.warn("web search enrichment (regenerate) failed",Y)}if(ke=[...new Set(ke)],Me&&ee.length>0?J=`${oe} - -${ee.join(` - -`)}`:J=null,ur){const Y=`msg-${Date.now()}-${Math.random()}`;let Vt="";t(ae=>ae.map(Ee=>Ee.session_id===S?{...Ee,messages:[...Ee.messages||[],{id:Y,role:"assistant",content:"",sources:ke}]}:Ee));try{const ae=await fetch(`${K}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:W.signal,body:JSON.stringify({index:u,model:z,stream:!0,enriched_message:J,sources:ke||[]})});if(!ae.ok)throw new Error(await uo(ae));const Ee=(Se=ae.body)==null?void 0:Se.getReader();if(!Ee)throw new Error("Missing response body");const dn=new TextDecoder;let Ot=!1;for(;;){const{value:Fn,done:wm}=await Ee.read();if(wm)break;const Sm=dn.decode(Fn,{stream:!0});Vt+=Sm,An(S,Y,Vt),!Ot&&De.current!==S&&(Ot=!0,$n(ns=>({...ns,[S]:Y})),dr(ns=>[...new Set([...ns,S])]))}De.current!==S?($n(Fn=>({...Fn,[S]:Y})),dr(Fn=>[...new Set([...Fn,S])])):fr.current[S]?pr(Fn=>({...Fn,[S]:Y})):requestAnimationFrame(()=>gr(Y,"smooth",S))}catch(ae){if($t(ae)){An(S,Y,Vt,{removeIfEmpty:!0});return}console.error(ae),An(S,Y,`Error: ${Ht(ae)}`,{removeIfEmpty:!0});return}}else{const Y=await fetch(`${K}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:W.signal,body:JSON.stringify({index:u,model:z,stream:!1,enriched_message:J,sources:ke||[]})});if(!Y.ok)throw new Error(await uo(Y));const Vt=await Y.json(),ae=`msg-${Date.now()}`;t(Ee=>Ee.map(dn=>dn.session_id===S?{...dn,messages:[...dn.messages||[],{role:"assistant",content:Vt.reply,id:ae,sources:ke}]}:dn)),De.current!==S?($n(Ee=>({...Ee,[S]:ae})),dr(Ee=>[...new Set([...Ee,S])])):fr.current[S]?pr(Ee=>({...Ee,[S]:ae})):requestAnimationFrame(()=>gr(ae,"smooth",S))}}catch(te){$t(te)||console.error(te)}finally{Xi(W)}}const[Vu,Qh]=f.useState({}),fr=f.useRef({}),[Yh,$n]=f.useState({}),On=f.useRef({}),Ku=f.useRef({}),[Qu,pr]=f.useState({}),[Gh,Yu]=f.useState({});f.useEffect(()=>{i.current=l},[l]);const Gu=(u,p,S)=>u!=null&&u.id?u.id:`${S}:${p}`;f.useEffect(()=>{var p;if(!n)return;const u=((p=e.find(S=>S.session_id===n))==null?void 0:p.messages)||[];Yu(S=>{const x={};return u.forEach((T,I)=>{if(T.role!=="user")return;const z=Gu(T,I,n),J=(T.content||"").split(/\r\n|\r|\n/).length>30;x[z]=J?S[z]??!0:!1}),x})},[e,n]);function Jh(u){Yu(p=>({...p,[u]:!(p[u]??!0)}))}const rl=Ve.useCallback((u,p)=>{Qh(S=>{const x={...S,[u]:p};return fr.current=x,x})},[]),hr=f.useRef(null),Xh=f.useRef(!1),qh=f.useRef(null),De=f.useRef(n);f.useEffect(()=>{De.current=n},[n]);const Ju=Ve.useCallback(u=>{const p=new AbortController;return hr.current={controller:p,sessionId:u},Vi(!0),p},[]),Xi=Ve.useCallback(u=>{var p;((p=hr.current)==null?void 0:p.controller)===u&&(hr.current=null,Vi(!1))},[]),Zh=Ve.useCallback(()=>{const u=hr.current;u&&(hr.current=null,u.controller.abort(),Vi(!1))},[]);f.useEffect(()=>()=>{var u;(u=hr.current)==null||u.controller.abort()},[]);const cn=f.useRef(null),[em,tm]=f.useState(230),[fo,Xu]=f.useState(!1),nm=Ve.useCallback(u=>{Xu(!0)},[]),ll=Ve.useCallback(()=>{Xu(!1)},[]),qi=Ve.useCallback(u=>{if(fo){const p=Math.max(230,Math.min(500,u.clientX));tm(p)}},[fo]);Ve.useEffect(()=>(window.addEventListener("mousemove",qi),window.addEventListener("mouseup",ll),window.addEventListener("blur",ll),()=>{window.removeEventListener("mousemove",qi),window.removeEventListener("mouseup",ll),window.removeEventListener("blur",ll)}),[qi,ll]),Ve.useEffect(()=>(fo?document.body.classList.add("no-select"):document.body.classList.remove("no-select"),()=>{document.body.classList.remove("no-select")}),[fo]),Ve.useEffect(()=>{const u=async p=>{const S=p.target.closest(".codeblock__copy");if(!S)return;const x=S.closest(".codeblock"),T=x==null?void 0:x.querySelector("pre > code");if(T)try{await navigator.clipboard.writeText(T.textContent||""),S.classList.add("copied"),setTimeout(()=>S.classList.remove("copied"),800)}catch(I){console.error("Copy failed:",I)}};return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[]),f.useEffect(()=>{let u=!1;return window.electronAPI.getSettings().then(p=>{u||(ar(dw(p)),Hi(p.colorScheme||"Default"),pt(p.chatModel||""),B(p.visionModel||p.chatModel||""),A(p.transcriptionModel||"base"),sn(p.streamOutput||!1),Gr(p.audioInputEnabled===!0),Jr(typeof p.audioInputDeviceId=="string"?p.audioInputDeviceId:""),nr(typeof p.audioInputLanguage=="string"?p.audioInputLanguage:""),Du(p.scrollPositions||{}),Ql(p.colorScheme||"Default"))}).finally(()=>{u||Ph(!0)}),()=>{u=!0}},[]),f.useEffect(()=>{const u=()=>{var p;i.current==="chats"&&((p=Mt.current)==null||p.focus())};return window.electronAPI.onWindowFocus(u),()=>{window.electronAPI.offWindowFocus(u)}},[]),f.useEffect(()=>{let u=!1;const p=new AbortController;return!K||!P?(H(!1),()=>{p.abort()}):((async()=>{try{const S=await Oh(P,p.signal);u||H(!!(S!=null&&S.supports_vision))}catch(S){!u&&!$t(S)&&(console.warn("Failed to load model capabilities",S),H(!1))}})(),()=>{u=!0,p.abort()})},[K,P]),f.useEffect(()=>{Le.current=0,Oe(!1)},[b,l]),f.useEffect(()=>{on||!pe||nl({shouldTranscribe:!1})},[on,pe]),f.useEffect(()=>{It||!pe||nl({shouldTranscribe:!1})},[It,pe]),f.useEffect(()=>{l==="chats"||!pe||nl()},[l,pe]),f.useEffect(()=>()=>{var p;(p=sr.current)==null||p.abort(),Gi();const u=rr.current;if(u){u.ondataavailable=null,u.onstop=null,u.onerror=null;try{u.state!=="inactive"&&u.stop()}catch{}}Ma(Mn.current)},[]),f.useEffect(()=>{if(!Fu||Ou||!K||zu.current)return;zu.current=!0;let u=!1;const p=window.setTimeout(()=>{(async()=>{let S=!1;try{let x=await Dh();if(u)return;if(Uu(x),!(x!=null&&x.ollama_running)&&(x!=null&&x.can_manage_locally)){const z=window.confirm(`Ollama is not running at ${x.ollama_url}. Start it in the background now with "ollama serve"?`);if(u)return;if(z){S=!0,cr(!0),an("Starting Ollama in the background...");const W=await fetch(`${K}/ollama/start`,{method:"POST"});if(x=await tl(W),u)return}}const T=!(x!=null&&x.whisper_model_available),I=!!(x!=null&&x.ollama_running&&(x!=null&&x.can_manage_locally)&&!(x!=null&&x.embedding_model_available));if(T||I){S=!0,cr(!0),an(T&&I?`Downloading Whisper ${(x==null?void 0:x.whisper_model)||"base"} and ${x.selected_embed_model}. This can take a while on first install.`:T?`Downloading Whisper ${(x==null?void 0:x.whisper_model)||"base"}. This can take a while on first install.`:`Downloading ${x.selected_embed_model} from Ollama. This can take a while on first install.`);const z=await Fh();if(u)return;Uu((z==null?void 0:z.ollama)||x)}}catch(x){u||(console.warn("startup Ollama check failed",x),Xe(!1),At(`Whisper availability could not be verified: ${Ht(x)}`),S&&window.alert(`Startup action failed: ${Ht(x)}`))}finally{u||(cr(!1),an(""))}})()},1200);return()=>{u=!0,window.clearTimeout(p)}},[K,Ou,Fu]),f.useEffect(()=>{Ql(Bi)},[Bi]);const rm=u=>{!u||!K||fetch(`${K}/history?session_id=${encodeURIComponent(u)}`).then(p=>p.json()).then(p=>{t(S=>S.map(x=>x.session_id===u?{...x,messages:p.messages||[]}:x))}).catch(()=>{})};async function ol(){if(K)try{const p=await(await fetch(`${K}/libraries`)).json(),S=Array.isArray(p.libraries)?p.libraries:[];if(E(S),S.length===0){h(null);return}S.some(x=>x.slug===v)||h(S[0].slug)}catch(u){console.warn("Failed to load libraries",u)}}async function po(){if(K)try{const p=await(await fetch(`${K}/jobs`)).json();R(Array.isArray(p.jobs)?p.jobs:[])}catch(u){console.warn("Failed to load library jobs",u)}}async function qu(u=null){const S=(typeof u=="string"?u:O).trim();if(!S){U("Name is required.");return}try{U("");const x=await fetch(`${K}/libraries`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})});if(!x.ok){const I=await x.text();throw new Error(I||`HTTP ${x.status}`)}const T=await x.json();$(!1),D(""),await ol(),T!=null&&T.slug&&h(T.slug)}catch(x){console.error("Failed to create library",x),U(String((x==null?void 0:x.message)||x))}}async function lm(){E([]),R([]),h(null),w(null),Ne(!1),C({}),await ol(),await po()}f.useEffect(()=>{K&&(Ki(!0),fetch(`${K}/sessions`).then(u=>u.json()).then(u=>{const p=u.sessions.map(S=>({...S,messages:[]}));t(p),p.length>0?r(p[0].session_id):r(null),Ki(!1)}).catch(()=>{Ki(!1)}))},[K]),f.useEffect(()=>{K&&(ol(),po())},[K]),f.useEffect(()=>{try{localStorage.setItem(Ud,JSON.stringify(m||{}))}catch{}},[m]),f.useEffect(()=>{if(!K)return;const u=setInterval(()=>{ol(),po()},3e3);return()=>clearInterval(u)},[K,l,v]),f.useEffect(()=>{rm(n)},[n,K]),f.useEffect(()=>{const u=new Set(k.map(p=>p.slug));C(p=>{let S=!1;const x={};for(const[T,I]of Object.entries(p||{}))u.has(I)?x[T]=I:S=!0;return S?x:p})},[k]);const Zi=u=>{o(u)},om=u=>{hm(u)},mr=f.useMemo(()=>{var u;return((u=e.find(p=>p.session_id===n))==null?void 0:u.messages)||[]},[n,e]),ho=f.useMemo(()=>k.find(u=>u.slug===v)||null,[v,k]),Wt=n&&m[n]||null,Et=f.useMemo(()=>k.find(u=>u.slug===Wt)||null,[Wt,k]),Zu=f.useMemo(()=>Wt?N.some(u=>u.slug===Wt&&(u.status==="queued"||u.status==="running")):!1,[Wt,N]),es=f.useMemo(()=>{var u,p;return Et?(u=Et.files)!=null&&u.length?(p=Et.states)!=null&&p.is_indexed?"":Zu?" (syncing)":" (needs sync)":" (empty)":""},[Et,Zu]);function im(u){return u&&m[u]||null}function ec(u){const p=im(u);return p&&k.find(S=>S.slug===p)||null}function tc(u){return u?N.some(p=>p.slug===u&&(p.status==="queued"||p.status==="running")):!1}function nc(u,p){u&&C(S=>{const x={...S||{}};return p?x[u]=p:delete x[u],x})}function sm(u){u&&C(p=>{let S=!1;const x={};for(const[T,I]of Object.entries(p||{})){if(I===u){S=!0;continue}x[T]=I}return S?x:p})}f.useEffect(()=>{if(!ne)return;const u=p=>{var S;(S=tr.current)!=null&&S.contains(p.target)||Ne(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[ne]),f.useEffect(()=>{Ne(!1)},[n,l]),f.useEffect(()=>{const u=n,p=l;return()=>{if(p==="chats"&&u){const S=typeof On.current[u]=="number"?On.current[u]:Pe.current?Pe.current.scrollTop:0;Du(x=>{const T={...x,[u]:S};return window.electronAPI.updateSettings({scrollPositions:T}),T})}}},[n,l]),f.useEffect(()=>{const u=Pe.current;if(!u)return;const p=()=>{const{scrollTop:S,scrollHeight:x,clientHeight:T}=u,I=x-S-T<=cw;if(n){const z=Ku.current[n],W=typeof z=="number"&&Su.removeEventListener("scroll",p)},[n,rl]),f.useEffect(()=>{const u=n;u&&Vu[u]===!1&&pr(p=>{if(!(u in p))return p;const S={...p};return delete S[u],S})},[n,Vu]),f.useLayoutEffect(()=>{if(l!=="chats"||!n)return;const u=Pe.current;if(!u)return;cn.current=null;const p=()=>{if(cn.current===n)return;const z=typeof On.current[n]=="number"?On.current[n]:void 0,W=typeof z=="number"?z:so[n];if(typeof W=="number"){u.scrollTop=W,cn.current=n;return}mr.length>0&&(u.scrollTop=u.scrollHeight,cn.current=n)};p();const S=requestAnimationFrame(p),x=()=>{cn.current!==n&&requestAnimationFrame(p)},T=new MutationObserver(x);T.observe(u,{childList:!0,subtree:!0});const I=new ResizeObserver(x);return I.observe(u),()=>{cancelAnimationFrame(S),T.disconnect(),I.disconnect()}},[n,l,mr.length,so]),f.useEffect(()=>{if(l!=="chats"||!n||cn.current===n)return;const u=typeof On.current[n]=="number"?On.current[n]:void 0;typeof(typeof u=="number"?u:so[n])!="number"&&mr.length>0&&requestAnimationFrame(()=>{const S=Pe.current;S&&(S.scrollTop=S.scrollHeight,cn.current=n)})},[mr.length,n,l,so]);const ts=(u="smooth",p=null)=>{const S=Pe.current;if(!S)return;const x=p??De.current;De.current===x&&(S.scrollTo({top:S.scrollHeight,behavior:u}),rl(x,!1))},gr=(u,p="auto",S=null)=>{const x=Pe.current;if(!x)return;const T=S??De.current;if(De.current!==T)return;const I=document.getElementById(u);if(I){const z=Math.max(0,I.offsetTop-uw);x.scrollTo({top:z,behavior:p})}},am=()=>{const u=De.current,p=Qu[u];p&&(gr(p,"smooth",u),pr(S=>{const{[u]:x,...T}=S;return T}))},um=u=>{l!=="chats"||!Ao(u)||(u.preventDefault(),Le.current+=1,b&&Hd(u)&&Oe(!0))},cm=u=>{l!=="chats"||!Ao(u)||(u.preventDefault(),u.dataTransfer.dropEffect=b?"copy":"none",b&&Hd(u)&&!ot&&Oe(!0))},dm=u=>{l!=="chats"||!Ao(u)||(Le.current=Math.max(0,Le.current-1),Le.current===0&&Oe(!1))},fm=async u=>{var p,S;l!=="chats"||!Ao(u)||(u.preventDefault(),Le.current=0,Oe(!1),b&&(await Hu((p=u.dataTransfer)==null?void 0:p.files),(S=Mt.current)==null||S.focus()))};async function rc(){var W,J,ke;const u=Z.trim();if(kt||!u&<.length===0||!de)return;if(lt.length>0&&!b){window.alert("The selected vision model does not support image inputs.");return}let p=n,S=!1;if(p){const ee=e.find(re=>re.session_id===p);S=ee&&ee.name==="New Chat"&&ee.messages.length===0}else{const ee=await lc();await new Promise(re=>setTimeout(re,200)),p=ee.session_id,S=!0}const x=lt.map(({id:ee,...re})=>({...re})),T=$h(x),I={role:"user",content:u,attachments:x,id:`msg-${Date.now()}-${Math.random()}`};Xh.current=!0,qh.current=p,rl(p,!1),De.current===p&&(cn.current=De.current),lh.flushSync(()=>{t(ee=>ee.map(re=>re.session_id===p?{...re,messages:[...re.messages||[],I]}:re)),se(""),Je([])}),requestAnimationFrame(()=>ts("auto",p));const z=Ju(p);try{let ee=[];if(I.content)try{ee=[...(((W=e.find(te=>te.session_id===p))==null?void 0:W.messages)||[]).slice(-8).map(te=>({role:te.role,content:te.content||""})),{role:"user",content:I.content}]}catch{}let re=I.content||null,He=[];const qe=[],Dn=ec(p);if(I.content&&((J=Dn==null?void 0:Dn.states)!=null&&J.is_indexed))try{const Q=await Bu(Dn.slug,I.content,z.signal);Q.contextBlock&&qe.push(Q.contextBlock),Array.isArray(Q.sources)&&He.push(...Q.sources)}catch(Q){if($t(Q))throw Q;console.warn("local library enrichment failed",Q)}if(I.content&&Be)try{const Se=await(await fetch(`${K}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({prompt:I.content,model:de,messages:ee,history_limit:8,searx_url:un||null,engines:Array.isArray(M)?M:null})})).json();Se&&typeof Se.context_block=="string"&&Se.context_block.trim()&&qe.push(Se.context_block.trim()),Array.isArray(Se==null?void 0:Se.sources)&&He.push(...Se.sources)}catch(Q){if($t(Q))throw Q;console.warn("web search enrichment failed",Q)}if(He=[...new Set(He)],I.content&&qe.length>0&&(re=`${I.content} - -${qe.join(` - -`)}`),ur){const Q=`msg-${Date.now()}-${Math.random()}`;let Se="";const te={role:"assistant",content:"",id:Q,sources:He};t(oe=>oe.map(Me=>Me.session_id===p?{...Me,messages:[...Me.messages||[],te]}:Me));try{const oe=await fetch(`${K}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({session_id:p,model:T,message:I.content,enriched_message:I.content&&qe.length>0?re:null,stream:!0,sources:He||[],attachments:x})});if(!oe.ok)throw new Error(await uo(oe));const Me=(ke=oe.body)==null?void 0:ke.getReader();if(!Me)throw new Error("Missing response body");const Y=new TextDecoder;let Vt=!1;for(;;){const{value:ae,done:Ee}=await Me.read();if(Ee){An(p,Q,Se),De.current===p?fr.current[p]?pr(Ot=>({...Ot,[p]:Q})):requestAnimationFrame(()=>gr(Q,"smooth",p)):($n(Ot=>({...Ot,[p]:Q})),dr(Ot=>[...new Set([...Ot,p])]));break}const dn=Y.decode(ae,{stream:!0});Se+=dn,An(p,Q,Se),De.current===p&&!fr.current[p]&&ts("auto",p),De.current!==p&&!Vt&&($n(Ot=>({...Ot,[p]:Q})),Vt=!0)}}catch(oe){if($t(oe)){An(p,Q,Se,{removeIfEmpty:!0});return}console.error("Failed to send message:",oe),An(p,Q,"Error: "+Ht(oe),{removeIfEmpty:!0});return}}else{const Q=await fetch(`${K}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({session_id:p,model:T,message:I.content,enriched_message:I.content&&qe.length>0?re:null,stream:!1,sources:He||[],attachments:x})});if(!Q.ok)throw new Error(await uo(Q));const Se=await Q.json(),te=`msg-${Date.now()}`,oe={role:"assistant",content:Se.reply,id:te,sources:He};t(Me=>Me.map(Y=>Y.session_id===p?{...Y,messages:[...Y.messages||[],oe]}:Y)),te&&(De.current===p?fr.current[p]?pr(Me=>({...Me,[p]:te})):requestAnimationFrame(()=>gr(te,"smooth",p)):$n(Me=>({...Me,[p]:te})))}De.current!==p&&dr(Q=>[...new Set([...Q,p])]),S&&fetch(`${K}/generate-title`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:p,message:I.content||(x.length>0?"Image attachment":I.content),model:de})}).then(Q=>Q.json()).then(Q=>{const Se=lw(Q.title);t(te=>te.map(oe=>oe.session_id===p?{...oe,name:Se}:oe))})}catch(ee){if($t(ee)){Xi(z);return}console.error("Failed to send message:",ee);const re={role:"assistant",content:"Error: "+Ht(ee),id:`msg-${Date.now()}-${Math.random()}`};t(He=>He.map(qe=>qe.session_id===p?{...qe,messages:[...qe.messages,re]}:qe))}finally{Xi(z)}}function pm(){Wi(u=>!u)}async function lc(){var T;const u="sess-"+Math.random().toString(36).slice(2)+Date.now().toString(36),S=await(await fetch(`${K}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:u})})).json(),x={...S,messages:[]};return t(I=>[x,...I]),r(S.session_id),(T=Mt.current)==null||T.focus(),S}function hm(u){r(u),dr(S=>S.filter(x=>x!==u));const p=Yh[u];p&&requestAnimationFrame(()=>{let S=12;const x=()=>{if(!Pe.current)return;let I=document.getElementById(p);if(!I){const z=e.find(W=>W.session_id===u);if(z&&Array.isArray(z.messages))for(let W=z.messages.length-1;W>=0;W--){const J=z.messages[W];if(J.role==="assistant"&&J.id){I=document.getElementById(J.id);break}}}I?(gr(I.id,"smooth",u),$n(z=>{const{[u]:W,...J}=z;return J})):S-- >0&&requestAnimationFrame(x)};requestAnimationFrame(x)})}function mm(u,p){fetch(`${K}/sessions/${u}/rename`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:p})}).then(()=>{t(S=>S.map(x=>x.session_id===u?{...x,name:p}:x)),g(null)})}function gm(u,p){const S=(p||"").trim(),x=k.find(T=>T.slug===u);if(!x){w(null);return}if(!S||S===x.name){w(null);return}fetch(`${K}/libraries/${u}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})}).then(()=>{E(T=>T.map(I=>I.slug===u?{...I,name:S}:I)),w(null)})}function oc(u){fetch(`${K}/sessions/${u}`,{method:"DELETE"}).then(()=>{const p=e.filter(S=>S.session_id!==u);t(p),C(S=>{const x={...S||{}};return delete x[u],x}),n===u&&r(p.length>0?p[0].session_id:null)})}function vm(u){fetch(`${K}/libraries/${u}`,{method:"DELETE"}).then(async p=>{var x;if(!p.ok){const T=await p.text();throw new Error(T||`HTTP ${p.status}`)}const S=k.filter(T=>T.slug!==u);E(S),R(T=>T.filter(I=>I.slug!==u)),w(T=>T===u?null:T),v===u&&h(((x=S[0])==null?void 0:x.slug)||null),sm(u)}).catch(p=>{console.error("Failed to delete library",p)})}f.useEffect(()=>{const u=e.filter(p=>p.name==="New Chat"&&p.session_id!==n&&p.messages.length===0);u.length>0&&u.forEach(p=>{oc(p.session_id)})},[n,e,K]);const ym=u=>{var S;window.getSelection().toString().length>0||document.activeElement!==Mt.current&&(u.target.closest(".msg")||(S=Mt.current)==null||S.focus())};return d.jsxs("div",{className:"app",style:{gridTemplateColumns:`${em}px 1fr`},children:[d.jsxs("div",{className:"sidebar",children:[d.jsxs("div",{className:"sidebar-header",children:[d.jsx("div",{className:`sidebar-tab ${l==="chats"?"active":""}`,onClick:()=>Zi("chats"),children:"Chats"}),d.jsx("div",{className:`sidebar-tab ${l==="dbs"?"active":""}`,onClick:()=>Zi("dbs"),children:"DBs"}),d.jsx("div",{className:`sidebar-tab ${l==="settings"?"active":""}`,onClick:()=>Zi("settings"),children:"Settings"})]}),d.jsxs("div",{className:"sidebar-content",children:[l==="chats"&&d.jsx("div",{className:"chat-list",children:e.map(u=>d.jsx("div",{className:`chat-item ${u.session_id===n?"active":""}`,onClick:()=>om(u.session_id),children:c===u.session_id?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>g(null),onKeyDown:p=>{p.key==="Enter"?mm(u.session_id,p.target.value):p.key==="Escape"&&g(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[Th.includes(u.session_id)&&d.jsx("div",{className:"unread-dot"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),g(u.session_id)},children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",children:d.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),oc(u.session_id)},children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-x",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})},u.session_id))}),l==="dbs"&&d.jsx("div",{className:"db-list",children:k.length===0?d.jsx("div",{className:"empty-list-message",children:"No databases yet."}):k.map(u=>d.jsx("div",{className:`chat-item ${u.slug===v?"active":""}`,onClick:()=>h(u.slug),children:y===u.slug?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>w(null),onKeyDown:p=>{p.key==="Enter"?gm(u.slug,p.target.value):p.key==="Escape"&&w(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[Wt===u.slug&&d.jsx("div",{className:"db-active-badge",children:"Chat"}),tc(u.slug)&&d.jsx("div",{className:"db-active-badge",children:"Syncing"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),w(u.slug)},children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",children:d.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),vm(u.slug)},children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-x",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})},u.slug))}),l==="settings"&&d.jsxs("div",{className:"settings-list",children:[d.jsx("div",{className:`settings-item ${s==="General"?"active":""}`,onClick:()=>a("General"),children:"General"}),d.jsx("div",{className:`settings-item ${s==="Interface"?"active":""}`,onClick:()=>a("Interface"),children:"Interface"}),d.jsx("div",{className:`settings-item ${s==="Websearch"?"active":""}`,onClick:()=>a("Websearch"),children:"Websearch"})]})]}),l!=="settings"&&d.jsxs("div",{className:"sidebar-footer",children:[l==="chats"&&d.jsx("button",{className:"button new-chat-button",onClick:lc,children:"New Chat"}),l==="dbs"&&(j?d.jsxs("div",{className:"new-db-form",children:[d.jsx("input",{type:"text",className:"rename-input",value:O,onChange:u=>D(u.target.value),onKeyDown:u=>{u.key==="Enter"?qu():u.key==="Escape"&&($(!1),D(""),U(""))},placeholder:"Database name",autoFocus:!0}),V&&d.jsx("div",{className:"form-error",children:V}),d.jsxs("div",{className:"new-db-actions",children:[d.jsx("button",{className:"button new-db-button",onClick:()=>qu(),children:"Create"}),d.jsx("button",{className:"button ghost",onClick:()=>{$(!1),D(""),U("")},children:"Cancel"})]})]}):d.jsx("button",{className:"button new-db-button",onClick:()=>{$(!0),U("")},children:"New Database"}))]}),d.jsx("div",{className:"resizer",onMouseDown:nm})]}),d.jsxs("div",{className:`main-content${l==="chats"&&ot?" main-content--drag-active":""}`,onDragEnter:um,onDragOver:cm,onDragLeave:dm,onDrop:fm,children:[el&&d.jsxs("div",{className:"startup-task-banner",role:"status","aria-live":"polite",children:[io&&d.jsx("div",{className:"spinner startup-task-banner__spinner"}),d.jsx("div",{className:"startup-task-banner__text",children:el})]}),l==="chats"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsxs("strong",{children:["Chat - ",((ic=e.find(u=>u.session_id===n))==null?void 0:ic.name)||"New Chat"]}),Et&&d.jsx("span",{className:"header-subtle",children:`DB: ${Et.name}${es}`})]}),d.jsx("div",{className:`chat${ot?" chat--drag-active":""}`,ref:Pe,onClick:ym,children:mr.map((u,p)=>{const S=u.role==="user"&&Mh===p;return d.jsx("div",{id:u.id,className:"msg "+(u.role==="user"?"user":"assistant")+(S?" editing":""),children:u.role==="assistant"?d.jsxs("div",{className:"assistant-message-wrapper",children:[d.jsx(iw,{content:u.content,streamOutput:ur,sources:u.sources}),!kt&&d.jsxs("div",{className:"message-options-bar assistant-options",children:[d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>bu(u),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),d.jsx("button",{className:"icon-button",title:"Regenerate response",onClick:()=>Wu(p),children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})})]})]}):d.jsxs("div",{className:"user-message-wrapper",children:[S?d.jsxs(d.Fragment,{children:[d.jsx(As,{attachments:u.attachments,className:"message-attachment-strip"}),d.jsxs("div",{className:"msg-content msg-content--user editing",children:[d.jsx("div",{className:"user-edit-shadow","aria-hidden":"true",children:Yi}),d.jsx(_d,{className:"edit-message-input edit-overlay",value:Yi,onChange:x=>ao(x.target.value),onBlur:co,onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),co()),x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),Kh(p))},autoFocus:!0,minRows:1})]})]}):(()=>{const x=u.content||"",T=Array.isArray(u.attachments)?u.attachments:[],I=x.split(/\r\n|\r|\n/),z=I.length>30,W=Gu(u,p,n),J=z?Gh[W]??!0:!1,ke=J?I.slice(0,30).join(` -`)+` -…`:x,ee=!!x.trim();return d.jsxs(d.Fragment,{children:[d.jsx(As,{attachments:T,className:"message-attachment-strip"}),ee&&d.jsx("div",{className:"msg-content msg-content--user",children:ke}),ee&&z&&d.jsx("button",{className:"user-msg-expand",onClick:()=>Jh(W),"aria-expanded":J?"false":"true",children:J?"Show entire message":"Collapse"})]})})(),!kt&&!S&&d.jsxs("div",{className:"message-options-bar user-options",children:[d.jsx("button",{className:"icon-button",title:"Edit message",onClick:()=>Vh(p,u.content),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 20h9"}),d.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}),d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>bu(u),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]})},u.id||p)})},n),Qu[n]&&d.jsxs("button",{className:"new-msg-tip",onClick:am,title:"Jump to the new message","aria-label":"Jump to the new message",children:["New message",d.jsx("span",{style:{marginLeft:6},children:"↓"})]}),d.jsx("div",{className:"footer",children:d.jsxs("div",{className:`footer-inner${ot?" footer-inner--drag-active":""}`,children:[d.jsx("input",{ref:ht,type:"file",accept:"image/*",multiple:!0,className:"composer-image-input",onChange:Wh,tabIndex:-1}),d.jsx(As,{attachments:lt,className:"composer-attachment-strip",removable:!0,onRemove:zh}),(pe||it)&&d.jsxs("div",{className:"composer-audio-status"+(pe?" composer-audio-status--recording":" composer-audio-status--transcribing"),role:"status","aria-live":"polite",children:[pe?d.jsx("span",{className:"composer-audio-status__dot","aria-hidden":"true"}):d.jsx("div",{className:"spinner composer-audio-status__spinner","aria-hidden":"true"}),d.jsx("span",{children:pe?`Listening ${hw(Ui)}`:"Transcribing audio…"})]}),d.jsxs("div",{className:"footer-content-wrapper",children:[d.jsx(_d,{ref:Mt,className:"input",value:Z,onChange:u=>se(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&!pe&&!it&&(u.preventDefault(),rc())},placeholder:"Ask any question...",maxRows:13}),d.jsxs("div",{className:"footer-tool-group",ref:tr,children:[d.jsx("button",{type:"button",className:"db-picker-toggle"+(Et?" active":""),onClick:()=>{n&&Ne(u=>!u)},title:Et?`Database: ${Et.name}${es}`:"Select database for this chat","aria-haspopup":"menu","aria-expanded":ne,disabled:!n,children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("ellipse",{cx:"12",cy:"5",rx:"8",ry:"3"}),d.jsx("path",{d:"M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5"}),d.jsx("path",{d:"M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6"})]})}),ne&&d.jsxs("div",{className:"db-picker-menu",role:"menu",children:[d.jsxs("button",{type:"button",className:"db-picker-option"+(Wt?"":" selected"),onClick:()=>{nc(n,null),Ne(!1)},children:[d.jsx("span",{children:"No database"}),!Wt&&d.jsx("span",{className:"db-picker-status",children:"Selected"})]}),k.length===0?d.jsx("div",{className:"db-picker-empty",children:"No databases yet."}):k.map(u=>{var T,I,z;const p=Wt===u.slug,S=tc(u.slug),x=(T=u.files)!=null&&T.length?(I=u.states)!=null&&I.is_indexed?"Ready":S?"Syncing":"Needs sync":"Empty";return d.jsxs("button",{type:"button",className:"db-picker-option"+(p?" selected":""),disabled:!((z=u.files)!=null&&z.length),onClick:()=>{nc(n,u.slug),Ne(!1)},children:[d.jsx("span",{children:u.name}),d.jsx("span",{className:"db-picker-status",children:p?"Selected":x})]},u.slug)})]})]}),b&&d.jsx("button",{type:"button",className:"image-attach-toggle"+(lt.length>0?" active":""),onClick:bh,title:"Attach images","aria-label":"Attach images",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),on&&d.jsx("button",{type:"button",className:"audio-input-toggle"+(pe||it?" active":"")+(pe?" recording":"")+(it?" transcribing":""),onClick:Hh,title:It?pe?"Stop voice input":it?"Transcribing audio":"Start voice input":lo||"Whisper is not available for audio input.","aria-label":It?pe?"Stop voice input":it?"Transcribing audio":"Start voice input":lo||"Whisper is not available for audio input.","aria-pressed":pe,disabled:!It||it||kt,children:it?d.jsx("div",{className:"spinner composer-audio-icon-spinner","aria-hidden":"true"}):d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M12 3a3 3 0 0 1 3 3v6a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z"}),d.jsx("path",{d:"M19 10a7 7 0 0 1-14 0"}),d.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"}),d.jsx("line",{x1:"8",y1:"22",x2:"16",y2:"22"})]})}),d.jsx("button",{type:"button",className:"websearch-toggle"+(Be?" active":""),onClick:pm,title:"Toggle web search","aria-pressed":Be,children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),d.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}),d.jsx("button",{className:"button",onClick:kt?Zh:rc,title:kt?"Cancel generation":"Send","aria-label":kt?"Cancel generation":"Send",disabled:!kt&&(pe||it),children:kt?d.jsx("div",{className:"spinner"}):"Send"})]})]})})]}),l==="dbs"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsx("strong",{children:(ho==null?void 0:ho.name)||"Databases"}),Et&&d.jsx("span",{className:"header-subtle",children:`Current chat DB: ${Et.name}${es}`})]}),d.jsx(q0,{apiBase:K,library:ho,jobs:N,onRefresh:async()=>{await ol(),await po()}})]}),l==="settings"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"header",children:d.jsxs("strong",{children:[s," Settings"]})}),s==="General"&&d.jsx(V0,{onModelChange:pt,onVisionModelChange:B,onTranscriptionModelChange:A,onBackendApiUrlChange:ar,streamOutput:ur,onStreamOutputChange:sn,onAudioInputEnabledChange:Gr,onAudioInputDeviceChange:Jr,onAudioInputLanguageChange:nr,onLibrariesPurged:lm}),s==="Interface"&&d.jsx(J0,{}),s==="Websearch"&&d.jsx(nw,{searxUrl:un,setSearxUrl:_,engines:M,setEngines:u=>he(xi(u))})]})]})]})}function gw(){return f.useEffect(()=>{window.electronAPI.getSettings().then(e=>{Ql(e.colorScheme||"Default")})},[]),d.jsx(Ve.StrictMode,{children:d.jsx(i0,{children:d.jsx(Dy,{children:d.jsx(vh,{path:"/",element:d.jsx(mw,{})})})})})}const vw=oh(document.getElementById("root"));vw.render(d.jsx(gw,{})); diff --git a/dist/assets/index-D_Wipza2.js b/dist/assets/index-D_Wipza2.js new file mode 100644 index 0000000..99ed383 --- /dev/null +++ b/dist/assets/index-D_Wipza2.js @@ -0,0 +1,88 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const o of l)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(l){const o={};return l.integrity&&(o.integrity=l.integrity),l.referrerPolicy&&(o.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?o.credentials="include":l.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(l){if(l.ep)return;l.ep=!0;const o=n(l);fetch(l.href,o)}})();function km(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hd={exports:{}},yi={},Wd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ul=Symbol.for("react.element"),Em=Symbol.for("react.portal"),Cm=Symbol.for("react.fragment"),Nm=Symbol.for("react.strict_mode"),_m=Symbol.for("react.profiler"),Rm=Symbol.for("react.provider"),jm=Symbol.for("react.context"),Lm=Symbol.for("react.forward_ref"),Tm=Symbol.for("react.suspense"),Pm=Symbol.for("react.memo"),Mm=Symbol.for("react.lazy"),oc=Symbol.iterator;function Am(e){return e===null||typeof e!="object"?null:(e=oc&&e[oc]||e["@@iterator"],typeof e=="function"?e:null)}var Vd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Kd=Object.assign,Qd={};function zr(e,t,n){this.props=e,this.context=t,this.refs=Qd,this.updater=n||Vd}zr.prototype.isReactComponent={};zr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};zr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Yd(){}Yd.prototype=zr.prototype;function Pa(e,t,n){this.props=e,this.context=t,this.refs=Qd,this.updater=n||Vd}var Ma=Pa.prototype=new Yd;Ma.constructor=Pa;Kd(Ma,zr.prototype);Ma.isPureReactComponent=!0;var ic=Array.isArray,Gd=Object.prototype.hasOwnProperty,Aa={current:null},Jd={key:!0,ref:!0,__self:!0,__source:!0};function Xd(e,t,n){var r,l={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)Gd.call(t,r)&&!Jd.hasOwnProperty(r)&&(l[r]=t[r]);var s=arguments.length-2;if(s===1)l.children=n;else if(1>>1,q=I[Z];if(0>>1;Zl(vt,W))Oel(Te,vt)?(I[Z]=Te,I[Oe]=W,Z=Oe):(I[Z]=vt,I[Be]=W,Z=Be);else if(Oel(Te,W))I[Z]=Te,I[Oe]=W,Z=Oe;else break e}}return b}function l(I,b){var W=I.sortIndex-b.sortIndex;return W!==0?W:I.id-b.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,s=i.now();e.unstable_now=function(){return i.now()-s}}var a=[],c=[],m=1,w=null,y=3,x=!1,E=!1,C=!1,R=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function g(I){for(var b=n(c);b!==null;){if(b.callback===null)r(c);else if(b.startTime<=I)r(c),b.sortIndex=b.expirationTime,t(a,b);else break;b=n(c)}}function N(I){if(C=!1,g(I),!E)if(n(a)!==null)E=!0,B(P);else{var b=n(c);b!==null&&G(N,b.startTime-I)}}function P(I,b){E=!1,C&&(C=!1,v(D),D=-1),x=!0;var W=y;try{for(g(b),w=n(a);w!==null&&(!(w.expirationTime>b)||I&&!le());){var Z=w.callback;if(typeof Z=="function"){w.callback=null,y=w.priorityLevel;var q=Z(w.expirationTime<=b);b=e.unstable_now(),typeof q=="function"?w.callback=q:w===n(a)&&r(a),g(b)}else r(a);w=n(a)}if(w!==null)var fe=!0;else{var Be=n(c);Be!==null&&G(N,Be.startTime-b),fe=!1}return fe}finally{w=null,y=W,x=!1}}var $=!1,O=null,D=-1,H=5,U=-1;function le(){return!(e.unstable_now()-UI||125Z?(I.sortIndex=W,t(c,I),n(a)===null&&I===n(c)&&(C?(v(D),D=-1):C=!0,G(N,W-Z))):(I.sortIndex=q,t(a,I),E||x||(E=!0,B(P))),I},e.unstable_shouldYield=le,e.unstable_wrapCallback=function(I){var b=y;return function(){var W=y;y=b;try{return I.apply(this,arguments)}finally{y=W}}}})(nf);tf.exports=nf;var Wm=tf.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vm=f,st=Wm;function j(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ms=Object.prototype.hasOwnProperty,Km=/^[: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]*$/,ac={},uc={};function Qm(e){return Ms.call(uc,e)?!0:Ms.call(ac,e)?!1:Km.test(e)?uc[e]=!0:(ac[e]=!0,!1)}function Ym(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Gm(e,t,n,r){if(t===null||typeof t>"u"||Ym(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ge(e,t,n,r,l,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var $e={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){$e[e]=new Ge(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];$e[t]=new Ge(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){$e[e]=new Ge(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){$e[e]=new Ge(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){$e[e]=new Ge(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){$e[e]=new Ge(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){$e[e]=new Ge(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){$e[e]=new Ge(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){$e[e]=new Ge(e,5,!1,e.toLowerCase(),null,!1,!1)});var $a=/[\-:]([a-z])/g;function Oa(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace($a,Oa);$e[t]=new Ge(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace($a,Oa);$e[t]=new Ge(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace($a,Oa);$e[t]=new Ge(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){$e[e]=new Ge(e,1,!1,e.toLowerCase(),null,!1,!1)});$e.xlinkHref=new Ge("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){$e[e]=new Ge(e,1,!1,e.toLowerCase(),null,!0,!0)});function Da(e,t,n,r){var l=$e.hasOwnProperty(t)?$e[t]:null;(l!==null?l.type!==0:r||!(2s||l[i]!==o[s]){var a=` +`+l[i].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=i&&0<=s);break}}}finally{es=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ul(e):""}function Jm(e){switch(e.tag){case 5:return ul(e.type);case 16:return ul("Lazy");case 13:return ul("Suspense");case 19:return ul("SuspenseList");case 0:case 2:case 15:return e=ts(e.type,!1),e;case 11:return e=ts(e.type.render,!1),e;case 1:return e=ts(e.type,!0),e;default:return""}}function Os(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case mr:return"Fragment";case hr:return"Portal";case As:return"Profiler";case Fa:return"StrictMode";case Is:return"Suspense";case $s:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case of:return(e.displayName||"Context")+".Consumer";case lf:return(e._context.displayName||"Context")+".Provider";case za:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ba:return t=e.displayName||null,t!==null?t:Os(e.type)||"Memo";case sn:t=e._payload,e=e._init;try{return Os(e(t))}catch{}}return null}function Xm(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Os(t);case 8:return t===Fa?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function xn(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function af(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function qm(e){var t=af(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function fo(e){e._valueTracker||(e._valueTracker=qm(e))}function uf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=af(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ko(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}}function Ds(e,t){var n=t.checked;return ge({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function dc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=xn(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function cf(e,t){t=t.checked,t!=null&&Da(e,"checked",t,!1)}function Fs(e,t){cf(e,t);var n=xn(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?zs(e,t.type,n):t.hasOwnProperty("defaultValue")&&zs(e,t.type,xn(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function fc(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function zs(e,t,n){(t!=="number"||Ko(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var cl=Array.isArray;function _r(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=po.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function El(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var pl={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Zm=["Webkit","ms","Moz","O"];Object.keys(pl).forEach(function(e){Zm.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),pl[t]=pl[e]})});function hf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||pl.hasOwnProperty(e)&&pl[e]?(""+t).trim():t+"px"}function mf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=hf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var eg=ge({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Bs(e,t){if(t){if(eg[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(j(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(j(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(j(61))}if(t.style!=null&&typeof t.style!="object")throw Error(j(62))}}function Hs(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";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 Ws=null;function Ua(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Vs=null,Rr=null,jr=null;function mc(e){if(e=Wl(e)){if(typeof Vs!="function")throw Error(j(280));var t=e.stateNode;t&&(t=Ei(t),Vs(e.stateNode,e.type,t))}}function gf(e){Rr?jr?jr.push(e):jr=[e]:Rr=e}function vf(){if(Rr){var e=Rr,t=jr;if(jr=Rr=null,mc(e),t)for(e=0;e>>=0,e===0?32:31-(dg(e)/fg|0)|0}var ho=64,mo=4194304;function dl(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Jo(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var s=i&~l;s!==0?r=dl(s):(o&=i,o!==0&&(r=dl(o)))}else i=n&~l,i!==0?r=dl(i):o!==0&&(r=dl(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Bl(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ct(t),e[t]=n}function gg(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=ml),Cc=" ",Nc=!1;function Df(e,t){switch(e){case"keyup":return Wg.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ff(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var gr=!1;function Kg(e,t){switch(e){case"compositionend":return Ff(t);case"keypress":return t.which!==32?null:(Nc=!0,Cc);case"textInput":return e=t.data,e===Cc&&Nc?null:e;default:return null}}function Qg(e,t){if(gr)return e==="compositionend"||!Ga&&Df(e,t)?(e=$f(),Io=Ka=dn=null,gr=!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)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Lc(n)}}function Bf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Bf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Hf(){for(var e=window,t=Ko();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ko(e.document)}return t}function Ja(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")}function nv(e){var t=Hf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Bf(n.ownerDocument.documentElement,n)){if(r!==null&&Ja(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,o=Math.min(r.start,l);r=r.end===void 0?o:Math.min(r.end,l),!e.extend&&o>r&&(l=r,r=o,o=l),l=Tc(n,o);var i=Tc(n,r);l&&i&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,vr=null,Xs=null,vl=null,qs=!1;function Pc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;qs||vr==null||vr!==Ko(r)||(r=vr,"selectionStart"in r&&Ja(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),vl&&Ll(vl,r)||(vl=r,r=Zo(Xs,"onSelect"),0Sr||(e.current=la[Sr],la[Sr]=null,Sr--)}function ie(e,t){Sr++,la[Sr]=e.current,e.current=t}var kn={},Ue=Cn(kn),Ze=Cn(!1),Hn=kn;function Ar(e,t){var n=e.type.contextTypes;if(!n)return kn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},o;for(o in n)l[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function et(e){return e=e.childContextTypes,e!=null}function ti(){ue(Ze),ue(Ue)}function Fc(e,t,n){if(Ue.current!==kn)throw Error(j(168));ie(Ue,t),ie(Ze,n)}function qf(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(j(108,Xm(e)||"Unknown",l));return ge({},n,r)}function ni(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||kn,Hn=Ue.current,ie(Ue,e),ie(Ze,Ze.current),!0}function zc(e,t,n){var r=e.stateNode;if(!r)throw Error(j(169));n?(e=qf(e,t,Hn),r.__reactInternalMemoizedMergedChildContext=e,ue(Ze),ue(Ue),ie(Ue,e)):ue(Ze),ie(Ze,n)}var Ht=null,Ci=!1,ms=!1;function Zf(e){Ht===null?Ht=[e]:Ht.push(e)}function hv(e){Ci=!0,Zf(e)}function Nn(){if(!ms&&Ht!==null){ms=!0;var e=0,t=re;try{var n=Ht;for(re=1;e>=i,l-=i,Wt=1<<32-Ct(t)+l|n<D?(H=O,O=null):H=O.sibling;var U=y(v,O,g[D],N);if(U===null){O===null&&(O=H);break}e&&O&&U.alternate===null&&t(v,O),h=o(U,h,D),$===null?P=U:$.sibling=U,$=U,O=H}if(D===g.length)return n(v,O),de&&On(v,D),P;if(O===null){for(;DD?(H=O,O=null):H=O.sibling;var le=y(v,O,U.value,N);if(le===null){O===null&&(O=H);break}e&&O&&le.alternate===null&&t(v,O),h=o(le,h,D),$===null?P=le:$.sibling=le,$=le,O=H}if(U.done)return n(v,O),de&&On(v,D),P;if(O===null){for(;!U.done;D++,U=g.next())U=w(v,U.value,N),U!==null&&(h=o(U,h,D),$===null?P=U:$.sibling=U,$=U);return de&&On(v,D),P}for(O=r(v,O);!U.done;D++,U=g.next())U=x(O,v,D,U.value,N),U!==null&&(e&&U.alternate!==null&&O.delete(U.key===null?D:U.key),h=o(U,h,D),$===null?P=U:$.sibling=U,$=U);return e&&O.forEach(function(Ne){return t(v,Ne)}),de&&On(v,D),P}function R(v,h,g,N){if(typeof g=="object"&&g!==null&&g.type===mr&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case co:e:{for(var P=g.key,$=h;$!==null;){if($.key===P){if(P=g.type,P===mr){if($.tag===7){n(v,$.sibling),h=l($,g.props.children),h.return=v,v=h;break e}}else if($.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===sn&&Bc(P)===$.type){n(v,$.sibling),h=l($,g.props),h.ref=ll(v,$,g),h.return=v,v=h;break e}n(v,$);break}else t(v,$);$=$.sibling}g.type===mr?(h=Bn(g.props.children,v.mode,N,g.key),h.return=v,v=h):(N=Bo(g.type,g.key,g.props,null,v.mode,N),N.ref=ll(v,h,g),N.return=v,v=N)}return i(v);case hr:e:{for($=g.key;h!==null;){if(h.key===$)if(h.tag===4&&h.stateNode.containerInfo===g.containerInfo&&h.stateNode.implementation===g.implementation){n(v,h.sibling),h=l(h,g.children||[]),h.return=v,v=h;break e}else{n(v,h);break}else t(v,h);h=h.sibling}h=Es(g,v.mode,N),h.return=v,v=h}return i(v);case sn:return $=g._init,R(v,h,$(g._payload),N)}if(cl(g))return E(v,h,g,N);if(Zr(g))return C(v,h,g,N);ko(v,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,h!==null&&h.tag===6?(n(v,h.sibling),h=l(h,g),h.return=v,v=h):(n(v,h),h=ks(g,v.mode,N),h.return=v,v=h),i(v)):n(v,h)}return R}var $r=rp(!0),lp=rp(!1),oi=Cn(null),ii=null,Er=null,eu=null;function tu(){eu=Er=ii=null}function nu(e){var t=oi.current;ue(oi),e._currentValue=t}function sa(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Tr(e,t){ii=e,eu=Er=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(qe=!0),e.firstContext=null)}function ht(e){var t=e._currentValue;if(eu!==e)if(e={context:e,memoizedValue:t,next:null},Er===null){if(ii===null)throw Error(j(308));Er=e,ii.dependencies={lanes:0,firstContext:e}}else Er=Er.next=e;return t}var zn=null;function ru(e){zn===null?zn=[e]:zn.push(e)}function op(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,ru(t)):(n.next=l.next,l.next=n),t.interleaved=n,Jt(e,r)}function Jt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var an=!1;function lu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ip(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Kt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function vn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,X&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Jt(e,n)}return l=r.interleaved,l===null?(t.next=t,ru(r)):(t.next=l.next,l.next=t),r.interleaved=t,Jt(e,n)}function Oo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ha(e,n)}}function Hc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?l=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?l=o=t:o=o.next=t}else l=o=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function si(e,t,n,r){var l=e.updateQueue;an=!1;var o=l.firstBaseUpdate,i=l.lastBaseUpdate,s=l.shared.pending;if(s!==null){l.shared.pending=null;var a=s,c=a.next;a.next=null,i===null?o=c:i.next=c,i=a;var m=e.alternate;m!==null&&(m=m.updateQueue,s=m.lastBaseUpdate,s!==i&&(s===null?m.firstBaseUpdate=c:s.next=c,m.lastBaseUpdate=a))}if(o!==null){var w=l.baseState;i=0,m=c=a=null,s=o;do{var y=s.lane,x=s.eventTime;if((r&y)===y){m!==null&&(m=m.next={eventTime:x,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var E=e,C=s;switch(y=t,x=n,C.tag){case 1:if(E=C.payload,typeof E=="function"){w=E.call(x,w,y);break e}w=E;break e;case 3:E.flags=E.flags&-65537|128;case 0:if(E=C.payload,y=typeof E=="function"?E.call(x,w,y):E,y==null)break e;w=ge({},w,y);break e;case 2:an=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,y=l.effects,y===null?l.effects=[s]:y.push(s))}else x={eventTime:x,lane:y,tag:s.tag,payload:s.payload,callback:s.callback,next:null},m===null?(c=m=x,a=w):m=m.next=x,i|=y;if(s=s.next,s===null){if(s=l.shared.pending,s===null)break;y=s,s=y.next,y.next=null,l.lastBaseUpdate=y,l.shared.pending=null}}while(!0);if(m===null&&(a=w),l.baseState=a,l.firstBaseUpdate=c,l.lastBaseUpdate=m,t=l.shared.interleaved,t!==null){l=t;do i|=l.lane,l=l.next;while(l!==t)}else o===null&&(l.shared.lanes=0);Kn|=i,e.lanes=i,e.memoizedState=w}}function Wc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=vs.transition;vs.transition={};try{e(!1),t()}finally{re=n,vs.transition=r}}function Ep(){return mt().memoizedState}function yv(e,t,n){var r=wn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Cp(e))Np(t,n);else if(n=op(e,t,n,r),n!==null){var l=Qe();Nt(n,e,r,l),_p(n,t,r)}}function wv(e,t,n){var r=wn(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Cp(e))Np(t,l);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,s=o(i,n);if(l.hasEagerState=!0,l.eagerState=s,_t(s,i)){var a=t.interleaved;a===null?(l.next=l,ru(t)):(l.next=a.next,a.next=l),t.interleaved=l;return}}catch{}finally{}n=op(e,t,l,r),n!==null&&(l=Qe(),Nt(n,e,r,l),_p(n,t,r))}}function Cp(e){var t=e.alternate;return e===he||t!==null&&t===he}function Np(e,t){yl=ui=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function _p(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ha(e,n)}}var ci={readContext:ht,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useInsertionEffect:Fe,useLayoutEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useMutableSource:Fe,useSyncExternalStore:Fe,useId:Fe,unstable_isNewReconciler:!1},Sv={readContext:ht,useCallback:function(e,t){return At().memoizedState=[e,t===void 0?null:t],e},useContext:ht,useEffect:Kc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Fo(4194308,4,yp.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Fo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Fo(4,2,e,t)},useMemo:function(e,t){var n=At();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=At();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=yv.bind(null,he,e),[r.memoizedState,e]},useRef:function(e){var t=At();return e={current:e},t.memoizedState=e},useState:Vc,useDebugValue:fu,useDeferredValue:function(e){return At().memoizedState=e},useTransition:function(){var e=Vc(!1),t=e[0];return e=vv.bind(null,e[1]),At().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=he,l=At();if(de){if(n===void 0)throw Error(j(407));n=n()}else{if(n=t(),Le===null)throw Error(j(349));Vn&30||cp(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Kc(fp.bind(null,r,o,e),[e]),r.flags|=2048,Dl(9,dp.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=At(),t=Le.identifierPrefix;if(de){var n=Vt,r=Wt;n=(r&~(1<<32-Ct(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=$l++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[It]=t,e[Ml]=r,Op(e,t,!1,!1),t.stateNode=e;e:{switch(i=Hs(n,r),n){case"dialog":ae("cancel",e),ae("close",e),l=r;break;case"iframe":case"object":case"embed":ae("load",e),l=r;break;case"video":case"audio":for(l=0;lFr&&(t.flags|=128,r=!0,ol(o,!1),t.lanes=4194304)}else{if(!r)if(e=ai(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ol(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!de)return ze(t),null}else 2*xe()-o.renderingStartTime>Fr&&n!==1073741824&&(t.flags|=128,r=!0,ol(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=xe(),t.sibling=null,n=pe.current,ie(pe,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return yu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?lt&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(j(156,t.tag))}function jv(e,t){switch(qa(t),t.tag){case 1:return et(t.type)&&ti(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Or(),ue(Ze),ue(Ue),su(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return iu(t),null;case 13:if(ue(pe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(j(340));Ir()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ue(pe),null;case 4:return Or(),null;case 10:return nu(t.type._context),null;case 22:case 23:return yu(),null;case 24:return null;default:return null}}var Co=!1,be=!1,Lv=typeof WeakSet=="function"?WeakSet:Set,F=null;function Cr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ye(e,t,r)}else n.current=null}function ga(e,t,n){try{n()}catch(r){ye(e,t,r)}}var rd=!1;function Tv(e,t){if(Zs=Xo,e=Hf(),Ja(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,s=-1,a=-1,c=0,m=0,w=e,y=null;t:for(;;){for(var x;w!==n||l!==0&&w.nodeType!==3||(s=i+l),w!==o||r!==0&&w.nodeType!==3||(a=i+r),w.nodeType===3&&(i+=w.nodeValue.length),(x=w.firstChild)!==null;)y=w,w=x;for(;;){if(w===e)break t;if(y===n&&++c===l&&(s=i),y===o&&++m===r&&(a=i),(x=w.nextSibling)!==null)break;w=y,y=w.parentNode}w=x}n=s===-1||a===-1?null:{start:s,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(ea={focusedElem:e,selectionRange:n},Xo=!1,F=t;F!==null;)if(t=F,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,F=e;else for(;F!==null;){t=F;try{var E=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(E!==null){var C=E.memoizedProps,R=E.memoizedState,v=t.stateNode,h=v.getSnapshotBeforeUpdate(t.elementType===t.type?C:xt(t.type,C),R);v.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var g=t.stateNode.containerInfo;g.nodeType===1?g.textContent="":g.nodeType===9&&g.documentElement&&g.removeChild(g.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(j(163))}}catch(N){ye(t,t.return,N)}if(e=t.sibling,e!==null){e.return=t.return,F=e;break}F=t.return}return E=rd,rd=!1,E}function wl(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var o=l.destroy;l.destroy=void 0,o!==void 0&&ga(t,n,o)}l=l.next}while(l!==r)}}function Ri(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function va(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function zp(e){var t=e.alternate;t!==null&&(e.alternate=null,zp(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[It],delete t[Ml],delete t[ra],delete t[fv],delete t[pv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function bp(e){return e.tag===5||e.tag===3||e.tag===4}function ld(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||bp(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.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 ya(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ei));else if(r!==4&&(e=e.child,e!==null))for(ya(e,t,n),e=e.sibling;e!==null;)ya(e,t,n),e=e.sibling}function wa(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(wa(e,t,n),e=e.sibling;e!==null;)wa(e,t,n),e=e.sibling}var Ae=null,kt=!1;function on(e,t,n){for(n=n.child;n!==null;)Up(e,t,n),n=n.sibling}function Up(e,t,n){if($t&&typeof $t.onCommitFiberUnmount=="function")try{$t.onCommitFiberUnmount(wi,n)}catch{}switch(n.tag){case 5:be||Cr(n,t);case 6:var r=Ae,l=kt;Ae=null,on(e,t,n),Ae=r,kt=l,Ae!==null&&(kt?(e=Ae,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ae.removeChild(n.stateNode));break;case 18:Ae!==null&&(kt?(e=Ae,n=n.stateNode,e.nodeType===8?hs(e.parentNode,n):e.nodeType===1&&hs(e,n),Rl(e)):hs(Ae,n.stateNode));break;case 4:r=Ae,l=kt,Ae=n.stateNode.containerInfo,kt=!0,on(e,t,n),Ae=r,kt=l;break;case 0:case 11:case 14:case 15:if(!be&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var o=l,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&ga(n,t,i),l=l.next}while(l!==r)}on(e,t,n);break;case 1:if(!be&&(Cr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){ye(n,t,s)}on(e,t,n);break;case 21:on(e,t,n);break;case 22:n.mode&1?(be=(r=be)||n.memoizedState!==null,on(e,t,n),be=r):on(e,t,n);break;default:on(e,t,n)}}function od(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Lv),t.forEach(function(r){var l=zv.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function St(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=xe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Mv(r/1960))-r,10e?16:e,fn===null)var r=!1;else{if(e=fn,fn=null,pi=0,X&6)throw Error(j(331));var l=X;for(X|=4,F=e.current;F!==null;){var o=F,i=o.child;if(F.flags&16){var s=o.deletions;if(s!==null){for(var a=0;axe()-gu?Un(e,0):mu|=n),tt(e,t)}function Gp(e,t){t===0&&(e.mode&1?(t=mo,mo<<=1,!(mo&130023424)&&(mo=4194304)):t=1);var n=Qe();e=Jt(e,t),e!==null&&(Bl(e,t,n),tt(e,n))}function Fv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gp(e,n)}function zv(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(j(314))}r!==null&&r.delete(t),Gp(e,n)}var Jp;Jp=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ze.current)qe=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return qe=!1,_v(e,t,n);qe=!!(e.flags&131072)}else qe=!1,de&&t.flags&1048576&&ep(t,li,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;zo(e,t),e=t.pendingProps;var l=Ar(t,Ue.current);Tr(t,n),l=uu(null,t,r,e,l,n);var o=cu();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,et(r)?(o=!0,ni(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,lu(t),l.updater=_i,t.stateNode=l,l._reactInternals=t,ua(t,r,e,n),t=fa(null,t,r,!0,o,n)):(t.tag=0,de&&o&&Xa(t),Ke(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(zo(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Uv(r),e=xt(r,e),l){case 0:t=da(null,t,r,e,n);break e;case 1:t=ed(null,t,r,e,n);break e;case 11:t=qc(null,t,r,e,n);break e;case 14:t=Zc(null,t,r,xt(r.type,e),n);break e}throw Error(j(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:xt(r,l),da(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:xt(r,l),ed(e,t,r,l,n);case 3:e:{if(Ap(t),e===null)throw Error(j(387));r=t.pendingProps,o=t.memoizedState,l=o.element,ip(e,t),si(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){l=Dr(Error(j(423)),t),t=td(e,t,r,n,l);break e}else if(r!==l){l=Dr(Error(j(424)),t),t=td(e,t,r,n,l);break e}else for(ot=gn(t.stateNode.containerInfo.firstChild),it=t,de=!0,Et=null,n=lp(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ir(),r===l){t=Xt(e,t,n);break e}Ke(e,t,r,n)}t=t.child}return t;case 5:return sp(t),e===null&&ia(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,ta(r,l)?i=null:o!==null&&ta(r,o)&&(t.flags|=32),Mp(e,t),Ke(e,t,i,n),t.child;case 6:return e===null&&ia(t),null;case 13:return Ip(e,t,n);case 4:return ou(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=$r(t,null,r,n):Ke(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:xt(r,l),qc(e,t,r,l,n);case 7:return Ke(e,t,t.pendingProps,n),t.child;case 8:return Ke(e,t,t.pendingProps.children,n),t.child;case 12:return Ke(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,o=t.memoizedProps,i=l.value,ie(oi,r._currentValue),r._currentValue=i,o!==null)if(_t(o.value,i)){if(o.children===l.children&&!Ze.current){t=Xt(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var s=o.dependencies;if(s!==null){i=o.child;for(var a=s.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=Kt(-1,n&-n),a.tag=2;var c=o.updateQueue;if(c!==null){c=c.shared;var m=c.pending;m===null?a.next=a:(a.next=m.next,m.next=a),c.pending=a}}o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),sa(o.return,n,t),s.lanes|=n;break}a=a.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(j(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),sa(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}Ke(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,Tr(t,n),l=ht(l),r=r(l),t.flags|=1,Ke(e,t,r,n),t.child;case 14:return r=t.type,l=xt(r,t.pendingProps),l=xt(r.type,l),Zc(e,t,r,l,n);case 15:return Tp(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:xt(r,l),zo(e,t),t.tag=1,et(r)?(e=!0,ni(t)):e=!1,Tr(t,n),Rp(t,r,l),ua(t,r,l,n),fa(null,t,r,!0,e,n);case 19:return $p(e,t,n);case 22:return Pp(e,t,n)}throw Error(j(156,t.tag))};function Xp(e,t){return Cf(e,t)}function bv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ft(e,t,n,r){return new bv(e,t,n,r)}function Su(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Uv(e){if(typeof e=="function")return Su(e)?1:0;if(e!=null){if(e=e.$$typeof,e===za)return 11;if(e===ba)return 14}return 2}function Sn(e,t){var n=e.alternate;return n===null?(n=ft(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Bo(e,t,n,r,l,o){var i=2;if(r=e,typeof e=="function")Su(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case mr:return Bn(n.children,l,o,t);case Fa:i=8,l|=8;break;case As:return e=ft(12,n,t,l|2),e.elementType=As,e.lanes=o,e;case Is:return e=ft(13,n,t,l),e.elementType=Is,e.lanes=o,e;case $s:return e=ft(19,n,t,l),e.elementType=$s,e.lanes=o,e;case sf:return Li(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case lf:i=10;break e;case of:i=9;break e;case za:i=11;break e;case ba:i=14;break e;case sn:i=16,r=null;break e}throw Error(j(130,e==null?e:typeof e,""))}return t=ft(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function Bn(e,t,n,r){return e=ft(7,e,r,t),e.lanes=n,e}function Li(e,t,n,r){return e=ft(22,e,r,t),e.elementType=sf,e.lanes=n,e.stateNode={isHidden:!1},e}function ks(e,t,n){return e=ft(6,e,null,t),e.lanes=n,e}function Es(e,t,n){return t=ft(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Bv(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=rs(0),this.expirationTimes=rs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rs(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function xu(e,t,n,r,l,o,i,s,a){return e=new Bv(e,t,n,s,a),t===1?(t=1,o===!0&&(t|=8)):t=0,o=ft(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},lu(o),e}function Hv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(th)}catch(e){console.error(e)}}th(),ef.exports=at;var nh=ef.exports,rh,pd=nh;rh=pd.createRoot,pd.hydrateRoot;/** + * react-router v7.8.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */var hd="popstate";function Yv(e={}){function t(l,o){let{pathname:i="/",search:s="",hash:a=""}=Jn(l.location.hash.substring(1));return!i.startsWith("/")&&!i.startsWith(".")&&(i="/"+i),Ca("",{pathname:i,search:s,hash:a},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function n(l,o){let i=l.document.querySelector("base"),s="";if(i&&i.getAttribute("href")){let a=l.location.href,c=a.indexOf("#");s=c===-1?a:a.slice(0,c)}return s+"#"+(typeof o=="string"?o:zl(o))}function r(l,o){Rt(l.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return Jv(t,n,r,e)}function me(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Rt(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Gv(){return Math.random().toString(36).substring(2,10)}function md(e,t){return{usr:e.state,key:e.key,idx:t}}function Ca(e,t,n=null,r){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?Jn(t):t,state:n,key:t&&t.key||r||Gv()}}function zl({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function Jn(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Jv(e,t,n,r={}){let{window:l=document.defaultView,v5Compat:o=!1}=r,i=l.history,s="POP",a=null,c=m();c==null&&(c=0,i.replaceState({...i.state,idx:c},""));function m(){return(i.state||{idx:null}).idx}function w(){s="POP";let R=m(),v=R==null?null:R-c;c=R,a&&a({action:s,location:C.location,delta:v})}function y(R,v){s="PUSH";let h=Ca(C.location,R,v);n&&n(h,R),c=m()+1;let g=md(h,c),N=C.createHref(h);try{i.pushState(g,"",N)}catch(P){if(P instanceof DOMException&&P.name==="DataCloneError")throw P;l.location.assign(N)}o&&a&&a({action:s,location:C.location,delta:1})}function x(R,v){s="REPLACE";let h=Ca(C.location,R,v);n&&n(h,R),c=m();let g=md(h,c),N=C.createHref(h);i.replaceState(g,"",N),o&&a&&a({action:s,location:C.location,delta:0})}function E(R){return Xv(R)}let C={get action(){return s},get location(){return e(l,i)},listen(R){if(a)throw new Error("A history only accepts one active listener");return l.addEventListener(hd,w),a=R,()=>{l.removeEventListener(hd,w),a=null}},createHref(R){return t(l,R)},createURL:E,encodeLocation(R){let v=E(R);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:y,replace:x,go(R){return i.go(R)}};return C}function Xv(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),me(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:zl(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function lh(e,t,n="/"){return qv(e,t,n,!1)}function qv(e,t,n,r){let l=typeof t=="string"?Jn(t):t,o=qt(l.pathname||"/",n);if(o==null)return null;let i=oh(e);Zv(i);let s=null;for(let a=0;s==null&&a{let m={relativePath:c===void 0?i.path||"":c,caseSensitive:i.caseSensitive===!0,childrenIndex:s,route:i};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(r)&&a)return;me(m.relativePath.startsWith(r),`Absolute route path "${m.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(r.length)}let w=Qt([r,m.relativePath]),y=n.concat(m);i.children&&i.children.length>0&&(me(i.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${w}".`),oh(i.children,t,y,w,a)),!(i.path==null&&!i.index)&&t.push({path:w,score:iy(w,i.index),routesMeta:y})};return e.forEach((i,s)=>{var a;if(i.path===""||!((a=i.path)!=null&&a.includes("?")))o(i,s);else for(let c of ih(i.path))o(i,s,!0,c)}),t}function ih(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,l=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return l?[o,""]:[o];let i=ih(r.join("/")),s=[];return s.push(...i.map(a=>a===""?o:[o,a].join("/"))),l&&s.push(...i),s.map(a=>e.startsWith("/")&&a===""?"/":a)}function Zv(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:sy(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var ey=/^:[\w-]+$/,ty=3,ny=2,ry=1,ly=10,oy=-2,gd=e=>e==="*";function iy(e,t){let n=e.split("/"),r=n.length;return n.some(gd)&&(r+=oy),t&&(r+=ny),n.filter(l=>!gd(l)).reduce((l,o)=>l+(ey.test(o)?ty:o===""?ry:ly),r)}function sy(e,t){return e.length===t.length&&e.slice(0,-1).every((r,l)=>r===t[l])?e[e.length-1]-t[t.length-1]:0}function ay(e,t,n=!1){let{routesMeta:r}=e,l={},o="/",i=[];for(let s=0;s{if(m==="*"){let E=s[y]||"";i=o.slice(0,o.length-E.length).replace(/(.)\/+$/,"$1")}const x=s[y];return w&&!x?c[m]=void 0:c[m]=(x||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:i,pattern:e}}function uy(e,t=!1,n=!0){Rt(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(i,s,a)=>(r.push({paramName:s,isOptional:a!=null}),a?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),r]}function cy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Rt(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function qt(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function dy(e,t="/"){let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?Jn(e):e;return{pathname:n?n.startsWith("/")?n:fy(n,t):t,search:my(r),hash:gy(l)}}function fy(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?n.length>1&&n.pop():l!=="."&&n.push(l)}),n.length>1?n.join("/"):"/"}function Cs(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function py(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function sh(e){let t=py(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ah(e,t,n,r=!1){let l;typeof e=="string"?l=Jn(e):(l={...e},me(!l.pathname||!l.pathname.includes("?"),Cs("?","pathname","search",l)),me(!l.pathname||!l.pathname.includes("#"),Cs("#","pathname","hash",l)),me(!l.search||!l.search.includes("#"),Cs("#","search","hash",l)));let o=e===""||l.pathname==="",i=o?"/":l.pathname,s;if(i==null)s=n;else{let w=t.length-1;if(!r&&i.startsWith("..")){let y=i.split("/");for(;y[0]==="..";)y.shift(),w-=1;l.pathname=y.join("/")}s=w>=0?t[w]:"/"}let a=dy(l,s),c=i&&i!=="/"&&i.endsWith("/"),m=(o||i===".")&&n.endsWith("/");return!a.pathname.endsWith("/")&&(c||m)&&(a.pathname+="/"),a}var Qt=e=>e.join("/").replace(/\/\/+/g,"/"),hy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),my=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,gy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function vy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}var uh=["POST","PUT","PATCH","DELETE"];new Set(uh);var yy=["GET",...uh];new Set(yy);var Br=f.createContext(null);Br.displayName="DataRouter";var Ii=f.createContext(null);Ii.displayName="DataRouterState";f.createContext(!1);var ch=f.createContext({isTransitioning:!1});ch.displayName="ViewTransition";var wy=f.createContext(new Map);wy.displayName="Fetchers";var Sy=f.createContext(null);Sy.displayName="Await";var Dt=f.createContext(null);Dt.displayName="Navigation";var Kl=f.createContext(null);Kl.displayName="Location";var en=f.createContext({outlet:null,matches:[],isDataRoute:!1});en.displayName="Route";var Nu=f.createContext(null);Nu.displayName="RouteError";function xy(e,{relative:t}={}){me(Ql(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=f.useContext(Dt),{hash:l,pathname:o,search:i}=Yl(e,{relative:t}),s=o;return n!=="/"&&(s=o==="/"?n:Qt([n,o])),r.createHref({pathname:s,search:i,hash:l})}function Ql(){return f.useContext(Kl)!=null}function Xn(){return me(Ql(),"useLocation() may be used only in the context of a component."),f.useContext(Kl).location}var dh="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function fh(e){f.useContext(Dt).static||f.useLayoutEffect(e)}function ky(){let{isDataRoute:e}=f.useContext(en);return e?$y():Ey()}function Ey(){me(Ql(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(Br),{basename:t,navigator:n}=f.useContext(Dt),{matches:r}=f.useContext(en),{pathname:l}=Xn(),o=JSON.stringify(sh(r)),i=f.useRef(!1);return fh(()=>{i.current=!0}),f.useCallback((a,c={})=>{if(Rt(i.current,dh),!i.current)return;if(typeof a=="number"){n.go(a);return}let m=ah(a,JSON.parse(o),l,c.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Qt([t,m.pathname])),(c.replace?n.replace:n.push)(m,c.state,c)},[t,n,o,l,e])}f.createContext(null);function Yl(e,{relative:t}={}){let{matches:n}=f.useContext(en),{pathname:r}=Xn(),l=JSON.stringify(sh(n));return f.useMemo(()=>ah(e,JSON.parse(l),r,t==="path"),[e,l,r,t])}function Cy(e,t){return ph(e,t)}function ph(e,t,n,r,l){var h;me(Ql(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext(Dt),{matches:i}=f.useContext(en),s=i[i.length-1],a=s?s.params:{},c=s?s.pathname:"/",m=s?s.pathnameBase:"/",w=s&&s.route;{let g=w&&w.path||"";hh(c,!w||g.endsWith("*")||g.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${c}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + +Please change the parent to .`)}let y=Xn(),x;if(t){let g=typeof t=="string"?Jn(t):t;me(m==="/"||((h=g.pathname)==null?void 0:h.startsWith(m)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${m}" but pathname "${g.pathname}" was given in the \`location\` prop.`),x=g}else x=y;let E=x.pathname||"/",C=E;if(m!=="/"){let g=m.replace(/^\//,"").split("/");C="/"+E.replace(/^\//,"").split("/").slice(g.length).join("/")}let R=lh(e,{pathname:C});Rt(w||R!=null,`No routes matched location "${x.pathname}${x.search}${x.hash}" `),Rt(R==null||R[R.length-1].route.element!==void 0||R[R.length-1].route.Component!==void 0||R[R.length-1].route.lazy!==void 0,`Matched leaf route at location "${x.pathname}${x.search}${x.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let v=Ly(R&&R.map(g=>Object.assign({},g,{params:Object.assign({},a,g.params),pathname:Qt([m,o.encodeLocation?o.encodeLocation(g.pathname).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?m:Qt([m,o.encodeLocation?o.encodeLocation(g.pathnameBase).pathname:g.pathnameBase])})),i,n,r,l);return t&&v?f.createElement(Kl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...x},navigationType:"POP"}},v):v}function Ny(){let e=Iy(),t=vy(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",l={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},i=null;return console.error("Error handled by React Router default ErrorBoundary:",e),i=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:o},"ErrorBoundary")," or"," ",f.createElement("code",{style:o},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},t),n?f.createElement("pre",{style:l},n):null,i)}var _y=f.createElement(Ny,null),Ry=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.unstable_onError?this.props.unstable_onError(e,t):console.error("React Router caught the following error during render",e)}render(){return this.state.error!==void 0?f.createElement(en.Provider,{value:this.props.routeContext},f.createElement(Nu.Provider,{value:this.state.error,children:this.props.component})):this.props.children}};function jy({routeContext:e,match:t,children:n}){let r=f.useContext(Br);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),f.createElement(en.Provider,{value:e},n)}function Ly(e,t=[],n=null,r=null,l=null){if(e==null){if(!n)return null;if(n.errors)e=n.matches;else if(t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let o=e,i=n==null?void 0:n.errors;if(i!=null){let c=o.findIndex(m=>m.route.id&&(i==null?void 0:i[m.route.id])!==void 0);me(c>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,c+1))}let s=!1,a=-1;if(n)for(let c=0;c=0?o=o.slice(0,a+1):o=[o[0]];break}}}return o.reduceRight((c,m,w)=>{let y,x=!1,E=null,C=null;n&&(y=i&&m.route.id?i[m.route.id]:void 0,E=m.route.errorElement||_y,s&&(a<0&&w===0?(hh("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,C=null):a===w&&(x=!0,C=m.route.hydrateFallbackElement||null)));let R=t.concat(o.slice(0,w+1)),v=()=>{let h;return y?h=E:x?h=C:m.route.Component?h=f.createElement(m.route.Component,null):m.route.element?h=m.route.element:h=c,f.createElement(jy,{match:m,routeContext:{outlet:c,matches:R,isDataRoute:n!=null},children:h})};return n&&(m.route.ErrorBoundary||m.route.errorElement||w===0)?f.createElement(Ry,{location:n.location,revalidation:n.revalidation,component:E,error:y,children:v(),routeContext:{outlet:null,matches:R,isDataRoute:!0},unstable_onError:r}):v()},null)}function _u(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ty(e){let t=f.useContext(Br);return me(t,_u(e)),t}function Py(e){let t=f.useContext(Ii);return me(t,_u(e)),t}function My(e){let t=f.useContext(en);return me(t,_u(e)),t}function Ru(e){let t=My(e),n=t.matches[t.matches.length-1];return me(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Ay(){return Ru("useRouteId")}function Iy(){var r;let e=f.useContext(Nu),t=Py("useRouteError"),n=Ru("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function $y(){let{router:e}=Ty("useNavigate"),t=Ru("useNavigate"),n=f.useRef(!1);return fh(()=>{n.current=!0}),f.useCallback(async(l,o={})=>{Rt(n.current,dh),n.current&&(typeof l=="number"?e.navigate(l):await e.navigate(l,{fromRouteId:t,...o}))},[e,t])}var vd={};function hh(e,t,n){!t&&!vd[e]&&(vd[e]=!0,Rt(!1,n))}f.memo(Oy);function Oy({routes:e,future:t,state:n,unstable_onError:r}){return ph(e,void 0,n,r,t)}function mh(e){me(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function Dy({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:l,static:o=!1}){me(!Ql(),"You cannot render a inside another . You should never have more than one in your app.");let i=e.replace(/^\/*/,"/"),s=f.useMemo(()=>({basename:i,navigator:l,static:o,future:{}}),[i,l,o]);typeof n=="string"&&(n=Jn(n));let{pathname:a="/",search:c="",hash:m="",state:w=null,key:y="default"}=n,x=f.useMemo(()=>{let E=qt(a,i);return E==null?null:{location:{pathname:E,search:c,hash:m,state:w,key:y},navigationType:r}},[i,a,c,m,w,y,r]);return Rt(x!=null,` is not able to match the URL "${a}${c}${m}" because it does not start with the basename, so the won't render anything.`),x==null?null:f.createElement(Dt.Provider,{value:s},f.createElement(Kl.Provider,{children:t,value:x}))}function Fy({children:e,location:t}){return Cy(Na(e),t)}function Na(e,t=[]){let n=[];return f.Children.forEach(e,(r,l)=>{if(!f.isValidElement(r))return;let o=[...t,l];if(r.type===f.Fragment){n.push.apply(n,Na(r.props.children,o));return}me(r.type===mh,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),me(!r.props.index||!r.props.children,"An index route cannot have child routes.");let i={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(i.children=Na(r.props.children,o)),n.push(i)}),n}var Ho="get",Wo="application/x-www-form-urlencoded";function $i(e){return e!=null&&typeof e.tagName=="string"}function zy(e){return $i(e)&&e.tagName.toLowerCase()==="button"}function by(e){return $i(e)&&e.tagName.toLowerCase()==="form"}function Uy(e){return $i(e)&&e.tagName.toLowerCase()==="input"}function By(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Hy(e,t){return e.button===0&&(!t||t==="_self")&&!By(e)}var Ro=null;function Wy(){if(Ro===null)try{new FormData(document.createElement("form"),0),Ro=!1}catch{Ro=!0}return Ro}var Vy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ns(e){return e!=null&&!Vy.has(e)?(Rt(!1,`"${e}" is not a valid \`encType\` for \`\`/\`\` and will default to "${Wo}"`),null):e}function Ky(e,t){let n,r,l,o,i;if(by(e)){let s=e.getAttribute("action");r=s?qt(s,t):null,n=e.getAttribute("method")||Ho,l=Ns(e.getAttribute("enctype"))||Wo,o=new FormData(e)}else if(zy(e)||Uy(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a
`,E=`
${y}
`;return`
${x}${E}
`}),i=i.replace(/
\s*(?=
]*>[\s\S]*?<\/div>)\s*
/g,"$1"),i}function lw(e){const t=e.split(/\r?\n/);let n=null;for(let r=0;r[\s\S]*?<\/think(?:ing)?>/gi,"").replace(/[*#]/g,"").replace(/\s+/g," ").trim()}function pr(e,t,n){return e.includes(t)?e:`${e} + +${n}`}function iw(e){const t=String(e||""),n=t.trim();if(!n)return t;const r=n.toLowerCase();return r.startsWith("error:")||r.startsWith("ollama error:")||r.includes("client error '")||r.includes("server error '")||r.includes("http")&&r.includes("error")||r.includes("unknown model architecture")||r.includes("out of memory")?r.includes("unknown model architecture")?pr(t,"[ERROR - Unsupported Model]",`[ERROR - Unsupported Model] +This Ollama version does not support the model. +Update Ollama.`):r.includes("out of memory")?pr(t,"[ERROR - Out of Memory]",`[ERROR - Out of Memory] +The model is too large for available memory. +Use a smaller or quantized model.`):r.includes("502")?pr(t,"[ERROR 502 - Bad Gateway]",`[ERROR 502 - Bad Gateway] +Ollama did not return a valid response. +Try restarting or updating Ollama.`):r.includes("500")?pr(t,"[ERROR 500 - Internal Server Error]",`[ERROR 500 - Internal Server Error] +Ollama crashed while processing the request. +Check 'ollama logs' and memory usage.`):r.includes("404")?pr(t,"[ERROR 404 - Not Found]",`[ERROR 404 - Not Found] +The model or endpoint was not found. +Check the model name or run 'ollama pull '.`):r.includes("400")?pr(t,"[ERROR 400 - Bad Request]",`[ERROR 400 - Bad Request] +The request sent to Ollama was invalid. +Check parameters or payload format.`):t:t}function _h(e){if(!e)return{think:null,answer:""};const t=//i,n=/<\/think(?:ing)?>/i,r=e.match(t);if(!r)return{think:null,answer:e};const l=r.index,o=r[0].length,i=e.substring(0,l).trim();let s=e.substring(l+o);const a=s.match(n);let c=null,m=i;return a?(c=s.substring(0,a.index).trim(),m+=s.substring(a.index+a[0].length)):c=s.trim(),{think:c||null,answer:m.trim()}}function sw({content:e,streamOutput:t,sources:n}){const r=iw(e||""),{think:l,answer:o}=_h(r),[i,s]=Ve.useState(!1),a=!!l;return d.jsxs("div",{className:"assistant-message",children:[a&&d.jsxs("div",{className:"assistant-thoughts",children:[d.jsxs("button",{className:"think-toggle",onClick:()=>s(c=>!c),"aria-expanded":i?"true":"false","aria-controls":"think-content",children:[d.jsx("span",{className:"think-toggle-icon","aria-hidden":"true",children:i?"▾":"▸"}),"Thoughts"]}),i&&d.jsx("div",{id:"think-content",className:"think-content",dangerouslySetInnerHTML:{__html:Od(l)}})]}),d.jsx("div",{className:"msg-content",dangerouslySetInnerHTML:{__html:Od(o||r||"")}}),Array.isArray(n)&&n.length>0&&d.jsx("div",{className:"msg-sources chips",children:n.map((c,m)=>{let w=c,y=!1;try{const x=new URL(c);if(x.protocol==="file:"){y=!0;const E=x.pathname.split("/").filter(Boolean);w=decodeURIComponent(E[E.length-1]||c)}else w=(x.hostname||c).replace(/^www\./i,"")}catch{}return d.jsx("a",{className:"chip",href:c,target:"_blank",rel:"noreferrer",title:c,onClick:x=>{var E,C;if(y){x.preventDefault();try{const R=new URL(c);(C=(E=window.electronAPI)==null?void 0:E.openPath)==null||C.call(E,decodeURIComponent(R.pathname))}catch{}}},children:w},c+m)})})]})}function Ls({attachments:e,className:t="",removable:n=!1,onRemove:r}){return!Array.isArray(e)||e.length===0?null:d.jsx("div",{className:`image-attachment-strip ${t}`.trim(),children:e.map((l,o)=>{const i=l==null?void 0:l.data_url;if(!i)return null;const s=l.id||`${l.name||"image"}-${o}-${i.length}`;return d.jsxs("div",{className:"image-attachment-card",children:[n&&d.jsx("button",{type:"button",className:"image-attachment-remove",onClick:()=>r==null?void 0:r(l.id),"aria-label":`Remove ${l.name||"image"}`,title:"Remove image",children:"×"}),d.jsx("img",{className:"image-attachment-thumb",src:i,alt:l.name||`Attachment ${o+1}`,loading:"lazy"})]},s)})})}const Dd="websearch.searxUrl",Fd="websearch.engines",zd="chat.libraryBySession",bd="http://127.0.0.1:8888",Ts=6,Ps=20*1024*1024,aw=5*60*1e3,uw=200;let Rh="http://127.0.0.1:8000";const cw=48,dw=24;function fw(e){return e.backendApiUrl||e.ollamaApiUrl||Rh}function pw(e){const t=typeof e=="string"?e.trim():"";return!t||t==="http://localhost:8888"?bd:t}function To(e){var n;return Array.from(((n=e==null?void 0:e.dataTransfer)==null?void 0:n.types)||[]).includes("Files")}function Ta(e){return e?typeof e.type=="string"&&e.type.toLowerCase().startsWith("image/")?!0:/\.(png|jpe?g|gif|bmp|webp|tiff?|heic|avif)$/i.test(e.name||""):!1}function Ud(e){var r,l;const t=Array.from(((r=e==null?void 0:e.dataTransfer)==null?void 0:r.items)||[]);return t.length>0?t.some(o=>{var i;return o.kind==="file"&&Ta((i=o.getAsFile)==null?void 0:i.call(o))}):Array.from(((l=e==null?void 0:e.dataTransfer)==null?void 0:l.files)||[]).some(Ta)}function Bd(e){return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(r.error||new Error(`Failed to read ${(e==null?void 0:e.name)||"image"}`)),r.onload=()=>t(String(r.result||"")),r.readAsDataURL(e)})}function hw(e,t){const n=String(t||"").trim();if(!n)return e||"";const r=String(e||"");if(!r.trim())return n;const l=/[\s\n]$/.test(r)?"":` +`;return`${r}${l}${n}`}function mw(e){const t=Math.max(0,Math.floor(Number(e||0)/1e3)),n=Math.floor(t/60),r=t%60;return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}`}function gw(){var lc;const[e,t]=f.useState([]),[n,r]=f.useState(null),[l,o]=f.useState("chats"),i=f.useRef(l),[s,a]=f.useState("AI Models"),[c,m]=f.useState(null),[w,y]=f.useState(null),[x,E]=f.useState([]),[C,R]=f.useState([]),[v,h]=f.useState(null),[g,N]=f.useState(()=>{try{const u=localStorage.getItem(zd);return u?JSON.parse(u):{}}catch{return{}}}),[P,$]=f.useState(!1),[O,D]=f.useState(""),[H,U]=f.useState(""),[le,Ne]=f.useState(!1),[ve,gt]=f.useState(""),[M,B]=f.useState(""),[G,I]=f.useState("base"),[b,W]=f.useState(!1),[Z,q]=f.useState(""),[fe,Be]=f.useState([]),[vt,Oe]=f.useState(!1),Te=f.useRef(null),jt=f.useRef(null),qn=f.useRef(null),Zn=f.useRef(null),Pe=f.useRef(0),[er,tn]=f.useState(!0),[tr,Ft]=f.useState(""),[Di,Gl]=f.useState(""),[nn,Hr]=f.useState(!0),[Jl,Wr]=f.useState(""),[we,Xl]=f.useState(!1),[nt,ql]=f.useState(!1),[Vr,Zl]=f.useState(0),nr=f.useRef(null),_n=f.useRef(null),Lt=f.useRef([]),rr=f.useRef(null),Rn=f.useRef(""),jn=f.useRef(null),Ln=f.useRef(null),lr=f.useRef(0),T=f.useRef(null),[_,ce]=f.useState(Rh),[rt,Fi]=f.useState("Default"),[eo,Pu]=f.useState(!1),[Mu,Kr]=f.useState(""),[jh,zi]=f.useState(!1),[Qr,Lh]=f.useState(()=>pw(localStorage.getItem(Dd))),[Tn,Th]=f.useState(()=>Z0(localStorage.getItem(Fd)));f.useEffect(()=>{localStorage.setItem(Dd,Qr||"")},[Qr]),f.useEffect(()=>{try{localStorage.setItem(Fd,JSON.stringify(vi(Tn)))}catch{}},[Tn]);const[to,Ph]=f.useState(!1),[yt,bi]=f.useState(!1),[Au,Ui]=f.useState(!0),[Mh,or]=f.useState([]),[no,Iu]=f.useState({}),[$u,Ah]=f.useState(!1),Ou=f.useRef(!1),[Ih,Bi]=f.useState(null),[Hi,ro]=f.useState("");function $h(u){const p=u.content||"";if(u.role==="assistant")try{const{answer:S}=_h(p);return(S||p).trim()}catch{return p.trim()}return p}async function Du(u){try{await navigator.clipboard.writeText($h(u))}catch(p){console.error("Failed to copy message:",p)}}function Pn(u,p,S,k={}){const{removeIfEmpty:L=!1}=k;t(A=>A.map(z=>{if(z.session_id!==u)return z;const V=[];for(const J of z.messages||[]){if(J.id!==p){V.push(J);continue}L&&!S||V.push({...J,content:S})}return{...z,messages:V}}))}function Tt(u){return(u==null?void 0:u.name)==="AbortError"}function Oh(u){return Array.isArray(u==null?void 0:u.attachments)&&u.attachments.length>0}function Dh(u=[]){return Array.isArray(u)&&u.length>0&&M||ve}function zt(u){return u instanceof Error&&u.message?u.message:String(u)}async function lo(u){const p=await u.text().catch(()=>"");if(p){try{const S=JSON.parse(p);if(typeof(S==null?void 0:S.detail)=="string"&&S.detail.trim())return S.detail.trim();if(typeof(S==null?void 0:S.message)=="string"&&S.message.trim())return S.message.trim()}catch{}return p.trim()}return`HTTP ${u.status}`}async function Yr(u){const p=await u.json().catch(()=>null);if(u.ok)return p;const S=typeof(p==null?void 0:p.detail)=="string"?p.detail:typeof(p==null?void 0:p.message)=="string"?p.message:"";throw new Error(S||`HTTP ${u.status}`)}async function Fh(u,p){const S=await fetch(`${_}/models/capabilities?name=${encodeURIComponent(u)}`,{signal:p});return Yr(S)}async function zh(){const u=await fetch(`${_}/ollama/startup-status`);return Yr(u)}async function bh(){const u=await fetch(`${_}/startup/prepare-models`,{method:"POST"});return Yr(u)}function Fu(u){if(!!(u!=null&&u.whisper_model_available)){Hr(!0),Wr("");return}const S=(u==null?void 0:u.whisper_model)||"base",k=String((u==null?void 0:u.whisper_error)||"").trim();Hr(!1),Wr(k||`Whisper ${S} is not available.`)}async function zu(u,p,S){if(!u)return{contextBlock:null,sources:[]};const L=await(await fetch(`${_}/libraries/${u}/context`,{method:"POST",headers:{"Content-Type":"application/json"},signal:S,body:JSON.stringify({prompt:p,top_k:5})})).json();return{contextBlock:typeof(L==null?void 0:L.context_block)=="string"&&L.context_block.trim()?L.context_block.trim():null,sources:Array.isArray(L==null?void 0:L.sources)?L.sources:[]}}async function bu(u){const p=Array.from(u||[]).filter(Ta);if(!p.length||!b)return;const S=Math.max(0,Ts-fe.length);if(S<=0){window.alert(`You can attach up to ${Ts} images per message.`);return}const k=p.slice(0,S),L=k.filter(z=>Number(z.size)>Ps),A=k.filter(z=>Number(z.size)<=Ps);if(L.length>0&&window.alert(`Images must be ${Math.round(Ps/(1024*1024))} MB or smaller.`),!!A.length)try{const z=await Promise.all(A.map(async(V,J)=>({id:`attachment-${Date.now()}-${J}-${Math.random().toString(36).slice(2)}`,name:V.name||"image",mime_type:V.type||"image/*",data_url:await Bd(V)})));Be(V=>[...V,...z]),p.length>S&&window.alert(`Only the first ${Ts} images can be attached.`)}catch(z){console.error("Failed to load image attachments",z),window.alert(`Image import failed: ${zt(z)}`)}}function Uh(u){Be(p=>p.filter(S=>S.id!==u))}function Bh(){var u;b&&((u=Zn.current)==null||u.click())}function Wi(){jn.current&&(window.clearInterval(jn.current),jn.current=null),Ln.current&&(window.clearTimeout(Ln.current),Ln.current=null)}function Vi(u=_n.current){Wi(),Ra(u),_n.current===u&&(_n.current=null),nr.current=null}async function Hh(u,p){if(!_)throw new Error("The Heimgeist backend is not configured.");const S=new AbortController;T.current=S,ql(!0);try{const k=await Bd(u),L=k.indexOf(",");if(L<=5)throw new Error("Recorded audio could not be encoded for upload.");const A=k.slice(0,L),z=k.slice(L+1);if(!/^data:[^,]+;base64$/i.test(A)||!z)throw new Error("Recorded audio could not be encoded for upload.");const V=A.slice(5).replace(/;base64$/i,"").trim(),J=await fetch(`${_}/audio/transcribe`,{method:"POST",headers:{"Content-Type":"application/json"},signal:S.signal,body:JSON.stringify({mime_type:p||V||"audio/webm",audio_base64:z,model:G||null,language:Di||null})}),ke=await Yr(J),ee=String((ke==null?void 0:ke.text)||"").trim();if(!ee){window.alert("No speech was detected. Try again and speak closer to the selected microphone.");return}q(ne=>hw(ne,ee)),requestAnimationFrame(()=>{var ne;return(ne=jt.current)==null?void 0:ne.focus()})}catch(k){if(Tt(k))return;throw k}finally{T.current===S&&(T.current=null),ql(!1)}}async function Gr(u={}){const{shouldTranscribe:p=!0}=u,S=nr.current,k=rr.current,L=Rn.current||(S==null?void 0:S.mimeType)||"audio/webm";if(!(!S||!k)){Xl(!1),Wi();try{S.state!=="inactive"&&S.stop();const A=await k;if(!p)return;if(!A||A.size<=0)throw new Error("Recorded audio was empty.");await Hh(A,L)}catch(A){p&&(console.error("Failed to stop microphone recording",A),window.alert(`Microphone transcription failed: ${zt(A)}`))}finally{rr.current=null,Lt.current=[],Rn.current="",lr.current=0,Zl(0)}}}async function Wh(){if(!er||!nn||we||nt||yt)return;if(!Oi()){window.alert("Microphone capture is not available in this environment.");return}let u=null;try{u=await navigator.mediaDevices.getUserMedia(D0(tr))}catch(k){console.error("Failed to access microphone",k),window.alert(`Microphone access failed: ${zt(k)}`);return}const p=z0();let S=null;try{S=p?new MediaRecorder(u,{mimeType:p}):new MediaRecorder(u)}catch(k){Vi(u),console.error("Failed to create audio recorder",k),window.alert(`Microphone recording is not available: ${zt(k)}`);return}_n.current=u,nr.current=S,Lt.current=[],Rn.current=S.mimeType||p||"audio/webm",lr.current=Date.now(),Zl(0),Xl(!0),S.ondataavailable=k=>{k.data&&k.data.size>0&&Lt.current.push(k.data)},rr.current=new Promise((k,L)=>{S.onstop=()=>{const A=new Blob(Lt.current,{type:S.mimeType||Rn.current||"audio/webm"});Vi(u),k(A)},S.onerror=A=>{Vi(u),L((A==null?void 0:A.error)||new Error("Audio recording failed."))}}),jn.current=window.setInterval(()=>{Zl(Date.now()-lr.current)},uw),Ln.current=window.setTimeout(()=>{Gr()},aw),S.start()}async function Vh(){if(!nt){if(we){await Gr();return}await Wh()}}async function Kh(u){var S;const p=(S=u.target)==null?void 0:S.files;try{await bu(p)}finally{u.target&&(u.target.value="")}}function Qh(u,p){Bi(u),ro(p||"")}function oo(){Bi(null),ro("")}async function Yh(u){var A;const p=(((A=ur[u])==null?void 0:A.content)||"").trim(),k=(Hi??"").trim();if(k.length===0){oo();return}if(k===p){oo();return}const L=n;if(L){t(z=>z.map(V=>{if(V.session_id!==L)return V;const ke=(V.messages||[]).slice(0,u+1).map((ee,ne)=>ne===u?{...ee,content:k}:ee);return{...V,messages:ke}})),Bi(null),ro(""),requestAnimationFrame(()=>Ji("auto",L));try{const z=await fetch(`${_}/sessions/${L}/messages/${u}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:k})});if(!z.ok)throw new Error(`HTTP ${z.status}`)}catch(z){console.error("Failed to update message:",z),t(V=>V.map(J=>{if(J.session_id!==L)return J;const ee=(J.messages||[]).map((ne,He)=>He===u?{...ne,content:p}:ne);return{...J,messages:ee}}));return}await Uu(u,k)}}async function Uu(u,p=null){var ne,He,Je,In,K,Se;const S=n;if(yt||!S||typeof u!="number")return;const k=((ne=e.find(te=>te.session_id===S))==null?void 0:ne.messages)||[];let L=u;for(let te=u;te>=0;te--)if(((He=k[te])==null?void 0:He.role)==="user"){L=te;break}t(te=>te.map(oe=>oe.session_id===S?{...oe,messages:(oe.messages||[]).slice(0,L+1)}:oe));const A=k.slice(0,L+1).some(Oh),z=A&&M||ve;if(A&&!b){window.alert("The selected vision model does not support image inputs.");return}const V=Qu(S);let J=p??(((Je=k[L])==null?void 0:Je.content)||""),ke=[];const ee=[];try{const te=qu(S),oe=p??(((In=k[L])==null?void 0:In.content)||""),Me=!!(oe||"").trim();if(Me&&((K=te==null?void 0:te.states)!=null&&K.is_indexed))try{const Q=await zu(te.slug,oe,V.signal);Q.contextBlock&&ee.push(Q.contextBlock),Array.isArray(Q.sources)&&ke.push(...Q.sources)}catch(Q){if(Tt(Q))throw Q;console.warn("local library enrichment (regenerate) failed",Q)}if(Me&&to)try{const Q=k.slice(Math.max(0,L-7),L+1).map(Ee=>({role:Ee.role,content:Ee.content||""}));Q.length>0&&(Q[Q.length-1]={role:"user",content:oe});const se=await(await fetch(`${_}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:V.signal,body:JSON.stringify({prompt:oe,model:ve,messages:Q,history_limit:8,searx_url:Qr||null,engines:Array.isArray(Tn)?Tn:null})})).json();se&&typeof se.context_block=="string"&&se.context_block.trim()&&ee.push(se.context_block.trim()),Array.isArray(se==null?void 0:se.sources)&&ke.push(...se.sources)}catch(Q){if(Tt(Q))throw Q;console.warn("web search enrichment (regenerate) failed",Q)}if(ke=[...new Set(ke)],Me&&ee.length>0?J=`${oe} + +${ee.join(` + +`)}`:J=null,eo){const Q=`msg-${Date.now()}-${Math.random()}`;let Ut="";t(se=>se.map(Ee=>Ee.session_id===S?{...Ee,messages:[...Ee.messages||[],{id:Q,role:"assistant",content:"",sources:ke}]}:Ee));try{const se=await fetch(`${_}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:V.signal,body:JSON.stringify({index:u,model:z,stream:!0,enriched_message:J,sources:ke||[]})});if(!se.ok)throw new Error(await lo(se));const Ee=(Se=se.body)==null?void 0:Se.getReader();if(!Ee)throw new Error("Missing response body");const ln=new TextDecoder;let Pt=!1;for(;;){const{value:$n,done:Sm}=await Ee.read();if(Sm)break;const xm=ln.decode($n,{stream:!0});Ut+=xm,Pn(S,Q,Ut),!Pt&&De.current!==S&&(Pt=!0,Mn(Xi=>({...Xi,[S]:Q})),or(Xi=>[...new Set([...Xi,S])]))}De.current!==S?(Mn($n=>({...$n,[S]:Q})),or($n=>[...new Set([...$n,S])])):ir.current[S]?sr($n=>({...$n,[S]:Q})):requestAnimationFrame(()=>cr(Q,"smooth",S))}catch(se){if(Tt(se)){Pn(S,Q,Ut,{removeIfEmpty:!0});return}console.error(se),Pn(S,Q,`Error: ${zt(se)}`,{removeIfEmpty:!0});return}}else{const Q=await fetch(`${_}/sessions/${S}/regenerate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:V.signal,body:JSON.stringify({index:u,model:z,stream:!1,enriched_message:J,sources:ke||[]})});if(!Q.ok)throw new Error(await lo(Q));const Ut=await Q.json(),se=`msg-${Date.now()}`;t(Ee=>Ee.map(ln=>ln.session_id===S?{...ln,messages:[...ln.messages||[],{role:"assistant",content:Ut.reply,id:se,sources:ke}]}:ln)),De.current!==S?(Mn(Ee=>({...Ee,[S]:se})),or(Ee=>[...new Set([...Ee,S])])):ir.current[S]?sr(Ee=>({...Ee,[S]:se})):requestAnimationFrame(()=>cr(se,"smooth",S))}}catch(te){Tt(te)||console.error(te)}finally{Ki(V)}}const[Bu,Gh]=f.useState({}),ir=f.useRef({}),[Jh,Mn]=f.useState({}),An=f.useRef({}),Hu=f.useRef({}),[Wu,sr]=f.useState({}),[Xh,Vu]=f.useState({});f.useEffect(()=>{i.current=l},[l]);const Ku=(u,p,S)=>u!=null&&u.id?u.id:`${S}:${p}`;f.useEffect(()=>{var p;if(!n)return;const u=((p=e.find(S=>S.session_id===n))==null?void 0:p.messages)||[];Vu(S=>{const k={};return u.forEach((L,A)=>{if(L.role!=="user")return;const z=Ku(L,A,n),J=(L.content||"").split(/\r\n|\r|\n/).length>30;k[z]=J?S[z]??!0:!1}),k})},[e,n]);function qh(u){Vu(p=>({...p,[u]:!(p[u]??!0)}))}const Jr=Ve.useCallback((u,p)=>{Gh(S=>{const k={...S,[u]:p};return ir.current=k,k})},[]),ar=f.useRef(null),Zh=f.useRef(!1),em=f.useRef(null),De=f.useRef(n);f.useEffect(()=>{De.current=n},[n]);const Qu=Ve.useCallback(u=>{const p=new AbortController;return ar.current={controller:p,sessionId:u},bi(!0),p},[]),Ki=Ve.useCallback(u=>{var p;((p=ar.current)==null?void 0:p.controller)===u&&(ar.current=null,bi(!1))},[]),tm=Ve.useCallback(()=>{const u=ar.current;u&&(ar.current=null,u.controller.abort(),bi(!1))},[]);f.useEffect(()=>()=>{var u;(u=ar.current)==null||u.controller.abort()},[]);const rn=f.useRef(null),[nm,rm]=f.useState(230),[io,Yu]=f.useState(!1),lm=Ve.useCallback(u=>{Yu(!0)},[]),Xr=Ve.useCallback(()=>{Yu(!1)},[]),Qi=Ve.useCallback(u=>{if(io){const p=Math.max(230,Math.min(500,u.clientX));rm(p)}},[io]);Ve.useEffect(()=>(window.addEventListener("mousemove",Qi),window.addEventListener("mouseup",Xr),window.addEventListener("blur",Xr),()=>{window.removeEventListener("mousemove",Qi),window.removeEventListener("mouseup",Xr),window.removeEventListener("blur",Xr)}),[Qi,Xr]),Ve.useEffect(()=>(io?document.body.classList.add("no-select"):document.body.classList.remove("no-select"),()=>{document.body.classList.remove("no-select")}),[io]),Ve.useEffect(()=>{const u=async p=>{const S=p.target.closest(".codeblock__copy");if(!S)return;const k=S.closest(".codeblock"),L=k==null?void 0:k.querySelector("pre > code");if(L)try{await navigator.clipboard.writeText(L.textContent||""),S.classList.add("copied"),setTimeout(()=>S.classList.remove("copied"),800)}catch(A){console.error("Copy failed:",A)}};return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[]),f.useEffect(()=>{let u=!1;return window.electronAPI.getSettings().then(p=>{u||(ce(fw(p)),Fi(p.colorScheme||"Default"),gt(p.chatModel||""),B(p.visionModel||p.chatModel||""),I(p.transcriptionModel||"base"),Pu(p.streamOutput||!1),tn(!0),p.audioInputEnabled!==!0&&window.electronAPI.setSetting("audioInputEnabled",!0),Ft(typeof p.audioInputDeviceId=="string"?p.audioInputDeviceId:""),Gl(typeof p.audioInputLanguage=="string"?p.audioInputLanguage:""),Iu(p.scrollPositions||{}),bl(p.colorScheme||"Default"))}).finally(()=>{u||Ah(!0)}),()=>{u=!0}},[]),f.useEffect(()=>{const u=()=>{var p;i.current==="chats"&&((p=jt.current)==null||p.focus())};return window.electronAPI.onWindowFocus(u),()=>{window.electronAPI.offWindowFocus(u)}},[]),f.useEffect(()=>{let u=!1;const p=new AbortController;return!_||!M?(W(!1),()=>{p.abort()}):((async()=>{try{const S=await Fh(M,p.signal);u||W(!!(S!=null&&S.supports_vision))}catch(S){!u&&!Tt(S)&&(console.warn("Failed to load model capabilities",S),W(!1))}})(),()=>{u=!0,p.abort()})},[_,M]),f.useEffect(()=>{Pe.current=0,Oe(!1)},[b,l]),f.useEffect(()=>{er||!we||Gr({shouldTranscribe:!1})},[er,we]),f.useEffect(()=>{nn||!we||Gr({shouldTranscribe:!1})},[nn,we]),f.useEffect(()=>{l==="chats"||!we||Gr()},[l,we]),f.useEffect(()=>()=>{var p;(p=T.current)==null||p.abort(),Wi();const u=nr.current;if(u){u.ondataavailable=null,u.onstop=null,u.onerror=null;try{u.state!=="inactive"&&u.stop()}catch{}}Ra(_n.current)},[]),f.useEffect(()=>{if(!$u||Au||!_||Ou.current)return;Ou.current=!0;let u=!1;const p=window.setTimeout(()=>{(async()=>{let S=!1;try{let k=await zh();if(u)return;if(Fu(k),!(k!=null&&k.ollama_running)&&(k!=null&&k.can_manage_locally)){const z=window.confirm(`Ollama is not running at ${k.ollama_url}. Start it in the background now with "ollama serve"?`);if(u)return;if(z){S=!0,zi(!0),Kr("Starting Ollama in the background...");const V=await fetch(`${_}/ollama/start`,{method:"POST"});if(k=await Yr(V),u)return}}const L=!(k!=null&&k.whisper_model_available),A=!!(k!=null&&k.ollama_running&&(k!=null&&k.can_manage_locally)&&!(k!=null&&k.embedding_model_available));if(L||A){S=!0,zi(!0),Kr(L&&A?`Downloading Whisper ${(k==null?void 0:k.whisper_model)||"base"} and ${k.selected_embed_model}. This can take a while on first install.`:L?`Downloading Whisper ${(k==null?void 0:k.whisper_model)||"base"}. This can take a while on first install.`:`Downloading ${k.selected_embed_model} from Ollama. This can take a while on first install.`);const z=await bh();if(u)return;Fu((z==null?void 0:z.ollama)||k)}}catch(k){u||(console.warn("startup Ollama check failed",k),Hr(!1),Wr(`Whisper availability could not be verified: ${zt(k)}`),S&&window.alert(`Startup action failed: ${zt(k)}`))}finally{u||(zi(!1),Kr(""))}})()},1200);return()=>{u=!0,window.clearTimeout(p)}},[_,Au,$u]),f.useEffect(()=>{bl(rt)},[rt]);const om=u=>{!u||!_||fetch(`${_}/history?session_id=${encodeURIComponent(u)}`).then(p=>p.json()).then(p=>{t(S=>S.map(k=>k.session_id===u?{...k,messages:p.messages||[]}:k))}).catch(()=>{})};async function qr(){if(_)try{const p=await(await fetch(`${_}/libraries`)).json(),S=Array.isArray(p.libraries)?p.libraries:[];if(E(S),S.length===0){h(null);return}S.some(k=>k.slug===v)||h(S[0].slug)}catch(u){console.warn("Failed to load libraries",u)}}async function so(){if(_)try{const p=await(await fetch(`${_}/jobs`)).json();R(Array.isArray(p.jobs)?p.jobs:[])}catch(u){console.warn("Failed to load library jobs",u)}}async function Gu(u=null){const S=(typeof u=="string"?u:O).trim();if(!S){U("Name is required.");return}try{U("");const k=await fetch(`${_}/libraries`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})});if(!k.ok){const A=await k.text();throw new Error(A||`HTTP ${k.status}`)}const L=await k.json();$(!1),D(""),await qr(),L!=null&&L.slug&&h(L.slug)}catch(k){console.error("Failed to create library",k),U(String((k==null?void 0:k.message)||k))}}async function Ju(){E([]),R([]),h(null),y(null),Ne(!1),N({}),await qr(),await so()}f.useEffect(()=>{_&&(Ui(!0),fetch(`${_}/sessions`).then(u=>u.json()).then(u=>{const p=u.sessions.map(S=>({...S,messages:[]}));t(p),p.length>0?r(p[0].session_id):r(null),Ui(!1)}).catch(()=>{Ui(!1)}))},[_]),f.useEffect(()=>{_&&(qr(),so())},[_]),f.useEffect(()=>{try{localStorage.setItem(zd,JSON.stringify(g||{}))}catch{}},[g]),f.useEffect(()=>{if(!_)return;const u=setInterval(()=>{qr(),so()},3e3);return()=>clearInterval(u)},[_,l,v]),f.useEffect(()=>{om(n)},[n,_]),f.useEffect(()=>{const u=new Set(x.map(p=>p.slug));N(p=>{let S=!1;const k={};for(const[L,A]of Object.entries(p||{}))u.has(A)?k[L]=A:S=!0;return S?k:p})},[x]);const Yi=u=>{o(u)},im=u=>{mm(u)},ur=f.useMemo(()=>{var u;return((u=e.find(p=>p.session_id===n))==null?void 0:u.messages)||[]},[n,e]),ao=f.useMemo(()=>x.find(u=>u.slug===v)||null,[v,x]),bt=n&&g[n]||null,wt=f.useMemo(()=>x.find(u=>u.slug===bt)||null,[bt,x]),Xu=f.useMemo(()=>bt?C.some(u=>u.slug===bt&&(u.status==="queued"||u.status==="running")):!1,[bt,C]),Gi=f.useMemo(()=>{var u,p;return wt?(u=wt.files)!=null&&u.length?(p=wt.states)!=null&&p.is_indexed?"":Xu?" (syncing)":" (needs sync)":" (empty)":""},[wt,Xu]);function sm(u){return u&&g[u]||null}function qu(u){const p=sm(u);return p&&x.find(S=>S.slug===p)||null}function Zu(u){return u?C.some(p=>p.slug===u&&(p.status==="queued"||p.status==="running")):!1}function ec(u,p){u&&N(S=>{const k={...S||{}};return p?k[u]=p:delete k[u],k})}function am(u){u&&N(p=>{let S=!1;const k={};for(const[L,A]of Object.entries(p||{})){if(A===u){S=!0;continue}k[L]=A}return S?k:p})}f.useEffect(()=>{if(!le)return;const u=p=>{var S;(S=qn.current)!=null&&S.contains(p.target)||Ne(!1)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[le]),f.useEffect(()=>{Ne(!1)},[n,l]),f.useEffect(()=>{const u=n,p=l;return()=>{if(p==="chats"&&u){const S=typeof An.current[u]=="number"?An.current[u]:Te.current?Te.current.scrollTop:0;Iu(k=>{const L={...k,[u]:S};return window.electronAPI.updateSettings({scrollPositions:L}),L})}}},[n,l]),f.useEffect(()=>{const u=Te.current;if(!u)return;const p=()=>{const{scrollTop:S,scrollHeight:k,clientHeight:L}=u,A=k-S-L<=dw;if(n){const z=Hu.current[n],V=typeof z=="number"&&Su.removeEventListener("scroll",p)},[n,Jr]),f.useEffect(()=>{const u=n;u&&Bu[u]===!1&&sr(p=>{if(!(u in p))return p;const S={...p};return delete S[u],S})},[n,Bu]),f.useLayoutEffect(()=>{if(l!=="chats"||!n)return;const u=Te.current;if(!u)return;rn.current=null;const p=()=>{if(rn.current===n)return;const z=typeof An.current[n]=="number"?An.current[n]:void 0,V=typeof z=="number"?z:no[n];if(typeof V=="number"){u.scrollTop=V,rn.current=n;return}ur.length>0&&(u.scrollTop=u.scrollHeight,rn.current=n)};p();const S=requestAnimationFrame(p),k=()=>{rn.current!==n&&requestAnimationFrame(p)},L=new MutationObserver(k);L.observe(u,{childList:!0,subtree:!0});const A=new ResizeObserver(k);return A.observe(u),()=>{cancelAnimationFrame(S),L.disconnect(),A.disconnect()}},[n,l,ur.length,no]),f.useEffect(()=>{if(l!=="chats"||!n||rn.current===n)return;const u=typeof An.current[n]=="number"?An.current[n]:void 0;typeof(typeof u=="number"?u:no[n])!="number"&&ur.length>0&&requestAnimationFrame(()=>{const S=Te.current;S&&(S.scrollTop=S.scrollHeight,rn.current=n)})},[ur.length,n,l,no]);const Ji=(u="smooth",p=null)=>{const S=Te.current;if(!S)return;const k=p??De.current;De.current===k&&(S.scrollTo({top:S.scrollHeight,behavior:u}),Jr(k,!1))},cr=(u,p="auto",S=null)=>{const k=Te.current;if(!k)return;const L=S??De.current;if(De.current!==L)return;const A=document.getElementById(u);if(A){const z=Math.max(0,A.offsetTop-cw);k.scrollTo({top:z,behavior:p})}},um=()=>{const u=De.current,p=Wu[u];p&&(cr(p,"smooth",u),sr(S=>{const{[u]:k,...L}=S;return L}))},cm=u=>{l!=="chats"||!To(u)||(u.preventDefault(),Pe.current+=1,b&&Ud(u)&&Oe(!0))},dm=u=>{l!=="chats"||!To(u)||(u.preventDefault(),u.dataTransfer.dropEffect=b?"copy":"none",b&&Ud(u)&&!vt&&Oe(!0))},fm=u=>{l!=="chats"||!To(u)||(Pe.current=Math.max(0,Pe.current-1),Pe.current===0&&Oe(!1))},pm=async u=>{var p,S;l!=="chats"||!To(u)||(u.preventDefault(),Pe.current=0,Oe(!1),b&&(await bu((p=u.dataTransfer)==null?void 0:p.files),(S=jt.current)==null||S.focus()))};async function tc(){var V,J,ke;const u=Z.trim();if(yt||!u&&fe.length===0||!ve)return;if(fe.length>0&&!b){window.alert("The selected vision model does not support image inputs.");return}let p=n,S=!1;if(p){const ee=e.find(ne=>ne.session_id===p);S=ee&&ee.name==="New Chat"&&ee.messages.length===0}else{const ee=await nc();await new Promise(ne=>setTimeout(ne,200)),p=ee.session_id,S=!0}const k=fe.map(({id:ee,...ne})=>({...ne})),L=Dh(k),A={role:"user",content:u,attachments:k,id:`msg-${Date.now()}-${Math.random()}`};Zh.current=!0,em.current=p,Jr(p,!1),De.current===p&&(rn.current=De.current),nh.flushSync(()=>{t(ee=>ee.map(ne=>ne.session_id===p?{...ne,messages:[...ne.messages||[],A]}:ne)),q(""),Be([])}),requestAnimationFrame(()=>Ji("auto",p));const z=Qu(p);try{let ee=[];if(A.content)try{ee=[...(((V=e.find(te=>te.session_id===p))==null?void 0:V.messages)||[]).slice(-8).map(te=>({role:te.role,content:te.content||""})),{role:"user",content:A.content}]}catch{}let ne=A.content||null,He=[];const Je=[],In=qu(p);if(A.content&&((J=In==null?void 0:In.states)!=null&&J.is_indexed))try{const K=await zu(In.slug,A.content,z.signal);K.contextBlock&&Je.push(K.contextBlock),Array.isArray(K.sources)&&He.push(...K.sources)}catch(K){if(Tt(K))throw K;console.warn("local library enrichment failed",K)}if(A.content&&to)try{const Se=await(await fetch(`${_}/websearch`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({prompt:A.content,model:ve,messages:ee,history_limit:8,searx_url:Qr||null,engines:Array.isArray(Tn)?Tn:null})})).json();Se&&typeof Se.context_block=="string"&&Se.context_block.trim()&&Je.push(Se.context_block.trim()),Array.isArray(Se==null?void 0:Se.sources)&&He.push(...Se.sources)}catch(K){if(Tt(K))throw K;console.warn("web search enrichment failed",K)}if(He=[...new Set(He)],A.content&&Je.length>0&&(ne=`${A.content} + +${Je.join(` + +`)}`),eo){const K=`msg-${Date.now()}-${Math.random()}`;let Se="";const te={role:"assistant",content:"",id:K,sources:He};t(oe=>oe.map(Me=>Me.session_id===p?{...Me,messages:[...Me.messages||[],te]}:Me));try{const oe=await fetch(`${_}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({session_id:p,model:L,message:A.content,enriched_message:A.content&&Je.length>0?ne:null,stream:!0,sources:He||[],attachments:k})});if(!oe.ok)throw new Error(await lo(oe));const Me=(ke=oe.body)==null?void 0:ke.getReader();if(!Me)throw new Error("Missing response body");const Q=new TextDecoder;let Ut=!1;for(;;){const{value:se,done:Ee}=await Me.read();if(Ee){Pn(p,K,Se),De.current===p?ir.current[p]?sr(Pt=>({...Pt,[p]:K})):requestAnimationFrame(()=>cr(K,"smooth",p)):(Mn(Pt=>({...Pt,[p]:K})),or(Pt=>[...new Set([...Pt,p])]));break}const ln=Q.decode(se,{stream:!0});Se+=ln,Pn(p,K,Se),De.current===p&&!ir.current[p]&&Ji("auto",p),De.current!==p&&!Ut&&(Mn(Pt=>({...Pt,[p]:K})),Ut=!0)}}catch(oe){if(Tt(oe)){Pn(p,K,Se,{removeIfEmpty:!0});return}console.error("Failed to send message:",oe),Pn(p,K,"Error: "+zt(oe),{removeIfEmpty:!0});return}}else{const K=await fetch(`${_}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},signal:z.signal,body:JSON.stringify({session_id:p,model:L,message:A.content,enriched_message:A.content&&Je.length>0?ne:null,stream:!1,sources:He||[],attachments:k})});if(!K.ok)throw new Error(await lo(K));const Se=await K.json(),te=`msg-${Date.now()}`,oe={role:"assistant",content:Se.reply,id:te,sources:He};t(Me=>Me.map(Q=>Q.session_id===p?{...Q,messages:[...Q.messages||[],oe]}:Q)),te&&(De.current===p?ir.current[p]?sr(Me=>({...Me,[p]:te})):requestAnimationFrame(()=>cr(te,"smooth",p)):Mn(Me=>({...Me,[p]:te})))}De.current!==p&&or(K=>[...new Set([...K,p])]),S&&fetch(`${_}/generate-title`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:p,message:A.content||(k.length>0?"Image attachment":A.content),model:ve})}).then(K=>K.json()).then(K=>{const Se=ow(K.title);t(te=>te.map(oe=>oe.session_id===p?{...oe,name:Se}:oe))})}catch(ee){if(Tt(ee)){Ki(z);return}console.error("Failed to send message:",ee);const ne={role:"assistant",content:"Error: "+zt(ee),id:`msg-${Date.now()}-${Math.random()}`};t(He=>He.map(Je=>Je.session_id===p?{...Je,messages:[...Je.messages,ne]}:Je))}finally{Ki(z)}}function hm(){Ph(u=>!u)}async function nc(){var L;const u="sess-"+Math.random().toString(36).slice(2)+Date.now().toString(36),S=await(await fetch(`${_}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({session_id:u})})).json(),k={...S,messages:[]};return t(A=>[k,...A]),r(S.session_id),(L=jt.current)==null||L.focus(),S}function mm(u){r(u),or(S=>S.filter(k=>k!==u));const p=Jh[u];p&&requestAnimationFrame(()=>{let S=12;const k=()=>{if(!Te.current)return;let A=document.getElementById(p);if(!A){const z=e.find(V=>V.session_id===u);if(z&&Array.isArray(z.messages))for(let V=z.messages.length-1;V>=0;V--){const J=z.messages[V];if(J.role==="assistant"&&J.id){A=document.getElementById(J.id);break}}}A?(cr(A.id,"smooth",u),Mn(z=>{const{[u]:V,...J}=z;return J})):S-- >0&&requestAnimationFrame(k)};requestAnimationFrame(k)})}function gm(u,p){fetch(`${_}/sessions/${u}/rename`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:p})}).then(()=>{t(S=>S.map(k=>k.session_id===u?{...k,name:p}:k)),m(null)})}function vm(u,p){const S=(p||"").trim(),k=x.find(L=>L.slug===u);if(!k){y(null);return}if(!S||S===k.name){y(null);return}fetch(`${_}/libraries/${u}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:S})}).then(()=>{E(L=>L.map(A=>A.slug===u?{...A,name:S}:A)),y(null)})}function rc(u){fetch(`${_}/sessions/${u}`,{method:"DELETE"}).then(()=>{const p=e.filter(S=>S.session_id!==u);t(p),N(S=>{const k={...S||{}};return delete k[u],k}),n===u&&r(p.length>0?p[0].session_id:null)})}function ym(u){fetch(`${_}/libraries/${u}`,{method:"DELETE"}).then(async p=>{var k;if(!p.ok){const L=await p.text();throw new Error(L||`HTTP ${p.status}`)}const S=x.filter(L=>L.slug!==u);E(S),R(L=>L.filter(A=>A.slug!==u)),y(L=>L===u?null:L),v===u&&h(((k=S[0])==null?void 0:k.slug)||null),am(u)}).catch(p=>{console.error("Failed to delete library",p)})}f.useEffect(()=>{const u=e.filter(p=>p.name==="New Chat"&&p.session_id!==n&&p.messages.length===0);u.length>0&&u.forEach(p=>{rc(p.session_id)})},[n,e,_]);const wm=u=>{var S;window.getSelection().toString().length>0||document.activeElement!==jt.current&&(u.target.closest(".msg")||(S=jt.current)==null||S.focus())};return d.jsxs("div",{className:"app",style:{gridTemplateColumns:`${nm}px 1fr`},children:[d.jsxs("div",{className:"sidebar",children:[d.jsxs("div",{className:"sidebar-header",children:[d.jsx("div",{className:`sidebar-tab ${l==="chats"?"active":""}`,onClick:()=>Yi("chats"),children:"Chats"}),d.jsx("div",{className:`sidebar-tab ${l==="dbs"?"active":""}`,onClick:()=>Yi("dbs"),children:"DBs"}),d.jsx("div",{className:`sidebar-tab ${l==="settings"?"active":""}`,onClick:()=>Yi("settings"),children:"Settings"})]}),d.jsxs("div",{className:"sidebar-content",children:[l==="chats"&&d.jsx("div",{className:"chat-list",children:e.map(u=>d.jsx("div",{className:`chat-item ${u.session_id===n?"active":""}`,onClick:()=>im(u.session_id),children:c===u.session_id?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>m(null),onKeyDown:p=>{p.key==="Enter"?gm(u.session_id,p.target.value):p.key==="Escape"&&m(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[Mh.includes(u.session_id)&&d.jsx("div",{className:"unread-dot"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),m(u.session_id)},children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",children:d.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),rc(u.session_id)},children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-x",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})},u.session_id))}),l==="dbs"&&d.jsx("div",{className:"db-list",children:x.length===0?d.jsx("div",{className:"empty-list-message",children:"No databases yet."}):x.map(u=>d.jsx("div",{className:`chat-item ${u.slug===v?"active":""}`,onClick:()=>h(u.slug),children:w===u.slug?d.jsx("input",{type:"text",className:"rename-input",defaultValue:u.name,onBlur:()=>y(null),onKeyDown:p=>{p.key==="Enter"?vm(u.slug,p.target.value):p.key==="Escape"&&y(null)},autoFocus:!0}):d.jsxs(d.Fragment,{children:[d.jsx("span",{children:u.name}),d.jsxs("div",{className:"chat-item-buttons",children:[bt===u.slug&&d.jsx("div",{className:"db-active-badge",children:"Chat"}),Zu(u.slug)&&d.jsx("div",{className:"db-active-badge",children:"Syncing"}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),y(u.slug)},children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-edit-2",children:d.jsx("path",{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"})})}),d.jsx("button",{className:"icon-button",onClick:p=>{p.stopPropagation(),ym(u.slug)},children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"feather feather-x",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]})},u.slug))}),l==="settings"&&d.jsxs("div",{className:"settings-list",children:[d.jsx("div",{className:`settings-item ${s==="AI Models"?"active":""}`,onClick:()=>a("AI Models"),children:"AI Models"}),d.jsx("div",{className:`settings-item ${s==="Interface"?"active":""}`,onClick:()=>a("Interface"),children:"Interface"}),d.jsx("div",{className:`settings-item ${s==="Microphone"?"active":""}`,onClick:()=>a("Microphone"),children:"Microphone"}),d.jsx("div",{className:`settings-item ${s==="Backend"?"active":""}`,onClick:()=>a("Backend"),children:"Backend"}),d.jsx("div",{className:`settings-item ${s==="Updates"?"active":""}`,onClick:()=>a("Updates"),children:"Updates"}),d.jsx("div",{className:`settings-item ${s==="Advanced"?"active":""}`,onClick:()=>a("Advanced"),children:"Advanced"})]})]}),l!=="settings"&&d.jsxs("div",{className:"sidebar-footer",children:[l==="chats"&&d.jsx("button",{className:"button new-chat-button",onClick:nc,children:"New Chat"}),l==="dbs"&&(P?d.jsxs("div",{className:"new-db-form",children:[d.jsx("input",{type:"text",className:"rename-input",value:O,onChange:u=>D(u.target.value),onKeyDown:u=>{u.key==="Enter"?Gu():u.key==="Escape"&&($(!1),D(""),U(""))},placeholder:"Database name",autoFocus:!0}),H&&d.jsx("div",{className:"form-error",children:H}),d.jsxs("div",{className:"new-db-actions",children:[d.jsx("button",{className:"button new-db-button",onClick:()=>Gu(),children:"Create"}),d.jsx("button",{className:"button ghost",onClick:()=>{$(!1),D(""),U("")},children:"Cancel"})]})]}):d.jsx("button",{className:"button new-db-button",onClick:()=>{$(!0),U("")},children:"New Database"}))]}),d.jsx("div",{className:"resizer",onMouseDown:lm})]}),d.jsxs("div",{className:`main-content${l==="chats"&&vt?" main-content--drag-active":""}`,onDragEnter:cm,onDragOver:dm,onDragLeave:fm,onDrop:pm,children:[Mu&&d.jsxs("div",{className:"startup-task-banner",role:"status","aria-live":"polite",children:[jh&&d.jsx("div",{className:"spinner startup-task-banner__spinner"}),d.jsx("div",{className:"startup-task-banner__text",children:Mu})]}),l==="chats"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsxs("strong",{children:["Chat - ",((lc=e.find(u=>u.session_id===n))==null?void 0:lc.name)||"New Chat"]}),wt&&d.jsx("span",{className:"header-subtle",children:`DB: ${wt.name}${Gi}`})]}),d.jsx("div",{className:`chat${vt?" chat--drag-active":""}`,ref:Te,onClick:wm,children:ur.map((u,p)=>{const S=u.role==="user"&&Ih===p;return d.jsx("div",{id:u.id,className:"msg "+(u.role==="user"?"user":"assistant")+(S?" editing":""),children:u.role==="assistant"?d.jsxs("div",{className:"assistant-message-wrapper",children:[d.jsx(sw,{content:u.content,streamOutput:eo,sources:u.sources}),!yt&&d.jsxs("div",{className:"message-options-bar assistant-options",children:[d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>Du(u),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),d.jsx("button",{className:"icon-button",title:"Regenerate response",onClick:()=>Uu(p),children:d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.3"})})})]})]}):d.jsxs("div",{className:"user-message-wrapper",children:[S?d.jsxs(d.Fragment,{children:[d.jsx(Ls,{attachments:u.attachments,className:"message-attachment-strip"}),d.jsxs("div",{className:"msg-content msg-content--user editing",children:[d.jsx("div",{className:"user-edit-shadow","aria-hidden":"true",children:Hi}),d.jsx(Cd,{className:"edit-message-input edit-overlay",value:Hi,onChange:k=>ro(k.target.value),onBlur:oo,onKeyDown:k=>{k.key==="Escape"&&(k.preventDefault(),oo()),k.key==="Enter"&&!k.shiftKey&&(k.preventDefault(),Yh(p))},autoFocus:!0,minRows:1})]})]}):(()=>{const k=u.content||"",L=Array.isArray(u.attachments)?u.attachments:[],A=k.split(/\r\n|\r|\n/),z=A.length>30,V=Ku(u,p,n),J=z?Xh[V]??!0:!1,ke=J?A.slice(0,30).join(` +`)+` +…`:k,ee=!!k.trim();return d.jsxs(d.Fragment,{children:[d.jsx(Ls,{attachments:L,className:"message-attachment-strip"}),ee&&d.jsx("div",{className:"msg-content msg-content--user",children:ke}),ee&&z&&d.jsx("button",{className:"user-msg-expand",onClick:()=>qh(V),"aria-expanded":J?"false":"true",children:J?"Show entire message":"Collapse"})]})})(),!yt&&!S&&d.jsxs("div",{className:"message-options-bar user-options",children:[d.jsx("button",{className:"icon-button",title:"Edit message",onClick:()=>Qh(p,u.content),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 20h9"}),d.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}),d.jsx("button",{className:"icon-button",title:"Copy message",onClick:()=>Du(u),children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})]})]})},u.id||p)})},n),Wu[n]&&d.jsxs("button",{className:"new-msg-tip",onClick:um,title:"Jump to the new message","aria-label":"Jump to the new message",children:["New message",d.jsx("span",{style:{marginLeft:6},children:"↓"})]}),d.jsx("div",{className:"footer",children:d.jsxs("div",{className:`footer-inner${vt?" footer-inner--drag-active":""}`,children:[d.jsx("input",{ref:Zn,type:"file",accept:"image/*",multiple:!0,className:"composer-image-input",onChange:Kh,tabIndex:-1}),d.jsx(Ls,{attachments:fe,className:"composer-attachment-strip",removable:!0,onRemove:Uh}),(we||nt)&&d.jsxs("div",{className:"composer-audio-status"+(we?" composer-audio-status--recording":" composer-audio-status--transcribing"),role:"status","aria-live":"polite",children:[we?d.jsx("span",{className:"composer-audio-status__dot","aria-hidden":"true"}):d.jsx("div",{className:"spinner composer-audio-status__spinner","aria-hidden":"true"}),d.jsx("span",{children:we?`Listening ${mw(Vr)}`:"Transcribing audio…"})]}),d.jsxs("div",{className:"footer-content-wrapper",children:[d.jsx(Cd,{ref:jt,className:"input",value:Z,onChange:u=>q(u.target.value),onKeyDown:u=>{u.key==="Enter"&&!u.shiftKey&&!we&&!nt&&(u.preventDefault(),tc())},placeholder:"Ask any question...",maxRows:13}),d.jsxs("div",{className:"footer-tool-group",ref:qn,children:[d.jsx("button",{type:"button",className:"db-picker-toggle"+(wt?" active":""),onClick:()=>{n&&Ne(u=>!u)},title:wt?`Database: ${wt.name}${Gi}`:"Select database for this chat","aria-haspopup":"menu","aria-expanded":le,disabled:!n,children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("ellipse",{cx:"12",cy:"5",rx:"8",ry:"3"}),d.jsx("path",{d:"M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5"}),d.jsx("path",{d:"M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6"})]})}),le&&d.jsxs("div",{className:"db-picker-menu",role:"menu",children:[d.jsxs("button",{type:"button",className:"db-picker-option"+(bt?"":" selected"),onClick:()=>{ec(n,null),Ne(!1)},children:[d.jsx("span",{children:"No database"}),!bt&&d.jsx("span",{className:"db-picker-status",children:"Selected"})]}),x.length===0?d.jsx("div",{className:"db-picker-empty",children:"No databases yet."}):x.map(u=>{var L,A,z;const p=bt===u.slug,S=Zu(u.slug),k=(L=u.files)!=null&&L.length?(A=u.states)!=null&&A.is_indexed?"Ready":S?"Syncing":"Needs sync":"Empty";return d.jsxs("button",{type:"button",className:"db-picker-option"+(p?" selected":""),disabled:!((z=u.files)!=null&&z.length),onClick:()=>{ec(n,u.slug),Ne(!1)},children:[d.jsx("span",{children:u.name}),d.jsx("span",{className:"db-picker-status",children:p?"Selected":k})]},u.slug)})]})]}),b&&d.jsx("button",{type:"button",className:"image-attach-toggle"+(fe.length>0?" active":""),onClick:Bh,title:"Attach images","aria-label":"Attach images",children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("path",{d:"M21 15l-5-5L5 21"})]})}),er&&d.jsx("button",{type:"button",className:"audio-input-toggle"+(we||nt?" active":"")+(we?" recording":"")+(nt?" transcribing":""),onClick:Vh,title:nn?we?"Stop voice input":nt?"Transcribing audio":"Start voice input":Jl||"Whisper is not available for audio input.","aria-label":nn?we?"Stop voice input":nt?"Transcribing audio":"Start voice input":Jl||"Whisper is not available for audio input.","aria-pressed":we,disabled:!nn||nt||yt,children:nt?d.jsx("div",{className:"spinner composer-audio-icon-spinner","aria-hidden":"true"}):d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("path",{d:"M12 3a3 3 0 0 1 3 3v6a3 3 0 0 1-6 0V6a3 3 0 0 1 3-3z"}),d.jsx("path",{d:"M19 10a7 7 0 0 1-14 0"}),d.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"}),d.jsx("line",{x1:"8",y1:"22",x2:"16",y2:"22"})]})}),d.jsx("button",{type:"button",className:"websearch-toggle"+(to?" active":""),onClick:hm,title:"Toggle web search","aria-pressed":to,children:d.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),d.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}),d.jsx("button",{className:"button",onClick:yt?tm:tc,title:yt?"Cancel generation":"Send","aria-label":yt?"Cancel generation":"Send",disabled:!yt&&(we||nt),children:yt?d.jsx("div",{className:"spinner"}):"Send"})]})]})})]}),l==="dbs"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"header",children:[d.jsx("strong",{children:(ao==null?void 0:ao.name)||"Databases"}),wt&&d.jsx("span",{className:"header-subtle",children:`Current chat DB: ${wt.name}${Gi}`})]}),d.jsx(J0,{apiBase:_,library:ao,jobs:C,onRefresh:async()=>{await qr(),await so()}})]}),l==="settings"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"header",children:d.jsxs("strong",{children:[s," Settings"]})}),s==="AI Models"&&d.jsx(jo,{panel:"AI Models",onModelChange:gt,onVisionModelChange:B,onTranscriptionModelChange:I,onLibrariesPurged:Ju}),s==="Interface"&&d.jsx(Y0,{streamOutput:eo,onStreamOutputChange:Pu}),s==="Microphone"&&d.jsx(jo,{panel:"Microphone",onAudioInputDeviceChange:Ft,onAudioInputLanguageChange:Gl}),s==="Backend"&&d.jsx(rw,{onBackendApiUrlChange:ce,searxUrl:Qr,setSearxUrl:Lh,engines:Tn,setEngines:u=>Th(vi(u))}),s==="Updates"&&d.jsx(jo,{panel:"Updates"}),s==="Advanced"&&d.jsx(jo,{panel:"Advanced",onLibrariesPurged:Ju})]})]})]})}function vw(){return f.useEffect(()=>{window.electronAPI.getSettings().then(e=>{bl(e.colorScheme||"Default")})},[]),d.jsx(Ve.StrictMode,{children:d.jsx(s0,{children:d.jsx(Fy,{children:d.jsx(mh,{path:"/",element:d.jsx(gw,{})})})})})}const yw=rh(document.getElementById("root"));yw.render(d.jsx(vw,{})); diff --git a/dist/index.html b/dist/index.html index 4ae184a..aa7c01f 100644 --- a/dist/index.html +++ b/dist/index.html @@ -5,7 +5,7 @@ LLM Desktop - + diff --git a/src/App.jsx b/src/App.jsx index 7bf3ce7..1c27d90 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -339,7 +339,7 @@ export default function App() { const [activeSessionId, setActiveSessionId] = useState(null) const [activeSidebarMode, setActiveSidebarMode] = useState('chats') // 'chats', 'dbs', 'settings' const activeSidebarModeRef = useRef(activeSidebarMode) - const [activeSettingsSubmenu, setActiveSettingsSubmenu] = useState('AI Models'); + const [activeSettingsSubmenu, setActiveSettingsSubmenu] = useState('General'); const [editingSessionId, setEditingSessionId] = useState(null); // ID of the session being edited const [editingLibrarySlug, setEditingLibrarySlug] = useState(null) const [libraries, setLibraries] = useState([]) @@ -2503,6 +2503,12 @@ async function createNewChat() { )} {activeSidebarMode === 'settings' && (
+
setActiveSettingsSubmenu('General')} + > + General +
setActiveSettingsSubmenu('AI Models')} @@ -2515,12 +2521,6 @@ async function createNewChat() { > Interface
-
setActiveSettingsSubmenu('Microphone')} - > - Microphone -
setActiveSettingsSubmenu('Backend')} @@ -2969,6 +2969,13 @@ async function createNewChat() {
{activeSettingsSubmenu} Settings
+ {activeSettingsSubmenu === 'General' && ( + + )} {activeSettingsSubmenu === 'AI Models' && ( )} - {activeSettingsSubmenu === 'Microphone' && ( - - )} {activeSettingsSubmenu === 'Backend' && (