claude-code-session-manager 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./TiptapBody-DyiZVN0v.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css","./TiptapBody-Py59G5JF.js"])))=>i.map(i=>d[i]);
2
2
  var rU=Object.defineProperty;var nU=(e,r,n)=>r in e?rU(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Gr=(e,r,n)=>nU(e,typeof r!="symbol"?r+"":r,n);import{_ as em}from"./monaco-editor-BW5C4Iv1.js";(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();var ax=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t1={exports:{}},qg={},r1={exports:{}},mr={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -38,7 +38,7 @@ var rU=Object.defineProperty;var nU=(e,r,n)=>r in e?rU(e,r,{enumerable:!0,config
38
38
  `+q[de].replace(" at new "," at ");return p.displayName&&Oe.includes("<anonymous>")&&(Oe=Oe.replace("<anonymous>",p.displayName)),Oe}while(1<=de&&0<=ke);break}}}finally{ce=!1,Error.prepareStackTrace=A}return(p=p?p.displayName||p.name:"")?ne(p):""}function _e(p){switch(p.tag){case 5:return ne(p.type);case 16:return ne("Lazy");case 13:return ne("Suspense");case 19:return ne("SuspenseList");case 0:case 2:case 15:return p=ge(p.type,!1),p;case 11:return p=ge(p.type.render,!1),p;case 1:return p=ge(p.type,!0),p;default:return""}}function Te(p){if(p==null)return null;if(typeof p=="function")return p.displayName||p.name||null;if(typeof p=="string")return p;switch(p){case N:return"Fragment";case $:return"Portal";case I:return"Profiler";case O:return"StrictMode";case U:return"Suspense";case D:return"SuspenseList"}if(typeof p=="object")switch(p.$$typeof){case H:return(p.displayName||"Context")+".Consumer";case W:return(p._context.displayName||"Context")+".Provider";case V:var v=p.render;return p=p.displayName,p||(p=v.displayName||v.name||"",p=p!==""?"ForwardRef("+p+")":"ForwardRef"),p;case G:return v=p.displayName||null,v!==null?v:Te(p.type)||"Memo";case ee:v=p._payload,p=p._init;try{return Te(p(v))}catch{}}return null}function ye(p){var v=p.type;switch(p.tag){case 24:return"Cache";case 9:return(v.displayName||"Context")+".Consumer";case 10:return(v._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return p=v.render,p=p.displayName||p.name||"",v.displayName||(p!==""?"ForwardRef("+p+")":"ForwardRef");case 7:return"Fragment";case 5:return v;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Te(v);case 8:return v===O?"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 v=="function")return v.displayName||v.name||null;if(typeof v=="string")return v}return null}function ie(p){switch(typeof p){case"boolean":case"number":case"string":case"undefined":return p;case"object":return p;default:return""}}function xe(p){var v=p.type;return(p=p.nodeName)&&p.toLowerCase()==="input"&&(v==="checkbox"||v==="radio")}function we(p){var v=xe(p)?"checked":"value",A=Object.getOwnPropertyDescriptor(p.constructor.prototype,v),M=""+p[v];if(!p.hasOwnProperty(v)&&typeof A<"u"&&typeof A.get=="function"&&typeof A.set=="function"){var q=A.get,Q=A.set;return Object.defineProperty(p,v,{configurable:!0,get:function(){return q.call(this)},set:function(de){M=""+de,Q.call(this,de)}}),Object.defineProperty(p,v,{enumerable:A.enumerable}),{getValue:function(){return M},setValue:function(de){M=""+de},stopTracking:function(){p._valueTracker=null,delete p[v]}}}}function Ve(p){p._valueTracker||(p._valueTracker=we(p))}function Me(p){if(!p)return!1;var v=p._valueTracker;if(!v)return!0;var A=v.getValue(),M="";return p&&(M=xe(p)?p.checked?"true":"false":p.value),p=M,p!==A?(v.setValue(p),!0):!1}function We(p){if(p=p||(typeof document<"u"?document:void 0),typeof p>"u")return null;try{return p.activeElement||p.body}catch{return p.body}}function Be(p,v){var A=v.checked;return X({},v,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:A??p._wrapperState.initialChecked})}function Ze(p,v){var A=v.defaultValue==null?"":v.defaultValue,M=v.checked!=null?v.checked:v.defaultChecked;A=ie(v.value!=null?v.value:A),p._wrapperState={initialChecked:M,initialValue:A,controlled:v.type==="checkbox"||v.type==="radio"?v.checked!=null:v.value!=null}}function dt(p,v){v=v.checked,v!=null&&C(p,"checked",v,!1)}function ut(p,v){dt(p,v);var A=ie(v.value),M=v.type;if(A!=null)M==="number"?(A===0&&p.value===""||p.value!=A)&&(p.value=""+A):p.value!==""+A&&(p.value=""+A);else if(M==="submit"||M==="reset"){p.removeAttribute("value");return}v.hasOwnProperty("value")?Xt(p,v.type,A):v.hasOwnProperty("defaultValue")&&Xt(p,v.type,ie(v.defaultValue)),v.checked==null&&v.defaultChecked!=null&&(p.defaultChecked=!!v.defaultChecked)}function or(p,v,A){if(v.hasOwnProperty("value")||v.hasOwnProperty("defaultValue")){var M=v.type;if(!(M!=="submit"&&M!=="reset"||v.value!==void 0&&v.value!==null))return;v=""+p._wrapperState.initialValue,A||v===p.value||(p.value=v),p.defaultValue=v}A=p.name,A!==""&&(p.name=""),p.defaultChecked=!!p._wrapperState.initialChecked,A!==""&&(p.name=A)}function Xt(p,v,A){(v!=="number"||We(p.ownerDocument)!==p)&&(A==null?p.defaultValue=""+p._wrapperState.initialValue:p.defaultValue!==""+A&&(p.defaultValue=""+A))}var ir=Array.isArray;function sr(p,v,A,M){if(p=p.options,v){v={};for(var q=0;q<A.length;q++)v["$"+A[q]]=!0;for(A=0;A<p.length;A++)q=v.hasOwnProperty("$"+p[A].value),p[A].selected!==q&&(p[A].selected=q),q&&M&&(p[A].defaultSelected=!0)}else{for(A=""+ie(A),v=null,q=0;q<p.length;q++){if(p[q].value===A){p[q].selected=!0,M&&(p[q].defaultSelected=!0);return}v!==null||p[q].disabled||(v=p[q])}v!==null&&(v.selected=!0)}}function Or(p,v){if(v.dangerouslySetInnerHTML!=null)throw Error(n(91));return X({},v,{value:void 0,defaultValue:void 0,children:""+p._wrapperState.initialValue})}function Ar(p,v){var A=v.value;if(A==null){if(A=v.children,v=v.defaultValue,A!=null){if(v!=null)throw Error(n(92));if(ir(A)){if(1<A.length)throw Error(n(93));A=A[0]}v=A}v==null&&(v=""),A=v}p._wrapperState={initialValue:ie(A)}}function en(p,v){var A=ie(v.value),M=ie(v.defaultValue);A!=null&&(A=""+A,A!==p.value&&(p.value=A),v.defaultValue==null&&p.defaultValue!==A&&(p.defaultValue=A)),M!=null&&(p.defaultValue=""+M)}function Ur(p){var v=p.textContent;v===p._wrapperState.initialValue&&v!==""&&v!==null&&(p.value=v)}function Ni(p){switch(p){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ui(p,v){return p==null||p==="http://www.w3.org/1999/xhtml"?Ni(v):p==="http://www.w3.org/2000/svg"&&v==="foreignObject"?"http://www.w3.org/1999/xhtml":p}var hr,Tn=(function(p){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(v,A,M,q){MSApp.execUnsafeLocalFunction(function(){return p(v,A,M,q)})}:p})(function(p,v){if(p.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in p)p.innerHTML=v;else{for(hr=hr||document.createElement("div"),hr.innerHTML="<svg>"+v.valueOf().toString()+"</svg>",v=hr.firstChild;p.firstChild;)p.removeChild(p.firstChild);for(;v.firstChild;)p.appendChild(v.firstChild)}});function lt(p,v){if(v){var A=p.firstChild;if(A&&A===p.lastChild&&A.nodeType===3){A.nodeValue=v;return}}p.textContent=v}var wt={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},bt=["Webkit","ms","Moz","O"];Object.keys(wt).forEach(function(p){bt.forEach(function(v){v=v+p.charAt(0).toUpperCase()+p.substring(1),wt[v]=wt[p]})});function br(p,v,A){return v==null||typeof v=="boolean"||v===""?"":A||typeof v!="number"||v===0||wt.hasOwnProperty(p)&&wt[p]?(""+v).trim():v+"px"}function mn(p,v){p=p.style;for(var A in v)if(v.hasOwnProperty(A)){var M=A.indexOf("--")===0,q=br(A,v[A],M);A==="float"&&(A="cssFloat"),M?p.setProperty(A,q):p[A]=q}}var Ki=X({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 ss(p,v){if(v){if(Ki[p]&&(v.children!=null||v.dangerouslySetInnerHTML!=null))throw Error(n(137,p));if(v.dangerouslySetInnerHTML!=null){if(v.children!=null)throw Error(n(60));if(typeof v.dangerouslySetInnerHTML!="object"||!("__html"in v.dangerouslySetInnerHTML))throw Error(n(61))}if(v.style!=null&&typeof v.style!="object")throw Error(n(62))}}function Er(p,v){if(p.indexOf("-")===-1)return typeof v.is=="string";switch(p){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 Xi=null;function di(p){return p=p.target||p.srcElement||window,p.correspondingUseElement&&(p=p.correspondingUseElement),p.nodeType===3?p.parentNode:p}var zn=null,Yn=null,fi=null;function xa(p){if(p=Fc(p)){if(typeof zn!="function")throw Error(n(280));var v=p.stateNode;v&&(v=Ju(v),zn(p.stateNode,p.type,v))}}function wa(p){Yn?fi?fi.push(p):fi=[p]:Yn=p}function _a(){if(Yn){var p=Yn,v=fi;if(fi=Yn=null,xa(p),v)for(p=0;p<v.length;p++)xa(v[p])}}function As(p,v){return p(v)}function Lo(){}var Oi=!1;function Sa(p,v,A){if(Oi)return p(v,A);Oi=!0;try{return As(p,v,A)}finally{Oi=!1,(Yn!==null||fi!==null)&&(Lo(),_a())}}function Pi(p,v){var A=p.stateNode;if(A===null)return null;var M=Ju(A);if(M===null)return null;A=M[v];e:switch(v){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(M=!M.disabled)||(p=p.type,M=!(p==="button"||p==="input"||p==="select"||p==="textarea")),p=!M;break e;default:p=!1}if(p)return null;if(A&&typeof A!="function")throw Error(n(231,v,typeof A));return A}var gr=!1;if(o)try{var Fn={};Object.defineProperty(Fn,"passive",{get:function(){gr=!0}}),window.addEventListener("test",Fn,Fn),window.removeEventListener("test",Fn,Fn)}catch{gr=!1}function Cl(p,v,A,M,q,Q,de,ke,Oe){var Ge=Array.prototype.slice.call(arguments,3);try{v.apply(A,Ge)}catch(ct){this.onError(ct)}}var $s=!1,Ns=null,as=!1,qt=null,hi={onError:function(p){$s=!0,Ns=p}};function vr(p,v,A,M,q,Q,de,ke,Oe){$s=!1,Ns=null,Cl.apply(hi,arguments)}function Jn(p,v,A,M,q,Q,de,ke,Oe){if(vr.apply(this,arguments),$s){if($s){var Ge=Ns;$s=!1,Ns=null}else throw Error(n(198));as||(as=!0,qt=Ge)}}function At(p){var v=p,A=p;if(p.alternate)for(;v.return;)v=v.return;else{p=v;do v=p,(v.flags&4098)!==0&&(A=v.return),p=v.return;while(p)}return v.tag===3?A:null}function Js(p){if(p.tag===13){var v=p.memoizedState;if(v===null&&(p=p.alternate,p!==null&&(v=p.memoizedState)),v!==null)return v.dehydrated}return null}function ka(p){if(At(p)!==p)throw Error(n(188))}function Bo(p){var v=p.alternate;if(!v){if(v=At(p),v===null)throw Error(n(188));return v!==p?null:p}for(var A=p,M=v;;){var q=A.return;if(q===null)break;var Q=q.alternate;if(Q===null){if(M=q.return,M!==null){A=M;continue}break}if(q.child===Q.child){for(Q=q.child;Q;){if(Q===A)return ka(q),p;if(Q===M)return ka(q),v;Q=Q.sibling}throw Error(n(188))}if(A.return!==M.return)A=q,M=Q;else{for(var de=!1,ke=q.child;ke;){if(ke===A){de=!0,A=q,M=Q;break}if(ke===M){de=!0,M=q,A=Q;break}ke=ke.sibling}if(!de){for(ke=Q.child;ke;){if(ke===A){de=!0,A=Q,M=q;break}if(ke===M){de=!0,M=Q,A=q;break}ke=ke.sibling}if(!de)throw Error(n(189))}}if(A.alternate!==M)throw Error(n(190))}if(A.tag!==3)throw Error(n(188));return A.stateNode.current===A?p:v}function os(p){return p=Bo(p),p!==null?Qs(p):null}function Qs(p){if(p.tag===5||p.tag===6)return p;for(p=p.child;p!==null;){var v=Qs(p);if(v!==null)return v;p=p.sibling}return null}var pi=r.unstable_scheduleCallback,An=r.unstable_cancelCallback,zo=r.unstable_shouldYield,El=r.unstable_requestPaint,qr=r.unstable_now,Qn=r.unstable_getCurrentPriorityLevel,gn=r.unstable_ImmediatePriority,dn=r.unstable_UserBlockingPriority,Et=r.unstable_NormalPriority,Se=r.unstable_LowPriority,rt=r.unstable_IdlePriority,_t=null,nr=null;function pt(p){if(nr&&typeof nr.onCommitFiberRoot=="function")try{nr.onCommitFiberRoot(_t,p,void 0,(p.current.flags&128)===128)}catch{}}var ar=Math.clz32?Math.clz32:qn,Yr=Math.log,Un=Math.LN2;function qn(p){return p>>>=0,p===0?32:31-(Yr(p)/Un|0)|0}var ls=64,jr=4194304;function cs(p){switch(p&-p){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 p&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return p&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return p}}function Os(p,v){var A=p.pendingLanes;if(A===0)return 0;var M=0,q=p.suspendedLanes,Q=p.pingedLanes,de=A&268435455;if(de!==0){var ke=de&~q;ke!==0?M=cs(ke):(Q&=de,Q!==0&&(M=cs(Q)))}else de=A&~q,de!==0?M=cs(de):Q!==0&&(M=cs(Q));if(M===0)return 0;if(v!==0&&v!==M&&(v&q)===0&&(q=M&-M,Q=v&-v,q>=Q||q===16&&(Q&4194240)!==0))return v;if((M&4)!==0&&(M|=A&16),v=p.entangledLanes,v!==0)for(p=p.entanglements,v&=M;0<v;)A=31-ar(v),q=1<<A,M|=p[A],v&=~q;return M}function lr(p,v){switch(p){case 1:case 2:case 4:return v+250;case 8:case 16:case 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 v+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function us(p,v){for(var A=p.suspendedLanes,M=p.pingedLanes,q=p.expirationTimes,Q=p.pendingLanes;0<Q;){var de=31-ar(Q),ke=1<<de,Oe=q[de];Oe===-1?((ke&A)===0||(ke&M)!==0)&&(q[de]=lr(ke,v)):Oe<=v&&(p.expiredLanes|=ke),Q&=~ke}}function Fo(p){return p=p.pendingLanes&-1073741825,p!==0?p:p&1073741824?1073741824:0}function Zs(){var p=ls;return ls<<=1,(ls&4194240)===0&&(ls=64),p}function Je(p){for(var v=[],A=0;31>A;A++)v.push(p);return v}function Ps(p,v,A){p.pendingLanes|=v,v!==536870912&&(p.suspendedLanes=0,p.pingedLanes=0),p=p.eventTimes,v=31-ar(v),p[v]=A}function Cc(p,v){var A=p.pendingLanes&~v;p.pendingLanes=v,p.suspendedLanes=0,p.pingedLanes=0,p.expiredLanes&=v,p.mutableReadLanes&=v,p.entangledLanes&=v,v=p.entanglements;var M=p.eventTimes;for(p=p.expirationTimes;0<A;){var q=31-ar(A),Q=1<<q;v[q]=0,M[q]=-1,p[q]=-1,A&=~Q}}function jl(p,v){var A=p.entangledLanes|=v;for(p=p.entanglements;A;){var M=31-ar(A),q=1<<M;q&v|p[M]&v&&(p[M]|=v),A&=~q}}var ur=0;function It(p){return p&=-p,1<p?4<p?(p&268435455)!==0?16:536870912:4:1}var ea,Ca,Ea,Za,Uo,eo=!1,Yi=[],Zn=null,ds=null,fs=null,ja=new Map,to=new Map,Rs=[],gf="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function ro(p,v){switch(p){case"focusin":case"focusout":Zn=null;break;case"dragenter":case"dragleave":ds=null;break;case"mouseover":case"mouseout":fs=null;break;case"pointerover":case"pointerout":ja.delete(v.pointerId);break;case"gotpointercapture":case"lostpointercapture":to.delete(v.pointerId)}}function no(p,v,A,M,q,Q){return p===null||p.nativeEvent!==Q?(p={blockedOn:v,domEventName:A,eventSystemFlags:M,nativeEvent:Q,targetContainers:[q]},v!==null&&(v=Fc(v),v!==null&&Ca(v)),p):(p.eventSystemFlags|=M,v=p.targetContainers,q!==null&&v.indexOf(q)===-1&&v.push(q),p)}function Mu(p,v,A,M,q){switch(v){case"focusin":return Zn=no(Zn,p,v,A,M,q),!0;case"dragenter":return ds=no(ds,p,v,A,M,q),!0;case"mouseover":return fs=no(fs,p,v,A,M,q),!0;case"pointerover":var Q=q.pointerId;return ja.set(Q,no(ja.get(Q)||null,p,v,A,M,q)),!0;case"gotpointercapture":return Q=q.pointerId,to.set(Q,no(to.get(Q)||null,p,v,A,M,q)),!0}return!1}function Ec(p){var v=Ho(p.target);if(v!==null){var A=At(v);if(A!==null){if(v=A.tag,v===13){if(v=Js(A),v!==null){p.blockedOn=v,Uo(p.priority,function(){Ea(A)});return}}else if(v===3&&A.stateNode.current.memoizedState.isDehydrated){p.blockedOn=A.tag===3?A.stateNode.containerInfo:null;return}}}p.blockedOn=null}function io(p){if(p.blockedOn!==null)return!1;for(var v=p.targetContainers;0<v.length;){var A=se(p.domEventName,p.eventSystemFlags,v[0],p.nativeEvent);if(A===null){A=p.nativeEvent;var M=new A.constructor(A.type,A);Xi=M,A.target.dispatchEvent(M),Xi=null}else return v=Fc(A),v!==null&&Ca(v),p.blockedOn=A,!1;v.shift()}return!0}function Tl(p,v,A){io(p)&&A.delete(v)}function jc(){eo=!1,Zn!==null&&io(Zn)&&(Zn=null),ds!==null&&io(ds)&&(ds=null),fs!==null&&io(fs)&&(fs=null),ja.forEach(Tl),to.forEach(Tl)}function ta(p,v){p.blockedOn===v&&(p.blockedOn=null,eo||(eo=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,jc)))}function Ta(p){function v(q){return ta(q,p)}if(0<Yi.length){ta(Yi[0],p);for(var A=1;A<Yi.length;A++){var M=Yi[A];M.blockedOn===p&&(M.blockedOn=null)}}for(Zn!==null&&ta(Zn,p),ds!==null&&ta(ds,p),fs!==null&&ta(fs,p),ja.forEach(v),to.forEach(v),A=0;A<Rs.length;A++)M=Rs[A],M.blockedOn===p&&(M.blockedOn=null);for(;0<Rs.length&&(A=Rs[0],A.blockedOn===null);)Ec(A),A.blockedOn===null&&Rs.shift()}var ra=T.ReactCurrentBatchConfig,so=!0;function Iu(p,v,A,M){var q=ur,Q=ra.transition;ra.transition=null;try{ur=1,Tc(p,v,A,M)}finally{ur=q,ra.transition=Q}}function Du(p,v,A,M){var q=ur,Q=ra.transition;ra.transition=null;try{ur=4,Tc(p,v,A,M)}finally{ur=q,ra.transition=Q}}function Tc(p,v,A,M){if(so){var q=se(p,v,A,M);if(q===null)$f(p,v,M,Ac,A),ro(p,M);else if(Mu(q,p,v,A,M))M.stopPropagation();else if(ro(p,M),v&4&&-1<gf.indexOf(p)){for(;q!==null;){var Q=Fc(q);if(Q!==null&&ea(Q),Q=se(p,v,A,M),Q===null&&$f(p,v,M,Ac,A),Q===q)break;q=Q}q!==null&&M.stopPropagation()}else $f(p,v,M,null,A)}}var Ac=null;function se(p,v,A,M){if(Ac=null,p=di(M),p=Ho(p),p!==null)if(v=At(p),v===null)p=null;else if(A=v.tag,A===13){if(p=Js(v),p!==null)return p;p=null}else if(A===3){if(v.stateNode.current.memoizedState.isDehydrated)return v.tag===3?v.stateNode.containerInfo:null;p=null}else v!==p&&(p=null);return Ac=p,null}function he(p){switch(p){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Qn()){case gn:return 1;case dn:return 4;case Et:case Se:return 16;case rt:return 536870912;default:return 16}default:return 16}}var be=null,Ne=null,Ee=null;function ze(){if(Ee)return Ee;var p,v=Ne,A=v.length,M,q="value"in be?be.value:be.textContent,Q=q.length;for(p=0;p<A&&v[p]===q[p];p++);var de=A-p;for(M=1;M<=de&&v[A-M]===q[Q-M];M++);return Ee=q.slice(p,1<M?1-M:void 0)}function Pe(p){var v=p.keyCode;return"charCode"in p?(p=p.charCode,p===0&&v===13&&(p=13)):p=v,p===10&&(p=13),32<=p||p===13?p:0}function Re(){return!0}function Ue(){return!1}function et(p){function v(A,M,q,Q,de){this._reactName=A,this._targetInst=q,this.type=M,this.nativeEvent=Q,this.target=de,this.currentTarget=null;for(var ke in p)p.hasOwnProperty(ke)&&(A=p[ke],this[ke]=A?A(Q):Q[ke]);return this.isDefaultPrevented=(Q.defaultPrevented!=null?Q.defaultPrevented:Q.returnValue===!1)?Re:Ue,this.isPropagationStopped=Ue,this}return X(v.prototype,{preventDefault:function(){this.defaultPrevented=!0;var A=this.nativeEvent;A&&(A.preventDefault?A.preventDefault():typeof A.returnValue!="unknown"&&(A.returnValue=!1),this.isDefaultPrevented=Re)},stopPropagation:function(){var A=this.nativeEvent;A&&(A.stopPropagation?A.stopPropagation():typeof A.cancelBubble!="unknown"&&(A.cancelBubble=!0),this.isPropagationStopped=Re)},persist:function(){},isPersistent:Re}),v}var at={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(p){return p.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tt=et(at),Ye=X({},at,{view:0,detail:0}),$t=et(Ye),Le,ht,Pr,Qt=X({},Ye,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:cr,button:0,buttons:0,relatedTarget:function(p){return p.relatedTarget===void 0?p.fromElement===p.srcElement?p.toElement:p.fromElement:p.relatedTarget},movementX:function(p){return"movementX"in p?p.movementX:(p!==Pr&&(Pr&&p.type==="mousemove"?(Le=p.screenX-Pr.screenX,ht=p.screenY-Pr.screenY):ht=Le=0,Pr=p),Le)},movementY:function(p){return"movementY"in p?p.movementY:ht}}),Zt=et(Qt),Rr=X({},Qt,{dataTransfer:0}),Dt=et(Rr),Lr=X({},Ye,{relatedTarget:0}),fr=et(Lr),$n=X({},at,{animationName:0,elapsedTime:0,pseudoElement:0}),ei=et($n),mi=X({},at,{clipboardData:function(p){return"clipboardData"in p?p.clipboardData:window.clipboardData}}),Al=et(mi),gi=X({},at,{data:0}),$c=et(gi),Lu={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Nn={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Ms={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bu(p){var v=this.nativeEvent;return v.getModifierState?v.getModifierState(p):(p=Ms[p])?!!v[p]:!1}function cr(){return Bu}var hs=X({},Ye,{key:function(p){if(p.key){var v=Lu[p.key]||p.key;if(v!=="Unidentified")return v}return p.type==="keypress"?(p=Pe(p),p===13?"Enter":String.fromCharCode(p)):p.type==="keydown"||p.type==="keyup"?Nn[p.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:cr,charCode:function(p){return p.type==="keypress"?Pe(p):0},keyCode:function(p){return p.type==="keydown"||p.type==="keyup"?p.keyCode:0},which:function(p){return p.type==="keypress"?Pe(p):p.type==="keydown"||p.type==="keyup"?p.keyCode:0}}),vf=et(hs),na=X({},Qt,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),qo=et(na),vn=X({},Ye,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:cr}),vi=et(vn),Nc=X({},at,{propertyName:0,elapsedTime:0,pseudoElement:0}),yi=et(Nc),zu=X({},Qt,{deltaX:function(p){return"deltaX"in p?p.deltaX:"wheelDeltaX"in p?-p.wheelDeltaX:0},deltaY:function(p){return"deltaY"in p?p.deltaY:"wheelDeltaY"in p?-p.wheelDeltaY:"wheelDelta"in p?-p.wheelDelta:0},deltaZ:0,deltaMode:0}),yf=et(zu),ia=[9,13,27,32],ps=o&&"CompositionEvent"in window,Is=null;o&&"documentMode"in document&&(Is=document.documentMode);var yn=o&&"TextEvent"in window&&!Is,Jr=o&&(!ps||Is&&8<Is&&11>=Is),ms=" ",Fu=!1;function Uu(p,v){switch(p){case"keyup":return ia.indexOf(v.keyCode)!==-1;case"keydown":return v.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cb(p){return p=p.detail,typeof p=="object"&&"data"in p?p.data:null}var bi=!1;function ub(p,v){switch(p){case"compositionend":return cb(v);case"keypress":return v.which!==32?null:(Fu=!0,ms);case"textInput":return p=v.data,p===ms&&Fu?null:p;default:return null}}function bf(p,v){if(bi)return p==="compositionend"||!ps&&Uu(p,v)?(p=ze(),Ee=Ne=be=null,bi=!1,p):null;switch(p){case"paste":return null;case"keypress":if(!(v.ctrlKey||v.altKey||v.metaKey)||v.ctrlKey&&v.altKey){if(v.char&&1<v.char.length)return v.char;if(v.which)return String.fromCharCode(v.which)}return null;case"compositionend":return Jr&&v.locale!=="ko"?null:v.data;default:return null}}var um={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Ds(p){var v=p&&p.nodeName&&p.nodeName.toLowerCase();return v==="input"?!!um[p.type]:v==="textarea"}function dm(p,v,A,M){wa(M),v=Gu(v,"onChange"),0<v.length&&(A=new tt("onChange","change",null,A,M),p.push({event:A,listeners:v}))}var Oc=null,Pc=null;function db(p){jm(p,0)}function qu(p){var v=Ol(p);if(Me(v))return p}function fb(p,v){if(p==="change")return v}var fm=!1;if(o){var xf;if(o){var wf="oninput"in document;if(!wf){var hm=document.createElement("div");hm.setAttribute("oninput","return;"),wf=typeof hm.oninput=="function"}xf=wf}else xf=!1;fm=xf&&(!document.documentMode||9<document.documentMode)}function Ls(){Oc&&(Oc.detachEvent("onpropertychange",pm),Pc=Oc=null)}function pm(p){if(p.propertyName==="value"&&qu(Pc)){var v=[];dm(v,Pc,p,di(p)),Sa(db,v)}}function hb(p,v,A){p==="focusin"?(Ls(),Oc=v,Pc=A,Oc.attachEvent("onpropertychange",pm)):p==="focusout"&&Ls()}function pb(p){if(p==="selectionchange"||p==="keyup"||p==="keydown")return qu(Pc)}function mb(p,v){if(p==="click")return qu(v)}function gb(p,v){if(p==="input"||p==="change")return qu(v)}function vb(p,v){return p===v&&(p!==0||1/p===1/v)||p!==p&&v!==v}var Bs=typeof Object.is=="function"?Object.is:vb;function Rc(p,v){if(Bs(p,v))return!0;if(typeof p!="object"||p===null||typeof v!="object"||v===null)return!1;var A=Object.keys(p),M=Object.keys(v);if(A.length!==M.length)return!1;for(M=0;M<A.length;M++){var q=A[M];if(!u.call(v,q)||!Bs(p[q],v[q]))return!1}return!0}function mm(p){for(;p&&p.firstChild;)p=p.firstChild;return p}function gm(p,v){var A=mm(p);p=0;for(var M;A;){if(A.nodeType===3){if(M=p+A.textContent.length,p<=v&&M>=v)return{node:A,offset:v-p};p=M}e:{for(;A;){if(A.nextSibling){A=A.nextSibling;break e}A=A.parentNode}A=void 0}A=mm(A)}}function _f(p,v){return p&&v?p===v?!0:p&&p.nodeType===3?!1:v&&v.nodeType===3?_f(p,v.parentNode):"contains"in p?p.contains(v):p.compareDocumentPosition?!!(p.compareDocumentPosition(v)&16):!1:!1}function Sf(){for(var p=window,v=We();v instanceof p.HTMLIFrameElement;){try{var A=typeof v.contentWindow.location.href=="string"}catch{A=!1}if(A)p=v.contentWindow;else break;v=We(p.document)}return v}function kf(p){var v=p&&p.nodeName&&p.nodeName.toLowerCase();return v&&(v==="input"&&(p.type==="text"||p.type==="search"||p.type==="tel"||p.type==="url"||p.type==="password")||v==="textarea"||p.contentEditable==="true")}function yb(p){var v=Sf(),A=p.focusedElem,M=p.selectionRange;if(v!==A&&A&&A.ownerDocument&&_f(A.ownerDocument.documentElement,A)){if(M!==null&&kf(A)){if(v=M.start,p=M.end,p===void 0&&(p=v),"selectionStart"in A)A.selectionStart=v,A.selectionEnd=Math.min(p,A.value.length);else if(p=(v=A.ownerDocument||document)&&v.defaultView||window,p.getSelection){p=p.getSelection();var q=A.textContent.length,Q=Math.min(M.start,q);M=M.end===void 0?Q:Math.min(M.end,q),!p.extend&&Q>M&&(q=M,M=Q,Q=q),q=gm(A,Q);var de=gm(A,M);q&&de&&(p.rangeCount!==1||p.anchorNode!==q.node||p.anchorOffset!==q.offset||p.focusNode!==de.node||p.focusOffset!==de.offset)&&(v=v.createRange(),v.setStart(q.node,q.offset),p.removeAllRanges(),Q>M?(p.addRange(v),p.extend(de.node,de.offset)):(v.setEnd(de.node,de.offset),p.addRange(v)))}}for(v=[],p=A;p=p.parentNode;)p.nodeType===1&&v.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<v.length;A++)p=v[A],p.element.scrollLeft=p.left,p.element.scrollTop=p.top}}var vm=o&&"documentMode"in document&&11>=document.documentMode,Mc=null,Cf=null,Wo=null,Ef=!1;function ym(p,v,A){var M=A.window===A?A.document:A.nodeType===9?A:A.ownerDocument;Ef||Mc==null||Mc!==We(M)||(M=Mc,"selectionStart"in M&&kf(M)?M={start:M.selectionStart,end:M.selectionEnd}:(M=(M.ownerDocument&&M.ownerDocument.defaultView||window).getSelection(),M={anchorNode:M.anchorNode,anchorOffset:M.anchorOffset,focusNode:M.focusNode,focusOffset:M.focusOffset}),Wo&&Rc(Wo,M)||(Wo=M,M=Gu(Cf,"onSelect"),0<M.length&&(v=new tt("onSelect","select",null,v,A),p.push({event:v,listeners:M}),v.target=Mc)))}function Wu(p,v){var A={};return A[p.toLowerCase()]=v.toLowerCase(),A["Webkit"+p]="webkit"+v,A["Moz"+p]="moz"+v,A}var Aa={animationend:Wu("Animation","AnimationEnd"),animationiteration:Wu("Animation","AnimationIteration"),animationstart:Wu("Animation","AnimationStart"),transitionend:Wu("Transition","TransitionEnd")},jf={},bm={};o&&(bm=document.createElement("div").style,"AnimationEvent"in window||(delete Aa.animationend.animation,delete Aa.animationiteration.animation,delete Aa.animationstart.animation),"TransitionEvent"in window||delete Aa.transitionend.transition);function Ic(p){if(jf[p])return jf[p];if(!Aa[p])return p;var v=Aa[p],A;for(A in v)if(v.hasOwnProperty(A)&&A in bm)return jf[p]=v[A];return p}var xm=Ic("animationend"),wm=Ic("animationiteration"),_m=Ic("animationstart"),Sm=Ic("transitionend"),bb=new Map,km="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function ao(p,v){bb.set(p,v),a(v,[p])}for(var Tf=0;Tf<km.length;Tf++){var Cm=km[Tf],xb=Cm.toLowerCase(),xr=Cm[0].toUpperCase()+Cm.slice(1);ao(xb,"on"+xr)}ao(xm,"onAnimationEnd"),ao(wm,"onAnimationIteration"),ao(_m,"onAnimationStart"),ao("dblclick","onDoubleClick"),ao("focusin","onFocus"),ao("focusout","onBlur"),ao(Sm,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),a("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),a("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),a("onBeforeInput",["compositionend","keypress","textInput","paste"]),a("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),a("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),wb=new Set("cancel close invalid load scroll toggle".split(" ").concat(Dc));function Em(p,v,A){var M=p.type||"unknown-event";p.currentTarget=A,Jn(M,v,void 0,p),p.currentTarget=null}function jm(p,v){v=(v&4)!==0;for(var A=0;A<p.length;A++){var M=p[A],q=M.event;M=M.listeners;e:{var Q=void 0;if(v)for(var de=M.length-1;0<=de;de--){var ke=M[de],Oe=ke.instance,Ge=ke.currentTarget;if(ke=ke.listener,Oe!==Q&&q.isPropagationStopped())break e;Em(q,ke,Ge),Q=Oe}else for(de=0;de<M.length;de++){if(ke=M[de],Oe=ke.instance,Ge=ke.currentTarget,ke=ke.listener,Oe!==Q&&q.isPropagationStopped())break e;Em(q,ke,Ge),Q=Oe}}}if(as)throw p=qt,as=!1,qt=null,p}function Wr(p,v){var A=v[If];A===void 0&&(A=v[If]=new Set);var M=p+"__bubble";A.has(M)||(Tm(v,p,2,!1),A.add(M))}function Af(p,v,A){var M=0;v&&(M|=4),Tm(A,p,M,v)}var Hu="_reactListening"+Math.random().toString(36).slice(2);function Lc(p){if(!p[Hu]){p[Hu]=!0,i.forEach(function(A){A!=="selectionchange"&&(wb.has(A)||Af(A,!1,p),Af(A,!0,p))});var v=p.nodeType===9?p:p.ownerDocument;v===null||v[Hu]||(v[Hu]=!0,Af("selectionchange",!1,v))}}function Tm(p,v,A,M){switch(he(v)){case 1:var q=Iu;break;case 4:q=Du;break;default:q=Tc}A=q.bind(null,v,A,p),q=void 0,!gr||v!=="touchstart"&&v!=="touchmove"&&v!=="wheel"||(q=!0),M?q!==void 0?p.addEventListener(v,A,{capture:!0,passive:q}):p.addEventListener(v,A,!0):q!==void 0?p.addEventListener(v,A,{passive:q}):p.addEventListener(v,A,!1)}function $f(p,v,A,M,q){var Q=M;if((v&1)===0&&(v&2)===0&&M!==null)e:for(;;){if(M===null)return;var de=M.tag;if(de===3||de===4){var ke=M.stateNode.containerInfo;if(ke===q||ke.nodeType===8&&ke.parentNode===q)break;if(de===4)for(de=M.return;de!==null;){var Oe=de.tag;if((Oe===3||Oe===4)&&(Oe=de.stateNode.containerInfo,Oe===q||Oe.nodeType===8&&Oe.parentNode===q))return;de=de.return}for(;ke!==null;){if(de=Ho(ke),de===null)return;if(Oe=de.tag,Oe===5||Oe===6){M=Q=de;continue e}ke=ke.parentNode}}M=M.return}Sa(function(){var Ge=Q,ct=di(A),ft=[];e:{var ot=bb.get(p);if(ot!==void 0){var Ct=tt,Ot=p;switch(p){case"keypress":if(Pe(A)===0)break e;case"keydown":case"keyup":Ct=vf;break;case"focusin":Ot="focus",Ct=fr;break;case"focusout":Ot="blur",Ct=fr;break;case"beforeblur":case"afterblur":Ct=fr;break;case"click":if(A.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ct=Zt;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ct=Dt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ct=vi;break;case xm:case wm:case _m:Ct=ei;break;case Sm:Ct=yi;break;case"scroll":Ct=$t;break;case"wheel":Ct=yf;break;case"copy":case"cut":case"paste":Ct=Al;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ct=qo}var Pt=(v&4)!==0,zr=!Pt&&p==="scroll",qe=Pt?ot!==null?ot+"Capture":null:ot;Pt=[];for(var Ie=Ge,Ke;Ie!==null;){Ke=Ie;var gt=Ke.stateNode;if(Ke.tag===5&&gt!==null&&(Ke=gt,qe!==null&&(gt=Pi(Ie,qe),gt!=null&&Pt.push(Bc(Ie,gt,Ke)))),zr)break;Ie=Ie.return}0<Pt.length&&(ot=new Ct(ot,Ot,null,A,ct),ft.push({event:ot,listeners:Pt}))}}if((v&7)===0){e:{if(ot=p==="mouseover"||p==="pointerover",Ct=p==="mouseout"||p==="pointerout",ot&&A!==Xi&&(Ot=A.relatedTarget||A.fromElement)&&(Ho(Ot)||Ot[aa]))break e;if((Ct||ot)&&(ot=ct.window===ct?ct:(ot=ct.ownerDocument)?ot.defaultView||ot.parentWindow:window,Ct?(Ot=A.relatedTarget||A.toElement,Ct=Ge,Ot=Ot?Ho(Ot):null,Ot!==null&&(zr=At(Ot),Ot!==zr||Ot.tag!==5&&Ot.tag!==6)&&(Ot=null)):(Ct=null,Ot=Ge),Ct!==Ot)){if(Pt=Zt,gt="onMouseLeave",qe="onMouseEnter",Ie="mouse",(p==="pointerout"||p==="pointerover")&&(Pt=qo,gt="onPointerLeave",qe="onPointerEnter",Ie="pointer"),zr=Ct==null?ot:Ol(Ct),Ke=Ot==null?ot:Ol(Ot),ot=new Pt(gt,Ie+"leave",Ct,A,ct),ot.target=zr,ot.relatedTarget=Ke,gt=null,Ho(ct)===Ge&&(Pt=new Pt(qe,Ie+"enter",Ot,A,ct),Pt.target=Ke,Pt.relatedTarget=zr,gt=Pt),zr=gt,Ct&&Ot)t:{for(Pt=Ct,qe=Ot,Ie=0,Ke=Pt;Ke;Ke=$l(Ke))Ie++;for(Ke=0,gt=qe;gt;gt=$l(gt))Ke++;for(;0<Ie-Ke;)Pt=$l(Pt),Ie--;for(;0<Ke-Ie;)qe=$l(qe),Ke--;for(;Ie--;){if(Pt===qe||qe!==null&&Pt===qe.alternate)break t;Pt=$l(Pt),qe=$l(qe)}Pt=null}else Pt=null;Ct!==null&&Am(ft,ot,Ct,Pt,!1),Ot!==null&&zr!==null&&Am(ft,zr,Ot,Pt,!0)}}e:{if(ot=Ge?Ol(Ge):window,Ct=ot.nodeName&&ot.nodeName.toLowerCase(),Ct==="select"||Ct==="input"&&ot.type==="file")var Bt=fb;else if(Ds(ot))if(fm)Bt=gb;else{Bt=pb;var Yt=hb}else(Ct=ot.nodeName)&&Ct.toLowerCase()==="input"&&(ot.type==="checkbox"||ot.type==="radio")&&(Bt=mb);if(Bt&&(Bt=Bt(p,Ge))){dm(ft,Bt,A,ct);break e}Yt&&Yt(p,ot,Ge),p==="focusout"&&(Yt=ot._wrapperState)&&Yt.controlled&&ot.type==="number"&&Xt(ot,"number",ot.value)}switch(Yt=Ge?Ol(Ge):window,p){case"focusin":(Ds(Yt)||Yt.contentEditable==="true")&&(Mc=Yt,Cf=Ge,Wo=null);break;case"focusout":Wo=Cf=Mc=null;break;case"mousedown":Ef=!0;break;case"contextmenu":case"mouseup":case"dragend":Ef=!1,ym(ft,A,ct);break;case"selectionchange":if(vm)break;case"keydown":case"keyup":ym(ft,A,ct)}var Jt;if(ps)e:{switch(p){case"compositionstart":var tr="onCompositionStart";break e;case"compositionend":tr="onCompositionEnd";break e;case"compositionupdate":tr="onCompositionUpdate";break e}tr=void 0}else bi?Uu(p,A)&&(tr="onCompositionEnd"):p==="keydown"&&A.keyCode===229&&(tr="onCompositionStart");tr&&(Jr&&A.locale!=="ko"&&(bi||tr!=="onCompositionStart"?tr==="onCompositionEnd"&&bi&&(Jt=ze()):(be=ct,Ne="value"in be?be.value:be.textContent,bi=!0)),Yt=Gu(Ge,tr),0<Yt.length&&(tr=new $c(tr,p,null,A,ct),ft.push({event:tr,listeners:Yt}),Jt?tr.data=Jt:(Jt=cb(A),Jt!==null&&(tr.data=Jt)))),(Jt=yn?ub(p,A):bf(p,A))&&(Ge=Gu(Ge,"onBeforeInput"),0<Ge.length&&(ct=new $c("onBeforeInput","beforeinput",null,A,ct),ft.push({event:ct,listeners:Ge}),ct.data=Jt))}jm(ft,v)})}function Bc(p,v,A){return{instance:p,listener:v,currentTarget:A}}function Gu(p,v){for(var A=v+"Capture",M=[];p!==null;){var q=p,Q=q.stateNode;q.tag===5&&Q!==null&&(q=Q,Q=Pi(p,A),Q!=null&&M.unshift(Bc(p,Q,q)),Q=Pi(p,v),Q!=null&&M.push(Bc(p,Q,q))),p=p.return}return M}function $l(p){if(p===null)return null;do p=p.return;while(p&&p.tag!==5);return p||null}function Am(p,v,A,M,q){for(var Q=v._reactName,de=[];A!==null&&A!==M;){var ke=A,Oe=ke.alternate,Ge=ke.stateNode;if(Oe!==null&&Oe===M)break;ke.tag===5&&Ge!==null&&(ke=Ge,q?(Oe=Pi(A,Q),Oe!=null&&de.unshift(Bc(A,Oe,ke))):q||(Oe=Pi(A,Q),Oe!=null&&de.push(Bc(A,Oe,ke)))),A=A.return}de.length!==0&&p.push({event:v,listeners:de})}var Vu=/\r\n?/g,_b=/\u0000|\uFFFD/g;function Ku(p){return(typeof p=="string"?p:""+p).replace(Vu,`
39
39
  `).replace(_b,"")}function Xu(p,v,A){if(v=Ku(v),Ku(p)!==v&&A)throw Error(n(425))}function Yu(){}var Nf=null,Of=null;function Pf(p,v){return p==="textarea"||p==="noscript"||typeof v.children=="string"||typeof v.children=="number"||typeof v.dangerouslySetInnerHTML=="object"&&v.dangerouslySetInnerHTML!==null&&v.dangerouslySetInnerHTML.__html!=null}var Rf=typeof setTimeout=="function"?setTimeout:void 0,Sb=typeof clearTimeout=="function"?clearTimeout:void 0,$m=typeof Promise=="function"?Promise:void 0,kb=typeof queueMicrotask=="function"?queueMicrotask:typeof $m<"u"?function(p){return $m.resolve(null).then(p).catch(Cb)}:Rf;function Cb(p){setTimeout(function(){throw p})}function Mf(p,v){var A=v,M=0;do{var q=A.nextSibling;if(p.removeChild(A),q&&q.nodeType===8)if(A=q.data,A==="/$"){if(M===0){p.removeChild(q),Ta(v);return}M--}else A!=="$"&&A!=="$?"&&A!=="$!"||M++;A=q}while(A);Ta(v)}function oo(p){for(;p!=null;p=p.nextSibling){var v=p.nodeType;if(v===1||v===3)break;if(v===8){if(v=p.data,v==="$"||v==="$!"||v==="$?")break;if(v==="/$")return null}}return p}function Nm(p){p=p.previousSibling;for(var v=0;p;){if(p.nodeType===8){var A=p.data;if(A==="$"||A==="$!"||A==="$?"){if(v===0)return p;v--}else A==="/$"&&v++}p=p.previousSibling}return null}var Nl=Math.random().toString(36).slice(2),sa="__reactFiber$"+Nl,zc="__reactProps$"+Nl,aa="__reactContainer$"+Nl,If="__reactEvents$"+Nl,Om="__reactListeners$"+Nl,Pm="__reactHandles$"+Nl;function Ho(p){var v=p[sa];if(v)return v;for(var A=p.parentNode;A;){if(v=A[aa]||A[sa]){if(A=v.alternate,v.child!==null||A!==null&&A.child!==null)for(p=Nm(p);p!==null;){if(A=p[sa])return A;p=Nm(p)}return v}p=A,A=p.parentNode}return null}function Fc(p){return p=p[sa]||p[aa],!p||p.tag!==5&&p.tag!==6&&p.tag!==13&&p.tag!==3?null:p}function Ol(p){if(p.tag===5||p.tag===6)return p.stateNode;throw Error(n(33))}function Ju(p){return p[zc]||null}var Df=[],Pl=-1;function $a(p){return{current:p}}function Hr(p){0>Pl||(p.current=Df[Pl],Df[Pl]=null,Pl--)}function Br(p,v){Pl++,Df[Pl]=p.current,p.current=v}var lo={},xi=$a(lo),Ri=$a(!1),Go=lo;function wi(p,v){var A=p.type.contextTypes;if(!A)return lo;var M=p.stateNode;if(M&&M.__reactInternalMemoizedUnmaskedChildContext===v)return M.__reactInternalMemoizedMaskedChildContext;var q={},Q;for(Q in A)q[Q]=v[Q];return M&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=v,p.__reactInternalMemoizedMaskedChildContext=q),q}function Mi(p){return p=p.childContextTypes,p!=null}function Qu(){Hr(Ri),Hr(xi)}function Rm(p,v,A){if(xi.current!==lo)throw Error(n(168));Br(xi,v),Br(Ri,A)}function Mm(p,v,A){var M=p.stateNode;if(v=v.childContextTypes,typeof M.getChildContext!="function")return A;M=M.getChildContext();for(var q in M)if(!(q in v))throw Error(n(108,ye(p)||"Unknown",q));return X({},A,M)}function Zu(p){return p=(p=p.stateNode)&&p.__reactInternalMemoizedMergedChildContext||lo,Go=xi.current,Br(xi,p),Br(Ri,Ri.current),!0}function Im(p,v,A){var M=p.stateNode;if(!M)throw Error(n(169));A?(p=Mm(p,v,Go),M.__reactInternalMemoizedMergedChildContext=p,Hr(Ri),Hr(xi),Br(xi,p)):Hr(Ri),Br(Ri,A)}var Na=null,ed=!1,Lf=!1;function Dm(p){Na===null?Na=[p]:Na.push(p)}function H_(p){ed=!0,Dm(p)}function co(){if(!Lf&&Na!==null){Lf=!0;var p=0,v=ur;try{var A=Na;for(ur=1;p<A.length;p++){var M=A[p];do M=M(!0);while(M!==null)}Na=null,ed=!1}catch(q){throw Na!==null&&(Na=Na.slice(p+1)),pi(gn,co),q}finally{ur=v,Lf=!1}}return null}var Rl=[],Ml=0,td=null,rd=0,gs=[],zs=0,vs=null,Ii=1,Di="";function uo(p,v){Rl[Ml++]=rd,Rl[Ml++]=td,td=p,rd=v}function Vo(p,v,A){gs[zs++]=Ii,gs[zs++]=Di,gs[zs++]=vs,vs=p;var M=Ii;p=Di;var q=32-ar(M)-1;M&=~(1<<q),A+=1;var Q=32-ar(v)+q;if(30<Q){var de=q-q%5;Q=(M&(1<<de)-1).toString(32),M>>=de,q-=de,Ii=1<<32-ar(v)+q|A<<q|M,Di=Q+p}else Ii=1<<Q|A<<q|M,Di=p}function wn(p){p.return!==null&&(uo(p,1),Vo(p,1,0))}function Bf(p){for(;p===td;)td=Rl[--Ml],Rl[Ml]=null,rd=Rl[--Ml],Rl[Ml]=null;for(;p===vs;)vs=gs[--zs],gs[zs]=null,Di=gs[--zs],gs[zs]=null,Ii=gs[--zs],gs[zs]=null}var Li=null,Ji=null,tn=!1,Bi=null;function zf(p,v){var A=Zi(5,null,null,0);A.elementType="DELETED",A.stateNode=v,A.return=p,v=p.deletions,v===null?(p.deletions=[A],p.flags|=16):v.push(A)}function Ff(p,v){switch(p.tag){case 5:var A=p.type;return v=v.nodeType!==1||A.toLowerCase()!==v.nodeName.toLowerCase()?null:v,v!==null?(p.stateNode=v,Li=p,Ji=oo(v.firstChild),!0):!1;case 6:return v=p.pendingProps===""||v.nodeType!==3?null:v,v!==null?(p.stateNode=v,Li=p,Ji=null,!0):!1;case 13:return v=v.nodeType!==8?null:v,v!==null?(A=vs!==null?{id:Ii,overflow:Di}:null,p.memoizedState={dehydrated:v,treeContext:A,retryLane:1073741824},A=Zi(18,null,null,0),A.stateNode=v,A.return=p,p.child=A,Li=p,Ji=null,!0):!1;default:return!1}}function Uf(p){return(p.mode&1)!==0&&(p.flags&128)===0}function qf(p){if(tn){var v=Ji;if(v){var A=v;if(!Ff(p,v)){if(Uf(p))throw Error(n(418));v=oo(A.nextSibling);var M=Li;v&&Ff(p,v)?zf(M,A):(p.flags=p.flags&-4097|2,tn=!1,Li=p)}}else{if(Uf(p))throw Error(n(418));p.flags=p.flags&-4097|2,tn=!1,Li=p}}}function Wf(p){for(p=p.return;p!==null&&p.tag!==5&&p.tag!==3&&p.tag!==13;)p=p.return;Li=p}function Uc(p){if(p!==Li)return!1;if(!tn)return Wf(p),tn=!0,!1;var v;if((v=p.tag!==3)&&!(v=p.tag!==5)&&(v=p.type,v=v!=="head"&&v!=="body"&&!Pf(p.type,p.memoizedProps)),v&&(v=Ji)){if(Uf(p))throw Lm(),Error(n(418));for(;v;)zf(p,v),v=oo(v.nextSibling)}if(Wf(p),p.tag===13){if(p=p.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(n(317));e:{for(p=p.nextSibling,v=0;p;){if(p.nodeType===8){var A=p.data;if(A==="/$"){if(v===0){Ji=oo(p.nextSibling);break e}v--}else A!=="$"&&A!=="$!"&&A!=="$?"||v++}p=p.nextSibling}Ji=null}}else Ji=Li?oo(p.stateNode.nextSibling):null;return!0}function Lm(){for(var p=Ji;p;)p=oo(p.nextSibling)}function Ko(){Ji=Li=null,tn=!1}function Hf(p){Bi===null?Bi=[p]:Bi.push(p)}var Gf=T.ReactCurrentBatchConfig;function Il(p,v,A){if(p=A.ref,p!==null&&typeof p!="function"&&typeof p!="object"){if(A._owner){if(A=A._owner,A){if(A.tag!==1)throw Error(n(309));var M=A.stateNode}if(!M)throw Error(n(147,p));var q=M,Q=""+p;return v!==null&&v.ref!==null&&typeof v.ref=="function"&&v.ref._stringRef===Q?v.ref:(v=function(de){var ke=q.refs;de===null?delete ke[Q]:ke[Q]=de},v._stringRef=Q,v)}if(typeof p!="string")throw Error(n(284));if(!A._owner)throw Error(n(290,p))}return p}function nd(p,v){throw p=Object.prototype.toString.call(v),Error(n(31,p==="[object Object]"?"object with keys {"+Object.keys(v).join(", ")+"}":p))}function Bm(p){var v=p._init;return v(p._payload)}function Eb(p){function v(qe,Ie){if(p){var Ke=qe.deletions;Ke===null?(qe.deletions=[Ie],qe.flags|=16):Ke.push(Ie)}}function A(qe,Ie){if(!p)return null;for(;Ie!==null;)v(qe,Ie),Ie=Ie.sibling;return null}function M(qe,Ie){for(qe=new Map;Ie!==null;)Ie.key!==null?qe.set(Ie.key,Ie):qe.set(Ie.index,Ie),Ie=Ie.sibling;return qe}function q(qe,Ie){return qe=bo(qe,Ie),qe.index=0,qe.sibling=null,qe}function Q(qe,Ie,Ke){return qe.index=Ke,p?(Ke=qe.alternate,Ke!==null?(Ke=Ke.index,Ke<Ie?(qe.flags|=2,Ie):Ke):(qe.flags|=2,Ie)):(qe.flags|=1048576,Ie)}function de(qe){return p&&qe.alternate===null&&(qe.flags|=2),qe}function ke(qe,Ie,Ke,gt){return Ie===null||Ie.tag!==6?(Ie=qh(Ke,qe.mode,gt),Ie.return=qe,Ie):(Ie=q(Ie,Ke),Ie.return=qe,Ie)}function Oe(qe,Ie,Ke,gt){var Bt=Ke.type;return Bt===N?ct(qe,Ie,Ke.props.children,gt,Ke.key):Ie!==null&&(Ie.elementType===Bt||typeof Bt=="object"&&Bt!==null&&Bt.$$typeof===ee&&Bm(Bt)===Ie.type)?(gt=q(Ie,Ke.props),gt.ref=Il(qe,Ie,Ke),gt.return=qe,gt):(gt=Cd(Ke.type,Ke.key,Ke.props,null,qe.mode,gt),gt.ref=Il(qe,Ie,Ke),gt.return=qe,gt)}function Ge(qe,Ie,Ke,gt){return Ie===null||Ie.tag!==4||Ie.stateNode.containerInfo!==Ke.containerInfo||Ie.stateNode.implementation!==Ke.implementation?(Ie=Wh(Ke,qe.mode,gt),Ie.return=qe,Ie):(Ie=q(Ie,Ke.children||[]),Ie.return=qe,Ie)}function ct(qe,Ie,Ke,gt,Bt){return Ie===null||Ie.tag!==7?(Ie=Gl(Ke,qe.mode,gt,Bt),Ie.return=qe,Ie):(Ie=q(Ie,Ke),Ie.return=qe,Ie)}function ft(qe,Ie,Ke){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number")return Ie=qh(""+Ie,qe.mode,Ke),Ie.return=qe,Ie;if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case E:return Ke=Cd(Ie.type,Ie.key,Ie.props,null,qe.mode,Ke),Ke.ref=Il(qe,null,Ie),Ke.return=qe,Ke;case $:return Ie=Wh(Ie,qe.mode,Ke),Ie.return=qe,Ie;case ee:var gt=Ie._init;return ft(qe,gt(Ie._payload),Ke)}if(ir(Ie)||J(Ie))return Ie=Gl(Ie,qe.mode,Ke,null),Ie.return=qe,Ie;nd(qe,Ie)}return null}function ot(qe,Ie,Ke,gt){var Bt=Ie!==null?Ie.key:null;if(typeof Ke=="string"&&Ke!==""||typeof Ke=="number")return Bt!==null?null:ke(qe,Ie,""+Ke,gt);if(typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case E:return Ke.key===Bt?Oe(qe,Ie,Ke,gt):null;case $:return Ke.key===Bt?Ge(qe,Ie,Ke,gt):null;case ee:return Bt=Ke._init,ot(qe,Ie,Bt(Ke._payload),gt)}if(ir(Ke)||J(Ke))return Bt!==null?null:ct(qe,Ie,Ke,gt,null);nd(qe,Ke)}return null}function Ct(qe,Ie,Ke,gt,Bt){if(typeof gt=="string"&&gt!==""||typeof gt=="number")return qe=qe.get(Ke)||null,ke(Ie,qe,""+gt,Bt);if(typeof gt=="object"&&gt!==null){switch(gt.$$typeof){case E:return qe=qe.get(gt.key===null?Ke:gt.key)||null,Oe(Ie,qe,gt,Bt);case $:return qe=qe.get(gt.key===null?Ke:gt.key)||null,Ge(Ie,qe,gt,Bt);case ee:var Yt=gt._init;return Ct(qe,Ie,Ke,Yt(gt._payload),Bt)}if(ir(gt)||J(gt))return qe=qe.get(Ke)||null,ct(Ie,qe,gt,Bt,null);nd(Ie,gt)}return null}function Ot(qe,Ie,Ke,gt){for(var Bt=null,Yt=null,Jt=Ie,tr=Ie=0,Rn=null;Jt!==null&&tr<Ke.length;tr++){Jt.index>tr?(Rn=Jt,Jt=null):Rn=Jt.sibling;var kr=ot(qe,Jt,Ke[tr],gt);if(kr===null){Jt===null&&(Jt=Rn);break}p&&Jt&&kr.alternate===null&&v(qe,Jt),Ie=Q(kr,Ie,tr),Yt===null?Bt=kr:Yt.sibling=kr,Yt=kr,Jt=Rn}if(tr===Ke.length)return A(qe,Jt),tn&&uo(qe,tr),Bt;if(Jt===null){for(;tr<Ke.length;tr++)Jt=ft(qe,Ke[tr],gt),Jt!==null&&(Ie=Q(Jt,Ie,tr),Yt===null?Bt=Jt:Yt.sibling=Jt,Yt=Jt);return tn&&uo(qe,tr),Bt}for(Jt=M(qe,Jt);tr<Ke.length;tr++)Rn=Ct(Jt,qe,tr,Ke[tr],gt),Rn!==null&&(p&&Rn.alternate!==null&&Jt.delete(Rn.key===null?tr:Rn.key),Ie=Q(Rn,Ie,tr),Yt===null?Bt=Rn:Yt.sibling=Rn,Yt=Rn);return p&&Jt.forEach(function(Ia){return v(qe,Ia)}),tn&&uo(qe,tr),Bt}function Pt(qe,Ie,Ke,gt){var Bt=J(Ke);if(typeof Bt!="function")throw Error(n(150));if(Ke=Bt.call(Ke),Ke==null)throw Error(n(151));for(var Yt=Bt=null,Jt=Ie,tr=Ie=0,Rn=null,kr=Ke.next();Jt!==null&&!kr.done;tr++,kr=Ke.next()){Jt.index>tr?(Rn=Jt,Jt=null):Rn=Jt.sibling;var Ia=ot(qe,Jt,kr.value,gt);if(Ia===null){Jt===null&&(Jt=Rn);break}p&&Jt&&Ia.alternate===null&&v(qe,Jt),Ie=Q(Ia,Ie,tr),Yt===null?Bt=Ia:Yt.sibling=Ia,Yt=Ia,Jt=Rn}if(kr.done)return A(qe,Jt),tn&&uo(qe,tr),Bt;if(Jt===null){for(;!kr.done;tr++,kr=Ke.next())kr=ft(qe,kr.value,gt),kr!==null&&(Ie=Q(kr,Ie,tr),Yt===null?Bt=kr:Yt.sibling=kr,Yt=kr);return tn&&uo(qe,tr),Bt}for(Jt=M(qe,Jt);!kr.done;tr++,kr=Ke.next())kr=Ct(Jt,qe,tr,kr.value,gt),kr!==null&&(p&&kr.alternate!==null&&Jt.delete(kr.key===null?tr:kr.key),Ie=Q(kr,Ie,tr),Yt===null?Bt=kr:Yt.sibling=kr,Yt=kr);return p&&Jt.forEach(function(sx){return v(qe,sx)}),tn&&uo(qe,tr),Bt}function zr(qe,Ie,Ke,gt){if(typeof Ke=="object"&&Ke!==null&&Ke.type===N&&Ke.key===null&&(Ke=Ke.props.children),typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case E:e:{for(var Bt=Ke.key,Yt=Ie;Yt!==null;){if(Yt.key===Bt){if(Bt=Ke.type,Bt===N){if(Yt.tag===7){A(qe,Yt.sibling),Ie=q(Yt,Ke.props.children),Ie.return=qe,qe=Ie;break e}}else if(Yt.elementType===Bt||typeof Bt=="object"&&Bt!==null&&Bt.$$typeof===ee&&Bm(Bt)===Yt.type){A(qe,Yt.sibling),Ie=q(Yt,Ke.props),Ie.ref=Il(qe,Yt,Ke),Ie.return=qe,qe=Ie;break e}A(qe,Yt);break}else v(qe,Yt);Yt=Yt.sibling}Ke.type===N?(Ie=Gl(Ke.props.children,qe.mode,gt,Ke.key),Ie.return=qe,qe=Ie):(gt=Cd(Ke.type,Ke.key,Ke.props,null,qe.mode,gt),gt.ref=Il(qe,Ie,Ke),gt.return=qe,qe=gt)}return de(qe);case $:e:{for(Yt=Ke.key;Ie!==null;){if(Ie.key===Yt)if(Ie.tag===4&&Ie.stateNode.containerInfo===Ke.containerInfo&&Ie.stateNode.implementation===Ke.implementation){A(qe,Ie.sibling),Ie=q(Ie,Ke.children||[]),Ie.return=qe,qe=Ie;break e}else{A(qe,Ie);break}else v(qe,Ie);Ie=Ie.sibling}Ie=Wh(Ke,qe.mode,gt),Ie.return=qe,qe=Ie}return de(qe);case ee:return Yt=Ke._init,zr(qe,Ie,Yt(Ke._payload),gt)}if(ir(Ke))return Ot(qe,Ie,Ke,gt);if(J(Ke))return Pt(qe,Ie,Ke,gt);nd(qe,Ke)}return typeof Ke=="string"&&Ke!==""||typeof Ke=="number"?(Ke=""+Ke,Ie!==null&&Ie.tag===6?(A(qe,Ie.sibling),Ie=q(Ie,Ke),Ie.return=qe,qe=Ie):(A(qe,Ie),Ie=qh(Ke,qe.mode,gt),Ie.return=qe,qe=Ie),de(qe)):A(qe,Ie)}return zr}var Dl=Eb(!0),Vf=Eb(!1),Xo=$a(null),id=null,Yo=null,Kf=null;function Xf(){Kf=Yo=id=null}function Yf(p){var v=Xo.current;Hr(Xo),p._currentValue=v}function zm(p,v,A){for(;p!==null;){var M=p.alternate;if((p.childLanes&v)!==v?(p.childLanes|=v,M!==null&&(M.childLanes|=v)):M!==null&&(M.childLanes&v)!==v&&(M.childLanes|=v),p===A)break;p=p.return}}function Ll(p,v){id=p,Kf=Yo=null,p=p.dependencies,p!==null&&p.firstContext!==null&&((p.lanes&v)!==0&&(zi=!0),p.firstContext=null)}function ys(p){var v=p._currentValue;if(Kf!==p)if(p={context:p,memoizedValue:v,next:null},Yo===null){if(id===null)throw Error(n(308));Yo=p,id.dependencies={lanes:0,firstContext:p}}else Yo=Yo.next=p;return v}var Bl=null;function Jf(p){Bl===null?Bl=[p]:Bl.push(p)}function sd(p,v,A,M){var q=v.interleaved;return q===null?(A.next=A,Jf(v)):(A.next=q.next,q.next=A),v.interleaved=A,Oa(p,M)}function Oa(p,v){p.lanes|=v;var A=p.alternate;for(A!==null&&(A.lanes|=v),A=p,p=p.return;p!==null;)p.childLanes|=v,A=p.alternate,A!==null&&(A.childLanes|=v),A=p,p=p.return;return A.tag===3?A.stateNode:null}var oa=!1;function ad(p){p.updateQueue={baseState:p.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Qf(p,v){p=p.updateQueue,v.updateQueue===p&&(v.updateQueue={baseState:p.baseState,firstBaseUpdate:p.firstBaseUpdate,lastBaseUpdate:p.lastBaseUpdate,shared:p.shared,effects:p.effects})}function Pa(p,v){return{eventTime:p,lane:v,tag:0,payload:null,callback:null,next:null}}function fo(p,v,A){var M=p.updateQueue;if(M===null)return null;if(M=M.shared,(wr&2)!==0){var q=M.pending;return q===null?v.next=v:(v.next=q.next,q.next=v),M.pending=v,Oa(p,A)}return q=M.interleaved,q===null?(v.next=v,Jf(M)):(v.next=q.next,q.next=v),M.interleaved=v,Oa(p,A)}function qc(p,v,A){if(v=v.updateQueue,v!==null&&(v=v.shared,(A&4194240)!==0)){var M=v.lanes;M&=p.pendingLanes,A|=M,v.lanes=A,jl(p,A)}}function jb(p,v){var A=p.updateQueue,M=p.alternate;if(M!==null&&(M=M.updateQueue,A===M)){var q=null,Q=null;if(A=A.firstBaseUpdate,A!==null){do{var de={eventTime:A.eventTime,lane:A.lane,tag:A.tag,payload:A.payload,callback:A.callback,next:null};Q===null?q=Q=de:Q=Q.next=de,A=A.next}while(A!==null);Q===null?q=Q=v:Q=Q.next=v}else q=Q=v;A={baseState:M.baseState,firstBaseUpdate:q,lastBaseUpdate:Q,shared:M.shared,effects:M.effects},p.updateQueue=A;return}p=A.lastBaseUpdate,p===null?A.firstBaseUpdate=v:p.next=v,A.lastBaseUpdate=v}function od(p,v,A,M){var q=p.updateQueue;oa=!1;var Q=q.firstBaseUpdate,de=q.lastBaseUpdate,ke=q.shared.pending;if(ke!==null){q.shared.pending=null;var Oe=ke,Ge=Oe.next;Oe.next=null,de===null?Q=Ge:de.next=Ge,de=Oe;var ct=p.alternate;ct!==null&&(ct=ct.updateQueue,ke=ct.lastBaseUpdate,ke!==de&&(ke===null?ct.firstBaseUpdate=Ge:ke.next=Ge,ct.lastBaseUpdate=Oe))}if(Q!==null){var ft=q.baseState;de=0,ct=Ge=Oe=null,ke=Q;do{var ot=ke.lane,Ct=ke.eventTime;if((M&ot)===ot){ct!==null&&(ct=ct.next={eventTime:Ct,lane:0,tag:ke.tag,payload:ke.payload,callback:ke.callback,next:null});e:{var Ot=p,Pt=ke;switch(ot=v,Ct=A,Pt.tag){case 1:if(Ot=Pt.payload,typeof Ot=="function"){ft=Ot.call(Ct,ft,ot);break e}ft=Ot;break e;case 3:Ot.flags=Ot.flags&-65537|128;case 0:if(Ot=Pt.payload,ot=typeof Ot=="function"?Ot.call(Ct,ft,ot):Ot,ot==null)break e;ft=X({},ft,ot);break e;case 2:oa=!0}}ke.callback!==null&&ke.lane!==0&&(p.flags|=64,ot=q.effects,ot===null?q.effects=[ke]:ot.push(ke))}else Ct={eventTime:Ct,lane:ot,tag:ke.tag,payload:ke.payload,callback:ke.callback,next:null},ct===null?(Ge=ct=Ct,Oe=ft):ct=ct.next=Ct,de|=ot;if(ke=ke.next,ke===null){if(ke=q.shared.pending,ke===null)break;ot=ke,ke=ot.next,ot.next=null,q.lastBaseUpdate=ot,q.shared.pending=null}}while(!0);if(ct===null&&(Oe=ft),q.baseState=Oe,q.firstBaseUpdate=Ge,q.lastBaseUpdate=ct,v=q.shared.interleaved,v!==null){q=v;do de|=q.lane,q=q.next;while(q!==v)}else Q===null&&(q.shared.lanes=0);rl|=de,p.lanes=de,p.memoizedState=ft}}function Tb(p,v,A){if(p=v.effects,v.effects=null,p!==null)for(v=0;v<p.length;v++){var M=p[v],q=M.callback;if(q!==null){if(M.callback=null,M=A,typeof q!="function")throw Error(n(191,q));q.call(M)}}}var Wc={},la=$a(Wc),Hc=$a(Wc),zl=$a(Wc);function Jo(p){if(p===Wc)throw Error(n(174));return p}function Zf(p,v){switch(Br(zl,v),Br(Hc,p),Br(la,Wc),p=v.nodeType,p){case 9:case 11:v=(v=v.documentElement)?v.namespaceURI:ui(null,"");break;default:p=p===8?v.parentNode:v,v=p.namespaceURI||null,p=p.tagName,v=ui(v,p)}Hr(la),Br(la,v)}function Qo(){Hr(la),Hr(Hc),Hr(zl)}function Fm(p){Jo(zl.current);var v=Jo(la.current),A=ui(v,p.type);v!==A&&(Br(Hc,p),Br(la,A))}function eh(p){Hc.current===p&&(Hr(la),Hr(Hc))}var sn=$a(0);function ld(p){for(var v=p;v!==null;){if(v.tag===13){var A=v.memoizedState;if(A!==null&&(A=A.dehydrated,A===null||A.data==="$?"||A.data==="$!"))return v}else if(v.tag===19&&v.memoizedProps.revealOrder!==void 0){if((v.flags&128)!==0)return v}else if(v.child!==null){v.child.return=v,v=v.child;continue}if(v===p)break;for(;v.sibling===null;){if(v.return===null||v.return===p)return null;v=v.return}v.sibling.return=v.return,v=v.sibling}return null}var th=[];function rh(){for(var p=0;p<th.length;p++)th[p]._workInProgressVersionPrimary=null;th.length=0}var nh=T.ReactCurrentDispatcher,ih=T.ReactCurrentBatchConfig,Zo=0,rn=null,_n=null,On=null,sh=!1,el=!1,ho=0,Um=0;function ti(){throw Error(n(321))}function ah(p,v){if(v===null)return!1;for(var A=0;A<v.length&&A<p.length;A++)if(!Bs(p[A],v[A]))return!1;return!0}function oh(p,v,A,M,q,Q){if(Zo=Q,rn=v,v.memoizedState=null,v.updateQueue=null,v.lanes=0,nh.current=p===null||p.memoizedState===null?Rb:Mb,p=A(M,q),el){Q=0;do{if(el=!1,ho=0,25<=Q)throw Error(n(301));Q+=1,On=_n=null,v.updateQueue=null,nh.current=V_,p=A(M,q)}while(el)}if(nh.current=fd,v=_n!==null&&_n.next!==null,Zo=0,On=_n=rn=null,sh=!1,v)throw Error(n(300));return p}function lh(){var p=ho!==0;return ho=0,p}function Fs(){var p={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return On===null?rn.memoizedState=On=p:On=On.next=p,On}function bs(){if(_n===null){var p=rn.alternate;p=p!==null?p.memoizedState:null}else p=_n.next;var v=On===null?rn.memoizedState:On.next;if(v!==null)On=v,_n=p;else{if(p===null)throw Error(n(310));_n=p,p={memoizedState:_n.memoizedState,baseState:_n.baseState,baseQueue:_n.baseQueue,queue:_n.queue,next:null},On===null?rn.memoizedState=On=p:On=On.next=p}return On}function Gc(p,v){return typeof v=="function"?v(p):v}function ch(p){var v=bs(),A=v.queue;if(A===null)throw Error(n(311));A.lastRenderedReducer=p;var M=_n,q=M.baseQueue,Q=A.pending;if(Q!==null){if(q!==null){var de=q.next;q.next=Q.next,Q.next=de}M.baseQueue=q=Q,A.pending=null}if(q!==null){Q=q.next,M=M.baseState;var ke=de=null,Oe=null,Ge=Q;do{var ct=Ge.lane;if((Zo&ct)===ct)Oe!==null&&(Oe=Oe.next={lane:0,action:Ge.action,hasEagerState:Ge.hasEagerState,eagerState:Ge.eagerState,next:null}),M=Ge.hasEagerState?Ge.eagerState:p(M,Ge.action);else{var ft={lane:ct,action:Ge.action,hasEagerState:Ge.hasEagerState,eagerState:Ge.eagerState,next:null};Oe===null?(ke=Oe=ft,de=M):Oe=Oe.next=ft,rn.lanes|=ct,rl|=ct}Ge=Ge.next}while(Ge!==null&&Ge!==Q);Oe===null?de=M:Oe.next=ke,Bs(M,v.memoizedState)||(zi=!0),v.memoizedState=M,v.baseState=de,v.baseQueue=Oe,A.lastRenderedState=M}if(p=A.interleaved,p!==null){q=p;do Q=q.lane,rn.lanes|=Q,rl|=Q,q=q.next;while(q!==p)}else q===null&&(A.lanes=0);return[v.memoizedState,A.dispatch]}function qm(p){var v=bs(),A=v.queue;if(A===null)throw Error(n(311));A.lastRenderedReducer=p;var M=A.dispatch,q=A.pending,Q=v.memoizedState;if(q!==null){A.pending=null;var de=q=q.next;do Q=p(Q,de.action),de=de.next;while(de!==q);Bs(Q,v.memoizedState)||(zi=!0),v.memoizedState=Q,v.baseQueue===null&&(v.baseState=Q),A.lastRenderedState=Q}return[Q,M]}function Wm(){}function uh(p,v){var A=rn,M=bs(),q=v(),Q=!Bs(M.memoizedState,q);if(Q&&(M.memoizedState=q,zi=!0),M=M.queue,Qm(Vm.bind(null,A,M,p),[p]),M.getSnapshot!==v||Q||On!==null&&On.memoizedState.tag&1){if(A.flags|=2048,cd(9,Gm.bind(null,A,M,q,v),void 0,null),kn===null)throw Error(n(349));(Zo&30)!==0||Hm(A,v,q)}return q}function Hm(p,v,A){p.flags|=16384,p={getSnapshot:v,value:A},v=rn.updateQueue,v===null?(v={lastEffect:null,stores:null},rn.updateQueue=v,v.stores=[p]):(A=v.stores,A===null?v.stores=[p]:A.push(p))}function Gm(p,v,A,M){v.value=A,v.getSnapshot=M,Ab(v)&&Km(p)}function Vm(p,v,A){return A(function(){Ab(v)&&Km(p)})}function Ab(p){var v=p.getSnapshot;p=p.value;try{var A=v();return!Bs(p,A)}catch{return!0}}function Km(p){var v=Oa(p,1);v!==null&&Ws(v,p,1,-1)}function Xm(p){var v=Fs();return typeof p=="function"&&(p=p()),v.memoizedState=v.baseState=p,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Gc,lastRenderedState:p},v.queue=p,p=p.dispatch=Ob.bind(null,rn,p),[v.memoizedState,p]}function cd(p,v,A,M){return p={tag:p,create:v,destroy:A,deps:M,next:null},v=rn.updateQueue,v===null?(v={lastEffect:null,stores:null},rn.updateQueue=v,v.lastEffect=p.next=p):(A=v.lastEffect,A===null?v.lastEffect=p.next=p:(M=A.next,A.next=p,p.next=M,v.lastEffect=p)),p}function Ym(){return bs().memoizedState}function ud(p,v,A,M){var q=Fs();rn.flags|=p,q.memoizedState=cd(1|v,A,void 0,M===void 0?null:M)}function dd(p,v,A,M){var q=bs();M=M===void 0?null:M;var Q=void 0;if(_n!==null){var de=_n.memoizedState;if(Q=de.destroy,M!==null&&ah(M,de.deps)){q.memoizedState=cd(v,A,Q,M);return}}rn.flags|=p,q.memoizedState=cd(1|v,A,Q,M)}function Jm(p,v){return ud(8390656,8,p,v)}function Qm(p,v){return dd(2048,8,p,v)}function Zm(p,v){return dd(4,2,p,v)}function eg(p,v){return dd(4,4,p,v)}function tg(p,v){if(typeof v=="function")return p=p(),v(p),function(){v(null)};if(v!=null)return p=p(),v.current=p,function(){v.current=null}}function $b(p,v,A){return A=A!=null?A.concat([p]):null,dd(4,4,tg.bind(null,v,p),A)}function dh(){}function rg(p,v){var A=bs();v=v===void 0?null:v;var M=A.memoizedState;return M!==null&&v!==null&&ah(v,M[1])?M[0]:(A.memoizedState=[p,v],p)}function ng(p,v){var A=bs();v=v===void 0?null:v;var M=A.memoizedState;return M!==null&&v!==null&&ah(v,M[1])?M[0]:(p=p(),A.memoizedState=[p,v],p)}function ig(p,v,A){return(Zo&21)===0?(p.baseState&&(p.baseState=!1,zi=!0),p.memoizedState=A):(Bs(A,v)||(A=Zs(),rn.lanes|=A,rl|=A,p.baseState=!0),v)}function G_(p,v){var A=ur;ur=A!==0&&4>A?A:4,p(!0);var M=ih.transition;ih.transition={};try{p(!1),v()}finally{ur=A,ih.transition=M}}function sg(){return bs().memoizedState}function Nb(p,v,A){var M=vo(p);if(A={lane:M,action:A,hasEagerState:!1,eagerState:null,next:null},ag(p))Pb(v,A);else if(A=sd(p,v,A,M),A!==null){var q=Si();Ws(A,p,M,q),og(A,v,M)}}function Ob(p,v,A){var M=vo(p),q={lane:M,action:A,hasEagerState:!1,eagerState:null,next:null};if(ag(p))Pb(v,q);else{var Q=p.alternate;if(p.lanes===0&&(Q===null||Q.lanes===0)&&(Q=v.lastRenderedReducer,Q!==null))try{var de=v.lastRenderedState,ke=Q(de,A);if(q.hasEagerState=!0,q.eagerState=ke,Bs(ke,de)){var Oe=v.interleaved;Oe===null?(q.next=q,Jf(v)):(q.next=Oe.next,Oe.next=q),v.interleaved=q;return}}catch{}finally{}A=sd(p,v,q,M),A!==null&&(q=Si(),Ws(A,p,M,q),og(A,v,M))}}function ag(p){var v=p.alternate;return p===rn||v!==null&&v===rn}function Pb(p,v){el=sh=!0;var A=p.pending;A===null?v.next=v:(v.next=A.next,A.next=v),p.pending=v}function og(p,v,A){if((A&4194240)!==0){var M=v.lanes;M&=p.pendingLanes,A|=M,v.lanes=A,jl(p,A)}}var fd={readContext:ys,useCallback:ti,useContext:ti,useEffect:ti,useImperativeHandle:ti,useInsertionEffect:ti,useLayoutEffect:ti,useMemo:ti,useReducer:ti,useRef:ti,useState:ti,useDebugValue:ti,useDeferredValue:ti,useTransition:ti,useMutableSource:ti,useSyncExternalStore:ti,useId:ti,unstable_isNewReconciler:!1},Rb={readContext:ys,useCallback:function(p,v){return Fs().memoizedState=[p,v===void 0?null:v],p},useContext:ys,useEffect:Jm,useImperativeHandle:function(p,v,A){return A=A!=null?A.concat([p]):null,ud(4194308,4,tg.bind(null,v,p),A)},useLayoutEffect:function(p,v){return ud(4194308,4,p,v)},useInsertionEffect:function(p,v){return ud(4,2,p,v)},useMemo:function(p,v){var A=Fs();return v=v===void 0?null:v,p=p(),A.memoizedState=[p,v],p},useReducer:function(p,v,A){var M=Fs();return v=A!==void 0?A(v):v,M.memoizedState=M.baseState=v,p={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:p,lastRenderedState:v},M.queue=p,p=p.dispatch=Nb.bind(null,rn,p),[M.memoizedState,p]},useRef:function(p){var v=Fs();return p={current:p},v.memoizedState=p},useState:Xm,useDebugValue:dh,useDeferredValue:function(p){return Fs().memoizedState=p},useTransition:function(){var p=Xm(!1),v=p[0];return p=G_.bind(null,p[1]),Fs().memoizedState=p,[v,p]},useMutableSource:function(){},useSyncExternalStore:function(p,v,A){var M=rn,q=Fs();if(tn){if(A===void 0)throw Error(n(407));A=A()}else{if(A=v(),kn===null)throw Error(n(349));(Zo&30)!==0||Hm(M,v,A)}q.memoizedState=A;var Q={value:A,getSnapshot:v};return q.queue=Q,Jm(Vm.bind(null,M,Q,p),[p]),M.flags|=2048,cd(9,Gm.bind(null,M,Q,A,v),void 0,null),A},useId:function(){var p=Fs(),v=kn.identifierPrefix;if(tn){var A=Di,M=Ii;A=(M&~(1<<32-ar(M)-1)).toString(32)+A,v=":"+v+"R"+A,A=ho++,0<A&&(v+="H"+A.toString(32)),v+=":"}else A=Um++,v=":"+v+"r"+A.toString(32)+":";return p.memoizedState=v},unstable_isNewReconciler:!1},Mb={readContext:ys,useCallback:rg,useContext:ys,useEffect:Qm,useImperativeHandle:$b,useInsertionEffect:Zm,useLayoutEffect:eg,useMemo:ng,useReducer:ch,useRef:Ym,useState:function(){return ch(Gc)},useDebugValue:dh,useDeferredValue:function(p){var v=bs();return ig(v,_n.memoizedState,p)},useTransition:function(){var p=ch(Gc)[0],v=bs().memoizedState;return[p,v]},useMutableSource:Wm,useSyncExternalStore:uh,useId:sg,unstable_isNewReconciler:!1},V_={readContext:ys,useCallback:rg,useContext:ys,useEffect:Qm,useImperativeHandle:$b,useInsertionEffect:Zm,useLayoutEffect:eg,useMemo:ng,useReducer:qm,useRef:Ym,useState:function(){return qm(Gc)},useDebugValue:dh,useDeferredValue:function(p){var v=bs();return _n===null?v.memoizedState=p:ig(v,_n.memoizedState,p)},useTransition:function(){var p=qm(Gc)[0],v=bs().memoizedState;return[p,v]},useMutableSource:Wm,useSyncExternalStore:uh,useId:sg,unstable_isNewReconciler:!1};function Sn(p,v){if(p&&p.defaultProps){v=X({},v),p=p.defaultProps;for(var A in p)v[A]===void 0&&(v[A]=p[A]);return v}return v}function ca(p,v,A,M){v=p.memoizedState,A=A(M,v),A=A==null?v:X({},v,A),p.memoizedState=A,p.lanes===0&&(p.updateQueue.baseState=A)}var Ra={isMounted:function(p){return(p=p._reactInternals)?At(p)===p:!1},enqueueSetState:function(p,v,A){p=p._reactInternals;var M=Si(),q=vo(p),Q=Pa(M,q);Q.payload=v,A!=null&&(Q.callback=A),v=fo(p,Q,q),v!==null&&(Ws(v,p,q,M),qc(v,p,q))},enqueueReplaceState:function(p,v,A){p=p._reactInternals;var M=Si(),q=vo(p),Q=Pa(M,q);Q.tag=1,Q.payload=v,A!=null&&(Q.callback=A),v=fo(p,Q,q),v!==null&&(Ws(v,p,q,M),qc(v,p,q))},enqueueForceUpdate:function(p,v){p=p._reactInternals;var A=Si(),M=vo(p),q=Pa(A,M);q.tag=2,v!=null&&(q.callback=v),v=fo(p,q,M),v!==null&&(Ws(v,p,M,A),qc(v,p,M))}};function tl(p,v,A,M,q,Q,de){return p=p.stateNode,typeof p.shouldComponentUpdate=="function"?p.shouldComponentUpdate(M,Q,de):v.prototype&&v.prototype.isPureReactComponent?!Rc(A,M)||!Rc(q,Q):!0}function lg(p,v,A){var M=!1,q=lo,Q=v.contextType;return typeof Q=="object"&&Q!==null?Q=ys(Q):(q=Mi(v)?Go:xi.current,M=v.contextTypes,Q=(M=M!=null)?wi(p,q):lo),v=new v(A,Q),p.memoizedState=v.state!==null&&v.state!==void 0?v.state:null,v.updater=Ra,p.stateNode=v,v._reactInternals=p,M&&(p=p.stateNode,p.__reactInternalMemoizedUnmaskedChildContext=q,p.__reactInternalMemoizedMaskedChildContext=Q),v}function cg(p,v,A,M){p=v.state,typeof v.componentWillReceiveProps=="function"&&v.componentWillReceiveProps(A,M),typeof v.UNSAFE_componentWillReceiveProps=="function"&&v.UNSAFE_componentWillReceiveProps(A,M),v.state!==p&&Ra.enqueueReplaceState(v,v.state,null)}function fh(p,v,A,M){var q=p.stateNode;q.props=A,q.state=p.memoizedState,q.refs={},ad(p);var Q=v.contextType;typeof Q=="object"&&Q!==null?q.context=ys(Q):(Q=Mi(v)?Go:xi.current,q.context=wi(p,Q)),q.state=p.memoizedState,Q=v.getDerivedStateFromProps,typeof Q=="function"&&(ca(p,v,Q,A),q.state=p.memoizedState),typeof v.getDerivedStateFromProps=="function"||typeof q.getSnapshotBeforeUpdate=="function"||typeof q.UNSAFE_componentWillMount!="function"&&typeof q.componentWillMount!="function"||(v=q.state,typeof q.componentWillMount=="function"&&q.componentWillMount(),typeof q.UNSAFE_componentWillMount=="function"&&q.UNSAFE_componentWillMount(),v!==q.state&&Ra.enqueueReplaceState(q,q.state,null),od(p,A,q,M),q.state=p.memoizedState),typeof q.componentDidMount=="function"&&(p.flags|=4194308)}function Fl(p,v){try{var A="",M=v;do A+=_e(M),M=M.return;while(M);var q=A}catch(Q){q=`
40
40
  Error generating stack: `+Q.message+`
41
- `+Q.stack}return{value:p,source:v,stack:q,digest:null}}function hh(p,v,A){return{value:p,source:null,stack:A??null,digest:v??null}}function ph(p,v){try{console.error(v.value)}catch(A){setTimeout(function(){throw A})}}var Ib=typeof WeakMap=="function"?WeakMap:Map;function ug(p,v,A){A=Pa(-1,A),A.tag=3,A.payload={element:null};var M=v.value;return A.callback=function(){xd||(xd=!0,Mh=M),ph(p,v)},A}function dg(p,v,A){A=Pa(-1,A),A.tag=3;var M=p.type.getDerivedStateFromError;if(typeof M=="function"){var q=v.value;A.payload=function(){return M(q)},A.callback=function(){ph(p,v)}}var Q=p.stateNode;return Q!==null&&typeof Q.componentDidCatch=="function"&&(A.callback=function(){ph(p,v),typeof M!="function"&&(go===null?go=new Set([this]):go.add(this));var de=v.stack;this.componentDidCatch(v.value,{componentStack:de!==null?de:""})}),A}function fg(p,v,A){var M=p.pingCache;if(M===null){M=p.pingCache=new Ib;var q=new Set;M.set(v,q)}else q=M.get(v),q===void 0&&(q=new Set,M.set(v,q));q.has(A)||(q.add(A),p=Kb.bind(null,p,v,A),v.then(p,p))}function Db(p){do{var v;if((v=p.tag===13)&&(v=p.memoizedState,v=v!==null?v.dehydrated!==null:!0),v)return p;p=p.return}while(p!==null);return null}function _i(p,v,A,M,q){return(p.mode&1)===0?(p===v?p.flags|=65536:(p.flags|=128,A.flags|=131072,A.flags&=-52805,A.tag===1&&(A.alternate===null?A.tag=17:(v=Pa(-1,1),v.tag=2,fo(A,v,1))),A.lanes|=1),p):(p.flags|=65536,p.lanes=q,p)}var Lb=T.ReactCurrentOwner,zi=!1;function ri(p,v,A,M){v.child=p===null?Vf(v,null,A,M):Dl(v,p.child,A,M)}function hg(p,v,A,M,q){A=A.render;var Q=v.ref;return Ll(v,q),M=oh(p,v,A,M,Q,q),A=lh(),p!==null&&!zi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~q,Ma(p,v,q)):(tn&&A&&wn(v),v.flags|=1,ri(p,v,M,q),v.child)}function Vc(p,v,A,M,q){if(p===null){var Q=A.type;return typeof Q=="function"&&!Uh(Q)&&Q.defaultProps===void 0&&A.compare===null&&A.defaultProps===void 0?(v.tag=15,v.type=Q,pg(p,v,Q,M,q)):(p=Cd(A.type,null,M,v,v.mode,q),p.ref=v.ref,p.return=v,v.child=p)}if(Q=p.child,(p.lanes&q)===0){var de=Q.memoizedProps;if(A=A.compare,A=A!==null?A:Rc,A(de,M)&&p.ref===v.ref)return Ma(p,v,q)}return v.flags|=1,p=bo(Q,M),p.ref=v.ref,p.return=v,v.child=p}function pg(p,v,A,M,q){if(p!==null){var Q=p.memoizedProps;if(Rc(Q,M)&&p.ref===v.ref)if(zi=!1,v.pendingProps=M=Q,(p.lanes&q)!==0)(p.flags&131072)!==0&&(zi=!0);else return v.lanes=p.lanes,Ma(p,v,q)}return mh(p,v,A,M,q)}function mg(p,v,A){var M=v.pendingProps,q=M.children,Q=p!==null?p.memoizedState:null;if(M.mode==="hidden")if((v.mode&1)===0)v.memoizedState={baseLanes:0,cachePool:null,transitions:null},Br(ql,Qi),Qi|=A;else{if((A&1073741824)===0)return p=Q!==null?Q.baseLanes|A:A,v.lanes=v.childLanes=1073741824,v.memoizedState={baseLanes:p,cachePool:null,transitions:null},v.updateQueue=null,Br(ql,Qi),Qi|=p,null;v.memoizedState={baseLanes:0,cachePool:null,transitions:null},M=Q!==null?Q.baseLanes:A,Br(ql,Qi),Qi|=M}else Q!==null?(M=Q.baseLanes|A,v.memoizedState=null):M=A,Br(ql,Qi),Qi|=M;return ri(p,v,q,A),v.child}function gg(p,v){var A=v.ref;(p===null&&A!==null||p!==null&&p.ref!==A)&&(v.flags|=512,v.flags|=2097152)}function mh(p,v,A,M,q){var Q=Mi(A)?Go:xi.current;return Q=wi(v,Q),Ll(v,q),A=oh(p,v,A,M,Q,q),M=lh(),p!==null&&!zi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~q,Ma(p,v,q)):(tn&&M&&wn(v),v.flags|=1,ri(p,v,A,q),v.child)}function vg(p,v,A,M,q){if(Mi(A)){var Q=!0;Zu(v)}else Q=!1;if(Ll(v,q),v.stateNode===null)pd(p,v),lg(v,A,M),fh(v,A,M,q),M=!0;else if(p===null){var de=v.stateNode,ke=v.memoizedProps;de.props=ke;var Oe=de.context,Ge=A.contextType;typeof Ge=="object"&&Ge!==null?Ge=ys(Ge):(Ge=Mi(A)?Go:xi.current,Ge=wi(v,Ge));var ct=A.getDerivedStateFromProps,ft=typeof ct=="function"||typeof de.getSnapshotBeforeUpdate=="function";ft||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(ke!==M||Oe!==Ge)&&cg(v,de,M,Ge),oa=!1;var ot=v.memoizedState;de.state=ot,od(v,M,de,q),Oe=v.memoizedState,ke!==M||ot!==Oe||Ri.current||oa?(typeof ct=="function"&&(ca(v,A,ct,M),Oe=v.memoizedState),(ke=oa||tl(v,A,ke,M,ot,Oe,Ge))?(ft||typeof de.UNSAFE_componentWillMount!="function"&&typeof de.componentWillMount!="function"||(typeof de.componentWillMount=="function"&&de.componentWillMount(),typeof de.UNSAFE_componentWillMount=="function"&&de.UNSAFE_componentWillMount()),typeof de.componentDidMount=="function"&&(v.flags|=4194308)):(typeof de.componentDidMount=="function"&&(v.flags|=4194308),v.memoizedProps=M,v.memoizedState=Oe),de.props=M,de.state=Oe,de.context=Ge,M=ke):(typeof de.componentDidMount=="function"&&(v.flags|=4194308),M=!1)}else{de=v.stateNode,Qf(p,v),ke=v.memoizedProps,Ge=v.type===v.elementType?ke:Sn(v.type,ke),de.props=Ge,ft=v.pendingProps,ot=de.context,Oe=A.contextType,typeof Oe=="object"&&Oe!==null?Oe=ys(Oe):(Oe=Mi(A)?Go:xi.current,Oe=wi(v,Oe));var Ct=A.getDerivedStateFromProps;(ct=typeof Ct=="function"||typeof de.getSnapshotBeforeUpdate=="function")||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(ke!==ft||ot!==Oe)&&cg(v,de,M,Oe),oa=!1,ot=v.memoizedState,de.state=ot,od(v,M,de,q);var Ot=v.memoizedState;ke!==ft||ot!==Ot||Ri.current||oa?(typeof Ct=="function"&&(ca(v,A,Ct,M),Ot=v.memoizedState),(Ge=oa||tl(v,A,Ge,M,ot,Ot,Oe)||!1)?(ct||typeof de.UNSAFE_componentWillUpdate!="function"&&typeof de.componentWillUpdate!="function"||(typeof de.componentWillUpdate=="function"&&de.componentWillUpdate(M,Ot,Oe),typeof de.UNSAFE_componentWillUpdate=="function"&&de.UNSAFE_componentWillUpdate(M,Ot,Oe)),typeof de.componentDidUpdate=="function"&&(v.flags|=4),typeof de.getSnapshotBeforeUpdate=="function"&&(v.flags|=1024)):(typeof de.componentDidUpdate!="function"||ke===p.memoizedProps&&ot===p.memoizedState||(v.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&ot===p.memoizedState||(v.flags|=1024),v.memoizedProps=M,v.memoizedState=Ot),de.props=M,de.state=Ot,de.context=Oe,M=Ge):(typeof de.componentDidUpdate!="function"||ke===p.memoizedProps&&ot===p.memoizedState||(v.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&ot===p.memoizedState||(v.flags|=1024),M=!1)}return gh(p,v,A,M,Q,q)}function gh(p,v,A,M,q,Q){gg(p,v);var de=(v.flags&128)!==0;if(!M&&!de)return q&&Im(v,A,!1),Ma(p,v,Q);M=v.stateNode,Lb.current=v;var ke=de&&typeof A.getDerivedStateFromError!="function"?null:M.render();return v.flags|=1,p!==null&&de?(v.child=Dl(v,p.child,null,Q),v.child=Dl(v,null,ke,Q)):ri(p,v,ke,Q),v.memoizedState=M.state,q&&Im(v,A,!0),v.child}function vh(p){var v=p.stateNode;v.pendingContext?Rm(p,v.pendingContext,v.pendingContext!==v.context):v.context&&Rm(p,v.context,!1),Zf(p,v.containerInfo)}function yg(p,v,A,M,q){return Ko(),Hf(q),v.flags|=256,ri(p,v,A,M),v.child}var yh={dehydrated:null,treeContext:null,retryLane:0};function bh(p){return{baseLanes:p,cachePool:null,transitions:null}}function bg(p,v,A){var M=v.pendingProps,q=sn.current,Q=!1,de=(v.flags&128)!==0,ke;if((ke=de)||(ke=p!==null&&p.memoizedState===null?!1:(q&2)!==0),ke?(Q=!0,v.flags&=-129):(p===null||p.memoizedState!==null)&&(q|=1),Br(sn,q&1),p===null)return qf(v),p=v.memoizedState,p!==null&&(p=p.dehydrated,p!==null)?((v.mode&1)===0?v.lanes=1:p.data==="$!"?v.lanes=8:v.lanes=1073741824,null):(de=M.children,p=M.fallback,Q?(M=v.mode,Q=v.child,de={mode:"hidden",children:de},(M&1)===0&&Q!==null?(Q.childLanes=0,Q.pendingProps=de):Q=Ed(de,M,0,null),p=Gl(p,M,A,null),Q.return=v,p.return=v,Q.sibling=p,v.child=Q,v.child.memoizedState=bh(A),v.memoizedState=yh,p):Kc(v,de));if(q=p.memoizedState,q!==null&&(ke=q.dehydrated,ke!==null))return Bb(p,v,de,M,ke,q,A);if(Q){Q=M.fallback,de=v.mode,q=p.child,ke=q.sibling;var Oe={mode:"hidden",children:M.children};return(de&1)===0&&v.child!==q?(M=v.child,M.childLanes=0,M.pendingProps=Oe,v.deletions=null):(M=bo(q,Oe),M.subtreeFlags=q.subtreeFlags&14680064),ke!==null?Q=bo(ke,Q):(Q=Gl(Q,de,A,null),Q.flags|=2),Q.return=v,M.return=v,M.sibling=Q,v.child=M,M=Q,Q=v.child,de=p.child.memoizedState,de=de===null?bh(A):{baseLanes:de.baseLanes|A,cachePool:null,transitions:de.transitions},Q.memoizedState=de,Q.childLanes=p.childLanes&~A,v.memoizedState=yh,M}return Q=p.child,p=Q.sibling,M=bo(Q,{mode:"visible",children:M.children}),(v.mode&1)===0&&(M.lanes=A),M.return=v,M.sibling=null,p!==null&&(A=v.deletions,A===null?(v.deletions=[p],v.flags|=16):A.push(p)),v.child=M,v.memoizedState=null,M}function Kc(p,v){return v=Ed({mode:"visible",children:v},p.mode,0,null),v.return=p,p.child=v}function hd(p,v,A,M){return M!==null&&Hf(M),Dl(v,p.child,null,A),p=Kc(v,v.pendingProps.children),p.flags|=2,v.memoizedState=null,p}function Bb(p,v,A,M,q,Q,de){if(A)return v.flags&256?(v.flags&=-257,M=hh(Error(n(422))),hd(p,v,de,M)):v.memoizedState!==null?(v.child=p.child,v.flags|=128,null):(Q=M.fallback,q=v.mode,M=Ed({mode:"visible",children:M.children},q,0,null),Q=Gl(Q,q,de,null),Q.flags|=2,M.return=v,Q.return=v,M.sibling=Q,v.child=M,(v.mode&1)!==0&&Dl(v,p.child,null,de),v.child.memoizedState=bh(de),v.memoizedState=yh,Q);if((v.mode&1)===0)return hd(p,v,de,null);if(q.data==="$!"){if(M=q.nextSibling&&q.nextSibling.dataset,M)var ke=M.dgst;return M=ke,Q=Error(n(419)),M=hh(Q,M,void 0),hd(p,v,de,M)}if(ke=(de&p.childLanes)!==0,zi||ke){if(M=kn,M!==null){switch(de&-de){case 4:q=2;break;case 16:q=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:q=32;break;case 536870912:q=268435456;break;default:q=0}q=(q&(M.suspendedLanes|de))!==0?0:q,q!==0&&q!==Q.retryLane&&(Q.retryLane=q,Oa(p,q),Ws(M,p,q,-1))}return Fh(),M=hh(Error(n(421))),hd(p,v,de,M)}return q.data==="$?"?(v.flags|=128,v.child=p.child,v=Yb.bind(null,p),q._reactRetry=v,null):(p=Q.treeContext,Ji=oo(q.nextSibling),Li=v,tn=!0,Bi=null,p!==null&&(gs[zs++]=Ii,gs[zs++]=Di,gs[zs++]=vs,Ii=p.id,Di=p.overflow,vs=v),v=Kc(v,M.children),v.flags|=4096,v)}function xg(p,v,A){p.lanes|=v;var M=p.alternate;M!==null&&(M.lanes|=v),zm(p.return,v,A)}function xh(p,v,A,M,q){var Q=p.memoizedState;Q===null?p.memoizedState={isBackwards:v,rendering:null,renderingStartTime:0,last:M,tail:A,tailMode:q}:(Q.isBackwards=v,Q.rendering=null,Q.renderingStartTime=0,Q.last=M,Q.tail=A,Q.tailMode=q)}function wh(p,v,A){var M=v.pendingProps,q=M.revealOrder,Q=M.tail;if(ri(p,v,M.children,A),M=sn.current,(M&2)!==0)M=M&1|2,v.flags|=128;else{if(p!==null&&(p.flags&128)!==0)e:for(p=v.child;p!==null;){if(p.tag===13)p.memoizedState!==null&&xg(p,A,v);else if(p.tag===19)xg(p,A,v);else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===v)break e;for(;p.sibling===null;){if(p.return===null||p.return===v)break e;p=p.return}p.sibling.return=p.return,p=p.sibling}M&=1}if(Br(sn,M),(v.mode&1)===0)v.memoizedState=null;else switch(q){case"forwards":for(A=v.child,q=null;A!==null;)p=A.alternate,p!==null&&ld(p)===null&&(q=A),A=A.sibling;A=q,A===null?(q=v.child,v.child=null):(q=A.sibling,A.sibling=null),xh(v,!1,q,A,Q);break;case"backwards":for(A=null,q=v.child,v.child=null;q!==null;){if(p=q.alternate,p!==null&&ld(p)===null){v.child=q;break}p=q.sibling,q.sibling=A,A=q,q=p}xh(v,!0,A,null,Q);break;case"together":xh(v,!1,null,null,void 0);break;default:v.memoizedState=null}return v.child}function pd(p,v){(v.mode&1)===0&&p!==null&&(p.alternate=null,v.alternate=null,v.flags|=2)}function Ma(p,v,A){if(p!==null&&(v.dependencies=p.dependencies),rl|=v.lanes,(A&v.childLanes)===0)return null;if(p!==null&&v.child!==p.child)throw Error(n(153));if(v.child!==null){for(p=v.child,A=bo(p,p.pendingProps),v.child=A,A.return=v;p.sibling!==null;)p=p.sibling,A=A.sibling=bo(p,p.pendingProps),A.return=v;A.sibling=null}return v.child}function K_(p,v,A){switch(v.tag){case 3:vh(v),Ko();break;case 5:Fm(v);break;case 1:Mi(v.type)&&Zu(v);break;case 4:Zf(v,v.stateNode.containerInfo);break;case 10:var M=v.type._context,q=v.memoizedProps.value;Br(Xo,M._currentValue),M._currentValue=q;break;case 13:if(M=v.memoizedState,M!==null)return M.dehydrated!==null?(Br(sn,sn.current&1),v.flags|=128,null):(A&v.child.childLanes)!==0?bg(p,v,A):(Br(sn,sn.current&1),p=Ma(p,v,A),p!==null?p.sibling:null);Br(sn,sn.current&1);break;case 19:if(M=(A&v.childLanes)!==0,(p.flags&128)!==0){if(M)return wh(p,v,A);v.flags|=128}if(q=v.memoizedState,q!==null&&(q.rendering=null,q.tail=null,q.lastEffect=null),Br(sn,sn.current),M)break;return null;case 22:case 23:return v.lanes=0,mg(p,v,A)}return Ma(p,v,A)}var _h,Sh,wg,_g;_h=function(p,v){for(var A=v.child;A!==null;){if(A.tag===5||A.tag===6)p.appendChild(A.stateNode);else if(A.tag!==4&&A.child!==null){A.child.return=A,A=A.child;continue}if(A===v)break;for(;A.sibling===null;){if(A.return===null||A.return===v)return;A=A.return}A.sibling.return=A.return,A=A.sibling}},Sh=function(){},wg=function(p,v,A,M){var q=p.memoizedProps;if(q!==M){p=v.stateNode,Jo(la.current);var Q=null;switch(A){case"input":q=Be(p,q),M=Be(p,M),Q=[];break;case"select":q=X({},q,{value:void 0}),M=X({},M,{value:void 0}),Q=[];break;case"textarea":q=Or(p,q),M=Or(p,M),Q=[];break;default:typeof q.onClick!="function"&&typeof M.onClick=="function"&&(p.onclick=Yu)}ss(A,M);var de;A=null;for(Ge in q)if(!M.hasOwnProperty(Ge)&&q.hasOwnProperty(Ge)&&q[Ge]!=null)if(Ge==="style"){var ke=q[Ge];for(de in ke)ke.hasOwnProperty(de)&&(A||(A={}),A[de]="")}else Ge!=="dangerouslySetInnerHTML"&&Ge!=="children"&&Ge!=="suppressContentEditableWarning"&&Ge!=="suppressHydrationWarning"&&Ge!=="autoFocus"&&(s.hasOwnProperty(Ge)?Q||(Q=[]):(Q=Q||[]).push(Ge,null));for(Ge in M){var Oe=M[Ge];if(ke=q!=null?q[Ge]:void 0,M.hasOwnProperty(Ge)&&Oe!==ke&&(Oe!=null||ke!=null))if(Ge==="style")if(ke){for(de in ke)!ke.hasOwnProperty(de)||Oe&&Oe.hasOwnProperty(de)||(A||(A={}),A[de]="");for(de in Oe)Oe.hasOwnProperty(de)&&ke[de]!==Oe[de]&&(A||(A={}),A[de]=Oe[de])}else A||(Q||(Q=[]),Q.push(Ge,A)),A=Oe;else Ge==="dangerouslySetInnerHTML"?(Oe=Oe?Oe.__html:void 0,ke=ke?ke.__html:void 0,Oe!=null&&ke!==Oe&&(Q=Q||[]).push(Ge,Oe)):Ge==="children"?typeof Oe!="string"&&typeof Oe!="number"||(Q=Q||[]).push(Ge,""+Oe):Ge!=="suppressContentEditableWarning"&&Ge!=="suppressHydrationWarning"&&(s.hasOwnProperty(Ge)?(Oe!=null&&Ge==="onScroll"&&Wr("scroll",p),Q||ke===Oe||(Q=[])):(Q=Q||[]).push(Ge,Oe))}A&&(Q=Q||[]).push("style",A);var Ge=Q;(v.updateQueue=Ge)&&(v.flags|=4)}},_g=function(p,v,A,M){A!==M&&(v.flags|=4)};function md(p,v){if(!tn)switch(p.tailMode){case"hidden":v=p.tail;for(var A=null;v!==null;)v.alternate!==null&&(A=v),v=v.sibling;A===null?p.tail=null:A.sibling=null;break;case"collapsed":A=p.tail;for(var M=null;A!==null;)A.alternate!==null&&(M=A),A=A.sibling;M===null?v||p.tail===null?p.tail=null:p.tail.sibling=null:M.sibling=null}}function ni(p){var v=p.alternate!==null&&p.alternate.child===p.child,A=0,M=0;if(v)for(var q=p.child;q!==null;)A|=q.lanes|q.childLanes,M|=q.subtreeFlags&14680064,M|=q.flags&14680064,q.return=p,q=q.sibling;else for(q=p.child;q!==null;)A|=q.lanes|q.childLanes,M|=q.subtreeFlags,M|=q.flags,q.return=p,q=q.sibling;return p.subtreeFlags|=M,p.childLanes=A,v}function zb(p,v,A){var M=v.pendingProps;switch(Bf(v),v.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ni(v),null;case 1:return Mi(v.type)&&Qu(),ni(v),null;case 3:return M=v.stateNode,Qo(),Hr(Ri),Hr(xi),rh(),M.pendingContext&&(M.context=M.pendingContext,M.pendingContext=null),(p===null||p.child===null)&&(Uc(v)?v.flags|=4:p===null||p.memoizedState.isDehydrated&&(v.flags&256)===0||(v.flags|=1024,Bi!==null&&(Lh(Bi),Bi=null))),Sh(p,v),ni(v),null;case 5:eh(v);var q=Jo(zl.current);if(A=v.type,p!==null&&v.stateNode!=null)wg(p,v,A,M,q),p.ref!==v.ref&&(v.flags|=512,v.flags|=2097152);else{if(!M){if(v.stateNode===null)throw Error(n(166));return ni(v),null}if(p=Jo(la.current),Uc(v)){M=v.stateNode,A=v.type;var Q=v.memoizedProps;switch(M[sa]=v,M[zc]=Q,p=(v.mode&1)!==0,A){case"dialog":Wr("cancel",M),Wr("close",M);break;case"iframe":case"object":case"embed":Wr("load",M);break;case"video":case"audio":for(q=0;q<Dc.length;q++)Wr(Dc[q],M);break;case"source":Wr("error",M);break;case"img":case"image":case"link":Wr("error",M),Wr("load",M);break;case"details":Wr("toggle",M);break;case"input":Ze(M,Q),Wr("invalid",M);break;case"select":M._wrapperState={wasMultiple:!!Q.multiple},Wr("invalid",M);break;case"textarea":Ar(M,Q),Wr("invalid",M)}ss(A,Q),q=null;for(var de in Q)if(Q.hasOwnProperty(de)){var ke=Q[de];de==="children"?typeof ke=="string"?M.textContent!==ke&&(Q.suppressHydrationWarning!==!0&&Xu(M.textContent,ke,p),q=["children",ke]):typeof ke=="number"&&M.textContent!==""+ke&&(Q.suppressHydrationWarning!==!0&&Xu(M.textContent,ke,p),q=["children",""+ke]):s.hasOwnProperty(de)&&ke!=null&&de==="onScroll"&&Wr("scroll",M)}switch(A){case"input":Ve(M),or(M,Q,!0);break;case"textarea":Ve(M),Ur(M);break;case"select":case"option":break;default:typeof Q.onClick=="function"&&(M.onclick=Yu)}M=q,v.updateQueue=M,M!==null&&(v.flags|=4)}else{de=q.nodeType===9?q:q.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=Ni(A)),p==="http://www.w3.org/1999/xhtml"?A==="script"?(p=de.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof M.is=="string"?p=de.createElement(A,{is:M.is}):(p=de.createElement(A),A==="select"&&(de=p,M.multiple?de.multiple=!0:M.size&&(de.size=M.size))):p=de.createElementNS(p,A),p[sa]=v,p[zc]=M,_h(p,v,!1,!1),v.stateNode=p;e:{switch(de=Er(A,M),A){case"dialog":Wr("cancel",p),Wr("close",p),q=M;break;case"iframe":case"object":case"embed":Wr("load",p),q=M;break;case"video":case"audio":for(q=0;q<Dc.length;q++)Wr(Dc[q],p);q=M;break;case"source":Wr("error",p),q=M;break;case"img":case"image":case"link":Wr("error",p),Wr("load",p),q=M;break;case"details":Wr("toggle",p),q=M;break;case"input":Ze(p,M),q=Be(p,M),Wr("invalid",p);break;case"option":q=M;break;case"select":p._wrapperState={wasMultiple:!!M.multiple},q=X({},M,{value:void 0}),Wr("invalid",p);break;case"textarea":Ar(p,M),q=Or(p,M),Wr("invalid",p);break;default:q=M}ss(A,q),ke=q;for(Q in ke)if(ke.hasOwnProperty(Q)){var Oe=ke[Q];Q==="style"?mn(p,Oe):Q==="dangerouslySetInnerHTML"?(Oe=Oe?Oe.__html:void 0,Oe!=null&&Tn(p,Oe)):Q==="children"?typeof Oe=="string"?(A!=="textarea"||Oe!=="")&&lt(p,Oe):typeof Oe=="number"&&lt(p,""+Oe):Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&Q!=="autoFocus"&&(s.hasOwnProperty(Q)?Oe!=null&&Q==="onScroll"&&Wr("scroll",p):Oe!=null&&C(p,Q,Oe,de))}switch(A){case"input":Ve(p),or(p,M,!1);break;case"textarea":Ve(p),Ur(p);break;case"option":M.value!=null&&p.setAttribute("value",""+ie(M.value));break;case"select":p.multiple=!!M.multiple,Q=M.value,Q!=null?sr(p,!!M.multiple,Q,!1):M.defaultValue!=null&&sr(p,!!M.multiple,M.defaultValue,!0);break;default:typeof q.onClick=="function"&&(p.onclick=Yu)}switch(A){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}}M&&(v.flags|=4)}v.ref!==null&&(v.flags|=512,v.flags|=2097152)}return ni(v),null;case 6:if(p&&v.stateNode!=null)_g(p,v,p.memoizedProps,M);else{if(typeof M!="string"&&v.stateNode===null)throw Error(n(166));if(A=Jo(zl.current),Jo(la.current),Uc(v)){if(M=v.stateNode,A=v.memoizedProps,M[sa]=v,(Q=M.nodeValue!==A)&&(p=Li,p!==null))switch(p.tag){case 3:Xu(M.nodeValue,A,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&Xu(M.nodeValue,A,(p.mode&1)!==0)}Q&&(v.flags|=4)}else M=(A.nodeType===9?A:A.ownerDocument).createTextNode(M),M[sa]=v,v.stateNode=M}return ni(v),null;case 13:if(Hr(sn),M=v.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(tn&&Ji!==null&&(v.mode&1)!==0&&(v.flags&128)===0)Lm(),Ko(),v.flags|=98560,Q=!1;else if(Q=Uc(v),M!==null&&M.dehydrated!==null){if(p===null){if(!Q)throw Error(n(318));if(Q=v.memoizedState,Q=Q!==null?Q.dehydrated:null,!Q)throw Error(n(317));Q[sa]=v}else Ko(),(v.flags&128)===0&&(v.memoizedState=null),v.flags|=4;ni(v),Q=!1}else Bi!==null&&(Lh(Bi),Bi=null),Q=!0;if(!Q)return v.flags&65536?v:null}return(v.flags&128)!==0?(v.lanes=A,v):(M=M!==null,M!==(p!==null&&p.memoizedState!==null)&&M&&(v.child.flags|=8192,(v.mode&1)!==0&&(p===null||(sn.current&1)!==0?Pn===0&&(Pn=3):Fh())),v.updateQueue!==null&&(v.flags|=4),ni(v),null);case 4:return Qo(),Sh(p,v),p===null&&Lc(v.stateNode.containerInfo),ni(v),null;case 10:return Yf(v.type._context),ni(v),null;case 17:return Mi(v.type)&&Qu(),ni(v),null;case 19:if(Hr(sn),Q=v.memoizedState,Q===null)return ni(v),null;if(M=(v.flags&128)!==0,de=Q.rendering,de===null)if(M)md(Q,!1);else{if(Pn!==0||p!==null&&(p.flags&128)!==0)for(p=v.child;p!==null;){if(de=ld(p),de!==null){for(v.flags|=128,md(Q,!1),M=de.updateQueue,M!==null&&(v.updateQueue=M,v.flags|=4),v.subtreeFlags=0,M=A,A=v.child;A!==null;)Q=A,p=M,Q.flags&=14680066,de=Q.alternate,de===null?(Q.childLanes=0,Q.lanes=p,Q.child=null,Q.subtreeFlags=0,Q.memoizedProps=null,Q.memoizedState=null,Q.updateQueue=null,Q.dependencies=null,Q.stateNode=null):(Q.childLanes=de.childLanes,Q.lanes=de.lanes,Q.child=de.child,Q.subtreeFlags=0,Q.deletions=null,Q.memoizedProps=de.memoizedProps,Q.memoizedState=de.memoizedState,Q.updateQueue=de.updateQueue,Q.type=de.type,p=de.dependencies,Q.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),A=A.sibling;return Br(sn,sn.current&1|2),v.child}p=p.sibling}Q.tail!==null&&qr()>Wl&&(v.flags|=128,M=!0,md(Q,!1),v.lanes=4194304)}else{if(!M)if(p=ld(de),p!==null){if(v.flags|=128,M=!0,A=p.updateQueue,A!==null&&(v.updateQueue=A,v.flags|=4),md(Q,!0),Q.tail===null&&Q.tailMode==="hidden"&&!de.alternate&&!tn)return ni(v),null}else 2*qr()-Q.renderingStartTime>Wl&&A!==1073741824&&(v.flags|=128,M=!0,md(Q,!1),v.lanes=4194304);Q.isBackwards?(de.sibling=v.child,v.child=de):(A=Q.last,A!==null?A.sibling=de:v.child=de,Q.last=de)}return Q.tail!==null?(v=Q.tail,Q.rendering=v,Q.tail=v.sibling,Q.renderingStartTime=qr(),v.sibling=null,A=sn.current,Br(sn,M?A&1|2:A&1),v):(ni(v),null);case 22:case 23:return zh(),M=v.memoizedState!==null,p!==null&&p.memoizedState!==null!==M&&(v.flags|=8192),M&&(v.mode&1)!==0?(Qi&1073741824)!==0&&(ni(v),v.subtreeFlags&6&&(v.flags|=8192)):ni(v),null;case 24:return null;case 25:return null}throw Error(n(156,v.tag))}function Fb(p,v){switch(Bf(v),v.tag){case 1:return Mi(v.type)&&Qu(),p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 3:return Qo(),Hr(Ri),Hr(xi),rh(),p=v.flags,(p&65536)!==0&&(p&128)===0?(v.flags=p&-65537|128,v):null;case 5:return eh(v),null;case 13:if(Hr(sn),p=v.memoizedState,p!==null&&p.dehydrated!==null){if(v.alternate===null)throw Error(n(340));Ko()}return p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 19:return Hr(sn),null;case 4:return Qo(),null;case 10:return Yf(v.type._context),null;case 22:case 23:return zh(),null;case 24:return null;default:return null}}var kh=!1,ii=!1,Ub=typeof WeakSet=="function"?WeakSet:Set,Nt=null;function Ul(p,v){var A=p.ref;if(A!==null)if(typeof A=="function")try{A(null)}catch(M){an(p,v,M)}else A.current=null}function Ch(p,v,A){try{A()}catch(M){an(p,v,M)}}var Sg=!1;function qb(p,v){if(Nf=so,p=Sf(),kf(p)){if("selectionStart"in p)var A={start:p.selectionStart,end:p.selectionEnd};else e:{A=(A=p.ownerDocument)&&A.defaultView||window;var M=A.getSelection&&A.getSelection();if(M&&M.rangeCount!==0){A=M.anchorNode;var q=M.anchorOffset,Q=M.focusNode;M=M.focusOffset;try{A.nodeType,Q.nodeType}catch{A=null;break e}var de=0,ke=-1,Oe=-1,Ge=0,ct=0,ft=p,ot=null;t:for(;;){for(var Ct;ft!==A||q!==0&&ft.nodeType!==3||(ke=de+q),ft!==Q||M!==0&&ft.nodeType!==3||(Oe=de+M),ft.nodeType===3&&(de+=ft.nodeValue.length),(Ct=ft.firstChild)!==null;)ot=ft,ft=Ct;for(;;){if(ft===p)break t;if(ot===A&&++Ge===q&&(ke=de),ot===Q&&++ct===M&&(Oe=de),(Ct=ft.nextSibling)!==null)break;ft=ot,ot=ft.parentNode}ft=Ct}A=ke===-1||Oe===-1?null:{start:ke,end:Oe}}else A=null}A=A||{start:0,end:0}}else A=null;for(Of={focusedElem:p,selectionRange:A},so=!1,Nt=v;Nt!==null;)if(v=Nt,p=v.child,(v.subtreeFlags&1028)!==0&&p!==null)p.return=v,Nt=p;else for(;Nt!==null;){v=Nt;try{var Ot=v.alternate;if((v.flags&1024)!==0)switch(v.tag){case 0:case 11:case 15:break;case 1:if(Ot!==null){var Pt=Ot.memoizedProps,zr=Ot.memoizedState,qe=v.stateNode,Ie=qe.getSnapshotBeforeUpdate(v.elementType===v.type?Pt:Sn(v.type,Pt),zr);qe.__reactInternalSnapshotBeforeUpdate=Ie}break;case 3:var Ke=v.stateNode.containerInfo;Ke.nodeType===1?Ke.textContent="":Ke.nodeType===9&&Ke.documentElement&&Ke.removeChild(Ke.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(gt){an(v,v.return,gt)}if(p=v.sibling,p!==null){p.return=v.return,Nt=p;break}Nt=v.return}return Ot=Sg,Sg=!1,Ot}function Xc(p,v,A){var M=v.updateQueue;if(M=M!==null?M.lastEffect:null,M!==null){var q=M=M.next;do{if((q.tag&p)===p){var Q=q.destroy;q.destroy=void 0,Q!==void 0&&Ch(v,A,Q)}q=q.next}while(q!==M)}}function Eh(p,v){if(v=v.updateQueue,v=v!==null?v.lastEffect:null,v!==null){var A=v=v.next;do{if((A.tag&p)===p){var M=A.create;A.destroy=M()}A=A.next}while(A!==v)}}function jh(p){var v=p.ref;if(v!==null){var A=p.stateNode;switch(p.tag){case 5:p=A;break;default:p=A}typeof v=="function"?v(p):v.current=p}}function kg(p){var v=p.alternate;v!==null&&(p.alternate=null,kg(v)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(v=p.stateNode,v!==null&&(delete v[sa],delete v[zc],delete v[If],delete v[Om],delete v[Pm])),p.stateNode=null,p.return=null,p.dependencies=null,p.memoizedProps=null,p.memoizedState=null,p.pendingProps=null,p.stateNode=null,p.updateQueue=null}function Cg(p){return p.tag===5||p.tag===3||p.tag===4}function Eg(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||Cg(p.return))return null;p=p.return}for(p.sibling.return=p.return,p=p.sibling;p.tag!==5&&p.tag!==6&&p.tag!==18;){if(p.flags&2||p.child===null||p.tag===4)continue e;p.child.return=p,p=p.child}if(!(p.flags&2))return p.stateNode}}function Th(p,v,A){var M=p.tag;if(M===5||M===6)p=p.stateNode,v?A.nodeType===8?A.parentNode.insertBefore(p,v):A.insertBefore(p,v):(A.nodeType===8?(v=A.parentNode,v.insertBefore(p,A)):(v=A,v.appendChild(p)),A=A._reactRootContainer,A!=null||v.onclick!==null||(v.onclick=Yu));else if(M!==4&&(p=p.child,p!==null))for(Th(p,v,A),p=p.sibling;p!==null;)Th(p,v,A),p=p.sibling}function Ah(p,v,A){var M=p.tag;if(M===5||M===6)p=p.stateNode,v?A.insertBefore(p,v):A.appendChild(p);else if(M!==4&&(p=p.child,p!==null))for(Ah(p,v,A),p=p.sibling;p!==null;)Ah(p,v,A),p=p.sibling}var Wn=null,Us=!1;function po(p,v,A){for(A=A.child;A!==null;)Wb(p,v,A),A=A.sibling}function Wb(p,v,A){if(nr&&typeof nr.onCommitFiberUnmount=="function")try{nr.onCommitFiberUnmount(_t,A)}catch{}switch(A.tag){case 5:ii||Ul(A,v);case 6:var M=Wn,q=Us;Wn=null,po(p,v,A),Wn=M,Us=q,Wn!==null&&(Us?(p=Wn,A=A.stateNode,p.nodeType===8?p.parentNode.removeChild(A):p.removeChild(A)):Wn.removeChild(A.stateNode));break;case 18:Wn!==null&&(Us?(p=Wn,A=A.stateNode,p.nodeType===8?Mf(p.parentNode,A):p.nodeType===1&&Mf(p,A),Ta(p)):Mf(Wn,A.stateNode));break;case 4:M=Wn,q=Us,Wn=A.stateNode.containerInfo,Us=!0,po(p,v,A),Wn=M,Us=q;break;case 0:case 11:case 14:case 15:if(!ii&&(M=A.updateQueue,M!==null&&(M=M.lastEffect,M!==null))){q=M=M.next;do{var Q=q,de=Q.destroy;Q=Q.tag,de!==void 0&&((Q&2)!==0||(Q&4)!==0)&&Ch(A,v,de),q=q.next}while(q!==M)}po(p,v,A);break;case 1:if(!ii&&(Ul(A,v),M=A.stateNode,typeof M.componentWillUnmount=="function"))try{M.props=A.memoizedProps,M.state=A.memoizedState,M.componentWillUnmount()}catch(ke){an(A,v,ke)}po(p,v,A);break;case 21:po(p,v,A);break;case 22:A.mode&1?(ii=(M=ii)||A.memoizedState!==null,po(p,v,A),ii=M):po(p,v,A);break;default:po(p,v,A)}}function Yc(p){var v=p.updateQueue;if(v!==null){p.updateQueue=null;var A=p.stateNode;A===null&&(A=p.stateNode=new Ub),v.forEach(function(M){var q=Jb.bind(null,p,M);A.has(M)||(A.add(M),M.then(q,q))})}}function xs(p,v){var A=v.deletions;if(A!==null)for(var M=0;M<A.length;M++){var q=A[M];try{var Q=p,de=v,ke=de;e:for(;ke!==null;){switch(ke.tag){case 5:Wn=ke.stateNode,Us=!1;break e;case 3:Wn=ke.stateNode.containerInfo,Us=!0;break e;case 4:Wn=ke.stateNode.containerInfo,Us=!0;break e}ke=ke.return}if(Wn===null)throw Error(n(160));Wb(Q,de,q),Wn=null,Us=!1;var Oe=q.alternate;Oe!==null&&(Oe.return=null),q.return=null}catch(Ge){an(q,v,Ge)}}if(v.subtreeFlags&12854)for(v=v.child;v!==null;)$h(v,p),v=v.sibling}function $h(p,v){var A=p.alternate,M=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(xs(v,p),qs(p),M&4){try{Xc(3,p,p.return),Eh(3,p)}catch(Pt){an(p,p.return,Pt)}try{Xc(5,p,p.return)}catch(Pt){an(p,p.return,Pt)}}break;case 1:xs(v,p),qs(p),M&512&&A!==null&&Ul(A,A.return);break;case 5:if(xs(v,p),qs(p),M&512&&A!==null&&Ul(A,A.return),p.flags&32){var q=p.stateNode;try{lt(q,"")}catch(Pt){an(p,p.return,Pt)}}if(M&4&&(q=p.stateNode,q!=null)){var Q=p.memoizedProps,de=A!==null?A.memoizedProps:Q,ke=p.type,Oe=p.updateQueue;if(p.updateQueue=null,Oe!==null)try{ke==="input"&&Q.type==="radio"&&Q.name!=null&&dt(q,Q),Er(ke,de);var Ge=Er(ke,Q);for(de=0;de<Oe.length;de+=2){var ct=Oe[de],ft=Oe[de+1];ct==="style"?mn(q,ft):ct==="dangerouslySetInnerHTML"?Tn(q,ft):ct==="children"?lt(q,ft):C(q,ct,ft,Ge)}switch(ke){case"input":ut(q,Q);break;case"textarea":en(q,Q);break;case"select":var ot=q._wrapperState.wasMultiple;q._wrapperState.wasMultiple=!!Q.multiple;var Ct=Q.value;Ct!=null?sr(q,!!Q.multiple,Ct,!1):ot!==!!Q.multiple&&(Q.defaultValue!=null?sr(q,!!Q.multiple,Q.defaultValue,!0):sr(q,!!Q.multiple,Q.multiple?[]:"",!1))}q[zc]=Q}catch(Pt){an(p,p.return,Pt)}}break;case 6:if(xs(v,p),qs(p),M&4){if(p.stateNode===null)throw Error(n(162));q=p.stateNode,Q=p.memoizedProps;try{q.nodeValue=Q}catch(Pt){an(p,p.return,Pt)}}break;case 3:if(xs(v,p),qs(p),M&4&&A!==null&&A.memoizedState.isDehydrated)try{Ta(v.containerInfo)}catch(Pt){an(p,p.return,Pt)}break;case 4:xs(v,p),qs(p);break;case 13:xs(v,p),qs(p),q=p.child,q.flags&8192&&(Q=q.memoizedState!==null,q.stateNode.isHidden=Q,!Q||q.alternate!==null&&q.alternate.memoizedState!==null||(Rh=qr())),M&4&&Yc(p);break;case 22:if(ct=A!==null&&A.memoizedState!==null,p.mode&1?(ii=(Ge=ii)||ct,xs(v,p),ii=Ge):xs(v,p),qs(p),M&8192){if(Ge=p.memoizedState!==null,(p.stateNode.isHidden=Ge)&&!ct&&(p.mode&1)!==0)for(Nt=p,ct=p.child;ct!==null;){for(ft=Nt=ct;Nt!==null;){switch(ot=Nt,Ct=ot.child,ot.tag){case 0:case 11:case 14:case 15:Xc(4,ot,ot.return);break;case 1:Ul(ot,ot.return);var Ot=ot.stateNode;if(typeof Ot.componentWillUnmount=="function"){M=ot,A=ot.return;try{v=M,Ot.props=v.memoizedProps,Ot.state=v.memoizedState,Ot.componentWillUnmount()}catch(Pt){an(M,A,Pt)}}break;case 5:Ul(ot,ot.return);break;case 22:if(ot.memoizedState!==null){Nh(ft);continue}}Ct!==null?(Ct.return=ot,Nt=Ct):Nh(ft)}ct=ct.sibling}e:for(ct=null,ft=p;;){if(ft.tag===5){if(ct===null){ct=ft;try{q=ft.stateNode,Ge?(Q=q.style,typeof Q.setProperty=="function"?Q.setProperty("display","none","important"):Q.display="none"):(ke=ft.stateNode,Oe=ft.memoizedProps.style,de=Oe!=null&&Oe.hasOwnProperty("display")?Oe.display:null,ke.style.display=br("display",de))}catch(Pt){an(p,p.return,Pt)}}}else if(ft.tag===6){if(ct===null)try{ft.stateNode.nodeValue=Ge?"":ft.memoizedProps}catch(Pt){an(p,p.return,Pt)}}else if((ft.tag!==22&&ft.tag!==23||ft.memoizedState===null||ft===p)&&ft.child!==null){ft.child.return=ft,ft=ft.child;continue}if(ft===p)break e;for(;ft.sibling===null;){if(ft.return===null||ft.return===p)break e;ct===ft&&(ct=null),ft=ft.return}ct===ft&&(ct=null),ft.sibling.return=ft.return,ft=ft.sibling}}break;case 19:xs(v,p),qs(p),M&4&&Yc(p);break;case 21:break;default:xs(v,p),qs(p)}}function qs(p){var v=p.flags;if(v&2){try{e:{for(var A=p.return;A!==null;){if(Cg(A)){var M=A;break e}A=A.return}throw Error(n(160))}switch(M.tag){case 5:var q=M.stateNode;M.flags&32&&(lt(q,""),M.flags&=-33);var Q=Eg(p);Ah(p,Q,q);break;case 3:case 4:var de=M.stateNode.containerInfo,ke=Eg(p);Th(p,ke,de);break;default:throw Error(n(161))}}catch(Oe){an(p,p.return,Oe)}p.flags&=-3}v&4096&&(p.flags&=-4097)}function jg(p,v,A){Nt=p,Tg(p)}function Tg(p,v,A){for(var M=(p.mode&1)!==0;Nt!==null;){var q=Nt,Q=q.child;if(q.tag===22&&M){var de=q.memoizedState!==null||kh;if(!de){var ke=q.alternate,Oe=ke!==null&&ke.memoizedState!==null||ii;ke=kh;var Ge=ii;if(kh=de,(ii=Oe)&&!Ge)for(Nt=q;Nt!==null;)de=Nt,Oe=de.child,de.tag===22&&de.memoizedState!==null?Oh(q):Oe!==null?(Oe.return=de,Nt=Oe):Oh(q);for(;Q!==null;)Nt=Q,Tg(Q),Q=Q.sibling;Nt=q,kh=ke,ii=Ge}Ag(p)}else(q.subtreeFlags&8772)!==0&&Q!==null?(Q.return=q,Nt=Q):Ag(p)}}function Ag(p){for(;Nt!==null;){var v=Nt;if((v.flags&8772)!==0){var A=v.alternate;try{if((v.flags&8772)!==0)switch(v.tag){case 0:case 11:case 15:ii||Eh(5,v);break;case 1:var M=v.stateNode;if(v.flags&4&&!ii)if(A===null)M.componentDidMount();else{var q=v.elementType===v.type?A.memoizedProps:Sn(v.type,A.memoizedProps);M.componentDidUpdate(q,A.memoizedState,M.__reactInternalSnapshotBeforeUpdate)}var Q=v.updateQueue;Q!==null&&Tb(v,Q,M);break;case 3:var de=v.updateQueue;if(de!==null){if(A=null,v.child!==null)switch(v.child.tag){case 5:A=v.child.stateNode;break;case 1:A=v.child.stateNode}Tb(v,de,A)}break;case 5:var ke=v.stateNode;if(A===null&&v.flags&4){A=ke;var Oe=v.memoizedProps;switch(v.type){case"button":case"input":case"select":case"textarea":Oe.autoFocus&&A.focus();break;case"img":Oe.src&&(A.src=Oe.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(v.memoizedState===null){var Ge=v.alternate;if(Ge!==null){var ct=Ge.memoizedState;if(ct!==null){var ft=ct.dehydrated;ft!==null&&Ta(ft)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ii||v.flags&512&&jh(v)}catch(ot){an(v,v.return,ot)}}if(v===p){Nt=null;break}if(A=v.sibling,A!==null){A.return=v.return,Nt=A;break}Nt=v.return}}function Nh(p){for(;Nt!==null;){var v=Nt;if(v===p){Nt=null;break}var A=v.sibling;if(A!==null){A.return=v.return,Nt=A;break}Nt=v.return}}function Oh(p){for(;Nt!==null;){var v=Nt;try{switch(v.tag){case 0:case 11:case 15:var A=v.return;try{Eh(4,v)}catch(Oe){an(v,A,Oe)}break;case 1:var M=v.stateNode;if(typeof M.componentDidMount=="function"){var q=v.return;try{M.componentDidMount()}catch(Oe){an(v,q,Oe)}}var Q=v.return;try{jh(v)}catch(Oe){an(v,Q,Oe)}break;case 5:var de=v.return;try{jh(v)}catch(Oe){an(v,de,Oe)}}}catch(Oe){an(v,v.return,Oe)}if(v===p){Nt=null;break}var ke=v.sibling;if(ke!==null){ke.return=v.return,Nt=ke;break}Nt=v.return}}var Hb=Math.ceil,gd=T.ReactCurrentDispatcher,vd=T.ReactCurrentOwner,ws=T.ReactCurrentBatchConfig,wr=0,kn=null,bn=null,Hn=0,Qi=0,ql=$a(0),Pn=0,Jc=null,rl=0,yd=0,Ph=0,bd=null,Fi=null,Rh=0,Wl=1/0,mo=null,xd=!1,Mh=null,go=null,wd=!1,nl=null,_d=0,Qc=0,Ih=null,Zc=-1,Sd=0;function Si(){return(wr&6)!==0?qr():Zc!==-1?Zc:Zc=qr()}function vo(p){return(p.mode&1)===0?1:(wr&2)!==0&&Hn!==0?Hn&-Hn:Gf.transition!==null?(Sd===0&&(Sd=Zs()),Sd):(p=ur,p!==0||(p=window.event,p=p===void 0?16:he(p.type)),p)}function Ws(p,v,A,M){if(50<Qc)throw Qc=0,Ih=null,Error(n(185));Ps(p,A,M),((wr&2)===0||p!==kn)&&(p===kn&&((wr&2)===0&&(yd|=A),Pn===4&&yo(p,Hn)),Ui(p,M),A===1&&wr===0&&(v.mode&1)===0&&(Wl=qr()+500,ed&&co()))}function Ui(p,v){var A=p.callbackNode;us(p,v);var M=Os(p,p===kn?Hn:0);if(M===0)A!==null&&An(A),p.callbackNode=null,p.callbackPriority=0;else if(v=M&-M,p.callbackPriority!==v){if(A!=null&&An(A),v===1)p.tag===0?H_(Og.bind(null,p)):Dm(Og.bind(null,p)),kb(function(){(wr&6)===0&&co()}),A=null;else{switch(It(M)){case 1:A=gn;break;case 4:A=dn;break;case 16:A=Et;break;case 536870912:A=rt;break;default:A=Et}A=Lg(A,$g.bind(null,p))}p.callbackPriority=v,p.callbackNode=A}}function $g(p,v){if(Zc=-1,Sd=0,(wr&6)!==0)throw Error(n(327));var A=p.callbackNode;if(Hl()&&p.callbackNode!==A)return null;var M=Os(p,p===kn?Hn:0);if(M===0)return null;if((M&30)!==0||(M&p.expiredLanes)!==0||v)v=kd(p,M);else{v=M;var q=wr;wr|=2;var Q=Gb();(kn!==p||Hn!==v)&&(mo=null,Wl=qr()+500,sl(p,v));do try{X_();break}catch(ke){Pg(p,ke)}while(!0);Xf(),gd.current=Q,wr=q,bn!==null?v=0:(kn=null,Hn=0,v=Pn)}if(v!==0){if(v===2&&(q=Fo(p),q!==0&&(M=q,v=Dh(p,q))),v===1)throw A=Jc,sl(p,0),yo(p,M),Ui(p,qr()),A;if(v===6)yo(p,M);else{if(q=p.current.alternate,(M&30)===0&&!Ng(q)&&(v=kd(p,M),v===2&&(Q=Fo(p),Q!==0&&(M=Q,v=Dh(p,Q))),v===1))throw A=Jc,sl(p,0),yo(p,M),Ui(p,qr()),A;switch(p.finishedWork=q,p.finishedLanes=M,v){case 0:case 1:throw Error(n(345));case 2:al(p,Fi,mo);break;case 3:if(yo(p,M),(M&130023424)===M&&(v=Rh+500-qr(),10<v)){if(Os(p,0)!==0)break;if(q=p.suspendedLanes,(q&M)!==M){Si(),p.pingedLanes|=p.suspendedLanes&q;break}p.timeoutHandle=Rf(al.bind(null,p,Fi,mo),v);break}al(p,Fi,mo);break;case 4:if(yo(p,M),(M&4194240)===M)break;for(v=p.eventTimes,q=-1;0<M;){var de=31-ar(M);Q=1<<de,de=v[de],de>q&&(q=de),M&=~Q}if(M=q,M=qr()-M,M=(120>M?120:480>M?480:1080>M?1080:1920>M?1920:3e3>M?3e3:4320>M?4320:1960*Hb(M/1960))-M,10<M){p.timeoutHandle=Rf(al.bind(null,p,Fi,mo),M);break}al(p,Fi,mo);break;case 5:al(p,Fi,mo);break;default:throw Error(n(329))}}}return Ui(p,qr()),p.callbackNode===A?$g.bind(null,p):null}function Dh(p,v){var A=bd;return p.current.memoizedState.isDehydrated&&(sl(p,v).flags|=256),p=kd(p,v),p!==2&&(v=Fi,Fi=A,v!==null&&Lh(v)),p}function Lh(p){Fi===null?Fi=p:Fi.push.apply(Fi,p)}function Ng(p){for(var v=p;;){if(v.flags&16384){var A=v.updateQueue;if(A!==null&&(A=A.stores,A!==null))for(var M=0;M<A.length;M++){var q=A[M],Q=q.getSnapshot;q=q.value;try{if(!Bs(Q(),q))return!1}catch{return!1}}}if(A=v.child,v.subtreeFlags&16384&&A!==null)A.return=v,v=A;else{if(v===p)break;for(;v.sibling===null;){if(v.return===null||v.return===p)return!0;v=v.return}v.sibling.return=v.return,v=v.sibling}}return!0}function yo(p,v){for(v&=~Ph,v&=~yd,p.suspendedLanes|=v,p.pingedLanes&=~v,p=p.expirationTimes;0<v;){var A=31-ar(v),M=1<<A;p[A]=-1,v&=~M}}function Og(p){if((wr&6)!==0)throw Error(n(327));Hl();var v=Os(p,0);if((v&1)===0)return Ui(p,qr()),null;var A=kd(p,v);if(p.tag!==0&&A===2){var M=Fo(p);M!==0&&(v=M,A=Dh(p,M))}if(A===1)throw A=Jc,sl(p,0),yo(p,v),Ui(p,qr()),A;if(A===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=v,al(p,Fi,mo),Ui(p,qr()),null}function Bh(p,v){var A=wr;wr|=1;try{return p(v)}finally{wr=A,wr===0&&(Wl=qr()+500,ed&&co())}}function il(p){nl!==null&&nl.tag===0&&(wr&6)===0&&Hl();var v=wr;wr|=1;var A=ws.transition,M=ur;try{if(ws.transition=null,ur=1,p)return p()}finally{ur=M,ws.transition=A,wr=v,(wr&6)===0&&co()}}function zh(){Qi=ql.current,Hr(ql)}function sl(p,v){p.finishedWork=null,p.finishedLanes=0;var A=p.timeoutHandle;if(A!==-1&&(p.timeoutHandle=-1,Sb(A)),bn!==null)for(A=bn.return;A!==null;){var M=A;switch(Bf(M),M.tag){case 1:M=M.type.childContextTypes,M!=null&&Qu();break;case 3:Qo(),Hr(Ri),Hr(xi),rh();break;case 5:eh(M);break;case 4:Qo();break;case 13:Hr(sn);break;case 19:Hr(sn);break;case 10:Yf(M.type._context);break;case 22:case 23:zh()}A=A.return}if(kn=p,bn=p=bo(p.current,null),Hn=Qi=v,Pn=0,Jc=null,Ph=yd=rl=0,Fi=bd=null,Bl!==null){for(v=0;v<Bl.length;v++)if(A=Bl[v],M=A.interleaved,M!==null){A.interleaved=null;var q=M.next,Q=A.pending;if(Q!==null){var de=Q.next;Q.next=q,M.next=de}A.pending=M}Bl=null}return p}function Pg(p,v){do{var A=bn;try{if(Xf(),nh.current=fd,sh){for(var M=rn.memoizedState;M!==null;){var q=M.queue;q!==null&&(q.pending=null),M=M.next}sh=!1}if(Zo=0,On=_n=rn=null,el=!1,ho=0,vd.current=null,A===null||A.return===null){Pn=1,Jc=v,bn=null;break}e:{var Q=p,de=A.return,ke=A,Oe=v;if(v=Hn,ke.flags|=32768,Oe!==null&&typeof Oe=="object"&&typeof Oe.then=="function"){var Ge=Oe,ct=ke,ft=ct.tag;if((ct.mode&1)===0&&(ft===0||ft===11||ft===15)){var ot=ct.alternate;ot?(ct.updateQueue=ot.updateQueue,ct.memoizedState=ot.memoizedState,ct.lanes=ot.lanes):(ct.updateQueue=null,ct.memoizedState=null)}var Ct=Db(de);if(Ct!==null){Ct.flags&=-257,_i(Ct,de,ke,Q,v),Ct.mode&1&&fg(Q,Ge,v),v=Ct,Oe=Ge;var Ot=v.updateQueue;if(Ot===null){var Pt=new Set;Pt.add(Oe),v.updateQueue=Pt}else Ot.add(Oe);break e}else{if((v&1)===0){fg(Q,Ge,v),Fh();break e}Oe=Error(n(426))}}else if(tn&&ke.mode&1){var zr=Db(de);if(zr!==null){(zr.flags&65536)===0&&(zr.flags|=256),_i(zr,de,ke,Q,v),Hf(Fl(Oe,ke));break e}}Q=Oe=Fl(Oe,ke),Pn!==4&&(Pn=2),bd===null?bd=[Q]:bd.push(Q),Q=de;do{switch(Q.tag){case 3:Q.flags|=65536,v&=-v,Q.lanes|=v;var qe=ug(Q,Oe,v);jb(Q,qe);break e;case 1:ke=Oe;var Ie=Q.type,Ke=Q.stateNode;if((Q.flags&128)===0&&(typeof Ie.getDerivedStateFromError=="function"||Ke!==null&&typeof Ke.componentDidCatch=="function"&&(go===null||!go.has(Ke)))){Q.flags|=65536,v&=-v,Q.lanes|=v;var gt=dg(Q,ke,v);jb(Q,gt);break e}}Q=Q.return}while(Q!==null)}eu(A)}catch(Bt){v=Bt,bn===A&&A!==null&&(bn=A=A.return);continue}break}while(!0)}function Gb(){var p=gd.current;return gd.current=fd,p===null?fd:p}function Fh(){(Pn===0||Pn===3||Pn===2)&&(Pn=4),kn===null||(rl&268435455)===0&&(yd&268435455)===0||yo(kn,Hn)}function kd(p,v){var A=wr;wr|=2;var M=Gb();(kn!==p||Hn!==v)&&(mo=null,sl(p,v));do try{Vb();break}catch(q){Pg(p,q)}while(!0);if(Xf(),wr=A,gd.current=M,bn!==null)throw Error(n(261));return kn=null,Hn=0,Pn}function Vb(){for(;bn!==null;)Rg(bn)}function X_(){for(;bn!==null&&!zo();)Rg(bn)}function Rg(p){var v=Dg(p.alternate,p,Qi);p.memoizedProps=p.pendingProps,v===null?eu(p):bn=v,vd.current=null}function eu(p){var v=p;do{var A=v.alternate;if(p=v.return,(v.flags&32768)===0){if(A=zb(A,v,Qi),A!==null){bn=A;return}}else{if(A=Fb(A,v),A!==null){A.flags&=32767,bn=A;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{Pn=6,bn=null;return}}if(v=v.sibling,v!==null){bn=v;return}bn=v=p}while(v!==null);Pn===0&&(Pn=5)}function al(p,v,A){var M=ur,q=ws.transition;try{ws.transition=null,ur=1,Mg(p,v,A,M)}finally{ws.transition=q,ur=M}return null}function Mg(p,v,A,M){do Hl();while(nl!==null);if((wr&6)!==0)throw Error(n(327));A=p.finishedWork;var q=p.finishedLanes;if(A===null)return null;if(p.finishedWork=null,p.finishedLanes=0,A===p.current)throw Error(n(177));p.callbackNode=null,p.callbackPriority=0;var Q=A.lanes|A.childLanes;if(Cc(p,Q),p===kn&&(bn=kn=null,Hn=0),(A.subtreeFlags&2064)===0&&(A.flags&2064)===0||wd||(wd=!0,Lg(Et,function(){return Hl(),null})),Q=(A.flags&15990)!==0,(A.subtreeFlags&15990)!==0||Q){Q=ws.transition,ws.transition=null;var de=ur;ur=1;var ke=wr;wr|=4,vd.current=null,qb(p,A),$h(A,p),yb(Of),so=!!Nf,Of=Nf=null,p.current=A,jg(A),El(),wr=ke,ur=de,ws.transition=Q}else p.current=A;if(wd&&(wd=!1,nl=p,_d=q),Q=p.pendingLanes,Q===0&&(go=null),pt(A.stateNode),Ui(p,qr()),v!==null)for(M=p.onRecoverableError,A=0;A<v.length;A++)q=v[A],M(q.value,{componentStack:q.stack,digest:q.digest});if(xd)throw xd=!1,p=Mh,Mh=null,p;return(_d&1)!==0&&p.tag!==0&&Hl(),Q=p.pendingLanes,(Q&1)!==0?p===Ih?Qc++:(Qc=0,Ih=p):Qc=0,co(),null}function Hl(){if(nl!==null){var p=It(_d),v=ws.transition,A=ur;try{if(ws.transition=null,ur=16>p?16:p,nl===null)var M=!1;else{if(p=nl,nl=null,_d=0,(wr&6)!==0)throw Error(n(331));var q=wr;for(wr|=4,Nt=p.current;Nt!==null;){var Q=Nt,de=Q.child;if((Nt.flags&16)!==0){var ke=Q.deletions;if(ke!==null){for(var Oe=0;Oe<ke.length;Oe++){var Ge=ke[Oe];for(Nt=Ge;Nt!==null;){var ct=Nt;switch(ct.tag){case 0:case 11:case 15:Xc(8,ct,Q)}var ft=ct.child;if(ft!==null)ft.return=ct,Nt=ft;else for(;Nt!==null;){ct=Nt;var ot=ct.sibling,Ct=ct.return;if(kg(ct),ct===Ge){Nt=null;break}if(ot!==null){ot.return=Ct,Nt=ot;break}Nt=Ct}}}var Ot=Q.alternate;if(Ot!==null){var Pt=Ot.child;if(Pt!==null){Ot.child=null;do{var zr=Pt.sibling;Pt.sibling=null,Pt=zr}while(Pt!==null)}}Nt=Q}}if((Q.subtreeFlags&2064)!==0&&de!==null)de.return=Q,Nt=de;else e:for(;Nt!==null;){if(Q=Nt,(Q.flags&2048)!==0)switch(Q.tag){case 0:case 11:case 15:Xc(9,Q,Q.return)}var qe=Q.sibling;if(qe!==null){qe.return=Q.return,Nt=qe;break e}Nt=Q.return}}var Ie=p.current;for(Nt=Ie;Nt!==null;){de=Nt;var Ke=de.child;if((de.subtreeFlags&2064)!==0&&Ke!==null)Ke.return=de,Nt=Ke;else e:for(de=Ie;Nt!==null;){if(ke=Nt,(ke.flags&2048)!==0)try{switch(ke.tag){case 0:case 11:case 15:Eh(9,ke)}}catch(Bt){an(ke,ke.return,Bt)}if(ke===de){Nt=null;break e}var gt=ke.sibling;if(gt!==null){gt.return=ke.return,Nt=gt;break e}Nt=ke.return}}if(wr=q,co(),nr&&typeof nr.onPostCommitFiberRoot=="function")try{nr.onPostCommitFiberRoot(_t,p)}catch{}M=!0}return M}finally{ur=A,ws.transition=v}}return!1}function Ig(p,v,A){v=Fl(A,v),v=ug(p,v,1),p=fo(p,v,1),v=Si(),p!==null&&(Ps(p,1,v),Ui(p,v))}function an(p,v,A){if(p.tag===3)Ig(p,p,A);else for(;v!==null;){if(v.tag===3){Ig(v,p,A);break}else if(v.tag===1){var M=v.stateNode;if(typeof v.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(go===null||!go.has(M))){p=Fl(A,p),p=dg(v,p,1),v=fo(v,p,1),p=Si(),v!==null&&(Ps(v,1,p),Ui(v,p));break}}v=v.return}}function Kb(p,v,A){var M=p.pingCache;M!==null&&M.delete(v),v=Si(),p.pingedLanes|=p.suspendedLanes&A,kn===p&&(Hn&A)===A&&(Pn===4||Pn===3&&(Hn&130023424)===Hn&&500>qr()-Rh?sl(p,0):Ph|=A),Ui(p,v)}function Xb(p,v){v===0&&((p.mode&1)===0?v=1:(v=jr,jr<<=1,(jr&130023424)===0&&(jr=4194304)));var A=Si();p=Oa(p,v),p!==null&&(Ps(p,v,A),Ui(p,A))}function Yb(p){var v=p.memoizedState,A=0;v!==null&&(A=v.retryLane),Xb(p,A)}function Jb(p,v){var A=0;switch(p.tag){case 13:var M=p.stateNode,q=p.memoizedState;q!==null&&(A=q.retryLane);break;case 19:M=p.stateNode;break;default:throw Error(n(314))}M!==null&&M.delete(v),Xb(p,A)}var Dg;Dg=function(p,v,A){if(p!==null)if(p.memoizedProps!==v.pendingProps||Ri.current)zi=!0;else{if((p.lanes&A)===0&&(v.flags&128)===0)return zi=!1,K_(p,v,A);zi=(p.flags&131072)!==0}else zi=!1,tn&&(v.flags&1048576)!==0&&Vo(v,rd,v.index);switch(v.lanes=0,v.tag){case 2:var M=v.type;pd(p,v),p=v.pendingProps;var q=wi(v,xi.current);Ll(v,A),q=oh(null,v,M,p,q,A);var Q=lh();return v.flags|=1,typeof q=="object"&&q!==null&&typeof q.render=="function"&&q.$$typeof===void 0?(v.tag=1,v.memoizedState=null,v.updateQueue=null,Mi(M)?(Q=!0,Zu(v)):Q=!1,v.memoizedState=q.state!==null&&q.state!==void 0?q.state:null,ad(v),q.updater=Ra,v.stateNode=q,q._reactInternals=v,fh(v,M,p,A),v=gh(null,v,M,!0,Q,A)):(v.tag=0,tn&&Q&&wn(v),ri(null,v,q,A),v=v.child),v;case 16:M=v.elementType;e:{switch(pd(p,v),p=v.pendingProps,q=M._init,M=q(M._payload),v.type=M,q=v.tag=Qb(M),p=Sn(M,p),q){case 0:v=mh(null,v,M,p,A);break e;case 1:v=vg(null,v,M,p,A);break e;case 11:v=hg(null,v,M,p,A);break e;case 14:v=Vc(null,v,M,Sn(M.type,p),A);break e}throw Error(n(306,M,""))}return v;case 0:return M=v.type,q=v.pendingProps,q=v.elementType===M?q:Sn(M,q),mh(p,v,M,q,A);case 1:return M=v.type,q=v.pendingProps,q=v.elementType===M?q:Sn(M,q),vg(p,v,M,q,A);case 3:e:{if(vh(v),p===null)throw Error(n(387));M=v.pendingProps,Q=v.memoizedState,q=Q.element,Qf(p,v),od(v,M,null,A);var de=v.memoizedState;if(M=de.element,Q.isDehydrated)if(Q={element:M,isDehydrated:!1,cache:de.cache,pendingSuspenseBoundaries:de.pendingSuspenseBoundaries,transitions:de.transitions},v.updateQueue.baseState=Q,v.memoizedState=Q,v.flags&256){q=Fl(Error(n(423)),v),v=yg(p,v,M,A,q);break e}else if(M!==q){q=Fl(Error(n(424)),v),v=yg(p,v,M,A,q);break e}else for(Ji=oo(v.stateNode.containerInfo.firstChild),Li=v,tn=!0,Bi=null,A=Vf(v,null,M,A),v.child=A;A;)A.flags=A.flags&-3|4096,A=A.sibling;else{if(Ko(),M===q){v=Ma(p,v,A);break e}ri(p,v,M,A)}v=v.child}return v;case 5:return Fm(v),p===null&&qf(v),M=v.type,q=v.pendingProps,Q=p!==null?p.memoizedProps:null,de=q.children,Pf(M,q)?de=null:Q!==null&&Pf(M,Q)&&(v.flags|=32),gg(p,v),ri(p,v,de,A),v.child;case 6:return p===null&&qf(v),null;case 13:return bg(p,v,A);case 4:return Zf(v,v.stateNode.containerInfo),M=v.pendingProps,p===null?v.child=Dl(v,null,M,A):ri(p,v,M,A),v.child;case 11:return M=v.type,q=v.pendingProps,q=v.elementType===M?q:Sn(M,q),hg(p,v,M,q,A);case 7:return ri(p,v,v.pendingProps,A),v.child;case 8:return ri(p,v,v.pendingProps.children,A),v.child;case 12:return ri(p,v,v.pendingProps.children,A),v.child;case 10:e:{if(M=v.type._context,q=v.pendingProps,Q=v.memoizedProps,de=q.value,Br(Xo,M._currentValue),M._currentValue=de,Q!==null)if(Bs(Q.value,de)){if(Q.children===q.children&&!Ri.current){v=Ma(p,v,A);break e}}else for(Q=v.child,Q!==null&&(Q.return=v);Q!==null;){var ke=Q.dependencies;if(ke!==null){de=Q.child;for(var Oe=ke.firstContext;Oe!==null;){if(Oe.context===M){if(Q.tag===1){Oe=Pa(-1,A&-A),Oe.tag=2;var Ge=Q.updateQueue;if(Ge!==null){Ge=Ge.shared;var ct=Ge.pending;ct===null?Oe.next=Oe:(Oe.next=ct.next,ct.next=Oe),Ge.pending=Oe}}Q.lanes|=A,Oe=Q.alternate,Oe!==null&&(Oe.lanes|=A),zm(Q.return,A,v),ke.lanes|=A;break}Oe=Oe.next}}else if(Q.tag===10)de=Q.type===v.type?null:Q.child;else if(Q.tag===18){if(de=Q.return,de===null)throw Error(n(341));de.lanes|=A,ke=de.alternate,ke!==null&&(ke.lanes|=A),zm(de,A,v),de=Q.sibling}else de=Q.child;if(de!==null)de.return=Q;else for(de=Q;de!==null;){if(de===v){de=null;break}if(Q=de.sibling,Q!==null){Q.return=de.return,de=Q;break}de=de.return}Q=de}ri(p,v,q.children,A),v=v.child}return v;case 9:return q=v.type,M=v.pendingProps.children,Ll(v,A),q=ys(q),M=M(q),v.flags|=1,ri(p,v,M,A),v.child;case 14:return M=v.type,q=Sn(M,v.pendingProps),q=Sn(M.type,q),Vc(p,v,M,q,A);case 15:return pg(p,v,v.type,v.pendingProps,A);case 17:return M=v.type,q=v.pendingProps,q=v.elementType===M?q:Sn(M,q),pd(p,v),v.tag=1,Mi(M)?(p=!0,Zu(v)):p=!1,Ll(v,A),lg(v,M,q),fh(v,M,q,A),gh(null,v,M,!0,p,A);case 19:return wh(p,v,A);case 22:return mg(p,v,A)}throw Error(n(156,v.tag))};function Lg(p,v){return pi(p,v)}function Y_(p,v,A,M){this.tag=p,this.key=A,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=v,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zi(p,v,A,M){return new Y_(p,v,A,M)}function Uh(p){return p=p.prototype,!(!p||!p.isReactComponent)}function Qb(p){if(typeof p=="function")return Uh(p)?1:0;if(p!=null){if(p=p.$$typeof,p===V)return 11;if(p===G)return 14}return 2}function bo(p,v){var A=p.alternate;return A===null?(A=Zi(p.tag,v,p.key,p.mode),A.elementType=p.elementType,A.type=p.type,A.stateNode=p.stateNode,A.alternate=p,p.alternate=A):(A.pendingProps=v,A.type=p.type,A.flags=0,A.subtreeFlags=0,A.deletions=null),A.flags=p.flags&14680064,A.childLanes=p.childLanes,A.lanes=p.lanes,A.child=p.child,A.memoizedProps=p.memoizedProps,A.memoizedState=p.memoizedState,A.updateQueue=p.updateQueue,v=p.dependencies,A.dependencies=v===null?null:{lanes:v.lanes,firstContext:v.firstContext},A.sibling=p.sibling,A.index=p.index,A.ref=p.ref,A}function Cd(p,v,A,M,q,Q){var de=2;if(M=p,typeof p=="function")Uh(p)&&(de=1);else if(typeof p=="string")de=5;else e:switch(p){case N:return Gl(A.children,q,Q,v);case O:de=8,q|=8;break;case I:return p=Zi(12,A,v,q|2),p.elementType=I,p.lanes=Q,p;case U:return p=Zi(13,A,v,q),p.elementType=U,p.lanes=Q,p;case D:return p=Zi(19,A,v,q),p.elementType=D,p.lanes=Q,p;case ae:return Ed(A,q,Q,v);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case W:de=10;break e;case H:de=9;break e;case V:de=11;break e;case G:de=14;break e;case ee:de=16,M=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return v=Zi(de,A,v,q),v.elementType=p,v.type=M,v.lanes=Q,v}function Gl(p,v,A,M){return p=Zi(7,p,M,v),p.lanes=A,p}function Ed(p,v,A,M){return p=Zi(22,p,M,v),p.elementType=ae,p.lanes=A,p.stateNode={isHidden:!1},p}function qh(p,v,A){return p=Zi(6,p,null,v),p.lanes=A,p}function Wh(p,v,A){return v=Zi(4,p.children!==null?p.children:[],p.key,v),v.lanes=A,v.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},v}function J_(p,v,A,M,q){this.tag=v,this.containerInfo=p,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Je(0),this.expirationTimes=Je(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Je(0),this.identifierPrefix=M,this.onRecoverableError=q,this.mutableSourceEagerHydrationData=null}function Hh(p,v,A,M,q,Q,de,ke,Oe){return p=new J_(p,v,A,ke,Oe),v===1?(v=1,Q===!0&&(v|=8)):v=0,Q=Zi(3,null,null,v),p.current=Q,Q.stateNode=p,Q.memoizedState={element:M,isDehydrated:A,cache:null,transitions:null,pendingSuspenseBoundaries:null},ad(Q),p}function Q_(p,v,A){var M=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:M==null?null:""+M,children:p,containerInfo:v,implementation:A}}function Bg(p){if(!p)return lo;p=p._reactInternals;e:{if(At(p)!==p||p.tag!==1)throw Error(n(170));var v=p;do{switch(v.tag){case 3:v=v.stateNode.context;break e;case 1:if(Mi(v.type)){v=v.stateNode.__reactInternalMemoizedMergedChildContext;break e}}v=v.return}while(v!==null);throw Error(n(171))}if(p.tag===1){var A=p.type;if(Mi(A))return Mm(p,A,v)}return v}function Zb(p,v,A,M,q,Q,de,ke,Oe){return p=Hh(A,M,!0,p,q,Q,de,ke,Oe),p.context=Bg(null),A=p.current,M=Si(),q=vo(A),Q=Pa(M,q),Q.callback=v??null,fo(A,Q,q),p.current.lanes=q,Ps(p,q,M),Ui(p,M),p}function jd(p,v,A,M){var q=v.current,Q=Si(),de=vo(q);return A=Bg(A),v.context===null?v.context=A:v.pendingContext=A,v=Pa(Q,de),v.payload={element:p},M=M===void 0?null:M,M!==null&&(v.callback=M),p=fo(q,v,de),p!==null&&(Ws(p,q,de,Q),qc(p,q,de)),de}function Td(p){if(p=p.current,!p.child)return null;switch(p.child.tag){case 5:return p.child.stateNode;default:return p.child.stateNode}}function zg(p,v){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var A=p.retryLane;p.retryLane=A!==0&&A<v?A:v}}function Gh(p,v){zg(p,v),(p=p.alternate)&&zg(p,v)}function ex(){return null}var tx=typeof reportError=="function"?reportError:function(p){console.error(p)};function Vh(p){this._internalRoot=p}Vl.prototype.render=Vh.prototype.render=function(p){var v=this._internalRoot;if(v===null)throw Error(n(409));jd(p,v,null,null)},Vl.prototype.unmount=Vh.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var v=p.containerInfo;il(function(){jd(null,p,null,null)}),v[aa]=null}};function Vl(p){this._internalRoot=p}Vl.prototype.unstable_scheduleHydration=function(p){if(p){var v=Za();p={blockedOn:null,target:p,priority:v};for(var A=0;A<Rs.length&&v!==0&&v<Rs[A].priority;A++);Rs.splice(A,0,p),A===0&&Ec(p)}};function Kh(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Ad(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function rx(){}function nx(p,v,A,M,q){if(q){if(typeof M=="function"){var Q=M;M=function(){var Ge=Td(de);Q.call(Ge)}}var de=Zb(v,M,p,0,null,!1,!1,"",rx);return p._reactRootContainer=de,p[aa]=de.current,Lc(p.nodeType===8?p.parentNode:p),il(),de}for(;q=p.lastChild;)p.removeChild(q);if(typeof M=="function"){var ke=M;M=function(){var Ge=Td(Oe);ke.call(Ge)}}var Oe=Hh(p,0,!1,null,null,!1,!1,"",rx);return p._reactRootContainer=Oe,p[aa]=Oe.current,Lc(p.nodeType===8?p.parentNode:p),il(function(){jd(v,Oe,A,M)}),Oe}function tu(p,v,A,M,q){var Q=A._reactRootContainer;if(Q){var de=Q;if(typeof q=="function"){var ke=q;q=function(){var Oe=Td(de);ke.call(Oe)}}jd(v,de,p,q)}else de=nx(A,v,p,q,M);return Td(de)}ea=function(p){switch(p.tag){case 3:var v=p.stateNode;if(v.current.memoizedState.isDehydrated){var A=cs(v.pendingLanes);A!==0&&(jl(v,A|1),Ui(v,qr()),(wr&6)===0&&(Wl=qr()+500,co()))}break;case 13:il(function(){var M=Oa(p,1);if(M!==null){var q=Si();Ws(M,p,1,q)}}),Gh(p,1)}},Ca=function(p){if(p.tag===13){var v=Oa(p,134217728);if(v!==null){var A=Si();Ws(v,p,134217728,A)}Gh(p,134217728)}},Ea=function(p){if(p.tag===13){var v=vo(p),A=Oa(p,v);if(A!==null){var M=Si();Ws(A,p,v,M)}Gh(p,v)}},Za=function(){return ur},Uo=function(p,v){var A=ur;try{return ur=p,v()}finally{ur=A}},zn=function(p,v,A){switch(v){case"input":if(ut(p,A),v=A.name,A.type==="radio"&&v!=null){for(A=p;A.parentNode;)A=A.parentNode;for(A=A.querySelectorAll("input[name="+JSON.stringify(""+v)+'][type="radio"]'),v=0;v<A.length;v++){var M=A[v];if(M!==p&&M.form===p.form){var q=Ju(M);if(!q)throw Error(n(90));Me(M),ut(M,q)}}}break;case"textarea":en(p,A);break;case"select":v=A.value,v!=null&&sr(p,!!A.multiple,v,!1)}},As=Bh,Lo=il;var Fg={usingClientEntryPoint:!1,Events:[Fc,Ol,Ju,wa,_a,Bh]},Hs={findFiberByHostInstance:Ho,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ix={bundleType:Hs.bundleType,version:Hs.version,rendererPackageName:Hs.rendererPackageName,rendererConfig:Hs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(p){return p=os(p),p===null?null:p.stateNode},findFiberByHostInstance:Hs.findFiberByHostInstance||ex,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ru.isDisabled&&ru.supportsFiber)try{_t=ru.inject(ix),nr=ru}catch{}}return Gs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Fg,Gs.createPortal=function(p,v){var A=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Kh(v))throw Error(n(200));return Q_(p,v,null,A)},Gs.createRoot=function(p,v){if(!Kh(p))throw Error(n(299));var A=!1,M="",q=tx;return v!=null&&(v.unstable_strictMode===!0&&(A=!0),v.identifierPrefix!==void 0&&(M=v.identifierPrefix),v.onRecoverableError!==void 0&&(q=v.onRecoverableError)),v=Hh(p,1,!1,null,null,A,!1,M,q),p[aa]=v.current,Lc(p.nodeType===8?p.parentNode:p),new Vh(v)},Gs.findDOMNode=function(p){if(p==null)return null;if(p.nodeType===1)return p;var v=p._reactInternals;if(v===void 0)throw typeof p.render=="function"?Error(n(188)):(p=Object.keys(p).join(","),Error(n(268,p)));return p=os(v),p=p===null?null:p.stateNode,p},Gs.flushSync=function(p){return il(p)},Gs.hydrate=function(p,v,A){if(!Ad(v))throw Error(n(200));return tu(null,p,v,!0,A)},Gs.hydrateRoot=function(p,v,A){if(!Kh(p))throw Error(n(405));var M=A!=null&&A.hydratedSources||null,q=!1,Q="",de=tx;if(A!=null&&(A.unstable_strictMode===!0&&(q=!0),A.identifierPrefix!==void 0&&(Q=A.identifierPrefix),A.onRecoverableError!==void 0&&(de=A.onRecoverableError)),v=Zb(v,null,p,1,A??null,q,!1,Q,de),p[aa]=v.current,Lc(p),M)for(p=0;p<M.length;p++)A=M[p],q=A._getVersion,q=q(A._source),v.mutableSourceEagerHydrationData==null?v.mutableSourceEagerHydrationData=[A,q]:v.mutableSourceEagerHydrationData.push(A,q);return new Vl(v)},Gs.render=function(p,v,A){if(!Ad(v))throw Error(n(200));return tu(null,p,v,!1,A)},Gs.unmountComponentAtNode=function(p){if(!Ad(p))throw Error(n(40));return p._reactRootContainer?(il(function(){tu(null,null,p,!1,function(){p._reactRootContainer=null,p[aa]=null})}),!0):!1},Gs.unstable_batchedUpdates=Bh,Gs.unstable_renderSubtreeIntoContainer=function(p,v,A,M){if(!Ad(A))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return tu(p,v,A,!1,M)},Gs.version="18.3.1-next-f1338f8080-20240426",Gs}var b$;function R5(){if(b$)return n1.exports;b$=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),n1.exports=cU(),n1.exports}var x$;function uU(){if(x$)return ox;x$=1;var e=R5();return ox.createRoot=e.createRoot,ox.hydrateRoot=e.hydrateRoot,ox}var dU=uU();const fU=Xr(dU);var B=yT();const Fe=Xr(B),w$=e=>{let r;const n=new Set,i=(f,m)=>{const h=typeof f=="function"?f(r):f;if(!Object.is(h,r)){const b=r;r=m??(typeof h!="object"||h===null)?h:Object.assign({},r,h),n.forEach(x=>x(r,b))}},s=()=>r,o={setState:i,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f))},u=r=e(i,s,o);return o},hU=(e=>e?w$(e):w$),pU=e=>e;function mU(e,r=pU){const n=Fe.useSyncExternalStore(e.subscribe,Fe.useCallback(()=>r(e.getState()),[e,r]),Fe.useCallback(()=>r(e.getInitialState()),[e,r]));return Fe.useDebugValue(n),n}const _$=e=>{const r=hU(e),n=i=>mU(r,i);return Object.assign(n,r),n},jn=(e=>e?_$(e):_$);function Ro(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const a1=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${Ro(e)}`,S$=({sessionId:e})=>`claude --session-id ${Ro(e)}`,gU=()=>"claude --resume",M5=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:a1},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:S$},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:a1},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:a1},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:S$},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:gU},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let Da=null;async function vU(){if(Da)return Da;try{const e=await window.api.app.engageRulesPath();if(!e)return Da=[],Da;const r=await window.api.config.readJson(e);if(!r.exists||r.parseError||!r.data)return Da=[],Da;const n=r.data;if(!n.presets||!Array.isArray(n.presets))return Da=[],Da;const i=n.projectPath;return Da=n.presets.map(s=>({id:s.id,label:s.label,description:s.description,category:"engage",cwd:i,platform:s.platform,pipeline:s.pipeline,rules:s.rules,command:()=>`cd ${Ro(i)} && ${s.cliEntry}`})),Da}catch(e){return console.warn("[presets] Failed to load engage presets:",e),Da=[],Da}}async function I5(e){const r=M5.find(i=>i.id===e);return r||((await vU()).find(i=>i.id===e)??null)}async function yU(e){return e.cwd==="app-cwd"?window.api.app.cwd():e.cwd==="home"?window.api.app.homeDir():e.cwd==="pick"?window.api.app.pickDirectory():e.cwd}function D5(e,r){return e.command?e.command(r):null}function bU(e){const r=e.split("/").filter(Boolean);return r[r.length-1]||e}const Gt=jn((e,r)=>({tabs:[],activeTabId:null,hydrated:!1,addTab:({id:n,cwd:i,startupCommand:s,presetId:a=null,label:l})=>{const o=n??crypto.randomUUID();if(r().tabs.find(m=>m.id===o))return e({activeTabId:o}),o;const f={id:o,claudeSessionId:o,label:l??bU(i),cwd:i,pid:null,status:"spawning",exitCode:null,startupCommand:s,presetId:a,generation:0};return e({tabs:[...r().tabs,f],activeTabId:o}),o},setTabRunning:(n,i)=>e({tabs:r().tabs.map(s=>s.id===n?{...s,pid:i,status:"running"}:s)}),setTabExited:(n,i)=>e({tabs:r().tabs.map(s=>s.id===n?{...s,status:"exited",exitCode:i}:s)}),closeTab:n=>{var a;window.api.pty.kill(n),window.api.watchers.killTab(n).catch(()=>{}),window.api.transcripts.closeTab(n).catch(()=>{});const i=r().tabs.filter(l=>l.id!==n),s=r().activeTabId===n?((a=i[i.length-1])==null?void 0:a.id)??null:r().activeTabId;e({tabs:i,activeTabId:s})},setActive:n=>e({activeTabId:n}),restartTab:n=>{const i=r().tabs.find(l=>l.id===n);if(!i)return;window.api.pty.kill(n);const s=crypto.randomUUID(),a=l=>{e({tabs:r().tabs.map(o=>o.id===n?{...o,claudeSessionId:s,pid:null,status:"spawning",exitCode:null,startupCommand:l,generation:o.generation+1}:o)})};i.presetId?I5(i.presetId).then(l=>{a(l?D5(l,{sessionId:s,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${Ro(s)}`)}):a(`claude --dangerously-skip-permissions --session-id ${Ro(s)}`)},reorderTab:(n,i)=>{const s=[...r().tabs];if(n<0||n>=s.length||i<0||i>=s.length||n===i)return;const[a]=s.splice(n,1);s.splice(i,0,a),e({tabs:s})},restoreTabs:(n,i)=>e({tabs:n,activeTabId:i,hydrated:!0})}));async function L5(){var n;if(Gt.getState().hydrated)return;try{const{tabs:i,activeTabId:s,freshStart:a}=await window.api.sessions.load();if(i.length>0){const l=await Promise.all(i.map(async u=>{let f=!a;if(f){const h=await window.api.transcripts.pathFor(u.cwd,u.claudeSessionId);f=await window.api.config.exists(h)}const m=f?u.claudeSessionId:crypto.randomUUID();return{id:u.id,claudeSessionId:m,cwd:u.cwd,label:u.label,presetId:u.presetId,pid:null,status:"spawning",exitCode:null,startupCommand:f?`claude --dangerously-skip-permissions --resume ${Ro(m)}`:`claude --dangerously-skip-permissions --session-id ${Ro(m)}`,generation:0}})),o=s&&l.find(u=>u.id===s)?s:((n=l[0])==null?void 0:n.id)??null;Gt.getState().restoreTabs(l,o)}else Gt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),Gt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:s}=Gt.getState(),a=i.map(l=>({id:l.id,claudeSessionId:l.claudeSessionId,cwd:l.cwd,label:l.label,presetId:l.presetId}));window.api.sessions.save({tabs:a,activeTabId:s}).catch(l=>{console.warn("[sessions] save failed:",l)})};let r=null;Gt.subscribe((i,s)=>{i.hydrated&&(i.tabs===s.tabs&&i.activeTabId===s.activeTabId||(r!==null&&window.clearTimeout(r),r=window.setTimeout(e,200)))}),e()}const xU=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:L5,useSessions:Gt},Symbol.toStringTag,{value:"Module"})),wU=5,k$=100,_U=5e3,nE=new Map;function C$(e){const r=nE.get(e);r!==void 0&&(clearTimeout(r),nE.delete(e))}function SU(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const pp=jn((e,r)=>({toasts:[],history:[],unreadCount:0,show:(n,i)=>{const s=SU(),a=Date.now();e(o=>{const u=[...o.toasts,{id:s,kind:n,message:i,createdAt:a}];for(;u.length>wU;){const h=u.shift();h&&C$(h.id)}const m=[{id:s,kind:n,message:i,createdAt:a,read:!1},...o.history];return m.length>k$&&(m.length=k$),{toasts:u,history:m,unreadCount:o.unreadCount+1}});const l=setTimeout(()=>r().dismiss(s),_U);return nE.set(s,l),s},dismiss:n=>{C$(n),e(i=>({toasts:i.toasts.filter(s=>s.id!==n)}))},markAllRead:()=>{e(n=>n.unreadCount===0?n:{history:n.history.map(i=>i.read?i:{...i,read:!0}),unreadCount:0})},clearHistory:()=>{e({history:[],unreadCount:0})},dismissHistoryEntry:n=>{e(i=>{const s=i.history.filter(l=>l.id!==n);if(s.length===i.history.length)return i;const a=i.history.find(l=>l.id===n&&!l.read);return{history:s,unreadCount:a?Math.max(0,i.unreadCount-1):i.unreadCount}})}})),it={info:e=>pp.getState().show("info",e),warn:e=>pp.getState().show("warn",e),error:e=>pp.getState().show("error",e)},B5=Object.freeze(Object.defineProperty({__proto__:null,toast:it,useToast:pp},Symbol.toStringTag,{value:"Module"})),E$=200,kU=/\x1b\[[0-9;]*m/g;function CU(e){return e.replace(kU,"")}const zv=jn((e,r)=>({watchers:{},initialized:!1,init:()=>{r().initialized||(e({initialized:!0}),window.api.watchers.onLine(n=>r().ingestLine(n)),window.api.watchers.onClosed(({watcherId:n})=>r().closed(n)))},add:async({tabId:n,label:i,command:s,cwd:a})=>{try{const l=await window.api.watchers.add({tabId:n,label:i,command:s,cwd:a??null}),o={watcherId:l.watcherId,tabId:l.tabId,label:l.label,command:l.command,cwd:l.cwd,pid:l.pid,startedAt:l.startedAt,lineCount:0,lines:[],lastLineAt:null};return e({watchers:{...r().watchers,[o.watcherId]:o}}),o}catch(l){return console.error("[watchers] add failed:",l),it.error("Failed to add watcher"),null}},remove:async n=>{try{await window.api.watchers.remove(n)}catch(s){console.error("[watchers] remove failed:",s);const a=s instanceof Error?s.message:String(s);it.error(`Could not remove watcher: ${a}`)}const i={...r().watchers};delete i[n],e({watchers:i})},watchersForTab:n=>Object.values(r().watchers).filter(i=>i.tabId===n),ingestLine:n=>{const i=r().watchers[n.watcherId];if(!i)return;const s=CU(n.line),a=i.lines.length>=E$?[...i.lines.slice(i.lines.length-E$+1),{line:s,ts:n.ts}]:[...i.lines,{line:s,ts:n.ts}];e({watchers:{...r().watchers,[n.watcherId]:{...i,lines:a,lineCount:i.lineCount+1,lastLineAt:n.ts}}})},closed:n=>{if(!r().watchers[n])return;const i={...r().watchers};delete i[n],e({watchers:i})}})),EU=4,j$=40,T$=6;function jU(e){const{onReorder:r,onActivate:n}=e,i=B.useRef(null),s=B.useRef(null),a=B.useRef(0),l=B.useRef(0),[o,u]=B.useState(!1),[,f]=B.useState(0),m=B.useRef(n);m.current=n;const h=B.useCallback(()=>i.current?Array.from(i.current.querySelectorAll("[data-drag-index]")):[],[]),b=B.useCallback((y,w,S)=>{for(let C=0;C<w.length;C++){const T=w[C].left+w[C].width/2;if(y<T)return C<=S?C:C-1}return w.length-1},[]),x=B.useCallback(()=>{const y=s.current,w=i.current;if(!(y!=null&&y.active)||!w)return;const S=w.getBoundingClientRect(),C=y.startX+y.deltaX,T=C-S.left,E=S.right-C;T<j$?w.scrollLeft-=T$:E<j$&&(w.scrollLeft+=T$),a.current=requestAnimationFrame(x)},[]);B.useEffect(()=>{const y=i.current;if(!y)return;let w=!1;const S=()=>{w||(w=!0,l.current=requestAnimationFrame(()=>{w=!1,f(E=>E+1)}))},C=E=>{var W;const $=s.current;if(!$)return;const N=E.clientX-$.startX;if(!$.active&&Math.abs(N)<EU)return;if(!$.active){$.active=!0,$.tabRects=h().map(H=>H.getBoundingClientRect()),u(!0);try{(W=i.current)==null||W.setPointerCapture($.pointerId)}catch{}a.current=requestAnimationFrame(x)}$.deltaX=N;const O=$.tabRects[$.fromIndex],I=O.left+O.width/2+N;$.currentIndex=b(I,$.tabRects,$.fromIndex),S()},T=E=>{const $=s.current;if($&&$.pointerId===E.pointerId){cancelAnimationFrame(a.current),cancelAnimationFrame(l.current);try{y.releasePointerCapture($.pointerId)}catch{}$.active&&$.fromIndex!==$.currentIndex?r($.fromIndex,$.currentIndex):m.current($.fromIndex),s.current=null,u(!1),f(N=>N+1)}};return y.addEventListener("pointermove",C),y.addEventListener("pointerup",T),y.addEventListener("pointercancel",T),()=>{y.removeEventListener("pointermove",C),y.removeEventListener("pointerup",T),y.removeEventListener("pointercancel",T),cancelAnimationFrame(a.current),cancelAnimationFrame(l.current)}},[r,h,b,x]);const k=B.useCallback((y,w)=>{y.button!==0||y.target.closest("button")||(s.current={active:!1,fromIndex:w,currentIndex:w,startX:y.clientX,deltaX:0,tabRects:[],pointerId:y.pointerId})},[]);return{getTabDragProps:B.useCallback(y=>{var C;const w=s.current,S={};if(w!=null&&w.active)if(y===w.fromIndex)S.transform=`translateX(${w.deltaX}px) scale(1.03)`,S.zIndex=10,S.opacity=.85,S.boxShadow="0 2px 8px rgba(0,0,0,0.4)",S.position="relative",S.pointerEvents="none";else{const T=w.fromIndex,E=w.currentIndex,N=(((C=w.tabRects[T])==null?void 0:C.width)??0)+4;S.transition="transform 0.15s ease",T<E&&y>T&&y<=E?S.transform=`translateX(-${N}px)`:T>E&&y>=E&&y<T?S.transform=`translateX(${N}px)`:S.transform="translateX(0)"}return{onPointerDown:T=>k(T,y),style:S,"data-drag-index":y}},[k]),isDragging:o,containerRef:i}}const TU=3e4;function AU(){const e=Gt(x=>x.tabs),r=Gt(x=>x.activeTabId),n=Gt(x=>x.closeTab),i=Gt(x=>x.setActive),s=Gt(x=>x.reorderTab),a=zv(x=>x.watchers),[l,o]=B.useState(()=>Date.now());B.useEffect(()=>{const x=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(x)},[]);const u=x=>{for(const k of Object.values(a))if(k.tabId===x&&k.lastLineAt&&l-k.lastLineAt<TU)return!0;return!1},{getTabDragProps:f,isDragging:m,containerRef:h}=jU({tabCount:e.length,onReorder:s,onActivate:x=>{const k=e[x];k&&i(k.id)}}),b=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return c.jsxs("div",{className:"h-11 bg-bg-elev border-b border-line flex items-end px-3 gap-0 shrink-0 relative","data-testid":"tour-tabbar",children:[c.jsx("div",{ref:h,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${m?"cursor-grabbing":""}`,children:e.map((x,k)=>{const _=x.id===r,y=f(k),w=b[k%b.length];return c.jsxs("div",{...y,style:y.style,className:`group flex items-center gap-2 px-3.5 pt-1.5 pb-2 rounded-t-[10px] text-[13px] shrink-0 transition-colors ${m?"":"cursor-grab"} ${_?"bg-bg text-fg font-medium relative z-10 -mb-px border border-b-0 border-line":"text-fg-dim hover:text-fg hover:bg-bg-hi/40"}`,title:x.cwd,"aria-current":_?"true":void 0,children:[c.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:w,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:x.status==="spawning"?.55:1}}),c.jsx("span",{className:"truncate max-w-[200px]",children:x.label}),x.status==="spawning"&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),u(x.id)&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"watcher emitted a line in the last 30s","data-testid":"tab-watcher-dot"}),c.jsx("button",{onClick:S=>{S.stopPropagation(),n(x.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${x.label}`,children:"×"})]},x.id)})}),c.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[c.jsx("span",{className:"font-semibold text-fg-dim",children:"Claude Session Manager"}),c.jsxs("span",{className:"font-mono text-[11px] text-fg-faint",children:["v","0.29.0"]})]})]})}function $U(e,r,n){return r?e.map(i=>i.id===r?{...i,lastActivityAt:n}:i):e}function NU(e,r,n){return{tabId:e,sessionUuid:n,cwd:r,path:null,todos:[],lastToolUses:[],plans:[],agents:[],usage:{inputTokens:0,outputTokens:0},lastEventAt:0,activityRing:[],activitySeq:0}}const s0=jn((e,r)=>({tabs:{},refs:{},unsubs:{},subscribe:(n,i,s)=>{const a={...r().refs};if(a[n]=(a[n]??0)+1,e({refs:a}),a[n]>1)return;e({tabs:{...r().tabs,[n]:NU(n,i,s)}});const l=window.api.transcripts.onEvent(n,o=>r().ingest(n,o));e({unsubs:{...r().unsubs,[n]:l}}),window.api.transcripts.subscribe({tabId:n,cwd:i,sessionUuid:s}).then(async o=>{const u=r().tabs[n];if(!u)return;if(!o.ok){const{toast:m}=await em(async()=>{const{toast:h}=await Promise.resolve().then(()=>B5);return{toast:h}},void 0,import.meta.url);m.error(`Live view unavailable: ${o.error??"subscribe failed"}`),e({tabs:{...r().tabs,[n]:{...u,path:null}}});return}e({tabs:{...r().tabs,[n]:{...u,path:o.path}}});const f=await window.api.transcripts.buffer(n);for(const m of f)r().ingest(n,m,{replay:!0})}).catch(o=>console.error("[live] transcripts.subscribe failed:",n,o))},unsubscribe:n=>{const i={...r().refs};if(!i[n])return;if(i[n]--,i[n]>0){e({refs:i});return}delete i[n];const s=r().unsubs[n];s==null||s();const a={...r().unsubs};delete a[n];const l={...r().tabs};delete l[n],window.api.transcripts.unsubscribe(n),e({refs:i,unsubs:a,tabs:l})},ingest:(n,i,s)=>{const a=r().tabs[n];if(!a)return;const l=Date.now(),o={...a,lastEventAt:s!=null&&s.replay?a.lastEventAt:l},u=[],f=(m,h)=>m.length>h?m.slice(0,h-1)+"…":m;switch(i.kind){case"todo_write":{const m=Array.isArray(i.data)?i.data:[];o.todos=m,s!=null&&s.replay||u.push({id:0,kind:"todo-update",at:l,label:`Todos · ${m.length} item${m.length!==1?"s":""}`});break}case"tool_use":{const m=i.data,h=m.input,b={};for(const x of["command","file_path","pattern","url","query","subagent_type","description"])h&&x in h&&(b[x]=h[x]);if(o.lastToolUses=[{id:m.id,name:m.name,input:b,at:l},...a.lastToolUses].slice(0,50),!(s!=null&&s.replay)){const x=m.input,k=["Edit","Write","NotebookEdit"].includes(m.name),_=typeof(x==null?void 0:x.file_path)=="string"?x.file_path:void 0,y=typeof(x==null?void 0:x.command)=="string"?x.command:void 0,w=_?_.split("/").pop()??_:y?f(y,28):"";u.push({id:0,kind:"tool-use",at:l,label:w?`${m.name} · ${w}`:m.name,target:_??y,toolName:m.name}),k&&_&&u.push({id:0,kind:"file-edit",at:l,label:`${m.name} · ${f(_.split("/").pop()??_,34)}`,target:_,toolName:m.name})}break}case"plan":{const m=i.data,h=typeof m=="string"?m:(m==null?void 0:m.plan)??JSON.stringify(m);o.plans=[{at:l,content:h??""},...a.plans].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"plan-revision",at:l,label:"Plan revised"});break}case"agent_spawn":{const m=i.data;o.agents=[{id:m==null?void 0:m.toolUseId,at:l,subagentType:m==null?void 0:m.subagent_type,description:m==null?void 0:m.description,lastActivityAt:l},...a.agents].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"agent-spawn",at:l,label:m!=null&&m.subagent_type?`Agent: ${f(m.subagent_type,32)}`:"Agent spawned"});break}case"usage":{const m=i.data,h=(a.usage.inputTokens||0)+(a.usage.outputTokens||0),b=m.input_tokens??m.inputTokens??0,x=m.output_tokens??m.outputTokens??0,k=h+b+x;o.usage={inputTokens:(a.usage.inputTokens||0)+b,outputTokens:(a.usage.outputTokens||0)+x,cacheCreationInputTokens:(a.usage.cacheCreationInputTokens||0)+(m.cache_creation_input_tokens??m.cacheCreationInputTokens??0),cacheReadInputTokens:(a.usage.cacheReadInputTokens||0)+(m.cache_read_input_tokens??m.cacheReadInputTokens??0)},!(s!=null&&s.replay)&&Math.floor(k/1e3)>Math.floor(h/1e3)&&u.push({id:0,kind:"usage-tick",at:l,label:`${Math.floor(k/1e3)}k tokens`});break}case"tool_result":{const m=i.data;o.agents=$U(a.agents,m==null?void 0:m.toolUseId,l);break}}if(u.length>0){let m=a.activitySeq;const h=u.map(b=>({...b,id:++m}));o.activitySeq=m,o.activityRing=[...a.activityRing,...h].slice(-32)}e({tabs:{...r().tabs,[n]:o}})}}));function z5(e){const r=s0(s=>s.subscribe),n=s0(s=>s.unsubscribe),i=s0(s=>e?s.tabs[e.id]:void 0);return B.useEffect(()=>{if(e)return r(e.id,e.cwd,e.claudeSessionId),()=>n(e.id)},[e==null?void 0:e.id,e==null?void 0:e.cwd,e==null?void 0:e.claudeSessionId,r,n]),i}var o1={},Wg={},A$;function F5(){if(A$)return Wg;A$=1,Object.defineProperty(Wg,"__esModule",{value:!0}),Wg.baseAssetPath=void 0;const r=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let n="/";return r&&(n=r.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^/]+$/,"/")),Wg.baseAssetPath=n,Wg}var Hg={},$$;function bT(){if($$)return Hg;$$=1,Object.defineProperty(Hg,"__esModule",{value:!0}),Hg.defaultModelFetcher=void 0;const e=r=>fetch(r).then(n=>n.arrayBuffer());return Hg.defaultModelFetcher=e,Hg}var Yl={},Gg={},N$;function qy(){if(N$)return Gg;N$=1,Object.defineProperty(Gg,"__esModule",{value:!0}),Gg.log=void 0;const e=r=>n=>{console.log(`VAD | ${r} >`,n)};return Gg.log={error:e("error"),debug:e("debug"),warn:e("warn")},Gg}var Vg={},O$;function Xw(){if(O$)return Vg;O$=1,Object.defineProperty(Vg,"__esModule",{value:!0}),Vg.Message=void 0;var e;return(function(r){r.AudioFrame="AUDIO_FRAME",r.SpeechStart="SPEECH_START",r.VADMisfire="VAD_MISFIRE",r.SpeechEnd="SPEECH_END",r.SpeechStop="SPEECH_STOP",r.SpeechRealStart="SPEECH_REAL_START",r.FrameProcessed="FRAME_PROCESSED"})(e||(Vg.Message=e={})),Vg}var P$;function xT(){if(P$)return Yl;P$=1,Object.defineProperty(Yl,"__esModule",{value:!0}),Yl.FrameProcessor=Yl.validateOptions=Yl.defaultFrameProcessorOptions=void 0;const e=qy(),r=Xw();Yl.defaultFrameProcessorOptions={positiveSpeechThreshold:.3,negativeSpeechThreshold:.25,preSpeechPadMs:800,redemptionMs:1400,minSpeechMs:400,submitUserSpeechOnPause:!1};function n(l){(l.positiveSpeechThreshold<0||l.positiveSpeechThreshold>1)&&e.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(l.negativeSpeechThreshold<0||l.negativeSpeechThreshold>l.positiveSpeechThreshold)&&e.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),l.preSpeechPadMs<0&&e.log.error("preSpeechPadMs should be positive"),l.redemptionMs<0&&e.log.error("redemptionMs should be positive"),l.minSpeechMs<0&&e.log.error("minSpeechMs should be positive")}Yl.validateOptions=n;const i=l=>{const o=l.reduce((f,m)=>(f.push(f.at(-1)+m.length),f),[0]),u=new Float32Array(o.at(-1));return l.forEach((f,m)=>{const h=o[m];u.set(f,h)}),u};function s(l,o){const u=Math.floor(l.redemptionMs/o),f=Math.floor(l.preSpeechPadMs/o),m=Math.floor(l.minSpeechMs/o);return{redemptionFrames:u,preSpeechPadFrames:f,minSpeechFrames:m}}class a{constructor(o,u,f,m){this.modelProcessFunc=o,this.modelResetFunc=u,this.options=f,this.msPerFrame=m,this.speaking=!1,this.redemptionCounter=0,this.speechFrameCount=0,this.active=!1,this.speechRealStartFired=!1,this.setOptions=k=>{this.options={...this.options,...k};const{redemptionFrames:_,preSpeechPadFrames:y,minSpeechFrames:w}=s(this.options,this.msPerFrame);this.redemptionFrames=_,this.preSpeechPadFrames=y,this.minSpeechFrames=w},this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=k=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(k):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=k=>{const _=this.audioBuffer;this.audioBuffer=[];const y=this.speaking;if(this.reset(),y)if(_.reduce((S,C)=>C.isSpeech?S+1:S,0)>=this.minSpeechFrames){const S=i(_.map(C=>C.frame));k({msg:r.Message.SpeechEnd,audio:S})}else k({msg:r.Message.VADMisfire});return{}},this.process=async(k,_)=>{if(!this.active)return;const y=await this.modelProcessFunc(k),w=y.isSpeech>=this.options.positiveSpeechThreshold;if(_({probs:y,msg:r.Message.FrameProcessed,frame:k}),this.audioBuffer.push({frame:k,isSpeech:w}),w&&(this.speechFrameCount++,this.redemptionCounter=0),w&&!this.speaking&&(this.speaking=!0,_({msg:r.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,_({msg:r.Message.SpeechRealStart})),y.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const S=this.audioBuffer;if(this.audioBuffer=[],S.reduce((T,E)=>E.isSpeech?T+1:T,0)>=this.minSpeechFrames){const T=i(S.map(E=>E.frame));_({msg:r.Message.SpeechEnd,audio:T})}else _({msg:r.Message.VADMisfire})}if(!this.speaking){for(;this.audioBuffer.length>this.preSpeechPadFrames;)this.audioBuffer.shift();this.speechFrameCount=0}},this.audioBuffer=[];const{redemptionFrames:h,preSpeechPadFrames:b,minSpeechFrames:x}=s(this.options,this.msPerFrame);this.redemptionFrames=h,this.preSpeechPadFrames=b,this.minSpeechFrames=x,this.reset()}}return Yl.FrameProcessor=a,Yl}var Jl={};function Wa(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var l1={exports:{}};/*!
41
+ `+Q.stack}return{value:p,source:v,stack:q,digest:null}}function hh(p,v,A){return{value:p,source:null,stack:A??null,digest:v??null}}function ph(p,v){try{console.error(v.value)}catch(A){setTimeout(function(){throw A})}}var Ib=typeof WeakMap=="function"?WeakMap:Map;function ug(p,v,A){A=Pa(-1,A),A.tag=3,A.payload={element:null};var M=v.value;return A.callback=function(){xd||(xd=!0,Mh=M),ph(p,v)},A}function dg(p,v,A){A=Pa(-1,A),A.tag=3;var M=p.type.getDerivedStateFromError;if(typeof M=="function"){var q=v.value;A.payload=function(){return M(q)},A.callback=function(){ph(p,v)}}var Q=p.stateNode;return Q!==null&&typeof Q.componentDidCatch=="function"&&(A.callback=function(){ph(p,v),typeof M!="function"&&(go===null?go=new Set([this]):go.add(this));var de=v.stack;this.componentDidCatch(v.value,{componentStack:de!==null?de:""})}),A}function fg(p,v,A){var M=p.pingCache;if(M===null){M=p.pingCache=new Ib;var q=new Set;M.set(v,q)}else q=M.get(v),q===void 0&&(q=new Set,M.set(v,q));q.has(A)||(q.add(A),p=Kb.bind(null,p,v,A),v.then(p,p))}function Db(p){do{var v;if((v=p.tag===13)&&(v=p.memoizedState,v=v!==null?v.dehydrated!==null:!0),v)return p;p=p.return}while(p!==null);return null}function _i(p,v,A,M,q){return(p.mode&1)===0?(p===v?p.flags|=65536:(p.flags|=128,A.flags|=131072,A.flags&=-52805,A.tag===1&&(A.alternate===null?A.tag=17:(v=Pa(-1,1),v.tag=2,fo(A,v,1))),A.lanes|=1),p):(p.flags|=65536,p.lanes=q,p)}var Lb=T.ReactCurrentOwner,zi=!1;function ri(p,v,A,M){v.child=p===null?Vf(v,null,A,M):Dl(v,p.child,A,M)}function hg(p,v,A,M,q){A=A.render;var Q=v.ref;return Ll(v,q),M=oh(p,v,A,M,Q,q),A=lh(),p!==null&&!zi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~q,Ma(p,v,q)):(tn&&A&&wn(v),v.flags|=1,ri(p,v,M,q),v.child)}function Vc(p,v,A,M,q){if(p===null){var Q=A.type;return typeof Q=="function"&&!Uh(Q)&&Q.defaultProps===void 0&&A.compare===null&&A.defaultProps===void 0?(v.tag=15,v.type=Q,pg(p,v,Q,M,q)):(p=Cd(A.type,null,M,v,v.mode,q),p.ref=v.ref,p.return=v,v.child=p)}if(Q=p.child,(p.lanes&q)===0){var de=Q.memoizedProps;if(A=A.compare,A=A!==null?A:Rc,A(de,M)&&p.ref===v.ref)return Ma(p,v,q)}return v.flags|=1,p=bo(Q,M),p.ref=v.ref,p.return=v,v.child=p}function pg(p,v,A,M,q){if(p!==null){var Q=p.memoizedProps;if(Rc(Q,M)&&p.ref===v.ref)if(zi=!1,v.pendingProps=M=Q,(p.lanes&q)!==0)(p.flags&131072)!==0&&(zi=!0);else return v.lanes=p.lanes,Ma(p,v,q)}return mh(p,v,A,M,q)}function mg(p,v,A){var M=v.pendingProps,q=M.children,Q=p!==null?p.memoizedState:null;if(M.mode==="hidden")if((v.mode&1)===0)v.memoizedState={baseLanes:0,cachePool:null,transitions:null},Br(ql,Qi),Qi|=A;else{if((A&1073741824)===0)return p=Q!==null?Q.baseLanes|A:A,v.lanes=v.childLanes=1073741824,v.memoizedState={baseLanes:p,cachePool:null,transitions:null},v.updateQueue=null,Br(ql,Qi),Qi|=p,null;v.memoizedState={baseLanes:0,cachePool:null,transitions:null},M=Q!==null?Q.baseLanes:A,Br(ql,Qi),Qi|=M}else Q!==null?(M=Q.baseLanes|A,v.memoizedState=null):M=A,Br(ql,Qi),Qi|=M;return ri(p,v,q,A),v.child}function gg(p,v){var A=v.ref;(p===null&&A!==null||p!==null&&p.ref!==A)&&(v.flags|=512,v.flags|=2097152)}function mh(p,v,A,M,q){var Q=Mi(A)?Go:xi.current;return Q=wi(v,Q),Ll(v,q),A=oh(p,v,A,M,Q,q),M=lh(),p!==null&&!zi?(v.updateQueue=p.updateQueue,v.flags&=-2053,p.lanes&=~q,Ma(p,v,q)):(tn&&M&&wn(v),v.flags|=1,ri(p,v,A,q),v.child)}function vg(p,v,A,M,q){if(Mi(A)){var Q=!0;Zu(v)}else Q=!1;if(Ll(v,q),v.stateNode===null)pd(p,v),lg(v,A,M),fh(v,A,M,q),M=!0;else if(p===null){var de=v.stateNode,ke=v.memoizedProps;de.props=ke;var Oe=de.context,Ge=A.contextType;typeof Ge=="object"&&Ge!==null?Ge=ys(Ge):(Ge=Mi(A)?Go:xi.current,Ge=wi(v,Ge));var ct=A.getDerivedStateFromProps,ft=typeof ct=="function"||typeof de.getSnapshotBeforeUpdate=="function";ft||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(ke!==M||Oe!==Ge)&&cg(v,de,M,Ge),oa=!1;var ot=v.memoizedState;de.state=ot,od(v,M,de,q),Oe=v.memoizedState,ke!==M||ot!==Oe||Ri.current||oa?(typeof ct=="function"&&(ca(v,A,ct,M),Oe=v.memoizedState),(ke=oa||tl(v,A,ke,M,ot,Oe,Ge))?(ft||typeof de.UNSAFE_componentWillMount!="function"&&typeof de.componentWillMount!="function"||(typeof de.componentWillMount=="function"&&de.componentWillMount(),typeof de.UNSAFE_componentWillMount=="function"&&de.UNSAFE_componentWillMount()),typeof de.componentDidMount=="function"&&(v.flags|=4194308)):(typeof de.componentDidMount=="function"&&(v.flags|=4194308),v.memoizedProps=M,v.memoizedState=Oe),de.props=M,de.state=Oe,de.context=Ge,M=ke):(typeof de.componentDidMount=="function"&&(v.flags|=4194308),M=!1)}else{de=v.stateNode,Qf(p,v),ke=v.memoizedProps,Ge=v.type===v.elementType?ke:Sn(v.type,ke),de.props=Ge,ft=v.pendingProps,ot=de.context,Oe=A.contextType,typeof Oe=="object"&&Oe!==null?Oe=ys(Oe):(Oe=Mi(A)?Go:xi.current,Oe=wi(v,Oe));var Ct=A.getDerivedStateFromProps;(ct=typeof Ct=="function"||typeof de.getSnapshotBeforeUpdate=="function")||typeof de.UNSAFE_componentWillReceiveProps!="function"&&typeof de.componentWillReceiveProps!="function"||(ke!==ft||ot!==Oe)&&cg(v,de,M,Oe),oa=!1,ot=v.memoizedState,de.state=ot,od(v,M,de,q);var Ot=v.memoizedState;ke!==ft||ot!==Ot||Ri.current||oa?(typeof Ct=="function"&&(ca(v,A,Ct,M),Ot=v.memoizedState),(Ge=oa||tl(v,A,Ge,M,ot,Ot,Oe)||!1)?(ct||typeof de.UNSAFE_componentWillUpdate!="function"&&typeof de.componentWillUpdate!="function"||(typeof de.componentWillUpdate=="function"&&de.componentWillUpdate(M,Ot,Oe),typeof de.UNSAFE_componentWillUpdate=="function"&&de.UNSAFE_componentWillUpdate(M,Ot,Oe)),typeof de.componentDidUpdate=="function"&&(v.flags|=4),typeof de.getSnapshotBeforeUpdate=="function"&&(v.flags|=1024)):(typeof de.componentDidUpdate!="function"||ke===p.memoizedProps&&ot===p.memoizedState||(v.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&ot===p.memoizedState||(v.flags|=1024),v.memoizedProps=M,v.memoizedState=Ot),de.props=M,de.state=Ot,de.context=Oe,M=Ge):(typeof de.componentDidUpdate!="function"||ke===p.memoizedProps&&ot===p.memoizedState||(v.flags|=4),typeof de.getSnapshotBeforeUpdate!="function"||ke===p.memoizedProps&&ot===p.memoizedState||(v.flags|=1024),M=!1)}return gh(p,v,A,M,Q,q)}function gh(p,v,A,M,q,Q){gg(p,v);var de=(v.flags&128)!==0;if(!M&&!de)return q&&Im(v,A,!1),Ma(p,v,Q);M=v.stateNode,Lb.current=v;var ke=de&&typeof A.getDerivedStateFromError!="function"?null:M.render();return v.flags|=1,p!==null&&de?(v.child=Dl(v,p.child,null,Q),v.child=Dl(v,null,ke,Q)):ri(p,v,ke,Q),v.memoizedState=M.state,q&&Im(v,A,!0),v.child}function vh(p){var v=p.stateNode;v.pendingContext?Rm(p,v.pendingContext,v.pendingContext!==v.context):v.context&&Rm(p,v.context,!1),Zf(p,v.containerInfo)}function yg(p,v,A,M,q){return Ko(),Hf(q),v.flags|=256,ri(p,v,A,M),v.child}var yh={dehydrated:null,treeContext:null,retryLane:0};function bh(p){return{baseLanes:p,cachePool:null,transitions:null}}function bg(p,v,A){var M=v.pendingProps,q=sn.current,Q=!1,de=(v.flags&128)!==0,ke;if((ke=de)||(ke=p!==null&&p.memoizedState===null?!1:(q&2)!==0),ke?(Q=!0,v.flags&=-129):(p===null||p.memoizedState!==null)&&(q|=1),Br(sn,q&1),p===null)return qf(v),p=v.memoizedState,p!==null&&(p=p.dehydrated,p!==null)?((v.mode&1)===0?v.lanes=1:p.data==="$!"?v.lanes=8:v.lanes=1073741824,null):(de=M.children,p=M.fallback,Q?(M=v.mode,Q=v.child,de={mode:"hidden",children:de},(M&1)===0&&Q!==null?(Q.childLanes=0,Q.pendingProps=de):Q=Ed(de,M,0,null),p=Gl(p,M,A,null),Q.return=v,p.return=v,Q.sibling=p,v.child=Q,v.child.memoizedState=bh(A),v.memoizedState=yh,p):Kc(v,de));if(q=p.memoizedState,q!==null&&(ke=q.dehydrated,ke!==null))return Bb(p,v,de,M,ke,q,A);if(Q){Q=M.fallback,de=v.mode,q=p.child,ke=q.sibling;var Oe={mode:"hidden",children:M.children};return(de&1)===0&&v.child!==q?(M=v.child,M.childLanes=0,M.pendingProps=Oe,v.deletions=null):(M=bo(q,Oe),M.subtreeFlags=q.subtreeFlags&14680064),ke!==null?Q=bo(ke,Q):(Q=Gl(Q,de,A,null),Q.flags|=2),Q.return=v,M.return=v,M.sibling=Q,v.child=M,M=Q,Q=v.child,de=p.child.memoizedState,de=de===null?bh(A):{baseLanes:de.baseLanes|A,cachePool:null,transitions:de.transitions},Q.memoizedState=de,Q.childLanes=p.childLanes&~A,v.memoizedState=yh,M}return Q=p.child,p=Q.sibling,M=bo(Q,{mode:"visible",children:M.children}),(v.mode&1)===0&&(M.lanes=A),M.return=v,M.sibling=null,p!==null&&(A=v.deletions,A===null?(v.deletions=[p],v.flags|=16):A.push(p)),v.child=M,v.memoizedState=null,M}function Kc(p,v){return v=Ed({mode:"visible",children:v},p.mode,0,null),v.return=p,p.child=v}function hd(p,v,A,M){return M!==null&&Hf(M),Dl(v,p.child,null,A),p=Kc(v,v.pendingProps.children),p.flags|=2,v.memoizedState=null,p}function Bb(p,v,A,M,q,Q,de){if(A)return v.flags&256?(v.flags&=-257,M=hh(Error(n(422))),hd(p,v,de,M)):v.memoizedState!==null?(v.child=p.child,v.flags|=128,null):(Q=M.fallback,q=v.mode,M=Ed({mode:"visible",children:M.children},q,0,null),Q=Gl(Q,q,de,null),Q.flags|=2,M.return=v,Q.return=v,M.sibling=Q,v.child=M,(v.mode&1)!==0&&Dl(v,p.child,null,de),v.child.memoizedState=bh(de),v.memoizedState=yh,Q);if((v.mode&1)===0)return hd(p,v,de,null);if(q.data==="$!"){if(M=q.nextSibling&&q.nextSibling.dataset,M)var ke=M.dgst;return M=ke,Q=Error(n(419)),M=hh(Q,M,void 0),hd(p,v,de,M)}if(ke=(de&p.childLanes)!==0,zi||ke){if(M=kn,M!==null){switch(de&-de){case 4:q=2;break;case 16:q=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:q=32;break;case 536870912:q=268435456;break;default:q=0}q=(q&(M.suspendedLanes|de))!==0?0:q,q!==0&&q!==Q.retryLane&&(Q.retryLane=q,Oa(p,q),Ws(M,p,q,-1))}return Fh(),M=hh(Error(n(421))),hd(p,v,de,M)}return q.data==="$?"?(v.flags|=128,v.child=p.child,v=Yb.bind(null,p),q._reactRetry=v,null):(p=Q.treeContext,Ji=oo(q.nextSibling),Li=v,tn=!0,Bi=null,p!==null&&(gs[zs++]=Ii,gs[zs++]=Di,gs[zs++]=vs,Ii=p.id,Di=p.overflow,vs=v),v=Kc(v,M.children),v.flags|=4096,v)}function xg(p,v,A){p.lanes|=v;var M=p.alternate;M!==null&&(M.lanes|=v),zm(p.return,v,A)}function xh(p,v,A,M,q){var Q=p.memoizedState;Q===null?p.memoizedState={isBackwards:v,rendering:null,renderingStartTime:0,last:M,tail:A,tailMode:q}:(Q.isBackwards=v,Q.rendering=null,Q.renderingStartTime=0,Q.last=M,Q.tail=A,Q.tailMode=q)}function wh(p,v,A){var M=v.pendingProps,q=M.revealOrder,Q=M.tail;if(ri(p,v,M.children,A),M=sn.current,(M&2)!==0)M=M&1|2,v.flags|=128;else{if(p!==null&&(p.flags&128)!==0)e:for(p=v.child;p!==null;){if(p.tag===13)p.memoizedState!==null&&xg(p,A,v);else if(p.tag===19)xg(p,A,v);else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===v)break e;for(;p.sibling===null;){if(p.return===null||p.return===v)break e;p=p.return}p.sibling.return=p.return,p=p.sibling}M&=1}if(Br(sn,M),(v.mode&1)===0)v.memoizedState=null;else switch(q){case"forwards":for(A=v.child,q=null;A!==null;)p=A.alternate,p!==null&&ld(p)===null&&(q=A),A=A.sibling;A=q,A===null?(q=v.child,v.child=null):(q=A.sibling,A.sibling=null),xh(v,!1,q,A,Q);break;case"backwards":for(A=null,q=v.child,v.child=null;q!==null;){if(p=q.alternate,p!==null&&ld(p)===null){v.child=q;break}p=q.sibling,q.sibling=A,A=q,q=p}xh(v,!0,A,null,Q);break;case"together":xh(v,!1,null,null,void 0);break;default:v.memoizedState=null}return v.child}function pd(p,v){(v.mode&1)===0&&p!==null&&(p.alternate=null,v.alternate=null,v.flags|=2)}function Ma(p,v,A){if(p!==null&&(v.dependencies=p.dependencies),rl|=v.lanes,(A&v.childLanes)===0)return null;if(p!==null&&v.child!==p.child)throw Error(n(153));if(v.child!==null){for(p=v.child,A=bo(p,p.pendingProps),v.child=A,A.return=v;p.sibling!==null;)p=p.sibling,A=A.sibling=bo(p,p.pendingProps),A.return=v;A.sibling=null}return v.child}function K_(p,v,A){switch(v.tag){case 3:vh(v),Ko();break;case 5:Fm(v);break;case 1:Mi(v.type)&&Zu(v);break;case 4:Zf(v,v.stateNode.containerInfo);break;case 10:var M=v.type._context,q=v.memoizedProps.value;Br(Xo,M._currentValue),M._currentValue=q;break;case 13:if(M=v.memoizedState,M!==null)return M.dehydrated!==null?(Br(sn,sn.current&1),v.flags|=128,null):(A&v.child.childLanes)!==0?bg(p,v,A):(Br(sn,sn.current&1),p=Ma(p,v,A),p!==null?p.sibling:null);Br(sn,sn.current&1);break;case 19:if(M=(A&v.childLanes)!==0,(p.flags&128)!==0){if(M)return wh(p,v,A);v.flags|=128}if(q=v.memoizedState,q!==null&&(q.rendering=null,q.tail=null,q.lastEffect=null),Br(sn,sn.current),M)break;return null;case 22:case 23:return v.lanes=0,mg(p,v,A)}return Ma(p,v,A)}var _h,Sh,wg,_g;_h=function(p,v){for(var A=v.child;A!==null;){if(A.tag===5||A.tag===6)p.appendChild(A.stateNode);else if(A.tag!==4&&A.child!==null){A.child.return=A,A=A.child;continue}if(A===v)break;for(;A.sibling===null;){if(A.return===null||A.return===v)return;A=A.return}A.sibling.return=A.return,A=A.sibling}},Sh=function(){},wg=function(p,v,A,M){var q=p.memoizedProps;if(q!==M){p=v.stateNode,Jo(la.current);var Q=null;switch(A){case"input":q=Be(p,q),M=Be(p,M),Q=[];break;case"select":q=X({},q,{value:void 0}),M=X({},M,{value:void 0}),Q=[];break;case"textarea":q=Or(p,q),M=Or(p,M),Q=[];break;default:typeof q.onClick!="function"&&typeof M.onClick=="function"&&(p.onclick=Yu)}ss(A,M);var de;A=null;for(Ge in q)if(!M.hasOwnProperty(Ge)&&q.hasOwnProperty(Ge)&&q[Ge]!=null)if(Ge==="style"){var ke=q[Ge];for(de in ke)ke.hasOwnProperty(de)&&(A||(A={}),A[de]="")}else Ge!=="dangerouslySetInnerHTML"&&Ge!=="children"&&Ge!=="suppressContentEditableWarning"&&Ge!=="suppressHydrationWarning"&&Ge!=="autoFocus"&&(s.hasOwnProperty(Ge)?Q||(Q=[]):(Q=Q||[]).push(Ge,null));for(Ge in M){var Oe=M[Ge];if(ke=q!=null?q[Ge]:void 0,M.hasOwnProperty(Ge)&&Oe!==ke&&(Oe!=null||ke!=null))if(Ge==="style")if(ke){for(de in ke)!ke.hasOwnProperty(de)||Oe&&Oe.hasOwnProperty(de)||(A||(A={}),A[de]="");for(de in Oe)Oe.hasOwnProperty(de)&&ke[de]!==Oe[de]&&(A||(A={}),A[de]=Oe[de])}else A||(Q||(Q=[]),Q.push(Ge,A)),A=Oe;else Ge==="dangerouslySetInnerHTML"?(Oe=Oe?Oe.__html:void 0,ke=ke?ke.__html:void 0,Oe!=null&&ke!==Oe&&(Q=Q||[]).push(Ge,Oe)):Ge==="children"?typeof Oe!="string"&&typeof Oe!="number"||(Q=Q||[]).push(Ge,""+Oe):Ge!=="suppressContentEditableWarning"&&Ge!=="suppressHydrationWarning"&&(s.hasOwnProperty(Ge)?(Oe!=null&&Ge==="onScroll"&&Wr("scroll",p),Q||ke===Oe||(Q=[])):(Q=Q||[]).push(Ge,Oe))}A&&(Q=Q||[]).push("style",A);var Ge=Q;(v.updateQueue=Ge)&&(v.flags|=4)}},_g=function(p,v,A,M){A!==M&&(v.flags|=4)};function md(p,v){if(!tn)switch(p.tailMode){case"hidden":v=p.tail;for(var A=null;v!==null;)v.alternate!==null&&(A=v),v=v.sibling;A===null?p.tail=null:A.sibling=null;break;case"collapsed":A=p.tail;for(var M=null;A!==null;)A.alternate!==null&&(M=A),A=A.sibling;M===null?v||p.tail===null?p.tail=null:p.tail.sibling=null:M.sibling=null}}function ni(p){var v=p.alternate!==null&&p.alternate.child===p.child,A=0,M=0;if(v)for(var q=p.child;q!==null;)A|=q.lanes|q.childLanes,M|=q.subtreeFlags&14680064,M|=q.flags&14680064,q.return=p,q=q.sibling;else for(q=p.child;q!==null;)A|=q.lanes|q.childLanes,M|=q.subtreeFlags,M|=q.flags,q.return=p,q=q.sibling;return p.subtreeFlags|=M,p.childLanes=A,v}function zb(p,v,A){var M=v.pendingProps;switch(Bf(v),v.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ni(v),null;case 1:return Mi(v.type)&&Qu(),ni(v),null;case 3:return M=v.stateNode,Qo(),Hr(Ri),Hr(xi),rh(),M.pendingContext&&(M.context=M.pendingContext,M.pendingContext=null),(p===null||p.child===null)&&(Uc(v)?v.flags|=4:p===null||p.memoizedState.isDehydrated&&(v.flags&256)===0||(v.flags|=1024,Bi!==null&&(Lh(Bi),Bi=null))),Sh(p,v),ni(v),null;case 5:eh(v);var q=Jo(zl.current);if(A=v.type,p!==null&&v.stateNode!=null)wg(p,v,A,M,q),p.ref!==v.ref&&(v.flags|=512,v.flags|=2097152);else{if(!M){if(v.stateNode===null)throw Error(n(166));return ni(v),null}if(p=Jo(la.current),Uc(v)){M=v.stateNode,A=v.type;var Q=v.memoizedProps;switch(M[sa]=v,M[zc]=Q,p=(v.mode&1)!==0,A){case"dialog":Wr("cancel",M),Wr("close",M);break;case"iframe":case"object":case"embed":Wr("load",M);break;case"video":case"audio":for(q=0;q<Dc.length;q++)Wr(Dc[q],M);break;case"source":Wr("error",M);break;case"img":case"image":case"link":Wr("error",M),Wr("load",M);break;case"details":Wr("toggle",M);break;case"input":Ze(M,Q),Wr("invalid",M);break;case"select":M._wrapperState={wasMultiple:!!Q.multiple},Wr("invalid",M);break;case"textarea":Ar(M,Q),Wr("invalid",M)}ss(A,Q),q=null;for(var de in Q)if(Q.hasOwnProperty(de)){var ke=Q[de];de==="children"?typeof ke=="string"?M.textContent!==ke&&(Q.suppressHydrationWarning!==!0&&Xu(M.textContent,ke,p),q=["children",ke]):typeof ke=="number"&&M.textContent!==""+ke&&(Q.suppressHydrationWarning!==!0&&Xu(M.textContent,ke,p),q=["children",""+ke]):s.hasOwnProperty(de)&&ke!=null&&de==="onScroll"&&Wr("scroll",M)}switch(A){case"input":Ve(M),or(M,Q,!0);break;case"textarea":Ve(M),Ur(M);break;case"select":case"option":break;default:typeof Q.onClick=="function"&&(M.onclick=Yu)}M=q,v.updateQueue=M,M!==null&&(v.flags|=4)}else{de=q.nodeType===9?q:q.ownerDocument,p==="http://www.w3.org/1999/xhtml"&&(p=Ni(A)),p==="http://www.w3.org/1999/xhtml"?A==="script"?(p=de.createElement("div"),p.innerHTML="<script><\/script>",p=p.removeChild(p.firstChild)):typeof M.is=="string"?p=de.createElement(A,{is:M.is}):(p=de.createElement(A),A==="select"&&(de=p,M.multiple?de.multiple=!0:M.size&&(de.size=M.size))):p=de.createElementNS(p,A),p[sa]=v,p[zc]=M,_h(p,v,!1,!1),v.stateNode=p;e:{switch(de=Er(A,M),A){case"dialog":Wr("cancel",p),Wr("close",p),q=M;break;case"iframe":case"object":case"embed":Wr("load",p),q=M;break;case"video":case"audio":for(q=0;q<Dc.length;q++)Wr(Dc[q],p);q=M;break;case"source":Wr("error",p),q=M;break;case"img":case"image":case"link":Wr("error",p),Wr("load",p),q=M;break;case"details":Wr("toggle",p),q=M;break;case"input":Ze(p,M),q=Be(p,M),Wr("invalid",p);break;case"option":q=M;break;case"select":p._wrapperState={wasMultiple:!!M.multiple},q=X({},M,{value:void 0}),Wr("invalid",p);break;case"textarea":Ar(p,M),q=Or(p,M),Wr("invalid",p);break;default:q=M}ss(A,q),ke=q;for(Q in ke)if(ke.hasOwnProperty(Q)){var Oe=ke[Q];Q==="style"?mn(p,Oe):Q==="dangerouslySetInnerHTML"?(Oe=Oe?Oe.__html:void 0,Oe!=null&&Tn(p,Oe)):Q==="children"?typeof Oe=="string"?(A!=="textarea"||Oe!=="")&&lt(p,Oe):typeof Oe=="number"&&lt(p,""+Oe):Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&Q!=="autoFocus"&&(s.hasOwnProperty(Q)?Oe!=null&&Q==="onScroll"&&Wr("scroll",p):Oe!=null&&C(p,Q,Oe,de))}switch(A){case"input":Ve(p),or(p,M,!1);break;case"textarea":Ve(p),Ur(p);break;case"option":M.value!=null&&p.setAttribute("value",""+ie(M.value));break;case"select":p.multiple=!!M.multiple,Q=M.value,Q!=null?sr(p,!!M.multiple,Q,!1):M.defaultValue!=null&&sr(p,!!M.multiple,M.defaultValue,!0);break;default:typeof q.onClick=="function"&&(p.onclick=Yu)}switch(A){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}}M&&(v.flags|=4)}v.ref!==null&&(v.flags|=512,v.flags|=2097152)}return ni(v),null;case 6:if(p&&v.stateNode!=null)_g(p,v,p.memoizedProps,M);else{if(typeof M!="string"&&v.stateNode===null)throw Error(n(166));if(A=Jo(zl.current),Jo(la.current),Uc(v)){if(M=v.stateNode,A=v.memoizedProps,M[sa]=v,(Q=M.nodeValue!==A)&&(p=Li,p!==null))switch(p.tag){case 3:Xu(M.nodeValue,A,(p.mode&1)!==0);break;case 5:p.memoizedProps.suppressHydrationWarning!==!0&&Xu(M.nodeValue,A,(p.mode&1)!==0)}Q&&(v.flags|=4)}else M=(A.nodeType===9?A:A.ownerDocument).createTextNode(M),M[sa]=v,v.stateNode=M}return ni(v),null;case 13:if(Hr(sn),M=v.memoizedState,p===null||p.memoizedState!==null&&p.memoizedState.dehydrated!==null){if(tn&&Ji!==null&&(v.mode&1)!==0&&(v.flags&128)===0)Lm(),Ko(),v.flags|=98560,Q=!1;else if(Q=Uc(v),M!==null&&M.dehydrated!==null){if(p===null){if(!Q)throw Error(n(318));if(Q=v.memoizedState,Q=Q!==null?Q.dehydrated:null,!Q)throw Error(n(317));Q[sa]=v}else Ko(),(v.flags&128)===0&&(v.memoizedState=null),v.flags|=4;ni(v),Q=!1}else Bi!==null&&(Lh(Bi),Bi=null),Q=!0;if(!Q)return v.flags&65536?v:null}return(v.flags&128)!==0?(v.lanes=A,v):(M=M!==null,M!==(p!==null&&p.memoizedState!==null)&&M&&(v.child.flags|=8192,(v.mode&1)!==0&&(p===null||(sn.current&1)!==0?Pn===0&&(Pn=3):Fh())),v.updateQueue!==null&&(v.flags|=4),ni(v),null);case 4:return Qo(),Sh(p,v),p===null&&Lc(v.stateNode.containerInfo),ni(v),null;case 10:return Yf(v.type._context),ni(v),null;case 17:return Mi(v.type)&&Qu(),ni(v),null;case 19:if(Hr(sn),Q=v.memoizedState,Q===null)return ni(v),null;if(M=(v.flags&128)!==0,de=Q.rendering,de===null)if(M)md(Q,!1);else{if(Pn!==0||p!==null&&(p.flags&128)!==0)for(p=v.child;p!==null;){if(de=ld(p),de!==null){for(v.flags|=128,md(Q,!1),M=de.updateQueue,M!==null&&(v.updateQueue=M,v.flags|=4),v.subtreeFlags=0,M=A,A=v.child;A!==null;)Q=A,p=M,Q.flags&=14680066,de=Q.alternate,de===null?(Q.childLanes=0,Q.lanes=p,Q.child=null,Q.subtreeFlags=0,Q.memoizedProps=null,Q.memoizedState=null,Q.updateQueue=null,Q.dependencies=null,Q.stateNode=null):(Q.childLanes=de.childLanes,Q.lanes=de.lanes,Q.child=de.child,Q.subtreeFlags=0,Q.deletions=null,Q.memoizedProps=de.memoizedProps,Q.memoizedState=de.memoizedState,Q.updateQueue=de.updateQueue,Q.type=de.type,p=de.dependencies,Q.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext}),A=A.sibling;return Br(sn,sn.current&1|2),v.child}p=p.sibling}Q.tail!==null&&qr()>Wl&&(v.flags|=128,M=!0,md(Q,!1),v.lanes=4194304)}else{if(!M)if(p=ld(de),p!==null){if(v.flags|=128,M=!0,A=p.updateQueue,A!==null&&(v.updateQueue=A,v.flags|=4),md(Q,!0),Q.tail===null&&Q.tailMode==="hidden"&&!de.alternate&&!tn)return ni(v),null}else 2*qr()-Q.renderingStartTime>Wl&&A!==1073741824&&(v.flags|=128,M=!0,md(Q,!1),v.lanes=4194304);Q.isBackwards?(de.sibling=v.child,v.child=de):(A=Q.last,A!==null?A.sibling=de:v.child=de,Q.last=de)}return Q.tail!==null?(v=Q.tail,Q.rendering=v,Q.tail=v.sibling,Q.renderingStartTime=qr(),v.sibling=null,A=sn.current,Br(sn,M?A&1|2:A&1),v):(ni(v),null);case 22:case 23:return zh(),M=v.memoizedState!==null,p!==null&&p.memoizedState!==null!==M&&(v.flags|=8192),M&&(v.mode&1)!==0?(Qi&1073741824)!==0&&(ni(v),v.subtreeFlags&6&&(v.flags|=8192)):ni(v),null;case 24:return null;case 25:return null}throw Error(n(156,v.tag))}function Fb(p,v){switch(Bf(v),v.tag){case 1:return Mi(v.type)&&Qu(),p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 3:return Qo(),Hr(Ri),Hr(xi),rh(),p=v.flags,(p&65536)!==0&&(p&128)===0?(v.flags=p&-65537|128,v):null;case 5:return eh(v),null;case 13:if(Hr(sn),p=v.memoizedState,p!==null&&p.dehydrated!==null){if(v.alternate===null)throw Error(n(340));Ko()}return p=v.flags,p&65536?(v.flags=p&-65537|128,v):null;case 19:return Hr(sn),null;case 4:return Qo(),null;case 10:return Yf(v.type._context),null;case 22:case 23:return zh(),null;case 24:return null;default:return null}}var kh=!1,ii=!1,Ub=typeof WeakSet=="function"?WeakSet:Set,Nt=null;function Ul(p,v){var A=p.ref;if(A!==null)if(typeof A=="function")try{A(null)}catch(M){an(p,v,M)}else A.current=null}function Ch(p,v,A){try{A()}catch(M){an(p,v,M)}}var Sg=!1;function qb(p,v){if(Nf=so,p=Sf(),kf(p)){if("selectionStart"in p)var A={start:p.selectionStart,end:p.selectionEnd};else e:{A=(A=p.ownerDocument)&&A.defaultView||window;var M=A.getSelection&&A.getSelection();if(M&&M.rangeCount!==0){A=M.anchorNode;var q=M.anchorOffset,Q=M.focusNode;M=M.focusOffset;try{A.nodeType,Q.nodeType}catch{A=null;break e}var de=0,ke=-1,Oe=-1,Ge=0,ct=0,ft=p,ot=null;t:for(;;){for(var Ct;ft!==A||q!==0&&ft.nodeType!==3||(ke=de+q),ft!==Q||M!==0&&ft.nodeType!==3||(Oe=de+M),ft.nodeType===3&&(de+=ft.nodeValue.length),(Ct=ft.firstChild)!==null;)ot=ft,ft=Ct;for(;;){if(ft===p)break t;if(ot===A&&++Ge===q&&(ke=de),ot===Q&&++ct===M&&(Oe=de),(Ct=ft.nextSibling)!==null)break;ft=ot,ot=ft.parentNode}ft=Ct}A=ke===-1||Oe===-1?null:{start:ke,end:Oe}}else A=null}A=A||{start:0,end:0}}else A=null;for(Of={focusedElem:p,selectionRange:A},so=!1,Nt=v;Nt!==null;)if(v=Nt,p=v.child,(v.subtreeFlags&1028)!==0&&p!==null)p.return=v,Nt=p;else for(;Nt!==null;){v=Nt;try{var Ot=v.alternate;if((v.flags&1024)!==0)switch(v.tag){case 0:case 11:case 15:break;case 1:if(Ot!==null){var Pt=Ot.memoizedProps,zr=Ot.memoizedState,qe=v.stateNode,Ie=qe.getSnapshotBeforeUpdate(v.elementType===v.type?Pt:Sn(v.type,Pt),zr);qe.__reactInternalSnapshotBeforeUpdate=Ie}break;case 3:var Ke=v.stateNode.containerInfo;Ke.nodeType===1?Ke.textContent="":Ke.nodeType===9&&Ke.documentElement&&Ke.removeChild(Ke.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(gt){an(v,v.return,gt)}if(p=v.sibling,p!==null){p.return=v.return,Nt=p;break}Nt=v.return}return Ot=Sg,Sg=!1,Ot}function Xc(p,v,A){var M=v.updateQueue;if(M=M!==null?M.lastEffect:null,M!==null){var q=M=M.next;do{if((q.tag&p)===p){var Q=q.destroy;q.destroy=void 0,Q!==void 0&&Ch(v,A,Q)}q=q.next}while(q!==M)}}function Eh(p,v){if(v=v.updateQueue,v=v!==null?v.lastEffect:null,v!==null){var A=v=v.next;do{if((A.tag&p)===p){var M=A.create;A.destroy=M()}A=A.next}while(A!==v)}}function jh(p){var v=p.ref;if(v!==null){var A=p.stateNode;switch(p.tag){case 5:p=A;break;default:p=A}typeof v=="function"?v(p):v.current=p}}function kg(p){var v=p.alternate;v!==null&&(p.alternate=null,kg(v)),p.child=null,p.deletions=null,p.sibling=null,p.tag===5&&(v=p.stateNode,v!==null&&(delete v[sa],delete v[zc],delete v[If],delete v[Om],delete v[Pm])),p.stateNode=null,p.return=null,p.dependencies=null,p.memoizedProps=null,p.memoizedState=null,p.pendingProps=null,p.stateNode=null,p.updateQueue=null}function Cg(p){return p.tag===5||p.tag===3||p.tag===4}function Eg(p){e:for(;;){for(;p.sibling===null;){if(p.return===null||Cg(p.return))return null;p=p.return}for(p.sibling.return=p.return,p=p.sibling;p.tag!==5&&p.tag!==6&&p.tag!==18;){if(p.flags&2||p.child===null||p.tag===4)continue e;p.child.return=p,p=p.child}if(!(p.flags&2))return p.stateNode}}function Th(p,v,A){var M=p.tag;if(M===5||M===6)p=p.stateNode,v?A.nodeType===8?A.parentNode.insertBefore(p,v):A.insertBefore(p,v):(A.nodeType===8?(v=A.parentNode,v.insertBefore(p,A)):(v=A,v.appendChild(p)),A=A._reactRootContainer,A!=null||v.onclick!==null||(v.onclick=Yu));else if(M!==4&&(p=p.child,p!==null))for(Th(p,v,A),p=p.sibling;p!==null;)Th(p,v,A),p=p.sibling}function Ah(p,v,A){var M=p.tag;if(M===5||M===6)p=p.stateNode,v?A.insertBefore(p,v):A.appendChild(p);else if(M!==4&&(p=p.child,p!==null))for(Ah(p,v,A),p=p.sibling;p!==null;)Ah(p,v,A),p=p.sibling}var Wn=null,Us=!1;function po(p,v,A){for(A=A.child;A!==null;)Wb(p,v,A),A=A.sibling}function Wb(p,v,A){if(nr&&typeof nr.onCommitFiberUnmount=="function")try{nr.onCommitFiberUnmount(_t,A)}catch{}switch(A.tag){case 5:ii||Ul(A,v);case 6:var M=Wn,q=Us;Wn=null,po(p,v,A),Wn=M,Us=q,Wn!==null&&(Us?(p=Wn,A=A.stateNode,p.nodeType===8?p.parentNode.removeChild(A):p.removeChild(A)):Wn.removeChild(A.stateNode));break;case 18:Wn!==null&&(Us?(p=Wn,A=A.stateNode,p.nodeType===8?Mf(p.parentNode,A):p.nodeType===1&&Mf(p,A),Ta(p)):Mf(Wn,A.stateNode));break;case 4:M=Wn,q=Us,Wn=A.stateNode.containerInfo,Us=!0,po(p,v,A),Wn=M,Us=q;break;case 0:case 11:case 14:case 15:if(!ii&&(M=A.updateQueue,M!==null&&(M=M.lastEffect,M!==null))){q=M=M.next;do{var Q=q,de=Q.destroy;Q=Q.tag,de!==void 0&&((Q&2)!==0||(Q&4)!==0)&&Ch(A,v,de),q=q.next}while(q!==M)}po(p,v,A);break;case 1:if(!ii&&(Ul(A,v),M=A.stateNode,typeof M.componentWillUnmount=="function"))try{M.props=A.memoizedProps,M.state=A.memoizedState,M.componentWillUnmount()}catch(ke){an(A,v,ke)}po(p,v,A);break;case 21:po(p,v,A);break;case 22:A.mode&1?(ii=(M=ii)||A.memoizedState!==null,po(p,v,A),ii=M):po(p,v,A);break;default:po(p,v,A)}}function Yc(p){var v=p.updateQueue;if(v!==null){p.updateQueue=null;var A=p.stateNode;A===null&&(A=p.stateNode=new Ub),v.forEach(function(M){var q=Jb.bind(null,p,M);A.has(M)||(A.add(M),M.then(q,q))})}}function xs(p,v){var A=v.deletions;if(A!==null)for(var M=0;M<A.length;M++){var q=A[M];try{var Q=p,de=v,ke=de;e:for(;ke!==null;){switch(ke.tag){case 5:Wn=ke.stateNode,Us=!1;break e;case 3:Wn=ke.stateNode.containerInfo,Us=!0;break e;case 4:Wn=ke.stateNode.containerInfo,Us=!0;break e}ke=ke.return}if(Wn===null)throw Error(n(160));Wb(Q,de,q),Wn=null,Us=!1;var Oe=q.alternate;Oe!==null&&(Oe.return=null),q.return=null}catch(Ge){an(q,v,Ge)}}if(v.subtreeFlags&12854)for(v=v.child;v!==null;)$h(v,p),v=v.sibling}function $h(p,v){var A=p.alternate,M=p.flags;switch(p.tag){case 0:case 11:case 14:case 15:if(xs(v,p),qs(p),M&4){try{Xc(3,p,p.return),Eh(3,p)}catch(Pt){an(p,p.return,Pt)}try{Xc(5,p,p.return)}catch(Pt){an(p,p.return,Pt)}}break;case 1:xs(v,p),qs(p),M&512&&A!==null&&Ul(A,A.return);break;case 5:if(xs(v,p),qs(p),M&512&&A!==null&&Ul(A,A.return),p.flags&32){var q=p.stateNode;try{lt(q,"")}catch(Pt){an(p,p.return,Pt)}}if(M&4&&(q=p.stateNode,q!=null)){var Q=p.memoizedProps,de=A!==null?A.memoizedProps:Q,ke=p.type,Oe=p.updateQueue;if(p.updateQueue=null,Oe!==null)try{ke==="input"&&Q.type==="radio"&&Q.name!=null&&dt(q,Q),Er(ke,de);var Ge=Er(ke,Q);for(de=0;de<Oe.length;de+=2){var ct=Oe[de],ft=Oe[de+1];ct==="style"?mn(q,ft):ct==="dangerouslySetInnerHTML"?Tn(q,ft):ct==="children"?lt(q,ft):C(q,ct,ft,Ge)}switch(ke){case"input":ut(q,Q);break;case"textarea":en(q,Q);break;case"select":var ot=q._wrapperState.wasMultiple;q._wrapperState.wasMultiple=!!Q.multiple;var Ct=Q.value;Ct!=null?sr(q,!!Q.multiple,Ct,!1):ot!==!!Q.multiple&&(Q.defaultValue!=null?sr(q,!!Q.multiple,Q.defaultValue,!0):sr(q,!!Q.multiple,Q.multiple?[]:"",!1))}q[zc]=Q}catch(Pt){an(p,p.return,Pt)}}break;case 6:if(xs(v,p),qs(p),M&4){if(p.stateNode===null)throw Error(n(162));q=p.stateNode,Q=p.memoizedProps;try{q.nodeValue=Q}catch(Pt){an(p,p.return,Pt)}}break;case 3:if(xs(v,p),qs(p),M&4&&A!==null&&A.memoizedState.isDehydrated)try{Ta(v.containerInfo)}catch(Pt){an(p,p.return,Pt)}break;case 4:xs(v,p),qs(p);break;case 13:xs(v,p),qs(p),q=p.child,q.flags&8192&&(Q=q.memoizedState!==null,q.stateNode.isHidden=Q,!Q||q.alternate!==null&&q.alternate.memoizedState!==null||(Rh=qr())),M&4&&Yc(p);break;case 22:if(ct=A!==null&&A.memoizedState!==null,p.mode&1?(ii=(Ge=ii)||ct,xs(v,p),ii=Ge):xs(v,p),qs(p),M&8192){if(Ge=p.memoizedState!==null,(p.stateNode.isHidden=Ge)&&!ct&&(p.mode&1)!==0)for(Nt=p,ct=p.child;ct!==null;){for(ft=Nt=ct;Nt!==null;){switch(ot=Nt,Ct=ot.child,ot.tag){case 0:case 11:case 14:case 15:Xc(4,ot,ot.return);break;case 1:Ul(ot,ot.return);var Ot=ot.stateNode;if(typeof Ot.componentWillUnmount=="function"){M=ot,A=ot.return;try{v=M,Ot.props=v.memoizedProps,Ot.state=v.memoizedState,Ot.componentWillUnmount()}catch(Pt){an(M,A,Pt)}}break;case 5:Ul(ot,ot.return);break;case 22:if(ot.memoizedState!==null){Nh(ft);continue}}Ct!==null?(Ct.return=ot,Nt=Ct):Nh(ft)}ct=ct.sibling}e:for(ct=null,ft=p;;){if(ft.tag===5){if(ct===null){ct=ft;try{q=ft.stateNode,Ge?(Q=q.style,typeof Q.setProperty=="function"?Q.setProperty("display","none","important"):Q.display="none"):(ke=ft.stateNode,Oe=ft.memoizedProps.style,de=Oe!=null&&Oe.hasOwnProperty("display")?Oe.display:null,ke.style.display=br("display",de))}catch(Pt){an(p,p.return,Pt)}}}else if(ft.tag===6){if(ct===null)try{ft.stateNode.nodeValue=Ge?"":ft.memoizedProps}catch(Pt){an(p,p.return,Pt)}}else if((ft.tag!==22&&ft.tag!==23||ft.memoizedState===null||ft===p)&&ft.child!==null){ft.child.return=ft,ft=ft.child;continue}if(ft===p)break e;for(;ft.sibling===null;){if(ft.return===null||ft.return===p)break e;ct===ft&&(ct=null),ft=ft.return}ct===ft&&(ct=null),ft.sibling.return=ft.return,ft=ft.sibling}}break;case 19:xs(v,p),qs(p),M&4&&Yc(p);break;case 21:break;default:xs(v,p),qs(p)}}function qs(p){var v=p.flags;if(v&2){try{e:{for(var A=p.return;A!==null;){if(Cg(A)){var M=A;break e}A=A.return}throw Error(n(160))}switch(M.tag){case 5:var q=M.stateNode;M.flags&32&&(lt(q,""),M.flags&=-33);var Q=Eg(p);Ah(p,Q,q);break;case 3:case 4:var de=M.stateNode.containerInfo,ke=Eg(p);Th(p,ke,de);break;default:throw Error(n(161))}}catch(Oe){an(p,p.return,Oe)}p.flags&=-3}v&4096&&(p.flags&=-4097)}function jg(p,v,A){Nt=p,Tg(p)}function Tg(p,v,A){for(var M=(p.mode&1)!==0;Nt!==null;){var q=Nt,Q=q.child;if(q.tag===22&&M){var de=q.memoizedState!==null||kh;if(!de){var ke=q.alternate,Oe=ke!==null&&ke.memoizedState!==null||ii;ke=kh;var Ge=ii;if(kh=de,(ii=Oe)&&!Ge)for(Nt=q;Nt!==null;)de=Nt,Oe=de.child,de.tag===22&&de.memoizedState!==null?Oh(q):Oe!==null?(Oe.return=de,Nt=Oe):Oh(q);for(;Q!==null;)Nt=Q,Tg(Q),Q=Q.sibling;Nt=q,kh=ke,ii=Ge}Ag(p)}else(q.subtreeFlags&8772)!==0&&Q!==null?(Q.return=q,Nt=Q):Ag(p)}}function Ag(p){for(;Nt!==null;){var v=Nt;if((v.flags&8772)!==0){var A=v.alternate;try{if((v.flags&8772)!==0)switch(v.tag){case 0:case 11:case 15:ii||Eh(5,v);break;case 1:var M=v.stateNode;if(v.flags&4&&!ii)if(A===null)M.componentDidMount();else{var q=v.elementType===v.type?A.memoizedProps:Sn(v.type,A.memoizedProps);M.componentDidUpdate(q,A.memoizedState,M.__reactInternalSnapshotBeforeUpdate)}var Q=v.updateQueue;Q!==null&&Tb(v,Q,M);break;case 3:var de=v.updateQueue;if(de!==null){if(A=null,v.child!==null)switch(v.child.tag){case 5:A=v.child.stateNode;break;case 1:A=v.child.stateNode}Tb(v,de,A)}break;case 5:var ke=v.stateNode;if(A===null&&v.flags&4){A=ke;var Oe=v.memoizedProps;switch(v.type){case"button":case"input":case"select":case"textarea":Oe.autoFocus&&A.focus();break;case"img":Oe.src&&(A.src=Oe.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(v.memoizedState===null){var Ge=v.alternate;if(Ge!==null){var ct=Ge.memoizedState;if(ct!==null){var ft=ct.dehydrated;ft!==null&&Ta(ft)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}ii||v.flags&512&&jh(v)}catch(ot){an(v,v.return,ot)}}if(v===p){Nt=null;break}if(A=v.sibling,A!==null){A.return=v.return,Nt=A;break}Nt=v.return}}function Nh(p){for(;Nt!==null;){var v=Nt;if(v===p){Nt=null;break}var A=v.sibling;if(A!==null){A.return=v.return,Nt=A;break}Nt=v.return}}function Oh(p){for(;Nt!==null;){var v=Nt;try{switch(v.tag){case 0:case 11:case 15:var A=v.return;try{Eh(4,v)}catch(Oe){an(v,A,Oe)}break;case 1:var M=v.stateNode;if(typeof M.componentDidMount=="function"){var q=v.return;try{M.componentDidMount()}catch(Oe){an(v,q,Oe)}}var Q=v.return;try{jh(v)}catch(Oe){an(v,Q,Oe)}break;case 5:var de=v.return;try{jh(v)}catch(Oe){an(v,de,Oe)}}}catch(Oe){an(v,v.return,Oe)}if(v===p){Nt=null;break}var ke=v.sibling;if(ke!==null){ke.return=v.return,Nt=ke;break}Nt=v.return}}var Hb=Math.ceil,gd=T.ReactCurrentDispatcher,vd=T.ReactCurrentOwner,ws=T.ReactCurrentBatchConfig,wr=0,kn=null,bn=null,Hn=0,Qi=0,ql=$a(0),Pn=0,Jc=null,rl=0,yd=0,Ph=0,bd=null,Fi=null,Rh=0,Wl=1/0,mo=null,xd=!1,Mh=null,go=null,wd=!1,nl=null,_d=0,Qc=0,Ih=null,Zc=-1,Sd=0;function Si(){return(wr&6)!==0?qr():Zc!==-1?Zc:Zc=qr()}function vo(p){return(p.mode&1)===0?1:(wr&2)!==0&&Hn!==0?Hn&-Hn:Gf.transition!==null?(Sd===0&&(Sd=Zs()),Sd):(p=ur,p!==0||(p=window.event,p=p===void 0?16:he(p.type)),p)}function Ws(p,v,A,M){if(50<Qc)throw Qc=0,Ih=null,Error(n(185));Ps(p,A,M),((wr&2)===0||p!==kn)&&(p===kn&&((wr&2)===0&&(yd|=A),Pn===4&&yo(p,Hn)),Ui(p,M),A===1&&wr===0&&(v.mode&1)===0&&(Wl=qr()+500,ed&&co()))}function Ui(p,v){var A=p.callbackNode;us(p,v);var M=Os(p,p===kn?Hn:0);if(M===0)A!==null&&An(A),p.callbackNode=null,p.callbackPriority=0;else if(v=M&-M,p.callbackPriority!==v){if(A!=null&&An(A),v===1)p.tag===0?H_(Og.bind(null,p)):Dm(Og.bind(null,p)),kb(function(){(wr&6)===0&&co()}),A=null;else{switch(It(M)){case 1:A=gn;break;case 4:A=dn;break;case 16:A=Et;break;case 536870912:A=rt;break;default:A=Et}A=Lg(A,$g.bind(null,p))}p.callbackPriority=v,p.callbackNode=A}}function $g(p,v){if(Zc=-1,Sd=0,(wr&6)!==0)throw Error(n(327));var A=p.callbackNode;if(Hl()&&p.callbackNode!==A)return null;var M=Os(p,p===kn?Hn:0);if(M===0)return null;if((M&30)!==0||(M&p.expiredLanes)!==0||v)v=kd(p,M);else{v=M;var q=wr;wr|=2;var Q=Gb();(kn!==p||Hn!==v)&&(mo=null,Wl=qr()+500,sl(p,v));do try{X_();break}catch(ke){Pg(p,ke)}while(!0);Xf(),gd.current=Q,wr=q,bn!==null?v=0:(kn=null,Hn=0,v=Pn)}if(v!==0){if(v===2&&(q=Fo(p),q!==0&&(M=q,v=Dh(p,q))),v===1)throw A=Jc,sl(p,0),yo(p,M),Ui(p,qr()),A;if(v===6)yo(p,M);else{if(q=p.current.alternate,(M&30)===0&&!Ng(q)&&(v=kd(p,M),v===2&&(Q=Fo(p),Q!==0&&(M=Q,v=Dh(p,Q))),v===1))throw A=Jc,sl(p,0),yo(p,M),Ui(p,qr()),A;switch(p.finishedWork=q,p.finishedLanes=M,v){case 0:case 1:throw Error(n(345));case 2:al(p,Fi,mo);break;case 3:if(yo(p,M),(M&130023424)===M&&(v=Rh+500-qr(),10<v)){if(Os(p,0)!==0)break;if(q=p.suspendedLanes,(q&M)!==M){Si(),p.pingedLanes|=p.suspendedLanes&q;break}p.timeoutHandle=Rf(al.bind(null,p,Fi,mo),v);break}al(p,Fi,mo);break;case 4:if(yo(p,M),(M&4194240)===M)break;for(v=p.eventTimes,q=-1;0<M;){var de=31-ar(M);Q=1<<de,de=v[de],de>q&&(q=de),M&=~Q}if(M=q,M=qr()-M,M=(120>M?120:480>M?480:1080>M?1080:1920>M?1920:3e3>M?3e3:4320>M?4320:1960*Hb(M/1960))-M,10<M){p.timeoutHandle=Rf(al.bind(null,p,Fi,mo),M);break}al(p,Fi,mo);break;case 5:al(p,Fi,mo);break;default:throw Error(n(329))}}}return Ui(p,qr()),p.callbackNode===A?$g.bind(null,p):null}function Dh(p,v){var A=bd;return p.current.memoizedState.isDehydrated&&(sl(p,v).flags|=256),p=kd(p,v),p!==2&&(v=Fi,Fi=A,v!==null&&Lh(v)),p}function Lh(p){Fi===null?Fi=p:Fi.push.apply(Fi,p)}function Ng(p){for(var v=p;;){if(v.flags&16384){var A=v.updateQueue;if(A!==null&&(A=A.stores,A!==null))for(var M=0;M<A.length;M++){var q=A[M],Q=q.getSnapshot;q=q.value;try{if(!Bs(Q(),q))return!1}catch{return!1}}}if(A=v.child,v.subtreeFlags&16384&&A!==null)A.return=v,v=A;else{if(v===p)break;for(;v.sibling===null;){if(v.return===null||v.return===p)return!0;v=v.return}v.sibling.return=v.return,v=v.sibling}}return!0}function yo(p,v){for(v&=~Ph,v&=~yd,p.suspendedLanes|=v,p.pingedLanes&=~v,p=p.expirationTimes;0<v;){var A=31-ar(v),M=1<<A;p[A]=-1,v&=~M}}function Og(p){if((wr&6)!==0)throw Error(n(327));Hl();var v=Os(p,0);if((v&1)===0)return Ui(p,qr()),null;var A=kd(p,v);if(p.tag!==0&&A===2){var M=Fo(p);M!==0&&(v=M,A=Dh(p,M))}if(A===1)throw A=Jc,sl(p,0),yo(p,v),Ui(p,qr()),A;if(A===6)throw Error(n(345));return p.finishedWork=p.current.alternate,p.finishedLanes=v,al(p,Fi,mo),Ui(p,qr()),null}function Bh(p,v){var A=wr;wr|=1;try{return p(v)}finally{wr=A,wr===0&&(Wl=qr()+500,ed&&co())}}function il(p){nl!==null&&nl.tag===0&&(wr&6)===0&&Hl();var v=wr;wr|=1;var A=ws.transition,M=ur;try{if(ws.transition=null,ur=1,p)return p()}finally{ur=M,ws.transition=A,wr=v,(wr&6)===0&&co()}}function zh(){Qi=ql.current,Hr(ql)}function sl(p,v){p.finishedWork=null,p.finishedLanes=0;var A=p.timeoutHandle;if(A!==-1&&(p.timeoutHandle=-1,Sb(A)),bn!==null)for(A=bn.return;A!==null;){var M=A;switch(Bf(M),M.tag){case 1:M=M.type.childContextTypes,M!=null&&Qu();break;case 3:Qo(),Hr(Ri),Hr(xi),rh();break;case 5:eh(M);break;case 4:Qo();break;case 13:Hr(sn);break;case 19:Hr(sn);break;case 10:Yf(M.type._context);break;case 22:case 23:zh()}A=A.return}if(kn=p,bn=p=bo(p.current,null),Hn=Qi=v,Pn=0,Jc=null,Ph=yd=rl=0,Fi=bd=null,Bl!==null){for(v=0;v<Bl.length;v++)if(A=Bl[v],M=A.interleaved,M!==null){A.interleaved=null;var q=M.next,Q=A.pending;if(Q!==null){var de=Q.next;Q.next=q,M.next=de}A.pending=M}Bl=null}return p}function Pg(p,v){do{var A=bn;try{if(Xf(),nh.current=fd,sh){for(var M=rn.memoizedState;M!==null;){var q=M.queue;q!==null&&(q.pending=null),M=M.next}sh=!1}if(Zo=0,On=_n=rn=null,el=!1,ho=0,vd.current=null,A===null||A.return===null){Pn=1,Jc=v,bn=null;break}e:{var Q=p,de=A.return,ke=A,Oe=v;if(v=Hn,ke.flags|=32768,Oe!==null&&typeof Oe=="object"&&typeof Oe.then=="function"){var Ge=Oe,ct=ke,ft=ct.tag;if((ct.mode&1)===0&&(ft===0||ft===11||ft===15)){var ot=ct.alternate;ot?(ct.updateQueue=ot.updateQueue,ct.memoizedState=ot.memoizedState,ct.lanes=ot.lanes):(ct.updateQueue=null,ct.memoizedState=null)}var Ct=Db(de);if(Ct!==null){Ct.flags&=-257,_i(Ct,de,ke,Q,v),Ct.mode&1&&fg(Q,Ge,v),v=Ct,Oe=Ge;var Ot=v.updateQueue;if(Ot===null){var Pt=new Set;Pt.add(Oe),v.updateQueue=Pt}else Ot.add(Oe);break e}else{if((v&1)===0){fg(Q,Ge,v),Fh();break e}Oe=Error(n(426))}}else if(tn&&ke.mode&1){var zr=Db(de);if(zr!==null){(zr.flags&65536)===0&&(zr.flags|=256),_i(zr,de,ke,Q,v),Hf(Fl(Oe,ke));break e}}Q=Oe=Fl(Oe,ke),Pn!==4&&(Pn=2),bd===null?bd=[Q]:bd.push(Q),Q=de;do{switch(Q.tag){case 3:Q.flags|=65536,v&=-v,Q.lanes|=v;var qe=ug(Q,Oe,v);jb(Q,qe);break e;case 1:ke=Oe;var Ie=Q.type,Ke=Q.stateNode;if((Q.flags&128)===0&&(typeof Ie.getDerivedStateFromError=="function"||Ke!==null&&typeof Ke.componentDidCatch=="function"&&(go===null||!go.has(Ke)))){Q.flags|=65536,v&=-v,Q.lanes|=v;var gt=dg(Q,ke,v);jb(Q,gt);break e}}Q=Q.return}while(Q!==null)}eu(A)}catch(Bt){v=Bt,bn===A&&A!==null&&(bn=A=A.return);continue}break}while(!0)}function Gb(){var p=gd.current;return gd.current=fd,p===null?fd:p}function Fh(){(Pn===0||Pn===3||Pn===2)&&(Pn=4),kn===null||(rl&268435455)===0&&(yd&268435455)===0||yo(kn,Hn)}function kd(p,v){var A=wr;wr|=2;var M=Gb();(kn!==p||Hn!==v)&&(mo=null,sl(p,v));do try{Vb();break}catch(q){Pg(p,q)}while(!0);if(Xf(),wr=A,gd.current=M,bn!==null)throw Error(n(261));return kn=null,Hn=0,Pn}function Vb(){for(;bn!==null;)Rg(bn)}function X_(){for(;bn!==null&&!zo();)Rg(bn)}function Rg(p){var v=Dg(p.alternate,p,Qi);p.memoizedProps=p.pendingProps,v===null?eu(p):bn=v,vd.current=null}function eu(p){var v=p;do{var A=v.alternate;if(p=v.return,(v.flags&32768)===0){if(A=zb(A,v,Qi),A!==null){bn=A;return}}else{if(A=Fb(A,v),A!==null){A.flags&=32767,bn=A;return}if(p!==null)p.flags|=32768,p.subtreeFlags=0,p.deletions=null;else{Pn=6,bn=null;return}}if(v=v.sibling,v!==null){bn=v;return}bn=v=p}while(v!==null);Pn===0&&(Pn=5)}function al(p,v,A){var M=ur,q=ws.transition;try{ws.transition=null,ur=1,Mg(p,v,A,M)}finally{ws.transition=q,ur=M}return null}function Mg(p,v,A,M){do Hl();while(nl!==null);if((wr&6)!==0)throw Error(n(327));A=p.finishedWork;var q=p.finishedLanes;if(A===null)return null;if(p.finishedWork=null,p.finishedLanes=0,A===p.current)throw Error(n(177));p.callbackNode=null,p.callbackPriority=0;var Q=A.lanes|A.childLanes;if(Cc(p,Q),p===kn&&(bn=kn=null,Hn=0),(A.subtreeFlags&2064)===0&&(A.flags&2064)===0||wd||(wd=!0,Lg(Et,function(){return Hl(),null})),Q=(A.flags&15990)!==0,(A.subtreeFlags&15990)!==0||Q){Q=ws.transition,ws.transition=null;var de=ur;ur=1;var ke=wr;wr|=4,vd.current=null,qb(p,A),$h(A,p),yb(Of),so=!!Nf,Of=Nf=null,p.current=A,jg(A),El(),wr=ke,ur=de,ws.transition=Q}else p.current=A;if(wd&&(wd=!1,nl=p,_d=q),Q=p.pendingLanes,Q===0&&(go=null),pt(A.stateNode),Ui(p,qr()),v!==null)for(M=p.onRecoverableError,A=0;A<v.length;A++)q=v[A],M(q.value,{componentStack:q.stack,digest:q.digest});if(xd)throw xd=!1,p=Mh,Mh=null,p;return(_d&1)!==0&&p.tag!==0&&Hl(),Q=p.pendingLanes,(Q&1)!==0?p===Ih?Qc++:(Qc=0,Ih=p):Qc=0,co(),null}function Hl(){if(nl!==null){var p=It(_d),v=ws.transition,A=ur;try{if(ws.transition=null,ur=16>p?16:p,nl===null)var M=!1;else{if(p=nl,nl=null,_d=0,(wr&6)!==0)throw Error(n(331));var q=wr;for(wr|=4,Nt=p.current;Nt!==null;){var Q=Nt,de=Q.child;if((Nt.flags&16)!==0){var ke=Q.deletions;if(ke!==null){for(var Oe=0;Oe<ke.length;Oe++){var Ge=ke[Oe];for(Nt=Ge;Nt!==null;){var ct=Nt;switch(ct.tag){case 0:case 11:case 15:Xc(8,ct,Q)}var ft=ct.child;if(ft!==null)ft.return=ct,Nt=ft;else for(;Nt!==null;){ct=Nt;var ot=ct.sibling,Ct=ct.return;if(kg(ct),ct===Ge){Nt=null;break}if(ot!==null){ot.return=Ct,Nt=ot;break}Nt=Ct}}}var Ot=Q.alternate;if(Ot!==null){var Pt=Ot.child;if(Pt!==null){Ot.child=null;do{var zr=Pt.sibling;Pt.sibling=null,Pt=zr}while(Pt!==null)}}Nt=Q}}if((Q.subtreeFlags&2064)!==0&&de!==null)de.return=Q,Nt=de;else e:for(;Nt!==null;){if(Q=Nt,(Q.flags&2048)!==0)switch(Q.tag){case 0:case 11:case 15:Xc(9,Q,Q.return)}var qe=Q.sibling;if(qe!==null){qe.return=Q.return,Nt=qe;break e}Nt=Q.return}}var Ie=p.current;for(Nt=Ie;Nt!==null;){de=Nt;var Ke=de.child;if((de.subtreeFlags&2064)!==0&&Ke!==null)Ke.return=de,Nt=Ke;else e:for(de=Ie;Nt!==null;){if(ke=Nt,(ke.flags&2048)!==0)try{switch(ke.tag){case 0:case 11:case 15:Eh(9,ke)}}catch(Bt){an(ke,ke.return,Bt)}if(ke===de){Nt=null;break e}var gt=ke.sibling;if(gt!==null){gt.return=ke.return,Nt=gt;break e}Nt=ke.return}}if(wr=q,co(),nr&&typeof nr.onPostCommitFiberRoot=="function")try{nr.onPostCommitFiberRoot(_t,p)}catch{}M=!0}return M}finally{ur=A,ws.transition=v}}return!1}function Ig(p,v,A){v=Fl(A,v),v=ug(p,v,1),p=fo(p,v,1),v=Si(),p!==null&&(Ps(p,1,v),Ui(p,v))}function an(p,v,A){if(p.tag===3)Ig(p,p,A);else for(;v!==null;){if(v.tag===3){Ig(v,p,A);break}else if(v.tag===1){var M=v.stateNode;if(typeof v.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(go===null||!go.has(M))){p=Fl(A,p),p=dg(v,p,1),v=fo(v,p,1),p=Si(),v!==null&&(Ps(v,1,p),Ui(v,p));break}}v=v.return}}function Kb(p,v,A){var M=p.pingCache;M!==null&&M.delete(v),v=Si(),p.pingedLanes|=p.suspendedLanes&A,kn===p&&(Hn&A)===A&&(Pn===4||Pn===3&&(Hn&130023424)===Hn&&500>qr()-Rh?sl(p,0):Ph|=A),Ui(p,v)}function Xb(p,v){v===0&&((p.mode&1)===0?v=1:(v=jr,jr<<=1,(jr&130023424)===0&&(jr=4194304)));var A=Si();p=Oa(p,v),p!==null&&(Ps(p,v,A),Ui(p,A))}function Yb(p){var v=p.memoizedState,A=0;v!==null&&(A=v.retryLane),Xb(p,A)}function Jb(p,v){var A=0;switch(p.tag){case 13:var M=p.stateNode,q=p.memoizedState;q!==null&&(A=q.retryLane);break;case 19:M=p.stateNode;break;default:throw Error(n(314))}M!==null&&M.delete(v),Xb(p,A)}var Dg;Dg=function(p,v,A){if(p!==null)if(p.memoizedProps!==v.pendingProps||Ri.current)zi=!0;else{if((p.lanes&A)===0&&(v.flags&128)===0)return zi=!1,K_(p,v,A);zi=(p.flags&131072)!==0}else zi=!1,tn&&(v.flags&1048576)!==0&&Vo(v,rd,v.index);switch(v.lanes=0,v.tag){case 2:var M=v.type;pd(p,v),p=v.pendingProps;var q=wi(v,xi.current);Ll(v,A),q=oh(null,v,M,p,q,A);var Q=lh();return v.flags|=1,typeof q=="object"&&q!==null&&typeof q.render=="function"&&q.$$typeof===void 0?(v.tag=1,v.memoizedState=null,v.updateQueue=null,Mi(M)?(Q=!0,Zu(v)):Q=!1,v.memoizedState=q.state!==null&&q.state!==void 0?q.state:null,ad(v),q.updater=Ra,v.stateNode=q,q._reactInternals=v,fh(v,M,p,A),v=gh(null,v,M,!0,Q,A)):(v.tag=0,tn&&Q&&wn(v),ri(null,v,q,A),v=v.child),v;case 16:M=v.elementType;e:{switch(pd(p,v),p=v.pendingProps,q=M._init,M=q(M._payload),v.type=M,q=v.tag=Qb(M),p=Sn(M,p),q){case 0:v=mh(null,v,M,p,A);break e;case 1:v=vg(null,v,M,p,A);break e;case 11:v=hg(null,v,M,p,A);break e;case 14:v=Vc(null,v,M,Sn(M.type,p),A);break e}throw Error(n(306,M,""))}return v;case 0:return M=v.type,q=v.pendingProps,q=v.elementType===M?q:Sn(M,q),mh(p,v,M,q,A);case 1:return M=v.type,q=v.pendingProps,q=v.elementType===M?q:Sn(M,q),vg(p,v,M,q,A);case 3:e:{if(vh(v),p===null)throw Error(n(387));M=v.pendingProps,Q=v.memoizedState,q=Q.element,Qf(p,v),od(v,M,null,A);var de=v.memoizedState;if(M=de.element,Q.isDehydrated)if(Q={element:M,isDehydrated:!1,cache:de.cache,pendingSuspenseBoundaries:de.pendingSuspenseBoundaries,transitions:de.transitions},v.updateQueue.baseState=Q,v.memoizedState=Q,v.flags&256){q=Fl(Error(n(423)),v),v=yg(p,v,M,A,q);break e}else if(M!==q){q=Fl(Error(n(424)),v),v=yg(p,v,M,A,q);break e}else for(Ji=oo(v.stateNode.containerInfo.firstChild),Li=v,tn=!0,Bi=null,A=Vf(v,null,M,A),v.child=A;A;)A.flags=A.flags&-3|4096,A=A.sibling;else{if(Ko(),M===q){v=Ma(p,v,A);break e}ri(p,v,M,A)}v=v.child}return v;case 5:return Fm(v),p===null&&qf(v),M=v.type,q=v.pendingProps,Q=p!==null?p.memoizedProps:null,de=q.children,Pf(M,q)?de=null:Q!==null&&Pf(M,Q)&&(v.flags|=32),gg(p,v),ri(p,v,de,A),v.child;case 6:return p===null&&qf(v),null;case 13:return bg(p,v,A);case 4:return Zf(v,v.stateNode.containerInfo),M=v.pendingProps,p===null?v.child=Dl(v,null,M,A):ri(p,v,M,A),v.child;case 11:return M=v.type,q=v.pendingProps,q=v.elementType===M?q:Sn(M,q),hg(p,v,M,q,A);case 7:return ri(p,v,v.pendingProps,A),v.child;case 8:return ri(p,v,v.pendingProps.children,A),v.child;case 12:return ri(p,v,v.pendingProps.children,A),v.child;case 10:e:{if(M=v.type._context,q=v.pendingProps,Q=v.memoizedProps,de=q.value,Br(Xo,M._currentValue),M._currentValue=de,Q!==null)if(Bs(Q.value,de)){if(Q.children===q.children&&!Ri.current){v=Ma(p,v,A);break e}}else for(Q=v.child,Q!==null&&(Q.return=v);Q!==null;){var ke=Q.dependencies;if(ke!==null){de=Q.child;for(var Oe=ke.firstContext;Oe!==null;){if(Oe.context===M){if(Q.tag===1){Oe=Pa(-1,A&-A),Oe.tag=2;var Ge=Q.updateQueue;if(Ge!==null){Ge=Ge.shared;var ct=Ge.pending;ct===null?Oe.next=Oe:(Oe.next=ct.next,ct.next=Oe),Ge.pending=Oe}}Q.lanes|=A,Oe=Q.alternate,Oe!==null&&(Oe.lanes|=A),zm(Q.return,A,v),ke.lanes|=A;break}Oe=Oe.next}}else if(Q.tag===10)de=Q.type===v.type?null:Q.child;else if(Q.tag===18){if(de=Q.return,de===null)throw Error(n(341));de.lanes|=A,ke=de.alternate,ke!==null&&(ke.lanes|=A),zm(de,A,v),de=Q.sibling}else de=Q.child;if(de!==null)de.return=Q;else for(de=Q;de!==null;){if(de===v){de=null;break}if(Q=de.sibling,Q!==null){Q.return=de.return,de=Q;break}de=de.return}Q=de}ri(p,v,q.children,A),v=v.child}return v;case 9:return q=v.type,M=v.pendingProps.children,Ll(v,A),q=ys(q),M=M(q),v.flags|=1,ri(p,v,M,A),v.child;case 14:return M=v.type,q=Sn(M,v.pendingProps),q=Sn(M.type,q),Vc(p,v,M,q,A);case 15:return pg(p,v,v.type,v.pendingProps,A);case 17:return M=v.type,q=v.pendingProps,q=v.elementType===M?q:Sn(M,q),pd(p,v),v.tag=1,Mi(M)?(p=!0,Zu(v)):p=!1,Ll(v,A),lg(v,M,q),fh(v,M,q,A),gh(null,v,M,!0,p,A);case 19:return wh(p,v,A);case 22:return mg(p,v,A)}throw Error(n(156,v.tag))};function Lg(p,v){return pi(p,v)}function Y_(p,v,A,M){this.tag=p,this.key=A,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=v,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Zi(p,v,A,M){return new Y_(p,v,A,M)}function Uh(p){return p=p.prototype,!(!p||!p.isReactComponent)}function Qb(p){if(typeof p=="function")return Uh(p)?1:0;if(p!=null){if(p=p.$$typeof,p===V)return 11;if(p===G)return 14}return 2}function bo(p,v){var A=p.alternate;return A===null?(A=Zi(p.tag,v,p.key,p.mode),A.elementType=p.elementType,A.type=p.type,A.stateNode=p.stateNode,A.alternate=p,p.alternate=A):(A.pendingProps=v,A.type=p.type,A.flags=0,A.subtreeFlags=0,A.deletions=null),A.flags=p.flags&14680064,A.childLanes=p.childLanes,A.lanes=p.lanes,A.child=p.child,A.memoizedProps=p.memoizedProps,A.memoizedState=p.memoizedState,A.updateQueue=p.updateQueue,v=p.dependencies,A.dependencies=v===null?null:{lanes:v.lanes,firstContext:v.firstContext},A.sibling=p.sibling,A.index=p.index,A.ref=p.ref,A}function Cd(p,v,A,M,q,Q){var de=2;if(M=p,typeof p=="function")Uh(p)&&(de=1);else if(typeof p=="string")de=5;else e:switch(p){case N:return Gl(A.children,q,Q,v);case O:de=8,q|=8;break;case I:return p=Zi(12,A,v,q|2),p.elementType=I,p.lanes=Q,p;case U:return p=Zi(13,A,v,q),p.elementType=U,p.lanes=Q,p;case D:return p=Zi(19,A,v,q),p.elementType=D,p.lanes=Q,p;case ae:return Ed(A,q,Q,v);default:if(typeof p=="object"&&p!==null)switch(p.$$typeof){case W:de=10;break e;case H:de=9;break e;case V:de=11;break e;case G:de=14;break e;case ee:de=16,M=null;break e}throw Error(n(130,p==null?p:typeof p,""))}return v=Zi(de,A,v,q),v.elementType=p,v.type=M,v.lanes=Q,v}function Gl(p,v,A,M){return p=Zi(7,p,M,v),p.lanes=A,p}function Ed(p,v,A,M){return p=Zi(22,p,M,v),p.elementType=ae,p.lanes=A,p.stateNode={isHidden:!1},p}function qh(p,v,A){return p=Zi(6,p,null,v),p.lanes=A,p}function Wh(p,v,A){return v=Zi(4,p.children!==null?p.children:[],p.key,v),v.lanes=A,v.stateNode={containerInfo:p.containerInfo,pendingChildren:null,implementation:p.implementation},v}function J_(p,v,A,M,q){this.tag=v,this.containerInfo=p,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Je(0),this.expirationTimes=Je(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Je(0),this.identifierPrefix=M,this.onRecoverableError=q,this.mutableSourceEagerHydrationData=null}function Hh(p,v,A,M,q,Q,de,ke,Oe){return p=new J_(p,v,A,ke,Oe),v===1?(v=1,Q===!0&&(v|=8)):v=0,Q=Zi(3,null,null,v),p.current=Q,Q.stateNode=p,Q.memoizedState={element:M,isDehydrated:A,cache:null,transitions:null,pendingSuspenseBoundaries:null},ad(Q),p}function Q_(p,v,A){var M=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:M==null?null:""+M,children:p,containerInfo:v,implementation:A}}function Bg(p){if(!p)return lo;p=p._reactInternals;e:{if(At(p)!==p||p.tag!==1)throw Error(n(170));var v=p;do{switch(v.tag){case 3:v=v.stateNode.context;break e;case 1:if(Mi(v.type)){v=v.stateNode.__reactInternalMemoizedMergedChildContext;break e}}v=v.return}while(v!==null);throw Error(n(171))}if(p.tag===1){var A=p.type;if(Mi(A))return Mm(p,A,v)}return v}function Zb(p,v,A,M,q,Q,de,ke,Oe){return p=Hh(A,M,!0,p,q,Q,de,ke,Oe),p.context=Bg(null),A=p.current,M=Si(),q=vo(A),Q=Pa(M,q),Q.callback=v??null,fo(A,Q,q),p.current.lanes=q,Ps(p,q,M),Ui(p,M),p}function jd(p,v,A,M){var q=v.current,Q=Si(),de=vo(q);return A=Bg(A),v.context===null?v.context=A:v.pendingContext=A,v=Pa(Q,de),v.payload={element:p},M=M===void 0?null:M,M!==null&&(v.callback=M),p=fo(q,v,de),p!==null&&(Ws(p,q,de,Q),qc(p,q,de)),de}function Td(p){if(p=p.current,!p.child)return null;switch(p.child.tag){case 5:return p.child.stateNode;default:return p.child.stateNode}}function zg(p,v){if(p=p.memoizedState,p!==null&&p.dehydrated!==null){var A=p.retryLane;p.retryLane=A!==0&&A<v?A:v}}function Gh(p,v){zg(p,v),(p=p.alternate)&&zg(p,v)}function ex(){return null}var tx=typeof reportError=="function"?reportError:function(p){console.error(p)};function Vh(p){this._internalRoot=p}Vl.prototype.render=Vh.prototype.render=function(p){var v=this._internalRoot;if(v===null)throw Error(n(409));jd(p,v,null,null)},Vl.prototype.unmount=Vh.prototype.unmount=function(){var p=this._internalRoot;if(p!==null){this._internalRoot=null;var v=p.containerInfo;il(function(){jd(null,p,null,null)}),v[aa]=null}};function Vl(p){this._internalRoot=p}Vl.prototype.unstable_scheduleHydration=function(p){if(p){var v=Za();p={blockedOn:null,target:p,priority:v};for(var A=0;A<Rs.length&&v!==0&&v<Rs[A].priority;A++);Rs.splice(A,0,p),A===0&&Ec(p)}};function Kh(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)}function Ad(p){return!(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11&&(p.nodeType!==8||p.nodeValue!==" react-mount-point-unstable "))}function rx(){}function nx(p,v,A,M,q){if(q){if(typeof M=="function"){var Q=M;M=function(){var Ge=Td(de);Q.call(Ge)}}var de=Zb(v,M,p,0,null,!1,!1,"",rx);return p._reactRootContainer=de,p[aa]=de.current,Lc(p.nodeType===8?p.parentNode:p),il(),de}for(;q=p.lastChild;)p.removeChild(q);if(typeof M=="function"){var ke=M;M=function(){var Ge=Td(Oe);ke.call(Ge)}}var Oe=Hh(p,0,!1,null,null,!1,!1,"",rx);return p._reactRootContainer=Oe,p[aa]=Oe.current,Lc(p.nodeType===8?p.parentNode:p),il(function(){jd(v,Oe,A,M)}),Oe}function tu(p,v,A,M,q){var Q=A._reactRootContainer;if(Q){var de=Q;if(typeof q=="function"){var ke=q;q=function(){var Oe=Td(de);ke.call(Oe)}}jd(v,de,p,q)}else de=nx(A,v,p,q,M);return Td(de)}ea=function(p){switch(p.tag){case 3:var v=p.stateNode;if(v.current.memoizedState.isDehydrated){var A=cs(v.pendingLanes);A!==0&&(jl(v,A|1),Ui(v,qr()),(wr&6)===0&&(Wl=qr()+500,co()))}break;case 13:il(function(){var M=Oa(p,1);if(M!==null){var q=Si();Ws(M,p,1,q)}}),Gh(p,1)}},Ca=function(p){if(p.tag===13){var v=Oa(p,134217728);if(v!==null){var A=Si();Ws(v,p,134217728,A)}Gh(p,134217728)}},Ea=function(p){if(p.tag===13){var v=vo(p),A=Oa(p,v);if(A!==null){var M=Si();Ws(A,p,v,M)}Gh(p,v)}},Za=function(){return ur},Uo=function(p,v){var A=ur;try{return ur=p,v()}finally{ur=A}},zn=function(p,v,A){switch(v){case"input":if(ut(p,A),v=A.name,A.type==="radio"&&v!=null){for(A=p;A.parentNode;)A=A.parentNode;for(A=A.querySelectorAll("input[name="+JSON.stringify(""+v)+'][type="radio"]'),v=0;v<A.length;v++){var M=A[v];if(M!==p&&M.form===p.form){var q=Ju(M);if(!q)throw Error(n(90));Me(M),ut(M,q)}}}break;case"textarea":en(p,A);break;case"select":v=A.value,v!=null&&sr(p,!!A.multiple,v,!1)}},As=Bh,Lo=il;var Fg={usingClientEntryPoint:!1,Events:[Fc,Ol,Ju,wa,_a,Bh]},Hs={findFiberByHostInstance:Ho,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},ix={bundleType:Hs.bundleType,version:Hs.version,rendererPackageName:Hs.rendererPackageName,rendererConfig:Hs.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(p){return p=os(p),p===null?null:p.stateNode},findFiberByHostInstance:Hs.findFiberByHostInstance||ex,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ru.isDisabled&&ru.supportsFiber)try{_t=ru.inject(ix),nr=ru}catch{}}return Gs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Fg,Gs.createPortal=function(p,v){var A=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Kh(v))throw Error(n(200));return Q_(p,v,null,A)},Gs.createRoot=function(p,v){if(!Kh(p))throw Error(n(299));var A=!1,M="",q=tx;return v!=null&&(v.unstable_strictMode===!0&&(A=!0),v.identifierPrefix!==void 0&&(M=v.identifierPrefix),v.onRecoverableError!==void 0&&(q=v.onRecoverableError)),v=Hh(p,1,!1,null,null,A,!1,M,q),p[aa]=v.current,Lc(p.nodeType===8?p.parentNode:p),new Vh(v)},Gs.findDOMNode=function(p){if(p==null)return null;if(p.nodeType===1)return p;var v=p._reactInternals;if(v===void 0)throw typeof p.render=="function"?Error(n(188)):(p=Object.keys(p).join(","),Error(n(268,p)));return p=os(v),p=p===null?null:p.stateNode,p},Gs.flushSync=function(p){return il(p)},Gs.hydrate=function(p,v,A){if(!Ad(v))throw Error(n(200));return tu(null,p,v,!0,A)},Gs.hydrateRoot=function(p,v,A){if(!Kh(p))throw Error(n(405));var M=A!=null&&A.hydratedSources||null,q=!1,Q="",de=tx;if(A!=null&&(A.unstable_strictMode===!0&&(q=!0),A.identifierPrefix!==void 0&&(Q=A.identifierPrefix),A.onRecoverableError!==void 0&&(de=A.onRecoverableError)),v=Zb(v,null,p,1,A??null,q,!1,Q,de),p[aa]=v.current,Lc(p),M)for(p=0;p<M.length;p++)A=M[p],q=A._getVersion,q=q(A._source),v.mutableSourceEagerHydrationData==null?v.mutableSourceEagerHydrationData=[A,q]:v.mutableSourceEagerHydrationData.push(A,q);return new Vl(v)},Gs.render=function(p,v,A){if(!Ad(v))throw Error(n(200));return tu(null,p,v,!1,A)},Gs.unmountComponentAtNode=function(p){if(!Ad(p))throw Error(n(40));return p._reactRootContainer?(il(function(){tu(null,null,p,!1,function(){p._reactRootContainer=null,p[aa]=null})}),!0):!1},Gs.unstable_batchedUpdates=Bh,Gs.unstable_renderSubtreeIntoContainer=function(p,v,A,M){if(!Ad(A))throw Error(n(200));if(p==null||p._reactInternals===void 0)throw Error(n(38));return tu(p,v,A,!1,M)},Gs.version="18.3.1-next-f1338f8080-20240426",Gs}var b$;function R5(){if(b$)return n1.exports;b$=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),n1.exports=cU(),n1.exports}var x$;function uU(){if(x$)return ox;x$=1;var e=R5();return ox.createRoot=e.createRoot,ox.hydrateRoot=e.hydrateRoot,ox}var dU=uU();const fU=Xr(dU);var B=yT();const Fe=Xr(B),w$=e=>{let r;const n=new Set,i=(f,m)=>{const h=typeof f=="function"?f(r):f;if(!Object.is(h,r)){const b=r;r=m??(typeof h!="object"||h===null)?h:Object.assign({},r,h),n.forEach(x=>x(r,b))}},s=()=>r,o={setState:i,getState:s,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f))},u=r=e(i,s,o);return o},hU=(e=>e?w$(e):w$),pU=e=>e;function mU(e,r=pU){const n=Fe.useSyncExternalStore(e.subscribe,Fe.useCallback(()=>r(e.getState()),[e,r]),Fe.useCallback(()=>r(e.getInitialState()),[e,r]));return Fe.useDebugValue(n),n}const _$=e=>{const r=hU(e),n=i=>mU(r,i);return Object.assign(n,r),n},jn=(e=>e?_$(e):_$);function Ro(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const a1=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${Ro(e)}`,S$=({sessionId:e})=>`claude --session-id ${Ro(e)}`,gU=()=>"claude --resume",M5=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:a1},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:S$},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:a1},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:a1},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:S$},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:gU},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let Da=null;async function vU(){if(Da)return Da;try{const e=await window.api.app.engageRulesPath();if(!e)return Da=[],Da;const r=await window.api.config.readJson(e);if(!r.exists||r.parseError||!r.data)return Da=[],Da;const n=r.data;if(!n.presets||!Array.isArray(n.presets))return Da=[],Da;const i=n.projectPath;return Da=n.presets.map(s=>({id:s.id,label:s.label,description:s.description,category:"engage",cwd:i,platform:s.platform,pipeline:s.pipeline,rules:s.rules,command:()=>`cd ${Ro(i)} && ${s.cliEntry}`})),Da}catch(e){return console.warn("[presets] Failed to load engage presets:",e),Da=[],Da}}async function I5(e){const r=M5.find(i=>i.id===e);return r||((await vU()).find(i=>i.id===e)??null)}async function yU(e){return e.cwd==="app-cwd"?window.api.app.cwd():e.cwd==="home"?window.api.app.homeDir():e.cwd==="pick"?window.api.app.pickDirectory():e.cwd}function D5(e,r){return e.command?e.command(r):null}function bU(e){const r=e.split("/").filter(Boolean);return r[r.length-1]||e}const Gt=jn((e,r)=>({tabs:[],activeTabId:null,hydrated:!1,addTab:({id:n,cwd:i,startupCommand:s,presetId:a=null,label:l})=>{const o=n??crypto.randomUUID();if(r().tabs.find(m=>m.id===o))return e({activeTabId:o}),o;const f={id:o,claudeSessionId:o,label:l??bU(i),cwd:i,pid:null,status:"spawning",exitCode:null,startupCommand:s,presetId:a,generation:0};return e({tabs:[...r().tabs,f],activeTabId:o}),o},setTabRunning:(n,i)=>e({tabs:r().tabs.map(s=>s.id===n?{...s,pid:i,status:"running"}:s)}),setTabExited:(n,i)=>e({tabs:r().tabs.map(s=>s.id===n?{...s,status:"exited",exitCode:i}:s)}),closeTab:n=>{var a;window.api.pty.kill(n),window.api.watchers.killTab(n).catch(()=>{}),window.api.transcripts.closeTab(n).catch(()=>{});const i=r().tabs.filter(l=>l.id!==n),s=r().activeTabId===n?((a=i[i.length-1])==null?void 0:a.id)??null:r().activeTabId;e({tabs:i,activeTabId:s})},setActive:n=>e({activeTabId:n}),restartTab:n=>{const i=r().tabs.find(l=>l.id===n);if(!i)return;window.api.pty.kill(n);const s=crypto.randomUUID(),a=l=>{e({tabs:r().tabs.map(o=>o.id===n?{...o,claudeSessionId:s,pid:null,status:"spawning",exitCode:null,startupCommand:l,generation:o.generation+1}:o)})};i.presetId?I5(i.presetId).then(l=>{a(l?D5(l,{sessionId:s,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${Ro(s)}`)}):a(`claude --dangerously-skip-permissions --session-id ${Ro(s)}`)},reorderTab:(n,i)=>{const s=[...r().tabs];if(n<0||n>=s.length||i<0||i>=s.length||n===i)return;const[a]=s.splice(n,1);s.splice(i,0,a),e({tabs:s})},restoreTabs:(n,i)=>e({tabs:n,activeTabId:i,hydrated:!0})}));async function L5(){var n;if(Gt.getState().hydrated)return;try{const{tabs:i,activeTabId:s,freshStart:a}=await window.api.sessions.load();if(i.length>0){const l=await Promise.all(i.map(async u=>{let f=!a;if(f){const h=await window.api.transcripts.pathFor(u.cwd,u.claudeSessionId);f=await window.api.config.exists(h)}const m=f?u.claudeSessionId:crypto.randomUUID();return{id:u.id,claudeSessionId:m,cwd:u.cwd,label:u.label,presetId:u.presetId,pid:null,status:"spawning",exitCode:null,startupCommand:f?`claude --dangerously-skip-permissions --resume ${Ro(m)}`:`claude --dangerously-skip-permissions --session-id ${Ro(m)}`,generation:0}})),o=s&&l.find(u=>u.id===s)?s:((n=l[0])==null?void 0:n.id)??null;Gt.getState().restoreTabs(l,o)}else Gt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),Gt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:s}=Gt.getState(),a=i.map(l=>({id:l.id,claudeSessionId:l.claudeSessionId,cwd:l.cwd,label:l.label,presetId:l.presetId}));window.api.sessions.save({tabs:a,activeTabId:s}).catch(l=>{console.warn("[sessions] save failed:",l)})};let r=null;Gt.subscribe((i,s)=>{i.hydrated&&(i.tabs===s.tabs&&i.activeTabId===s.activeTabId||(r!==null&&window.clearTimeout(r),r=window.setTimeout(e,200)))}),e()}const xU=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:L5,useSessions:Gt},Symbol.toStringTag,{value:"Module"})),wU=5,k$=100,_U=5e3,nE=new Map;function C$(e){const r=nE.get(e);r!==void 0&&(clearTimeout(r),nE.delete(e))}function SU(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const pp=jn((e,r)=>({toasts:[],history:[],unreadCount:0,show:(n,i)=>{const s=SU(),a=Date.now();e(o=>{const u=[...o.toasts,{id:s,kind:n,message:i,createdAt:a}];for(;u.length>wU;){const h=u.shift();h&&C$(h.id)}const m=[{id:s,kind:n,message:i,createdAt:a,read:!1},...o.history];return m.length>k$&&(m.length=k$),{toasts:u,history:m,unreadCount:o.unreadCount+1}});const l=setTimeout(()=>r().dismiss(s),_U);return nE.set(s,l),s},dismiss:n=>{C$(n),e(i=>({toasts:i.toasts.filter(s=>s.id!==n)}))},markAllRead:()=>{e(n=>n.unreadCount===0?n:{history:n.history.map(i=>i.read?i:{...i,read:!0}),unreadCount:0})},clearHistory:()=>{e({history:[],unreadCount:0})},dismissHistoryEntry:n=>{e(i=>{const s=i.history.filter(l=>l.id!==n);if(s.length===i.history.length)return i;const a=i.history.find(l=>l.id===n&&!l.read);return{history:s,unreadCount:a?Math.max(0,i.unreadCount-1):i.unreadCount}})}})),it={info:e=>pp.getState().show("info",e),warn:e=>pp.getState().show("warn",e),error:e=>pp.getState().show("error",e)},B5=Object.freeze(Object.defineProperty({__proto__:null,toast:it,useToast:pp},Symbol.toStringTag,{value:"Module"})),E$=200,kU=/\x1b\[[0-9;]*m/g;function CU(e){return e.replace(kU,"")}const zv=jn((e,r)=>({watchers:{},initialized:!1,init:()=>{r().initialized||(e({initialized:!0}),window.api.watchers.onLine(n=>r().ingestLine(n)),window.api.watchers.onClosed(({watcherId:n})=>r().closed(n)))},add:async({tabId:n,label:i,command:s,cwd:a})=>{try{const l=await window.api.watchers.add({tabId:n,label:i,command:s,cwd:a??null}),o={watcherId:l.watcherId,tabId:l.tabId,label:l.label,command:l.command,cwd:l.cwd,pid:l.pid,startedAt:l.startedAt,lineCount:0,lines:[],lastLineAt:null};return e({watchers:{...r().watchers,[o.watcherId]:o}}),o}catch(l){return console.error("[watchers] add failed:",l),it.error("Failed to add watcher"),null}},remove:async n=>{try{await window.api.watchers.remove(n)}catch(s){console.error("[watchers] remove failed:",s);const a=s instanceof Error?s.message:String(s);it.error(`Could not remove watcher: ${a}`)}const i={...r().watchers};delete i[n],e({watchers:i})},watchersForTab:n=>Object.values(r().watchers).filter(i=>i.tabId===n),ingestLine:n=>{const i=r().watchers[n.watcherId];if(!i)return;const s=CU(n.line),a=i.lines.length>=E$?[...i.lines.slice(i.lines.length-E$+1),{line:s,ts:n.ts}]:[...i.lines,{line:s,ts:n.ts}];e({watchers:{...r().watchers,[n.watcherId]:{...i,lines:a,lineCount:i.lineCount+1,lastLineAt:n.ts}}})},closed:n=>{if(!r().watchers[n])return;const i={...r().watchers};delete i[n],e({watchers:i})}})),EU=4,j$=40,T$=6;function jU(e){const{onReorder:r,onActivate:n}=e,i=B.useRef(null),s=B.useRef(null),a=B.useRef(0),l=B.useRef(0),[o,u]=B.useState(!1),[,f]=B.useState(0),m=B.useRef(n);m.current=n;const h=B.useCallback(()=>i.current?Array.from(i.current.querySelectorAll("[data-drag-index]")):[],[]),b=B.useCallback((y,w,S)=>{for(let C=0;C<w.length;C++){const T=w[C].left+w[C].width/2;if(y<T)return C<=S?C:C-1}return w.length-1},[]),x=B.useCallback(()=>{const y=s.current,w=i.current;if(!(y!=null&&y.active)||!w)return;const S=w.getBoundingClientRect(),C=y.startX+y.deltaX,T=C-S.left,E=S.right-C;T<j$?w.scrollLeft-=T$:E<j$&&(w.scrollLeft+=T$),a.current=requestAnimationFrame(x)},[]);B.useEffect(()=>{const y=i.current;if(!y)return;let w=!1;const S=()=>{w||(w=!0,l.current=requestAnimationFrame(()=>{w=!1,f(E=>E+1)}))},C=E=>{var W;const $=s.current;if(!$)return;const N=E.clientX-$.startX;if(!$.active&&Math.abs(N)<EU)return;if(!$.active){$.active=!0,$.tabRects=h().map(H=>H.getBoundingClientRect()),u(!0);try{(W=i.current)==null||W.setPointerCapture($.pointerId)}catch{}a.current=requestAnimationFrame(x)}$.deltaX=N;const O=$.tabRects[$.fromIndex],I=O.left+O.width/2+N;$.currentIndex=b(I,$.tabRects,$.fromIndex),S()},T=E=>{const $=s.current;if($&&$.pointerId===E.pointerId){cancelAnimationFrame(a.current),cancelAnimationFrame(l.current);try{y.releasePointerCapture($.pointerId)}catch{}$.active&&$.fromIndex!==$.currentIndex?r($.fromIndex,$.currentIndex):m.current($.fromIndex),s.current=null,u(!1),f(N=>N+1)}};return y.addEventListener("pointermove",C),y.addEventListener("pointerup",T),y.addEventListener("pointercancel",T),()=>{y.removeEventListener("pointermove",C),y.removeEventListener("pointerup",T),y.removeEventListener("pointercancel",T),cancelAnimationFrame(a.current),cancelAnimationFrame(l.current)}},[r,h,b,x]);const k=B.useCallback((y,w)=>{y.button!==0||y.target.closest("button")||(s.current={active:!1,fromIndex:w,currentIndex:w,startX:y.clientX,deltaX:0,tabRects:[],pointerId:y.pointerId})},[]);return{getTabDragProps:B.useCallback(y=>{var C;const w=s.current,S={};if(w!=null&&w.active)if(y===w.fromIndex)S.transform=`translateX(${w.deltaX}px) scale(1.03)`,S.zIndex=10,S.opacity=.85,S.boxShadow="0 2px 8px rgba(0,0,0,0.4)",S.position="relative",S.pointerEvents="none";else{const T=w.fromIndex,E=w.currentIndex,N=(((C=w.tabRects[T])==null?void 0:C.width)??0)+4;S.transition="transform 0.15s ease",T<E&&y>T&&y<=E?S.transform=`translateX(-${N}px)`:T>E&&y>=E&&y<T?S.transform=`translateX(${N}px)`:S.transform="translateX(0)"}return{onPointerDown:T=>k(T,y),style:S,"data-drag-index":y}},[k]),isDragging:o,containerRef:i}}const TU=3e4;function AU(){const e=Gt(x=>x.tabs),r=Gt(x=>x.activeTabId),n=Gt(x=>x.closeTab),i=Gt(x=>x.setActive),s=Gt(x=>x.reorderTab),a=zv(x=>x.watchers),[l,o]=B.useState(()=>Date.now());B.useEffect(()=>{const x=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(x)},[]);const u=x=>{for(const k of Object.values(a))if(k.tabId===x&&k.lastLineAt&&l-k.lastLineAt<TU)return!0;return!1},{getTabDragProps:f,isDragging:m,containerRef:h}=jU({tabCount:e.length,onReorder:s,onActivate:x=>{const k=e[x];k&&i(k.id)}}),b=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return c.jsxs("div",{className:"h-11 bg-bg-elev border-b border-line flex items-end px-3 gap-0 shrink-0 relative","data-testid":"tour-tabbar",children:[c.jsx("div",{ref:h,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${m?"cursor-grabbing":""}`,children:e.map((x,k)=>{const _=x.id===r,y=f(k),w=b[k%b.length];return c.jsxs("div",{...y,style:y.style,className:`group flex items-center gap-2 px-3.5 pt-1.5 pb-2 rounded-t-[10px] text-[13px] shrink-0 transition-colors ${m?"":"cursor-grab"} ${_?"bg-bg text-fg font-medium relative z-10 -mb-px border border-b-0 border-line":"text-fg-dim hover:text-fg hover:bg-bg-hi/40"}`,title:x.cwd,"aria-current":_?"true":void 0,children:[c.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:w,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:x.status==="spawning"?.55:1}}),c.jsx("span",{className:"truncate max-w-[200px]",children:x.label}),x.status==="spawning"&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),u(x.id)&&c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"watcher emitted a line in the last 30s","data-testid":"tab-watcher-dot"}),c.jsx("button",{onClick:S=>{S.stopPropagation(),n(x.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${x.label}`,children:"×"})]},x.id)})}),c.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[c.jsx("span",{className:"font-semibold text-fg-dim",children:"Claude Session Manager"}),c.jsxs("span",{className:"font-mono text-[11px] text-fg-faint",children:["v","0.30.0"]})]})]})}function $U(e,r,n){return r?e.map(i=>i.id===r?{...i,lastActivityAt:n}:i):e}function NU(e,r,n){return{tabId:e,sessionUuid:n,cwd:r,path:null,todos:[],lastToolUses:[],plans:[],agents:[],usage:{inputTokens:0,outputTokens:0},lastEventAt:0,activityRing:[],activitySeq:0}}const s0=jn((e,r)=>({tabs:{},refs:{},unsubs:{},subscribe:(n,i,s)=>{const a={...r().refs};if(a[n]=(a[n]??0)+1,e({refs:a}),a[n]>1)return;e({tabs:{...r().tabs,[n]:NU(n,i,s)}});const l=window.api.transcripts.onEvent(n,o=>r().ingest(n,o));e({unsubs:{...r().unsubs,[n]:l}}),window.api.transcripts.subscribe({tabId:n,cwd:i,sessionUuid:s}).then(async o=>{const u=r().tabs[n];if(!u)return;if(!o.ok){const{toast:m}=await em(async()=>{const{toast:h}=await Promise.resolve().then(()=>B5);return{toast:h}},void 0,import.meta.url);m.error(`Live view unavailable: ${o.error??"subscribe failed"}`),e({tabs:{...r().tabs,[n]:{...u,path:null}}});return}e({tabs:{...r().tabs,[n]:{...u,path:o.path}}});const f=await window.api.transcripts.buffer(n);for(const m of f)r().ingest(n,m,{replay:!0})}).catch(o=>console.error("[live] transcripts.subscribe failed:",n,o))},unsubscribe:n=>{const i={...r().refs};if(!i[n])return;if(i[n]--,i[n]>0){e({refs:i});return}delete i[n];const s=r().unsubs[n];s==null||s();const a={...r().unsubs};delete a[n];const l={...r().tabs};delete l[n],window.api.transcripts.unsubscribe(n),e({refs:i,unsubs:a,tabs:l})},ingest:(n,i,s)=>{const a=r().tabs[n];if(!a)return;const l=Date.now(),o={...a,lastEventAt:s!=null&&s.replay?a.lastEventAt:l},u=[],f=(m,h)=>m.length>h?m.slice(0,h-1)+"…":m;switch(i.kind){case"todo_write":{const m=Array.isArray(i.data)?i.data:[];o.todos=m,s!=null&&s.replay||u.push({id:0,kind:"todo-update",at:l,label:`Todos · ${m.length} item${m.length!==1?"s":""}`});break}case"tool_use":{const m=i.data,h=m.input,b={};for(const x of["command","file_path","pattern","url","query","subagent_type","description"])h&&x in h&&(b[x]=h[x]);if(o.lastToolUses=[{id:m.id,name:m.name,input:b,at:l},...a.lastToolUses].slice(0,50),!(s!=null&&s.replay)){const x=m.input,k=["Edit","Write","NotebookEdit"].includes(m.name),_=typeof(x==null?void 0:x.file_path)=="string"?x.file_path:void 0,y=typeof(x==null?void 0:x.command)=="string"?x.command:void 0,w=_?_.split("/").pop()??_:y?f(y,28):"";u.push({id:0,kind:"tool-use",at:l,label:w?`${m.name} · ${w}`:m.name,target:_??y,toolName:m.name}),k&&_&&u.push({id:0,kind:"file-edit",at:l,label:`${m.name} · ${f(_.split("/").pop()??_,34)}`,target:_,toolName:m.name})}break}case"plan":{const m=i.data,h=typeof m=="string"?m:(m==null?void 0:m.plan)??JSON.stringify(m);o.plans=[{at:l,content:h??""},...a.plans].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"plan-revision",at:l,label:"Plan revised"});break}case"agent_spawn":{const m=i.data;o.agents=[{id:m==null?void 0:m.toolUseId,at:l,subagentType:m==null?void 0:m.subagent_type,description:m==null?void 0:m.description,lastActivityAt:l},...a.agents].slice(0,50),s!=null&&s.replay||u.push({id:0,kind:"agent-spawn",at:l,label:m!=null&&m.subagent_type?`Agent: ${f(m.subagent_type,32)}`:"Agent spawned"});break}case"usage":{const m=i.data,h=(a.usage.inputTokens||0)+(a.usage.outputTokens||0),b=m.input_tokens??m.inputTokens??0,x=m.output_tokens??m.outputTokens??0,k=h+b+x;o.usage={inputTokens:(a.usage.inputTokens||0)+b,outputTokens:(a.usage.outputTokens||0)+x,cacheCreationInputTokens:(a.usage.cacheCreationInputTokens||0)+(m.cache_creation_input_tokens??m.cacheCreationInputTokens??0),cacheReadInputTokens:(a.usage.cacheReadInputTokens||0)+(m.cache_read_input_tokens??m.cacheReadInputTokens??0)},!(s!=null&&s.replay)&&Math.floor(k/1e3)>Math.floor(h/1e3)&&u.push({id:0,kind:"usage-tick",at:l,label:`${Math.floor(k/1e3)}k tokens`});break}case"tool_result":{const m=i.data;o.agents=$U(a.agents,m==null?void 0:m.toolUseId,l);break}}if(u.length>0){let m=a.activitySeq;const h=u.map(b=>({...b,id:++m}));o.activitySeq=m,o.activityRing=[...a.activityRing,...h].slice(-32)}e({tabs:{...r().tabs,[n]:o}})}}));function z5(e){const r=s0(s=>s.subscribe),n=s0(s=>s.unsubscribe),i=s0(s=>e?s.tabs[e.id]:void 0);return B.useEffect(()=>{if(e)return r(e.id,e.cwd,e.claudeSessionId),()=>n(e.id)},[e==null?void 0:e.id,e==null?void 0:e.cwd,e==null?void 0:e.claudeSessionId,r,n]),i}var o1={},Wg={},A$;function F5(){if(A$)return Wg;A$=1,Object.defineProperty(Wg,"__esModule",{value:!0}),Wg.baseAssetPath=void 0;const r=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let n="/";return r&&(n=r.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^/]+$/,"/")),Wg.baseAssetPath=n,Wg}var Hg={},$$;function bT(){if($$)return Hg;$$=1,Object.defineProperty(Hg,"__esModule",{value:!0}),Hg.defaultModelFetcher=void 0;const e=r=>fetch(r).then(n=>n.arrayBuffer());return Hg.defaultModelFetcher=e,Hg}var Yl={},Gg={},N$;function qy(){if(N$)return Gg;N$=1,Object.defineProperty(Gg,"__esModule",{value:!0}),Gg.log=void 0;const e=r=>n=>{console.log(`VAD | ${r} >`,n)};return Gg.log={error:e("error"),debug:e("debug"),warn:e("warn")},Gg}var Vg={},O$;function Xw(){if(O$)return Vg;O$=1,Object.defineProperty(Vg,"__esModule",{value:!0}),Vg.Message=void 0;var e;return(function(r){r.AudioFrame="AUDIO_FRAME",r.SpeechStart="SPEECH_START",r.VADMisfire="VAD_MISFIRE",r.SpeechEnd="SPEECH_END",r.SpeechStop="SPEECH_STOP",r.SpeechRealStart="SPEECH_REAL_START",r.FrameProcessed="FRAME_PROCESSED"})(e||(Vg.Message=e={})),Vg}var P$;function xT(){if(P$)return Yl;P$=1,Object.defineProperty(Yl,"__esModule",{value:!0}),Yl.FrameProcessor=Yl.validateOptions=Yl.defaultFrameProcessorOptions=void 0;const e=qy(),r=Xw();Yl.defaultFrameProcessorOptions={positiveSpeechThreshold:.3,negativeSpeechThreshold:.25,preSpeechPadMs:800,redemptionMs:1400,minSpeechMs:400,submitUserSpeechOnPause:!1};function n(l){(l.positiveSpeechThreshold<0||l.positiveSpeechThreshold>1)&&e.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(l.negativeSpeechThreshold<0||l.negativeSpeechThreshold>l.positiveSpeechThreshold)&&e.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),l.preSpeechPadMs<0&&e.log.error("preSpeechPadMs should be positive"),l.redemptionMs<0&&e.log.error("redemptionMs should be positive"),l.minSpeechMs<0&&e.log.error("minSpeechMs should be positive")}Yl.validateOptions=n;const i=l=>{const o=l.reduce((f,m)=>(f.push(f.at(-1)+m.length),f),[0]),u=new Float32Array(o.at(-1));return l.forEach((f,m)=>{const h=o[m];u.set(f,h)}),u};function s(l,o){const u=Math.floor(l.redemptionMs/o),f=Math.floor(l.preSpeechPadMs/o),m=Math.floor(l.minSpeechMs/o);return{redemptionFrames:u,preSpeechPadFrames:f,minSpeechFrames:m}}class a{constructor(o,u,f,m){this.modelProcessFunc=o,this.modelResetFunc=u,this.options=f,this.msPerFrame=m,this.speaking=!1,this.redemptionCounter=0,this.speechFrameCount=0,this.active=!1,this.speechRealStartFired=!1,this.setOptions=k=>{this.options={...this.options,...k};const{redemptionFrames:_,preSpeechPadFrames:y,minSpeechFrames:w}=s(this.options,this.msPerFrame);this.redemptionFrames=_,this.preSpeechPadFrames=y,this.minSpeechFrames=w},this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=k=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(k):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=k=>{const _=this.audioBuffer;this.audioBuffer=[];const y=this.speaking;if(this.reset(),y)if(_.reduce((S,C)=>C.isSpeech?S+1:S,0)>=this.minSpeechFrames){const S=i(_.map(C=>C.frame));k({msg:r.Message.SpeechEnd,audio:S})}else k({msg:r.Message.VADMisfire});return{}},this.process=async(k,_)=>{if(!this.active)return;const y=await this.modelProcessFunc(k),w=y.isSpeech>=this.options.positiveSpeechThreshold;if(_({probs:y,msg:r.Message.FrameProcessed,frame:k}),this.audioBuffer.push({frame:k,isSpeech:w}),w&&(this.speechFrameCount++,this.redemptionCounter=0),w&&!this.speaking&&(this.speaking=!0,_({msg:r.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,_({msg:r.Message.SpeechRealStart})),y.isSpeech<this.options.negativeSpeechThreshold&&this.speaking&&++this.redemptionCounter>=this.redemptionFrames){this.redemptionCounter=0,this.speechFrameCount=0,this.speaking=!1,this.speechRealStartFired=!1;const S=this.audioBuffer;if(this.audioBuffer=[],S.reduce((T,E)=>E.isSpeech?T+1:T,0)>=this.minSpeechFrames){const T=i(S.map(E=>E.frame));_({msg:r.Message.SpeechEnd,audio:T})}else _({msg:r.Message.VADMisfire})}if(!this.speaking){for(;this.audioBuffer.length>this.preSpeechPadFrames;)this.audioBuffer.shift();this.speechFrameCount=0}},this.audioBuffer=[];const{redemptionFrames:h,preSpeechPadFrames:b,minSpeechFrames:x}=s(this.options,this.msPerFrame);this.redemptionFrames=h,this.preSpeechPadFrames=b,this.minSpeechFrames=x,this.reset()}}return Yl.FrameProcessor=a,Yl}var Jl={};function Wa(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var l1={exports:{}};/*!
42
42
  * ONNX Runtime Web v1.26.0
43
43
  * Copyright (c) Microsoft Corporation. All rights reserved.
44
44
  * Licensed under the MIT License.
@@ -2892,7 +2892,7 @@ ${L}`,F=j.createShaderModule({code:z,label:d.name});lr("verbose",()=>`[WebGPU] $
2892
2892
  * ONNX Runtime Web v1.26.0
2893
2893
  * Copyright (c) Microsoft Corporation. All rights reserved.
2894
2894
  * Licensed under the MIT License.
2895
- */var U$;function LU(){return U$||(U$=1,(function(e,r){var n=(()=>{var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,o=(se=>typeof Wa<"u"?Wa:typeof Proxy<"u"?new Proxy(se,{get:(he,be)=>(typeof Wa<"u"?Wa:he)[be]}):se)(function(se){if(typeof Wa<"u")return Wa.apply(this,arguments);throw Error('Dynamic require of "'+se+'" is not supported')}),u=(se,he)=>()=>(se&&(he=se(se=0)),he),f=(se,he)=>{for(var be in he)i(se,be,{get:he[be],enumerable:!0})},m=(se,he,be,Ne)=>{if(he&&typeof he=="object"||typeof he=="function")for(let Ee of a(he))!l.call(se,Ee)&&Ee!==be&&i(se,Ee,{get:()=>he[Ee],enumerable:!(Ne=s(he,Ee))||Ne.enumerable});return se},h=se=>m(i({},"__esModule",{value:!0}),se),b,x,k,_,y,w=u(()=>{b=new Map,x=[],k=(se,he,be)=>{if(he&&typeof he.init=="function"&&typeof he.createInferenceSessionHandler=="function"){let Ne=b.get(se);if(Ne===void 0)b.set(se,{backend:he,priority:be});else{if(Ne.priority>be)return;if(Ne.priority===be&&Ne.backend!==he)throw new Error(`cannot register backend "${se}" using priority ${be}`)}if(be>=0){let Ee=x.indexOf(se);Ee!==-1&&x.splice(Ee,1);for(let ze=0;ze<x.length;ze++)if(b.get(x[ze]).priority<=be){x.splice(ze,0,se);return}x.push(se)}return}throw new TypeError("not a valid backend")},_=async se=>{let he=b.get(se);if(!he)return"backend not found.";if(he.initialized)return he.backend;if(he.aborted)return he.error;{let be=!!he.initPromise;try{return be||(he.initPromise=he.backend.init(se)),await he.initPromise,he.initialized=!0,he.backend}catch(Ne){return be||(he.error=`${Ne}`,he.aborted=!0),he.error}finally{delete he.initPromise}}},y=async se=>{let he=se.executionProviders||[],be=he.map(Ue=>typeof Ue=="string"?Ue:Ue.name),Ne=be.length===0?x:be,Ee,ze=[],Pe=new Set;for(let Ue of Ne){let et=await _(Ue);typeof et=="string"?ze.push({name:Ue,err:et}):(Ee||(Ee=et),Ee===et&&Pe.add(Ue))}if(!Ee)throw new Error(`no available backend found. ERR: ${ze.map(Ue=>`[${Ue.name}] ${Ue.err}`).join(", ")}`);for(let{name:Ue,err:et}of ze)be.includes(Ue)&&console.warn(`removing requested execution provider "${Ue}" from session options because it is not available: ${et}`);let Re=he.filter(Ue=>Pe.has(typeof Ue=="string"?Ue:Ue.name));return[Ee,new Proxy(se,{get:(Ue,et)=>et==="executionProviders"?Re:Reflect.get(Ue,et)})]}}),S=u(()=>{w()}),C,T=u(()=>{C="1.26.0"}),E,$,N=u(()=>{T(),E="warning",$={wasm:{},webgl:{},webgpu:{},versions:{common:C},set logLevel(se){if(se!==void 0){if(typeof se!="string"||["verbose","info","warning","error","fatal"].indexOf(se)===-1)throw new Error(`Unsupported logging level: ${se}`);E=se}},get logLevel(){return E}},Object.defineProperty($,"logLevel",{enumerable:!0})}),O,I=u(()=>{N(),O=$}),W,H,V=u(()=>{W=(se,he)=>{let be=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);be.width=se.dims[3],be.height=se.dims[2];let Ne=be.getContext("2d");if(Ne!=null){let Ee,ze;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(Ee=se.dims[2],ze=se.dims[3]):(Ee=se.dims[3],ze=se.dims[2]);let Pe=(he==null?void 0:he.format)!==void 0?he.format:"RGB",Re=he==null?void 0:he.norm,Ue,et;Re===void 0||Re.mean===void 0?Ue=[255,255,255,255]:typeof Re.mean=="number"?Ue=[Re.mean,Re.mean,Re.mean,Re.mean]:(Ue=[Re.mean[0],Re.mean[1],Re.mean[2],0],Re.mean[3]!==void 0&&(Ue[3]=Re.mean[3])),Re===void 0||Re.bias===void 0?et=[0,0,0,0]:typeof Re.bias=="number"?et=[Re.bias,Re.bias,Re.bias,Re.bias]:(et=[Re.bias[0],Re.bias[1],Re.bias[2],0],Re.bias[3]!==void 0&&(et[3]=Re.bias[3]));let at=ze*Ee,tt=0,Ye=at,$t=at*2,Le=-1;Pe==="RGBA"?(tt=0,Ye=at,$t=at*2,Le=at*3):Pe==="RGB"?(tt=0,Ye=at,$t=at*2):Pe==="RBG"&&(tt=0,$t=at,Ye=at*2);for(let ht=0;ht<ze;ht++)for(let Pr=0;Pr<Ee;Pr++){let Qt=(se.data[tt++]-et[0])*Ue[0],Zt=(se.data[Ye++]-et[1])*Ue[1],Rr=(se.data[$t++]-et[2])*Ue[2],Dt=Le===-1?255:(se.data[Le++]-et[3])*Ue[3];Ne.fillStyle="rgba("+Qt+","+Zt+","+Rr+","+Dt+")",Ne.fillRect(Pr,ht,1,1)}if("toDataURL"in be)return be.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},H=(se,he)=>{let be=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Ne;if(be!=null){let Ee,ze,Pe;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(Ee=se.dims[2],ze=se.dims[1],Pe=se.dims[3]):(Ee=se.dims[3],ze=se.dims[2],Pe=se.dims[1]);let Re=he!==void 0&&he.format!==void 0?he.format:"RGB",Ue=he==null?void 0:he.norm,et,at;Ue===void 0||Ue.mean===void 0?et=[255,255,255,255]:typeof Ue.mean=="number"?et=[Ue.mean,Ue.mean,Ue.mean,Ue.mean]:(et=[Ue.mean[0],Ue.mean[1],Ue.mean[2],255],Ue.mean[3]!==void 0&&(et[3]=Ue.mean[3])),Ue===void 0||Ue.bias===void 0?at=[0,0,0,0]:typeof Ue.bias=="number"?at=[Ue.bias,Ue.bias,Ue.bias,Ue.bias]:(at=[Ue.bias[0],Ue.bias[1],Ue.bias[2],0],Ue.bias[3]!==void 0&&(at[3]=Ue.bias[3]));let tt=ze*Ee;if(he!==void 0&&(he.format!==void 0&&Pe===4&&he.format!=="RGBA"||Pe===3&&he.format!=="RGB"&&he.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Ye=4,$t=0,Le=1,ht=2,Pr=3,Qt=0,Zt=tt,Rr=tt*2,Dt=-1;Re==="RGBA"?(Qt=0,Zt=tt,Rr=tt*2,Dt=tt*3):Re==="RGB"?(Qt=0,Zt=tt,Rr=tt*2):Re==="RBG"&&(Qt=0,Rr=tt,Zt=tt*2),Ne=be.createImageData(Ee,ze);for(let Lr=0;Lr<ze*Ee;$t+=Ye,Le+=Ye,ht+=Ye,Pr+=Ye,Lr++)Ne.data[$t]=(se.data[Qt++]-at[0])*et[0],Ne.data[Le]=(se.data[Zt++]-at[1])*et[1],Ne.data[ht]=(se.data[Rr++]-at[2])*et[2],Ne.data[Pr]=Dt===-1?255:(se.data[Dt++]-at[3])*et[3]}else throw new Error("Can not access image data");return Ne}}),U,D,G,ee,ae,oe,J=u(()=>{xe(),U=(se,he)=>{if(se===void 0)throw new Error("Image buffer must be defined");if(he.height===void 0||he.width===void 0)throw new Error("Image height and width must be defined");if(he.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:be,width:Ne}=he,Ee=he.norm??{mean:255,bias:0},ze,Pe;typeof Ee.mean=="number"?ze=[Ee.mean,Ee.mean,Ee.mean,Ee.mean]:ze=[Ee.mean[0],Ee.mean[1],Ee.mean[2],Ee.mean[3]??255],typeof Ee.bias=="number"?Pe=[Ee.bias,Ee.bias,Ee.bias,Ee.bias]:Pe=[Ee.bias[0],Ee.bias[1],Ee.bias[2],Ee.bias[3]??0];let Re=he.format!==void 0?he.format:"RGBA",Ue=he.tensorFormat!==void 0&&he.tensorFormat!==void 0?he.tensorFormat:"RGB",et=be*Ne,at=Ue==="RGBA"?new Float32Array(et*4):new Float32Array(et*3),tt=4,Ye=0,$t=1,Le=2,ht=3,Pr=0,Qt=et,Zt=et*2,Rr=-1;Re==="RGB"&&(tt=3,Ye=0,$t=1,Le=2,ht=-1),Ue==="RGBA"?Rr=et*3:Ue==="RBG"?(Pr=0,Zt=et,Qt=et*2):Ue==="BGR"&&(Zt=0,Qt=et,Pr=et*2);for(let Dt=0;Dt<et;Dt++,Ye+=tt,Le+=tt,$t+=tt,ht+=tt)at[Pr++]=(se[Ye]+Pe[0])/ze[0],at[Qt++]=(se[$t]+Pe[1])/ze[1],at[Zt++]=(se[Le]+Pe[2])/ze[2],Rr!==-1&&ht!==-1&&(at[Rr++]=(se[ht]+Pe[3])/ze[3]);return Ue==="RGBA"?new ie("float32",at,[1,4,be,Ne]):new ie("float32",at,[1,3,be,Ne])},D=async(se,he)=>{let be=typeof HTMLImageElement<"u"&&se instanceof HTMLImageElement,Ne=typeof ImageData<"u"&&se instanceof ImageData,Ee=typeof ImageBitmap<"u"&&se instanceof ImageBitmap,ze=typeof se=="string",Pe,Re=he??{},Ue=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},et=at=>typeof HTMLCanvasElement<"u"&&at instanceof HTMLCanvasElement||at instanceof OffscreenCanvas?at.getContext("2d"):null;if(be){let at=Ue();at.width=se.width,at.height=se.height;let tt=et(at);if(tt!=null){let Ye=se.height,$t=se.width;if(he!==void 0&&he.resizedHeight!==void 0&&he.resizedWidth!==void 0&&(Ye=he.resizedHeight,$t=he.resizedWidth),he!==void 0){if(Re=he,he.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");Re.tensorFormat="RGBA",Re.height=Ye,Re.width=$t}else Re.tensorFormat="RGBA",Re.height=Ye,Re.width=$t;tt.drawImage(se,0,0),Pe=tt.getImageData(0,0,$t,Ye).data}else throw new Error("Can not access image data")}else if(Ne){let at,tt;if(he!==void 0&&he.resizedWidth!==void 0&&he.resizedHeight!==void 0?(at=he.resizedHeight,tt=he.resizedWidth):(at=se.height,tt=se.width),he!==void 0&&(Re=he),Re.format="RGBA",Re.height=at,Re.width=tt,he!==void 0){let Ye=Ue();Ye.width=tt,Ye.height=at;let $t=et(Ye);if($t!=null)$t.putImageData(se,0,0),Pe=$t.getImageData(0,0,tt,at).data;else throw new Error("Can not access image data")}else Pe=se.data}else if(Ee){if(he===void 0)throw new Error("Please provide image config with format for Imagebitmap");let at=Ue();at.width=se.width,at.height=se.height;let tt=et(at);if(tt!=null){let Ye=se.height,$t=se.width;return tt.drawImage(se,0,0,$t,Ye),Pe=tt.getImageData(0,0,$t,Ye).data,Re.height=Ye,Re.width=$t,U(Pe,Re)}else throw new Error("Can not access image data")}else{if(ze)return new Promise((at,tt)=>{let Ye=Ue(),$t=et(Ye);if(!se||!$t)return tt();let Le=new Image;Le.crossOrigin="Anonymous",Le.src=se,Le.onload=()=>{Ye.width=Le.width,Ye.height=Le.height,$t.drawImage(Le,0,0,Ye.width,Ye.height);let ht=$t.getImageData(0,0,Ye.width,Ye.height);Re.height=Ye.height,Re.width=Ye.width,at(U(ht.data,Re))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Pe!==void 0)return U(Pe,Re);throw new Error("Input data provided is not supported - aborted tensor creation")},G=(se,he)=>{let{width:be,height:Ne,download:Ee,dispose:ze}=he,Pe=[1,Ne,be,4];return new ie({location:"texture",type:"float32",texture:se,dims:Pe,download:Ee,dispose:ze})},ee=(se,he)=>{let{dataType:be,dims:Ne,download:Ee,dispose:ze}=he;return new ie({location:"gpu-buffer",type:be??"float32",gpuBuffer:se,dims:Ne,download:Ee,dispose:ze})},ae=(se,he)=>{let{dataType:be,dims:Ne,download:Ee,dispose:ze}=he;return new ie({location:"ml-tensor",type:be??"float32",mlTensor:se,dims:Ne,download:Ee,dispose:ze})},oe=(se,he,be)=>new ie({location:"cpu-pinned",type:se,data:he,dims:be??[he.length]})}),X,Z,ne,ce,ge=u(()=>{X=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Z=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ne=!1,ce=()=>{if(!ne){ne=!0;let se=typeof BigInt64Array<"u"&&BigInt64Array.from,he=typeof BigUint64Array<"u"&&BigUint64Array.from,be=globalThis.Float16Array,Ne=typeof be<"u"&&be.from;se&&(X.set("int64",BigInt64Array),Z.set(BigInt64Array,"int64")),he&&(X.set("uint64",BigUint64Array),Z.set(BigUint64Array,"uint64")),Ne?(X.set("float16",be),Z.set(be,"float16")):X.set("float16",Uint16Array)}}}),_e,Te,ye=u(()=>{xe(),_e=se=>{let he=1;for(let be=0;be<se.length;be++){let Ne=se[be];if(typeof Ne!="number"||!Number.isSafeInteger(Ne))throw new TypeError(`dims[${be}] must be an integer, got: ${Ne}`);if(Ne<0)throw new RangeError(`dims[${be}] must be a non-negative integer, got: ${Ne}`);he*=Ne}return he},Te=(se,he)=>{switch(se.location){case"cpu":return new ie(se.type,se.data,he);case"cpu-pinned":return new ie({location:"cpu-pinned",data:se.data,type:se.type,dims:he});case"texture":return new ie({location:"texture",texture:se.texture,type:se.type,dims:he});case"gpu-buffer":return new ie({location:"gpu-buffer",gpuBuffer:se.gpuBuffer,type:se.type,dims:he});case"ml-tensor":return new ie({location:"ml-tensor",mlTensor:se.mlTensor,type:se.type,dims:he});default:throw new Error(`tensorReshape: tensor location ${se.location} is not supported`)}}}),ie,xe=u(()=>{V(),J(),ge(),ye(),ie=class{constructor(se,he,be){ce();let Ne,Ee;if(typeof se=="object"&&"location"in se)switch(this.dataLocation=se.location,Ne=se.type,Ee=se.dims,se.location){case"cpu-pinned":{let Pe=X.get(Ne);if(!Pe)throw new TypeError(`unsupported type "${Ne}" to create tensor from pinned buffer`);if(!(se.data instanceof Pe))throw new TypeError(`buffer should be of type ${Pe.name}`);this.cpuData=se.data;break}case"texture":{if(Ne!=="float32")throw new TypeError(`unsupported type "${Ne}" to create tensor from texture`);this.gpuTextureData=se.texture,this.downloader=se.download,this.disposer=se.dispose;break}case"gpu-buffer":{if(Ne!=="float32"&&Ne!=="float16"&&Ne!=="int32"&&Ne!=="int64"&&Ne!=="uint32"&&Ne!=="uint8"&&Ne!=="bool"&&Ne!=="uint4"&&Ne!=="int4")throw new TypeError(`unsupported type "${Ne}" to create tensor from gpu buffer`);this.gpuBufferData=se.gpuBuffer,this.downloader=se.download,this.disposer=se.dispose;break}case"ml-tensor":{if(Ne!=="float32"&&Ne!=="float16"&&Ne!=="int32"&&Ne!=="int64"&&Ne!=="uint32"&&Ne!=="uint64"&&Ne!=="int8"&&Ne!=="uint8"&&Ne!=="bool"&&Ne!=="uint4"&&Ne!=="int4")throw new TypeError(`unsupported type "${Ne}" to create tensor from MLTensor`);this.mlTensorData=se.mlTensor,this.downloader=se.download,this.disposer=se.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Pe,Re;if(typeof se=="string")if(Ne=se,Re=be,se==="string"){if(!Array.isArray(he))throw new TypeError("A string tensor's data must be a string array.");Pe=he}else{let Ue=X.get(se);if(Ue===void 0)throw new TypeError(`Unsupported tensor type: ${se}.`);if(Array.isArray(he)){if(se==="float16"&&Ue===Uint16Array||se==="uint4"||se==="int4")throw new TypeError(`Creating a ${se} tensor from number array is not supported. Please use ${Ue.name} as data.`);se==="uint64"||se==="int64"?Pe=Ue.from(he,BigInt):Pe=Ue.from(he)}else if(he instanceof Ue)Pe=he;else if(he instanceof Uint8ClampedArray)if(se==="uint8")Pe=Uint8Array.from(he);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(se==="float16"&&he instanceof Uint16Array&&Ue!==Uint16Array)Pe=new globalThis.Float16Array(he.buffer,he.byteOffset,he.length);else throw new TypeError(`A ${Ne} tensor's data must be type of ${Ue}`)}else if(Re=he,Array.isArray(se)){if(se.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Ue=typeof se[0];if(Ue==="string")Ne="string",Pe=se;else if(Ue==="boolean")Ne="bool",Pe=Uint8Array.from(se);else throw new TypeError(`Invalid element type of data array: ${Ue}.`)}else if(se instanceof Uint8ClampedArray)Ne="uint8",Pe=Uint8Array.from(se);else{let Ue=Z.get(se.constructor);if(Ue===void 0)throw new TypeError(`Unsupported type for tensor data: ${se.constructor}.`);Ne=Ue,Pe=se}if(Re===void 0)Re=[Pe.length];else if(!Array.isArray(Re))throw new TypeError("A tensor's dims must be a number array");Ee=Re,this.cpuData=Pe,this.dataLocation="cpu"}let ze=_e(Ee);if(this.cpuData&&ze!==this.cpuData.length&&!((Ne==="uint4"||Ne==="int4")&&Math.ceil(ze/2)===this.cpuData.length))throw new Error(`Tensor's size(${ze}) does not match data length(${this.cpuData.length}).`);this.type=Ne,this.dims=Ee,this.size=ze}static async fromImage(se,he){return D(se,he)}static fromTexture(se,he){return G(se,he)}static fromGpuBuffer(se,he){return ee(se,he)}static fromMLTensor(se,he){return ae(se,he)}static fromPinnedBuffer(se,he,be){return oe(se,he,be)}toDataURL(se){return W(this,se)}toImageData(se){return H(this,se)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(se){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let he=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=he,se&&this.disposer&&(this.disposer(),this.disposer=void 0),he}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(se){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Te(this,se)}}}),we,Ve=u(()=>{xe(),we=ie}),Me,We,Be,Ze,dt,ut,or=u(()=>{N(),Me=(se,he)=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeStamp(`${se}::ORT::${he}`)},We=(se,he)=>{var Ee;let be=((Ee=new Error().stack)==null?void 0:Ee.split(/\r\n|\r|\n/g))||[],Ne=!1;for(let ze=0;ze<be.length;ze++){if(Ne&&!be[ze].includes("TRACE_FUNC")){let Pe=`FUNC_${se}::${be[ze].trim().split(" ")[1]}`;he&&(Pe+=`::${he}`),Me("CPU",Pe);return}be[ze].includes("TRACE_FUNC")&&(Ne=!0)}},Be=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||We("BEGIN",se)},Ze=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||We("END",se)},dt=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.time(`ORT::${se}`)},ut=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeEnd(`ORT::${se}`)}}),Xt,ir=u(()=>{w(),Ve(),or(),Xt=class G5{constructor(he){this.handler=he}async run(he,be,Ne){Be(),dt("InferenceSession.run");let Ee={},ze={};if(typeof he!="object"||he===null||he instanceof we||Array.isArray(he))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Pe=!0;if(typeof be=="object"){if(be===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(be instanceof we)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(be)){if(be.length===0)throw new TypeError("'fetches' cannot be an empty array.");Pe=!1;for(let et of be){if(typeof et!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(et)===-1)throw new RangeError(`'fetches' contains invalid output name: ${et}.`);Ee[et]=null}if(typeof Ne=="object"&&Ne!==null)ze=Ne;else if(typeof Ne<"u")throw new TypeError("'options' must be an object.")}else{let et=!1,at=Object.getOwnPropertyNames(be);for(let tt of this.outputNames)if(at.indexOf(tt)!==-1){let Ye=be[tt];(Ye===null||Ye instanceof we)&&(et=!0,Pe=!1,Ee[tt]=Ye)}if(et){if(typeof Ne=="object"&&Ne!==null)ze=Ne;else if(typeof Ne<"u")throw new TypeError("'options' must be an object.")}else ze=be}}else if(typeof be<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let et of this.inputNames)if(typeof he[et]>"u")throw new Error(`input '${et}' is missing in 'feeds'.`);if(Pe)for(let et of this.outputNames)Ee[et]=null;let Re=await this.handler.run(he,Ee,ze),Ue={};for(let et in Re)if(Object.hasOwnProperty.call(Re,et)){let at=Re[et];at instanceof we?Ue[et]=at:Ue[et]=new we(at.type,at.data,at.dims)}return ut("InferenceSession.run"),Ze(),Ue}async release(){return this.handler.dispose()}static async create(he,be,Ne,Ee){Be(),dt("InferenceSession.create");let ze,Pe={};if(typeof he=="string"){if(ze=he,typeof be=="object"&&be!==null)Pe=be;else if(typeof be<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof Uint8Array){if(ze=he,typeof be=="object"&&be!==null)Pe=be;else if(typeof be<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&he instanceof SharedArrayBuffer){let at=he,tt=0,Ye=he.byteLength;if(typeof be=="object"&&be!==null)Pe=be;else if(typeof be=="number"){if(tt=be,!Number.isSafeInteger(tt))throw new RangeError("'byteOffset' must be an integer.");if(tt<0||tt>=at.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${at.byteLength}).`);if(Ye=he.byteLength-tt,typeof Ne=="number"){if(Ye=Ne,!Number.isSafeInteger(Ye))throw new RangeError("'byteLength' must be an integer.");if(Ye<=0||tt+Ye>at.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${at.byteLength-tt}].`);if(typeof Ee=="object"&&Ee!==null)Pe=Ee;else if(typeof Ee<"u")throw new TypeError("'options' must be an object.")}else if(typeof Ne<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof be<"u")throw new TypeError("'options' must be an object.");ze=new Uint8Array(at,tt,Ye)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[Re,Ue]=await y(Pe),et=await Re.createInferenceSessionHandler(ze,Ue);return ut("InferenceSession.create"),Ze(),new G5(et)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),sr,Or=u(()=>{ir(),sr=Xt}),Ar=u(()=>{}),en=u(()=>{}),Ur=u(()=>{}),Ni=u(()=>{}),ui={};f(ui,{InferenceSession:()=>sr,TRACE:()=>Me,TRACE_EVENT_BEGIN:()=>dt,TRACE_EVENT_END:()=>ut,TRACE_FUNC_BEGIN:()=>Be,TRACE_FUNC_END:()=>Ze,Tensor:()=>we,env:()=>O,registerBackend:()=>k});var hr=u(()=>{S(),I(),Or(),Ve(),Ar(),en(),or(),Ur(),Ni()}),Tn=u(()=>{}),lt={};f(lt,{default:()=>br});var wt,bt,br,mn=u(()=>{var se;jl(),hi(),Oi(),wt="ort-wasm-proxy-worker",bt=((se=globalThis.self)==null?void 0:se.name)===wt,bt&&(self.onmessage=he=>{let{type:be,in:Ne}=he.data;try{switch(be){case"init-wasm":as(Ne.wasm).then(()=>{qn(Ne).then(()=>{postMessage({type:be})},Ee=>{postMessage({type:be,err:Ee})})},Ee=>{postMessage({type:be,err:Ee})});break;case"init-ep":{let{epName:Ee,env:ze}=Ne;ls(ze,Ee).then(()=>{postMessage({type:be})},Pe=>{postMessage({type:be,err:Pe})});break}case"copy-from":{let{buffer:Ee}=Ne,ze=lr(Ee);postMessage({type:be,out:ze});break}case"create":{let{model:Ee,options:ze}=Ne;us(Ee,ze).then(Pe=>{postMessage({type:be,out:Pe})},Pe=>{postMessage({type:be,err:Pe})});break}case"release":Fo(Ne),postMessage({type:be});break;case"run":{let{sessionId:Ee,inputIndices:ze,inputs:Pe,outputIndices:Re,options:Ue}=Ne;Je(Ee,ze,Pe,Re,new Array(Re.length).fill(null),Ue).then(et=>{et.some(at=>at[3]!=="cpu")?postMessage({type:be,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:be,out:et},Cc([...Pe,...et]))},et=>{postMessage({type:be,err:et})});break}case"end-profiling":Ps(Ne),postMessage({type:be});break;default:}}catch(Ee){postMessage({type:be,err:Ee})}}),br=bt?null:he=>new Worker(he??Er,{type:"classic",name:wt})}),Ki,ss,Er,Xi,di,zn,Yn,fi,xa,wa,_a,As,Lo,Oi=u(()=>{Tn(),Ki=typeof location>"u"?void 0:location.origin,ss=()=>{var se,he;return typeof document<"u"?(se=document.currentScript)==null?void 0:se.src:typeof self<"u"?(he=self.location)==null?void 0:he.href:void 0},Er=ss(),Xi=()=>{if(Er&&!Er.startsWith("blob:"))return Er.substring(0,Er.lastIndexOf("/")+1)},di=(se,he)=>{try{let be=he??Er;return(be?new URL(se,be):new URL(se)).origin===Ki}catch{return!1}},zn=(se,he)=>{let be=he??Er;try{return(be?new URL(se,be):new URL(se)).href}catch{return}},Yn=(se,he)=>`${he??"./"}${se}`,fi=async se=>{let he=await(await fetch(se,{credentials:"same-origin"})).blob();return URL.createObjectURL(he)},xa=async se=>(await import(se)).default,wa=(mn(),h(lt)).default,_a=async()=>{if(!Er)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(di(Er))return[void 0,wa()];let se=await fi(Er);return[se,wa(se)]},As=void 0,Lo=async(se,he,be,Ne)=>{let Ee=As&&!(se||he);if(Ee)if(Er)Ee=di(Er)||Ne&&!be;else if(Ne&&!be)Ee=!0;else throw new Error("cannot determine the script source URL.");if(Ee)return[void 0,As];{let ze="ort-wasm-simd-threaded.mjs",Pe=se??zn(ze,he),Re=be&&Pe&&!di(Pe,he),Ue=Re?await fi(Pe):Pe??Yn(ze,he);return[Re?Ue:void 0,await xa(Ue)]}}}),Sa,Pi,gr,Fn,Cl,$s,Ns,as,qt,hi=u(()=>{Oi(),Pi=!1,gr=!1,Fn=!1,Cl=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},$s=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Ns=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},as=async se=>{if(Pi)return Promise.resolve();if(gr)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Fn)throw new Error("previous call to 'initializeWebAssembly()' failed.");gr=!0;let he=se.initTimeout,be=se.numThreads;if(se.simd!==!1){if(se.simd==="relaxed"){if(!Ns())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!$s())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Ne=Cl();be>1&&!Ne&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+be+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),se.numThreads=be=1);let Ee=se.wasmPaths,ze=typeof Ee=="string"?Ee:void 0,Pe=Ee==null?void 0:Ee.mjs,Re=(Pe==null?void 0:Pe.href)??Pe,Ue=Ee==null?void 0:Ee.wasm,et=(Ue==null?void 0:Ue.href)??Ue,at=se.wasmBinary,[tt,Ye]=await Lo(Re,ze,be>1,!!at||!!et),$t=!1,Le=[];if(he>0&&Le.push(new Promise(ht=>{setTimeout(()=>{$t=!0,ht()},he)})),Le.push(new Promise((ht,Pr)=>{let Qt={numThreads:be};if(at)Qt.wasmBinary=at,Qt.locateFile=Zt=>Zt;else if(et||ze)Qt.locateFile=Zt=>et??ze+Zt;else if(Re&&Re.indexOf("blob:")!==0)Qt.locateFile=Zt=>new URL(Zt,Re).href;else if(tt){let Zt=Xi();Zt&&(Qt.locateFile=Rr=>Zt+Rr)}Ye(Qt).then(Zt=>{gr=!1,Pi=!0,Sa=Zt,ht(),tt&&URL.revokeObjectURL(tt)},Zt=>{gr=!1,Fn=!0,Pr(Zt)})})),await Promise.race(Le),$t)throw new Error(`WebAssembly backend initializing failed due to timeout: ${he}ms`)},qt=()=>{if(Pi&&Sa)return Sa;throw new Error("WebAssembly is not initialized yet.")}}),vr,Jn,At,Js=u(()=>{hi(),vr=(se,he)=>{let be=qt(),Ne=be.lengthBytesUTF8(se)+1,Ee=be._malloc(Ne);return be.stringToUTF8(se,Ee,Ne),he.push(Ee),Ee},Jn=(se,he,be,Ne)=>{if(typeof se=="object"&&se!==null){if(be.has(se))throw new Error("Circular reference in options");be.add(se)}Object.entries(se).forEach(([Ee,ze])=>{let Pe=he?he+Ee:Ee;if(typeof ze=="object")Jn(ze,Pe+".",be,Ne);else if(typeof ze=="string"||typeof ze=="number")Ne(Pe,ze.toString());else if(typeof ze=="boolean")Ne(Pe,ze?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof ze}`)})},At=se=>{let he=qt(),be=he.stackSave();try{let Ne=he.PTR_SIZE,Ee=he.stackAlloc(2*Ne);he._OrtGetLastError(Ee,Ee+Ne);let ze=Number(he.getValue(Ee,Ne===4?"i32":"i64")),Pe=he.getValue(Ee+Ne,"*"),Re=Pe?he.UTF8ToString(Pe):"";throw new Error(`${se} ERROR_CODE: ${ze}, ERROR_MESSAGE: ${Re}`)}finally{he.stackRestore(be)}}}),ka,Bo=u(()=>{hi(),Js(),ka=se=>{let he=qt(),be=0,Ne=[],Ee=se||{};try{if((se==null?void 0:se.logSeverityLevel)===void 0)Ee.logSeverityLevel=2;else if(typeof se.logSeverityLevel!="number"||!Number.isInteger(se.logSeverityLevel)||se.logSeverityLevel<0||se.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${se.logSeverityLevel}`);if((se==null?void 0:se.logVerbosityLevel)===void 0)Ee.logVerbosityLevel=0;else if(typeof se.logVerbosityLevel!="number"||!Number.isInteger(se.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${se.logVerbosityLevel}`);(se==null?void 0:se.terminate)===void 0&&(Ee.terminate=!1);let ze=0;return(se==null?void 0:se.tag)!==void 0&&(ze=vr(se.tag,Ne)),be=he._OrtCreateRunOptions(Ee.logSeverityLevel,Ee.logVerbosityLevel,!!Ee.terminate,ze),be===0&&At("Can't create run options."),(se==null?void 0:se.extra)!==void 0&&Jn(se.extra,"",new WeakSet,(Pe,Re)=>{let Ue=vr(Pe,Ne),et=vr(Re,Ne);he._OrtAddRunConfigEntry(be,Ue,et)!==0&&At(`Can't set a run config entry: ${Pe} - ${Re}.`)}),[be,Ne]}catch(ze){throw be!==0&&he._OrtReleaseRunOptions(be),Ne.forEach(Pe=>he._free(Pe)),ze}}}),os,Qs,pi,An,zo,El,qr=u(()=>{hi(),Js(),os=se=>{switch(se){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${se}`)}},Qs=se=>{switch(se){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${se}`)}},pi=se=>{se.extra||(se.extra={}),se.extra.session||(se.extra.session={});let he=se.extra.session;he.use_ort_model_bytes_directly||(he.use_ort_model_bytes_directly="1"),se.executionProviders&&se.executionProviders.some(be=>(typeof be=="string"?be:be.name)==="webgpu")&&(se.enableMemPattern=!1)},An=(se,he,be,Ne)=>{let Ee=vr(he,Ne),ze=vr(be,Ne);qt()._OrtAddSessionConfigEntry(se,Ee,ze)!==0&&At(`Can't set a session config entry: ${he} - ${be}.`)},zo=async(se,he,be)=>{let Ne=he.executionProviders;for(let Ee of Ne){let ze=typeof Ee=="string"?Ee:Ee.name,Pe=[];switch(ze){case"webnn":if(ze="WEBNN",An(se,"session.disable_quant_qdq","1",be),An(se,"session.disable_qdq_constant_folding","1",be),typeof Ee!="string"){let tt=Ee==null?void 0:Ee.deviceType;tt&&An(se,"deviceType",tt,be)}break;case"webgpu":if(ze="JS",typeof Ee!="string"){let tt=Ee;if(tt!=null&&tt.preferredLayout){if(tt.preferredLayout!=="NCHW"&&tt.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${tt.preferredLayout}`);An(se,"preferredLayout",tt.preferredLayout,be)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${ze}`)}let Re=vr(ze,be),Ue=Pe.length,et=0,at=0;if(Ue>0){et=qt()._malloc(Ue*qt().PTR_SIZE),be.push(et),at=qt()._malloc(Ue*qt().PTR_SIZE),be.push(at);for(let tt=0;tt<Ue;tt++)qt().setValue(et+tt*qt().PTR_SIZE,Pe[tt][0],"*"),qt().setValue(at+tt*qt().PTR_SIZE,Pe[tt][1],"*")}await qt()._OrtAppendExecutionProvider(se,Re,et,at,Ue)!==0&&At(`Can't append execution provider: ${ze}.`)}},El=async se=>{let he=qt(),be=0,Ne=[],Ee=se||{};pi(Ee);try{let ze=os(Ee.graphOptimizationLevel??"all"),Pe=Qs(Ee.executionMode??"sequential"),Re=typeof Ee.logId=="string"?vr(Ee.logId,Ne):0,Ue=Ee.logSeverityLevel??2;if(!Number.isInteger(Ue)||Ue<0||Ue>4)throw new Error(`log severity level is not valid: ${Ue}`);let et=Ee.logVerbosityLevel??0;if(!Number.isInteger(et)||et<0||et>4)throw new Error(`log verbosity level is not valid: ${et}`);let at=typeof Ee.optimizedModelFilePath=="string"?vr(Ee.optimizedModelFilePath,Ne):0;if(be=he._OrtCreateSessionOptions(ze,!!Ee.enableCpuMemArena,!!Ee.enableMemPattern,Pe,!!Ee.enableProfiling,0,Re,Ue,et,at),be===0&&At("Can't create session options."),Ee.executionProviders&&await zo(be,Ee,Ne),Ee.enableGraphCapture!==void 0){if(typeof Ee.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${Ee.enableGraphCapture}`);An(be,"enableGraphCapture",Ee.enableGraphCapture.toString(),Ne)}if(Ee.freeDimensionOverrides)for(let[tt,Ye]of Object.entries(Ee.freeDimensionOverrides)){if(typeof tt!="string")throw new Error(`free dimension override name must be a string: ${tt}`);if(typeof Ye!="number"||!Number.isInteger(Ye)||Ye<0)throw new Error(`free dimension override value must be a non-negative integer: ${Ye}`);let $t=vr(tt,Ne);he._OrtAddFreeDimensionOverride(be,$t,Ye)!==0&&At(`Can't set a free dimension override: ${tt} - ${Ye}.`)}return Ee.extra!==void 0&&Jn(Ee.extra,"",new WeakSet,(tt,Ye)=>{An(be,tt,Ye,Ne)}),[be,Ne]}catch(ze){throw be!==0&&he._OrtReleaseSessionOptions(be)!==0&&At("Can't release session options."),Ne.forEach(Pe=>he._free(Pe)),ze}}}),Qn,gn,dn,Et,Se,rt,_t,nr,pt=u(()=>{Qn=se=>{switch(se){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${se}`)}},gn=se=>{switch(se){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${se}`)}},dn=(se,he)=>{let be=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][se],Ne=typeof he=="number"?he:he.reduce((Ee,ze)=>Ee*ze,1);return be>0?Math.ceil(Ne*be):void 0},Et=se=>{switch(se){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${se}`)}},Se=se=>{switch(se){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${se}`)}},rt=se=>se==="float32"||se==="float16"||se==="int32"||se==="int64"||se==="uint32"||se==="uint8"||se==="bool"||se==="uint4"||se==="int4",_t=se=>se==="float32"||se==="float16"||se==="int32"||se==="int64"||se==="uint32"||se==="uint64"||se==="int8"||se==="uint8"||se==="bool"||se==="uint4"||se==="int4",nr=se=>{switch(se){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${se}`)}}}),ar,Yr=u(()=>{Tn(),ar=async se=>{if(typeof se=="string"){let he=await fetch(se);if(!he.ok)throw new Error(`failed to load external data file: ${se}`);let be=he.headers.get("Content-Length"),Ne=be?parseInt(be,10):0;if(Ne<1073741824)return new Uint8Array(await he.arrayBuffer());{if(!he.body)throw new Error(`failed to load external data file: ${se}, no response body.`);let Ee=he.body.getReader(),ze;try{ze=new ArrayBuffer(Ne)}catch(Re){if(Re instanceof RangeError){let Ue=Math.ceil(Ne/65536);ze=new WebAssembly.Memory({initial:Ue,maximum:Ue}).buffer}else throw Re}let Pe=0;for(;;){let{done:Re,value:Ue}=await Ee.read();if(Re)break;let et=Ue.byteLength;new Uint8Array(ze,Pe,et).set(Ue),Pe+=et}return new Uint8Array(ze,0,Ne)}}else return se instanceof Blob?new Uint8Array(await se.arrayBuffer()):se instanceof Uint8Array?se:new Uint8Array(se)}}),Un,qn,ls,jr,cs,Os,lr,us,Fo,Zs,Je,Ps,Cc,jl=u(()=>{hr(),Bo(),qr(),pt(),hi(),Js(),Yr(),Un=(se,he)=>{qt()._OrtInit(se,he)!==0&&At("Can't initialize onnxruntime.")},qn=async se=>{Un(se.wasm.numThreads,Se(se.logLevel))},ls=async(se,he)=>{var Ne,Ee;(Ee=(Ne=qt()).asyncInit)==null||Ee.call(Ne);let be=se.webgpu.adapter;if(he==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(be){if(typeof be.limits!="object"||typeof be.features!="object"||typeof be.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let ze=se.webgpu.powerPreference;if(ze!==void 0&&ze!=="low-power"&&ze!=="high-performance")throw new Error(`Invalid powerPreference setting: "${ze}"`);let Pe=se.webgpu.forceFallbackAdapter;if(Pe!==void 0&&typeof Pe!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Pe}"`);if(be=await navigator.gpu.requestAdapter({powerPreference:ze,forceFallbackAdapter:Pe}),!be)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(he==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},jr=new Map,cs=se=>{let he=qt(),be=he.stackSave();try{let Ne=he.PTR_SIZE,Ee=he.stackAlloc(2*Ne);he._OrtGetInputOutputCount(se,Ee,Ee+Ne)!==0&&At("Can't get session input/output count.");let ze=Ne===4?"i32":"i64";return[Number(he.getValue(Ee,ze)),Number(he.getValue(Ee+Ne,ze))]}finally{he.stackRestore(be)}},Os=(se,he)=>{let be=qt(),Ne=be.stackSave(),Ee=0;try{let ze=be.PTR_SIZE,Pe=be.stackAlloc(2*ze);be._OrtGetInputOutputMetadata(se,he,Pe,Pe+ze)!==0&&At("Can't get session input/output metadata.");let Re=Number(be.getValue(Pe,"*"));Ee=Number(be.getValue(Pe+ze,"*"));let Ue=be.HEAP32[Ee/4];if(Ue===0)return[Re,0];let et=be.HEAPU32[Ee/4+1],at=[];for(let tt=0;tt<et;tt++){let Ye=Number(be.getValue(Ee+8+tt*ze,"*"));at.push(Ye!==0?be.UTF8ToString(Ye):Number(be.getValue(Ee+8+(tt+et)*ze,"*")))}return[Re,Ue,at]}finally{be.stackRestore(Ne),Ee!==0&&be._OrtFree(Ee)}},lr=se=>{let he=qt(),be=he._malloc(se.byteLength);if(be===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${se.byteLength}.`);return he.HEAPU8.set(se,be),[be,se.byteLength]},us=async(se,he)=>{var at,tt,Ye;let be,Ne,Ee=qt();Array.isArray(se)?[be,Ne]=se:se.buffer===Ee.HEAPU8.buffer?[be,Ne]=[se.byteOffset,se.byteLength]:[be,Ne]=lr(se);let ze=0,Pe=0,Re=[],Ue=[],et=[];try{if([Pe,Re]=await El(he),(he==null?void 0:he.externalData)&&Ee.mountExternalData){let Lr=[];for(let fr of he.externalData){let $n=typeof fr=="string"?fr:fr.path;Lr.push(ar(typeof fr=="string"?fr:fr.data).then(ei=>{Ee.mountExternalData($n,ei)}))}await Promise.all(Lr)}for(let Lr of(he==null?void 0:he.executionProviders)??[])if((typeof Lr=="string"?Lr:Lr.name)==="webnn"){if(Ee.shouldTransferToMLTensor=!1,typeof Lr!="string"){let fr=Lr,$n=fr==null?void 0:fr.context,ei=fr==null?void 0:fr.gpuDevice,mi=fr==null?void 0:fr.deviceType,Al=fr==null?void 0:fr.powerPreference;$n?Ee.currentContext=$n:ei?Ee.currentContext=await Ee.webnnCreateMLContext(ei):Ee.currentContext=await Ee.webnnCreateMLContext({deviceType:mi,powerPreference:Al})}else Ee.currentContext=await Ee.webnnCreateMLContext();break}ze=await Ee._OrtCreateSession(be,Ne,Pe),(at=Ee.webgpuOnCreateSession)==null||at.call(Ee,ze),ze===0&&At("Can't create a session."),(tt=Ee.jsepOnCreateSession)==null||tt.call(Ee),Ee.currentContext&&(Ee.webnnRegisterMLContext(ze,Ee.currentContext),Ee.currentContext=void 0,Ee.shouldTransferToMLTensor=!0);let[$t,Le]=cs(ze),ht=!!(he!=null&&he.enableGraphCapture),Pr=[],Qt=[],Zt=[],Rr=[],Dt=[];for(let Lr=0;Lr<$t;Lr++){let[fr,$n,ei]=Os(ze,Lr);fr===0&&At("Can't get an input name."),Ue.push(fr);let mi=Ee.UTF8ToString(fr);Pr.push(mi),Zt.push($n===0?{name:mi,isTensor:!1}:{name:mi,isTensor:!0,type:gn($n),shape:ei})}for(let Lr=0;Lr<Le;Lr++){let[fr,$n,ei]=Os(ze,Lr+$t);fr===0&&At("Can't get an output name."),et.push(fr);let mi=Ee.UTF8ToString(fr);Qt.push(mi),Rr.push($n===0?{name:mi,isTensor:!1}:{name:mi,isTensor:!0,type:gn($n),shape:ei})}return jr.set(ze,[ze,Ue,et,null,ht,!1]),[ze,Pr,Qt,Zt,Rr]}catch($t){throw Ue.forEach(Le=>Ee._OrtFree(Le)),et.forEach(Le=>Ee._OrtFree(Le)),ze!==0&&Ee._OrtReleaseSession(ze)!==0&&At("Can't release session."),$t}finally{Ee._free(be),Pe!==0&&Ee._OrtReleaseSessionOptions(Pe)!==0&&At("Can't release session options."),Re.forEach($t=>Ee._free($t)),(Ye=Ee.unmountExternalData)==null||Ye.call(Ee)}},Fo=se=>{var Ue,et,at;let he=qt(),be=jr.get(se);if(!be)throw new Error(`cannot release session. invalid session id: ${se}`);let[Ne,Ee,ze,Pe,Re]=be;Pe&&(Re&&he._OrtClearBoundOutputs(Pe.handle)!==0&&At("Can't clear bound outputs."),he._OrtReleaseBinding(Pe.handle)!==0&&At("Can't release IO binding.")),(Ue=he.jsepOnReleaseSession)==null||Ue.call(he,se),(et=he.webnnOnReleaseSession)==null||et.call(he,se),(at=he.webgpuOnReleaseSession)==null||at.call(he,se),Ee.forEach(tt=>he._OrtFree(tt)),ze.forEach(tt=>he._OrtFree(tt)),he._OrtReleaseSession(Ne)!==0&&At("Can't release session."),jr.delete(se)},Zs=async(se,he,be,Ne,Ee,ze,Pe=!1)=>{if(!se){he.push(0);return}let Re=qt(),Ue=Re.PTR_SIZE,et=se[0],at=se[1],tt=se[3],Ye=tt,$t,Le;if(et==="string"&&(tt==="gpu-buffer"||tt==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Pe&&tt!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${ze} when enableGraphCapture is true.`);if(tt==="gpu-buffer"){let Qt=se[2].gpuBuffer;Le=dn(Qn(et),at);{let Zt=Re.jsepRegisterBuffer;if(!Zt)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');$t=Zt(Ne,ze,Qt,Le)}}else if(tt==="ml-tensor"){let Qt=se[2].mlTensor;Le=dn(Qn(et),at);let Zt=Re.webnnRegisterMLTensor;if(!Zt)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');$t=Zt(Ne,Qt,Qn(et),at)}else{let Qt=se[2];if(Array.isArray(Qt)){Le=Ue*Qt.length,$t=Re._malloc(Le),be.push($t);for(let Zt=0;Zt<Qt.length;Zt++){if(typeof Qt[Zt]!="string")throw new TypeError(`tensor data at index ${Zt} is not a string`);Re.setValue($t+Zt*Ue,vr(Qt[Zt],be),"*")}}else{let Zt=Re.webnnIsGraphInput,Rr=Re.webnnIsGraphOutput;if(et!=="string"&&Zt&&Rr){let Dt=Re.UTF8ToString(Ee);if(Zt(Ne,Dt)||Rr(Ne,Dt)){let Lr=Qn(et);Le=dn(Lr,at),Ye="ml-tensor";let fr=Re.webnnCreateTemporaryTensor,$n=Re.webnnUploadTensor;if(!fr||!$n)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let ei=await fr(Ne,Lr,at);$n(ei,new Uint8Array(Qt.buffer,Qt.byteOffset,Qt.byteLength)),$t=ei}else Le=Qt.byteLength,$t=Re._malloc(Le),be.push($t),Re.HEAPU8.set(new Uint8Array(Qt.buffer,Qt.byteOffset,Le),$t)}else Le=Qt.byteLength,$t=Re._malloc(Le),be.push($t),Re.HEAPU8.set(new Uint8Array(Qt.buffer,Qt.byteOffset,Le),$t)}}let ht=Re.stackSave(),Pr=Re.stackAlloc(4*at.length);try{at.forEach((Zt,Rr)=>Re.setValue(Pr+Rr*Ue,Zt,Ue===4?"i32":"i64"));let Qt=Re._OrtCreateTensor(Qn(et),$t,Le,Pr,at.length,nr(Ye));Qt===0&&At(`Can't create tensor for input/output. session=${Ne}, index=${ze}.`),he.push(Qt)}finally{Re.stackRestore(ht)}},Je=async(se,he,be,Ne,Ee,ze)=>{var gi,$c,Lu;let Pe=qt(),Re=Pe.PTR_SIZE,Ue=jr.get(se);if(!Ue)throw new Error(`cannot run inference. invalid session id: ${se}`);let et=Ue[0],at=Ue[1],tt=Ue[2],Ye=Ue[3],$t=Ue[4];Ue[5];let Le=he.length,ht=Ne.length,Pr=0,Qt=[],Zt=[],Rr=[],Dt=[],Lr=[],fr=Pe.stackSave(),$n=Pe.stackAlloc(Le*Re),ei=Pe.stackAlloc(Le*Re),mi=Pe.stackAlloc(ht*Re),Al=Pe.stackAlloc(ht*Re);try{[Pr,Qt]=ka(ze),dt("wasm prepareInputOutputTensor");for(let cr=0;cr<Le;cr++)await Zs(be[cr],Zt,Dt,se,at[he[cr]],he[cr],$t);for(let cr=0;cr<ht;cr++)await Zs(Ee[cr],Rr,Dt,se,tt[Ne[cr]],Le+Ne[cr],$t);ut("wasm prepareInputOutputTensor");for(let cr=0;cr<Le;cr++)Pe.setValue($n+cr*Re,Zt[cr],"*"),Pe.setValue(ei+cr*Re,at[he[cr]],"*");for(let cr=0;cr<ht;cr++)Pe.setValue(mi+cr*Re,Rr[cr],"*"),Pe.setValue(Al+cr*Re,tt[Ne[cr]],"*");(gi=Pe.jsepOnRunStart)==null||gi.call(Pe,et),($c=Pe.webnnOnRunStart)==null||$c.call(Pe,et);let Nn;Nn=await Pe._OrtRun(et,ei,$n,Le,Al,ht,mi,Pr),Nn!==0&&At("failed to call OrtRun().");let Ms=[],Bu=[];dt("wasm ProcessOutputTensor");for(let cr=0;cr<ht;cr++){let hs=Number(Pe.getValue(mi+cr*Re,"*"));if(hs===Rr[cr]||Lr.includes(Rr[cr])){Ms.push(Ee[cr]),hs!==Rr[cr]&&Pe._OrtReleaseTensor(hs)!==0&&At("Can't release tensor.");continue}let vf=Pe.stackSave(),na=Pe.stackAlloc(4*Re),qo=!1,vn,vi=0;try{Pe._OrtGetTensorData(hs,na,na+Re,na+2*Re,na+3*Re)!==0&&At(`Can't access output tensor data on index ${cr}.`);let Nc=Re===4?"i32":"i64",yi=Number(Pe.getValue(na,Nc));vi=Pe.getValue(na+Re,"*");let zu=Pe.getValue(na+Re*2,"*"),yf=Number(Pe.getValue(na+Re*3,Nc)),ia=[];for(let yn=0;yn<yf;yn++)ia.push(Number(Pe.getValue(zu+yn*Re,Nc)));Pe._OrtFree(zu)!==0&&At("Can't free memory for tensor dims.");let ps=ia.reduce((yn,Jr)=>yn*Jr,1);vn=gn(yi);let Is=Ye==null?void 0:Ye.outputPreferredLocations[Ne[cr]];if(vn==="string"){if(Is==="gpu-buffer"||Is==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let yn=[];for(let Jr=0;Jr<ps;Jr++){let ms=Pe.getValue(vi+Jr*Re,"*"),Fu=Pe.getValue(vi+(Jr+1)*Re,"*"),Uu=Jr===ps-1?void 0:Fu-ms;yn.push(Pe.UTF8ToString(ms,Uu))}Ms.push([vn,ia,yn,"cpu"])}else if(Is==="gpu-buffer"&&ps>0){let yn=Pe.jsepGetBuffer;if(!yn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let Jr=yn(vi),ms=dn(yi,ps);if(ms===void 0||!rt(vn))throw new Error(`Unsupported data type: ${vn}`);qo=!0,Ms.push([vn,ia,{gpuBuffer:Jr,download:Pe.jsepCreateDownloader(Jr,ms,vn),dispose:()=>{Pe._OrtReleaseTensor(hs)!==0&&At("Can't release tensor.")}},"gpu-buffer"])}else if(Is==="ml-tensor"&&ps>0){let yn=Pe.webnnEnsureTensor,Jr=Pe.webnnIsGraphInputOutputTypeSupported;if(!yn||!Jr)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(dn(yi,ps)===void 0||!_t(vn))throw new Error(`Unsupported data type: ${vn}`);if(!Jr(se,vn,!1))throw new Error(`preferredLocation "ml-tensor" for ${vn} output is not supported by current WebNN Context.`);let ms=await yn(se,vi,yi,ia,!1);qo=!0,Ms.push([vn,ia,{mlTensor:ms,download:Pe.webnnCreateMLTensorDownloader(vi,vn),dispose:()=>{Pe.webnnReleaseTensorId(vi),Pe._OrtReleaseTensor(hs)}},"ml-tensor"])}else if(Is==="ml-tensor-cpu-output"&&ps>0){let yn=Pe.webnnCreateMLTensorDownloader(vi,vn)(),Jr=Ms.length;qo=!0,Bu.push((async()=>{let ms=[Jr,await yn];return Pe.webnnReleaseTensorId(vi),Pe._OrtReleaseTensor(hs),ms})()),Ms.push([vn,ia,[],"cpu"])}else{let yn=Et(vn),Jr=new yn(ps);new Uint8Array(Jr.buffer,Jr.byteOffset,Jr.byteLength).set(Pe.HEAPU8.subarray(vi,vi+Jr.byteLength)),Ms.push([vn,ia,Jr,"cpu"])}}finally{Pe.stackRestore(vf),vn==="string"&&vi&&Pe._free(vi),qo||Pe._OrtReleaseTensor(hs)}}Ye&&!$t&&(Pe._OrtClearBoundOutputs(Ye.handle)!==0&&At("Can't clear bound outputs."),jr.set(se,[et,at,tt,Ye,$t,!1]));for(let[cr,hs]of await Promise.all(Bu))Ms[cr][2]=hs;return ut("wasm ProcessOutputTensor"),Ms}finally{(Lu=Pe.webnnOnRunEnd)==null||Lu.call(Pe,et),Pe.stackRestore(fr),Zt.forEach(Nn=>Pe._OrtReleaseTensor(Nn)),Rr.forEach(Nn=>Pe._OrtReleaseTensor(Nn)),Dt.forEach(Nn=>Pe._free(Nn)),Pr!==0&&Pe._OrtReleaseRunOptions(Pr),Qt.forEach(Nn=>Pe._free(Nn))}},Ps=se=>{let he=qt(),be=jr.get(se);if(!be)throw new Error("invalid session id");let Ne=be[0],Ee=he._OrtEndProfiling(Ne);Ee===0&&At("Can't get an profile file name."),he._OrtFree(Ee)},Cc=se=>{let he=[];for(let be of se){let Ne=be[2];!Array.isArray(Ne)&&"buffer"in Ne&&he.push(Ne.buffer)}return he}}),ur,It,ea,Ca,Ea,Za,Uo,eo,Yi,Zn,ds,fs,ja,to,Rs,gf,ro,no,Mu=u(()=>{hr(),jl(),hi(),Oi(),ur=()=>!!O.wasm.proxy&&typeof document<"u",ea=!1,Ca=!1,Ea=!1,eo=new Map,Yi=(se,he)=>{let be=eo.get(se);be?be.push(he):eo.set(se,[he])},Zn=()=>{if(ea||!Ca||Ea||!It)throw new Error("worker not ready")},ds=se=>{switch(se.data.type){case"init-wasm":ea=!1,se.data.err?(Ea=!0,Uo[1](se.data.err)):(Ca=!0,Uo[0]()),Za&&(URL.revokeObjectURL(Za),Za=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let he=eo.get(se.data.type);se.data.err?he.shift()[1](se.data.err):he.shift()[0](se.data.out);break}}},fs=async()=>{if(!Ca){if(ea)throw new Error("multiple calls to 'initWasm()' detected.");if(Ea)throw new Error("previous call to 'initWasm()' failed.");if(ea=!0,ur())return new Promise((se,he)=>{It==null||It.terminate(),_a().then(([be,Ne])=>{try{It=Ne,It.onerror=ze=>he(ze),It.onmessage=ds,Uo=[se,he];let Ee={type:"init-wasm",in:O};if(!Ee.in.wasm.wasmPaths&&be){let ze=Xi();ze&&(Ee.in.wasm.wasmPaths=ze)}It.postMessage(Ee),Za=be}catch(Ee){he(Ee)}},he)});try{await as(O.wasm),await qn(O),Ca=!0}catch(se){throw Ea=!0,se}finally{ea=!1}}},ja=async se=>{if(ur())return Zn(),new Promise((he,be)=>{Yi("init-ep",[he,be]);let Ne={type:"init-ep",in:{epName:se,env:O}};It.postMessage(Ne)});await ls(O,se)},to=async se=>ur()?(Zn(),new Promise((he,be)=>{Yi("copy-from",[he,be]);let Ne={type:"copy-from",in:{buffer:se}};It.postMessage(Ne,[se.buffer])})):lr(se),Rs=async(se,he)=>{if(ur()){if(he!=null&&he.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Zn(),new Promise((be,Ne)=>{Yi("create",[be,Ne]);let Ee={type:"create",in:{model:se,options:{...he}}},ze=[];se instanceof Uint8Array&&ze.push(se.buffer),It.postMessage(Ee,ze)})}else return us(se,he)},gf=async se=>{if(ur())return Zn(),new Promise((he,be)=>{Yi("release",[he,be]);let Ne={type:"release",in:se};It.postMessage(Ne)});Fo(se)},ro=async(se,he,be,Ne,Ee,ze)=>{if(ur()){if(be.some(Pe=>Pe[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(Ee.some(Pe=>Pe))throw new Error("pre-allocated output tensor is not supported for proxy.");return Zn(),new Promise((Pe,Re)=>{Yi("run",[Pe,Re]);let Ue=be,et={type:"run",in:{sessionId:se,inputIndices:he,inputs:Ue,outputIndices:Ne,options:ze}};It.postMessage(et,Cc(Ue))})}else return Je(se,he,be,Ne,Ee,ze)},no=async se=>{if(ur())return Zn(),new Promise((he,be)=>{Yi("end-profiling",[he,be]);let Ne={type:"end-profiling",in:se};It.postMessage(Ne)});Ps(se)}}),Ec,io,Tl,jc=u(()=>{hr(),Mu(),pt(),Tn(),Yr(),Ec=(se,he)=>{switch(se.location){case"cpu":return[se.type,se.dims,se.data,"cpu"];case"gpu-buffer":return[se.type,se.dims,{gpuBuffer:se.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[se.type,se.dims,{mlTensor:se.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${se.location} for ${he()}`)}},io=se=>{switch(se[3]){case"cpu":return new we(se[0],se[2],se[1]);case"gpu-buffer":{let he=se[0];if(!rt(he))throw new Error(`not supported data type: ${he} for deserializing GPU tensor`);let{gpuBuffer:be,download:Ne,dispose:Ee}=se[2];return we.fromGpuBuffer(be,{dataType:he,dims:se[1],download:Ne,dispose:Ee})}case"ml-tensor":{let he=se[0];if(!_t(he))throw new Error(`not supported data type: ${he} for deserializing MLTensor tensor`);let{mlTensor:be,download:Ne,dispose:Ee}=se[2];return we.fromMLTensor(be,{dataType:he,dims:se[1],download:Ne,dispose:Ee})}default:throw new Error(`invalid data location: ${se[3]}`)}},Tl=class{async fetchModelAndCopyToWasmMemory(se){return to(await ar(se))}async loadModel(se,he){Be();let be;typeof se=="string"?be=await this.fetchModelAndCopyToWasmMemory(se):be=se,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Rs(be,he),Ze()}async dispose(){return gf(this.sessionId)}async run(se,he,be){Be();let Ne=[],Ee=[];Object.entries(se).forEach(tt=>{let Ye=tt[0],$t=tt[1],Le=this.inputNames.indexOf(Ye);if(Le===-1)throw new Error(`invalid input '${Ye}'`);Ne.push($t),Ee.push(Le)});let ze=[],Pe=[];Object.entries(he).forEach(tt=>{let Ye=tt[0],$t=tt[1],Le=this.outputNames.indexOf(Ye);if(Le===-1)throw new Error(`invalid output '${Ye}'`);ze.push($t),Pe.push(Le)});let Re=Ne.map((tt,Ye)=>Ec(tt,()=>`input "${this.inputNames[Ee[Ye]]}"`)),Ue=ze.map((tt,Ye)=>tt?Ec(tt,()=>`output "${this.outputNames[Pe[Ye]]}"`):null),et=await ro(this.sessionId,Ee,Re,Pe,Ue,be),at={};for(let tt=0;tt<et.length;tt++)at[this.outputNames[Pe[tt]]]=ze[tt]??io(et[tt]);return Ze(),at}startProfiling(){}endProfiling(){no(this.sessionId)}}}),ta={};f(ta,{OnnxruntimeWebAssemblyBackend:()=>ra,initializeFlags:()=>Ta,wasmBackend:()=>so});var Ta,ra,so,Iu=u(()=>{hr(),Mu(),jc(),Ta=()=>{(typeof O.wasm.initTimeout!="number"||O.wasm.initTimeout<0)&&(O.wasm.initTimeout=0);let se=O.wasm.simd;if(typeof se!="boolean"&&se!==void 0&&se!=="fixed"&&se!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${se}". Reset it to \`false\` and ignore SIMD feature checking.`),O.wasm.simd=!1),typeof O.wasm.proxy!="boolean"&&(O.wasm.proxy=!1),typeof O.wasm.trace!="boolean"&&(O.wasm.trace=!1),typeof O.wasm.numThreads!="number"||!Number.isInteger(O.wasm.numThreads)||O.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)O.wasm.numThreads=1;else{let he=typeof navigator>"u"?o("node:os").cpus().length:navigator.hardwareConcurrency;O.wasm.numThreads=Math.min(4,Math.ceil((he||1)/2))}},ra=class{async init(se){Ta(),await fs(),await ja(se)}async createInferenceSessionHandler(se,he){let be=new Tl;return await be.loadModel(se,he),be}},so=new ra}),Du={};f(Du,{InferenceSession:()=>sr,TRACE:()=>Me,TRACE_EVENT_BEGIN:()=>dt,TRACE_EVENT_END:()=>ut,TRACE_FUNC_BEGIN:()=>Be,TRACE_FUNC_END:()=>Ze,Tensor:()=>we,default:()=>Ac,env:()=>O,registerBackend:()=>k}),hr(),hr(),hr();var Tc="1.26.0",Ac=ui;{let se=(Iu(),h(ta)).wasmBackend;k("cpu",se,10),k("wasm",se,10)}return Object.defineProperty(O.versions,"web",{value:Tc,enumerable:!0}),h(Du)})();e.exports=n})(u1)),u1.exports}var q$;function BU(){return q$||(q$=1,(function(e){var r=Ql&&Ql.__createBinding||(Object.create?(function(C,T,E,$){$===void 0&&($=E);var N=Object.getOwnPropertyDescriptor(T,E);(!N||("get"in N?!T.__esModule:N.writable||N.configurable))&&(N={enumerable:!0,get:function(){return T[E]}}),Object.defineProperty(C,$,N)}):(function(C,T,E,$){$===void 0&&($=E),C[$]=T[E]})),n=Ql&&Ql.__setModuleDefault||(Object.create?(function(C,T){Object.defineProperty(C,"default",{enumerable:!0,value:T})}):function(C,T){C.default=T}),i=Ql&&Ql.__importStar||function(C){if(C&&C.__esModule)return C;var T={};if(C!=null)for(var E in C)E!=="default"&&Object.prototype.hasOwnProperty.call(C,E)&&r(T,C,E);return n(T,C),T};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const s=i(LU()),a=bT(),l=xT(),o=qy(),u=Xw(),f=W5(),m=H5();e.DEFAULT_MODEL="legacy",e.ort=s;const h="vad.worklet.bundle.min.js",b="silero_vad_v5.onnx",x="silero_vad_legacy.onnx",k=C=>({...l.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{o.log.debug("VAD misfire")},onSpeechStart:()=>{o.log.debug("Detected speech start")},onSpeechEnd:()=>{o.log.debug("Detected speech end")},onSpeechRealStart:()=>{o.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:C,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(E=>{E.stop()})},resumeStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),ortConfig:T=>{T.env.logLevel="error"},startOnLoad:!0,processorType:"auto"});e.getDefaultRealTimeVADOptions=k;const _=C=>"audioWorklet"in C&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function y(C,T,E,$,N){await E.audioWorklet.addModule(C),T.processorOptions={...T.processorOptions??{},frameSamples:$};const O=new AudioWorkletNode(E,"vad-helper-worklet",T);return O.port.onmessage=async I=>{const W=I.data;if(!(typeof W=="object"&&W&&"message"in W)){console.error("Invalid message event",W);return}switch(W.message){case u.Message.AudioFrame:{if(!("data"in W&&W.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const H=new Float32Array(W.data);await N(H);break}}},O}async function w(C,T,E){const $=new m.Resampler({nativeSampleRate:C.sampleRate,targetSampleRate:16e3,targetFrameSize:T});o.log.debug("using script processor");const O=C.createScriptProcessor(4096,1,1);let I=!1;return O.onaudioprocess=async W=>{if(!I){I=!0;try{const H=W.inputBuffer.getChannelData(0);W.outputBuffer.getChannelData(0).fill(0);const U=$.process(H);for(const D of U)await E(D)}catch(H){console.error("Error processing audio:",H)}finally{I=!1}}},O.connect(C.destination),O}class S{constructor(T,E,$,N,O=!1,I=null,W=null,H=null,V=null,U=null,D=null,G="uninitialized",ee=!1){this.options=T,this.frameProcessor=E,this.model=$,this.frameSamples=N,this.listening=O,this.errored=I,this._stream=W,this._audioContext=H,this._vadNode=V,this._mediaStreamAudioSourceNode=U,this._audioProcessorAdapterType=D,this.initializationState=G,this.ownsAudioContext=ee,this.getAudioInstances=()=>{if(this._stream===null||this._audioContext===null||this._vadNode==null||this._mediaStreamAudioSourceNode==null)throw new Error("MicVAD has null stream, audio context, or processor adapter");return{stream:this._stream,audioContext:this._audioContext,vadNode:this._vadNode,mediaStreamAudioSourceNode:this._mediaStreamAudioSourceNode}},this.setErrored=ae=>{this.initializationState="errored",this.errored=ae},this.start=async()=>{switch(this.initializationState){case"uninitialized":{o.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(ae){throw ae instanceof Error?this.setErrored(ae.message):this.setErrored(String(ae)),ae}if(this.options.audioContext?(console.log("using custom audio context"),this._audioContext=this.options.audioContext):(console.log("using default audio context"),this._audioContext=new AudioContext,this.ownsAudioContext=!0),!this._audioContext)throw this.setErrored("Audio context is null"),Error("Audio context is null");switch(this._audioProcessorAdapterType=this.options.processorType=="auto"?_(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await y(this.options.baseAssetPath+h,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await w(this._audioContext,this.frameSamples,this.processFrame);break;default:throw new Error(`Unsupported audio processor adapter type: ${this._audioProcessorAdapterType}`)}this._mediaStreamAudioSourceNode=new MediaStreamAudioSourceNode(this._audioContext,{mediaStream:this._stream}),this._mediaStreamAudioSourceNode.connect(this._vadNode),o.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{o.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:ae,audioContext:oe,vadNode:J}=this.getAudioInstances();this._stream=await this.options.resumeStream(ae);const X=new MediaStreamAudioSourceNode(oe,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=X,X.connect(J);break}case"destroyed":{o.log.warn("start called after destroyed");break}case"errored":{o.log.error("start called after errored");break}default:{o.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:ae,mediaStreamAudioSourceNode:oe}=this.getAudioInstances();await this.options.pauseStream(ae),oe.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var oe;o.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:ae}=this.getAudioInstances();ae instanceof AudioWorkletNode&&ae.port.postMessage(u.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((oe=this._audioContext)==null?void 0:oe.close())},this.setOptions=ae=>{this.frameProcessor.setOptions(ae)},this.processFrame=async ae=>{await this.frameProcessor.process(ae,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=ae=>{switch(ae.msg){case u.Message.FrameProcessed:this.options.onFrameProcessed(ae.probs,ae.frame);break;case u.Message.SpeechStart:this.options.onSpeechStart();break;case u.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case u.Message.VADMisfire:this.options.onVADMisfire();break;case u.Message.SpeechEnd:this.options.onSpeechEnd(ae.audio);break}}}static async new(T={}){const E={...(0,e.getDefaultRealTimeVADOptions)(T.model??e.DEFAULT_MODEL),...T};(0,l.validateOptions)(E),e.ort.env.wasm.wasmPaths=E.onnxWASMBasePath,E.ortConfig!==void 0&&E.ortConfig(e.ort);const $=E.model==="v5"?b:x,N=E.baseAssetPath+$,O=E.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let I;try{I=await O(e.ort,()=>(0,a.defaultModelFetcher)(N))}catch(D){throw console.error(`Encountered an error while loading model file ${N}`),D}const W=E.model==="v5"?512:1536,H=W/16,V=new l.FrameProcessor(I.process,I.reset_state,{positiveSpeechThreshold:E.positiveSpeechThreshold,negativeSpeechThreshold:E.negativeSpeechThreshold,redemptionMs:E.redemptionMs,preSpeechPadMs:E.preSpeechPadMs,minSpeechMs:E.minSpeechMs,submitUserSpeechOnPause:E.submitUserSpeechOnPause},H),U=new S(E,V,I,W);if(E.startOnLoad)try{await U.start()}catch(D){throw console.error("Error starting micVad",D),D}return U}}e.MicVAD=S})(Ql)),Ql}var W$;function zU(){return W$||(W$=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultRealTimeVADOptions=e.MicVAD=e.DEFAULT_MODEL=e.utils=e.NonRealTimeVAD=e.Message=e.FrameProcessor=e.defaultModelFetcher=e.baseAssetPath=void 0;var r=F5();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return r.baseAssetPath}});var n=bT();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return n.defaultModelFetcher}});var i=xT();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var s=Xw();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return s.Message}});var a=IU();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return a.NonRealTimeVAD}});const l=DU();e.utils={audioFileToArray:l.audioFileToArray,minFramesForTargetMS:l.minFramesForTargetMS,arrayBufferToBase64:l.arrayBufferToBase64,encodeWAV:l.encodeWAV};var o=BU();Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return o.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return o.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return o.getDefaultRealTimeVADOptions}})})(o1)),o1}var FU=zU();function lx(e,r,n,i){var a,l;try{(l=(a=window.api)==null?void 0:a.logs)==null||l.write(e,r,n,i)}catch{}const s=r==="error"?console.error:r==="warn"?console.warn:console.log;i!==void 0?s(`[${e}]`,n,i):s(`[${e}]`,n)}const mt={debug:(e,r,n)=>lx(e,"debug",r,n),info:(e,r,n)=>lx(e,"info",r,n),warn:(e,r,n)=>lx(e,"warn",r,n),error:(e,r,n)=>lx(e,"error",r,n)},V5=16e3,UU=6,Xh=V5*UU,qU=400,WU=V5*qU/1e3,H$=300,G$=2e3,V$=1500,K$=3e3,HU=600,K5=.5,X5=.35,X$=.85,Y$=.7;let Vs=null,gl=!1,ks=!1;const iE=new Set;function cx(e){for(const r of Array.from(iE))try{r(e)}catch(n){mt.warn("speech","workerDeath listener threw",{error:n instanceof Error?n.message:String(n)})}}let d1=0;const J$=2;let mp=!1,Y5=!1;function J5(e){e.addEventListener("message",r=>{var i;if(((i=r.data)==null?void 0:i.type)!=="log")return;const n=r.data.level||"info";mt[n]("whisperWorker",r.data.message??"",r.data.meta)}),e.addEventListener("error",r=>{mt.error("whisperWorker","worker error event (fatal)",{message:r.message,filename:r.filename,lineno:r.lineno}),GU(`error:${r.message||"unknown"}`)})}function x0(){return Vs||(Vs=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),J5(Vs),mt.info("speech","worker spawned"),Vs)}let ux=!1;function GU(e){if(!mp){if(ux){mt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(ux=!0,d1+=1,Y5=!0,mt.warn("speech","respawnWorker: starting",{reason:e,attempt:d1}),cx({reason:e,respawned:!1,finalOnly:!0}),d1>J$){if(mp=!0,mt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:J$}),Vs)try{Vs.terminate()}catch{}Vs=null,gl=!1,ks=!1,cx({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),ux=!1;return}if(Vs)try{Vs.terminate()}catch{}Vs=null,gl=!1,ks=!1;try{Vs=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),J5(Vs),ks=!0,Vs.postMessage({type:"load"}),mt.info("speech","respawnWorker: new worker spawned, load posted"),cx({reason:e,respawned:!0,finalOnly:!0})}catch(r){mp=!0,mt.error("speech","respawnWorker: spawn failed, disabling speech",{error:r instanceof Error?r.message:String(r)}),cx({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{ux=!1}}}function VU(e,r){if(gl||ks)return;ks=!0;const n=x0();mt.info("speech","preloadModel: posting load");const i=s=>{s.data.type==="status"?(e==null||e(s.data.status,s.data.message),s.data.status==="ready"&&(gl=!0,ks=!1,mt.info("speech","preloadModel: ready"),n.removeEventListener("message",i))):s.data.type==="progress"?r==null||r(s.data.pct):s.data.type==="error"&&(ks=!1,mt.error("speech","preloadModel: worker reported error",{error:s.data.error}),e==null||e("error",s.data.error),n.removeEventListener("message",i))};n.addEventListener("message",i),n.postMessage({type:"load"})}function KU(){mt.info("speech","resetModel: clearing load flags"),gl=!1,ks=!1}function wT(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function XU(e){const r=x0();return!gl&&!ks&&(ks=!0,r.postMessage({type:"load"})),new Promise((n,i)=>{const s=a=>{var l,o,u;((l=a.data)==null?void 0:l.type)==="result"?(r.removeEventListener("message",s),n((a.data.text??"").trim())):((o=a.data)==null?void 0:o.type)==="error"?(r.removeEventListener("message",s),i(new Error(String(a.data.error??"Transcription failed")))):((u=a.data)==null?void 0:u.type)==="status"&&a.data.status==="ready"&&(gl=!0,ks=!1)};r.addEventListener("message",s),r.postMessage({type:"transcribe",audio:e},[e.buffer])})}function YU(e){let r=x0(),n=!1,i=null,s=null,a=null,l=null,o=null;const u=[],f=new Set;let m=null,h=0,b=!1,x=0,k=!1,_=!1,y=0,w=0,S=0,C=-1,T=H$,E=0,$=null,N="",O="",I=!1,W=0;function H(ce,ge){const _e=Math.min(ce.length,ge.length);let Te=0;for(;Te<_e&&ce.charCodeAt(Te)===ge.charCodeAt(Te);)Te++;return Te}function V(ce){const ge=H(N,ce);return N=ce,ge>O.length&&(O=ce.slice(0,ge)),O.length>ce.length&&(O=ce),O}const U=()=>(m||(m=new Float32Array(Xh)),m),D=()=>{h=0},G=ce=>{const ge=U(),_e=ce.length;if(_e>=Xh){ge.set(ce.subarray(_e-Xh)),h=Xh;return}if(h+_e<=Xh){ge.set(ce,h),h+=_e;return}const Te=h+_e-Xh;ge.copyWithin(0,Te,h),h-=Te,ge.set(ce,h),h+=_e},ee=()=>{$&&(clearTimeout($),$=null)},ae=()=>{ee(),b=!1,k=!1,_=!1,T=H$,N="",O="",I=!1,W=0,D()},oe=()=>{if(n||!b||_||k||$)return;if(h<WU){$=setTimeout(()=>{$=null,oe()},T);return}const ce=performance.now()-y;if(ce<T&&y!==0){$=setTimeout(()=>{$=null,oe()},T-ce);return}if(Y5||mp||e.partialsEnabled&&!e.partialsEnabled())return;const ge=U(),_e=new Float32Array(h);_e.set(ge.subarray(0,h)),w+=1,S=w,k=!0,E=performance.now(),y=E,r.postMessage({type:"transcribe-partial",audio:_e,seq:w},[_e.buffer])},J=ce=>ce.length===0?Promise.resolve():mp?(mt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),n||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(ge=>{u.push(ge),w+=1;const _e=w;C=_e,r.postMessage({type:"transcribe",audio:ce,seq:_e},[ce.buffer])}),X=ce=>{const ge=J(ce);return f.add(ge),ge.finally(()=>{f.delete(ge)}),ge},Z=ce=>{var ge,_e,Te,ye,ie;if(ce.data.type==="result"){const xe=ce.data.text,we=ce.data.seq??0;we&&we<C&&mt.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:we,latestFinalSeq:C}),!n&&xe&&e.onFinal(xe),(ge=u.shift())==null||ge()}else if(ce.data.type==="partial"){const xe=ce.data.seq??0,we=ce.data.text??"",Ve=performance.now()-E;k=!1,Ve>=K$?(_=!0,mt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ve),seq:xe})):Ve>=V$&&(T=Math.min(T*2,G$),mt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ve),newIntervalMs:T,seq:xe})),I||(I=!0,Ve>HU&&T<500&&(T=500,mt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ve),newIntervalMs:500})));const Me=xe!==S||xe<=C;if(!n&&!Me&&we){const We=V(we);We&&((_e=e.onPartial)==null||_e.call(e,We),W===0&&(W=performance.now(),mt.info("speech","partial.first",{msSinceSpeechStart:Math.round(W-x)})))}oe()}else if(ce.data.type==="partial-error"){const xe=performance.now()-E;k=!1,xe>=K$?(_=!0,mt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(xe),seq:ce.data.seq})):xe>=V$&&(T=Math.min(T*2,G$),mt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(xe),newIntervalMs:T,seq:ce.data.seq})),mt.warn("speech","partial encode failed",{error:ce.data.error,seq:ce.data.seq}),oe()}else ce.data.type==="error"?(n||e.onError(ce.data.error),(Te=u.shift())==null||Te()):ce.data.type==="status"?(n||(ye=e.onModelStatus)==null||ye.call(e,ce.data.status,ce.data.message),ce.data.status==="ready"&&(gl=!0,ks=!1)):ce.data.type==="progress"&&(n||(ie=e.onProgress)==null||ie.call(e,ce.data.pct))};r.addEventListener("message",Z);const ne=ce=>{var ge,_e;if(!n){for(mt.warn("speech","createRecognition: worker death event",ce),(ge=e.onStatusChange)==null||ge.call(e,"restarting");u.length;)(_e=u.shift())==null||_e();if(f.clear(),ee(),k=!1,ce.respawned){try{r.removeEventListener("message",Z)}catch{}r=x0(),r.addEventListener("message",Z)}}};return iE.add(ne),{start:async()=>{if(!n){if(mp){e.onError("Speech recognition disabled — please reload the app.");return}!gl&&!ks&&(ks=!0,mt.info("speech","createRecognition.start: triggering model load"),r.postMessage({type:"load"})),mt.info("speech","createRecognition.start: initializing VAD",{modelReady:gl,modelLoading:ks});try{const ce=new URL("vad/",document.baseURI).href,ge=e.inputDeviceId||null,_e={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};ge&&(_e.deviceId={exact:ge}),mt.info("speech","getUserMedia",{hasDeviceId:!!ge,deviceIdPrefix:ge?ge.slice(0,8):null});const Te=await navigator.mediaDevices.getUserMedia({audio:_e});s=Te,a=new AudioContext;for(const ye of Te.getAudioTracks())ye.addEventListener("ended",()=>{n||(mt.warn("speech","mic track ended (permission revoked or device removed)"),e.onError("Microphone disconnected or permission revoked"))});try{o=a.createMediaStreamSource(s),l=a.createAnalyser(),l.fftSize=2048,l.smoothingTimeConstant=.3,o.connect(l)}catch(ye){mt.warn("speech","analyser init failed",{error:ye instanceof Error?ye.message:String(ye)}),o=null,l=null}i=await FU.MicVAD.new({audioContext:a,getStream:async()=>Te,resumeStream:async()=>Te,pauseStream:async()=>{},baseAssetPath:ce,onnxWASMBasePath:ce,model:"v5",positiveSpeechThreshold:K5,negativeSpeechThreshold:X5,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(ye,ie)=>{var xe;n||((xe=e.onFrame)==null||xe.call(e,ye),b&&(G(ie),oe()))},onSpeechStart:()=>{var ye;n||(ae(),b=!0,x=performance.now(),(ye=e.onSpeechStart)==null||ye.call(e))},onSpeechEnd:ye=>{var ie;n||((ie=e.onStatusChange)==null||ie.call(e,"transcribing"),ae(),X(ye))},onVADMisfire:()=>{var ye,ie;n||((ye=e.onStatusChange)==null||ye.call(e,"idle"),ae(),(ie=e.onMisfire)==null||ie.call(e))}}),i.start()}catch(ce){const ge=ce instanceof Error?ce.message:"Microphone access denied",_e=ce instanceof Error?ce.stack:"";if(mt.error("speech","createRecognition.start: VAD init failed",{error:ge,stack:_e}),l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(s){try{s.getTracks().forEach(Te=>Te.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}e.onError(ge)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(ae();f.size>0;)await Promise.all(Array.from(f));if(i){try{await i.destroy()}catch{}i=null}if(l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(s){try{s.getTracks().forEach(ce=>ce.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}},setVadThresholds:(ce,ge)=>{if(i)try{i.setOptions({positiveSpeechThreshold:ce,negativeSpeechThreshold:ge})}catch(_e){mt.warn("speech","setVadThresholds failed",{error:_e instanceof Error?_e.message:String(_e)})}},getAnalyser:()=>l,destroy:()=>{if(n=!0,ae(),i){try{i.destroy()}catch{}i=null}if(l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(a){try{a.close()}catch{}a=null}if(s){try{s.getTracks().forEach(ce=>ce.stop())}catch{}s=null}iE.delete(ne),r.removeEventListener("message",Z)}}}let Fv=null;const sE=new Set,aE=new Set;function JU(){for(const e of sE)try{e()}catch{}}function oE(){for(const e of aE)try{e()}catch{}}function QU(e){return e.replace(/```[\s\S]*?```/g,"").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/\*{1,3}([^*]+)\*{1,3}/g,"$1").replace(/_{1,3}([^_]+)_{1,3}/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/^[-*_]{3,}\s*$/gm,"").replace(/^>\s?/gm,"").replace(/^[\s]*[-*+]\s/gm,"").replace(/^[\s]*\d+\.\s/gm,"").trim()}function ZU(e){if(!window.speechSynthesis)return;const r=QU(e);if(!r)return;const n=new SpeechSynthesisUtterance(r);n.rate=1,n.pitch=1,n.onstart=()=>{Fv=performance.now(),JU()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Fv=null,oE())},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Fv=null,oE())},window.speechSynthesis.speak(n)}function Q5(){window.speechSynthesis&&(window.speechSynthesis.cancel(),Fv=null,oE())}function Z5(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function eq(){return Fv}function tq(e){return sE.add(e),()=>{sE.delete(e)}}function rq(e){return aE.add(e),()=>{aE.delete(e)}}function nq(e){Z5()&&(e.setVadThresholds(X$,Y$),mt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const r=tq(()=>{e.setVadThresholds(X$,Y$),mt.info("voice","tts.duck.on")}),n=rq(()=>{e.setVadThresholds(K5,X5),mt.info("voice","tts.duck.off")});return()=>{r(),n()}}const iq=[{match:/^(send|submit|enter)\.?$/i,data:"\r",label:"send"},{match:/^(cancel|escape)\.?$/i,data:"\x1B",label:"cancel"},{match:/^clear( line)?\.?$/i,data:"",label:"clear"}];function sq(e){const r=e.trim();return iq.find(n=>n.match.test(r))??null}const aq=4e4;let Ud=null;function gp(){Ud&&clearTimeout(Ud),Ud=setTimeout(()=>{Ud=null,Rt.getState().stopRecording()},aq)}function dx(){Ud&&(clearTimeout(Ud),Ud=null)}let vu=null,gu=null;const oq=.04,lq=.3;let w0=0,lE=0;function cq(e){gu!==null&&cancelAnimationFrame(gu);const r=()=>{if(vu===null||Rt.getState().submitCountdownStartAt===null){gu=null;return}const n=performance.now();if(n-lE<200&&w0>lq){const s=n-e;mt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:w0.toFixed(2),msIntoCountdown:Math.round(s)}),fu(),gp();return}const i=e4();if(i){const s=new Uint8Array(i.fftSize);i.getByteTimeDomainData(s);let a=0;for(let o=0;o<s.length;o++){const u=(s[o]-128)/128;a+=u*u}const l=Math.sqrt(a/s.length);if(l>oq){const o=n-e;mt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:l.toFixed(3),msIntoCountdown:Math.round(o)}),fu(),gp();return}}gu=requestAnimationFrame(r)};gu=requestAnimationFrame(r)}function uq(e){vu&&clearTimeout(vu);const r=Rt.getState().submitDelayMs,n=performance.now();Rt.setState({submitCountdownStartAt:n}),vu=setTimeout(()=>{vu=null,Rt.setState({submitCountdownStartAt:null});try{window.api.pty.write({tabId:e,data:"\r"})}catch(i){mt.warn("voice","submit pty.write failed",{error:i instanceof Error?i.message:String(i)})}gp()},r),cq(n)}function fu(){gu!==null&&(cancelAnimationFrame(gu),gu=null),vu&&(clearTimeout(vu),vu=null),Rt.getState().submitCountdownStartAt!==null&&Rt.setState({submitCountdownStartAt:null})}let Ci=null,es=null;function e4(){var e;return((e=Ci==null?void 0:Ci.getAnalyser)==null?void 0:e.call(Ci))??null}const fx=1e4;let Uv=null;function hx(){Uv&&(clearTimeout(Uv),Uv=null)}let o0=null,l0=null;function px(){o0=null,l0&&(l0(),l0=null)}const dq=1500,fq=9e4;let mx=0,c0=null,cE=-1;function gx(){c0&&(clearTimeout(c0),c0=null,cE=-1)}const hq=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Rt=jn((e,r)=>({isRecording:!1,ttsEnabled:!1,autoSubmit:!0,submitDelayMs:8e3,submitCountdownStartAt:null,lastTranscript:"",lastPartial:"",statusPill:"idle",partialsEnabled:!0,error:null,errorKind:null,modelStatus:"idle",loadingProgress:0,permissionState:"unknown",lastBargeInAt:null,hotkeyState:"idle",levelMeterEnabled:!0,turnDetectorState:"disabled",turnDetectorMode:"off",wizardArmed:!1,wizardOpen:!1,initModel:()=>{if(r().modelStatus!=="idle")return;mt.info("voice","initModel: kicking off preload"),e({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const n=++mx,i=()=>{n===mx&&(gx(),cE=n,c0=setTimeout(()=>{cE===n&&r().modelStatus==="loading"&&(mt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},fq))};i(),VU((s,a)=>{n===mx&&(s==="ready"?(gx(),mt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):s==="error"?(gx(),mt.error("voice","modelStatus -> error",{msg:a}),e({modelStatus:"error",error:a,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},s=>{n===mx&&(i(),e({loadingProgress:Math.round(s)}))})},resetAndRetryModel:()=>{mt.info("voice","mic.gate.retry"),gx(),KU(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),r().initModel()},startRecording:n=>{if(r().isRecording)return;if(Ci){mt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!wT()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=s=>{try{const a=YU({inputDeviceId:s,onStatusChange:l=>{e(l==="transcribing"?{statusPill:"transcribing"}:l==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:l=>{r().partialsEnabled&&e({lastPartial:l})},partialsEnabled:()=>r().partialsEnabled,onFrame:l=>{w0=l.isSpeech,lE=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),dx(),fu(),Z5()){const o=eq(),u=o!==null?performance.now()-o:null;Q5(),e({lastBargeInAt:performance.now()}),mt.info("voice","barge-in",{tabId:n,utteranceOffsetMs:u})}else mt.debug("voice","barge-in.no-op",{tabId:n})},onMisfire:()=>{e({lastPartial:"",statusPill:"idle"}),gp();const l=r().lastBargeInAt;l!==null&&performance.now()-l<600&&mt.warn("voice","barge-in.misfire",{tabId:n,sinceBargeInMs:Math.round(performance.now()-l)})},onFinal:l=>{gp();const o=l.trim();if(!o||hq.has(o)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const u=sq(o);if(u){mt.info("voice","voice-command",{tabId:n,label:u.label,transcript:o}),window.api.pty.write({tabId:n,data:u.data}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),fu();const m=window;m.__transcripts&&(m.__transcripts.push({tabId:n,text:o}),m.__transcripts.length>500&&m.__transcripts.shift());return}window.api.pty.write({tabId:n,data:o}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),r().autoSubmit&&uq(n);const f=window;f.__transcripts&&(f.__transcripts.push({tabId:n,text:o}),f.__transcripts.length>500&&f.__transcripts.shift())},onError:l=>{mt.error("voice","recognition error",{err:l}),fu(),e({error:l,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),es==null||es(),es=null,dx(),Ci==null||Ci.destroy(),Ci=null,it.error(`Microphone error: ${l}`)},onModelStatus:l=>{l==="ready"?e({modelStatus:"ready",loadingProgress:100}):l==="loading"&&e({modelStatus:"loading"})},onProgress:l=>e({loadingProgress:Math.round(l)})});Ci=a,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),gp(),a.start().then(()=>{Ci===a&&(es==null||es(),es=nq(a))}).catch(l=>{const o=l instanceof Error?l.message:String(l);mt.error("voice","handle.start() failed",{error:o}),it.error(`Could not start mic: ${o}`)})}catch(a){e({error:a instanceof Error?a.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var s,a,l;return((l=(a=(s=window.api)==null?void 0:s.voice)==null?void 0:a.getDevicePref)==null?void 0:l.call(a))??Promise.resolve(null)}).then(s=>i((s==null?void 0:s.selectedDeviceId)??null)).catch(s=>{mt.warn("voice","getDevicePref failed; using default device",{error:s instanceof Error?s.message:String(s)}),i(null)})},stopRecording:()=>{const n=Ci;n&&(dx(),fu(),w0=0,lE=0,es==null||es(),es=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),n.stop().finally(()=>{n.destroy(),Ci===n&&(Ci=null),r().hotkeyState==="stopping"&&(hx(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!r().isRecording)return;const n=Ci;if(!n)return;dx(),es==null||es(),es=null,e({isRecording:!1,lastTranscript:"",lastPartial:""});try{await n.stop()}catch(a){mt.warn("voice","restartWithDevice: drain rejected",{error:a instanceof Error?a.message:String(a)})}n.destroy(),Ci===n&&(Ci=null);const{useSessions:i}=await em(async()=>{const{useSessions:a}=await Promise.resolve().then(()=>xU);return{useSessions:a}},[],import.meta.url),s=i.getState().activeTabId;s&&r().startRecording(s)},toggleTTS:()=>e(n=>({ttsEnabled:!n.ttsEnabled})),setAutoSubmit:n=>e({autoSubmit:n}),setSubmitDelayMs:n=>e({submitDelayMs:Math.max(500,Math.min(13e3,Math.floor(n)))}),cancelSubmit:()=>fu(),setPartialsEnabled:n=>{r().partialsEnabled!==n&&(e({partialsEnabled:n}),n||e({lastPartial:""}))},clearError:()=>e({error:null,errorKind:null}),setPermissionState:n=>{r().permissionState!==n&&(mt.info("voice","mic.gate.permission_changed",{from:r().permissionState,to:n}),e({permissionState:n}))},setLevelMeterEnabled:n=>{r().levelMeterEnabled!==n&&e({levelMeterEnabled:n})},setTurnDetectorRuntimeState:n=>{r().turnDetectorState!==n&&(e({turnDetectorState:n}),n==="load_failed"?mt.warn("voice-turn","voice-turn.load_failed"):n==="runtime_error"?mt.warn("voice-turn","voice-turn.runtime_error"):n==="disabled"&&mt.info("voice-turn","voice-turn.fallback_to_vad"))},setWizardArmed:n=>{r().wizardArmed!==n&&e({wizardArmed:n})},openWizard:()=>{r().wizardOpen||e({wizardOpen:!0})},closeWizard:()=>{r().wizardOpen&&e({wizardOpen:!1})},armHotkey:({phase:n,source:i,mode:s,tabId:a})=>{const l=r(),{canRecord:o,reason:u}=uE(l);if(n==="down"){if(u==="error"||u==="load-timeout"){l.resetAndRetryModel(),mt.info("voice-hotkey","down.retry",{source:i,reason:u});return}if(!o&&u!=="loading"){mt.warn("voice-hotkey","miss-model-loading",{modelStatus:l.modelStatus,reason:u});return}if(l.hotkeyState==="recording"||l.isRecording){(s==="toggle"||i==="global")&&(e({hotkeyState:"stopping"}),hx(),Uv=setTimeout(()=>{r().hotkeyState==="stopping"&&(mt.warn("voice-hotkey","drain-timeout",{durationMs:fx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},fx),l.stopRecording());return}if(u==="loading"){l.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),mt.info("voice-hotkey","armed",{source:i,modelStatus:l.modelStatus})),px(),o0={tabId:a,source:i,mode:s},l0=Rt.subscribe((f,m)=>{if(o0&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const h=o0;if(px(),!h.tabId){mt.warn("voice-hotkey","armed-promote-no-tab",{source:h.source}),e({hotkeyState:"idle"});return}mt.info("voice-hotkey","armed-promote",h),e({hotkeyState:"recording"}),Rt.getState().startRecording(h.tabId)}});return}if(!a){mt.warn("voice-hotkey","no-active-tab",{source:i});return}mt.info("voice-hotkey","start",{source:i,mode:s,tabId:a}),l.startRecording(a),r().isRecording?e({hotkeyState:"recording"}):(mt.warn("voice-hotkey","start: recording did not engage",{errorKind:r().errorKind}),e({hotkeyState:"idle"}));return}if(!(s!=="hold"||i==="global")){if(l.hotkeyState==="armed"){px(),mt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}l.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),hx(),Uv=setTimeout(()=>{r().hotkeyState==="stopping"&&(mt.warn("voice-hotkey","drain-timeout",{durationMs:fx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},fx),l.stopRecording())}},destroyHotkey:()=>{const n=r();if(px(),fu(),n.hotkeyState==="recording"){mt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{n.stopRecording()}catch{}}else(n.hotkeyState==="armed"||n.hotkeyState==="stopping")&&(hx(),e({hotkeyState:"destroyed"}))}})),pq=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),uE=e=>wT()?e.permissionState==="denied"?{canRecord:!1,reason:"permission-denied"}:e.modelStatus==="ready"?{canRecord:!0,reason:"ready"}:e.modelStatus==="loading"?{canRecord:!1,reason:"loading"}:e.modelStatus==="error"?{canRecord:!1,reason:e.errorKind==="timeout"?"load-timeout":"error"}:{canRecord:!1,reason:"idle"}:{canRecord:!1,reason:"unsupported"};if(typeof window<"u"){const e=window;e.__voice=Rt,e.__transcripts=[]}function _T(e,r,n){return new Promise((i,s)=>{const a=setTimeout(()=>s(new Error(`${n} timed out after ${r}ms`)),r);e.then(l=>{clearTimeout(a),i(l)},l=>{clearTimeout(a),s(l)})})}const mq=5e3,ku=jn(()=>({snapshot:null,loaded:!1}));let Q$=!1,Z$=!1,Jg;async function gq(){var e;if(!Q$){Q$=!0;try{const r=await _T(window.api.schedule.state(),mq,"schedule.state");ku.setState({snapshot:r,loaded:!0}),Jg=((e=r.paused)==null?void 0:e.reason)??null}catch(r){if(!Z$){Z$=!0;const n=r instanceof Error?r.message:String(r);it.error(`Scheduler state hydrate failed: ${n}`)}Jg=null}window.api.schedule.onState(r=>{var i;const n=((i=r.paused)==null?void 0:i.reason)??null;Jg!==void 0&&n!==Jg&&(n==="auth"?it.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):n==="network"&&it.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),Jg=n,ku.setState({snapshot:r,loaded:!0})})}}const vq=6e4,yq=5e3,vp=jn(()=>({data:null,refreshing:!1}));let eN=!1,u0=null,tN=null,rN=!1;async function ST(){vp.setState({refreshing:!0});let e=vq;try{const r=await _T(window.api.billing.fetch(),yq,"billing.fetch");vp.setState({data:r,refreshing:!1}),r.kind==="transient"?e=tN==="transient"?3e4:5e3:r.kind==="auth"&&(e=3e4),tN=r.kind}catch(r){if(vp.setState({refreshing:!1}),!rN){rN=!0;const n=r instanceof Error?r.message:String(r);it.warn(`Billing usage fetch failed: ${n}`)}}u0=setTimeout(ST,e)}function bq(){eN||(eN=!0,ST())}function Yw(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:e.kind==="auth"&&e.cached?e.cached:null:null}function _0(){u0!==null&&(clearTimeout(u0),u0=null),ST()}function oi({name:e,size:r=17,stroke:n=1.6,className:i}){const s={width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",className:i};switch(e){case"home":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M4 11l8-7 8 7"}),c.jsx("path",{d:"M6 10v9h12v-9"}),c.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M7 10l3 2-3 2"}),c.jsx("path",{d:"M13 14h4"})]});case"agents":case"subagents":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"7",cy:"9",r:"2.5"}),c.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),c.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),c.jsx("path",{d:"M8.6 11l2.8 4M15.4 11l-2.8 4M9.5 9h5"})]});case"skills":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 3l2.5 5.5L20 9l-4 4 1 6-5-3-5 3 1-6-4-4 5.5-.5z"})});case"history":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"}),c.jsx("path",{d:"M4 6l2 2"})]});case"usage":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"hive":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M8 4h8l4 7-4 7H8l-4-7z"}),c.jsx("circle",{cx:"12",cy:"11",r:"2.5"})]});case"knowledge-graph":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"6",cy:"7",r:"2.2"}),c.jsx("circle",{cx:"18",cy:"6",r:"2.2"}),c.jsx("circle",{cx:"17",cy:"18",r:"2.2"}),c.jsx("circle",{cx:"7",cy:"17",r:"2.2"}),c.jsx("path",{d:"M8 8l8 8M8 16l8-9M8 7h8"})]});case"plugins":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),c.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),c.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),c.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),c.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"8",cy:"12",r:"4"}),c.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"plans":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),c.jsx("path",{d:"M8 9h8M8 13h8M8 17h5"})]});case"tasks":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),c.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1.5"}),c.jsx("path",{d:"M14 6h7M14 10h5M14 15h7M14 19h5"})]});case"projects":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"docs":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M6 3h8l4 4v14H6z"}),c.jsx("path",{d:"M14 3v4h4M9 13h6M9 17h6M9 9h3"})]});case"memory":case"agent-memory":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M9 4a4 4 0 00-4 4v1a3 3 0 000 6v1a4 4 0 004 4h6a4 4 0 004-4v-1a3 3 0 000-6V8a4 4 0 00-4-4z"}),c.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":case"global-search":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"11",cy:"11",r:"6"}),c.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return c.jsx("svg",{...s,children:c.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M7 3h7l4 4v14H7z"}),c.jsx("path",{d:"M14 3v4h4"})]});case"play":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),c.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),c.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),c.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M12 2v3M12 19v3M4 12H1M23 12h-3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"})]});case"mic":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),c.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"orchestrator":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"6",r:"2.5"}),c.jsx("circle",{cx:"5",cy:"17",r:"2.5"}),c.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),c.jsx("circle",{cx:"19",cy:"17",r:"2.5"}),c.jsx("path",{d:"M12 8.5v6M12 14.5l-7 0M12 14.5l7 0"})]});case"race":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M5 4v16M5 5h7l-1 3h7v6h-7l-1 3H5"})});case"background":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M3 4h18v4H3zM3 10h18v4H3zM3 16h18v4H3z"}),c.jsx("circle",{cx:"6",cy:"6",r:".75",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6",cy:"12",r:".75",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6",cy:"18",r:".75",fill:"currentColor",stroke:"none"})]});case"repoviz":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"6",cy:"12",r:"3"}),c.jsx("circle",{cx:"18",cy:"6",r:"3"}),c.jsx("circle",{cx:"18",cy:"18",r:"3"}),c.jsx("path",{d:"M8.5 10.5L15.5 7.5M8.5 13.5L15.5 16.5"})]});case"system-prompt":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),c.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),c.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),c.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M14 4a4 4 0 014 4l-7 7-4-4 7-7zM7 11l-3 3 6 6 3-3"})});case"quick-open":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"remote":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M5 12.5a7 7 0 0114 0M1.5 9a11 11 0 0121 0M8.5 16a3.5 3.5 0 017 0"}),c.jsx("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]});case"wifi":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M5 12.5a10 10 0 0114 0M8 15.5a6 6 0 018 0M12 18.5h.01"})});case"shield":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),c.jsx("path",{d:"M9 12l2 2 4-4"})]});case"link":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M9 12h6"}),c.jsx("path",{d:"M10 8H7a4 4 0 000 8h3M14 8h3a4 4 0 010 8h-3"})]});case"copy":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),c.jsx("path",{d:"M5 15V5a2 2 0 012-2h8"})]});default:return null}}function xq(e,r={}){switch(e){case"ready":return r.isRecording?"Stop voice input":"Start voice input (local Whisper, offline)";case"idle":return"Microphone — speech model not started";case"loading":return`Microphone — loading speech model, ${typeof r.loadingPct=="number"?Math.round(r.loadingPct):0} percent`;case"error":return r.errorMessage?`Microphone — speech model error: ${r.errorMessage}. Activate to retry.`:"Microphone — speech model error. Activate to retry.";case"load-timeout":return"Microphone — model load timed out. Activate to retry.";case"permission-denied":return"Microphone — permission denied. Open OS settings.";case"unsupported":return"Microphone — voice input not supported in this build."}}const nN=e=>Symbol.iterator in e,iN=e=>"entries"in e,sN=(e,r)=>{const n=e instanceof Map?e:new Map(e.entries()),i=r instanceof Map?r:new Map(r.entries());if(n.size!==i.size)return!1;for(const[s,a]of n)if(!i.has(s)||!Object.is(a,i.get(s)))return!1;return!0},wq=(e,r)=>{const n=e[Symbol.iterator](),i=r[Symbol.iterator]();let s=n.next(),a=i.next();for(;!s.done&&!a.done;){if(!Object.is(s.value,a.value))return!1;s=n.next(),a=i.next()}return!!s.done&&!!a.done};function _q(e,r){return Object.is(e,r)?!0:typeof e!="object"||e===null||typeof r!="object"||r===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(r)?!1:nN(e)&&nN(r)?iN(e)&&iN(r)?sN(e,r):wq(e,r):sN({entries:()=>Object.entries(e)},{entries:()=>Object.entries(r)})}function t4(e){const r=Fe.useRef(void 0);return n=>{const i=e(n);return _q(r.current,i)?r.current:r.current=i}}let aN=0;const Sq=1e3;function kq(e){const r=performance.now();r-aN<Sq||(aN=r,mt.debug("voice","mic.gate.click_rejected",{reason:e}))}function r4(){const e=Rt(f=>f.isRecording),r=Rt(f=>f.error),n=Rt(f=>f.loadingProgress),i=Rt(t4(uE)),s=()=>{const f=Rt.getState(),{canRecord:m,reason:h}=uE(f);if(f.isRecording)return f.stopRecording();if(f.wizardArmed&&!f.wizardOpen){f.openWizard();return}if(h==="error"||h==="load-timeout"){f.resetAndRetryModel();return}if(!m)return kq(h);const b=Gt.getState().activeTabId;b&&f.startRecording(b)},a=xq(i.reason,{loadingPct:n,errorMessage:r,isRecording:e}),l=i.reason==="unsupported",o=!i.canRecord,u=i.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":i.reason==="error"||i.reason==="load-timeout"?"text-red-400 cursor-pointer":i.reason==="permission-denied"?"text-amber-400 cursor-pointer":i.reason==="idle"?"text-fg-faint cursor-pointer":i.reason==="unsupported"?"text-fg-faint cursor-not-allowed":e?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return c.jsx("button",{onClick:s,disabled:l,"aria-disabled":o,"aria-label":a,title:a,"data-testid":"mic-button","data-state":i.reason,className:`p-1.5 rounded transition-colors ${u}`,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),c.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),c.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function Cq(){const e=Rt(n=>n.ttsEnabled),r=Rt(n=>n.toggleTTS);return c.jsxs("button",{onClick:r,title:e?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${e?"text-accent":"text-fg-dim hover:text-fg"}`,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e?c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),c.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),c.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),c.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}const oN=[{key:"overview",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"projects",label:"File Explorer",icon:"projects",hint:"Browse files + edit, per project"},{key:"subagents",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Fan out work: Hive · Orchestrate · Race · Boss"},{key:"scheduler",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"prompts",label:"Prompts",icon:"book",hint:"Click-to-insert prompt library"},{key:"history",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"},{key:"knowledge-graph",label:"Knowledge Graph",icon:"knowledge-graph",hint:"Distilled graph + Q&A over your prompt log"}],lN=[{key:"skills",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"doc-editor",label:"Doc Editor",icon:"docs",hint:"Edit CLAUDE.md and friends"},{key:"memory",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"system-prompt",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"}],cN=[{key:"voice",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"repoviz",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],dE="sm.almanac.sidebarWidth",n4=180,i4=480,fE=252;function Eq(){try{const e=parseInt(localStorage.getItem(dE)??"",10);if(Number.isFinite(e))return Math.min(i4,Math.max(n4,e))}catch{}return fE}const jq=52,s4="sm.almanac.sidebarCollapsed";function Tq(){try{return localStorage.getItem(s4)==="1"}catch{}return!1}const a4="sm.almanac.collapsedGroups";function Aq(){try{const e=localStorage.getItem(a4);if(!e)return new Set;const r=JSON.parse(e);return Array.isArray(r)?new Set(r.filter(n=>n==="Workspace"||n==="Configure"||n==="Tools")):new Set}catch{return new Set}}function $q(){const e=s0(a=>a.tabs),r=ku(a=>{var l;return(((l=a.snapshot)==null?void 0:l.jobs)??[]).some(o=>o.status==="running")}),[n,i]=B.useState(()=>Date.now());return B.useEffect(()=>{const a=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(a)},[]),{subagents:Object.values(e).some(a=>a.agents.some(l=>n-l.at<6e4)),scheduler:r}}function Nq({active:e,onNavigate:r,onNewSession:n}){const[i,s]=B.useState(()=>Aq()),a=B.useCallback(S=>{s(C=>{const T=new Set(C);T.has(S)?T.delete(S):T.add(S);try{localStorage.setItem(a4,JSON.stringify(Array.from(T)))}catch{}return T})},[]),[l,o]=B.useState(()=>Tq()),u=B.useCallback(()=>{o(S=>{const C=!S;try{localStorage.setItem(s4,C?"1":"0")}catch{}return C})},[]),f=Gt(S=>S.tabs),m=Gt(S=>S.activeTabId),h=f.find(S=>S.id===m)??null,b=$q(),[x,k]=B.useState(()=>Eq()),_=B.useRef(x);_.current=x;const y=B.useCallback(S=>{S.preventDefault();const C=S.clientX,T=_.current;let E=T;const $=O=>{E=Math.min(i4,Math.max(n4,T+(O.clientX-C))),k(E)},N=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",N),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(dE,String(E))}catch{}};window.addEventListener("pointermove",$),window.addEventListener("pointerup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),w=B.useCallback(()=>{k(fE);try{localStorage.setItem(dE,String(fE))}catch{}},[]);return c.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative transition-[width] duration-150",style:{width:l?jq:x},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[c.jsx(Oq,{tab:h,onNewSession:n,rail:l,onToggleRail:u}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto pb-3",style:{paddingInline:l?"4px":"8px"},children:c.jsxs(c.Fragment,{children:[!l&&c.jsx(f1,{label:"Workspace",collapsed:i.has("Workspace"),count:oN.length,onToggle:()=>a("Workspace")}),(l||!i.has("Workspace"))&&oN.map(S=>c.jsx(uN,{item:S,active:e===S.key,live:S.liveKind?b[S.liveKind]:!1,onClick:()=>r(S.key),rail:l},S.key)),!l&&c.jsx(f1,{label:"Configure",collapsed:i.has("Configure"),count:lN.length,onToggle:()=>a("Configure")}),(l||!i.has("Configure"))&&lN.map(S=>c.jsx(uN,{item:S,active:e===S.key,live:!1,onClick:()=>r(S.key),rail:l},S.key)),!l&&c.jsx(f1,{label:"Tools",collapsed:i.has("Tools"),count:cN.length,onToggle:()=>a("Tools")}),(l||!i.has("Tools"))&&cN.map(S=>c.jsx(Mq,{tool:S,active:e===S.key,onClick:()=>r(S.key),rail:l},S.key))]})}),c.jsx(Iq,{rail:l}),!l&&c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:y,onDoubleClick:w,className:"absolute top-0 right-0 h-full w-1.5 translate-x-1/2 z-10 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"})]})}function Oq({tab:e,onNewSession:r,rail:n,onToggleRail:i}){const s=(e==null?void 0:e.label)??"no session",a=Rq((e==null?void 0:e.cwd)??null);return n?c.jsxs("div",{className:"flex flex-col items-center gap-1.5 pt-2 pb-2 border-b border-rule",children:[c.jsx("button",{onClick:r,"data-testid":"tour-new-session",title:"New session",className:"w-9 h-9 rounded-md bg-bg-hi border border-line text-fg hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center",children:c.jsx(oi,{name:"plus",size:15,stroke:1.8})}),c.jsx("button",{onClick:i,title:"Expand sidebar","data-testid":"sidebar-rail-toggle",className:"w-9 h-9 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:c.jsx("span",{style:{display:"inline-flex",transform:"rotate(0deg)"},children:c.jsx(oi,{name:"chevron",size:15,stroke:1.8})})})]}):c.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),c.jsx("button",{onClick:i,title:"Collapse sidebar","data-testid":"sidebar-rail-toggle",className:"w-6 h-6 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:c.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:c.jsx(oi,{name:"chevron",size:13,stroke:1.8})})})]}),c.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[c.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),c.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(e==null?void 0:e.cwd)??"",children:s})]}),c.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:a?`⌥${a}`:e?e.cwd:"—"}),c.jsxs("div",{className:"mt-3 flex items-stretch gap-1.5",children:[c.jsxs("button",{onClick:r,"data-testid":"tour-new-session",className:"flex-1 px-3 py-1.5 rounded-md bg-bg-hi border border-line text-fg text-[12.5px] font-medium hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center gap-1.5",children:[c.jsx(oi,{name:"plus",size:13,stroke:1.8}),"New session"]}),c.jsx("div",{className:"flex items-center rounded-md bg-bg-hi border border-line",children:c.jsx(r4,{})})]})]})}const vx=new Map,Pq=3e4;function Rq(e){const[r,n]=B.useState(()=>{var i;return e?((i=vx.get(e))==null?void 0:i.value)??null:null});return B.useEffect(()=>{if(!e){n(null);return}let i=!1;return(async()=>{const a=vx.get(e);if(a&&Date.now()-a.ts<Pq){i||n(a.value);return}try{const l=await window.api.app.gitBranch(e);if(i)return;vx.set(e,{value:l,ts:Date.now()}),n(l)}catch{if(i)return;vx.set(e,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[e]),r}function f1({label:e,collapsed:r,count:n,onToggle:i}){return c.jsxs("button",{onClick:i,"aria-expanded":!r,title:r?`Expand ${e}`:`Collapse ${e}`,className:"group w-full flex items-center gap-1.5 px-3 pt-3.5 pb-1.5 font-serif italic text-[11px] font-bold tracking-[0.07em] uppercase text-fg-faint hover:text-fg-dim transition-colors text-left",children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:r?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),c.jsx("span",{className:"flex-1",children:e}),r&&c.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:n})]})}function uN({item:e,active:r,live:n,onClick:i,rail:s}){return c.jsxs("button",{onClick:i,title:e.hint,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${s?"justify-center px-0 py-[9px]":"gap-3 px-3.5 py-[9px] text-[14px]"} ${r?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[r&&c.jsx("span",{"aria-hidden":!0,className:`absolute top-3 bottom-3 w-[3px] rounded-sm bg-accent ${s?"-left-[4px]":"-left-[10px]"}`}),c.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:c.jsx(oi,{name:e.icon,size:17,stroke:1.6})}),!s&&c.jsx("span",{className:"flex-1 truncate",children:e.label}),!s&&n&&c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"}),s&&n&&c.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"})]})}function Mq({tool:e,active:r,onClick:n,rail:i}){return c.jsxs("button",{onClick:n,title:e.hint,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${i?"justify-center px-0 py-[7px]":"gap-3 px-3.5 py-[7px] text-[13px]"} ${r?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[r&&c.jsx("span",{"aria-hidden":!0,className:`absolute top-2 bottom-2 w-[3px] rounded-sm bg-accent ${i?"-left-[4px]":"-left-[10px]"}`}),c.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:c.jsx(oi,{name:e.icon,size:15,stroke:1.6})}),!i&&c.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function Iq({rail:e}){const r=Rt(o=>o.isRecording),n=Gt(o=>o.tabs),i=Gt(o=>o.activeTabId),s=n.find(o=>o.id===i)??null,[a,l]=B.useState(null);return B.useEffect(()=>{let o=!1;if(!(s!=null&&s.presetId)){l(null);return}return I5(s.presetId).then(u=>{o||l((u==null?void 0:u.model)??null)}).catch(()=>{o||l(null)}),()=>{o=!0}},[s==null?void 0:s.presetId]),e?c.jsx("div",{className:"py-2.5 border-t border-rule flex justify-center",children:c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-red-500 animate-pulse":"bg-sage"}`,title:r?"recording":"idle"})}):c.jsxs("div",{className:"px-3.5 py-2.5 border-t border-rule flex items-center gap-2 text-[11.5px] text-fg-dim font-mono",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-red-500 animate-pulse":"bg-sage"}`,title:r?"recording":"idle"}),c.jsx("span",{className:"truncate",title:a??"",children:r?"recording…":a?`Claude · ${Dq(a)}`:"Claude Code"})]})}function Dq(e){var n,i,s,a,l,o;const r=e.toLowerCase();if(r.includes("opus")){const u=(i=(n=e.match(/(\d+[-.]?\d*)/))==null?void 0:n[1])==null?void 0:i.replace("-",".");return u?`Opus ${u}`:"Opus"}if(r.includes("sonnet")){const u=(a=(s=e.match(/(\d+[-.]?\d*)/))==null?void 0:s[1])==null?void 0:a.replace("-",".");return u?`Sonnet ${u}`:"Sonnet"}if(r.includes("haiku")){const u=(o=(l=e.match(/(\d+[-.]?\d*)/))==null?void 0:l[1])==null?void 0:o.replace("-",".");return u?`Haiku ${u}`:"Haiku"}return e}function Lq({onNavigate:e}){const r=Gt(T=>T.tabs),n=Gt(T=>T.activeTabId),i=r.find(T=>T.id===n)??null,s=z5(i),a=(s==null?void 0:s.lastEventAt)??0,l=vp(T=>T.data),o=ku(T=>{var E;return((E=T.snapshot)==null?void 0:E.paused)??null}),[u,f]=B.useState(null),[,m]=B.useState(0);B.useEffect(()=>{const T=setInterval(()=>m(E=>E+1),6e4);return()=>clearInterval(T)},[]),B.useEffect(()=>{let T=!1;if(!(i!=null&&i.cwd)){f(null);return}return window.api.app.gitBranch(i.cwd).then(E=>{T||f(E)}).catch(()=>{T||f(null)}),()=>{T=!0}},[i==null?void 0:i.cwd]);const h=(s==null?void 0:s.todos)??[],[b,x]=B.useState(!1),k=B.useRef(null);B.useEffect(()=>{if(!b)return;const T=E=>{k.current&&!k.current.contains(E.target)&&x(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[b]),B.useEffect(()=>{h.length===0&&x(!1)},[h.length]);const _=Yw(l),y=(_==null?void 0:_.usage.five_hour)??null,w=y?Math.round(y.utilization):null,S=(l==null?void 0:l.kind)==="ok"||(l==null?void 0:l.kind)==="ok-stale",C=a>0?Fq(Date.now()-a):"—";return c.jsxs("div",{className:"h-[30px] shrink-0 bg-bg-elev border-t border-line flex items-center gap-4 px-[18px] font-mono text-[11.5px] text-fg-dim","data-testid":"tour-statusbar",children:[c.jsxs("button",{onClick:()=>e==null?void 0:e("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:S?"Connected to Anthropic":"Disconnected",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${S?"bg-sage":"bg-fg-faint"}`}),c.jsx("span",{children:S?"connected":"offline"})]}),c.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:w!=null?`${w}% of 5h window used`:"5h —"}),o&&c.jsxs("button",{onClick:()=>e==null?void 0:e("scheduler"),title:"Scheduler is paused — click to open Scheduler",className:`flex items-center gap-1 px-1.5 py-0.5 rounded border font-mono text-[10.5px] transition-colors ${o.reason==="auth"||o.reason==="network"?"border-red-700/60 text-red-300 hover:bg-red-900/20":"border-amber-700/60 text-amber-300 hover:bg-amber-900/20"}`,children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",o.reason]}),i&&c.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,u&&c.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",u]})]}),c.jsxs("span",{className:"text-fg-faint",children:["last activity: ",c.jsx("span",{className:"text-fg-dim",children:C})]}),h.length>0&&c.jsx(Bq,{ref:k,todos:h,open:b,onToggle:()=>x(T=>!T)}),c.jsx("span",{className:"flex-1"}),c.jsxs("span",{className:"text-fg-faint",children:["v","0.29.0"]})]})}const Bq=B.forwardRef(function({todos:r,open:n,onToggle:i},s){const a={completed:r.filter(l=>l.status==="completed").length,in_progress:r.filter(l=>l.status==="in_progress").length,pending:r.filter(l=>l.status==="pending").length};return c.jsxs("div",{ref:s,className:"relative",children:[c.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:"Live to-dos for this session","data-testid":"footer-todos",children:[c.jsxs("span",{className:"text-green-400",children:["✓",a.completed]}),c.jsxs("span",{className:"text-accent",children:["●",a.in_progress]}),c.jsxs("span",{className:"text-fg-dim",children:["○",a.pending]}),c.jsxs("span",{className:"text-fg-faint",children:["todos ",n?"▾":"▴"]})]}),n&&c.jsx("div",{className:"absolute bottom-full left-0 mb-1.5 w-80 max-h-72 overflow-auto bg-bg-elev border border-line rounded shadow-xl p-2 z-50","data-testid":"footer-todos-popover",children:c.jsx("ul",{className:"space-y-0.5",children:r.map((l,o)=>c.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${l.status==="in_progress"?"bg-bg-hi":""}`,children:[c.jsx(zq,{status:l.status}),c.jsx("span",{className:l.status==="completed"?"text-fg-faint line-through":l.status==="in_progress"?"text-fg":"text-fg-dim",children:l.status==="in_progress"&&l.activeForm?l.activeForm:l.content})]},o))})})]})});function zq({status:e}){return e==="completed"?c.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):e==="in_progress"?c.jsx("span",{className:"w-3 shrink-0",children:c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):c.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function Fq(e){const r=Math.max(0,Math.floor(e/1e3));if(r<60)return`${r}s ago`;const n=Math.floor(r/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}var h1={exports:{}},dN;function Uq(){return dN||(dN=1,(function(e,r){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(l,o,u){var f=this&&this.__decorate||function(S,C,T,E){var $,N=arguments.length,O=N<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,T):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(S,C,T,E);else for(var I=S.length-1;I>=0;I--)($=S[I])&&(O=(N<3?$(O):N>3?$(C,T,O):$(C,T))||O);return N>3&&O&&Object.defineProperty(C,T,O),O},m=this&&this.__param||function(S,C){return function(T,E){C(T,E,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const h=u(9042),b=u(9924),x=u(844),k=u(4725),_=u(2585),y=u(3656);let w=o.AccessibilityManager=class extends x.Disposable{constructor(S,C,T,E){super(),this._terminal=S,this._coreBrowserService=T,this._renderService=E,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let $=0;$<this._terminal.rows;$++)this._rowElements[$]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[$]);if(this._topBoundaryFocusListener=$=>this._handleBoundaryFocus($,0),this._bottomBoundaryFocusListener=$=>this._handleBoundaryFocus($,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new b.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(($=>this._handleResize($.rows)))),this.register(this._terminal.onRender(($=>this._refreshRows($.start,$.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar(($=>this._handleChar($)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
2895
+ */var U$;function LU(){return U$||(U$=1,(function(e,r){var n=(()=>{var i=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,l=Object.prototype.hasOwnProperty,o=(se=>typeof Wa<"u"?Wa:typeof Proxy<"u"?new Proxy(se,{get:(he,be)=>(typeof Wa<"u"?Wa:he)[be]}):se)(function(se){if(typeof Wa<"u")return Wa.apply(this,arguments);throw Error('Dynamic require of "'+se+'" is not supported')}),u=(se,he)=>()=>(se&&(he=se(se=0)),he),f=(se,he)=>{for(var be in he)i(se,be,{get:he[be],enumerable:!0})},m=(se,he,be,Ne)=>{if(he&&typeof he=="object"||typeof he=="function")for(let Ee of a(he))!l.call(se,Ee)&&Ee!==be&&i(se,Ee,{get:()=>he[Ee],enumerable:!(Ne=s(he,Ee))||Ne.enumerable});return se},h=se=>m(i({},"__esModule",{value:!0}),se),b,x,k,_,y,w=u(()=>{b=new Map,x=[],k=(se,he,be)=>{if(he&&typeof he.init=="function"&&typeof he.createInferenceSessionHandler=="function"){let Ne=b.get(se);if(Ne===void 0)b.set(se,{backend:he,priority:be});else{if(Ne.priority>be)return;if(Ne.priority===be&&Ne.backend!==he)throw new Error(`cannot register backend "${se}" using priority ${be}`)}if(be>=0){let Ee=x.indexOf(se);Ee!==-1&&x.splice(Ee,1);for(let ze=0;ze<x.length;ze++)if(b.get(x[ze]).priority<=be){x.splice(ze,0,se);return}x.push(se)}return}throw new TypeError("not a valid backend")},_=async se=>{let he=b.get(se);if(!he)return"backend not found.";if(he.initialized)return he.backend;if(he.aborted)return he.error;{let be=!!he.initPromise;try{return be||(he.initPromise=he.backend.init(se)),await he.initPromise,he.initialized=!0,he.backend}catch(Ne){return be||(he.error=`${Ne}`,he.aborted=!0),he.error}finally{delete he.initPromise}}},y=async se=>{let he=se.executionProviders||[],be=he.map(Ue=>typeof Ue=="string"?Ue:Ue.name),Ne=be.length===0?x:be,Ee,ze=[],Pe=new Set;for(let Ue of Ne){let et=await _(Ue);typeof et=="string"?ze.push({name:Ue,err:et}):(Ee||(Ee=et),Ee===et&&Pe.add(Ue))}if(!Ee)throw new Error(`no available backend found. ERR: ${ze.map(Ue=>`[${Ue.name}] ${Ue.err}`).join(", ")}`);for(let{name:Ue,err:et}of ze)be.includes(Ue)&&console.warn(`removing requested execution provider "${Ue}" from session options because it is not available: ${et}`);let Re=he.filter(Ue=>Pe.has(typeof Ue=="string"?Ue:Ue.name));return[Ee,new Proxy(se,{get:(Ue,et)=>et==="executionProviders"?Re:Reflect.get(Ue,et)})]}}),S=u(()=>{w()}),C,T=u(()=>{C="1.26.0"}),E,$,N=u(()=>{T(),E="warning",$={wasm:{},webgl:{},webgpu:{},versions:{common:C},set logLevel(se){if(se!==void 0){if(typeof se!="string"||["verbose","info","warning","error","fatal"].indexOf(se)===-1)throw new Error(`Unsupported logging level: ${se}`);E=se}},get logLevel(){return E}},Object.defineProperty($,"logLevel",{enumerable:!0})}),O,I=u(()=>{N(),O=$}),W,H,V=u(()=>{W=(se,he)=>{let be=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);be.width=se.dims[3],be.height=se.dims[2];let Ne=be.getContext("2d");if(Ne!=null){let Ee,ze;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(Ee=se.dims[2],ze=se.dims[3]):(Ee=se.dims[3],ze=se.dims[2]);let Pe=(he==null?void 0:he.format)!==void 0?he.format:"RGB",Re=he==null?void 0:he.norm,Ue,et;Re===void 0||Re.mean===void 0?Ue=[255,255,255,255]:typeof Re.mean=="number"?Ue=[Re.mean,Re.mean,Re.mean,Re.mean]:(Ue=[Re.mean[0],Re.mean[1],Re.mean[2],0],Re.mean[3]!==void 0&&(Ue[3]=Re.mean[3])),Re===void 0||Re.bias===void 0?et=[0,0,0,0]:typeof Re.bias=="number"?et=[Re.bias,Re.bias,Re.bias,Re.bias]:(et=[Re.bias[0],Re.bias[1],Re.bias[2],0],Re.bias[3]!==void 0&&(et[3]=Re.bias[3]));let at=ze*Ee,tt=0,Ye=at,$t=at*2,Le=-1;Pe==="RGBA"?(tt=0,Ye=at,$t=at*2,Le=at*3):Pe==="RGB"?(tt=0,Ye=at,$t=at*2):Pe==="RBG"&&(tt=0,$t=at,Ye=at*2);for(let ht=0;ht<ze;ht++)for(let Pr=0;Pr<Ee;Pr++){let Qt=(se.data[tt++]-et[0])*Ue[0],Zt=(se.data[Ye++]-et[1])*Ue[1],Rr=(se.data[$t++]-et[2])*Ue[2],Dt=Le===-1?255:(se.data[Le++]-et[3])*Ue[3];Ne.fillStyle="rgba("+Qt+","+Zt+","+Rr+","+Dt+")",Ne.fillRect(Pr,ht,1,1)}if("toDataURL"in be)return be.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},H=(se,he)=>{let be=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Ne;if(be!=null){let Ee,ze,Pe;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(Ee=se.dims[2],ze=se.dims[1],Pe=se.dims[3]):(Ee=se.dims[3],ze=se.dims[2],Pe=se.dims[1]);let Re=he!==void 0&&he.format!==void 0?he.format:"RGB",Ue=he==null?void 0:he.norm,et,at;Ue===void 0||Ue.mean===void 0?et=[255,255,255,255]:typeof Ue.mean=="number"?et=[Ue.mean,Ue.mean,Ue.mean,Ue.mean]:(et=[Ue.mean[0],Ue.mean[1],Ue.mean[2],255],Ue.mean[3]!==void 0&&(et[3]=Ue.mean[3])),Ue===void 0||Ue.bias===void 0?at=[0,0,0,0]:typeof Ue.bias=="number"?at=[Ue.bias,Ue.bias,Ue.bias,Ue.bias]:(at=[Ue.bias[0],Ue.bias[1],Ue.bias[2],0],Ue.bias[3]!==void 0&&(at[3]=Ue.bias[3]));let tt=ze*Ee;if(he!==void 0&&(he.format!==void 0&&Pe===4&&he.format!=="RGBA"||Pe===3&&he.format!=="RGB"&&he.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Ye=4,$t=0,Le=1,ht=2,Pr=3,Qt=0,Zt=tt,Rr=tt*2,Dt=-1;Re==="RGBA"?(Qt=0,Zt=tt,Rr=tt*2,Dt=tt*3):Re==="RGB"?(Qt=0,Zt=tt,Rr=tt*2):Re==="RBG"&&(Qt=0,Rr=tt,Zt=tt*2),Ne=be.createImageData(Ee,ze);for(let Lr=0;Lr<ze*Ee;$t+=Ye,Le+=Ye,ht+=Ye,Pr+=Ye,Lr++)Ne.data[$t]=(se.data[Qt++]-at[0])*et[0],Ne.data[Le]=(se.data[Zt++]-at[1])*et[1],Ne.data[ht]=(se.data[Rr++]-at[2])*et[2],Ne.data[Pr]=Dt===-1?255:(se.data[Dt++]-at[3])*et[3]}else throw new Error("Can not access image data");return Ne}}),U,D,G,ee,ae,oe,J=u(()=>{xe(),U=(se,he)=>{if(se===void 0)throw new Error("Image buffer must be defined");if(he.height===void 0||he.width===void 0)throw new Error("Image height and width must be defined");if(he.tensorLayout==="NHWC")throw new Error("NHWC Tensor layout is not supported yet");let{height:be,width:Ne}=he,Ee=he.norm??{mean:255,bias:0},ze,Pe;typeof Ee.mean=="number"?ze=[Ee.mean,Ee.mean,Ee.mean,Ee.mean]:ze=[Ee.mean[0],Ee.mean[1],Ee.mean[2],Ee.mean[3]??255],typeof Ee.bias=="number"?Pe=[Ee.bias,Ee.bias,Ee.bias,Ee.bias]:Pe=[Ee.bias[0],Ee.bias[1],Ee.bias[2],Ee.bias[3]??0];let Re=he.format!==void 0?he.format:"RGBA",Ue=he.tensorFormat!==void 0&&he.tensorFormat!==void 0?he.tensorFormat:"RGB",et=be*Ne,at=Ue==="RGBA"?new Float32Array(et*4):new Float32Array(et*3),tt=4,Ye=0,$t=1,Le=2,ht=3,Pr=0,Qt=et,Zt=et*2,Rr=-1;Re==="RGB"&&(tt=3,Ye=0,$t=1,Le=2,ht=-1),Ue==="RGBA"?Rr=et*3:Ue==="RBG"?(Pr=0,Zt=et,Qt=et*2):Ue==="BGR"&&(Zt=0,Qt=et,Pr=et*2);for(let Dt=0;Dt<et;Dt++,Ye+=tt,Le+=tt,$t+=tt,ht+=tt)at[Pr++]=(se[Ye]+Pe[0])/ze[0],at[Qt++]=(se[$t]+Pe[1])/ze[1],at[Zt++]=(se[Le]+Pe[2])/ze[2],Rr!==-1&&ht!==-1&&(at[Rr++]=(se[ht]+Pe[3])/ze[3]);return Ue==="RGBA"?new ie("float32",at,[1,4,be,Ne]):new ie("float32",at,[1,3,be,Ne])},D=async(se,he)=>{let be=typeof HTMLImageElement<"u"&&se instanceof HTMLImageElement,Ne=typeof ImageData<"u"&&se instanceof ImageData,Ee=typeof ImageBitmap<"u"&&se instanceof ImageBitmap,ze=typeof se=="string",Pe,Re=he??{},Ue=()=>{if(typeof document<"u")return document.createElement("canvas");if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(1,1);throw new Error("Canvas is not supported")},et=at=>typeof HTMLCanvasElement<"u"&&at instanceof HTMLCanvasElement||at instanceof OffscreenCanvas?at.getContext("2d"):null;if(be){let at=Ue();at.width=se.width,at.height=se.height;let tt=et(at);if(tt!=null){let Ye=se.height,$t=se.width;if(he!==void 0&&he.resizedHeight!==void 0&&he.resizedWidth!==void 0&&(Ye=he.resizedHeight,$t=he.resizedWidth),he!==void 0){if(Re=he,he.tensorFormat!==void 0)throw new Error("Image input config format must be RGBA for HTMLImageElement");Re.tensorFormat="RGBA",Re.height=Ye,Re.width=$t}else Re.tensorFormat="RGBA",Re.height=Ye,Re.width=$t;tt.drawImage(se,0,0),Pe=tt.getImageData(0,0,$t,Ye).data}else throw new Error("Can not access image data")}else if(Ne){let at,tt;if(he!==void 0&&he.resizedWidth!==void 0&&he.resizedHeight!==void 0?(at=he.resizedHeight,tt=he.resizedWidth):(at=se.height,tt=se.width),he!==void 0&&(Re=he),Re.format="RGBA",Re.height=at,Re.width=tt,he!==void 0){let Ye=Ue();Ye.width=tt,Ye.height=at;let $t=et(Ye);if($t!=null)$t.putImageData(se,0,0),Pe=$t.getImageData(0,0,tt,at).data;else throw new Error("Can not access image data")}else Pe=se.data}else if(Ee){if(he===void 0)throw new Error("Please provide image config with format for Imagebitmap");let at=Ue();at.width=se.width,at.height=se.height;let tt=et(at);if(tt!=null){let Ye=se.height,$t=se.width;return tt.drawImage(se,0,0,$t,Ye),Pe=tt.getImageData(0,0,$t,Ye).data,Re.height=Ye,Re.width=$t,U(Pe,Re)}else throw new Error("Can not access image data")}else{if(ze)return new Promise((at,tt)=>{let Ye=Ue(),$t=et(Ye);if(!se||!$t)return tt();let Le=new Image;Le.crossOrigin="Anonymous",Le.src=se,Le.onload=()=>{Ye.width=Le.width,Ye.height=Le.height,$t.drawImage(Le,0,0,Ye.width,Ye.height);let ht=$t.getImageData(0,0,Ye.width,Ye.height);Re.height=Ye.height,Re.width=Ye.width,at(U(ht.data,Re))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Pe!==void 0)return U(Pe,Re);throw new Error("Input data provided is not supported - aborted tensor creation")},G=(se,he)=>{let{width:be,height:Ne,download:Ee,dispose:ze}=he,Pe=[1,Ne,be,4];return new ie({location:"texture",type:"float32",texture:se,dims:Pe,download:Ee,dispose:ze})},ee=(se,he)=>{let{dataType:be,dims:Ne,download:Ee,dispose:ze}=he;return new ie({location:"gpu-buffer",type:be??"float32",gpuBuffer:se,dims:Ne,download:Ee,dispose:ze})},ae=(se,he)=>{let{dataType:be,dims:Ne,download:Ee,dispose:ze}=he;return new ie({location:"ml-tensor",type:be??"float32",mlTensor:se,dims:Ne,download:Ee,dispose:ze})},oe=(se,he,be)=>new ie({location:"cpu-pinned",type:se,data:he,dims:be??[he.length]})}),X,Z,ne,ce,ge=u(()=>{X=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),Z=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ne=!1,ce=()=>{if(!ne){ne=!0;let se=typeof BigInt64Array<"u"&&BigInt64Array.from,he=typeof BigUint64Array<"u"&&BigUint64Array.from,be=globalThis.Float16Array,Ne=typeof be<"u"&&be.from;se&&(X.set("int64",BigInt64Array),Z.set(BigInt64Array,"int64")),he&&(X.set("uint64",BigUint64Array),Z.set(BigUint64Array,"uint64")),Ne?(X.set("float16",be),Z.set(be,"float16")):X.set("float16",Uint16Array)}}}),_e,Te,ye=u(()=>{xe(),_e=se=>{let he=1;for(let be=0;be<se.length;be++){let Ne=se[be];if(typeof Ne!="number"||!Number.isSafeInteger(Ne))throw new TypeError(`dims[${be}] must be an integer, got: ${Ne}`);if(Ne<0)throw new RangeError(`dims[${be}] must be a non-negative integer, got: ${Ne}`);he*=Ne}return he},Te=(se,he)=>{switch(se.location){case"cpu":return new ie(se.type,se.data,he);case"cpu-pinned":return new ie({location:"cpu-pinned",data:se.data,type:se.type,dims:he});case"texture":return new ie({location:"texture",texture:se.texture,type:se.type,dims:he});case"gpu-buffer":return new ie({location:"gpu-buffer",gpuBuffer:se.gpuBuffer,type:se.type,dims:he});case"ml-tensor":return new ie({location:"ml-tensor",mlTensor:se.mlTensor,type:se.type,dims:he});default:throw new Error(`tensorReshape: tensor location ${se.location} is not supported`)}}}),ie,xe=u(()=>{V(),J(),ge(),ye(),ie=class{constructor(se,he,be){ce();let Ne,Ee;if(typeof se=="object"&&"location"in se)switch(this.dataLocation=se.location,Ne=se.type,Ee=se.dims,se.location){case"cpu-pinned":{let Pe=X.get(Ne);if(!Pe)throw new TypeError(`unsupported type "${Ne}" to create tensor from pinned buffer`);if(!(se.data instanceof Pe))throw new TypeError(`buffer should be of type ${Pe.name}`);this.cpuData=se.data;break}case"texture":{if(Ne!=="float32")throw new TypeError(`unsupported type "${Ne}" to create tensor from texture`);this.gpuTextureData=se.texture,this.downloader=se.download,this.disposer=se.dispose;break}case"gpu-buffer":{if(Ne!=="float32"&&Ne!=="float16"&&Ne!=="int32"&&Ne!=="int64"&&Ne!=="uint32"&&Ne!=="uint8"&&Ne!=="bool"&&Ne!=="uint4"&&Ne!=="int4")throw new TypeError(`unsupported type "${Ne}" to create tensor from gpu buffer`);this.gpuBufferData=se.gpuBuffer,this.downloader=se.download,this.disposer=se.dispose;break}case"ml-tensor":{if(Ne!=="float32"&&Ne!=="float16"&&Ne!=="int32"&&Ne!=="int64"&&Ne!=="uint32"&&Ne!=="uint64"&&Ne!=="int8"&&Ne!=="uint8"&&Ne!=="bool"&&Ne!=="uint4"&&Ne!=="int4")throw new TypeError(`unsupported type "${Ne}" to create tensor from MLTensor`);this.mlTensorData=se.mlTensor,this.downloader=se.download,this.disposer=se.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Pe,Re;if(typeof se=="string")if(Ne=se,Re=be,se==="string"){if(!Array.isArray(he))throw new TypeError("A string tensor's data must be a string array.");Pe=he}else{let Ue=X.get(se);if(Ue===void 0)throw new TypeError(`Unsupported tensor type: ${se}.`);if(Array.isArray(he)){if(se==="float16"&&Ue===Uint16Array||se==="uint4"||se==="int4")throw new TypeError(`Creating a ${se} tensor from number array is not supported. Please use ${Ue.name} as data.`);se==="uint64"||se==="int64"?Pe=Ue.from(he,BigInt):Pe=Ue.from(he)}else if(he instanceof Ue)Pe=he;else if(he instanceof Uint8ClampedArray)if(se==="uint8")Pe=Uint8Array.from(he);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(se==="float16"&&he instanceof Uint16Array&&Ue!==Uint16Array)Pe=new globalThis.Float16Array(he.buffer,he.byteOffset,he.length);else throw new TypeError(`A ${Ne} tensor's data must be type of ${Ue}`)}else if(Re=he,Array.isArray(se)){if(se.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Ue=typeof se[0];if(Ue==="string")Ne="string",Pe=se;else if(Ue==="boolean")Ne="bool",Pe=Uint8Array.from(se);else throw new TypeError(`Invalid element type of data array: ${Ue}.`)}else if(se instanceof Uint8ClampedArray)Ne="uint8",Pe=Uint8Array.from(se);else{let Ue=Z.get(se.constructor);if(Ue===void 0)throw new TypeError(`Unsupported type for tensor data: ${se.constructor}.`);Ne=Ue,Pe=se}if(Re===void 0)Re=[Pe.length];else if(!Array.isArray(Re))throw new TypeError("A tensor's dims must be a number array");Ee=Re,this.cpuData=Pe,this.dataLocation="cpu"}let ze=_e(Ee);if(this.cpuData&&ze!==this.cpuData.length&&!((Ne==="uint4"||Ne==="int4")&&Math.ceil(ze/2)===this.cpuData.length))throw new Error(`Tensor's size(${ze}) does not match data length(${this.cpuData.length}).`);this.type=Ne,this.dims=Ee,this.size=ze}static async fromImage(se,he){return D(se,he)}static fromTexture(se,he){return G(se,he)}static fromGpuBuffer(se,he){return ee(se,he)}static fromMLTensor(se,he){return ae(se,he)}static fromPinnedBuffer(se,he,be){return oe(se,he,be)}toDataURL(se){return W(this,se)}toImageData(se){return H(this,se)}get data(){if(this.ensureValid(),!this.cpuData)throw new Error("The data is not on CPU. Use `getData()` to download GPU data to CPU, or use `texture` or `gpuBuffer` property to access the GPU data directly.");return this.cpuData}get location(){return this.dataLocation}get texture(){if(this.ensureValid(),!this.gpuTextureData)throw new Error("The data is not stored as a WebGL texture.");return this.gpuTextureData}get gpuBuffer(){if(this.ensureValid(),!this.gpuBufferData)throw new Error("The data is not stored as a WebGPU buffer.");return this.gpuBufferData}get mlTensor(){if(this.ensureValid(),!this.mlTensorData)throw new Error("The data is not stored as a WebNN MLTensor.");return this.mlTensorData}async getData(se){switch(this.ensureValid(),this.dataLocation){case"cpu":case"cpu-pinned":return this.data;case"texture":case"gpu-buffer":case"ml-tensor":{if(!this.downloader)throw new Error("The current tensor is not created with a specified data downloader.");if(this.isDownloading)throw new Error("The current tensor is being downloaded.");try{this.isDownloading=!0;let he=await this.downloader();return this.downloader=void 0,this.dataLocation="cpu",this.cpuData=he,se&&this.disposer&&(this.disposer(),this.disposer=void 0),he}finally{this.isDownloading=!1}}default:throw new Error(`cannot get data from location: ${this.dataLocation}`)}}dispose(){if(this.isDownloading)throw new Error("The current tensor is being downloaded.");this.disposer&&(this.disposer(),this.disposer=void 0),this.cpuData=void 0,this.gpuTextureData=void 0,this.gpuBufferData=void 0,this.mlTensorData=void 0,this.downloader=void 0,this.isDownloading=void 0,this.dataLocation="none"}ensureValid(){if(this.dataLocation==="none")throw new Error("The tensor is disposed.")}reshape(se){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return Te(this,se)}}}),we,Ve=u(()=>{xe(),we=ie}),Me,We,Be,Ze,dt,ut,or=u(()=>{N(),Me=(se,he)=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeStamp(`${se}::ORT::${he}`)},We=(se,he)=>{var Ee;let be=((Ee=new Error().stack)==null?void 0:Ee.split(/\r\n|\r|\n/g))||[],Ne=!1;for(let ze=0;ze<be.length;ze++){if(Ne&&!be[ze].includes("TRACE_FUNC")){let Pe=`FUNC_${se}::${be[ze].trim().split(" ")[1]}`;he&&(Pe+=`::${he}`),Me("CPU",Pe);return}be[ze].includes("TRACE_FUNC")&&(Ne=!0)}},Be=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||We("BEGIN",se)},Ze=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||We("END",se)},dt=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.time(`ORT::${se}`)},ut=se=>{(typeof $.trace>"u"?!$.wasm.trace:!$.trace)||console.timeEnd(`ORT::${se}`)}}),Xt,ir=u(()=>{w(),Ve(),or(),Xt=class G5{constructor(he){this.handler=he}async run(he,be,Ne){Be(),dt("InferenceSession.run");let Ee={},ze={};if(typeof he!="object"||he===null||he instanceof we||Array.isArray(he))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Pe=!0;if(typeof be=="object"){if(be===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(be instanceof we)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(be)){if(be.length===0)throw new TypeError("'fetches' cannot be an empty array.");Pe=!1;for(let et of be){if(typeof et!="string")throw new TypeError("'fetches' must be a string array or an object.");if(this.outputNames.indexOf(et)===-1)throw new RangeError(`'fetches' contains invalid output name: ${et}.`);Ee[et]=null}if(typeof Ne=="object"&&Ne!==null)ze=Ne;else if(typeof Ne<"u")throw new TypeError("'options' must be an object.")}else{let et=!1,at=Object.getOwnPropertyNames(be);for(let tt of this.outputNames)if(at.indexOf(tt)!==-1){let Ye=be[tt];(Ye===null||Ye instanceof we)&&(et=!0,Pe=!1,Ee[tt]=Ye)}if(et){if(typeof Ne=="object"&&Ne!==null)ze=Ne;else if(typeof Ne<"u")throw new TypeError("'options' must be an object.")}else ze=be}}else if(typeof be<"u")throw new TypeError("Unexpected argument[1]: must be 'fetches' or 'options'.");for(let et of this.inputNames)if(typeof he[et]>"u")throw new Error(`input '${et}' is missing in 'feeds'.`);if(Pe)for(let et of this.outputNames)Ee[et]=null;let Re=await this.handler.run(he,Ee,ze),Ue={};for(let et in Re)if(Object.hasOwnProperty.call(Re,et)){let at=Re[et];at instanceof we?Ue[et]=at:Ue[et]=new we(at.type,at.data,at.dims)}return ut("InferenceSession.run"),Ze(),Ue}async release(){return this.handler.dispose()}static async create(he,be,Ne,Ee){Be(),dt("InferenceSession.create");let ze,Pe={};if(typeof he=="string"){if(ze=he,typeof be=="object"&&be!==null)Pe=be;else if(typeof be<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof Uint8Array){if(ze=he,typeof be=="object"&&be!==null)Pe=be;else if(typeof be<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&he instanceof SharedArrayBuffer){let at=he,tt=0,Ye=he.byteLength;if(typeof be=="object"&&be!==null)Pe=be;else if(typeof be=="number"){if(tt=be,!Number.isSafeInteger(tt))throw new RangeError("'byteOffset' must be an integer.");if(tt<0||tt>=at.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${at.byteLength}).`);if(Ye=he.byteLength-tt,typeof Ne=="number"){if(Ye=Ne,!Number.isSafeInteger(Ye))throw new RangeError("'byteLength' must be an integer.");if(Ye<=0||tt+Ye>at.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${at.byteLength-tt}].`);if(typeof Ee=="object"&&Ee!==null)Pe=Ee;else if(typeof Ee<"u")throw new TypeError("'options' must be an object.")}else if(typeof Ne<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof be<"u")throw new TypeError("'options' must be an object.");ze=new Uint8Array(at,tt,Ye)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[Re,Ue]=await y(Pe),et=await Re.createInferenceSessionHandler(ze,Ue);return ut("InferenceSession.create"),Ze(),new G5(et)}startProfiling(){this.handler.startProfiling()}endProfiling(){this.handler.endProfiling()}get inputNames(){return this.handler.inputNames}get outputNames(){return this.handler.outputNames}get inputMetadata(){return this.handler.inputMetadata}get outputMetadata(){return this.handler.outputMetadata}}}),sr,Or=u(()=>{ir(),sr=Xt}),Ar=u(()=>{}),en=u(()=>{}),Ur=u(()=>{}),Ni=u(()=>{}),ui={};f(ui,{InferenceSession:()=>sr,TRACE:()=>Me,TRACE_EVENT_BEGIN:()=>dt,TRACE_EVENT_END:()=>ut,TRACE_FUNC_BEGIN:()=>Be,TRACE_FUNC_END:()=>Ze,Tensor:()=>we,env:()=>O,registerBackend:()=>k});var hr=u(()=>{S(),I(),Or(),Ve(),Ar(),en(),or(),Ur(),Ni()}),Tn=u(()=>{}),lt={};f(lt,{default:()=>br});var wt,bt,br,mn=u(()=>{var se;jl(),hi(),Oi(),wt="ort-wasm-proxy-worker",bt=((se=globalThis.self)==null?void 0:se.name)===wt,bt&&(self.onmessage=he=>{let{type:be,in:Ne}=he.data;try{switch(be){case"init-wasm":as(Ne.wasm).then(()=>{qn(Ne).then(()=>{postMessage({type:be})},Ee=>{postMessage({type:be,err:Ee})})},Ee=>{postMessage({type:be,err:Ee})});break;case"init-ep":{let{epName:Ee,env:ze}=Ne;ls(ze,Ee).then(()=>{postMessage({type:be})},Pe=>{postMessage({type:be,err:Pe})});break}case"copy-from":{let{buffer:Ee}=Ne,ze=lr(Ee);postMessage({type:be,out:ze});break}case"create":{let{model:Ee,options:ze}=Ne;us(Ee,ze).then(Pe=>{postMessage({type:be,out:Pe})},Pe=>{postMessage({type:be,err:Pe})});break}case"release":Fo(Ne),postMessage({type:be});break;case"run":{let{sessionId:Ee,inputIndices:ze,inputs:Pe,outputIndices:Re,options:Ue}=Ne;Je(Ee,ze,Pe,Re,new Array(Re.length).fill(null),Ue).then(et=>{et.some(at=>at[3]!=="cpu")?postMessage({type:be,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:be,out:et},Cc([...Pe,...et]))},et=>{postMessage({type:be,err:et})});break}case"end-profiling":Ps(Ne),postMessage({type:be});break;default:}}catch(Ee){postMessage({type:be,err:Ee})}}),br=bt?null:he=>new Worker(he??Er,{type:"classic",name:wt})}),Ki,ss,Er,Xi,di,zn,Yn,fi,xa,wa,_a,As,Lo,Oi=u(()=>{Tn(),Ki=typeof location>"u"?void 0:location.origin,ss=()=>{var se,he;return typeof document<"u"?(se=document.currentScript)==null?void 0:se.src:typeof self<"u"?(he=self.location)==null?void 0:he.href:void 0},Er=ss(),Xi=()=>{if(Er&&!Er.startsWith("blob:"))return Er.substring(0,Er.lastIndexOf("/")+1)},di=(se,he)=>{try{let be=he??Er;return(be?new URL(se,be):new URL(se)).origin===Ki}catch{return!1}},zn=(se,he)=>{let be=he??Er;try{return(be?new URL(se,be):new URL(se)).href}catch{return}},Yn=(se,he)=>`${he??"./"}${se}`,fi=async se=>{let he=await(await fetch(se,{credentials:"same-origin"})).blob();return URL.createObjectURL(he)},xa=async se=>(await import(se)).default,wa=(mn(),h(lt)).default,_a=async()=>{if(!Er)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(di(Er))return[void 0,wa()];let se=await fi(Er);return[se,wa(se)]},As=void 0,Lo=async(se,he,be,Ne)=>{let Ee=As&&!(se||he);if(Ee)if(Er)Ee=di(Er)||Ne&&!be;else if(Ne&&!be)Ee=!0;else throw new Error("cannot determine the script source URL.");if(Ee)return[void 0,As];{let ze="ort-wasm-simd-threaded.mjs",Pe=se??zn(ze,he),Re=be&&Pe&&!di(Pe,he),Ue=Re?await fi(Pe):Pe??Yn(ze,he);return[Re?Ue:void 0,await xa(Ue)]}}}),Sa,Pi,gr,Fn,Cl,$s,Ns,as,qt,hi=u(()=>{Oi(),Pi=!1,gr=!1,Fn=!1,Cl=()=>{if(typeof SharedArrayBuffer>"u")return!1;try{return typeof MessageChannel<"u"&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch{return!1}},$s=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,30,1,28,0,65,0,253,15,253,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,253,186,1,26,11]))}catch{return!1}},Ns=()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,19,1,17,0,65,1,253,15,65,2,253,15,65,3,253,15,253,147,2,11]))}catch{return!1}},as=async se=>{if(Pi)return Promise.resolve();if(gr)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(Fn)throw new Error("previous call to 'initializeWebAssembly()' failed.");gr=!0;let he=se.initTimeout,be=se.numThreads;if(se.simd!==!1){if(se.simd==="relaxed"){if(!Ns())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!$s())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Ne=Cl();be>1&&!Ne&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+be+", but this will not work unless you enable crossOriginIsolated mode. See https://web.dev/cross-origin-isolation-guide/ for more info."),console.warn("WebAssembly multi-threading is not supported in the current environment. Falling back to single-threading."),se.numThreads=be=1);let Ee=se.wasmPaths,ze=typeof Ee=="string"?Ee:void 0,Pe=Ee==null?void 0:Ee.mjs,Re=(Pe==null?void 0:Pe.href)??Pe,Ue=Ee==null?void 0:Ee.wasm,et=(Ue==null?void 0:Ue.href)??Ue,at=se.wasmBinary,[tt,Ye]=await Lo(Re,ze,be>1,!!at||!!et),$t=!1,Le=[];if(he>0&&Le.push(new Promise(ht=>{setTimeout(()=>{$t=!0,ht()},he)})),Le.push(new Promise((ht,Pr)=>{let Qt={numThreads:be};if(at)Qt.wasmBinary=at,Qt.locateFile=Zt=>Zt;else if(et||ze)Qt.locateFile=Zt=>et??ze+Zt;else if(Re&&Re.indexOf("blob:")!==0)Qt.locateFile=Zt=>new URL(Zt,Re).href;else if(tt){let Zt=Xi();Zt&&(Qt.locateFile=Rr=>Zt+Rr)}Ye(Qt).then(Zt=>{gr=!1,Pi=!0,Sa=Zt,ht(),tt&&URL.revokeObjectURL(tt)},Zt=>{gr=!1,Fn=!0,Pr(Zt)})})),await Promise.race(Le),$t)throw new Error(`WebAssembly backend initializing failed due to timeout: ${he}ms`)},qt=()=>{if(Pi&&Sa)return Sa;throw new Error("WebAssembly is not initialized yet.")}}),vr,Jn,At,Js=u(()=>{hi(),vr=(se,he)=>{let be=qt(),Ne=be.lengthBytesUTF8(se)+1,Ee=be._malloc(Ne);return be.stringToUTF8(se,Ee,Ne),he.push(Ee),Ee},Jn=(se,he,be,Ne)=>{if(typeof se=="object"&&se!==null){if(be.has(se))throw new Error("Circular reference in options");be.add(se)}Object.entries(se).forEach(([Ee,ze])=>{let Pe=he?he+Ee:Ee;if(typeof ze=="object")Jn(ze,Pe+".",be,Ne);else if(typeof ze=="string"||typeof ze=="number")Ne(Pe,ze.toString());else if(typeof ze=="boolean")Ne(Pe,ze?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof ze}`)})},At=se=>{let he=qt(),be=he.stackSave();try{let Ne=he.PTR_SIZE,Ee=he.stackAlloc(2*Ne);he._OrtGetLastError(Ee,Ee+Ne);let ze=Number(he.getValue(Ee,Ne===4?"i32":"i64")),Pe=he.getValue(Ee+Ne,"*"),Re=Pe?he.UTF8ToString(Pe):"";throw new Error(`${se} ERROR_CODE: ${ze}, ERROR_MESSAGE: ${Re}`)}finally{he.stackRestore(be)}}}),ka,Bo=u(()=>{hi(),Js(),ka=se=>{let he=qt(),be=0,Ne=[],Ee=se||{};try{if((se==null?void 0:se.logSeverityLevel)===void 0)Ee.logSeverityLevel=2;else if(typeof se.logSeverityLevel!="number"||!Number.isInteger(se.logSeverityLevel)||se.logSeverityLevel<0||se.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${se.logSeverityLevel}`);if((se==null?void 0:se.logVerbosityLevel)===void 0)Ee.logVerbosityLevel=0;else if(typeof se.logVerbosityLevel!="number"||!Number.isInteger(se.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${se.logVerbosityLevel}`);(se==null?void 0:se.terminate)===void 0&&(Ee.terminate=!1);let ze=0;return(se==null?void 0:se.tag)!==void 0&&(ze=vr(se.tag,Ne)),be=he._OrtCreateRunOptions(Ee.logSeverityLevel,Ee.logVerbosityLevel,!!Ee.terminate,ze),be===0&&At("Can't create run options."),(se==null?void 0:se.extra)!==void 0&&Jn(se.extra,"",new WeakSet,(Pe,Re)=>{let Ue=vr(Pe,Ne),et=vr(Re,Ne);he._OrtAddRunConfigEntry(be,Ue,et)!==0&&At(`Can't set a run config entry: ${Pe} - ${Re}.`)}),[be,Ne]}catch(ze){throw be!==0&&he._OrtReleaseRunOptions(be),Ne.forEach(Pe=>he._free(Pe)),ze}}}),os,Qs,pi,An,zo,El,qr=u(()=>{hi(),Js(),os=se=>{switch(se){case"disabled":return 0;case"basic":return 1;case"extended":return 2;case"layout":return 3;case"all":return 99;default:throw new Error(`unsupported graph optimization level: ${se}`)}},Qs=se=>{switch(se){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${se}`)}},pi=se=>{se.extra||(se.extra={}),se.extra.session||(se.extra.session={});let he=se.extra.session;he.use_ort_model_bytes_directly||(he.use_ort_model_bytes_directly="1"),se.executionProviders&&se.executionProviders.some(be=>(typeof be=="string"?be:be.name)==="webgpu")&&(se.enableMemPattern=!1)},An=(se,he,be,Ne)=>{let Ee=vr(he,Ne),ze=vr(be,Ne);qt()._OrtAddSessionConfigEntry(se,Ee,ze)!==0&&At(`Can't set a session config entry: ${he} - ${be}.`)},zo=async(se,he,be)=>{let Ne=he.executionProviders;for(let Ee of Ne){let ze=typeof Ee=="string"?Ee:Ee.name,Pe=[];switch(ze){case"webnn":if(ze="WEBNN",An(se,"session.disable_quant_qdq","1",be),An(se,"session.disable_qdq_constant_folding","1",be),typeof Ee!="string"){let tt=Ee==null?void 0:Ee.deviceType;tt&&An(se,"deviceType",tt,be)}break;case"webgpu":if(ze="JS",typeof Ee!="string"){let tt=Ee;if(tt!=null&&tt.preferredLayout){if(tt.preferredLayout!=="NCHW"&&tt.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${tt.preferredLayout}`);An(se,"preferredLayout",tt.preferredLayout,be)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${ze}`)}let Re=vr(ze,be),Ue=Pe.length,et=0,at=0;if(Ue>0){et=qt()._malloc(Ue*qt().PTR_SIZE),be.push(et),at=qt()._malloc(Ue*qt().PTR_SIZE),be.push(at);for(let tt=0;tt<Ue;tt++)qt().setValue(et+tt*qt().PTR_SIZE,Pe[tt][0],"*"),qt().setValue(at+tt*qt().PTR_SIZE,Pe[tt][1],"*")}await qt()._OrtAppendExecutionProvider(se,Re,et,at,Ue)!==0&&At(`Can't append execution provider: ${ze}.`)}},El=async se=>{let he=qt(),be=0,Ne=[],Ee=se||{};pi(Ee);try{let ze=os(Ee.graphOptimizationLevel??"all"),Pe=Qs(Ee.executionMode??"sequential"),Re=typeof Ee.logId=="string"?vr(Ee.logId,Ne):0,Ue=Ee.logSeverityLevel??2;if(!Number.isInteger(Ue)||Ue<0||Ue>4)throw new Error(`log severity level is not valid: ${Ue}`);let et=Ee.logVerbosityLevel??0;if(!Number.isInteger(et)||et<0||et>4)throw new Error(`log verbosity level is not valid: ${et}`);let at=typeof Ee.optimizedModelFilePath=="string"?vr(Ee.optimizedModelFilePath,Ne):0;if(be=he._OrtCreateSessionOptions(ze,!!Ee.enableCpuMemArena,!!Ee.enableMemPattern,Pe,!!Ee.enableProfiling,0,Re,Ue,et,at),be===0&&At("Can't create session options."),Ee.executionProviders&&await zo(be,Ee,Ne),Ee.enableGraphCapture!==void 0){if(typeof Ee.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${Ee.enableGraphCapture}`);An(be,"enableGraphCapture",Ee.enableGraphCapture.toString(),Ne)}if(Ee.freeDimensionOverrides)for(let[tt,Ye]of Object.entries(Ee.freeDimensionOverrides)){if(typeof tt!="string")throw new Error(`free dimension override name must be a string: ${tt}`);if(typeof Ye!="number"||!Number.isInteger(Ye)||Ye<0)throw new Error(`free dimension override value must be a non-negative integer: ${Ye}`);let $t=vr(tt,Ne);he._OrtAddFreeDimensionOverride(be,$t,Ye)!==0&&At(`Can't set a free dimension override: ${tt} - ${Ye}.`)}return Ee.extra!==void 0&&Jn(Ee.extra,"",new WeakSet,(tt,Ye)=>{An(be,tt,Ye,Ne)}),[be,Ne]}catch(ze){throw be!==0&&he._OrtReleaseSessionOptions(be)!==0&&At("Can't release session options."),Ne.forEach(Pe=>he._free(Pe)),ze}}}),Qn,gn,dn,Et,Se,rt,_t,nr,pt=u(()=>{Qn=se=>{switch(se){case"int8":return 3;case"uint8":return 2;case"bool":return 9;case"int16":return 5;case"uint16":return 4;case"int32":return 6;case"uint32":return 12;case"float16":return 10;case"float32":return 1;case"float64":return 11;case"string":return 8;case"int64":return 7;case"uint64":return 13;case"int4":return 22;case"uint4":return 21;default:throw new Error(`unsupported data type: ${se}`)}},gn=se=>{switch(se){case 3:return"int8";case 2:return"uint8";case 9:return"bool";case 5:return"int16";case 4:return"uint16";case 6:return"int32";case 12:return"uint32";case 10:return"float16";case 1:return"float32";case 11:return"float64";case 8:return"string";case 7:return"int64";case 13:return"uint64";case 22:return"int4";case 21:return"uint4";default:throw new Error(`unsupported data type: ${se}`)}},dn=(se,he)=>{let be=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][se],Ne=typeof he=="number"?he:he.reduce((Ee,ze)=>Ee*ze,1);return be>0?Math.ceil(Ne*be):void 0},Et=se=>{switch(se){case"float16":return typeof Float16Array<"u"&&Float16Array.from?Float16Array:Uint16Array;case"float32":return Float32Array;case"uint8":return Uint8Array;case"int8":return Int8Array;case"uint16":return Uint16Array;case"int16":return Int16Array;case"int32":return Int32Array;case"bool":return Uint8Array;case"float64":return Float64Array;case"uint32":return Uint32Array;case"int64":return BigInt64Array;case"uint64":return BigUint64Array;default:throw new Error(`unsupported type: ${se}`)}},Se=se=>{switch(se){case"verbose":return 0;case"info":return 1;case"warning":return 2;case"error":return 3;case"fatal":return 4;default:throw new Error(`unsupported logging level: ${se}`)}},rt=se=>se==="float32"||se==="float16"||se==="int32"||se==="int64"||se==="uint32"||se==="uint8"||se==="bool"||se==="uint4"||se==="int4",_t=se=>se==="float32"||se==="float16"||se==="int32"||se==="int64"||se==="uint32"||se==="uint64"||se==="int8"||se==="uint8"||se==="bool"||se==="uint4"||se==="int4",nr=se=>{switch(se){case"none":return 0;case"cpu":return 1;case"cpu-pinned":return 2;case"texture":return 3;case"gpu-buffer":return 4;case"ml-tensor":return 5;default:throw new Error(`unsupported data location: ${se}`)}}}),ar,Yr=u(()=>{Tn(),ar=async se=>{if(typeof se=="string"){let he=await fetch(se);if(!he.ok)throw new Error(`failed to load external data file: ${se}`);let be=he.headers.get("Content-Length"),Ne=be?parseInt(be,10):0;if(Ne<1073741824)return new Uint8Array(await he.arrayBuffer());{if(!he.body)throw new Error(`failed to load external data file: ${se}, no response body.`);let Ee=he.body.getReader(),ze;try{ze=new ArrayBuffer(Ne)}catch(Re){if(Re instanceof RangeError){let Ue=Math.ceil(Ne/65536);ze=new WebAssembly.Memory({initial:Ue,maximum:Ue}).buffer}else throw Re}let Pe=0;for(;;){let{done:Re,value:Ue}=await Ee.read();if(Re)break;let et=Ue.byteLength;new Uint8Array(ze,Pe,et).set(Ue),Pe+=et}return new Uint8Array(ze,0,Ne)}}else return se instanceof Blob?new Uint8Array(await se.arrayBuffer()):se instanceof Uint8Array?se:new Uint8Array(se)}}),Un,qn,ls,jr,cs,Os,lr,us,Fo,Zs,Je,Ps,Cc,jl=u(()=>{hr(),Bo(),qr(),pt(),hi(),Js(),Yr(),Un=(se,he)=>{qt()._OrtInit(se,he)!==0&&At("Can't initialize onnxruntime.")},qn=async se=>{Un(se.wasm.numThreads,Se(se.logLevel))},ls=async(se,he)=>{var Ne,Ee;(Ee=(Ne=qt()).asyncInit)==null||Ee.call(Ne);let be=se.webgpu.adapter;if(he==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(be){if(typeof be.limits!="object"||typeof be.features!="object"||typeof be.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let ze=se.webgpu.powerPreference;if(ze!==void 0&&ze!=="low-power"&&ze!=="high-performance")throw new Error(`Invalid powerPreference setting: "${ze}"`);let Pe=se.webgpu.forceFallbackAdapter;if(Pe!==void 0&&typeof Pe!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Pe}"`);if(be=await navigator.gpu.requestAdapter({powerPreference:ze,forceFallbackAdapter:Pe}),!be)throw new Error('Failed to get GPU adapter. You may need to enable flag "--enable-unsafe-webgpu" if you are using Chrome.')}}if(he==="webnn"&&(typeof navigator>"u"||!navigator.ml))throw new Error("WebNN is not supported in current environment")},jr=new Map,cs=se=>{let he=qt(),be=he.stackSave();try{let Ne=he.PTR_SIZE,Ee=he.stackAlloc(2*Ne);he._OrtGetInputOutputCount(se,Ee,Ee+Ne)!==0&&At("Can't get session input/output count.");let ze=Ne===4?"i32":"i64";return[Number(he.getValue(Ee,ze)),Number(he.getValue(Ee+Ne,ze))]}finally{he.stackRestore(be)}},Os=(se,he)=>{let be=qt(),Ne=be.stackSave(),Ee=0;try{let ze=be.PTR_SIZE,Pe=be.stackAlloc(2*ze);be._OrtGetInputOutputMetadata(se,he,Pe,Pe+ze)!==0&&At("Can't get session input/output metadata.");let Re=Number(be.getValue(Pe,"*"));Ee=Number(be.getValue(Pe+ze,"*"));let Ue=be.HEAP32[Ee/4];if(Ue===0)return[Re,0];let et=be.HEAPU32[Ee/4+1],at=[];for(let tt=0;tt<et;tt++){let Ye=Number(be.getValue(Ee+8+tt*ze,"*"));at.push(Ye!==0?be.UTF8ToString(Ye):Number(be.getValue(Ee+8+(tt+et)*ze,"*")))}return[Re,Ue,at]}finally{be.stackRestore(Ne),Ee!==0&&be._OrtFree(Ee)}},lr=se=>{let he=qt(),be=he._malloc(se.byteLength);if(be===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${se.byteLength}.`);return he.HEAPU8.set(se,be),[be,se.byteLength]},us=async(se,he)=>{var at,tt,Ye;let be,Ne,Ee=qt();Array.isArray(se)?[be,Ne]=se:se.buffer===Ee.HEAPU8.buffer?[be,Ne]=[se.byteOffset,se.byteLength]:[be,Ne]=lr(se);let ze=0,Pe=0,Re=[],Ue=[],et=[];try{if([Pe,Re]=await El(he),(he==null?void 0:he.externalData)&&Ee.mountExternalData){let Lr=[];for(let fr of he.externalData){let $n=typeof fr=="string"?fr:fr.path;Lr.push(ar(typeof fr=="string"?fr:fr.data).then(ei=>{Ee.mountExternalData($n,ei)}))}await Promise.all(Lr)}for(let Lr of(he==null?void 0:he.executionProviders)??[])if((typeof Lr=="string"?Lr:Lr.name)==="webnn"){if(Ee.shouldTransferToMLTensor=!1,typeof Lr!="string"){let fr=Lr,$n=fr==null?void 0:fr.context,ei=fr==null?void 0:fr.gpuDevice,mi=fr==null?void 0:fr.deviceType,Al=fr==null?void 0:fr.powerPreference;$n?Ee.currentContext=$n:ei?Ee.currentContext=await Ee.webnnCreateMLContext(ei):Ee.currentContext=await Ee.webnnCreateMLContext({deviceType:mi,powerPreference:Al})}else Ee.currentContext=await Ee.webnnCreateMLContext();break}ze=await Ee._OrtCreateSession(be,Ne,Pe),(at=Ee.webgpuOnCreateSession)==null||at.call(Ee,ze),ze===0&&At("Can't create a session."),(tt=Ee.jsepOnCreateSession)==null||tt.call(Ee),Ee.currentContext&&(Ee.webnnRegisterMLContext(ze,Ee.currentContext),Ee.currentContext=void 0,Ee.shouldTransferToMLTensor=!0);let[$t,Le]=cs(ze),ht=!!(he!=null&&he.enableGraphCapture),Pr=[],Qt=[],Zt=[],Rr=[],Dt=[];for(let Lr=0;Lr<$t;Lr++){let[fr,$n,ei]=Os(ze,Lr);fr===0&&At("Can't get an input name."),Ue.push(fr);let mi=Ee.UTF8ToString(fr);Pr.push(mi),Zt.push($n===0?{name:mi,isTensor:!1}:{name:mi,isTensor:!0,type:gn($n),shape:ei})}for(let Lr=0;Lr<Le;Lr++){let[fr,$n,ei]=Os(ze,Lr+$t);fr===0&&At("Can't get an output name."),et.push(fr);let mi=Ee.UTF8ToString(fr);Qt.push(mi),Rr.push($n===0?{name:mi,isTensor:!1}:{name:mi,isTensor:!0,type:gn($n),shape:ei})}return jr.set(ze,[ze,Ue,et,null,ht,!1]),[ze,Pr,Qt,Zt,Rr]}catch($t){throw Ue.forEach(Le=>Ee._OrtFree(Le)),et.forEach(Le=>Ee._OrtFree(Le)),ze!==0&&Ee._OrtReleaseSession(ze)!==0&&At("Can't release session."),$t}finally{Ee._free(be),Pe!==0&&Ee._OrtReleaseSessionOptions(Pe)!==0&&At("Can't release session options."),Re.forEach($t=>Ee._free($t)),(Ye=Ee.unmountExternalData)==null||Ye.call(Ee)}},Fo=se=>{var Ue,et,at;let he=qt(),be=jr.get(se);if(!be)throw new Error(`cannot release session. invalid session id: ${se}`);let[Ne,Ee,ze,Pe,Re]=be;Pe&&(Re&&he._OrtClearBoundOutputs(Pe.handle)!==0&&At("Can't clear bound outputs."),he._OrtReleaseBinding(Pe.handle)!==0&&At("Can't release IO binding.")),(Ue=he.jsepOnReleaseSession)==null||Ue.call(he,se),(et=he.webnnOnReleaseSession)==null||et.call(he,se),(at=he.webgpuOnReleaseSession)==null||at.call(he,se),Ee.forEach(tt=>he._OrtFree(tt)),ze.forEach(tt=>he._OrtFree(tt)),he._OrtReleaseSession(Ne)!==0&&At("Can't release session."),jr.delete(se)},Zs=async(se,he,be,Ne,Ee,ze,Pe=!1)=>{if(!se){he.push(0);return}let Re=qt(),Ue=Re.PTR_SIZE,et=se[0],at=se[1],tt=se[3],Ye=tt,$t,Le;if(et==="string"&&(tt==="gpu-buffer"||tt==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Pe&&tt!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${ze} when enableGraphCapture is true.`);if(tt==="gpu-buffer"){let Qt=se[2].gpuBuffer;Le=dn(Qn(et),at);{let Zt=Re.jsepRegisterBuffer;if(!Zt)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');$t=Zt(Ne,ze,Qt,Le)}}else if(tt==="ml-tensor"){let Qt=se[2].mlTensor;Le=dn(Qn(et),at);let Zt=Re.webnnRegisterMLTensor;if(!Zt)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');$t=Zt(Ne,Qt,Qn(et),at)}else{let Qt=se[2];if(Array.isArray(Qt)){Le=Ue*Qt.length,$t=Re._malloc(Le),be.push($t);for(let Zt=0;Zt<Qt.length;Zt++){if(typeof Qt[Zt]!="string")throw new TypeError(`tensor data at index ${Zt} is not a string`);Re.setValue($t+Zt*Ue,vr(Qt[Zt],be),"*")}}else{let Zt=Re.webnnIsGraphInput,Rr=Re.webnnIsGraphOutput;if(et!=="string"&&Zt&&Rr){let Dt=Re.UTF8ToString(Ee);if(Zt(Ne,Dt)||Rr(Ne,Dt)){let Lr=Qn(et);Le=dn(Lr,at),Ye="ml-tensor";let fr=Re.webnnCreateTemporaryTensor,$n=Re.webnnUploadTensor;if(!fr||!$n)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let ei=await fr(Ne,Lr,at);$n(ei,new Uint8Array(Qt.buffer,Qt.byteOffset,Qt.byteLength)),$t=ei}else Le=Qt.byteLength,$t=Re._malloc(Le),be.push($t),Re.HEAPU8.set(new Uint8Array(Qt.buffer,Qt.byteOffset,Le),$t)}else Le=Qt.byteLength,$t=Re._malloc(Le),be.push($t),Re.HEAPU8.set(new Uint8Array(Qt.buffer,Qt.byteOffset,Le),$t)}}let ht=Re.stackSave(),Pr=Re.stackAlloc(4*at.length);try{at.forEach((Zt,Rr)=>Re.setValue(Pr+Rr*Ue,Zt,Ue===4?"i32":"i64"));let Qt=Re._OrtCreateTensor(Qn(et),$t,Le,Pr,at.length,nr(Ye));Qt===0&&At(`Can't create tensor for input/output. session=${Ne}, index=${ze}.`),he.push(Qt)}finally{Re.stackRestore(ht)}},Je=async(se,he,be,Ne,Ee,ze)=>{var gi,$c,Lu;let Pe=qt(),Re=Pe.PTR_SIZE,Ue=jr.get(se);if(!Ue)throw new Error(`cannot run inference. invalid session id: ${se}`);let et=Ue[0],at=Ue[1],tt=Ue[2],Ye=Ue[3],$t=Ue[4];Ue[5];let Le=he.length,ht=Ne.length,Pr=0,Qt=[],Zt=[],Rr=[],Dt=[],Lr=[],fr=Pe.stackSave(),$n=Pe.stackAlloc(Le*Re),ei=Pe.stackAlloc(Le*Re),mi=Pe.stackAlloc(ht*Re),Al=Pe.stackAlloc(ht*Re);try{[Pr,Qt]=ka(ze),dt("wasm prepareInputOutputTensor");for(let cr=0;cr<Le;cr++)await Zs(be[cr],Zt,Dt,se,at[he[cr]],he[cr],$t);for(let cr=0;cr<ht;cr++)await Zs(Ee[cr],Rr,Dt,se,tt[Ne[cr]],Le+Ne[cr],$t);ut("wasm prepareInputOutputTensor");for(let cr=0;cr<Le;cr++)Pe.setValue($n+cr*Re,Zt[cr],"*"),Pe.setValue(ei+cr*Re,at[he[cr]],"*");for(let cr=0;cr<ht;cr++)Pe.setValue(mi+cr*Re,Rr[cr],"*"),Pe.setValue(Al+cr*Re,tt[Ne[cr]],"*");(gi=Pe.jsepOnRunStart)==null||gi.call(Pe,et),($c=Pe.webnnOnRunStart)==null||$c.call(Pe,et);let Nn;Nn=await Pe._OrtRun(et,ei,$n,Le,Al,ht,mi,Pr),Nn!==0&&At("failed to call OrtRun().");let Ms=[],Bu=[];dt("wasm ProcessOutputTensor");for(let cr=0;cr<ht;cr++){let hs=Number(Pe.getValue(mi+cr*Re,"*"));if(hs===Rr[cr]||Lr.includes(Rr[cr])){Ms.push(Ee[cr]),hs!==Rr[cr]&&Pe._OrtReleaseTensor(hs)!==0&&At("Can't release tensor.");continue}let vf=Pe.stackSave(),na=Pe.stackAlloc(4*Re),qo=!1,vn,vi=0;try{Pe._OrtGetTensorData(hs,na,na+Re,na+2*Re,na+3*Re)!==0&&At(`Can't access output tensor data on index ${cr}.`);let Nc=Re===4?"i32":"i64",yi=Number(Pe.getValue(na,Nc));vi=Pe.getValue(na+Re,"*");let zu=Pe.getValue(na+Re*2,"*"),yf=Number(Pe.getValue(na+Re*3,Nc)),ia=[];for(let yn=0;yn<yf;yn++)ia.push(Number(Pe.getValue(zu+yn*Re,Nc)));Pe._OrtFree(zu)!==0&&At("Can't free memory for tensor dims.");let ps=ia.reduce((yn,Jr)=>yn*Jr,1);vn=gn(yi);let Is=Ye==null?void 0:Ye.outputPreferredLocations[Ne[cr]];if(vn==="string"){if(Is==="gpu-buffer"||Is==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let yn=[];for(let Jr=0;Jr<ps;Jr++){let ms=Pe.getValue(vi+Jr*Re,"*"),Fu=Pe.getValue(vi+(Jr+1)*Re,"*"),Uu=Jr===ps-1?void 0:Fu-ms;yn.push(Pe.UTF8ToString(ms,Uu))}Ms.push([vn,ia,yn,"cpu"])}else if(Is==="gpu-buffer"&&ps>0){let yn=Pe.jsepGetBuffer;if(!yn)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let Jr=yn(vi),ms=dn(yi,ps);if(ms===void 0||!rt(vn))throw new Error(`Unsupported data type: ${vn}`);qo=!0,Ms.push([vn,ia,{gpuBuffer:Jr,download:Pe.jsepCreateDownloader(Jr,ms,vn),dispose:()=>{Pe._OrtReleaseTensor(hs)!==0&&At("Can't release tensor.")}},"gpu-buffer"])}else if(Is==="ml-tensor"&&ps>0){let yn=Pe.webnnEnsureTensor,Jr=Pe.webnnIsGraphInputOutputTypeSupported;if(!yn||!Jr)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(dn(yi,ps)===void 0||!_t(vn))throw new Error(`Unsupported data type: ${vn}`);if(!Jr(se,vn,!1))throw new Error(`preferredLocation "ml-tensor" for ${vn} output is not supported by current WebNN Context.`);let ms=await yn(se,vi,yi,ia,!1);qo=!0,Ms.push([vn,ia,{mlTensor:ms,download:Pe.webnnCreateMLTensorDownloader(vi,vn),dispose:()=>{Pe.webnnReleaseTensorId(vi),Pe._OrtReleaseTensor(hs)}},"ml-tensor"])}else if(Is==="ml-tensor-cpu-output"&&ps>0){let yn=Pe.webnnCreateMLTensorDownloader(vi,vn)(),Jr=Ms.length;qo=!0,Bu.push((async()=>{let ms=[Jr,await yn];return Pe.webnnReleaseTensorId(vi),Pe._OrtReleaseTensor(hs),ms})()),Ms.push([vn,ia,[],"cpu"])}else{let yn=Et(vn),Jr=new yn(ps);new Uint8Array(Jr.buffer,Jr.byteOffset,Jr.byteLength).set(Pe.HEAPU8.subarray(vi,vi+Jr.byteLength)),Ms.push([vn,ia,Jr,"cpu"])}}finally{Pe.stackRestore(vf),vn==="string"&&vi&&Pe._free(vi),qo||Pe._OrtReleaseTensor(hs)}}Ye&&!$t&&(Pe._OrtClearBoundOutputs(Ye.handle)!==0&&At("Can't clear bound outputs."),jr.set(se,[et,at,tt,Ye,$t,!1]));for(let[cr,hs]of await Promise.all(Bu))Ms[cr][2]=hs;return ut("wasm ProcessOutputTensor"),Ms}finally{(Lu=Pe.webnnOnRunEnd)==null||Lu.call(Pe,et),Pe.stackRestore(fr),Zt.forEach(Nn=>Pe._OrtReleaseTensor(Nn)),Rr.forEach(Nn=>Pe._OrtReleaseTensor(Nn)),Dt.forEach(Nn=>Pe._free(Nn)),Pr!==0&&Pe._OrtReleaseRunOptions(Pr),Qt.forEach(Nn=>Pe._free(Nn))}},Ps=se=>{let he=qt(),be=jr.get(se);if(!be)throw new Error("invalid session id");let Ne=be[0],Ee=he._OrtEndProfiling(Ne);Ee===0&&At("Can't get an profile file name."),he._OrtFree(Ee)},Cc=se=>{let he=[];for(let be of se){let Ne=be[2];!Array.isArray(Ne)&&"buffer"in Ne&&he.push(Ne.buffer)}return he}}),ur,It,ea,Ca,Ea,Za,Uo,eo,Yi,Zn,ds,fs,ja,to,Rs,gf,ro,no,Mu=u(()=>{hr(),jl(),hi(),Oi(),ur=()=>!!O.wasm.proxy&&typeof document<"u",ea=!1,Ca=!1,Ea=!1,eo=new Map,Yi=(se,he)=>{let be=eo.get(se);be?be.push(he):eo.set(se,[he])},Zn=()=>{if(ea||!Ca||Ea||!It)throw new Error("worker not ready")},ds=se=>{switch(se.data.type){case"init-wasm":ea=!1,se.data.err?(Ea=!0,Uo[1](se.data.err)):(Ca=!0,Uo[0]()),Za&&(URL.revokeObjectURL(Za),Za=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let he=eo.get(se.data.type);se.data.err?he.shift()[1](se.data.err):he.shift()[0](se.data.out);break}}},fs=async()=>{if(!Ca){if(ea)throw new Error("multiple calls to 'initWasm()' detected.");if(Ea)throw new Error("previous call to 'initWasm()' failed.");if(ea=!0,ur())return new Promise((se,he)=>{It==null||It.terminate(),_a().then(([be,Ne])=>{try{It=Ne,It.onerror=ze=>he(ze),It.onmessage=ds,Uo=[se,he];let Ee={type:"init-wasm",in:O};if(!Ee.in.wasm.wasmPaths&&be){let ze=Xi();ze&&(Ee.in.wasm.wasmPaths=ze)}It.postMessage(Ee),Za=be}catch(Ee){he(Ee)}},he)});try{await as(O.wasm),await qn(O),Ca=!0}catch(se){throw Ea=!0,se}finally{ea=!1}}},ja=async se=>{if(ur())return Zn(),new Promise((he,be)=>{Yi("init-ep",[he,be]);let Ne={type:"init-ep",in:{epName:se,env:O}};It.postMessage(Ne)});await ls(O,se)},to=async se=>ur()?(Zn(),new Promise((he,be)=>{Yi("copy-from",[he,be]);let Ne={type:"copy-from",in:{buffer:se}};It.postMessage(Ne,[se.buffer])})):lr(se),Rs=async(se,he)=>{if(ur()){if(he!=null&&he.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return Zn(),new Promise((be,Ne)=>{Yi("create",[be,Ne]);let Ee={type:"create",in:{model:se,options:{...he}}},ze=[];se instanceof Uint8Array&&ze.push(se.buffer),It.postMessage(Ee,ze)})}else return us(se,he)},gf=async se=>{if(ur())return Zn(),new Promise((he,be)=>{Yi("release",[he,be]);let Ne={type:"release",in:se};It.postMessage(Ne)});Fo(se)},ro=async(se,he,be,Ne,Ee,ze)=>{if(ur()){if(be.some(Pe=>Pe[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(Ee.some(Pe=>Pe))throw new Error("pre-allocated output tensor is not supported for proxy.");return Zn(),new Promise((Pe,Re)=>{Yi("run",[Pe,Re]);let Ue=be,et={type:"run",in:{sessionId:se,inputIndices:he,inputs:Ue,outputIndices:Ne,options:ze}};It.postMessage(et,Cc(Ue))})}else return Je(se,he,be,Ne,Ee,ze)},no=async se=>{if(ur())return Zn(),new Promise((he,be)=>{Yi("end-profiling",[he,be]);let Ne={type:"end-profiling",in:se};It.postMessage(Ne)});Ps(se)}}),Ec,io,Tl,jc=u(()=>{hr(),Mu(),pt(),Tn(),Yr(),Ec=(se,he)=>{switch(se.location){case"cpu":return[se.type,se.dims,se.data,"cpu"];case"gpu-buffer":return[se.type,se.dims,{gpuBuffer:se.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[se.type,se.dims,{mlTensor:se.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${se.location} for ${he()}`)}},io=se=>{switch(se[3]){case"cpu":return new we(se[0],se[2],se[1]);case"gpu-buffer":{let he=se[0];if(!rt(he))throw new Error(`not supported data type: ${he} for deserializing GPU tensor`);let{gpuBuffer:be,download:Ne,dispose:Ee}=se[2];return we.fromGpuBuffer(be,{dataType:he,dims:se[1],download:Ne,dispose:Ee})}case"ml-tensor":{let he=se[0];if(!_t(he))throw new Error(`not supported data type: ${he} for deserializing MLTensor tensor`);let{mlTensor:be,download:Ne,dispose:Ee}=se[2];return we.fromMLTensor(be,{dataType:he,dims:se[1],download:Ne,dispose:Ee})}default:throw new Error(`invalid data location: ${se[3]}`)}},Tl=class{async fetchModelAndCopyToWasmMemory(se){return to(await ar(se))}async loadModel(se,he){Be();let be;typeof se=="string"?be=await this.fetchModelAndCopyToWasmMemory(se):be=se,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await Rs(be,he),Ze()}async dispose(){return gf(this.sessionId)}async run(se,he,be){Be();let Ne=[],Ee=[];Object.entries(se).forEach(tt=>{let Ye=tt[0],$t=tt[1],Le=this.inputNames.indexOf(Ye);if(Le===-1)throw new Error(`invalid input '${Ye}'`);Ne.push($t),Ee.push(Le)});let ze=[],Pe=[];Object.entries(he).forEach(tt=>{let Ye=tt[0],$t=tt[1],Le=this.outputNames.indexOf(Ye);if(Le===-1)throw new Error(`invalid output '${Ye}'`);ze.push($t),Pe.push(Le)});let Re=Ne.map((tt,Ye)=>Ec(tt,()=>`input "${this.inputNames[Ee[Ye]]}"`)),Ue=ze.map((tt,Ye)=>tt?Ec(tt,()=>`output "${this.outputNames[Pe[Ye]]}"`):null),et=await ro(this.sessionId,Ee,Re,Pe,Ue,be),at={};for(let tt=0;tt<et.length;tt++)at[this.outputNames[Pe[tt]]]=ze[tt]??io(et[tt]);return Ze(),at}startProfiling(){}endProfiling(){no(this.sessionId)}}}),ta={};f(ta,{OnnxruntimeWebAssemblyBackend:()=>ra,initializeFlags:()=>Ta,wasmBackend:()=>so});var Ta,ra,so,Iu=u(()=>{hr(),Mu(),jc(),Ta=()=>{(typeof O.wasm.initTimeout!="number"||O.wasm.initTimeout<0)&&(O.wasm.initTimeout=0);let se=O.wasm.simd;if(typeof se!="boolean"&&se!==void 0&&se!=="fixed"&&se!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${se}". Reset it to \`false\` and ignore SIMD feature checking.`),O.wasm.simd=!1),typeof O.wasm.proxy!="boolean"&&(O.wasm.proxy=!1),typeof O.wasm.trace!="boolean"&&(O.wasm.trace=!1),typeof O.wasm.numThreads!="number"||!Number.isInteger(O.wasm.numThreads)||O.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)O.wasm.numThreads=1;else{let he=typeof navigator>"u"?o("node:os").cpus().length:navigator.hardwareConcurrency;O.wasm.numThreads=Math.min(4,Math.ceil((he||1)/2))}},ra=class{async init(se){Ta(),await fs(),await ja(se)}async createInferenceSessionHandler(se,he){let be=new Tl;return await be.loadModel(se,he),be}},so=new ra}),Du={};f(Du,{InferenceSession:()=>sr,TRACE:()=>Me,TRACE_EVENT_BEGIN:()=>dt,TRACE_EVENT_END:()=>ut,TRACE_FUNC_BEGIN:()=>Be,TRACE_FUNC_END:()=>Ze,Tensor:()=>we,default:()=>Ac,env:()=>O,registerBackend:()=>k}),hr(),hr(),hr();var Tc="1.26.0",Ac=ui;{let se=(Iu(),h(ta)).wasmBackend;k("cpu",se,10),k("wasm",se,10)}return Object.defineProperty(O.versions,"web",{value:Tc,enumerable:!0}),h(Du)})();e.exports=n})(u1)),u1.exports}var q$;function BU(){return q$||(q$=1,(function(e){var r=Ql&&Ql.__createBinding||(Object.create?(function(C,T,E,$){$===void 0&&($=E);var N=Object.getOwnPropertyDescriptor(T,E);(!N||("get"in N?!T.__esModule:N.writable||N.configurable))&&(N={enumerable:!0,get:function(){return T[E]}}),Object.defineProperty(C,$,N)}):(function(C,T,E,$){$===void 0&&($=E),C[$]=T[E]})),n=Ql&&Ql.__setModuleDefault||(Object.create?(function(C,T){Object.defineProperty(C,"default",{enumerable:!0,value:T})}):function(C,T){C.default=T}),i=Ql&&Ql.__importStar||function(C){if(C&&C.__esModule)return C;var T={};if(C!=null)for(var E in C)E!=="default"&&Object.prototype.hasOwnProperty.call(C,E)&&r(T,C,E);return n(T,C),T};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const s=i(LU()),a=bT(),l=xT(),o=qy(),u=Xw(),f=W5(),m=H5();e.DEFAULT_MODEL="legacy",e.ort=s;const h="vad.worklet.bundle.min.js",b="silero_vad_v5.onnx",x="silero_vad_legacy.onnx",k=C=>({...l.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{o.log.debug("VAD misfire")},onSpeechStart:()=>{o.log.debug("Detected speech start")},onSpeechEnd:()=>{o.log.debug("Detected speech end")},onSpeechRealStart:()=>{o.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:C,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(E=>{E.stop()})},resumeStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),ortConfig:T=>{T.env.logLevel="error"},startOnLoad:!0,processorType:"auto"});e.getDefaultRealTimeVADOptions=k;const _=C=>"audioWorklet"in C&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function y(C,T,E,$,N){await E.audioWorklet.addModule(C),T.processorOptions={...T.processorOptions??{},frameSamples:$};const O=new AudioWorkletNode(E,"vad-helper-worklet",T);return O.port.onmessage=async I=>{const W=I.data;if(!(typeof W=="object"&&W&&"message"in W)){console.error("Invalid message event",W);return}switch(W.message){case u.Message.AudioFrame:{if(!("data"in W&&W.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const H=new Float32Array(W.data);await N(H);break}}},O}async function w(C,T,E){const $=new m.Resampler({nativeSampleRate:C.sampleRate,targetSampleRate:16e3,targetFrameSize:T});o.log.debug("using script processor");const O=C.createScriptProcessor(4096,1,1);let I=!1;return O.onaudioprocess=async W=>{if(!I){I=!0;try{const H=W.inputBuffer.getChannelData(0);W.outputBuffer.getChannelData(0).fill(0);const U=$.process(H);for(const D of U)await E(D)}catch(H){console.error("Error processing audio:",H)}finally{I=!1}}},O.connect(C.destination),O}class S{constructor(T,E,$,N,O=!1,I=null,W=null,H=null,V=null,U=null,D=null,G="uninitialized",ee=!1){this.options=T,this.frameProcessor=E,this.model=$,this.frameSamples=N,this.listening=O,this.errored=I,this._stream=W,this._audioContext=H,this._vadNode=V,this._mediaStreamAudioSourceNode=U,this._audioProcessorAdapterType=D,this.initializationState=G,this.ownsAudioContext=ee,this.getAudioInstances=()=>{if(this._stream===null||this._audioContext===null||this._vadNode==null||this._mediaStreamAudioSourceNode==null)throw new Error("MicVAD has null stream, audio context, or processor adapter");return{stream:this._stream,audioContext:this._audioContext,vadNode:this._vadNode,mediaStreamAudioSourceNode:this._mediaStreamAudioSourceNode}},this.setErrored=ae=>{this.initializationState="errored",this.errored=ae},this.start=async()=>{switch(this.initializationState){case"uninitialized":{o.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(ae){throw ae instanceof Error?this.setErrored(ae.message):this.setErrored(String(ae)),ae}if(this.options.audioContext?(console.log("using custom audio context"),this._audioContext=this.options.audioContext):(console.log("using default audio context"),this._audioContext=new AudioContext,this.ownsAudioContext=!0),!this._audioContext)throw this.setErrored("Audio context is null"),Error("Audio context is null");switch(this._audioProcessorAdapterType=this.options.processorType=="auto"?_(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await y(this.options.baseAssetPath+h,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await w(this._audioContext,this.frameSamples,this.processFrame);break;default:throw new Error(`Unsupported audio processor adapter type: ${this._audioProcessorAdapterType}`)}this._mediaStreamAudioSourceNode=new MediaStreamAudioSourceNode(this._audioContext,{mediaStream:this._stream}),this._mediaStreamAudioSourceNode.connect(this._vadNode),o.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{o.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:ae,audioContext:oe,vadNode:J}=this.getAudioInstances();this._stream=await this.options.resumeStream(ae);const X=new MediaStreamAudioSourceNode(oe,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=X,X.connect(J);break}case"destroyed":{o.log.warn("start called after destroyed");break}case"errored":{o.log.error("start called after errored");break}default:{o.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:ae,mediaStreamAudioSourceNode:oe}=this.getAudioInstances();await this.options.pauseStream(ae),oe.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var oe;o.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:ae}=this.getAudioInstances();ae instanceof AudioWorkletNode&&ae.port.postMessage(u.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((oe=this._audioContext)==null?void 0:oe.close())},this.setOptions=ae=>{this.frameProcessor.setOptions(ae)},this.processFrame=async ae=>{await this.frameProcessor.process(ae,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=ae=>{switch(ae.msg){case u.Message.FrameProcessed:this.options.onFrameProcessed(ae.probs,ae.frame);break;case u.Message.SpeechStart:this.options.onSpeechStart();break;case u.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case u.Message.VADMisfire:this.options.onVADMisfire();break;case u.Message.SpeechEnd:this.options.onSpeechEnd(ae.audio);break}}}static async new(T={}){const E={...(0,e.getDefaultRealTimeVADOptions)(T.model??e.DEFAULT_MODEL),...T};(0,l.validateOptions)(E),e.ort.env.wasm.wasmPaths=E.onnxWASMBasePath,E.ortConfig!==void 0&&E.ortConfig(e.ort);const $=E.model==="v5"?b:x,N=E.baseAssetPath+$,O=E.model==="v5"?f.SileroV5.new:f.SileroLegacy.new;let I;try{I=await O(e.ort,()=>(0,a.defaultModelFetcher)(N))}catch(D){throw console.error(`Encountered an error while loading model file ${N}`),D}const W=E.model==="v5"?512:1536,H=W/16,V=new l.FrameProcessor(I.process,I.reset_state,{positiveSpeechThreshold:E.positiveSpeechThreshold,negativeSpeechThreshold:E.negativeSpeechThreshold,redemptionMs:E.redemptionMs,preSpeechPadMs:E.preSpeechPadMs,minSpeechMs:E.minSpeechMs,submitUserSpeechOnPause:E.submitUserSpeechOnPause},H),U=new S(E,V,I,W);if(E.startOnLoad)try{await U.start()}catch(D){throw console.error("Error starting micVad",D),D}return U}}e.MicVAD=S})(Ql)),Ql}var W$;function zU(){return W$||(W$=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getDefaultRealTimeVADOptions=e.MicVAD=e.DEFAULT_MODEL=e.utils=e.NonRealTimeVAD=e.Message=e.FrameProcessor=e.defaultModelFetcher=e.baseAssetPath=void 0;var r=F5();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return r.baseAssetPath}});var n=bT();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return n.defaultModelFetcher}});var i=xT();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var s=Xw();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return s.Message}});var a=IU();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return a.NonRealTimeVAD}});const l=DU();e.utils={audioFileToArray:l.audioFileToArray,minFramesForTargetMS:l.minFramesForTargetMS,arrayBufferToBase64:l.arrayBufferToBase64,encodeWAV:l.encodeWAV};var o=BU();Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return o.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return o.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return o.getDefaultRealTimeVADOptions}})})(o1)),o1}var FU=zU();function lx(e,r,n,i){var a,l;try{(l=(a=window.api)==null?void 0:a.logs)==null||l.write(e,r,n,i)}catch{}const s=r==="error"?console.error:r==="warn"?console.warn:console.log;i!==void 0?s(`[${e}]`,n,i):s(`[${e}]`,n)}const mt={debug:(e,r,n)=>lx(e,"debug",r,n),info:(e,r,n)=>lx(e,"info",r,n),warn:(e,r,n)=>lx(e,"warn",r,n),error:(e,r,n)=>lx(e,"error",r,n)},V5=16e3,UU=6,Xh=V5*UU,qU=400,WU=V5*qU/1e3,H$=300,G$=2e3,V$=1500,K$=3e3,HU=600,K5=.5,X5=.35,X$=.85,Y$=.7;let Vs=null,gl=!1,ks=!1;const iE=new Set;function cx(e){for(const r of Array.from(iE))try{r(e)}catch(n){mt.warn("speech","workerDeath listener threw",{error:n instanceof Error?n.message:String(n)})}}let d1=0;const J$=2;let mp=!1,Y5=!1;function J5(e){e.addEventListener("message",r=>{var i;if(((i=r.data)==null?void 0:i.type)!=="log")return;const n=r.data.level||"info";mt[n]("whisperWorker",r.data.message??"",r.data.meta)}),e.addEventListener("error",r=>{mt.error("whisperWorker","worker error event (fatal)",{message:r.message,filename:r.filename,lineno:r.lineno}),GU(`error:${r.message||"unknown"}`)})}function x0(){return Vs||(Vs=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),J5(Vs),mt.info("speech","worker spawned"),Vs)}let ux=!1;function GU(e){if(!mp){if(ux){mt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(ux=!0,d1+=1,Y5=!0,mt.warn("speech","respawnWorker: starting",{reason:e,attempt:d1}),cx({reason:e,respawned:!1,finalOnly:!0}),d1>J$){if(mp=!0,mt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:J$}),Vs)try{Vs.terminate()}catch{}Vs=null,gl=!1,ks=!1,cx({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),ux=!1;return}if(Vs)try{Vs.terminate()}catch{}Vs=null,gl=!1,ks=!1;try{Vs=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),J5(Vs),ks=!0,Vs.postMessage({type:"load"}),mt.info("speech","respawnWorker: new worker spawned, load posted"),cx({reason:e,respawned:!0,finalOnly:!0})}catch(r){mp=!0,mt.error("speech","respawnWorker: spawn failed, disabling speech",{error:r instanceof Error?r.message:String(r)}),cx({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{ux=!1}}}function VU(e,r){if(gl||ks)return;ks=!0;const n=x0();mt.info("speech","preloadModel: posting load");const i=s=>{s.data.type==="status"?(e==null||e(s.data.status,s.data.message),s.data.status==="ready"&&(gl=!0,ks=!1,mt.info("speech","preloadModel: ready"),n.removeEventListener("message",i))):s.data.type==="progress"?r==null||r(s.data.pct):s.data.type==="error"&&(ks=!1,mt.error("speech","preloadModel: worker reported error",{error:s.data.error}),e==null||e("error",s.data.error),n.removeEventListener("message",i))};n.addEventListener("message",i),n.postMessage({type:"load"})}function KU(){mt.info("speech","resetModel: clearing load flags"),gl=!1,ks=!1}function wT(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function XU(e){const r=x0();return!gl&&!ks&&(ks=!0,r.postMessage({type:"load"})),new Promise((n,i)=>{const s=a=>{var l,o,u;((l=a.data)==null?void 0:l.type)==="result"?(r.removeEventListener("message",s),n((a.data.text??"").trim())):((o=a.data)==null?void 0:o.type)==="error"?(r.removeEventListener("message",s),i(new Error(String(a.data.error??"Transcription failed")))):((u=a.data)==null?void 0:u.type)==="status"&&a.data.status==="ready"&&(gl=!0,ks=!1)};r.addEventListener("message",s),r.postMessage({type:"transcribe",audio:e},[e.buffer])})}function YU(e){let r=x0(),n=!1,i=null,s=null,a=null,l=null,o=null;const u=[],f=new Set;let m=null,h=0,b=!1,x=0,k=!1,_=!1,y=0,w=0,S=0,C=-1,T=H$,E=0,$=null,N="",O="",I=!1,W=0;function H(ce,ge){const _e=Math.min(ce.length,ge.length);let Te=0;for(;Te<_e&&ce.charCodeAt(Te)===ge.charCodeAt(Te);)Te++;return Te}function V(ce){const ge=H(N,ce);return N=ce,ge>O.length&&(O=ce.slice(0,ge)),O.length>ce.length&&(O=ce),O}const U=()=>(m||(m=new Float32Array(Xh)),m),D=()=>{h=0},G=ce=>{const ge=U(),_e=ce.length;if(_e>=Xh){ge.set(ce.subarray(_e-Xh)),h=Xh;return}if(h+_e<=Xh){ge.set(ce,h),h+=_e;return}const Te=h+_e-Xh;ge.copyWithin(0,Te,h),h-=Te,ge.set(ce,h),h+=_e},ee=()=>{$&&(clearTimeout($),$=null)},ae=()=>{ee(),b=!1,k=!1,_=!1,T=H$,N="",O="",I=!1,W=0,D()},oe=()=>{if(n||!b||_||k||$)return;if(h<WU){$=setTimeout(()=>{$=null,oe()},T);return}const ce=performance.now()-y;if(ce<T&&y!==0){$=setTimeout(()=>{$=null,oe()},T-ce);return}if(Y5||mp||e.partialsEnabled&&!e.partialsEnabled())return;const ge=U(),_e=new Float32Array(h);_e.set(ge.subarray(0,h)),w+=1,S=w,k=!0,E=performance.now(),y=E,r.postMessage({type:"transcribe-partial",audio:_e,seq:w},[_e.buffer])},J=ce=>ce.length===0?Promise.resolve():mp?(mt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),n||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(ge=>{u.push(ge),w+=1;const _e=w;C=_e,r.postMessage({type:"transcribe",audio:ce,seq:_e},[ce.buffer])}),X=ce=>{const ge=J(ce);return f.add(ge),ge.finally(()=>{f.delete(ge)}),ge},Z=ce=>{var ge,_e,Te,ye,ie;if(ce.data.type==="result"){const xe=ce.data.text,we=ce.data.seq??0;we&&we<C&&mt.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:we,latestFinalSeq:C}),!n&&xe&&e.onFinal(xe),(ge=u.shift())==null||ge()}else if(ce.data.type==="partial"){const xe=ce.data.seq??0,we=ce.data.text??"",Ve=performance.now()-E;k=!1,Ve>=K$?(_=!0,mt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Ve),seq:xe})):Ve>=V$&&(T=Math.min(T*2,G$),mt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Ve),newIntervalMs:T,seq:xe})),I||(I=!0,Ve>HU&&T<500&&(T=500,mt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Ve),newIntervalMs:500})));const Me=xe!==S||xe<=C;if(!n&&!Me&&we){const We=V(we);We&&((_e=e.onPartial)==null||_e.call(e,We),W===0&&(W=performance.now(),mt.info("speech","partial.first",{msSinceSpeechStart:Math.round(W-x)})))}oe()}else if(ce.data.type==="partial-error"){const xe=performance.now()-E;k=!1,xe>=K$?(_=!0,mt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(xe),seq:ce.data.seq})):xe>=V$&&(T=Math.min(T*2,G$),mt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(xe),newIntervalMs:T,seq:ce.data.seq})),mt.warn("speech","partial encode failed",{error:ce.data.error,seq:ce.data.seq}),oe()}else ce.data.type==="error"?(n||e.onError(ce.data.error),(Te=u.shift())==null||Te()):ce.data.type==="status"?(n||(ye=e.onModelStatus)==null||ye.call(e,ce.data.status,ce.data.message),ce.data.status==="ready"&&(gl=!0,ks=!1)):ce.data.type==="progress"&&(n||(ie=e.onProgress)==null||ie.call(e,ce.data.pct))};r.addEventListener("message",Z);const ne=ce=>{var ge,_e;if(!n){for(mt.warn("speech","createRecognition: worker death event",ce),(ge=e.onStatusChange)==null||ge.call(e,"restarting");u.length;)(_e=u.shift())==null||_e();if(f.clear(),ee(),k=!1,ce.respawned){try{r.removeEventListener("message",Z)}catch{}r=x0(),r.addEventListener("message",Z)}}};return iE.add(ne),{start:async()=>{if(!n){if(mp){e.onError("Speech recognition disabled — please reload the app.");return}!gl&&!ks&&(ks=!0,mt.info("speech","createRecognition.start: triggering model load"),r.postMessage({type:"load"})),mt.info("speech","createRecognition.start: initializing VAD",{modelReady:gl,modelLoading:ks});try{const ce=new URL("vad/",document.baseURI).href,ge=e.inputDeviceId||null,_e={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};ge&&(_e.deviceId={exact:ge}),mt.info("speech","getUserMedia",{hasDeviceId:!!ge,deviceIdPrefix:ge?ge.slice(0,8):null});const Te=await navigator.mediaDevices.getUserMedia({audio:_e});s=Te,a=new AudioContext;for(const ye of Te.getAudioTracks())ye.addEventListener("ended",()=>{n||(mt.warn("speech","mic track ended (permission revoked or device removed)"),e.onError("Microphone disconnected or permission revoked"))});try{o=a.createMediaStreamSource(s),l=a.createAnalyser(),l.fftSize=2048,l.smoothingTimeConstant=.3,o.connect(l)}catch(ye){mt.warn("speech","analyser init failed",{error:ye instanceof Error?ye.message:String(ye)}),o=null,l=null}i=await FU.MicVAD.new({audioContext:a,getStream:async()=>Te,resumeStream:async()=>Te,pauseStream:async()=>{},baseAssetPath:ce,onnxWASMBasePath:ce,model:"v5",positiveSpeechThreshold:K5,negativeSpeechThreshold:X5,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(ye,ie)=>{var xe;n||((xe=e.onFrame)==null||xe.call(e,ye),b&&(G(ie),oe()))},onSpeechStart:()=>{var ye;n||(ae(),b=!0,x=performance.now(),(ye=e.onSpeechStart)==null||ye.call(e))},onSpeechEnd:ye=>{var ie;n||((ie=e.onStatusChange)==null||ie.call(e,"transcribing"),ae(),X(ye))},onVADMisfire:()=>{var ye,ie;n||((ye=e.onStatusChange)==null||ye.call(e,"idle"),ae(),(ie=e.onMisfire)==null||ie.call(e))}}),i.start()}catch(ce){const ge=ce instanceof Error?ce.message:"Microphone access denied",_e=ce instanceof Error?ce.stack:"";if(mt.error("speech","createRecognition.start: VAD init failed",{error:ge,stack:_e}),l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(s){try{s.getTracks().forEach(Te=>Te.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}e.onError(ge)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(ae();f.size>0;)await Promise.all(Array.from(f));if(i){try{await i.destroy()}catch{}i=null}if(l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(s){try{s.getTracks().forEach(ce=>ce.stop())}catch{}s=null}if(a){try{await a.close()}catch{}a=null}},setVadThresholds:(ce,ge)=>{if(i)try{i.setOptions({positiveSpeechThreshold:ce,negativeSpeechThreshold:ge})}catch(_e){mt.warn("speech","setVadThresholds failed",{error:_e instanceof Error?_e.message:String(_e)})}},getAnalyser:()=>l,destroy:()=>{if(n=!0,ae(),i){try{i.destroy()}catch{}i=null}if(l){try{l.disconnect()}catch{}l=null}if(o){try{o.disconnect()}catch{}o=null}if(a){try{a.close()}catch{}a=null}if(s){try{s.getTracks().forEach(ce=>ce.stop())}catch{}s=null}iE.delete(ne),r.removeEventListener("message",Z)}}}let Fv=null;const sE=new Set,aE=new Set;function JU(){for(const e of sE)try{e()}catch{}}function oE(){for(const e of aE)try{e()}catch{}}function QU(e){return e.replace(/```[\s\S]*?```/g,"").replace(/`([^`]+)`/g,"$1").replace(/^#{1,6}\s+/gm,"").replace(/\*{1,3}([^*]+)\*{1,3}/g,"$1").replace(/_{1,3}([^_]+)_{1,3}/g,"$1").replace(/\[([^\]]+)\]\([^)]+\)/g,"$1").replace(/!\[([^\]]*)\]\([^)]+\)/g,"$1").replace(/^[-*_]{3,}\s*$/gm,"").replace(/^>\s?/gm,"").replace(/^[\s]*[-*+]\s/gm,"").replace(/^[\s]*\d+\.\s/gm,"").trim()}function ZU(e){if(!window.speechSynthesis)return;const r=QU(e);if(!r)return;const n=new SpeechSynthesisUtterance(r);n.rate=1,n.pitch=1,n.onstart=()=>{Fv=performance.now(),JU()},n.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Fv=null,oE())},n.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Fv=null,oE())},window.speechSynthesis.speak(n)}function Q5(){window.speechSynthesis&&(window.speechSynthesis.cancel(),Fv=null,oE())}function Z5(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function eq(){return Fv}function tq(e){return sE.add(e),()=>{sE.delete(e)}}function rq(e){return aE.add(e),()=>{aE.delete(e)}}function nq(e){Z5()&&(e.setVadThresholds(X$,Y$),mt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const r=tq(()=>{e.setVadThresholds(X$,Y$),mt.info("voice","tts.duck.on")}),n=rq(()=>{e.setVadThresholds(K5,X5),mt.info("voice","tts.duck.off")});return()=>{r(),n()}}const iq=[{match:/^(send|submit|enter)\.?$/i,data:"\r",label:"send"},{match:/^(cancel|escape)\.?$/i,data:"\x1B",label:"cancel"},{match:/^clear( line)?\.?$/i,data:"",label:"clear"}];function sq(e){const r=e.trim();return iq.find(n=>n.match.test(r))??null}const aq=4e4;let Ud=null;function gp(){Ud&&clearTimeout(Ud),Ud=setTimeout(()=>{Ud=null,Rt.getState().stopRecording()},aq)}function dx(){Ud&&(clearTimeout(Ud),Ud=null)}let vu=null,gu=null;const oq=.04,lq=.3;let w0=0,lE=0;function cq(e){gu!==null&&cancelAnimationFrame(gu);const r=()=>{if(vu===null||Rt.getState().submitCountdownStartAt===null){gu=null;return}const n=performance.now();if(n-lE<200&&w0>lq){const s=n-e;mt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:w0.toFixed(2),msIntoCountdown:Math.round(s)}),fu(),gp();return}const i=e4();if(i){const s=new Uint8Array(i.fftSize);i.getByteTimeDomainData(s);let a=0;for(let o=0;o<s.length;o++){const u=(s[o]-128)/128;a+=u*u}const l=Math.sqrt(a/s.length);if(l>oq){const o=n-e;mt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:l.toFixed(3),msIntoCountdown:Math.round(o)}),fu(),gp();return}}gu=requestAnimationFrame(r)};gu=requestAnimationFrame(r)}function uq(e){vu&&clearTimeout(vu);const r=Rt.getState().submitDelayMs,n=performance.now();Rt.setState({submitCountdownStartAt:n}),vu=setTimeout(()=>{vu=null,Rt.setState({submitCountdownStartAt:null});try{window.api.pty.write({tabId:e,data:"\r"})}catch(i){mt.warn("voice","submit pty.write failed",{error:i instanceof Error?i.message:String(i)})}gp()},r),cq(n)}function fu(){gu!==null&&(cancelAnimationFrame(gu),gu=null),vu&&(clearTimeout(vu),vu=null),Rt.getState().submitCountdownStartAt!==null&&Rt.setState({submitCountdownStartAt:null})}let Ci=null,es=null;function e4(){var e;return((e=Ci==null?void 0:Ci.getAnalyser)==null?void 0:e.call(Ci))??null}const fx=1e4;let Uv=null;function hx(){Uv&&(clearTimeout(Uv),Uv=null)}let o0=null,l0=null;function px(){o0=null,l0&&(l0(),l0=null)}const dq=1500,fq=9e4;let mx=0,c0=null,cE=-1;function gx(){c0&&(clearTimeout(c0),c0=null,cE=-1)}const hq=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Rt=jn((e,r)=>({isRecording:!1,ttsEnabled:!1,autoSubmit:!0,submitDelayMs:8e3,submitCountdownStartAt:null,lastTranscript:"",lastPartial:"",statusPill:"idle",partialsEnabled:!0,error:null,errorKind:null,modelStatus:"idle",loadingProgress:0,permissionState:"unknown",lastBargeInAt:null,hotkeyState:"idle",levelMeterEnabled:!0,turnDetectorState:"disabled",turnDetectorMode:"off",wizardArmed:!1,wizardOpen:!1,initModel:()=>{if(r().modelStatus!=="idle")return;mt.info("voice","initModel: kicking off preload"),e({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const n=++mx,i=()=>{n===mx&&(gx(),cE=n,c0=setTimeout(()=>{cE===n&&r().modelStatus==="loading"&&(mt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},fq))};i(),VU((s,a)=>{n===mx&&(s==="ready"?(gx(),mt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):s==="error"?(gx(),mt.error("voice","modelStatus -> error",{msg:a}),e({modelStatus:"error",error:a,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},s=>{n===mx&&(i(),e({loadingProgress:Math.round(s)}))})},resetAndRetryModel:()=>{mt.info("voice","mic.gate.retry"),gx(),KU(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),r().initModel()},startRecording:n=>{if(r().isRecording)return;if(Ci){mt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!wT()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=s=>{try{const a=YU({inputDeviceId:s,onStatusChange:l=>{e(l==="transcribing"?{statusPill:"transcribing"}:l==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:l=>{r().partialsEnabled&&e({lastPartial:l})},partialsEnabled:()=>r().partialsEnabled,onFrame:l=>{w0=l.isSpeech,lE=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),dx(),fu(),Z5()){const o=eq(),u=o!==null?performance.now()-o:null;Q5(),e({lastBargeInAt:performance.now()}),mt.info("voice","barge-in",{tabId:n,utteranceOffsetMs:u})}else mt.debug("voice","barge-in.no-op",{tabId:n})},onMisfire:()=>{e({lastPartial:"",statusPill:"idle"}),gp();const l=r().lastBargeInAt;l!==null&&performance.now()-l<600&&mt.warn("voice","barge-in.misfire",{tabId:n,sinceBargeInMs:Math.round(performance.now()-l)})},onFinal:l=>{gp();const o=l.trim();if(!o||hq.has(o)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const u=sq(o);if(u){mt.info("voice","voice-command",{tabId:n,label:u.label,transcript:o}),window.api.pty.write({tabId:n,data:u.data}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),fu();const m=window;m.__transcripts&&(m.__transcripts.push({tabId:n,text:o}),m.__transcripts.length>500&&m.__transcripts.shift());return}window.api.pty.write({tabId:n,data:o}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),r().autoSubmit&&uq(n);const f=window;f.__transcripts&&(f.__transcripts.push({tabId:n,text:o}),f.__transcripts.length>500&&f.__transcripts.shift())},onError:l=>{mt.error("voice","recognition error",{err:l}),fu(),e({error:l,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),es==null||es(),es=null,dx(),Ci==null||Ci.destroy(),Ci=null,it.error(`Microphone error: ${l}`)},onModelStatus:l=>{l==="ready"?e({modelStatus:"ready",loadingProgress:100}):l==="loading"&&e({modelStatus:"loading"})},onProgress:l=>e({loadingProgress:Math.round(l)})});Ci=a,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),gp(),a.start().then(()=>{Ci===a&&(es==null||es(),es=nq(a))}).catch(l=>{const o=l instanceof Error?l.message:String(l);mt.error("voice","handle.start() failed",{error:o}),it.error(`Could not start mic: ${o}`)})}catch(a){e({error:a instanceof Error?a.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var s,a,l;return((l=(a=(s=window.api)==null?void 0:s.voice)==null?void 0:a.getDevicePref)==null?void 0:l.call(a))??Promise.resolve(null)}).then(s=>i((s==null?void 0:s.selectedDeviceId)??null)).catch(s=>{mt.warn("voice","getDevicePref failed; using default device",{error:s instanceof Error?s.message:String(s)}),i(null)})},stopRecording:()=>{const n=Ci;n&&(dx(),fu(),w0=0,lE=0,es==null||es(),es=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),n.stop().finally(()=>{n.destroy(),Ci===n&&(Ci=null),r().hotkeyState==="stopping"&&(hx(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!r().isRecording)return;const n=Ci;if(!n)return;dx(),es==null||es(),es=null,e({isRecording:!1,lastTranscript:"",lastPartial:""});try{await n.stop()}catch(a){mt.warn("voice","restartWithDevice: drain rejected",{error:a instanceof Error?a.message:String(a)})}n.destroy(),Ci===n&&(Ci=null);const{useSessions:i}=await em(async()=>{const{useSessions:a}=await Promise.resolve().then(()=>xU);return{useSessions:a}},[],import.meta.url),s=i.getState().activeTabId;s&&r().startRecording(s)},toggleTTS:()=>e(n=>({ttsEnabled:!n.ttsEnabled})),setAutoSubmit:n=>e({autoSubmit:n}),setSubmitDelayMs:n=>e({submitDelayMs:Math.max(500,Math.min(13e3,Math.floor(n)))}),cancelSubmit:()=>fu(),setPartialsEnabled:n=>{r().partialsEnabled!==n&&(e({partialsEnabled:n}),n||e({lastPartial:""}))},clearError:()=>e({error:null,errorKind:null}),setPermissionState:n=>{r().permissionState!==n&&(mt.info("voice","mic.gate.permission_changed",{from:r().permissionState,to:n}),e({permissionState:n}))},setLevelMeterEnabled:n=>{r().levelMeterEnabled!==n&&e({levelMeterEnabled:n})},setTurnDetectorRuntimeState:n=>{r().turnDetectorState!==n&&(e({turnDetectorState:n}),n==="load_failed"?mt.warn("voice-turn","voice-turn.load_failed"):n==="runtime_error"?mt.warn("voice-turn","voice-turn.runtime_error"):n==="disabled"&&mt.info("voice-turn","voice-turn.fallback_to_vad"))},setWizardArmed:n=>{r().wizardArmed!==n&&e({wizardArmed:n})},openWizard:()=>{r().wizardOpen||e({wizardOpen:!0})},closeWizard:()=>{r().wizardOpen&&e({wizardOpen:!1})},armHotkey:({phase:n,source:i,mode:s,tabId:a})=>{const l=r(),{canRecord:o,reason:u}=uE(l);if(n==="down"){if(u==="error"||u==="load-timeout"){l.resetAndRetryModel(),mt.info("voice-hotkey","down.retry",{source:i,reason:u});return}if(!o&&u!=="loading"){mt.warn("voice-hotkey","miss-model-loading",{modelStatus:l.modelStatus,reason:u});return}if(l.hotkeyState==="recording"||l.isRecording){(s==="toggle"||i==="global")&&(e({hotkeyState:"stopping"}),hx(),Uv=setTimeout(()=>{r().hotkeyState==="stopping"&&(mt.warn("voice-hotkey","drain-timeout",{durationMs:fx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},fx),l.stopRecording());return}if(u==="loading"){l.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),mt.info("voice-hotkey","armed",{source:i,modelStatus:l.modelStatus})),px(),o0={tabId:a,source:i,mode:s},l0=Rt.subscribe((f,m)=>{if(o0&&f.modelStatus==="ready"&&m.modelStatus!=="ready"&&f.hotkeyState==="armed"){const h=o0;if(px(),!h.tabId){mt.warn("voice-hotkey","armed-promote-no-tab",{source:h.source}),e({hotkeyState:"idle"});return}mt.info("voice-hotkey","armed-promote",h),e({hotkeyState:"recording"}),Rt.getState().startRecording(h.tabId)}});return}if(!a){mt.warn("voice-hotkey","no-active-tab",{source:i});return}mt.info("voice-hotkey","start",{source:i,mode:s,tabId:a}),l.startRecording(a),r().isRecording?e({hotkeyState:"recording"}):(mt.warn("voice-hotkey","start: recording did not engage",{errorKind:r().errorKind}),e({hotkeyState:"idle"}));return}if(!(s!=="hold"||i==="global")){if(l.hotkeyState==="armed"){px(),mt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}l.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),hx(),Uv=setTimeout(()=>{r().hotkeyState==="stopping"&&(mt.warn("voice-hotkey","drain-timeout",{durationMs:fx}),e({hotkeyState:"aborted"}),setTimeout(()=>{r().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},fx),l.stopRecording())}},destroyHotkey:()=>{const n=r();if(px(),fu(),n.hotkeyState==="recording"){mt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{n.stopRecording()}catch{}}else(n.hotkeyState==="armed"||n.hotkeyState==="stopping")&&(hx(),e({hotkeyState:"destroyed"}))}})),pq=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),uE=e=>wT()?e.permissionState==="denied"?{canRecord:!1,reason:"permission-denied"}:e.modelStatus==="ready"?{canRecord:!0,reason:"ready"}:e.modelStatus==="loading"?{canRecord:!1,reason:"loading"}:e.modelStatus==="error"?{canRecord:!1,reason:e.errorKind==="timeout"?"load-timeout":"error"}:{canRecord:!1,reason:"idle"}:{canRecord:!1,reason:"unsupported"};if(typeof window<"u"){const e=window;e.__voice=Rt,e.__transcripts=[]}function _T(e,r,n){return new Promise((i,s)=>{const a=setTimeout(()=>s(new Error(`${n} timed out after ${r}ms`)),r);e.then(l=>{clearTimeout(a),i(l)},l=>{clearTimeout(a),s(l)})})}const mq=5e3,ku=jn(()=>({snapshot:null,loaded:!1}));let Q$=!1,Z$=!1,Jg;async function gq(){var e;if(!Q$){Q$=!0;try{const r=await _T(window.api.schedule.state(),mq,"schedule.state");ku.setState({snapshot:r,loaded:!0}),Jg=((e=r.paused)==null?void 0:e.reason)??null}catch(r){if(!Z$){Z$=!0;const n=r instanceof Error?r.message:String(r);it.error(`Scheduler state hydrate failed: ${n}`)}Jg=null}window.api.schedule.onState(r=>{var i;const n=((i=r.paused)==null?void 0:i.reason)??null;Jg!==void 0&&n!==Jg&&(n==="auth"?it.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):n==="network"&&it.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),Jg=n,ku.setState({snapshot:r,loaded:!0})})}}const vq=6e4,yq=5e3,vp=jn(()=>({data:null,refreshing:!1}));let eN=!1,u0=null,tN=null,rN=!1;async function ST(){vp.setState({refreshing:!0});let e=vq;try{const r=await _T(window.api.billing.fetch(),yq,"billing.fetch");vp.setState({data:r,refreshing:!1}),r.kind==="transient"?e=tN==="transient"?3e4:5e3:r.kind==="auth"&&(e=3e4),tN=r.kind}catch(r){if(vp.setState({refreshing:!1}),!rN){rN=!0;const n=r instanceof Error?r.message:String(r);it.warn(`Billing usage fetch failed: ${n}`)}}u0=setTimeout(ST,e)}function bq(){eN||(eN=!0,ST())}function Yw(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:e.kind==="auth"&&e.cached?e.cached:null:null}function _0(){u0!==null&&(clearTimeout(u0),u0=null),ST()}function oi({name:e,size:r=17,stroke:n=1.6,className:i}){const s={width:r,height:r,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round",className:i};switch(e){case"home":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M4 11l8-7 8 7"}),c.jsx("path",{d:"M6 10v9h12v-9"}),c.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M7 10l3 2-3 2"}),c.jsx("path",{d:"M13 14h4"})]});case"agents":case"subagents":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"7",cy:"9",r:"2.5"}),c.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),c.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),c.jsx("path",{d:"M8.6 11l2.8 4M15.4 11l-2.8 4M9.5 9h5"})]});case"skills":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 3l2.5 5.5L20 9l-4 4 1 6-5-3-5 3 1-6-4-4 5.5-.5z"})});case"history":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"}),c.jsx("path",{d:"M4 6l2 2"})]});case"usage":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"hive":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M8 4h8l4 7-4 7H8l-4-7z"}),c.jsx("circle",{cx:"12",cy:"11",r:"2.5"})]});case"knowledge-graph":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"6",cy:"7",r:"2.2"}),c.jsx("circle",{cx:"18",cy:"6",r:"2.2"}),c.jsx("circle",{cx:"17",cy:"18",r:"2.2"}),c.jsx("circle",{cx:"7",cy:"17",r:"2.2"}),c.jsx("path",{d:"M8 8l8 8M8 16l8-9M8 7h8"})]});case"plugins":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),c.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),c.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),c.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),c.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"8",cy:"12",r:"4"}),c.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"plans":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),c.jsx("path",{d:"M8 9h8M8 13h8M8 17h5"})]});case"tasks":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),c.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1.5"}),c.jsx("path",{d:"M14 6h7M14 10h5M14 15h7M14 19h5"})]});case"projects":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"docs":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M6 3h8l4 4v14H6z"}),c.jsx("path",{d:"M14 3v4h4M9 13h6M9 17h6M9 9h3"})]});case"memory":case"agent-memory":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M9 4a4 4 0 00-4 4v1a3 3 0 000 6v1a4 4 0 004 4h6a4 4 0 004-4v-1a3 3 0 000-6V8a4 4 0 00-4-4z"}),c.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":case"global-search":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"11",cy:"11",r:"6"}),c.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return c.jsx("svg",{...s,children:c.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M7 3h7l4 4v14H7z"}),c.jsx("path",{d:"M14 3v4h4"})]});case"play":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),c.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),c.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),c.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"3"}),c.jsx("path",{d:"M12 2v3M12 19v3M4 12H1M23 12h-3M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1"})]});case"mic":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"12",r:"8"}),c.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),c.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"orchestrator":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"12",cy:"6",r:"2.5"}),c.jsx("circle",{cx:"5",cy:"17",r:"2.5"}),c.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),c.jsx("circle",{cx:"19",cy:"17",r:"2.5"}),c.jsx("path",{d:"M12 8.5v6M12 14.5l-7 0M12 14.5l7 0"})]});case"race":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M5 4v16M5 5h7l-1 3h7v6h-7l-1 3H5"})});case"background":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M3 4h18v4H3zM3 10h18v4H3zM3 16h18v4H3z"}),c.jsx("circle",{cx:"6",cy:"6",r:".75",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6",cy:"12",r:".75",fill:"currentColor",stroke:"none"}),c.jsx("circle",{cx:"6",cy:"18",r:".75",fill:"currentColor",stroke:"none"})]});case"repoviz":return c.jsxs("svg",{...s,children:[c.jsx("circle",{cx:"6",cy:"12",r:"3"}),c.jsx("circle",{cx:"18",cy:"6",r:"3"}),c.jsx("circle",{cx:"18",cy:"18",r:"3"}),c.jsx("path",{d:"M8.5 10.5L15.5 7.5M8.5 13.5L15.5 16.5"})]});case"system-prompt":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),c.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),c.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),c.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M14 4a4 4 0 014 4l-7 7-4-4 7-7zM7 11l-3 3 6 6 3-3"})});case"quick-open":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),c.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"remote":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M5 12.5a7 7 0 0114 0M1.5 9a11 11 0 0121 0M8.5 16a3.5 3.5 0 017 0"}),c.jsx("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]});case"wifi":return c.jsx("svg",{...s,children:c.jsx("path",{d:"M5 12.5a10 10 0 0114 0M8 15.5a6 6 0 018 0M12 18.5h.01"})});case"shield":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),c.jsx("path",{d:"M9 12l2 2 4-4"})]});case"link":return c.jsxs("svg",{...s,children:[c.jsx("path",{d:"M9 12h6"}),c.jsx("path",{d:"M10 8H7a4 4 0 000 8h3M14 8h3a4 4 0 010 8h-3"})]});case"copy":return c.jsxs("svg",{...s,children:[c.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),c.jsx("path",{d:"M5 15V5a2 2 0 012-2h8"})]});default:return null}}function xq(e,r={}){switch(e){case"ready":return r.isRecording?"Stop voice input":"Start voice input (local Whisper, offline)";case"idle":return"Microphone — speech model not started";case"loading":return`Microphone — loading speech model, ${typeof r.loadingPct=="number"?Math.round(r.loadingPct):0} percent`;case"error":return r.errorMessage?`Microphone — speech model error: ${r.errorMessage}. Activate to retry.`:"Microphone — speech model error. Activate to retry.";case"load-timeout":return"Microphone — model load timed out. Activate to retry.";case"permission-denied":return"Microphone — permission denied. Open OS settings.";case"unsupported":return"Microphone — voice input not supported in this build."}}const nN=e=>Symbol.iterator in e,iN=e=>"entries"in e,sN=(e,r)=>{const n=e instanceof Map?e:new Map(e.entries()),i=r instanceof Map?r:new Map(r.entries());if(n.size!==i.size)return!1;for(const[s,a]of n)if(!i.has(s)||!Object.is(a,i.get(s)))return!1;return!0},wq=(e,r)=>{const n=e[Symbol.iterator](),i=r[Symbol.iterator]();let s=n.next(),a=i.next();for(;!s.done&&!a.done;){if(!Object.is(s.value,a.value))return!1;s=n.next(),a=i.next()}return!!s.done&&!!a.done};function _q(e,r){return Object.is(e,r)?!0:typeof e!="object"||e===null||typeof r!="object"||r===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(r)?!1:nN(e)&&nN(r)?iN(e)&&iN(r)?sN(e,r):wq(e,r):sN({entries:()=>Object.entries(e)},{entries:()=>Object.entries(r)})}function t4(e){const r=Fe.useRef(void 0);return n=>{const i=e(n);return _q(r.current,i)?r.current:r.current=i}}let aN=0;const Sq=1e3;function kq(e){const r=performance.now();r-aN<Sq||(aN=r,mt.debug("voice","mic.gate.click_rejected",{reason:e}))}function r4(){const e=Rt(f=>f.isRecording),r=Rt(f=>f.error),n=Rt(f=>f.loadingProgress),i=Rt(t4(uE)),s=()=>{const f=Rt.getState(),{canRecord:m,reason:h}=uE(f);if(f.isRecording)return f.stopRecording();if(f.wizardArmed&&!f.wizardOpen){f.openWizard();return}if(h==="error"||h==="load-timeout"){f.resetAndRetryModel();return}if(!m)return kq(h);const b=Gt.getState().activeTabId;b&&f.startRecording(b)},a=xq(i.reason,{loadingPct:n,errorMessage:r,isRecording:e}),l=i.reason==="unsupported",o=!i.canRecord,u=i.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":i.reason==="error"||i.reason==="load-timeout"?"text-red-400 cursor-pointer":i.reason==="permission-denied"?"text-amber-400 cursor-pointer":i.reason==="idle"?"text-fg-faint cursor-pointer":i.reason==="unsupported"?"text-fg-faint cursor-not-allowed":e?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return c.jsx("button",{onClick:s,disabled:l,"aria-disabled":o,"aria-label":a,title:a,"data-testid":"mic-button","data-state":i.reason,className:`p-1.5 rounded transition-colors ${u}`,children:c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),c.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),c.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),c.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function Cq(){const e=Rt(n=>n.ttsEnabled),r=Rt(n=>n.toggleTTS);return c.jsxs("button",{onClick:r,title:e?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${e?"text-accent":"text-fg-dim hover:text-fg"}`,children:[c.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[c.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e?c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),c.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),c.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),c.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}const oN=[{key:"overview",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"projects",label:"File Explorer",icon:"projects",hint:"Browse files + edit, per project"},{key:"subagents",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Fan out work: Hive · Orchestrate · Race · Boss"},{key:"scheduler",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"prompts",label:"Prompts",icon:"book",hint:"Click-to-insert prompt library"},{key:"history",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"},{key:"knowledge-graph",label:"Knowledge Graph",icon:"knowledge-graph",hint:"Distilled graph + Q&A over your prompt log"}],lN=[{key:"skills",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"doc-editor",label:"Doc Editor",icon:"docs",hint:"Edit CLAUDE.md and friends"},{key:"memory",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"system-prompt",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"}],cN=[{key:"voice",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"repoviz",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],dE="sm.almanac.sidebarWidth",n4=180,i4=480,fE=252;function Eq(){try{const e=parseInt(localStorage.getItem(dE)??"",10);if(Number.isFinite(e))return Math.min(i4,Math.max(n4,e))}catch{}return fE}const jq=52,s4="sm.almanac.sidebarCollapsed";function Tq(){try{return localStorage.getItem(s4)==="1"}catch{}return!1}const a4="sm.almanac.collapsedGroups";function Aq(){try{const e=localStorage.getItem(a4);if(!e)return new Set;const r=JSON.parse(e);return Array.isArray(r)?new Set(r.filter(n=>n==="Workspace"||n==="Configure"||n==="Tools")):new Set}catch{return new Set}}function $q(){const e=s0(a=>a.tabs),r=ku(a=>{var l;return(((l=a.snapshot)==null?void 0:l.jobs)??[]).some(o=>o.status==="running")}),[n,i]=B.useState(()=>Date.now());return B.useEffect(()=>{const a=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(a)},[]),{subagents:Object.values(e).some(a=>a.agents.some(l=>n-l.at<6e4)),scheduler:r}}function Nq({active:e,onNavigate:r,onNewSession:n}){const[i,s]=B.useState(()=>Aq()),a=B.useCallback(S=>{s(C=>{const T=new Set(C);T.has(S)?T.delete(S):T.add(S);try{localStorage.setItem(a4,JSON.stringify(Array.from(T)))}catch{}return T})},[]),[l,o]=B.useState(()=>Tq()),u=B.useCallback(()=>{o(S=>{const C=!S;try{localStorage.setItem(s4,C?"1":"0")}catch{}return C})},[]),f=Gt(S=>S.tabs),m=Gt(S=>S.activeTabId),h=f.find(S=>S.id===m)??null,b=$q(),[x,k]=B.useState(()=>Eq()),_=B.useRef(x);_.current=x;const y=B.useCallback(S=>{S.preventDefault();const C=S.clientX,T=_.current;let E=T;const $=O=>{E=Math.min(i4,Math.max(n4,T+(O.clientX-C))),k(E)},N=()=>{window.removeEventListener("pointermove",$),window.removeEventListener("pointerup",N),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(dE,String(E))}catch{}};window.addEventListener("pointermove",$),window.addEventListener("pointerup",N),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),w=B.useCallback(()=>{k(fE);try{localStorage.setItem(dE,String(fE))}catch{}},[]);return c.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative transition-[width] duration-150",style:{width:l?jq:x},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[c.jsx(Oq,{tab:h,onNewSession:n,rail:l,onToggleRail:u}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto pb-3",style:{paddingInline:l?"4px":"8px"},children:c.jsxs(c.Fragment,{children:[!l&&c.jsx(f1,{label:"Workspace",collapsed:i.has("Workspace"),count:oN.length,onToggle:()=>a("Workspace")}),(l||!i.has("Workspace"))&&oN.map(S=>c.jsx(uN,{item:S,active:e===S.key,live:S.liveKind?b[S.liveKind]:!1,onClick:()=>r(S.key),rail:l},S.key)),!l&&c.jsx(f1,{label:"Configure",collapsed:i.has("Configure"),count:lN.length,onToggle:()=>a("Configure")}),(l||!i.has("Configure"))&&lN.map(S=>c.jsx(uN,{item:S,active:e===S.key,live:!1,onClick:()=>r(S.key),rail:l},S.key)),!l&&c.jsx(f1,{label:"Tools",collapsed:i.has("Tools"),count:cN.length,onToggle:()=>a("Tools")}),(l||!i.has("Tools"))&&cN.map(S=>c.jsx(Mq,{tool:S,active:e===S.key,onClick:()=>r(S.key),rail:l},S.key))]})}),c.jsx(Iq,{rail:l}),!l&&c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:y,onDoubleClick:w,className:"absolute top-0 right-0 h-full w-1.5 translate-x-1/2 z-10 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"})]})}function Oq({tab:e,onNewSession:r,rail:n,onToggleRail:i}){const s=(e==null?void 0:e.label)??"no session",a=Rq((e==null?void 0:e.cwd)??null);return n?c.jsxs("div",{className:"flex flex-col items-center gap-1.5 pt-2 pb-2 border-b border-rule",children:[c.jsx("button",{onClick:r,"data-testid":"tour-new-session",title:"New session",className:"w-9 h-9 rounded-md bg-bg-hi border border-line text-fg hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center",children:c.jsx(oi,{name:"plus",size:15,stroke:1.8})}),c.jsx("button",{onClick:i,title:"Expand sidebar","data-testid":"sidebar-rail-toggle",className:"w-9 h-9 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:c.jsx("span",{style:{display:"inline-flex",transform:"rotate(0deg)"},children:c.jsx(oi,{name:"chevron",size:15,stroke:1.8})})})]}):c.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),c.jsx("button",{onClick:i,title:"Collapse sidebar","data-testid":"sidebar-rail-toggle",className:"w-6 h-6 rounded-md text-fg-faint hover:text-fg hover:bg-bg-hi/50 transition-colors flex items-center justify-center",children:c.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:c.jsx(oi,{name:"chevron",size:13,stroke:1.8})})})]}),c.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[c.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),c.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(e==null?void 0:e.cwd)??"",children:s})]}),c.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:a?`⌥${a}`:e?e.cwd:"—"}),c.jsxs("div",{className:"mt-3 flex items-stretch gap-1.5",children:[c.jsxs("button",{onClick:r,"data-testid":"tour-new-session",className:"flex-1 px-3 py-1.5 rounded-md bg-bg-hi border border-line text-fg text-[12.5px] font-medium hover:bg-bg-hi/80 hover:border-accent/40 transition-colors flex items-center justify-center gap-1.5",children:[c.jsx(oi,{name:"plus",size:13,stroke:1.8}),"New session"]}),c.jsx("div",{className:"flex items-center rounded-md bg-bg-hi border border-line",children:c.jsx(r4,{})})]})]})}const vx=new Map,Pq=3e4;function Rq(e){const[r,n]=B.useState(()=>{var i;return e?((i=vx.get(e))==null?void 0:i.value)??null:null});return B.useEffect(()=>{if(!e){n(null);return}let i=!1;return(async()=>{const a=vx.get(e);if(a&&Date.now()-a.ts<Pq){i||n(a.value);return}try{const l=await window.api.app.gitBranch(e);if(i)return;vx.set(e,{value:l,ts:Date.now()}),n(l)}catch{if(i)return;vx.set(e,{value:null,ts:Date.now()}),n(null)}})(),()=>{i=!0}},[e]),r}function f1({label:e,collapsed:r,count:n,onToggle:i}){return c.jsxs("button",{onClick:i,"aria-expanded":!r,title:r?`Expand ${e}`:`Collapse ${e}`,className:"group w-full flex items-center gap-1.5 px-3 pt-3.5 pb-1.5 font-serif italic text-[11px] font-bold tracking-[0.07em] uppercase text-fg-faint hover:text-fg-dim transition-colors text-left",children:[c.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:r?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),c.jsx("span",{className:"flex-1",children:e}),r&&c.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:n})]})}function uN({item:e,active:r,live:n,onClick:i,rail:s}){return c.jsxs("button",{onClick:i,title:e.hint,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${s?"justify-center px-0 py-[9px]":"gap-3 px-3.5 py-[9px] text-[14px]"} ${r?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[r&&c.jsx("span",{"aria-hidden":!0,className:`absolute top-3 bottom-3 w-[3px] rounded-sm bg-accent ${s?"-left-[4px]":"-left-[10px]"}`}),c.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:c.jsx(oi,{name:e.icon,size:17,stroke:1.6})}),!s&&c.jsx("span",{className:"flex-1 truncate",children:e.label}),!s&&n&&c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"}),s&&n&&c.jsx("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"})]})}function Mq({tool:e,active:r,onClick:n,rail:i}){return c.jsxs("button",{onClick:n,title:e.hint,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${i?"justify-center px-0 py-[7px]":"gap-3 px-3.5 py-[7px] text-[13px]"} ${r?"bg-bg-hi text-fg font-semibold border border-line":"text-fg-dim hover:bg-bg-hi/50 hover:text-fg border border-transparent"}`,children:[r&&c.jsx("span",{"aria-hidden":!0,className:`absolute top-2 bottom-2 w-[3px] rounded-sm bg-accent ${i?"-left-[4px]":"-left-[10px]"}`}),c.jsx("span",{className:`inline-flex ${r?"text-accent":"text-fg-faint"}`,children:c.jsx(oi,{name:e.icon,size:15,stroke:1.6})}),!i&&c.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function Iq({rail:e}){const r=Rt(o=>o.isRecording),n=Gt(o=>o.tabs),i=Gt(o=>o.activeTabId),s=n.find(o=>o.id===i)??null,[a,l]=B.useState(null);return B.useEffect(()=>{let o=!1;if(!(s!=null&&s.presetId)){l(null);return}return I5(s.presetId).then(u=>{o||l((u==null?void 0:u.model)??null)}).catch(()=>{o||l(null)}),()=>{o=!0}},[s==null?void 0:s.presetId]),e?c.jsx("div",{className:"py-2.5 border-t border-rule flex justify-center",children:c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-red-500 animate-pulse":"bg-sage"}`,title:r?"recording":"idle"})}):c.jsxs("div",{className:"px-3.5 py-2.5 border-t border-rule flex items-center gap-2 text-[11.5px] text-fg-dim font-mono",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${r?"bg-red-500 animate-pulse":"bg-sage"}`,title:r?"recording":"idle"}),c.jsx("span",{className:"truncate",title:a??"",children:r?"recording…":a?`Claude · ${Dq(a)}`:"Claude Code"})]})}function Dq(e){var n,i,s,a,l,o;const r=e.toLowerCase();if(r.includes("opus")){const u=(i=(n=e.match(/(\d+[-.]?\d*)/))==null?void 0:n[1])==null?void 0:i.replace("-",".");return u?`Opus ${u}`:"Opus"}if(r.includes("sonnet")){const u=(a=(s=e.match(/(\d+[-.]?\d*)/))==null?void 0:s[1])==null?void 0:a.replace("-",".");return u?`Sonnet ${u}`:"Sonnet"}if(r.includes("haiku")){const u=(o=(l=e.match(/(\d+[-.]?\d*)/))==null?void 0:l[1])==null?void 0:o.replace("-",".");return u?`Haiku ${u}`:"Haiku"}return e}function Lq({onNavigate:e}){const r=Gt(T=>T.tabs),n=Gt(T=>T.activeTabId),i=r.find(T=>T.id===n)??null,s=z5(i),a=(s==null?void 0:s.lastEventAt)??0,l=vp(T=>T.data),o=ku(T=>{var E;return((E=T.snapshot)==null?void 0:E.paused)??null}),[u,f]=B.useState(null),[,m]=B.useState(0);B.useEffect(()=>{const T=setInterval(()=>m(E=>E+1),6e4);return()=>clearInterval(T)},[]),B.useEffect(()=>{let T=!1;if(!(i!=null&&i.cwd)){f(null);return}return window.api.app.gitBranch(i.cwd).then(E=>{T||f(E)}).catch(()=>{T||f(null)}),()=>{T=!0}},[i==null?void 0:i.cwd]);const h=(s==null?void 0:s.todos)??[],[b,x]=B.useState(!1),k=B.useRef(null);B.useEffect(()=>{if(!b)return;const T=E=>{k.current&&!k.current.contains(E.target)&&x(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[b]),B.useEffect(()=>{h.length===0&&x(!1)},[h.length]);const _=Yw(l),y=(_==null?void 0:_.usage.five_hour)??null,w=y?Math.round(y.utilization):null,S=(l==null?void 0:l.kind)==="ok"||(l==null?void 0:l.kind)==="ok-stale",C=a>0?Fq(Date.now()-a):"—";return c.jsxs("div",{className:"h-[30px] shrink-0 bg-bg-elev border-t border-line flex items-center gap-4 px-[18px] font-mono text-[11.5px] text-fg-dim","data-testid":"tour-statusbar",children:[c.jsxs("button",{onClick:()=>e==null?void 0:e("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:S?"Connected to Anthropic":"Disconnected",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${S?"bg-sage":"bg-fg-faint"}`}),c.jsx("span",{children:S?"connected":"offline"})]}),c.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:w!=null?`${w}% of 5h window used`:"5h —"}),o&&c.jsxs("button",{onClick:()=>e==null?void 0:e("scheduler"),title:"Scheduler is paused — click to open Scheduler",className:`flex items-center gap-1 px-1.5 py-0.5 rounded border font-mono text-[10.5px] transition-colors ${o.reason==="auth"||o.reason==="network"?"border-red-700/60 text-red-300 hover:bg-red-900/20":"border-amber-700/60 text-amber-300 hover:bg-amber-900/20"}`,children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",o.reason]}),i&&c.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,u&&c.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",u]})]}),c.jsxs("span",{className:"text-fg-faint",children:["last activity: ",c.jsx("span",{className:"text-fg-dim",children:C})]}),h.length>0&&c.jsx(Bq,{ref:k,todos:h,open:b,onToggle:()=>x(T=>!T)}),c.jsx("span",{className:"flex-1"}),c.jsxs("span",{className:"text-fg-faint",children:["v","0.30.0"]})]})}const Bq=B.forwardRef(function({todos:r,open:n,onToggle:i},s){const a={completed:r.filter(l=>l.status==="completed").length,in_progress:r.filter(l=>l.status==="in_progress").length,pending:r.filter(l=>l.status==="pending").length};return c.jsxs("div",{ref:s,className:"relative",children:[c.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:"Live to-dos for this session","data-testid":"footer-todos",children:[c.jsxs("span",{className:"text-green-400",children:["✓",a.completed]}),c.jsxs("span",{className:"text-accent",children:["●",a.in_progress]}),c.jsxs("span",{className:"text-fg-dim",children:["○",a.pending]}),c.jsxs("span",{className:"text-fg-faint",children:["todos ",n?"▾":"▴"]})]}),n&&c.jsx("div",{className:"absolute bottom-full left-0 mb-1.5 w-80 max-h-72 overflow-auto bg-bg-elev border border-line rounded shadow-xl p-2 z-50","data-testid":"footer-todos-popover",children:c.jsx("ul",{className:"space-y-0.5",children:r.map((l,o)=>c.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${l.status==="in_progress"?"bg-bg-hi":""}`,children:[c.jsx(zq,{status:l.status}),c.jsx("span",{className:l.status==="completed"?"text-fg-faint line-through":l.status==="in_progress"?"text-fg":"text-fg-dim",children:l.status==="in_progress"&&l.activeForm?l.activeForm:l.content})]},o))})})]})});function zq({status:e}){return e==="completed"?c.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):e==="in_progress"?c.jsx("span",{className:"w-3 shrink-0",children:c.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):c.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function Fq(e){const r=Math.max(0,Math.floor(e/1e3));if(r<60)return`${r}s ago`;const n=Math.floor(r/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}var h1={exports:{}},dN;function Uq(){return dN||(dN=1,(function(e,r){(function(n,i){e.exports=i()})(globalThis,(()=>(()=>{var n={4567:function(l,o,u){var f=this&&this.__decorate||function(S,C,T,E){var $,N=arguments.length,O=N<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,T):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(S,C,T,E);else for(var I=S.length-1;I>=0;I--)($=S[I])&&(O=(N<3?$(O):N>3?$(C,T,O):$(C,T))||O);return N>3&&O&&Object.defineProperty(C,T,O),O},m=this&&this.__param||function(S,C){return function(T,E){C(T,E,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const h=u(9042),b=u(9924),x=u(844),k=u(4725),_=u(2585),y=u(3656);let w=o.AccessibilityManager=class extends x.Disposable{constructor(S,C,T,E){super(),this._terminal=S,this._coreBrowserService=T,this._renderService=E,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let $=0;$<this._terminal.rows;$++)this._rowElements[$]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[$]);if(this._topBoundaryFocusListener=$=>this._handleBoundaryFocus($,0),this._bottomBoundaryFocusListener=$=>this._handleBoundaryFocus($,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new b.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(($=>this._handleResize($.rows)))),this.register(this._terminal.onRender(($=>this._refreshRows($.start,$.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar(($=>this._handleChar($)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
2896
2896
  `)))),this.register(this._terminal.onA11yTab(($=>this._handleTab($)))),this.register(this._terminal.onKey(($=>this._handleKey($.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,y.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,x.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(S){for(let C=0;C<S;C++)this._handleChar(" ")}_handleChar(S){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==S&&(this._charsToAnnounce+=S):this._charsToAnnounce+=S,S===`
2897
2897
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=h.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(S){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(S)||this._charsToConsume.push(S)}_refreshRows(S,C){this._liveRegionDebouncer.refresh(S,C,this._terminal.rows)}_renderRows(S,C){const T=this._terminal.buffer,E=T.lines.length.toString();for(let $=S;$<=C;$++){const N=T.lines.get(T.ydisp+$),O=[],I=(N==null?void 0:N.translateToString(!0,void 0,void 0,O))||"",W=(T.ydisp+$+1).toString(),H=this._rowElements[$];H&&(I.length===0?(H.innerText=" ",this._rowColumns.set(H,[0,1])):(H.textContent=I,this._rowColumns.set(H,O)),H.setAttribute("aria-posinset",W),H.setAttribute("aria-setsize",E))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(S,C){const T=S.target,E=this._rowElements[C===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(C===0?"1":`${this._terminal.buffer.lines.length}`)||S.relatedTarget!==E)return;let $,N;if(C===0?($=T,N=this._rowElements.pop(),this._rowContainer.removeChild(N)):($=this._rowElements.shift(),N=T,this._rowContainer.removeChild($)),$.removeEventListener("focus",this._topBoundaryFocusListener),N.removeEventListener("focus",this._bottomBoundaryFocusListener),C===0){const O=this._createAccessibilityTreeNode();this._rowElements.unshift(O),this._rowContainer.insertAdjacentElement("afterbegin",O)}else{const O=this._createAccessibilityTreeNode();this._rowElements.push(O),this._rowContainer.appendChild(O)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(C===0?-1:1),this._rowElements[C===0?1:this._rowElements.length-2].focus(),S.preventDefault(),S.stopImmediatePropagation()}_handleSelectionChange(){var I;if(this._rowElements.length===0)return;const S=document.getSelection();if(!S)return;if(S.isCollapsed)return void(this._rowContainer.contains(S.anchorNode)&&this._terminal.clearSelection());if(!S.anchorNode||!S.focusNode)return void console.error("anchorNode and/or focusNode are null");let C={node:S.anchorNode,offset:S.anchorOffset},T={node:S.focusNode,offset:S.focusOffset};if((C.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||C.node===T.node&&C.offset>T.offset)&&([C,T]=[T,C]),C.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(C={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(C.node))return;const E=this._rowElements.slice(-1)[0];if(T.node.compareDocumentPosition(E)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(T={node:E,offset:((I=E.textContent)==null?void 0:I.length)??0}),!this._rowContainer.contains(T.node))return;const $=({node:W,offset:H})=>{const V=W instanceof Text?W.parentNode:W;let U=parseInt(V==null?void 0:V.getAttribute("aria-posinset"),10)-1;if(isNaN(U))return console.warn("row is invalid. Race condition?"),null;const D=this._rowColumns.get(V);if(!D)return console.warn("columns is null. Race condition?"),null;let G=H<D.length?D[H]:D.slice(-1)[0]+1;return G>=this._terminal.cols&&(++U,G=0),{row:U,column:G}},N=$(C),O=$(T);if(N&&O){if(N.row>O.row||N.row===O.row&&N.column>=O.column)throw new Error("invalid range");this._terminal.select(N.column,N.row,(O.row-N.row)*this._terminal.cols-N.column+O.column)}}_handleResize(S){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let C=this._rowContainer.children.length;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);for(;this._rowElements.length>S;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const S=this._coreBrowserService.mainDocument.createElement("div");return S.setAttribute("role","listitem"),S.tabIndex=-1,this._refreshRowDimensions(S),S}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let S=0;S<this._terminal.rows;S++)this._refreshRowDimensions(this._rowElements[S])}}_refreshRowDimensions(S){S.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=w=f([m(1,_.IInstantiationService),m(2,k.ICoreBrowserService),m(3,k.IRenderService)],w)},3614:(l,o)=>{function u(b){return b.replace(/\r?\n/g,"\r")}function f(b,x){return x?"\x1B[200~"+b+"\x1B[201~":b}function m(b,x,k,_){b=f(b=u(b),k.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),k.triggerDataEvent(b,!0),x.value=""}function h(b,x,k){const _=k.getBoundingClientRect(),y=b.clientX-_.left-10,w=b.clientY-_.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${y}px`,x.style.top=`${w}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(o,"__esModule",{value:!0}),o.rightClickHandler=o.moveTextAreaUnderMouseCursor=o.paste=o.handlePasteEvent=o.copyHandler=o.bracketTextForPaste=o.prepareTextForTerminal=void 0,o.prepareTextForTerminal=u,o.bracketTextForPaste=f,o.copyHandler=function(b,x){b.clipboardData&&b.clipboardData.setData("text/plain",x.selectionText),b.preventDefault()},o.handlePasteEvent=function(b,x,k,_){b.stopPropagation(),b.clipboardData&&m(b.clipboardData.getData("text/plain"),x,k,_)},o.paste=m,o.moveTextAreaUnderMouseCursor=h,o.rightClickHandler=function(b,x,k,_,y){h(b,x,k),y&&_.rightClickSelect(b),x.value=_.selectionText,x.select()}},7239:(l,o,u)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorContrastCache=void 0;const f=u(1505);o.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(m,h,b){this._css.set(m,h,b)}getCss(m,h){return this._css.get(m,h)}setColor(m,h,b){this._color.set(m,h,b)}getColor(m,h){return this._color.get(m,h)}clear(){this._color.clear(),this._css.clear()}}},3656:(l,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.addDisposableDomListener=void 0,o.addDisposableDomListener=function(u,f,m,h){u.addEventListener(f,m,h);let b=!1;return{dispose:()=>{b||(b=!0,u.removeEventListener(f,m,h))}}}},3551:function(l,o,u){var f=this&&this.__decorate||function(w,S,C,T){var E,$=arguments.length,N=$<3?S:T===null?T=Object.getOwnPropertyDescriptor(S,C):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(w,S,C,T);else for(var O=w.length-1;O>=0;O--)(E=w[O])&&(N=($<3?E(N):$>3?E(S,C,N):E(S,C))||N);return $>3&&N&&Object.defineProperty(S,C,N),N},m=this&&this.__param||function(w,S){return function(C,T){S(C,T,w)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const h=u(3656),b=u(8460),x=u(844),k=u(2585),_=u(4725);let y=o.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(w,S,C,T,E){super(),this._element=w,this._mouseService=S,this._renderService=C,this._bufferService=T,this._linkProviderService=E,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new b.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new b.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,x.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,x.toDisposable)((()=>{var $;this._lastMouseEvent=void 0,($=this._activeProviderReplies)==null||$.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,h.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,h.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,h.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,h.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(w){this._lastMouseEvent=w;const S=this._positionFromMouseEvent(w,this._element,this._mouseService);if(!S)return;this._isMouseOut=!1;const C=w.composedPath();for(let T=0;T<C.length;T++){const E=C[T];if(E.classList.contains("xterm"))break;if(E.classList.contains("xterm-hover"))return}this._lastBufferCell&&S.x===this._lastBufferCell.x&&S.y===this._lastBufferCell.y||(this._handleHover(S),this._lastBufferCell=S)}_handleHover(w){if(this._activeLine!==w.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(w,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,w)||(this._clearCurrentLink(),this._askForLink(w,!0))}_askForLink(w,S){var T,E;this._activeProviderReplies&&S||((T=this._activeProviderReplies)==null||T.forEach(($=>{$==null||$.forEach((N=>{N.link.dispose&&N.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=w.y);let C=!1;for(const[$,N]of this._linkProviderService.linkProviders.entries())S?(E=this._activeProviderReplies)!=null&&E.get($)&&(C=this._checkLinkProviderResult($,w,C)):N.provideLinks(w.y,(O=>{var W,H;if(this._isMouseOut)return;const I=O==null?void 0:O.map((V=>({link:V})));(W=this._activeProviderReplies)==null||W.set($,I),C=this._checkLinkProviderResult($,w,C),((H=this._activeProviderReplies)==null?void 0:H.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(w.y,this._activeProviderReplies)}))}_removeIntersectingLinks(w,S){const C=new Set;for(let T=0;T<S.size;T++){const E=S.get(T);if(E)for(let $=0;$<E.length;$++){const N=E[$],O=N.link.range.start.y<w?0:N.link.range.start.x,I=N.link.range.end.y>w?this._bufferService.cols:N.link.range.end.x;for(let W=O;W<=I;W++){if(C.has(W)){E.splice($--,1);break}C.add(W)}}}}_checkLinkProviderResult(w,S,C){var $;if(!this._activeProviderReplies)return C;const T=this._activeProviderReplies.get(w);let E=!1;for(let N=0;N<w;N++)this._activeProviderReplies.has(N)&&!this._activeProviderReplies.get(N)||(E=!0);if(!E&&T){const N=T.find((O=>this._linkAtPosition(O.link,S)));N&&(C=!0,this._handleNewLink(N))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!C)for(let N=0;N<this._activeProviderReplies.size;N++){const O=($=this._activeProviderReplies.get(N))==null?void 0:$.find((I=>this._linkAtPosition(I.link,S)));if(O){C=!0,this._handleNewLink(O);break}}return C}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(w){if(!this._currentLink)return;const S=this._positionFromMouseEvent(w,this._element,this._mouseService);S&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,S)&&this._currentLink.link.activate(w,this._currentLink.link.text)}_clearCurrentLink(w,S){this._currentLink&&this._lastMouseEvent&&(!w||!S||this._currentLink.link.range.start.y>=w&&this._currentLink.link.range.end.y<=S)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,x.disposeArray)(this._linkCacheDisposables))}_handleNewLink(w){if(!this._lastMouseEvent)return;const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._linkAtPosition(w.link,S)&&(this._currentLink=w,this._currentLink.state={decorations:{underline:w.link.decorations===void 0||w.link.decorations.underline,pointerCursor:w.link.decorations===void 0||w.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,w.link,this._lastMouseEvent),w.link.decorations={},Object.defineProperties(w.link.decorations,{pointerCursor:{get:()=>{var C,T;return(T=(C=this._currentLink)==null?void 0:C.state)==null?void 0:T.decorations.pointerCursor},set:C=>{var T;(T=this._currentLink)!=null&&T.state&&this._currentLink.state.decorations.pointerCursor!==C&&(this._currentLink.state.decorations.pointerCursor=C,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",C))}},underline:{get:()=>{var C,T;return(T=(C=this._currentLink)==null?void 0:C.state)==null?void 0:T.decorations.underline},set:C=>{var T,E,$;(T=this._currentLink)!=null&&T.state&&(($=(E=this._currentLink)==null?void 0:E.state)==null?void 0:$.decorations.underline)!==C&&(this._currentLink.state.decorations.underline=C,this._currentLink.state.isHovered&&this._fireUnderlineEvent(w.link,C))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((C=>{if(!this._currentLink)return;const T=C.start===0?0:C.start+1+this._bufferService.buffer.ydisp,E=this._bufferService.buffer.ydisp+1+C.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=E&&(this._clearCurrentLink(T,E),this._lastMouseEvent)){const $=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);$&&this._askForLink($,!1)}}))))}_linkHover(w,S,C){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(S,!0),this._currentLink.state.decorations.pointerCursor&&w.classList.add("xterm-cursor-pointer")),S.hover&&S.hover(C,S.text)}_fireUnderlineEvent(w,S){const C=w.range,T=this._bufferService.buffer.ydisp,E=this._createLinkUnderlineEvent(C.start.x-1,C.start.y-T-1,C.end.x,C.end.y-T-1,void 0);(S?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(E)}_linkLeave(w,S,C){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(S,!1),this._currentLink.state.decorations.pointerCursor&&w.classList.remove("xterm-cursor-pointer")),S.leave&&S.leave(C,S.text)}_linkAtPosition(w,S){const C=w.range.start.y*this._bufferService.cols+w.range.start.x,T=w.range.end.y*this._bufferService.cols+w.range.end.x,E=S.y*this._bufferService.cols+S.x;return C<=E&&E<=T}_positionFromMouseEvent(w,S,C){const T=C.getCoords(w,S,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(w,S,C,T,E){return{x1:w,y1:S,x2:C,y2:T,cols:this._bufferService.cols,fg:E}}};o.Linkifier=y=f([m(1,_.IMouseService),m(2,_.IRenderService),m(3,k.IBufferService),m(4,_.ILinkProviderService)],y)},9042:(l,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.tooMuchOutput=o.promptLabel=void 0,o.promptLabel="Terminal input",o.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(l,o,u){var f=this&&this.__decorate||function(_,y,w,S){var C,T=arguments.length,E=T<3?y:S===null?S=Object.getOwnPropertyDescriptor(y,w):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(_,y,w,S);else for(var $=_.length-1;$>=0;$--)(C=_[$])&&(E=(T<3?C(E):T>3?C(y,w,E):C(y,w))||E);return T>3&&E&&Object.defineProperty(y,w,E),E},m=this&&this.__param||function(_,y){return function(w,S){y(w,S,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const h=u(511),b=u(2585);let x=o.OscLinkProvider=class{constructor(_,y,w){this._bufferService=_,this._optionsService=y,this._oscLinkService=w}provideLinks(_,y){var I;const w=this._bufferService.buffer.lines.get(_-1);if(!w)return void y(void 0);const S=[],C=this._optionsService.rawOptions.linkHandler,T=new h.CellData,E=w.getTrimmedLength();let $=-1,N=-1,O=!1;for(let W=0;W<E;W++)if(N!==-1||w.hasContent(W)){if(w.loadCell(W,T),T.hasExtendedAttrs()&&T.extended.urlId){if(N===-1){N=W,$=T.extended.urlId;continue}O=T.extended.urlId!==$}else N!==-1&&(O=!0);if(O||N!==-1&&W===E-1){const H=(I=this._oscLinkService.getLinkData($))==null?void 0:I.uri;if(H){const V={start:{x:N+1,y:_},end:{x:W+(O||W!==E-1?0:1),y:_}};let U=!1;if(!(C!=null&&C.allowNonHttpProtocols))try{const D=new URL(H);["http:","https:"].includes(D.protocol)||(U=!0)}catch{U=!0}U||S.push({text:H,range:V,activate:(D,G)=>C?C.activate(D,G,V):k(0,G),hover:(D,G)=>{var ee;return(ee=C==null?void 0:C.hover)==null?void 0:ee.call(C,D,G,V)},leave:(D,G)=>{var ee;return(ee=C==null?void 0:C.leave)==null?void 0:ee.call(C,D,G,V)}})}O=!1,T.hasExtendedAttrs()&&T.extended.urlId?(N=W,$=T.extended.urlId):(N=-1,$=-1)}}y(S)}};function k(_,y){if(confirm(`Do you want to navigate to ${y}?
2898
2898
 
@@ -3514,7 +3514,7 @@ Invoke the \`security-review\` skill on the currently staged diff. Walk OWASP To
3514
3514
  `,Qxe="---\nid: security/secret-credential-scan\ntitle: Secret + credential scan with remediation plan\ncategory: Security\nsendMode: auto-fire\ndescription: Greps the tree for hardcoded secrets, checks git history, and orders rotate → redact → gitignore.\n---\nGrep the working tree for hardcoded secrets — API keys, OAuth tokens, JWTs, private keys, database URLs with embedded passwords, and webhook signing secrets. Use both pattern matching (e.g., `sk-`, `xoxb-`, `AKIA`, `-----BEGIN`, `Bearer `) and entropy heuristics on string literals over 20 chars. For each finding report file:line, the secret type, whether it is in tracked git history (`git log -S`), and a remediation order: rotate first, then redact, then add to `.gitignore`/secret manager. Do not print the secret value in clear — show a masked prefix only.\n",Zxe=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,e0e=["id","title","category","sendMode","description"];function A8(e){const r=e.match(Zxe);if(!r)return console.error("[promptFrontmatter] no frontmatter block found"),null;const n=r[1],i=(r[2]??"").trim(),s={};for(const l of n.split(/\r?\n/)){const o=l.indexOf(":");if(o<0||l.startsWith(" ")||l.startsWith(" "))continue;const u=l.slice(0,o).trim(),f=l.slice(o+1).trim();u&&(s[u]=f)}for(const l of e0e)if(!s[l])return console.error(`[promptFrontmatter] missing required key "${l}" in: ${e.slice(0,120).replace(/\n/g,"\\n")}`),null;const a=s.sendMode==="auto-fire"?"auto-fire":"paste";return{id:s.id,title:s.title,category:s.category,sendMode:a,description:s.description,body:i}}const t0e=Object.assign({"../../seed/prompts/code-review/ac-coverage-check.md":oxe,"../../seed/prompts/code-review/correctness-only.md":lxe,"../../seed/prompts/code-review/full-spectrum-high.md":cxe,"../../seed/prompts/code-review/hallucination-check.md":uxe,"../../seed/prompts/code-review/public-api-compat.md":dxe,"../../seed/prompts/code-review/readability-naming.md":fxe,"../../seed/prompts/debugging/bug-as-failing-test.md":hxe,"../../seed/prompts/debugging/git-bisect-regression.md":pxe,"../../seed/prompts/debugging/instrument-intermittent-bug.md":mxe,"../../seed/prompts/debugging/localize-pipeline-failure.md":gxe,"../../seed/prompts/debugging/reproduce-then-diagnose.md":vxe,"../../seed/prompts/documentation/adr-from-change.md":yxe,"../../seed/prompts/documentation/module-readme.md":bxe,"../../seed/prompts/documentation/onboarding-plan.md":xxe,"../../seed/prompts/documentation/refresh-claude-md.md":wxe,"../../seed/prompts/documentation/tsdoc-public-exports.md":_xe,"../../seed/prompts/git-pr/conventional-commit.md":Sxe,"../../seed/prompts/git-pr/draft-pr-title-body.md":kxe,"../../seed/prompts/git-pr/pre-commit-safety-sweep.md":Cxe,"../../seed/prompts/git-pr/release-notes-block.md":Exe,"../../seed/prompts/git-pr/split-large-pr.md":jxe,"../../seed/prompts/performance/bundle-startup-audit.md":Txe,"../../seed/prompts/performance/complexity-audit.md":Axe,"../../seed/prompts/performance/cpu-profile-hot-path.md":$xe,"../../seed/prompts/performance/db-query-plan-review.md":Nxe,"../../seed/prompts/performance/memory-leak-hunt.md":Oxe,"../../seed/prompts/qa/api-contract-tests.md":Pxe,"../../seed/prompts/qa/e2e-critical-path.md":Rxe,"../../seed/prompts/qa/failing-test-for-bug.md":Mxe,"../../seed/prompts/qa/find-missing-test-coverage.md":Ixe,"../../seed/prompts/qa/stabilize-flaky-test.md":Dxe,"../../seed/prompts/qa/tdd-red-first.md":Lxe,"../../seed/prompts/qa/visual-regression-review.md":Bxe,"../../seed/prompts/qa/wcag-axe-scan.md":zxe,"../../seed/prompts/refactoring/dead-code-sweep.md":Fxe,"../../seed/prompts/refactoring/extract-duplicated-pattern.md":Uxe,"../../seed/prompts/refactoring/modernize-legacy-file.md":qxe,"../../seed/prompts/refactoring/reduce-cyclomatic-complexity.md":Wxe,"../../seed/prompts/refactoring/tighten-module-boundaries.md":Hxe,"../../seed/prompts/security/authz-audit.md":Gxe,"../../seed/prompts/security/crypto-correctness.md":Vxe,"../../seed/prompts/security/cwe-top-25-hunt.md":Kxe,"../../seed/prompts/security/dependency-audit.md":Xxe,"../../seed/prompts/security/ipc-boundary-hardening.md":Yxe,"../../seed/prompts/security/owasp-top-10-staged-diff.md":Jxe,"../../seed/prompts/security/secret-credential-scan.md":Qxe}),zd=Object.values(t0e).map(A8).filter(e=>e!==null);let Zx=null;async function i$(){return Zx||(Zx=await window.api.app.homeDir(),Zx)}function s$(e){const r=zd.find(n=>n.id===e);if(!r)throw new Error(`[promptsStore] unknown prompt id: ${e}`);return r}function a$(e,r){if(!/^[a-z0-9][a-z0-9_-]*\/[a-z0-9][a-z0-9_-]*$/i.test(r))throw new Error(`invalid prompt id: ${r}`);return`${e}/.claude/session-manager/prompts/${r}.md`}function r0e(e,r){return["---",`id: ${e.id}`,`title: ${e.title}`,`category: ${e.category}`,`sendMode: ${e.sendMode}`,`description: ${e.description}`,"---",r].join(`
3515
3515
  `)}async function d5(e){const r=s$(e);try{const n=await i$(),i=await window.api.config.readText(a$(n,e));if(i.exists&&i.text){const s=A8(i.text);if(s)return s}}catch{}return r}async function $8(e,r){const n=s$(e),i=await i$();await window.api.config.writeText(a$(i,e),r0e(n,r))}async function n0e(e){const r=s$(e),n=await i$(),i=a$(n,e);if(!(await window.api.config.readText(i)).exists)return;(await window.api.files.delete(i)).ok||await $8(e,r.body)}function i0e({prompt:e,open:r,activeTabId:n,onClose:i}){const[s,a]=B.useState(e.body),[l,o]=B.useState(e.sendMode);function u(){if(!n)return;const f=l==="auto-fire"?s+`
3516
3516
  `:s;window.api.pty.write({tabId:n,data:f}),i(),it.info(`Sent to terminal (${l})`)}return c.jsxs(Tu,{open:r,onClose:i,title:`Tweak: ${e.title}`,size:"lg",children:[c.jsx("textarea",{value:s,onChange:f=>a(f.target.value),rows:12,className:"w-full bg-bg border border-line rounded px-3 py-2 text-xs font-mono text-fg resize-y focus:outline-none focus:border-accent/60","aria-label":"Prompt body"}),c.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-fg-dim",children:[c.jsx("span",{className:"font-medium text-fg",children:"Send mode:"}),["paste","auto-fire"].map(f=>c.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer select-none",children:[c.jsx("input",{type:"radio",name:"sendMode",value:f,checked:l===f,onChange:()=>o(f),className:"accent-accent"}),c.jsx("span",{className:l===f?"text-fg":"",children:f})]},f)),l==="paste"&&c.jsx("span",{className:"text-fg-faint italic",children:"— you hit Enter to submit"}),l==="auto-fire"&&c.jsx("span",{className:"text-fg-faint italic",children:"— submits immediately"})]}),c.jsxs("div",{className:"mt-4 flex items-center justify-end gap-3",children:[c.jsx("button",{onClick:i,className:"text-xs text-fg-dim hover:text-fg transition-colors",children:"Cancel"}),c.jsx("button",{onClick:u,disabled:!n,title:n?void 0:"Open a terminal session first",className:"px-4 py-1.5 rounded bg-accent text-white text-xs font-medium hover:bg-accent/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:"Send to terminal"})]})]})}const f5=["Security","QA","Performance","Code Review","Debugging","Refactoring","Documentation","Git / PR"],h5=[...f5,...[...new Set(zd.map(e=>e.category))].filter(e=>!f5.includes(e))],s0e={Security:"bg-red-500/10 text-red-400 border-red-500/20",QA:"bg-green-500/10 text-green-400 border-green-500/20",Performance:"bg-orange-500/10 text-orange-400 border-orange-500/20","Code Review":"bg-blue-500/10 text-blue-400 border-blue-500/20",Debugging:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",Refactoring:"bg-purple-500/10 text-purple-400 border-purple-500/20",Documentation:"bg-cyan-500/10 text-cyan-400 border-cyan-500/20","Git / PR":"bg-pink-500/10 text-pink-400 border-pink-500/20"},a0e={paste:"bg-fg-faint/10 text-fg-faint border-fg-faint/20","auto-fire":"bg-accent/10 text-accent border-accent/20"};function o0e(){const[e,r]=B.useState(""),[n,i]=B.useState(()=>{var V;return((V=zd[0])==null?void 0:V.id)??null}),[s,a]=B.useState(!1),[l,o]=B.useState(!1),[u,f]=B.useState(null),[m,h]=B.useState(!1),[b,x]=B.useState(""),[k,_]=B.useState(!1),[y,w]=B.useState(null),S=Gt(V=>V.activeTabId),C=B.useRef(n);C.current=n,B.useEffect(()=>{if(!n){f(null);return}let V=!1;return h(!0),d5(n).then(U=>{V||(f(U),h(!1))}).catch(()=>{if(!V){const U=zd.find(D=>D.id===n)??null;f(U),h(!1)}}),()=>{V=!0}},[n]),B.useEffect(()=>{l&&u&&(x(u.body),w(null))},[l,u]);const T=l&&u!==null&&b!==u.body,E=B.useMemo(()=>{var V;return((V=zd.find(U=>U.id===n))==null?void 0:V.body)??null},[n]),$=u!==null&&E!==null&&u.body!==E,N=B.useMemo(()=>{const V=e.toLowerCase();return h5.map(U=>({category:U,items:zd.filter(D=>D.category===U&&(!V||D.title.toLowerCase().includes(V)||D.description.toLowerCase().includes(V)))})).filter(U=>U.items.length>0)},[e]),O=B.useCallback(V=>{V!==n&&(i(V),o(!1),w(null))},[n]);async function I(V,U){if(!n)return;const D=n;_(!0),w(null);try{await V(D);const G=await d5(D);if(C.current!==D)return;f(G),o(!1)}catch(G){const ee=G instanceof Error?G.message:U;it.error(ee),C.current===D&&w(ee)}finally{_(!1)}}const W=()=>I(V=>$8(V,b),"save failed"),H=()=>I(n0e,"reset failed");return c.jsxs(cn,{toolbar:c.jsxs("span",{className:"text-fg-faint",children:[zd.length," prompts across ",h5.length," categories"]}),footer:l&&n?c.jsx(ju,{dirty:T,busy:k,parseError:y,lastSavedAt:null,onSave:W,onRevert:()=>{x((u==null?void 0:u.body)??""),w(null)}}):null,children:[c.jsx(cf,{sidebarWidth:"17rem",sidebar:c.jsxs("div",{className:"py-1",children:[c.jsx("div",{className:"px-2 pb-2 pt-1",children:c.jsx("input",{value:e,onChange:V=>r(V.target.value),placeholder:"filter…",className:"w-full bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"})}),N.length===0?c.jsx("div",{className:"px-3 py-2 text-xs text-fg-faint italic",children:"no matches"}):N.map(({category:V,items:U})=>c.jsxs("div",{className:"mb-2",children:[c.jsx("div",{className:"px-3 py-1 text-[10.5px] uppercase tracking-wider text-fg-faint font-semibold",children:V}),U.map(D=>c.jsx("button",{onClick:()=>O(D.id),title:D.description,className:`w-full px-3 py-1.5 text-xs text-left truncate transition-colors ${n===D.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi/50"}`,children:D.title},D.id))]},V))]}),detail:m||!u?c.jsx(Wt,{title:m?"loading…":"select a prompt"}):l?c.jsx(c0e,{draft:b,onChange:x,onCancel:()=>o(!1)}):c.jsx(l0e,{effective:u,isCustomized:$,activeTabId:S,onUsePrompt:()=>a(!0),onEdit:()=>o(!0),onReset:H})}),s&&u&&c.jsx(i0e,{prompt:u,open:s,activeTabId:S,onClose:()=>a(!1)},u.id)]})}function l0e({effective:e,isCustomized:r,activeTabId:n,onUsePrompt:i,onEdit:s,onReset:a}){const l=s0e[e.category]??"bg-fg-faint/10 text-fg-faint border-fg-faint/20",o=a0e[e.sendMode];return c.jsxs("div",{className:"p-4 flex flex-col gap-3",children:[c.jsxs("div",{className:"flex items-start gap-2 flex-wrap",children:[c.jsx("h2",{className:"text-sm font-semibold text-fg flex-1 min-w-0",children:e.title}),c.jsx("span",{className:`shrink-0 text-[10.5px] px-1.5 py-0.5 rounded border font-mono ${l}`,children:e.category}),c.jsx("span",{className:`shrink-0 text-[10.5px] px-1.5 py-0.5 rounded border font-mono ${o}`,children:e.sendMode})]}),c.jsx("p",{className:"text-xs text-fg-dim",children:e.description}),c.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[12.5px] bg-bg-elev border border-line rounded p-3 text-fg overflow-x-auto",children:e.body}),c.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[c.jsxs("button",{onClick:i,className:"px-3 py-1.5 rounded bg-accent text-white text-xs font-medium hover:bg-accent/80 transition-colors",children:["Use prompt",!n&&c.jsx("span",{className:"ml-1 opacity-60 font-normal",children:"(no session)"})]}),c.jsx("button",{onClick:s,className:"px-3 py-1.5 rounded bg-bg-hi border border-line text-fg text-xs hover:bg-bg-hi/70 transition-colors",children:"Edit root template"}),r&&c.jsx("button",{onClick:a,className:"ml-auto px-3 py-1.5 rounded border border-line text-xs text-fg-dim hover:text-fg hover:border-accent/40 transition-colors",children:"Reset to default"})]})]})}function c0e({draft:e,onChange:r,onCancel:n}){return c.jsxs("div",{className:"p-4 flex flex-col gap-3 h-full",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-xs font-medium text-fg",children:"Edit root template"}),c.jsx("button",{onClick:n,className:"text-xs text-fg-dim hover:text-fg transition-colors",children:"Cancel"})]}),c.jsx("textarea",{value:e,onChange:i=>r(i.target.value),className:"flex-1 min-h-[16rem] w-full bg-bg border border-line rounded px-3 py-2 text-xs font-mono text-fg resize-y focus:outline-none focus:border-accent/60","aria-label":"Edit prompt body"}),c.jsxs("p",{className:"text-[11px] text-fg-faint",children:["Saves to ",c.jsx("code",{children:"~/.claude/session-manager/prompts/…"})," — overrides the seed on future opens."]})]})}const N8="~/.claude/session-manager/projects-prefs.json",u0e={project:"asc",sessions:"desc",last:"desc",size:"desc"};function lu(e){const r=e(),n={pinned:r.pinned,sort:r.sort,recentFilter:r.recentFilter,hasRemote:r.hasRemote,hasClaudemd:r.hasClaudemd,pinnedOnly:r.pinnedOnly,search:r.search,editor:r.editor};window.api.config.writeJson(N8,n).catch(()=>{})}const p5=jn((e,r)=>({pinned:{},sort:{col:"last",dir:"desc"},recentFilter:"all",hasRemote:null,hasClaudemd:null,pinnedOnly:!1,search:"",editor:"auto",hydrated:!1,hydrate:async()=>{try{const n=await window.api.config.readJson(N8);if(n.exists&&n.data&&typeof n.data=="object"){const i=n.data;e({pinned:i.pinned??{},sort:i.sort??{col:"last",dir:"desc"},recentFilter:i.recentFilter??"all",hasRemote:i.hasRemote??null,hasClaudemd:i.hasClaudemd??null,pinnedOnly:i.pinnedOnly??!1,search:i.search??"",editor:i.editor??"auto",hydrated:!0});return}}catch{}e({hydrated:!0})},togglePin:n=>{const i={...r().pinned,[n]:!r().pinned[n]};e({pinned:i}),lu(r)},setSort:n=>{const i=r(),s=i.sort.col===n?i.sort.dir==="asc"?"desc":"asc":u0e[n];e({sort:{col:n,dir:s}}),lu(r)},setRecentFilter:n=>{e({recentFilter:n}),lu(r)},setHasRemote:n=>{e({hasRemote:n}),lu(r)},setHasClaudemd:n=>{e({hasClaudemd:n}),lu(r)},setPinnedOnly:n=>{e({pinnedOnly:n}),lu(r)},setSearch:n=>{e({search:n}),lu(r)},setEditor:n=>{e({editor:n}),lu(r)}}));async function d0e(e){const r={};try{const n=await window.api.config.readJson(`${e}/package.json`);if(n.exists&&n.data){const i=n.data.name;typeof i=="string"&&(r.name=i)}}catch{}try{const n=await window.api.config.readText(`${e}/.git/config`);if(n.exists&&n.text){const i=n.text.match(/\[remote "origin"\][^\[]*url\s*=\s*([^\n]+)/);if(i){let s=i[1].trim();s=s.replace(/^git@([^:]+):/,"$1/").replace(/\.git$/,"").replace(/^https?:\/\//,""),r.gitRemote=s}}}catch{}try{const n=await window.api.config.readText(`${e}/.git/HEAD`);if(n.exists&&n.text){const i=n.text.match(/ref: refs\/heads\/(.+)/);i&&(r.lastBranch=i[1].trim())}}catch{}try{const n=await window.api.config.readText(`${e}/CLAUDE.md`);n.exists&&n.text&&(r.claudemdPreview=n.text.slice(0,200))}catch{}if(!r.name){const n=e.split("/");r.name=n[n.length-1]||e}return r}function O8(e){return e.replace(/-/g,"/")}async function m5(e){const n=(await window.api.config.listDir(e,{filesOnly:!0})).entries.filter(i=>i.name.endsWith(".jsonl")).sort((i,s)=>i.size-s.size);for(const i of n){const s=await window.api.config.readText(i.path);if(!(!s.exists||!s.text)){for(const a of s.text.split(`
3517
- `))if(a.includes('"cwd"'))try{const l=JSON.parse(a);if(typeof l.cwd=="string"&&l.cwd.length>0)return l.cwd}catch{}}}return null}function f0e(){const e=un(),[r,n]=B.useState([]),[i,s]=B.useState(!0),[a,l]=B.useState({}),o=Gt(m=>m.addTab);return B.useEffect(()=>{if(!e)return;let m=!1;return(async()=>{s(!0);try{const h=await window.api.config.listDir(`${e}/.claude/projects`,{dirsOnly:!0});if(m)return;const b=[];for(const x of h.entries){if(m)return;const _=(await window.api.config.listDir(x.path,{filesOnly:!0})).entries.filter(S=>S.name.endsWith(".jsonl")),y=_.reduce((S,C)=>Math.max(S,C.mtimeMs),0),w=_.reduce((S,C)=>S+C.size,0);b.push({encoded:x.name,displayPath:O8(x.name),sessionCount:_.length,lastSession:y,path:x.path,sizeBytes:w})}b.sort((x,k)=>k.lastSession-x.lastSession),m||(n(b),l({}))}catch(h){console.error("[useKnownProjects] scan failed:",h)}finally{m||s(!1)}})(),()=>{m=!0}},[e]),B.useEffect(()=>{if(!r.length)return;let m=!1;const h=r.slice();let b=0;const x=()=>{for(;!m&&b<6&&h.length;){const k=h.shift();b++,m5(k.path).then(async _=>{if(m)return;const y=_?await d0e(_):{};m||l(w=>({...w,[k.encoded]:{cwd:_??null,...y}}))}).catch(()=>{m||l(_=>({..._,[k.encoded]:{cwd:null}}))}).finally(()=>{b--,m||x()})}};return x(),()=>{m=!0}},[r]),{rows:r,enriched:a,loading:i,openInSession:async m=>{var x;let h=((x=a[m.encoded])==null?void 0:x.cwd)??null;if(h||(h=await m5(m.path)),!h&&(h=await window.api.app.pickDirectory(),!h))return;const b=crypto.randomUUID();o({id:b,cwd:h,startupCommand:`claude --dangerously-skip-permissions --session-id ${Ro(b)}`,presetId:"projects-tab"})},archiveProject:async m=>{try{const h=await window.api.app.archiveProject(m);return h.ok&&(n(b=>b.filter(x=>x.encoded!==m)),l(b=>{const x={...b};return delete x[m],x})),h}catch(h){return{ok:!1,error:h instanceof Error?h.message:"Archive failed"}}}}}const P8=e=>`sm.fileTree.expanded:${e}`;function h0e(e){try{const r=localStorage.getItem(P8(e)),n=r?JSON.parse(r):[];return Array.isArray(n)?n.filter(i=>typeof i=="string"):[]}catch{return[]}}function p0e(e,r){try{localStorage.setItem(P8(e),JSON.stringify([...r].slice(0,500)))}catch{}}function XC(e,r){const n=r+"/";let i=!1;const s=new Set;for(const a of e){if(a===r||a.startsWith(n)){i=!0;continue}s.add(a)}return i?s:e}const YC={modified:{color:"#e2a93d",label:"M"},added:{color:"#3fb950",label:"A"},deleted:{color:"#f85149",label:"D"},renamed:{color:"#a371f7",label:"R"},untracked:{color:"#8b949e",label:"U"},staged:{color:"#3fb950",label:"S"},conflict:{color:"#f85149",label:"!"}},m0e=new Set(["md","txt","json","jsonl","ndjson","js","jsx","ts","tsx","py","go","rs","rb","c","cpp","h","hpp","java","sh","bash","css","scss","html","xml","yaml","yml","toml","ini","conf","env","log","sql","gitignore","png","jpg","jpeg","gif","svg","webp"]);function g0e(e){const r=e.toLowerCase().split(".").pop()||"";return m0e.has(r)}function v0e(e,r){if(r)return"#d97757";switch(e.toLowerCase().split(".").pop()||""){case"ts":case"tsx":return"#3178c6";case"js":case"jsx":return"#f7df1e";case"json":return"#cbcb41";case"md":return"#8a93a0";case"css":case"scss":return"#cc6699";case"py":return"#3776ab";case"go":return"#00add8";case"rs":return"#dea584";case"sh":case"bash":return"#89e051";case"png":case"jpg":case"jpeg":case"gif":case"svg":return"#a4c639";default:return"#8a93a0"}}async function e0(e){var r;try{const n=window.api;return(r=n==null?void 0:n.git)!=null&&r.fileStatus?await n.git.fileStatus(e):{}}catch{return{}}}function y0e({cwd:e,onPreviewFile:r,onSendToChat:n,activeTabId:i}){const[s,a]=B.useState([]),[l,o]=B.useState(new Set),u=B.useRef(l);u.current=l;const[f,m]=B.useState(""),[h,b]=B.useState(!1),[x,k]=B.useState(!1),[_,y]=B.useState(null),[w,S]=B.useState({}),[C,T]=B.useState(null),[E,$]=B.useState(null),[N,O]=B.useState(""),[I,W]=B.useState(null),[H,V]=B.useState(""),[U,D]=B.useState(null),G=B.useRef(null),ee=B.useRef(null),ae=B.useRef(0),oe=B.useCallback(async()=>{if(!e)return;const Be=++ae.current;k(!0),y(null);const Ze=await window.api.files.list(e,h);ae.current===Be&&(Ze.ok?a(Ze.entries.map(dt=>({...dt}))):(y(Ze.error??"failed to list"),a([])),k(!1))},[e,h]),J=B.useCallback(async Be=>{const Ze=ae.current,dt=new Map;for(const or of Be){const Xt=or.split("/").length,ir=dt.get(Xt);ir?ir.push(or):dt.set(Xt,[or])}const ut=[];for(const or of[...dt.keys()].sort((Xt,ir)=>Xt-ir)){const Xt=dt.get(or),ir=await Promise.all(Xt.map(async sr=>({p:sr,result:await window.api.files.list(sr,h)})));if(ae.current!==Ze)return ut;for(const{p:sr,result:Or}of ir)Or.ok?a(Ar=>b0(Ar,sr,Or.entries.map(en=>({...en})))):ut.push(sr)}return ut},[h]),X=B.useCallback(async Be=>(await oe(),Be.length?J(Be):[]),[oe,J]);B.useEffect(()=>{m(""),$(null),T(null),W(null),D(null),S({});const Be=h0e(e),Ze=new Set(Be);u.current=Ze,o(Ze);let dt=!1;return(async()=>{const ut=await X(Be);dt||!ut.length||ne(or=>{const Xt=new Set;let ir=!1;for(const sr of or){if(ut.some(Or=>sr===Or||sr.startsWith(Or+"/"))){ir=!0;continue}Xt.add(sr)}return ir?Xt:or})})(),e0(e).then(ut=>{dt||S(ut)}),()=>{dt=!0}},[e]);const Z=B.useRef(!0);B.useEffect(()=>{if(Z.current){Z.current=!1;return}X([...u.current])},[h]),B.useEffect(()=>{if(!e)return;const Be=window.setInterval(()=>{e0(e).then(S)},5e3);return()=>window.clearInterval(Be)},[e]),B.useEffect(()=>{if(!C)return;const Be=()=>T(null),Ze=dt=>{dt.key==="Escape"&&T(null)};return window.addEventListener("mousedown",Be),window.addEventListener("keydown",Ze),()=>{window.removeEventListener("mousedown",Be),window.removeEventListener("keydown",Ze)}},[C]),B.useEffect(()=>{E&&setTimeout(()=>{var Be;return(Be=G.current)==null?void 0:Be.select()},30)},[E]),B.useEffect(()=>{I&&setTimeout(()=>{var Be;return(Be=ee.current)==null?void 0:Be.focus()},30)},[I]);const ne=B.useCallback(Be=>{const Ze=u.current,dt=Be(Ze);dt!==Ze&&(u.current=dt,o(dt),p0e(e,dt))},[e]),ce=B.useCallback(async Be=>{if(l.has(Be.path)){ne(dt=>XC(dt,Be.path));return}if(ne(dt=>new Set(dt).add(Be.path)),Be.children)return;const Ze=await window.api.files.list(Be.path,h);Ze.ok&&a(dt=>b0(dt,Be.path,Ze.entries.map(ut=>({...ut}))))},[l,h,ne]),ge=B.useCallback(async Be=>{if(Be===e){await oe();return}const Ze=await window.api.files.list(Be,h);Ze.ok&&a(dt=>b0(dt,Be,Ze.entries.map(ut=>({...ut}))))},[e,oe,h]),_e=B.useCallback(Be=>{if(Be.isDirectory){ce(Be);return}g0e(Be.name)&&r?r(Be.path):window.api.files.openExternal(Be.path)},[ce,r]),Te=B.useCallback(Be=>{if(n){n(Be);return}if(i){const Ze=Be.startsWith(e+"/")?Be.slice(e.length+1):Be;window.api.pty.write({tabId:i,data:`@${Ze} `})}},[n,i,e]),ye=B.useCallback((Be,Ze)=>{Be.preventDefault(),Be.stopPropagation(),T({x:Be.clientX,y:Be.clientY,node:Ze})},[]),ie=Be=>{$(Be.path),O(Be.name)},xe=async()=>{if(!E)return;const Be=N.trim();if(!Be){$(null);return}const Ze=await window.api.files.rename(E,Be);if($(null),Ze.ok){const dt=E.slice(0,E.lastIndexOf("/"));ne(ut=>XC(ut,E)),await ge(dt||e),e0(e).then(S)}else y(Ze.error??"rename failed")},we=async()=>{if(!I)return;const Be=H.trim();if(!Be){W(null),V("");return}const Ze=await window.api.files.create(I.parent,Be,I.kind);W(null),V(""),Ze.ok?(await ge(I.parent),I.kind==="folder"&&ne(dt=>new Set(dt).add(I.parent))):y(Ze.error??"create failed")},Ve=async()=>{if(!U)return;const Be=await window.api.files.delete(U.path),Ze=U.path.slice(0,U.path.lastIndexOf("/"));D(null),Be.ok?(ne(dt=>XC(dt,U.path)),await ge(Ze||e),e0(e).then(S)):y(Be.error??"delete failed")},Me=B.useMemo(()=>{if(!f.trim())return s;const Be=f.toLowerCase();return s.filter(Ze=>Ze.name.toLowerCase().includes(Be))},[s,f]),We=(e==null?void 0:e.split("/").filter(Boolean).pop())||"project";return c.jsxs("div",{className:"w-full h-full flex flex-col bg-bg-elev text-fg",children:[c.jsxs("div",{className:"p-3 border-b border-line shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 min-w-0",children:[c.jsx(M8,{size:14,className:"shrink-0 text-accent"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium text-fg truncate",children:We}),c.jsx("p",{className:"text-[10px] text-fg-faint truncate",title:e,children:e})]}),c.jsx("button",{onClick:oe,className:"p-1 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"Refresh",disabled:x,children:c.jsx(k0e,{size:12,className:x?"animate-spin":""})})]}),c.jsx("div",{className:"relative",children:c.jsx("input",{value:f,onChange:Be=>m(Be.target.value),placeholder:"Search files…",className:"w-full px-2 py-1 text-xs bg-bg-hi border border-line rounded text-fg placeholder-fg-faint focus:outline-none focus:border-accent/40"})})]}),c.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-line shrink-0",children:[c.jsx("button",{onClick:()=>W({parent:e,kind:"file"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New file",children:c.jsx(C0e,{size:12})}),c.jsx("button",{onClick:()=>W({parent:e,kind:"folder"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New folder",children:c.jsx(E0e,{size:12})}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>b(Be=>!Be),className:`p-1.5 rounded transition-colors ${h?"text-accent":"text-fg-faint hover:text-fg"} hover:bg-bg-hi`,title:h?"Hide hidden files":"Show hidden files",children:h?c.jsx(j0e,{size:12}):c.jsx(T0e,{size:12})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[_&&c.jsx("div",{className:"px-3 py-2 text-[11px] text-red-400",children:_}),!_&&Me.length===0&&!x&&c.jsx("div",{className:"p-4 text-center text-[11px] text-fg-faint",children:f?"no matches":"empty folder"}),!_&&c.jsx(R8,{nodes:Me,depth:0,expanded:l,gitStatus:w,renaming:E,renameValue:N,renameInputRef:G,onRenameChange:O,onRenameCommit:xe,onRenameCancel:()=>$(null),onToggleDir:ce,onFileClick:_e,onSendToChat:Te,onContextMenu:ye})]}),c.jsx("div",{className:"px-3 py-1.5 border-t border-line text-[10px] text-fg-faint shrink-0",children:"Click to preview · Double-click external · Right-click for more"}),C&&c.jsx(b0e,{x:C.x,y:C.y,node:C.node,onClose:()=>T(null),onRename:()=>{ie(C.node),T(null)},onDelete:()=>{D(C.node),T(null)},onNewFile:()=>{W({parent:C.node.path,kind:"file"}),T(null)},onNewFolder:()=>{W({parent:C.node.path,kind:"folder"}),T(null)},onOpenExternal:()=>{window.api.files.openExternal(C.node.path),T(null)},onShowInFinder:()=>{window.api.files.showInFinder(C.node.path),T(null)},onCopyPath:()=>{var Be;(Be=navigator.clipboard)==null||Be.writeText(C.node.path),T(null)},onSendToChat:()=>{Te(C.node.path),T(null)}}),I&&c.jsx(g5,{title:`New ${I.kind}`,subtitle:`in ${x0e(I.parent)}`,onCancel:()=>{W(null),V("")},onConfirm:we,confirmLabel:"Create",confirmDisabled:!H.trim(),children:c.jsx("input",{ref:ee,value:H,onChange:Be=>V(Be.target.value),onKeyDown:Be=>{Be.key==="Enter"&&we(),Be.key==="Escape"&&(W(null),V(""))},placeholder:I.kind==="file"?"filename.txt":"folder-name",className:"w-full px-3 py-2 rounded bg-bg-hi border border-line text-fg text-sm placeholder-fg-faint focus:outline-none focus:border-accent/50"})}),U&&c.jsx(g5,{title:`Delete ${U.isDirectory?"folder":"file"}`,subtitle:null,onCancel:()=>D(null),onConfirm:Ve,confirmLabel:"Delete",danger:!0,children:c.jsxs("p",{className:"text-sm text-fg-dim",children:["Move ",c.jsxs("span",{className:"text-fg font-medium",children:['"',U.name,'"']})," to the trash?",U.isDirectory&&c.jsx("span",{className:"block text-xs text-fg-faint mt-1",children:"All contents will be moved with it."})]})})]})}function R8(e){const{nodes:r,depth:n,expanded:i,gitStatus:s,renaming:a,onContextMenu:l}=e;return c.jsx(c.Fragment,{children:r.map(o=>{const u=i.has(o.path),f=a===o.path,m=s[o.path],h=v0e(o.name,o.isDirectory);return c.jsxs("div",{children:[c.jsxs("div",{className:"group flex items-center gap-1.5 py-0.5 pr-2 cursor-pointer transition-colors hover:bg-bg-hi",style:{paddingLeft:`${8+n*14}px`},onClick:()=>{f||(o.isDirectory?e.onToggleDir(o):e.onFileClick(o))},onDoubleClick:()=>{o.isDirectory||window.api.files.openExternal(o.path)},onContextMenu:b=>l(b,o),children:[o.isDirectory?c.jsx(S0e,{size:10,className:`shrink-0 text-fg-faint transition-transform ${u?"rotate-90":""}`}):c.jsx("span",{className:"w-[10px] shrink-0"}),o.isDirectory?u?c.jsx(w0e,{size:12,color:h}):c.jsx(M8,{size:12,color:h}):c.jsx(_0e,{size:12,color:h}),f?c.jsx("input",{ref:e.renameInputRef,value:e.renameValue,onChange:b=>e.onRenameChange(b.target.value),onClick:b=>b.stopPropagation(),onBlur:e.onRenameCommit,onKeyDown:b=>{b.key==="Enter"&&e.onRenameCommit(),b.key==="Escape"&&e.onRenameCancel()},className:"flex-1 min-w-0 px-1 py-0 text-xs bg-bg border border-accent/40 rounded text-fg focus:outline-none"}):c.jsx("span",{className:`flex-1 truncate text-xs ${o.name.startsWith(".")?"text-fg-faint":"text-fg-dim"}`,children:o.name}),m&&c.jsx("span",{className:"shrink-0 text-[9px] font-bold px-1 rounded",style:{color:YC[m].color,backgroundColor:`${YC[m].color}20`},title:m,children:YC[m].label}),!o.isDirectory&&c.jsx("button",{onClick:b=>{b.stopPropagation(),e.onSendToChat(o.path)},title:"Send @path to active terminal",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded text-fg-faint hover:text-accent hover:bg-bg transition-all shrink-0",children:c.jsx(A0e,{size:10})})]}),o.isDirectory&&u&&o.children&&c.jsx(R8,{...e,nodes:o.children,depth:n+1})]},o.path)})})}function b0e(e){const{x:r,y:n,node:i}=e;return c.jsxs("div",{onMouseDown:s=>s.stopPropagation(),className:"fixed z-[300] w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1",style:{left:r,top:n},children:[!i.isDirectory&&c.jsx(cu,{label:"Send to chat",onClick:e.onSendToChat}),c.jsx(cu,{label:"Open in default app",onClick:e.onOpenExternal}),c.jsx(cu,{label:"Reveal in OS",onClick:e.onShowInFinder}),c.jsx(JC,{}),c.jsx(cu,{label:"Copy path",onClick:e.onCopyPath}),c.jsx(cu,{label:"Rename",onClick:e.onRename}),i.isDirectory&&c.jsxs(c.Fragment,{children:[c.jsx(JC,{}),c.jsx(cu,{label:"New file",onClick:e.onNewFile}),c.jsx(cu,{label:"New folder",onClick:e.onNewFolder})]}),c.jsx(JC,{}),c.jsx(cu,{label:"Delete",onClick:e.onDelete,danger:!0})]})}function cu({label:e,onClick:r,danger:n}){return c.jsx("button",{onClick:r,className:`w-full text-left px-3 py-1.5 hover:bg-bg-hi transition-colors ${n?"text-red-400":"text-fg-dim hover:text-fg"}`,children:e})}function JC(){return c.jsx("div",{className:"my-1 border-t border-line"})}function g5(e){return c.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:r=>{r.target===r.currentTarget&&e.onCancel()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-1",children:e.title}),e.subtitle&&c.jsx("p",{className:"text-[11px] text-fg-faint mb-3 truncate",children:e.subtitle}),c.jsx("div",{className:"mb-4",children:e.children}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:e.onCancel,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded transition-colors",children:"Cancel"}),c.jsx("button",{onClick:e.onConfirm,disabled:!!e.confirmDisabled,className:`px-3 py-1 text-xs text-white rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${e.danger?"bg-red-600 hover:bg-red-500":"bg-accent hover:bg-accent/90"}`,children:e.confirmLabel??"OK"})]})]})})}function x0e(e){return e.split("/").filter(Boolean).pop()||e}function b0(e,r,n){return e.map(i=>i.path===r?{...i,children:n}:i.children?{...i,children:b0(i.children,r,n)}:i)}function kl({size:e,children:r,className:n,color:i}){return c.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:i||"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,children:r})}function M8({size:e,className:r,color:n}){return c.jsx(kl,{size:e,className:r,color:n,children:c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function w0e({size:e,className:r,color:n}){return c.jsx(kl,{size:e,className:r,color:n,children:c.jsx("path",{d:"M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2"})})}function _0e({size:e,className:r,color:n}){return c.jsxs(kl,{size:e,className:r,color:n,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function S0e({size:e,className:r}){return c.jsx(kl,{size:e,className:r,children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}function k0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("polyline",{points:"1 20 1 14 7 14"}),c.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function C0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"}),c.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),c.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]})}function E0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}),c.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"17"}),c.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14"})]})}function j0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function T0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),c.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function A0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),c.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function QC(e){const r="/home/";if(e.startsWith(r)){const n=e.slice(r.length).split("/").slice(1).join("/");return n?`~/${n}`:"~"}return e}const hT="sm.projects.splitPct",pT=33,I8=20,D8=60,L8="sm.projects.fileTreeCollapsed",$0e=32;function N0e(){try{const e=parseFloat(localStorage.getItem(hT)??"");if(Number.isFinite(e))return Math.min(D8,Math.max(I8,e))}catch{}return pT}function O0e(){try{return localStorage.getItem(L8)==="1"}catch{return!1}}function P0e(){const e=Gt(N=>N.tabs),r=Gt(N=>N.activeTabId),n=e.find(N=>N.id===r)??null,[i,s]=B.useState(()=>N0e()),[a,l]=B.useState(()=>O0e()),[o,u]=B.useState(!1),f=B.useRef(i);f.current=i;const m=B.useRef(null),h=B.useRef(null),{rows:b,enriched:x,openInSession:k,archiveProject:_}=f0e(),y=p5(N=>N.pinned),w=p5(N=>N.togglePin),S=[...b].sort((N,O)=>(y[O.encoded]?1:0)-(y[N.encoded]?1:0));B.useEffect(()=>{if(!o)return;const N=O=>{h.current&&!h.current.contains(O.target)&&u(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[o]);const C=B.useCallback(N=>{xn.getState().openFile(N)},[]),T=B.useCallback(N=>{N.preventDefault();const O=N.clientX,I=f.current;let W=I;const H=U=>{const D=m.current;if(!D)return;const G=D.getBoundingClientRect(),ee=U.clientX-O;W=Math.min(D8,Math.max(I8,I+ee/G.width*100)),s(W)},V=()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",V),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(hT,String(W))}catch{}};window.addEventListener("pointermove",H),window.addEventListener("pointerup",V),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),E=B.useCallback(()=>{s(pT);try{localStorage.setItem(hT,String(pT))}catch{}},[]),$=B.useCallback(()=>{l(N=>{const O=!N;try{localStorage.setItem(L8,O?"1":"0")}catch{}return O})},[]);return a?c.jsxs("div",{ref:m,className:"flex h-full w-full","data-testid":"projects-workspace",children:[c.jsxs("button",{onClick:$,"data-testid":"projects-file-tree-rail-toggle",title:"Show file explorer",className:"shrink-0 flex flex-col items-center gap-2 py-2 border-r border-line text-fg-faint hover:text-fg hover:bg-surface-raised transition-colors",style:{width:$0e},children:[c.jsx("span",{className:"text-[11px]",children:"▸"}),c.jsx("span",{className:"text-[10px] tracking-wide [writing-mode:vertical-rl]",children:"Files"})]}),c.jsx("div",{className:"flex-1 min-w-0","data-testid":"projects-editor-pane",children:c.jsx(Hj,{})})]}):c.jsxs("div",{ref:m,className:"flex h-full w-full","data-testid":"projects-workspace",children:[c.jsxs("div",{className:"shrink-0 flex flex-col border-r border-line overflow-hidden",style:{width:`${i}%`},"data-testid":"projects-file-tree-pane",children:[c.jsxs("div",{ref:h,className:"relative shrink-0 flex items-stretch border-b border-line",children:[c.jsxs("button",{"data-testid":"projects-launcher-trigger",onClick:()=>u(N=>!N),className:"flex-1 min-w-0 px-3 py-1.5 text-[11.5px] text-fg-dim font-mono flex items-center gap-1 hover:bg-surface-raised transition-colors",children:[c.jsx("span",{className:"flex-1 truncate text-left",children:n?QC(n.cwd):"Projects"}),c.jsx("span",{className:"text-fg-faint shrink-0 text-[10px]",children:o?"▲":"▼"})]}),c.jsx("button",{onClick:$,"data-testid":"projects-file-tree-collapse",title:"Hide file explorer",className:"shrink-0 px-2 border-l border-line text-fg-faint hover:text-fg hover:bg-surface-raised transition-colors text-[11px]",children:"◂"}),o&&c.jsx("div",{"data-testid":"projects-launcher-list",className:"absolute left-0 right-0 top-full z-50 bg-surface border border-line shadow-lg max-h-60 overflow-auto",children:S.length===0?c.jsx("div",{className:"px-3 py-2 text-[11.5px] text-fg-faint",children:"No projects found."}):S.map(N=>{var I;const O=QC(((I=x[N.encoded])==null?void 0:I.cwd)??O8(N.encoded));return c.jsxs("div",{"data-testid":"projects-launcher-row",className:"flex items-center gap-1 px-2 py-1 hover:bg-surface-raised group",children:[c.jsx(rm,{content:y[N.encoded]?"Unpin":"Pin to top",children:c.jsx("button",{onClick:()=>w(N.encoded),className:`shrink-0 text-sm leading-none transition-colors ${y[N.encoded]?"text-yellow-400":"text-fg-faint hover:text-fg-dim"}`,children:y[N.encoded]?"★":"☆"})}),c.jsx("button",{onClick:()=>{k(N),u(!1)},className:"flex-1 min-w-0 text-left text-[11.5px] font-mono truncate text-fg-dim hover:text-fg",children:O}),c.jsx("button",{onClick:async()=>{window.confirm(`Archive ${O}?`)&&await _(N.encoded)},className:"shrink-0 text-[10px] text-fg-faint hover:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity",title:"Archive",children:"✕"})]},N.encoded)})})]}),n?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-3 py-2 border-b border-line text-[11.5px] text-fg-faint font-mono truncate shrink-0",title:n.cwd,children:QC(n.cwd)}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsx(y0e,{cwd:n.cwd,activeTabId:n.id,onPreviewFile:C})})]}):c.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-fg-faint",children:"No session selected."})]}),c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:T,onDoubleClick:E,className:"w-1.5 shrink-0 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"}),c.jsx("div",{className:"flex-1 min-w-0","data-testid":"projects-editor-pane",children:c.jsx(Hj,{})})]})}const mT="~/.config/session-manager/doc-editor.json",R0e=20;let ZC=null;function kv(e){ZC&&clearTimeout(ZC),ZC=setTimeout(async()=>{const r=e();try{const n=await window.api.config.readJson(mT).catch(()=>null),i=(n==null?void 0:n.data)??{};await window.api.config.writeJson(mT,{...i,recents:r.recents,openPaths:Object.keys(r.docs),viewModes:r.viewModes})}catch(n){console.warn("[docEditor] persist failed:",n)}},500)}function v5(e,r){return[r,...e.filter(n=>n!==r)].slice(0,R0e)}const fa=jn((e,r)=>({docs:{},activePath:null,recents:[],viewModes:{},hydrated:!1,open:async n=>{if(r().docs[n]){e({activePath:n});return}const s=await window.api.docEditor.readFile(n);if(!s.ok){it.warn(`Could not open ${n.split("/").pop()}: ${s.error??"unknown error"}`),e(l=>({recents:l.recents.filter(o=>o!==n)})),kv(r);return}const a={path:n,diskText:s.text??"",bufferText:s.text??"",mtimeMs:s.mtimeMs??0,loadedAt:Date.now()};e(l=>({docs:{...l.docs,[n]:a},activePath:n,recents:v5(l.recents,n)})),kv(r)},close:n=>{var o;const i=r(),s=i.docs[n];if(!s)return;if(s.bufferText!==s.diskText){const u=n.split("/").pop()??n;if(!window.confirm(`"${u}" has unsaved changes. Close without saving?`))return}const a={...i.docs};delete a[n];let l=i.activePath;i.activePath===n&&(l=((o=Object.values(a).sort((f,m)=>m.loadedAt-f.loadedAt)[0])==null?void 0:o.path)??null),e({docs:a,activePath:l}),kv(r)},setActive:n=>{e({activePath:n})},setViewMode:(n,i)=>{e(s=>({viewModes:{...s.viewModes,[n]:i}})),kv(r)},edit:(n,i)=>{const s=r().docs[n];s&&e(a=>({docs:{...a.docs,[n]:{...s,bufferText:i}}}))},save:async n=>{const i=r().docs[n];if(!i)return;const s=i.bufferText,a=await window.api.docEditor.writeFile(n,s);if(!a.ok){it.error(`Save failed for ${n.split("/").pop()}: ${a.error??"unknown"}`);return}e(l=>{const o=l.docs[n];return o?{docs:{...l.docs,[n]:{...o,diskText:s,mtimeMs:a.mtimeMs??o.mtimeMs}},recents:v5(l.recents,n)}:{}}),kv(r)},saveAll:async()=>{const n=Object.values(r().docs).filter(i=>i.bufferText!==i.diskText).map(i=>i.path);await Promise.all(n.map(i=>r().save(i)))},hydrate:async()=>{if(!r().hydrated){e({hydrated:!0});try{const i=(await window.api.config.readJson(mT)).data??{},s=Array.isArray(i.recents)?i.recents:[],a=Array.isArray(i.openPaths)?i.openPaths:[],l=i.viewModes??{},o={};for(const[u,f]of Object.entries(l))(f==="wysiwyg"||f==="source")&&(o[u]=f);e({recents:s,viewModes:o});for(const u of a)await r().open(u)}catch(n){console.warn("[docEditor] hydrate failed:",n)}}}}));window.__docEditor=fa;const M0e={json:"json",ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",cjs:"javascript",mjs:"javascript",py:"python",sh:"shell",bash:"shell",yaml:"yaml",yml:"yaml",toml:"ini",css:"css",html:"html",xml:"xml",sql:"sql",rs:"rust",go:"go",md:"markdown",markdown:"markdown"},y5={Dockerfile:"dockerfile",Makefile:"makefile"};function I0e(e){const r=e.split("/").pop()??e;if(y5[r])return y5[r];const n=r.lastIndexOf(".");if(n===-1)return null;const i=r.slice(n+1);return M0e[i]??null}const D0e=B.lazy(()=>em(()=>import("./TiptapBody-DyiZVN0v.js"),__vite__mapDeps([2,0,1]),import.meta.url).then(e=>({default:e.TiptapBody})));function L0e(e){return e.split("/").pop()??e}function B0e(e){return e.endsWith(".md")||e.endsWith(".markdown")}function z0e({docs:e,activePath:r,onSetActive:n,onClose:i}){const s=Object.keys(e);return c.jsx("div",{className:"h-9 bg-bg-elev border-b border-line flex items-center overflow-x-auto shrink-0 px-2 gap-1","data-testid":"doc-tab-strip",children:s.map(a=>{const l=e[a],o=l.bufferText!==l.diskText,u=L0e(a),f=a===r;return c.jsxs("div",{className:`group px-3 py-1 flex items-center gap-1 rounded-t text-xs shrink-0 cursor-pointer transition-colors ${f?"bg-bg-hi text-fg font-semibold border border-b-0 border-accent border-t-2 -mb-px relative z-10":"bg-bg-elev text-fg-dim border border-line hover:text-fg hover:bg-bg"}`,onClick:()=>n(a),title:a,"data-testid":`doc-tab-${u}`,children:[o&&c.jsx("span",{className:"text-amber-400","aria-label":"unsaved changes","data-testid":"doc-tab-dirty",children:"●"}),c.jsx("span",{children:u}),c.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),i(a)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1",title:`Close ${u}`,"aria-label":`Close ${u}`,"data-testid":`doc-x-${u}`,children:"×"})]},a)})})}function F0e({path:e,value:r,onChange:n,language:i}){const s=B.useRef(null),a=B.useRef(e);a.current=e;const l=async o=>{s.current=o;const u=await em(()=>import("./monaco-editor-BW5C4Iv1.js").then(f=>f.b),__vite__mapDeps([0,1]),import.meta.url);o.addCommand(u.KeyMod.CtrlCmd|u.KeyCode.KeyS,()=>{fa.getState().save(a.current)})};return c.jsx(Qw,{path:`file://${e}`,language:i,value:r,onChange:o=>n(o??""),onMount:l,theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:12,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,formatOnPaste:!0,automaticLayout:!0,bracketPairColorization:{enabled:!0},wordWrap:"on"}})}function U0e({path:e,value:r,onChange:n}){const i=I0e(e);if(!i){const s=e.split("/").pop()??e;return c.jsx("textarea",{className:"w-full h-full resize-none bg-bg text-fg font-mono text-sm p-3 focus:outline-none leading-relaxed",value:r,onChange:a=>n(a.target.value),spellCheck:!1,"data-testid":"doc-textarea","aria-label":`Edit ${s}`},e)}return c.jsx(F0e,{path:e,value:r,onChange:n,language:i})}function q0e(){const e=fa(y=>y.docs),r=fa(y=>y.activePath),n=fa(y=>y.viewModes),i=fa(y=>y.open),s=fa(y=>y.close),a=fa(y=>y.setActive),l=fa(y=>y.edit),o=fa(y=>y.save),u=fa(y=>y.saveAll),f=fa(y=>y.setViewMode),m=fa(y=>y.hydrate);B.useEffect(()=>{m()},[m]);const h=r?e[r]??null:null,b=Object.values(e).some(y=>y.bufferText!==y.diskText),x=r?n[r]??"wysiwyg":"wysiwyg",k=r?B0e(r):!1,_=async()=>{const y=r?r.split("/").slice(0,-1).join("/"):void 0,w=await window.api.docEditor.pickFile(y?{lastDir:y}:void 0);w.path&&await i(w.path)};return r===null?c.jsx(Wt,{title:"No document open",hint:c.jsxs("span",{children:["Click ",c.jsx("strong",{children:"Open…"})," or use"," ",c.jsx("kbd",{className:"px-1 py-0.5 border border-line rounded font-mono text-[10px]",children:"Cmd-K"})," ","and type ",c.jsx("code",{children:"doc:open"})]})}):c.jsxs("div",{className:"h-full flex flex-col",onKeyDown:y=>{(y.ctrlKey||y.metaKey)&&y.key.toLowerCase()==="s"&&!y.shiftKey&&(y.preventDefault(),r&&o(r)),(y.ctrlKey||y.metaKey)&&y.key.toLowerCase()==="w"&&!y.shiftKey&&(y.preventDefault(),r&&s(r))},"data-testid":"doc-editor-panel",children:[c.jsx(z0e,{docs:e,activePath:r,onSetActive:a,onClose:s}),c.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:[c.jsx("button",{type:"button",onClick:_,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors","data-testid":"doc-open-btn",children:"Open…"}),c.jsx("button",{type:"button",onClick:()=>r&&o(r),disabled:!h||h.bufferText===h.diskText,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"doc-save-btn",children:"Save"}),c.jsx("button",{type:"button",onClick:()=>u(),disabled:!b,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"doc-save-all-btn",children:"Save All"}),k&&r&&c.jsxs("div",{className:"flex items-center border border-line rounded overflow-hidden text-[11px]","data-testid":"view-mode-toggle",children:[c.jsx("button",{type:"button",onClick:()=>f(r,"wysiwyg"),className:`px-2 py-0.5 transition-colors ${x==="wysiwyg"?"bg-accent text-bg font-semibold":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,"data-testid":"view-mode-wysiwyg",children:"WYSIWYG"}),c.jsx("button",{type:"button",onClick:()=>f(r,"source"),className:`px-2 py-0.5 transition-colors ${x==="source"?"bg-accent text-bg font-semibold":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,"data-testid":"view-mode-source",children:"Source"})]}),r&&c.jsx("span",{className:"ml-2 text-fg-faint truncate flex-1 font-mono text-[11px]",title:r,children:r})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:k&&x==="wysiwyg"&&r&&h?c.jsx(B.Suspense,{fallback:c.jsx("div",{className:"p-4 text-fg-faint text-sm",children:"Loading editor…"}),children:c.jsx(D0e,{value:h.bufferText,onChange:y=>l(r,y)},r)}):k&&r&&h?c.jsx(Eu,{path:r,value:h.bufferText,onChange:y=>l(r,y)},r):r&&h?c.jsx(U0e,{path:r,value:h.bufferText,onChange:y=>l(r,y)}):null})]})}const W0e=5e3;let t0=null,Cv=null;async function gT(e){const r=Date.now();return!(e!=null&&e.fresh)&&t0&&r-t0.at<W0e?t0.result:Cv||(Cv=(async()=>{try{const n=await window.api.schedule.lintQueue();return t0={result:n,at:Date.now()},n}finally{Cv=null}})(),Cv)}const b5=2e3;function H0e(e){return e.is_error===!0||e.error!=null&&e.error!==""||e.type==="result"&&e.subtype!=="success"&&e.subtype!=null}function G0e(e){return typeof e.error=="string"&&e.error?e.error:typeof e.result=="string"&&e.result?e.result:typeof e.subtype=="string"?e.subtype:JSON.stringify(e).slice(0,200)}function V0e(e){if(typeof e.text=="string")return e.text.slice(0,200);if(typeof e.content=="string")return e.content.slice(0,200);if(Array.isArray(e.content)){for(const n of e.content)if(n&&typeof n=="object"&&"text"in n&&typeof n.text=="string")return n.text.slice(0,200)}const r=e.message;if(r&&typeof r=="object"){const n=r;if(typeof n.content=="string")return n.content.slice(0,200);if(Array.isArray(n.content)){for(const i of n.content)if(i&&typeof i=="object"&&"text"in i&&typeof i.text=="string")return i.text.slice(0,200)}}return typeof e.result=="string"&&e.result?e.result.slice(0,200):typeof e.subtype=="string"?e.subtype:JSON.stringify(e).slice(0,200)}function K0e(e){if(!e||!e.trim())return{events:[],errors:{count:0,firstMessage:null},rawLineCount:0,truncated:!1};const n=e.split(`
3517
+ `))if(a.includes('"cwd"'))try{const l=JSON.parse(a);if(typeof l.cwd=="string"&&l.cwd.length>0)return l.cwd}catch{}}}return null}function f0e(){const e=un(),[r,n]=B.useState([]),[i,s]=B.useState(!0),[a,l]=B.useState({}),o=Gt(m=>m.addTab);return B.useEffect(()=>{if(!e)return;let m=!1;return(async()=>{s(!0);try{const h=await window.api.config.listDir(`${e}/.claude/projects`,{dirsOnly:!0});if(m)return;const b=[];for(const x of h.entries){if(m)return;const _=(await window.api.config.listDir(x.path,{filesOnly:!0})).entries.filter(S=>S.name.endsWith(".jsonl")),y=_.reduce((S,C)=>Math.max(S,C.mtimeMs),0),w=_.reduce((S,C)=>S+C.size,0);b.push({encoded:x.name,displayPath:O8(x.name),sessionCount:_.length,lastSession:y,path:x.path,sizeBytes:w})}b.sort((x,k)=>k.lastSession-x.lastSession),m||(n(b),l({}))}catch(h){console.error("[useKnownProjects] scan failed:",h)}finally{m||s(!1)}})(),()=>{m=!0}},[e]),B.useEffect(()=>{if(!r.length)return;let m=!1;const h=r.slice();let b=0;const x=()=>{for(;!m&&b<6&&h.length;){const k=h.shift();b++,m5(k.path).then(async _=>{if(m)return;const y=_?await d0e(_):{};m||l(w=>({...w,[k.encoded]:{cwd:_??null,...y}}))}).catch(()=>{m||l(_=>({..._,[k.encoded]:{cwd:null}}))}).finally(()=>{b--,m||x()})}};return x(),()=>{m=!0}},[r]),{rows:r,enriched:a,loading:i,openInSession:async m=>{var x;let h=((x=a[m.encoded])==null?void 0:x.cwd)??null;if(h||(h=await m5(m.path)),!h&&(h=await window.api.app.pickDirectory(),!h))return;const b=crypto.randomUUID();o({id:b,cwd:h,startupCommand:`claude --dangerously-skip-permissions --session-id ${Ro(b)}`,presetId:"projects-tab"})},archiveProject:async m=>{try{const h=await window.api.app.archiveProject(m);return h.ok&&(n(b=>b.filter(x=>x.encoded!==m)),l(b=>{const x={...b};return delete x[m],x})),h}catch(h){return{ok:!1,error:h instanceof Error?h.message:"Archive failed"}}}}}const P8=e=>`sm.fileTree.expanded:${e}`;function h0e(e){try{const r=localStorage.getItem(P8(e)),n=r?JSON.parse(r):[];return Array.isArray(n)?n.filter(i=>typeof i=="string"):[]}catch{return[]}}function p0e(e,r){try{localStorage.setItem(P8(e),JSON.stringify([...r].slice(0,500)))}catch{}}function XC(e,r){const n=r+"/";let i=!1;const s=new Set;for(const a of e){if(a===r||a.startsWith(n)){i=!0;continue}s.add(a)}return i?s:e}const YC={modified:{color:"#e2a93d",label:"M"},added:{color:"#3fb950",label:"A"},deleted:{color:"#f85149",label:"D"},renamed:{color:"#a371f7",label:"R"},untracked:{color:"#8b949e",label:"U"},staged:{color:"#3fb950",label:"S"},conflict:{color:"#f85149",label:"!"}},m0e=new Set(["md","txt","json","jsonl","ndjson","js","jsx","ts","tsx","py","go","rs","rb","c","cpp","h","hpp","java","sh","bash","css","scss","html","xml","yaml","yml","toml","ini","conf","env","log","sql","gitignore","png","jpg","jpeg","gif","svg","webp"]);function g0e(e){const r=e.toLowerCase().split(".").pop()||"";return m0e.has(r)}function v0e(e,r){if(r)return"#d97757";switch(e.toLowerCase().split(".").pop()||""){case"ts":case"tsx":return"#3178c6";case"js":case"jsx":return"#f7df1e";case"json":return"#cbcb41";case"md":return"#8a93a0";case"css":case"scss":return"#cc6699";case"py":return"#3776ab";case"go":return"#00add8";case"rs":return"#dea584";case"sh":case"bash":return"#89e051";case"png":case"jpg":case"jpeg":case"gif":case"svg":return"#a4c639";default:return"#8a93a0"}}async function e0(e){var r;try{const n=window.api;return(r=n==null?void 0:n.git)!=null&&r.fileStatus?await n.git.fileStatus(e):{}}catch{return{}}}function y0e({cwd:e,onPreviewFile:r,onSendToChat:n,activeTabId:i}){const[s,a]=B.useState([]),[l,o]=B.useState(new Set),u=B.useRef(l);u.current=l;const[f,m]=B.useState(""),[h,b]=B.useState(!1),[x,k]=B.useState(!1),[_,y]=B.useState(null),[w,S]=B.useState({}),[C,T]=B.useState(null),[E,$]=B.useState(null),[N,O]=B.useState(""),[I,W]=B.useState(null),[H,V]=B.useState(""),[U,D]=B.useState(null),G=B.useRef(null),ee=B.useRef(null),ae=B.useRef(0),oe=B.useCallback(async()=>{if(!e)return;const Be=++ae.current;k(!0),y(null);const Ze=await window.api.files.list(e,h);ae.current===Be&&(Ze.ok?a(Ze.entries.map(dt=>({...dt}))):(y(Ze.error??"failed to list"),a([])),k(!1))},[e,h]),J=B.useCallback(async Be=>{const Ze=ae.current,dt=new Map;for(const or of Be){const Xt=or.split("/").length,ir=dt.get(Xt);ir?ir.push(or):dt.set(Xt,[or])}const ut=[];for(const or of[...dt.keys()].sort((Xt,ir)=>Xt-ir)){const Xt=dt.get(or),ir=await Promise.all(Xt.map(async sr=>({p:sr,result:await window.api.files.list(sr,h)})));if(ae.current!==Ze)return ut;for(const{p:sr,result:Or}of ir)Or.ok?a(Ar=>b0(Ar,sr,Or.entries.map(en=>({...en})))):ut.push(sr)}return ut},[h]),X=B.useCallback(async Be=>(await oe(),Be.length?J(Be):[]),[oe,J]);B.useEffect(()=>{m(""),$(null),T(null),W(null),D(null),S({});const Be=h0e(e),Ze=new Set(Be);u.current=Ze,o(Ze);let dt=!1;return(async()=>{const ut=await X(Be);dt||!ut.length||ne(or=>{const Xt=new Set;let ir=!1;for(const sr of or){if(ut.some(Or=>sr===Or||sr.startsWith(Or+"/"))){ir=!0;continue}Xt.add(sr)}return ir?Xt:or})})(),e0(e).then(ut=>{dt||S(ut)}),()=>{dt=!0}},[e]);const Z=B.useRef(!0);B.useEffect(()=>{if(Z.current){Z.current=!1;return}X([...u.current])},[h]),B.useEffect(()=>{if(!e)return;const Be=window.setInterval(()=>{e0(e).then(S)},5e3);return()=>window.clearInterval(Be)},[e]),B.useEffect(()=>{if(!C)return;const Be=()=>T(null),Ze=dt=>{dt.key==="Escape"&&T(null)};return window.addEventListener("mousedown",Be),window.addEventListener("keydown",Ze),()=>{window.removeEventListener("mousedown",Be),window.removeEventListener("keydown",Ze)}},[C]),B.useEffect(()=>{E&&setTimeout(()=>{var Be;return(Be=G.current)==null?void 0:Be.select()},30)},[E]),B.useEffect(()=>{I&&setTimeout(()=>{var Be;return(Be=ee.current)==null?void 0:Be.focus()},30)},[I]);const ne=B.useCallback(Be=>{const Ze=u.current,dt=Be(Ze);dt!==Ze&&(u.current=dt,o(dt),p0e(e,dt))},[e]),ce=B.useCallback(async Be=>{if(l.has(Be.path)){ne(dt=>XC(dt,Be.path));return}if(ne(dt=>new Set(dt).add(Be.path)),Be.children)return;const Ze=await window.api.files.list(Be.path,h);Ze.ok&&a(dt=>b0(dt,Be.path,Ze.entries.map(ut=>({...ut}))))},[l,h,ne]),ge=B.useCallback(async Be=>{if(Be===e){await oe();return}const Ze=await window.api.files.list(Be,h);Ze.ok&&a(dt=>b0(dt,Be,Ze.entries.map(ut=>({...ut}))))},[e,oe,h]),_e=B.useCallback(Be=>{if(Be.isDirectory){ce(Be);return}g0e(Be.name)&&r?r(Be.path):window.api.files.openExternal(Be.path)},[ce,r]),Te=B.useCallback(Be=>{if(n){n(Be);return}if(i){const Ze=Be.startsWith(e+"/")?Be.slice(e.length+1):Be;window.api.pty.write({tabId:i,data:`@${Ze} `})}},[n,i,e]),ye=B.useCallback((Be,Ze)=>{Be.preventDefault(),Be.stopPropagation(),T({x:Be.clientX,y:Be.clientY,node:Ze})},[]),ie=Be=>{$(Be.path),O(Be.name)},xe=async()=>{if(!E)return;const Be=N.trim();if(!Be){$(null);return}const Ze=await window.api.files.rename(E,Be);if($(null),Ze.ok){const dt=E.slice(0,E.lastIndexOf("/"));ne(ut=>XC(ut,E)),await ge(dt||e),e0(e).then(S)}else y(Ze.error??"rename failed")},we=async()=>{if(!I)return;const Be=H.trim();if(!Be){W(null),V("");return}const Ze=await window.api.files.create(I.parent,Be,I.kind);W(null),V(""),Ze.ok?(await ge(I.parent),I.kind==="folder"&&ne(dt=>new Set(dt).add(I.parent))):y(Ze.error??"create failed")},Ve=async()=>{if(!U)return;const Be=await window.api.files.delete(U.path),Ze=U.path.slice(0,U.path.lastIndexOf("/"));D(null),Be.ok?(ne(dt=>XC(dt,U.path)),await ge(Ze||e),e0(e).then(S)):y(Be.error??"delete failed")},Me=B.useMemo(()=>{if(!f.trim())return s;const Be=f.toLowerCase();return s.filter(Ze=>Ze.name.toLowerCase().includes(Be))},[s,f]),We=(e==null?void 0:e.split("/").filter(Boolean).pop())||"project";return c.jsxs("div",{className:"w-full h-full flex flex-col bg-bg-elev text-fg",children:[c.jsxs("div",{className:"p-3 border-b border-line shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2 mb-2 min-w-0",children:[c.jsx(M8,{size:14,className:"shrink-0 text-accent"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-xs font-medium text-fg truncate",children:We}),c.jsx("p",{className:"text-[10px] text-fg-faint truncate",title:e,children:e})]}),c.jsx("button",{onClick:oe,className:"p-1 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"Refresh",disabled:x,children:c.jsx(k0e,{size:12,className:x?"animate-spin":""})})]}),c.jsx("div",{className:"relative",children:c.jsx("input",{value:f,onChange:Be=>m(Be.target.value),placeholder:"Search files…",className:"w-full px-2 py-1 text-xs bg-bg-hi border border-line rounded text-fg placeholder-fg-faint focus:outline-none focus:border-accent/40"})})]}),c.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-line shrink-0",children:[c.jsx("button",{onClick:()=>W({parent:e,kind:"file"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New file",children:c.jsx(C0e,{size:12})}),c.jsx("button",{onClick:()=>W({parent:e,kind:"folder"}),className:"p-1.5 rounded text-fg-faint hover:text-fg hover:bg-bg-hi transition-colors",title:"New folder",children:c.jsx(E0e,{size:12})}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>b(Be=>!Be),className:`p-1.5 rounded transition-colors ${h?"text-accent":"text-fg-faint hover:text-fg"} hover:bg-bg-hi`,title:h?"Hide hidden files":"Show hidden files",children:h?c.jsx(j0e,{size:12}):c.jsx(T0e,{size:12})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto py-1",children:[_&&c.jsx("div",{className:"px-3 py-2 text-[11px] text-red-400",children:_}),!_&&Me.length===0&&!x&&c.jsx("div",{className:"p-4 text-center text-[11px] text-fg-faint",children:f?"no matches":"empty folder"}),!_&&c.jsx(R8,{nodes:Me,depth:0,expanded:l,gitStatus:w,renaming:E,renameValue:N,renameInputRef:G,onRenameChange:O,onRenameCommit:xe,onRenameCancel:()=>$(null),onToggleDir:ce,onFileClick:_e,onSendToChat:Te,onContextMenu:ye})]}),c.jsx("div",{className:"px-3 py-1.5 border-t border-line text-[10px] text-fg-faint shrink-0",children:"Click to preview · Double-click external · Right-click for more"}),C&&c.jsx(b0e,{x:C.x,y:C.y,node:C.node,onClose:()=>T(null),onRename:()=>{ie(C.node),T(null)},onDelete:()=>{D(C.node),T(null)},onNewFile:()=>{W({parent:C.node.path,kind:"file"}),T(null)},onNewFolder:()=>{W({parent:C.node.path,kind:"folder"}),T(null)},onOpenExternal:()=>{window.api.files.openExternal(C.node.path),T(null)},onShowInFinder:()=>{window.api.files.showInFinder(C.node.path),T(null)},onCopyPath:()=>{var Be;(Be=navigator.clipboard)==null||Be.writeText(C.node.path),T(null)},onSendToChat:()=>{Te(C.node.path),T(null)}}),I&&c.jsx(g5,{title:`New ${I.kind}`,subtitle:`in ${x0e(I.parent)}`,onCancel:()=>{W(null),V("")},onConfirm:we,confirmLabel:"Create",confirmDisabled:!H.trim(),children:c.jsx("input",{ref:ee,value:H,onChange:Be=>V(Be.target.value),onKeyDown:Be=>{Be.key==="Enter"&&we(),Be.key==="Escape"&&(W(null),V(""))},placeholder:I.kind==="file"?"filename.txt":"folder-name",className:"w-full px-3 py-2 rounded bg-bg-hi border border-line text-fg text-sm placeholder-fg-faint focus:outline-none focus:border-accent/50"})}),U&&c.jsx(g5,{title:`Delete ${U.isDirectory?"folder":"file"}`,subtitle:null,onCancel:()=>D(null),onConfirm:Ve,confirmLabel:"Delete",danger:!0,children:c.jsxs("p",{className:"text-sm text-fg-dim",children:["Move ",c.jsxs("span",{className:"text-fg font-medium",children:['"',U.name,'"']})," to the trash?",U.isDirectory&&c.jsx("span",{className:"block text-xs text-fg-faint mt-1",children:"All contents will be moved with it."})]})})]})}function R8(e){const{nodes:r,depth:n,expanded:i,gitStatus:s,renaming:a,onContextMenu:l}=e;return c.jsx(c.Fragment,{children:r.map(o=>{const u=i.has(o.path),f=a===o.path,m=s[o.path],h=v0e(o.name,o.isDirectory);return c.jsxs("div",{children:[c.jsxs("div",{className:"group flex items-center gap-1.5 py-0.5 pr-2 cursor-pointer transition-colors hover:bg-bg-hi",style:{paddingLeft:`${8+n*14}px`},onClick:()=>{f||(o.isDirectory?e.onToggleDir(o):e.onFileClick(o))},onDoubleClick:()=>{o.isDirectory||window.api.files.openExternal(o.path)},onContextMenu:b=>l(b,o),children:[o.isDirectory?c.jsx(S0e,{size:10,className:`shrink-0 text-fg-faint transition-transform ${u?"rotate-90":""}`}):c.jsx("span",{className:"w-[10px] shrink-0"}),o.isDirectory?u?c.jsx(w0e,{size:12,color:h}):c.jsx(M8,{size:12,color:h}):c.jsx(_0e,{size:12,color:h}),f?c.jsx("input",{ref:e.renameInputRef,value:e.renameValue,onChange:b=>e.onRenameChange(b.target.value),onClick:b=>b.stopPropagation(),onBlur:e.onRenameCommit,onKeyDown:b=>{b.key==="Enter"&&e.onRenameCommit(),b.key==="Escape"&&e.onRenameCancel()},className:"flex-1 min-w-0 px-1 py-0 text-xs bg-bg border border-accent/40 rounded text-fg focus:outline-none"}):c.jsx("span",{className:`flex-1 truncate text-xs ${o.name.startsWith(".")?"text-fg-faint":"text-fg-dim"}`,children:o.name}),m&&c.jsx("span",{className:"shrink-0 text-[9px] font-bold px-1 rounded",style:{color:YC[m].color,backgroundColor:`${YC[m].color}20`},title:m,children:YC[m].label}),!o.isDirectory&&c.jsx("button",{onClick:b=>{b.stopPropagation(),e.onSendToChat(o.path)},title:"Send @path to active terminal",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded text-fg-faint hover:text-accent hover:bg-bg transition-all shrink-0",children:c.jsx(A0e,{size:10})})]}),o.isDirectory&&u&&o.children&&c.jsx(R8,{...e,nodes:o.children,depth:n+1})]},o.path)})})}function b0e(e){const{x:r,y:n,node:i}=e;return c.jsxs("div",{onMouseDown:s=>s.stopPropagation(),className:"fixed z-[300] w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1",style:{left:r,top:n},children:[!i.isDirectory&&c.jsx(cu,{label:"Send to chat",onClick:e.onSendToChat}),c.jsx(cu,{label:"Open in default app",onClick:e.onOpenExternal}),c.jsx(cu,{label:"Reveal in OS",onClick:e.onShowInFinder}),c.jsx(JC,{}),c.jsx(cu,{label:"Copy path",onClick:e.onCopyPath}),c.jsx(cu,{label:"Rename",onClick:e.onRename}),i.isDirectory&&c.jsxs(c.Fragment,{children:[c.jsx(JC,{}),c.jsx(cu,{label:"New file",onClick:e.onNewFile}),c.jsx(cu,{label:"New folder",onClick:e.onNewFolder})]}),c.jsx(JC,{}),c.jsx(cu,{label:"Delete",onClick:e.onDelete,danger:!0})]})}function cu({label:e,onClick:r,danger:n}){return c.jsx("button",{onClick:r,className:`w-full text-left px-3 py-1.5 hover:bg-bg-hi transition-colors ${n?"text-red-400":"text-fg-dim hover:text-fg"}`,children:e})}function JC(){return c.jsx("div",{className:"my-1 border-t border-line"})}function g5(e){return c.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:r=>{r.target===r.currentTarget&&e.onCancel()},children:c.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[c.jsx("h3",{className:"text-sm font-medium text-fg mb-1",children:e.title}),e.subtitle&&c.jsx("p",{className:"text-[11px] text-fg-faint mb-3 truncate",children:e.subtitle}),c.jsx("div",{className:"mb-4",children:e.children}),c.jsxs("div",{className:"flex justify-end gap-2",children:[c.jsx("button",{onClick:e.onCancel,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded transition-colors",children:"Cancel"}),c.jsx("button",{onClick:e.onConfirm,disabled:!!e.confirmDisabled,className:`px-3 py-1 text-xs text-white rounded transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${e.danger?"bg-red-600 hover:bg-red-500":"bg-accent hover:bg-accent/90"}`,children:e.confirmLabel??"OK"})]})]})})}function x0e(e){return e.split("/").filter(Boolean).pop()||e}function b0(e,r,n){return e.map(i=>i.path===r?{...i,children:n}:i.children?{...i,children:b0(i.children,r,n)}:i)}function kl({size:e,children:r,className:n,color:i}){return c.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:i||"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,children:r})}function M8({size:e,className:r,color:n}){return c.jsx(kl,{size:e,className:r,color:n,children:c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function w0e({size:e,className:r,color:n}){return c.jsx(kl,{size:e,className:r,color:n,children:c.jsx("path",{d:"M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.93a2 2 0 0 1 1.66.9l.82 1.2a2 2 0 0 0 1.66.9H18a2 2 0 0 1 2 2v2"})})}function _0e({size:e,className:r,color:n}){return c.jsxs(kl,{size:e,className:r,color:n,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function S0e({size:e,className:r}){return c.jsx(kl,{size:e,className:r,children:c.jsx("polyline",{points:"9 18 15 12 9 6"})})}function k0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("polyline",{points:"23 4 23 10 17 10"}),c.jsx("polyline",{points:"1 20 1 14 7 14"}),c.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function C0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),c.jsx("polyline",{points:"14 2 14 8 20 8"}),c.jsx("line",{x1:"12",y1:"18",x2:"12",y2:"12"}),c.jsx("line",{x1:"9",y1:"15",x2:"15",y2:"15"})]})}function E0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"}),c.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"17"}),c.jsx("line",{x1:"9",y1:"14",x2:"15",y2:"14"})]})}function j0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function T0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"}),c.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function A0e({size:e,className:r}){return c.jsxs(kl,{size:e,className:r,children:[c.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),c.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function QC(e){const r="/home/";if(e.startsWith(r)){const n=e.slice(r.length).split("/").slice(1).join("/");return n?`~/${n}`:"~"}return e}const hT="sm.projects.splitPct",pT=33,I8=20,D8=60,L8="sm.projects.fileTreeCollapsed",$0e=32;function N0e(){try{const e=parseFloat(localStorage.getItem(hT)??"");if(Number.isFinite(e))return Math.min(D8,Math.max(I8,e))}catch{}return pT}function O0e(){try{return localStorage.getItem(L8)==="1"}catch{return!1}}function P0e(){const e=Gt(N=>N.tabs),r=Gt(N=>N.activeTabId),n=e.find(N=>N.id===r)??null,[i,s]=B.useState(()=>N0e()),[a,l]=B.useState(()=>O0e()),[o,u]=B.useState(!1),f=B.useRef(i);f.current=i;const m=B.useRef(null),h=B.useRef(null),{rows:b,enriched:x,openInSession:k,archiveProject:_}=f0e(),y=p5(N=>N.pinned),w=p5(N=>N.togglePin),S=[...b].sort((N,O)=>(y[O.encoded]?1:0)-(y[N.encoded]?1:0));B.useEffect(()=>{if(!o)return;const N=O=>{h.current&&!h.current.contains(O.target)&&u(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[o]);const C=B.useCallback(N=>{xn.getState().openFile(N)},[]),T=B.useCallback(N=>{N.preventDefault();const O=N.clientX,I=f.current;let W=I;const H=U=>{const D=m.current;if(!D)return;const G=D.getBoundingClientRect(),ee=U.clientX-O;W=Math.min(D8,Math.max(I8,I+ee/G.width*100)),s(W)},V=()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",V),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(hT,String(W))}catch{}};window.addEventListener("pointermove",H),window.addEventListener("pointerup",V),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),E=B.useCallback(()=>{s(pT);try{localStorage.setItem(hT,String(pT))}catch{}},[]),$=B.useCallback(()=>{l(N=>{const O=!N;try{localStorage.setItem(L8,O?"1":"0")}catch{}return O})},[]);return a?c.jsxs("div",{ref:m,className:"flex h-full w-full","data-testid":"projects-workspace",children:[c.jsxs("button",{onClick:$,"data-testid":"projects-file-tree-rail-toggle",title:"Show file explorer",className:"shrink-0 flex flex-col items-center gap-2 py-2 border-r border-line text-fg-faint hover:text-fg hover:bg-surface-raised transition-colors",style:{width:$0e},children:[c.jsx("span",{className:"text-[11px]",children:"▸"}),c.jsx("span",{className:"text-[10px] tracking-wide [writing-mode:vertical-rl]",children:"Files"})]}),c.jsx("div",{className:"flex-1 min-w-0","data-testid":"projects-editor-pane",children:c.jsx(Hj,{})})]}):c.jsxs("div",{ref:m,className:"flex h-full w-full","data-testid":"projects-workspace",children:[c.jsxs("div",{className:"shrink-0 flex flex-col border-r border-line overflow-hidden",style:{width:`${i}%`},"data-testid":"projects-file-tree-pane",children:[c.jsxs("div",{ref:h,className:"relative shrink-0 flex items-stretch border-b border-line",children:[c.jsxs("button",{"data-testid":"projects-launcher-trigger",onClick:()=>u(N=>!N),className:"flex-1 min-w-0 px-3 py-1.5 text-[11.5px] text-fg-dim font-mono flex items-center gap-1 hover:bg-surface-raised transition-colors",children:[c.jsx("span",{className:"flex-1 truncate text-left",children:n?QC(n.cwd):"Projects"}),c.jsx("span",{className:"text-fg-faint shrink-0 text-[10px]",children:o?"▲":"▼"})]}),c.jsx("button",{onClick:$,"data-testid":"projects-file-tree-collapse",title:"Hide file explorer",className:"shrink-0 px-2 border-l border-line text-fg-faint hover:text-fg hover:bg-surface-raised transition-colors text-[11px]",children:"◂"}),o&&c.jsx("div",{"data-testid":"projects-launcher-list",className:"absolute left-0 right-0 top-full z-50 bg-surface border border-line shadow-lg max-h-60 overflow-auto",children:S.length===0?c.jsx("div",{className:"px-3 py-2 text-[11.5px] text-fg-faint",children:"No projects found."}):S.map(N=>{var I;const O=QC(((I=x[N.encoded])==null?void 0:I.cwd)??O8(N.encoded));return c.jsxs("div",{"data-testid":"projects-launcher-row",className:"flex items-center gap-1 px-2 py-1 hover:bg-surface-raised group",children:[c.jsx(rm,{content:y[N.encoded]?"Unpin":"Pin to top",children:c.jsx("button",{onClick:()=>w(N.encoded),className:`shrink-0 text-sm leading-none transition-colors ${y[N.encoded]?"text-yellow-400":"text-fg-faint hover:text-fg-dim"}`,children:y[N.encoded]?"★":"☆"})}),c.jsx("button",{onClick:()=>{k(N),u(!1)},className:"flex-1 min-w-0 text-left text-[11.5px] font-mono truncate text-fg-dim hover:text-fg",children:O}),c.jsx("button",{onClick:async()=>{window.confirm(`Archive ${O}?`)&&await _(N.encoded)},className:"shrink-0 text-[10px] text-fg-faint hover:text-red-400 opacity-0 group-hover:opacity-100 transition-opacity",title:"Archive",children:"✕"})]},N.encoded)})})]}),n?c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-3 py-2 border-b border-line text-[11.5px] text-fg-faint font-mono truncate shrink-0",title:n.cwd,children:QC(n.cwd)}),c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:c.jsx(y0e,{cwd:n.cwd,activeTabId:n.id,onPreviewFile:C})})]}):c.jsx("div",{className:"px-3 py-6 text-center text-[12px] text-fg-faint",children:"No session selected."})]}),c.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:T,onDoubleClick:E,className:"w-1.5 shrink-0 cursor-col-resize hover:bg-accent/40 active:bg-accent/60 transition-colors"}),c.jsx("div",{className:"flex-1 min-w-0","data-testid":"projects-editor-pane",children:c.jsx(Hj,{})})]})}const mT="~/.config/session-manager/doc-editor.json",R0e=20;let ZC=null;function kv(e){ZC&&clearTimeout(ZC),ZC=setTimeout(async()=>{const r=e();try{const n=await window.api.config.readJson(mT).catch(()=>null),i=(n==null?void 0:n.data)??{};await window.api.config.writeJson(mT,{...i,recents:r.recents,openPaths:Object.keys(r.docs),viewModes:r.viewModes})}catch(n){console.warn("[docEditor] persist failed:",n)}},500)}function v5(e,r){return[r,...e.filter(n=>n!==r)].slice(0,R0e)}const fa=jn((e,r)=>({docs:{},activePath:null,recents:[],viewModes:{},hydrated:!1,open:async n=>{if(r().docs[n]){e({activePath:n});return}const s=await window.api.docEditor.readFile(n);if(!s.ok){it.warn(`Could not open ${n.split("/").pop()}: ${s.error??"unknown error"}`),e(l=>({recents:l.recents.filter(o=>o!==n)})),kv(r);return}const a={path:n,diskText:s.text??"",bufferText:s.text??"",mtimeMs:s.mtimeMs??0,loadedAt:Date.now()};e(l=>({docs:{...l.docs,[n]:a},activePath:n,recents:v5(l.recents,n)})),kv(r)},close:n=>{var o;const i=r(),s=i.docs[n];if(!s)return;if(s.bufferText!==s.diskText){const u=n.split("/").pop()??n;if(!window.confirm(`"${u}" has unsaved changes. Close without saving?`))return}const a={...i.docs};delete a[n];let l=i.activePath;i.activePath===n&&(l=((o=Object.values(a).sort((f,m)=>m.loadedAt-f.loadedAt)[0])==null?void 0:o.path)??null),e({docs:a,activePath:l}),kv(r)},setActive:n=>{e({activePath:n})},setViewMode:(n,i)=>{e(s=>({viewModes:{...s.viewModes,[n]:i}})),kv(r)},edit:(n,i)=>{const s=r().docs[n];s&&e(a=>({docs:{...a.docs,[n]:{...s,bufferText:i}}}))},save:async n=>{const i=r().docs[n];if(!i)return;const s=i.bufferText,a=await window.api.docEditor.writeFile(n,s);if(!a.ok){it.error(`Save failed for ${n.split("/").pop()}: ${a.error??"unknown"}`);return}e(l=>{const o=l.docs[n];return o?{docs:{...l.docs,[n]:{...o,diskText:s,mtimeMs:a.mtimeMs??o.mtimeMs}},recents:v5(l.recents,n)}:{}}),kv(r)},saveAll:async()=>{const n=Object.values(r().docs).filter(i=>i.bufferText!==i.diskText).map(i=>i.path);await Promise.all(n.map(i=>r().save(i)))},hydrate:async()=>{if(!r().hydrated){e({hydrated:!0});try{const i=(await window.api.config.readJson(mT)).data??{},s=Array.isArray(i.recents)?i.recents:[],a=Array.isArray(i.openPaths)?i.openPaths:[],l=i.viewModes??{},o={};for(const[u,f]of Object.entries(l))(f==="wysiwyg"||f==="source")&&(o[u]=f);e({recents:s,viewModes:o});for(const u of a)await r().open(u)}catch(n){console.warn("[docEditor] hydrate failed:",n)}}}}));window.__docEditor=fa;const M0e={json:"json",ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",cjs:"javascript",mjs:"javascript",py:"python",sh:"shell",bash:"shell",yaml:"yaml",yml:"yaml",toml:"ini",css:"css",html:"html",xml:"xml",sql:"sql",rs:"rust",go:"go",md:"markdown",markdown:"markdown"},y5={Dockerfile:"dockerfile",Makefile:"makefile"};function I0e(e){const r=e.split("/").pop()??e;if(y5[r])return y5[r];const n=r.lastIndexOf(".");if(n===-1)return null;const i=r.slice(n+1);return M0e[i]??null}const D0e=B.lazy(()=>em(()=>import("./TiptapBody-Py59G5JF.js"),__vite__mapDeps([2,0,1]),import.meta.url).then(e=>({default:e.TiptapBody})));function L0e(e){return e.split("/").pop()??e}function B0e(e){return e.endsWith(".md")||e.endsWith(".markdown")}function z0e({docs:e,activePath:r,onSetActive:n,onClose:i}){const s=Object.keys(e);return c.jsx("div",{className:"h-9 bg-bg-elev border-b border-line flex items-center overflow-x-auto shrink-0 px-2 gap-1","data-testid":"doc-tab-strip",children:s.map(a=>{const l=e[a],o=l.bufferText!==l.diskText,u=L0e(a),f=a===r;return c.jsxs("div",{className:`group px-3 py-1 flex items-center gap-1 rounded-t text-xs shrink-0 cursor-pointer transition-colors ${f?"bg-bg-hi text-fg font-semibold border border-b-0 border-accent border-t-2 -mb-px relative z-10":"bg-bg-elev text-fg-dim border border-line hover:text-fg hover:bg-bg"}`,onClick:()=>n(a),title:a,"data-testid":`doc-tab-${u}`,children:[o&&c.jsx("span",{className:"text-amber-400","aria-label":"unsaved changes","data-testid":"doc-tab-dirty",children:"●"}),c.jsx("span",{children:u}),c.jsx("button",{type:"button",onClick:m=>{m.stopPropagation(),i(a)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1",title:`Close ${u}`,"aria-label":`Close ${u}`,"data-testid":`doc-x-${u}`,children:"×"})]},a)})})}function F0e({path:e,value:r,onChange:n,language:i}){const s=B.useRef(null),a=B.useRef(e);a.current=e;const l=async o=>{s.current=o;const u=await em(()=>import("./monaco-editor-BW5C4Iv1.js").then(f=>f.b),__vite__mapDeps([0,1]),import.meta.url);o.addCommand(u.KeyMod.CtrlCmd|u.KeyCode.KeyS,()=>{fa.getState().save(a.current)})};return c.jsx(Qw,{path:`file://${e}`,language:i,value:r,onChange:o=>n(o??""),onMount:l,theme:"vs-dark",options:{minimap:{enabled:!1},fontSize:12,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,formatOnPaste:!0,automaticLayout:!0,bracketPairColorization:{enabled:!0},wordWrap:"on"}})}function U0e({path:e,value:r,onChange:n}){const i=I0e(e);if(!i){const s=e.split("/").pop()??e;return c.jsx("textarea",{className:"w-full h-full resize-none bg-bg text-fg font-mono text-sm p-3 focus:outline-none leading-relaxed",value:r,onChange:a=>n(a.target.value),spellCheck:!1,"data-testid":"doc-textarea","aria-label":`Edit ${s}`},e)}return c.jsx(F0e,{path:e,value:r,onChange:n,language:i})}function q0e(){const e=fa(y=>y.docs),r=fa(y=>y.activePath),n=fa(y=>y.viewModes),i=fa(y=>y.open),s=fa(y=>y.close),a=fa(y=>y.setActive),l=fa(y=>y.edit),o=fa(y=>y.save),u=fa(y=>y.saveAll),f=fa(y=>y.setViewMode),m=fa(y=>y.hydrate);B.useEffect(()=>{m()},[m]);const h=r?e[r]??null:null,b=Object.values(e).some(y=>y.bufferText!==y.diskText),x=r?n[r]??"wysiwyg":"wysiwyg",k=r?B0e(r):!1,_=async()=>{const y=r?r.split("/").slice(0,-1).join("/"):void 0,w=await window.api.docEditor.pickFile(y?{lastDir:y}:void 0);w.path&&await i(w.path)};return r===null?c.jsx(Wt,{title:"No document open",hint:c.jsxs("span",{children:["Click ",c.jsx("strong",{children:"Open…"})," or use"," ",c.jsx("kbd",{className:"px-1 py-0.5 border border-line rounded font-mono text-[10px]",children:"Cmd-K"})," ","and type ",c.jsx("code",{children:"doc:open"})]})}):c.jsxs("div",{className:"h-full flex flex-col",onKeyDown:y=>{(y.ctrlKey||y.metaKey)&&y.key.toLowerCase()==="s"&&!y.shiftKey&&(y.preventDefault(),r&&o(r)),(y.ctrlKey||y.metaKey)&&y.key.toLowerCase()==="w"&&!y.shiftKey&&(y.preventDefault(),r&&s(r))},"data-testid":"doc-editor-panel",children:[c.jsx(z0e,{docs:e,activePath:r,onSetActive:a,onClose:s}),c.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-2 text-xs",children:[c.jsx("button",{type:"button",onClick:_,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors","data-testid":"doc-open-btn",children:"Open…"}),c.jsx("button",{type:"button",onClick:()=>r&&o(r),disabled:!h||h.bufferText===h.diskText,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"doc-save-btn",children:"Save"}),c.jsx("button",{type:"button",onClick:()=>u(),disabled:!b,className:"px-2 py-1 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi transition-colors disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"doc-save-all-btn",children:"Save All"}),k&&r&&c.jsxs("div",{className:"flex items-center border border-line rounded overflow-hidden text-[11px]","data-testid":"view-mode-toggle",children:[c.jsx("button",{type:"button",onClick:()=>f(r,"wysiwyg"),className:`px-2 py-0.5 transition-colors ${x==="wysiwyg"?"bg-accent text-bg font-semibold":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,"data-testid":"view-mode-wysiwyg",children:"WYSIWYG"}),c.jsx("button",{type:"button",onClick:()=>f(r,"source"),className:`px-2 py-0.5 transition-colors ${x==="source"?"bg-accent text-bg font-semibold":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,"data-testid":"view-mode-source",children:"Source"})]}),r&&c.jsx("span",{className:"ml-2 text-fg-faint truncate flex-1 font-mono text-[11px]",title:r,children:r})]}),c.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:k&&x==="wysiwyg"&&r&&h?c.jsx(B.Suspense,{fallback:c.jsx("div",{className:"p-4 text-fg-faint text-sm",children:"Loading editor…"}),children:c.jsx(D0e,{value:h.bufferText,onChange:y=>l(r,y)},r)}):k&&r&&h?c.jsx(Eu,{path:r,value:h.bufferText,onChange:y=>l(r,y)},r):r&&h?c.jsx(U0e,{path:r,value:h.bufferText,onChange:y=>l(r,y)}):null})]})}const W0e=5e3;let t0=null,Cv=null;async function gT(e){const r=Date.now();return!(e!=null&&e.fresh)&&t0&&r-t0.at<W0e?t0.result:Cv||(Cv=(async()=>{try{const n=await window.api.schedule.lintQueue();return t0={result:n,at:Date.now()},n}finally{Cv=null}})(),Cv)}const b5=2e3;function H0e(e){return e.is_error===!0||e.error!=null&&e.error!==""||e.type==="result"&&e.subtype!=="success"&&e.subtype!=null}function G0e(e){return typeof e.error=="string"&&e.error?e.error:typeof e.result=="string"&&e.result?e.result:typeof e.subtype=="string"?e.subtype:JSON.stringify(e).slice(0,200)}function V0e(e){if(typeof e.text=="string")return e.text.slice(0,200);if(typeof e.content=="string")return e.content.slice(0,200);if(Array.isArray(e.content)){for(const n of e.content)if(n&&typeof n=="object"&&"text"in n&&typeof n.text=="string")return n.text.slice(0,200)}const r=e.message;if(r&&typeof r=="object"){const n=r;if(typeof n.content=="string")return n.content.slice(0,200);if(Array.isArray(n.content)){for(const i of n.content)if(i&&typeof i=="object"&&"text"in i&&typeof i.text=="string")return i.text.slice(0,200)}}return typeof e.result=="string"&&e.result?e.result.slice(0,200):typeof e.subtype=="string"?e.subtype:JSON.stringify(e).slice(0,200)}function K0e(e){if(!e||!e.trim())return{events:[],errors:{count:0,firstMessage:null},rawLineCount:0,truncated:!1};const n=e.split(`
3518
3518
  `).filter(f=>f.trim().length>0),i=n.length,s=i>b5,a=s?n.slice(0,b5):n,l=[];let o=0,u=null;for(const f of a){let m=null;try{const h=JSON.parse(f);h!==null&&typeof h=="object"&&!Array.isArray(h)&&"type"in h&&(m=h)}catch{}if(m!==null){const h=typeof m.type=="string"?m.type:"unknown",b=H0e(m);b&&(o++,u===null&&(u=G0e(m))),l.push({type:h,raw:f,preview:V0e(m),isError:b})}else l.push({type:"raw",raw:f,preview:f.slice(0,200),isError:!1})}return{events:l,errors:{count:o,firstMessage:u},rawLineCount:i,truncated:s}}const X0e={assistant:"accent",user:"default",system:"dim",result:"warn",tool_use:"default",tool_result:"default",raw:"dim"};function Y0e(e){return X0e[e]??"default"}function B8({runId:e,slug:r,title:n,onClose:i}){const[s,a]=B.useState(!0),[l,o]=B.useState(null),[u,f]=B.useState(""),[m,h]=B.useState(null),[b,x]=B.useState("parsed");return B.useEffect(()=>{a(!0),o(null),window.api.schedule.readLog(e,r).then(k=>{if(k.ok){const _=k.text??"";f(_),h(K0e(_))}else{const _=k.error??"Failed to read log";o(_),it.error(`Log read failed: ${_}`)}}).catch(k=>{const _=k instanceof Error?k.message:String(k);o(_),it.error(`Log read failed: ${_}`)}).finally(()=>a(!1))},[e,r]),c.jsx(Tu,{open:!0,onClose:i,size:"xl",fillHeight:!0,noPadding:!0,title:n,children:c.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[c.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 py-2 border-b border-line",children:[c.jsx("button",{type:"button",onClick:()=>x("parsed"),className:`text-[10px] px-2 py-0.5 rounded border ${b==="parsed"?"bg-accent/20 text-accent border-accent/40":"text-fg-faint border-line hover:text-fg-dim hover:border-fg-faint"}`,children:"Parsed"}),c.jsx("button",{type:"button",onClick:()=>x("raw"),className:`text-[10px] px-2 py-0.5 rounded border ${b==="raw"?"bg-accent/20 text-accent border-accent/40":"text-fg-faint border-line hover:text-fg-dim hover:border-fg-faint"}`,children:"Raw"}),c.jsxs("span",{className:"ml-auto text-[10px] text-fg-faint font-mono",children:[r," · ",e.slice(0,8)]}),c.jsx("button",{type:"button",onClick:i,className:"text-fg-faint hover:text-fg-dim text-sm leading-none ml-1","aria-label":"Close",children:"×"})]}),c.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[s&&c.jsx("div",{className:"flex-1 flex items-center justify-center text-[11px] text-fg-faint",children:"Loading log…"}),!s&&l&&c.jsx("div",{className:"flex-1 flex items-center justify-center",children:c.jsx("div",{className:"text-[11px] text-red-300 px-6 text-center max-w-md",children:l})}),!s&&!l&&b==="raw"&&c.jsx("pre",{className:"flex-1 overflow-auto p-4 text-[10px] font-mono text-fg-dim whitespace-pre-wrap break-all leading-relaxed",children:u||c.jsx("span",{className:"text-fg-faint italic",children:"log is empty"})}),!s&&!l&&b==="parsed"&&m&&c.jsx(J0e,{parsed:m,onSwitchRaw:()=>x("raw")})]})]})})}function J0e({parsed:e,onSwitchRaw:r}){const{events:n,errors:i,rawLineCount:s,truncated:a}=e;return n.length===0?c.jsx("div",{className:"flex-1 flex items-center justify-center text-[11px] text-fg-faint italic",children:"log is empty"}):c.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[c.jsx("div",{className:`shrink-0 px-4 py-2 border-b border-line text-[11px] ${i.count>0?"bg-red-950/20":"bg-bg-elev/50"}`,children:i.count>0?c.jsxs("span",{className:"text-red-300",children:[c.jsxs("span",{className:"font-medium",children:[i.count," error",i.count===1?"":"s"," detected"]}),i.firstMessage&&c.jsx("span",{className:"text-red-300/70 ml-2 font-mono",children:i.firstMessage.slice(0,120)})]}):c.jsx("span",{className:"text-green-400/70",children:"no errors detected"})}),a&&c.jsxs("div",{className:"shrink-0 px-4 py-1.5 border-b border-line bg-yellow-950/20 text-[10px] text-yellow-400/80",children:["showing first ",n.length," of ",s," events —"," ",c.jsx("button",{type:"button",onClick:r,className:"underline hover:text-yellow-300",children:"open Raw for full"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto",children:n.map((l,o)=>c.jsx(Q0e,{event:l},o))})]})}function Q0e({event:e}){const[r,n]=B.useState(!1),i=e.type==="raw";return c.jsxs("div",{className:`flex items-start gap-2 px-3 py-1 border-b border-line/30 cursor-pointer hover:bg-bg-hi ${e.isError?"bg-red-950/10":""}`,onClick:()=>n(s=>!s),children:[c.jsx("div",{className:"shrink-0 pt-0.5 w-16",children:i?c.jsx("span",{className:"text-[9px] text-fg-faint/50 font-mono",children:"raw"}):c.jsx(Bn,{tone:Y0e(e.type),className:"text-[9px]",children:e.type})}),c.jsx("div",{className:"flex-1 min-w-0",children:r?c.jsx("pre",{className:"text-[10px] font-mono text-fg-dim whitespace-pre-wrap break-all",children:e.raw}):c.jsx("span",{className:`text-[10px] truncate block ${i?"text-fg-faint/60 font-mono":"text-fg-dim"}`,children:e.preview||c.jsx("span",{className:"italic text-fg-faint/40",children:"(empty)"})})})]})}function z8({options:e,value:r,onChange:n,pillPadding:i="px-3 py-1.5"}){return c.jsx("div",{className:"flex gap-1.5 flex-wrap",children:e.map(s=>{const a=s.value===r;return c.jsx("button",{type:"button",onClick:()=>n(s.value),className:`rounded-full ${i} text-[12.5px] border transition-colors ${a?"bg-accent text-white border-accent font-semibold":"bg-bg-hi text-fg-dim border-line hover:border-fg-faint font-medium"}`,children:s.label},s.value)})})}const x5=["#6f7d52","#b85c34","#8a7a60","#e4b85a","#5f6f86","#4f7d72","#8a5a6e"];function Z0e(e){let r=0;for(let n=0;n<e.length;n++)r=r*31+e.charCodeAt(n)>>>0;return r}function ewe(e,r){const n=e?e.split("/").filter(Boolean).pop()??"":r??"";return x5[Z0e(n)%x5.length]}const twe={running:"bg-accent text-white",pending:"bg-bg text-fg-dim border border-line",completed:"bg-sage/20 text-sage",needs_review:"bg-butter/25 text-fg-dim",failed:"bg-accent/15 text-accent"},rwe={pending:"○",completed:"✓",needs_review:"!",failed:"✕"};function F8({status:e}){const r=rwe[e];return c.jsxs("span",{className:`inline-flex items-center gap-1.5 shrink-0 px-2.5 py-1 rounded-lg min-w-[104px] justify-center text-xs font-semibold tracking-wide ${twe[e]}`,role:"status","aria-label":`Status: ${e.replace("_"," ")}`,children:[e==="running"?c.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white animate-pulse","aria-hidden":"true"}):r&&c.jsx("span",{"aria-hidden":"true",children:r}),e.replace("_"," ")]})}function o$({cwd:e,name:r}){const n=r??(e?e.split("/").filter(Boolean).pop()??e:"—"),i=ewe(e,r);return c.jsxs("span",{className:"inline-flex items-center gap-1.5 font-mono text-xs text-fg-faint",children:[c.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:i},"aria-hidden":"true"}),n]})}function bu({label:e,children:r}){return c.jsxs("div",{children:[c.jsx("div",{className:"text-[11px] font-bold tracking-[0.7px] uppercase text-fg-faint mb-2",children:e}),c.jsx("div",{className:"grid gap-1.5",children:r})]})}function ji({k:e,v:r,wrap:n}){return c.jsxs("div",{className:"flex gap-2 font-mono text-xs leading-relaxed",children:[c.jsx("span",{className:"text-fg-faint shrink-0 w-14",children:e}),c.jsx("span",{className:`text-fg ${n?"break-all":""}`,children:r})]})}function eE({dotClass:e,n:r,label:n}){return c.jsxs("span",{className:"inline-flex items-center gap-1.5 text-[13px] text-fg-dim",children:[c.jsx("span",{className:`w-2 h-2 rounded-full ${e}`,"aria-hidden":"true"}),c.jsx("strong",{className:"text-fg font-mono text-[13.5px]",children:r})," ",n]})}function hp(e){const r=e.match(/^(\d+)-/);return r?r[1]:null}function U8({n:e}){return c.jsxs("span",{className:"font-mono text-[12px] font-semibold text-fg-faint shrink-0 tracking-tight select-none","aria-hidden":"true",children:["#",e]})}const nwe={running:{bg:"bg-butter/30",text:"text-fg-dim",border:!1,label:"running"},queued:{bg:"bg-sage/25",text:"text-sage",border:!1,label:"queued"},ready:{bg:"bg-bg",text:"text-fg-dim",border:!0,label:"ready to run"},draft:{bg:"bg-bg",text:"text-fg-faint",border:!0,label:"draft"},completed:{bg:"bg-sage/20",text:"text-sage",border:!1,label:"completed"},failed:{bg:"bg-accent/15",text:"text-accent",border:!1,label:"failed"},needs_review:{bg:"bg-butter/25",text:"text-fg-dim",border:!1,label:"needs review"}},iwe=5,swe=1440*60*1e3,q8="sm.scheduler.hiddenCompletedSlugs",r0="sm.scheduler.focusedJobIndex",W8="sm.scheduler.queueFilter",awe=["all","running","pending","completed","needs_review","failed"];function owe(){try{const e=localStorage.getItem(W8);if(!e)return{text:"",status:"all"};const r=JSON.parse(e);return{text:"",status:awe.includes(r.status)?r.status:"all"}}catch{return{text:"",status:"all"}}}function lwe(e){try{localStorage.setItem(W8,JSON.stringify({status:e.status}))}catch{}}function cwe(e,r){if(r.status==="all"&&!r.text)return e;const n=r.text.toLowerCase();return e.filter(i=>{if(r.status!=="all"&&i.status!==r.status)return!1;if(!n)return!0;const s=dwe(i.cwd)??"";return i.title.toLowerCase().includes(n)||i.slug.toLowerCase().includes(n)||s.toLowerCase().includes(n)})}const w5={halt:"verifier halted",deps_unmet:"dependencies unmet",transcript_errors:"transcript had errors",verify_unavailable:"verify unavailable",uncommitted_changes:"uncommitted changes"};function uwe(){try{const e=localStorage.getItem(q8);if(!e)return new Set;const r=JSON.parse(e);return Array.isArray(r)?new Set(r.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function _5(e){try{localStorage.setItem(q8,JSON.stringify([...e]))}catch{}}function dwe(e){if(!e)return null;const r=e.replace(/\/+$/,"").split("/");return r[r.length-1]||e}function fwe(){const e=ku(_e=>_e.snapshot),[r,n]=B.useState(null),[i,s]=B.useState(!1),[a,l]=B.useState(()=>Date.now()),[o,u]=B.useState(()=>uwe()),[f,m]=B.useState(!1),[h,b]=B.useState(()=>owe()),[x,k]=B.useState(!1),[_,y]=B.useState("queue"),w=B.useRef(null),[S,C]=B.useState(()=>{try{return Number(localStorage.getItem(r0))||0}catch{return 0}}),[T,E]=B.useState("");B.useEffect(()=>(window.api.schedule.health().then(n).catch(()=>{}),window.api.schedule.onState(()=>{window.api.schedule.health().then(n).catch(()=>{})})),[]),B.useEffect(()=>{const _e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(_e)},[]);const $=B.useMemo(()=>{if(!e)return 15e4;const _e=[];for(const Te of e.jobs)if(Te.status==="completed"&&Te.startedAt&&Te.finishedAt){const ye=Date.parse(Te.finishedAt)-Date.parse(Te.startedAt);ye>0&&_e.push(ye)}return _e.length===0?15e4:_e.reduce((Te,ye)=>Te+ye,0)/_e.length},[e]),N=B.useRef(new Map);if(B.useEffect(()=>{if(!e)return;const _e=[];for(const Te of e.jobs){const ye=N.current.get(Te.slug);ye&&ye!==Te.status&&_e.push(`${Te.title}: ${ye} → ${Te.status}`),N.current.set(Te.slug,Te.status)}_e.length>0&&E(_e.join("; "))},[e]),!e)return null;if(_==="supervisor")return c.jsx(wwe,{supervisorConfig:e.config.supervisor,onSetConfig:_e=>window.api.schedule.setConfig({supervisor:_e}),onBack:()=>y("queue")});const{config:O,jobs:I,paused:W,lastRunAt:H,nextReset:V}=e,U={pending:0,running:0,completed:0,needs_review:0,failed:0};for(const _e of I)_e.status in U&&U[_e.status]++;const D=I.filter(_e=>_e.status==="running"),G=hwe({snap:e,now:a,avgDurationMs:$,runningJobs:D}),ee=cwe(I,h),ae=pwe(ee),{inline:oe,collapsedCount:J}=mwe(ee,o,a,f),X=()=>{const _e=new Set(o);for(const Te of I)(Te.status==="completed"||Te.status==="failed")&&_e.add(Te.slug);u(_e),_5(_e)},Z=async()=>{const _e=I.filter(ie=>ie.status!=="running").length;if(_e===0)return;const Te=`Archive ${_e} non-running PRD${_e===1?"":"s"} and remove from the queue?
3519
3519
 
3520
3520
  Files are moved to prds-archived/<timestamp>/ and can be restored from disk. Running jobs are kept.`;if(!window.confirm(Te))return;const ye=await window.api.schedule.clearQueue();ye.ok||it.error(`Clear queue failed: ${ye.error??"unknown error"}`)},ne=()=>{u(new Set),_5(new Set),m(!1)},ce=oe.some(_e=>_e.status==="completed"),ge=B.useCallback(_e=>{var ye,ie,xe;const Te=(ye=w.current)==null?void 0:ye.querySelectorAll("[data-job-row]");if(!(!Te||Te.length===0)){if(_e.key==="ArrowDown"){_e.preventDefault();const we=Math.min(S+1,Te.length-1);C(we);try{localStorage.setItem(r0,String(we))}catch{}(ie=Te[we])==null||ie.focus()}else if(_e.key==="ArrowUp"){_e.preventDefault();const we=Math.max(S-1,0);C(we);try{localStorage.setItem(r0,String(we))}catch{}(xe=Te[we])==null||xe.focus()}}},[S]);return c.jsxs("div",{className:"overflow-y-auto h-full",children:[c.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:T}),c.jsxs("div",{className:"px-9 py-6 max-w-[1100px] mx-auto space-y-4",children:[c.jsxs("div",{className:`flex flex-wrap items-center gap-3 px-4 py-3 rounded-xl border ${vwe(G.kind)}`,title:G.tooltip,children:[c.jsxs("div",{className:"flex items-center gap-2.5 min-w-0 flex-1",children:[c.jsx(gwe,{kind:G.kind}),c.jsxs("div",{className:"min-w-0",children:[c.jsx("div",{className:"text-[13px] font-medium text-fg truncate",children:G.line1}),G.line2&&c.jsx("div",{className:"text-[11.5px] text-fg-faint font-mono mt-0.5 truncate",children:G.line2})]})]}),G.action&&c.jsx("button",{type:"button",onClick:G.action.onClick,className:"text-[12px] px-3 py-1.5 border border-line hover:border-fg-faint rounded-lg shrink-0 hover:bg-bg-hi text-fg-dim hover:text-fg",title:G.action.title,children:G.action.label})]}),r&&r.consecutiveFailures>5&&r.lastFailureKind==="meter_rate_limited"&&!W&&!x&&c.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 bg-amber-400/15 border border-amber-400/30 rounded-xl",children:[c.jsx("span",{className:"text-[12.5px] text-amber-400 font-medium",children:"Meter rate-limited — firing on heuristic"}),c.jsx("button",{type:"button",onClick:()=>k(!0),className:"text-[12px] text-amber-400/70 hover:text-amber-400 shrink-0",title:"Dismiss this banner. The scheduler continues firing normally.",children:"Dismiss"})]}),c.jsxs("div",{className:"flex items-center gap-[18px] flex-wrap bg-bg-elev border border-line rounded-xl px-4 py-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[13px] text-fg-dim",children:"Start jobs"}),c.jsxs("select",{value:O.firePolicy??"when-available",onChange:_e=>window.api.schedule.setConfig({firePolicy:_e.target.value}),className:"appearance-none border border-line bg-bg-hi rounded-lg px-2.5 py-1.5 font-sans text-[13px] text-fg font-medium",title:"when-available: poll usage and fire when tokens are below threshold. on-reset: fire after each 5h reset. manual: only on Run now.",children:[c.jsx("option",{value:"when-available",children:"when available"}),c.jsx("option",{value:"on-reset",children:"only on reset"}),c.jsx("option",{value:"manual",children:"manually"})]})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[13px] text-fg-dim",children:"Up to"}),c.jsx("input",{type:"number",min:1,max:20,value:O.concurrencyCap,onChange:_e=>window.api.schedule.setConfig({concurrencyCap:Number(_e.target.value)}),className:"w-11 text-center border border-line bg-bg-hi rounded-lg py-1.5 font-mono text-[13px] text-fg",title:"Max simultaneous jobs within a parallel group"}),c.jsx("span",{className:"text-[13px] text-fg-dim",children:"at once"})]}),(O.firePolicy??"when-available")==="when-available"&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-[13px] text-fg-dim",children:"Pause above"}),c.jsx("input",{type:"number",min:0,max:100,value:O.utilizationThreshold??90,onChange:_e=>window.api.schedule.setConfig({utilizationThreshold:Number(_e.target.value)}),className:"w-11 text-center border border-line bg-bg-hi rounded-lg py-1.5 font-mono text-[13px] text-fg",title:"Fire only when 5h utilization is below this percent"}),c.jsx("span",{className:"text-[13px] text-fg-dim",children:"% of window"})]}),c.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[c.jsx("button",{type:"button",onClick:()=>window.api.schedule.forceTick(),disabled:U.pending===0&&U.running===0,className:"bg-accent text-white rounded-lg px-4 py-2 text-[13px] font-semibold whitespace-nowrap disabled:opacity-40 disabled:cursor-not-allowed hover:opacity-90",title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress.",children:"Fire next batch now"}),c.jsx("button",{type:"button",onClick:()=>window.api.schedule.rescan(),className:"bg-bg-hi border border-line text-fg-dim hover:text-fg rounded-lg px-3.5 py-2 text-[13px] font-medium",title:"Re-scan the prds/ folder. Use when you've added or edited PRDs on disk and want the queue to reflect them immediately.",children:"Refresh"})]})]}),D.length>0&&(()=>{var ie;const _e=O.concurrencyCap??4,Te=(ie=D[0])==null?void 0:ie.parallelGroup,ye=I.filter(xe=>xe.status==="pending"&&xe.parallelGroup===Te).length;return c.jsxs("div",{className:"flex items-center gap-2 text-[12px] font-mono",children:[c.jsxs("span",{className:"px-2 py-0.5 rounded bg-amber-400/20 text-amber-400 shrink-0",children:[D.length,"/",_e," running"]}),ye>0&&c.jsxs("span",{className:"text-fg-faint",children:["+",ye," ready in this group"]})]})})(),I.length>0&&c.jsx(xwe,{filter:h,onChange:_e=>{b(_e),lwe(_e)}}),c.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-[18px] py-3 bg-bg-elev",children:[c.jsxs("span",{className:"font-serif text-base font-semibold text-fg",children:[ee.length," job",ee.length!==1?"s":""]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsxs("span",{className:"font-mono text-[12px] text-fg-faint",children:[U.pending,"p · ",U.running,"r · ",U.completed,"d",U.failed>0&&c.jsxs("span",{className:"text-accent",children:[" · ",U.failed,"f"]})]}),ce&&c.jsx("button",{type:"button",onClick:X,className:"text-[12.5px] text-fg-dim hover:text-fg bg-transparent border-0 cursor-pointer font-medium",title:"Hide completed jobs from this view (queue.json unchanged — they remain in history)",children:"Clear completed"}),c.jsx("button",{type:"button",onClick:Z,disabled:I.every(_e=>_e.status==="running"),className:"text-[12.5px] text-fg-dim hover:text-accent bg-transparent border-0 cursor-pointer font-medium disabled:opacity-40 disabled:cursor-not-allowed",title:"Archive every non-running PRD (moved to prds-archived/<timestamp>/) and remove them from the queue. Running jobs are kept.",children:"Clear queue"})]})]}),I.length===0&&c.jsxs("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:["No PRDs queued. Drop .md files in:",c.jsx("button",{type:"button",onClick:()=>window.api.schedule.openFolder(),className:"block mt-1 text-fg-dim hover:text-fg underline truncate w-full text-left",children:"~/.claude/session-manager/scheduled-plans/prds/"})]}),I.length>0&&oe.length===0&&J===0&&c.jsx("div",{className:"px-[18px] py-6 text-[13px] text-fg-faint italic",children:"no matching jobs"}),c.jsx("div",{ref:w,role:"list","aria-label":"Job queue",onKeyDown:ge,children:oe.map((_e,Te)=>c.jsx(bwe,{job:_e,eta:ywe(_e,I,ae.get(_e.slug)??0,$,G.kind,a),now:a,avgDurationMs:$,listIndex:Te,onFocused:ye=>{C(ye);try{localStorage.setItem(r0,String(ye))}catch{}}},_e.slug))}),J>0&&c.jsxs("button",{type:"button",onClick:()=>m(_e=>!_e),className:"w-full text-left text-[12px] text-fg-faint hover:text-fg-dim px-[18px] py-3 border-t border-line",title:f?"Re-collapse old/cleared completed":"Show all completed (incl. cleared and >24h)",children:[f?"▾":"▸"," ",J," more completed",o.size>0&&c.jsx("span",{className:"ml-2 underline",onClick:_e=>{_e.stopPropagation(),ne()},children:"un-hide"})]})]}),c.jsx(kwe,{snap:e}),c.jsx(Swe,{health:r,now:a,showHealth:i,setShowHealth:s}),c.jsxs("div",{className:"flex items-center justify-between text-[12px] text-fg-faint pt-1 border-t border-line",children:[c.jsxs("span",{children:[V&&c.jsxs("span",{title:`next 5h reset: ${V}`,children:["reset ",Po(Date.parse(V)-a)]}),H&&c.jsxs("span",{className:"ml-2",title:H,children:["last run ",Po(a-Date.parse(H))," ago"]})]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("button",{type:"button",onClick:()=>y("supervisor"),className:"hover:text-fg-dim underline",title:"Open supervisor log and settings",children:"supervisor"}),c.jsx("button",{type:"button",onClick:()=>window.api.schedule.openFolder(),className:"hover:text-fg-dim underline",children:"folder"})]})]})]})]})}function hwe({snap:e,now:r,avgDurationMs:n,runningJobs:i}){const{config:s,jobs:a,paused:l,nextReset:o,utilization:u}=e;let f=0,m=0;for(const y of a)y.status==="pending"?f++:y.status==="completed"&&m++;const h=i.length,b=f+h,x=s.concurrencyCap??4;if(h>0){const y=i.reduce((E,$)=>(E.startedAt??"")<($.startedAt??"")?E:$),w=y.startedAt?r-Date.parse(y.startedAt):0,S=m+h,C=m+b,T=h>1?` · ${h}/${x} parallel`:"";return{kind:"running",line1:`Running ${S}/${C}${T} · ${ny(w)}`,line2:h===1?y.title:i.map(E=>E.title).join(", "),tooltip:i.map(E=>`${E.slug} (g${E.parallelGroup})`).join("; ")}}if(l){const y=l.resumeAt?Date.parse(l.resumeAt)-r:null;return{kind:"paused",line1:{rate_limit:"Paused — tokens exhausted",auth:"Paused — authentication failed",network:"Paused — network unreachable",reset_failure:"Paused — billing data unavailable",manual:"Paused — manual"}[l.reason]??`Paused — ${l.reason}`,line2:l.reason==="auth"?"Run `claude` in any terminal to refresh credentials, then Resume":y!==null&&y>0?`auto-resume ${bp(Date.parse(l.resumeAt))} (in ${Po(y)})`:l.resumeAt?"resuming…":"no auto-resume scheduled",tooltip:l.resumeAt??"",action:{label:"Resume",onClick:()=>window.api.schedule.resume(),title:"Clear the pause and resume queue immediately"}}}if(b===0)return{kind:"idle",line1:"No work queued",line2:null};const k=s.firePolicy??"when-available";if(k==="manual")return{kind:"manual",line1:`Manual · ${f} pending`,line2:"click Fire next batch now to fire",action:{label:"Fire next batch now",onClick:()=>window.api.schedule.forceTick(),title:"Bypasses the billing-usage poll. Use when the meter is rate-limited or you want immediate progress."}};if(k==="on-reset"){if(!o)return{kind:"on-reset",line1:"On-reset · waiting for billing data",line2:null};const y=Date.parse(o)+s.offsetMinutes*6e4,w=y-r;return{kind:"on-reset",line1:`On-reset · ${f} pending`,line2:w>0?`fires ${bp(y)} (in ${Po(w)})`:"firing now…"}}const _=s.utilizationThreshold??90;if(u==null)return{kind:"auto-soon",line1:`Auto · ${f} pending`,line2:"checking token availability…"};if(u>=_){const y=o?Date.parse(o)-r:null;return{kind:"auto-throttled",line1:`Auto · throttled (util ${u.toFixed(0)}% ≥ ${_}%)`,line2:y&&y>0?`next reset ${bp(Date.parse(o))} (in ${Po(y)})`:"will fire when usage drops"}}return{kind:"auto-soon",line1:`Auto · ${f} pending · util ${u.toFixed(0)}%`,line2:"fires within 2 min (poll cycle)"}}function pwe(e){const r=e.filter(i=>i.status==="running"||i.status==="pending").sort((i,s)=>i.parallelGroup-s.parallelGroup||i.slug.localeCompare(s.slug)),n=new Map;return r.forEach((i,s)=>n.set(i.slug,s)),n}function mwe(e,r,n,i){if(i)return{inline:e,collapsedCount:0};const s=e.filter(f=>f.status==="completed").sort((f,m)=>{const h=f.finishedAt?Date.parse(f.finishedAt):0;return(m.finishedAt?Date.parse(m.finishedAt):0)-h}),a=new Set;let l=0;for(const f of s){if(l>=iwe)break;r.has(f.slug)||f.finishedAt&&n-Date.parse(f.finishedAt)>swe||(a.add(f.slug),l++)}const o=[];let u=0;for(const f of e){if(f.status==="failed"&&r.has(f.slug)){u++;continue}if(f.status!=="completed"){o.push(f);continue}a.has(f.slug)?o.push(f):u++}return{inline:o,collapsedCount:u}}function gwe({kind:e}){return e==="running"?c.jsx("span",{className:"w-2 h-2 rounded-full bg-amber-400 animate-pulse shrink-0"}):e==="paused"?c.jsx("span",{className:"text-[13px] shrink-0",title:"paused",children:"⏸"}):e==="manual"?c.jsx("span",{className:"text-[13px] shrink-0",title:"manual",children:"✋"}):e==="on-reset"||e==="auto-soon"?c.jsx("span",{className:"text-[13px] shrink-0",title:"auto",children:"⏰"}):e==="auto-throttled"?c.jsx("span",{className:"text-[13px] shrink-0",title:"throttled",children:"⏳"}):c.jsx("span",{className:"w-2 h-2 rounded-full bg-fg-faint/40 shrink-0"})}function vwe(e){return e==="running"?"bg-amber-400/10 border-amber-400/25":e==="paused"?"bg-amber-500/10 border-amber-500/25":e==="auto-throttled"?"bg-amber-500/5 border-amber-500/15":"bg-bg-elev border-line"}function ywe(e,r,n,i,s,a){if(e.status!=="pending"||s==="paused"||s==="manual"||s==="auto-throttled")return null;let l=n*i;if(n>0){const o=r.find(u=>u.status==="running"&&u.startedAt);o&&o.startedAt&&(l-=Math.min(i,a-Date.parse(o.startedAt)))}return l<=5e3?"~now":`~${ny(l)}`}function bwe({job:e,eta:r,now:n,avgDurationMs:i,listIndex:s,onFocused:a}){const[l,o]=B.useState(!1),[u,f]=B.useState(!1),m=e.status==="running",h=e.status==="failed";let b=null;m&&e.startedAt?b=`${k0(n-Date.parse(e.startedAt))} elapsed`:e.status==="completed"&&e.startedAt&&e.finishedAt?b=`took ${ny(Date.parse(e.finishedAt)-Date.parse(e.startedAt))}`:r&&(b=r);const x=e.error??null,k=h&&x?x.split(`