(function(){const m=document.createElement("link").relList;if(m&&m.supports&&m.supports("modulepreload"))return;for(const P of document.querySelectorAll('link[rel="modulepreload"]'))O(P);new MutationObserver(P=>{for(const F of P)if(F.type==="childList")for(const Q of F.addedNodes)Q.tagName==="LINK"&&Q.rel==="modulepreload"&&O(Q)}).observe(document,{childList:!0,subtree:!0});function p(P){const F={};return P.integrity&&(F.integrity=P.integrity),P.referrerPolicy&&(F.referrerPolicy=P.referrerPolicy),P.crossOrigin==="use-credentials"?F.credentials="include":P.crossOrigin==="anonymous"?F.credentials="omit":F.credentials="same-origin",F}function O(P){if(P.ep)return;P.ep=!0;const F=p(P);fetch(P.href,F)}})();function gc(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var gi={exports:{}},xl={},yi={exports:{}},oe={};var Yu;function nf(){if(Yu)return oe;Yu=1;var a=Symbol.for("react.element"),m=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),P=Symbol.for("react.profiler"),F=Symbol.for("react.provider"),Q=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),U=Symbol.for("react.suspense"),z=Symbol.for("react.memo"),ee=Symbol.for("react.lazy"),C=Symbol.iterator;function H(h){return h===null||typeof h!="object"?null:(h=C&&h[C]||h["@@iterator"],typeof h=="function"?h:null)}var pe={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Te=Object.assign,te={};function re(h,S,q){this.props=h,this.context=S,this.refs=te,this.updater=q||pe}re.prototype.isReactComponent={},re.prototype.setState=function(h,S){if(typeof h!="object"&&typeof h!="function"&&h!=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,h,S,"setState")},re.prototype.forceUpdate=function(h){this.updater.enqueueForceUpdate(this,h,"forceUpdate")};function Se(){}Se.prototype=re.prototype;function me(h,S,q){this.props=h,this.context=S,this.refs=te,this.updater=q||pe}var Me=me.prototype=new Se;Me.constructor=me,Te(Me,re.prototype),Me.isPureReactComponent=!0;var Ne=Array.isArray,Ae=Object.prototype.hasOwnProperty,Fe={current:null},Ue={key:!0,ref:!0,__self:!0,__source:!0};function Ke(h,S,q){var b,ne={},le=null,de=null;if(S!=null)for(b in S.ref!==void 0&&(de=S.ref),S.key!==void 0&&(le=""+S.key),S)Ae.call(S,b)&&!Ue.hasOwnProperty(b)&&(ne[b]=S[b]);var ue=arguments.length-2;if(ue===1)ne.children=q;else if(1>>1,S=T[h];if(0>>1;hP(ne,M))leP(de,ne)?(T[h]=de,T[le]=M,h=le):(T[h]=ne,T[b]=M,h=b);else if(leP(de,M))T[h]=de,T[le]=M,h=le;else break e}}return W}function P(T,W){var M=T.sortIndex-W.sortIndex;return M!==0?M:T.id-W.id}if(typeof performance=="object"&&typeof performance.now=="function"){var F=performance;a.unstable_now=function(){return F.now()}}else{var Q=Date,Z=Q.now();a.unstable_now=function(){return Q.now()-Z}}var U=[],z=[],ee=1,C=null,H=3,pe=!1,Te=!1,te=!1,re=typeof setTimeout=="function"?setTimeout:null,Se=typeof clearTimeout=="function"?clearTimeout:null,me=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function Me(T){for(var W=p(z);W!==null;){if(W.callback===null)O(z);else if(W.startTime<=T)O(z),W.sortIndex=W.expirationTime,m(U,W);else break;W=p(z)}}function Ne(T){if(te=!1,Me(T),!Te)if(p(U)!==null)Te=!0,he(Ae);else{var W=p(z);W!==null&&ye(Ne,W.startTime-T)}}function Ae(T,W){Te=!1,te&&(te=!1,Se(Ke),Ke=-1),pe=!0;var M=H;try{for(Me(W),C=p(U);C!==null&&(!(C.expirationTime>W)||T&&!xe());){var h=C.callback;if(typeof h=="function"){C.callback=null,H=C.priorityLevel;var S=h(C.expirationTime<=W);W=a.unstable_now(),typeof S=="function"?C.callback=S:C===p(U)&&O(U),Me(W)}else O(U);C=p(U)}if(C!==null)var q=!0;else{var b=p(z);b!==null&&ye(Ne,b.startTime-W),q=!1}return q}finally{C=null,H=M,pe=!1}}var Fe=!1,Ue=null,Ke=-1,st=5,be=-1;function xe(){return!(a.unstable_now()-beT||125h?(T.sortIndex=M,m(z,T),p(U)===null&&T===p(z)&&(te?(Se(Ke),Ke=-1):te=!0,ye(Ne,M-h))):(T.sortIndex=S,m(U,T),Te||pe||(Te=!0,he(Ae))),T},a.unstable_shouldYield=xe,a.unstable_wrapCallback=function(T){var W=H;return function(){var M=H;H=W;try{return T.apply(this,arguments)}finally{H=M}}}})(Si)),Si}var ec;function af(){return ec||(ec=1,_i.exports=sf()),_i.exports}var tc;function uf(){if(tc)return _t;tc=1;var a=Ci(),m=af();function p(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"),U=Object.prototype.hasOwnProperty,z=/^[: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]*$/,ee={},C={};function H(e){return U.call(C,e)?!0:U.call(ee,e)?!1:z.test(e)?C[e]=!0:(ee[e]=!0,!1)}function pe(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 Te(e,t,n,r){if(t===null||typeof t>"u"||pe(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 te(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 re={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){re[e]=new te(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];re[t]=new te(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){re[e]=new te(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){re[e]=new te(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){re[e]=new te(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){re[e]=new te(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){re[e]=new te(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){re[e]=new te(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){re[e]=new te(e,5,!1,e.toLowerCase(),null,!1,!1)});var Se=/[\-:]([a-z])/g;function me(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(Se,me);re[t]=new te(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(Se,me);re[t]=new te(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(Se,me);re[t]=new te(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){re[e]=new te(e,1,!1,e.toLowerCase(),null,!1,!1)}),re.xlinkHref=new te("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){re[e]=new te(e,1,!1,e.toLowerCase(),null,!0,!0)});function Me(e,t,n,r){var l=re.hasOwnProperty(t)?re[t]:null;(l!==null?l.type!==0:r||!(2c||l[i]!==o[c]){var d=` `+l[i].replace(" at new "," at ");return e.displayName&&d.includes("")&&(d=d.replace("",e.displayName)),d}while(1<=i&&0<=c);break}}}finally{q=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?S(e):""}function ne(e){switch(e.tag){case 5:return S(e.type);case 16:return S("Lazy");case 13:return S("Suspense");case 19:return S("SuspenseList");case 0:case 2:case 15:return e=b(e.type,!1),e;case 11:return e=b(e.type.render,!1),e;case 1:return e=b(e.type,!0),e;default:return""}}function le(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 Ue:return"Fragment";case Fe:return"Portal";case st:return"Profiler";case Ke:return"StrictMode";case Ee:return"Suspense";case Ve:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case xe:return(e.displayName||"Context")+".Consumer";case be:return(e._context.displayName||"Context")+".Provider";case it:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case X:return t=e.displayName||null,t!==null?t:le(e.type)||"Memo";case he:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}function de(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 le(t);case 8:return t===Ke?"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 ue(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function se(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function ve(e){var t=se(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 Et(e){e._valueTracker||(e._valueTracker=ve(e))}function on(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=se(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function St(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 Kt(e,t){var n=t.checked;return M({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function xn(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ue(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 at(e,t){t=t.checked,t!=null&&Me(e,"checked",t,!1)}function ae(e,t){at(e,t);var n=ue(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")?Gt(e,t.type,n):t.hasOwnProperty("defaultValue")&&Gt(e,t.type,ue(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function et(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 Gt(e,t,n){(t!=="number"||St(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ut=Array.isArray;function Pt(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=dt.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ge(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Yt={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},At=["Webkit","ms","Moz","O"];Object.keys(Yt).forEach(function(e){At.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Yt[t]=Yt[e]})});function mt(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Yt.hasOwnProperty(e)&&Yt[e]?(""+t).trim():t+"px"}function It(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=mt(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var nr=M({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 wt(e,t){if(t){if(nr[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(p(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(p(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(p(61))}if(t.style!=null&&typeof t.style!="object")throw Error(p(62))}}function Sn(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 Jt=null;function an(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var u=null,_=null,V=null;function je(e){if(e=ll(e)){if(typeof u!="function")throw Error(p(280));var t=e.stateNode;t&&(t=Kl(t),u(e.stateNode,e.type,t))}}function Ft(e){_?V?V.push(e):V=[e]:_=e}function Ut(){if(_){var e=_,t=V;if(V=_=null,je(e),t)for(e=0;e>>=0,e===0?32:31-(yc(e)/xc|0)|0}var Pl=64,Rl=4194304;function $r(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 Tl(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 c=i&~l;c!==0?r=$r(c):(o&=i,o!==0&&(r=$r(o)))}else i=n&~l,i!==0?r=$r(i):o!==0&&(r=$r(o));if(r===0)return 0;if(t!==0&&t!==r&&(t&l)===0&&(l=r&-r,o=t&-t,l>=o||l===16&&(o&4194240)!==0))return t;if((r&4)!==0&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Br(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ie(t),e[t]=n}function jc(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=Yr),Hi=" ",Vi=!1;function Qi(e,t){switch(e){case"keyup":return Xc.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wi(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var cr=!1;function bc(e,t){switch(e){case"compositionend":return Wi(t);case"keypress":return t.which!==32?null:(Vi=!0,Hi);case"textInput":return e=t.data,e===Hi&&Vi?null:e;default:return null}}function ed(e,t){if(cr)return e==="compositionend"||!Xo&&Qi(e,t)?(e=Ai(),Ol=Wo=Pn=null,cr=!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=Zi(n)}}function ea(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ea(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ta(){for(var e=window,t=St();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=St(e.document)}return t}function es(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 ud(e){var t=ta(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&ea(n.ownerDocument.documentElement,n)){if(r!==null&&es(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=bi(n,o);var i=bi(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,dr=null,ts=null,br=null,ns=!1;function na(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ns||dr==null||dr!==St(r)||(r=dr,"selectionStart"in r&&es(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}),br&&Zr(br,r)||(br=r,r=Vl(ts,"onSelect"),0vr||(e.current=ms[vr],ms[vr]=null,vr--)}function we(e,t){vr++,ms[vr]=e.current,e.current=t}var Ln={},tt=Mn(Ln),ht=Mn(!1),Wn=Ln;function gr(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 vt(e){return e=e.childContextTypes,e!=null}function Gl(){Ce(ht),Ce(tt)}function ga(e,t,n){if(tt.current!==Ln)throw Error(p(168));we(tt,t),we(ht,n)}function ya(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(p(108,de(e)||"Unknown",l));return M({},n,r)}function ql(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,Wn=tt.current,we(tt,e),we(ht,ht.current),!0}function xa(e,t,n){var r=e.stateNode;if(!r)throw Error(p(169));n?(e=ya(e,t,Wn),r.__reactInternalMemoizedMergedChildContext=e,Ce(ht),Ce(tt),we(tt,e)):Ce(ht),we(ht,n)}var dn=null,Yl=!1,hs=!1;function _a(e){dn===null?dn=[e]:dn.push(e)}function Sd(e){Yl=!0,_a(e)}function zn(){if(!hs&&dn!==null){hs=!0;var e=0,t=ge;try{var n=dn;for(ge=1;e>=i,l-=i,fn=1<<32-ie(t)+l|n<J?(Je=G,G=null):Je=G.sibling;var fe=w(v,G,g[J],R);if(fe===null){G===null&&(G=Je);break}e&&G&&fe.alternate===null&&t(v,G),f=o(fe,f,J),K===null?B=fe:K.sibling=fe,K=fe,G=Je}if(J===g.length)return n(v,G),Re&&Gn(v,J),B;if(G===null){for(;JJ?(Je=G,G=null):Je=G.sibling;var Hn=w(v,G,fe.value,R);if(Hn===null){G===null&&(G=Je);break}e&&G&&Hn.alternate===null&&t(v,G),f=o(Hn,f,J),K===null?B=Hn:K.sibling=Hn,K=Hn,G=Je}if(fe.done)return n(v,G),Re&&Gn(v,J),B;if(G===null){for(;!fe.done;J++,fe=g.next())fe=N(v,fe.value,R),fe!==null&&(f=o(fe,f,J),K===null?B=fe:K.sibling=fe,K=fe);return Re&&Gn(v,J),B}for(G=r(v,G);!fe.done;J++,fe=g.next())fe=D(G,v,J,fe.value,R),fe!==null&&(e&&fe.alternate!==null&&G.delete(fe.key===null?J:fe.key),f=o(fe,f,J),K===null?B=fe:K.sibling=fe,K=fe);return e&&G.forEach(function(tf){return t(v,tf)}),Re&&Gn(v,J),B}function $e(v,f,g,R){if(typeof g=="object"&&g!==null&&g.type===Ue&&g.key===null&&(g=g.props.children),typeof g=="object"&&g!==null){switch(g.$$typeof){case Ae:e:{for(var B=g.key,K=f;K!==null;){if(K.key===B){if(B=g.type,B===Ue){if(K.tag===7){n(v,K.sibling),f=l(K,g.props.children),f.return=v,v=f;break e}}else if(K.elementType===B||typeof B=="object"&&B!==null&&B.$$typeof===he&&Na(B)===K.type){n(v,K.sibling),f=l(K,g.props),f.ref=ol(v,K,g),f.return=v,v=f;break e}n(v,K);break}else t(v,K);K=K.sibling}g.type===Ue?(f=tr(g.props.children,v.mode,R,g.key),f.return=v,v=f):(R=ko(g.type,g.key,g.props,null,v.mode,R),R.ref=ol(v,f,g),R.return=v,v=R)}return i(v);case Fe:e:{for(K=g.key;f!==null;){if(f.key===K)if(f.tag===4&&f.stateNode.containerInfo===g.containerInfo&&f.stateNode.implementation===g.implementation){n(v,f.sibling),f=l(f,g.children||[]),f.return=v,v=f;break e}else{n(v,f);break}else t(v,f);f=f.sibling}f=fi(g,v.mode,R),f.return=v,v=f}return i(v);case he:return K=g._init,$e(v,f,K(g._payload),R)}if(ut(g))return I(v,f,g,R);if(W(g))return $(v,f,g,R);bl(v,g)}return typeof g=="string"&&g!==""||typeof g=="number"?(g=""+g,f!==null&&f.tag===6?(n(v,f.sibling),f=l(f,g),f.return=v,v=f):(n(v,f),f=di(g,v.mode,R),f.return=v,v=f),i(v)):n(v,f)}return $e}var Sr=Ea(!0),Pa=Ea(!1),eo=Mn(null),to=null,wr=null,Ss=null;function ws(){Ss=wr=to=null}function js(e){var t=eo.current;Ce(eo),e._currentValue=t}function ks(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 jr(e,t){to=e,Ss=wr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(gt=!0),e.firstContext=null)}function Mt(e){var t=e._currentValue;if(Ss!==e)if(e={context:e,memoizedValue:t,next:null},wr===null){if(to===null)throw Error(p(308));wr=e,to.dependencies={lanes:0,firstContext:e}}else wr=wr.next=e;return t}var qn=null;function Cs(e){qn===null?qn=[e]:qn.push(e)}function Ra(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,Cs(t)):(n.next=l.next,l.next=n),t.interleaved=n,mn(e,r)}function mn(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 Dn=!1;function Ns(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ta(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 hn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function On(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(ce&2)!==0){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,mn(e,n)}return l=r.interleaved,l===null?(t.next=t,Cs(r)):(t.next=l.next,l.next=t),r.interleaved=t,mn(e,n)}function no(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,$o(e,n)}}function Ma(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 ro(e,t,n,r){var l=e.updateQueue;Dn=!1;var o=l.firstBaseUpdate,i=l.lastBaseUpdate,c=l.shared.pending;if(c!==null){l.shared.pending=null;var d=c,x=d.next;d.next=null,i===null?o=x:i.next=x,i=d;var k=e.alternate;k!==null&&(k=k.updateQueue,c=k.lastBaseUpdate,c!==i&&(c===null?k.firstBaseUpdate=x:c.next=x,k.lastBaseUpdate=d))}if(o!==null){var N=l.baseState;i=0,k=x=d=null,c=o;do{var w=c.lane,D=c.eventTime;if((r&w)===w){k!==null&&(k=k.next={eventTime:D,lane:0,tag:c.tag,payload:c.payload,callback:c.callback,next:null});e:{var I=e,$=c;switch(w=t,D=n,$.tag){case 1:if(I=$.payload,typeof I=="function"){N=I.call(D,N,w);break e}N=I;break e;case 3:I.flags=I.flags&-65537|128;case 0:if(I=$.payload,w=typeof I=="function"?I.call(D,N,w):I,w==null)break e;N=M({},N,w);break e;case 2:Dn=!0}}c.callback!==null&&c.lane!==0&&(e.flags|=64,w=l.effects,w===null?l.effects=[c]:w.push(c))}else D={eventTime:D,lane:w,tag:c.tag,payload:c.payload,callback:c.callback,next:null},k===null?(x=k=D,d=N):k=k.next=D,i|=w;if(c=c.next,c===null){if(c=l.shared.pending,c===null)break;w=c,c=w.next,w.next=null,l.lastBaseUpdate=w,l.shared.pending=null}}while(!0);if(k===null&&(d=N),l.baseState=d,l.firstBaseUpdate=x,l.lastBaseUpdate=k,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);Xn|=i,e.lanes=i,e.memoizedState=N}}function La(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Ms.transition;Ms.transition={};try{e(!1),t()}finally{ge=n,Ms.transition=r}}function Xa(){return Lt().memoizedState}function Cd(e,t,n){var r=Un(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Za(e))ba(t,n);else if(n=Ra(e,t,n,r),n!==null){var l=pt();Wt(n,e,r,l),eu(n,t,r)}}function Nd(e,t,n){var r=Un(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Za(e))ba(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,c=o(i,n);if(l.hasEagerState=!0,l.eagerState=c,$t(c,i)){var d=t.interleaved;d===null?(l.next=l,Cs(t)):(l.next=d.next,d.next=l),t.interleaved=l;return}}catch{}n=Ra(e,t,l,r),n!==null&&(l=pt(),Wt(n,e,r,l),eu(n,t,r))}}function Za(e){var t=e.alternate;return e===De||t!==null&&t===De}function ba(e,t){ul=so=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function eu(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,$o(e,n)}}var uo={readContext:Mt,useCallback:nt,useContext:nt,useEffect:nt,useImperativeHandle:nt,useInsertionEffect:nt,useLayoutEffect:nt,useMemo:nt,useReducer:nt,useRef:nt,useState:nt,useDebugValue:nt,useDeferredValue:nt,useTransition:nt,useMutableSource:nt,useSyncExternalStore:nt,useId:nt,unstable_isNewReconciler:!1},Ed={readContext:Mt,useCallback:function(e,t){return nn().memoizedState=[e,t===void 0?null:t],e},useContext:Mt,useEffect:Va,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,io(4194308,4,Ka.bind(null,t,e),n)},useLayoutEffect:function(e,t){return io(4194308,4,e,t)},useInsertionEffect:function(e,t){return io(4,2,e,t)},useMemo:function(e,t){var n=nn();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=nn();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=Cd.bind(null,De,e),[r.memoizedState,e]},useRef:function(e){var t=nn();return e={current:e},t.memoizedState=e},useState:Ba,useDebugValue:Fs,useDeferredValue:function(e){return nn().memoizedState=e},useTransition:function(){var e=Ba(!1),t=e[0];return e=kd.bind(null,e[1]),nn().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=De,l=nn();if(Re){if(n===void 0)throw Error(p(407));n=n()}else{if(n=t(),Ye===null)throw Error(p(349));(Jn&30)!==0||Aa(r,t,n)}l.memoizedState=n;var o={value:n,getSnapshot:t};return l.queue=o,Va(Fa.bind(null,r,o,e),[e]),r.flags|=2048,fl(9,Ia.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=nn(),t=Ye.identifierPrefix;if(Re){var n=pn,r=fn;n=(r&~(1<<32-ie(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=cl++,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[en]=t,e[rl]=r,_u(e,t,!1,!1),t.stateNode=e;e:{switch(i=Sn(n,r),n){case"dialog":ke("cancel",e),ke("close",e),l=r;break;case"iframe":case"object":case"embed":ke("load",e),l=r;break;case"video":case"audio":for(l=0;lPr&&(t.flags|=128,r=!0,pl(o,!1),t.lanes=4194304)}else{if(!r)if(e=lo(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),pl(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!Re)return rt(t),null}else 2*Le()-o.renderingStartTime>Pr&&n!==1073741824&&(t.flags|=128,r=!0,pl(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=Le(),t.sibling=null,n=ze.current,we(ze,r?n&1|2:n&1),t):(rt(t),null);case 22:case 23:return ai(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(Nt&1073741824)!==0&&(rt(t),t.subtreeFlags&6&&(t.flags|=8192)):rt(t),null;case 24:return null;case 25:return null}throw Error(p(156,t.tag))}function Od(e,t){switch(gs(t),t.tag){case 1:return vt(t.type)&&Gl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return kr(),Ce(ht),Ce(tt),Ts(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Ps(t),null;case 13:if(Ce(ze),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(p(340));_r()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ce(ze),null;case 4:return kr(),null;case 10:return js(t.type._context),null;case 22:case 23:return ai(),null;case 24:return null;default:return null}}var mo=!1,lt=!1,Ad=typeof WeakSet=="function"?WeakSet:Set,A=null;function Nr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ie(e,t,r)}else n.current=null}function Js(e,t,n){try{n()}catch(r){Ie(e,t,r)}}var ju=!1;function Id(e,t){if(as=zl,e=ta(),es(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,c=-1,d=-1,x=0,k=0,N=e,w=null;t:for(;;){for(var D;N!==n||l!==0&&N.nodeType!==3||(c=i+l),N!==o||r!==0&&N.nodeType!==3||(d=i+r),N.nodeType===3&&(i+=N.nodeValue.length),(D=N.firstChild)!==null;)w=N,N=D;for(;;){if(N===e)break t;if(w===n&&++x===l&&(c=i),w===o&&++k===r&&(d=i),(D=N.nextSibling)!==null)break;N=w,w=N.parentNode}N=D}n=c===-1||d===-1?null:{start:c,end:d}}else n=null}n=n||{start:0,end:0}}else n=null;for(us={focusedElem:e,selectionRange:n},zl=!1,A=t;A!==null;)if(t=A,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,A=e;else for(;A!==null;){t=A;try{var I=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(I!==null){var $=I.memoizedProps,$e=I.memoizedState,v=t.stateNode,f=v.getSnapshotBeforeUpdate(t.elementType===t.type?$:Ht(t.type,$),$e);v.__reactInternalSnapshotBeforeUpdate=f}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(p(163))}}catch(R){Ie(t,t.return,R)}if(e=t.sibling,e!==null){e.return=t.return,A=e;break}A=t.return}return I=ju,ju=!1,I}function ml(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&&Js(t,n,o)}l=l.next}while(l!==r)}}function ho(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 Xs(e){var t=e.ref;if(t!==null){var n=e.stateNode;e.tag,e=n,typeof t=="function"?t(e):t.current=e}}function ku(e){var t=e.alternate;t!==null&&(e.alternate=null,ku(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[en],delete t[rl],delete t[ps],delete t[xd],delete t[_d])),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 Cu(e){return e.tag===5||e.tag===3||e.tag===4}function Nu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Cu(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 Zs(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=Wl));else if(r!==4&&(e=e.child,e!==null))for(Zs(e,t,n),e=e.sibling;e!==null;)Zs(e,t,n),e=e.sibling}function bs(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(bs(e,t,n),e=e.sibling;e!==null;)bs(e,t,n),e=e.sibling}var Xe=null,Vt=!1;function An(e,t,n){for(n=n.child;n!==null;)Eu(e,t,n),n=n.sibling}function Eu(e,t,n){if(L&&typeof L.onCommitFiberUnmount=="function")try{L.onCommitFiberUnmount(y,n)}catch{}switch(n.tag){case 5:lt||Nr(n,t);case 6:var r=Xe,l=Vt;Xe=null,An(e,t,n),Xe=r,Vt=l,Xe!==null&&(Vt?(e=Xe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Xe.removeChild(n.stateNode));break;case 18:Xe!==null&&(Vt?(e=Xe,n=n.stateNode,e.nodeType===8?fs(e.parentNode,n):e.nodeType===1&&fs(e,n),Kr(e)):fs(Xe,n.stateNode));break;case 4:r=Xe,l=Vt,Xe=n.stateNode.containerInfo,Vt=!0,An(e,t,n),Xe=r,Vt=l;break;case 0:case 11:case 14:case 15:if(!lt&&(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)!==0||(o&4)!==0)&&Js(n,t,i),l=l.next}while(l!==r)}An(e,t,n);break;case 1:if(!lt&&(Nr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(c){Ie(n,t,c)}An(e,t,n);break;case 21:An(e,t,n);break;case 22:n.mode&1?(lt=(r=lt)||n.memoizedState!==null,An(e,t,n),lt=r):An(e,t,n);break;default:An(e,t,n)}}function Pu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Ad),t.forEach(function(r){var l=Kd.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Qt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~o}if(r=l,r=Le()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ud(r/1960))-r,10e?16:e,Fn===null)var r=!1;else{if(e=Fn,Fn=null,_o=0,(ce&6)!==0)throw Error(p(331));var l=ce;for(ce|=4,A=e.current;A!==null;){var o=A,i=o.child;if((A.flags&16)!==0){var c=o.deletions;if(c!==null){for(var d=0;dLe()-ni?bn(e,0):ti|=n),xt(e,t)}function Bu(e,t){t===0&&((e.mode&1)===0?t=1:(t=Rl,Rl<<=1,(Rl&130023424)===0&&(Rl=4194304)));var n=pt();e=mn(e,t),e!==null&&(Br(e,t,n),xt(e,n))}function Wd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bu(e,n)}function Kd(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(p(314))}r!==null&&r.delete(t),Bu(e,n)}var Hu;Hu=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ht.current)gt=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return gt=!1,zd(e,t,n);gt=(e.flags&131072)!==0}else gt=!1,Re&&(t.flags&1048576)!==0&&Sa(t,Xl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;po(e,t),e=t.pendingProps;var l=gr(t,tt.current);jr(t,n),l=zs(null,t,r,e,l,n);var o=Ds();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,vt(r)?(o=!0,ql(t)):o=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Ns(t),l.updater=co,t.stateNode=l,l._reactInternals=t,$s(t,r,e,n),t=Qs(null,t,r,!0,o,n)):(t.tag=0,Re&&o&&vs(t),ft(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(po(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=qd(r),e=Ht(r,e),l){case 0:t=Vs(null,t,r,e,n);break e;case 1:t=mu(null,t,r,e,n);break e;case 11:t=uu(null,t,r,e,n);break e;case 14:t=cu(null,t,r,Ht(r.type,e),n);break e}throw Error(p(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ht(r,l),Vs(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ht(r,l),mu(e,t,r,l,n);case 3:e:{if(hu(t),e===null)throw Error(p(387));r=t.pendingProps,o=t.memoizedState,l=o.element,Ta(e,t),ro(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=Cr(Error(p(423)),t),t=vu(e,t,r,n,l);break e}else if(r!==l){l=Cr(Error(p(424)),t),t=vu(e,t,r,n,l);break e}else for(Ct=Tn(t.stateNode.containerInfo.firstChild),kt=t,Re=!0,Bt=null,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(_r(),r===l){t=vn(e,t,n);break e}ft(e,t,r,n)}t=t.child}return t;case 5:return za(t),e===null&&xs(t),r=t.type,l=t.pendingProps,o=e!==null?e.memoizedProps:null,i=l.children,cs(r,l)?i=null:o!==null&&cs(r,o)&&(t.flags|=32),pu(e,t),ft(e,t,i,n),t.child;case 6:return e===null&&xs(t),null;case 13:return gu(e,t,n);case 4:return Es(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Sr(t,null,r,n):ft(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ht(r,l),uu(e,t,r,l,n);case 7:return ft(e,t,t.pendingProps,n),t.child;case 8:return ft(e,t,t.pendingProps.children,n),t.child;case 12:return ft(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,we(eo,r._currentValue),r._currentValue=i,o!==null)if($t(o.value,i)){if(o.children===l.children&&!ht.current){t=vn(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){i=o.child;for(var d=c.firstContext;d!==null;){if(d.context===r){if(o.tag===1){d=hn(-1,n&-n),d.tag=2;var x=o.updateQueue;if(x!==null){x=x.shared;var k=x.pending;k===null?d.next=d:(d.next=k.next,k.next=d),x.pending=d}}o.lanes|=n,d=o.alternate,d!==null&&(d.lanes|=n),ks(o.return,n,t),c.lanes|=n;break}d=d.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(p(341));i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),ks(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}ft(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,jr(t,n),l=Mt(l),r=r(l),t.flags|=1,ft(e,t,r,n),t.child;case 14:return r=t.type,l=Ht(r,t.pendingProps),l=Ht(r.type,l),cu(e,t,r,l,n);case 15:return du(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ht(r,l),po(e,t),t.tag=1,vt(r)?(e=!0,ql(t)):e=!1,jr(t,n),nu(t,r,l),$s(t,r,l,n),Qs(null,t,r,!0,e,n);case 19:return xu(e,t,n);case 22:return fu(e,t,n)}throw Error(p(156,t.tag))};function Vu(e,t){return Ir(e,t)}function Gd(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 Dt(e,t,n,r){return new Gd(e,t,n,r)}function ci(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qd(e){if(typeof e=="function")return ci(e)?1:0;if(e!=null){if(e=e.$$typeof,e===it)return 11;if(e===X)return 14}return 2}function Bn(e,t){var n=e.alternate;return n===null?(n=Dt(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")ci(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Ue:return tr(n.children,l,o,t);case Ke:i=8,l|=8;break;case st:return e=Dt(12,n,t,l|2),e.elementType=st,e.lanes=o,e;case Ee:return e=Dt(13,n,t,l),e.elementType=Ee,e.lanes=o,e;case Ve:return e=Dt(19,n,t,l),e.elementType=Ve,e.lanes=o,e;case ye:return Co(n,l,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case be:i=10;break e;case xe:i=9;break e;case it:i=11;break e;case X:i=14;break e;case he:i=16,r=null;break e}throw Error(p(130,e==null?e:typeof e,""))}return t=Dt(i,n,t,l),t.elementType=e,t.type=r,t.lanes=o,t}function tr(e,t,n,r){return e=Dt(7,e,r,t),e.lanes=n,e}function Co(e,t,n,r){return e=Dt(22,e,r,t),e.elementType=ye,e.lanes=n,e.stateNode={isHidden:!1},e}function di(e,t,n){return e=Dt(6,e,null,t),e.lanes=n,e}function fi(e,t,n){return t=Dt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Yd(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=Uo(0),this.expirationTimes=Uo(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Uo(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function pi(e,t,n,r,l,o,i,c,d){return e=new Yd(e,t,n,c,d),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Dt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ns(o),e}function Jd(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(m){console.error(m)}}return a(),xi.exports=uf(),xi.exports}var rc;function df(){if(rc)return Lo;rc=1;var a=cf();return Lo.createRoot=a.createRoot,Lo.hydrateRoot=a.hydrateRoot,Lo}var ff=df();const pf=gc(ff),mf="/api";async function Oe(a,m){const p=await fetch(`${mf}${a}`,{...m,headers:{"Content-Type":"application/json",...m?.headers??{}}}),O=await p.json();if(!p.ok){const P=O.error?.message??"Ошибка запроса";throw new Error(P)}return O}const Be={async listModels(a){return Oe("/llm/models",{method:"POST",body:JSON.stringify({llmProvider:a.llmProvider,apiKey:a.apiKey,model:a.model,baseUrl:a.baseUrl})})},async testConnection(a){return Oe("/llm/test-connection",{method:"POST",body:JSON.stringify({llmProvider:a.llmProvider,apiKey:a.apiKey,model:a.model,baseUrl:a.baseUrl})})},async normalize(a){return Oe("/normalize",{method:"POST",body:JSON.stringify({llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion,systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples,userQuestion:a.query.userQuestion,context:{period_hint:a.query.periodHint??"",business_context:a.query.businessContext??"",expected_route:a.query.expectedRoute??""},saveAsTestCase:!!a.saveAsTestCase,useMock:!!a.useMock})})},async loadHistory(){return Oe("/history")},async loadTrace(a){return Oe(`/history/${a}`)},async loadPresets(){return Oe("/presets")},async savePreset(a){return Oe("/presets/save",{method:"POST",body:JSON.stringify(a)})},async runEval(a){return Oe("/eval/run",{method:"POST",body:JSON.stringify({normalizeConfig:{llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion,systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples},caseIds:a.caseIds,useMock:!!a.useMock,mode:a.mode??"standard",caseSetFile:a.caseSetFile,rawQuestions:a.rawQuestions})})},async startRun(){return Oe("/accounting-agent/v1/runs/start",{method:"POST",body:JSON.stringify({initiator:"ndc_operator",source:"gui"})})},async finishRun(a){return Oe("/accounting-agent/v1/runs/finish",{method:"POST",body:JSON.stringify({runId:a,status:"DONE",source:"gui",reason:"Остановлено оператором из GUI"})})},async listRuns(){return Oe("/accounting-agent/v1/runs")},async listResults(){return Oe("/accounting-agent/v1/results")},async runTrace(a){return Oe(`/accounting-agent/v1/trace/run/${a}`)},async sendAssistantMessage(a){return Oe("/assistant/message",{method:"POST",body:JSON.stringify({session_id:a.sessionId??"",mode:"assistant",message:a.userMessage,user_message:a.userMessage,llmProvider:a.connection.llmProvider,apiKey:a.connection.apiKey,model:a.connection.model,baseUrl:a.connection.baseUrl,temperature:a.connection.temperature,maxOutputTokens:a.connection.maxOutputTokens,promptVersion:a.promptVersion??"address_query_runtime_v1",systemPrompt:a.prompts.systemPrompt,developerPrompt:a.prompts.developerPrompt,domainPrompt:a.prompts.domainPrompt,fewShotExamples:a.prompts.fewShotExamples,context:{period_hint:a.context?.periodHint??"",business_context:a.context?.businessContext??""},useMock:!!a.useMock})})},async loadAssistantSession(a){return Oe(`/assistant/session/${a}`)},async loadAutoRunsHistory(a){const m=new URLSearchParams;a?.from&&m.set("from",a.from),a?.to&&m.set("to",a.to),a?.target&&m.set("target",a.target),a?.mode&&m.set("mode",a.mode),a?.use_mock&&m.set("use_mock",a.use_mock),a?.prompt_contains&&m.set("prompt_contains",a.prompt_contains),typeof a?.limit=="number"&&m.set("limit",String(a.limit)),typeof a?.scan_limit=="number"&&m.set("scan_limit",String(a.scan_limit));const p=m.toString();return Oe(`/autoruns/history${p?`?${p}`:""}`)},async loadAutoRunDetail(a){return Oe(`/autoruns/history/${encodeURIComponent(a)}`)},async loadAutoRunCaseDialog(a,m){return Oe(`/autoruns/history/${encodeURIComponent(a)}/case/${encodeURIComponent(m)}/dialog`)},async loadAutoRunAnnotations(a){const m=new URLSearchParams;a?.run_id&&m.set("run_id",a.run_id),a?.case_id&&m.set("case_id",a.case_id),typeof a?.min_rating=="number"&&m.set("min_rating",String(a.min_rating)),a?.manual_case_decision&&m.set("manual_case_decision",a.manual_case_decision),typeof a?.limit=="number"&&m.set("limit",String(a.limit));const p=m.toString();return Oe(`/autoruns/annotations${p?`?${p}`:""}`)},async saveAutoRunAnnotation(a){return Oe("/autoruns/annotations",{method:"POST",body:JSON.stringify(a)})},async loadAutoRunPostAnalysis(a){const m=new URLSearchParams;a?.run_id&&m.set("run_id",a.run_id),typeof a?.limit_per_queue=="number"&&m.set("limit_per_queue",String(a.limit_per_queue)),typeof a?.annotation_limit=="number"&&m.set("annotation_limit",String(a.annotation_limit)),typeof a?.scan_limit=="number"&&m.set("scan_limit",String(a.scan_limit)),a?.from&&m.set("from",a.from),a?.to&&m.set("to",a.to),a?.target&&m.set("target",a.target),a?.mode&&m.set("mode",a.mode),a?.use_mock&&m.set("use_mock",a.use_mock),a?.prompt_contains&&m.set("prompt_contains",a.prompt_contains);const p=m.toString();return Oe(`/autoruns/post-analysis${p?`?${p}`:""}`)},async loadAutoRunAutogenHistory(a){const m=new URLSearchParams;a?.mode&&m.set("mode",a.mode),typeof a?.limit=="number"&&m.set("limit",String(a.limit));const p=m.toString();return Oe(`/autoruns/autogen/history${p?`?${p}`:""}`)},async generateAutoRunQuestions(a){return Oe("/autoruns/autogen/generate",{method:"POST",body:JSON.stringify(a)})}};function ot({value:a}){return s.jsx("pre",{className:"json-view",children:JSON.stringify(a??{},null,2)})}function ln({title:a,subtitle:m,actions:p,className:O,hideHeader:P,children:F}){return s.jsxs("section",{className:O?`panel-frame ${O}`:"panel-frame",children:[P?null:s.jsxs("header",{className:"panel-header",children:[s.jsxs("div",{children:[s.jsx("h2",{children:a}),m?s.jsx("p",{children:m}):null]}),p?s.jsx("div",{className:"panel-actions",children:p}):null]}),s.jsx("div",{className:"panel-body",children:F})]})}function hf(a){const m=new Date(a);return Number.isNaN(m.getTime())?a:m.toLocaleString("ru-RU")}function vf({sessionId:a,conversation:m,statusText:p,errorMessage:O,useMock:P,appLogs:F}){const Q=m.filter(z=>z.role==="assistant").length,Z=m.filter(z=>z.role==="user").length,U=m.length>0?m[m.length-1]:null;return s.jsxs(ln,{title:"SAM",subtitle:"System Assistant Monitor: срез по текущей сессии и логам.",children:[s.jsxs("div",{className:"metrics-grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"session_id"}),s.jsx("strong",{children:a||"новая сессия"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"mock_mode"}),s.jsx("strong",{children:P?"on":"off"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"сообщений пользователя"}),s.jsx("strong",{children:Z})]}),s.jsxs("div",{children:[s.jsx("span",{children:"ответов ассистента"}),s.jsx("strong",{children:Q})]}),s.jsxs("div",{children:[s.jsx("span",{children:"статус"}),s.jsx("strong",{children:p||"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"ошибка"}),s.jsx("strong",{children:O||"нет"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"последнее сообщение"}),s.jsx("strong",{children:U?.created_at?hf(U.created_at):"нет данных"})]})]}),s.jsx("h3",{style:{marginTop:12},children:"Последние системные логи"}),s.jsx(ot,{value:F.slice(0,120)})]})}const lc={fromLocal:"",toLocal:"",target:"all",mode:"all",useMock:"any",promptContains:"",limit:120},zo="needs_dialog_policy_fix",oc="ndc_autoruns_ui_config_v1",sc="ndc-autoruns-save",Mr=[{id:"general",label:"Общий контур",domain:"",defaultPrompt:"Генерируй реалистичные живые вопросы бухгалтера по 1С. Добавляй разговорные формулировки и опечатки, но сохраняй бизнес-смысл."},{id:"settlements_60_62",label:"Расчеты 60/62",domain:"settlements_60_62",defaultPrompt:"Генерируй вопросы по расчетам с контрагентами (счета 60/62): закрытие задолженности, авансы, сверки, переносы остатков, цепочки документов."},{id:"month_close_costs_20_44",label:"Закрытие месяца 20/44",domain:"month_close_costs_20_44",defaultPrompt:"Генерируй вопросы по закрытию месяца и затратам на счетах 20/44: распределение, закрытие, остатки, аномалии и разницы по периодам."},{id:"vat_document_register_book",label:"НДС и регистры",domain:"vat_document_register_book",defaultPrompt:"Генерируй вопросы по НДС: начисление, вычет, книги покупок/продаж, счета-фактуры, прогноз обязательств и сверка цепочки документов."}];function gf(){return Mr.reduce((a,m)=>(a[m.id]=m.defaultPrompt,a),{})}const yf=new Set(Mr.map(a=>a.id)),xf={mode:"codex_creative",count:24,personalityId:"general",personalityPrompts:gf(),persistToEvalCases:!0,generatedBy:"manual_reviewer"};function _f(a){const m=a.getFullYear(),p=String(a.getMonth()+1).padStart(2,"0"),O=String(a.getDate()).padStart(2,"0"),P=String(a.getHours()).padStart(2,"0"),F=String(a.getMinutes()).padStart(2,"0");return`${m}-${p}-${O}T${P}:${F}`}function ic(){const a=new Date;return a.setDate(a.getDate()-14),_f(a)}function Do(a){if(!a.trim())return;const m=Date.parse(a);if(Number.isFinite(m))return new Date(m).toISOString()}function Tr(a){if(!a)return"нет данных";const m=Date.parse(a);return Number.isFinite(m)?new Date(m).toLocaleString("ru-RU"):a}function Sf(a,m){return m<=0?0:Math.max(0,Math.min(100,Number((a/m*100).toFixed(1))))}function _l(a){return typeof a!="number"?"нет данных":`${a.toFixed(1)}%`}function wf(a){return a==="assistant_stage1"?"assistant/s1":a==="assistant_stage2"?"assistant/s2":a==="assistant_p0"?"assistant/p0":a}function ac(a){return a==="up"?"Рост":a==="down"?"Регресс":"Без изменений"}function jf(a,m){return a.find(p=>p.case_id===m)??null}function uc(a){const m=Math.max(1,Math.min(5,Math.round(a)));return`${"●".repeat(m)}${"○".repeat(5-m)}`}function cc(a){return a.length===0?s.jsx("p",{className:"muted",children:"Покрытие доменов пока не сформировано."}):s.jsx("div",{className:"autoruns-coverage-list",children:a.map(m=>{const p=Sf(m.closed_cases,m.total_cases);return s.jsxs("div",{className:"autoruns-coverage-item",children:[s.jsxs("div",{className:"autoruns-coverage-head",children:[s.jsx("strong",{children:m.domain}),s.jsxs("span",{children:[m.closed_cases,"/",m.total_cases," (",p,"%)"]})]}),s.jsx("div",{className:"autoruns-coverage-bar",children:s.jsx("div",{style:{width:`${p}%`}})})]},m.domain)})})}function kf({connection:a,prompts:m,assistantPromptVersion:p,decompositionPromptVersion:O,showAssistantMode:P,showDecompositionMode:F,showProgressMode:Q,showCommentsMode:Z,onLog:U}){const[z,ee]=j.useState({...lc,fromLocal:ic()}),[C,H]=j.useState(null),[pe,Te]=j.useState(null),[te,re]=j.useState(null),[Se,me]=j.useState([]),[Me,Ne]=j.useState("all"),[Ae,Fe]=j.useState(null),[Ue,Ke]=j.useState([]),[st,be]=j.useState(""),[xe,it]=j.useState(""),[Ee,Ve]=j.useState(""),[X,he]=j.useState(xf),[ye,T]=j.useState([]),[W,M]=j.useState(null),[h,S]=j.useState(!1),[q,b]=j.useState(!1),[ne,le]=j.useState(!1),[de,ue]=j.useState(!1),[se,ve]=j.useState(!1),[Et,on]=j.useState(!1),[St,Kt]=j.useState(!1),[xn,at]=j.useState(""),[ae,et]=j.useState({open:!1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:zo,annotationAuthor:"manual_reviewer",saving:!1,error:""}),Gt=j.useRef(!1),ut=j.useMemo(()=>Mr.find(u=>u.id===X.personalityId)??Mr[0],[X.personalityId]),Pt=C?.items.find(u=>u.run_id===xe)??pe?.run??null,ct=pe?jf(pe.cases,Ee):null,_e=Se.find(u=>u.annotation_id===st)??null,qt=te?.messages.find(u=>u.message_index===ae.messageIndex)??null,_n=j.useMemo(()=>{if(Se.length===0)return null;const u=Se.reduce((_,V)=>_+V.rating,0)/Se.length;return Number(u.toFixed(2))},[Se]),sn=j.useMemo(()=>{const u=[...C?.items??[]];return xe&&!u.some(_=>_.run_id===xe)&&pe?.run&&u.unshift(pe.run),u},[C?.items,pe?.run,xe]),Pe=j.useCallback(u=>{U?.(`[autoruns] ${u}`)},[U]),dt=j.useCallback(async()=>{Kt(!0);try{const u=await Be.loadAutoRunAnnotations({limit:800,manual_case_decision:Me});me(u.items),Fe(u.manual_case_decision_schema??null),Ke(u.available_manual_case_decisions??[]),be(_=>u.items.length===0?"":u.items.some(V=>V.annotation_id===_)?_:u.items[0].annotation_id)}catch(u){Pe(`Annotations load error: ${u instanceof Error?u.message:String(u)}`)}finally{Kt(!1)}},[Me,Pe]),Ot=j.useCallback(async()=>{le(!0);try{const u=await Be.loadAutoRunAutogenHistory({limit:180});T(u.items)}catch(u){Pe(`Autogen history load error: ${u instanceof Error?u.message:String(u)}`)}finally{le(!1)}},[Pe]),Ge=j.useCallback(async()=>{b(!0);try{const u=await Be.loadAutoRunPostAnalysis({run_id:xe||void 0,limit_per_queue:30,annotation_limit:1500,from:Do(z.fromLocal),to:Do(z.toLocal),target:z.target,mode:z.mode,use_mock:z.useMock,prompt_contains:z.promptContains.trim()||void 0});M(u)}catch(u){Pe(`Post-analysis load error: ${u instanceof Error?u.message:String(u)}`),M(null)}finally{b(!1)}},[z.fromLocal,z.mode,z.promptContains,z.target,z.toLocal,z.useMock,Pe,xe]),Yt=j.useCallback(async()=>{S(!0),at("");try{const u=X.personalityPrompts[X.personalityId]??"",_=[m.systemPrompt,m.developerPrompt,m.domainPrompt,m.schemaNotes,m.fewShotExamples].join(` `).slice(0,900),V=await Be.generateAutoRunQuestions({mode:X.mode,count:X.count,domain:ut.domain||void 0,persist_to_eval_cases:X.persistToEvalCases,generated_by:X.generatedBy.trim()||void 0,context:{llm_provider:a.llmProvider,model:a.model,assistant_prompt_version:p,decomposition_prompt_version:O,prompt_fingerprint:_,autogen_personality_id:ut.id,autogen_personality_prompt:u.trim()||void 0}});Pe(`Generated ${V.generation.count} questions (${V.generation.mode}) id=${V.generation.generation_id}`+(V.generation.saved_case_set_file?` saved=${V.generation.saved_case_set_file}`:"")),await Ot()}catch(u){const _=u instanceof Error?u.message:String(u);at(`Автогенерация: ${_}`),Pe(`Autogen generate error: ${_}`)}finally{S(!1)}},[p,X.count,X.generatedBy,X.mode,X.personalityId,X.personalityPrompts,X.persistToEvalCases,a.llmProvider,a.model,O,Ot,Pe,m.developerPrompt,m.domainPrompt,m.fewShotExamples,m.schemaNotes,m.systemPrompt,ut.domain,ut.id]),At=j.useCallback(async(u,_)=>{on(!0);try{const V=await Be.loadAutoRunCaseDialog(u,_);re(V)}catch(V){const je=V instanceof Error?V.message:String(V);at(`Диалог кейса: ${je}`),re(null),Pe(`Dialog load error for ${u}/${_}: ${je}`)}finally{on(!1)}},[Pe]),mt=j.useCallback(async(u,_)=>{ve(!0);try{const V=await Be.loadAutoRunDetail(u);Te(V);const je=(_&&V.cases.some(Ft=>Ft.case_id===_)?_:"")||V.cases[0]?.case_id||"";it(u),Ve(je),je?await At(u,je):re(null)}catch(V){const je=V instanceof Error?V.message:String(V);at(`Детализация прогона: ${je}`),Te(null),re(null),Pe(`Run detail load error for ${u}: ${je}`)}finally{ve(!1)}},[At,Pe]),It=j.useCallback(async u=>{ue(!0),at("");try{const _=await Be.loadAutoRunsHistory({from:Do(z.fromLocal),to:Do(z.toLocal),target:z.target,mode:z.mode,use_mock:z.useMock,prompt_contains:z.promptContains.trim()||void 0,limit:z.limit});if(H(_),_.items.length===0){it(""),Ve(""),Te(null),re(null);return}const V=u?.keepSelection??!0,je=u?.preferredRunId??"",Ft=u?.preferredCaseId??"",Ut=V&&je&&_.items.some(Xt=>Xt.run_id===je)?je:_.items[0].run_id;await mt(Ut,V?Ft:void 0),Ge()}catch(_){const V=_ instanceof Error?_.message:String(_);at(`История прогонов: ${V}`),Pe(`History load error: ${V}`)}finally{ue(!1)}},[z.fromLocal,z.limit,z.mode,z.promptContains,z.target,z.toLocal,z.useMock,Ge,mt,Pe]),nr=j.useCallback(u=>{u.role==="assistant"&&et({open:!0,messageIndex:u.message_index,rating:u.annotation?.rating??3,comment:u.annotation?.comment??"",manualCaseDecision:u.annotation?.manual_case_decision??zo,annotationAuthor:u.annotation?.annotation_author??X.generatedBy,saving:!1,error:""})},[X.generatedBy]),wt=j.useCallback(()=>{et(u=>u.saving?u:{open:!1,messageIndex:-1,rating:3,comment:"",manualCaseDecision:zo,annotationAuthor:X.generatedBy,saving:!1,error:""})},[X.generatedBy]),Sn=j.useCallback(async()=>{if(!(!xe||!Ee||ae.messageIndex<0)){if(!ae.comment.trim()){et(u=>({...u,error:"Добавьте комментарий."}));return}et(u=>({...u,saving:!0,error:""}));try{await Be.saveAutoRunAnnotation({run_id:xe,case_id:Ee,message_index:ae.messageIndex,rating:ae.rating,comment:ae.comment.trim(),manual_case_decision:ae.manualCaseDecision,annotation_author:ae.annotationAuthor.trim()||void 0}),await Promise.all([mt(xe,Ee),dt(),Ge()]),wt()}catch(u){et(_=>({..._,saving:!1,error:u instanceof Error?u.message:String(u)}))}}},[wt,ae.annotationAuthor,ae.comment,ae.manualCaseDecision,ae.messageIndex,ae.rating,dt,Ge,mt,Ee,xe]),Jt=j.useCallback(async u=>{be(u.annotation_id),await mt(u.run_id,u.case_id),C?.items.some(_=>_.run_id===u.run_id)||at("Комментарий относится к прогону вне текущего фильтра. Детали загружены напрямую.")},[C?.items,mt]);j.useEffect(()=>{Gt.current||(Gt.current=!0,It({keepSelection:!1}),Ot(),Ge())},[Ot,It,Ge]),j.useEffect(()=>{Gt.current&&dt()},[Me,dt]),j.useEffect(()=>{const u=localStorage.getItem(oc);if(u)try{const _=JSON.parse(u);if(_.filters){const V=_.filters;ee(je=>({...je,...V,limit:typeof V.limit=="number"?Math.max(1,Math.min(500,V.limit)):je.limit}))}_.autoGenSettings&&he(V=>{const je={...V.personalityPrompts};for(const Ut of Mr){const Xt=_.autoGenSettings?.personalityPrompts?.[Ut.id];typeof Xt=="string"&&(je[Ut.id]=Xt)}const Ft=_.autoGenSettings?.personalityId&&yf.has(_.autoGenSettings.personalityId)?_.autoGenSettings.personalityId:V.personalityId;return{...V,mode:_.autoGenSettings?.mode==="codex_creative"||_.autoGenSettings?.mode==="qwen_seed"?_.autoGenSettings.mode:V.mode,count:typeof _.autoGenSettings?.count=="number"?Math.max(1,Math.min(200,_.autoGenSettings.count)):V.count,personalityId:Ft,personalityPrompts:je,persistToEvalCases:typeof _.autoGenSettings?.persistToEvalCases=="boolean"?_.autoGenSettings.persistToEvalCases:V.persistToEvalCases,generatedBy:typeof _.autoGenSettings?.generatedBy=="string"?_.autoGenSettings.generatedBy:V.generatedBy}}),(_.annotationDecisionFilter==="all"||typeof _.annotationDecisionFilter=="string"&&_.annotationDecisionFilter.length>0)&&Ne(_.annotationDecisionFilter)}catch{}},[]);const an=j.useCallback(()=>{const u={filters:z,autoGenSettings:{mode:X.mode,count:X.count,personalityId:X.personalityId,personalityPrompts:X.personalityPrompts,persistToEvalCases:X.persistToEvalCases,generatedBy:X.generatedBy},annotationDecisionFilter:Me};localStorage.setItem(oc,JSON.stringify(u))},[Me,X,z]);return j.useEffect(()=>{const u=()=>{an(),Pe("Сохранены настройки панели автопрогонов.")};return window.addEventListener(sc,u),()=>{window.removeEventListener(sc,u)}},[Pe,an]),s.jsxs(ln,{className:"autoruns-frame",title:"",hideHeader:!0,children:[s.jsxs("div",{className:"autoruns-columns",children:[s.jsxs("section",{className:"autoruns-col",children:[s.jsx("div",{className:"autoruns-col-header",children:s.jsx("h3",{children:"Настройки"})}),s.jsx("h4",{children:"Настройки выборки"}),s.jsxs("div",{className:"autoruns-form-grid",children:[s.jsxs("label",{children:["Дата с",s.jsx("input",{type:"datetime-local",value:z.fromLocal,onChange:u=>ee(_=>({..._,fromLocal:u.target.value}))})]}),s.jsxs("label",{children:["Дата по",s.jsx("input",{type:"datetime-local",value:z.toLocal,onChange:u=>ee(_=>({..._,toLocal:u.target.value}))})]}),s.jsxs("label",{children:["Целевой контур",s.jsxs("select",{value:z.target,onChange:u=>ee(_=>({..._,target:u.target.value})),children:[s.jsx("option",{value:"all",children:"все"}),(C?.available.targets??[]).map(u=>s.jsx("option",{value:u,children:u},u))]})]}),s.jsxs("label",{children:["Режим",s.jsxs("select",{value:z.mode,onChange:u=>ee(_=>({..._,mode:u.target.value})),children:[s.jsx("option",{value:"all",children:"все"}),(C?.available.modes??[]).map(u=>s.jsx("option",{value:u,children:u},u))]})]}),s.jsxs("label",{children:["Использовать mock",s.jsxs("select",{value:z.useMock,onChange:u=>ee(_=>({..._,useMock:u.target.value})),children:[s.jsx("option",{value:"any",children:"любой"}),s.jsx("option",{value:"true",children:"да"}),s.jsx("option",{value:"false",children:"нет"})]})]}),s.jsxs("label",{children:["Лимит",s.jsx("input",{type:"number",min:1,max:500,value:z.limit,onChange:u=>ee(_=>({..._,limit:Number(u.target.value||120)}))})]}),s.jsxs("label",{className:"full-width",children:["Версия промпта содержит",s.jsx("input",{value:z.promptContains,onChange:u=>ee(_=>({..._,promptContains:u.target.value})),placeholder:"normalizer_v2_0_2 / address_query_runtime_v1",list:"autoruns-prompt-versions"})]})]}),s.jsx("datalist",{id:"autoruns-prompt-versions",children:(C?.available.prompt_versions??[]).map(u=>s.jsx("option",{value:u},u))}),s.jsxs("div",{className:"button-row",children:[s.jsx("button",{type:"button",disabled:de,onClick:()=>{It({keepSelection:!1})},children:de?"Обновляю...":"Применить"}),s.jsx("button",{type:"button",className:"tab",onClick:()=>{ee({...lc,fromLocal:ic()}),at("")},children:"Сбросить фильтры"})]}),s.jsx("h4",{children:"Контур генерации"}),s.jsxs("div",{className:"autoruns-meta-list",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Провайдер:"}),s.jsx("strong",{children:a.llmProvider})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Модель:"}),s.jsx("strong",{children:a.model||"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Промпт ассистента:"}),s.jsx("strong",{children:p})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Промпт декомпозиции:"}),s.jsx("strong",{children:O})]})]}),s.jsx("h4",{children:"Автогенерация вопросов"}),s.jsxs("div",{className:"autoruns-form-grid",children:[s.jsxs("label",{children:["Режим генерации",s.jsxs("select",{value:X.mode,onChange:u=>he(_=>({..._,mode:u.target.value})),children:[s.jsx("option",{value:"codex_creative",children:"codex_creative"}),s.jsx("option",{value:"qwen_seed",children:"qwen_seed"})]})]}),s.jsxs("label",{children:["Кол-во",s.jsx("input",{type:"number",min:1,max:200,value:X.count,onChange:u=>he(_=>({..._,count:Math.max(1,Math.min(200,Number(u.target.value||24)))}))})]}),s.jsxs("label",{children:["Личность автогенерации",s.jsx("select",{value:X.personalityId,onChange:u=>he(_=>({..._,personalityId:u.target.value})),children:Mr.map(u=>s.jsx("option",{value:u.id,children:u.label},u.id))})]}),s.jsxs("label",{children:["Кто генерирует",s.jsx("input",{value:X.generatedBy,onChange:u=>he(_=>({..._,generatedBy:u.target.value})),placeholder:"manual_reviewer"})]}),s.jsxs("label",{className:"full-width",children:["Промпт личности",s.jsx("textarea",{value:X.personalityPrompts[X.personalityId]??"",onChange:u=>he(_=>({..._,personalityPrompts:{..._.personalityPrompts,[_.personalityId]:u.target.value}})),placeholder:"Текст промпта для выбранной личности автогенерации"})]}),s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:X.persistToEvalCases,onChange:u=>he(_=>({..._,persistToEvalCases:u.target.checked}))}),"Сохранять кейс-сет в `eval_cases`"]})]}),s.jsxs("div",{className:"button-row",children:[s.jsx("button",{type:"button",disabled:h,onClick:()=>{Yt()},children:h?"Генерирую...":"Сгенерировать пачку"}),s.jsx("button",{type:"button",className:"tab",disabled:ne,onClick:()=>{Ot()},children:ne?"Обновляю...":"Обновить историю"})]}),s.jsxs("div",{className:"autoruns-autogen-list",children:[ne?s.jsx("p",{className:"muted",children:"Загружаю историю автогенераций..."}):null,!ne&&ye.length===0?s.jsx("p",{className:"muted",children:"История автогенераций пока пустая."}):null,ye.slice(0,30).map(u=>s.jsxs("article",{className:"autoruns-autogen-item",children:[s.jsxs("header",{children:[s.jsx("strong",{children:Tr(u.created_at)}),s.jsx("span",{children:u.mode})]}),s.jsxs("div",{className:"autoruns-run-meta",children:["id=",u.generation_id," | count=",u.count]}),s.jsxs("div",{className:"autoruns-run-meta",children:["домен=",u.domain??"общий",u.generated_by?` | автор=${u.generated_by}`:""]}),u.saved_case_set_file?s.jsxs("div",{className:"autoruns-run-meta",children:["кейс-сет=",u.saved_case_set_file]}):null,(u.questions??[]).length>0?s.jsx("p",{children:u.questions[0]}):null]},u.generation_id))]}),s.jsxs("details",{className:"autoruns-prompt-details",children:[s.jsx("summary",{children:"Копия активного промпта (только чтение)"}),s.jsxs("label",{children:["Системный",s.jsx("textarea",{readOnly:!0,value:m.systemPrompt})]}),s.jsxs("label",{children:["Разработчика",s.jsx("textarea",{readOnly:!0,value:m.developerPrompt})]}),s.jsxs("label",{children:["Доменный",s.jsx("textarea",{readOnly:!0,value:m.domainPrompt})]}),s.jsxs("label",{children:["Заметки по схеме",s.jsx("textarea",{readOnly:!0,value:m.schemaNotes})]}),s.jsxs("label",{children:["Примеры few-shot",s.jsx("textarea",{readOnly:!0,value:m.fewShotExamples})]})]}),xn?s.jsx("p",{className:"error-text",children:xn}):null]}),s.jsxs("section",{className:"autoruns-col",children:[s.jsx("div",{className:"autoruns-col-header",children:s.jsx("h3",{children:"Выдача прогонов"})}),s.jsxs("div",{className:"autoruns-stats-grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Всего"}),s.jsx("strong",{children:C?.stats.runs_total??0})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Средний score"}),s.jsx("strong",{children:_l(C?.stats.avg_score_index??null)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Тренд"}),s.jsx("strong",{children:C?ac(C.stats.trend):"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Блокеры"}),s.jsx("strong",{children:C?.stats.blocking_runs??0})]})]}),s.jsxs("div",{className:"autoruns-run-list",children:[(C?.items??[]).map(u=>s.jsxs("button",{type:"button",className:xe===u.run_id?"autoruns-run-item selected":"autoruns-run-item",onClick:()=>{mt(u.run_id)},children:[s.jsxs("div",{className:"autoruns-run-head",children:[s.jsx("strong",{children:Tr(u.run_timestamp)}),s.jsx("span",{children:wf(u.eval_target)})]}),s.jsx("div",{className:"autoruns-run-meta",children:u.run_id}),s.jsxs("div",{className:"autoruns-run-meta",children:["режим=",u.mode??"нет данных"," | mock=",String(u.use_mock)]}),u.llm_provider||u.model?s.jsxs("div",{className:"autoruns-run-meta",children:["llm=",u.llm_provider??"нет данных"," | модель=",u.model??"нет данных"]}):null,s.jsxs("div",{className:"autoruns-run-meta",children:["промпт=",u.prompt_version??"нет данных"]}),s.jsxs("div",{className:"autoruns-run-foot",children:[s.jsxs("span",{children:["оценка: ",_l(u.score_index)]}),s.jsxs("span",{children:["закрыто/открыто: ",u.closed_cases,"/",u.open_cases]})]}),s.jsxs("div",{className:"autoruns-run-foot",children:[s.jsxs("span",{children:["блокеры: ",u.blocking_failures]}),s.jsxs("span",{children:["качество: ",u.quality_failures]})]})]},u.run_id)),(C?.items.length??0)===0?s.jsx("p",{className:"muted",children:"За выбранный диапазон прогонов нет."}):null]})]}),s.jsxs("section",{className:"autoruns-col",children:[s.jsxs("div",{className:"autoruns-col-header",children:[s.jsx("h3",{children:"Диалог прогона"}),s.jsxs("div",{className:"autoruns-dialog-toolbar",children:[s.jsxs("label",{children:["Прогон",s.jsx("select",{value:xe,onChange:u=>{const _=u.target.value;mt(_)},children:sn.map(u=>s.jsxs("option",{value:u.run_id,children:[Tr(u.run_timestamp)," | ",u.run_id]},u.run_id))})]}),s.jsxs("label",{children:["Кейс",s.jsx("select",{value:Ee,onChange:u=>{const _=u.target.value;Ve(_),xe&&_&&At(xe,_)},children:(pe?.cases??[]).map(u=>s.jsxs("option",{value:u.case_id,children:[u.case_id," | ",u.status]},u.case_id))})]})]})]}),s.jsx("div",{className:"autoruns-case-list",children:(pe?.cases??[]).map(u=>s.jsxs("button",{type:"button",className:Ee===u.case_id?"autoruns-case-item selected":"autoruns-case-item",onClick:()=>{Ve(u.case_id),xe&&At(xe,u.case_id)},children:[s.jsx("span",{children:u.case_id}),s.jsxs("span",{children:[u.status,u.commented_count>0?` | 💬${u.commented_count}`:""]})]},u.case_id))}),s.jsxs("div",{className:"autoruns-dialog-view",children:[Et||se?s.jsx("p",{className:"muted",children:"Загружаю диалог..."}):null,!Et&&!se&&(te?.messages.length??0)===0?s.jsx("p",{className:"muted",children:"Диалог для этого кейса не найден."}):null,(te?.messages??[]).map((u,_)=>{const V=u.role==="assistant"?"assistant":"user";return s.jsxs("article",{className:`autoruns-msg ${V}`,children:[s.jsxs("header",{children:[s.jsx("strong",{children:V==="assistant"?"Система":"Модель/вопрос"}),s.jsxs("div",{className:"autoruns-msg-head-actions",children:[s.jsx("span",{children:u.created_at?Tr(u.created_at):"нет данных"}),V==="assistant"?s.jsx("button",{type:"button",className:u.commented?"autoruns-comment-icon commented":"autoruns-comment-icon",onClick:()=>nr(u),title:"Комментировать ответ системы",children:"💬"}):null]})]}),s.jsx("p",{children:u.text}),V==="assistant"&&u.annotation?s.jsxs("div",{className:"autoruns-msg-annotation",children:[s.jsx("strong",{children:uc(u.annotation.rating)}),s.jsx("span",{children:u.annotation.comment}),s.jsxs("span",{className:"muted",children:[u.annotation.manual_case_decision,u.annotation.annotation_author?` | ${u.annotation.annotation_author}`:""]})]}):null,(u.trace_id||u.reply_type)&&s.jsxs("footer",{children:[u.trace_id?s.jsxs("span",{children:["trace=",u.trace_id]}):null,u.reply_type?s.jsxs("span",{children:["reply_type=",u.reply_type]}):null]})]},u.message_id??`${V}-${_}`)})]})]}),P?s.jsxs("section",{className:"autoruns-col",children:[s.jsx("div",{className:"autoruns-col-header",children:s.jsx("h3",{children:"Режим ассистента"})}),s.jsxs("div",{className:"autoruns-meta-list",children:[s.jsxs("div",{children:[s.jsx("span",{children:"источник:"}),s.jsx("strong",{children:te?.source??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"сессия:"}),s.jsx("strong",{children:te?.session_id??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"контур прогона:"}),s.jsx("strong",{children:Pt?.eval_target??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"оценка прогона:"}),s.jsx("strong",{children:_l(Pt?.score_index??null)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"комментарии:"}),s.jsx("strong",{children:pe?.annotations_summary?.total??0})]})]}),s.jsx("h4",{children:"Пакет режима ассистента"}),s.jsx(ot,{value:te?.assistant_mode??{note:"assistant_mode недоступен"}}),s.jsx("h4",{style:{marginTop:12},children:"Проверки кейса"}),s.jsx(ot,{value:ct?.checks??{note:"checks недоступен"}}),s.jsx("h4",{style:{marginTop:12},children:"Сабскор метрик"}),s.jsx(ot,{value:ct?.metric_subscores??{note:"metric_subscores недоступен"}})]}):null,F?s.jsxs("section",{className:"autoruns-col",children:[s.jsx("div",{className:"autoruns-col-header",children:s.jsx("h3",{children:"Режим декомпозиции"})}),s.jsxs("div",{className:"autoruns-meta-list",children:[s.jsxs("div",{children:[s.jsx("span",{children:"кейс:"}),s.jsx("strong",{children:ct?.case_id??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"домен:"}),s.jsx("strong",{children:ct?.domain??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"класс запроса:"}),s.jsx("strong",{children:ct?.query_class??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"trace:"}),s.jsx("strong",{children:ct?.trace_id??"нет данных"})]})]}),s.jsx("h4",{children:"Шаги декомпозиции"}),(te?.decomposition.length??0)>0?s.jsx("ol",{className:"autoruns-decomposition-list",children:(te?.decomposition??[]).map((u,_)=>s.jsx("li",{children:u},`${_}-${u.slice(0,24)}`))}):s.jsx("p",{className:"muted",children:"В логах кейса нет явной декомпозиции."})]}):null,Q?s.jsxs("section",{className:"autoruns-col",children:[s.jsx("div",{className:"autoruns-col-header",children:s.jsx("h3",{children:"Прогресс / регресс"})}),s.jsxs("div",{className:"autoruns-stats-grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Последний score"}),s.jsx("strong",{children:_l(C?.stats.latest_score_index??null)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Предыдущий"}),s.jsx("strong",{children:_l(C?.stats.previous_score_index??null)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Тренд"}),s.jsx("strong",{children:C?ac(C.stats.trend):"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Пробелы качества"}),s.jsx("strong",{children:C?.stats.quality_gap_runs??0})]})]}),s.jsx("h4",{children:"Покрытие доменов (история)"}),cc(C?.stats.domain_coverage??[]),s.jsx("h4",{style:{marginTop:14},children:"Покрытие доменов (выбранный прогон)"}),cc(pe?.coverage.domain_coverage??[]),s.jsx("h4",{style:{marginTop:14},children:"Очереди фиксов пост-анализа"}),q?s.jsx("p",{className:"muted",children:"Собираю пост-анализ..."}):null,q?null:s.jsx("div",{className:"autoruns-stats-grid",children:Object.entries(W?.post_analysis.stats.by_queue??{}).map(([u,_])=>s.jsxs("div",{children:[s.jsx("span",{children:u}),s.jsx("strong",{children:_})]},u))}),s.jsxs("div",{className:"autoruns-autogen-list",children:[(W?.post_analysis.recommended_regression_candidates??[]).slice(0,12).map(u=>s.jsxs("article",{className:"autoruns-autogen-item",children:[s.jsxs("header",{children:[s.jsx("strong",{children:u.manual_case_decision}),s.jsxs("span",{children:[u.rating,"/5"]})]}),s.jsxs("div",{className:"autoruns-run-meta",children:[u.domain??"неизвестно"," / ",u.query_class??"неизвестно"]}),s.jsx("p",{children:u.comment})]},u.annotation_id)),!q&&(W?.post_analysis.recommended_regression_candidates.length??0)===0?s.jsx("p",{className:"muted",children:"Рекомендованных кандидатов пока нет."}):null]})]}):null,Z?s.jsxs("section",{className:"autoruns-col",children:[s.jsx("div",{className:"autoruns-col-header",children:s.jsx("h3",{children:"Комментарии"})}),s.jsx("h4",{children:"Размеченные ответы"}),s.jsx("div",{className:"autoruns-form-grid",children:s.jsxs("label",{children:["Фильтр решений",s.jsxs("select",{value:Me,onChange:u=>Ne(u.target.value),children:[s.jsx("option",{value:"all",children:"все"}),(Ue.length>0?Ue:Ae?.enum??[]).map(u=>s.jsx("option",{value:u,children:String(Ae?.labels?.[u]??u)},u))]})]})}),s.jsxs("div",{className:"autoruns-stats-grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Комментариев"}),s.jsx("strong",{children:Se.length})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Средний рейтинг"}),s.jsx("strong",{children:_n===null?"нет данных":`${_n.toFixed(2)} / 5`})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Последний"}),s.jsx("strong",{children:Se.length>0?Tr(Se[0].updated_at):"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Статус"}),s.jsx("strong",{children:St?"обновляю":"готово"})]})]}),s.jsxs("div",{className:"button-row",children:[s.jsx("button",{type:"button",disabled:St,onClick:()=>{dt()},children:St?"Обновляю...":"Обновить список"}),s.jsx("button",{type:"button",className:"tab",disabled:q,onClick:()=>{Ge()},children:q?"Идет пост-анализ...":"Обновить пост-анализ"})]}),s.jsxs("div",{className:"autoruns-comments-list",children:[St?s.jsx("p",{className:"muted",children:"Загружаю комментарии..."}):null,!St&&Se.length===0?s.jsx("p",{className:"muted",children:"Пока нет откомментированных ответов."}):null,Se.map(u=>s.jsxs("button",{type:"button",className:st===u.annotation_id?"autoruns-comment-item selected":"autoruns-comment-item",onClick:()=>{Jt(u)},children:[s.jsxs("div",{className:"autoruns-comment-head",children:[s.jsx("strong",{children:uc(u.rating)}),s.jsx("span",{children:Tr(u.updated_at)})]}),s.jsx("div",{className:"autoruns-run-meta",children:u.run_id}),s.jsxs("div",{className:"autoruns-run-meta",children:["case=",u.case_id," | msg=",u.message_index]}),s.jsxs("div",{className:"autoruns-run-meta",children:["decision=",u.manual_case_decision,u.annotation_author?` | author=${u.annotation_author}`:""]}),s.jsx("p",{children:u.comment})]},u.annotation_id))]}),_e?s.jsxs(s.Fragment,{children:[s.jsx("h4",{children:"Тех-контекст брака"}),s.jsxs("div",{className:"autoruns-meta-list",children:[s.jsxs("div",{children:[s.jsx("span",{children:"trace:"}),s.jsx("strong",{children:_e.technical_context.trace_id??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"reply_type:"}),s.jsx("strong",{children:_e.technical_context.reply_type??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"domain:"}),s.jsx("strong",{children:_e.technical_context.domain??"нет данных"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"query_class:"}),s.jsx("strong",{children:_e.technical_context.query_class??"нет данных"})]})]}),s.jsx("h4",{children:"JSON разбор"}),s.jsx(ot,{value:{annotation_id:_e.annotation_id,run_id:_e.run_id,case_id:_e.case_id,message_index:_e.message_index,rating:_e.rating,comment:_e.comment,manual_case_decision:_e.manual_case_decision,annotation_author:_e.annotation_author,context:_e.context,technical_context:_e.technical_context,case_summary:_e.case_summary?{case_id:_e.case_summary.case_id,domain:_e.case_summary.domain,query_class:_e.case_summary.query_class,checks:_e.case_summary.checks,metric_subscores:_e.case_summary.metric_subscores}:null}})]}):null]}):null]}),ae.open?s.jsx("div",{className:"autoruns-comment-modal-backdrop",onClick:u=>{u.target===u.currentTarget&&wt()},children:s.jsxs("div",{className:"autoruns-comment-modal",children:[s.jsx("h3",{children:"Комментарий к ответу системы"}),s.jsx("p",{className:"muted",children:"Оцените ответ по 5-балльной шкале и добавьте комментарий по браку."}),qt?s.jsxs("details",{className:"autoruns-prompt-details",open:!0,children:[s.jsx("summary",{children:"Ответ системы"}),s.jsx("p",{className:"autoruns-comment-quote",children:qt.text})]}):null,s.jsx("div",{className:"autoruns-rating-row",role:"group","aria-label":"Рейтинг ответа",children:[1,2,3,4,5].map(u=>s.jsx("button",{type:"button",className:ae.rating>=u?"autoruns-rating-dot active":"autoruns-rating-dot",onClick:()=>et(_=>({..._,rating:u})),disabled:ae.saving,"aria-label":`Оценка ${u}`,children:ae.rating>=u?"●":"○"},u))}),s.jsxs("div",{className:"autoruns-form-grid",children:[s.jsxs("label",{children:["Решение по кейсу",s.jsx("select",{value:ae.manualCaseDecision,onChange:u=>et(_=>({..._,manualCaseDecision:u.target.value})),disabled:ae.saving,children:(Ue.length>0?Ue:Ae?.enum??[zo]).map(u=>s.jsx("option",{value:u,children:String(Ae?.labels?.[u]??u)},u))})]}),s.jsxs("label",{children:["Автор комментария",s.jsx("input",{value:ae.annotationAuthor,onChange:u=>et(_=>({..._,annotationAuthor:u.target.value})),placeholder:"manual_reviewer",disabled:ae.saving})]})]}),s.jsxs("label",{children:["Комментарий",s.jsx("textarea",{value:ae.comment,onChange:u=>et(_=>({..._,comment:u.target.value})),placeholder:"Почему ответ бракованный, что именно пошло не так, какие технические детали проверить.",rows:4,disabled:ae.saving})]}),ae.error?s.jsx("p",{className:"error-text",children:ae.error}):null,s.jsxs("div",{className:"button-row",children:[s.jsx("button",{type:"button",onClick:()=>{Sn()},disabled:ae.saving,children:ae.saving?"Сохраняю...":"Готово"}),s.jsx("button",{type:"button",className:"tab",onClick:wt,disabled:ae.saving,children:"Отмена"})]})]})}):null]})}const Cf=/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json|debug_payload|technical_breakdown)\b/i,Nf=[/\b(?:debug_payload_json|technical_breakdown_json)\b/i,/\b(?:route_summary|semantic_profile|domain_scope|relation_patterns|account_scope)\b/i,/\b(?:coverage_report|retrieval_status|problem_unit_state|candidate_evidence)\b/i,/\b(?:graph_domain_scope|graph_runtime|selection_reason|why_included)\b/i];function Ef(a){try{return JSON.stringify(a,null,2)}catch{return String(a)}}function Pf(a){const m=String(a??""),p=m.match(Cf);return(p?m.slice(0,p.index):m).replace(/###\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)[\s\S]*?(?:```[\s\S]*?```|$)/gi,"").replace(/(?:^|\n)\s*#{0,6}\s*(?:debug_payload_json|technical_breakdown_json|route_summary_json)\b[\s\S]*$/gi,"").split(/\r?\n/g).map(Q=>Q.trimEnd()).filter(Q=>Q.trim().length>0).filter(Q=>!Nf.some(Z=>Z.test(Q))).join(` `).trim()}function Rf(a,m,p="default"){const O=p==="technical",P=[];P.push("# Assistant conversation export"),P.push(`session_id: ${a||"n/a"}`),P.push(`export_mode: ${p}`),P.push(`exported_at: ${new Date().toISOString()}`),P.push("");for(let F=0;F{C.current&&(C.current.scrollTop=C.current.scrollHeight)},[m,z]),j.useEffect(()=>()=>{H.current!==null&&window.clearTimeout(H.current)},[]);async function Se(me){if(m.length===0)return;const Me=Rf(a,m,me),Ne=await Lf(Me);re(me==="technical"?"тех":"чат"),Te(Ne?"success":"error"),H.current!==null&&window.clearTimeout(H.current),H.current=window.setTimeout(()=>{Te("idle")},2200)}return s.jsxs(ln,{title:"Режим ассистента",subtitle:"Диалоговый слой поверх normalizer, маршрутизации и factual retrieval.",actions:s.jsxs("div",{className:"assistant-panel-actions",children:[s.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Se("default")},disabled:m.length===0,title:"Экспорт только user-facing чата",children:"Скопировать чат"}),s.jsx("button",{type:"button",className:"assistant-copy-btn",onClick:()=>{Se("technical")},disabled:m.length===0,title:"Технический экспорт с debug payload",children:"Скопировать техчат"}),pe==="success"?s.jsxs("span",{className:"assistant-copy-feedback success",children:["Скопировано (",te,")"]}):null,pe==="error"?s.jsx("span",{className:"assistant-copy-feedback error",children:"Ошибка копирования"}):null,s.jsx("span",{className:"status-chip",children:a?`session: ${a}`:"новая сессия"})]}),children:[s.jsxs("div",{ref:C,className:"assistant-chat-list",children:[m.length===0?s.jsx("div",{className:"assistant-empty muted",children:"Диалог пуст. Отправьте первый вопрос, чтобы запустить контур ассистента."}):null,m.map(me=>s.jsxs("article",{className:`assistant-msg ${me.role}`,children:[s.jsxs("header",{className:"assistant-msg-head",children:[s.jsx("strong",{children:Tf(me.role)}),s.jsx("span",{children:Mf(me.created_at)})]}),s.jsx("div",{className:"assistant-msg-body",children:me.text}),me.role==="assistant"&&me.debug?s.jsxs("details",{className:"assistant-debug",children:[s.jsx("summary",{children:"Показать технический разбор"}),s.jsx(ot,{value:me.debug})]}):null]},me.message_id))]}),s.jsxs("div",{className:"assistant-compose",children:[s.jsxs("label",{className:"full-width",children:["Сообщение",s.jsx("textarea",{value:p,onChange:me=>O(me.target.value),rows:4,placeholder:"Введите вопрос к данным компании..."})]}),s.jsxs("div",{className:"button-row",children:[s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:P,onChange:me=>F(me.target.checked)}),"Mock-режим"]}),s.jsx("button",{type:"button",onClick:()=>Q(),disabled:U||!p.trim(),children:U?"Выполняю...":"Отправить"}),s.jsx("button",{type:"button",onClick:()=>Z(),disabled:U&&m.length===0,children:"Сбросить сессию"})]}),z?s.jsx("p",{className:"diff-summary",children:z}):null,ee?s.jsx("p",{className:"error-text",children:ee}):null]})]})}function dc({value:a,modelOptions:m,modelsBusy:p,onChange:O,onReloadModels:P,onTestConnection:F,onSaveLocalConfig:Q,lastStatus:Z,busy:U}){const z=a.llmProvider==="local",ee=m.includes(a.model);return s.jsxs(ln,{title:"LLM Connection",subtitle:"Switch between OpenAI cloud and local OpenAI-compatible server.",actions:s.jsx("span",{className:"status-chip",children:Z||"Status: not checked"}),children:[s.jsxs("div",{className:"grid-two",children:[s.jsxs("label",{children:["Provider",s.jsxs("select",{value:a.llmProvider,onChange:C=>{const H=C.target.value==="local"?"local":"openai";O({...a,llmProvider:H,baseUrl:H==="local"?"http://127.0.0.1:1234/v1":"https://api.openai.com/v1"})},children:[s.jsx("option",{value:"openai",children:"OpenAI (token)"}),s.jsx("option",{value:"local",children:"Local (LM Studio / OpenAI-compatible)"})]})]}),s.jsxs("label",{children:["Model",s.jsxs("select",{value:ee?a.model:"__manual__",onChange:C=>{const H=C.target.value;H!=="__manual__"&&O({...a,model:H})},children:[s.jsx("option",{value:"__manual__",children:"Manual input"}),m.map(C=>s.jsx("option",{value:C,children:C},C))]})]}),s.jsxs("label",{children:["Model ID (manual)",s.jsx("input",{value:a.model,onChange:C=>O({...a,model:C.target.value}),placeholder:"qwen2.5-14b-instruct or lmstudio loaded model id"})]}),z?null:s.jsxs("label",{className:"full-width",children:["OpenAI API Key",s.jsx("input",{type:"password",value:a.apiKey,onChange:C=>O({...a,apiKey:C.target.value}),placeholder:"sk-..."})]}),s.jsxs("label",{className:z?"full-width":void 0,children:[z?"Local server base URL":"Base URL",s.jsx("input",{value:a.baseUrl,onChange:C=>O({...a,baseUrl:C.target.value}),placeholder:z?"http://127.0.0.1:1234/v1":"https://api.openai.com/v1"})]}),s.jsxs("label",{children:["Temperature",s.jsx("input",{type:"number",step:"0.1",value:a.temperature,onChange:C=>O({...a,temperature:Number(C.target.value)})})]}),s.jsxs("label",{children:["Max output tokens",s.jsx("input",{type:"number",value:a.maxOutputTokens,onChange:C=>O({...a,maxOutputTokens:Number(C.target.value)})})]})]}),s.jsxs("div",{className:"button-row",children:[s.jsx("button",{type:"button",onClick:()=>Q(),children:"Save local config"}),s.jsx("button",{type:"button",onClick:()=>P(),disabled:U||p,children:p?"Loading models...":"Load model list"}),s.jsx("button",{type:"button",onClick:()=>F(),disabled:U,children:U?"Checking...":"Test connection"})]})]})}function Df({items:a,onRefresh:m,onOpenTrace:p}){return s.jsx(ln,{title:"История нормализаций",subtitle:"Короткий вопрос, confidence, route hint и статус валидации.",actions:s.jsx("button",{type:"button",onClick:()=>m(),children:"Обновить"}),children:s.jsxs("div",{className:"history-list",children:[a.length===0?s.jsx("p",{className:"muted",children:"История пока пустая."}):null,a.map(O=>s.jsxs("button",{type:"button",className:"history-item",onClick:()=>p(O.trace_id),children:[s.jsxs("div",{className:"history-row",children:[s.jsx("strong",{children:O.route_hint??"route: n/a"}),s.jsx("span",{children:O.validation_passed?"schema: ok":"schema: fail"})]}),s.jsx("p",{children:O.question_short}),s.jsxs("div",{className:"history-row",children:[s.jsx("span",{children:O.model}),s.jsx("span",{children:new Date(O.timestamp).toLocaleString("ru-RU")})]})]},O.trace_id))]})})}function yn(a){return a==null||a===""?"—":String(a)}function Of({result:a}){return s.jsx(ln,{title:"Runtime метрики",subtitle:"trace_id, токены, latency и статус валидации.",children:s.jsxs("div",{className:"metrics-grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"trace_id"}),s.jsx("strong",{children:yn(a?.trace_id)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"request_started_at"}),s.jsx("strong",{children:yn(a?new Date(Date.now()-a.latency_ms).toISOString():null)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"request_finished_at"}),s.jsx("strong",{children:yn(a?new Date().toISOString():null)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"latency_ms"}),s.jsx("strong",{children:yn(a?.latency_ms)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"input_tokens"}),s.jsx("strong",{children:yn(a?.usage?.input_tokens)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"output_tokens"}),s.jsx("strong",{children:yn(a?.usage?.output_tokens)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"total_tokens"}),s.jsx("strong",{children:yn(a?.usage?.total_tokens)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"validation_status"}),s.jsx("strong",{children:a?.validation?.passed?"passed":"failed"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"prompt_version"}),s.jsx("strong",{children:yn(a?.prompt_version)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"schema_version"}),s.jsx("strong",{children:yn(a?.schema_version)})]})]})})}const Af={normalized:"Normalized JSON",fragments:"Fragment View",scope:"Scope View",flags:"Flags View",route:"Route Simulation",raw:"Raw model output",validation:"Validation",logs:"Logs"};function If(a){return a&&typeof a=="object"?a:null}function Ff({tab:a,onTabChange:m,result:p,appLogs:O}){const P=["normalized","fragments","scope","flags","route","raw","validation","logs"],F=If(p?.normalized),Q=String(F?.schema_version??""),Z=Q==="normalized_query_v2"||Q==="normalized_query_v2_0_1"||Q==="normalized_query_v2_0_2",U=Z?{fragments:F?.fragments??[],discarded_fragments:F?.discarded_fragments??[]}:{note:"Fragment View доступен для normalized_query_v2."},z=Z?{message_in_scope:F?.message_in_scope??null,scope_confidence:F?.scope_confidence??null,contains_multiple_tasks:F?.contains_multiple_tasks??null,global_notes:F?.global_notes??null}:{note:"Scope View доступен для normalized_query_v2."},ee=Z?Array.isArray(F?.fragments)?(F?.fragments).map(C=>({fragment_id:C.fragment_id??null,domain_relevance:C.domain_relevance??null,candidate_labels:C.candidate_labels??[],execution_readiness:C.execution_readiness??null,clarification_reason:C.clarification_reason??null,soft_assumption_used:C.soft_assumption_used??[],route_status:C.route_status??null,no_route_reason:C.no_route_reason??null,flags:C.flags??{}})):[]:{note:"Flags View доступен для normalized_query_v2."};return s.jsxs(ln,{title:"Выходные данные",subtitle:"Structured output и диагностические вкладки.",children:[s.jsx("div",{className:"tab-row",children:P.map(C=>s.jsx("button",{type:"button",className:a===C?"tab active":"tab",onClick:()=>m(C),children:Af[C]},C))}),a==="normalized"?s.jsx(ot,{value:p?.normalized??{note:"Нет данных."}}):null,a==="fragments"?s.jsx(ot,{value:U}):null,a==="scope"?s.jsx(ot,{value:z}):null,a==="flags"?s.jsx(ot,{value:ee}):null,a==="route"?s.jsx(ot,{value:p?.route_hint_summary??{note:"Нет данных."}}):null,a==="raw"?s.jsx(ot,{value:p?.raw_model_output??{note:"Нет данных."}}):null,a==="validation"?s.jsx(ot,{value:p?.validation??{note:"Нет данных."}}):null,a==="logs"?s.jsx(ot,{value:O}):null]})}function fc({value:a,onChange:m,presets:p,selectedPresetId:O,onSelectPreset:P,onLoadPreset:F,onSavePreset:Q,onResetDefaults:Z,onDiffPrevious:U,presetName:z,onPresetNameChange:ee,diffSummary:C}){return s.jsxs(ln,{title:"Prompt Manager",subtitle:"Системный, developer и domain уровни управляются отдельно.",children:[s.jsxs("div",{className:"prompt-manager-grid",children:[s.jsxs("label",{children:["Системный prompt",s.jsx("textarea",{value:a.systemPrompt,onChange:H=>m({...a,systemPrompt:H.target.value}),rows:6})]}),s.jsxs("label",{children:["Developer / Instruction prompt",s.jsx("textarea",{value:a.developerPrompt,onChange:H=>m({...a,developerPrompt:H.target.value}),rows:6})]}),s.jsxs("label",{children:["Domain prompt",s.jsx("textarea",{value:a.domainPrompt,onChange:H=>m({...a,domainPrompt:H.target.value}),rows:6})]}),s.jsxs("label",{children:["Schema notes",s.jsx("textarea",{value:a.schemaNotes,onChange:H=>m({...a,schemaNotes:H.target.value}),rows:6})]}),s.jsxs("label",{className:"full-width",children:["Few-shot examples",s.jsx("textarea",{value:a.fewShotExamples,onChange:H=>m({...a,fewShotExamples:H.target.value}),rows:8})]})]}),s.jsxs("div",{className:"button-row",children:[s.jsxs("select",{value:O,onChange:H=>P(H.target.value),children:[s.jsx("option",{value:"",children:"Выберите preset..."}),p.map(H=>s.jsx("option",{value:H.id,children:H.name},H.id))]}),s.jsx("button",{type:"button",onClick:()=>F(),children:"Загрузить preset"}),s.jsx("input",{value:z,onChange:H=>ee(H.target.value),placeholder:"Имя для сохранения"}),s.jsx("button",{type:"button",onClick:()=>Q(),children:"Сохранить preset"}),s.jsx("button",{type:"button",onClick:()=>U(),children:"Diff с предыдущим"}),s.jsx("button",{type:"button",onClick:()=>Z(),children:"Сбросить к default"})]}),C?s.jsx("p",{className:"diff-summary",children:C}):null]})}function Uf({value:a,onChange:m,onApplyBatchFormat:p,onNormalize:O,busy:P,useMock:F,onUseMockChange:Q,errorMessage:Z}){return s.jsxs(ln,{title:"Запрос пользователя",subtitle:"NDC semantic front-end: нормализуем, но не отвечаем за бухгалтерскую суть.",children:[s.jsxs("div",{className:"grid-two",children:[s.jsxs("label",{className:"full-width",children:["Raw user question",s.jsx("textarea",{value:a.userQuestion,onChange:U=>m({...a,userQuestion:U.target.value}),rows:6,placeholder:"Например: По каким покупателям у нас на конец июня висят отгрузки без оплаты..."})]}),s.jsxs("label",{className:"full-width",children:["Batch queries (`;` separator)",s.jsx("textarea",{value:a.batchQuestionsRaw,onChange:U=>m({...a,batchQuestionsRaw:U.target.value}),onBlur:()=>p(),rows:8,placeholder:"Вопрос 1; Вопрос 2; Вопрос 3"})]}),s.jsxs("label",{children:["Optional period context",s.jsx("input",{value:a.periodHint,onChange:U=>m({...a,periodHint:U.target.value})})]}),s.jsxs("label",{children:["Optional business context",s.jsx("input",{value:a.businessContext,onChange:U=>m({...a,businessContext:U.target.value})})]}),s.jsxs("label",{children:["Optional expected route (eval)",s.jsx("input",{value:a.expectedRoute,onChange:U=>m({...a,expectedRoute:U.target.value})})]})]}),s.jsxs("div",{className:"button-row",children:[s.jsxs("label",{className:"checkbox-row",children:[s.jsx("input",{type:"checkbox",checked:F,onChange:U=>Q(U.target.checked)}),"Mock-режим (без вызова OpenAI)"]}),s.jsx("button",{type:"button",onClick:()=>p(),disabled:P||!a.batchQuestionsRaw.trim(),children:"Применить `;` в переносы"}),s.jsx("button",{type:"button",onClick:()=>O(!1),disabled:P||!a.userQuestion.trim(),children:P?"Нормализуем...":"Normalize"}),s.jsx("button",{type:"button",onClick:()=>O(!0),disabled:P||!a.userQuestion.trim(),children:P?"Сохраняем...":"Normalize + Save as test case"})]}),Z?s.jsx("p",{className:"error-text",children:Z}):null]})}function $f({runs:a,selectedRunId:m,onSelectRun:p,onStartRun:O,onFinishRun:P,onRefreshRuns:F,onRunEval:Q,onCopyEvalReport:Z,evalBusy:U,traceItems:z,evalReport:ee}){return s.jsxs(ln,{title:"NDC Run Monitor",subtitle:"Важно: кнопка Запустить run создает только run-сущность. Кнопка eval запускает batch-проверку normalizer v2.0.2.",children:[s.jsxs("div",{className:"button-row",children:[s.jsx("button",{type:"button",onClick:()=>O(),children:"Запустить run"}),s.jsx("button",{type:"button",onClick:()=>P(),disabled:!m,children:"Завершить выбранный run"}),s.jsx("button",{type:"button",onClick:()=>F(),children:"Обновить runs"}),s.jsx("button",{type:"button",onClick:()=>Q(),disabled:U,children:U?"Идет eval v2.0.2...":"Запустить eval v2.0.2"})]}),s.jsxs("div",{className:"runtime-stack",children:[s.jsxs("div",{className:"runtime-runs",children:[a.map(C=>s.jsxs("button",{type:"button",className:m===C.runId?"history-item selected":"history-item",onClick:()=>p(C.runId),children:[s.jsxs("div",{className:"history-row",children:[s.jsx("strong",{children:C.status}),s.jsx("span",{children:C.runId})]}),s.jsxs("div",{className:"history-row",children:[s.jsx("span",{children:C.sessionId}),s.jsx("span",{children:new Date(C.updatedAt).toLocaleString("ru-RU")})]})]},C.runId)),a.length===0?s.jsx("p",{className:"muted",children:"Нет активных запусков."}):null]}),s.jsxs("div",{className:"runtime-details",children:[s.jsx("h3",{children:"Trace выбранного run"}),s.jsx(ot,{value:z}),s.jsxs("div",{className:"eval-report-wrap",children:[s.jsx("h3",{style:{marginTop:12},children:"Отчет eval"}),s.jsx(ot,{value:ee??{note:"Eval пока не запускался"}}),s.jsx("button",{type:"button",className:"copy-cube-button",title:"Скопировать отчет eval",onClick:()=>Z(),children:"⧉"})]})]})]})]})}const Bf={llmProvider:"openai",apiKey:"",model:"gpt-4o-mini",baseUrl:"https://api.openai.com/v1",temperature:0,maxOutputTokens:700},pc={systemPrompt:"Ты semantic-normalizer для бухгалтерского ассистента NDC. Возвращай только JSON по схеме normalized_query_v2_0_2.",developerPrompt:"Сначала делай decomposition сообщения на task fragments, затем определяй domain scope и route-critical flags. Для каждого fragment заполняй execution_readiness + route_status + no_route_reason. Если fragment routable, не оставляй его в no_route.",domainPrompt:"Контур: данные текущего предприятия в 1С/NDC. In-scope: документы, проводки, взаиморасчеты, остатки, периодное закрытие, аномалии и контрольные проверки. Out-of-scope: общая теория, законы и оффтоп.",schemaNotes:"schema_version: normalized_query_v2_0_2. Строгий JSON без дополнительных полей.",fewShotExamples:"Q: Проверь по поставщикам хвосты и разложи цепочку документов/оплат. => fragment in_scope, flags: multi_entity + chain_explanation. Q: Как вообще по ФСБУ? => out_of_scope/generic_accounting."},Hf={userQuestion:"",batchQuestionsRaw:"",periodHint:"",businessContext:"",expectedRoute:""},wi={colors:{backgroundRgb:"18, 18, 18",mainSurfaceRgb:"25, 25, 25",horizontalSurfaceRgb:"30, 30, 30",focusSurfaceRgb:"35, 35, 35",activeRgb:"167, 59, 255",activeTextRgb:"240, 240, 240",textMainRgb:"240, 240, 240",textMutedRgb:"166, 166, 166",dangerRgb:"126, 126, 126",scrollbarTrackRgb:"20, 20, 20",scrollbarThumbRgb:"30, 30, 30",scrollbarThumbHoverRgb:"30, 50, 30"},layout:{modeColumnWidthPx:440,modeToggleWidthPx:188}},mc="ndc_normalizer_session_config_v1",hc="ndc_autoruns_layout_config_v1",Vf="ndc-autoruns-save",ji=["Анализ запроса","Получение данных","Подготовка ответа"],Qf="assistant",ki="normalizer_v2_0_2",vc="address_query_runtime_v1",Wf=["normalized","fragments","scope","flags","route","raw","validation","logs"];function Kf(a){return`[${new Date().toLocaleTimeString("ru-RU")}] ${a}`}function Gf(a,m){if(!m)return"Previous preset is not selected.";const O=["systemPrompt","developerPrompt","domainPrompt","schemaNotes","fewShotExamples"].filter(P=>a[P]!==m[P]).map(P=>`${P}: ${Math.abs(a[P].length-m[P].length)} chars delta`);return O.length===0?"No changes against previous preset.":`Changed fields: ${O.length}. ${O.join(" | ")}`}function qf(){const[a,m]=j.useState(Bf),[p,O]=j.useState(pc),[P,F]=j.useState(Hf),[Q,Z]=j.useState(null),[U,z]=j.useState([]),[ee,C]=j.useState([]),[H,pe]=j.useState("normalized"),[Te,te]=j.useState(!1),[re,Se]=j.useState(!1),[me,Me]=j.useState([]),[Ne,Ae]=j.useState(""),[Fe,Ue]=j.useState([]),[Ke,st]=j.useState(""),[be,xe]=j.useState("NDC custom preset"),[it,Ee]=j.useState(null),[Ve,X]=j.useState(""),[he,ye]=j.useState(!1),[T,W]=j.useState([]),[M,h]=j.useState(""),[S,q]=j.useState([]),[b,ne]=j.useState(!1),[le,de]=j.useState(null),[ue,se]=j.useState(""),[ve,Et]=j.useState(Qf),[on,St]=j.useState(!0),[Kt,xn]=j.useState(!0),[at,ae]=j.useState(!0),[et,Gt]=j.useState(!0),[ut,Pt]=j.useState(!0),[ct,_e]=j.useState(!0),[qt,_n]=j.useState(!0),[sn,Pe]=j.useState(!0),[dt,Ot]=j.useState(!0),[Ge,Yt]=j.useState(!0),[At,mt]=j.useState(!0),[It,nr]=j.useState(!0),[wt,Sn]=j.useState(!0),[Jt,an]=j.useState(!0),[u,_]=j.useState(!0),[V,je]=j.useState(""),[Ft,Ut]=j.useState([]),[Xt,rr]=j.useState(""),[lr,Lr]=j.useState(!1),[wn,un]=j.useState(""),[jn,zr]=j.useState(""),Zt=j.useRef(!1),Vn=j.useRef(!1);j.useEffect(()=>{const y=document.documentElement,{colors:L}=wi;y.style.setProperty("--rgb-background",L.backgroundRgb),y.style.setProperty("--rgb-surface-main",L.mainSurfaceRgb),y.style.setProperty("--rgb-surface-horizontal",L.horizontalSurfaceRgb),y.style.setProperty("--rgb-surface-focus",L.focusSurfaceRgb),y.style.setProperty("--rgb-active",L.activeRgb),y.style.setProperty("--rgb-active-text",L.activeTextRgb),y.style.setProperty("--rgb-text-main",L.textMainRgb),y.style.setProperty("--rgb-text-muted",L.textMutedRgb),y.style.setProperty("--rgb-danger",L.dangerRgb),y.style.setProperty("--rgb-scrollbar-track",L.scrollbarTrackRgb),y.style.setProperty("--rgb-scrollbar-thumb",L.scrollbarThumbRgb),y.style.setProperty("--rgb-scrollbar-thumb-hover",L.scrollbarThumbHoverRgb),y.style.setProperty("--mode-column-width",`${wi.layout.modeColumnWidthPx}px`),y.style.setProperty("--mode-toggle-width",`${wi.layout.modeToggleWidthPx}px`)},[]);const Y=y=>{C(L=>[Kf(y),...L].slice(0,300))};function Dr(){let y=0;un(ji[0]);const L=window.setInterval(()=>{y=Math.min(y+1,ji.length-1),un(ji[y])},650);return()=>window.clearInterval(L)}j.useEffect(()=>{const y=localStorage.getItem(mc);if(y)try{const E=JSON.parse(y);m(ie=>({...ie,llmProvider:E.llmProvider==="local"?"local":"openai",model:E.model??ie.model,baseUrl:E.baseUrl??ie.baseUrl,temperature:E.temperature??ie.temperature,maxOutputTokens:E.maxOutputTokens??ie.maxOutputTokens}))}catch{}const L=localStorage.getItem(hc);if(L)try{const E=JSON.parse(L);(E.uiMode==="assistant"||E.uiMode==="decomposition"||E.uiMode==="autoruns")&&Et(E.uiMode),E.activeTab&&Wf.includes(E.activeTab)&&pe(E.activeTab),typeof E.showAutorunsAssistantMode=="boolean"&&St(E.showAutorunsAssistantMode),typeof E.showAutorunsDecompositionMode=="boolean"&&xn(E.showAutorunsDecompositionMode),typeof E.showAutorunsProgressMode=="boolean"&&ae(E.showAutorunsProgressMode),typeof E.showAutorunsCommentsMode=="boolean"&&Gt(E.showAutorunsCommentsMode),typeof E.showAssistantConnectionMode=="boolean"&&Pt(E.showAssistantConnectionMode),typeof E.showAssistantPromptMode=="boolean"&&_e(E.showAssistantPromptMode),typeof E.showAssistantChatMode=="boolean"&&_n(E.showAssistantChatMode),typeof E.showAssistantSamMode=="boolean"&&Pe(E.showAssistantSamMode),typeof E.showDecompositionConnectionMode=="boolean"&&Ot(E.showDecompositionConnectionMode),typeof E.showDecompositionPromptMode=="boolean"&&Yt(E.showDecompositionPromptMode),typeof E.showDecompositionQueryMode=="boolean"&&mt(E.showDecompositionQueryMode),typeof E.showDecompositionOutputMode=="boolean"&&nr(E.showDecompositionOutputMode),typeof E.showDecompositionMetricsMode=="boolean"&&Sn(E.showDecompositionMetricsMode),typeof E.showDecompositionHistoryMode=="boolean"&&an(E.showDecompositionHistoryMode),typeof E.showDecompositionRuntimeMode=="boolean"&&_(E.showDecompositionRuntimeMode),E.prompts&&(O(ie=>({...ie,...E.prompts})),Vn.current=!0)}catch{}or(),Sl(),sr()},[]);async function or(){try{const y=await Be.loadHistory();z(y.items??[])}catch(y){Y(`History load error: ${y instanceof Error?y.message:String(y)}`)}}async function Sl(){try{const L=(await Be.loadPresets()).presets??[];if(Ue(L),Vn.current){Zt.current=!0;return}if(Zt.current)return;const E=L.find(ie=>ie.prompt_version===ki)??L.find(ie=>ie.id==="default-normalizer-v2_0_2");if(!E){Zt.current=!0,Y(`Preset autoload skipped: ${ki} not found.`);return}st(E.id),Ee(p),O({systemPrompt:E.systemPrompt,developerPrompt:E.developerPrompt,domainPrompt:E.domainPrompt,schemaNotes:E.schemaNotes??"",fewShotExamples:E.fewShotExamples??""}),Zt.current=!0,Y(`Preset autoloaded: ${E.name} (${E.prompt_version}).`)}catch(y){Y(`Presets load error: ${y instanceof Error?y.message:String(y)}`)}}async function sr(){try{const y=await Be.listRuns();W(y.items??[])}catch(y){Y(`Runs load error: ${y instanceof Error?y.message:String(y)}`)}}function bt(){localStorage.setItem(mc,JSON.stringify({model:a.model,llmProvider:a.llmProvider,baseUrl:a.baseUrl,temperature:a.temperature,maxOutputTokens:a.maxOutputTokens})),Y("Local config saved (without API key).")}function wl(){localStorage.setItem(hc,JSON.stringify({uiMode:ve,activeTab:H,showAutorunsAssistantMode:on,showAutorunsDecompositionMode:Kt,showAutorunsProgressMode:at,showAutorunsCommentsMode:et,showAssistantConnectionMode:ut,showAssistantPromptMode:ct,showAssistantChatMode:qt,showAssistantSamMode:sn,showDecompositionConnectionMode:dt,showDecompositionPromptMode:Ge,showDecompositionQueryMode:At,showDecompositionOutputMode:It,showDecompositionMetricsMode:wt,showDecompositionHistoryMode:Jt,showDecompositionRuntimeMode:u,prompts:p})),window.dispatchEvent(new CustomEvent(Vf)),Y("UI layout and prompts saved.")}async function Or(){te(!0),se("");try{const y=await Be.testConnection(a);y.provider==="local"?y.model_found===!0?(Ae(`LOCAL OK - ${y.model}`),Y(`Local model is available: ${y.model} (catalog size=${y.models_count??"n/a"}).`)):y.model_found===!1?(Ae(`LOCAL OK, model not loaded - ${y.model}`),Y(`Local server is reachable, but model '${y.model}' is not in loaded catalog. Use 'Load model list' and select one of loaded models.`)):(Ae(`LOCAL OK (model list unavailable) - ${y.model}`),Y("Local server is reachable, but model catalog could not be verified.")):(Ae(`OPENAI OK - ${y.model}`),Y(`OpenAI connection ok: ${y.model}`))}catch(y){const L=y instanceof Error?y.message:String(y);Ae("Connection error"),se(`Test connection: ${L}`),Y(`Test connection error: ${L}`)}finally{te(!1)}}async function jl(){Se(!0);try{const L=(await Be.listModels(a)).models??[];Me(L),L.length>0&&m(E=>E.model&&L.includes(E.model)?E:{...E,model:L[0]}),Y(`Model catalog loaded (${a.llmProvider}): ${L.length} items.`)}catch(y){const L=y instanceof Error?y.message:String(y);Y(`Load model list error: ${L}`)}finally{Se(!1)}}j.useEffect(()=>{Me([])},[a.llmProvider,a.baseUrl]);async function kl(y){te(!0),se("");try{const L=await Be.normalize({connection:a,prompts:p,promptVersion:"normalizer_v2_0_2",query:{userQuestion:P.userQuestion,periodHint:P.periodHint,businessContext:P.businessContext,expectedRoute:P.expectedRoute},saveAsTestCase:y,useMock:he});Z(L),pe("normalized"),Y(`Normalize done: trace=${L.trace_id}, validation=${L.validation.passed?"passed":"failed"}`),or()}catch(L){const E=L instanceof Error?L.message:String(L);se(`Normalize: ${E}`),Y(`Normalize error: ${E}`)}finally{te(!1)}}function Ar(){const y=Fe.find(L=>L.id===Ke);if(!y){Y("Preset is not selected.");return}Ee(p),O({systemPrompt:y.systemPrompt,developerPrompt:y.developerPrompt,domainPrompt:y.domainPrompt,schemaNotes:y.schemaNotes??"",fewShotExamples:y.fewShotExamples??""}),Y(`Preset loaded: ${y.name}`)}async function Ir(){try{await Be.savePreset({name:be||"NDC preset",prompt_version:"normalizer_v2_0_2",systemPrompt:p.systemPrompt,developerPrompt:p.developerPrompt,domainPrompt:p.domainPrompt,schemaNotes:p.schemaNotes,fewShotExamples:p.fewShotExamples}),Y("Preset saved."),await Sl()}catch(y){Y(`Preset save error: ${y instanceof Error?y.message:String(y)}`)}}function Fr(){O(pc),Y("Prompt panel reset to defaults.")}function Cl(){const y=Gf(p,it);X(y),Y(y)}function Oo(){const y=P.batchQuestionsRaw.split(";").map(L=>L.trim()).filter(Boolean).join(` `);y&&(F(L=>({...L,batchQuestionsRaw:y})),Y("Batch field formatted: `;` converted to blank-line separators."))}async function Le(y){try{const E=(await Be.loadTrace(y)).trace,ie=E.parsed_normalized_json??null;Z({trace_id:String(E.trace_id??y),ok:!!E.validation_result?.passed,normalized:ie,route_hint_summary:E.route_hint_summary??(ie?{route_hint:ie.route_hint??null,confidence:ie.confidence?.route_hint??null}:null),raw_model_output:E.raw_model_response??{},validation:E.validation_result??{passed:!1,errors:["validation not found"]},usage:E.usage??{input_tokens:0,output_tokens:0,total_tokens:0},latency_ms:Number(E.latency_ms??0),prompt_version:String(E.prompt_version??"unknown"),schema_version:String(E.schema_version??"unknown")}),pe("raw"),se(""),Y(`Trace opened: ${y}`)}catch(L){const E=L instanceof Error?L.message:String(L);se(`Trace: ${E}`),Y(`Trace open error ${y}: ${E}`)}}async function Ao(){try{const y=await Be.startRun();h(y.run.runId),Y(`Run started: ${y.run.runId}`),Y("Tip: start run does not execute normalize by itself. Use 'Run eval v2.0.2' button."),await sr()}catch(y){Y(`Run start error: ${y instanceof Error?y.message:String(y)}`)}}async function Ur(){if(M)try{await Be.finishRun(M),Y(`Run finished: ${M}`),await sr()}catch(y){Y(`Run finish error: ${y instanceof Error?y.message:String(y)}`)}}async function Nl(){ne(!0),se("");try{Y("Starting eval in v2 contour.");const y=P.batchQuestionsRaw.trim()||P.userQuestion.trim();if(!y)throw new Error("Fill batch field or Raw user question first.");const L=await Be.runEval({connection:a,prompts:p,promptVersion:"normalizer_v2_0_2",mode:"single-pass-strict",rawQuestions:y,useMock:he});de(L.report),Y("Eval v2.0.2 run finished.");const E=L.report;if(E.run_id&&Y(`Eval run id: ${E.run_id}`),E.metrics){const ie=E.metrics;Y(`Eval metrics v2.0.2: schema=${ie.schema_validation_pass_rate??"n/a"}%, route_accuracy=${ie.route_resolution_accuracy??"n/a"}%, no_route_precision=${ie.no_route_precision??"n/a"}%, state_consistency=${ie.execution_state_consistency_rate??"n/a"}%`)}await or()}catch(y){const L=y instanceof Error?y.message:String(y);L.includes("Legacy eval runner supports normalized_query_v1 only")?(de({status:"plan_only",prompt_version:"normalizer_v2",reason:"backend eval runner is still legacy-v1 only",plan_file:"reports/v2_pilot_eval_plan.md",next_steps:["run cheap mock sanity for schema/fragment/scope","run small real batch (10-15 messages, temperature=0)","run challenge-30 replay with v2 metrics"]}),Y("Backend is legacy-only for eval right now. Showing v2 pilot plan.")):(se(`Eval: ${L}`),Y(`Eval run error: ${L}`))}finally{ne(!1)}}async function ir(){try{const y=JSON.stringify(le??{},null,2);await navigator.clipboard.writeText(y),Y("Eval report copied to clipboard.")}catch(y){Y(`Eval report copy error: ${y instanceof Error?y.message:String(y)}`)}}function Io(){je(""),Ut([]),rr(""),un(""),zr(""),Y("Assistant session reset.")}async function El(){const y=Xt.trim();if(!y)return;Lr(!0),zr(""),rr(""),Ut(E=>[...E,{message_id:`local-${Date.now()}`,session_id:V||"pending",role:"user",text:y,reply_type:null,created_at:new Date().toISOString(),trace_id:null,debug:null}]);const L=Dr();try{const E=await Be.sendAssistantMessage({connection:a,prompts:p,userMessage:y,sessionId:V||void 0,promptVersion:vc,useMock:he});je(E.session_id),Ut(E.conversation),un("Ответ готов"),Y(`Assistant reply received: trace=${E.debug.trace_id}`)}catch(E){const ie=E instanceof Error?E.message:String(E);zr(ie),un("Ошибка ассистента"),Y(`Assistant error: ${ie}`)}finally{L(),Lr(!1)}}return j.useEffect(()=>{if(!M){q([]);return}Be.runTrace(M).then(y=>q(y.items)).catch(y=>Y(`Run trace error: ${y instanceof Error?y.message:String(y)}`))},[M]),s.jsxs("main",{className:`app-root ${ve==="assistant"||ve==="decomposition"||ve==="autoruns"?"app-root-autoruns":""}`,children:[s.jsxs("header",{className:"app-topbar",children:[s.jsxs("div",{className:"mode-switch-row",children:[s.jsx("button",{type:"button",className:ve==="assistant"?"tab active":"tab",onClick:()=>Et("assistant"),children:"Ассистент"}),s.jsx("button",{type:"button",className:ve==="decomposition"?"tab active":"tab",onClick:()=>Et("decomposition"),children:"Декомпозиция"}),s.jsx("button",{type:"button",className:ve==="autoruns"?"tab active":"tab",onClick:()=>Et("autoruns"),children:"История автопрогонов"}),s.jsx("button",{type:"button",className:"tab",onClick:wl,children:"Сохранить"})]}),ve==="assistant"?s.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[s.jsx("button",{type:"button",className:ut?"tab active":"tab",onClick:()=>Pt(y=>!y),children:"LLM Connector"}),s.jsx("button",{type:"button",className:ct?"tab active":"tab",onClick:()=>_e(y=>!y),children:"Prompt Manager"}),s.jsx("button",{type:"button",className:qt?"tab active":"tab",onClick:()=>_n(y=>!y),children:"Режим ассистента"}),s.jsx("button",{type:"button",className:sn?"tab active":"tab",onClick:()=>Pe(y=>!y),children:"SAM"})]}):ve==="decomposition"?s.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[s.jsx("button",{type:"button",className:dt?"tab active":"tab",onClick:()=>Ot(y=>!y),children:"LLM"}),s.jsx("button",{type:"button",className:Ge?"tab active":"tab",onClick:()=>Yt(y=>!y),children:"Prompt"}),s.jsx("button",{type:"button",className:At?"tab active":"tab",onClick:()=>mt(y=>!y),children:"Запрос"}),s.jsx("button",{type:"button",className:It?"tab active":"tab",onClick:()=>nr(y=>!y),children:"Выход"}),s.jsx("button",{type:"button",className:wt?"tab active":"tab",onClick:()=>Sn(y=>!y),children:"Метрики"}),s.jsx("button",{type:"button",className:Jt?"tab active":"tab",onClick:()=>an(y=>!y),children:"История"}),s.jsx("button",{type:"button",className:u?"tab active":"tab",onClick:()=>_(y=>!y),children:"NDC Run Monitor"})]}):ve==="autoruns"?s.jsxs("div",{className:"mode-switch-row mode-switch-row-right",children:[s.jsx("button",{type:"button",className:on?"tab active":"tab",onClick:()=>St(y=>!y),children:"Режим ассистента"}),s.jsx("button",{type:"button",className:Kt?"tab active":"tab",onClick:()=>xn(y=>!y),children:"Режим декомпозиции"}),s.jsx("button",{type:"button",className:at?"tab active":"tab",onClick:()=>ae(y=>!y),children:"Прогресс/регресс"}),s.jsx("button",{type:"button",className:et?"tab active":"tab",onClick:()=>Gt(y=>!y),children:"Комментарии"})]}):null]}),ve==="assistant"?s.jsx("div",{className:"layout-grid layout-grid-mode-columns",children:s.jsxs("div",{className:"mode-columns",children:[ut?s.jsx("div",{className:"mode-col",children:s.jsx(dc,{value:a,modelOptions:me,modelsBusy:re,onChange:m,onReloadModels:jl,onSaveLocalConfig:bt,onTestConnection:Or,lastStatus:Ne,busy:Te||lr})}):null,ct?s.jsx("div",{className:"mode-col mode-col-wide",children:s.jsx(fc,{value:p,onChange:O,presets:Fe,selectedPresetId:Ke,onSelectPreset:st,onLoadPreset:Ar,onSavePreset:Ir,onResetDefaults:Fr,onDiffPrevious:Cl,presetName:be,onPresetNameChange:xe,diffSummary:Ve})}):null,qt?s.jsx("div",{className:"mode-col mode-col-xwide",children:s.jsx(zf,{sessionId:V,conversation:Ft,inputValue:Xt,onInputChange:rr,useMock:he,onUseMockChange:ye,onSend:El,onClear:Io,busy:lr,statusText:wn,errorMessage:jn})}):null,sn?s.jsx("div",{className:"mode-col",children:s.jsx(vf,{sessionId:V,conversation:Ft,statusText:wn,errorMessage:jn,useMock:he,appLogs:ee})}):null,!ut&&!ct&&!qt&&!sn?s.jsx("div",{className:"mode-columns-empty",children:"Все панели режима ассистента скрыты. Включите нужные блоки справа в шапке."}):null]})}):ve==="decomposition"?s.jsx("div",{className:"layout-grid layout-grid-mode-columns",children:s.jsxs("div",{className:"mode-columns",children:[dt?s.jsx("div",{className:"mode-col",children:s.jsx(dc,{value:a,modelOptions:me,modelsBusy:re,onChange:m,onReloadModels:jl,onSaveLocalConfig:bt,onTestConnection:Or,lastStatus:Ne,busy:Te})}):null,Ge?s.jsx("div",{className:"mode-col mode-col-wide",children:s.jsx(fc,{value:p,onChange:O,presets:Fe,selectedPresetId:Ke,onSelectPreset:st,onLoadPreset:Ar,onSavePreset:Ir,onResetDefaults:Fr,onDiffPrevious:Cl,presetName:be,onPresetNameChange:xe,diffSummary:Ve})}):null,At?s.jsx("div",{className:"mode-col",children:s.jsx(Uf,{value:P,onChange:F,onApplyBatchFormat:Oo,onNormalize:kl,busy:Te,useMock:he,onUseMockChange:ye,errorMessage:ue})}):null,It?s.jsx("div",{className:"mode-col mode-col-xwide",children:s.jsx(Ff,{tab:H,onTabChange:pe,result:Q,appLogs:ee})}):null,wt?s.jsx("div",{className:"mode-col",children:s.jsx(Of,{result:Q})}):null,Jt?s.jsx("div",{className:"mode-col",children:s.jsx(Df,{items:U,onRefresh:or,onOpenTrace:Le})}):null,u?s.jsx("div",{className:"mode-col mode-col-xwide",children:s.jsx($f,{runs:T,selectedRunId:M,onSelectRun:h,onStartRun:Ao,onFinishRun:Ur,onRefreshRuns:sr,onRunEval:Nl,onCopyEvalReport:ir,evalBusy:b,traceItems:S,evalReport:le})}):null,!dt&&!Ge&&!At&&!It&&!wt&&!Jt&&!u?s.jsx("div",{className:"mode-columns-empty",children:"Все панели режима декомпозиции скрыты. Включите нужные блоки справа в шапке."}):null]})}):s.jsx("div",{className:"layout-grid layout-grid-autoruns",children:s.jsx(kf,{connection:a,prompts:p,assistantPromptVersion:vc,decompositionPromptVersion:ki,showAssistantMode:on,showDecompositionMode:Kt,showProgressMode:at,showCommentsMode:et,onLog:Y})})]})}pf.createRoot(document.getElementById("root")).render(s.jsx(of.StrictMode,{children:s.jsx(qf,{})}));