claude-code-session-manager 0.37.0 → 0.37.1

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=["./TiptapBody-Cg8YZhVZ.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TiptapBody-DXQDiOUx.js","./monaco-editor-BW5C4Iv1.js","./monaco-editor-BTnBOi8r.css"])))=>i.map(i=>d[i]);
2
2
  var rN=Object.defineProperty;var sN=(e,n,r)=>n in e?rN(e,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[n]=r;var Fn=(e,n,r)=>sN(e,typeof n!="symbol"?n+"":n,r);import{_ as Gm}from"./monaco-editor-BW5C4Iv1.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))i(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const h of l.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&i(h)}).observe(document,{childList:!0,subtree:!0});function r(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function i(o){if(o.ep)return;o.ep=!0;const l=r(o);fetch(o.href,l)}})();function qy(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bv={exports:{}},zp={},wv={exports:{}},pn={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -38,7 +38,7 @@ var rN=Object.defineProperty;var sN=(e,n,r)=>n in e?rN(e,n,{enumerable:!0,config
38
38
  `+F[ue].replace(" at new "," at ");return c.displayName&&$e.includes("<anonymous>")&&($e=$e.replace("<anonymous>",c.displayName)),$e}while(1<=ue&&0<=_e);break}}}finally{le=!1,Error.prepareStackTrace=k}return(c=c?c.displayName||c.name:"")?ae(c):""}function Me(c){switch(c.tag){case 5:return ae(c.type);case 16:return ae("Lazy");case 13:return ae("Suspense");case 19:return ae("SuspenseList");case 0:case 2:case 15:return c=fe(c.type,!1),c;case 11:return c=fe(c.type.render,!1),c;case 1:return c=fe(c.type,!0),c;default:return""}}function je(c){if(c==null)return null;if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case O:return"Fragment";case M:return"Portal";case z:return"Profiler";case I:return"StrictMode";case V:return"Suspense";case H:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case W:return(c.displayName||"Context")+".Consumer";case U:return(c._context.displayName||"Context")+".Provider";case Y:var p=c.render;return c=c.displayName,c||(c=p.displayName||p.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case te:return p=c.displayName||null,p!==null?p:je(c.type)||"Memo";case oe:p=c._payload,c=c._init;try{return je(c(p))}catch{}}return null}function ye(c){var p=c.type;switch(c.tag){case 24:return"Cache";case 9:return(p.displayName||"Context")+".Consumer";case 10:return(p._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return c=p.render,c=c.displayName||c.name||"",p.displayName||(c!==""?"ForwardRef("+c+")":"ForwardRef");case 7:return"Fragment";case 5:return p;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return je(p);case 8:return p===I?"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 p=="function")return p.displayName||p.name||null;if(typeof p=="string")return p}return null}function ne(c){switch(typeof c){case"boolean":case"number":case"string":case"undefined":return c;case"object":return c;default:return""}}function we(c){var p=c.type;return(c=c.nodeName)&&c.toLowerCase()==="input"&&(p==="checkbox"||p==="radio")}function Ne(c){var p=we(c)?"checked":"value",k=Object.getOwnPropertyDescriptor(c.constructor.prototype,p),R=""+c[p];if(!c.hasOwnProperty(p)&&typeof k<"u"&&typeof k.get=="function"&&typeof k.set=="function"){var F=k.get,K=k.set;return Object.defineProperty(c,p,{configurable:!0,get:function(){return F.call(this)},set:function(ue){R=""+ue,K.call(this,ue)}}),Object.defineProperty(c,p,{enumerable:k.enumerable}),{getValue:function(){return R},setValue:function(ue){R=""+ue},stopTracking:function(){c._valueTracker=null,delete c[p]}}}}function Je(c){c._valueTracker||(c._valueTracker=Ne(c))}function lt(c){if(!c)return!1;var p=c._valueTracker;if(!p)return!0;var k=p.getValue(),R="";return c&&(R=we(c)?c.checked?"true":"false":c.value),c=R,c!==k?(p.setValue(c),!0):!1}function xt(c){if(c=c||(typeof document<"u"?document:void 0),typeof c>"u")return null;try{return c.activeElement||c.body}catch{return c.body}}function At(c,p){var k=p.checked;return Q({},p,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:k??c._wrapperState.initialChecked})}function He(c,p){var k=p.defaultValue==null?"":p.defaultValue,R=p.checked!=null?p.checked:p.defaultChecked;k=ne(p.value!=null?p.value:k),c._wrapperState={initialChecked:R,initialValue:k,controlled:p.type==="checkbox"||p.type==="radio"?p.checked!=null:p.value!=null}}function vt(c,p){p=p.checked,p!=null&&j(c,"checked",p,!1)}function st(c,p){vt(c,p);var k=ne(p.value),R=p.type;if(k!=null)R==="number"?(k===0&&c.value===""||c.value!=k)&&(c.value=""+k):c.value!==""+k&&(c.value=""+k);else if(R==="submit"||R==="reset"){c.removeAttribute("value");return}p.hasOwnProperty("value")?sn(c,p.type,k):p.hasOwnProperty("defaultValue")&&sn(c,p.type,ne(p.defaultValue)),p.checked==null&&p.defaultChecked!=null&&(c.defaultChecked=!!p.defaultChecked)}function an(c,p,k){if(p.hasOwnProperty("value")||p.hasOwnProperty("defaultValue")){var R=p.type;if(!(R!=="submit"&&R!=="reset"||p.value!==void 0&&p.value!==null))return;p=""+c._wrapperState.initialValue,k||p===c.value||(c.value=p),c.defaultValue=p}k=c.name,k!==""&&(c.name=""),c.defaultChecked=!!c._wrapperState.initialChecked,k!==""&&(c.name=k)}function sn(c,p,k){(p!=="number"||xt(c.ownerDocument)!==c)&&(k==null?c.defaultValue=""+c._wrapperState.initialValue:c.defaultValue!==""+k&&(c.defaultValue=""+k))}var Ye=Array.isArray;function yt(c,p,k,R){if(c=c.options,p){p={};for(var F=0;F<k.length;F++)p["$"+k[F]]=!0;for(k=0;k<c.length;k++)F=p.hasOwnProperty("$"+c[k].value),c[k].selected!==F&&(c[k].selected=F),F&&R&&(c[k].defaultSelected=!0)}else{for(k=""+ne(k),p=null,F=0;F<c.length;F++){if(c[F].value===k){c[F].selected=!0,R&&(c[F].defaultSelected=!0);return}p!==null||c[F].disabled||(p=c[F])}p!==null&&(p.selected=!0)}}function _t(c,p){if(p.dangerouslySetInnerHTML!=null)throw Error(r(91));return Q({},p,{value:void 0,defaultValue:void 0,children:""+c._wrapperState.initialValue})}function Kt(c,p){var k=p.value;if(k==null){if(k=p.children,p=p.defaultValue,k!=null){if(p!=null)throw Error(r(92));if(Ye(k)){if(1<k.length)throw Error(r(93));k=k[0]}p=k}p==null&&(p=""),k=p}c._wrapperState={initialValue:ne(k)}}function On(c,p){var k=ne(p.value),R=ne(p.defaultValue);k!=null&&(k=""+k,k!==c.value&&(c.value=k),p.defaultValue==null&&c.defaultValue!==k&&(c.defaultValue=k)),R!=null&&(c.defaultValue=""+R)}function Rn(c){var p=c.textContent;p===c._wrapperState.initialValue&&p!==""&&p!==null&&(c.value=p)}function Br(c){switch(c){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 Tr(c,p){return c==null||c==="http://www.w3.org/1999/xhtml"?Br(p):c==="http://www.w3.org/2000/svg"&&p==="foreignObject"?"http://www.w3.org/1999/xhtml":c}var rt,St=(function(c){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(p,k,R,F){MSApp.execUnsafeLocalFunction(function(){return c(p,k,R,F)})}:c})(function(c,p){if(c.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in c)c.innerHTML=p;else{for(rt=rt||document.createElement("div"),rt.innerHTML="<svg>"+p.valueOf().toString()+"</svg>",p=rt.firstChild;c.firstChild;)c.removeChild(c.firstChild);for(;p.firstChild;)c.appendChild(p.firstChild)}});function Rt(c,p){if(p){var k=c.firstChild;if(k&&k===c.lastChild&&k.nodeType===3){k.nodeValue=p;return}}c.textContent=p}var cn={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},nn=["Webkit","ms","Moz","O"];Object.keys(cn).forEach(function(c){nn.forEach(function(p){p=p+c.charAt(0).toUpperCase()+c.substring(1),cn[p]=cn[c]})});function $r(c,p,k){return p==null||typeof p=="boolean"||p===""?"":k||typeof p!="number"||p===0||cn.hasOwnProperty(c)&&cn[c]?(""+p).trim():p+"px"}function Ea(c,p){c=c.style;for(var k in p)if(p.hasOwnProperty(k)){var R=k.indexOf("--")===0,F=$r(k,p[k],R);k==="float"&&(k="cssFloat"),R?c.setProperty(k,F):c[k]=F}}var Wo=Q({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 yi(c,p){if(p){if(Wo[c]&&(p.children!=null||p.dangerouslySetInnerHTML!=null))throw Error(r(137,c));if(p.dangerouslySetInnerHTML!=null){if(p.children!=null)throw Error(r(60));if(typeof p.dangerouslySetInnerHTML!="object"||!("__html"in p.dangerouslySetInnerHTML))throw Error(r(61))}if(p.style!=null&&typeof p.style!="object")throw Error(r(62))}}function yn(c,p){if(c.indexOf("-")===-1)return typeof p.is=="string";switch(c){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 Fr=null;function Zn(c){return c=c.target||c.srcElement||window,c.correspondingUseElement&&(c=c.correspondingUseElement),c.nodeType===3?c.parentNode:c}var vi=null,Ms=null,as=null;function Bi(c){if(c=Ml(c)){if(typeof vi!="function")throw Error(r(280));var p=c.stateNode;p&&(p=zc(p),vi(c.stateNode,c.type,p))}}function bi(c){Ms?as?as.push(c):as=[c]:Ms=c}function wi(){if(Ms){var c=Ms,p=as;if(as=Ms=null,Bi(c),p)for(c=0;c<p.length;c++)Bi(p[c])}}function Is(c,p){return c(p)}function Ar(){}var Ur=!1;function Js(c,p,k){if(Ur)return c(p,k);Ur=!0;try{return Is(c,p,k)}finally{Ur=!1,(Ms!==null||as!==null)&&(Ar(),wi())}}function Rr(c,p){var k=c.stateNode;if(k===null)return null;var R=zc(k);if(R===null)return null;k=R[p];e:switch(p){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(R=!R.disabled)||(c=c.type,R=!(c==="button"||c==="input"||c==="select"||c==="textarea")),c=!R;break e;default:c=!1}if(c)return null;if(k&&typeof k!="function")throw Error(r(231,p,typeof k));return k}var ls=!1;if(u)try{var js={};Object.defineProperty(js,"passive",{get:function(){ls=!0}}),window.addEventListener("test",js,js),window.removeEventListener("test",js,js)}catch{ls=!1}function uo(c,p,k,R,F,K,ue,_e,$e){var qe=Array.prototype.slice.call(arguments,3);try{p.apply(k,qe)}catch(at){this.onError(at)}}var Qs=!1,Zs=null,ei=!1,zt=null,Hr={onError:function(c){Qs=!0,Zs=c}};function Hn(c,p,k,R,F,K,ue,_e,$e){Qs=!1,Zs=null,uo.apply(Hr,arguments)}function _n(c,p,k,R,F,K,ue,_e,$e){if(Hn.apply(this,arguments),Qs){if(Qs){var qe=Zs;Qs=!1,Zs=null}else throw Error(r(198));ei||(ei=!0,zt=qe)}}function Ct(c){var p=c,k=c;if(c.alternate)for(;p.return;)p=p.return;else{c=p;do p=c,(p.flags&4098)!==0&&(k=p.return),c=p.return;while(c)}return p.tag===3?k:null}function Fi(c){if(c.tag===13){var p=c.memoizedState;if(p===null&&(c=c.alternate,c!==null&&(p=c.memoizedState)),p!==null)return p.dehydrated}return null}function ho(c){if(Ct(c)!==c)throw Error(r(188))}function Na(c){var p=c.alternate;if(!p){if(p=Ct(c),p===null)throw Error(r(188));return p!==c?null:c}for(var k=c,R=p;;){var F=k.return;if(F===null)break;var K=F.alternate;if(K===null){if(R=F.return,R!==null){k=R;continue}break}if(F.child===K.child){for(K=F.child;K;){if(K===k)return ho(F),c;if(K===R)return ho(F),p;K=K.sibling}throw Error(r(188))}if(k.return!==R.return)k=F,R=K;else{for(var ue=!1,_e=F.child;_e;){if(_e===k){ue=!0,k=F,R=K;break}if(_e===R){ue=!0,R=F,k=K;break}_e=_e.sibling}if(!ue){for(_e=K.child;_e;){if(_e===k){ue=!0,k=K,R=F;break}if(_e===R){ue=!0,R=K,k=F;break}_e=_e.sibling}if(!ue)throw Error(r(189))}}if(k.alternate!==R)throw Error(r(190))}if(k.tag!==3)throw Error(r(188));return k.stateNode.current===k?c:p}function fo(c){return c=Na(c),c!==null?po(c):null}function po(c){if(c.tag===5||c.tag===6)return c;for(c=c.child;c!==null;){var p=po(c);if(p!==null)return p;c=c.sibling}return null}var qo=n.unstable_scheduleCallback,Sr=n.unstable_cancelCallback,Ta=n.unstable_shouldYield,$a=n.unstable_requestPaint,kn=n.unstable_now,Mr=n.unstable_getCurrentPriorityLevel,Vn=n.unstable_ImmediatePriority,Ir=n.unstable_UserBlockingPriority,ti=n.unstable_NormalPriority,Ui=n.unstable_LowPriority,_i=n.unstable_IdlePriority,cs=null,gr=null;function Bt(c){if(gr&&typeof gr.onCommitFiberRoot=="function")try{gr.onCommitFiberRoot(cs,c,void 0,(c.current.flags&128)===128)}catch{}}var Gn=Math.clz32?Math.clz32:Vo,ki=Math.log,us=Math.LN2;function Vo(c){return c>>>=0,c===0?32:31-(ki(c)/us|0)|0}var Si=64,Wr=4194304;function Ps(c){switch(c&-c){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 c&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return c&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return c}}function Ci(c,p){var k=c.pendingLanes;if(k===0)return 0;var R=0,F=c.suspendedLanes,K=c.pingedLanes,ue=k&268435455;if(ue!==0){var _e=ue&~F;_e!==0?R=Ps(_e):(K&=ue,K!==0&&(R=Ps(K)))}else ue=k&~F,ue!==0?R=Ps(ue):K!==0&&(R=Ps(K));if(R===0)return 0;if(p!==0&&p!==R&&(p&F)===0&&(F=R&-R,K=p&-p,F>=K||F===16&&(K&4194240)!==0))return p;if((R&4)!==0&&(R|=k&16),p=c.entangledLanes,p!==0)for(c=c.entanglements,p&=R;0<p;)k=31-Gn(p),F=1<<k,R|=c[k],p&=~F;return R}function on(c,p){switch(c){case 1:case 2:case 4:return p+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 p+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 ds(c,p){for(var k=c.suspendedLanes,R=c.pingedLanes,F=c.expirationTimes,K=c.pendingLanes;0<K;){var ue=31-Gn(K),_e=1<<ue,$e=F[ue];$e===-1?((_e&k)===0||(_e&R)!==0)&&(F[ue]=on(_e,p)):$e<=p&&(c.expiredLanes|=_e),K&=~_e}}function Hi(c){return c=c.pendingLanes&-1073741825,c!==0?c:c&1073741824?1073741824:0}function Es(){var c=Si;return Si<<=1,(Si&4194240)===0&&(Si=64),c}function Ke(c){for(var p=[],k=0;31>k;k++)p.push(c);return p}function qr(c,p,k){c.pendingLanes|=p,p!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,p=31-Gn(p),c[p]=k}function ft(c,p){var k=c.pendingLanes&~p;c.pendingLanes=p,c.suspendedLanes=0,c.pingedLanes=0,c.expiredLanes&=p,c.mutableReadLanes&=p,c.entangledLanes&=p,p=c.entanglements;var R=c.eventTimes;for(c=c.expirationTimes;0<k;){var F=31-Gn(k),K=1<<F;p[F]=0,R[F]=-1,c[F]=-1,k&=~K}}function be(c,p){var k=c.entangledLanes|=p;for(c=c.entanglements;k;){var R=31-Gn(k),F=1<<R;F&p|c[R]&p&&(c[R]|=p),k&=~F}}var Pe=0;function Qe(c){return c&=-c,1<c?4<c?(c&268435455)!==0?16:536870912:4:1}var Et,en,ln,Tn,En,er=!1,Ln=[],sr=null,Nn=null,Ds=null,Wi=new Map,mo=new Map,ni=[],qu="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 go(c,p){switch(c){case"focusin":case"focusout":sr=null;break;case"dragenter":case"dragleave":Nn=null;break;case"mouseover":case"mouseout":Ds=null;break;case"pointerover":case"pointerout":Wi.delete(p.pointerId);break;case"gotpointercapture":case"lostpointercapture":mo.delete(p.pointerId)}}function xo(c,p,k,R,F,K){return c===null||c.nativeEvent!==K?(c={blockedOn:p,domEventName:k,eventSystemFlags:R,nativeEvent:K,targetContainers:[F]},p!==null&&(p=Ml(p),p!==null&&en(p)),c):(c.eventSystemFlags|=R,p=c.targetContainers,F!==null&&p.indexOf(F)===-1&&p.push(F),c)}function kc(c,p,k,R,F){switch(p){case"focusin":return sr=xo(sr,c,p,k,R,F),!0;case"dragenter":return Nn=xo(Nn,c,p,k,R,F),!0;case"mouseover":return Ds=xo(Ds,c,p,k,R,F),!0;case"pointerover":var K=F.pointerId;return Wi.set(K,xo(Wi.get(K)||null,c,p,k,R,F)),!0;case"gotpointercapture":return K=F.pointerId,mo.set(K,xo(mo.get(K)||null,c,p,k,R,F)),!0}return!1}function yl(c){var p=Xo(c.target);if(p!==null){var k=Ct(p);if(k!==null){if(p=k.tag,p===13){if(p=Fi(k),p!==null){c.blockedOn=p,En(c.priority,function(){ln(k)});return}}else if(p===3&&k.stateNode.current.memoizedState.isDehydrated){c.blockedOn=k.tag===3?k.stateNode.containerInfo:null;return}}}c.blockedOn=null}function yo(c){if(c.blockedOn!==null)return!1;for(var p=c.targetContainers;0<p.length;){var k=re(c.domEventName,c.eventSystemFlags,p[0],c.nativeEvent);if(k===null){k=c.nativeEvent;var R=new k.constructor(k.type,k);Fr=R,k.target.dispatchEvent(R),Fr=null}else return p=Ml(k),p!==null&&en(p),c.blockedOn=k,!1;p.shift()}return!0}function Aa(c,p,k){yo(c)&&k.delete(p)}function vl(){er=!1,sr!==null&&yo(sr)&&(sr=null),Nn!==null&&yo(Nn)&&(Nn=null),Ds!==null&&yo(Ds)&&(Ds=null),Wi.forEach(Aa),mo.forEach(Aa)}function ji(c,p){c.blockedOn===p&&(c.blockedOn=null,er||(er=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,vl)))}function qi(c){function p(F){return ji(F,c)}if(0<Ln.length){ji(Ln[0],c);for(var k=1;k<Ln.length;k++){var R=Ln[k];R.blockedOn===c&&(R.blockedOn=null)}}for(sr!==null&&ji(sr,c),Nn!==null&&ji(Nn,c),Ds!==null&&ji(Ds,c),Wi.forEach(p),mo.forEach(p),k=0;k<ni.length;k++)R=ni[k],R.blockedOn===c&&(R.blockedOn=null);for(;0<ni.length&&(k=ni[0],k.blockedOn===null);)yl(k),k.blockedOn===null&&ni.shift()}var Ei=T.ReactCurrentBatchConfig,vo=!0;function Sc(c,p,k,R){var F=Pe,K=Ei.transition;Ei.transition=null;try{Pe=1,bl(c,p,k,R)}finally{Pe=F,Ei.transition=K}}function Cc(c,p,k,R){var F=Pe,K=Ei.transition;Ei.transition=null;try{Pe=4,bl(c,p,k,R)}finally{Pe=F,Ei.transition=K}}function bl(c,p,k,R){if(vo){var F=re(c,p,k,R);if(F===null)id(c,p,R,wl,k),go(c,R);else if(kc(F,c,p,k,R))R.stopPropagation();else if(go(c,R),p&4&&-1<qu.indexOf(c)){for(;F!==null;){var K=Ml(F);if(K!==null&&Et(K),K=re(c,p,k,R),K===null&&id(c,p,R,wl,k),K===F)break;F=K}F!==null&&R.stopPropagation()}else id(c,p,R,null,k)}}var wl=null;function re(c,p,k,R){if(wl=null,c=Zn(R),c=Xo(c),c!==null)if(p=Ct(c),p===null)c=null;else if(k=p.tag,k===13){if(c=Fi(p),c!==null)return c;c=null}else if(k===3){if(p.stateNode.current.memoizedState.isDehydrated)return p.tag===3?p.stateNode.containerInfo:null;c=null}else p!==c&&(c=null);return wl=c,null}function he(c){switch(c){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(Mr()){case Vn:return 1;case Ir:return 4;case ti:case Ui:return 16;case _i:return 536870912;default:return 16}default:return 16}}var ve=null,Te=null,Se=null;function Be(){if(Se)return Se;var c,p=Te,k=p.length,R,F="value"in ve?ve.value:ve.textContent,K=F.length;for(c=0;c<k&&p[c]===F[c];c++);var ue=k-c;for(R=1;R<=ue&&p[k-R]===F[K-R];R++);return Se=F.slice(c,1<R?1-R:void 0)}function Ae(c){var p=c.keyCode;return"charCode"in c?(c=c.charCode,c===0&&p===13&&(c=13)):c=p,c===10&&(c=13),32<=c||c===13?c:0}function Re(){return!0}function Fe(){return!1}function et(c){function p(k,R,F,K,ue){this._reactName=k,this._targetInst=F,this.type=R,this.nativeEvent=K,this.target=ue,this.currentTarget=null;for(var _e in c)c.hasOwnProperty(_e)&&(k=c[_e],this[_e]=k?k(K):K[_e]);return this.isDefaultPrevented=(K.defaultPrevented!=null?K.defaultPrevented:K.returnValue===!1)?Re:Fe,this.isPropagationStopped=Fe,this}return Q(p.prototype,{preventDefault:function(){this.defaultPrevented=!0;var k=this.nativeEvent;k&&(k.preventDefault?k.preventDefault():typeof k.returnValue!="unknown"&&(k.returnValue=!1),this.isDefaultPrevented=Re)},stopPropagation:function(){var k=this.nativeEvent;k&&(k.stopPropagation?k.stopPropagation():typeof k.cancelBubble!="unknown"&&(k.cancelBubble=!0),this.isPropagationStopped=Re)},persist:function(){},isPersistent:Re}),p}var it={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(c){return c.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},tt=et(it),Xe=Q({},it,{view:0,detail:0}),$t=et(Xe),Le,ut,Cn,Jt=Q({},Xe,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:un,button:0,buttons:0,relatedTarget:function(c){return c.relatedTarget===void 0?c.fromElement===c.srcElement?c.toElement:c.fromElement:c.relatedTarget},movementX:function(c){return"movementX"in c?c.movementX:(c!==Cn&&(Cn&&c.type==="mousemove"?(Le=c.screenX-Cn.screenX,ut=c.screenY-Cn.screenY):ut=Le=0,Cn=c),Le)},movementY:function(c){return"movementY"in c?c.movementY:ut}}),Qt=et(Jt),jn=Q({},Jt,{dataTransfer:0}),Ot=et(jn),Mn=Q({},Xe,{relatedTarget:0}),hn=et(Mn),xr=Q({},it,{animationName:0,elapsedTime:0,pseudoElement:0}),Pr=et(xr),Vr=Q({},it,{clipboardData:function(c){return"clipboardData"in c?c.clipboardData:window.clipboardData}}),Ra=et(Vr),Gr=Q({},it,{data:0}),_l=et(Gr),jc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},yr={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"},ri={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Ec(c){var p=this.nativeEvent;return p.getModifierState?p.getModifierState(c):(c=ri[c])?!!p[c]:!1}function un(){return Ec}var Os=Q({},Xe,{key:function(c){if(c.key){var p=jc[c.key]||c.key;if(p!=="Unidentified")return p}return c.type==="keypress"?(c=Ae(c),c===13?"Enter":String.fromCharCode(c)):c.type==="keydown"||c.type==="keyup"?yr[c.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:un,charCode:function(c){return c.type==="keypress"?Ae(c):0},keyCode:function(c){return c.type==="keydown"||c.type==="keyup"?c.keyCode:0},which:function(c){return c.type==="keypress"?Ae(c):c.type==="keydown"||c.type==="keyup"?c.keyCode:0}}),Vu=et(Os),Ni=Q({},Jt,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Go=et(Ni),ir=Q({},Xe,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:un}),Kr=et(ir),kl=Q({},it,{propertyName:0,elapsedTime:0,pseudoElement:0}),Xr=et(kl),Nc=Q({},Jt,{deltaX:function(c){return"deltaX"in c?c.deltaX:"wheelDeltaX"in c?-c.wheelDeltaX:0},deltaY:function(c){return"deltaY"in c?c.deltaY:"wheelDeltaY"in c?-c.wheelDeltaY:"wheelDelta"in c?-c.wheelDelta:0},deltaZ:0,deltaMode:0}),Gu=et(Nc),Ti=[9,13,27,32],Ls=u&&"CompositionEvent"in window,si=null;u&&"documentMode"in document&&(si=document.documentMode);var or=u&&"TextEvent"in window&&!si,Wn=u&&(!Ls||si&&8<si&&11>=si),zs=" ",Tc=!1;function $c(c,p){switch(c){case"keyup":return Ti.indexOf(p.keyCode)!==-1;case"keydown":return p.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sg(c){return c=c.detail,typeof c=="object"&&"data"in c?c.data:null}var Yr=!1;function ig(c,p){switch(c){case"compositionend":return sg(p);case"keypress":return p.which!==32?null:(Tc=!0,zs);case"textInput":return c=p.data,c===zs&&Tc?null:c;default:return null}}function Ku(c,p){if(Yr)return c==="compositionend"||!Ls&&$c(c,p)?(c=Be(),Se=Te=ve=null,Yr=!1,c):null;switch(c){case"paste":return null;case"keypress":if(!(p.ctrlKey||p.altKey||p.metaKey)||p.ctrlKey&&p.altKey){if(p.char&&1<p.char.length)return p.char;if(p.which)return String.fromCharCode(p.which)}return null;case"compositionend":return Wn&&p.locale!=="ko"?null:p.data;default:return null}}var of={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 ii(c){var p=c&&c.nodeName&&c.nodeName.toLowerCase();return p==="input"?!!of[c.type]:p==="textarea"}function af(c,p,k,R){bi(R),p=Ic(p,"onChange"),0<p.length&&(k=new tt("onChange","change",null,k,R),c.push({event:k,listeners:p}))}var Sl=null,Cl=null;function og(c){kf(c,0)}function Ac(c){var p=Pa(c);if(lt(p))return c}function ag(c,p){if(c==="change")return p}var lf=!1;if(u){var Xu;if(u){var Yu="oninput"in document;if(!Yu){var cf=document.createElement("div");cf.setAttribute("oninput","return;"),Yu=typeof cf.oninput=="function"}Xu=Yu}else Xu=!1;lf=Xu&&(!document.documentMode||9<document.documentMode)}function oi(){Sl&&(Sl.detachEvent("onpropertychange",uf),Cl=Sl=null)}function uf(c){if(c.propertyName==="value"&&Ac(Cl)){var p=[];af(p,Cl,c,Zn(c)),Js(og,p)}}function lg(c,p,k){c==="focusin"?(oi(),Sl=p,Cl=k,Sl.attachEvent("onpropertychange",uf)):c==="focusout"&&oi()}function cg(c){if(c==="selectionchange"||c==="keyup"||c==="keydown")return Ac(Cl)}function ug(c,p){if(c==="click")return Ac(p)}function dg(c,p){if(c==="input"||c==="change")return Ac(p)}function hg(c,p){return c===p&&(c!==0||1/c===1/p)||c!==c&&p!==p}var ai=typeof Object.is=="function"?Object.is:hg;function jl(c,p){if(ai(c,p))return!0;if(typeof c!="object"||c===null||typeof p!="object"||p===null)return!1;var k=Object.keys(c),R=Object.keys(p);if(k.length!==R.length)return!1;for(R=0;R<k.length;R++){var F=k[R];if(!d.call(p,F)||!ai(c[F],p[F]))return!1}return!0}function df(c){for(;c&&c.firstChild;)c=c.firstChild;return c}function hf(c,p){var k=df(c);c=0;for(var R;k;){if(k.nodeType===3){if(R=c+k.textContent.length,c<=p&&R>=p)return{node:k,offset:p-c};c=R}e:{for(;k;){if(k.nextSibling){k=k.nextSibling;break e}k=k.parentNode}k=void 0}k=df(k)}}function Ju(c,p){return c&&p?c===p?!0:c&&c.nodeType===3?!1:p&&p.nodeType===3?Ju(c,p.parentNode):"contains"in c?c.contains(p):c.compareDocumentPosition?!!(c.compareDocumentPosition(p)&16):!1:!1}function Qu(){for(var c=window,p=xt();p instanceof c.HTMLIFrameElement;){try{var k=typeof p.contentWindow.location.href=="string"}catch{k=!1}if(k)c=p.contentWindow;else break;p=xt(c.document)}return p}function Zu(c){var p=c&&c.nodeName&&c.nodeName.toLowerCase();return p&&(p==="input"&&(c.type==="text"||c.type==="search"||c.type==="tel"||c.type==="url"||c.type==="password")||p==="textarea"||c.contentEditable==="true")}function fg(c){var p=Qu(),k=c.focusedElem,R=c.selectionRange;if(p!==k&&k&&k.ownerDocument&&Ju(k.ownerDocument.documentElement,k)){if(R!==null&&Zu(k)){if(p=R.start,c=R.end,c===void 0&&(c=p),"selectionStart"in k)k.selectionStart=p,k.selectionEnd=Math.min(c,k.value.length);else if(c=(p=k.ownerDocument||document)&&p.defaultView||window,c.getSelection){c=c.getSelection();var F=k.textContent.length,K=Math.min(R.start,F);R=R.end===void 0?K:Math.min(R.end,F),!c.extend&&K>R&&(F=R,R=K,K=F),F=hf(k,K);var ue=hf(k,R);F&&ue&&(c.rangeCount!==1||c.anchorNode!==F.node||c.anchorOffset!==F.offset||c.focusNode!==ue.node||c.focusOffset!==ue.offset)&&(p=p.createRange(),p.setStart(F.node,F.offset),c.removeAllRanges(),K>R?(c.addRange(p),c.extend(ue.node,ue.offset)):(p.setEnd(ue.node,ue.offset),c.addRange(p)))}}for(p=[],c=k;c=c.parentNode;)c.nodeType===1&&p.push({element:c,left:c.scrollLeft,top:c.scrollTop});for(typeof k.focus=="function"&&k.focus(),k=0;k<p.length;k++)c=p[k],c.element.scrollLeft=c.left,c.element.scrollTop=c.top}}var ff=u&&"documentMode"in document&&11>=document.documentMode,El=null,ed=null,Ko=null,td=!1;function pf(c,p,k){var R=k.window===k?k.document:k.nodeType===9?k:k.ownerDocument;td||El==null||El!==xt(R)||(R=El,"selectionStart"in R&&Zu(R)?R={start:R.selectionStart,end:R.selectionEnd}:(R=(R.ownerDocument&&R.ownerDocument.defaultView||window).getSelection(),R={anchorNode:R.anchorNode,anchorOffset:R.anchorOffset,focusNode:R.focusNode,focusOffset:R.focusOffset}),Ko&&jl(Ko,R)||(Ko=R,R=Ic(ed,"onSelect"),0<R.length&&(p=new tt("onSelect","select",null,p,k),c.push({event:p,listeners:R}),p.target=El)))}function Rc(c,p){var k={};return k[c.toLowerCase()]=p.toLowerCase(),k["Webkit"+c]="webkit"+p,k["Moz"+c]="moz"+p,k}var Vi={animationend:Rc("Animation","AnimationEnd"),animationiteration:Rc("Animation","AnimationIteration"),animationstart:Rc("Animation","AnimationStart"),transitionend:Rc("Transition","TransitionEnd")},nd={},mf={};u&&(mf=document.createElement("div").style,"AnimationEvent"in window||(delete Vi.animationend.animation,delete Vi.animationiteration.animation,delete Vi.animationstart.animation),"TransitionEvent"in window||delete Vi.transitionend.transition);function Nl(c){if(nd[c])return nd[c];if(!Vi[c])return c;var p=Vi[c],k;for(k in p)if(p.hasOwnProperty(k)&&k in mf)return nd[c]=p[k];return c}var gf=Nl("animationend"),xf=Nl("animationiteration"),yf=Nl("animationstart"),vf=Nl("transitionend"),pg=new Map,bf="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 bo(c,p){pg.set(c,p),l(p,[c])}for(var rd=0;rd<bf.length;rd++){var wf=bf[rd],mg=wf.toLowerCase(),mn=wf[0].toUpperCase()+wf.slice(1);bo(mg,"on"+mn)}bo(gf,"onAnimationEnd"),bo(xf,"onAnimationIteration"),bo(yf,"onAnimationStart"),bo("dblclick","onDoubleClick"),bo("focusin","onFocus"),bo("focusout","onBlur"),bo(vf,"onTransitionEnd"),h("onMouseEnter",["mouseout","mouseover"]),h("onMouseLeave",["mouseout","mouseover"]),h("onPointerEnter",["pointerout","pointerover"]),h("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Tl="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(" "),gg=new Set("cancel close invalid load scroll toggle".split(" ").concat(Tl));function _f(c,p,k){var R=c.type||"unknown-event";c.currentTarget=k,_n(R,p,void 0,c),c.currentTarget=null}function kf(c,p){p=(p&4)!==0;for(var k=0;k<c.length;k++){var R=c[k],F=R.event;R=R.listeners;e:{var K=void 0;if(p)for(var ue=R.length-1;0<=ue;ue--){var _e=R[ue],$e=_e.instance,qe=_e.currentTarget;if(_e=_e.listener,$e!==K&&F.isPropagationStopped())break e;_f(F,_e,qe),K=$e}else for(ue=0;ue<R.length;ue++){if(_e=R[ue],$e=_e.instance,qe=_e.currentTarget,_e=_e.listener,$e!==K&&F.isPropagationStopped())break e;_f(F,_e,qe),K=$e}}}if(ei)throw c=zt,ei=!1,zt=null,c}function zn(c,p){var k=p[dd];k===void 0&&(k=p[dd]=new Set);var R=c+"__bubble";k.has(R)||(Sf(p,c,2,!1),k.add(R))}function sd(c,p,k){var R=0;p&&(R|=4),Sf(k,c,R,p)}var Mc="_reactListening"+Math.random().toString(36).slice(2);function $l(c){if(!c[Mc]){c[Mc]=!0,i.forEach(function(k){k!=="selectionchange"&&(gg.has(k)||sd(k,!1,c),sd(k,!0,c))});var p=c.nodeType===9?c:c.ownerDocument;p===null||p[Mc]||(p[Mc]=!0,sd("selectionchange",!1,p))}}function Sf(c,p,k,R){switch(he(p)){case 1:var F=Sc;break;case 4:F=Cc;break;default:F=bl}k=F.bind(null,p,k,c),F=void 0,!ls||p!=="touchstart"&&p!=="touchmove"&&p!=="wheel"||(F=!0),R?F!==void 0?c.addEventListener(p,k,{capture:!0,passive:F}):c.addEventListener(p,k,!0):F!==void 0?c.addEventListener(p,k,{passive:F}):c.addEventListener(p,k,!1)}function id(c,p,k,R,F){var K=R;if((p&1)===0&&(p&2)===0&&R!==null)e:for(;;){if(R===null)return;var ue=R.tag;if(ue===3||ue===4){var _e=R.stateNode.containerInfo;if(_e===F||_e.nodeType===8&&_e.parentNode===F)break;if(ue===4)for(ue=R.return;ue!==null;){var $e=ue.tag;if(($e===3||$e===4)&&($e=ue.stateNode.containerInfo,$e===F||$e.nodeType===8&&$e.parentNode===F))return;ue=ue.return}for(;_e!==null;){if(ue=Xo(_e),ue===null)return;if($e=ue.tag,$e===5||$e===6){R=K=ue;continue e}_e=_e.parentNode}}R=R.return}Js(function(){var qe=K,at=Zn(k),ct=[];e:{var ot=pg.get(c);if(ot!==void 0){var jt=tt,Pt=c;switch(c){case"keypress":if(Ae(k)===0)break e;case"keydown":case"keyup":jt=Vu;break;case"focusin":Pt="focus",jt=hn;break;case"focusout":Pt="blur",jt=hn;break;case"beforeblur":case"afterblur":jt=hn;break;case"click":if(k.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":jt=Qt;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":jt=Ot;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":jt=Kr;break;case gf:case xf:case yf:jt=Pr;break;case vf:jt=Xr;break;case"scroll":jt=$t;break;case"wheel":jt=Gu;break;case"copy":case"cut":case"paste":jt=Ra;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":jt=Go}var Dt=(p&4)!==0,Pn=!Dt&&c==="scroll",Ue=Dt?ot!==null?ot+"Capture":null:ot;Dt=[];for(var Ie=qe,Ve;Ie!==null;){Ve=Ie;var ht=Ve.stateNode;if(Ve.tag===5&&ht!==null&&(Ve=ht,Ue!==null&&(ht=Rr(Ie,Ue),ht!=null&&Dt.push(Al(Ie,ht,Ve)))),Pn)break;Ie=Ie.return}0<Dt.length&&(ot=new jt(ot,Pt,null,k,at),ct.push({event:ot,listeners:Dt}))}}if((p&7)===0){e:{if(ot=c==="mouseover"||c==="pointerover",jt=c==="mouseout"||c==="pointerout",ot&&k!==Fr&&(Pt=k.relatedTarget||k.fromElement)&&(Xo(Pt)||Pt[Ai]))break e;if((jt||ot)&&(ot=at.window===at?at:(ot=at.ownerDocument)?ot.defaultView||ot.parentWindow:window,jt?(Pt=k.relatedTarget||k.toElement,jt=qe,Pt=Pt?Xo(Pt):null,Pt!==null&&(Pn=Ct(Pt),Pt!==Pn||Pt.tag!==5&&Pt.tag!==6)&&(Pt=null)):(jt=null,Pt=qe),jt!==Pt)){if(Dt=Qt,ht="onMouseLeave",Ue="onMouseEnter",Ie="mouse",(c==="pointerout"||c==="pointerover")&&(Dt=Go,ht="onPointerLeave",Ue="onPointerEnter",Ie="pointer"),Pn=jt==null?ot:Pa(jt),Ve=Pt==null?ot:Pa(Pt),ot=new Dt(ht,Ie+"leave",jt,k,at),ot.target=Pn,ot.relatedTarget=Ve,ht=null,Xo(at)===qe&&(Dt=new Dt(Ue,Ie+"enter",Pt,k,at),Dt.target=Ve,Dt.relatedTarget=Pn,ht=Dt),Pn=ht,jt&&Pt)t:{for(Dt=jt,Ue=Pt,Ie=0,Ve=Dt;Ve;Ve=Ma(Ve))Ie++;for(Ve=0,ht=Ue;ht;ht=Ma(ht))Ve++;for(;0<Ie-Ve;)Dt=Ma(Dt),Ie--;for(;0<Ve-Ie;)Ue=Ma(Ue),Ve--;for(;Ie--;){if(Dt===Ue||Ue!==null&&Dt===Ue.alternate)break t;Dt=Ma(Dt),Ue=Ma(Ue)}Dt=null}else Dt=null;jt!==null&&Cf(ct,ot,jt,Dt,!1),Pt!==null&&Pn!==null&&Cf(ct,Pn,Pt,Dt,!0)}}e:{if(ot=qe?Pa(qe):window,jt=ot.nodeName&&ot.nodeName.toLowerCase(),jt==="select"||jt==="input"&&ot.type==="file")var Ft=ag;else if(ii(ot))if(lf)Ft=dg;else{Ft=cg;var Xt=lg}else(jt=ot.nodeName)&&jt.toLowerCase()==="input"&&(ot.type==="checkbox"||ot.type==="radio")&&(Ft=ug);if(Ft&&(Ft=Ft(c,qe))){af(ct,Ft,k,at);break e}Xt&&Xt(c,ot,qe),c==="focusout"&&(Xt=ot._wrapperState)&&Xt.controlled&&ot.type==="number"&&sn(ot,"number",ot.value)}switch(Xt=qe?Pa(qe):window,c){case"focusin":(ii(Xt)||Xt.contentEditable==="true")&&(El=Xt,ed=qe,Ko=null);break;case"focusout":Ko=ed=El=null;break;case"mousedown":td=!0;break;case"contextmenu":case"mouseup":case"dragend":td=!1,pf(ct,k,at);break;case"selectionchange":if(ff)break;case"keydown":case"keyup":pf(ct,k,at)}var Yt;if(Ls)e:{switch(c){case"compositionstart":var rn="onCompositionStart";break e;case"compositionend":rn="onCompositionEnd";break e;case"compositionupdate":rn="onCompositionUpdate";break e}rn=void 0}else Yr?$c(c,k)&&(rn="onCompositionEnd"):c==="keydown"&&k.keyCode===229&&(rn="onCompositionStart");rn&&(Wn&&k.locale!=="ko"&&(Yr||rn!=="onCompositionStart"?rn==="onCompositionEnd"&&Yr&&(Yt=Be()):(ve=at,Te="value"in ve?ve.value:ve.textContent,Yr=!0)),Xt=Ic(qe,rn),0<Xt.length&&(rn=new _l(rn,c,null,k,at),ct.push({event:rn,listeners:Xt}),Yt?rn.data=Yt:(Yt=sg(k),Yt!==null&&(rn.data=Yt)))),(Yt=or?ig(c,k):Ku(c,k))&&(qe=Ic(qe,"onBeforeInput"),0<qe.length&&(at=new _l("onBeforeInput","beforeinput",null,k,at),ct.push({event:at,listeners:qe}),at.data=Yt))}kf(ct,p)})}function Al(c,p,k){return{instance:c,listener:p,currentTarget:k}}function Ic(c,p){for(var k=p+"Capture",R=[];c!==null;){var F=c,K=F.stateNode;F.tag===5&&K!==null&&(F=K,K=Rr(c,k),K!=null&&R.unshift(Al(c,K,F)),K=Rr(c,p),K!=null&&R.push(Al(c,K,F))),c=c.return}return R}function Ma(c){if(c===null)return null;do c=c.return;while(c&&c.tag!==5);return c||null}function Cf(c,p,k,R,F){for(var K=p._reactName,ue=[];k!==null&&k!==R;){var _e=k,$e=_e.alternate,qe=_e.stateNode;if($e!==null&&$e===R)break;_e.tag===5&&qe!==null&&(_e=qe,F?($e=Rr(k,K),$e!=null&&ue.unshift(Al(k,$e,_e))):F||($e=Rr(k,K),$e!=null&&ue.push(Al(k,$e,_e)))),k=k.return}ue.length!==0&&c.push({event:p,listeners:ue})}var Pc=/\r\n?/g,xg=/\u0000|\uFFFD/g;function Dc(c){return(typeof c=="string"?c:""+c).replace(Pc,`
39
39
  `).replace(xg,"")}function Oc(c,p,k){if(p=Dc(p),Dc(c)!==p&&k)throw Error(r(425))}function Lc(){}var od=null,ad=null;function ld(c,p){return c==="textarea"||c==="noscript"||typeof p.children=="string"||typeof p.children=="number"||typeof p.dangerouslySetInnerHTML=="object"&&p.dangerouslySetInnerHTML!==null&&p.dangerouslySetInnerHTML.__html!=null}var cd=typeof setTimeout=="function"?setTimeout:void 0,yg=typeof clearTimeout=="function"?clearTimeout:void 0,jf=typeof Promise=="function"?Promise:void 0,vg=typeof queueMicrotask=="function"?queueMicrotask:typeof jf<"u"?function(c){return jf.resolve(null).then(c).catch(bg)}:cd;function bg(c){setTimeout(function(){throw c})}function ud(c,p){var k=p,R=0;do{var F=k.nextSibling;if(c.removeChild(k),F&&F.nodeType===8)if(k=F.data,k==="/$"){if(R===0){c.removeChild(F),qi(p);return}R--}else k!=="$"&&k!=="$?"&&k!=="$!"||R++;k=F}while(k);qi(p)}function wo(c){for(;c!=null;c=c.nextSibling){var p=c.nodeType;if(p===1||p===3)break;if(p===8){if(p=c.data,p==="$"||p==="$!"||p==="$?")break;if(p==="/$")return null}}return c}function Ef(c){c=c.previousSibling;for(var p=0;c;){if(c.nodeType===8){var k=c.data;if(k==="$"||k==="$!"||k==="$?"){if(p===0)return c;p--}else k==="/$"&&p++}c=c.previousSibling}return null}var Ia=Math.random().toString(36).slice(2),$i="__reactFiber$"+Ia,Rl="__reactProps$"+Ia,Ai="__reactContainer$"+Ia,dd="__reactEvents$"+Ia,Nf="__reactListeners$"+Ia,Tf="__reactHandles$"+Ia;function Xo(c){var p=c[$i];if(p)return p;for(var k=c.parentNode;k;){if(p=k[Ai]||k[$i]){if(k=p.alternate,p.child!==null||k!==null&&k.child!==null)for(c=Ef(c);c!==null;){if(k=c[$i])return k;c=Ef(c)}return p}c=k,k=c.parentNode}return null}function Ml(c){return c=c[$i]||c[Ai],!c||c.tag!==5&&c.tag!==6&&c.tag!==13&&c.tag!==3?null:c}function Pa(c){if(c.tag===5||c.tag===6)return c.stateNode;throw Error(r(33))}function zc(c){return c[Rl]||null}var hd=[],Da=-1;function Gi(c){return{current:c}}function Bn(c){0>Da||(c.current=hd[Da],hd[Da]=null,Da--)}function In(c,p){Da++,hd[Da]=c.current,c.current=p}var _o={},Jr=Gi(_o),hs=Gi(!1),Yo=_o;function Qr(c,p){var k=c.type.contextTypes;if(!k)return _o;var R=c.stateNode;if(R&&R.__reactInternalMemoizedUnmaskedChildContext===p)return R.__reactInternalMemoizedMaskedChildContext;var F={},K;for(K in k)F[K]=p[K];return R&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=p,c.__reactInternalMemoizedMaskedChildContext=F),F}function fs(c){return c=c.childContextTypes,c!=null}function Bc(){Bn(hs),Bn(Jr)}function $f(c,p,k){if(Jr.current!==_o)throw Error(r(168));In(Jr,p),In(hs,k)}function Af(c,p,k){var R=c.stateNode;if(p=p.childContextTypes,typeof R.getChildContext!="function")return k;R=R.getChildContext();for(var F in R)if(!(F in p))throw Error(r(108,ye(c)||"Unknown",F));return Q({},k,R)}function Fc(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||_o,Yo=Jr.current,In(Jr,c),In(hs,hs.current),!0}function Rf(c,p,k){var R=c.stateNode;if(!R)throw Error(r(169));k?(c=Af(c,p,Yo),R.__reactInternalMemoizedMergedChildContext=c,Bn(hs),Bn(Jr),In(Jr,c)):Bn(hs),In(hs,k)}var Ki=null,Uc=!1,fd=!1;function Mf(c){Ki===null?Ki=[c]:Ki.push(c)}function uv(c){Uc=!0,Mf(c)}function ko(){if(!fd&&Ki!==null){fd=!0;var c=0,p=Pe;try{var k=Ki;for(Pe=1;c<k.length;c++){var R=k[c];do R=R(!0);while(R!==null)}Ki=null,Uc=!1}catch(F){throw Ki!==null&&(Ki=Ki.slice(c+1)),qo(Vn,ko),F}finally{Pe=p,fd=!1}}return null}var Oa=[],La=0,Hc=null,Wc=0,Bs=[],li=0,Fs=null,ps=1,ms="";function So(c,p){Oa[La++]=Wc,Oa[La++]=Hc,Hc=c,Wc=p}function Jo(c,p,k){Bs[li++]=ps,Bs[li++]=ms,Bs[li++]=Fs,Fs=c;var R=ps;c=ms;var F=32-Gn(R)-1;R&=~(1<<F),k+=1;var K=32-Gn(p)+F;if(30<K){var ue=F-F%5;K=(R&(1<<ue)-1).toString(32),R>>=ue,F-=ue,ps=1<<32-Gn(p)+F|k<<F|R,ms=K+c}else ps=1<<K|k<<F|R,ms=c}function ur(c){c.return!==null&&(So(c,1),Jo(c,1,0))}function pd(c){for(;c===Hc;)Hc=Oa[--La],Oa[La]=null,Wc=Oa[--La],Oa[La]=null;for(;c===Fs;)Fs=Bs[--li],Bs[li]=null,ms=Bs[--li],Bs[li]=null,ps=Bs[--li],Bs[li]=null}var gs=null,Ns=null,Kn=!1,xs=null;function md(c,p){var k=$s(5,null,null,0);k.elementType="DELETED",k.stateNode=p,k.return=c,p=c.deletions,p===null?(c.deletions=[k],c.flags|=16):p.push(k)}function gd(c,p){switch(c.tag){case 5:var k=c.type;return p=p.nodeType!==1||k.toLowerCase()!==p.nodeName.toLowerCase()?null:p,p!==null?(c.stateNode=p,gs=c,Ns=wo(p.firstChild),!0):!1;case 6:return p=c.pendingProps===""||p.nodeType!==3?null:p,p!==null?(c.stateNode=p,gs=c,Ns=null,!0):!1;case 13:return p=p.nodeType!==8?null:p,p!==null?(k=Fs!==null?{id:ps,overflow:ms}:null,c.memoizedState={dehydrated:p,treeContext:k,retryLane:1073741824},k=$s(18,null,null,0),k.stateNode=p,k.return=c,c.child=k,gs=c,Ns=null,!0):!1;default:return!1}}function xd(c){return(c.mode&1)!==0&&(c.flags&128)===0}function yd(c){if(Kn){var p=Ns;if(p){var k=p;if(!gd(c,p)){if(xd(c))throw Error(r(418));p=wo(k.nextSibling);var R=gs;p&&gd(c,p)?md(R,k):(c.flags=c.flags&-4097|2,Kn=!1,gs=c)}}else{if(xd(c))throw Error(r(418));c.flags=c.flags&-4097|2,Kn=!1,gs=c}}}function vd(c){for(c=c.return;c!==null&&c.tag!==5&&c.tag!==3&&c.tag!==13;)c=c.return;gs=c}function Il(c){if(c!==gs)return!1;if(!Kn)return vd(c),Kn=!0,!1;var p;if((p=c.tag!==3)&&!(p=c.tag!==5)&&(p=c.type,p=p!=="head"&&p!=="body"&&!ld(c.type,c.memoizedProps)),p&&(p=Ns)){if(xd(c))throw If(),Error(r(418));for(;p;)md(c,p),p=wo(p.nextSibling)}if(vd(c),c.tag===13){if(c=c.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(r(317));e:{for(c=c.nextSibling,p=0;c;){if(c.nodeType===8){var k=c.data;if(k==="/$"){if(p===0){Ns=wo(c.nextSibling);break e}p--}else k!=="$"&&k!=="$!"&&k!=="$?"||p++}c=c.nextSibling}Ns=null}}else Ns=gs?wo(c.stateNode.nextSibling):null;return!0}function If(){for(var c=Ns;c;)c=wo(c.nextSibling)}function Qo(){Ns=gs=null,Kn=!1}function bd(c){xs===null?xs=[c]:xs.push(c)}var wd=T.ReactCurrentBatchConfig;function za(c,p,k){if(c=k.ref,c!==null&&typeof c!="function"&&typeof c!="object"){if(k._owner){if(k=k._owner,k){if(k.tag!==1)throw Error(r(309));var R=k.stateNode}if(!R)throw Error(r(147,c));var F=R,K=""+c;return p!==null&&p.ref!==null&&typeof p.ref=="function"&&p.ref._stringRef===K?p.ref:(p=function(ue){var _e=F.refs;ue===null?delete _e[K]:_e[K]=ue},p._stringRef=K,p)}if(typeof c!="string")throw Error(r(284));if(!k._owner)throw Error(r(290,c))}return c}function qc(c,p){throw c=Object.prototype.toString.call(p),Error(r(31,c==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":c))}function Pf(c){var p=c._init;return p(c._payload)}function wg(c){function p(Ue,Ie){if(c){var Ve=Ue.deletions;Ve===null?(Ue.deletions=[Ie],Ue.flags|=16):Ve.push(Ie)}}function k(Ue,Ie){if(!c)return null;for(;Ie!==null;)p(Ue,Ie),Ie=Ie.sibling;return null}function R(Ue,Ie){for(Ue=new Map;Ie!==null;)Ie.key!==null?Ue.set(Ie.key,Ie):Ue.set(Ie.index,Ie),Ie=Ie.sibling;return Ue}function F(Ue,Ie){return Ue=Ro(Ue,Ie),Ue.index=0,Ue.sibling=null,Ue}function K(Ue,Ie,Ve){return Ue.index=Ve,c?(Ve=Ue.alternate,Ve!==null?(Ve=Ve.index,Ve<Ie?(Ue.flags|=2,Ie):Ve):(Ue.flags|=2,Ie)):(Ue.flags|=1048576,Ie)}function ue(Ue){return c&&Ue.alternate===null&&(Ue.flags|=2),Ue}function _e(Ue,Ie,Ve,ht){return Ie===null||Ie.tag!==6?(Ie=yh(Ve,Ue.mode,ht),Ie.return=Ue,Ie):(Ie=F(Ie,Ve),Ie.return=Ue,Ie)}function $e(Ue,Ie,Ve,ht){var Ft=Ve.type;return Ft===O?at(Ue,Ie,Ve.props.children,ht,Ve.key):Ie!==null&&(Ie.elementType===Ft||typeof Ft=="object"&&Ft!==null&&Ft.$$typeof===oe&&Pf(Ft)===Ie.type)?(ht=F(Ie,Ve.props),ht.ref=za(Ue,Ie,Ve),ht.return=Ue,ht):(ht=fu(Ve.type,Ve.key,Ve.props,null,Ue.mode,ht),ht.ref=za(Ue,Ie,Ve),ht.return=Ue,ht)}function qe(Ue,Ie,Ve,ht){return Ie===null||Ie.tag!==4||Ie.stateNode.containerInfo!==Ve.containerInfo||Ie.stateNode.implementation!==Ve.implementation?(Ie=vh(Ve,Ue.mode,ht),Ie.return=Ue,Ie):(Ie=F(Ie,Ve.children||[]),Ie.return=Ue,Ie)}function at(Ue,Ie,Ve,ht,Ft){return Ie===null||Ie.tag!==7?(Ie=Xa(Ve,Ue.mode,ht,Ft),Ie.return=Ue,Ie):(Ie=F(Ie,Ve),Ie.return=Ue,Ie)}function ct(Ue,Ie,Ve){if(typeof Ie=="string"&&Ie!==""||typeof Ie=="number")return Ie=yh(""+Ie,Ue.mode,Ve),Ie.return=Ue,Ie;if(typeof Ie=="object"&&Ie!==null){switch(Ie.$$typeof){case A:return Ve=fu(Ie.type,Ie.key,Ie.props,null,Ue.mode,Ve),Ve.ref=za(Ue,null,Ie),Ve.return=Ue,Ve;case M:return Ie=vh(Ie,Ue.mode,Ve),Ie.return=Ue,Ie;case oe:var ht=Ie._init;return ct(Ue,ht(Ie._payload),Ve)}if(Ye(Ie)||X(Ie))return Ie=Xa(Ie,Ue.mode,Ve,null),Ie.return=Ue,Ie;qc(Ue,Ie)}return null}function ot(Ue,Ie,Ve,ht){var Ft=Ie!==null?Ie.key:null;if(typeof Ve=="string"&&Ve!==""||typeof Ve=="number")return Ft!==null?null:_e(Ue,Ie,""+Ve,ht);if(typeof Ve=="object"&&Ve!==null){switch(Ve.$$typeof){case A:return Ve.key===Ft?$e(Ue,Ie,Ve,ht):null;case M:return Ve.key===Ft?qe(Ue,Ie,Ve,ht):null;case oe:return Ft=Ve._init,ot(Ue,Ie,Ft(Ve._payload),ht)}if(Ye(Ve)||X(Ve))return Ft!==null?null:at(Ue,Ie,Ve,ht,null);qc(Ue,Ve)}return null}function jt(Ue,Ie,Ve,ht,Ft){if(typeof ht=="string"&&ht!==""||typeof ht=="number")return Ue=Ue.get(Ve)||null,_e(Ie,Ue,""+ht,Ft);if(typeof ht=="object"&&ht!==null){switch(ht.$$typeof){case A:return Ue=Ue.get(ht.key===null?Ve:ht.key)||null,$e(Ie,Ue,ht,Ft);case M:return Ue=Ue.get(ht.key===null?Ve:ht.key)||null,qe(Ie,Ue,ht,Ft);case oe:var Xt=ht._init;return jt(Ue,Ie,Ve,Xt(ht._payload),Ft)}if(Ye(ht)||X(ht))return Ue=Ue.get(Ve)||null,at(Ie,Ue,ht,Ft,null);qc(Ie,ht)}return null}function Pt(Ue,Ie,Ve,ht){for(var Ft=null,Xt=null,Yt=Ie,rn=Ie=0,wr=null;Yt!==null&&rn<Ve.length;rn++){Yt.index>rn?(wr=Yt,Yt=null):wr=Yt.sibling;var vn=ot(Ue,Yt,Ve[rn],ht);if(vn===null){Yt===null&&(Yt=wr);break}c&&Yt&&vn.alternate===null&&p(Ue,Yt),Ie=K(vn,Ie,rn),Xt===null?Ft=vn:Xt.sibling=vn,Xt=vn,Yt=wr}if(rn===Ve.length)return k(Ue,Yt),Kn&&So(Ue,rn),Ft;if(Yt===null){for(;rn<Ve.length;rn++)Yt=ct(Ue,Ve[rn],ht),Yt!==null&&(Ie=K(Yt,Ie,rn),Xt===null?Ft=Yt:Xt.sibling=Yt,Xt=Yt);return Kn&&So(Ue,rn),Ft}for(Yt=R(Ue,Yt);rn<Ve.length;rn++)wr=jt(Yt,Ue,rn,Ve[rn],ht),wr!==null&&(c&&wr.alternate!==null&&Yt.delete(wr.key===null?rn:wr.key),Ie=K(wr,Ie,rn),Xt===null?Ft=wr:Xt.sibling=wr,Xt=wr);return c&&Yt.forEach(function(Zi){return p(Ue,Zi)}),Kn&&So(Ue,rn),Ft}function Dt(Ue,Ie,Ve,ht){var Ft=X(Ve);if(typeof Ft!="function")throw Error(r(150));if(Ve=Ft.call(Ve),Ve==null)throw Error(r(151));for(var Xt=Ft=null,Yt=Ie,rn=Ie=0,wr=null,vn=Ve.next();Yt!==null&&!vn.done;rn++,vn=Ve.next()){Yt.index>rn?(wr=Yt,Yt=null):wr=Yt.sibling;var Zi=ot(Ue,Yt,vn.value,ht);if(Zi===null){Yt===null&&(Yt=wr);break}c&&Yt&&Zi.alternate===null&&p(Ue,Yt),Ie=K(Zi,Ie,rn),Xt===null?Ft=Zi:Xt.sibling=Zi,Xt=Zi,Yt=wr}if(vn.done)return k(Ue,Yt),Kn&&So(Ue,rn),Ft;if(Yt===null){for(;!vn.done;rn++,vn=Ve.next())vn=ct(Ue,vn.value,ht),vn!==null&&(Ie=K(vn,Ie,rn),Xt===null?Ft=vn:Xt.sibling=vn,Xt=vn);return Kn&&So(Ue,rn),Ft}for(Yt=R(Ue,Yt);!vn.done;rn++,vn=Ve.next())vn=jt(Yt,Ue,rn,vn.value,ht),vn!==null&&(c&&vn.alternate!==null&&Yt.delete(vn.key===null?rn:vn.key),Ie=K(vn,Ie,rn),Xt===null?Ft=vn:Xt.sibling=vn,Xt=vn);return c&&Yt.forEach(function(ex){return p(Ue,ex)}),Kn&&So(Ue,rn),Ft}function Pn(Ue,Ie,Ve,ht){if(typeof Ve=="object"&&Ve!==null&&Ve.type===O&&Ve.key===null&&(Ve=Ve.props.children),typeof Ve=="object"&&Ve!==null){switch(Ve.$$typeof){case A:e:{for(var Ft=Ve.key,Xt=Ie;Xt!==null;){if(Xt.key===Ft){if(Ft=Ve.type,Ft===O){if(Xt.tag===7){k(Ue,Xt.sibling),Ie=F(Xt,Ve.props.children),Ie.return=Ue,Ue=Ie;break e}}else if(Xt.elementType===Ft||typeof Ft=="object"&&Ft!==null&&Ft.$$typeof===oe&&Pf(Ft)===Xt.type){k(Ue,Xt.sibling),Ie=F(Xt,Ve.props),Ie.ref=za(Ue,Xt,Ve),Ie.return=Ue,Ue=Ie;break e}k(Ue,Xt);break}else p(Ue,Xt);Xt=Xt.sibling}Ve.type===O?(Ie=Xa(Ve.props.children,Ue.mode,ht,Ve.key),Ie.return=Ue,Ue=Ie):(ht=fu(Ve.type,Ve.key,Ve.props,null,Ue.mode,ht),ht.ref=za(Ue,Ie,Ve),ht.return=Ue,Ue=ht)}return ue(Ue);case M:e:{for(Xt=Ve.key;Ie!==null;){if(Ie.key===Xt)if(Ie.tag===4&&Ie.stateNode.containerInfo===Ve.containerInfo&&Ie.stateNode.implementation===Ve.implementation){k(Ue,Ie.sibling),Ie=F(Ie,Ve.children||[]),Ie.return=Ue,Ue=Ie;break e}else{k(Ue,Ie);break}else p(Ue,Ie);Ie=Ie.sibling}Ie=vh(Ve,Ue.mode,ht),Ie.return=Ue,Ue=Ie}return ue(Ue);case oe:return Xt=Ve._init,Pn(Ue,Ie,Xt(Ve._payload),ht)}if(Ye(Ve))return Pt(Ue,Ie,Ve,ht);if(X(Ve))return Dt(Ue,Ie,Ve,ht);qc(Ue,Ve)}return typeof Ve=="string"&&Ve!==""||typeof Ve=="number"?(Ve=""+Ve,Ie!==null&&Ie.tag===6?(k(Ue,Ie.sibling),Ie=F(Ie,Ve),Ie.return=Ue,Ue=Ie):(k(Ue,Ie),Ie=yh(Ve,Ue.mode,ht),Ie.return=Ue,Ue=Ie),ue(Ue)):k(Ue,Ie)}return Pn}var Ba=wg(!0),_d=wg(!1),Zo=Gi(null),Vc=null,ea=null,kd=null;function Sd(){kd=ea=Vc=null}function Cd(c){var p=Zo.current;Bn(Zo),c._currentValue=p}function Df(c,p,k){for(;c!==null;){var R=c.alternate;if((c.childLanes&p)!==p?(c.childLanes|=p,R!==null&&(R.childLanes|=p)):R!==null&&(R.childLanes&p)!==p&&(R.childLanes|=p),c===k)break;c=c.return}}function Fa(c,p){Vc=c,kd=ea=null,c=c.dependencies,c!==null&&c.firstContext!==null&&((c.lanes&p)!==0&&(ys=!0),c.firstContext=null)}function Us(c){var p=c._currentValue;if(kd!==c)if(c={context:c,memoizedValue:p,next:null},ea===null){if(Vc===null)throw Error(r(308));ea=c,Vc.dependencies={lanes:0,firstContext:c}}else ea=ea.next=c;return p}var Ua=null;function jd(c){Ua===null?Ua=[c]:Ua.push(c)}function Gc(c,p,k,R){var F=p.interleaved;return F===null?(k.next=k,jd(p)):(k.next=F.next,F.next=k),p.interleaved=k,Xi(c,R)}function Xi(c,p){c.lanes|=p;var k=c.alternate;for(k!==null&&(k.lanes|=p),k=c,c=c.return;c!==null;)c.childLanes|=p,k=c.alternate,k!==null&&(k.childLanes|=p),k=c,c=c.return;return k.tag===3?k.stateNode:null}var Ri=!1;function Kc(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ed(c,p){c=c.updateQueue,p.updateQueue===c&&(p.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,effects:c.effects})}function Yi(c,p){return{eventTime:c,lane:p,tag:0,payload:null,callback:null,next:null}}function Co(c,p,k){var R=c.updateQueue;if(R===null)return null;if(R=R.shared,(gn&2)!==0){var F=R.pending;return F===null?p.next=p:(p.next=F.next,F.next=p),R.pending=p,Xi(c,k)}return F=R.interleaved,F===null?(p.next=p,jd(R)):(p.next=F.next,F.next=p),R.interleaved=p,Xi(c,k)}function Pl(c,p,k){if(p=p.updateQueue,p!==null&&(p=p.shared,(k&4194240)!==0)){var R=p.lanes;R&=c.pendingLanes,k|=R,p.lanes=k,be(c,k)}}function _g(c,p){var k=c.updateQueue,R=c.alternate;if(R!==null&&(R=R.updateQueue,k===R)){var F=null,K=null;if(k=k.firstBaseUpdate,k!==null){do{var ue={eventTime:k.eventTime,lane:k.lane,tag:k.tag,payload:k.payload,callback:k.callback,next:null};K===null?F=K=ue:K=K.next=ue,k=k.next}while(k!==null);K===null?F=K=p:K=K.next=p}else F=K=p;k={baseState:R.baseState,firstBaseUpdate:F,lastBaseUpdate:K,shared:R.shared,effects:R.effects},c.updateQueue=k;return}c=k.lastBaseUpdate,c===null?k.firstBaseUpdate=p:c.next=p,k.lastBaseUpdate=p}function Xc(c,p,k,R){var F=c.updateQueue;Ri=!1;var K=F.firstBaseUpdate,ue=F.lastBaseUpdate,_e=F.shared.pending;if(_e!==null){F.shared.pending=null;var $e=_e,qe=$e.next;$e.next=null,ue===null?K=qe:ue.next=qe,ue=$e;var at=c.alternate;at!==null&&(at=at.updateQueue,_e=at.lastBaseUpdate,_e!==ue&&(_e===null?at.firstBaseUpdate=qe:_e.next=qe,at.lastBaseUpdate=$e))}if(K!==null){var ct=F.baseState;ue=0,at=qe=$e=null,_e=K;do{var ot=_e.lane,jt=_e.eventTime;if((R&ot)===ot){at!==null&&(at=at.next={eventTime:jt,lane:0,tag:_e.tag,payload:_e.payload,callback:_e.callback,next:null});e:{var Pt=c,Dt=_e;switch(ot=p,jt=k,Dt.tag){case 1:if(Pt=Dt.payload,typeof Pt=="function"){ct=Pt.call(jt,ct,ot);break e}ct=Pt;break e;case 3:Pt.flags=Pt.flags&-65537|128;case 0:if(Pt=Dt.payload,ot=typeof Pt=="function"?Pt.call(jt,ct,ot):Pt,ot==null)break e;ct=Q({},ct,ot);break e;case 2:Ri=!0}}_e.callback!==null&&_e.lane!==0&&(c.flags|=64,ot=F.effects,ot===null?F.effects=[_e]:ot.push(_e))}else jt={eventTime:jt,lane:ot,tag:_e.tag,payload:_e.payload,callback:_e.callback,next:null},at===null?(qe=at=jt,$e=ct):at=at.next=jt,ue|=ot;if(_e=_e.next,_e===null){if(_e=F.shared.pending,_e===null)break;ot=_e,_e=ot.next,ot.next=null,F.lastBaseUpdate=ot,F.shared.pending=null}}while(!0);if(at===null&&($e=ct),F.baseState=$e,F.firstBaseUpdate=qe,F.lastBaseUpdate=at,p=F.shared.interleaved,p!==null){F=p;do ue|=F.lane,F=F.next;while(F!==p)}else K===null&&(F.shared.lanes=0);oa|=ue,c.lanes=ue,c.memoizedState=ct}}function kg(c,p,k){if(c=p.effects,p.effects=null,c!==null)for(p=0;p<c.length;p++){var R=c[p],F=R.callback;if(F!==null){if(R.callback=null,R=k,typeof F!="function")throw Error(r(191,F));F.call(R)}}}var Dl={},Mi=Gi(Dl),Ol=Gi(Dl),Ha=Gi(Dl);function ta(c){if(c===Dl)throw Error(r(174));return c}function Nd(c,p){switch(In(Ha,p),In(Ol,c),In(Mi,Dl),c=p.nodeType,c){case 9:case 11:p=(p=p.documentElement)?p.namespaceURI:Tr(null,"");break;default:c=c===8?p.parentNode:p,p=c.namespaceURI||null,c=c.tagName,p=Tr(p,c)}Bn(Mi),In(Mi,p)}function na(){Bn(Mi),Bn(Ol),Bn(Ha)}function Of(c){ta(Ha.current);var p=ta(Mi.current),k=Tr(p,c.type);p!==k&&(In(Ol,c),In(Mi,k))}function Td(c){Ol.current===c&&(Bn(Mi),Bn(Ol))}var Yn=Gi(0);function Yc(c){for(var p=c;p!==null;){if(p.tag===13){var k=p.memoizedState;if(k!==null&&(k=k.dehydrated,k===null||k.data==="$?"||k.data==="$!"))return p}else if(p.tag===19&&p.memoizedProps.revealOrder!==void 0){if((p.flags&128)!==0)return p}else if(p.child!==null){p.child.return=p,p=p.child;continue}if(p===c)break;for(;p.sibling===null;){if(p.return===null||p.return===c)return null;p=p.return}p.sibling.return=p.return,p=p.sibling}return null}var $d=[];function Ad(){for(var c=0;c<$d.length;c++)$d[c]._workInProgressVersionPrimary=null;$d.length=0}var Rd=T.ReactCurrentDispatcher,Md=T.ReactCurrentBatchConfig,ra=0,Xn=null,dr=null,vr=null,Id=!1,sa=!1,jo=0,Lf=0;function Dr(){throw Error(r(321))}function Pd(c,p){if(p===null)return!1;for(var k=0;k<p.length&&k<c.length;k++)if(!ai(c[k],p[k]))return!1;return!0}function Dd(c,p,k,R,F,K){if(ra=K,Xn=p,p.memoizedState=null,p.updateQueue=null,p.lanes=0,Rd.current=c===null||c.memoizedState===null?Tg:$g,c=k(R,F),sa){K=0;do{if(sa=!1,jo=0,25<=K)throw Error(r(301));K+=1,vr=dr=null,p.updateQueue=null,Rd.current=hv,c=k(R,F)}while(sa)}if(Rd.current=eu,p=dr!==null&&dr.next!==null,ra=0,vr=dr=Xn=null,Id=!1,p)throw Error(r(300));return c}function Od(){var c=jo!==0;return jo=0,c}function ci(){var c={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vr===null?Xn.memoizedState=vr=c:vr=vr.next=c,vr}function Hs(){if(dr===null){var c=Xn.alternate;c=c!==null?c.memoizedState:null}else c=dr.next;var p=vr===null?Xn.memoizedState:vr.next;if(p!==null)vr=p,dr=c;else{if(c===null)throw Error(r(310));dr=c,c={memoizedState:dr.memoizedState,baseState:dr.baseState,baseQueue:dr.baseQueue,queue:dr.queue,next:null},vr===null?Xn.memoizedState=vr=c:vr=vr.next=c}return vr}function Ll(c,p){return typeof p=="function"?p(c):p}function Ld(c){var p=Hs(),k=p.queue;if(k===null)throw Error(r(311));k.lastRenderedReducer=c;var R=dr,F=R.baseQueue,K=k.pending;if(K!==null){if(F!==null){var ue=F.next;F.next=K.next,K.next=ue}R.baseQueue=F=K,k.pending=null}if(F!==null){K=F.next,R=R.baseState;var _e=ue=null,$e=null,qe=K;do{var at=qe.lane;if((ra&at)===at)$e!==null&&($e=$e.next={lane:0,action:qe.action,hasEagerState:qe.hasEagerState,eagerState:qe.eagerState,next:null}),R=qe.hasEagerState?qe.eagerState:c(R,qe.action);else{var ct={lane:at,action:qe.action,hasEagerState:qe.hasEagerState,eagerState:qe.eagerState,next:null};$e===null?(_e=$e=ct,ue=R):$e=$e.next=ct,Xn.lanes|=at,oa|=at}qe=qe.next}while(qe!==null&&qe!==K);$e===null?ue=R:$e.next=_e,ai(R,p.memoizedState)||(ys=!0),p.memoizedState=R,p.baseState=ue,p.baseQueue=$e,k.lastRenderedState=R}if(c=k.interleaved,c!==null){F=c;do K=F.lane,Xn.lanes|=K,oa|=K,F=F.next;while(F!==c)}else F===null&&(k.lanes=0);return[p.memoizedState,k.dispatch]}function zf(c){var p=Hs(),k=p.queue;if(k===null)throw Error(r(311));k.lastRenderedReducer=c;var R=k.dispatch,F=k.pending,K=p.memoizedState;if(F!==null){k.pending=null;var ue=F=F.next;do K=c(K,ue.action),ue=ue.next;while(ue!==F);ai(K,p.memoizedState)||(ys=!0),p.memoizedState=K,p.baseQueue===null&&(p.baseState=K),k.lastRenderedState=K}return[K,R]}function Bf(){}function zd(c,p){var k=Xn,R=Hs(),F=p(),K=!ai(R.memoizedState,F);if(K&&(R.memoizedState=F,ys=!0),R=R.queue,Kf(Hf.bind(null,k,R,c),[c]),R.getSnapshot!==p||K||vr!==null&&vr.memoizedState.tag&1){if(k.flags|=2048,Jc(9,Uf.bind(null,k,R,F,p),void 0,null),fr===null)throw Error(r(349));(ra&30)!==0||Ff(k,p,F)}return F}function Ff(c,p,k){c.flags|=16384,c={getSnapshot:p,value:k},p=Xn.updateQueue,p===null?(p={lastEffect:null,stores:null},Xn.updateQueue=p,p.stores=[c]):(k=p.stores,k===null?p.stores=[c]:k.push(c))}function Uf(c,p,k,R){p.value=k,p.getSnapshot=R,Sg(p)&&Wf(c)}function Hf(c,p,k){return k(function(){Sg(p)&&Wf(c)})}function Sg(c){var p=c.getSnapshot;c=c.value;try{var k=p();return!ai(c,k)}catch{return!0}}function Wf(c){var p=Xi(c,1);p!==null&&hi(p,c,1,-1)}function qf(c){var p=ci();return typeof c=="function"&&(c=c()),p.memoizedState=p.baseState=c,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ll,lastRenderedState:c},p.queue=c,c=c.dispatch=Eg.bind(null,Xn,c),[p.memoizedState,c]}function Jc(c,p,k,R){return c={tag:c,create:p,destroy:k,deps:R,next:null},p=Xn.updateQueue,p===null?(p={lastEffect:null,stores:null},Xn.updateQueue=p,p.lastEffect=c.next=c):(k=p.lastEffect,k===null?p.lastEffect=c.next=c:(R=k.next,k.next=c,c.next=R,p.lastEffect=c)),c}function Vf(){return Hs().memoizedState}function Qc(c,p,k,R){var F=ci();Xn.flags|=c,F.memoizedState=Jc(1|p,k,void 0,R===void 0?null:R)}function Zc(c,p,k,R){var F=Hs();R=R===void 0?null:R;var K=void 0;if(dr!==null){var ue=dr.memoizedState;if(K=ue.destroy,R!==null&&Pd(R,ue.deps)){F.memoizedState=Jc(p,k,K,R);return}}Xn.flags|=c,F.memoizedState=Jc(1|p,k,K,R)}function Gf(c,p){return Qc(8390656,8,c,p)}function Kf(c,p){return Zc(2048,8,c,p)}function Xf(c,p){return Zc(4,2,c,p)}function Yf(c,p){return Zc(4,4,c,p)}function Jf(c,p){if(typeof p=="function")return c=c(),p(c),function(){p(null)};if(p!=null)return c=c(),p.current=c,function(){p.current=null}}function Cg(c,p,k){return k=k!=null?k.concat([c]):null,Zc(4,4,Jf.bind(null,p,c),k)}function Bd(){}function Qf(c,p){var k=Hs();p=p===void 0?null:p;var R=k.memoizedState;return R!==null&&p!==null&&Pd(p,R[1])?R[0]:(k.memoizedState=[c,p],c)}function Zf(c,p){var k=Hs();p=p===void 0?null:p;var R=k.memoizedState;return R!==null&&p!==null&&Pd(p,R[1])?R[0]:(c=c(),k.memoizedState=[c,p],c)}function ep(c,p,k){return(ra&21)===0?(c.baseState&&(c.baseState=!1,ys=!0),c.memoizedState=k):(ai(k,p)||(k=Es(),Xn.lanes|=k,oa|=k,c.baseState=!0),p)}function dv(c,p){var k=Pe;Pe=k!==0&&4>k?k:4,c(!0);var R=Md.transition;Md.transition={};try{c(!1),p()}finally{Pe=k,Md.transition=R}}function tp(){return Hs().memoizedState}function jg(c,p,k){var R=$o(c);if(k={lane:R,action:k,hasEagerState:!1,eagerState:null,next:null},np(c))Ng(p,k);else if(k=Gc(c,p,k,R),k!==null){var F=es();hi(k,c,R,F),rp(k,p,R)}}function Eg(c,p,k){var R=$o(c),F={lane:R,action:k,hasEagerState:!1,eagerState:null,next:null};if(np(c))Ng(p,F);else{var K=c.alternate;if(c.lanes===0&&(K===null||K.lanes===0)&&(K=p.lastRenderedReducer,K!==null))try{var ue=p.lastRenderedState,_e=K(ue,k);if(F.hasEagerState=!0,F.eagerState=_e,ai(_e,ue)){var $e=p.interleaved;$e===null?(F.next=F,jd(p)):(F.next=$e.next,$e.next=F),p.interleaved=F;return}}catch{}finally{}k=Gc(c,p,F,R),k!==null&&(F=es(),hi(k,c,R,F),rp(k,p,R))}}function np(c){var p=c.alternate;return c===Xn||p!==null&&p===Xn}function Ng(c,p){sa=Id=!0;var k=c.pending;k===null?p.next=p:(p.next=k.next,k.next=p),c.pending=p}function rp(c,p,k){if((k&4194240)!==0){var R=p.lanes;R&=c.pendingLanes,k|=R,p.lanes=k,be(c,k)}}var eu={readContext:Us,useCallback:Dr,useContext:Dr,useEffect:Dr,useImperativeHandle:Dr,useInsertionEffect:Dr,useLayoutEffect:Dr,useMemo:Dr,useReducer:Dr,useRef:Dr,useState:Dr,useDebugValue:Dr,useDeferredValue:Dr,useTransition:Dr,useMutableSource:Dr,useSyncExternalStore:Dr,useId:Dr,unstable_isNewReconciler:!1},Tg={readContext:Us,useCallback:function(c,p){return ci().memoizedState=[c,p===void 0?null:p],c},useContext:Us,useEffect:Gf,useImperativeHandle:function(c,p,k){return k=k!=null?k.concat([c]):null,Qc(4194308,4,Jf.bind(null,p,c),k)},useLayoutEffect:function(c,p){return Qc(4194308,4,c,p)},useInsertionEffect:function(c,p){return Qc(4,2,c,p)},useMemo:function(c,p){var k=ci();return p=p===void 0?null:p,c=c(),k.memoizedState=[c,p],c},useReducer:function(c,p,k){var R=ci();return p=k!==void 0?k(p):p,R.memoizedState=R.baseState=p,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:p},R.queue=c,c=c.dispatch=jg.bind(null,Xn,c),[R.memoizedState,c]},useRef:function(c){var p=ci();return c={current:c},p.memoizedState=c},useState:qf,useDebugValue:Bd,useDeferredValue:function(c){return ci().memoizedState=c},useTransition:function(){var c=qf(!1),p=c[0];return c=dv.bind(null,c[1]),ci().memoizedState=c,[p,c]},useMutableSource:function(){},useSyncExternalStore:function(c,p,k){var R=Xn,F=ci();if(Kn){if(k===void 0)throw Error(r(407));k=k()}else{if(k=p(),fr===null)throw Error(r(349));(ra&30)!==0||Ff(R,p,k)}F.memoizedState=k;var K={value:k,getSnapshot:p};return F.queue=K,Gf(Hf.bind(null,R,K,c),[c]),R.flags|=2048,Jc(9,Uf.bind(null,R,K,k,p),void 0,null),k},useId:function(){var c=ci(),p=fr.identifierPrefix;if(Kn){var k=ms,R=ps;k=(R&~(1<<32-Gn(R)-1)).toString(32)+k,p=":"+p+"R"+k,k=jo++,0<k&&(p+="H"+k.toString(32)),p+=":"}else k=Lf++,p=":"+p+"r"+k.toString(32)+":";return c.memoizedState=p},unstable_isNewReconciler:!1},$g={readContext:Us,useCallback:Qf,useContext:Us,useEffect:Kf,useImperativeHandle:Cg,useInsertionEffect:Xf,useLayoutEffect:Yf,useMemo:Zf,useReducer:Ld,useRef:Vf,useState:function(){return Ld(Ll)},useDebugValue:Bd,useDeferredValue:function(c){var p=Hs();return ep(p,dr.memoizedState,c)},useTransition:function(){var c=Ld(Ll)[0],p=Hs().memoizedState;return[c,p]},useMutableSource:Bf,useSyncExternalStore:zd,useId:tp,unstable_isNewReconciler:!1},hv={readContext:Us,useCallback:Qf,useContext:Us,useEffect:Kf,useImperativeHandle:Cg,useInsertionEffect:Xf,useLayoutEffect:Yf,useMemo:Zf,useReducer:zf,useRef:Vf,useState:function(){return zf(Ll)},useDebugValue:Bd,useDeferredValue:function(c){var p=Hs();return dr===null?p.memoizedState=c:ep(p,dr.memoizedState,c)},useTransition:function(){var c=zf(Ll)[0],p=Hs().memoizedState;return[c,p]},useMutableSource:Bf,useSyncExternalStore:zd,useId:tp,unstable_isNewReconciler:!1};function hr(c,p){if(c&&c.defaultProps){p=Q({},p),c=c.defaultProps;for(var k in c)p[k]===void 0&&(p[k]=c[k]);return p}return p}function Ii(c,p,k,R){p=c.memoizedState,k=k(R,p),k=k==null?p:Q({},p,k),c.memoizedState=k,c.lanes===0&&(c.updateQueue.baseState=k)}var Ji={isMounted:function(c){return(c=c._reactInternals)?Ct(c)===c:!1},enqueueSetState:function(c,p,k){c=c._reactInternals;var R=es(),F=$o(c),K=Yi(R,F);K.payload=p,k!=null&&(K.callback=k),p=Co(c,K,F),p!==null&&(hi(p,c,F,R),Pl(p,c,F))},enqueueReplaceState:function(c,p,k){c=c._reactInternals;var R=es(),F=$o(c),K=Yi(R,F);K.tag=1,K.payload=p,k!=null&&(K.callback=k),p=Co(c,K,F),p!==null&&(hi(p,c,F,R),Pl(p,c,F))},enqueueForceUpdate:function(c,p){c=c._reactInternals;var k=es(),R=$o(c),F=Yi(k,R);F.tag=2,p!=null&&(F.callback=p),p=Co(c,F,R),p!==null&&(hi(p,c,R,k),Pl(p,c,R))}};function ia(c,p,k,R,F,K,ue){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(R,K,ue):p.prototype&&p.prototype.isPureReactComponent?!jl(k,R)||!jl(F,K):!0}function sp(c,p,k){var R=!1,F=_o,K=p.contextType;return typeof K=="object"&&K!==null?K=Us(K):(F=fs(p)?Yo:Jr.current,R=p.contextTypes,K=(R=R!=null)?Qr(c,F):_o),p=new p(k,K),c.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=Ji,c.stateNode=p,p._reactInternals=c,R&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=F,c.__reactInternalMemoizedMaskedChildContext=K),p}function ip(c,p,k,R){c=p.state,typeof p.componentWillReceiveProps=="function"&&p.componentWillReceiveProps(k,R),typeof p.UNSAFE_componentWillReceiveProps=="function"&&p.UNSAFE_componentWillReceiveProps(k,R),p.state!==c&&Ji.enqueueReplaceState(p,p.state,null)}function Fd(c,p,k,R){var F=c.stateNode;F.props=k,F.state=c.memoizedState,F.refs={},Kc(c);var K=p.contextType;typeof K=="object"&&K!==null?F.context=Us(K):(K=fs(p)?Yo:Jr.current,F.context=Qr(c,K)),F.state=c.memoizedState,K=p.getDerivedStateFromProps,typeof K=="function"&&(Ii(c,p,K,k),F.state=c.memoizedState),typeof p.getDerivedStateFromProps=="function"||typeof F.getSnapshotBeforeUpdate=="function"||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(p=F.state,typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount(),p!==F.state&&Ji.enqueueReplaceState(F,F.state,null),Xc(c,k,F,R),F.state=c.memoizedState),typeof F.componentDidMount=="function"&&(c.flags|=4194308)}function Wa(c,p){try{var k="",R=p;do k+=Me(R),R=R.return;while(R);var F=k}catch(K){F=`
40
40
  Error generating stack: `+K.message+`
41
- `+K.stack}return{value:c,source:p,stack:F,digest:null}}function Ud(c,p,k){return{value:c,source:null,stack:k??null,digest:p??null}}function Hd(c,p){try{console.error(p.value)}catch(k){setTimeout(function(){throw k})}}var Ag=typeof WeakMap=="function"?WeakMap:Map;function op(c,p,k){k=Yi(-1,k),k.tag=3,k.payload={element:null};var R=p.value;return k.callback=function(){lu||(lu=!0,uh=R),Hd(c,p)},k}function ap(c,p,k){k=Yi(-1,k),k.tag=3;var R=c.type.getDerivedStateFromError;if(typeof R=="function"){var F=p.value;k.payload=function(){return R(F)},k.callback=function(){Hd(c,p)}}var K=c.stateNode;return K!==null&&typeof K.componentDidCatch=="function"&&(k.callback=function(){Hd(c,p),typeof R!="function"&&(To===null?To=new Set([this]):To.add(this));var ue=p.stack;this.componentDidCatch(p.value,{componentStack:ue!==null?ue:""})}),k}function lp(c,p,k){var R=c.pingCache;if(R===null){R=c.pingCache=new Ag;var F=new Set;R.set(p,F)}else F=R.get(p),F===void 0&&(F=new Set,R.set(p,F));F.has(k)||(F.add(k),c=Hg.bind(null,c,p,k),p.then(c,c))}function Rg(c){do{var p;if((p=c.tag===13)&&(p=c.memoizedState,p=p!==null?p.dehydrated!==null:!0),p)return c;c=c.return}while(c!==null);return null}function Zr(c,p,k,R,F){return(c.mode&1)===0?(c===p?c.flags|=65536:(c.flags|=128,k.flags|=131072,k.flags&=-52805,k.tag===1&&(k.alternate===null?k.tag=17:(p=Yi(-1,1),p.tag=2,Co(k,p,1))),k.lanes|=1),c):(c.flags|=65536,c.lanes=F,c)}var Mg=T.ReactCurrentOwner,ys=!1;function Or(c,p,k,R){p.child=c===null?_d(p,null,k,R):Ba(p,c.child,k,R)}function cp(c,p,k,R,F){k=k.render;var K=p.ref;return Fa(p,F),R=Dd(c,p,k,R,K,F),k=Od(),c!==null&&!ys?(p.updateQueue=c.updateQueue,p.flags&=-2053,c.lanes&=~F,Qi(c,p,F)):(Kn&&k&&ur(p),p.flags|=1,Or(c,p,R,F),p.child)}function zl(c,p,k,R,F){if(c===null){var K=k.type;return typeof K=="function"&&!xh(K)&&K.defaultProps===void 0&&k.compare===null&&k.defaultProps===void 0?(p.tag=15,p.type=K,up(c,p,K,R,F)):(c=fu(k.type,null,R,p,p.mode,F),c.ref=p.ref,c.return=p,p.child=c)}if(K=c.child,(c.lanes&F)===0){var ue=K.memoizedProps;if(k=k.compare,k=k!==null?k:jl,k(ue,R)&&c.ref===p.ref)return Qi(c,p,F)}return p.flags|=1,c=Ro(K,R),c.ref=p.ref,c.return=p,p.child=c}function up(c,p,k,R,F){if(c!==null){var K=c.memoizedProps;if(jl(K,R)&&c.ref===p.ref)if(ys=!1,p.pendingProps=R=K,(c.lanes&F)!==0)(c.flags&131072)!==0&&(ys=!0);else return p.lanes=c.lanes,Qi(c,p,F)}return Wd(c,p,k,R,F)}function dp(c,p,k){var R=p.pendingProps,F=R.children,K=c!==null?c.memoizedState:null;if(R.mode==="hidden")if((p.mode&1)===0)p.memoizedState={baseLanes:0,cachePool:null,transitions:null},In(Va,Ts),Ts|=k;else{if((k&1073741824)===0)return c=K!==null?K.baseLanes|k:k,p.lanes=p.childLanes=1073741824,p.memoizedState={baseLanes:c,cachePool:null,transitions:null},p.updateQueue=null,In(Va,Ts),Ts|=c,null;p.memoizedState={baseLanes:0,cachePool:null,transitions:null},R=K!==null?K.baseLanes:k,In(Va,Ts),Ts|=R}else K!==null?(R=K.baseLanes|k,p.memoizedState=null):R=k,In(Va,Ts),Ts|=R;return Or(c,p,F,k),p.child}function hp(c,p){var k=p.ref;(c===null&&k!==null||c!==null&&c.ref!==k)&&(p.flags|=512,p.flags|=2097152)}function Wd(c,p,k,R,F){var K=fs(k)?Yo:Jr.current;return K=Qr(p,K),Fa(p,F),k=Dd(c,p,k,R,K,F),R=Od(),c!==null&&!ys?(p.updateQueue=c.updateQueue,p.flags&=-2053,c.lanes&=~F,Qi(c,p,F)):(Kn&&R&&ur(p),p.flags|=1,Or(c,p,k,F),p.child)}function fp(c,p,k,R,F){if(fs(k)){var K=!0;Fc(p)}else K=!1;if(Fa(p,F),p.stateNode===null)nu(c,p),sp(p,k,R),Fd(p,k,R,F),R=!0;else if(c===null){var ue=p.stateNode,_e=p.memoizedProps;ue.props=_e;var $e=ue.context,qe=k.contextType;typeof qe=="object"&&qe!==null?qe=Us(qe):(qe=fs(k)?Yo:Jr.current,qe=Qr(p,qe));var at=k.getDerivedStateFromProps,ct=typeof at=="function"||typeof ue.getSnapshotBeforeUpdate=="function";ct||typeof ue.UNSAFE_componentWillReceiveProps!="function"&&typeof ue.componentWillReceiveProps!="function"||(_e!==R||$e!==qe)&&ip(p,ue,R,qe),Ri=!1;var ot=p.memoizedState;ue.state=ot,Xc(p,R,ue,F),$e=p.memoizedState,_e!==R||ot!==$e||hs.current||Ri?(typeof at=="function"&&(Ii(p,k,at,R),$e=p.memoizedState),(_e=Ri||ia(p,k,_e,R,ot,$e,qe))?(ct||typeof ue.UNSAFE_componentWillMount!="function"&&typeof ue.componentWillMount!="function"||(typeof ue.componentWillMount=="function"&&ue.componentWillMount(),typeof ue.UNSAFE_componentWillMount=="function"&&ue.UNSAFE_componentWillMount()),typeof ue.componentDidMount=="function"&&(p.flags|=4194308)):(typeof ue.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=R,p.memoizedState=$e),ue.props=R,ue.state=$e,ue.context=qe,R=_e):(typeof ue.componentDidMount=="function"&&(p.flags|=4194308),R=!1)}else{ue=p.stateNode,Ed(c,p),_e=p.memoizedProps,qe=p.type===p.elementType?_e:hr(p.type,_e),ue.props=qe,ct=p.pendingProps,ot=ue.context,$e=k.contextType,typeof $e=="object"&&$e!==null?$e=Us($e):($e=fs(k)?Yo:Jr.current,$e=Qr(p,$e));var jt=k.getDerivedStateFromProps;(at=typeof jt=="function"||typeof ue.getSnapshotBeforeUpdate=="function")||typeof ue.UNSAFE_componentWillReceiveProps!="function"&&typeof ue.componentWillReceiveProps!="function"||(_e!==ct||ot!==$e)&&ip(p,ue,R,$e),Ri=!1,ot=p.memoizedState,ue.state=ot,Xc(p,R,ue,F);var Pt=p.memoizedState;_e!==ct||ot!==Pt||hs.current||Ri?(typeof jt=="function"&&(Ii(p,k,jt,R),Pt=p.memoizedState),(qe=Ri||ia(p,k,qe,R,ot,Pt,$e)||!1)?(at||typeof ue.UNSAFE_componentWillUpdate!="function"&&typeof ue.componentWillUpdate!="function"||(typeof ue.componentWillUpdate=="function"&&ue.componentWillUpdate(R,Pt,$e),typeof ue.UNSAFE_componentWillUpdate=="function"&&ue.UNSAFE_componentWillUpdate(R,Pt,$e)),typeof ue.componentDidUpdate=="function"&&(p.flags|=4),typeof ue.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof ue.componentDidUpdate!="function"||_e===c.memoizedProps&&ot===c.memoizedState||(p.flags|=4),typeof ue.getSnapshotBeforeUpdate!="function"||_e===c.memoizedProps&&ot===c.memoizedState||(p.flags|=1024),p.memoizedProps=R,p.memoizedState=Pt),ue.props=R,ue.state=Pt,ue.context=$e,R=qe):(typeof ue.componentDidUpdate!="function"||_e===c.memoizedProps&&ot===c.memoizedState||(p.flags|=4),typeof ue.getSnapshotBeforeUpdate!="function"||_e===c.memoizedProps&&ot===c.memoizedState||(p.flags|=1024),R=!1)}return qd(c,p,k,R,K,F)}function qd(c,p,k,R,F,K){hp(c,p);var ue=(p.flags&128)!==0;if(!R&&!ue)return F&&Rf(p,k,!1),Qi(c,p,K);R=p.stateNode,Mg.current=p;var _e=ue&&typeof k.getDerivedStateFromError!="function"?null:R.render();return p.flags|=1,c!==null&&ue?(p.child=Ba(p,c.child,null,K),p.child=Ba(p,null,_e,K)):Or(c,p,_e,K),p.memoizedState=R.state,F&&Rf(p,k,!0),p.child}function Vd(c){var p=c.stateNode;p.pendingContext?$f(c,p.pendingContext,p.pendingContext!==p.context):p.context&&$f(c,p.context,!1),Nd(c,p.containerInfo)}function pp(c,p,k,R,F){return Qo(),bd(F),p.flags|=256,Or(c,p,k,R),p.child}var Gd={dehydrated:null,treeContext:null,retryLane:0};function Kd(c){return{baseLanes:c,cachePool:null,transitions:null}}function mp(c,p,k){var R=p.pendingProps,F=Yn.current,K=!1,ue=(p.flags&128)!==0,_e;if((_e=ue)||(_e=c!==null&&c.memoizedState===null?!1:(F&2)!==0),_e?(K=!0,p.flags&=-129):(c===null||c.memoizedState!==null)&&(F|=1),In(Yn,F&1),c===null)return yd(p),c=p.memoizedState,c!==null&&(c=c.dehydrated,c!==null)?((p.mode&1)===0?p.lanes=1:c.data==="$!"?p.lanes=8:p.lanes=1073741824,null):(ue=R.children,c=R.fallback,K?(R=p.mode,K=p.child,ue={mode:"hidden",children:ue},(R&1)===0&&K!==null?(K.childLanes=0,K.pendingProps=ue):K=pu(ue,R,0,null),c=Xa(c,R,k,null),K.return=p,c.return=p,K.sibling=c,p.child=K,p.child.memoizedState=Kd(k),p.memoizedState=Gd,c):Bl(p,ue));if(F=c.memoizedState,F!==null&&(_e=F.dehydrated,_e!==null))return Ig(c,p,ue,R,_e,F,k);if(K){K=R.fallback,ue=p.mode,F=c.child,_e=F.sibling;var $e={mode:"hidden",children:R.children};return(ue&1)===0&&p.child!==F?(R=p.child,R.childLanes=0,R.pendingProps=$e,p.deletions=null):(R=Ro(F,$e),R.subtreeFlags=F.subtreeFlags&14680064),_e!==null?K=Ro(_e,K):(K=Xa(K,ue,k,null),K.flags|=2),K.return=p,R.return=p,R.sibling=K,p.child=R,R=K,K=p.child,ue=c.child.memoizedState,ue=ue===null?Kd(k):{baseLanes:ue.baseLanes|k,cachePool:null,transitions:ue.transitions},K.memoizedState=ue,K.childLanes=c.childLanes&~k,p.memoizedState=Gd,R}return K=c.child,c=K.sibling,R=Ro(K,{mode:"visible",children:R.children}),(p.mode&1)===0&&(R.lanes=k),R.return=p,R.sibling=null,c!==null&&(k=p.deletions,k===null?(p.deletions=[c],p.flags|=16):k.push(c)),p.child=R,p.memoizedState=null,R}function Bl(c,p){return p=pu({mode:"visible",children:p},c.mode,0,null),p.return=c,c.child=p}function tu(c,p,k,R){return R!==null&&bd(R),Ba(p,c.child,null,k),c=Bl(p,p.pendingProps.children),c.flags|=2,p.memoizedState=null,c}function Ig(c,p,k,R,F,K,ue){if(k)return p.flags&256?(p.flags&=-257,R=Ud(Error(r(422))),tu(c,p,ue,R)):p.memoizedState!==null?(p.child=c.child,p.flags|=128,null):(K=R.fallback,F=p.mode,R=pu({mode:"visible",children:R.children},F,0,null),K=Xa(K,F,ue,null),K.flags|=2,R.return=p,K.return=p,R.sibling=K,p.child=R,(p.mode&1)!==0&&Ba(p,c.child,null,ue),p.child.memoizedState=Kd(ue),p.memoizedState=Gd,K);if((p.mode&1)===0)return tu(c,p,ue,null);if(F.data==="$!"){if(R=F.nextSibling&&F.nextSibling.dataset,R)var _e=R.dgst;return R=_e,K=Error(r(419)),R=Ud(K,R,void 0),tu(c,p,ue,R)}if(_e=(ue&c.childLanes)!==0,ys||_e){if(R=fr,R!==null){switch(ue&-ue){case 4:F=2;break;case 16:F=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:F=32;break;case 536870912:F=268435456;break;default:F=0}F=(F&(R.suspendedLanes|ue))!==0?0:F,F!==0&&F!==K.retryLane&&(K.retryLane=F,Xi(c,F),hi(R,c,F,-1))}return gh(),R=Ud(Error(r(421))),tu(c,p,ue,R)}return F.data==="$?"?(p.flags|=128,p.child=c.child,p=qg.bind(null,c),F._reactRetry=p,null):(c=K.treeContext,Ns=wo(F.nextSibling),gs=p,Kn=!0,xs=null,c!==null&&(Bs[li++]=ps,Bs[li++]=ms,Bs[li++]=Fs,ps=c.id,ms=c.overflow,Fs=p),p=Bl(p,R.children),p.flags|=4096,p)}function gp(c,p,k){c.lanes|=p;var R=c.alternate;R!==null&&(R.lanes|=p),Df(c.return,p,k)}function Xd(c,p,k,R,F){var K=c.memoizedState;K===null?c.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:R,tail:k,tailMode:F}:(K.isBackwards=p,K.rendering=null,K.renderingStartTime=0,K.last=R,K.tail=k,K.tailMode=F)}function Yd(c,p,k){var R=p.pendingProps,F=R.revealOrder,K=R.tail;if(Or(c,p,R.children,k),R=Yn.current,(R&2)!==0)R=R&1|2,p.flags|=128;else{if(c!==null&&(c.flags&128)!==0)e:for(c=p.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&gp(c,k,p);else if(c.tag===19)gp(c,k,p);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===p)break e;for(;c.sibling===null;){if(c.return===null||c.return===p)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}R&=1}if(In(Yn,R),(p.mode&1)===0)p.memoizedState=null;else switch(F){case"forwards":for(k=p.child,F=null;k!==null;)c=k.alternate,c!==null&&Yc(c)===null&&(F=k),k=k.sibling;k=F,k===null?(F=p.child,p.child=null):(F=k.sibling,k.sibling=null),Xd(p,!1,F,k,K);break;case"backwards":for(k=null,F=p.child,p.child=null;F!==null;){if(c=F.alternate,c!==null&&Yc(c)===null){p.child=F;break}c=F.sibling,F.sibling=k,k=F,F=c}Xd(p,!0,k,null,K);break;case"together":Xd(p,!1,null,null,void 0);break;default:p.memoizedState=null}return p.child}function nu(c,p){(p.mode&1)===0&&c!==null&&(c.alternate=null,p.alternate=null,p.flags|=2)}function Qi(c,p,k){if(c!==null&&(p.dependencies=c.dependencies),oa|=p.lanes,(k&p.childLanes)===0)return null;if(c!==null&&p.child!==c.child)throw Error(r(153));if(p.child!==null){for(c=p.child,k=Ro(c,c.pendingProps),p.child=k,k.return=p;c.sibling!==null;)c=c.sibling,k=k.sibling=Ro(c,c.pendingProps),k.return=p;k.sibling=null}return p.child}function fv(c,p,k){switch(p.tag){case 3:Vd(p),Qo();break;case 5:Of(p);break;case 1:fs(p.type)&&Fc(p);break;case 4:Nd(p,p.stateNode.containerInfo);break;case 10:var R=p.type._context,F=p.memoizedProps.value;In(Zo,R._currentValue),R._currentValue=F;break;case 13:if(R=p.memoizedState,R!==null)return R.dehydrated!==null?(In(Yn,Yn.current&1),p.flags|=128,null):(k&p.child.childLanes)!==0?mp(c,p,k):(In(Yn,Yn.current&1),c=Qi(c,p,k),c!==null?c.sibling:null);In(Yn,Yn.current&1);break;case 19:if(R=(k&p.childLanes)!==0,(c.flags&128)!==0){if(R)return Yd(c,p,k);p.flags|=128}if(F=p.memoizedState,F!==null&&(F.rendering=null,F.tail=null,F.lastEffect=null),In(Yn,Yn.current),R)break;return null;case 22:case 23:return p.lanes=0,dp(c,p,k)}return Qi(c,p,k)}var Jd,Qd,xp,yp;Jd=function(c,p){for(var k=p.child;k!==null;){if(k.tag===5||k.tag===6)c.appendChild(k.stateNode);else if(k.tag!==4&&k.child!==null){k.child.return=k,k=k.child;continue}if(k===p)break;for(;k.sibling===null;){if(k.return===null||k.return===p)return;k=k.return}k.sibling.return=k.return,k=k.sibling}},Qd=function(){},xp=function(c,p,k,R){var F=c.memoizedProps;if(F!==R){c=p.stateNode,ta(Mi.current);var K=null;switch(k){case"input":F=At(c,F),R=At(c,R),K=[];break;case"select":F=Q({},F,{value:void 0}),R=Q({},R,{value:void 0}),K=[];break;case"textarea":F=_t(c,F),R=_t(c,R),K=[];break;default:typeof F.onClick!="function"&&typeof R.onClick=="function"&&(c.onclick=Lc)}yi(k,R);var ue;k=null;for(qe in F)if(!R.hasOwnProperty(qe)&&F.hasOwnProperty(qe)&&F[qe]!=null)if(qe==="style"){var _e=F[qe];for(ue in _e)_e.hasOwnProperty(ue)&&(k||(k={}),k[ue]="")}else qe!=="dangerouslySetInnerHTML"&&qe!=="children"&&qe!=="suppressContentEditableWarning"&&qe!=="suppressHydrationWarning"&&qe!=="autoFocus"&&(o.hasOwnProperty(qe)?K||(K=[]):(K=K||[]).push(qe,null));for(qe in R){var $e=R[qe];if(_e=F!=null?F[qe]:void 0,R.hasOwnProperty(qe)&&$e!==_e&&($e!=null||_e!=null))if(qe==="style")if(_e){for(ue in _e)!_e.hasOwnProperty(ue)||$e&&$e.hasOwnProperty(ue)||(k||(k={}),k[ue]="");for(ue in $e)$e.hasOwnProperty(ue)&&_e[ue]!==$e[ue]&&(k||(k={}),k[ue]=$e[ue])}else k||(K||(K=[]),K.push(qe,k)),k=$e;else qe==="dangerouslySetInnerHTML"?($e=$e?$e.__html:void 0,_e=_e?_e.__html:void 0,$e!=null&&_e!==$e&&(K=K||[]).push(qe,$e)):qe==="children"?typeof $e!="string"&&typeof $e!="number"||(K=K||[]).push(qe,""+$e):qe!=="suppressContentEditableWarning"&&qe!=="suppressHydrationWarning"&&(o.hasOwnProperty(qe)?($e!=null&&qe==="onScroll"&&zn("scroll",c),K||_e===$e||(K=[])):(K=K||[]).push(qe,$e))}k&&(K=K||[]).push("style",k);var qe=K;(p.updateQueue=qe)&&(p.flags|=4)}},yp=function(c,p,k,R){k!==R&&(p.flags|=4)};function ru(c,p){if(!Kn)switch(c.tailMode){case"hidden":p=c.tail;for(var k=null;p!==null;)p.alternate!==null&&(k=p),p=p.sibling;k===null?c.tail=null:k.sibling=null;break;case"collapsed":k=c.tail;for(var R=null;k!==null;)k.alternate!==null&&(R=k),k=k.sibling;R===null?p||c.tail===null?c.tail=null:c.tail.sibling=null:R.sibling=null}}function Lr(c){var p=c.alternate!==null&&c.alternate.child===c.child,k=0,R=0;if(p)for(var F=c.child;F!==null;)k|=F.lanes|F.childLanes,R|=F.subtreeFlags&14680064,R|=F.flags&14680064,F.return=c,F=F.sibling;else for(F=c.child;F!==null;)k|=F.lanes|F.childLanes,R|=F.subtreeFlags,R|=F.flags,F.return=c,F=F.sibling;return c.subtreeFlags|=R,c.childLanes=k,p}function Pg(c,p,k){var R=p.pendingProps;switch(pd(p),p.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lr(p),null;case 1:return fs(p.type)&&Bc(),Lr(p),null;case 3:return R=p.stateNode,na(),Bn(hs),Bn(Jr),Ad(),R.pendingContext&&(R.context=R.pendingContext,R.pendingContext=null),(c===null||c.child===null)&&(Il(p)?p.flags|=4:c===null||c.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,xs!==null&&(fh(xs),xs=null))),Qd(c,p),Lr(p),null;case 5:Td(p);var F=ta(Ha.current);if(k=p.type,c!==null&&p.stateNode!=null)xp(c,p,k,R,F),c.ref!==p.ref&&(p.flags|=512,p.flags|=2097152);else{if(!R){if(p.stateNode===null)throw Error(r(166));return Lr(p),null}if(c=ta(Mi.current),Il(p)){R=p.stateNode,k=p.type;var K=p.memoizedProps;switch(R[$i]=p,R[Rl]=K,c=(p.mode&1)!==0,k){case"dialog":zn("cancel",R),zn("close",R);break;case"iframe":case"object":case"embed":zn("load",R);break;case"video":case"audio":for(F=0;F<Tl.length;F++)zn(Tl[F],R);break;case"source":zn("error",R);break;case"img":case"image":case"link":zn("error",R),zn("load",R);break;case"details":zn("toggle",R);break;case"input":He(R,K),zn("invalid",R);break;case"select":R._wrapperState={wasMultiple:!!K.multiple},zn("invalid",R);break;case"textarea":Kt(R,K),zn("invalid",R)}yi(k,K),F=null;for(var ue in K)if(K.hasOwnProperty(ue)){var _e=K[ue];ue==="children"?typeof _e=="string"?R.textContent!==_e&&(K.suppressHydrationWarning!==!0&&Oc(R.textContent,_e,c),F=["children",_e]):typeof _e=="number"&&R.textContent!==""+_e&&(K.suppressHydrationWarning!==!0&&Oc(R.textContent,_e,c),F=["children",""+_e]):o.hasOwnProperty(ue)&&_e!=null&&ue==="onScroll"&&zn("scroll",R)}switch(k){case"input":Je(R),an(R,K,!0);break;case"textarea":Je(R),Rn(R);break;case"select":case"option":break;default:typeof K.onClick=="function"&&(R.onclick=Lc)}R=F,p.updateQueue=R,R!==null&&(p.flags|=4)}else{ue=F.nodeType===9?F:F.ownerDocument,c==="http://www.w3.org/1999/xhtml"&&(c=Br(k)),c==="http://www.w3.org/1999/xhtml"?k==="script"?(c=ue.createElement("div"),c.innerHTML="<script><\/script>",c=c.removeChild(c.firstChild)):typeof R.is=="string"?c=ue.createElement(k,{is:R.is}):(c=ue.createElement(k),k==="select"&&(ue=c,R.multiple?ue.multiple=!0:R.size&&(ue.size=R.size))):c=ue.createElementNS(c,k),c[$i]=p,c[Rl]=R,Jd(c,p,!1,!1),p.stateNode=c;e:{switch(ue=yn(k,R),k){case"dialog":zn("cancel",c),zn("close",c),F=R;break;case"iframe":case"object":case"embed":zn("load",c),F=R;break;case"video":case"audio":for(F=0;F<Tl.length;F++)zn(Tl[F],c);F=R;break;case"source":zn("error",c),F=R;break;case"img":case"image":case"link":zn("error",c),zn("load",c),F=R;break;case"details":zn("toggle",c),F=R;break;case"input":He(c,R),F=At(c,R),zn("invalid",c);break;case"option":F=R;break;case"select":c._wrapperState={wasMultiple:!!R.multiple},F=Q({},R,{value:void 0}),zn("invalid",c);break;case"textarea":Kt(c,R),F=_t(c,R),zn("invalid",c);break;default:F=R}yi(k,F),_e=F;for(K in _e)if(_e.hasOwnProperty(K)){var $e=_e[K];K==="style"?Ea(c,$e):K==="dangerouslySetInnerHTML"?($e=$e?$e.__html:void 0,$e!=null&&St(c,$e)):K==="children"?typeof $e=="string"?(k!=="textarea"||$e!=="")&&Rt(c,$e):typeof $e=="number"&&Rt(c,""+$e):K!=="suppressContentEditableWarning"&&K!=="suppressHydrationWarning"&&K!=="autoFocus"&&(o.hasOwnProperty(K)?$e!=null&&K==="onScroll"&&zn("scroll",c):$e!=null&&j(c,K,$e,ue))}switch(k){case"input":Je(c),an(c,R,!1);break;case"textarea":Je(c),Rn(c);break;case"option":R.value!=null&&c.setAttribute("value",""+ne(R.value));break;case"select":c.multiple=!!R.multiple,K=R.value,K!=null?yt(c,!!R.multiple,K,!1):R.defaultValue!=null&&yt(c,!!R.multiple,R.defaultValue,!0);break;default:typeof F.onClick=="function"&&(c.onclick=Lc)}switch(k){case"button":case"input":case"select":case"textarea":R=!!R.autoFocus;break e;case"img":R=!0;break e;default:R=!1}}R&&(p.flags|=4)}p.ref!==null&&(p.flags|=512,p.flags|=2097152)}return Lr(p),null;case 6:if(c&&p.stateNode!=null)yp(c,p,c.memoizedProps,R);else{if(typeof R!="string"&&p.stateNode===null)throw Error(r(166));if(k=ta(Ha.current),ta(Mi.current),Il(p)){if(R=p.stateNode,k=p.memoizedProps,R[$i]=p,(K=R.nodeValue!==k)&&(c=gs,c!==null))switch(c.tag){case 3:Oc(R.nodeValue,k,(c.mode&1)!==0);break;case 5:c.memoizedProps.suppressHydrationWarning!==!0&&Oc(R.nodeValue,k,(c.mode&1)!==0)}K&&(p.flags|=4)}else R=(k.nodeType===9?k:k.ownerDocument).createTextNode(R),R[$i]=p,p.stateNode=R}return Lr(p),null;case 13:if(Bn(Yn),R=p.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(Kn&&Ns!==null&&(p.mode&1)!==0&&(p.flags&128)===0)If(),Qo(),p.flags|=98560,K=!1;else if(K=Il(p),R!==null&&R.dehydrated!==null){if(c===null){if(!K)throw Error(r(318));if(K=p.memoizedState,K=K!==null?K.dehydrated:null,!K)throw Error(r(317));K[$i]=p}else Qo(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;Lr(p),K=!1}else xs!==null&&(fh(xs),xs=null),K=!0;if(!K)return p.flags&65536?p:null}return(p.flags&128)!==0?(p.lanes=k,p):(R=R!==null,R!==(c!==null&&c.memoizedState!==null)&&R&&(p.child.flags|=8192,(p.mode&1)!==0&&(c===null||(Yn.current&1)!==0?br===0&&(br=3):gh())),p.updateQueue!==null&&(p.flags|=4),Lr(p),null);case 4:return na(),Qd(c,p),c===null&&$l(p.stateNode.containerInfo),Lr(p),null;case 10:return Cd(p.type._context),Lr(p),null;case 17:return fs(p.type)&&Bc(),Lr(p),null;case 19:if(Bn(Yn),K=p.memoizedState,K===null)return Lr(p),null;if(R=(p.flags&128)!==0,ue=K.rendering,ue===null)if(R)ru(K,!1);else{if(br!==0||c!==null&&(c.flags&128)!==0)for(c=p.child;c!==null;){if(ue=Yc(c),ue!==null){for(p.flags|=128,ru(K,!1),R=ue.updateQueue,R!==null&&(p.updateQueue=R,p.flags|=4),p.subtreeFlags=0,R=k,k=p.child;k!==null;)K=k,c=R,K.flags&=14680066,ue=K.alternate,ue===null?(K.childLanes=0,K.lanes=c,K.child=null,K.subtreeFlags=0,K.memoizedProps=null,K.memoizedState=null,K.updateQueue=null,K.dependencies=null,K.stateNode=null):(K.childLanes=ue.childLanes,K.lanes=ue.lanes,K.child=ue.child,K.subtreeFlags=0,K.deletions=null,K.memoizedProps=ue.memoizedProps,K.memoizedState=ue.memoizedState,K.updateQueue=ue.updateQueue,K.type=ue.type,c=ue.dependencies,K.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext}),k=k.sibling;return In(Yn,Yn.current&1|2),p.child}c=c.sibling}K.tail!==null&&kn()>Ga&&(p.flags|=128,R=!0,ru(K,!1),p.lanes=4194304)}else{if(!R)if(c=Yc(ue),c!==null){if(p.flags|=128,R=!0,k=c.updateQueue,k!==null&&(p.updateQueue=k,p.flags|=4),ru(K,!0),K.tail===null&&K.tailMode==="hidden"&&!ue.alternate&&!Kn)return Lr(p),null}else 2*kn()-K.renderingStartTime>Ga&&k!==1073741824&&(p.flags|=128,R=!0,ru(K,!1),p.lanes=4194304);K.isBackwards?(ue.sibling=p.child,p.child=ue):(k=K.last,k!==null?k.sibling=ue:p.child=ue,K.last=ue)}return K.tail!==null?(p=K.tail,K.rendering=p,K.tail=p.sibling,K.renderingStartTime=kn(),p.sibling=null,k=Yn.current,In(Yn,R?k&1|2:k&1),p):(Lr(p),null);case 22:case 23:return mh(),R=p.memoizedState!==null,c!==null&&c.memoizedState!==null!==R&&(p.flags|=8192),R&&(p.mode&1)!==0?(Ts&1073741824)!==0&&(Lr(p),p.subtreeFlags&6&&(p.flags|=8192)):Lr(p),null;case 24:return null;case 25:return null}throw Error(r(156,p.tag))}function Dg(c,p){switch(pd(p),p.tag){case 1:return fs(p.type)&&Bc(),c=p.flags,c&65536?(p.flags=c&-65537|128,p):null;case 3:return na(),Bn(hs),Bn(Jr),Ad(),c=p.flags,(c&65536)!==0&&(c&128)===0?(p.flags=c&-65537|128,p):null;case 5:return Td(p),null;case 13:if(Bn(Yn),c=p.memoizedState,c!==null&&c.dehydrated!==null){if(p.alternate===null)throw Error(r(340));Qo()}return c=p.flags,c&65536?(p.flags=c&-65537|128,p):null;case 19:return Bn(Yn),null;case 4:return na(),null;case 10:return Cd(p.type._context),null;case 22:case 23:return mh(),null;case 24:return null;default:return null}}var Zd=!1,zr=!1,Og=typeof WeakSet=="function"?WeakSet:Set,It=null;function qa(c,p){var k=c.ref;if(k!==null)if(typeof k=="function")try{k(null)}catch(R){Jn(c,p,R)}else k.current=null}function eh(c,p,k){try{k()}catch(R){Jn(c,p,R)}}var vp=!1;function Lg(c,p){if(od=vo,c=Qu(),Zu(c)){if("selectionStart"in c)var k={start:c.selectionStart,end:c.selectionEnd};else e:{k=(k=c.ownerDocument)&&k.defaultView||window;var R=k.getSelection&&k.getSelection();if(R&&R.rangeCount!==0){k=R.anchorNode;var F=R.anchorOffset,K=R.focusNode;R=R.focusOffset;try{k.nodeType,K.nodeType}catch{k=null;break e}var ue=0,_e=-1,$e=-1,qe=0,at=0,ct=c,ot=null;t:for(;;){for(var jt;ct!==k||F!==0&&ct.nodeType!==3||(_e=ue+F),ct!==K||R!==0&&ct.nodeType!==3||($e=ue+R),ct.nodeType===3&&(ue+=ct.nodeValue.length),(jt=ct.firstChild)!==null;)ot=ct,ct=jt;for(;;){if(ct===c)break t;if(ot===k&&++qe===F&&(_e=ue),ot===K&&++at===R&&($e=ue),(jt=ct.nextSibling)!==null)break;ct=ot,ot=ct.parentNode}ct=jt}k=_e===-1||$e===-1?null:{start:_e,end:$e}}else k=null}k=k||{start:0,end:0}}else k=null;for(ad={focusedElem:c,selectionRange:k},vo=!1,It=p;It!==null;)if(p=It,c=p.child,(p.subtreeFlags&1028)!==0&&c!==null)c.return=p,It=c;else for(;It!==null;){p=It;try{var Pt=p.alternate;if((p.flags&1024)!==0)switch(p.tag){case 0:case 11:case 15:break;case 1:if(Pt!==null){var Dt=Pt.memoizedProps,Pn=Pt.memoizedState,Ue=p.stateNode,Ie=Ue.getSnapshotBeforeUpdate(p.elementType===p.type?Dt:hr(p.type,Dt),Pn);Ue.__reactInternalSnapshotBeforeUpdate=Ie}break;case 3:var Ve=p.stateNode.containerInfo;Ve.nodeType===1?Ve.textContent="":Ve.nodeType===9&&Ve.documentElement&&Ve.removeChild(Ve.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(ht){Jn(p,p.return,ht)}if(c=p.sibling,c!==null){c.return=p.return,It=c;break}It=p.return}return Pt=vp,vp=!1,Pt}function Fl(c,p,k){var R=p.updateQueue;if(R=R!==null?R.lastEffect:null,R!==null){var F=R=R.next;do{if((F.tag&c)===c){var K=F.destroy;F.destroy=void 0,K!==void 0&&eh(p,k,K)}F=F.next}while(F!==R)}}function th(c,p){if(p=p.updateQueue,p=p!==null?p.lastEffect:null,p!==null){var k=p=p.next;do{if((k.tag&c)===c){var R=k.create;k.destroy=R()}k=k.next}while(k!==p)}}function nh(c){var p=c.ref;if(p!==null){var k=c.stateNode;switch(c.tag){case 5:c=k;break;default:c=k}typeof p=="function"?p(c):p.current=c}}function bp(c){var p=c.alternate;p!==null&&(c.alternate=null,bp(p)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(p=c.stateNode,p!==null&&(delete p[$i],delete p[Rl],delete p[dd],delete p[Nf],delete p[Tf])),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function wp(c){return c.tag===5||c.tag===3||c.tag===4}function _p(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||wp(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function rh(c,p,k){var R=c.tag;if(R===5||R===6)c=c.stateNode,p?k.nodeType===8?k.parentNode.insertBefore(c,p):k.insertBefore(c,p):(k.nodeType===8?(p=k.parentNode,p.insertBefore(c,k)):(p=k,p.appendChild(c)),k=k._reactRootContainer,k!=null||p.onclick!==null||(p.onclick=Lc));else if(R!==4&&(c=c.child,c!==null))for(rh(c,p,k),c=c.sibling;c!==null;)rh(c,p,k),c=c.sibling}function sh(c,p,k){var R=c.tag;if(R===5||R===6)c=c.stateNode,p?k.insertBefore(c,p):k.appendChild(c);else if(R!==4&&(c=c.child,c!==null))for(sh(c,p,k),c=c.sibling;c!==null;)sh(c,p,k),c=c.sibling}var Cr=null,ui=!1;function Eo(c,p,k){for(k=k.child;k!==null;)zg(c,p,k),k=k.sibling}function zg(c,p,k){if(gr&&typeof gr.onCommitFiberUnmount=="function")try{gr.onCommitFiberUnmount(cs,k)}catch{}switch(k.tag){case 5:zr||qa(k,p);case 6:var R=Cr,F=ui;Cr=null,Eo(c,p,k),Cr=R,ui=F,Cr!==null&&(ui?(c=Cr,k=k.stateNode,c.nodeType===8?c.parentNode.removeChild(k):c.removeChild(k)):Cr.removeChild(k.stateNode));break;case 18:Cr!==null&&(ui?(c=Cr,k=k.stateNode,c.nodeType===8?ud(c.parentNode,k):c.nodeType===1&&ud(c,k),qi(c)):ud(Cr,k.stateNode));break;case 4:R=Cr,F=ui,Cr=k.stateNode.containerInfo,ui=!0,Eo(c,p,k),Cr=R,ui=F;break;case 0:case 11:case 14:case 15:if(!zr&&(R=k.updateQueue,R!==null&&(R=R.lastEffect,R!==null))){F=R=R.next;do{var K=F,ue=K.destroy;K=K.tag,ue!==void 0&&((K&2)!==0||(K&4)!==0)&&eh(k,p,ue),F=F.next}while(F!==R)}Eo(c,p,k);break;case 1:if(!zr&&(qa(k,p),R=k.stateNode,typeof R.componentWillUnmount=="function"))try{R.props=k.memoizedProps,R.state=k.memoizedState,R.componentWillUnmount()}catch(_e){Jn(k,p,_e)}Eo(c,p,k);break;case 21:Eo(c,p,k);break;case 22:k.mode&1?(zr=(R=zr)||k.memoizedState!==null,Eo(c,p,k),zr=R):Eo(c,p,k);break;default:Eo(c,p,k)}}function Ul(c){var p=c.updateQueue;if(p!==null){c.updateQueue=null;var k=c.stateNode;k===null&&(k=c.stateNode=new Og),p.forEach(function(R){var F=Vg.bind(null,c,R);k.has(R)||(k.add(R),R.then(F,F))})}}function Ws(c,p){var k=p.deletions;if(k!==null)for(var R=0;R<k.length;R++){var F=k[R];try{var K=c,ue=p,_e=ue;e:for(;_e!==null;){switch(_e.tag){case 5:Cr=_e.stateNode,ui=!1;break e;case 3:Cr=_e.stateNode.containerInfo,ui=!0;break e;case 4:Cr=_e.stateNode.containerInfo,ui=!0;break e}_e=_e.return}if(Cr===null)throw Error(r(160));zg(K,ue,F),Cr=null,ui=!1;var $e=F.alternate;$e!==null&&($e.return=null),F.return=null}catch(qe){Jn(F,p,qe)}}if(p.subtreeFlags&12854)for(p=p.child;p!==null;)ih(p,c),p=p.sibling}function ih(c,p){var k=c.alternate,R=c.flags;switch(c.tag){case 0:case 11:case 14:case 15:if(Ws(p,c),di(c),R&4){try{Fl(3,c,c.return),th(3,c)}catch(Dt){Jn(c,c.return,Dt)}try{Fl(5,c,c.return)}catch(Dt){Jn(c,c.return,Dt)}}break;case 1:Ws(p,c),di(c),R&512&&k!==null&&qa(k,k.return);break;case 5:if(Ws(p,c),di(c),R&512&&k!==null&&qa(k,k.return),c.flags&32){var F=c.stateNode;try{Rt(F,"")}catch(Dt){Jn(c,c.return,Dt)}}if(R&4&&(F=c.stateNode,F!=null)){var K=c.memoizedProps,ue=k!==null?k.memoizedProps:K,_e=c.type,$e=c.updateQueue;if(c.updateQueue=null,$e!==null)try{_e==="input"&&K.type==="radio"&&K.name!=null&&vt(F,K),yn(_e,ue);var qe=yn(_e,K);for(ue=0;ue<$e.length;ue+=2){var at=$e[ue],ct=$e[ue+1];at==="style"?Ea(F,ct):at==="dangerouslySetInnerHTML"?St(F,ct):at==="children"?Rt(F,ct):j(F,at,ct,qe)}switch(_e){case"input":st(F,K);break;case"textarea":On(F,K);break;case"select":var ot=F._wrapperState.wasMultiple;F._wrapperState.wasMultiple=!!K.multiple;var jt=K.value;jt!=null?yt(F,!!K.multiple,jt,!1):ot!==!!K.multiple&&(K.defaultValue!=null?yt(F,!!K.multiple,K.defaultValue,!0):yt(F,!!K.multiple,K.multiple?[]:"",!1))}F[Rl]=K}catch(Dt){Jn(c,c.return,Dt)}}break;case 6:if(Ws(p,c),di(c),R&4){if(c.stateNode===null)throw Error(r(162));F=c.stateNode,K=c.memoizedProps;try{F.nodeValue=K}catch(Dt){Jn(c,c.return,Dt)}}break;case 3:if(Ws(p,c),di(c),R&4&&k!==null&&k.memoizedState.isDehydrated)try{qi(p.containerInfo)}catch(Dt){Jn(c,c.return,Dt)}break;case 4:Ws(p,c),di(c);break;case 13:Ws(p,c),di(c),F=c.child,F.flags&8192&&(K=F.memoizedState!==null,F.stateNode.isHidden=K,!K||F.alternate!==null&&F.alternate.memoizedState!==null||(ch=kn())),R&4&&Ul(c);break;case 22:if(at=k!==null&&k.memoizedState!==null,c.mode&1?(zr=(qe=zr)||at,Ws(p,c),zr=qe):Ws(p,c),di(c),R&8192){if(qe=c.memoizedState!==null,(c.stateNode.isHidden=qe)&&!at&&(c.mode&1)!==0)for(It=c,at=c.child;at!==null;){for(ct=It=at;It!==null;){switch(ot=It,jt=ot.child,ot.tag){case 0:case 11:case 14:case 15:Fl(4,ot,ot.return);break;case 1:qa(ot,ot.return);var Pt=ot.stateNode;if(typeof Pt.componentWillUnmount=="function"){R=ot,k=ot.return;try{p=R,Pt.props=p.memoizedProps,Pt.state=p.memoizedState,Pt.componentWillUnmount()}catch(Dt){Jn(R,k,Dt)}}break;case 5:qa(ot,ot.return);break;case 22:if(ot.memoizedState!==null){oh(ct);continue}}jt!==null?(jt.return=ot,It=jt):oh(ct)}at=at.sibling}e:for(at=null,ct=c;;){if(ct.tag===5){if(at===null){at=ct;try{F=ct.stateNode,qe?(K=F.style,typeof K.setProperty=="function"?K.setProperty("display","none","important"):K.display="none"):(_e=ct.stateNode,$e=ct.memoizedProps.style,ue=$e!=null&&$e.hasOwnProperty("display")?$e.display:null,_e.style.display=$r("display",ue))}catch(Dt){Jn(c,c.return,Dt)}}}else if(ct.tag===6){if(at===null)try{ct.stateNode.nodeValue=qe?"":ct.memoizedProps}catch(Dt){Jn(c,c.return,Dt)}}else if((ct.tag!==22&&ct.tag!==23||ct.memoizedState===null||ct===c)&&ct.child!==null){ct.child.return=ct,ct=ct.child;continue}if(ct===c)break e;for(;ct.sibling===null;){if(ct.return===null||ct.return===c)break e;at===ct&&(at=null),ct=ct.return}at===ct&&(at=null),ct.sibling.return=ct.return,ct=ct.sibling}}break;case 19:Ws(p,c),di(c),R&4&&Ul(c);break;case 21:break;default:Ws(p,c),di(c)}}function di(c){var p=c.flags;if(p&2){try{e:{for(var k=c.return;k!==null;){if(wp(k)){var R=k;break e}k=k.return}throw Error(r(160))}switch(R.tag){case 5:var F=R.stateNode;R.flags&32&&(Rt(F,""),R.flags&=-33);var K=_p(c);sh(c,K,F);break;case 3:case 4:var ue=R.stateNode.containerInfo,_e=_p(c);rh(c,_e,ue);break;default:throw Error(r(161))}}catch($e){Jn(c,c.return,$e)}c.flags&=-3}p&4096&&(c.flags&=-4097)}function kp(c,p,k){It=c,Sp(c)}function Sp(c,p,k){for(var R=(c.mode&1)!==0;It!==null;){var F=It,K=F.child;if(F.tag===22&&R){var ue=F.memoizedState!==null||Zd;if(!ue){var _e=F.alternate,$e=_e!==null&&_e.memoizedState!==null||zr;_e=Zd;var qe=zr;if(Zd=ue,(zr=$e)&&!qe)for(It=F;It!==null;)ue=It,$e=ue.child,ue.tag===22&&ue.memoizedState!==null?ah(F):$e!==null?($e.return=ue,It=$e):ah(F);for(;K!==null;)It=K,Sp(K),K=K.sibling;It=F,Zd=_e,zr=qe}Cp(c)}else(F.subtreeFlags&8772)!==0&&K!==null?(K.return=F,It=K):Cp(c)}}function Cp(c){for(;It!==null;){var p=It;if((p.flags&8772)!==0){var k=p.alternate;try{if((p.flags&8772)!==0)switch(p.tag){case 0:case 11:case 15:zr||th(5,p);break;case 1:var R=p.stateNode;if(p.flags&4&&!zr)if(k===null)R.componentDidMount();else{var F=p.elementType===p.type?k.memoizedProps:hr(p.type,k.memoizedProps);R.componentDidUpdate(F,k.memoizedState,R.__reactInternalSnapshotBeforeUpdate)}var K=p.updateQueue;K!==null&&kg(p,K,R);break;case 3:var ue=p.updateQueue;if(ue!==null){if(k=null,p.child!==null)switch(p.child.tag){case 5:k=p.child.stateNode;break;case 1:k=p.child.stateNode}kg(p,ue,k)}break;case 5:var _e=p.stateNode;if(k===null&&p.flags&4){k=_e;var $e=p.memoizedProps;switch(p.type){case"button":case"input":case"select":case"textarea":$e.autoFocus&&k.focus();break;case"img":$e.src&&(k.src=$e.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(p.memoizedState===null){var qe=p.alternate;if(qe!==null){var at=qe.memoizedState;if(at!==null){var ct=at.dehydrated;ct!==null&&qi(ct)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}zr||p.flags&512&&nh(p)}catch(ot){Jn(p,p.return,ot)}}if(p===c){It=null;break}if(k=p.sibling,k!==null){k.return=p.return,It=k;break}It=p.return}}function oh(c){for(;It!==null;){var p=It;if(p===c){It=null;break}var k=p.sibling;if(k!==null){k.return=p.return,It=k;break}It=p.return}}function ah(c){for(;It!==null;){var p=It;try{switch(p.tag){case 0:case 11:case 15:var k=p.return;try{th(4,p)}catch($e){Jn(p,k,$e)}break;case 1:var R=p.stateNode;if(typeof R.componentDidMount=="function"){var F=p.return;try{R.componentDidMount()}catch($e){Jn(p,F,$e)}}var K=p.return;try{nh(p)}catch($e){Jn(p,K,$e)}break;case 5:var ue=p.return;try{nh(p)}catch($e){Jn(p,ue,$e)}}}catch($e){Jn(p,p.return,$e)}if(p===c){It=null;break}var _e=p.sibling;if(_e!==null){_e.return=p.return,It=_e;break}It=p.return}}var Bg=Math.ceil,su=T.ReactCurrentDispatcher,iu=T.ReactCurrentOwner,qs=T.ReactCurrentBatchConfig,gn=0,fr=null,ar=null,jr=0,Ts=0,Va=Gi(0),br=0,Hl=null,oa=0,ou=0,lh=0,au=null,vs=null,ch=0,Ga=1/0,No=null,lu=!1,uh=null,To=null,cu=!1,aa=null,uu=0,Wl=0,dh=null,ql=-1,du=0;function es(){return(gn&6)!==0?kn():ql!==-1?ql:ql=kn()}function $o(c){return(c.mode&1)===0?1:(gn&2)!==0&&jr!==0?jr&-jr:wd.transition!==null?(du===0&&(du=Es()),du):(c=Pe,c!==0||(c=window.event,c=c===void 0?16:he(c.type)),c)}function hi(c,p,k,R){if(50<Wl)throw Wl=0,dh=null,Error(r(185));qr(c,k,R),((gn&2)===0||c!==fr)&&(c===fr&&((gn&2)===0&&(ou|=k),br===4&&Ao(c,jr)),bs(c,R),k===1&&gn===0&&(p.mode&1)===0&&(Ga=kn()+500,Uc&&ko()))}function bs(c,p){var k=c.callbackNode;ds(c,p);var R=Ci(c,c===fr?jr:0);if(R===0)k!==null&&Sr(k),c.callbackNode=null,c.callbackPriority=0;else if(p=R&-R,c.callbackPriority!==p){if(k!=null&&Sr(k),p===1)c.tag===0?uv(Np.bind(null,c)):Mf(Np.bind(null,c)),vg(function(){(gn&6)===0&&ko()}),k=null;else{switch(Qe(R)){case 1:k=Vn;break;case 4:k=Ir;break;case 16:k=ti;break;case 536870912:k=_i;break;default:k=ti}k=Ip(k,jp.bind(null,c))}c.callbackPriority=p,c.callbackNode=k}}function jp(c,p){if(ql=-1,du=0,(gn&6)!==0)throw Error(r(327));var k=c.callbackNode;if(Ka()&&c.callbackNode!==k)return null;var R=Ci(c,c===fr?jr:0);if(R===0)return null;if((R&30)!==0||(R&c.expiredLanes)!==0||p)p=hu(c,R);else{p=R;var F=gn;gn|=2;var K=Fg();(fr!==c||jr!==p)&&(No=null,Ga=kn()+500,ca(c,p));do try{pv();break}catch(_e){Tp(c,_e)}while(!0);Sd(),su.current=K,gn=F,ar!==null?p=0:(fr=null,jr=0,p=br)}if(p!==0){if(p===2&&(F=Hi(c),F!==0&&(R=F,p=hh(c,F))),p===1)throw k=Hl,ca(c,0),Ao(c,R),bs(c,kn()),k;if(p===6)Ao(c,R);else{if(F=c.current.alternate,(R&30)===0&&!Ep(F)&&(p=hu(c,R),p===2&&(K=Hi(c),K!==0&&(R=K,p=hh(c,K))),p===1))throw k=Hl,ca(c,0),Ao(c,R),bs(c,kn()),k;switch(c.finishedWork=F,c.finishedLanes=R,p){case 0:case 1:throw Error(r(345));case 2:ua(c,vs,No);break;case 3:if(Ao(c,R),(R&130023424)===R&&(p=ch+500-kn(),10<p)){if(Ci(c,0)!==0)break;if(F=c.suspendedLanes,(F&R)!==R){es(),c.pingedLanes|=c.suspendedLanes&F;break}c.timeoutHandle=cd(ua.bind(null,c,vs,No),p);break}ua(c,vs,No);break;case 4:if(Ao(c,R),(R&4194240)===R)break;for(p=c.eventTimes,F=-1;0<R;){var ue=31-Gn(R);K=1<<ue,ue=p[ue],ue>F&&(F=ue),R&=~K}if(R=F,R=kn()-R,R=(120>R?120:480>R?480:1080>R?1080:1920>R?1920:3e3>R?3e3:4320>R?4320:1960*Bg(R/1960))-R,10<R){c.timeoutHandle=cd(ua.bind(null,c,vs,No),R);break}ua(c,vs,No);break;case 5:ua(c,vs,No);break;default:throw Error(r(329))}}}return bs(c,kn()),c.callbackNode===k?jp.bind(null,c):null}function hh(c,p){var k=au;return c.current.memoizedState.isDehydrated&&(ca(c,p).flags|=256),c=hu(c,p),c!==2&&(p=vs,vs=k,p!==null&&fh(p)),c}function fh(c){vs===null?vs=c:vs.push.apply(vs,c)}function Ep(c){for(var p=c;;){if(p.flags&16384){var k=p.updateQueue;if(k!==null&&(k=k.stores,k!==null))for(var R=0;R<k.length;R++){var F=k[R],K=F.getSnapshot;F=F.value;try{if(!ai(K(),F))return!1}catch{return!1}}}if(k=p.child,p.subtreeFlags&16384&&k!==null)k.return=p,p=k;else{if(p===c)break;for(;p.sibling===null;){if(p.return===null||p.return===c)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function Ao(c,p){for(p&=~lh,p&=~ou,c.suspendedLanes|=p,c.pingedLanes&=~p,c=c.expirationTimes;0<p;){var k=31-Gn(p),R=1<<k;c[k]=-1,p&=~R}}function Np(c){if((gn&6)!==0)throw Error(r(327));Ka();var p=Ci(c,0);if((p&1)===0)return bs(c,kn()),null;var k=hu(c,p);if(c.tag!==0&&k===2){var R=Hi(c);R!==0&&(p=R,k=hh(c,R))}if(k===1)throw k=Hl,ca(c,0),Ao(c,p),bs(c,kn()),k;if(k===6)throw Error(r(345));return c.finishedWork=c.current.alternate,c.finishedLanes=p,ua(c,vs,No),bs(c,kn()),null}function ph(c,p){var k=gn;gn|=1;try{return c(p)}finally{gn=k,gn===0&&(Ga=kn()+500,Uc&&ko())}}function la(c){aa!==null&&aa.tag===0&&(gn&6)===0&&Ka();var p=gn;gn|=1;var k=qs.transition,R=Pe;try{if(qs.transition=null,Pe=1,c)return c()}finally{Pe=R,qs.transition=k,gn=p,(gn&6)===0&&ko()}}function mh(){Ts=Va.current,Bn(Va)}function ca(c,p){c.finishedWork=null,c.finishedLanes=0;var k=c.timeoutHandle;if(k!==-1&&(c.timeoutHandle=-1,yg(k)),ar!==null)for(k=ar.return;k!==null;){var R=k;switch(pd(R),R.tag){case 1:R=R.type.childContextTypes,R!=null&&Bc();break;case 3:na(),Bn(hs),Bn(Jr),Ad();break;case 5:Td(R);break;case 4:na();break;case 13:Bn(Yn);break;case 19:Bn(Yn);break;case 10:Cd(R.type._context);break;case 22:case 23:mh()}k=k.return}if(fr=c,ar=c=Ro(c.current,null),jr=Ts=p,br=0,Hl=null,lh=ou=oa=0,vs=au=null,Ua!==null){for(p=0;p<Ua.length;p++)if(k=Ua[p],R=k.interleaved,R!==null){k.interleaved=null;var F=R.next,K=k.pending;if(K!==null){var ue=K.next;K.next=F,R.next=ue}k.pending=R}Ua=null}return c}function Tp(c,p){do{var k=ar;try{if(Sd(),Rd.current=eu,Id){for(var R=Xn.memoizedState;R!==null;){var F=R.queue;F!==null&&(F.pending=null),R=R.next}Id=!1}if(ra=0,vr=dr=Xn=null,sa=!1,jo=0,iu.current=null,k===null||k.return===null){br=1,Hl=p,ar=null;break}e:{var K=c,ue=k.return,_e=k,$e=p;if(p=jr,_e.flags|=32768,$e!==null&&typeof $e=="object"&&typeof $e.then=="function"){var qe=$e,at=_e,ct=at.tag;if((at.mode&1)===0&&(ct===0||ct===11||ct===15)){var ot=at.alternate;ot?(at.updateQueue=ot.updateQueue,at.memoizedState=ot.memoizedState,at.lanes=ot.lanes):(at.updateQueue=null,at.memoizedState=null)}var jt=Rg(ue);if(jt!==null){jt.flags&=-257,Zr(jt,ue,_e,K,p),jt.mode&1&&lp(K,qe,p),p=jt,$e=qe;var Pt=p.updateQueue;if(Pt===null){var Dt=new Set;Dt.add($e),p.updateQueue=Dt}else Pt.add($e);break e}else{if((p&1)===0){lp(K,qe,p),gh();break e}$e=Error(r(426))}}else if(Kn&&_e.mode&1){var Pn=Rg(ue);if(Pn!==null){(Pn.flags&65536)===0&&(Pn.flags|=256),Zr(Pn,ue,_e,K,p),bd(Wa($e,_e));break e}}K=$e=Wa($e,_e),br!==4&&(br=2),au===null?au=[K]:au.push(K),K=ue;do{switch(K.tag){case 3:K.flags|=65536,p&=-p,K.lanes|=p;var Ue=op(K,$e,p);_g(K,Ue);break e;case 1:_e=$e;var Ie=K.type,Ve=K.stateNode;if((K.flags&128)===0&&(typeof Ie.getDerivedStateFromError=="function"||Ve!==null&&typeof Ve.componentDidCatch=="function"&&(To===null||!To.has(Ve)))){K.flags|=65536,p&=-p,K.lanes|=p;var ht=ap(K,_e,p);_g(K,ht);break e}}K=K.return}while(K!==null)}Vl(k)}catch(Ft){p=Ft,ar===k&&k!==null&&(ar=k=k.return);continue}break}while(!0)}function Fg(){var c=su.current;return su.current=eu,c===null?eu:c}function gh(){(br===0||br===3||br===2)&&(br=4),fr===null||(oa&268435455)===0&&(ou&268435455)===0||Ao(fr,jr)}function hu(c,p){var k=gn;gn|=2;var R=Fg();(fr!==c||jr!==p)&&(No=null,ca(c,p));do try{Ug();break}catch(F){Tp(c,F)}while(!0);if(Sd(),gn=k,su.current=R,ar!==null)throw Error(r(261));return fr=null,jr=0,br}function Ug(){for(;ar!==null;)$p(ar)}function pv(){for(;ar!==null&&!Ta();)$p(ar)}function $p(c){var p=Mp(c.alternate,c,Ts);c.memoizedProps=c.pendingProps,p===null?Vl(c):ar=p,iu.current=null}function Vl(c){var p=c;do{var k=p.alternate;if(c=p.return,(p.flags&32768)===0){if(k=Pg(k,p,Ts),k!==null){ar=k;return}}else{if(k=Dg(k,p),k!==null){k.flags&=32767,ar=k;return}if(c!==null)c.flags|=32768,c.subtreeFlags=0,c.deletions=null;else{br=6,ar=null;return}}if(p=p.sibling,p!==null){ar=p;return}ar=p=c}while(p!==null);br===0&&(br=5)}function ua(c,p,k){var R=Pe,F=qs.transition;try{qs.transition=null,Pe=1,Ap(c,p,k,R)}finally{qs.transition=F,Pe=R}return null}function Ap(c,p,k,R){do Ka();while(aa!==null);if((gn&6)!==0)throw Error(r(327));k=c.finishedWork;var F=c.finishedLanes;if(k===null)return null;if(c.finishedWork=null,c.finishedLanes=0,k===c.current)throw Error(r(177));c.callbackNode=null,c.callbackPriority=0;var K=k.lanes|k.childLanes;if(ft(c,K),c===fr&&(ar=fr=null,jr=0),(k.subtreeFlags&2064)===0&&(k.flags&2064)===0||cu||(cu=!0,Ip(ti,function(){return Ka(),null})),K=(k.flags&15990)!==0,(k.subtreeFlags&15990)!==0||K){K=qs.transition,qs.transition=null;var ue=Pe;Pe=1;var _e=gn;gn|=4,iu.current=null,Lg(c,k),ih(k,c),fg(ad),vo=!!od,ad=od=null,c.current=k,kp(k),$a(),gn=_e,Pe=ue,qs.transition=K}else c.current=k;if(cu&&(cu=!1,aa=c,uu=F),K=c.pendingLanes,K===0&&(To=null),Bt(k.stateNode),bs(c,kn()),p!==null)for(R=c.onRecoverableError,k=0;k<p.length;k++)F=p[k],R(F.value,{componentStack:F.stack,digest:F.digest});if(lu)throw lu=!1,c=uh,uh=null,c;return(uu&1)!==0&&c.tag!==0&&Ka(),K=c.pendingLanes,(K&1)!==0?c===dh?Wl++:(Wl=0,dh=c):Wl=0,ko(),null}function Ka(){if(aa!==null){var c=Qe(uu),p=qs.transition,k=Pe;try{if(qs.transition=null,Pe=16>c?16:c,aa===null)var R=!1;else{if(c=aa,aa=null,uu=0,(gn&6)!==0)throw Error(r(331));var F=gn;for(gn|=4,It=c.current;It!==null;){var K=It,ue=K.child;if((It.flags&16)!==0){var _e=K.deletions;if(_e!==null){for(var $e=0;$e<_e.length;$e++){var qe=_e[$e];for(It=qe;It!==null;){var at=It;switch(at.tag){case 0:case 11:case 15:Fl(8,at,K)}var ct=at.child;if(ct!==null)ct.return=at,It=ct;else for(;It!==null;){at=It;var ot=at.sibling,jt=at.return;if(bp(at),at===qe){It=null;break}if(ot!==null){ot.return=jt,It=ot;break}It=jt}}}var Pt=K.alternate;if(Pt!==null){var Dt=Pt.child;if(Dt!==null){Pt.child=null;do{var Pn=Dt.sibling;Dt.sibling=null,Dt=Pn}while(Dt!==null)}}It=K}}if((K.subtreeFlags&2064)!==0&&ue!==null)ue.return=K,It=ue;else e:for(;It!==null;){if(K=It,(K.flags&2048)!==0)switch(K.tag){case 0:case 11:case 15:Fl(9,K,K.return)}var Ue=K.sibling;if(Ue!==null){Ue.return=K.return,It=Ue;break e}It=K.return}}var Ie=c.current;for(It=Ie;It!==null;){ue=It;var Ve=ue.child;if((ue.subtreeFlags&2064)!==0&&Ve!==null)Ve.return=ue,It=Ve;else e:for(ue=Ie;It!==null;){if(_e=It,(_e.flags&2048)!==0)try{switch(_e.tag){case 0:case 11:case 15:th(9,_e)}}catch(Ft){Jn(_e,_e.return,Ft)}if(_e===ue){It=null;break e}var ht=_e.sibling;if(ht!==null){ht.return=_e.return,It=ht;break e}It=_e.return}}if(gn=F,ko(),gr&&typeof gr.onPostCommitFiberRoot=="function")try{gr.onPostCommitFiberRoot(cs,c)}catch{}R=!0}return R}finally{Pe=k,qs.transition=p}}return!1}function Rp(c,p,k){p=Wa(k,p),p=op(c,p,1),c=Co(c,p,1),p=es(),c!==null&&(qr(c,1,p),bs(c,p))}function Jn(c,p,k){if(c.tag===3)Rp(c,c,k);else for(;p!==null;){if(p.tag===3){Rp(p,c,k);break}else if(p.tag===1){var R=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof R.componentDidCatch=="function"&&(To===null||!To.has(R))){c=Wa(k,c),c=ap(p,c,1),p=Co(p,c,1),c=es(),p!==null&&(qr(p,1,c),bs(p,c));break}}p=p.return}}function Hg(c,p,k){var R=c.pingCache;R!==null&&R.delete(p),p=es(),c.pingedLanes|=c.suspendedLanes&k,fr===c&&(jr&k)===k&&(br===4||br===3&&(jr&130023424)===jr&&500>kn()-ch?ca(c,0):lh|=k),bs(c,p)}function Wg(c,p){p===0&&((c.mode&1)===0?p=1:(p=Wr,Wr<<=1,(Wr&130023424)===0&&(Wr=4194304)));var k=es();c=Xi(c,p),c!==null&&(qr(c,p,k),bs(c,k))}function qg(c){var p=c.memoizedState,k=0;p!==null&&(k=p.retryLane),Wg(c,k)}function Vg(c,p){var k=0;switch(c.tag){case 13:var R=c.stateNode,F=c.memoizedState;F!==null&&(k=F.retryLane);break;case 19:R=c.stateNode;break;default:throw Error(r(314))}R!==null&&R.delete(p),Wg(c,k)}var Mp;Mp=function(c,p,k){if(c!==null)if(c.memoizedProps!==p.pendingProps||hs.current)ys=!0;else{if((c.lanes&k)===0&&(p.flags&128)===0)return ys=!1,fv(c,p,k);ys=(c.flags&131072)!==0}else ys=!1,Kn&&(p.flags&1048576)!==0&&Jo(p,Wc,p.index);switch(p.lanes=0,p.tag){case 2:var R=p.type;nu(c,p),c=p.pendingProps;var F=Qr(p,Jr.current);Fa(p,k),F=Dd(null,p,R,c,F,k);var K=Od();return p.flags|=1,typeof F=="object"&&F!==null&&typeof F.render=="function"&&F.$$typeof===void 0?(p.tag=1,p.memoizedState=null,p.updateQueue=null,fs(R)?(K=!0,Fc(p)):K=!1,p.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,Kc(p),F.updater=Ji,p.stateNode=F,F._reactInternals=p,Fd(p,R,c,k),p=qd(null,p,R,!0,K,k)):(p.tag=0,Kn&&K&&ur(p),Or(null,p,F,k),p=p.child),p;case 16:R=p.elementType;e:{switch(nu(c,p),c=p.pendingProps,F=R._init,R=F(R._payload),p.type=R,F=p.tag=Gg(R),c=hr(R,c),F){case 0:p=Wd(null,p,R,c,k);break e;case 1:p=fp(null,p,R,c,k);break e;case 11:p=cp(null,p,R,c,k);break e;case 14:p=zl(null,p,R,hr(R.type,c),k);break e}throw Error(r(306,R,""))}return p;case 0:return R=p.type,F=p.pendingProps,F=p.elementType===R?F:hr(R,F),Wd(c,p,R,F,k);case 1:return R=p.type,F=p.pendingProps,F=p.elementType===R?F:hr(R,F),fp(c,p,R,F,k);case 3:e:{if(Vd(p),c===null)throw Error(r(387));R=p.pendingProps,K=p.memoizedState,F=K.element,Ed(c,p),Xc(p,R,null,k);var ue=p.memoizedState;if(R=ue.element,K.isDehydrated)if(K={element:R,isDehydrated:!1,cache:ue.cache,pendingSuspenseBoundaries:ue.pendingSuspenseBoundaries,transitions:ue.transitions},p.updateQueue.baseState=K,p.memoizedState=K,p.flags&256){F=Wa(Error(r(423)),p),p=pp(c,p,R,k,F);break e}else if(R!==F){F=Wa(Error(r(424)),p),p=pp(c,p,R,k,F);break e}else for(Ns=wo(p.stateNode.containerInfo.firstChild),gs=p,Kn=!0,xs=null,k=_d(p,null,R,k),p.child=k;k;)k.flags=k.flags&-3|4096,k=k.sibling;else{if(Qo(),R===F){p=Qi(c,p,k);break e}Or(c,p,R,k)}p=p.child}return p;case 5:return Of(p),c===null&&yd(p),R=p.type,F=p.pendingProps,K=c!==null?c.memoizedProps:null,ue=F.children,ld(R,F)?ue=null:K!==null&&ld(R,K)&&(p.flags|=32),hp(c,p),Or(c,p,ue,k),p.child;case 6:return c===null&&yd(p),null;case 13:return mp(c,p,k);case 4:return Nd(p,p.stateNode.containerInfo),R=p.pendingProps,c===null?p.child=Ba(p,null,R,k):Or(c,p,R,k),p.child;case 11:return R=p.type,F=p.pendingProps,F=p.elementType===R?F:hr(R,F),cp(c,p,R,F,k);case 7:return Or(c,p,p.pendingProps,k),p.child;case 8:return Or(c,p,p.pendingProps.children,k),p.child;case 12:return Or(c,p,p.pendingProps.children,k),p.child;case 10:e:{if(R=p.type._context,F=p.pendingProps,K=p.memoizedProps,ue=F.value,In(Zo,R._currentValue),R._currentValue=ue,K!==null)if(ai(K.value,ue)){if(K.children===F.children&&!hs.current){p=Qi(c,p,k);break e}}else for(K=p.child,K!==null&&(K.return=p);K!==null;){var _e=K.dependencies;if(_e!==null){ue=K.child;for(var $e=_e.firstContext;$e!==null;){if($e.context===R){if(K.tag===1){$e=Yi(-1,k&-k),$e.tag=2;var qe=K.updateQueue;if(qe!==null){qe=qe.shared;var at=qe.pending;at===null?$e.next=$e:($e.next=at.next,at.next=$e),qe.pending=$e}}K.lanes|=k,$e=K.alternate,$e!==null&&($e.lanes|=k),Df(K.return,k,p),_e.lanes|=k;break}$e=$e.next}}else if(K.tag===10)ue=K.type===p.type?null:K.child;else if(K.tag===18){if(ue=K.return,ue===null)throw Error(r(341));ue.lanes|=k,_e=ue.alternate,_e!==null&&(_e.lanes|=k),Df(ue,k,p),ue=K.sibling}else ue=K.child;if(ue!==null)ue.return=K;else for(ue=K;ue!==null;){if(ue===p){ue=null;break}if(K=ue.sibling,K!==null){K.return=ue.return,ue=K;break}ue=ue.return}K=ue}Or(c,p,F.children,k),p=p.child}return p;case 9:return F=p.type,R=p.pendingProps.children,Fa(p,k),F=Us(F),R=R(F),p.flags|=1,Or(c,p,R,k),p.child;case 14:return R=p.type,F=hr(R,p.pendingProps),F=hr(R.type,F),zl(c,p,R,F,k);case 15:return up(c,p,p.type,p.pendingProps,k);case 17:return R=p.type,F=p.pendingProps,F=p.elementType===R?F:hr(R,F),nu(c,p),p.tag=1,fs(R)?(c=!0,Fc(p)):c=!1,Fa(p,k),sp(p,R,F),Fd(p,R,F,k),qd(null,p,R,!0,c,k);case 19:return Yd(c,p,k);case 22:return dp(c,p,k)}throw Error(r(156,p.tag))};function Ip(c,p){return qo(c,p)}function mv(c,p,k,R){this.tag=c,this.key=k,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=R,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function $s(c,p,k,R){return new mv(c,p,k,R)}function xh(c){return c=c.prototype,!(!c||!c.isReactComponent)}function Gg(c){if(typeof c=="function")return xh(c)?1:0;if(c!=null){if(c=c.$$typeof,c===Y)return 11;if(c===te)return 14}return 2}function Ro(c,p){var k=c.alternate;return k===null?(k=$s(c.tag,p,c.key,c.mode),k.elementType=c.elementType,k.type=c.type,k.stateNode=c.stateNode,k.alternate=c,c.alternate=k):(k.pendingProps=p,k.type=c.type,k.flags=0,k.subtreeFlags=0,k.deletions=null),k.flags=c.flags&14680064,k.childLanes=c.childLanes,k.lanes=c.lanes,k.child=c.child,k.memoizedProps=c.memoizedProps,k.memoizedState=c.memoizedState,k.updateQueue=c.updateQueue,p=c.dependencies,k.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},k.sibling=c.sibling,k.index=c.index,k.ref=c.ref,k}function fu(c,p,k,R,F,K){var ue=2;if(R=c,typeof c=="function")xh(c)&&(ue=1);else if(typeof c=="string")ue=5;else e:switch(c){case O:return Xa(k.children,F,K,p);case I:ue=8,F|=8;break;case z:return c=$s(12,k,p,F|2),c.elementType=z,c.lanes=K,c;case V:return c=$s(13,k,p,F),c.elementType=V,c.lanes=K,c;case H:return c=$s(19,k,p,F),c.elementType=H,c.lanes=K,c;case pe:return pu(k,F,K,p);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case U:ue=10;break e;case W:ue=9;break e;case Y:ue=11;break e;case te:ue=14;break e;case oe:ue=16,R=null;break e}throw Error(r(130,c==null?c:typeof c,""))}return p=$s(ue,k,p,F),p.elementType=c,p.type=R,p.lanes=K,p}function Xa(c,p,k,R){return c=$s(7,c,R,p),c.lanes=k,c}function pu(c,p,k,R){return c=$s(22,c,R,p),c.elementType=pe,c.lanes=k,c.stateNode={isHidden:!1},c}function yh(c,p,k){return c=$s(6,c,null,p),c.lanes=k,c}function vh(c,p,k){return p=$s(4,c.children!==null?c.children:[],c.key,p),p.lanes=k,p.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},p}function gv(c,p,k,R,F){this.tag=p,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ke(0),this.expirationTimes=Ke(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ke(0),this.identifierPrefix=R,this.onRecoverableError=F,this.mutableSourceEagerHydrationData=null}function bh(c,p,k,R,F,K,ue,_e,$e){return c=new gv(c,p,k,_e,$e),p===1?(p=1,K===!0&&(p|=8)):p=0,K=$s(3,null,null,p),c.current=K,K.stateNode=c,K.memoizedState={element:R,isDehydrated:k,cache:null,transitions:null,pendingSuspenseBoundaries:null},Kc(K),c}function xv(c,p,k){var R=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:R==null?null:""+R,children:c,containerInfo:p,implementation:k}}function Pp(c){if(!c)return _o;c=c._reactInternals;e:{if(Ct(c)!==c||c.tag!==1)throw Error(r(170));var p=c;do{switch(p.tag){case 3:p=p.stateNode.context;break e;case 1:if(fs(p.type)){p=p.stateNode.__reactInternalMemoizedMergedChildContext;break e}}p=p.return}while(p!==null);throw Error(r(171))}if(c.tag===1){var k=c.type;if(fs(k))return Af(c,k,p)}return p}function Kg(c,p,k,R,F,K,ue,_e,$e){return c=bh(k,R,!0,c,F,K,ue,_e,$e),c.context=Pp(null),k=c.current,R=es(),F=$o(k),K=Yi(R,F),K.callback=p??null,Co(k,K,F),c.current.lanes=F,qr(c,F,R),bs(c,R),c}function mu(c,p,k,R){var F=p.current,K=es(),ue=$o(F);return k=Pp(k),p.context===null?p.context=k:p.pendingContext=k,p=Yi(K,ue),p.payload={element:c},R=R===void 0?null:R,R!==null&&(p.callback=R),c=Co(F,p,ue),c!==null&&(hi(c,F,ue,K),Pl(c,F,ue)),ue}function gu(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 5:return c.child.stateNode;default:return c.child.stateNode}}function Dp(c,p){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var k=c.retryLane;c.retryLane=k!==0&&k<p?k:p}}function wh(c,p){Dp(c,p),(c=c.alternate)&&Dp(c,p)}function Xg(){return null}var Yg=typeof reportError=="function"?reportError:function(c){console.error(c)};function _h(c){this._internalRoot=c}Ya.prototype.render=_h.prototype.render=function(c){var p=this._internalRoot;if(p===null)throw Error(r(409));mu(c,p,null,null)},Ya.prototype.unmount=_h.prototype.unmount=function(){var c=this._internalRoot;if(c!==null){this._internalRoot=null;var p=c.containerInfo;la(function(){mu(null,c,null,null)}),p[Ai]=null}};function Ya(c){this._internalRoot=c}Ya.prototype.unstable_scheduleHydration=function(c){if(c){var p=Tn();c={blockedOn:null,target:c,priority:p};for(var k=0;k<ni.length&&p!==0&&p<ni[k].priority;k++);ni.splice(k,0,c),k===0&&yl(c)}};function kh(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)}function xu(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11&&(c.nodeType!==8||c.nodeValue!==" react-mount-point-unstable "))}function Jg(){}function Qg(c,p,k,R,F){if(F){if(typeof R=="function"){var K=R;R=function(){var qe=gu(ue);K.call(qe)}}var ue=Kg(p,R,c,0,null,!1,!1,"",Jg);return c._reactRootContainer=ue,c[Ai]=ue.current,$l(c.nodeType===8?c.parentNode:c),la(),ue}for(;F=c.lastChild;)c.removeChild(F);if(typeof R=="function"){var _e=R;R=function(){var qe=gu($e);_e.call(qe)}}var $e=bh(c,0,!1,null,null,!1,!1,"",Jg);return c._reactRootContainer=$e,c[Ai]=$e.current,$l(c.nodeType===8?c.parentNode:c),la(function(){mu(p,$e,k,R)}),$e}function Gl(c,p,k,R,F){var K=k._reactRootContainer;if(K){var ue=K;if(typeof F=="function"){var _e=F;F=function(){var $e=gu(ue);_e.call($e)}}mu(p,ue,c,F)}else ue=Qg(k,p,c,F,R);return gu(ue)}Et=function(c){switch(c.tag){case 3:var p=c.stateNode;if(p.current.memoizedState.isDehydrated){var k=Ps(p.pendingLanes);k!==0&&(be(p,k|1),bs(p,kn()),(gn&6)===0&&(Ga=kn()+500,ko()))}break;case 13:la(function(){var R=Xi(c,1);if(R!==null){var F=es();hi(R,c,1,F)}}),wh(c,1)}},en=function(c){if(c.tag===13){var p=Xi(c,134217728);if(p!==null){var k=es();hi(p,c,134217728,k)}wh(c,134217728)}},ln=function(c){if(c.tag===13){var p=$o(c),k=Xi(c,p);if(k!==null){var R=es();hi(k,c,p,R)}wh(c,p)}},Tn=function(){return Pe},En=function(c,p){var k=Pe;try{return Pe=c,p()}finally{Pe=k}},vi=function(c,p,k){switch(p){case"input":if(st(c,k),p=k.name,k.type==="radio"&&p!=null){for(k=c;k.parentNode;)k=k.parentNode;for(k=k.querySelectorAll("input[name="+JSON.stringify(""+p)+'][type="radio"]'),p=0;p<k.length;p++){var R=k[p];if(R!==c&&R.form===c.form){var F=zc(R);if(!F)throw Error(r(90));lt(R),st(R,F)}}}break;case"textarea":On(c,k);break;case"select":p=k.value,p!=null&&yt(c,!!k.multiple,p,!1)}},Is=ph,Ar=la;var Op={usingClientEntryPoint:!1,Events:[Ml,Pa,zc,bi,wi,ph]},fi={findFiberByHostInstance:Xo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Zg={bundleType:fi.bundleType,version:fi.version,rendererPackageName:fi.rendererPackageName,rendererConfig:fi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(c){return c=fo(c),c===null?null:c.stateNode},findFiberByHostInstance:fi.findFiberByHostInstance||Xg,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 Kl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Kl.isDisabled&&Kl.supportsFiber)try{cs=Kl.inject(Zg),gr=Kl}catch{}}return pi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Op,pi.createPortal=function(c,p){var k=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!kh(p))throw Error(r(200));return xv(c,p,null,k)},pi.createRoot=function(c,p){if(!kh(c))throw Error(r(299));var k=!1,R="",F=Yg;return p!=null&&(p.unstable_strictMode===!0&&(k=!0),p.identifierPrefix!==void 0&&(R=p.identifierPrefix),p.onRecoverableError!==void 0&&(F=p.onRecoverableError)),p=bh(c,1,!1,null,null,k,!1,R,F),c[Ai]=p.current,$l(c.nodeType===8?c.parentNode:c),new _h(p)},pi.findDOMNode=function(c){if(c==null)return null;if(c.nodeType===1)return c;var p=c._reactInternals;if(p===void 0)throw typeof c.render=="function"?Error(r(188)):(c=Object.keys(c).join(","),Error(r(268,c)));return c=fo(p),c=c===null?null:c.stateNode,c},pi.flushSync=function(c){return la(c)},pi.hydrate=function(c,p,k){if(!xu(p))throw Error(r(200));return Gl(null,c,p,!0,k)},pi.hydrateRoot=function(c,p,k){if(!kh(c))throw Error(r(405));var R=k!=null&&k.hydratedSources||null,F=!1,K="",ue=Yg;if(k!=null&&(k.unstable_strictMode===!0&&(F=!0),k.identifierPrefix!==void 0&&(K=k.identifierPrefix),k.onRecoverableError!==void 0&&(ue=k.onRecoverableError)),p=Kg(p,null,c,1,k??null,F,!1,K,ue),c[Ai]=p.current,$l(c),R)for(c=0;c<R.length;c++)k=R[c],F=k._getVersion,F=F(k._source),p.mutableSourceEagerHydrationData==null?p.mutableSourceEagerHydrationData=[k,F]:p.mutableSourceEagerHydrationData.push(k,F);return new Ya(p)},pi.render=function(c,p,k){if(!xu(p))throw Error(r(200));return Gl(null,c,p,!1,k)},pi.unmountComponentAtNode=function(c){if(!xu(c))throw Error(r(40));return c._reactRootContainer?(la(function(){Gl(null,null,c,!1,function(){c._reactRootContainer=null,c[Ai]=null})}),!0):!1},pi.unstable_batchedUpdates=ph,pi.unstable_renderSubtreeIntoContainer=function(c,p,k,R){if(!xu(k))throw Error(r(200));if(c==null||c._reactInternals===void 0)throw Error(r(38));return Gl(c,p,k,!1,R)},pi.version="18.3.1-next-f1338f8080-20240426",pi}var V0;function h2(){if(V0)return _v.exports;V0=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(n){console.error(n)}}return e(),_v.exports=uN(),_v.exports}var G0;function dN(){if(G0)return tx;G0=1;var e=h2();return tx.createRoot=e.createRoot,tx.hydrateRoot=e.hydrateRoot,tx}var hN=dN();const fN=qy(hN);var L=Bw();const lo=qy(L),K0=e=>{let n;const r=new Set,i=(m,x)=>{const g=typeof m=="function"?m(n):m;if(!Object.is(g,n)){const b=n;n=x??(typeof g!="object"||g===null)?g:Object.assign({},n,g),r.forEach(S=>S(n,b))}},o=()=>n,u={setState:i,getState:o,getInitialState:()=>d,subscribe:m=>(r.add(m),()=>r.delete(m))},d=n=e(i,o,u);return u},pN=(e=>e?K0(e):K0),mN=e=>e;function gN(e,n=mN){const r=lo.useSyncExternalStore(e.subscribe,lo.useCallback(()=>n(e.getState()),[e,n]),lo.useCallback(()=>n(e.getInitialState()),[e,n]));return lo.useDebugValue(r),r}const X0=e=>{const n=pN(e),r=i=>gN(n,i);return Object.assign(r,n),r},cr=(e=>e?X0(e):X0);function Fo(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const Cv=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${Fo(e)}`,Y0=({sessionId:e})=>`claude --session-id ${Fo(e)}`,xN=()=>"claude --resume",f2=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:Cv},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:Y0},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:Cv},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:Cv},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:Y0},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:xN},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let eo=null;async function yN(){if(eo)return eo;try{const e=await window.api.app.engageRulesPath();if(!e)return eo=[],eo;const n=await window.api.config.readJson(e);if(!n.exists||n.parseError||!n.data)return eo=[],eo;const r=n.data;if(!r.presets||!Array.isArray(r.presets))return eo=[],eo;const i=r.projectPath;return eo=r.presets.map(o=>({id:o.id,label:o.label,description:o.description,category:"engage",cwd:i,platform:o.platform,pipeline:o.pipeline,rules:o.rules,command:()=>`cd ${Fo(i)} && ${o.cliEntry}`})),eo}catch(e){return console.warn("[presets] Failed to load engage presets:",e),eo=[],eo}}async function p2(e){const n=f2.find(i=>i.id===e);return n||((await yN()).find(i=>i.id===e)??null)}async function J0(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 m2(e,n){return e.command?e.command(n):null}const Fw=["opus","sonnet","haiku"],g2="sm.rawSessionModel",vN="opus";function bN(e){return Fw.includes(e)}function wN(){try{const e=localStorage.getItem(g2);if(e&&bN(e))return e}catch{}return vN}let Lh=wN();const Rb=new Set;function x2(){return Lh}function _N(e){if(e!==Lh){Lh=e;try{localStorage.setItem(g2,e)}catch{}Rb.forEach(n=>n(e))}}function kN(){const[e,n]=L.useState(Lh);L.useEffect(()=>{const i=o=>n(o);return Rb.add(i),Lh!==e&&n(Lh),()=>{Rb.delete(i)}},[]);const r=L.useCallback(i=>_N(i),[]);return{model:e,setModel:r}}async function y2(e,n){const r=await window.api.transcripts.pathFor(e,n);return window.api.config.exists(r)}function SN(e){const n=e.split("/").filter(Boolean);return n[n.length-1]||e}async function v2(e,n=!1,r=x2()){let i=!n;i&&(i=await y2(e.cwd,e.claudeSessionId));const o=n&&!i?crypto.randomUUID():e.claudeSessionId,l=i?`claude --dangerously-skip-permissions --resume ${Fo(o)} --model ${r}`:`claude --dangerously-skip-permissions --session-id ${Fo(o)} --model ${r}`;return{claudeSessionId:o,startupCommand:l}}const kt=cr((e,n)=>({tabs:[],activeTabId:null,hydrated:!1,addTab:({id:r,cwd:i,startupCommand:o,presetId:l=null,label:h})=>{const u=r??crypto.randomUUID();if(n().tabs.find(x=>x.id===u))return e({activeTabId:u}),u;const m={id:u,claudeSessionId:u,chatSessionId:crypto.randomUUID(),label:h??SN(i),cwd:i,pid:null,status:"spawning",exitCode:null,startupCommand:o,presetId:l,generation:0};return e({tabs:[...n().tabs,m],activeTabId:u}),u},setTabRunning:(r,i)=>e({tabs:n().tabs.map(o=>o.id===r?{...o,pid:i,status:"running"}:o)}),setTabExited:(r,i)=>e({tabs:n().tabs.map(o=>o.id===r?{...o,status:"exited",exitCode:i}:o)}),closeTab:r=>{var l;window.api.pty.kill(r),window.api.watchers.killTab(r).catch(()=>{}),window.api.transcripts.closeTab(r).catch(()=>{});const i=n().tabs.filter(h=>h.id!==r),o=n().activeTabId===r?((l=i[i.length-1])==null?void 0:l.id)??null:n().activeTabId;e({tabs:i,activeTabId:o})},setActive:r=>e({activeTabId:r}),restartTab:r=>{const i=n().tabs.find(h=>h.id===r);if(!i)return;window.api.pty.kill(r);const o=crypto.randomUUID(),l=h=>{e({tabs:n().tabs.map(u=>u.id===r?{...u,claudeSessionId:o,pid:null,status:"spawning",exitCode:null,startupCommand:h,generation:u.generation+1}:u)})};i.presetId?p2(i.presetId).then(h=>{l(h?m2(h,{sessionId:o,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${Fo(o)}`)}):l(`claude --dangerously-skip-permissions --session-id ${Fo(o)}`)},reorderTab:(r,i)=>{const o=[...n().tabs];if(r<0||r>=o.length||i<0||i>=o.length||r===i)return;const[l]=o.splice(r,1);o.splice(i,0,l),e({tabs:o})},restoreTabs:(r,i)=>e({tabs:r,activeTabId:i,hydrated:!0}),wakeTab:async(r,i)=>{const o=n().tabs.find(u=>u.id===r);if(!o||o.status!=="dormant")return;const{claudeSessionId:l,startupCommand:h}=await v2({cwd:o.cwd,claudeSessionId:o.claudeSessionId},!1,i??x2());e({tabs:n().tabs.map(u=>u.id===r?{...u,claudeSessionId:l,status:"spawning",startupCommand:h,generation:u.generation+1}:u)})},sleepTab:r=>{const i=n().tabs.find(o=>o.id===r);!i||i.status==="dormant"||(window.api.pty.kill(r),e({tabs:n().tabs.map(o=>o.id===r?{...o,pid:null,status:"dormant"}:o)}))},newChatThread:r=>{n().tabs.find(o=>o.id===r)&&e({tabs:n().tabs.map(o=>o.id===r?{...o,chatSessionId:crypto.randomUUID()}:o)})}}));async function Mb(){var r;if(kt.getState().hydrated)return;try{const{tabs:i,activeTabId:o,freshStart:l}=await window.api.sessions.load();if(i.length>0){const h=await Promise.all(i.map(async d=>{const{claudeSessionId:m}=await v2(d,l);return{id:d.id,claudeSessionId:m,chatSessionId:d.chatSessionId??crypto.randomUUID(),cwd:d.cwd,label:d.label,presetId:d.presetId,pid:null,status:"dormant",exitCode:null,startupCommand:null,generation:0}})),u=o&&h.find(d=>d.id===o)?o:((r=h[0])==null?void 0:r.id)??null;kt.getState().restoreTabs(h,u)}else kt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),kt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:o}=kt.getState(),l=i.map(h=>({id:h.id,claudeSessionId:h.claudeSessionId,chatSessionId:h.chatSessionId,cwd:h.cwd,label:h.label,presetId:h.presetId}));window.api.sessions.save({tabs:l,activeTabId:o}).catch(h=>{console.warn("[sessions] save failed:",h)})};let n=null;kt.subscribe((i,o)=>{i.hydrated&&(i.tabs===o.tabs&&i.activeTabId===o.activeTabId||(n!==null&&window.clearTimeout(n),n=window.setTimeout(e,200)))}),e()}const CN=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:Mb,useSessions:kt},Symbol.toStringTag,{value:"Module"})),jN=5,Q0=100,EN=5e3,Ib=new Map;function Z0(e){const n=Ib.get(e);n!==void 0&&(clearTimeout(n),Ib.delete(e))}function NN(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const Eu=cr((e,n)=>({toasts:[],history:[],unreadCount:0,show:(r,i)=>{const o=NN(),l=Date.now();e(u=>{const d=[...u.toasts,{id:o,kind:r,message:i,createdAt:l}];for(;d.length>jN;){const g=d.shift();g&&Z0(g.id)}const x=[{id:o,kind:r,message:i,createdAt:l,read:!1},...u.history];return x.length>Q0&&(x.length=Q0),{toasts:d,history:x,unreadCount:u.unreadCount+1}});const h=setTimeout(()=>n().dismiss(o),EN);return Ib.set(o,h),o},dismiss:r=>{Z0(r),e(i=>({toasts:i.toasts.filter(o=>o.id!==r)}))},markAllRead:()=>{e(r=>r.unreadCount===0?r:{history:r.history.map(i=>i.read?i:{...i,read:!0}),unreadCount:0})},clearHistory:()=>{e({history:[],unreadCount:0})},dismissHistoryEntry:r=>{e(i=>{const o=i.history.filter(h=>h.id!==r);if(o.length===i.history.length)return i;const l=i.history.find(h=>h.id===r&&!h.read);return{history:o,unreadCount:l?Math.max(0,i.unreadCount-1):i.unreadCount}})}})),ze={info:e=>Eu.getState().show("info",e),warn:e=>Eu.getState().show("warn",e),error:e=>Eu.getState().show("error",e),fromOutcome:e=>Eu.getState().show(e.kind??(e.ok?"info":"warn"),e.message)},b2=Object.freeze(Object.defineProperty({__proto__:null,toast:ze,useToast:Eu},Symbol.toStringTag,{value:"Module"})),e_=200,TN=/\x1b\[[0-9;]*m/g;function $N(e){return e.replace(TN,"")}const jm=cr((e,n)=>({watchers:{},initialized:!1,init:()=>{n().initialized||(e({initialized:!0}),window.api.watchers.onLine(r=>n().ingestLine(r)),window.api.watchers.onClosed(({watcherId:r})=>n().closed(r)))},add:async({tabId:r,label:i,command:o,cwd:l})=>{try{const h=await window.api.watchers.add({tabId:r,label:i,command:o,cwd:l??null}),u={watcherId:h.watcherId,tabId:h.tabId,label:h.label,command:h.command,cwd:h.cwd,pid:h.pid,startedAt:h.startedAt,lineCount:0,lines:[],lastLineAt:null};return e({watchers:{...n().watchers,[u.watcherId]:u}}),u}catch(h){return console.error("[watchers] add failed:",h),ze.error("Failed to add watcher"),null}},remove:async r=>{try{await window.api.watchers.remove(r)}catch(o){console.error("[watchers] remove failed:",o);const l=o instanceof Error?o.message:String(o);ze.error(`Could not remove watcher: ${l}`)}const i={...n().watchers};delete i[r],e({watchers:i})},watchersForTab:r=>Object.values(n().watchers).filter(i=>i.tabId===r),ingestLine:r=>{const i=n().watchers[r.watcherId];if(!i)return;const o=$N(r.line),l=i.lines.length>=e_?[...i.lines.slice(i.lines.length-e_+1),{line:o,ts:r.ts}]:[...i.lines,{line:o,ts:r.ts}];e({watchers:{...n().watchers,[r.watcherId]:{...i,lines:l,lineCount:i.lineCount+1,lastLineAt:r.ts}}})},closed:r=>{if(!n().watchers[r])return;const i={...n().watchers};delete i[r],e({watchers:i})}})),AN="~/.claude/session-manager/browser/history.json",t_="~/.claude/session-manager/browser/bookmarks.json",RN=.25,MN=3,n_=.1,r_=["#b85c34","#6f7d52","#e4b85a","#5f6f86","#8a5a6e","#4f7d72"];let s_=0;function IN(){const e=r_[s_%r_.length];return s_+=1,e}const dy=new Map;function PN(e){if(dy.has(e))return;const n=window.api.browser.onNavState(e,r=>{Mt.setState(i=>({tabs:i.tabs.map(o=>o.viewId===e?{...o,url:r.url,title:r.title||o.title,canGoBack:r.canGoBack,canGoForward:r.canGoForward,loading:r.loading,isSecure:r.isSecure}:o)}))});dy.set(e,n)}function DN(e){const n=dy.get(e);n&&(n(),dy.delete(e))}const Pb=new Map;let qx=null;function i_(e){const n=Pb.get(e);n&&(n(),Pb.delete(e))}function o_(){qx&&(clearInterval(qx),qx=null)}const Db=new Map;function jv(e){const n=Db.get(e);n&&(n(),Db.delete(e))}const Mt=cr((e,n)=>({tabs:[],activeTabId:null,openTab:r=>{const i=crypto.randomUUID(),o=i,l={id:i,viewId:o,title:"New Tab",url:(r==null?void 0:r.url)??"about:blank",color:(r==null?void 0:r.color)??IN(),canGoBack:!1,canGoForward:!1,loading:!1,isSecure:!1,zoomFactor:1};return e(h=>({tabs:[...h.tabs,l],activeTabId:i})),PN(o),window.api.browser.create({viewId:o,partition:"persist:browser"}).then(()=>{r!=null&&r.url&&window.api.browser.navigate({viewId:o,url:r.url}).catch(()=>{})}).catch(h=>{var d,m;const u=h instanceof Error?h.message:String(h);(m=(d=window.api)==null?void 0:d.logs)==null||m.write("browser","error",`browser:create failed for viewId ${o}: ${u}`)}),i},closeTab:r=>{const i=n().tabs.find(o=>o.id===r);i&&(DN(i.viewId),jv(i.viewId),window.api.browser.destroy(i.viewId).catch(()=>{}),e(o=>{const l=o.tabs.filter(u=>u.id!==r),h=o.activeTabId===r?l.length?l[l.length-1].id:null:o.activeTabId;return{tabs:l,activeTabId:h}}))},setActive:r=>{e({activeTabId:r})},navigate:(r,i)=>{const o=n().tabs.find(l=>l.id===r);o&&window.api.browser.navigate({viewId:o.viewId,url:i}).catch(()=>{})},back:r=>{const i=n().tabs.find(o=>o.id===r);i&&window.api.browser.back(i.viewId).catch(()=>{})},forward:r=>{const i=n().tabs.find(o=>o.id===r);i&&window.api.browser.forward(i.viewId).catch(()=>{})},reload:r=>{const i=n().tabs.find(o=>o.id===r);i&&window.api.browser.reload(i.viewId).catch(()=>{})},stop:r=>{const i=n().tabs.find(o=>o.id===r);i&&window.api.browser.stop(i.viewId).catch(()=>{})},mode:"browse",captureMode:"agent",setMode:r=>e(i=>({mode:r,captured:r==="capture"?i.captured:null})),setCaptureMode:r=>e({captureMode:r,captured:null}),onVerb:r=>{const{mode:i}=n();if(r==="shot"){e({mode:"capture",captureMode:"shot",captured:null});return}if(i===r){e({mode:"browse",captured:r==="capture"?null:n().captured});return}e({mode:r,captureMode:r==="capture"?"agent":n().captureMode,captured:r==="capture"?n().captured:null})},captured:null,capture:async r=>{const{activeTabId:i,tabs:o,captureMode:l}=n(),h=o.find(d=>d.id===i);if(!h)throw new Error("No active browser tab");if(l==="shot"){const d=await window.api.browser.captureShot(h.viewId);if(!d.ok)throw new Error(d.error);e({captured:{mode:l,url:d.url,title:d.title,dataUrl:d.dataUrl,at:Date.now()}});return}if(!r||!r.length)throw new Error("No element selected");const u=await window.api.browser.capture({viewId:h.viewId,selectors:r,mode:l});if(!u.ok)throw new Error(u.error);e({captured:{mode:l,url:h.url,title:h.title,text:u.text,meta:u.meta,selectors:r,at:Date.now()}})},recorderActive:!1,recording:!1,recorderElapsedSec:0,recorderSteps:[],startRecording:r=>{if(n().recorderActive)return;e({recorderActive:!0,recording:!0,recorderElapsedSec:0,recorderSteps:[]}),window.api.browser.recordStart(r).catch(()=>{}),i_(r);const i=window.api.browser.onRecordStep(r,o=>{Mt.getState().recording&&Mt.setState(l=>({recorderSteps:[...l.recorderSteps,o]}))});Pb.set(r,i),o_(),qx=setInterval(()=>{Mt.getState().recording&&Mt.setState(o=>({recorderElapsedSec:o.recorderElapsedSec+1}))},1e3)},stopRecording:r=>{n().recorderActive&&(window.api.browser.recordStop(r).catch(()=>{}),i_(r),o_(),e({recorderActive:!1,recording:!1}))},toggleRecordingPause:()=>{n().recorderActive&&e(r=>({recording:!r.recording}))},toggleStepVariable:r=>{e(i=>({recorderSteps:i.recorderSteps.map(o=>o.n===r?{...o,variable:o.variable?null:o.variableSuggestion||"value"}:o)}))},bookmarks:[],bookmarksHydrated:!1,hydrateBookmarks:async()=>{if(!n().bookmarksHydrated)try{const r=await window.api.config.readJson(t_),i=r.exists&&Array.isArray(r.data)?r.data:[];e({bookmarks:i,bookmarksHydrated:!0})}catch{e({bookmarksHydrated:!0})}},toggleBookmark:r=>{const i=n().tabs.find(u=>u.id===r);if(!i||!i.url||i.url==="about:blank")return;const o=n().bookmarks,h=o.some(u=>u.url===i.url)?o.filter(u=>u.url!==i.url):[{url:i.url,title:i.title,ts:Date.now()},...o];e({bookmarks:h}),window.api.config.writeJson(t_,h).catch(()=>{})},historyEntries:[],refreshHistory:async()=>{try{const r=await window.api.config.readJson(AN),i=r.exists&&Array.isArray(r.data)?r.data:[];e({historyEntries:i})}catch{}},setZoom:(r,i)=>{const o=n().tabs.find(h=>h.id===r);if(!o)return;const l=Math.min(MN,Math.max(RN,i));e(h=>({tabs:h.tabs.map(u=>u.id===r?{...u,zoomFactor:l}:u)})),window.api.browser.setZoom({viewId:o.viewId,factor:l}).catch(()=>{})},zoomIn:r=>{const i=n().tabs.find(o=>o.id===r);i&&n().setZoom(r,i.zoomFactor+n_)},zoomOut:r=>{const i=n().tabs.find(o=>o.id===r);i&&n().setZoom(r,i.zoomFactor-n_)},zoomReset:r=>n().setZoom(r,1),findOpen:!1,findText:"",findMatches:null,openFind:r=>{const i=n().tabs.find(l=>l.id===r);if(!i)return;e({findOpen:!0,findText:"",findMatches:null}),jv(i.viewId);const o=window.api.browser.onFindResult(i.viewId,l=>{Mt.setState({findMatches:l})});Db.set(i.viewId,o)},closeFind:r=>{const i=n().tabs.find(o=>o.id===r);e({findOpen:!1,findText:"",findMatches:null}),i&&(jv(i.viewId),window.api.browser.stopFind(i.viewId).catch(()=>{}))},setFindText:(r,i)=>{const o=n().tabs.find(l=>l.id===r);if(e({findText:i}),!!o){if(!i){window.api.browser.find({viewId:o.viewId,text:""}).catch(()=>{});return}window.api.browser.find({viewId:o.viewId,text:i,forward:!0}).catch(()=>{})}},findNext:r=>{const i=n().tabs.find(l=>l.id===r),{findText:o}=n();!i||!o||window.api.browser.find({viewId:i.viewId,text:o,forward:!0}).catch(()=>{})},findPrev:r=>{const i=n().tabs.find(l=>l.id===r),{findText:o}=n();!i||!o||window.api.browser.find({viewId:i.viewId,text:o,forward:!1}).catch(()=>{})}})),ON=4,a_=40,l_=6;function LN(e){const{onReorder:n,onActivate:r}=e,i=L.useRef(null),o=L.useRef(null),l=L.useRef(0),h=L.useRef(0),[u,d]=L.useState(!1),[,m]=L.useState(0),x=L.useRef(r);x.current=r;const g=L.useCallback(()=>i.current?Array.from(i.current.querySelectorAll("[data-drag-index]")):[],[]),b=L.useCallback((y,v,_)=>{for(let j=0;j<v.length;j++){const T=v[j].left+v[j].width/2;if(y<T)return j<=_?j:j-1}return v.length-1},[]),S=L.useCallback(()=>{const y=o.current,v=i.current;if(!(y!=null&&y.active)||!v)return;const _=v.getBoundingClientRect(),j=y.startX+y.deltaX,T=j-_.left,A=_.right-j;T<a_?v.scrollLeft-=l_:A<a_&&(v.scrollLeft+=l_),l.current=requestAnimationFrame(S)},[]);L.useEffect(()=>{const y=i.current;if(!y)return;let v=!1;const _=()=>{v||(v=!0,h.current=requestAnimationFrame(()=>{v=!1,m(A=>A+1)}))},j=A=>{var U;const M=o.current;if(!M)return;const O=A.clientX-M.startX;if(!M.active&&Math.abs(O)<ON)return;if(!M.active){M.active=!0,M.tabRects=g().map(W=>W.getBoundingClientRect()),d(!0);try{(U=i.current)==null||U.setPointerCapture(M.pointerId)}catch{}l.current=requestAnimationFrame(S)}M.deltaX=O;const I=M.tabRects[M.fromIndex],z=I.left+I.width/2+O;M.currentIndex=b(z,M.tabRects,M.fromIndex),_()},T=A=>{const M=o.current;if(M&&M.pointerId===A.pointerId){cancelAnimationFrame(l.current),cancelAnimationFrame(h.current);try{y.releasePointerCapture(M.pointerId)}catch{}M.active&&M.fromIndex!==M.currentIndex?n(M.fromIndex,M.currentIndex):x.current(M.fromIndex),o.current=null,d(!1),m(O=>O+1)}};return y.addEventListener("pointermove",j),y.addEventListener("pointerup",T),y.addEventListener("pointercancel",T),()=>{y.removeEventListener("pointermove",j),y.removeEventListener("pointerup",T),y.removeEventListener("pointercancel",T),cancelAnimationFrame(l.current),cancelAnimationFrame(h.current)}},[n,g,b,S]);const E=L.useCallback((y,v)=>{y.button!==0||y.target.closest("button")||(o.current={active:!1,fromIndex:v,currentIndex:v,startX:y.clientX,deltaX:0,tabRects:[],pointerId:y.pointerId})},[]);return{getTabDragProps:L.useCallback(y=>{var j;const v=o.current,_={};if(v!=null&&v.active)if(y===v.fromIndex)_.transform=`translateX(${v.deltaX}px) scale(1.03)`,_.zIndex=10,_.opacity=.85,_.boxShadow="0 2px 8px rgba(0,0,0,0.4)",_.position="relative",_.pointerEvents="none";else{const T=v.fromIndex,A=v.currentIndex,O=(((j=v.tabRects[T])==null?void 0:j.width)??0)+4;_.transition="transform 0.15s ease",T<A&&y>T&&y<=A?_.transform=`translateX(-${O}px)`:T>A&&y>=A&&y<T?_.transform=`translateX(${O}px)`:_.transform="translateX(0)"}return{onPointerDown:T=>E(T,y),style:_,"data-drag-index":y}},[E]),isDragging:u,containerRef:i}}const zN=3e4;function BN({onToggleSplitView:e,splitViewActive:n}={}){const r=kt(v=>v.tabs),i=kt(v=>v.activeTabId),o=kt(v=>v.closeTab),l=kt(v=>v.setActive),h=kt(v=>v.reorderTab),u=jm(v=>v.watchers),d=Mt(v=>v.tabs.length>0),m=i!=null&&d,[x,g]=L.useState(()=>Date.now());L.useEffect(()=>{const v=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(v)},[]);const b=v=>{for(const _ of Object.values(u))if(_.tabId===v&&_.lastLineAt&&x-_.lastLineAt<zN)return!0;return!1},{getTabDragProps:S,isDragging:E,containerRef:C}=LN({tabCount:r.length,onReorder:h,onActivate:v=>{const _=r[v];_&&l(_.id)}}),y=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return s.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:[s.jsx("div",{ref:C,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${E?"cursor-grabbing":""}`,children:r.map((v,_)=>{const j=v.id===i,T=S(_),A=y[_%y.length];return s.jsxs("div",{...T,style:T.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 ${E?"":"cursor-grab"} ${j?"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:v.cwd,"aria-current":j?"true":void 0,children:[s.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:A,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:v.status==="spawning"?.55:1}}),s.jsx("span",{className:"truncate max-w-[200px]",children:v.label}),v.status==="spawning"&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),b(v.id)&&s.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"}),s.jsx("button",{onClick:M=>{M.stopPropagation(),o(v.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${v.label}`,children:"×"})]},v.id)})}),s.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[m&&e&&s.jsxs("button",{onClick:e,className:`flex items-center gap-1 px-2 py-0.5 rounded text-[11px] border border-line hover:bg-bg-hi/40 ${n?"text-accent border-accent":"text-fg-faint hover:text-fg"}`,title:"Split view: agent terminal + browser","aria-pressed":n??!1,children:[s.jsx("span",{"aria-hidden":"true",children:"⇄"}),s.jsx("span",{children:"Split view"})]}),s.jsx("span",{className:"font-semibold text-fg-dim",children:"Claude Session Manager"}),s.jsxs("span",{className:"font-mono text-[11px] text-fg-faint",children:["v","0.37.0"]})]})]})}function FN(e,n,r){return n?e.map(i=>i.id===n?{...i,lastActivityAt:r}:i):e}function UN(e,n,r){return{tabId:e,sessionUuid:r,cwd:n,path:null,todos:[],lastToolUses:[],plans:[],agents:[],usage:{inputTokens:0,outputTokens:0},lastEventAt:0,activityRing:[],activitySeq:0}}const Vx=cr((e,n)=>({tabs:{},refs:{},unsubs:{},subscribe:(r,i,o)=>{const l={...n().refs};if(l[r]=(l[r]??0)+1,e({refs:l}),l[r]>1)return;e({tabs:{...n().tabs,[r]:UN(r,i,o)}});const h=window.api.transcripts.onEvent(r,u=>n().ingest(r,u));e({unsubs:{...n().unsubs,[r]:h}}),window.api.transcripts.subscribe({tabId:r,cwd:i,sessionUuid:o}).then(async u=>{const d=n().tabs[r];if(!d)return;if(!u.ok){const{toast:x}=await Gm(async()=>{const{toast:g}=await Promise.resolve().then(()=>b2);return{toast:g}},void 0,import.meta.url);x.error(`Live view unavailable: ${u.error??"subscribe failed"}`),e({tabs:{...n().tabs,[r]:{...d,path:null}}});return}e({tabs:{...n().tabs,[r]:{...d,path:u.path}}});const m=await window.api.transcripts.buffer(r);for(const x of m)n().ingest(r,x,{replay:!0})}).catch(u=>console.error("[live] transcripts.subscribe failed:",r,u))},unsubscribe:r=>{const i={...n().refs};if(!i[r])return;if(i[r]--,i[r]>0){e({refs:i});return}delete i[r];const o=n().unsubs[r];o==null||o();const l={...n().unsubs};delete l[r];const h={...n().tabs};delete h[r],window.api.transcripts.unsubscribe(r),e({refs:i,unsubs:l,tabs:h})},ingest:(r,i,o)=>{const l=n().tabs[r];if(!l)return;const h=Date.now(),u={...l,lastEventAt:o!=null&&o.replay?l.lastEventAt:h},d=[],m=(x,g)=>x.length>g?x.slice(0,g-1)+"…":x;switch(i.kind){case"todo_write":{const x=Array.isArray(i.data)?i.data:[];u.todos=x,o!=null&&o.replay||d.push({id:0,kind:"todo-update",at:h,label:`Todos · ${x.length} item${x.length!==1?"s":""}`});break}case"tool_use":{const x=i.data,g=x.input,b={};for(const S of["command","file_path","pattern","url","query","subagent_type","description"])g&&S in g&&(b[S]=g[S]);if(u.lastToolUses=[{id:x.id,name:x.name,input:b,at:h},...l.lastToolUses].slice(0,50),!(o!=null&&o.replay)){const S=x.input,E=["Edit","Write","NotebookEdit"].includes(x.name),C=typeof(S==null?void 0:S.file_path)=="string"?S.file_path:void 0,y=typeof(S==null?void 0:S.command)=="string"?S.command:void 0,v=C?C.split("/").pop()??C:y?m(y,28):"";d.push({id:0,kind:"tool-use",at:h,label:v?`${x.name} · ${v}`:x.name,target:C??y,toolName:x.name}),E&&C&&d.push({id:0,kind:"file-edit",at:h,label:`${x.name} · ${m(C.split("/").pop()??C,34)}`,target:C,toolName:x.name})}break}case"plan":{const x=i.data,g=typeof x=="string"?x:(x==null?void 0:x.plan)??JSON.stringify(x);u.plans=[{at:h,content:g??""},...l.plans].slice(0,50),o!=null&&o.replay||d.push({id:0,kind:"plan-revision",at:h,label:"Plan revised"});break}case"agent_spawn":{const x=i.data;u.agents=[{id:x==null?void 0:x.toolUseId,at:h,subagentType:x==null?void 0:x.subagent_type,description:x==null?void 0:x.description,lastActivityAt:h},...l.agents].slice(0,50),o!=null&&o.replay||d.push({id:0,kind:"agent-spawn",at:h,label:x!=null&&x.subagent_type?`Agent: ${m(x.subagent_type,32)}`:"Agent spawned"});break}case"usage":{const x=i.data,g=(l.usage.inputTokens||0)+(l.usage.outputTokens||0),b=x.input_tokens??x.inputTokens??0,S=x.output_tokens??x.outputTokens??0,E=g+b+S;u.usage={inputTokens:(l.usage.inputTokens||0)+b,outputTokens:(l.usage.outputTokens||0)+S,cacheCreationInputTokens:(l.usage.cacheCreationInputTokens||0)+(x.cache_creation_input_tokens??x.cacheCreationInputTokens??0),cacheReadInputTokens:(l.usage.cacheReadInputTokens||0)+(x.cache_read_input_tokens??x.cacheReadInputTokens??0)},!(o!=null&&o.replay)&&Math.floor(E/1e3)>Math.floor(g/1e3)&&d.push({id:0,kind:"usage-tick",at:h,label:`${Math.floor(E/1e3)}k tokens`});break}case"tool_result":{const x=i.data;u.agents=FN(l.agents,x==null?void 0:x.toolUseId,h);break}}if(d.length>0){let x=l.activitySeq;const g=d.map(b=>({...b,id:++x}));u.activitySeq=x,u.activityRing=[...l.activityRing,...g].slice(-32)}e({tabs:{...n().tabs,[r]:u}})}}));function w2(e){const n=Vx(o=>o.subscribe),r=Vx(o=>o.unsubscribe),i=Vx(o=>e?o.tabs[e.id]:void 0);return L.useEffect(()=>{if(e)return n(e.id,e.cwd,e.claudeSessionId),()=>r(e.id)},[e==null?void 0:e.id,e==null?void 0:e.cwd,e==null?void 0:e.claudeSessionId,n,r]),i}var Ev={},Bp={},c_;function _2(){if(c_)return Bp;c_=1,Object.defineProperty(Bp,"__esModule",{value:!0}),Bp.baseAssetPath=void 0;const n=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let r="/";return n&&(r=n.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^/]+$/,"/")),Bp.baseAssetPath=r,Bp}var Fp={},u_;function Uw(){if(u_)return Fp;u_=1,Object.defineProperty(Fp,"__esModule",{value:!0}),Fp.defaultModelFetcher=void 0;const e=n=>fetch(n).then(r=>r.arrayBuffer());return Fp.defaultModelFetcher=e,Fp}var Za={},Up={},d_;function Km(){if(d_)return Up;d_=1,Object.defineProperty(Up,"__esModule",{value:!0}),Up.log=void 0;const e=n=>r=>{console.log(`VAD | ${n} >`,r)};return Up.log={error:e("error"),debug:e("debug"),warn:e("warn")},Up}var Hp={},h_;function Vy(){if(h_)return Hp;h_=1,Object.defineProperty(Hp,"__esModule",{value:!0}),Hp.Message=void 0;var e;return(function(n){n.AudioFrame="AUDIO_FRAME",n.SpeechStart="SPEECH_START",n.VADMisfire="VAD_MISFIRE",n.SpeechEnd="SPEECH_END",n.SpeechStop="SPEECH_STOP",n.SpeechRealStart="SPEECH_REAL_START",n.FrameProcessed="FRAME_PROCESSED"})(e||(Hp.Message=e={})),Hp}var f_;function Hw(){if(f_)return Za;f_=1,Object.defineProperty(Za,"__esModule",{value:!0}),Za.FrameProcessor=Za.validateOptions=Za.defaultFrameProcessorOptions=void 0;const e=Km(),n=Vy();Za.defaultFrameProcessorOptions={positiveSpeechThreshold:.3,negativeSpeechThreshold:.25,preSpeechPadMs:800,redemptionMs:1400,minSpeechMs:400,submitUserSpeechOnPause:!1};function r(h){(h.positiveSpeechThreshold<0||h.positiveSpeechThreshold>1)&&e.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(h.negativeSpeechThreshold<0||h.negativeSpeechThreshold>h.positiveSpeechThreshold)&&e.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),h.preSpeechPadMs<0&&e.log.error("preSpeechPadMs should be positive"),h.redemptionMs<0&&e.log.error("redemptionMs should be positive"),h.minSpeechMs<0&&e.log.error("minSpeechMs should be positive")}Za.validateOptions=r;const i=h=>{const u=h.reduce((m,x)=>(m.push(m.at(-1)+x.length),m),[0]),d=new Float32Array(u.at(-1));return h.forEach((m,x)=>{const g=u[x];d.set(m,g)}),d};function o(h,u){const d=Math.floor(h.redemptionMs/u),m=Math.floor(h.preSpeechPadMs/u),x=Math.floor(h.minSpeechMs/u);return{redemptionFrames:d,preSpeechPadFrames:m,minSpeechFrames:x}}class l{constructor(u,d,m,x){this.modelProcessFunc=u,this.modelResetFunc=d,this.options=m,this.msPerFrame=x,this.speaking=!1,this.redemptionCounter=0,this.speechFrameCount=0,this.active=!1,this.speechRealStartFired=!1,this.setOptions=E=>{this.options={...this.options,...E};const{redemptionFrames:C,preSpeechPadFrames:y,minSpeechFrames:v}=o(this.options,this.msPerFrame);this.redemptionFrames=C,this.preSpeechPadFrames=y,this.minSpeechFrames=v},this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=E=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(E):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=E=>{const C=this.audioBuffer;this.audioBuffer=[];const y=this.speaking;if(this.reset(),y)if(C.reduce((_,j)=>j.isSpeech?_+1:_,0)>=this.minSpeechFrames){const _=i(C.map(j=>j.frame));E({msg:n.Message.SpeechEnd,audio:_})}else E({msg:n.Message.VADMisfire});return{}},this.process=async(E,C)=>{if(!this.active)return;const y=await this.modelProcessFunc(E),v=y.isSpeech>=this.options.positiveSpeechThreshold;if(C({probs:y,msg:n.Message.FrameProcessed,frame:E}),this.audioBuffer.push({frame:E,isSpeech:v}),v&&(this.speechFrameCount++,this.redemptionCounter=0),v&&!this.speaking&&(this.speaking=!0,C({msg:n.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,C({msg:n.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 _=this.audioBuffer;if(this.audioBuffer=[],_.reduce((T,A)=>A.isSpeech?T+1:T,0)>=this.minSpeechFrames){const T=i(_.map(A=>A.frame));C({msg:n.Message.SpeechEnd,audio:T})}else C({msg:n.Message.VADMisfire})}if(!this.speaking){for(;this.audioBuffer.length>this.preSpeechPadFrames;)this.audioBuffer.shift();this.speechFrameCount=0}},this.audioBuffer=[];const{redemptionFrames:g,preSpeechPadFrames:b,minSpeechFrames:S}=o(this.options,this.msPerFrame);this.redemptionFrames=g,this.preSpeechPadFrames=b,this.minSpeechFrames=S,this.reset()}}return Za.FrameProcessor=l,Za}var el={};function io(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 Nv={exports:{}};/*!
41
+ `+K.stack}return{value:c,source:p,stack:F,digest:null}}function Ud(c,p,k){return{value:c,source:null,stack:k??null,digest:p??null}}function Hd(c,p){try{console.error(p.value)}catch(k){setTimeout(function(){throw k})}}var Ag=typeof WeakMap=="function"?WeakMap:Map;function op(c,p,k){k=Yi(-1,k),k.tag=3,k.payload={element:null};var R=p.value;return k.callback=function(){lu||(lu=!0,uh=R),Hd(c,p)},k}function ap(c,p,k){k=Yi(-1,k),k.tag=3;var R=c.type.getDerivedStateFromError;if(typeof R=="function"){var F=p.value;k.payload=function(){return R(F)},k.callback=function(){Hd(c,p)}}var K=c.stateNode;return K!==null&&typeof K.componentDidCatch=="function"&&(k.callback=function(){Hd(c,p),typeof R!="function"&&(To===null?To=new Set([this]):To.add(this));var ue=p.stack;this.componentDidCatch(p.value,{componentStack:ue!==null?ue:""})}),k}function lp(c,p,k){var R=c.pingCache;if(R===null){R=c.pingCache=new Ag;var F=new Set;R.set(p,F)}else F=R.get(p),F===void 0&&(F=new Set,R.set(p,F));F.has(k)||(F.add(k),c=Hg.bind(null,c,p,k),p.then(c,c))}function Rg(c){do{var p;if((p=c.tag===13)&&(p=c.memoizedState,p=p!==null?p.dehydrated!==null:!0),p)return c;c=c.return}while(c!==null);return null}function Zr(c,p,k,R,F){return(c.mode&1)===0?(c===p?c.flags|=65536:(c.flags|=128,k.flags|=131072,k.flags&=-52805,k.tag===1&&(k.alternate===null?k.tag=17:(p=Yi(-1,1),p.tag=2,Co(k,p,1))),k.lanes|=1),c):(c.flags|=65536,c.lanes=F,c)}var Mg=T.ReactCurrentOwner,ys=!1;function Or(c,p,k,R){p.child=c===null?_d(p,null,k,R):Ba(p,c.child,k,R)}function cp(c,p,k,R,F){k=k.render;var K=p.ref;return Fa(p,F),R=Dd(c,p,k,R,K,F),k=Od(),c!==null&&!ys?(p.updateQueue=c.updateQueue,p.flags&=-2053,c.lanes&=~F,Qi(c,p,F)):(Kn&&k&&ur(p),p.flags|=1,Or(c,p,R,F),p.child)}function zl(c,p,k,R,F){if(c===null){var K=k.type;return typeof K=="function"&&!xh(K)&&K.defaultProps===void 0&&k.compare===null&&k.defaultProps===void 0?(p.tag=15,p.type=K,up(c,p,K,R,F)):(c=fu(k.type,null,R,p,p.mode,F),c.ref=p.ref,c.return=p,p.child=c)}if(K=c.child,(c.lanes&F)===0){var ue=K.memoizedProps;if(k=k.compare,k=k!==null?k:jl,k(ue,R)&&c.ref===p.ref)return Qi(c,p,F)}return p.flags|=1,c=Ro(K,R),c.ref=p.ref,c.return=p,p.child=c}function up(c,p,k,R,F){if(c!==null){var K=c.memoizedProps;if(jl(K,R)&&c.ref===p.ref)if(ys=!1,p.pendingProps=R=K,(c.lanes&F)!==0)(c.flags&131072)!==0&&(ys=!0);else return p.lanes=c.lanes,Qi(c,p,F)}return Wd(c,p,k,R,F)}function dp(c,p,k){var R=p.pendingProps,F=R.children,K=c!==null?c.memoizedState:null;if(R.mode==="hidden")if((p.mode&1)===0)p.memoizedState={baseLanes:0,cachePool:null,transitions:null},In(Va,Ts),Ts|=k;else{if((k&1073741824)===0)return c=K!==null?K.baseLanes|k:k,p.lanes=p.childLanes=1073741824,p.memoizedState={baseLanes:c,cachePool:null,transitions:null},p.updateQueue=null,In(Va,Ts),Ts|=c,null;p.memoizedState={baseLanes:0,cachePool:null,transitions:null},R=K!==null?K.baseLanes:k,In(Va,Ts),Ts|=R}else K!==null?(R=K.baseLanes|k,p.memoizedState=null):R=k,In(Va,Ts),Ts|=R;return Or(c,p,F,k),p.child}function hp(c,p){var k=p.ref;(c===null&&k!==null||c!==null&&c.ref!==k)&&(p.flags|=512,p.flags|=2097152)}function Wd(c,p,k,R,F){var K=fs(k)?Yo:Jr.current;return K=Qr(p,K),Fa(p,F),k=Dd(c,p,k,R,K,F),R=Od(),c!==null&&!ys?(p.updateQueue=c.updateQueue,p.flags&=-2053,c.lanes&=~F,Qi(c,p,F)):(Kn&&R&&ur(p),p.flags|=1,Or(c,p,k,F),p.child)}function fp(c,p,k,R,F){if(fs(k)){var K=!0;Fc(p)}else K=!1;if(Fa(p,F),p.stateNode===null)nu(c,p),sp(p,k,R),Fd(p,k,R,F),R=!0;else if(c===null){var ue=p.stateNode,_e=p.memoizedProps;ue.props=_e;var $e=ue.context,qe=k.contextType;typeof qe=="object"&&qe!==null?qe=Us(qe):(qe=fs(k)?Yo:Jr.current,qe=Qr(p,qe));var at=k.getDerivedStateFromProps,ct=typeof at=="function"||typeof ue.getSnapshotBeforeUpdate=="function";ct||typeof ue.UNSAFE_componentWillReceiveProps!="function"&&typeof ue.componentWillReceiveProps!="function"||(_e!==R||$e!==qe)&&ip(p,ue,R,qe),Ri=!1;var ot=p.memoizedState;ue.state=ot,Xc(p,R,ue,F),$e=p.memoizedState,_e!==R||ot!==$e||hs.current||Ri?(typeof at=="function"&&(Ii(p,k,at,R),$e=p.memoizedState),(_e=Ri||ia(p,k,_e,R,ot,$e,qe))?(ct||typeof ue.UNSAFE_componentWillMount!="function"&&typeof ue.componentWillMount!="function"||(typeof ue.componentWillMount=="function"&&ue.componentWillMount(),typeof ue.UNSAFE_componentWillMount=="function"&&ue.UNSAFE_componentWillMount()),typeof ue.componentDidMount=="function"&&(p.flags|=4194308)):(typeof ue.componentDidMount=="function"&&(p.flags|=4194308),p.memoizedProps=R,p.memoizedState=$e),ue.props=R,ue.state=$e,ue.context=qe,R=_e):(typeof ue.componentDidMount=="function"&&(p.flags|=4194308),R=!1)}else{ue=p.stateNode,Ed(c,p),_e=p.memoizedProps,qe=p.type===p.elementType?_e:hr(p.type,_e),ue.props=qe,ct=p.pendingProps,ot=ue.context,$e=k.contextType,typeof $e=="object"&&$e!==null?$e=Us($e):($e=fs(k)?Yo:Jr.current,$e=Qr(p,$e));var jt=k.getDerivedStateFromProps;(at=typeof jt=="function"||typeof ue.getSnapshotBeforeUpdate=="function")||typeof ue.UNSAFE_componentWillReceiveProps!="function"&&typeof ue.componentWillReceiveProps!="function"||(_e!==ct||ot!==$e)&&ip(p,ue,R,$e),Ri=!1,ot=p.memoizedState,ue.state=ot,Xc(p,R,ue,F);var Pt=p.memoizedState;_e!==ct||ot!==Pt||hs.current||Ri?(typeof jt=="function"&&(Ii(p,k,jt,R),Pt=p.memoizedState),(qe=Ri||ia(p,k,qe,R,ot,Pt,$e)||!1)?(at||typeof ue.UNSAFE_componentWillUpdate!="function"&&typeof ue.componentWillUpdate!="function"||(typeof ue.componentWillUpdate=="function"&&ue.componentWillUpdate(R,Pt,$e),typeof ue.UNSAFE_componentWillUpdate=="function"&&ue.UNSAFE_componentWillUpdate(R,Pt,$e)),typeof ue.componentDidUpdate=="function"&&(p.flags|=4),typeof ue.getSnapshotBeforeUpdate=="function"&&(p.flags|=1024)):(typeof ue.componentDidUpdate!="function"||_e===c.memoizedProps&&ot===c.memoizedState||(p.flags|=4),typeof ue.getSnapshotBeforeUpdate!="function"||_e===c.memoizedProps&&ot===c.memoizedState||(p.flags|=1024),p.memoizedProps=R,p.memoizedState=Pt),ue.props=R,ue.state=Pt,ue.context=$e,R=qe):(typeof ue.componentDidUpdate!="function"||_e===c.memoizedProps&&ot===c.memoizedState||(p.flags|=4),typeof ue.getSnapshotBeforeUpdate!="function"||_e===c.memoizedProps&&ot===c.memoizedState||(p.flags|=1024),R=!1)}return qd(c,p,k,R,K,F)}function qd(c,p,k,R,F,K){hp(c,p);var ue=(p.flags&128)!==0;if(!R&&!ue)return F&&Rf(p,k,!1),Qi(c,p,K);R=p.stateNode,Mg.current=p;var _e=ue&&typeof k.getDerivedStateFromError!="function"?null:R.render();return p.flags|=1,c!==null&&ue?(p.child=Ba(p,c.child,null,K),p.child=Ba(p,null,_e,K)):Or(c,p,_e,K),p.memoizedState=R.state,F&&Rf(p,k,!0),p.child}function Vd(c){var p=c.stateNode;p.pendingContext?$f(c,p.pendingContext,p.pendingContext!==p.context):p.context&&$f(c,p.context,!1),Nd(c,p.containerInfo)}function pp(c,p,k,R,F){return Qo(),bd(F),p.flags|=256,Or(c,p,k,R),p.child}var Gd={dehydrated:null,treeContext:null,retryLane:0};function Kd(c){return{baseLanes:c,cachePool:null,transitions:null}}function mp(c,p,k){var R=p.pendingProps,F=Yn.current,K=!1,ue=(p.flags&128)!==0,_e;if((_e=ue)||(_e=c!==null&&c.memoizedState===null?!1:(F&2)!==0),_e?(K=!0,p.flags&=-129):(c===null||c.memoizedState!==null)&&(F|=1),In(Yn,F&1),c===null)return yd(p),c=p.memoizedState,c!==null&&(c=c.dehydrated,c!==null)?((p.mode&1)===0?p.lanes=1:c.data==="$!"?p.lanes=8:p.lanes=1073741824,null):(ue=R.children,c=R.fallback,K?(R=p.mode,K=p.child,ue={mode:"hidden",children:ue},(R&1)===0&&K!==null?(K.childLanes=0,K.pendingProps=ue):K=pu(ue,R,0,null),c=Xa(c,R,k,null),K.return=p,c.return=p,K.sibling=c,p.child=K,p.child.memoizedState=Kd(k),p.memoizedState=Gd,c):Bl(p,ue));if(F=c.memoizedState,F!==null&&(_e=F.dehydrated,_e!==null))return Ig(c,p,ue,R,_e,F,k);if(K){K=R.fallback,ue=p.mode,F=c.child,_e=F.sibling;var $e={mode:"hidden",children:R.children};return(ue&1)===0&&p.child!==F?(R=p.child,R.childLanes=0,R.pendingProps=$e,p.deletions=null):(R=Ro(F,$e),R.subtreeFlags=F.subtreeFlags&14680064),_e!==null?K=Ro(_e,K):(K=Xa(K,ue,k,null),K.flags|=2),K.return=p,R.return=p,R.sibling=K,p.child=R,R=K,K=p.child,ue=c.child.memoizedState,ue=ue===null?Kd(k):{baseLanes:ue.baseLanes|k,cachePool:null,transitions:ue.transitions},K.memoizedState=ue,K.childLanes=c.childLanes&~k,p.memoizedState=Gd,R}return K=c.child,c=K.sibling,R=Ro(K,{mode:"visible",children:R.children}),(p.mode&1)===0&&(R.lanes=k),R.return=p,R.sibling=null,c!==null&&(k=p.deletions,k===null?(p.deletions=[c],p.flags|=16):k.push(c)),p.child=R,p.memoizedState=null,R}function Bl(c,p){return p=pu({mode:"visible",children:p},c.mode,0,null),p.return=c,c.child=p}function tu(c,p,k,R){return R!==null&&bd(R),Ba(p,c.child,null,k),c=Bl(p,p.pendingProps.children),c.flags|=2,p.memoizedState=null,c}function Ig(c,p,k,R,F,K,ue){if(k)return p.flags&256?(p.flags&=-257,R=Ud(Error(r(422))),tu(c,p,ue,R)):p.memoizedState!==null?(p.child=c.child,p.flags|=128,null):(K=R.fallback,F=p.mode,R=pu({mode:"visible",children:R.children},F,0,null),K=Xa(K,F,ue,null),K.flags|=2,R.return=p,K.return=p,R.sibling=K,p.child=R,(p.mode&1)!==0&&Ba(p,c.child,null,ue),p.child.memoizedState=Kd(ue),p.memoizedState=Gd,K);if((p.mode&1)===0)return tu(c,p,ue,null);if(F.data==="$!"){if(R=F.nextSibling&&F.nextSibling.dataset,R)var _e=R.dgst;return R=_e,K=Error(r(419)),R=Ud(K,R,void 0),tu(c,p,ue,R)}if(_e=(ue&c.childLanes)!==0,ys||_e){if(R=fr,R!==null){switch(ue&-ue){case 4:F=2;break;case 16:F=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:F=32;break;case 536870912:F=268435456;break;default:F=0}F=(F&(R.suspendedLanes|ue))!==0?0:F,F!==0&&F!==K.retryLane&&(K.retryLane=F,Xi(c,F),hi(R,c,F,-1))}return gh(),R=Ud(Error(r(421))),tu(c,p,ue,R)}return F.data==="$?"?(p.flags|=128,p.child=c.child,p=qg.bind(null,c),F._reactRetry=p,null):(c=K.treeContext,Ns=wo(F.nextSibling),gs=p,Kn=!0,xs=null,c!==null&&(Bs[li++]=ps,Bs[li++]=ms,Bs[li++]=Fs,ps=c.id,ms=c.overflow,Fs=p),p=Bl(p,R.children),p.flags|=4096,p)}function gp(c,p,k){c.lanes|=p;var R=c.alternate;R!==null&&(R.lanes|=p),Df(c.return,p,k)}function Xd(c,p,k,R,F){var K=c.memoizedState;K===null?c.memoizedState={isBackwards:p,rendering:null,renderingStartTime:0,last:R,tail:k,tailMode:F}:(K.isBackwards=p,K.rendering=null,K.renderingStartTime=0,K.last=R,K.tail=k,K.tailMode=F)}function Yd(c,p,k){var R=p.pendingProps,F=R.revealOrder,K=R.tail;if(Or(c,p,R.children,k),R=Yn.current,(R&2)!==0)R=R&1|2,p.flags|=128;else{if(c!==null&&(c.flags&128)!==0)e:for(c=p.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&gp(c,k,p);else if(c.tag===19)gp(c,k,p);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===p)break e;for(;c.sibling===null;){if(c.return===null||c.return===p)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}R&=1}if(In(Yn,R),(p.mode&1)===0)p.memoizedState=null;else switch(F){case"forwards":for(k=p.child,F=null;k!==null;)c=k.alternate,c!==null&&Yc(c)===null&&(F=k),k=k.sibling;k=F,k===null?(F=p.child,p.child=null):(F=k.sibling,k.sibling=null),Xd(p,!1,F,k,K);break;case"backwards":for(k=null,F=p.child,p.child=null;F!==null;){if(c=F.alternate,c!==null&&Yc(c)===null){p.child=F;break}c=F.sibling,F.sibling=k,k=F,F=c}Xd(p,!0,k,null,K);break;case"together":Xd(p,!1,null,null,void 0);break;default:p.memoizedState=null}return p.child}function nu(c,p){(p.mode&1)===0&&c!==null&&(c.alternate=null,p.alternate=null,p.flags|=2)}function Qi(c,p,k){if(c!==null&&(p.dependencies=c.dependencies),oa|=p.lanes,(k&p.childLanes)===0)return null;if(c!==null&&p.child!==c.child)throw Error(r(153));if(p.child!==null){for(c=p.child,k=Ro(c,c.pendingProps),p.child=k,k.return=p;c.sibling!==null;)c=c.sibling,k=k.sibling=Ro(c,c.pendingProps),k.return=p;k.sibling=null}return p.child}function fv(c,p,k){switch(p.tag){case 3:Vd(p),Qo();break;case 5:Of(p);break;case 1:fs(p.type)&&Fc(p);break;case 4:Nd(p,p.stateNode.containerInfo);break;case 10:var R=p.type._context,F=p.memoizedProps.value;In(Zo,R._currentValue),R._currentValue=F;break;case 13:if(R=p.memoizedState,R!==null)return R.dehydrated!==null?(In(Yn,Yn.current&1),p.flags|=128,null):(k&p.child.childLanes)!==0?mp(c,p,k):(In(Yn,Yn.current&1),c=Qi(c,p,k),c!==null?c.sibling:null);In(Yn,Yn.current&1);break;case 19:if(R=(k&p.childLanes)!==0,(c.flags&128)!==0){if(R)return Yd(c,p,k);p.flags|=128}if(F=p.memoizedState,F!==null&&(F.rendering=null,F.tail=null,F.lastEffect=null),In(Yn,Yn.current),R)break;return null;case 22:case 23:return p.lanes=0,dp(c,p,k)}return Qi(c,p,k)}var Jd,Qd,xp,yp;Jd=function(c,p){for(var k=p.child;k!==null;){if(k.tag===5||k.tag===6)c.appendChild(k.stateNode);else if(k.tag!==4&&k.child!==null){k.child.return=k,k=k.child;continue}if(k===p)break;for(;k.sibling===null;){if(k.return===null||k.return===p)return;k=k.return}k.sibling.return=k.return,k=k.sibling}},Qd=function(){},xp=function(c,p,k,R){var F=c.memoizedProps;if(F!==R){c=p.stateNode,ta(Mi.current);var K=null;switch(k){case"input":F=At(c,F),R=At(c,R),K=[];break;case"select":F=Q({},F,{value:void 0}),R=Q({},R,{value:void 0}),K=[];break;case"textarea":F=_t(c,F),R=_t(c,R),K=[];break;default:typeof F.onClick!="function"&&typeof R.onClick=="function"&&(c.onclick=Lc)}yi(k,R);var ue;k=null;for(qe in F)if(!R.hasOwnProperty(qe)&&F.hasOwnProperty(qe)&&F[qe]!=null)if(qe==="style"){var _e=F[qe];for(ue in _e)_e.hasOwnProperty(ue)&&(k||(k={}),k[ue]="")}else qe!=="dangerouslySetInnerHTML"&&qe!=="children"&&qe!=="suppressContentEditableWarning"&&qe!=="suppressHydrationWarning"&&qe!=="autoFocus"&&(o.hasOwnProperty(qe)?K||(K=[]):(K=K||[]).push(qe,null));for(qe in R){var $e=R[qe];if(_e=F!=null?F[qe]:void 0,R.hasOwnProperty(qe)&&$e!==_e&&($e!=null||_e!=null))if(qe==="style")if(_e){for(ue in _e)!_e.hasOwnProperty(ue)||$e&&$e.hasOwnProperty(ue)||(k||(k={}),k[ue]="");for(ue in $e)$e.hasOwnProperty(ue)&&_e[ue]!==$e[ue]&&(k||(k={}),k[ue]=$e[ue])}else k||(K||(K=[]),K.push(qe,k)),k=$e;else qe==="dangerouslySetInnerHTML"?($e=$e?$e.__html:void 0,_e=_e?_e.__html:void 0,$e!=null&&_e!==$e&&(K=K||[]).push(qe,$e)):qe==="children"?typeof $e!="string"&&typeof $e!="number"||(K=K||[]).push(qe,""+$e):qe!=="suppressContentEditableWarning"&&qe!=="suppressHydrationWarning"&&(o.hasOwnProperty(qe)?($e!=null&&qe==="onScroll"&&zn("scroll",c),K||_e===$e||(K=[])):(K=K||[]).push(qe,$e))}k&&(K=K||[]).push("style",k);var qe=K;(p.updateQueue=qe)&&(p.flags|=4)}},yp=function(c,p,k,R){k!==R&&(p.flags|=4)};function ru(c,p){if(!Kn)switch(c.tailMode){case"hidden":p=c.tail;for(var k=null;p!==null;)p.alternate!==null&&(k=p),p=p.sibling;k===null?c.tail=null:k.sibling=null;break;case"collapsed":k=c.tail;for(var R=null;k!==null;)k.alternate!==null&&(R=k),k=k.sibling;R===null?p||c.tail===null?c.tail=null:c.tail.sibling=null:R.sibling=null}}function Lr(c){var p=c.alternate!==null&&c.alternate.child===c.child,k=0,R=0;if(p)for(var F=c.child;F!==null;)k|=F.lanes|F.childLanes,R|=F.subtreeFlags&14680064,R|=F.flags&14680064,F.return=c,F=F.sibling;else for(F=c.child;F!==null;)k|=F.lanes|F.childLanes,R|=F.subtreeFlags,R|=F.flags,F.return=c,F=F.sibling;return c.subtreeFlags|=R,c.childLanes=k,p}function Pg(c,p,k){var R=p.pendingProps;switch(pd(p),p.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lr(p),null;case 1:return fs(p.type)&&Bc(),Lr(p),null;case 3:return R=p.stateNode,na(),Bn(hs),Bn(Jr),Ad(),R.pendingContext&&(R.context=R.pendingContext,R.pendingContext=null),(c===null||c.child===null)&&(Il(p)?p.flags|=4:c===null||c.memoizedState.isDehydrated&&(p.flags&256)===0||(p.flags|=1024,xs!==null&&(fh(xs),xs=null))),Qd(c,p),Lr(p),null;case 5:Td(p);var F=ta(Ha.current);if(k=p.type,c!==null&&p.stateNode!=null)xp(c,p,k,R,F),c.ref!==p.ref&&(p.flags|=512,p.flags|=2097152);else{if(!R){if(p.stateNode===null)throw Error(r(166));return Lr(p),null}if(c=ta(Mi.current),Il(p)){R=p.stateNode,k=p.type;var K=p.memoizedProps;switch(R[$i]=p,R[Rl]=K,c=(p.mode&1)!==0,k){case"dialog":zn("cancel",R),zn("close",R);break;case"iframe":case"object":case"embed":zn("load",R);break;case"video":case"audio":for(F=0;F<Tl.length;F++)zn(Tl[F],R);break;case"source":zn("error",R);break;case"img":case"image":case"link":zn("error",R),zn("load",R);break;case"details":zn("toggle",R);break;case"input":He(R,K),zn("invalid",R);break;case"select":R._wrapperState={wasMultiple:!!K.multiple},zn("invalid",R);break;case"textarea":Kt(R,K),zn("invalid",R)}yi(k,K),F=null;for(var ue in K)if(K.hasOwnProperty(ue)){var _e=K[ue];ue==="children"?typeof _e=="string"?R.textContent!==_e&&(K.suppressHydrationWarning!==!0&&Oc(R.textContent,_e,c),F=["children",_e]):typeof _e=="number"&&R.textContent!==""+_e&&(K.suppressHydrationWarning!==!0&&Oc(R.textContent,_e,c),F=["children",""+_e]):o.hasOwnProperty(ue)&&_e!=null&&ue==="onScroll"&&zn("scroll",R)}switch(k){case"input":Je(R),an(R,K,!0);break;case"textarea":Je(R),Rn(R);break;case"select":case"option":break;default:typeof K.onClick=="function"&&(R.onclick=Lc)}R=F,p.updateQueue=R,R!==null&&(p.flags|=4)}else{ue=F.nodeType===9?F:F.ownerDocument,c==="http://www.w3.org/1999/xhtml"&&(c=Br(k)),c==="http://www.w3.org/1999/xhtml"?k==="script"?(c=ue.createElement("div"),c.innerHTML="<script><\/script>",c=c.removeChild(c.firstChild)):typeof R.is=="string"?c=ue.createElement(k,{is:R.is}):(c=ue.createElement(k),k==="select"&&(ue=c,R.multiple?ue.multiple=!0:R.size&&(ue.size=R.size))):c=ue.createElementNS(c,k),c[$i]=p,c[Rl]=R,Jd(c,p,!1,!1),p.stateNode=c;e:{switch(ue=yn(k,R),k){case"dialog":zn("cancel",c),zn("close",c),F=R;break;case"iframe":case"object":case"embed":zn("load",c),F=R;break;case"video":case"audio":for(F=0;F<Tl.length;F++)zn(Tl[F],c);F=R;break;case"source":zn("error",c),F=R;break;case"img":case"image":case"link":zn("error",c),zn("load",c),F=R;break;case"details":zn("toggle",c),F=R;break;case"input":He(c,R),F=At(c,R),zn("invalid",c);break;case"option":F=R;break;case"select":c._wrapperState={wasMultiple:!!R.multiple},F=Q({},R,{value:void 0}),zn("invalid",c);break;case"textarea":Kt(c,R),F=_t(c,R),zn("invalid",c);break;default:F=R}yi(k,F),_e=F;for(K in _e)if(_e.hasOwnProperty(K)){var $e=_e[K];K==="style"?Ea(c,$e):K==="dangerouslySetInnerHTML"?($e=$e?$e.__html:void 0,$e!=null&&St(c,$e)):K==="children"?typeof $e=="string"?(k!=="textarea"||$e!=="")&&Rt(c,$e):typeof $e=="number"&&Rt(c,""+$e):K!=="suppressContentEditableWarning"&&K!=="suppressHydrationWarning"&&K!=="autoFocus"&&(o.hasOwnProperty(K)?$e!=null&&K==="onScroll"&&zn("scroll",c):$e!=null&&j(c,K,$e,ue))}switch(k){case"input":Je(c),an(c,R,!1);break;case"textarea":Je(c),Rn(c);break;case"option":R.value!=null&&c.setAttribute("value",""+ne(R.value));break;case"select":c.multiple=!!R.multiple,K=R.value,K!=null?yt(c,!!R.multiple,K,!1):R.defaultValue!=null&&yt(c,!!R.multiple,R.defaultValue,!0);break;default:typeof F.onClick=="function"&&(c.onclick=Lc)}switch(k){case"button":case"input":case"select":case"textarea":R=!!R.autoFocus;break e;case"img":R=!0;break e;default:R=!1}}R&&(p.flags|=4)}p.ref!==null&&(p.flags|=512,p.flags|=2097152)}return Lr(p),null;case 6:if(c&&p.stateNode!=null)yp(c,p,c.memoizedProps,R);else{if(typeof R!="string"&&p.stateNode===null)throw Error(r(166));if(k=ta(Ha.current),ta(Mi.current),Il(p)){if(R=p.stateNode,k=p.memoizedProps,R[$i]=p,(K=R.nodeValue!==k)&&(c=gs,c!==null))switch(c.tag){case 3:Oc(R.nodeValue,k,(c.mode&1)!==0);break;case 5:c.memoizedProps.suppressHydrationWarning!==!0&&Oc(R.nodeValue,k,(c.mode&1)!==0)}K&&(p.flags|=4)}else R=(k.nodeType===9?k:k.ownerDocument).createTextNode(R),R[$i]=p,p.stateNode=R}return Lr(p),null;case 13:if(Bn(Yn),R=p.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(Kn&&Ns!==null&&(p.mode&1)!==0&&(p.flags&128)===0)If(),Qo(),p.flags|=98560,K=!1;else if(K=Il(p),R!==null&&R.dehydrated!==null){if(c===null){if(!K)throw Error(r(318));if(K=p.memoizedState,K=K!==null?K.dehydrated:null,!K)throw Error(r(317));K[$i]=p}else Qo(),(p.flags&128)===0&&(p.memoizedState=null),p.flags|=4;Lr(p),K=!1}else xs!==null&&(fh(xs),xs=null),K=!0;if(!K)return p.flags&65536?p:null}return(p.flags&128)!==0?(p.lanes=k,p):(R=R!==null,R!==(c!==null&&c.memoizedState!==null)&&R&&(p.child.flags|=8192,(p.mode&1)!==0&&(c===null||(Yn.current&1)!==0?br===0&&(br=3):gh())),p.updateQueue!==null&&(p.flags|=4),Lr(p),null);case 4:return na(),Qd(c,p),c===null&&$l(p.stateNode.containerInfo),Lr(p),null;case 10:return Cd(p.type._context),Lr(p),null;case 17:return fs(p.type)&&Bc(),Lr(p),null;case 19:if(Bn(Yn),K=p.memoizedState,K===null)return Lr(p),null;if(R=(p.flags&128)!==0,ue=K.rendering,ue===null)if(R)ru(K,!1);else{if(br!==0||c!==null&&(c.flags&128)!==0)for(c=p.child;c!==null;){if(ue=Yc(c),ue!==null){for(p.flags|=128,ru(K,!1),R=ue.updateQueue,R!==null&&(p.updateQueue=R,p.flags|=4),p.subtreeFlags=0,R=k,k=p.child;k!==null;)K=k,c=R,K.flags&=14680066,ue=K.alternate,ue===null?(K.childLanes=0,K.lanes=c,K.child=null,K.subtreeFlags=0,K.memoizedProps=null,K.memoizedState=null,K.updateQueue=null,K.dependencies=null,K.stateNode=null):(K.childLanes=ue.childLanes,K.lanes=ue.lanes,K.child=ue.child,K.subtreeFlags=0,K.deletions=null,K.memoizedProps=ue.memoizedProps,K.memoizedState=ue.memoizedState,K.updateQueue=ue.updateQueue,K.type=ue.type,c=ue.dependencies,K.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext}),k=k.sibling;return In(Yn,Yn.current&1|2),p.child}c=c.sibling}K.tail!==null&&kn()>Ga&&(p.flags|=128,R=!0,ru(K,!1),p.lanes=4194304)}else{if(!R)if(c=Yc(ue),c!==null){if(p.flags|=128,R=!0,k=c.updateQueue,k!==null&&(p.updateQueue=k,p.flags|=4),ru(K,!0),K.tail===null&&K.tailMode==="hidden"&&!ue.alternate&&!Kn)return Lr(p),null}else 2*kn()-K.renderingStartTime>Ga&&k!==1073741824&&(p.flags|=128,R=!0,ru(K,!1),p.lanes=4194304);K.isBackwards?(ue.sibling=p.child,p.child=ue):(k=K.last,k!==null?k.sibling=ue:p.child=ue,K.last=ue)}return K.tail!==null?(p=K.tail,K.rendering=p,K.tail=p.sibling,K.renderingStartTime=kn(),p.sibling=null,k=Yn.current,In(Yn,R?k&1|2:k&1),p):(Lr(p),null);case 22:case 23:return mh(),R=p.memoizedState!==null,c!==null&&c.memoizedState!==null!==R&&(p.flags|=8192),R&&(p.mode&1)!==0?(Ts&1073741824)!==0&&(Lr(p),p.subtreeFlags&6&&(p.flags|=8192)):Lr(p),null;case 24:return null;case 25:return null}throw Error(r(156,p.tag))}function Dg(c,p){switch(pd(p),p.tag){case 1:return fs(p.type)&&Bc(),c=p.flags,c&65536?(p.flags=c&-65537|128,p):null;case 3:return na(),Bn(hs),Bn(Jr),Ad(),c=p.flags,(c&65536)!==0&&(c&128)===0?(p.flags=c&-65537|128,p):null;case 5:return Td(p),null;case 13:if(Bn(Yn),c=p.memoizedState,c!==null&&c.dehydrated!==null){if(p.alternate===null)throw Error(r(340));Qo()}return c=p.flags,c&65536?(p.flags=c&-65537|128,p):null;case 19:return Bn(Yn),null;case 4:return na(),null;case 10:return Cd(p.type._context),null;case 22:case 23:return mh(),null;case 24:return null;default:return null}}var Zd=!1,zr=!1,Og=typeof WeakSet=="function"?WeakSet:Set,It=null;function qa(c,p){var k=c.ref;if(k!==null)if(typeof k=="function")try{k(null)}catch(R){Jn(c,p,R)}else k.current=null}function eh(c,p,k){try{k()}catch(R){Jn(c,p,R)}}var vp=!1;function Lg(c,p){if(od=vo,c=Qu(),Zu(c)){if("selectionStart"in c)var k={start:c.selectionStart,end:c.selectionEnd};else e:{k=(k=c.ownerDocument)&&k.defaultView||window;var R=k.getSelection&&k.getSelection();if(R&&R.rangeCount!==0){k=R.anchorNode;var F=R.anchorOffset,K=R.focusNode;R=R.focusOffset;try{k.nodeType,K.nodeType}catch{k=null;break e}var ue=0,_e=-1,$e=-1,qe=0,at=0,ct=c,ot=null;t:for(;;){for(var jt;ct!==k||F!==0&&ct.nodeType!==3||(_e=ue+F),ct!==K||R!==0&&ct.nodeType!==3||($e=ue+R),ct.nodeType===3&&(ue+=ct.nodeValue.length),(jt=ct.firstChild)!==null;)ot=ct,ct=jt;for(;;){if(ct===c)break t;if(ot===k&&++qe===F&&(_e=ue),ot===K&&++at===R&&($e=ue),(jt=ct.nextSibling)!==null)break;ct=ot,ot=ct.parentNode}ct=jt}k=_e===-1||$e===-1?null:{start:_e,end:$e}}else k=null}k=k||{start:0,end:0}}else k=null;for(ad={focusedElem:c,selectionRange:k},vo=!1,It=p;It!==null;)if(p=It,c=p.child,(p.subtreeFlags&1028)!==0&&c!==null)c.return=p,It=c;else for(;It!==null;){p=It;try{var Pt=p.alternate;if((p.flags&1024)!==0)switch(p.tag){case 0:case 11:case 15:break;case 1:if(Pt!==null){var Dt=Pt.memoizedProps,Pn=Pt.memoizedState,Ue=p.stateNode,Ie=Ue.getSnapshotBeforeUpdate(p.elementType===p.type?Dt:hr(p.type,Dt),Pn);Ue.__reactInternalSnapshotBeforeUpdate=Ie}break;case 3:var Ve=p.stateNode.containerInfo;Ve.nodeType===1?Ve.textContent="":Ve.nodeType===9&&Ve.documentElement&&Ve.removeChild(Ve.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(ht){Jn(p,p.return,ht)}if(c=p.sibling,c!==null){c.return=p.return,It=c;break}It=p.return}return Pt=vp,vp=!1,Pt}function Fl(c,p,k){var R=p.updateQueue;if(R=R!==null?R.lastEffect:null,R!==null){var F=R=R.next;do{if((F.tag&c)===c){var K=F.destroy;F.destroy=void 0,K!==void 0&&eh(p,k,K)}F=F.next}while(F!==R)}}function th(c,p){if(p=p.updateQueue,p=p!==null?p.lastEffect:null,p!==null){var k=p=p.next;do{if((k.tag&c)===c){var R=k.create;k.destroy=R()}k=k.next}while(k!==p)}}function nh(c){var p=c.ref;if(p!==null){var k=c.stateNode;switch(c.tag){case 5:c=k;break;default:c=k}typeof p=="function"?p(c):p.current=c}}function bp(c){var p=c.alternate;p!==null&&(c.alternate=null,bp(p)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(p=c.stateNode,p!==null&&(delete p[$i],delete p[Rl],delete p[dd],delete p[Nf],delete p[Tf])),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function wp(c){return c.tag===5||c.tag===3||c.tag===4}function _p(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||wp(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function rh(c,p,k){var R=c.tag;if(R===5||R===6)c=c.stateNode,p?k.nodeType===8?k.parentNode.insertBefore(c,p):k.insertBefore(c,p):(k.nodeType===8?(p=k.parentNode,p.insertBefore(c,k)):(p=k,p.appendChild(c)),k=k._reactRootContainer,k!=null||p.onclick!==null||(p.onclick=Lc));else if(R!==4&&(c=c.child,c!==null))for(rh(c,p,k),c=c.sibling;c!==null;)rh(c,p,k),c=c.sibling}function sh(c,p,k){var R=c.tag;if(R===5||R===6)c=c.stateNode,p?k.insertBefore(c,p):k.appendChild(c);else if(R!==4&&(c=c.child,c!==null))for(sh(c,p,k),c=c.sibling;c!==null;)sh(c,p,k),c=c.sibling}var Cr=null,ui=!1;function Eo(c,p,k){for(k=k.child;k!==null;)zg(c,p,k),k=k.sibling}function zg(c,p,k){if(gr&&typeof gr.onCommitFiberUnmount=="function")try{gr.onCommitFiberUnmount(cs,k)}catch{}switch(k.tag){case 5:zr||qa(k,p);case 6:var R=Cr,F=ui;Cr=null,Eo(c,p,k),Cr=R,ui=F,Cr!==null&&(ui?(c=Cr,k=k.stateNode,c.nodeType===8?c.parentNode.removeChild(k):c.removeChild(k)):Cr.removeChild(k.stateNode));break;case 18:Cr!==null&&(ui?(c=Cr,k=k.stateNode,c.nodeType===8?ud(c.parentNode,k):c.nodeType===1&&ud(c,k),qi(c)):ud(Cr,k.stateNode));break;case 4:R=Cr,F=ui,Cr=k.stateNode.containerInfo,ui=!0,Eo(c,p,k),Cr=R,ui=F;break;case 0:case 11:case 14:case 15:if(!zr&&(R=k.updateQueue,R!==null&&(R=R.lastEffect,R!==null))){F=R=R.next;do{var K=F,ue=K.destroy;K=K.tag,ue!==void 0&&((K&2)!==0||(K&4)!==0)&&eh(k,p,ue),F=F.next}while(F!==R)}Eo(c,p,k);break;case 1:if(!zr&&(qa(k,p),R=k.stateNode,typeof R.componentWillUnmount=="function"))try{R.props=k.memoizedProps,R.state=k.memoizedState,R.componentWillUnmount()}catch(_e){Jn(k,p,_e)}Eo(c,p,k);break;case 21:Eo(c,p,k);break;case 22:k.mode&1?(zr=(R=zr)||k.memoizedState!==null,Eo(c,p,k),zr=R):Eo(c,p,k);break;default:Eo(c,p,k)}}function Ul(c){var p=c.updateQueue;if(p!==null){c.updateQueue=null;var k=c.stateNode;k===null&&(k=c.stateNode=new Og),p.forEach(function(R){var F=Vg.bind(null,c,R);k.has(R)||(k.add(R),R.then(F,F))})}}function Ws(c,p){var k=p.deletions;if(k!==null)for(var R=0;R<k.length;R++){var F=k[R];try{var K=c,ue=p,_e=ue;e:for(;_e!==null;){switch(_e.tag){case 5:Cr=_e.stateNode,ui=!1;break e;case 3:Cr=_e.stateNode.containerInfo,ui=!0;break e;case 4:Cr=_e.stateNode.containerInfo,ui=!0;break e}_e=_e.return}if(Cr===null)throw Error(r(160));zg(K,ue,F),Cr=null,ui=!1;var $e=F.alternate;$e!==null&&($e.return=null),F.return=null}catch(qe){Jn(F,p,qe)}}if(p.subtreeFlags&12854)for(p=p.child;p!==null;)ih(p,c),p=p.sibling}function ih(c,p){var k=c.alternate,R=c.flags;switch(c.tag){case 0:case 11:case 14:case 15:if(Ws(p,c),di(c),R&4){try{Fl(3,c,c.return),th(3,c)}catch(Dt){Jn(c,c.return,Dt)}try{Fl(5,c,c.return)}catch(Dt){Jn(c,c.return,Dt)}}break;case 1:Ws(p,c),di(c),R&512&&k!==null&&qa(k,k.return);break;case 5:if(Ws(p,c),di(c),R&512&&k!==null&&qa(k,k.return),c.flags&32){var F=c.stateNode;try{Rt(F,"")}catch(Dt){Jn(c,c.return,Dt)}}if(R&4&&(F=c.stateNode,F!=null)){var K=c.memoizedProps,ue=k!==null?k.memoizedProps:K,_e=c.type,$e=c.updateQueue;if(c.updateQueue=null,$e!==null)try{_e==="input"&&K.type==="radio"&&K.name!=null&&vt(F,K),yn(_e,ue);var qe=yn(_e,K);for(ue=0;ue<$e.length;ue+=2){var at=$e[ue],ct=$e[ue+1];at==="style"?Ea(F,ct):at==="dangerouslySetInnerHTML"?St(F,ct):at==="children"?Rt(F,ct):j(F,at,ct,qe)}switch(_e){case"input":st(F,K);break;case"textarea":On(F,K);break;case"select":var ot=F._wrapperState.wasMultiple;F._wrapperState.wasMultiple=!!K.multiple;var jt=K.value;jt!=null?yt(F,!!K.multiple,jt,!1):ot!==!!K.multiple&&(K.defaultValue!=null?yt(F,!!K.multiple,K.defaultValue,!0):yt(F,!!K.multiple,K.multiple?[]:"",!1))}F[Rl]=K}catch(Dt){Jn(c,c.return,Dt)}}break;case 6:if(Ws(p,c),di(c),R&4){if(c.stateNode===null)throw Error(r(162));F=c.stateNode,K=c.memoizedProps;try{F.nodeValue=K}catch(Dt){Jn(c,c.return,Dt)}}break;case 3:if(Ws(p,c),di(c),R&4&&k!==null&&k.memoizedState.isDehydrated)try{qi(p.containerInfo)}catch(Dt){Jn(c,c.return,Dt)}break;case 4:Ws(p,c),di(c);break;case 13:Ws(p,c),di(c),F=c.child,F.flags&8192&&(K=F.memoizedState!==null,F.stateNode.isHidden=K,!K||F.alternate!==null&&F.alternate.memoizedState!==null||(ch=kn())),R&4&&Ul(c);break;case 22:if(at=k!==null&&k.memoizedState!==null,c.mode&1?(zr=(qe=zr)||at,Ws(p,c),zr=qe):Ws(p,c),di(c),R&8192){if(qe=c.memoizedState!==null,(c.stateNode.isHidden=qe)&&!at&&(c.mode&1)!==0)for(It=c,at=c.child;at!==null;){for(ct=It=at;It!==null;){switch(ot=It,jt=ot.child,ot.tag){case 0:case 11:case 14:case 15:Fl(4,ot,ot.return);break;case 1:qa(ot,ot.return);var Pt=ot.stateNode;if(typeof Pt.componentWillUnmount=="function"){R=ot,k=ot.return;try{p=R,Pt.props=p.memoizedProps,Pt.state=p.memoizedState,Pt.componentWillUnmount()}catch(Dt){Jn(R,k,Dt)}}break;case 5:qa(ot,ot.return);break;case 22:if(ot.memoizedState!==null){oh(ct);continue}}jt!==null?(jt.return=ot,It=jt):oh(ct)}at=at.sibling}e:for(at=null,ct=c;;){if(ct.tag===5){if(at===null){at=ct;try{F=ct.stateNode,qe?(K=F.style,typeof K.setProperty=="function"?K.setProperty("display","none","important"):K.display="none"):(_e=ct.stateNode,$e=ct.memoizedProps.style,ue=$e!=null&&$e.hasOwnProperty("display")?$e.display:null,_e.style.display=$r("display",ue))}catch(Dt){Jn(c,c.return,Dt)}}}else if(ct.tag===6){if(at===null)try{ct.stateNode.nodeValue=qe?"":ct.memoizedProps}catch(Dt){Jn(c,c.return,Dt)}}else if((ct.tag!==22&&ct.tag!==23||ct.memoizedState===null||ct===c)&&ct.child!==null){ct.child.return=ct,ct=ct.child;continue}if(ct===c)break e;for(;ct.sibling===null;){if(ct.return===null||ct.return===c)break e;at===ct&&(at=null),ct=ct.return}at===ct&&(at=null),ct.sibling.return=ct.return,ct=ct.sibling}}break;case 19:Ws(p,c),di(c),R&4&&Ul(c);break;case 21:break;default:Ws(p,c),di(c)}}function di(c){var p=c.flags;if(p&2){try{e:{for(var k=c.return;k!==null;){if(wp(k)){var R=k;break e}k=k.return}throw Error(r(160))}switch(R.tag){case 5:var F=R.stateNode;R.flags&32&&(Rt(F,""),R.flags&=-33);var K=_p(c);sh(c,K,F);break;case 3:case 4:var ue=R.stateNode.containerInfo,_e=_p(c);rh(c,_e,ue);break;default:throw Error(r(161))}}catch($e){Jn(c,c.return,$e)}c.flags&=-3}p&4096&&(c.flags&=-4097)}function kp(c,p,k){It=c,Sp(c)}function Sp(c,p,k){for(var R=(c.mode&1)!==0;It!==null;){var F=It,K=F.child;if(F.tag===22&&R){var ue=F.memoizedState!==null||Zd;if(!ue){var _e=F.alternate,$e=_e!==null&&_e.memoizedState!==null||zr;_e=Zd;var qe=zr;if(Zd=ue,(zr=$e)&&!qe)for(It=F;It!==null;)ue=It,$e=ue.child,ue.tag===22&&ue.memoizedState!==null?ah(F):$e!==null?($e.return=ue,It=$e):ah(F);for(;K!==null;)It=K,Sp(K),K=K.sibling;It=F,Zd=_e,zr=qe}Cp(c)}else(F.subtreeFlags&8772)!==0&&K!==null?(K.return=F,It=K):Cp(c)}}function Cp(c){for(;It!==null;){var p=It;if((p.flags&8772)!==0){var k=p.alternate;try{if((p.flags&8772)!==0)switch(p.tag){case 0:case 11:case 15:zr||th(5,p);break;case 1:var R=p.stateNode;if(p.flags&4&&!zr)if(k===null)R.componentDidMount();else{var F=p.elementType===p.type?k.memoizedProps:hr(p.type,k.memoizedProps);R.componentDidUpdate(F,k.memoizedState,R.__reactInternalSnapshotBeforeUpdate)}var K=p.updateQueue;K!==null&&kg(p,K,R);break;case 3:var ue=p.updateQueue;if(ue!==null){if(k=null,p.child!==null)switch(p.child.tag){case 5:k=p.child.stateNode;break;case 1:k=p.child.stateNode}kg(p,ue,k)}break;case 5:var _e=p.stateNode;if(k===null&&p.flags&4){k=_e;var $e=p.memoizedProps;switch(p.type){case"button":case"input":case"select":case"textarea":$e.autoFocus&&k.focus();break;case"img":$e.src&&(k.src=$e.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(p.memoizedState===null){var qe=p.alternate;if(qe!==null){var at=qe.memoizedState;if(at!==null){var ct=at.dehydrated;ct!==null&&qi(ct)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(r(163))}zr||p.flags&512&&nh(p)}catch(ot){Jn(p,p.return,ot)}}if(p===c){It=null;break}if(k=p.sibling,k!==null){k.return=p.return,It=k;break}It=p.return}}function oh(c){for(;It!==null;){var p=It;if(p===c){It=null;break}var k=p.sibling;if(k!==null){k.return=p.return,It=k;break}It=p.return}}function ah(c){for(;It!==null;){var p=It;try{switch(p.tag){case 0:case 11:case 15:var k=p.return;try{th(4,p)}catch($e){Jn(p,k,$e)}break;case 1:var R=p.stateNode;if(typeof R.componentDidMount=="function"){var F=p.return;try{R.componentDidMount()}catch($e){Jn(p,F,$e)}}var K=p.return;try{nh(p)}catch($e){Jn(p,K,$e)}break;case 5:var ue=p.return;try{nh(p)}catch($e){Jn(p,ue,$e)}}}catch($e){Jn(p,p.return,$e)}if(p===c){It=null;break}var _e=p.sibling;if(_e!==null){_e.return=p.return,It=_e;break}It=p.return}}var Bg=Math.ceil,su=T.ReactCurrentDispatcher,iu=T.ReactCurrentOwner,qs=T.ReactCurrentBatchConfig,gn=0,fr=null,ar=null,jr=0,Ts=0,Va=Gi(0),br=0,Hl=null,oa=0,ou=0,lh=0,au=null,vs=null,ch=0,Ga=1/0,No=null,lu=!1,uh=null,To=null,cu=!1,aa=null,uu=0,Wl=0,dh=null,ql=-1,du=0;function es(){return(gn&6)!==0?kn():ql!==-1?ql:ql=kn()}function $o(c){return(c.mode&1)===0?1:(gn&2)!==0&&jr!==0?jr&-jr:wd.transition!==null?(du===0&&(du=Es()),du):(c=Pe,c!==0||(c=window.event,c=c===void 0?16:he(c.type)),c)}function hi(c,p,k,R){if(50<Wl)throw Wl=0,dh=null,Error(r(185));qr(c,k,R),((gn&2)===0||c!==fr)&&(c===fr&&((gn&2)===0&&(ou|=k),br===4&&Ao(c,jr)),bs(c,R),k===1&&gn===0&&(p.mode&1)===0&&(Ga=kn()+500,Uc&&ko()))}function bs(c,p){var k=c.callbackNode;ds(c,p);var R=Ci(c,c===fr?jr:0);if(R===0)k!==null&&Sr(k),c.callbackNode=null,c.callbackPriority=0;else if(p=R&-R,c.callbackPriority!==p){if(k!=null&&Sr(k),p===1)c.tag===0?uv(Np.bind(null,c)):Mf(Np.bind(null,c)),vg(function(){(gn&6)===0&&ko()}),k=null;else{switch(Qe(R)){case 1:k=Vn;break;case 4:k=Ir;break;case 16:k=ti;break;case 536870912:k=_i;break;default:k=ti}k=Ip(k,jp.bind(null,c))}c.callbackPriority=p,c.callbackNode=k}}function jp(c,p){if(ql=-1,du=0,(gn&6)!==0)throw Error(r(327));var k=c.callbackNode;if(Ka()&&c.callbackNode!==k)return null;var R=Ci(c,c===fr?jr:0);if(R===0)return null;if((R&30)!==0||(R&c.expiredLanes)!==0||p)p=hu(c,R);else{p=R;var F=gn;gn|=2;var K=Fg();(fr!==c||jr!==p)&&(No=null,Ga=kn()+500,ca(c,p));do try{pv();break}catch(_e){Tp(c,_e)}while(!0);Sd(),su.current=K,gn=F,ar!==null?p=0:(fr=null,jr=0,p=br)}if(p!==0){if(p===2&&(F=Hi(c),F!==0&&(R=F,p=hh(c,F))),p===1)throw k=Hl,ca(c,0),Ao(c,R),bs(c,kn()),k;if(p===6)Ao(c,R);else{if(F=c.current.alternate,(R&30)===0&&!Ep(F)&&(p=hu(c,R),p===2&&(K=Hi(c),K!==0&&(R=K,p=hh(c,K))),p===1))throw k=Hl,ca(c,0),Ao(c,R),bs(c,kn()),k;switch(c.finishedWork=F,c.finishedLanes=R,p){case 0:case 1:throw Error(r(345));case 2:ua(c,vs,No);break;case 3:if(Ao(c,R),(R&130023424)===R&&(p=ch+500-kn(),10<p)){if(Ci(c,0)!==0)break;if(F=c.suspendedLanes,(F&R)!==R){es(),c.pingedLanes|=c.suspendedLanes&F;break}c.timeoutHandle=cd(ua.bind(null,c,vs,No),p);break}ua(c,vs,No);break;case 4:if(Ao(c,R),(R&4194240)===R)break;for(p=c.eventTimes,F=-1;0<R;){var ue=31-Gn(R);K=1<<ue,ue=p[ue],ue>F&&(F=ue),R&=~K}if(R=F,R=kn()-R,R=(120>R?120:480>R?480:1080>R?1080:1920>R?1920:3e3>R?3e3:4320>R?4320:1960*Bg(R/1960))-R,10<R){c.timeoutHandle=cd(ua.bind(null,c,vs,No),R);break}ua(c,vs,No);break;case 5:ua(c,vs,No);break;default:throw Error(r(329))}}}return bs(c,kn()),c.callbackNode===k?jp.bind(null,c):null}function hh(c,p){var k=au;return c.current.memoizedState.isDehydrated&&(ca(c,p).flags|=256),c=hu(c,p),c!==2&&(p=vs,vs=k,p!==null&&fh(p)),c}function fh(c){vs===null?vs=c:vs.push.apply(vs,c)}function Ep(c){for(var p=c;;){if(p.flags&16384){var k=p.updateQueue;if(k!==null&&(k=k.stores,k!==null))for(var R=0;R<k.length;R++){var F=k[R],K=F.getSnapshot;F=F.value;try{if(!ai(K(),F))return!1}catch{return!1}}}if(k=p.child,p.subtreeFlags&16384&&k!==null)k.return=p,p=k;else{if(p===c)break;for(;p.sibling===null;){if(p.return===null||p.return===c)return!0;p=p.return}p.sibling.return=p.return,p=p.sibling}}return!0}function Ao(c,p){for(p&=~lh,p&=~ou,c.suspendedLanes|=p,c.pingedLanes&=~p,c=c.expirationTimes;0<p;){var k=31-Gn(p),R=1<<k;c[k]=-1,p&=~R}}function Np(c){if((gn&6)!==0)throw Error(r(327));Ka();var p=Ci(c,0);if((p&1)===0)return bs(c,kn()),null;var k=hu(c,p);if(c.tag!==0&&k===2){var R=Hi(c);R!==0&&(p=R,k=hh(c,R))}if(k===1)throw k=Hl,ca(c,0),Ao(c,p),bs(c,kn()),k;if(k===6)throw Error(r(345));return c.finishedWork=c.current.alternate,c.finishedLanes=p,ua(c,vs,No),bs(c,kn()),null}function ph(c,p){var k=gn;gn|=1;try{return c(p)}finally{gn=k,gn===0&&(Ga=kn()+500,Uc&&ko())}}function la(c){aa!==null&&aa.tag===0&&(gn&6)===0&&Ka();var p=gn;gn|=1;var k=qs.transition,R=Pe;try{if(qs.transition=null,Pe=1,c)return c()}finally{Pe=R,qs.transition=k,gn=p,(gn&6)===0&&ko()}}function mh(){Ts=Va.current,Bn(Va)}function ca(c,p){c.finishedWork=null,c.finishedLanes=0;var k=c.timeoutHandle;if(k!==-1&&(c.timeoutHandle=-1,yg(k)),ar!==null)for(k=ar.return;k!==null;){var R=k;switch(pd(R),R.tag){case 1:R=R.type.childContextTypes,R!=null&&Bc();break;case 3:na(),Bn(hs),Bn(Jr),Ad();break;case 5:Td(R);break;case 4:na();break;case 13:Bn(Yn);break;case 19:Bn(Yn);break;case 10:Cd(R.type._context);break;case 22:case 23:mh()}k=k.return}if(fr=c,ar=c=Ro(c.current,null),jr=Ts=p,br=0,Hl=null,lh=ou=oa=0,vs=au=null,Ua!==null){for(p=0;p<Ua.length;p++)if(k=Ua[p],R=k.interleaved,R!==null){k.interleaved=null;var F=R.next,K=k.pending;if(K!==null){var ue=K.next;K.next=F,R.next=ue}k.pending=R}Ua=null}return c}function Tp(c,p){do{var k=ar;try{if(Sd(),Rd.current=eu,Id){for(var R=Xn.memoizedState;R!==null;){var F=R.queue;F!==null&&(F.pending=null),R=R.next}Id=!1}if(ra=0,vr=dr=Xn=null,sa=!1,jo=0,iu.current=null,k===null||k.return===null){br=1,Hl=p,ar=null;break}e:{var K=c,ue=k.return,_e=k,$e=p;if(p=jr,_e.flags|=32768,$e!==null&&typeof $e=="object"&&typeof $e.then=="function"){var qe=$e,at=_e,ct=at.tag;if((at.mode&1)===0&&(ct===0||ct===11||ct===15)){var ot=at.alternate;ot?(at.updateQueue=ot.updateQueue,at.memoizedState=ot.memoizedState,at.lanes=ot.lanes):(at.updateQueue=null,at.memoizedState=null)}var jt=Rg(ue);if(jt!==null){jt.flags&=-257,Zr(jt,ue,_e,K,p),jt.mode&1&&lp(K,qe,p),p=jt,$e=qe;var Pt=p.updateQueue;if(Pt===null){var Dt=new Set;Dt.add($e),p.updateQueue=Dt}else Pt.add($e);break e}else{if((p&1)===0){lp(K,qe,p),gh();break e}$e=Error(r(426))}}else if(Kn&&_e.mode&1){var Pn=Rg(ue);if(Pn!==null){(Pn.flags&65536)===0&&(Pn.flags|=256),Zr(Pn,ue,_e,K,p),bd(Wa($e,_e));break e}}K=$e=Wa($e,_e),br!==4&&(br=2),au===null?au=[K]:au.push(K),K=ue;do{switch(K.tag){case 3:K.flags|=65536,p&=-p,K.lanes|=p;var Ue=op(K,$e,p);_g(K,Ue);break e;case 1:_e=$e;var Ie=K.type,Ve=K.stateNode;if((K.flags&128)===0&&(typeof Ie.getDerivedStateFromError=="function"||Ve!==null&&typeof Ve.componentDidCatch=="function"&&(To===null||!To.has(Ve)))){K.flags|=65536,p&=-p,K.lanes|=p;var ht=ap(K,_e,p);_g(K,ht);break e}}K=K.return}while(K!==null)}Vl(k)}catch(Ft){p=Ft,ar===k&&k!==null&&(ar=k=k.return);continue}break}while(!0)}function Fg(){var c=su.current;return su.current=eu,c===null?eu:c}function gh(){(br===0||br===3||br===2)&&(br=4),fr===null||(oa&268435455)===0&&(ou&268435455)===0||Ao(fr,jr)}function hu(c,p){var k=gn;gn|=2;var R=Fg();(fr!==c||jr!==p)&&(No=null,ca(c,p));do try{Ug();break}catch(F){Tp(c,F)}while(!0);if(Sd(),gn=k,su.current=R,ar!==null)throw Error(r(261));return fr=null,jr=0,br}function Ug(){for(;ar!==null;)$p(ar)}function pv(){for(;ar!==null&&!Ta();)$p(ar)}function $p(c){var p=Mp(c.alternate,c,Ts);c.memoizedProps=c.pendingProps,p===null?Vl(c):ar=p,iu.current=null}function Vl(c){var p=c;do{var k=p.alternate;if(c=p.return,(p.flags&32768)===0){if(k=Pg(k,p,Ts),k!==null){ar=k;return}}else{if(k=Dg(k,p),k!==null){k.flags&=32767,ar=k;return}if(c!==null)c.flags|=32768,c.subtreeFlags=0,c.deletions=null;else{br=6,ar=null;return}}if(p=p.sibling,p!==null){ar=p;return}ar=p=c}while(p!==null);br===0&&(br=5)}function ua(c,p,k){var R=Pe,F=qs.transition;try{qs.transition=null,Pe=1,Ap(c,p,k,R)}finally{qs.transition=F,Pe=R}return null}function Ap(c,p,k,R){do Ka();while(aa!==null);if((gn&6)!==0)throw Error(r(327));k=c.finishedWork;var F=c.finishedLanes;if(k===null)return null;if(c.finishedWork=null,c.finishedLanes=0,k===c.current)throw Error(r(177));c.callbackNode=null,c.callbackPriority=0;var K=k.lanes|k.childLanes;if(ft(c,K),c===fr&&(ar=fr=null,jr=0),(k.subtreeFlags&2064)===0&&(k.flags&2064)===0||cu||(cu=!0,Ip(ti,function(){return Ka(),null})),K=(k.flags&15990)!==0,(k.subtreeFlags&15990)!==0||K){K=qs.transition,qs.transition=null;var ue=Pe;Pe=1;var _e=gn;gn|=4,iu.current=null,Lg(c,k),ih(k,c),fg(ad),vo=!!od,ad=od=null,c.current=k,kp(k),$a(),gn=_e,Pe=ue,qs.transition=K}else c.current=k;if(cu&&(cu=!1,aa=c,uu=F),K=c.pendingLanes,K===0&&(To=null),Bt(k.stateNode),bs(c,kn()),p!==null)for(R=c.onRecoverableError,k=0;k<p.length;k++)F=p[k],R(F.value,{componentStack:F.stack,digest:F.digest});if(lu)throw lu=!1,c=uh,uh=null,c;return(uu&1)!==0&&c.tag!==0&&Ka(),K=c.pendingLanes,(K&1)!==0?c===dh?Wl++:(Wl=0,dh=c):Wl=0,ko(),null}function Ka(){if(aa!==null){var c=Qe(uu),p=qs.transition,k=Pe;try{if(qs.transition=null,Pe=16>c?16:c,aa===null)var R=!1;else{if(c=aa,aa=null,uu=0,(gn&6)!==0)throw Error(r(331));var F=gn;for(gn|=4,It=c.current;It!==null;){var K=It,ue=K.child;if((It.flags&16)!==0){var _e=K.deletions;if(_e!==null){for(var $e=0;$e<_e.length;$e++){var qe=_e[$e];for(It=qe;It!==null;){var at=It;switch(at.tag){case 0:case 11:case 15:Fl(8,at,K)}var ct=at.child;if(ct!==null)ct.return=at,It=ct;else for(;It!==null;){at=It;var ot=at.sibling,jt=at.return;if(bp(at),at===qe){It=null;break}if(ot!==null){ot.return=jt,It=ot;break}It=jt}}}var Pt=K.alternate;if(Pt!==null){var Dt=Pt.child;if(Dt!==null){Pt.child=null;do{var Pn=Dt.sibling;Dt.sibling=null,Dt=Pn}while(Dt!==null)}}It=K}}if((K.subtreeFlags&2064)!==0&&ue!==null)ue.return=K,It=ue;else e:for(;It!==null;){if(K=It,(K.flags&2048)!==0)switch(K.tag){case 0:case 11:case 15:Fl(9,K,K.return)}var Ue=K.sibling;if(Ue!==null){Ue.return=K.return,It=Ue;break e}It=K.return}}var Ie=c.current;for(It=Ie;It!==null;){ue=It;var Ve=ue.child;if((ue.subtreeFlags&2064)!==0&&Ve!==null)Ve.return=ue,It=Ve;else e:for(ue=Ie;It!==null;){if(_e=It,(_e.flags&2048)!==0)try{switch(_e.tag){case 0:case 11:case 15:th(9,_e)}}catch(Ft){Jn(_e,_e.return,Ft)}if(_e===ue){It=null;break e}var ht=_e.sibling;if(ht!==null){ht.return=_e.return,It=ht;break e}It=_e.return}}if(gn=F,ko(),gr&&typeof gr.onPostCommitFiberRoot=="function")try{gr.onPostCommitFiberRoot(cs,c)}catch{}R=!0}return R}finally{Pe=k,qs.transition=p}}return!1}function Rp(c,p,k){p=Wa(k,p),p=op(c,p,1),c=Co(c,p,1),p=es(),c!==null&&(qr(c,1,p),bs(c,p))}function Jn(c,p,k){if(c.tag===3)Rp(c,c,k);else for(;p!==null;){if(p.tag===3){Rp(p,c,k);break}else if(p.tag===1){var R=p.stateNode;if(typeof p.type.getDerivedStateFromError=="function"||typeof R.componentDidCatch=="function"&&(To===null||!To.has(R))){c=Wa(k,c),c=ap(p,c,1),p=Co(p,c,1),c=es(),p!==null&&(qr(p,1,c),bs(p,c));break}}p=p.return}}function Hg(c,p,k){var R=c.pingCache;R!==null&&R.delete(p),p=es(),c.pingedLanes|=c.suspendedLanes&k,fr===c&&(jr&k)===k&&(br===4||br===3&&(jr&130023424)===jr&&500>kn()-ch?ca(c,0):lh|=k),bs(c,p)}function Wg(c,p){p===0&&((c.mode&1)===0?p=1:(p=Wr,Wr<<=1,(Wr&130023424)===0&&(Wr=4194304)));var k=es();c=Xi(c,p),c!==null&&(qr(c,p,k),bs(c,k))}function qg(c){var p=c.memoizedState,k=0;p!==null&&(k=p.retryLane),Wg(c,k)}function Vg(c,p){var k=0;switch(c.tag){case 13:var R=c.stateNode,F=c.memoizedState;F!==null&&(k=F.retryLane);break;case 19:R=c.stateNode;break;default:throw Error(r(314))}R!==null&&R.delete(p),Wg(c,k)}var Mp;Mp=function(c,p,k){if(c!==null)if(c.memoizedProps!==p.pendingProps||hs.current)ys=!0;else{if((c.lanes&k)===0&&(p.flags&128)===0)return ys=!1,fv(c,p,k);ys=(c.flags&131072)!==0}else ys=!1,Kn&&(p.flags&1048576)!==0&&Jo(p,Wc,p.index);switch(p.lanes=0,p.tag){case 2:var R=p.type;nu(c,p),c=p.pendingProps;var F=Qr(p,Jr.current);Fa(p,k),F=Dd(null,p,R,c,F,k);var K=Od();return p.flags|=1,typeof F=="object"&&F!==null&&typeof F.render=="function"&&F.$$typeof===void 0?(p.tag=1,p.memoizedState=null,p.updateQueue=null,fs(R)?(K=!0,Fc(p)):K=!1,p.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,Kc(p),F.updater=Ji,p.stateNode=F,F._reactInternals=p,Fd(p,R,c,k),p=qd(null,p,R,!0,K,k)):(p.tag=0,Kn&&K&&ur(p),Or(null,p,F,k),p=p.child),p;case 16:R=p.elementType;e:{switch(nu(c,p),c=p.pendingProps,F=R._init,R=F(R._payload),p.type=R,F=p.tag=Gg(R),c=hr(R,c),F){case 0:p=Wd(null,p,R,c,k);break e;case 1:p=fp(null,p,R,c,k);break e;case 11:p=cp(null,p,R,c,k);break e;case 14:p=zl(null,p,R,hr(R.type,c),k);break e}throw Error(r(306,R,""))}return p;case 0:return R=p.type,F=p.pendingProps,F=p.elementType===R?F:hr(R,F),Wd(c,p,R,F,k);case 1:return R=p.type,F=p.pendingProps,F=p.elementType===R?F:hr(R,F),fp(c,p,R,F,k);case 3:e:{if(Vd(p),c===null)throw Error(r(387));R=p.pendingProps,K=p.memoizedState,F=K.element,Ed(c,p),Xc(p,R,null,k);var ue=p.memoizedState;if(R=ue.element,K.isDehydrated)if(K={element:R,isDehydrated:!1,cache:ue.cache,pendingSuspenseBoundaries:ue.pendingSuspenseBoundaries,transitions:ue.transitions},p.updateQueue.baseState=K,p.memoizedState=K,p.flags&256){F=Wa(Error(r(423)),p),p=pp(c,p,R,k,F);break e}else if(R!==F){F=Wa(Error(r(424)),p),p=pp(c,p,R,k,F);break e}else for(Ns=wo(p.stateNode.containerInfo.firstChild),gs=p,Kn=!0,xs=null,k=_d(p,null,R,k),p.child=k;k;)k.flags=k.flags&-3|4096,k=k.sibling;else{if(Qo(),R===F){p=Qi(c,p,k);break e}Or(c,p,R,k)}p=p.child}return p;case 5:return Of(p),c===null&&yd(p),R=p.type,F=p.pendingProps,K=c!==null?c.memoizedProps:null,ue=F.children,ld(R,F)?ue=null:K!==null&&ld(R,K)&&(p.flags|=32),hp(c,p),Or(c,p,ue,k),p.child;case 6:return c===null&&yd(p),null;case 13:return mp(c,p,k);case 4:return Nd(p,p.stateNode.containerInfo),R=p.pendingProps,c===null?p.child=Ba(p,null,R,k):Or(c,p,R,k),p.child;case 11:return R=p.type,F=p.pendingProps,F=p.elementType===R?F:hr(R,F),cp(c,p,R,F,k);case 7:return Or(c,p,p.pendingProps,k),p.child;case 8:return Or(c,p,p.pendingProps.children,k),p.child;case 12:return Or(c,p,p.pendingProps.children,k),p.child;case 10:e:{if(R=p.type._context,F=p.pendingProps,K=p.memoizedProps,ue=F.value,In(Zo,R._currentValue),R._currentValue=ue,K!==null)if(ai(K.value,ue)){if(K.children===F.children&&!hs.current){p=Qi(c,p,k);break e}}else for(K=p.child,K!==null&&(K.return=p);K!==null;){var _e=K.dependencies;if(_e!==null){ue=K.child;for(var $e=_e.firstContext;$e!==null;){if($e.context===R){if(K.tag===1){$e=Yi(-1,k&-k),$e.tag=2;var qe=K.updateQueue;if(qe!==null){qe=qe.shared;var at=qe.pending;at===null?$e.next=$e:($e.next=at.next,at.next=$e),qe.pending=$e}}K.lanes|=k,$e=K.alternate,$e!==null&&($e.lanes|=k),Df(K.return,k,p),_e.lanes|=k;break}$e=$e.next}}else if(K.tag===10)ue=K.type===p.type?null:K.child;else if(K.tag===18){if(ue=K.return,ue===null)throw Error(r(341));ue.lanes|=k,_e=ue.alternate,_e!==null&&(_e.lanes|=k),Df(ue,k,p),ue=K.sibling}else ue=K.child;if(ue!==null)ue.return=K;else for(ue=K;ue!==null;){if(ue===p){ue=null;break}if(K=ue.sibling,K!==null){K.return=ue.return,ue=K;break}ue=ue.return}K=ue}Or(c,p,F.children,k),p=p.child}return p;case 9:return F=p.type,R=p.pendingProps.children,Fa(p,k),F=Us(F),R=R(F),p.flags|=1,Or(c,p,R,k),p.child;case 14:return R=p.type,F=hr(R,p.pendingProps),F=hr(R.type,F),zl(c,p,R,F,k);case 15:return up(c,p,p.type,p.pendingProps,k);case 17:return R=p.type,F=p.pendingProps,F=p.elementType===R?F:hr(R,F),nu(c,p),p.tag=1,fs(R)?(c=!0,Fc(p)):c=!1,Fa(p,k),sp(p,R,F),Fd(p,R,F,k),qd(null,p,R,!0,c,k);case 19:return Yd(c,p,k);case 22:return dp(c,p,k)}throw Error(r(156,p.tag))};function Ip(c,p){return qo(c,p)}function mv(c,p,k,R){this.tag=c,this.key=k,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=p,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=R,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function $s(c,p,k,R){return new mv(c,p,k,R)}function xh(c){return c=c.prototype,!(!c||!c.isReactComponent)}function Gg(c){if(typeof c=="function")return xh(c)?1:0;if(c!=null){if(c=c.$$typeof,c===Y)return 11;if(c===te)return 14}return 2}function Ro(c,p){var k=c.alternate;return k===null?(k=$s(c.tag,p,c.key,c.mode),k.elementType=c.elementType,k.type=c.type,k.stateNode=c.stateNode,k.alternate=c,c.alternate=k):(k.pendingProps=p,k.type=c.type,k.flags=0,k.subtreeFlags=0,k.deletions=null),k.flags=c.flags&14680064,k.childLanes=c.childLanes,k.lanes=c.lanes,k.child=c.child,k.memoizedProps=c.memoizedProps,k.memoizedState=c.memoizedState,k.updateQueue=c.updateQueue,p=c.dependencies,k.dependencies=p===null?null:{lanes:p.lanes,firstContext:p.firstContext},k.sibling=c.sibling,k.index=c.index,k.ref=c.ref,k}function fu(c,p,k,R,F,K){var ue=2;if(R=c,typeof c=="function")xh(c)&&(ue=1);else if(typeof c=="string")ue=5;else e:switch(c){case O:return Xa(k.children,F,K,p);case I:ue=8,F|=8;break;case z:return c=$s(12,k,p,F|2),c.elementType=z,c.lanes=K,c;case V:return c=$s(13,k,p,F),c.elementType=V,c.lanes=K,c;case H:return c=$s(19,k,p,F),c.elementType=H,c.lanes=K,c;case pe:return pu(k,F,K,p);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case U:ue=10;break e;case W:ue=9;break e;case Y:ue=11;break e;case te:ue=14;break e;case oe:ue=16,R=null;break e}throw Error(r(130,c==null?c:typeof c,""))}return p=$s(ue,k,p,F),p.elementType=c,p.type=R,p.lanes=K,p}function Xa(c,p,k,R){return c=$s(7,c,R,p),c.lanes=k,c}function pu(c,p,k,R){return c=$s(22,c,R,p),c.elementType=pe,c.lanes=k,c.stateNode={isHidden:!1},c}function yh(c,p,k){return c=$s(6,c,null,p),c.lanes=k,c}function vh(c,p,k){return p=$s(4,c.children!==null?c.children:[],c.key,p),p.lanes=k,p.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},p}function gv(c,p,k,R,F){this.tag=p,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ke(0),this.expirationTimes=Ke(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ke(0),this.identifierPrefix=R,this.onRecoverableError=F,this.mutableSourceEagerHydrationData=null}function bh(c,p,k,R,F,K,ue,_e,$e){return c=new gv(c,p,k,_e,$e),p===1?(p=1,K===!0&&(p|=8)):p=0,K=$s(3,null,null,p),c.current=K,K.stateNode=c,K.memoizedState={element:R,isDehydrated:k,cache:null,transitions:null,pendingSuspenseBoundaries:null},Kc(K),c}function xv(c,p,k){var R=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:R==null?null:""+R,children:c,containerInfo:p,implementation:k}}function Pp(c){if(!c)return _o;c=c._reactInternals;e:{if(Ct(c)!==c||c.tag!==1)throw Error(r(170));var p=c;do{switch(p.tag){case 3:p=p.stateNode.context;break e;case 1:if(fs(p.type)){p=p.stateNode.__reactInternalMemoizedMergedChildContext;break e}}p=p.return}while(p!==null);throw Error(r(171))}if(c.tag===1){var k=c.type;if(fs(k))return Af(c,k,p)}return p}function Kg(c,p,k,R,F,K,ue,_e,$e){return c=bh(k,R,!0,c,F,K,ue,_e,$e),c.context=Pp(null),k=c.current,R=es(),F=$o(k),K=Yi(R,F),K.callback=p??null,Co(k,K,F),c.current.lanes=F,qr(c,F,R),bs(c,R),c}function mu(c,p,k,R){var F=p.current,K=es(),ue=$o(F);return k=Pp(k),p.context===null?p.context=k:p.pendingContext=k,p=Yi(K,ue),p.payload={element:c},R=R===void 0?null:R,R!==null&&(p.callback=R),c=Co(F,p,ue),c!==null&&(hi(c,F,ue,K),Pl(c,F,ue)),ue}function gu(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 5:return c.child.stateNode;default:return c.child.stateNode}}function Dp(c,p){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var k=c.retryLane;c.retryLane=k!==0&&k<p?k:p}}function wh(c,p){Dp(c,p),(c=c.alternate)&&Dp(c,p)}function Xg(){return null}var Yg=typeof reportError=="function"?reportError:function(c){console.error(c)};function _h(c){this._internalRoot=c}Ya.prototype.render=_h.prototype.render=function(c){var p=this._internalRoot;if(p===null)throw Error(r(409));mu(c,p,null,null)},Ya.prototype.unmount=_h.prototype.unmount=function(){var c=this._internalRoot;if(c!==null){this._internalRoot=null;var p=c.containerInfo;la(function(){mu(null,c,null,null)}),p[Ai]=null}};function Ya(c){this._internalRoot=c}Ya.prototype.unstable_scheduleHydration=function(c){if(c){var p=Tn();c={blockedOn:null,target:c,priority:p};for(var k=0;k<ni.length&&p!==0&&p<ni[k].priority;k++);ni.splice(k,0,c),k===0&&yl(c)}};function kh(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)}function xu(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11&&(c.nodeType!==8||c.nodeValue!==" react-mount-point-unstable "))}function Jg(){}function Qg(c,p,k,R,F){if(F){if(typeof R=="function"){var K=R;R=function(){var qe=gu(ue);K.call(qe)}}var ue=Kg(p,R,c,0,null,!1,!1,"",Jg);return c._reactRootContainer=ue,c[Ai]=ue.current,$l(c.nodeType===8?c.parentNode:c),la(),ue}for(;F=c.lastChild;)c.removeChild(F);if(typeof R=="function"){var _e=R;R=function(){var qe=gu($e);_e.call(qe)}}var $e=bh(c,0,!1,null,null,!1,!1,"",Jg);return c._reactRootContainer=$e,c[Ai]=$e.current,$l(c.nodeType===8?c.parentNode:c),la(function(){mu(p,$e,k,R)}),$e}function Gl(c,p,k,R,F){var K=k._reactRootContainer;if(K){var ue=K;if(typeof F=="function"){var _e=F;F=function(){var $e=gu(ue);_e.call($e)}}mu(p,ue,c,F)}else ue=Qg(k,p,c,F,R);return gu(ue)}Et=function(c){switch(c.tag){case 3:var p=c.stateNode;if(p.current.memoizedState.isDehydrated){var k=Ps(p.pendingLanes);k!==0&&(be(p,k|1),bs(p,kn()),(gn&6)===0&&(Ga=kn()+500,ko()))}break;case 13:la(function(){var R=Xi(c,1);if(R!==null){var F=es();hi(R,c,1,F)}}),wh(c,1)}},en=function(c){if(c.tag===13){var p=Xi(c,134217728);if(p!==null){var k=es();hi(p,c,134217728,k)}wh(c,134217728)}},ln=function(c){if(c.tag===13){var p=$o(c),k=Xi(c,p);if(k!==null){var R=es();hi(k,c,p,R)}wh(c,p)}},Tn=function(){return Pe},En=function(c,p){var k=Pe;try{return Pe=c,p()}finally{Pe=k}},vi=function(c,p,k){switch(p){case"input":if(st(c,k),p=k.name,k.type==="radio"&&p!=null){for(k=c;k.parentNode;)k=k.parentNode;for(k=k.querySelectorAll("input[name="+JSON.stringify(""+p)+'][type="radio"]'),p=0;p<k.length;p++){var R=k[p];if(R!==c&&R.form===c.form){var F=zc(R);if(!F)throw Error(r(90));lt(R),st(R,F)}}}break;case"textarea":On(c,k);break;case"select":p=k.value,p!=null&&yt(c,!!k.multiple,p,!1)}},Is=ph,Ar=la;var Op={usingClientEntryPoint:!1,Events:[Ml,Pa,zc,bi,wi,ph]},fi={findFiberByHostInstance:Xo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},Zg={bundleType:fi.bundleType,version:fi.version,rendererPackageName:fi.rendererPackageName,rendererConfig:fi.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:T.ReactCurrentDispatcher,findHostInstanceByFiber:function(c){return c=fo(c),c===null?null:c.stateNode},findFiberByHostInstance:fi.findFiberByHostInstance||Xg,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 Kl=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Kl.isDisabled&&Kl.supportsFiber)try{cs=Kl.inject(Zg),gr=Kl}catch{}}return pi.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Op,pi.createPortal=function(c,p){var k=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!kh(p))throw Error(r(200));return xv(c,p,null,k)},pi.createRoot=function(c,p){if(!kh(c))throw Error(r(299));var k=!1,R="",F=Yg;return p!=null&&(p.unstable_strictMode===!0&&(k=!0),p.identifierPrefix!==void 0&&(R=p.identifierPrefix),p.onRecoverableError!==void 0&&(F=p.onRecoverableError)),p=bh(c,1,!1,null,null,k,!1,R,F),c[Ai]=p.current,$l(c.nodeType===8?c.parentNode:c),new _h(p)},pi.findDOMNode=function(c){if(c==null)return null;if(c.nodeType===1)return c;var p=c._reactInternals;if(p===void 0)throw typeof c.render=="function"?Error(r(188)):(c=Object.keys(c).join(","),Error(r(268,c)));return c=fo(p),c=c===null?null:c.stateNode,c},pi.flushSync=function(c){return la(c)},pi.hydrate=function(c,p,k){if(!xu(p))throw Error(r(200));return Gl(null,c,p,!0,k)},pi.hydrateRoot=function(c,p,k){if(!kh(c))throw Error(r(405));var R=k!=null&&k.hydratedSources||null,F=!1,K="",ue=Yg;if(k!=null&&(k.unstable_strictMode===!0&&(F=!0),k.identifierPrefix!==void 0&&(K=k.identifierPrefix),k.onRecoverableError!==void 0&&(ue=k.onRecoverableError)),p=Kg(p,null,c,1,k??null,F,!1,K,ue),c[Ai]=p.current,$l(c),R)for(c=0;c<R.length;c++)k=R[c],F=k._getVersion,F=F(k._source),p.mutableSourceEagerHydrationData==null?p.mutableSourceEagerHydrationData=[k,F]:p.mutableSourceEagerHydrationData.push(k,F);return new Ya(p)},pi.render=function(c,p,k){if(!xu(p))throw Error(r(200));return Gl(null,c,p,!1,k)},pi.unmountComponentAtNode=function(c){if(!xu(c))throw Error(r(40));return c._reactRootContainer?(la(function(){Gl(null,null,c,!1,function(){c._reactRootContainer=null,c[Ai]=null})}),!0):!1},pi.unstable_batchedUpdates=ph,pi.unstable_renderSubtreeIntoContainer=function(c,p,k,R){if(!xu(k))throw Error(r(200));if(c==null||c._reactInternals===void 0)throw Error(r(38));return Gl(c,p,k,!1,R)},pi.version="18.3.1-next-f1338f8080-20240426",pi}var V0;function h2(){if(V0)return _v.exports;V0=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(n){console.error(n)}}return e(),_v.exports=uN(),_v.exports}var G0;function dN(){if(G0)return tx;G0=1;var e=h2();return tx.createRoot=e.createRoot,tx.hydrateRoot=e.hydrateRoot,tx}var hN=dN();const fN=qy(hN);var L=Bw();const lo=qy(L),K0=e=>{let n;const r=new Set,i=(m,x)=>{const g=typeof m=="function"?m(n):m;if(!Object.is(g,n)){const b=n;n=x??(typeof g!="object"||g===null)?g:Object.assign({},n,g),r.forEach(S=>S(n,b))}},o=()=>n,u={setState:i,getState:o,getInitialState:()=>d,subscribe:m=>(r.add(m),()=>r.delete(m))},d=n=e(i,o,u);return u},pN=(e=>e?K0(e):K0),mN=e=>e;function gN(e,n=mN){const r=lo.useSyncExternalStore(e.subscribe,lo.useCallback(()=>n(e.getState()),[e,n]),lo.useCallback(()=>n(e.getInitialState()),[e,n]));return lo.useDebugValue(r),r}const X0=e=>{const n=pN(e),r=i=>gN(n,i);return Object.assign(r,n),r},cr=(e=>e?X0(e):X0);function Fo(e){return"'"+e.replace(/'/g,"'\\''")+"'"}const Cv=({sessionId:e})=>`claude --dangerously-skip-permissions --session-id ${Fo(e)}`,Y0=({sessionId:e})=>`claude --session-id ${Fo(e)}`,xN=()=>"claude --resume",f2=[{id:"sm-dangerous",label:"Session Manager (skip perms)",description:"claude --dangerously-skip-permissions in this project",category:"build",cwd:"app-cwd",command:Cv},{id:"sm-safe",label:"Session Manager (safe)",description:"claude with normal permission prompts in this project",category:"build",cwd:"app-cwd",command:Y0},{id:"home-dangerous",label:"Home (skip perms)",description:"claude --dangerously-skip-permissions in ~",category:"build",cwd:"home",command:Cv},{id:"pick-dangerous",label:"Pick directory (skip perms)…",description:"Choose a folder, launch claude --dangerously-skip-permissions",category:"build",cwd:"pick",command:Cv},{id:"pick-safe",label:"Pick directory (safe)…",description:"Choose a folder, launch claude with normal prompts",category:"build",cwd:"pick",command:Y0},{id:"pick-resume",label:"Pick directory + resume…",description:"Choose a folder, then pick a past session to resume",category:"build",cwd:"pick",command:xN},{id:"pick-shell",label:"Pick directory (shell only)…",description:"Bare interactive shell, no claude auto-launch",category:"build",cwd:"pick",command:null}];let eo=null;async function yN(){if(eo)return eo;try{const e=await window.api.app.engageRulesPath();if(!e)return eo=[],eo;const n=await window.api.config.readJson(e);if(!n.exists||n.parseError||!n.data)return eo=[],eo;const r=n.data;if(!r.presets||!Array.isArray(r.presets))return eo=[],eo;const i=r.projectPath;return eo=r.presets.map(o=>({id:o.id,label:o.label,description:o.description,category:"engage",cwd:i,platform:o.platform,pipeline:o.pipeline,rules:o.rules,command:()=>`cd ${Fo(i)} && ${o.cliEntry}`})),eo}catch(e){return console.warn("[presets] Failed to load engage presets:",e),eo=[],eo}}async function p2(e){const n=f2.find(i=>i.id===e);return n||((await yN()).find(i=>i.id===e)??null)}async function J0(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 m2(e,n){return e.command?e.command(n):null}const Fw=["opus","sonnet","haiku"],g2="sm.rawSessionModel",vN="opus";function bN(e){return Fw.includes(e)}function wN(){try{const e=localStorage.getItem(g2);if(e&&bN(e))return e}catch{}return vN}let Lh=wN();const Rb=new Set;function x2(){return Lh}function _N(e){if(e!==Lh){Lh=e;try{localStorage.setItem(g2,e)}catch{}Rb.forEach(n=>n(e))}}function kN(){const[e,n]=L.useState(Lh);L.useEffect(()=>{const i=o=>n(o);return Rb.add(i),Lh!==e&&n(Lh),()=>{Rb.delete(i)}},[]);const r=L.useCallback(i=>_N(i),[]);return{model:e,setModel:r}}async function y2(e,n){const r=await window.api.transcripts.pathFor(e,n);return window.api.config.exists(r)}function SN(e){const n=e.split("/").filter(Boolean);return n[n.length-1]||e}async function v2(e,n=!1,r=x2()){let i=!n;i&&(i=await y2(e.cwd,e.claudeSessionId));const o=n&&!i?crypto.randomUUID():e.claudeSessionId,l=i?`claude --dangerously-skip-permissions --resume ${Fo(o)} --model ${r}`:`claude --dangerously-skip-permissions --session-id ${Fo(o)} --model ${r}`;return{claudeSessionId:o,startupCommand:l}}const kt=cr((e,n)=>({tabs:[],activeTabId:null,hydrated:!1,addTab:({id:r,cwd:i,startupCommand:o,presetId:l=null,label:h})=>{const u=r??crypto.randomUUID();if(n().tabs.find(x=>x.id===u))return e({activeTabId:u}),u;const m={id:u,claudeSessionId:u,chatSessionId:crypto.randomUUID(),label:h??SN(i),cwd:i,pid:null,status:"spawning",exitCode:null,startupCommand:o,presetId:l,generation:0};return e({tabs:[...n().tabs,m],activeTabId:u}),u},setTabRunning:(r,i)=>e({tabs:n().tabs.map(o=>o.id===r?{...o,pid:i,status:"running"}:o)}),setTabExited:(r,i)=>e({tabs:n().tabs.map(o=>o.id===r?{...o,status:"exited",exitCode:i}:o)}),closeTab:r=>{var l;window.api.pty.kill(r),window.api.watchers.killTab(r).catch(()=>{}),window.api.transcripts.closeTab(r).catch(()=>{});const i=n().tabs.filter(h=>h.id!==r),o=n().activeTabId===r?((l=i[i.length-1])==null?void 0:l.id)??null:n().activeTabId;e({tabs:i,activeTabId:o})},setActive:r=>e({activeTabId:r}),restartTab:r=>{const i=n().tabs.find(h=>h.id===r);if(!i)return;window.api.pty.kill(r);const o=crypto.randomUUID(),l=h=>{e({tabs:n().tabs.map(u=>u.id===r?{...u,claudeSessionId:o,pid:null,status:"spawning",exitCode:null,startupCommand:h,generation:u.generation+1}:u)})};i.presetId?p2(i.presetId).then(h=>{l(h?m2(h,{sessionId:o,cwd:i.cwd}):`claude --dangerously-skip-permissions --session-id ${Fo(o)}`)}):l(`claude --dangerously-skip-permissions --session-id ${Fo(o)}`)},reorderTab:(r,i)=>{const o=[...n().tabs];if(r<0||r>=o.length||i<0||i>=o.length||r===i)return;const[l]=o.splice(r,1);o.splice(i,0,l),e({tabs:o})},restoreTabs:(r,i)=>e({tabs:r,activeTabId:i,hydrated:!0}),wakeTab:async(r,i)=>{const o=n().tabs.find(u=>u.id===r);if(!o||o.status!=="dormant")return;const{claudeSessionId:l,startupCommand:h}=await v2({cwd:o.cwd,claudeSessionId:o.claudeSessionId},!1,i??x2());e({tabs:n().tabs.map(u=>u.id===r?{...u,claudeSessionId:l,status:"spawning",startupCommand:h,generation:u.generation+1}:u)})},sleepTab:r=>{const i=n().tabs.find(o=>o.id===r);!i||i.status==="dormant"||(window.api.pty.kill(r),e({tabs:n().tabs.map(o=>o.id===r?{...o,pid:null,status:"dormant"}:o)}))},newChatThread:r=>{n().tabs.find(o=>o.id===r)&&e({tabs:n().tabs.map(o=>o.id===r?{...o,chatSessionId:crypto.randomUUID()}:o)})}}));async function Mb(){var r;if(kt.getState().hydrated)return;try{const{tabs:i,activeTabId:o,freshStart:l}=await window.api.sessions.load();if(i.length>0){const h=await Promise.all(i.map(async d=>{const{claudeSessionId:m}=await v2(d,l);return{id:d.id,claudeSessionId:m,chatSessionId:d.chatSessionId??crypto.randomUUID(),cwd:d.cwd,label:d.label,presetId:d.presetId,pid:null,status:"dormant",exitCode:null,startupCommand:null,generation:0}})),u=o&&h.find(d=>d.id===o)?o:((r=h[0])==null?void 0:r.id)??null;kt.getState().restoreTabs(h,u)}else kt.setState({hydrated:!0})}catch(i){console.warn("[sessions] hydrate failed:",i),kt.setState({hydrated:!0})}const e=()=>{const{tabs:i,activeTabId:o}=kt.getState(),l=i.map(h=>({id:h.id,claudeSessionId:h.claudeSessionId,chatSessionId:h.chatSessionId,cwd:h.cwd,label:h.label,presetId:h.presetId}));window.api.sessions.save({tabs:l,activeTabId:o}).catch(h=>{console.warn("[sessions] save failed:",h)})};let n=null;kt.subscribe((i,o)=>{i.hydrated&&(i.tabs===o.tabs&&i.activeTabId===o.activeTabId||(n!==null&&window.clearTimeout(n),n=window.setTimeout(e,200)))}),e()}const CN=Object.freeze(Object.defineProperty({__proto__:null,hydrateSessions:Mb,useSessions:kt},Symbol.toStringTag,{value:"Module"})),jN=5,Q0=100,EN=5e3,Ib=new Map;function Z0(e){const n=Ib.get(e);n!==void 0&&(clearTimeout(n),Ib.delete(e))}function NN(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`t-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}const Eu=cr((e,n)=>({toasts:[],history:[],unreadCount:0,show:(r,i)=>{const o=NN(),l=Date.now();e(u=>{const d=[...u.toasts,{id:o,kind:r,message:i,createdAt:l}];for(;d.length>jN;){const g=d.shift();g&&Z0(g.id)}const x=[{id:o,kind:r,message:i,createdAt:l,read:!1},...u.history];return x.length>Q0&&(x.length=Q0),{toasts:d,history:x,unreadCount:u.unreadCount+1}});const h=setTimeout(()=>n().dismiss(o),EN);return Ib.set(o,h),o},dismiss:r=>{Z0(r),e(i=>({toasts:i.toasts.filter(o=>o.id!==r)}))},markAllRead:()=>{e(r=>r.unreadCount===0?r:{history:r.history.map(i=>i.read?i:{...i,read:!0}),unreadCount:0})},clearHistory:()=>{e({history:[],unreadCount:0})},dismissHistoryEntry:r=>{e(i=>{const o=i.history.filter(h=>h.id!==r);if(o.length===i.history.length)return i;const l=i.history.find(h=>h.id===r&&!h.read);return{history:o,unreadCount:l?Math.max(0,i.unreadCount-1):i.unreadCount}})}})),ze={info:e=>Eu.getState().show("info",e),warn:e=>Eu.getState().show("warn",e),error:e=>Eu.getState().show("error",e),fromOutcome:e=>Eu.getState().show(e.kind??(e.ok?"info":"warn"),e.message)},b2=Object.freeze(Object.defineProperty({__proto__:null,toast:ze,useToast:Eu},Symbol.toStringTag,{value:"Module"})),e_=200,TN=/\x1b\[[0-9;]*m/g;function $N(e){return e.replace(TN,"")}const jm=cr((e,n)=>({watchers:{},initialized:!1,init:()=>{n().initialized||(e({initialized:!0}),window.api.watchers.onLine(r=>n().ingestLine(r)),window.api.watchers.onClosed(({watcherId:r})=>n().closed(r)))},add:async({tabId:r,label:i,command:o,cwd:l})=>{try{const h=await window.api.watchers.add({tabId:r,label:i,command:o,cwd:l??null}),u={watcherId:h.watcherId,tabId:h.tabId,label:h.label,command:h.command,cwd:h.cwd,pid:h.pid,startedAt:h.startedAt,lineCount:0,lines:[],lastLineAt:null};return e({watchers:{...n().watchers,[u.watcherId]:u}}),u}catch(h){return console.error("[watchers] add failed:",h),ze.error("Failed to add watcher"),null}},remove:async r=>{try{await window.api.watchers.remove(r)}catch(o){console.error("[watchers] remove failed:",o);const l=o instanceof Error?o.message:String(o);ze.error(`Could not remove watcher: ${l}`)}const i={...n().watchers};delete i[r],e({watchers:i})},watchersForTab:r=>Object.values(n().watchers).filter(i=>i.tabId===r),ingestLine:r=>{const i=n().watchers[r.watcherId];if(!i)return;const o=$N(r.line),l=i.lines.length>=e_?[...i.lines.slice(i.lines.length-e_+1),{line:o,ts:r.ts}]:[...i.lines,{line:o,ts:r.ts}];e({watchers:{...n().watchers,[r.watcherId]:{...i,lines:l,lineCount:i.lineCount+1,lastLineAt:r.ts}}})},closed:r=>{if(!n().watchers[r])return;const i={...n().watchers};delete i[r],e({watchers:i})}})),AN="~/.claude/session-manager/browser/history.json",t_="~/.claude/session-manager/browser/bookmarks.json",RN=.25,MN=3,n_=.1,r_=["#b85c34","#6f7d52","#e4b85a","#5f6f86","#8a5a6e","#4f7d72"];let s_=0;function IN(){const e=r_[s_%r_.length];return s_+=1,e}const dy=new Map;function PN(e){if(dy.has(e))return;const n=window.api.browser.onNavState(e,r=>{Mt.setState(i=>({tabs:i.tabs.map(o=>o.viewId===e?{...o,url:r.url,title:r.title||o.title,canGoBack:r.canGoBack,canGoForward:r.canGoForward,loading:r.loading,isSecure:r.isSecure}:o)}))});dy.set(e,n)}function DN(e){const n=dy.get(e);n&&(n(),dy.delete(e))}const Pb=new Map;let qx=null;function i_(e){const n=Pb.get(e);n&&(n(),Pb.delete(e))}function o_(){qx&&(clearInterval(qx),qx=null)}const Db=new Map;function jv(e){const n=Db.get(e);n&&(n(),Db.delete(e))}const Mt=cr((e,n)=>({tabs:[],activeTabId:null,openTab:r=>{const i=crypto.randomUUID(),o=i,l={id:i,viewId:o,title:"New Tab",url:(r==null?void 0:r.url)??"about:blank",color:(r==null?void 0:r.color)??IN(),canGoBack:!1,canGoForward:!1,loading:!1,isSecure:!1,zoomFactor:1};return e(h=>({tabs:[...h.tabs,l],activeTabId:i})),PN(o),window.api.browser.create({viewId:o,partition:"persist:browser"}).then(()=>{r!=null&&r.url&&window.api.browser.navigate({viewId:o,url:r.url}).catch(()=>{})}).catch(h=>{var d,m;const u=h instanceof Error?h.message:String(h);(m=(d=window.api)==null?void 0:d.logs)==null||m.write("browser","error",`browser:create failed for viewId ${o}: ${u}`)}),i},closeTab:r=>{const i=n().tabs.find(o=>o.id===r);i&&(DN(i.viewId),jv(i.viewId),window.api.browser.destroy(i.viewId).catch(()=>{}),e(o=>{const l=o.tabs.filter(u=>u.id!==r),h=o.activeTabId===r?l.length?l[l.length-1].id:null:o.activeTabId;return{tabs:l,activeTabId:h}}))},setActive:r=>{e({activeTabId:r})},navigate:(r,i)=>{const o=n().tabs.find(l=>l.id===r);o&&window.api.browser.navigate({viewId:o.viewId,url:i}).catch(()=>{})},back:r=>{const i=n().tabs.find(o=>o.id===r);i&&window.api.browser.back(i.viewId).catch(()=>{})},forward:r=>{const i=n().tabs.find(o=>o.id===r);i&&window.api.browser.forward(i.viewId).catch(()=>{})},reload:r=>{const i=n().tabs.find(o=>o.id===r);i&&window.api.browser.reload(i.viewId).catch(()=>{})},stop:r=>{const i=n().tabs.find(o=>o.id===r);i&&window.api.browser.stop(i.viewId).catch(()=>{})},mode:"browse",captureMode:"agent",setMode:r=>e(i=>({mode:r,captured:r==="capture"?i.captured:null})),setCaptureMode:r=>e({captureMode:r,captured:null}),onVerb:r=>{const{mode:i}=n();if(r==="shot"){e({mode:"capture",captureMode:"shot",captured:null});return}if(i===r){e({mode:"browse",captured:r==="capture"?null:n().captured});return}e({mode:r,captureMode:r==="capture"?"agent":n().captureMode,captured:r==="capture"?n().captured:null})},captured:null,capture:async r=>{const{activeTabId:i,tabs:o,captureMode:l}=n(),h=o.find(d=>d.id===i);if(!h)throw new Error("No active browser tab");if(l==="shot"){const d=await window.api.browser.captureShot(h.viewId);if(!d.ok)throw new Error(d.error);e({captured:{mode:l,url:d.url,title:d.title,dataUrl:d.dataUrl,at:Date.now()}});return}if(!r||!r.length)throw new Error("No element selected");const u=await window.api.browser.capture({viewId:h.viewId,selectors:r,mode:l});if(!u.ok)throw new Error(u.error);e({captured:{mode:l,url:h.url,title:h.title,text:u.text,meta:u.meta,selectors:r,at:Date.now()}})},recorderActive:!1,recording:!1,recorderElapsedSec:0,recorderSteps:[],startRecording:r=>{if(n().recorderActive)return;e({recorderActive:!0,recording:!0,recorderElapsedSec:0,recorderSteps:[]}),window.api.browser.recordStart(r).catch(()=>{}),i_(r);const i=window.api.browser.onRecordStep(r,o=>{Mt.getState().recording&&Mt.setState(l=>({recorderSteps:[...l.recorderSteps,o]}))});Pb.set(r,i),o_(),qx=setInterval(()=>{Mt.getState().recording&&Mt.setState(o=>({recorderElapsedSec:o.recorderElapsedSec+1}))},1e3)},stopRecording:r=>{n().recorderActive&&(window.api.browser.recordStop(r).catch(()=>{}),i_(r),o_(),e({recorderActive:!1,recording:!1}))},toggleRecordingPause:()=>{n().recorderActive&&e(r=>({recording:!r.recording}))},toggleStepVariable:r=>{e(i=>({recorderSteps:i.recorderSteps.map(o=>o.n===r?{...o,variable:o.variable?null:o.variableSuggestion||"value"}:o)}))},bookmarks:[],bookmarksHydrated:!1,hydrateBookmarks:async()=>{if(!n().bookmarksHydrated)try{const r=await window.api.config.readJson(t_),i=r.exists&&Array.isArray(r.data)?r.data:[];e({bookmarks:i,bookmarksHydrated:!0})}catch{e({bookmarksHydrated:!0})}},toggleBookmark:r=>{const i=n().tabs.find(u=>u.id===r);if(!i||!i.url||i.url==="about:blank")return;const o=n().bookmarks,h=o.some(u=>u.url===i.url)?o.filter(u=>u.url!==i.url):[{url:i.url,title:i.title,ts:Date.now()},...o];e({bookmarks:h}),window.api.config.writeJson(t_,h).catch(()=>{})},historyEntries:[],refreshHistory:async()=>{try{const r=await window.api.config.readJson(AN),i=r.exists&&Array.isArray(r.data)?r.data:[];e({historyEntries:i})}catch{}},setZoom:(r,i)=>{const o=n().tabs.find(h=>h.id===r);if(!o)return;const l=Math.min(MN,Math.max(RN,i));e(h=>({tabs:h.tabs.map(u=>u.id===r?{...u,zoomFactor:l}:u)})),window.api.browser.setZoom({viewId:o.viewId,factor:l}).catch(()=>{})},zoomIn:r=>{const i=n().tabs.find(o=>o.id===r);i&&n().setZoom(r,i.zoomFactor+n_)},zoomOut:r=>{const i=n().tabs.find(o=>o.id===r);i&&n().setZoom(r,i.zoomFactor-n_)},zoomReset:r=>n().setZoom(r,1),findOpen:!1,findText:"",findMatches:null,openFind:r=>{const i=n().tabs.find(l=>l.id===r);if(!i)return;e({findOpen:!0,findText:"",findMatches:null}),jv(i.viewId);const o=window.api.browser.onFindResult(i.viewId,l=>{Mt.setState({findMatches:l})});Db.set(i.viewId,o)},closeFind:r=>{const i=n().tabs.find(o=>o.id===r);e({findOpen:!1,findText:"",findMatches:null}),i&&(jv(i.viewId),window.api.browser.stopFind(i.viewId).catch(()=>{}))},setFindText:(r,i)=>{const o=n().tabs.find(l=>l.id===r);if(e({findText:i}),!!o){if(!i){window.api.browser.find({viewId:o.viewId,text:""}).catch(()=>{});return}window.api.browser.find({viewId:o.viewId,text:i,forward:!0}).catch(()=>{})}},findNext:r=>{const i=n().tabs.find(l=>l.id===r),{findText:o}=n();!i||!o||window.api.browser.find({viewId:i.viewId,text:o,forward:!0}).catch(()=>{})},findPrev:r=>{const i=n().tabs.find(l=>l.id===r),{findText:o}=n();!i||!o||window.api.browser.find({viewId:i.viewId,text:o,forward:!1}).catch(()=>{})}})),ON=4,a_=40,l_=6;function LN(e){const{onReorder:n,onActivate:r}=e,i=L.useRef(null),o=L.useRef(null),l=L.useRef(0),h=L.useRef(0),[u,d]=L.useState(!1),[,m]=L.useState(0),x=L.useRef(r);x.current=r;const g=L.useCallback(()=>i.current?Array.from(i.current.querySelectorAll("[data-drag-index]")):[],[]),b=L.useCallback((y,v,_)=>{for(let j=0;j<v.length;j++){const T=v[j].left+v[j].width/2;if(y<T)return j<=_?j:j-1}return v.length-1},[]),S=L.useCallback(()=>{const y=o.current,v=i.current;if(!(y!=null&&y.active)||!v)return;const _=v.getBoundingClientRect(),j=y.startX+y.deltaX,T=j-_.left,A=_.right-j;T<a_?v.scrollLeft-=l_:A<a_&&(v.scrollLeft+=l_),l.current=requestAnimationFrame(S)},[]);L.useEffect(()=>{const y=i.current;if(!y)return;let v=!1;const _=()=>{v||(v=!0,h.current=requestAnimationFrame(()=>{v=!1,m(A=>A+1)}))},j=A=>{var U;const M=o.current;if(!M)return;const O=A.clientX-M.startX;if(!M.active&&Math.abs(O)<ON)return;if(!M.active){M.active=!0,M.tabRects=g().map(W=>W.getBoundingClientRect()),d(!0);try{(U=i.current)==null||U.setPointerCapture(M.pointerId)}catch{}l.current=requestAnimationFrame(S)}M.deltaX=O;const I=M.tabRects[M.fromIndex],z=I.left+I.width/2+O;M.currentIndex=b(z,M.tabRects,M.fromIndex),_()},T=A=>{const M=o.current;if(M&&M.pointerId===A.pointerId){cancelAnimationFrame(l.current),cancelAnimationFrame(h.current);try{y.releasePointerCapture(M.pointerId)}catch{}M.active&&M.fromIndex!==M.currentIndex?n(M.fromIndex,M.currentIndex):x.current(M.fromIndex),o.current=null,d(!1),m(O=>O+1)}};return y.addEventListener("pointermove",j),y.addEventListener("pointerup",T),y.addEventListener("pointercancel",T),()=>{y.removeEventListener("pointermove",j),y.removeEventListener("pointerup",T),y.removeEventListener("pointercancel",T),cancelAnimationFrame(l.current),cancelAnimationFrame(h.current)}},[n,g,b,S]);const E=L.useCallback((y,v)=>{y.button!==0||y.target.closest("button")||(o.current={active:!1,fromIndex:v,currentIndex:v,startX:y.clientX,deltaX:0,tabRects:[],pointerId:y.pointerId})},[]);return{getTabDragProps:L.useCallback(y=>{var j;const v=o.current,_={};if(v!=null&&v.active)if(y===v.fromIndex)_.transform=`translateX(${v.deltaX}px) scale(1.03)`,_.zIndex=10,_.opacity=.85,_.boxShadow="0 2px 8px rgba(0,0,0,0.4)",_.position="relative",_.pointerEvents="none";else{const T=v.fromIndex,A=v.currentIndex,O=(((j=v.tabRects[T])==null?void 0:j.width)??0)+4;_.transition="transform 0.15s ease",T<A&&y>T&&y<=A?_.transform=`translateX(-${O}px)`:T>A&&y>=A&&y<T?_.transform=`translateX(${O}px)`:_.transform="translateX(0)"}return{onPointerDown:T=>E(T,y),style:_,"data-drag-index":y}},[E]),isDragging:u,containerRef:i}}const zN=3e4;function BN({onToggleSplitView:e,splitViewActive:n}={}){const r=kt(v=>v.tabs),i=kt(v=>v.activeTabId),o=kt(v=>v.closeTab),l=kt(v=>v.setActive),h=kt(v=>v.reorderTab),u=jm(v=>v.watchers),d=Mt(v=>v.tabs.length>0),m=i!=null&&d,[x,g]=L.useState(()=>Date.now());L.useEffect(()=>{const v=window.setInterval(()=>g(Date.now()),1e3);return()=>window.clearInterval(v)},[]);const b=v=>{for(const _ of Object.values(u))if(_.tabId===v&&_.lastLineAt&&x-_.lastLineAt<zN)return!0;return!1},{getTabDragProps:S,isDragging:E,containerRef:C}=LN({tabCount:r.length,onReorder:h,onActivate:v=>{const _=r[v];_&&l(_.id)}}),y=["#6f7d52","#b85c34","#a39079","#7a8466","#5b4a36"];return s.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:[s.jsx("div",{ref:C,className:`flex items-end gap-0.5 overflow-x-auto min-w-0 flex-1 select-none ${E?"cursor-grabbing":""}`,children:r.map((v,_)=>{const j=v.id===i,T=S(_),A=y[_%y.length];return s.jsxs("div",{...T,style:T.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 ${E?"":"cursor-grab"} ${j?"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:v.cwd,"aria-current":j?"true":void 0,children:[s.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:A,boxShadow:"inset 0 0 0 0.5px rgba(0,0,0,0.15)",opacity:v.status==="spawning"?.55:1}}),s.jsx("span",{className:"truncate max-w-[200px]",children:v.label}),v.status==="spawning"&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-butter animate-pulse",title:"spawning"}),b(v.id)&&s.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"}),s.jsx("button",{onClick:M=>{M.stopPropagation(),o(v.id)},className:"text-fg-faint opacity-0 group-hover:opacity-100 hover:text-fg ml-1 leading-none",title:"Close session","aria-label":`Close ${v.label}`,children:"×"})]},v.id)})}),s.jsxs("div",{className:"flex items-center gap-2 pb-2 pl-3 text-[12px] text-fg-faint shrink-0",children:[m&&e&&s.jsxs("button",{onClick:e,className:`flex items-center gap-1 px-2 py-0.5 rounded text-[11px] border border-line hover:bg-bg-hi/40 ${n?"text-accent border-accent":"text-fg-faint hover:text-fg"}`,title:"Split view: agent terminal + browser","aria-pressed":n??!1,children:[s.jsx("span",{"aria-hidden":"true",children:"⇄"}),s.jsx("span",{children:"Split view"})]}),s.jsx("span",{className:"font-semibold text-fg-dim",children:"Claude Session Manager"}),s.jsxs("span",{className:"font-mono text-[11px] text-fg-faint",children:["v","0.37.1"]})]})]})}function FN(e,n,r){return n?e.map(i=>i.id===n?{...i,lastActivityAt:r}:i):e}function UN(e,n,r){return{tabId:e,sessionUuid:r,cwd:n,path:null,todos:[],lastToolUses:[],plans:[],agents:[],usage:{inputTokens:0,outputTokens:0},lastEventAt:0,activityRing:[],activitySeq:0}}const Vx=cr((e,n)=>({tabs:{},refs:{},unsubs:{},subscribe:(r,i,o)=>{const l={...n().refs};if(l[r]=(l[r]??0)+1,e({refs:l}),l[r]>1)return;e({tabs:{...n().tabs,[r]:UN(r,i,o)}});const h=window.api.transcripts.onEvent(r,u=>n().ingest(r,u));e({unsubs:{...n().unsubs,[r]:h}}),window.api.transcripts.subscribe({tabId:r,cwd:i,sessionUuid:o}).then(async u=>{const d=n().tabs[r];if(!d)return;if(!u.ok){const{toast:x}=await Gm(async()=>{const{toast:g}=await Promise.resolve().then(()=>b2);return{toast:g}},void 0,import.meta.url);x.error(`Live view unavailable: ${u.error??"subscribe failed"}`),e({tabs:{...n().tabs,[r]:{...d,path:null}}});return}e({tabs:{...n().tabs,[r]:{...d,path:u.path}}});const m=await window.api.transcripts.buffer(r);for(const x of m)n().ingest(r,x,{replay:!0})}).catch(u=>console.error("[live] transcripts.subscribe failed:",r,u))},unsubscribe:r=>{const i={...n().refs};if(!i[r])return;if(i[r]--,i[r]>0){e({refs:i});return}delete i[r];const o=n().unsubs[r];o==null||o();const l={...n().unsubs};delete l[r];const h={...n().tabs};delete h[r],window.api.transcripts.unsubscribe(r),e({refs:i,unsubs:l,tabs:h})},ingest:(r,i,o)=>{const l=n().tabs[r];if(!l)return;const h=Date.now(),u={...l,lastEventAt:o!=null&&o.replay?l.lastEventAt:h},d=[],m=(x,g)=>x.length>g?x.slice(0,g-1)+"…":x;switch(i.kind){case"todo_write":{const x=Array.isArray(i.data)?i.data:[];u.todos=x,o!=null&&o.replay||d.push({id:0,kind:"todo-update",at:h,label:`Todos · ${x.length} item${x.length!==1?"s":""}`});break}case"tool_use":{const x=i.data,g=x.input,b={};for(const S of["command","file_path","pattern","url","query","subagent_type","description"])g&&S in g&&(b[S]=g[S]);if(u.lastToolUses=[{id:x.id,name:x.name,input:b,at:h},...l.lastToolUses].slice(0,50),!(o!=null&&o.replay)){const S=x.input,E=["Edit","Write","NotebookEdit"].includes(x.name),C=typeof(S==null?void 0:S.file_path)=="string"?S.file_path:void 0,y=typeof(S==null?void 0:S.command)=="string"?S.command:void 0,v=C?C.split("/").pop()??C:y?m(y,28):"";d.push({id:0,kind:"tool-use",at:h,label:v?`${x.name} · ${v}`:x.name,target:C??y,toolName:x.name}),E&&C&&d.push({id:0,kind:"file-edit",at:h,label:`${x.name} · ${m(C.split("/").pop()??C,34)}`,target:C,toolName:x.name})}break}case"plan":{const x=i.data,g=typeof x=="string"?x:(x==null?void 0:x.plan)??JSON.stringify(x);u.plans=[{at:h,content:g??""},...l.plans].slice(0,50),o!=null&&o.replay||d.push({id:0,kind:"plan-revision",at:h,label:"Plan revised"});break}case"agent_spawn":{const x=i.data;u.agents=[{id:x==null?void 0:x.toolUseId,at:h,subagentType:x==null?void 0:x.subagent_type,description:x==null?void 0:x.description,lastActivityAt:h},...l.agents].slice(0,50),o!=null&&o.replay||d.push({id:0,kind:"agent-spawn",at:h,label:x!=null&&x.subagent_type?`Agent: ${m(x.subagent_type,32)}`:"Agent spawned"});break}case"usage":{const x=i.data,g=(l.usage.inputTokens||0)+(l.usage.outputTokens||0),b=x.input_tokens??x.inputTokens??0,S=x.output_tokens??x.outputTokens??0,E=g+b+S;u.usage={inputTokens:(l.usage.inputTokens||0)+b,outputTokens:(l.usage.outputTokens||0)+S,cacheCreationInputTokens:(l.usage.cacheCreationInputTokens||0)+(x.cache_creation_input_tokens??x.cacheCreationInputTokens??0),cacheReadInputTokens:(l.usage.cacheReadInputTokens||0)+(x.cache_read_input_tokens??x.cacheReadInputTokens??0)},!(o!=null&&o.replay)&&Math.floor(E/1e3)>Math.floor(g/1e3)&&d.push({id:0,kind:"usage-tick",at:h,label:`${Math.floor(E/1e3)}k tokens`});break}case"tool_result":{const x=i.data;u.agents=FN(l.agents,x==null?void 0:x.toolUseId,h);break}}if(d.length>0){let x=l.activitySeq;const g=d.map(b=>({...b,id:++x}));u.activitySeq=x,u.activityRing=[...l.activityRing,...g].slice(-32)}e({tabs:{...n().tabs,[r]:u}})}}));function w2(e){const n=Vx(o=>o.subscribe),r=Vx(o=>o.unsubscribe),i=Vx(o=>e?o.tabs[e.id]:void 0);return L.useEffect(()=>{if(e)return n(e.id,e.cwd,e.claudeSessionId),()=>r(e.id)},[e==null?void 0:e.id,e==null?void 0:e.cwd,e==null?void 0:e.claudeSessionId,n,r]),i}var Ev={},Bp={},c_;function _2(){if(c_)return Bp;c_=1,Object.defineProperty(Bp,"__esModule",{value:!0}),Bp.baseAssetPath=void 0;const n=typeof window<"u"&&typeof window.document<"u"?window.document.currentScript:null;let r="/";return n&&(r=n.src.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^/]+$/,"/")),Bp.baseAssetPath=r,Bp}var Fp={},u_;function Uw(){if(u_)return Fp;u_=1,Object.defineProperty(Fp,"__esModule",{value:!0}),Fp.defaultModelFetcher=void 0;const e=n=>fetch(n).then(r=>r.arrayBuffer());return Fp.defaultModelFetcher=e,Fp}var Za={},Up={},d_;function Km(){if(d_)return Up;d_=1,Object.defineProperty(Up,"__esModule",{value:!0}),Up.log=void 0;const e=n=>r=>{console.log(`VAD | ${n} >`,r)};return Up.log={error:e("error"),debug:e("debug"),warn:e("warn")},Up}var Hp={},h_;function Vy(){if(h_)return Hp;h_=1,Object.defineProperty(Hp,"__esModule",{value:!0}),Hp.Message=void 0;var e;return(function(n){n.AudioFrame="AUDIO_FRAME",n.SpeechStart="SPEECH_START",n.VADMisfire="VAD_MISFIRE",n.SpeechEnd="SPEECH_END",n.SpeechStop="SPEECH_STOP",n.SpeechRealStart="SPEECH_REAL_START",n.FrameProcessed="FRAME_PROCESSED"})(e||(Hp.Message=e={})),Hp}var f_;function Hw(){if(f_)return Za;f_=1,Object.defineProperty(Za,"__esModule",{value:!0}),Za.FrameProcessor=Za.validateOptions=Za.defaultFrameProcessorOptions=void 0;const e=Km(),n=Vy();Za.defaultFrameProcessorOptions={positiveSpeechThreshold:.3,negativeSpeechThreshold:.25,preSpeechPadMs:800,redemptionMs:1400,minSpeechMs:400,submitUserSpeechOnPause:!1};function r(h){(h.positiveSpeechThreshold<0||h.positiveSpeechThreshold>1)&&e.log.error("positiveSpeechThreshold should be a number between 0 and 1"),(h.negativeSpeechThreshold<0||h.negativeSpeechThreshold>h.positiveSpeechThreshold)&&e.log.error("negativeSpeechThreshold should be between 0 and positiveSpeechThreshold"),h.preSpeechPadMs<0&&e.log.error("preSpeechPadMs should be positive"),h.redemptionMs<0&&e.log.error("redemptionMs should be positive"),h.minSpeechMs<0&&e.log.error("minSpeechMs should be positive")}Za.validateOptions=r;const i=h=>{const u=h.reduce((m,x)=>(m.push(m.at(-1)+x.length),m),[0]),d=new Float32Array(u.at(-1));return h.forEach((m,x)=>{const g=u[x];d.set(m,g)}),d};function o(h,u){const d=Math.floor(h.redemptionMs/u),m=Math.floor(h.preSpeechPadMs/u),x=Math.floor(h.minSpeechMs/u);return{redemptionFrames:d,preSpeechPadFrames:m,minSpeechFrames:x}}class l{constructor(u,d,m,x){this.modelProcessFunc=u,this.modelResetFunc=d,this.options=m,this.msPerFrame=x,this.speaking=!1,this.redemptionCounter=0,this.speechFrameCount=0,this.active=!1,this.speechRealStartFired=!1,this.setOptions=E=>{this.options={...this.options,...E};const{redemptionFrames:C,preSpeechPadFrames:y,minSpeechFrames:v}=o(this.options,this.msPerFrame);this.redemptionFrames=C,this.preSpeechPadFrames=y,this.minSpeechFrames=v},this.reset=()=>{this.speaking=!1,this.speechRealStartFired=!1,this.audioBuffer=[],this.modelResetFunc(),this.redemptionCounter=0,this.speechFrameCount=0},this.pause=E=>{this.active=!1,this.options.submitUserSpeechOnPause?this.endSegment(E):this.reset()},this.resume=()=>{this.active=!0},this.endSegment=E=>{const C=this.audioBuffer;this.audioBuffer=[];const y=this.speaking;if(this.reset(),y)if(C.reduce((_,j)=>j.isSpeech?_+1:_,0)>=this.minSpeechFrames){const _=i(C.map(j=>j.frame));E({msg:n.Message.SpeechEnd,audio:_})}else E({msg:n.Message.VADMisfire});return{}},this.process=async(E,C)=>{if(!this.active)return;const y=await this.modelProcessFunc(E),v=y.isSpeech>=this.options.positiveSpeechThreshold;if(C({probs:y,msg:n.Message.FrameProcessed,frame:E}),this.audioBuffer.push({frame:E,isSpeech:v}),v&&(this.speechFrameCount++,this.redemptionCounter=0),v&&!this.speaking&&(this.speaking=!0,C({msg:n.Message.SpeechStart})),this.speaking&&this.speechFrameCount===this.minSpeechFrames&&!this.speechRealStartFired&&(this.speechRealStartFired=!0,C({msg:n.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 _=this.audioBuffer;if(this.audioBuffer=[],_.reduce((T,A)=>A.isSpeech?T+1:T,0)>=this.minSpeechFrames){const T=i(_.map(A=>A.frame));C({msg:n.Message.SpeechEnd,audio:T})}else C({msg:n.Message.VADMisfire})}if(!this.speaking){for(;this.audioBuffer.length>this.preSpeechPadFrames;)this.audioBuffer.shift();this.speechFrameCount=0}},this.audioBuffer=[];const{redemptionFrames:g,preSpeechPadFrames:b,minSpeechFrames:S}=o(this.options,this.msPerFrame);this.redemptionFrames=g,this.preSpeechPadFrames=b,this.minSpeechFrames=S,this.reset()}}return Za.FrameProcessor=l,Za}var el={};function io(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 Nv={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 @@ ${P}`,B=w.createShaderModule({code:D,label:a.name});on("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 __;function XN(){return __||(__=1,(function(e,n){var r=(()=>{var i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,h=Object.prototype.hasOwnProperty,u=(re=>typeof io<"u"?io:typeof Proxy<"u"?new Proxy(re,{get:(he,ve)=>(typeof io<"u"?io:he)[ve]}):re)(function(re){if(typeof io<"u")return io.apply(this,arguments);throw Error('Dynamic require of "'+re+'" is not supported')}),d=(re,he)=>()=>(re&&(he=re(re=0)),he),m=(re,he)=>{for(var ve in he)i(re,ve,{get:he[ve],enumerable:!0})},x=(re,he,ve,Te)=>{if(he&&typeof he=="object"||typeof he=="function")for(let Se of l(he))!h.call(re,Se)&&Se!==ve&&i(re,Se,{get:()=>he[Se],enumerable:!(Te=o(he,Se))||Te.enumerable});return re},g=re=>x(i({},"__esModule",{value:!0}),re),b,S,E,C,y,v=d(()=>{b=new Map,S=[],E=(re,he,ve)=>{if(he&&typeof he.init=="function"&&typeof he.createInferenceSessionHandler=="function"){let Te=b.get(re);if(Te===void 0)b.set(re,{backend:he,priority:ve});else{if(Te.priority>ve)return;if(Te.priority===ve&&Te.backend!==he)throw new Error(`cannot register backend "${re}" using priority ${ve}`)}if(ve>=0){let Se=S.indexOf(re);Se!==-1&&S.splice(Se,1);for(let Be=0;Be<S.length;Be++)if(b.get(S[Be]).priority<=ve){S.splice(Be,0,re);return}S.push(re)}return}throw new TypeError("not a valid backend")},C=async re=>{let he=b.get(re);if(!he)return"backend not found.";if(he.initialized)return he.backend;if(he.aborted)return he.error;{let ve=!!he.initPromise;try{return ve||(he.initPromise=he.backend.init(re)),await he.initPromise,he.initialized=!0,he.backend}catch(Te){return ve||(he.error=`${Te}`,he.aborted=!0),he.error}finally{delete he.initPromise}}},y=async re=>{let he=re.executionProviders||[],ve=he.map(Fe=>typeof Fe=="string"?Fe:Fe.name),Te=ve.length===0?S:ve,Se,Be=[],Ae=new Set;for(let Fe of Te){let et=await C(Fe);typeof et=="string"?Be.push({name:Fe,err:et}):(Se||(Se=et),Se===et&&Ae.add(Fe))}if(!Se)throw new Error(`no available backend found. ERR: ${Be.map(Fe=>`[${Fe.name}] ${Fe.err}`).join(", ")}`);for(let{name:Fe,err:et}of Be)ve.includes(Fe)&&console.warn(`removing requested execution provider "${Fe}" from session options because it is not available: ${et}`);let Re=he.filter(Fe=>Ae.has(typeof Fe=="string"?Fe:Fe.name));return[Se,new Proxy(re,{get:(Fe,et)=>et==="executionProviders"?Re:Reflect.get(Fe,et)})]}}),_=d(()=>{v()}),j,T=d(()=>{j="1.26.0"}),A,M,O=d(()=>{T(),A="warning",M={wasm:{},webgl:{},webgpu:{},versions:{common:j},set logLevel(re){if(re!==void 0){if(typeof re!="string"||["verbose","info","warning","error","fatal"].indexOf(re)===-1)throw new Error(`Unsupported logging level: ${re}`);A=re}},get logLevel(){return A}},Object.defineProperty(M,"logLevel",{enumerable:!0})}),I,z=d(()=>{O(),I=M}),U,W,Y=d(()=>{U=(re,he)=>{let ve=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);ve.width=re.dims[3],ve.height=re.dims[2];let Te=ve.getContext("2d");if(Te!=null){let Se,Be;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(Se=re.dims[2],Be=re.dims[3]):(Se=re.dims[3],Be=re.dims[2]);let Ae=(he==null?void 0:he.format)!==void 0?he.format:"RGB",Re=he==null?void 0:he.norm,Fe,et;Re===void 0||Re.mean===void 0?Fe=[255,255,255,255]:typeof Re.mean=="number"?Fe=[Re.mean,Re.mean,Re.mean,Re.mean]:(Fe=[Re.mean[0],Re.mean[1],Re.mean[2],0],Re.mean[3]!==void 0&&(Fe[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 it=Be*Se,tt=0,Xe=it,$t=it*2,Le=-1;Ae==="RGBA"?(tt=0,Xe=it,$t=it*2,Le=it*3):Ae==="RGB"?(tt=0,Xe=it,$t=it*2):Ae==="RBG"&&(tt=0,$t=it,Xe=it*2);for(let ut=0;ut<Be;ut++)for(let Cn=0;Cn<Se;Cn++){let Jt=(re.data[tt++]-et[0])*Fe[0],Qt=(re.data[Xe++]-et[1])*Fe[1],jn=(re.data[$t++]-et[2])*Fe[2],Ot=Le===-1?255:(re.data[Le++]-et[3])*Fe[3];Te.fillStyle="rgba("+Jt+","+Qt+","+jn+","+Ot+")",Te.fillRect(Cn,ut,1,1)}if("toDataURL"in ve)return ve.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},W=(re,he)=>{let ve=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Te;if(ve!=null){let Se,Be,Ae;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(Se=re.dims[2],Be=re.dims[1],Ae=re.dims[3]):(Se=re.dims[3],Be=re.dims[2],Ae=re.dims[1]);let Re=he!==void 0&&he.format!==void 0?he.format:"RGB",Fe=he==null?void 0:he.norm,et,it;Fe===void 0||Fe.mean===void 0?et=[255,255,255,255]:typeof Fe.mean=="number"?et=[Fe.mean,Fe.mean,Fe.mean,Fe.mean]:(et=[Fe.mean[0],Fe.mean[1],Fe.mean[2],255],Fe.mean[3]!==void 0&&(et[3]=Fe.mean[3])),Fe===void 0||Fe.bias===void 0?it=[0,0,0,0]:typeof Fe.bias=="number"?it=[Fe.bias,Fe.bias,Fe.bias,Fe.bias]:(it=[Fe.bias[0],Fe.bias[1],Fe.bias[2],0],Fe.bias[3]!==void 0&&(it[3]=Fe.bias[3]));let tt=Be*Se;if(he!==void 0&&(he.format!==void 0&&Ae===4&&he.format!=="RGBA"||Ae===3&&he.format!=="RGB"&&he.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Xe=4,$t=0,Le=1,ut=2,Cn=3,Jt=0,Qt=tt,jn=tt*2,Ot=-1;Re==="RGBA"?(Jt=0,Qt=tt,jn=tt*2,Ot=tt*3):Re==="RGB"?(Jt=0,Qt=tt,jn=tt*2):Re==="RBG"&&(Jt=0,jn=tt,Qt=tt*2),Te=ve.createImageData(Se,Be);for(let Mn=0;Mn<Be*Se;$t+=Xe,Le+=Xe,ut+=Xe,Cn+=Xe,Mn++)Te.data[$t]=(re.data[Jt++]-it[0])*et[0],Te.data[Le]=(re.data[Qt++]-it[1])*et[1],Te.data[ut]=(re.data[jn++]-it[2])*et[2],Te.data[Cn]=Ot===-1?255:(re.data[Ot++]-it[3])*et[3]}else throw new Error("Can not access image data");return Te}}),V,H,te,oe,pe,ie,X=d(()=>{we(),V=(re,he)=>{if(re===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:ve,width:Te}=he,Se=he.norm??{mean:255,bias:0},Be,Ae;typeof Se.mean=="number"?Be=[Se.mean,Se.mean,Se.mean,Se.mean]:Be=[Se.mean[0],Se.mean[1],Se.mean[2],Se.mean[3]??255],typeof Se.bias=="number"?Ae=[Se.bias,Se.bias,Se.bias,Se.bias]:Ae=[Se.bias[0],Se.bias[1],Se.bias[2],Se.bias[3]??0];let Re=he.format!==void 0?he.format:"RGBA",Fe=he.tensorFormat!==void 0&&he.tensorFormat!==void 0?he.tensorFormat:"RGB",et=ve*Te,it=Fe==="RGBA"?new Float32Array(et*4):new Float32Array(et*3),tt=4,Xe=0,$t=1,Le=2,ut=3,Cn=0,Jt=et,Qt=et*2,jn=-1;Re==="RGB"&&(tt=3,Xe=0,$t=1,Le=2,ut=-1),Fe==="RGBA"?jn=et*3:Fe==="RBG"?(Cn=0,Qt=et,Jt=et*2):Fe==="BGR"&&(Qt=0,Jt=et,Cn=et*2);for(let Ot=0;Ot<et;Ot++,Xe+=tt,Le+=tt,$t+=tt,ut+=tt)it[Cn++]=(re[Xe]+Ae[0])/Be[0],it[Jt++]=(re[$t]+Ae[1])/Be[1],it[Qt++]=(re[Le]+Ae[2])/Be[2],jn!==-1&&ut!==-1&&(it[jn++]=(re[ut]+Ae[3])/Be[3]);return Fe==="RGBA"?new ne("float32",it,[1,4,ve,Te]):new ne("float32",it,[1,3,ve,Te])},H=async(re,he)=>{let ve=typeof HTMLImageElement<"u"&&re instanceof HTMLImageElement,Te=typeof ImageData<"u"&&re instanceof ImageData,Se=typeof ImageBitmap<"u"&&re instanceof ImageBitmap,Be=typeof re=="string",Ae,Re=he??{},Fe=()=>{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=it=>typeof HTMLCanvasElement<"u"&&it instanceof HTMLCanvasElement||it instanceof OffscreenCanvas?it.getContext("2d"):null;if(ve){let it=Fe();it.width=re.width,it.height=re.height;let tt=et(it);if(tt!=null){let Xe=re.height,$t=re.width;if(he!==void 0&&he.resizedHeight!==void 0&&he.resizedWidth!==void 0&&(Xe=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=Xe,Re.width=$t}else Re.tensorFormat="RGBA",Re.height=Xe,Re.width=$t;tt.drawImage(re,0,0),Ae=tt.getImageData(0,0,$t,Xe).data}else throw new Error("Can not access image data")}else if(Te){let it,tt;if(he!==void 0&&he.resizedWidth!==void 0&&he.resizedHeight!==void 0?(it=he.resizedHeight,tt=he.resizedWidth):(it=re.height,tt=re.width),he!==void 0&&(Re=he),Re.format="RGBA",Re.height=it,Re.width=tt,he!==void 0){let Xe=Fe();Xe.width=tt,Xe.height=it;let $t=et(Xe);if($t!=null)$t.putImageData(re,0,0),Ae=$t.getImageData(0,0,tt,it).data;else throw new Error("Can not access image data")}else Ae=re.data}else if(Se){if(he===void 0)throw new Error("Please provide image config with format for Imagebitmap");let it=Fe();it.width=re.width,it.height=re.height;let tt=et(it);if(tt!=null){let Xe=re.height,$t=re.width;return tt.drawImage(re,0,0,$t,Xe),Ae=tt.getImageData(0,0,$t,Xe).data,Re.height=Xe,Re.width=$t,V(Ae,Re)}else throw new Error("Can not access image data")}else{if(Be)return new Promise((it,tt)=>{let Xe=Fe(),$t=et(Xe);if(!re||!$t)return tt();let Le=new Image;Le.crossOrigin="Anonymous",Le.src=re,Le.onload=()=>{Xe.width=Le.width,Xe.height=Le.height,$t.drawImage(Le,0,0,Xe.width,Xe.height);let ut=$t.getImageData(0,0,Xe.width,Xe.height);Re.height=Xe.height,Re.width=Xe.width,it(V(ut.data,Re))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Ae!==void 0)return V(Ae,Re);throw new Error("Input data provided is not supported - aborted tensor creation")},te=(re,he)=>{let{width:ve,height:Te,download:Se,dispose:Be}=he,Ae=[1,Te,ve,4];return new ne({location:"texture",type:"float32",texture:re,dims:Ae,download:Se,dispose:Be})},oe=(re,he)=>{let{dataType:ve,dims:Te,download:Se,dispose:Be}=he;return new ne({location:"gpu-buffer",type:ve??"float32",gpuBuffer:re,dims:Te,download:Se,dispose:Be})},pe=(re,he)=>{let{dataType:ve,dims:Te,download:Se,dispose:Be}=he;return new ne({location:"ml-tensor",type:ve??"float32",mlTensor:re,dims:Te,download:Se,dispose:Be})},ie=(re,he,ve)=>new ne({location:"cpu-pinned",type:re,data:he,dims:ve??[he.length]})}),Q,J,ae,le,fe=d(()=>{Q=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),J=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ae=!1,le=()=>{if(!ae){ae=!0;let re=typeof BigInt64Array<"u"&&BigInt64Array.from,he=typeof BigUint64Array<"u"&&BigUint64Array.from,ve=globalThis.Float16Array,Te=typeof ve<"u"&&ve.from;re&&(Q.set("int64",BigInt64Array),J.set(BigInt64Array,"int64")),he&&(Q.set("uint64",BigUint64Array),J.set(BigUint64Array,"uint64")),Te?(Q.set("float16",ve),J.set(ve,"float16")):Q.set("float16",Uint16Array)}}}),Me,je,ye=d(()=>{we(),Me=re=>{let he=1;for(let ve=0;ve<re.length;ve++){let Te=re[ve];if(typeof Te!="number"||!Number.isSafeInteger(Te))throw new TypeError(`dims[${ve}] must be an integer, got: ${Te}`);if(Te<0)throw new RangeError(`dims[${ve}] must be a non-negative integer, got: ${Te}`);he*=Te}return he},je=(re,he)=>{switch(re.location){case"cpu":return new ne(re.type,re.data,he);case"cpu-pinned":return new ne({location:"cpu-pinned",data:re.data,type:re.type,dims:he});case"texture":return new ne({location:"texture",texture:re.texture,type:re.type,dims:he});case"gpu-buffer":return new ne({location:"gpu-buffer",gpuBuffer:re.gpuBuffer,type:re.type,dims:he});case"ml-tensor":return new ne({location:"ml-tensor",mlTensor:re.mlTensor,type:re.type,dims:he});default:throw new Error(`tensorReshape: tensor location ${re.location} is not supported`)}}}),ne,we=d(()=>{Y(),X(),fe(),ye(),ne=class{constructor(re,he,ve){le();let Te,Se;if(typeof re=="object"&&"location"in re)switch(this.dataLocation=re.location,Te=re.type,Se=re.dims,re.location){case"cpu-pinned":{let Ae=Q.get(Te);if(!Ae)throw new TypeError(`unsupported type "${Te}" to create tensor from pinned buffer`);if(!(re.data instanceof Ae))throw new TypeError(`buffer should be of type ${Ae.name}`);this.cpuData=re.data;break}case"texture":{if(Te!=="float32")throw new TypeError(`unsupported type "${Te}" to create tensor from texture`);this.gpuTextureData=re.texture,this.downloader=re.download,this.disposer=re.dispose;break}case"gpu-buffer":{if(Te!=="float32"&&Te!=="float16"&&Te!=="int32"&&Te!=="int64"&&Te!=="uint32"&&Te!=="uint8"&&Te!=="bool"&&Te!=="uint4"&&Te!=="int4")throw new TypeError(`unsupported type "${Te}" to create tensor from gpu buffer`);this.gpuBufferData=re.gpuBuffer,this.downloader=re.download,this.disposer=re.dispose;break}case"ml-tensor":{if(Te!=="float32"&&Te!=="float16"&&Te!=="int32"&&Te!=="int64"&&Te!=="uint32"&&Te!=="uint64"&&Te!=="int8"&&Te!=="uint8"&&Te!=="bool"&&Te!=="uint4"&&Te!=="int4")throw new TypeError(`unsupported type "${Te}" to create tensor from MLTensor`);this.mlTensorData=re.mlTensor,this.downloader=re.download,this.disposer=re.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Ae,Re;if(typeof re=="string")if(Te=re,Re=ve,re==="string"){if(!Array.isArray(he))throw new TypeError("A string tensor's data must be a string array.");Ae=he}else{let Fe=Q.get(re);if(Fe===void 0)throw new TypeError(`Unsupported tensor type: ${re}.`);if(Array.isArray(he)){if(re==="float16"&&Fe===Uint16Array||re==="uint4"||re==="int4")throw new TypeError(`Creating a ${re} tensor from number array is not supported. Please use ${Fe.name} as data.`);re==="uint64"||re==="int64"?Ae=Fe.from(he,BigInt):Ae=Fe.from(he)}else if(he instanceof Fe)Ae=he;else if(he instanceof Uint8ClampedArray)if(re==="uint8")Ae=Uint8Array.from(he);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(re==="float16"&&he instanceof Uint16Array&&Fe!==Uint16Array)Ae=new globalThis.Float16Array(he.buffer,he.byteOffset,he.length);else throw new TypeError(`A ${Te} tensor's data must be type of ${Fe}`)}else if(Re=he,Array.isArray(re)){if(re.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Fe=typeof re[0];if(Fe==="string")Te="string",Ae=re;else if(Fe==="boolean")Te="bool",Ae=Uint8Array.from(re);else throw new TypeError(`Invalid element type of data array: ${Fe}.`)}else if(re instanceof Uint8ClampedArray)Te="uint8",Ae=Uint8Array.from(re);else{let Fe=J.get(re.constructor);if(Fe===void 0)throw new TypeError(`Unsupported type for tensor data: ${re.constructor}.`);Te=Fe,Ae=re}if(Re===void 0)Re=[Ae.length];else if(!Array.isArray(Re))throw new TypeError("A tensor's dims must be a number array");Se=Re,this.cpuData=Ae,this.dataLocation="cpu"}let Be=Me(Se);if(this.cpuData&&Be!==this.cpuData.length&&!((Te==="uint4"||Te==="int4")&&Math.ceil(Be/2)===this.cpuData.length))throw new Error(`Tensor's size(${Be}) does not match data length(${this.cpuData.length}).`);this.type=Te,this.dims=Se,this.size=Be}static async fromImage(re,he){return H(re,he)}static fromTexture(re,he){return te(re,he)}static fromGpuBuffer(re,he){return oe(re,he)}static fromMLTensor(re,he){return pe(re,he)}static fromPinnedBuffer(re,he,ve){return ie(re,he,ve)}toDataURL(re){return U(this,re)}toImageData(re){return W(this,re)}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(re){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,re&&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(re){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return je(this,re)}}}),Ne,Je=d(()=>{we(),Ne=ne}),lt,xt,At,He,vt,st,an=d(()=>{O(),lt=(re,he)=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||console.timeStamp(`${re}::ORT::${he}`)},xt=(re,he)=>{var Se;let ve=((Se=new Error().stack)==null?void 0:Se.split(/\r\n|\r|\n/g))||[],Te=!1;for(let Be=0;Be<ve.length;Be++){if(Te&&!ve[Be].includes("TRACE_FUNC")){let Ae=`FUNC_${re}::${ve[Be].trim().split(" ")[1]}`;he&&(Ae+=`::${he}`),lt("CPU",Ae);return}ve[Be].includes("TRACE_FUNC")&&(Te=!0)}},At=re=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||xt("BEGIN",re)},He=re=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||xt("END",re)},vt=re=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||console.time(`ORT::${re}`)},st=re=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||console.timeEnd(`ORT::${re}`)}}),sn,Ye=d(()=>{v(),Je(),an(),sn=class E2{constructor(he){this.handler=he}async run(he,ve,Te){At(),vt("InferenceSession.run");let Se={},Be={};if(typeof he!="object"||he===null||he instanceof Ne||Array.isArray(he))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Ae=!0;if(typeof ve=="object"){if(ve===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(ve instanceof Ne)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(ve)){if(ve.length===0)throw new TypeError("'fetches' cannot be an empty array.");Ae=!1;for(let et of ve){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}.`);Se[et]=null}if(typeof Te=="object"&&Te!==null)Be=Te;else if(typeof Te<"u")throw new TypeError("'options' must be an object.")}else{let et=!1,it=Object.getOwnPropertyNames(ve);for(let tt of this.outputNames)if(it.indexOf(tt)!==-1){let Xe=ve[tt];(Xe===null||Xe instanceof Ne)&&(et=!0,Ae=!1,Se[tt]=Xe)}if(et){if(typeof Te=="object"&&Te!==null)Be=Te;else if(typeof Te<"u")throw new TypeError("'options' must be an object.")}else Be=ve}}else if(typeof ve<"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(Ae)for(let et of this.outputNames)Se[et]=null;let Re=await this.handler.run(he,Se,Be),Fe={};for(let et in Re)if(Object.hasOwnProperty.call(Re,et)){let it=Re[et];it instanceof Ne?Fe[et]=it:Fe[et]=new Ne(it.type,it.data,it.dims)}return st("InferenceSession.run"),He(),Fe}async release(){return this.handler.dispose()}static async create(he,ve,Te,Se){At(),vt("InferenceSession.create");let Be,Ae={};if(typeof he=="string"){if(Be=he,typeof ve=="object"&&ve!==null)Ae=ve;else if(typeof ve<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof Uint8Array){if(Be=he,typeof ve=="object"&&ve!==null)Ae=ve;else if(typeof ve<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&he instanceof SharedArrayBuffer){let it=he,tt=0,Xe=he.byteLength;if(typeof ve=="object"&&ve!==null)Ae=ve;else if(typeof ve=="number"){if(tt=ve,!Number.isSafeInteger(tt))throw new RangeError("'byteOffset' must be an integer.");if(tt<0||tt>=it.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${it.byteLength}).`);if(Xe=he.byteLength-tt,typeof Te=="number"){if(Xe=Te,!Number.isSafeInteger(Xe))throw new RangeError("'byteLength' must be an integer.");if(Xe<=0||tt+Xe>it.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${it.byteLength-tt}].`);if(typeof Se=="object"&&Se!==null)Ae=Se;else if(typeof Se<"u")throw new TypeError("'options' must be an object.")}else if(typeof Te<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof ve<"u")throw new TypeError("'options' must be an object.");Be=new Uint8Array(it,tt,Xe)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[Re,Fe]=await y(Ae),et=await Re.createInferenceSessionHandler(Be,Fe);return st("InferenceSession.create"),He(),new E2(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}}}),yt,_t=d(()=>{Ye(),yt=sn}),Kt=d(()=>{}),On=d(()=>{}),Rn=d(()=>{}),Br=d(()=>{}),Tr={};m(Tr,{InferenceSession:()=>yt,TRACE:()=>lt,TRACE_EVENT_BEGIN:()=>vt,TRACE_EVENT_END:()=>st,TRACE_FUNC_BEGIN:()=>At,TRACE_FUNC_END:()=>He,Tensor:()=>Ne,env:()=>I,registerBackend:()=>E});var rt=d(()=>{_(),z(),_t(),Je(),Kt(),On(),an(),Rn(),Br()}),St=d(()=>{}),Rt={};m(Rt,{default:()=>$r});var cn,nn,$r,Ea=d(()=>{var re;be(),Hr(),Ur(),cn="ort-wasm-proxy-worker",nn=((re=globalThis.self)==null?void 0:re.name)===cn,nn&&(self.onmessage=he=>{let{type:ve,in:Te}=he.data;try{switch(ve){case"init-wasm":ei(Te.wasm).then(()=>{Vo(Te).then(()=>{postMessage({type:ve})},Se=>{postMessage({type:ve,err:Se})})},Se=>{postMessage({type:ve,err:Se})});break;case"init-ep":{let{epName:Se,env:Be}=Te;Si(Be,Se).then(()=>{postMessage({type:ve})},Ae=>{postMessage({type:ve,err:Ae})});break}case"copy-from":{let{buffer:Se}=Te,Be=on(Se);postMessage({type:ve,out:Be});break}case"create":{let{model:Se,options:Be}=Te;ds(Se,Be).then(Ae=>{postMessage({type:ve,out:Ae})},Ae=>{postMessage({type:ve,err:Ae})});break}case"release":Hi(Te),postMessage({type:ve});break;case"run":{let{sessionId:Se,inputIndices:Be,inputs:Ae,outputIndices:Re,options:Fe}=Te;Ke(Se,Be,Ae,Re,new Array(Re.length).fill(null),Fe).then(et=>{et.some(it=>it[3]!=="cpu")?postMessage({type:ve,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:ve,out:et},ft([...Ae,...et]))},et=>{postMessage({type:ve,err:et})});break}case"end-profiling":qr(Te),postMessage({type:ve});break;default:}}catch(Se){postMessage({type:ve,err:Se})}}),$r=nn?null:he=>new Worker(he??yn,{type:"classic",name:cn})}),Wo,yi,yn,Fr,Zn,vi,Ms,as,Bi,bi,wi,Is,Ar,Ur=d(()=>{St(),Wo=typeof location>"u"?void 0:location.origin,yi=()=>{var re,he;return typeof document<"u"?(re=document.currentScript)==null?void 0:re.src:typeof self<"u"?(he=self.location)==null?void 0:he.href:void 0},yn=yi(),Fr=()=>{if(yn&&!yn.startsWith("blob:"))return yn.substring(0,yn.lastIndexOf("/")+1)},Zn=(re,he)=>{try{let ve=he??yn;return(ve?new URL(re,ve):new URL(re)).origin===Wo}catch{return!1}},vi=(re,he)=>{let ve=he??yn;try{return(ve?new URL(re,ve):new URL(re)).href}catch{return}},Ms=(re,he)=>`${he??"./"}${re}`,as=async re=>{let he=await(await fetch(re,{credentials:"same-origin"})).blob();return URL.createObjectURL(he)},Bi=async re=>(await import(re)).default,bi=(Ea(),g(Rt)).default,wi=async()=>{if(!yn)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Zn(yn))return[void 0,bi()];let re=await as(yn);return[re,bi(re)]},Is=void 0,Ar=async(re,he,ve,Te)=>{let Se=Is&&!(re||he);if(Se)if(yn)Se=Zn(yn)||Te&&!ve;else if(Te&&!ve)Se=!0;else throw new Error("cannot determine the script source URL.");if(Se)return[void 0,Is];{let Be="ort-wasm-simd-threaded.mjs",Ae=re??vi(Be,he),Re=ve&&Ae&&!Zn(Ae,he),Fe=Re?await as(Ae):Ae??Ms(Be,he);return[Re?Fe:void 0,await Bi(Fe)]}}}),Js,Rr,ls,js,uo,Qs,Zs,ei,zt,Hr=d(()=>{Ur(),Rr=!1,ls=!1,js=!1,uo=()=>{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}},Qs=()=>{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}},Zs=()=>{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}},ei=async re=>{if(Rr)return Promise.resolve();if(ls)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(js)throw new Error("previous call to 'initializeWebAssembly()' failed.");ls=!0;let he=re.initTimeout,ve=re.numThreads;if(re.simd!==!1){if(re.simd==="relaxed"){if(!Zs())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!Qs())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Te=uo();ve>1&&!Te&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+ve+", 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."),re.numThreads=ve=1);let Se=re.wasmPaths,Be=typeof Se=="string"?Se:void 0,Ae=Se==null?void 0:Se.mjs,Re=(Ae==null?void 0:Ae.href)??Ae,Fe=Se==null?void 0:Se.wasm,et=(Fe==null?void 0:Fe.href)??Fe,it=re.wasmBinary,[tt,Xe]=await Ar(Re,Be,ve>1,!!it||!!et),$t=!1,Le=[];if(he>0&&Le.push(new Promise(ut=>{setTimeout(()=>{$t=!0,ut()},he)})),Le.push(new Promise((ut,Cn)=>{let Jt={numThreads:ve};if(it)Jt.wasmBinary=it,Jt.locateFile=Qt=>Qt;else if(et||Be)Jt.locateFile=Qt=>et??Be+Qt;else if(Re&&Re.indexOf("blob:")!==0)Jt.locateFile=Qt=>new URL(Qt,Re).href;else if(tt){let Qt=Fr();Qt&&(Jt.locateFile=jn=>Qt+jn)}Xe(Jt).then(Qt=>{ls=!1,Rr=!0,Js=Qt,ut(),tt&&URL.revokeObjectURL(tt)},Qt=>{ls=!1,js=!0,Cn(Qt)})})),await Promise.race(Le),$t)throw new Error(`WebAssembly backend initializing failed due to timeout: ${he}ms`)},zt=()=>{if(Rr&&Js)return Js;throw new Error("WebAssembly is not initialized yet.")}}),Hn,_n,Ct,Fi=d(()=>{Hr(),Hn=(re,he)=>{let ve=zt(),Te=ve.lengthBytesUTF8(re)+1,Se=ve._malloc(Te);return ve.stringToUTF8(re,Se,Te),he.push(Se),Se},_n=(re,he,ve,Te)=>{if(typeof re=="object"&&re!==null){if(ve.has(re))throw new Error("Circular reference in options");ve.add(re)}Object.entries(re).forEach(([Se,Be])=>{let Ae=he?he+Se:Se;if(typeof Be=="object")_n(Be,Ae+".",ve,Te);else if(typeof Be=="string"||typeof Be=="number")Te(Ae,Be.toString());else if(typeof Be=="boolean")Te(Ae,Be?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof Be}`)})},Ct=re=>{let he=zt(),ve=he.stackSave();try{let Te=he.PTR_SIZE,Se=he.stackAlloc(2*Te);he._OrtGetLastError(Se,Se+Te);let Be=Number(he.getValue(Se,Te===4?"i32":"i64")),Ae=he.getValue(Se+Te,"*"),Re=Ae?he.UTF8ToString(Ae):"";throw new Error(`${re} ERROR_CODE: ${Be}, ERROR_MESSAGE: ${Re}`)}finally{he.stackRestore(ve)}}}),ho,Na=d(()=>{Hr(),Fi(),ho=re=>{let he=zt(),ve=0,Te=[],Se=re||{};try{if((re==null?void 0:re.logSeverityLevel)===void 0)Se.logSeverityLevel=2;else if(typeof re.logSeverityLevel!="number"||!Number.isInteger(re.logSeverityLevel)||re.logSeverityLevel<0||re.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${re.logSeverityLevel}`);if((re==null?void 0:re.logVerbosityLevel)===void 0)Se.logVerbosityLevel=0;else if(typeof re.logVerbosityLevel!="number"||!Number.isInteger(re.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${re.logVerbosityLevel}`);(re==null?void 0:re.terminate)===void 0&&(Se.terminate=!1);let Be=0;return(re==null?void 0:re.tag)!==void 0&&(Be=Hn(re.tag,Te)),ve=he._OrtCreateRunOptions(Se.logSeverityLevel,Se.logVerbosityLevel,!!Se.terminate,Be),ve===0&&Ct("Can't create run options."),(re==null?void 0:re.extra)!==void 0&&_n(re.extra,"",new WeakSet,(Ae,Re)=>{let Fe=Hn(Ae,Te),et=Hn(Re,Te);he._OrtAddRunConfigEntry(ve,Fe,et)!==0&&Ct(`Can't set a run config entry: ${Ae} - ${Re}.`)}),[ve,Te]}catch(Be){throw ve!==0&&he._OrtReleaseRunOptions(ve),Te.forEach(Ae=>he._free(Ae)),Be}}}),fo,po,qo,Sr,Ta,$a,kn=d(()=>{Hr(),Fi(),fo=re=>{switch(re){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: ${re}`)}},po=re=>{switch(re){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${re}`)}},qo=re=>{re.extra||(re.extra={}),re.extra.session||(re.extra.session={});let he=re.extra.session;he.use_ort_model_bytes_directly||(he.use_ort_model_bytes_directly="1"),re.executionProviders&&re.executionProviders.some(ve=>(typeof ve=="string"?ve:ve.name)==="webgpu")&&(re.enableMemPattern=!1)},Sr=(re,he,ve,Te)=>{let Se=Hn(he,Te),Be=Hn(ve,Te);zt()._OrtAddSessionConfigEntry(re,Se,Be)!==0&&Ct(`Can't set a session config entry: ${he} - ${ve}.`)},Ta=async(re,he,ve)=>{let Te=he.executionProviders;for(let Se of Te){let Be=typeof Se=="string"?Se:Se.name,Ae=[];switch(Be){case"webnn":if(Be="WEBNN",Sr(re,"session.disable_quant_qdq","1",ve),Sr(re,"session.disable_qdq_constant_folding","1",ve),typeof Se!="string"){let tt=Se==null?void 0:Se.deviceType;tt&&Sr(re,"deviceType",tt,ve)}break;case"webgpu":if(Be="JS",typeof Se!="string"){let tt=Se;if(tt!=null&&tt.preferredLayout){if(tt.preferredLayout!=="NCHW"&&tt.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${tt.preferredLayout}`);Sr(re,"preferredLayout",tt.preferredLayout,ve)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${Be}`)}let Re=Hn(Be,ve),Fe=Ae.length,et=0,it=0;if(Fe>0){et=zt()._malloc(Fe*zt().PTR_SIZE),ve.push(et),it=zt()._malloc(Fe*zt().PTR_SIZE),ve.push(it);for(let tt=0;tt<Fe;tt++)zt().setValue(et+tt*zt().PTR_SIZE,Ae[tt][0],"*"),zt().setValue(it+tt*zt().PTR_SIZE,Ae[tt][1],"*")}await zt()._OrtAppendExecutionProvider(re,Re,et,it,Fe)!==0&&Ct(`Can't append execution provider: ${Be}.`)}},$a=async re=>{let he=zt(),ve=0,Te=[],Se=re||{};qo(Se);try{let Be=fo(Se.graphOptimizationLevel??"all"),Ae=po(Se.executionMode??"sequential"),Re=typeof Se.logId=="string"?Hn(Se.logId,Te):0,Fe=Se.logSeverityLevel??2;if(!Number.isInteger(Fe)||Fe<0||Fe>4)throw new Error(`log severity level is not valid: ${Fe}`);let et=Se.logVerbosityLevel??0;if(!Number.isInteger(et)||et<0||et>4)throw new Error(`log verbosity level is not valid: ${et}`);let it=typeof Se.optimizedModelFilePath=="string"?Hn(Se.optimizedModelFilePath,Te):0;if(ve=he._OrtCreateSessionOptions(Be,!!Se.enableCpuMemArena,!!Se.enableMemPattern,Ae,!!Se.enableProfiling,0,Re,Fe,et,it),ve===0&&Ct("Can't create session options."),Se.executionProviders&&await Ta(ve,Se,Te),Se.enableGraphCapture!==void 0){if(typeof Se.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${Se.enableGraphCapture}`);Sr(ve,"enableGraphCapture",Se.enableGraphCapture.toString(),Te)}if(Se.freeDimensionOverrides)for(let[tt,Xe]of Object.entries(Se.freeDimensionOverrides)){if(typeof tt!="string")throw new Error(`free dimension override name must be a string: ${tt}`);if(typeof Xe!="number"||!Number.isInteger(Xe)||Xe<0)throw new Error(`free dimension override value must be a non-negative integer: ${Xe}`);let $t=Hn(tt,Te);he._OrtAddFreeDimensionOverride(ve,$t,Xe)!==0&&Ct(`Can't set a free dimension override: ${tt} - ${Xe}.`)}return Se.extra!==void 0&&_n(Se.extra,"",new WeakSet,(tt,Xe)=>{Sr(ve,tt,Xe,Te)}),[ve,Te]}catch(Be){throw ve!==0&&he._OrtReleaseSessionOptions(ve)!==0&&Ct("Can't release session options."),Te.forEach(Ae=>he._free(Ae)),Be}}}),Mr,Vn,Ir,ti,Ui,_i,cs,gr,Bt=d(()=>{Mr=re=>{switch(re){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: ${re}`)}},Vn=re=>{switch(re){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: ${re}`)}},Ir=(re,he)=>{let ve=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][re],Te=typeof he=="number"?he:he.reduce((Se,Be)=>Se*Be,1);return ve>0?Math.ceil(Te*ve):void 0},ti=re=>{switch(re){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: ${re}`)}},Ui=re=>{switch(re){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: ${re}`)}},_i=re=>re==="float32"||re==="float16"||re==="int32"||re==="int64"||re==="uint32"||re==="uint8"||re==="bool"||re==="uint4"||re==="int4",cs=re=>re==="float32"||re==="float16"||re==="int32"||re==="int64"||re==="uint32"||re==="uint64"||re==="int8"||re==="uint8"||re==="bool"||re==="uint4"||re==="int4",gr=re=>{switch(re){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: ${re}`)}}}),Gn,ki=d(()=>{St(),Gn=async re=>{if(typeof re=="string"){let he=await fetch(re);if(!he.ok)throw new Error(`failed to load external data file: ${re}`);let ve=he.headers.get("Content-Length"),Te=ve?parseInt(ve,10):0;if(Te<1073741824)return new Uint8Array(await he.arrayBuffer());{if(!he.body)throw new Error(`failed to load external data file: ${re}, no response body.`);let Se=he.body.getReader(),Be;try{Be=new ArrayBuffer(Te)}catch(Re){if(Re instanceof RangeError){let Fe=Math.ceil(Te/65536);Be=new WebAssembly.Memory({initial:Fe,maximum:Fe}).buffer}else throw Re}let Ae=0;for(;;){let{done:Re,value:Fe}=await Se.read();if(Re)break;let et=Fe.byteLength;new Uint8Array(Be,Ae,et).set(Fe),Ae+=et}return new Uint8Array(Be,0,Te)}}else return re instanceof Blob?new Uint8Array(await re.arrayBuffer()):re instanceof Uint8Array?re:new Uint8Array(re)}}),us,Vo,Si,Wr,Ps,Ci,on,ds,Hi,Es,Ke,qr,ft,be=d(()=>{rt(),Na(),kn(),Bt(),Hr(),Fi(),ki(),us=(re,he)=>{zt()._OrtInit(re,he)!==0&&Ct("Can't initialize onnxruntime.")},Vo=async re=>{us(re.wasm.numThreads,Ui(re.logLevel))},Si=async(re,he)=>{var Te,Se;(Se=(Te=zt()).asyncInit)==null||Se.call(Te);let ve=re.webgpu.adapter;if(he==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(ve){if(typeof ve.limits!="object"||typeof ve.features!="object"||typeof ve.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let Be=re.webgpu.powerPreference;if(Be!==void 0&&Be!=="low-power"&&Be!=="high-performance")throw new Error(`Invalid powerPreference setting: "${Be}"`);let Ae=re.webgpu.forceFallbackAdapter;if(Ae!==void 0&&typeof Ae!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Ae}"`);if(ve=await navigator.gpu.requestAdapter({powerPreference:Be,forceFallbackAdapter:Ae}),!ve)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")},Wr=new Map,Ps=re=>{let he=zt(),ve=he.stackSave();try{let Te=he.PTR_SIZE,Se=he.stackAlloc(2*Te);he._OrtGetInputOutputCount(re,Se,Se+Te)!==0&&Ct("Can't get session input/output count.");let Be=Te===4?"i32":"i64";return[Number(he.getValue(Se,Be)),Number(he.getValue(Se+Te,Be))]}finally{he.stackRestore(ve)}},Ci=(re,he)=>{let ve=zt(),Te=ve.stackSave(),Se=0;try{let Be=ve.PTR_SIZE,Ae=ve.stackAlloc(2*Be);ve._OrtGetInputOutputMetadata(re,he,Ae,Ae+Be)!==0&&Ct("Can't get session input/output metadata.");let Re=Number(ve.getValue(Ae,"*"));Se=Number(ve.getValue(Ae+Be,"*"));let Fe=ve.HEAP32[Se/4];if(Fe===0)return[Re,0];let et=ve.HEAPU32[Se/4+1],it=[];for(let tt=0;tt<et;tt++){let Xe=Number(ve.getValue(Se+8+tt*Be,"*"));it.push(Xe!==0?ve.UTF8ToString(Xe):Number(ve.getValue(Se+8+(tt+et)*Be,"*")))}return[Re,Fe,it]}finally{ve.stackRestore(Te),Se!==0&&ve._OrtFree(Se)}},on=re=>{let he=zt(),ve=he._malloc(re.byteLength);if(ve===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${re.byteLength}.`);return he.HEAPU8.set(re,ve),[ve,re.byteLength]},ds=async(re,he)=>{var it,tt,Xe;let ve,Te,Se=zt();Array.isArray(re)?[ve,Te]=re:re.buffer===Se.HEAPU8.buffer?[ve,Te]=[re.byteOffset,re.byteLength]:[ve,Te]=on(re);let Be=0,Ae=0,Re=[],Fe=[],et=[];try{if([Ae,Re]=await $a(he),(he==null?void 0:he.externalData)&&Se.mountExternalData){let Mn=[];for(let hn of he.externalData){let xr=typeof hn=="string"?hn:hn.path;Mn.push(Gn(typeof hn=="string"?hn:hn.data).then(Pr=>{Se.mountExternalData(xr,Pr)}))}await Promise.all(Mn)}for(let Mn of(he==null?void 0:he.executionProviders)??[])if((typeof Mn=="string"?Mn:Mn.name)==="webnn"){if(Se.shouldTransferToMLTensor=!1,typeof Mn!="string"){let hn=Mn,xr=hn==null?void 0:hn.context,Pr=hn==null?void 0:hn.gpuDevice,Vr=hn==null?void 0:hn.deviceType,Ra=hn==null?void 0:hn.powerPreference;xr?Se.currentContext=xr:Pr?Se.currentContext=await Se.webnnCreateMLContext(Pr):Se.currentContext=await Se.webnnCreateMLContext({deviceType:Vr,powerPreference:Ra})}else Se.currentContext=await Se.webnnCreateMLContext();break}Be=await Se._OrtCreateSession(ve,Te,Ae),(it=Se.webgpuOnCreateSession)==null||it.call(Se,Be),Be===0&&Ct("Can't create a session."),(tt=Se.jsepOnCreateSession)==null||tt.call(Se),Se.currentContext&&(Se.webnnRegisterMLContext(Be,Se.currentContext),Se.currentContext=void 0,Se.shouldTransferToMLTensor=!0);let[$t,Le]=Ps(Be),ut=!!(he!=null&&he.enableGraphCapture),Cn=[],Jt=[],Qt=[],jn=[],Ot=[];for(let Mn=0;Mn<$t;Mn++){let[hn,xr,Pr]=Ci(Be,Mn);hn===0&&Ct("Can't get an input name."),Fe.push(hn);let Vr=Se.UTF8ToString(hn);Cn.push(Vr),Qt.push(xr===0?{name:Vr,isTensor:!1}:{name:Vr,isTensor:!0,type:Vn(xr),shape:Pr})}for(let Mn=0;Mn<Le;Mn++){let[hn,xr,Pr]=Ci(Be,Mn+$t);hn===0&&Ct("Can't get an output name."),et.push(hn);let Vr=Se.UTF8ToString(hn);Jt.push(Vr),jn.push(xr===0?{name:Vr,isTensor:!1}:{name:Vr,isTensor:!0,type:Vn(xr),shape:Pr})}return Wr.set(Be,[Be,Fe,et,null,ut,!1]),[Be,Cn,Jt,Qt,jn]}catch($t){throw Fe.forEach(Le=>Se._OrtFree(Le)),et.forEach(Le=>Se._OrtFree(Le)),Be!==0&&Se._OrtReleaseSession(Be)!==0&&Ct("Can't release session."),$t}finally{Se._free(ve),Ae!==0&&Se._OrtReleaseSessionOptions(Ae)!==0&&Ct("Can't release session options."),Re.forEach($t=>Se._free($t)),(Xe=Se.unmountExternalData)==null||Xe.call(Se)}},Hi=re=>{var Fe,et,it;let he=zt(),ve=Wr.get(re);if(!ve)throw new Error(`cannot release session. invalid session id: ${re}`);let[Te,Se,Be,Ae,Re]=ve;Ae&&(Re&&he._OrtClearBoundOutputs(Ae.handle)!==0&&Ct("Can't clear bound outputs."),he._OrtReleaseBinding(Ae.handle)!==0&&Ct("Can't release IO binding.")),(Fe=he.jsepOnReleaseSession)==null||Fe.call(he,re),(et=he.webnnOnReleaseSession)==null||et.call(he,re),(it=he.webgpuOnReleaseSession)==null||it.call(he,re),Se.forEach(tt=>he._OrtFree(tt)),Be.forEach(tt=>he._OrtFree(tt)),he._OrtReleaseSession(Te)!==0&&Ct("Can't release session."),Wr.delete(re)},Es=async(re,he,ve,Te,Se,Be,Ae=!1)=>{if(!re){he.push(0);return}let Re=zt(),Fe=Re.PTR_SIZE,et=re[0],it=re[1],tt=re[3],Xe=tt,$t,Le;if(et==="string"&&(tt==="gpu-buffer"||tt==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Ae&&tt!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${Be} when enableGraphCapture is true.`);if(tt==="gpu-buffer"){let Jt=re[2].gpuBuffer;Le=Ir(Mr(et),it);{let Qt=Re.jsepRegisterBuffer;if(!Qt)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');$t=Qt(Te,Be,Jt,Le)}}else if(tt==="ml-tensor"){let Jt=re[2].mlTensor;Le=Ir(Mr(et),it);let Qt=Re.webnnRegisterMLTensor;if(!Qt)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');$t=Qt(Te,Jt,Mr(et),it)}else{let Jt=re[2];if(Array.isArray(Jt)){Le=Fe*Jt.length,$t=Re._malloc(Le),ve.push($t);for(let Qt=0;Qt<Jt.length;Qt++){if(typeof Jt[Qt]!="string")throw new TypeError(`tensor data at index ${Qt} is not a string`);Re.setValue($t+Qt*Fe,Hn(Jt[Qt],ve),"*")}}else{let Qt=Re.webnnIsGraphInput,jn=Re.webnnIsGraphOutput;if(et!=="string"&&Qt&&jn){let Ot=Re.UTF8ToString(Se);if(Qt(Te,Ot)||jn(Te,Ot)){let Mn=Mr(et);Le=Ir(Mn,it),Xe="ml-tensor";let hn=Re.webnnCreateTemporaryTensor,xr=Re.webnnUploadTensor;if(!hn||!xr)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let Pr=await hn(Te,Mn,it);xr(Pr,new Uint8Array(Jt.buffer,Jt.byteOffset,Jt.byteLength)),$t=Pr}else Le=Jt.byteLength,$t=Re._malloc(Le),ve.push($t),Re.HEAPU8.set(new Uint8Array(Jt.buffer,Jt.byteOffset,Le),$t)}else Le=Jt.byteLength,$t=Re._malloc(Le),ve.push($t),Re.HEAPU8.set(new Uint8Array(Jt.buffer,Jt.byteOffset,Le),$t)}}let ut=Re.stackSave(),Cn=Re.stackAlloc(4*it.length);try{it.forEach((Qt,jn)=>Re.setValue(Cn+jn*Fe,Qt,Fe===4?"i32":"i64"));let Jt=Re._OrtCreateTensor(Mr(et),$t,Le,Cn,it.length,gr(Xe));Jt===0&&Ct(`Can't create tensor for input/output. session=${Te}, index=${Be}.`),he.push(Jt)}finally{Re.stackRestore(ut)}},Ke=async(re,he,ve,Te,Se,Be)=>{var Gr,_l,jc;let Ae=zt(),Re=Ae.PTR_SIZE,Fe=Wr.get(re);if(!Fe)throw new Error(`cannot run inference. invalid session id: ${re}`);let et=Fe[0],it=Fe[1],tt=Fe[2],Xe=Fe[3],$t=Fe[4];Fe[5];let Le=he.length,ut=Te.length,Cn=0,Jt=[],Qt=[],jn=[],Ot=[],Mn=[],hn=Ae.stackSave(),xr=Ae.stackAlloc(Le*Re),Pr=Ae.stackAlloc(Le*Re),Vr=Ae.stackAlloc(ut*Re),Ra=Ae.stackAlloc(ut*Re);try{[Cn,Jt]=ho(Be),vt("wasm prepareInputOutputTensor");for(let un=0;un<Le;un++)await Es(ve[un],Qt,Ot,re,it[he[un]],he[un],$t);for(let un=0;un<ut;un++)await Es(Se[un],jn,Ot,re,tt[Te[un]],Le+Te[un],$t);st("wasm prepareInputOutputTensor");for(let un=0;un<Le;un++)Ae.setValue(xr+un*Re,Qt[un],"*"),Ae.setValue(Pr+un*Re,it[he[un]],"*");for(let un=0;un<ut;un++)Ae.setValue(Vr+un*Re,jn[un],"*"),Ae.setValue(Ra+un*Re,tt[Te[un]],"*");(Gr=Ae.jsepOnRunStart)==null||Gr.call(Ae,et),(_l=Ae.webnnOnRunStart)==null||_l.call(Ae,et);let yr;yr=await Ae._OrtRun(et,Pr,xr,Le,Ra,ut,Vr,Cn),yr!==0&&Ct("failed to call OrtRun().");let ri=[],Ec=[];vt("wasm ProcessOutputTensor");for(let un=0;un<ut;un++){let Os=Number(Ae.getValue(Vr+un*Re,"*"));if(Os===jn[un]||Mn.includes(jn[un])){ri.push(Se[un]),Os!==jn[un]&&Ae._OrtReleaseTensor(Os)!==0&&Ct("Can't release tensor.");continue}let Vu=Ae.stackSave(),Ni=Ae.stackAlloc(4*Re),Go=!1,ir,Kr=0;try{Ae._OrtGetTensorData(Os,Ni,Ni+Re,Ni+2*Re,Ni+3*Re)!==0&&Ct(`Can't access output tensor data on index ${un}.`);let kl=Re===4?"i32":"i64",Xr=Number(Ae.getValue(Ni,kl));Kr=Ae.getValue(Ni+Re,"*");let Nc=Ae.getValue(Ni+Re*2,"*"),Gu=Number(Ae.getValue(Ni+Re*3,kl)),Ti=[];for(let or=0;or<Gu;or++)Ti.push(Number(Ae.getValue(Nc+or*Re,kl)));Ae._OrtFree(Nc)!==0&&Ct("Can't free memory for tensor dims.");let Ls=Ti.reduce((or,Wn)=>or*Wn,1);ir=Vn(Xr);let si=Xe==null?void 0:Xe.outputPreferredLocations[Te[un]];if(ir==="string"){if(si==="gpu-buffer"||si==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let or=[];for(let Wn=0;Wn<Ls;Wn++){let zs=Ae.getValue(Kr+Wn*Re,"*"),Tc=Ae.getValue(Kr+(Wn+1)*Re,"*"),$c=Wn===Ls-1?void 0:Tc-zs;or.push(Ae.UTF8ToString(zs,$c))}ri.push([ir,Ti,or,"cpu"])}else if(si==="gpu-buffer"&&Ls>0){let or=Ae.jsepGetBuffer;if(!or)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let Wn=or(Kr),zs=Ir(Xr,Ls);if(zs===void 0||!_i(ir))throw new Error(`Unsupported data type: ${ir}`);Go=!0,ri.push([ir,Ti,{gpuBuffer:Wn,download:Ae.jsepCreateDownloader(Wn,zs,ir),dispose:()=>{Ae._OrtReleaseTensor(Os)!==0&&Ct("Can't release tensor.")}},"gpu-buffer"])}else if(si==="ml-tensor"&&Ls>0){let or=Ae.webnnEnsureTensor,Wn=Ae.webnnIsGraphInputOutputTypeSupported;if(!or||!Wn)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Ir(Xr,Ls)===void 0||!cs(ir))throw new Error(`Unsupported data type: ${ir}`);if(!Wn(re,ir,!1))throw new Error(`preferredLocation "ml-tensor" for ${ir} output is not supported by current WebNN Context.`);let zs=await or(re,Kr,Xr,Ti,!1);Go=!0,ri.push([ir,Ti,{mlTensor:zs,download:Ae.webnnCreateMLTensorDownloader(Kr,ir),dispose:()=>{Ae.webnnReleaseTensorId(Kr),Ae._OrtReleaseTensor(Os)}},"ml-tensor"])}else if(si==="ml-tensor-cpu-output"&&Ls>0){let or=Ae.webnnCreateMLTensorDownloader(Kr,ir)(),Wn=ri.length;Go=!0,Ec.push((async()=>{let zs=[Wn,await or];return Ae.webnnReleaseTensorId(Kr),Ae._OrtReleaseTensor(Os),zs})()),ri.push([ir,Ti,[],"cpu"])}else{let or=ti(ir),Wn=new or(Ls);new Uint8Array(Wn.buffer,Wn.byteOffset,Wn.byteLength).set(Ae.HEAPU8.subarray(Kr,Kr+Wn.byteLength)),ri.push([ir,Ti,Wn,"cpu"])}}finally{Ae.stackRestore(Vu),ir==="string"&&Kr&&Ae._free(Kr),Go||Ae._OrtReleaseTensor(Os)}}Xe&&!$t&&(Ae._OrtClearBoundOutputs(Xe.handle)!==0&&Ct("Can't clear bound outputs."),Wr.set(re,[et,it,tt,Xe,$t,!1]));for(let[un,Os]of await Promise.all(Ec))ri[un][2]=Os;return st("wasm ProcessOutputTensor"),ri}finally{(jc=Ae.webnnOnRunEnd)==null||jc.call(Ae,et),Ae.stackRestore(hn),Qt.forEach(yr=>Ae._OrtReleaseTensor(yr)),jn.forEach(yr=>Ae._OrtReleaseTensor(yr)),Ot.forEach(yr=>Ae._free(yr)),Cn!==0&&Ae._OrtReleaseRunOptions(Cn),Jt.forEach(yr=>Ae._free(yr))}},qr=re=>{let he=zt(),ve=Wr.get(re);if(!ve)throw new Error("invalid session id");let Te=ve[0],Se=he._OrtEndProfiling(Te);Se===0&&Ct("Can't get an profile file name."),he._OrtFree(Se)},ft=re=>{let he=[];for(let ve of re){let Te=ve[2];!Array.isArray(Te)&&"buffer"in Te&&he.push(Te.buffer)}return he}}),Pe,Qe,Et,en,ln,Tn,En,er,Ln,sr,Nn,Ds,Wi,mo,ni,qu,go,xo,kc=d(()=>{rt(),be(),Hr(),Ur(),Pe=()=>!!I.wasm.proxy&&typeof document<"u",Et=!1,en=!1,ln=!1,er=new Map,Ln=(re,he)=>{let ve=er.get(re);ve?ve.push(he):er.set(re,[he])},sr=()=>{if(Et||!en||ln||!Qe)throw new Error("worker not ready")},Nn=re=>{switch(re.data.type){case"init-wasm":Et=!1,re.data.err?(ln=!0,En[1](re.data.err)):(en=!0,En[0]()),Tn&&(URL.revokeObjectURL(Tn),Tn=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let he=er.get(re.data.type);re.data.err?he.shift()[1](re.data.err):he.shift()[0](re.data.out);break}}},Ds=async()=>{if(!en){if(Et)throw new Error("multiple calls to 'initWasm()' detected.");if(ln)throw new Error("previous call to 'initWasm()' failed.");if(Et=!0,Pe())return new Promise((re,he)=>{Qe==null||Qe.terminate(),wi().then(([ve,Te])=>{try{Qe=Te,Qe.onerror=Be=>he(Be),Qe.onmessage=Nn,En=[re,he];let Se={type:"init-wasm",in:I};if(!Se.in.wasm.wasmPaths&&ve){let Be=Fr();Be&&(Se.in.wasm.wasmPaths=Be)}Qe.postMessage(Se),Tn=ve}catch(Se){he(Se)}},he)});try{await ei(I.wasm),await Vo(I),en=!0}catch(re){throw ln=!0,re}finally{Et=!1}}},Wi=async re=>{if(Pe())return sr(),new Promise((he,ve)=>{Ln("init-ep",[he,ve]);let Te={type:"init-ep",in:{epName:re,env:I}};Qe.postMessage(Te)});await Si(I,re)},mo=async re=>Pe()?(sr(),new Promise((he,ve)=>{Ln("copy-from",[he,ve]);let Te={type:"copy-from",in:{buffer:re}};Qe.postMessage(Te,[re.buffer])})):on(re),ni=async(re,he)=>{if(Pe()){if(he!=null&&he.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return sr(),new Promise((ve,Te)=>{Ln("create",[ve,Te]);let Se={type:"create",in:{model:re,options:{...he}}},Be=[];re instanceof Uint8Array&&Be.push(re.buffer),Qe.postMessage(Se,Be)})}else return ds(re,he)},qu=async re=>{if(Pe())return sr(),new Promise((he,ve)=>{Ln("release",[he,ve]);let Te={type:"release",in:re};Qe.postMessage(Te)});Hi(re)},go=async(re,he,ve,Te,Se,Be)=>{if(Pe()){if(ve.some(Ae=>Ae[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(Se.some(Ae=>Ae))throw new Error("pre-allocated output tensor is not supported for proxy.");return sr(),new Promise((Ae,Re)=>{Ln("run",[Ae,Re]);let Fe=ve,et={type:"run",in:{sessionId:re,inputIndices:he,inputs:Fe,outputIndices:Te,options:Be}};Qe.postMessage(et,ft(Fe))})}else return Ke(re,he,ve,Te,Se,Be)},xo=async re=>{if(Pe())return sr(),new Promise((he,ve)=>{Ln("end-profiling",[he,ve]);let Te={type:"end-profiling",in:re};Qe.postMessage(Te)});qr(re)}}),yl,yo,Aa,vl=d(()=>{rt(),kc(),Bt(),St(),ki(),yl=(re,he)=>{switch(re.location){case"cpu":return[re.type,re.dims,re.data,"cpu"];case"gpu-buffer":return[re.type,re.dims,{gpuBuffer:re.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[re.type,re.dims,{mlTensor:re.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${re.location} for ${he()}`)}},yo=re=>{switch(re[3]){case"cpu":return new Ne(re[0],re[2],re[1]);case"gpu-buffer":{let he=re[0];if(!_i(he))throw new Error(`not supported data type: ${he} for deserializing GPU tensor`);let{gpuBuffer:ve,download:Te,dispose:Se}=re[2];return Ne.fromGpuBuffer(ve,{dataType:he,dims:re[1],download:Te,dispose:Se})}case"ml-tensor":{let he=re[0];if(!cs(he))throw new Error(`not supported data type: ${he} for deserializing MLTensor tensor`);let{mlTensor:ve,download:Te,dispose:Se}=re[2];return Ne.fromMLTensor(ve,{dataType:he,dims:re[1],download:Te,dispose:Se})}default:throw new Error(`invalid data location: ${re[3]}`)}},Aa=class{async fetchModelAndCopyToWasmMemory(re){return mo(await Gn(re))}async loadModel(re,he){At();let ve;typeof re=="string"?ve=await this.fetchModelAndCopyToWasmMemory(re):ve=re,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await ni(ve,he),He()}async dispose(){return qu(this.sessionId)}async run(re,he,ve){At();let Te=[],Se=[];Object.entries(re).forEach(tt=>{let Xe=tt[0],$t=tt[1],Le=this.inputNames.indexOf(Xe);if(Le===-1)throw new Error(`invalid input '${Xe}'`);Te.push($t),Se.push(Le)});let Be=[],Ae=[];Object.entries(he).forEach(tt=>{let Xe=tt[0],$t=tt[1],Le=this.outputNames.indexOf(Xe);if(Le===-1)throw new Error(`invalid output '${Xe}'`);Be.push($t),Ae.push(Le)});let Re=Te.map((tt,Xe)=>yl(tt,()=>`input "${this.inputNames[Se[Xe]]}"`)),Fe=Be.map((tt,Xe)=>tt?yl(tt,()=>`output "${this.outputNames[Ae[Xe]]}"`):null),et=await go(this.sessionId,Se,Re,Ae,Fe,ve),it={};for(let tt=0;tt<et.length;tt++)it[this.outputNames[Ae[tt]]]=Be[tt]??yo(et[tt]);return He(),it}startProfiling(){}endProfiling(){xo(this.sessionId)}}}),ji={};m(ji,{OnnxruntimeWebAssemblyBackend:()=>Ei,initializeFlags:()=>qi,wasmBackend:()=>vo});var qi,Ei,vo,Sc=d(()=>{rt(),kc(),vl(),qi=()=>{(typeof I.wasm.initTimeout!="number"||I.wasm.initTimeout<0)&&(I.wasm.initTimeout=0);let re=I.wasm.simd;if(typeof re!="boolean"&&re!==void 0&&re!=="fixed"&&re!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${re}". Reset it to \`false\` and ignore SIMD feature checking.`),I.wasm.simd=!1),typeof I.wasm.proxy!="boolean"&&(I.wasm.proxy=!1),typeof I.wasm.trace!="boolean"&&(I.wasm.trace=!1),typeof I.wasm.numThreads!="number"||!Number.isInteger(I.wasm.numThreads)||I.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)I.wasm.numThreads=1;else{let he=typeof navigator>"u"?u("node:os").cpus().length:navigator.hardwareConcurrency;I.wasm.numThreads=Math.min(4,Math.ceil((he||1)/2))}},Ei=class{async init(re){qi(),await Ds(),await Wi(re)}async createInferenceSessionHandler(re,he){let ve=new Aa;return await ve.loadModel(re,he),ve}},vo=new Ei}),Cc={};m(Cc,{InferenceSession:()=>yt,TRACE:()=>lt,TRACE_EVENT_BEGIN:()=>vt,TRACE_EVENT_END:()=>st,TRACE_FUNC_BEGIN:()=>At,TRACE_FUNC_END:()=>He,Tensor:()=>Ne,default:()=>wl,env:()=>I,registerBackend:()=>E}),rt(),rt(),rt();var bl="1.26.0",wl=Tr;{let re=(Sc(),g(ji)).wasmBackend;E("cpu",re,10),E("wasm",re,10)}return Object.defineProperty(I.versions,"web",{value:bl,enumerable:!0}),g(Cc)})();e.exports=r})($v)),$v.exports}var k_;function YN(){return k_||(k_=1,(function(e){var n=tl&&tl.__createBinding||(Object.create?(function(j,T,A,M){M===void 0&&(M=A);var O=Object.getOwnPropertyDescriptor(T,A);(!O||("get"in O?!T.__esModule:O.writable||O.configurable))&&(O={enumerable:!0,get:function(){return T[A]}}),Object.defineProperty(j,M,O)}):(function(j,T,A,M){M===void 0&&(M=A),j[M]=T[A]})),r=tl&&tl.__setModuleDefault||(Object.create?(function(j,T){Object.defineProperty(j,"default",{enumerable:!0,value:T})}):function(j,T){j.default=T}),i=tl&&tl.__importStar||function(j){if(j&&j.__esModule)return j;var T={};if(j!=null)for(var A in j)A!=="default"&&Object.prototype.hasOwnProperty.call(j,A)&&n(T,j,A);return r(T,j),T};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const o=i(XN()),l=Uw(),h=Hw(),u=Km(),d=Vy(),m=C2(),x=j2();e.DEFAULT_MODEL="legacy",e.ort=o;const g="vad.worklet.bundle.min.js",b="silero_vad_v5.onnx",S="silero_vad_legacy.onnx",E=j=>({...h.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{u.log.debug("VAD misfire")},onSpeechStart:()=>{u.log.debug("Detected speech start")},onSpeechEnd:()=>{u.log.debug("Detected speech end")},onSpeechRealStart:()=>{u.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:j,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(A=>{A.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=E;const C=j=>"audioWorklet"in j&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function y(j,T,A,M,O){await A.audioWorklet.addModule(j),T.processorOptions={...T.processorOptions??{},frameSamples:M};const I=new AudioWorkletNode(A,"vad-helper-worklet",T);return I.port.onmessage=async z=>{const U=z.data;if(!(typeof U=="object"&&U&&"message"in U)){console.error("Invalid message event",U);return}switch(U.message){case d.Message.AudioFrame:{if(!("data"in U&&U.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const W=new Float32Array(U.data);await O(W);break}}},I}async function v(j,T,A){const M=new x.Resampler({nativeSampleRate:j.sampleRate,targetSampleRate:16e3,targetFrameSize:T});u.log.debug("using script processor");const I=j.createScriptProcessor(4096,1,1);let z=!1;return I.onaudioprocess=async U=>{if(!z){z=!0;try{const W=U.inputBuffer.getChannelData(0);U.outputBuffer.getChannelData(0).fill(0);const V=M.process(W);for(const H of V)await A(H)}catch(W){console.error("Error processing audio:",W)}finally{z=!1}}},I.connect(j.destination),I}class _{constructor(T,A,M,O,I=!1,z=null,U=null,W=null,Y=null,V=null,H=null,te="uninitialized",oe=!1){this.options=T,this.frameProcessor=A,this.model=M,this.frameSamples=O,this.listening=I,this.errored=z,this._stream=U,this._audioContext=W,this._vadNode=Y,this._mediaStreamAudioSourceNode=V,this._audioProcessorAdapterType=H,this.initializationState=te,this.ownsAudioContext=oe,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=pe=>{this.initializationState="errored",this.errored=pe},this.start=async()=>{switch(this.initializationState){case"uninitialized":{u.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(pe){throw pe instanceof Error?this.setErrored(pe.message):this.setErrored(String(pe)),pe}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"?C(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await y(this.options.baseAssetPath+g,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await v(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),u.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{u.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:pe,audioContext:ie,vadNode:X}=this.getAudioInstances();this._stream=await this.options.resumeStream(pe);const Q=new MediaStreamAudioSourceNode(ie,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=Q,Q.connect(X);break}case"destroyed":{u.log.warn("start called after destroyed");break}case"errored":{u.log.error("start called after errored");break}default:{u.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:pe,mediaStreamAudioSourceNode:ie}=this.getAudioInstances();await this.options.pauseStream(pe),ie.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var ie;u.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:pe}=this.getAudioInstances();pe instanceof AudioWorkletNode&&pe.port.postMessage(d.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((ie=this._audioContext)==null?void 0:ie.close())},this.setOptions=pe=>{this.frameProcessor.setOptions(pe)},this.processFrame=async pe=>{await this.frameProcessor.process(pe,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=pe=>{switch(pe.msg){case d.Message.FrameProcessed:this.options.onFrameProcessed(pe.probs,pe.frame);break;case d.Message.SpeechStart:this.options.onSpeechStart();break;case d.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case d.Message.VADMisfire:this.options.onVADMisfire();break;case d.Message.SpeechEnd:this.options.onSpeechEnd(pe.audio);break}}}static async new(T={}){const A={...(0,e.getDefaultRealTimeVADOptions)(T.model??e.DEFAULT_MODEL),...T};(0,h.validateOptions)(A),e.ort.env.wasm.wasmPaths=A.onnxWASMBasePath,A.ortConfig!==void 0&&A.ortConfig(e.ort);const M=A.model==="v5"?b:S,O=A.baseAssetPath+M,I=A.model==="v5"?m.SileroV5.new:m.SileroLegacy.new;let z;try{z=await I(e.ort,()=>(0,l.defaultModelFetcher)(O))}catch(H){throw console.error(`Encountered an error while loading model file ${O}`),H}const U=A.model==="v5"?512:1536,W=U/16,Y=new h.FrameProcessor(z.process,z.reset_state,{positiveSpeechThreshold:A.positiveSpeechThreshold,negativeSpeechThreshold:A.negativeSpeechThreshold,redemptionMs:A.redemptionMs,preSpeechPadMs:A.preSpeechPadMs,minSpeechMs:A.minSpeechMs,submitUserSpeechOnPause:A.submitUserSpeechOnPause},W),V=new _(A,Y,z,U);if(A.startOnLoad)try{await V.start()}catch(H){throw console.error("Error starting micVad",H),H}return V}}e.MicVAD=_})(tl)),tl}var S_;function JN(){return S_||(S_=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 n=_2();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return n.baseAssetPath}});var r=Uw();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return r.defaultModelFetcher}});var i=Hw();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var o=Vy();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return o.Message}});var l=GN();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return l.NonRealTimeVAD}});const h=KN();e.utils={audioFileToArray:h.audioFileToArray,minFramesForTargetMS:h.minFramesForTargetMS,arrayBufferToBase64:h.arrayBufferToBase64,encodeWAV:h.encodeWAV};var u=YN();Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return u.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return u.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return u.getDefaultRealTimeVADOptions}})})(Ev)),Ev}var QN=JN();function nx(e,n,r,i){var l,h;try{(h=(l=window.api)==null?void 0:l.logs)==null||h.write(e,n,r,i)}catch{}const o=n==="error"?console.error:n==="warn"?console.warn:console.log;i!==void 0?o(`[${e}]`,r,i):o(`[${e}]`,r)}const dt={debug:(e,n,r)=>nx(e,"debug",n,r),info:(e,n,r)=>nx(e,"info",n,r),warn:(e,n,r)=>nx(e,"warn",n,r),error:(e,n,r)=>nx(e,"error",n,r)},N2=16e3,ZN=6,Sh=N2*ZN,eT=400,tT=N2*eT/1e3,C_=300,j_=2e3,E_=1500,N_=3e3,nT=600,T2=.5,$2=.35,T_=.85,$_=.7;let mi=null,va=!1,Ks=!1;const Ob=new Set;function rx(e){for(const n of Array.from(Ob))try{n(e)}catch(r){dt.warn("speech","workerDeath listener threw",{error:r instanceof Error?r.message:String(r)})}}let Av=0;const A_=2;let zh=!1,A2=!1;function R2(e){e.addEventListener("message",n=>{var i;if(((i=n.data)==null?void 0:i.type)!=="log")return;const r=n.data.level||"info";dt[r]("whisperWorker",n.data.message??"",n.data.meta)}),e.addEventListener("error",n=>{dt.error("whisperWorker","worker error event (fatal)",{message:n.message,filename:n.filename,lineno:n.lineno}),rT(`error:${n.message||"unknown"}`)})}function hy(){return mi||(mi=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),R2(mi),dt.info("speech","worker spawned"),mi)}let sx=!1;function rT(e){if(!zh){if(sx){dt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(sx=!0,Av+=1,A2=!0,dt.warn("speech","respawnWorker: starting",{reason:e,attempt:Av}),rx({reason:e,respawned:!1,finalOnly:!0}),Av>A_){if(zh=!0,dt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:A_}),mi)try{mi.terminate()}catch{}mi=null,va=!1,Ks=!1,rx({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),sx=!1;return}if(mi)try{mi.terminate()}catch{}mi=null,va=!1,Ks=!1;try{mi=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),R2(mi),Ks=!0,mi.postMessage({type:"load"}),dt.info("speech","respawnWorker: new worker spawned, load posted"),rx({reason:e,respawned:!0,finalOnly:!0})}catch(n){zh=!0,dt.error("speech","respawnWorker: spawn failed, disabling speech",{error:n instanceof Error?n.message:String(n)}),rx({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{sx=!1}}}function sT(e,n){if(va||Ks)return;Ks=!0;const r=hy();dt.info("speech","preloadModel: posting load");const i=o=>{o.data.type==="status"?(e==null||e(o.data.status,o.data.message),o.data.status==="ready"&&(va=!0,Ks=!1,dt.info("speech","preloadModel: ready"),r.removeEventListener("message",i))):o.data.type==="progress"?n==null||n(o.data.pct):o.data.type==="error"&&(Ks=!1,dt.error("speech","preloadModel: worker reported error",{error:o.data.error}),e==null||e("error",o.data.error),r.removeEventListener("message",i))};r.addEventListener("message",i),r.postMessage({type:"load"})}function iT(){dt.info("speech","resetModel: clearing load flags"),va=!1,Ks=!1}function Gy(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function oT(e){const n=hy();return!va&&!Ks&&(Ks=!0,n.postMessage({type:"load"})),new Promise((r,i)=>{const o=l=>{var h,u,d;((h=l.data)==null?void 0:h.type)==="result"?(n.removeEventListener("message",o),r((l.data.text??"").trim())):((u=l.data)==null?void 0:u.type)==="error"?(n.removeEventListener("message",o),i(new Error(String(l.data.error??"Transcription failed")))):((d=l.data)==null?void 0:d.type)==="status"&&l.data.status==="ready"&&(va=!0,Ks=!1)};n.addEventListener("message",o),n.postMessage({type:"transcribe",audio:e},[e.buffer])})}function M2(e){let n=hy(),r=!1,i=null,o=null,l=null,h=null,u=null;const d=[],m=new Set;let x=null,g=0,b=!1,S=0,E=!1,C=!1,y=0,v=0,_=0,j=-1,T=C_,A=0,M=null,O="",I="",z=!1,U=0;function W(le,fe){const Me=Math.min(le.length,fe.length);let je=0;for(;je<Me&&le.charCodeAt(je)===fe.charCodeAt(je);)je++;return je}function Y(le){const fe=W(O,le);return O=le,fe>I.length&&(I=le.slice(0,fe)),I.length>le.length&&(I=le),I}const V=()=>(x||(x=new Float32Array(Sh)),x),H=()=>{g=0},te=le=>{const fe=V(),Me=le.length;if(Me>=Sh){fe.set(le.subarray(Me-Sh)),g=Sh;return}if(g+Me<=Sh){fe.set(le,g),g+=Me;return}const je=g+Me-Sh;fe.copyWithin(0,je,g),g-=je,fe.set(le,g),g+=Me},oe=()=>{M&&(clearTimeout(M),M=null)},pe=()=>{oe(),b=!1,E=!1,C=!1,T=C_,O="",I="",z=!1,U=0,H()},ie=()=>{if(r||!b||C||E||M)return;if(g<tT){M=setTimeout(()=>{M=null,ie()},T);return}const le=performance.now()-y;if(le<T&&y!==0){M=setTimeout(()=>{M=null,ie()},T-le);return}if(A2||zh||e.partialsEnabled&&!e.partialsEnabled())return;const fe=V(),Me=new Float32Array(g);Me.set(fe.subarray(0,g)),v+=1,_=v,E=!0,A=performance.now(),y=A,n.postMessage({type:"transcribe-partial",audio:Me,seq:v},[Me.buffer])},X=le=>le.length===0?Promise.resolve():zh?(dt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),r||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(fe=>{d.push(fe),v+=1;const Me=v;j=Me,n.postMessage({type:"transcribe",audio:le,seq:Me},[le.buffer])}),Q=le=>{const fe=X(le);return m.add(fe),fe.finally(()=>{m.delete(fe)}),fe},J=le=>{var fe,Me,je,ye,ne;if(le.data.type==="result"){const we=le.data.text,Ne=le.data.seq??0;Ne&&Ne<j&&dt.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:Ne,latestFinalSeq:j}),!r&&we&&e.onFinal(we),(fe=d.shift())==null||fe()}else if(le.data.type==="partial"){const we=le.data.seq??0,Ne=le.data.text??"",Je=performance.now()-A;E=!1,Je>=N_?(C=!0,dt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Je),seq:we})):Je>=E_&&(T=Math.min(T*2,j_),dt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Je),newIntervalMs:T,seq:we})),z||(z=!0,Je>nT&&T<500&&(T=500,dt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Je),newIntervalMs:500})));const lt=we!==_||we<=j;if(!r&&!lt&&Ne){const xt=Y(Ne);xt&&((Me=e.onPartial)==null||Me.call(e,xt),U===0&&(U=performance.now(),dt.info("speech","partial.first",{msSinceSpeechStart:Math.round(U-S)})))}ie()}else if(le.data.type==="partial-error"){const we=performance.now()-A;E=!1,we>=N_?(C=!0,dt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(we),seq:le.data.seq})):we>=E_&&(T=Math.min(T*2,j_),dt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(we),newIntervalMs:T,seq:le.data.seq})),dt.warn("speech","partial encode failed",{error:le.data.error,seq:le.data.seq}),ie()}else le.data.type==="error"?(r||e.onError(le.data.error),(je=d.shift())==null||je()):le.data.type==="status"?(r||(ye=e.onModelStatus)==null||ye.call(e,le.data.status,le.data.message),le.data.status==="ready"&&(va=!0,Ks=!1)):le.data.type==="progress"&&(r||(ne=e.onProgress)==null||ne.call(e,le.data.pct))};n.addEventListener("message",J);const ae=le=>{var fe,Me;if(!r){for(dt.warn("speech","createRecognition: worker death event",le),(fe=e.onStatusChange)==null||fe.call(e,"restarting");d.length;)(Me=d.shift())==null||Me();if(m.clear(),oe(),E=!1,le.respawned){try{n.removeEventListener("message",J)}catch{}n=hy(),n.addEventListener("message",J)}}};return Ob.add(ae),{start:async()=>{if(!r){if(zh){e.onError("Speech recognition disabled — please reload the app.");return}!va&&!Ks&&(Ks=!0,dt.info("speech","createRecognition.start: triggering model load"),n.postMessage({type:"load"})),dt.info("speech","createRecognition.start: initializing VAD",{modelReady:va,modelLoading:Ks});try{const le=new URL("vad/",document.baseURI).href,fe=e.inputDeviceId||null,Me={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};fe&&(Me.deviceId={exact:fe}),dt.info("speech","getUserMedia",{hasDeviceId:!!fe,deviceIdPrefix:fe?fe.slice(0,8):null});const je=await navigator.mediaDevices.getUserMedia({audio:Me});o=je,l=new AudioContext;for(const ye of je.getAudioTracks())ye.addEventListener("ended",()=>{r||(dt.warn("speech","mic track ended (permission revoked or device removed)"),e.onError("Microphone disconnected or permission revoked"))});try{u=l.createMediaStreamSource(o),h=l.createAnalyser(),h.fftSize=2048,h.smoothingTimeConstant=.3,u.connect(h)}catch(ye){dt.warn("speech","analyser init failed",{error:ye instanceof Error?ye.message:String(ye)}),u=null,h=null}i=await QN.MicVAD.new({audioContext:l,getStream:async()=>je,resumeStream:async()=>je,pauseStream:async()=>{},baseAssetPath:le,onnxWASMBasePath:le,model:"v5",positiveSpeechThreshold:T2,negativeSpeechThreshold:$2,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(ye,ne)=>{var we;r||((we=e.onFrame)==null||we.call(e,ye),b&&(te(ne),ie()))},onSpeechStart:()=>{var ye;r||(pe(),b=!0,S=performance.now(),(ye=e.onSpeechStart)==null||ye.call(e))},onSpeechEnd:ye=>{var ne;r||((ne=e.onStatusChange)==null||ne.call(e,"transcribing"),pe(),Q(ye))},onVADMisfire:()=>{var ye,ne;r||((ye=e.onStatusChange)==null||ye.call(e,"idle"),pe(),(ne=e.onMisfire)==null||ne.call(e))}}),i.start()}catch(le){const fe=le instanceof Error?le.message:"Microphone access denied",Me=le instanceof Error?le.stack:"";if(dt.error("speech","createRecognition.start: VAD init failed",{error:fe,stack:Me}),h){try{h.disconnect()}catch{}h=null}if(u){try{u.disconnect()}catch{}u=null}if(o){try{o.getTracks().forEach(je=>je.stop())}catch{}o=null}if(l){try{await l.close()}catch{}l=null}e.onError(fe)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(pe();m.size>0;)await Promise.all(Array.from(m));if(i){try{await i.destroy()}catch{}i=null}if(h){try{h.disconnect()}catch{}h=null}if(u){try{u.disconnect()}catch{}u=null}if(o){try{o.getTracks().forEach(le=>le.stop())}catch{}o=null}if(l){try{await l.close()}catch{}l=null}},setVadThresholds:(le,fe)=>{if(i)try{i.setOptions({positiveSpeechThreshold:le,negativeSpeechThreshold:fe})}catch(Me){dt.warn("speech","setVadThresholds failed",{error:Me instanceof Error?Me.message:String(Me)})}},getAnalyser:()=>h,destroy:()=>{if(r=!0,pe(),i){try{i.destroy()}catch{}i=null}if(h){try{h.disconnect()}catch{}h=null}if(u){try{u.disconnect()}catch{}u=null}if(l){try{l.close()}catch{}l=null}if(o){try{o.getTracks().forEach(le=>le.stop())}catch{}o=null}Ob.delete(ae),n.removeEventListener("message",J)}}}let Em=null;const Lb=new Set,zb=new Set;function aT(){for(const e of Lb)try{e()}catch{}}function Bb(){for(const e of zb)try{e()}catch{}}function lT(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 cT(e){if(!window.speechSynthesis)return;const n=lT(e);if(!n)return;const r=new SpeechSynthesisUtterance(n);r.rate=1,r.pitch=1,r.onstart=()=>{Em=performance.now(),aT()},r.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Em=null,Bb())},r.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Em=null,Bb())},window.speechSynthesis.speak(r)}function I2(){window.speechSynthesis&&(window.speechSynthesis.cancel(),Em=null,Bb())}function P2(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function uT(){return Em}function dT(e){return Lb.add(e),()=>{Lb.delete(e)}}function hT(e){return zb.add(e),()=>{zb.delete(e)}}function fT(e){P2()&&(e.setVadThresholds(T_,$_),dt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const n=dT(()=>{e.setVadThresholds(T_,$_),dt.info("voice","tts.duck.on")}),r=hT(()=>{e.setVadThresholds(T2,$2),dt.info("voice","tts.duck.off")});return()=>{n(),r()}}const pT=[{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 mT(e){const n=e.trim();return pT.find(r=>r.match.test(n))??null}const gT=4e4;let Nu=null;function Bh(){Nu&&clearTimeout(Nu),Nu=setTimeout(()=>{Nu=null,Tt.getState().stopRecording()},gT)}function ix(){Nu&&(clearTimeout(Nu),Nu=null)}let pc=null,dc=null;const xT=.04,yT=.3;let fy=0,Fb=0;function vT(e){dc!==null&&cancelAnimationFrame(dc);const n=()=>{if(pc===null||Tt.getState().submitCountdownStartAt===null){dc=null;return}const r=performance.now();if(r-Fb<200&&fy>yT){const o=r-e;dt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:fy.toFixed(2),msIntoCountdown:Math.round(o)}),oc(),Bh();return}const i=D2();if(i){const o=new Uint8Array(i.fftSize);i.getByteTimeDomainData(o);let l=0;for(let u=0;u<o.length;u++){const d=(o[u]-128)/128;l+=d*d}const h=Math.sqrt(l/o.length);if(h>xT){const u=r-e;dt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:h.toFixed(3),msIntoCountdown:Math.round(u)}),oc(),Bh();return}}dc=requestAnimationFrame(n)};dc=requestAnimationFrame(n)}function bT(e){pc&&clearTimeout(pc);const n=Tt.getState().submitDelayMs,r=performance.now();Tt.setState({submitCountdownStartAt:r}),pc=setTimeout(()=>{pc=null,Tt.setState({submitCountdownStartAt:null});try{window.api.pty.write({tabId:e,data:"\r"})}catch(i){dt.warn("voice","submit pty.write failed",{error:i instanceof Error?i.message:String(i)})}Bh()},n),vT(r)}function oc(){dc!==null&&(cancelAnimationFrame(dc),dc=null),pc&&(clearTimeout(pc),pc=null),Tt.getState().submitCountdownStartAt!==null&&Tt.setState({submitCountdownStartAt:null})}let rs=null,As=null;function D2(){var e;return((e=rs==null?void 0:rs.getAnalyser)==null?void 0:e.call(rs))??null}const ox=1e4;let Nm=null;function ax(){Nm&&(clearTimeout(Nm),Nm=null)}let Kx=null,Xx=null;function lx(){Kx=null,Xx&&(Xx(),Xx=null)}const wT=1500,_T=9e4;let cx=0,Yx=null,Ub=-1;function ux(){Yx&&(clearTimeout(Yx),Yx=null,Ub=-1)}const kT=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Tt=cr((e,n)=>({isRecording:!1,externalRecording:!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(n().modelStatus!=="idle")return;dt.info("voice","initModel: kicking off preload"),e({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const r=++cx,i=()=>{r===cx&&(ux(),Ub=r,Yx=setTimeout(()=>{Ub===r&&n().modelStatus==="loading"&&(dt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},_T))};i(),sT((o,l)=>{r===cx&&(o==="ready"?(ux(),dt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):o==="error"?(ux(),dt.error("voice","modelStatus -> error",{msg:l}),e({modelStatus:"error",error:l,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},o=>{r===cx&&(i(),e({loadingProgress:Math.round(o)}))})},resetAndRetryModel:()=>{dt.info("voice","mic.gate.retry"),ux(),iT(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),n().initModel()},startRecording:r=>{if(n().isRecording)return;if(rs){dt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!Gy()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=o=>{try{const l=M2({inputDeviceId:o,onStatusChange:h=>{e(h==="transcribing"?{statusPill:"transcribing"}:h==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:h=>{n().partialsEnabled&&e({lastPartial:h})},partialsEnabled:()=>n().partialsEnabled,onFrame:h=>{fy=h.isSpeech,Fb=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),ix(),oc(),P2()){const u=uT(),d=u!==null?performance.now()-u:null;I2(),e({lastBargeInAt:performance.now()}),dt.info("voice","barge-in",{tabId:r,utteranceOffsetMs:d})}else dt.debug("voice","barge-in.no-op",{tabId:r})},onMisfire:()=>{e({lastPartial:"",statusPill:"idle"}),Bh();const h=n().lastBargeInAt;h!==null&&performance.now()-h<600&&dt.warn("voice","barge-in.misfire",{tabId:r,sinceBargeInMs:Math.round(performance.now()-h)})},onFinal:h=>{Bh();const u=h.trim();if(!u||kT.has(u)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const d=mT(u);if(d){dt.info("voice","voice-command",{tabId:r,label:d.label,transcript:u}),window.api.pty.write({tabId:r,data:d.data}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),oc();const x=window;x.__transcripts&&(x.__transcripts.push({tabId:r,text:u}),x.__transcripts.length>500&&x.__transcripts.shift());return}window.api.pty.write({tabId:r,data:u}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),n().autoSubmit&&bT(r);const m=window;m.__transcripts&&(m.__transcripts.push({tabId:r,text:u}),m.__transcripts.length>500&&m.__transcripts.shift())},onError:h=>{dt.error("voice","recognition error",{err:h}),oc(),e({error:h,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),As==null||As(),As=null,ix(),rs==null||rs.destroy(),rs=null,ze.error(`Microphone error: ${h}`)},onModelStatus:h=>{h==="ready"?e({modelStatus:"ready",loadingProgress:100}):h==="loading"&&e({modelStatus:"loading"})},onProgress:h=>e({loadingProgress:Math.round(h)})});rs=l,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),Bh(),l.start().then(()=>{rs===l&&(As==null||As(),As=fT(l))}).catch(h=>{const u=h instanceof Error?h.message:String(h);dt.error("voice","handle.start() failed",{error:u}),ze.error(`Could not start mic: ${u}`)})}catch(l){e({error:l instanceof Error?l.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var o,l,h;return((h=(l=(o=window.api)==null?void 0:o.voice)==null?void 0:l.getDevicePref)==null?void 0:h.call(l))??Promise.resolve(null)}).then(o=>i((o==null?void 0:o.selectedDeviceId)??null)).catch(o=>{dt.warn("voice","getDevicePref failed; using default device",{error:o instanceof Error?o.message:String(o)}),i(null)})},stopRecording:()=>{const r=rs;r&&(ix(),oc(),fy=0,Fb=0,As==null||As(),As=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),r.stop().finally(()=>{r.destroy(),rs===r&&(rs=null),n().hotkeyState==="stopping"&&(ax(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!n().isRecording)return;const r=rs;if(!r)return;ix(),As==null||As(),As=null,e({isRecording:!1,lastTranscript:"",lastPartial:""});try{await r.stop()}catch(l){dt.warn("voice","restartWithDevice: drain rejected",{error:l instanceof Error?l.message:String(l)})}r.destroy(),rs===r&&(rs=null);const{useSessions:i}=await Gm(async()=>{const{useSessions:l}=await Promise.resolve().then(()=>CN);return{useSessions:l}},[],import.meta.url),o=i.getState().activeTabId;o&&n().startRecording(o)},setExternalRecording:r=>e({externalRecording:r}),toggleTTS:()=>e(r=>({ttsEnabled:!r.ttsEnabled})),setAutoSubmit:r=>e({autoSubmit:r}),setSubmitDelayMs:r=>e({submitDelayMs:Math.max(500,Math.min(13e3,Math.floor(r)))}),cancelSubmit:()=>oc(),setPartialsEnabled:r=>{n().partialsEnabled!==r&&(e({partialsEnabled:r}),r||e({lastPartial:""}))},clearError:()=>e({error:null,errorKind:null}),setPermissionState:r=>{n().permissionState!==r&&(dt.info("voice","mic.gate.permission_changed",{from:n().permissionState,to:r}),e({permissionState:r}))},setLevelMeterEnabled:r=>{n().levelMeterEnabled!==r&&e({levelMeterEnabled:r})},setTurnDetectorRuntimeState:r=>{n().turnDetectorState!==r&&(e({turnDetectorState:r}),r==="load_failed"?dt.warn("voice-turn","voice-turn.load_failed"):r==="runtime_error"?dt.warn("voice-turn","voice-turn.runtime_error"):r==="disabled"&&dt.info("voice-turn","voice-turn.fallback_to_vad"))},setWizardArmed:r=>{n().wizardArmed!==r&&e({wizardArmed:r})},openWizard:()=>{n().wizardOpen||e({wizardOpen:!0})},closeWizard:()=>{n().wizardOpen&&e({wizardOpen:!1})},armHotkey:({phase:r,source:i,mode:o,tabId:l})=>{const h=n(),{canRecord:u,reason:d}=Hb(h);if(r==="down"){if(d==="error"||d==="load-timeout"){h.resetAndRetryModel(),dt.info("voice-hotkey","down.retry",{source:i,reason:d});return}if(!u&&d!=="loading"){dt.warn("voice-hotkey","miss-model-loading",{modelStatus:h.modelStatus,reason:d});return}if(h.hotkeyState==="recording"||h.isRecording){(o==="toggle"||i==="global")&&(e({hotkeyState:"stopping"}),ax(),Nm=setTimeout(()=>{n().hotkeyState==="stopping"&&(dt.warn("voice-hotkey","drain-timeout",{durationMs:ox}),e({hotkeyState:"aborted"}),setTimeout(()=>{n().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},ox),h.stopRecording());return}if(d==="loading"){h.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),dt.info("voice-hotkey","armed",{source:i,modelStatus:h.modelStatus})),lx(),Kx={tabId:l,source:i,mode:o},Xx=Tt.subscribe((m,x)=>{if(Kx&&m.modelStatus==="ready"&&x.modelStatus!=="ready"&&m.hotkeyState==="armed"){const g=Kx;if(lx(),!g.tabId){dt.warn("voice-hotkey","armed-promote-no-tab",{source:g.source}),e({hotkeyState:"idle"});return}dt.info("voice-hotkey","armed-promote",g),e({hotkeyState:"recording"}),Tt.getState().startRecording(g.tabId)}});return}if(!l){dt.warn("voice-hotkey","no-active-tab",{source:i});return}dt.info("voice-hotkey","start",{source:i,mode:o,tabId:l}),h.startRecording(l),n().isRecording?e({hotkeyState:"recording"}):(dt.warn("voice-hotkey","start: recording did not engage",{errorKind:n().errorKind}),e({hotkeyState:"idle"}));return}if(!(o!=="hold"||i==="global")){if(h.hotkeyState==="armed"){lx(),dt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}h.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),ax(),Nm=setTimeout(()=>{n().hotkeyState==="stopping"&&(dt.warn("voice-hotkey","drain-timeout",{durationMs:ox}),e({hotkeyState:"aborted"}),setTimeout(()=>{n().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},ox),h.stopRecording())}},destroyHotkey:()=>{const r=n();if(lx(),oc(),r.hotkeyState==="recording"){dt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{r.stopRecording()}catch{}}else(r.hotkeyState==="armed"||r.hotkeyState==="stopping")&&(ax(),e({hotkeyState:"destroyed"}))}})),ST=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),Hb=e=>Gy()?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=Tt,e.__transcripts=[]}function Ww(e,n,r){return new Promise((i,o)=>{const l=setTimeout(()=>o(new Error(`${r} timed out after ${n}ms`)),n);e.then(h=>{clearTimeout(l),i(h)},h=>{clearTimeout(l),o(h)})})}const CT=5e3,yc=cr(()=>({snapshot:null,loaded:!1}));let R_=!1,M_=!1,Gp;async function jT(){var e;if(!R_){R_=!0;try{const n=await Ww(window.api.schedule.state(),CT,"schedule.state");yc.setState({snapshot:n,loaded:!0}),Gp=((e=n.paused)==null?void 0:e.reason)??null}catch(n){if(!M_){M_=!0;const r=n instanceof Error?n.message:String(n);ze.error(`Scheduler state hydrate failed: ${r}`)}Gp=null}window.api.schedule.onState(n=>{var i;const r=((i=n.paused)==null?void 0:i.reason)??null;Gp!==void 0&&r!==Gp&&(r==="auth"?ze.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):r==="network"&&ze.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),Gp=r,yc.setState({snapshot:n,loaded:!0})})}}const ET=6e4,NT=5e3,Fh=cr(()=>({data:null,refreshing:!1}));let I_=!1,Jx=null,P_=null,D_=!1;async function qw(){Fh.setState({refreshing:!0});let e=ET;try{const n=await Ww(window.api.billing.fetch(),NT,"billing.fetch");Fh.setState({data:n,refreshing:!1}),n.kind==="transient"?e=P_==="transient"?3e4:5e3:(n.kind==="auth"||n.kind==="meter_rate_limited")&&(e=3e4),P_=n.kind}catch(n){if(Fh.setState({refreshing:!1}),!D_){D_=!0;const r=n instanceof Error?n.message:String(n);ze.warn(`Billing usage fetch failed: ${r}`)}}Jx=setTimeout(qw,e)}function TT(){I_||(I_=!0,qw())}function Ky(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:(e.kind==="auth"||e.kind==="meter_rate_limited")&&e.cached?e.cached:null:null}function py(){Jx!==null&&(clearTimeout(Jx),Jx=null),qw()}function dn({name:e,size:n=17,stroke:r=1.6,className:i}){const o={width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round",className:i};switch(e){case"home":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M4 11l8-7 8 7"}),s.jsx("path",{d:"M6 10v9h12v-9"}),s.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"M7 10l3 2-3 2"}),s.jsx("path",{d:"M13 14h4"})]});case"agents":case"subagents":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"7",cy:"9",r:"2.5"}),s.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),s.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),s.jsx("path",{d:"M8.6 11l2.8 4M15.4 11l-2.8 4M9.5 9h5"})]});case"skills":return s.jsx("svg",{...o,children:s.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 s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("path",{d:"M12 7v5l3 2"}),s.jsx("path",{d:"M4 6l2 2"})]});case"usage":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"hive":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M8 4h8l4 7-4 7H8l-4-7z"}),s.jsx("circle",{cx:"12",cy:"11",r:"2.5"})]});case"plugins":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),s.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),s.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),s.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),s.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"8",cy:"12",r:"4"}),s.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"plans":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),s.jsx("path",{d:"M8 9h8M8 13h8M8 17h5"})]});case"tasks":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),s.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1.5"}),s.jsx("path",{d:"M14 6h7M14 10h5M14 15h7M14 19h5"})]});case"projects":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"memory":case"agent-memory":return s.jsxs("svg",{...o,children:[s.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"}),s.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":case"global-search":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"11",cy:"11",r:"6"}),s.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return s.jsx("svg",{...o,children:s.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M7 3h7l4 4v14H7z"}),s.jsx("path",{d:"M14 3v4h4"})]});case"play":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),s.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),s.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),s.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.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 s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),s.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),s.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"orchestrator":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"6",r:"2.5"}),s.jsx("circle",{cx:"5",cy:"17",r:"2.5"}),s.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),s.jsx("circle",{cx:"19",cy:"17",r:"2.5"}),s.jsx("path",{d:"M12 8.5v6M12 14.5l-7 0M12 14.5l7 0"})]});case"race":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 4v16M5 5h7l-1 3h7v6h-7l-1 3H5"})});case"background":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M3 4h18v4H3zM3 10h18v4H3zM3 16h18v4H3z"}),s.jsx("circle",{cx:"6",cy:"6",r:".75",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"6",cy:"12",r:".75",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"6",cy:"18",r:".75",fill:"currentColor",stroke:"none"})]});case"repoviz":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"18",cy:"18",r:"3"}),s.jsx("path",{d:"M8.5 10.5L15.5 7.5M8.5 13.5L15.5 16.5"})]});case"system-prompt":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),s.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),s.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),s.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return s.jsx("svg",{...o,children:s.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 s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"remote":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M5 12.5a7 7 0 0114 0M1.5 9a11 11 0 0121 0M8.5 16a3.5 3.5 0 017 0"}),s.jsx("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]});case"wifi":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 12.5a10 10 0 0114 0M8 15.5a6 6 0 018 0M12 18.5h.01"})});case"shield":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),s.jsx("path",{d:"M9 12l2 2 4-4"})]});case"link":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M9 12h6"}),s.jsx("path",{d:"M10 8H7a4 4 0 000 8h3M14 8h3a4 4 0 010 8h-3"})]});case"copy":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),s.jsx("path",{d:"M5 15V5a2 2 0 012-2h8"})]});case"check":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 12l5 5 9-10"})});case"x":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M6 6l12 12M18 6L6 18"})});case"send":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M4 11l17-7-7 17-3-7z"})});case"browser":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("ellipse",{cx:"12",cy:"12",rx:"3.2",ry:"8"}),s.jsx("path",{d:"M4 12h16"})]});case"target":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("circle",{cx:"12",cy:"12",r:"3.5"}),s.jsx("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]});case"record":return s.jsx("svg",{...o,children:s.jsx("circle",{cx:"12",cy:"12",r:"7",fill:"currentColor",stroke:"none"})});case"eye":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"camera":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M4 8h3l2-2h6l2 2h3v11H4z"}),s.jsx("circle",{cx:"12",cy:"13.5",r:"3.5"})]});case"arrowleft":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M19 12H5M11 6l-6 6 6 6"})});case"arrowright":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})});case"reload":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M4 12a8 8 0 0114-5.3M20 12a8 8 0 01-14 5.3"}),s.jsx("path",{d:"M18 3v4h-4M6 21v-4h4"})]});case"lock":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),s.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"})]});case"stop":return s.jsx("svg",{...o,children:s.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5",fill:"currentColor",stroke:"none"})});case"star":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M12 3l2.6 5.6 6.1.6-4.6 4.1 1.3 6-5.4-3.2-5.4 3.2 1.3-6-4.6-4.1 6.1-.6z"})});case"minus":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 12h14"})});default:return null}}function $T(e,n={}){switch(e){case"ready":return n.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 n.loadingPct=="number"?Math.round(n.loadingPct):0} percent`;case"error":return n.errorMessage?`Microphone — speech model error: ${n.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 O_=e=>Symbol.iterator in e,L_=e=>"entries"in e,z_=(e,n)=>{const r=e instanceof Map?e:new Map(e.entries()),i=n instanceof Map?n:new Map(n.entries());if(r.size!==i.size)return!1;for(const[o,l]of r)if(!i.has(o)||!Object.is(l,i.get(o)))return!1;return!0},AT=(e,n)=>{const r=e[Symbol.iterator](),i=n[Symbol.iterator]();let o=r.next(),l=i.next();for(;!o.done&&!l.done;){if(!Object.is(o.value,l.value))return!1;o=r.next(),l=i.next()}return!!o.done&&!!l.done};function RT(e,n){return Object.is(e,n)?!0:typeof e!="object"||e===null||typeof n!="object"||n===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(n)?!1:O_(e)&&O_(n)?L_(e)&&L_(n)?z_(e,n):AT(e,n):z_({entries:()=>Object.entries(e)},{entries:()=>Object.entries(n)})}function O2(e){const n=lo.useRef(void 0);return r=>{const i=e(r);return RT(n.current,i)?n.current:n.current=i}}let B_=0;const MT=1e3;function IT(e){const n=performance.now();n-B_<MT||(B_=n,dt.debug("voice","mic.gate.click_rejected",{reason:e}))}function L2(){const e=Tt(m=>m.isRecording),n=Tt(m=>m.error),r=Tt(m=>m.loadingProgress),i=Tt(O2(Hb)),o=()=>{const m=Tt.getState(),{canRecord:x,reason:g}=Hb(m);if(m.isRecording)return m.stopRecording();if(m.wizardArmed&&!m.wizardOpen){m.openWizard();return}if(g==="error"||g==="load-timeout"){m.resetAndRetryModel();return}if(!x)return IT(g);const b=kt.getState().activeTabId;b&&m.startRecording(b)},l=$T(i.reason,{loadingPct:r,errorMessage:n,isRecording:e}),h=i.reason==="unsupported",u=!i.canRecord,d=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 s.jsx("button",{onClick:o,disabled:h,"aria-disabled":u,"aria-label":l,title:l,"data-testid":"mic-button","data-state":i.reason,className:`p-1.5 rounded transition-colors ${d}`,children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),s.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),s.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),s.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function PT(){const e=Tt(r=>r.ttsEnabled),n=Tt(r=>r.toggleTTS);return s.jsxs("button",{onClick:n,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:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e?s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),s.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),s.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),s.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}function Xm(e){if(!e||e==="—"||e==="unknown")return e;const n=/\[(\dm)\]/.exec(e),r=/(opus|sonnet|haiku)[-_](\d+)[-_.]?(\d+)?/i.exec(e);if(!r)return e;const i=r[1].charAt(0).toUpperCase()+r[1].slice(1).toLowerCase(),o=r[3]?`${r[2]}.${r[3]}`:r[2];return n?`${i} ${o} ${n[1]}`:`${i} ${o}`}const dx=new Map,DT=3e4;function z2(e){const[n,r]=L.useState(()=>{var i;return e?((i=dx.get(e))==null?void 0:i.value)??null:null});return L.useEffect(()=>{if(!e){r(null);return}let i=!1;return(async()=>{const l=dx.get(e);if(l&&Date.now()-l.ts<DT){i||r(l.value);return}try{const h=await window.api.app.gitBranch(e);if(i)return;dx.set(e,{value:h,ts:Date.now()}),r(h)}catch{if(i)return;dx.set(e,{value:null,ts:Date.now()}),r(null)}})(),()=>{i=!0}},[e]),n}const Xy=[{key:"overview",group:"Workspace",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",group:"Workspace",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"browser",group:"Workspace",label:"Browser",icon:"browser",hint:"Embedded dev browser — capture DOM, record click-sequences"},{key:"projects",group:"Workspace",label:"File Explorer",icon:"projects",hint:"Browse files + edit, per project"},{key:"subagents",group:"Workspace",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Fan out work: Hive · Orchestrate · Race · Boss"},{key:"scheduler",group:"Workspace",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"history",group:"Workspace",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",group:"Workspace",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"},{key:"skills",group:"Configure",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",group:"Configure",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",group:"Configure",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",group:"Configure",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",group:"Configure",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"memory",group:"Configure",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"system-prompt",group:"Configure",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",group:"Configure",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",group:"Configure",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",group:"Configure",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"},{key:"voice",group:"Tools",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"repoviz",group:"Tools",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",group:"Tools",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],OT=Object.fromEntries(Xy.map(e=>[e.key,e.group])),F_=Xy.filter(e=>e.group==="Workspace"),U_=Xy.filter(e=>e.group==="Configure"),H_=Xy.filter(e=>e.group==="Tools").map(({key:e,label:n,icon:r,hint:i})=>({key:e,label:n,icon:r,hint:i})),Wb="sm.almanac.sidebarWidth",B2=180,F2=480,qb=252;function LT(){try{const e=parseInt(localStorage.getItem(Wb)??"",10);if(Number.isFinite(e))return Math.min(F2,Math.max(B2,e))}catch{}return qb}const zT=52,U2="sm.almanac.sidebarCollapsed";function BT(){try{return localStorage.getItem(U2)==="1"}catch{}return!1}const H2="sm.almanac.collapsedGroups";function FT(){try{const e=localStorage.getItem(H2);if(!e)return new Set;const n=JSON.parse(e);return Array.isArray(n)?new Set(n.filter(r=>r==="Workspace"||r==="Configure"||r==="Tools")):new Set}catch{return new Set}}function UT(){const e=Vx(l=>l.tabs),n=yc(l=>{var h;return(((h=l.snapshot)==null?void 0:h.jobs)??[]).some(u=>u.status==="running")}),[r,i]=L.useState(()=>Date.now());return L.useEffect(()=>{const l=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(l)},[]),{subagents:Object.values(e).some(l=>l.agents.some(h=>r-h.at<6e4)),scheduler:n}}function HT({active:e,onNavigate:n,onNewSession:r}){const[i,o]=L.useState(()=>FT()),l=L.useCallback(_=>{o(j=>{const T=new Set(j);T.has(_)?T.delete(_):T.add(_);try{localStorage.setItem(H2,JSON.stringify(Array.from(T)))}catch{}return T})},[]),[h,u]=L.useState(()=>BT()),d=L.useCallback(()=>{u(_=>{const j=!_;try{localStorage.setItem(U2,j?"1":"0")}catch{}return j})},[]),m=kt(_=>_.tabs),x=kt(_=>_.activeTabId),g=m.find(_=>_.id===x)??null,b=UT(),[S,E]=L.useState(()=>LT()),C=L.useRef(S);C.current=S;const y=L.useCallback(_=>{_.preventDefault();const j=_.clientX,T=C.current;let A=T;const M=I=>{A=Math.min(F2,Math.max(B2,T+(I.clientX-j))),E(A)},O=()=>{window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",O),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(Wb,String(A))}catch{}};window.addEventListener("pointermove",M),window.addEventListener("pointerup",O),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),v=L.useCallback(()=>{E(qb);try{localStorage.setItem(Wb,String(qb))}catch{}},[]);return s.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative transition-[width] duration-150",style:{width:h?zT:S},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[s.jsx(WT,{tab:g,onNewSession:r,rail:h,onToggleRail:d}),s.jsx("div",{className:"flex-1 min-h-0 overflow-auto pb-3",style:{paddingInline:h?"4px":"8px"},children:s.jsxs(s.Fragment,{children:[!h&&s.jsx(Rv,{label:"Workspace",collapsed:i.has("Workspace"),count:F_.length,onToggle:()=>l("Workspace")}),(h||!i.has("Workspace"))&&F_.map(_=>s.jsx(W_,{item:_,active:e===_.key,live:_.liveKind?b[_.liveKind]:!1,onClick:()=>n(_.key),rail:h},_.key)),!h&&s.jsx(Rv,{label:"Configure",collapsed:i.has("Configure"),count:U_.length,onToggle:()=>l("Configure")}),(h||!i.has("Configure"))&&U_.map(_=>s.jsx(W_,{item:_,active:e===_.key,live:!1,onClick:()=>n(_.key),rail:h},_.key)),!h&&s.jsx(Rv,{label:"Tools",collapsed:i.has("Tools"),count:H_.length,onToggle:()=>l("Tools")}),(h||!i.has("Tools"))&&H_.map(_=>s.jsx(qT,{tool:_,active:e===_.key,onClick:()=>n(_.key),rail:h},_.key))]})}),s.jsx(VT,{rail:h}),!h&&s.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:y,onDoubleClick:v,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 WT({tab:e,onNewSession:n,rail:r,onToggleRail:i}){const o=(e==null?void 0:e.label)??"no session",l=z2((e==null?void 0:e.cwd)??null);return r?s.jsxs("div",{className:"flex flex-col items-center gap-1.5 pt-2 pb-2 border-b border-rule",children:[s.jsx("button",{onClick:n,"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:s.jsx(dn,{name:"plus",size:15,stroke:1.8})}),s.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:s.jsx("span",{style:{display:"inline-flex",transform:"rotate(0deg)"},children:s.jsx(dn,{name:"chevron",size:15,stroke:1.8})})})]}):s.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),s.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:s.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:s.jsx(dn,{name:"chevron",size:13,stroke:1.8})})})]}),s.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[s.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),s.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(e==null?void 0:e.cwd)??"",children:o})]}),s.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:l?`⌥${l}`:e?e.cwd:"—"}),s.jsxs("div",{className:"mt-3 flex items-stretch gap-1.5",children:[s.jsxs("button",{onClick:n,"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:[s.jsx(dn,{name:"plus",size:13,stroke:1.8}),"New session"]}),s.jsx("div",{className:"flex items-center rounded-md bg-bg-hi border border-line",children:s.jsx(L2,{})})]})]})}function Rv({label:e,collapsed:n,count:r,onToggle:i}){return s.jsxs("button",{onClick:i,"aria-expanded":!n,title:n?`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:[s.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:n?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),s.jsx("span",{className:"flex-1",children:e}),n&&s.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:r})]})}function W_({item:e,active:n,live:r,onClick:i,rail:o}){return s.jsxs("button",{onClick:i,title:e.hint,"data-testid":e.key==="scheduler"?"tour-scheduler":void 0,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${o?"justify-center px-0 py-[9px]":"gap-3 px-3.5 py-[9px] text-[14px]"} ${n?"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:[n&&s.jsx("span",{"aria-hidden":!0,className:`absolute top-3 bottom-3 w-[3px] rounded-sm bg-accent ${o?"-left-[4px]":"-left-[10px]"}`}),s.jsx("span",{className:`inline-flex ${n?"text-accent":"text-fg-faint"}`,children:s.jsx(dn,{name:e.icon,size:17,stroke:1.6})}),!o&&s.jsx("span",{className:"flex-1 truncate",children:e.label}),!o&&r&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"}),o&&r&&s.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 qT({tool:e,active:n,onClick:r,rail:i}){return s.jsxs("button",{onClick:r,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]"} ${n?"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:[n&&s.jsx("span",{"aria-hidden":!0,className:`absolute top-2 bottom-2 w-[3px] rounded-sm bg-accent ${i?"-left-[4px]":"-left-[10px]"}`}),s.jsx("span",{className:`inline-flex ${n?"text-accent":"text-fg-faint"}`,children:s.jsx(dn,{name:e.icon,size:15,stroke:1.6})}),!i&&s.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function VT({rail:e}){const n=Tt(u=>u.isRecording),r=kt(u=>u.tabs),i=kt(u=>u.activeTabId),o=r.find(u=>u.id===i)??null,[l,h]=L.useState(null);return L.useEffect(()=>{let u=!1;if(!(o!=null&&o.presetId)){h(null);return}return p2(o.presetId).then(d=>{u||h((d==null?void 0:d.model)??null)}).catch(()=>{u||h(null)}),()=>{u=!0}},[o==null?void 0:o.presetId]),e?s.jsx("div",{className:"py-2.5 border-t border-rule flex justify-center",children:s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n?"bg-red-500 animate-pulse":"bg-sage"}`,title:n?"recording":"idle"})}):s.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:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n?"bg-red-500 animate-pulse":"bg-sage"}`,title:n?"recording":"idle"}),s.jsx("span",{className:"truncate",title:l??"",children:n?"recording…":l?`Claude · ${Xm(l)}`:"Claude Code"})]})}function GT({onNavigate:e}){const n=kt(j=>j.tabs),r=kt(j=>j.activeTabId),i=n.find(j=>j.id===r)??null,o=w2(i),l=(o==null?void 0:o.lastEventAt)??0,h=Fh(j=>j.data),u=yc(j=>{var T;return((T=j.snapshot)==null?void 0:T.paused)??null}),d=z2((i==null?void 0:i.cwd)??null),[,m]=L.useState(0);L.useEffect(()=>{const j=setInterval(()=>m(T=>T+1),6e4);return()=>clearInterval(j)},[]);const x=(o==null?void 0:o.todos)??[],[g,b]=L.useState(!1),S=L.useRef(null);L.useEffect(()=>{if(!g)return;const j=T=>{S.current&&!S.current.contains(T.target)&&b(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[g]),L.useEffect(()=>{x.length===0&&b(!1)},[x.length]);const E=Ky(h),C=(E==null?void 0:E.usage.five_hour)??null,y=C?Math.round(C.utilization):null,v=(h==null?void 0:h.kind)==="ok"||(h==null?void 0:h.kind)==="ok-stale",_=l>0?YT(Date.now()-l):"—";return s.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:[s.jsxs("button",{onClick:()=>e==null?void 0:e("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:v?"Connected to Anthropic":"Disconnected",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v?"bg-sage":"bg-fg-faint"}`}),s.jsx("span",{children:v?"connected":"offline"})]}),s.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:y!=null?`${y}% of 5h window used`:"5h —"}),u&&s.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 ${u.reason==="auth"||u.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:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",u.reason]}),i&&s.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,d&&s.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",d]})]}),s.jsxs("span",{className:"text-fg-faint",children:["last activity: ",s.jsx("span",{className:"text-fg-dim",children:_})]}),x.length>0&&s.jsx(KT,{ref:S,todos:x,open:g,onToggle:()=>b(j=>!j)}),s.jsx("span",{className:"flex-1"}),s.jsxs("span",{className:"text-fg-faint",children:["v","0.37.0"]})]})}const KT=L.forwardRef(function({todos:n,open:r,onToggle:i},o){const l={completed:n.filter(h=>h.status==="completed").length,in_progress:n.filter(h=>h.status==="in_progress").length,pending:n.filter(h=>h.status==="pending").length};return s.jsxs("div",{ref:o,className:"relative",children:[s.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:[s.jsxs("span",{className:"text-green-400",children:["✓",l.completed]}),s.jsxs("span",{className:"text-accent",children:["●",l.in_progress]}),s.jsxs("span",{className:"text-fg-dim",children:["○",l.pending]}),s.jsxs("span",{className:"text-fg-faint",children:["todos ",r?"▾":"▴"]})]}),r&&s.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:s.jsx("ul",{className:"space-y-0.5",children:n.map((h,u)=>s.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${h.status==="in_progress"?"bg-bg-hi":""}`,children:[s.jsx(XT,{status:h.status}),s.jsx("span",{className:h.status==="completed"?"text-fg-faint line-through":h.status==="in_progress"?"text-fg":"text-fg-dim",children:h.status==="in_progress"&&h.activeForm?h.activeForm:h.content})]},u))})})]})});function XT({status:e}){return e==="completed"?s.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):e==="in_progress"?s.jsx("span",{className:"w-3 shrink-0",children:s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):s.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function YT(e){const n=Math.max(0,Math.floor(e/1e3));if(n<60)return`${n}s ago`;const r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}var Mv={exports:{}},q_;function JT(){return q_||(q_=1,(function(e,n){(function(r,i){e.exports=i()})(globalThis,(()=>(()=>{var r={4567:function(h,u,d){var m=this&&this.__decorate||function(_,j,T,A){var M,O=arguments.length,I=O<3?j:A===null?A=Object.getOwnPropertyDescriptor(j,T):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(_,j,T,A);else for(var z=_.length-1;z>=0;z--)(M=_[z])&&(I=(O<3?M(I):O>3?M(j,T,I):M(j,T))||I);return O>3&&I&&Object.defineProperty(j,T,I),I},x=this&&this.__param||function(_,j){return function(T,A){j(T,A,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.AccessibilityManager=void 0;const g=d(9042),b=d(9924),S=d(844),E=d(4725),C=d(2585),y=d(3656);let v=u.AccessibilityManager=class extends S.Disposable{constructor(_,j,T,A){super(),this._terminal=_,this._coreBrowserService=T,this._renderService=A,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 M=0;M<this._terminal.rows;M++)this._rowElements[M]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[M]);if(this._topBoundaryFocusListener=M=>this._handleBoundaryFocus(M,0),this._bottomBoundaryFocusListener=M=>this._handleBoundaryFocus(M,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((M=>this._handleResize(M.rows)))),this.register(this._terminal.onRender((M=>this._refreshRows(M.start,M.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((M=>this._handleChar(M)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
2895
+ */var __;function XN(){return __||(__=1,(function(e,n){var r=(()=>{var i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,h=Object.prototype.hasOwnProperty,u=(re=>typeof io<"u"?io:typeof Proxy<"u"?new Proxy(re,{get:(he,ve)=>(typeof io<"u"?io:he)[ve]}):re)(function(re){if(typeof io<"u")return io.apply(this,arguments);throw Error('Dynamic require of "'+re+'" is not supported')}),d=(re,he)=>()=>(re&&(he=re(re=0)),he),m=(re,he)=>{for(var ve in he)i(re,ve,{get:he[ve],enumerable:!0})},x=(re,he,ve,Te)=>{if(he&&typeof he=="object"||typeof he=="function")for(let Se of l(he))!h.call(re,Se)&&Se!==ve&&i(re,Se,{get:()=>he[Se],enumerable:!(Te=o(he,Se))||Te.enumerable});return re},g=re=>x(i({},"__esModule",{value:!0}),re),b,S,E,C,y,v=d(()=>{b=new Map,S=[],E=(re,he,ve)=>{if(he&&typeof he.init=="function"&&typeof he.createInferenceSessionHandler=="function"){let Te=b.get(re);if(Te===void 0)b.set(re,{backend:he,priority:ve});else{if(Te.priority>ve)return;if(Te.priority===ve&&Te.backend!==he)throw new Error(`cannot register backend "${re}" using priority ${ve}`)}if(ve>=0){let Se=S.indexOf(re);Se!==-1&&S.splice(Se,1);for(let Be=0;Be<S.length;Be++)if(b.get(S[Be]).priority<=ve){S.splice(Be,0,re);return}S.push(re)}return}throw new TypeError("not a valid backend")},C=async re=>{let he=b.get(re);if(!he)return"backend not found.";if(he.initialized)return he.backend;if(he.aborted)return he.error;{let ve=!!he.initPromise;try{return ve||(he.initPromise=he.backend.init(re)),await he.initPromise,he.initialized=!0,he.backend}catch(Te){return ve||(he.error=`${Te}`,he.aborted=!0),he.error}finally{delete he.initPromise}}},y=async re=>{let he=re.executionProviders||[],ve=he.map(Fe=>typeof Fe=="string"?Fe:Fe.name),Te=ve.length===0?S:ve,Se,Be=[],Ae=new Set;for(let Fe of Te){let et=await C(Fe);typeof et=="string"?Be.push({name:Fe,err:et}):(Se||(Se=et),Se===et&&Ae.add(Fe))}if(!Se)throw new Error(`no available backend found. ERR: ${Be.map(Fe=>`[${Fe.name}] ${Fe.err}`).join(", ")}`);for(let{name:Fe,err:et}of Be)ve.includes(Fe)&&console.warn(`removing requested execution provider "${Fe}" from session options because it is not available: ${et}`);let Re=he.filter(Fe=>Ae.has(typeof Fe=="string"?Fe:Fe.name));return[Se,new Proxy(re,{get:(Fe,et)=>et==="executionProviders"?Re:Reflect.get(Fe,et)})]}}),_=d(()=>{v()}),j,T=d(()=>{j="1.26.0"}),A,M,O=d(()=>{T(),A="warning",M={wasm:{},webgl:{},webgpu:{},versions:{common:j},set logLevel(re){if(re!==void 0){if(typeof re!="string"||["verbose","info","warning","error","fatal"].indexOf(re)===-1)throw new Error(`Unsupported logging level: ${re}`);A=re}},get logLevel(){return A}},Object.defineProperty(M,"logLevel",{enumerable:!0})}),I,z=d(()=>{O(),I=M}),U,W,Y=d(()=>{U=(re,he)=>{let ve=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(1,1);ve.width=re.dims[3],ve.height=re.dims[2];let Te=ve.getContext("2d");if(Te!=null){let Se,Be;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(Se=re.dims[2],Be=re.dims[3]):(Se=re.dims[3],Be=re.dims[2]);let Ae=(he==null?void 0:he.format)!==void 0?he.format:"RGB",Re=he==null?void 0:he.norm,Fe,et;Re===void 0||Re.mean===void 0?Fe=[255,255,255,255]:typeof Re.mean=="number"?Fe=[Re.mean,Re.mean,Re.mean,Re.mean]:(Fe=[Re.mean[0],Re.mean[1],Re.mean[2],0],Re.mean[3]!==void 0&&(Fe[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 it=Be*Se,tt=0,Xe=it,$t=it*2,Le=-1;Ae==="RGBA"?(tt=0,Xe=it,$t=it*2,Le=it*3):Ae==="RGB"?(tt=0,Xe=it,$t=it*2):Ae==="RBG"&&(tt=0,$t=it,Xe=it*2);for(let ut=0;ut<Be;ut++)for(let Cn=0;Cn<Se;Cn++){let Jt=(re.data[tt++]-et[0])*Fe[0],Qt=(re.data[Xe++]-et[1])*Fe[1],jn=(re.data[$t++]-et[2])*Fe[2],Ot=Le===-1?255:(re.data[Le++]-et[3])*Fe[3];Te.fillStyle="rgba("+Jt+","+Qt+","+jn+","+Ot+")",Te.fillRect(Cn,ut,1,1)}if("toDataURL"in ve)return ve.toDataURL();throw new Error("toDataURL is not supported")}else throw new Error("Can not access image data")},W=(re,he)=>{let ve=typeof document<"u"?document.createElement("canvas").getContext("2d"):new OffscreenCanvas(1,1).getContext("2d"),Te;if(ve!=null){let Se,Be,Ae;(he==null?void 0:he.tensorLayout)!==void 0&&he.tensorLayout==="NHWC"?(Se=re.dims[2],Be=re.dims[1],Ae=re.dims[3]):(Se=re.dims[3],Be=re.dims[2],Ae=re.dims[1]);let Re=he!==void 0&&he.format!==void 0?he.format:"RGB",Fe=he==null?void 0:he.norm,et,it;Fe===void 0||Fe.mean===void 0?et=[255,255,255,255]:typeof Fe.mean=="number"?et=[Fe.mean,Fe.mean,Fe.mean,Fe.mean]:(et=[Fe.mean[0],Fe.mean[1],Fe.mean[2],255],Fe.mean[3]!==void 0&&(et[3]=Fe.mean[3])),Fe===void 0||Fe.bias===void 0?it=[0,0,0,0]:typeof Fe.bias=="number"?it=[Fe.bias,Fe.bias,Fe.bias,Fe.bias]:(it=[Fe.bias[0],Fe.bias[1],Fe.bias[2],0],Fe.bias[3]!==void 0&&(it[3]=Fe.bias[3]));let tt=Be*Se;if(he!==void 0&&(he.format!==void 0&&Ae===4&&he.format!=="RGBA"||Ae===3&&he.format!=="RGB"&&he.format!=="BGR"))throw new Error("Tensor format doesn't match input tensor dims");let Xe=4,$t=0,Le=1,ut=2,Cn=3,Jt=0,Qt=tt,jn=tt*2,Ot=-1;Re==="RGBA"?(Jt=0,Qt=tt,jn=tt*2,Ot=tt*3):Re==="RGB"?(Jt=0,Qt=tt,jn=tt*2):Re==="RBG"&&(Jt=0,jn=tt,Qt=tt*2),Te=ve.createImageData(Se,Be);for(let Mn=0;Mn<Be*Se;$t+=Xe,Le+=Xe,ut+=Xe,Cn+=Xe,Mn++)Te.data[$t]=(re.data[Jt++]-it[0])*et[0],Te.data[Le]=(re.data[Qt++]-it[1])*et[1],Te.data[ut]=(re.data[jn++]-it[2])*et[2],Te.data[Cn]=Ot===-1?255:(re.data[Ot++]-it[3])*et[3]}else throw new Error("Can not access image data");return Te}}),V,H,te,oe,pe,ie,X=d(()=>{we(),V=(re,he)=>{if(re===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:ve,width:Te}=he,Se=he.norm??{mean:255,bias:0},Be,Ae;typeof Se.mean=="number"?Be=[Se.mean,Se.mean,Se.mean,Se.mean]:Be=[Se.mean[0],Se.mean[1],Se.mean[2],Se.mean[3]??255],typeof Se.bias=="number"?Ae=[Se.bias,Se.bias,Se.bias,Se.bias]:Ae=[Se.bias[0],Se.bias[1],Se.bias[2],Se.bias[3]??0];let Re=he.format!==void 0?he.format:"RGBA",Fe=he.tensorFormat!==void 0&&he.tensorFormat!==void 0?he.tensorFormat:"RGB",et=ve*Te,it=Fe==="RGBA"?new Float32Array(et*4):new Float32Array(et*3),tt=4,Xe=0,$t=1,Le=2,ut=3,Cn=0,Jt=et,Qt=et*2,jn=-1;Re==="RGB"&&(tt=3,Xe=0,$t=1,Le=2,ut=-1),Fe==="RGBA"?jn=et*3:Fe==="RBG"?(Cn=0,Qt=et,Jt=et*2):Fe==="BGR"&&(Qt=0,Jt=et,Cn=et*2);for(let Ot=0;Ot<et;Ot++,Xe+=tt,Le+=tt,$t+=tt,ut+=tt)it[Cn++]=(re[Xe]+Ae[0])/Be[0],it[Jt++]=(re[$t]+Ae[1])/Be[1],it[Qt++]=(re[Le]+Ae[2])/Be[2],jn!==-1&&ut!==-1&&(it[jn++]=(re[ut]+Ae[3])/Be[3]);return Fe==="RGBA"?new ne("float32",it,[1,4,ve,Te]):new ne("float32",it,[1,3,ve,Te])},H=async(re,he)=>{let ve=typeof HTMLImageElement<"u"&&re instanceof HTMLImageElement,Te=typeof ImageData<"u"&&re instanceof ImageData,Se=typeof ImageBitmap<"u"&&re instanceof ImageBitmap,Be=typeof re=="string",Ae,Re=he??{},Fe=()=>{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=it=>typeof HTMLCanvasElement<"u"&&it instanceof HTMLCanvasElement||it instanceof OffscreenCanvas?it.getContext("2d"):null;if(ve){let it=Fe();it.width=re.width,it.height=re.height;let tt=et(it);if(tt!=null){let Xe=re.height,$t=re.width;if(he!==void 0&&he.resizedHeight!==void 0&&he.resizedWidth!==void 0&&(Xe=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=Xe,Re.width=$t}else Re.tensorFormat="RGBA",Re.height=Xe,Re.width=$t;tt.drawImage(re,0,0),Ae=tt.getImageData(0,0,$t,Xe).data}else throw new Error("Can not access image data")}else if(Te){let it,tt;if(he!==void 0&&he.resizedWidth!==void 0&&he.resizedHeight!==void 0?(it=he.resizedHeight,tt=he.resizedWidth):(it=re.height,tt=re.width),he!==void 0&&(Re=he),Re.format="RGBA",Re.height=it,Re.width=tt,he!==void 0){let Xe=Fe();Xe.width=tt,Xe.height=it;let $t=et(Xe);if($t!=null)$t.putImageData(re,0,0),Ae=$t.getImageData(0,0,tt,it).data;else throw new Error("Can not access image data")}else Ae=re.data}else if(Se){if(he===void 0)throw new Error("Please provide image config with format for Imagebitmap");let it=Fe();it.width=re.width,it.height=re.height;let tt=et(it);if(tt!=null){let Xe=re.height,$t=re.width;return tt.drawImage(re,0,0,$t,Xe),Ae=tt.getImageData(0,0,$t,Xe).data,Re.height=Xe,Re.width=$t,V(Ae,Re)}else throw new Error("Can not access image data")}else{if(Be)return new Promise((it,tt)=>{let Xe=Fe(),$t=et(Xe);if(!re||!$t)return tt();let Le=new Image;Le.crossOrigin="Anonymous",Le.src=re,Le.onload=()=>{Xe.width=Le.width,Xe.height=Le.height,$t.drawImage(Le,0,0,Xe.width,Xe.height);let ut=$t.getImageData(0,0,Xe.width,Xe.height);Re.height=Xe.height,Re.width=Xe.width,it(V(ut.data,Re))}});throw new Error("Input data provided is not supported - aborted tensor creation")}if(Ae!==void 0)return V(Ae,Re);throw new Error("Input data provided is not supported - aborted tensor creation")},te=(re,he)=>{let{width:ve,height:Te,download:Se,dispose:Be}=he,Ae=[1,Te,ve,4];return new ne({location:"texture",type:"float32",texture:re,dims:Ae,download:Se,dispose:Be})},oe=(re,he)=>{let{dataType:ve,dims:Te,download:Se,dispose:Be}=he;return new ne({location:"gpu-buffer",type:ve??"float32",gpuBuffer:re,dims:Te,download:Se,dispose:Be})},pe=(re,he)=>{let{dataType:ve,dims:Te,download:Se,dispose:Be}=he;return new ne({location:"ml-tensor",type:ve??"float32",mlTensor:re,dims:Te,download:Se,dispose:Be})},ie=(re,he,ve)=>new ne({location:"cpu-pinned",type:re,data:he,dims:ve??[he.length]})}),Q,J,ae,le,fe=d(()=>{Q=new Map([["float32",Float32Array],["uint8",Uint8Array],["int8",Int8Array],["uint16",Uint16Array],["int16",Int16Array],["int32",Int32Array],["bool",Uint8Array],["float64",Float64Array],["uint32",Uint32Array],["int4",Uint8Array],["uint4",Uint8Array]]),J=new Map([[Float32Array,"float32"],[Uint8Array,"uint8"],[Int8Array,"int8"],[Uint16Array,"uint16"],[Int16Array,"int16"],[Int32Array,"int32"],[Float64Array,"float64"],[Uint32Array,"uint32"]]),ae=!1,le=()=>{if(!ae){ae=!0;let re=typeof BigInt64Array<"u"&&BigInt64Array.from,he=typeof BigUint64Array<"u"&&BigUint64Array.from,ve=globalThis.Float16Array,Te=typeof ve<"u"&&ve.from;re&&(Q.set("int64",BigInt64Array),J.set(BigInt64Array,"int64")),he&&(Q.set("uint64",BigUint64Array),J.set(BigUint64Array,"uint64")),Te?(Q.set("float16",ve),J.set(ve,"float16")):Q.set("float16",Uint16Array)}}}),Me,je,ye=d(()=>{we(),Me=re=>{let he=1;for(let ve=0;ve<re.length;ve++){let Te=re[ve];if(typeof Te!="number"||!Number.isSafeInteger(Te))throw new TypeError(`dims[${ve}] must be an integer, got: ${Te}`);if(Te<0)throw new RangeError(`dims[${ve}] must be a non-negative integer, got: ${Te}`);he*=Te}return he},je=(re,he)=>{switch(re.location){case"cpu":return new ne(re.type,re.data,he);case"cpu-pinned":return new ne({location:"cpu-pinned",data:re.data,type:re.type,dims:he});case"texture":return new ne({location:"texture",texture:re.texture,type:re.type,dims:he});case"gpu-buffer":return new ne({location:"gpu-buffer",gpuBuffer:re.gpuBuffer,type:re.type,dims:he});case"ml-tensor":return new ne({location:"ml-tensor",mlTensor:re.mlTensor,type:re.type,dims:he});default:throw new Error(`tensorReshape: tensor location ${re.location} is not supported`)}}}),ne,we=d(()=>{Y(),X(),fe(),ye(),ne=class{constructor(re,he,ve){le();let Te,Se;if(typeof re=="object"&&"location"in re)switch(this.dataLocation=re.location,Te=re.type,Se=re.dims,re.location){case"cpu-pinned":{let Ae=Q.get(Te);if(!Ae)throw new TypeError(`unsupported type "${Te}" to create tensor from pinned buffer`);if(!(re.data instanceof Ae))throw new TypeError(`buffer should be of type ${Ae.name}`);this.cpuData=re.data;break}case"texture":{if(Te!=="float32")throw new TypeError(`unsupported type "${Te}" to create tensor from texture`);this.gpuTextureData=re.texture,this.downloader=re.download,this.disposer=re.dispose;break}case"gpu-buffer":{if(Te!=="float32"&&Te!=="float16"&&Te!=="int32"&&Te!=="int64"&&Te!=="uint32"&&Te!=="uint8"&&Te!=="bool"&&Te!=="uint4"&&Te!=="int4")throw new TypeError(`unsupported type "${Te}" to create tensor from gpu buffer`);this.gpuBufferData=re.gpuBuffer,this.downloader=re.download,this.disposer=re.dispose;break}case"ml-tensor":{if(Te!=="float32"&&Te!=="float16"&&Te!=="int32"&&Te!=="int64"&&Te!=="uint32"&&Te!=="uint64"&&Te!=="int8"&&Te!=="uint8"&&Te!=="bool"&&Te!=="uint4"&&Te!=="int4")throw new TypeError(`unsupported type "${Te}" to create tensor from MLTensor`);this.mlTensorData=re.mlTensor,this.downloader=re.download,this.disposer=re.dispose;break}default:throw new Error(`Tensor constructor: unsupported location '${this.dataLocation}'`)}else{let Ae,Re;if(typeof re=="string")if(Te=re,Re=ve,re==="string"){if(!Array.isArray(he))throw new TypeError("A string tensor's data must be a string array.");Ae=he}else{let Fe=Q.get(re);if(Fe===void 0)throw new TypeError(`Unsupported tensor type: ${re}.`);if(Array.isArray(he)){if(re==="float16"&&Fe===Uint16Array||re==="uint4"||re==="int4")throw new TypeError(`Creating a ${re} tensor from number array is not supported. Please use ${Fe.name} as data.`);re==="uint64"||re==="int64"?Ae=Fe.from(he,BigInt):Ae=Fe.from(he)}else if(he instanceof Fe)Ae=he;else if(he instanceof Uint8ClampedArray)if(re==="uint8")Ae=Uint8Array.from(he);else throw new TypeError("A Uint8ClampedArray tensor's data must be type of uint8");else if(re==="float16"&&he instanceof Uint16Array&&Fe!==Uint16Array)Ae=new globalThis.Float16Array(he.buffer,he.byteOffset,he.length);else throw new TypeError(`A ${Te} tensor's data must be type of ${Fe}`)}else if(Re=he,Array.isArray(re)){if(re.length===0)throw new TypeError("Tensor type cannot be inferred from an empty array.");let Fe=typeof re[0];if(Fe==="string")Te="string",Ae=re;else if(Fe==="boolean")Te="bool",Ae=Uint8Array.from(re);else throw new TypeError(`Invalid element type of data array: ${Fe}.`)}else if(re instanceof Uint8ClampedArray)Te="uint8",Ae=Uint8Array.from(re);else{let Fe=J.get(re.constructor);if(Fe===void 0)throw new TypeError(`Unsupported type for tensor data: ${re.constructor}.`);Te=Fe,Ae=re}if(Re===void 0)Re=[Ae.length];else if(!Array.isArray(Re))throw new TypeError("A tensor's dims must be a number array");Se=Re,this.cpuData=Ae,this.dataLocation="cpu"}let Be=Me(Se);if(this.cpuData&&Be!==this.cpuData.length&&!((Te==="uint4"||Te==="int4")&&Math.ceil(Be/2)===this.cpuData.length))throw new Error(`Tensor's size(${Be}) does not match data length(${this.cpuData.length}).`);this.type=Te,this.dims=Se,this.size=Be}static async fromImage(re,he){return H(re,he)}static fromTexture(re,he){return te(re,he)}static fromGpuBuffer(re,he){return oe(re,he)}static fromMLTensor(re,he){return pe(re,he)}static fromPinnedBuffer(re,he,ve){return ie(re,he,ve)}toDataURL(re){return U(this,re)}toImageData(re){return W(this,re)}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(re){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,re&&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(re){if(this.ensureValid(),this.downloader||this.disposer)throw new Error("Cannot reshape a tensor that owns GPU resource.");return je(this,re)}}}),Ne,Je=d(()=>{we(),Ne=ne}),lt,xt,At,He,vt,st,an=d(()=>{O(),lt=(re,he)=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||console.timeStamp(`${re}::ORT::${he}`)},xt=(re,he)=>{var Se;let ve=((Se=new Error().stack)==null?void 0:Se.split(/\r\n|\r|\n/g))||[],Te=!1;for(let Be=0;Be<ve.length;Be++){if(Te&&!ve[Be].includes("TRACE_FUNC")){let Ae=`FUNC_${re}::${ve[Be].trim().split(" ")[1]}`;he&&(Ae+=`::${he}`),lt("CPU",Ae);return}ve[Be].includes("TRACE_FUNC")&&(Te=!0)}},At=re=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||xt("BEGIN",re)},He=re=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||xt("END",re)},vt=re=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||console.time(`ORT::${re}`)},st=re=>{(typeof M.trace>"u"?!M.wasm.trace:!M.trace)||console.timeEnd(`ORT::${re}`)}}),sn,Ye=d(()=>{v(),Je(),an(),sn=class E2{constructor(he){this.handler=he}async run(he,ve,Te){At(),vt("InferenceSession.run");let Se={},Be={};if(typeof he!="object"||he===null||he instanceof Ne||Array.isArray(he))throw new TypeError("'feeds' must be an object that use input names as keys and OnnxValue as corresponding values.");let Ae=!0;if(typeof ve=="object"){if(ve===null)throw new TypeError("Unexpected argument[1]: cannot be null.");if(ve instanceof Ne)throw new TypeError("'fetches' cannot be a Tensor");if(Array.isArray(ve)){if(ve.length===0)throw new TypeError("'fetches' cannot be an empty array.");Ae=!1;for(let et of ve){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}.`);Se[et]=null}if(typeof Te=="object"&&Te!==null)Be=Te;else if(typeof Te<"u")throw new TypeError("'options' must be an object.")}else{let et=!1,it=Object.getOwnPropertyNames(ve);for(let tt of this.outputNames)if(it.indexOf(tt)!==-1){let Xe=ve[tt];(Xe===null||Xe instanceof Ne)&&(et=!0,Ae=!1,Se[tt]=Xe)}if(et){if(typeof Te=="object"&&Te!==null)Be=Te;else if(typeof Te<"u")throw new TypeError("'options' must be an object.")}else Be=ve}}else if(typeof ve<"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(Ae)for(let et of this.outputNames)Se[et]=null;let Re=await this.handler.run(he,Se,Be),Fe={};for(let et in Re)if(Object.hasOwnProperty.call(Re,et)){let it=Re[et];it instanceof Ne?Fe[et]=it:Fe[et]=new Ne(it.type,it.data,it.dims)}return st("InferenceSession.run"),He(),Fe}async release(){return this.handler.dispose()}static async create(he,ve,Te,Se){At(),vt("InferenceSession.create");let Be,Ae={};if(typeof he=="string"){if(Be=he,typeof ve=="object"&&ve!==null)Ae=ve;else if(typeof ve<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof Uint8Array){if(Be=he,typeof ve=="object"&&ve!==null)Ae=ve;else if(typeof ve<"u")throw new TypeError("'options' must be an object.")}else if(he instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&he instanceof SharedArrayBuffer){let it=he,tt=0,Xe=he.byteLength;if(typeof ve=="object"&&ve!==null)Ae=ve;else if(typeof ve=="number"){if(tt=ve,!Number.isSafeInteger(tt))throw new RangeError("'byteOffset' must be an integer.");if(tt<0||tt>=it.byteLength)throw new RangeError(`'byteOffset' is out of range [0, ${it.byteLength}).`);if(Xe=he.byteLength-tt,typeof Te=="number"){if(Xe=Te,!Number.isSafeInteger(Xe))throw new RangeError("'byteLength' must be an integer.");if(Xe<=0||tt+Xe>it.byteLength)throw new RangeError(`'byteLength' is out of range (0, ${it.byteLength-tt}].`);if(typeof Se=="object"&&Se!==null)Ae=Se;else if(typeof Se<"u")throw new TypeError("'options' must be an object.")}else if(typeof Te<"u")throw new TypeError("'byteLength' must be a number.")}else if(typeof ve<"u")throw new TypeError("'options' must be an object.");Be=new Uint8Array(it,tt,Xe)}else throw new TypeError("Unexpected argument[0]: must be 'path' or 'buffer'.");let[Re,Fe]=await y(Ae),et=await Re.createInferenceSessionHandler(Be,Fe);return st("InferenceSession.create"),He(),new E2(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}}}),yt,_t=d(()=>{Ye(),yt=sn}),Kt=d(()=>{}),On=d(()=>{}),Rn=d(()=>{}),Br=d(()=>{}),Tr={};m(Tr,{InferenceSession:()=>yt,TRACE:()=>lt,TRACE_EVENT_BEGIN:()=>vt,TRACE_EVENT_END:()=>st,TRACE_FUNC_BEGIN:()=>At,TRACE_FUNC_END:()=>He,Tensor:()=>Ne,env:()=>I,registerBackend:()=>E});var rt=d(()=>{_(),z(),_t(),Je(),Kt(),On(),an(),Rn(),Br()}),St=d(()=>{}),Rt={};m(Rt,{default:()=>$r});var cn,nn,$r,Ea=d(()=>{var re;be(),Hr(),Ur(),cn="ort-wasm-proxy-worker",nn=((re=globalThis.self)==null?void 0:re.name)===cn,nn&&(self.onmessage=he=>{let{type:ve,in:Te}=he.data;try{switch(ve){case"init-wasm":ei(Te.wasm).then(()=>{Vo(Te).then(()=>{postMessage({type:ve})},Se=>{postMessage({type:ve,err:Se})})},Se=>{postMessage({type:ve,err:Se})});break;case"init-ep":{let{epName:Se,env:Be}=Te;Si(Be,Se).then(()=>{postMessage({type:ve})},Ae=>{postMessage({type:ve,err:Ae})});break}case"copy-from":{let{buffer:Se}=Te,Be=on(Se);postMessage({type:ve,out:Be});break}case"create":{let{model:Se,options:Be}=Te;ds(Se,Be).then(Ae=>{postMessage({type:ve,out:Ae})},Ae=>{postMessage({type:ve,err:Ae})});break}case"release":Hi(Te),postMessage({type:ve});break;case"run":{let{sessionId:Se,inputIndices:Be,inputs:Ae,outputIndices:Re,options:Fe}=Te;Ke(Se,Be,Ae,Re,new Array(Re.length).fill(null),Fe).then(et=>{et.some(it=>it[3]!=="cpu")?postMessage({type:ve,err:"Proxy does not support non-cpu tensor location."}):postMessage({type:ve,out:et},ft([...Ae,...et]))},et=>{postMessage({type:ve,err:et})});break}case"end-profiling":qr(Te),postMessage({type:ve});break;default:}}catch(Se){postMessage({type:ve,err:Se})}}),$r=nn?null:he=>new Worker(he??yn,{type:"classic",name:cn})}),Wo,yi,yn,Fr,Zn,vi,Ms,as,Bi,bi,wi,Is,Ar,Ur=d(()=>{St(),Wo=typeof location>"u"?void 0:location.origin,yi=()=>{var re,he;return typeof document<"u"?(re=document.currentScript)==null?void 0:re.src:typeof self<"u"?(he=self.location)==null?void 0:he.href:void 0},yn=yi(),Fr=()=>{if(yn&&!yn.startsWith("blob:"))return yn.substring(0,yn.lastIndexOf("/")+1)},Zn=(re,he)=>{try{let ve=he??yn;return(ve?new URL(re,ve):new URL(re)).origin===Wo}catch{return!1}},vi=(re,he)=>{let ve=he??yn;try{return(ve?new URL(re,ve):new URL(re)).href}catch{return}},Ms=(re,he)=>`${he??"./"}${re}`,as=async re=>{let he=await(await fetch(re,{credentials:"same-origin"})).blob();return URL.createObjectURL(he)},Bi=async re=>(await import(re)).default,bi=(Ea(),g(Rt)).default,wi=async()=>{if(!yn)throw new Error("Failed to load proxy worker: cannot determine the script source URL.");if(Zn(yn))return[void 0,bi()];let re=await as(yn);return[re,bi(re)]},Is=void 0,Ar=async(re,he,ve,Te)=>{let Se=Is&&!(re||he);if(Se)if(yn)Se=Zn(yn)||Te&&!ve;else if(Te&&!ve)Se=!0;else throw new Error("cannot determine the script source URL.");if(Se)return[void 0,Is];{let Be="ort-wasm-simd-threaded.mjs",Ae=re??vi(Be,he),Re=ve&&Ae&&!Zn(Ae,he),Fe=Re?await as(Ae):Ae??Ms(Be,he);return[Re?Fe:void 0,await Bi(Fe)]}}}),Js,Rr,ls,js,uo,Qs,Zs,ei,zt,Hr=d(()=>{Ur(),Rr=!1,ls=!1,js=!1,uo=()=>{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}},Qs=()=>{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}},Zs=()=>{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}},ei=async re=>{if(Rr)return Promise.resolve();if(ls)throw new Error("multiple calls to 'initializeWebAssembly()' detected.");if(js)throw new Error("previous call to 'initializeWebAssembly()' failed.");ls=!0;let he=re.initTimeout,ve=re.numThreads;if(re.simd!==!1){if(re.simd==="relaxed"){if(!Zs())throw new Error("Relaxed WebAssembly SIMD is not supported in the current environment.")}else if(!Qs())throw new Error("WebAssembly SIMD is not supported in the current environment.")}let Te=uo();ve>1&&!Te&&(typeof self<"u"&&!self.crossOriginIsolated&&console.warn("env.wasm.numThreads is set to "+ve+", 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."),re.numThreads=ve=1);let Se=re.wasmPaths,Be=typeof Se=="string"?Se:void 0,Ae=Se==null?void 0:Se.mjs,Re=(Ae==null?void 0:Ae.href)??Ae,Fe=Se==null?void 0:Se.wasm,et=(Fe==null?void 0:Fe.href)??Fe,it=re.wasmBinary,[tt,Xe]=await Ar(Re,Be,ve>1,!!it||!!et),$t=!1,Le=[];if(he>0&&Le.push(new Promise(ut=>{setTimeout(()=>{$t=!0,ut()},he)})),Le.push(new Promise((ut,Cn)=>{let Jt={numThreads:ve};if(it)Jt.wasmBinary=it,Jt.locateFile=Qt=>Qt;else if(et||Be)Jt.locateFile=Qt=>et??Be+Qt;else if(Re&&Re.indexOf("blob:")!==0)Jt.locateFile=Qt=>new URL(Qt,Re).href;else if(tt){let Qt=Fr();Qt&&(Jt.locateFile=jn=>Qt+jn)}Xe(Jt).then(Qt=>{ls=!1,Rr=!0,Js=Qt,ut(),tt&&URL.revokeObjectURL(tt)},Qt=>{ls=!1,js=!0,Cn(Qt)})})),await Promise.race(Le),$t)throw new Error(`WebAssembly backend initializing failed due to timeout: ${he}ms`)},zt=()=>{if(Rr&&Js)return Js;throw new Error("WebAssembly is not initialized yet.")}}),Hn,_n,Ct,Fi=d(()=>{Hr(),Hn=(re,he)=>{let ve=zt(),Te=ve.lengthBytesUTF8(re)+1,Se=ve._malloc(Te);return ve.stringToUTF8(re,Se,Te),he.push(Se),Se},_n=(re,he,ve,Te)=>{if(typeof re=="object"&&re!==null){if(ve.has(re))throw new Error("Circular reference in options");ve.add(re)}Object.entries(re).forEach(([Se,Be])=>{let Ae=he?he+Se:Se;if(typeof Be=="object")_n(Be,Ae+".",ve,Te);else if(typeof Be=="string"||typeof Be=="number")Te(Ae,Be.toString());else if(typeof Be=="boolean")Te(Ae,Be?"1":"0");else throw new Error(`Can't handle extra config type: ${typeof Be}`)})},Ct=re=>{let he=zt(),ve=he.stackSave();try{let Te=he.PTR_SIZE,Se=he.stackAlloc(2*Te);he._OrtGetLastError(Se,Se+Te);let Be=Number(he.getValue(Se,Te===4?"i32":"i64")),Ae=he.getValue(Se+Te,"*"),Re=Ae?he.UTF8ToString(Ae):"";throw new Error(`${re} ERROR_CODE: ${Be}, ERROR_MESSAGE: ${Re}`)}finally{he.stackRestore(ve)}}}),ho,Na=d(()=>{Hr(),Fi(),ho=re=>{let he=zt(),ve=0,Te=[],Se=re||{};try{if((re==null?void 0:re.logSeverityLevel)===void 0)Se.logSeverityLevel=2;else if(typeof re.logSeverityLevel!="number"||!Number.isInteger(re.logSeverityLevel)||re.logSeverityLevel<0||re.logSeverityLevel>4)throw new Error(`log severity level is not valid: ${re.logSeverityLevel}`);if((re==null?void 0:re.logVerbosityLevel)===void 0)Se.logVerbosityLevel=0;else if(typeof re.logVerbosityLevel!="number"||!Number.isInteger(re.logVerbosityLevel))throw new Error(`log verbosity level is not valid: ${re.logVerbosityLevel}`);(re==null?void 0:re.terminate)===void 0&&(Se.terminate=!1);let Be=0;return(re==null?void 0:re.tag)!==void 0&&(Be=Hn(re.tag,Te)),ve=he._OrtCreateRunOptions(Se.logSeverityLevel,Se.logVerbosityLevel,!!Se.terminate,Be),ve===0&&Ct("Can't create run options."),(re==null?void 0:re.extra)!==void 0&&_n(re.extra,"",new WeakSet,(Ae,Re)=>{let Fe=Hn(Ae,Te),et=Hn(Re,Te);he._OrtAddRunConfigEntry(ve,Fe,et)!==0&&Ct(`Can't set a run config entry: ${Ae} - ${Re}.`)}),[ve,Te]}catch(Be){throw ve!==0&&he._OrtReleaseRunOptions(ve),Te.forEach(Ae=>he._free(Ae)),Be}}}),fo,po,qo,Sr,Ta,$a,kn=d(()=>{Hr(),Fi(),fo=re=>{switch(re){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: ${re}`)}},po=re=>{switch(re){case"sequential":return 0;case"parallel":return 1;default:throw new Error(`unsupported execution mode: ${re}`)}},qo=re=>{re.extra||(re.extra={}),re.extra.session||(re.extra.session={});let he=re.extra.session;he.use_ort_model_bytes_directly||(he.use_ort_model_bytes_directly="1"),re.executionProviders&&re.executionProviders.some(ve=>(typeof ve=="string"?ve:ve.name)==="webgpu")&&(re.enableMemPattern=!1)},Sr=(re,he,ve,Te)=>{let Se=Hn(he,Te),Be=Hn(ve,Te);zt()._OrtAddSessionConfigEntry(re,Se,Be)!==0&&Ct(`Can't set a session config entry: ${he} - ${ve}.`)},Ta=async(re,he,ve)=>{let Te=he.executionProviders;for(let Se of Te){let Be=typeof Se=="string"?Se:Se.name,Ae=[];switch(Be){case"webnn":if(Be="WEBNN",Sr(re,"session.disable_quant_qdq","1",ve),Sr(re,"session.disable_qdq_constant_folding","1",ve),typeof Se!="string"){let tt=Se==null?void 0:Se.deviceType;tt&&Sr(re,"deviceType",tt,ve)}break;case"webgpu":if(Be="JS",typeof Se!="string"){let tt=Se;if(tt!=null&&tt.preferredLayout){if(tt.preferredLayout!=="NCHW"&&tt.preferredLayout!=="NHWC")throw new Error(`preferredLayout must be either 'NCHW' or 'NHWC': ${tt.preferredLayout}`);Sr(re,"preferredLayout",tt.preferredLayout,ve)}}break;case"wasm":case"cpu":continue;default:throw new Error(`not supported execution provider: ${Be}`)}let Re=Hn(Be,ve),Fe=Ae.length,et=0,it=0;if(Fe>0){et=zt()._malloc(Fe*zt().PTR_SIZE),ve.push(et),it=zt()._malloc(Fe*zt().PTR_SIZE),ve.push(it);for(let tt=0;tt<Fe;tt++)zt().setValue(et+tt*zt().PTR_SIZE,Ae[tt][0],"*"),zt().setValue(it+tt*zt().PTR_SIZE,Ae[tt][1],"*")}await zt()._OrtAppendExecutionProvider(re,Re,et,it,Fe)!==0&&Ct(`Can't append execution provider: ${Be}.`)}},$a=async re=>{let he=zt(),ve=0,Te=[],Se=re||{};qo(Se);try{let Be=fo(Se.graphOptimizationLevel??"all"),Ae=po(Se.executionMode??"sequential"),Re=typeof Se.logId=="string"?Hn(Se.logId,Te):0,Fe=Se.logSeverityLevel??2;if(!Number.isInteger(Fe)||Fe<0||Fe>4)throw new Error(`log severity level is not valid: ${Fe}`);let et=Se.logVerbosityLevel??0;if(!Number.isInteger(et)||et<0||et>4)throw new Error(`log verbosity level is not valid: ${et}`);let it=typeof Se.optimizedModelFilePath=="string"?Hn(Se.optimizedModelFilePath,Te):0;if(ve=he._OrtCreateSessionOptions(Be,!!Se.enableCpuMemArena,!!Se.enableMemPattern,Ae,!!Se.enableProfiling,0,Re,Fe,et,it),ve===0&&Ct("Can't create session options."),Se.executionProviders&&await Ta(ve,Se,Te),Se.enableGraphCapture!==void 0){if(typeof Se.enableGraphCapture!="boolean")throw new Error(`enableGraphCapture must be a boolean value: ${Se.enableGraphCapture}`);Sr(ve,"enableGraphCapture",Se.enableGraphCapture.toString(),Te)}if(Se.freeDimensionOverrides)for(let[tt,Xe]of Object.entries(Se.freeDimensionOverrides)){if(typeof tt!="string")throw new Error(`free dimension override name must be a string: ${tt}`);if(typeof Xe!="number"||!Number.isInteger(Xe)||Xe<0)throw new Error(`free dimension override value must be a non-negative integer: ${Xe}`);let $t=Hn(tt,Te);he._OrtAddFreeDimensionOverride(ve,$t,Xe)!==0&&Ct(`Can't set a free dimension override: ${tt} - ${Xe}.`)}return Se.extra!==void 0&&_n(Se.extra,"",new WeakSet,(tt,Xe)=>{Sr(ve,tt,Xe,Te)}),[ve,Te]}catch(Be){throw ve!==0&&he._OrtReleaseSessionOptions(ve)!==0&&Ct("Can't release session options."),Te.forEach(Ae=>he._free(Ae)),Be}}}),Mr,Vn,Ir,ti,Ui,_i,cs,gr,Bt=d(()=>{Mr=re=>{switch(re){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: ${re}`)}},Vn=re=>{switch(re){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: ${re}`)}},Ir=(re,he)=>{let ve=[-1,4,1,1,2,2,4,8,-1,1,2,8,4,8,-1,-1,-1,-1,-1,-1,-1,.5,.5][re],Te=typeof he=="number"?he:he.reduce((Se,Be)=>Se*Be,1);return ve>0?Math.ceil(Te*ve):void 0},ti=re=>{switch(re){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: ${re}`)}},Ui=re=>{switch(re){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: ${re}`)}},_i=re=>re==="float32"||re==="float16"||re==="int32"||re==="int64"||re==="uint32"||re==="uint8"||re==="bool"||re==="uint4"||re==="int4",cs=re=>re==="float32"||re==="float16"||re==="int32"||re==="int64"||re==="uint32"||re==="uint64"||re==="int8"||re==="uint8"||re==="bool"||re==="uint4"||re==="int4",gr=re=>{switch(re){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: ${re}`)}}}),Gn,ki=d(()=>{St(),Gn=async re=>{if(typeof re=="string"){let he=await fetch(re);if(!he.ok)throw new Error(`failed to load external data file: ${re}`);let ve=he.headers.get("Content-Length"),Te=ve?parseInt(ve,10):0;if(Te<1073741824)return new Uint8Array(await he.arrayBuffer());{if(!he.body)throw new Error(`failed to load external data file: ${re}, no response body.`);let Se=he.body.getReader(),Be;try{Be=new ArrayBuffer(Te)}catch(Re){if(Re instanceof RangeError){let Fe=Math.ceil(Te/65536);Be=new WebAssembly.Memory({initial:Fe,maximum:Fe}).buffer}else throw Re}let Ae=0;for(;;){let{done:Re,value:Fe}=await Se.read();if(Re)break;let et=Fe.byteLength;new Uint8Array(Be,Ae,et).set(Fe),Ae+=et}return new Uint8Array(Be,0,Te)}}else return re instanceof Blob?new Uint8Array(await re.arrayBuffer()):re instanceof Uint8Array?re:new Uint8Array(re)}}),us,Vo,Si,Wr,Ps,Ci,on,ds,Hi,Es,Ke,qr,ft,be=d(()=>{rt(),Na(),kn(),Bt(),Hr(),Fi(),ki(),us=(re,he)=>{zt()._OrtInit(re,he)!==0&&Ct("Can't initialize onnxruntime.")},Vo=async re=>{us(re.wasm.numThreads,Ui(re.logLevel))},Si=async(re,he)=>{var Te,Se;(Se=(Te=zt()).asyncInit)==null||Se.call(Te);let ve=re.webgpu.adapter;if(he==="webgpu"){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not supported in current environment");if(ve){if(typeof ve.limits!="object"||typeof ve.features!="object"||typeof ve.requestDevice!="function")throw new Error("Invalid GPU adapter set in `env.webgpu.adapter`. It must be a GPUAdapter object.")}else{let Be=re.webgpu.powerPreference;if(Be!==void 0&&Be!=="low-power"&&Be!=="high-performance")throw new Error(`Invalid powerPreference setting: "${Be}"`);let Ae=re.webgpu.forceFallbackAdapter;if(Ae!==void 0&&typeof Ae!="boolean")throw new Error(`Invalid forceFallbackAdapter setting: "${Ae}"`);if(ve=await navigator.gpu.requestAdapter({powerPreference:Be,forceFallbackAdapter:Ae}),!ve)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")},Wr=new Map,Ps=re=>{let he=zt(),ve=he.stackSave();try{let Te=he.PTR_SIZE,Se=he.stackAlloc(2*Te);he._OrtGetInputOutputCount(re,Se,Se+Te)!==0&&Ct("Can't get session input/output count.");let Be=Te===4?"i32":"i64";return[Number(he.getValue(Se,Be)),Number(he.getValue(Se+Te,Be))]}finally{he.stackRestore(ve)}},Ci=(re,he)=>{let ve=zt(),Te=ve.stackSave(),Se=0;try{let Be=ve.PTR_SIZE,Ae=ve.stackAlloc(2*Be);ve._OrtGetInputOutputMetadata(re,he,Ae,Ae+Be)!==0&&Ct("Can't get session input/output metadata.");let Re=Number(ve.getValue(Ae,"*"));Se=Number(ve.getValue(Ae+Be,"*"));let Fe=ve.HEAP32[Se/4];if(Fe===0)return[Re,0];let et=ve.HEAPU32[Se/4+1],it=[];for(let tt=0;tt<et;tt++){let Xe=Number(ve.getValue(Se+8+tt*Be,"*"));it.push(Xe!==0?ve.UTF8ToString(Xe):Number(ve.getValue(Se+8+(tt+et)*Be,"*")))}return[Re,Fe,it]}finally{ve.stackRestore(Te),Se!==0&&ve._OrtFree(Se)}},on=re=>{let he=zt(),ve=he._malloc(re.byteLength);if(ve===0)throw new Error(`Can't create a session. failed to allocate a buffer of size ${re.byteLength}.`);return he.HEAPU8.set(re,ve),[ve,re.byteLength]},ds=async(re,he)=>{var it,tt,Xe;let ve,Te,Se=zt();Array.isArray(re)?[ve,Te]=re:re.buffer===Se.HEAPU8.buffer?[ve,Te]=[re.byteOffset,re.byteLength]:[ve,Te]=on(re);let Be=0,Ae=0,Re=[],Fe=[],et=[];try{if([Ae,Re]=await $a(he),(he==null?void 0:he.externalData)&&Se.mountExternalData){let Mn=[];for(let hn of he.externalData){let xr=typeof hn=="string"?hn:hn.path;Mn.push(Gn(typeof hn=="string"?hn:hn.data).then(Pr=>{Se.mountExternalData(xr,Pr)}))}await Promise.all(Mn)}for(let Mn of(he==null?void 0:he.executionProviders)??[])if((typeof Mn=="string"?Mn:Mn.name)==="webnn"){if(Se.shouldTransferToMLTensor=!1,typeof Mn!="string"){let hn=Mn,xr=hn==null?void 0:hn.context,Pr=hn==null?void 0:hn.gpuDevice,Vr=hn==null?void 0:hn.deviceType,Ra=hn==null?void 0:hn.powerPreference;xr?Se.currentContext=xr:Pr?Se.currentContext=await Se.webnnCreateMLContext(Pr):Se.currentContext=await Se.webnnCreateMLContext({deviceType:Vr,powerPreference:Ra})}else Se.currentContext=await Se.webnnCreateMLContext();break}Be=await Se._OrtCreateSession(ve,Te,Ae),(it=Se.webgpuOnCreateSession)==null||it.call(Se,Be),Be===0&&Ct("Can't create a session."),(tt=Se.jsepOnCreateSession)==null||tt.call(Se),Se.currentContext&&(Se.webnnRegisterMLContext(Be,Se.currentContext),Se.currentContext=void 0,Se.shouldTransferToMLTensor=!0);let[$t,Le]=Ps(Be),ut=!!(he!=null&&he.enableGraphCapture),Cn=[],Jt=[],Qt=[],jn=[],Ot=[];for(let Mn=0;Mn<$t;Mn++){let[hn,xr,Pr]=Ci(Be,Mn);hn===0&&Ct("Can't get an input name."),Fe.push(hn);let Vr=Se.UTF8ToString(hn);Cn.push(Vr),Qt.push(xr===0?{name:Vr,isTensor:!1}:{name:Vr,isTensor:!0,type:Vn(xr),shape:Pr})}for(let Mn=0;Mn<Le;Mn++){let[hn,xr,Pr]=Ci(Be,Mn+$t);hn===0&&Ct("Can't get an output name."),et.push(hn);let Vr=Se.UTF8ToString(hn);Jt.push(Vr),jn.push(xr===0?{name:Vr,isTensor:!1}:{name:Vr,isTensor:!0,type:Vn(xr),shape:Pr})}return Wr.set(Be,[Be,Fe,et,null,ut,!1]),[Be,Cn,Jt,Qt,jn]}catch($t){throw Fe.forEach(Le=>Se._OrtFree(Le)),et.forEach(Le=>Se._OrtFree(Le)),Be!==0&&Se._OrtReleaseSession(Be)!==0&&Ct("Can't release session."),$t}finally{Se._free(ve),Ae!==0&&Se._OrtReleaseSessionOptions(Ae)!==0&&Ct("Can't release session options."),Re.forEach($t=>Se._free($t)),(Xe=Se.unmountExternalData)==null||Xe.call(Se)}},Hi=re=>{var Fe,et,it;let he=zt(),ve=Wr.get(re);if(!ve)throw new Error(`cannot release session. invalid session id: ${re}`);let[Te,Se,Be,Ae,Re]=ve;Ae&&(Re&&he._OrtClearBoundOutputs(Ae.handle)!==0&&Ct("Can't clear bound outputs."),he._OrtReleaseBinding(Ae.handle)!==0&&Ct("Can't release IO binding.")),(Fe=he.jsepOnReleaseSession)==null||Fe.call(he,re),(et=he.webnnOnReleaseSession)==null||et.call(he,re),(it=he.webgpuOnReleaseSession)==null||it.call(he,re),Se.forEach(tt=>he._OrtFree(tt)),Be.forEach(tt=>he._OrtFree(tt)),he._OrtReleaseSession(Te)!==0&&Ct("Can't release session."),Wr.delete(re)},Es=async(re,he,ve,Te,Se,Be,Ae=!1)=>{if(!re){he.push(0);return}let Re=zt(),Fe=Re.PTR_SIZE,et=re[0],it=re[1],tt=re[3],Xe=tt,$t,Le;if(et==="string"&&(tt==="gpu-buffer"||tt==="ml-tensor"))throw new Error("String tensor is not supported on GPU.");if(Ae&&tt!=="gpu-buffer")throw new Error(`External buffer must be provided for input/output index ${Be} when enableGraphCapture is true.`);if(tt==="gpu-buffer"){let Jt=re[2].gpuBuffer;Le=Ir(Mr(et),it);{let Qt=Re.jsepRegisterBuffer;if(!Qt)throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');$t=Qt(Te,Be,Jt,Le)}}else if(tt==="ml-tensor"){let Jt=re[2].mlTensor;Le=Ir(Mr(et),it);let Qt=Re.webnnRegisterMLTensor;if(!Qt)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');$t=Qt(Te,Jt,Mr(et),it)}else{let Jt=re[2];if(Array.isArray(Jt)){Le=Fe*Jt.length,$t=Re._malloc(Le),ve.push($t);for(let Qt=0;Qt<Jt.length;Qt++){if(typeof Jt[Qt]!="string")throw new TypeError(`tensor data at index ${Qt} is not a string`);Re.setValue($t+Qt*Fe,Hn(Jt[Qt],ve),"*")}}else{let Qt=Re.webnnIsGraphInput,jn=Re.webnnIsGraphOutput;if(et!=="string"&&Qt&&jn){let Ot=Re.UTF8ToString(Se);if(Qt(Te,Ot)||jn(Te,Ot)){let Mn=Mr(et);Le=Ir(Mn,it),Xe="ml-tensor";let hn=Re.webnnCreateTemporaryTensor,xr=Re.webnnUploadTensor;if(!hn||!xr)throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');let Pr=await hn(Te,Mn,it);xr(Pr,new Uint8Array(Jt.buffer,Jt.byteOffset,Jt.byteLength)),$t=Pr}else Le=Jt.byteLength,$t=Re._malloc(Le),ve.push($t),Re.HEAPU8.set(new Uint8Array(Jt.buffer,Jt.byteOffset,Le),$t)}else Le=Jt.byteLength,$t=Re._malloc(Le),ve.push($t),Re.HEAPU8.set(new Uint8Array(Jt.buffer,Jt.byteOffset,Le),$t)}}let ut=Re.stackSave(),Cn=Re.stackAlloc(4*it.length);try{it.forEach((Qt,jn)=>Re.setValue(Cn+jn*Fe,Qt,Fe===4?"i32":"i64"));let Jt=Re._OrtCreateTensor(Mr(et),$t,Le,Cn,it.length,gr(Xe));Jt===0&&Ct(`Can't create tensor for input/output. session=${Te}, index=${Be}.`),he.push(Jt)}finally{Re.stackRestore(ut)}},Ke=async(re,he,ve,Te,Se,Be)=>{var Gr,_l,jc;let Ae=zt(),Re=Ae.PTR_SIZE,Fe=Wr.get(re);if(!Fe)throw new Error(`cannot run inference. invalid session id: ${re}`);let et=Fe[0],it=Fe[1],tt=Fe[2],Xe=Fe[3],$t=Fe[4];Fe[5];let Le=he.length,ut=Te.length,Cn=0,Jt=[],Qt=[],jn=[],Ot=[],Mn=[],hn=Ae.stackSave(),xr=Ae.stackAlloc(Le*Re),Pr=Ae.stackAlloc(Le*Re),Vr=Ae.stackAlloc(ut*Re),Ra=Ae.stackAlloc(ut*Re);try{[Cn,Jt]=ho(Be),vt("wasm prepareInputOutputTensor");for(let un=0;un<Le;un++)await Es(ve[un],Qt,Ot,re,it[he[un]],he[un],$t);for(let un=0;un<ut;un++)await Es(Se[un],jn,Ot,re,tt[Te[un]],Le+Te[un],$t);st("wasm prepareInputOutputTensor");for(let un=0;un<Le;un++)Ae.setValue(xr+un*Re,Qt[un],"*"),Ae.setValue(Pr+un*Re,it[he[un]],"*");for(let un=0;un<ut;un++)Ae.setValue(Vr+un*Re,jn[un],"*"),Ae.setValue(Ra+un*Re,tt[Te[un]],"*");(Gr=Ae.jsepOnRunStart)==null||Gr.call(Ae,et),(_l=Ae.webnnOnRunStart)==null||_l.call(Ae,et);let yr;yr=await Ae._OrtRun(et,Pr,xr,Le,Ra,ut,Vr,Cn),yr!==0&&Ct("failed to call OrtRun().");let ri=[],Ec=[];vt("wasm ProcessOutputTensor");for(let un=0;un<ut;un++){let Os=Number(Ae.getValue(Vr+un*Re,"*"));if(Os===jn[un]||Mn.includes(jn[un])){ri.push(Se[un]),Os!==jn[un]&&Ae._OrtReleaseTensor(Os)!==0&&Ct("Can't release tensor.");continue}let Vu=Ae.stackSave(),Ni=Ae.stackAlloc(4*Re),Go=!1,ir,Kr=0;try{Ae._OrtGetTensorData(Os,Ni,Ni+Re,Ni+2*Re,Ni+3*Re)!==0&&Ct(`Can't access output tensor data on index ${un}.`);let kl=Re===4?"i32":"i64",Xr=Number(Ae.getValue(Ni,kl));Kr=Ae.getValue(Ni+Re,"*");let Nc=Ae.getValue(Ni+Re*2,"*"),Gu=Number(Ae.getValue(Ni+Re*3,kl)),Ti=[];for(let or=0;or<Gu;or++)Ti.push(Number(Ae.getValue(Nc+or*Re,kl)));Ae._OrtFree(Nc)!==0&&Ct("Can't free memory for tensor dims.");let Ls=Ti.reduce((or,Wn)=>or*Wn,1);ir=Vn(Xr);let si=Xe==null?void 0:Xe.outputPreferredLocations[Te[un]];if(ir==="string"){if(si==="gpu-buffer"||si==="ml-tensor")throw new Error("String tensor is not supported on GPU.");let or=[];for(let Wn=0;Wn<Ls;Wn++){let zs=Ae.getValue(Kr+Wn*Re,"*"),Tc=Ae.getValue(Kr+(Wn+1)*Re,"*"),$c=Wn===Ls-1?void 0:Tc-zs;or.push(Ae.UTF8ToString(zs,$c))}ri.push([ir,Ti,or,"cpu"])}else if(si==="gpu-buffer"&&Ls>0){let or=Ae.jsepGetBuffer;if(!or)throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');let Wn=or(Kr),zs=Ir(Xr,Ls);if(zs===void 0||!_i(ir))throw new Error(`Unsupported data type: ${ir}`);Go=!0,ri.push([ir,Ti,{gpuBuffer:Wn,download:Ae.jsepCreateDownloader(Wn,zs,ir),dispose:()=>{Ae._OrtReleaseTensor(Os)!==0&&Ct("Can't release tensor.")}},"gpu-buffer"])}else if(si==="ml-tensor"&&Ls>0){let or=Ae.webnnEnsureTensor,Wn=Ae.webnnIsGraphInputOutputTypeSupported;if(!or||!Wn)throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');if(Ir(Xr,Ls)===void 0||!cs(ir))throw new Error(`Unsupported data type: ${ir}`);if(!Wn(re,ir,!1))throw new Error(`preferredLocation "ml-tensor" for ${ir} output is not supported by current WebNN Context.`);let zs=await or(re,Kr,Xr,Ti,!1);Go=!0,ri.push([ir,Ti,{mlTensor:zs,download:Ae.webnnCreateMLTensorDownloader(Kr,ir),dispose:()=>{Ae.webnnReleaseTensorId(Kr),Ae._OrtReleaseTensor(Os)}},"ml-tensor"])}else if(si==="ml-tensor-cpu-output"&&Ls>0){let or=Ae.webnnCreateMLTensorDownloader(Kr,ir)(),Wn=ri.length;Go=!0,Ec.push((async()=>{let zs=[Wn,await or];return Ae.webnnReleaseTensorId(Kr),Ae._OrtReleaseTensor(Os),zs})()),ri.push([ir,Ti,[],"cpu"])}else{let or=ti(ir),Wn=new or(Ls);new Uint8Array(Wn.buffer,Wn.byteOffset,Wn.byteLength).set(Ae.HEAPU8.subarray(Kr,Kr+Wn.byteLength)),ri.push([ir,Ti,Wn,"cpu"])}}finally{Ae.stackRestore(Vu),ir==="string"&&Kr&&Ae._free(Kr),Go||Ae._OrtReleaseTensor(Os)}}Xe&&!$t&&(Ae._OrtClearBoundOutputs(Xe.handle)!==0&&Ct("Can't clear bound outputs."),Wr.set(re,[et,it,tt,Xe,$t,!1]));for(let[un,Os]of await Promise.all(Ec))ri[un][2]=Os;return st("wasm ProcessOutputTensor"),ri}finally{(jc=Ae.webnnOnRunEnd)==null||jc.call(Ae,et),Ae.stackRestore(hn),Qt.forEach(yr=>Ae._OrtReleaseTensor(yr)),jn.forEach(yr=>Ae._OrtReleaseTensor(yr)),Ot.forEach(yr=>Ae._free(yr)),Cn!==0&&Ae._OrtReleaseRunOptions(Cn),Jt.forEach(yr=>Ae._free(yr))}},qr=re=>{let he=zt(),ve=Wr.get(re);if(!ve)throw new Error("invalid session id");let Te=ve[0],Se=he._OrtEndProfiling(Te);Se===0&&Ct("Can't get an profile file name."),he._OrtFree(Se)},ft=re=>{let he=[];for(let ve of re){let Te=ve[2];!Array.isArray(Te)&&"buffer"in Te&&he.push(Te.buffer)}return he}}),Pe,Qe,Et,en,ln,Tn,En,er,Ln,sr,Nn,Ds,Wi,mo,ni,qu,go,xo,kc=d(()=>{rt(),be(),Hr(),Ur(),Pe=()=>!!I.wasm.proxy&&typeof document<"u",Et=!1,en=!1,ln=!1,er=new Map,Ln=(re,he)=>{let ve=er.get(re);ve?ve.push(he):er.set(re,[he])},sr=()=>{if(Et||!en||ln||!Qe)throw new Error("worker not ready")},Nn=re=>{switch(re.data.type){case"init-wasm":Et=!1,re.data.err?(ln=!0,En[1](re.data.err)):(en=!0,En[0]()),Tn&&(URL.revokeObjectURL(Tn),Tn=void 0);break;case"init-ep":case"copy-from":case"create":case"release":case"run":case"end-profiling":{let he=er.get(re.data.type);re.data.err?he.shift()[1](re.data.err):he.shift()[0](re.data.out);break}}},Ds=async()=>{if(!en){if(Et)throw new Error("multiple calls to 'initWasm()' detected.");if(ln)throw new Error("previous call to 'initWasm()' failed.");if(Et=!0,Pe())return new Promise((re,he)=>{Qe==null||Qe.terminate(),wi().then(([ve,Te])=>{try{Qe=Te,Qe.onerror=Be=>he(Be),Qe.onmessage=Nn,En=[re,he];let Se={type:"init-wasm",in:I};if(!Se.in.wasm.wasmPaths&&ve){let Be=Fr();Be&&(Se.in.wasm.wasmPaths=Be)}Qe.postMessage(Se),Tn=ve}catch(Se){he(Se)}},he)});try{await ei(I.wasm),await Vo(I),en=!0}catch(re){throw ln=!0,re}finally{Et=!1}}},Wi=async re=>{if(Pe())return sr(),new Promise((he,ve)=>{Ln("init-ep",[he,ve]);let Te={type:"init-ep",in:{epName:re,env:I}};Qe.postMessage(Te)});await Si(I,re)},mo=async re=>Pe()?(sr(),new Promise((he,ve)=>{Ln("copy-from",[he,ve]);let Te={type:"copy-from",in:{buffer:re}};Qe.postMessage(Te,[re.buffer])})):on(re),ni=async(re,he)=>{if(Pe()){if(he!=null&&he.preferredOutputLocation)throw new Error('session option "preferredOutputLocation" is not supported for proxy.');return sr(),new Promise((ve,Te)=>{Ln("create",[ve,Te]);let Se={type:"create",in:{model:re,options:{...he}}},Be=[];re instanceof Uint8Array&&Be.push(re.buffer),Qe.postMessage(Se,Be)})}else return ds(re,he)},qu=async re=>{if(Pe())return sr(),new Promise((he,ve)=>{Ln("release",[he,ve]);let Te={type:"release",in:re};Qe.postMessage(Te)});Hi(re)},go=async(re,he,ve,Te,Se,Be)=>{if(Pe()){if(ve.some(Ae=>Ae[3]!=="cpu"))throw new Error("input tensor on GPU is not supported for proxy.");if(Se.some(Ae=>Ae))throw new Error("pre-allocated output tensor is not supported for proxy.");return sr(),new Promise((Ae,Re)=>{Ln("run",[Ae,Re]);let Fe=ve,et={type:"run",in:{sessionId:re,inputIndices:he,inputs:Fe,outputIndices:Te,options:Be}};Qe.postMessage(et,ft(Fe))})}else return Ke(re,he,ve,Te,Se,Be)},xo=async re=>{if(Pe())return sr(),new Promise((he,ve)=>{Ln("end-profiling",[he,ve]);let Te={type:"end-profiling",in:re};Qe.postMessage(Te)});qr(re)}}),yl,yo,Aa,vl=d(()=>{rt(),kc(),Bt(),St(),ki(),yl=(re,he)=>{switch(re.location){case"cpu":return[re.type,re.dims,re.data,"cpu"];case"gpu-buffer":return[re.type,re.dims,{gpuBuffer:re.gpuBuffer},"gpu-buffer"];case"ml-tensor":return[re.type,re.dims,{mlTensor:re.mlTensor},"ml-tensor"];default:throw new Error(`invalid data location: ${re.location} for ${he()}`)}},yo=re=>{switch(re[3]){case"cpu":return new Ne(re[0],re[2],re[1]);case"gpu-buffer":{let he=re[0];if(!_i(he))throw new Error(`not supported data type: ${he} for deserializing GPU tensor`);let{gpuBuffer:ve,download:Te,dispose:Se}=re[2];return Ne.fromGpuBuffer(ve,{dataType:he,dims:re[1],download:Te,dispose:Se})}case"ml-tensor":{let he=re[0];if(!cs(he))throw new Error(`not supported data type: ${he} for deserializing MLTensor tensor`);let{mlTensor:ve,download:Te,dispose:Se}=re[2];return Ne.fromMLTensor(ve,{dataType:he,dims:re[1],download:Te,dispose:Se})}default:throw new Error(`invalid data location: ${re[3]}`)}},Aa=class{async fetchModelAndCopyToWasmMemory(re){return mo(await Gn(re))}async loadModel(re,he){At();let ve;typeof re=="string"?ve=await this.fetchModelAndCopyToWasmMemory(re):ve=re,[this.sessionId,this.inputNames,this.outputNames,this.inputMetadata,this.outputMetadata]=await ni(ve,he),He()}async dispose(){return qu(this.sessionId)}async run(re,he,ve){At();let Te=[],Se=[];Object.entries(re).forEach(tt=>{let Xe=tt[0],$t=tt[1],Le=this.inputNames.indexOf(Xe);if(Le===-1)throw new Error(`invalid input '${Xe}'`);Te.push($t),Se.push(Le)});let Be=[],Ae=[];Object.entries(he).forEach(tt=>{let Xe=tt[0],$t=tt[1],Le=this.outputNames.indexOf(Xe);if(Le===-1)throw new Error(`invalid output '${Xe}'`);Be.push($t),Ae.push(Le)});let Re=Te.map((tt,Xe)=>yl(tt,()=>`input "${this.inputNames[Se[Xe]]}"`)),Fe=Be.map((tt,Xe)=>tt?yl(tt,()=>`output "${this.outputNames[Ae[Xe]]}"`):null),et=await go(this.sessionId,Se,Re,Ae,Fe,ve),it={};for(let tt=0;tt<et.length;tt++)it[this.outputNames[Ae[tt]]]=Be[tt]??yo(et[tt]);return He(),it}startProfiling(){}endProfiling(){xo(this.sessionId)}}}),ji={};m(ji,{OnnxruntimeWebAssemblyBackend:()=>Ei,initializeFlags:()=>qi,wasmBackend:()=>vo});var qi,Ei,vo,Sc=d(()=>{rt(),kc(),vl(),qi=()=>{(typeof I.wasm.initTimeout!="number"||I.wasm.initTimeout<0)&&(I.wasm.initTimeout=0);let re=I.wasm.simd;if(typeof re!="boolean"&&re!==void 0&&re!=="fixed"&&re!=="relaxed"&&(console.warn(`Property "env.wasm.simd" is set to unknown value "${re}". Reset it to \`false\` and ignore SIMD feature checking.`),I.wasm.simd=!1),typeof I.wasm.proxy!="boolean"&&(I.wasm.proxy=!1),typeof I.wasm.trace!="boolean"&&(I.wasm.trace=!1),typeof I.wasm.numThreads!="number"||!Number.isInteger(I.wasm.numThreads)||I.wasm.numThreads<=0)if(typeof self<"u"&&!self.crossOriginIsolated)I.wasm.numThreads=1;else{let he=typeof navigator>"u"?u("node:os").cpus().length:navigator.hardwareConcurrency;I.wasm.numThreads=Math.min(4,Math.ceil((he||1)/2))}},Ei=class{async init(re){qi(),await Ds(),await Wi(re)}async createInferenceSessionHandler(re,he){let ve=new Aa;return await ve.loadModel(re,he),ve}},vo=new Ei}),Cc={};m(Cc,{InferenceSession:()=>yt,TRACE:()=>lt,TRACE_EVENT_BEGIN:()=>vt,TRACE_EVENT_END:()=>st,TRACE_FUNC_BEGIN:()=>At,TRACE_FUNC_END:()=>He,Tensor:()=>Ne,default:()=>wl,env:()=>I,registerBackend:()=>E}),rt(),rt(),rt();var bl="1.26.0",wl=Tr;{let re=(Sc(),g(ji)).wasmBackend;E("cpu",re,10),E("wasm",re,10)}return Object.defineProperty(I.versions,"web",{value:bl,enumerable:!0}),g(Cc)})();e.exports=r})($v)),$v.exports}var k_;function YN(){return k_||(k_=1,(function(e){var n=tl&&tl.__createBinding||(Object.create?(function(j,T,A,M){M===void 0&&(M=A);var O=Object.getOwnPropertyDescriptor(T,A);(!O||("get"in O?!T.__esModule:O.writable||O.configurable))&&(O={enumerable:!0,get:function(){return T[A]}}),Object.defineProperty(j,M,O)}):(function(j,T,A,M){M===void 0&&(M=A),j[M]=T[A]})),r=tl&&tl.__setModuleDefault||(Object.create?(function(j,T){Object.defineProperty(j,"default",{enumerable:!0,value:T})}):function(j,T){j.default=T}),i=tl&&tl.__importStar||function(j){if(j&&j.__esModule)return j;var T={};if(j!=null)for(var A in j)A!=="default"&&Object.prototype.hasOwnProperty.call(j,A)&&n(T,j,A);return r(T,j),T};Object.defineProperty(e,"__esModule",{value:!0}),e.MicVAD=e.getDefaultRealTimeVADOptions=e.ort=e.DEFAULT_MODEL=void 0;const o=i(XN()),l=Uw(),h=Hw(),u=Km(),d=Vy(),m=C2(),x=j2();e.DEFAULT_MODEL="legacy",e.ort=o;const g="vad.worklet.bundle.min.js",b="silero_vad_v5.onnx",S="silero_vad_legacy.onnx",E=j=>({...h.defaultFrameProcessorOptions,onFrameProcessed:()=>{},onVADMisfire:()=>{u.log.debug("VAD misfire")},onSpeechStart:()=>{u.log.debug("Detected speech start")},onSpeechEnd:()=>{u.log.debug("Detected speech end")},onSpeechRealStart:()=>{u.log.debug("Detected real speech start")},baseAssetPath:"./",onnxWASMBasePath:"./",model:j,workletOptions:{},getStream:async()=>await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0}}),pauseStream:async T=>{T.getTracks().forEach(A=>{A.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=E;const C=j=>"audioWorklet"in j&&typeof AudioWorkletNode=="function"?"AudioWorklet":"ScriptProcessor";async function y(j,T,A,M,O){await A.audioWorklet.addModule(j),T.processorOptions={...T.processorOptions??{},frameSamples:M};const I=new AudioWorkletNode(A,"vad-helper-worklet",T);return I.port.onmessage=async z=>{const U=z.data;if(!(typeof U=="object"&&U&&"message"in U)){console.error("Invalid message event",U);return}switch(U.message){case d.Message.AudioFrame:{if(!("data"in U&&U.data instanceof ArrayBuffer)){console.log("Audio frame message has no data");return}const W=new Float32Array(U.data);await O(W);break}}},I}async function v(j,T,A){const M=new x.Resampler({nativeSampleRate:j.sampleRate,targetSampleRate:16e3,targetFrameSize:T});u.log.debug("using script processor");const I=j.createScriptProcessor(4096,1,1);let z=!1;return I.onaudioprocess=async U=>{if(!z){z=!0;try{const W=U.inputBuffer.getChannelData(0);U.outputBuffer.getChannelData(0).fill(0);const V=M.process(W);for(const H of V)await A(H)}catch(W){console.error("Error processing audio:",W)}finally{z=!1}}},I.connect(j.destination),I}class _{constructor(T,A,M,O,I=!1,z=null,U=null,W=null,Y=null,V=null,H=null,te="uninitialized",oe=!1){this.options=T,this.frameProcessor=A,this.model=M,this.frameSamples=O,this.listening=I,this.errored=z,this._stream=U,this._audioContext=W,this._vadNode=Y,this._mediaStreamAudioSourceNode=V,this._audioProcessorAdapterType=H,this.initializationState=te,this.ownsAudioContext=oe,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=pe=>{this.initializationState="errored",this.errored=pe},this.start=async()=>{switch(this.initializationState){case"uninitialized":{u.log.debug("initializing micVAD"),this.initializationState="initializing",this.frameProcessor.resume();try{this._stream=await this.options.getStream()}catch(pe){throw pe instanceof Error?this.setErrored(pe.message):this.setErrored(String(pe)),pe}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"?C(this._audioContext):this.options.processorType,this._audioProcessorAdapterType){case"AudioWorklet":this._vadNode=await y(this.options.baseAssetPath+g,this.options.workletOptions,this._audioContext,this.frameSamples,this.processFrame);break;case"ScriptProcessor":this._vadNode=await v(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),u.log.debug("started micVAD"),this.listening=!0,this.initializationState="initialized";break}case"initializing":{u.log.warn("start called while initializing");break}case"initialized":{if(this.listening)return;this.listening=!0,this.frameProcessor.resume();const{stream:pe,audioContext:ie,vadNode:X}=this.getAudioInstances();this._stream=await this.options.resumeStream(pe);const Q=new MediaStreamAudioSourceNode(ie,{mediaStream:this._stream});this._mediaStreamAudioSourceNode=Q,Q.connect(X);break}case"destroyed":{u.log.warn("start called after destroyed");break}case"errored":{u.log.error("start called after errored");break}default:{u.log.warn("weird initialization state");break}}},this.pause=async()=>{if(!this.listening)return;this.listening=!1;const{stream:pe,mediaStreamAudioSourceNode:ie}=this.getAudioInstances();await this.options.pauseStream(pe),ie.disconnect(),this.frameProcessor.pause(this.handleFrameProcessorEvent)},this.destroy=async()=>{var ie;u.log.debug("destroy called"),this.initializationState="destroyed";const{vadNode:pe}=this.getAudioInstances();pe instanceof AudioWorkletNode&&pe.port.postMessage(d.Message.SpeechStop),this.listening&&await this.pause(),await this.model.release(),this.ownsAudioContext&&await((ie=this._audioContext)==null?void 0:ie.close())},this.setOptions=pe=>{this.frameProcessor.setOptions(pe)},this.processFrame=async pe=>{await this.frameProcessor.process(pe,this.handleFrameProcessorEvent)},this.handleFrameProcessorEvent=pe=>{switch(pe.msg){case d.Message.FrameProcessed:this.options.onFrameProcessed(pe.probs,pe.frame);break;case d.Message.SpeechStart:this.options.onSpeechStart();break;case d.Message.SpeechRealStart:this.options.onSpeechRealStart();break;case d.Message.VADMisfire:this.options.onVADMisfire();break;case d.Message.SpeechEnd:this.options.onSpeechEnd(pe.audio);break}}}static async new(T={}){const A={...(0,e.getDefaultRealTimeVADOptions)(T.model??e.DEFAULT_MODEL),...T};(0,h.validateOptions)(A),e.ort.env.wasm.wasmPaths=A.onnxWASMBasePath,A.ortConfig!==void 0&&A.ortConfig(e.ort);const M=A.model==="v5"?b:S,O=A.baseAssetPath+M,I=A.model==="v5"?m.SileroV5.new:m.SileroLegacy.new;let z;try{z=await I(e.ort,()=>(0,l.defaultModelFetcher)(O))}catch(H){throw console.error(`Encountered an error while loading model file ${O}`),H}const U=A.model==="v5"?512:1536,W=U/16,Y=new h.FrameProcessor(z.process,z.reset_state,{positiveSpeechThreshold:A.positiveSpeechThreshold,negativeSpeechThreshold:A.negativeSpeechThreshold,redemptionMs:A.redemptionMs,preSpeechPadMs:A.preSpeechPadMs,minSpeechMs:A.minSpeechMs,submitUserSpeechOnPause:A.submitUserSpeechOnPause},W),V=new _(A,Y,z,U);if(A.startOnLoad)try{await V.start()}catch(H){throw console.error("Error starting micVad",H),H}return V}}e.MicVAD=_})(tl)),tl}var S_;function JN(){return S_||(S_=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 n=_2();Object.defineProperty(e,"baseAssetPath",{enumerable:!0,get:function(){return n.baseAssetPath}});var r=Uw();Object.defineProperty(e,"defaultModelFetcher",{enumerable:!0,get:function(){return r.defaultModelFetcher}});var i=Hw();Object.defineProperty(e,"FrameProcessor",{enumerable:!0,get:function(){return i.FrameProcessor}});var o=Vy();Object.defineProperty(e,"Message",{enumerable:!0,get:function(){return o.Message}});var l=GN();Object.defineProperty(e,"NonRealTimeVAD",{enumerable:!0,get:function(){return l.NonRealTimeVAD}});const h=KN();e.utils={audioFileToArray:h.audioFileToArray,minFramesForTargetMS:h.minFramesForTargetMS,arrayBufferToBase64:h.arrayBufferToBase64,encodeWAV:h.encodeWAV};var u=YN();Object.defineProperty(e,"DEFAULT_MODEL",{enumerable:!0,get:function(){return u.DEFAULT_MODEL}}),Object.defineProperty(e,"MicVAD",{enumerable:!0,get:function(){return u.MicVAD}}),Object.defineProperty(e,"getDefaultRealTimeVADOptions",{enumerable:!0,get:function(){return u.getDefaultRealTimeVADOptions}})})(Ev)),Ev}var QN=JN();function nx(e,n,r,i){var l,h;try{(h=(l=window.api)==null?void 0:l.logs)==null||h.write(e,n,r,i)}catch{}const o=n==="error"?console.error:n==="warn"?console.warn:console.log;i!==void 0?o(`[${e}]`,r,i):o(`[${e}]`,r)}const dt={debug:(e,n,r)=>nx(e,"debug",n,r),info:(e,n,r)=>nx(e,"info",n,r),warn:(e,n,r)=>nx(e,"warn",n,r),error:(e,n,r)=>nx(e,"error",n,r)},N2=16e3,ZN=6,Sh=N2*ZN,eT=400,tT=N2*eT/1e3,C_=300,j_=2e3,E_=1500,N_=3e3,nT=600,T2=.5,$2=.35,T_=.85,$_=.7;let mi=null,va=!1,Ks=!1;const Ob=new Set;function rx(e){for(const n of Array.from(Ob))try{n(e)}catch(r){dt.warn("speech","workerDeath listener threw",{error:r instanceof Error?r.message:String(r)})}}let Av=0;const A_=2;let zh=!1,A2=!1;function R2(e){e.addEventListener("message",n=>{var i;if(((i=n.data)==null?void 0:i.type)!=="log")return;const r=n.data.level||"info";dt[r]("whisperWorker",n.data.message??"",n.data.meta)}),e.addEventListener("error",n=>{dt.error("whisperWorker","worker error event (fatal)",{message:n.message,filename:n.filename,lineno:n.lineno}),rT(`error:${n.message||"unknown"}`)})}function hy(){return mi||(mi=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),R2(mi),dt.info("speech","worker spawned"),mi)}let sx=!1;function rT(e){if(!zh){if(sx){dt.warn("speech","respawnWorker: already in flight, ignoring",{reason:e});return}if(sx=!0,Av+=1,A2=!0,dt.warn("speech","respawnWorker: starting",{reason:e,attempt:Av}),rx({reason:e,respawned:!1,finalOnly:!0}),Av>A_){if(zh=!0,dt.error("speech","respawnWorker: limit exceeded, disabling speech",{limit:A_}),mi)try{mi.terminate()}catch{}mi=null,va=!1,Ks=!1,rx({reason:"respawn-limit-exceeded",respawned:!1,finalOnly:!0}),sx=!1;return}if(mi)try{mi.terminate()}catch{}mi=null,va=!1,Ks=!1;try{mi=new Worker(new URL(""+new URL("whisperWorker-Dbia1OpC.js",import.meta.url).href,import.meta.url),{type:"module"}),R2(mi),Ks=!0,mi.postMessage({type:"load"}),dt.info("speech","respawnWorker: new worker spawned, load posted"),rx({reason:e,respawned:!0,finalOnly:!0})}catch(n){zh=!0,dt.error("speech","respawnWorker: spawn failed, disabling speech",{error:n instanceof Error?n.message:String(n)}),rx({reason:"spawn-failed",respawned:!1,finalOnly:!0})}finally{sx=!1}}}function sT(e,n){if(va||Ks)return;Ks=!0;const r=hy();dt.info("speech","preloadModel: posting load");const i=o=>{o.data.type==="status"?(e==null||e(o.data.status,o.data.message),o.data.status==="ready"&&(va=!0,Ks=!1,dt.info("speech","preloadModel: ready"),r.removeEventListener("message",i))):o.data.type==="progress"?n==null||n(o.data.pct):o.data.type==="error"&&(Ks=!1,dt.error("speech","preloadModel: worker reported error",{error:o.data.error}),e==null||e("error",o.data.error),r.removeEventListener("message",i))};r.addEventListener("message",i),r.postMessage({type:"load"})}function iT(){dt.info("speech","resetModel: clearing load flags"),va=!1,Ks=!1}function Gy(){var e;return typeof Worker<"u"&&!!((e=navigator.mediaDevices)!=null&&e.getUserMedia)&&typeof AudioWorkletNode<"u"}function oT(e){const n=hy();return!va&&!Ks&&(Ks=!0,n.postMessage({type:"load"})),new Promise((r,i)=>{const o=l=>{var h,u,d;((h=l.data)==null?void 0:h.type)==="result"?(n.removeEventListener("message",o),r((l.data.text??"").trim())):((u=l.data)==null?void 0:u.type)==="error"?(n.removeEventListener("message",o),i(new Error(String(l.data.error??"Transcription failed")))):((d=l.data)==null?void 0:d.type)==="status"&&l.data.status==="ready"&&(va=!0,Ks=!1)};n.addEventListener("message",o),n.postMessage({type:"transcribe",audio:e},[e.buffer])})}function M2(e){let n=hy(),r=!1,i=null,o=null,l=null,h=null,u=null;const d=[],m=new Set;let x=null,g=0,b=!1,S=0,E=!1,C=!1,y=0,v=0,_=0,j=-1,T=C_,A=0,M=null,O="",I="",z=!1,U=0;function W(le,fe){const Me=Math.min(le.length,fe.length);let je=0;for(;je<Me&&le.charCodeAt(je)===fe.charCodeAt(je);)je++;return je}function Y(le){const fe=W(O,le);return O=le,fe>I.length&&(I=le.slice(0,fe)),I.length>le.length&&(I=le),I}const V=()=>(x||(x=new Float32Array(Sh)),x),H=()=>{g=0},te=le=>{const fe=V(),Me=le.length;if(Me>=Sh){fe.set(le.subarray(Me-Sh)),g=Sh;return}if(g+Me<=Sh){fe.set(le,g),g+=Me;return}const je=g+Me-Sh;fe.copyWithin(0,je,g),g-=je,fe.set(le,g),g+=Me},oe=()=>{M&&(clearTimeout(M),M=null)},pe=()=>{oe(),b=!1,E=!1,C=!1,T=C_,O="",I="",z=!1,U=0,H()},ie=()=>{if(r||!b||C||E||M)return;if(g<tT){M=setTimeout(()=>{M=null,ie()},T);return}const le=performance.now()-y;if(le<T&&y!==0){M=setTimeout(()=>{M=null,ie()},T-le);return}if(A2||zh||e.partialsEnabled&&!e.partialsEnabled())return;const fe=V(),Me=new Float32Array(g);Me.set(fe.subarray(0,g)),v+=1,_=v,E=!0,A=performance.now(),y=A,n.postMessage({type:"transcribe-partial",audio:Me,seq:v},[Me.buffer])},X=le=>le.length===0?Promise.resolve():zh?(dt.warn("speech","transcribeAudio: speech disabled (worker respawn limit hit)"),r||e.onError("Speech recognition disabled — please reload the app."),Promise.resolve()):new Promise(fe=>{d.push(fe),v+=1;const Me=v;j=Me,n.postMessage({type:"transcribe",audio:le,seq:Me},[le.buffer])}),Q=le=>{const fe=X(le);return m.add(fe),fe.finally(()=>{m.delete(fe)}),fe},J=le=>{var fe,Me,je,ye,ne;if(le.data.type==="result"){const we=le.data.text,Ne=le.data.seq??0;Ne&&Ne<j&&dt.warn("speech","result: seq below latestFinalSeq (delivering anyway)",{seq:Ne,latestFinalSeq:j}),!r&&we&&e.onFinal(we),(fe=d.shift())==null||fe()}else if(le.data.type==="partial"){const we=le.data.seq??0,Ne=le.data.text??"",Je=performance.now()-A;E=!1,Je>=N_?(C=!0,dt.warn("speech","partials.disabled.budget",{elapsedMs:Math.round(Je),seq:we})):Je>=E_&&(T=Math.min(T*2,j_),dt.warn("speech","partials.slowdown",{elapsedMs:Math.round(Je),newIntervalMs:T,seq:we})),z||(z=!0,Je>nT&&T<500&&(T=500,dt.info("speech","partials.probe.slow_host",{elapsedMs:Math.round(Je),newIntervalMs:500})));const lt=we!==_||we<=j;if(!r&&!lt&&Ne){const xt=Y(Ne);xt&&((Me=e.onPartial)==null||Me.call(e,xt),U===0&&(U=performance.now(),dt.info("speech","partial.first",{msSinceSpeechStart:Math.round(U-S)})))}ie()}else if(le.data.type==="partial-error"){const we=performance.now()-A;E=!1,we>=N_?(C=!0,dt.warn("speech","partials.disabled.budget (after error)",{elapsedMs:Math.round(we),seq:le.data.seq})):we>=E_&&(T=Math.min(T*2,j_),dt.warn("speech","partials.slowdown (after error)",{elapsedMs:Math.round(we),newIntervalMs:T,seq:le.data.seq})),dt.warn("speech","partial encode failed",{error:le.data.error,seq:le.data.seq}),ie()}else le.data.type==="error"?(r||e.onError(le.data.error),(je=d.shift())==null||je()):le.data.type==="status"?(r||(ye=e.onModelStatus)==null||ye.call(e,le.data.status,le.data.message),le.data.status==="ready"&&(va=!0,Ks=!1)):le.data.type==="progress"&&(r||(ne=e.onProgress)==null||ne.call(e,le.data.pct))};n.addEventListener("message",J);const ae=le=>{var fe,Me;if(!r){for(dt.warn("speech","createRecognition: worker death event",le),(fe=e.onStatusChange)==null||fe.call(e,"restarting");d.length;)(Me=d.shift())==null||Me();if(m.clear(),oe(),E=!1,le.respawned){try{n.removeEventListener("message",J)}catch{}n=hy(),n.addEventListener("message",J)}}};return Ob.add(ae),{start:async()=>{if(!r){if(zh){e.onError("Speech recognition disabled — please reload the app.");return}!va&&!Ks&&(Ks=!0,dt.info("speech","createRecognition.start: triggering model load"),n.postMessage({type:"load"})),dt.info("speech","createRecognition.start: initializing VAD",{modelReady:va,modelLoading:Ks});try{const le=new URL("vad/",document.baseURI).href,fe=e.inputDeviceId||null,Me={channelCount:1,echoCancellation:!0,autoGainControl:!0,noiseSuppression:!0};fe&&(Me.deviceId={exact:fe}),dt.info("speech","getUserMedia",{hasDeviceId:!!fe,deviceIdPrefix:fe?fe.slice(0,8):null});const je=await navigator.mediaDevices.getUserMedia({audio:Me});o=je,l=new AudioContext;for(const ye of je.getAudioTracks())ye.addEventListener("ended",()=>{r||(dt.warn("speech","mic track ended (permission revoked or device removed)"),e.onError("Microphone disconnected or permission revoked"))});try{u=l.createMediaStreamSource(o),h=l.createAnalyser(),h.fftSize=2048,h.smoothingTimeConstant=.3,u.connect(h)}catch(ye){dt.warn("speech","analyser init failed",{error:ye instanceof Error?ye.message:String(ye)}),u=null,h=null}i=await QN.MicVAD.new({audioContext:l,getStream:async()=>je,resumeStream:async()=>je,pauseStream:async()=>{},baseAssetPath:le,onnxWASMBasePath:le,model:"v5",positiveSpeechThreshold:T2,negativeSpeechThreshold:$2,minSpeechMs:300,redemptionMs:1500,preSpeechPadMs:300,submitUserSpeechOnPause:!0,onFrameProcessed:(ye,ne)=>{var we;r||((we=e.onFrame)==null||we.call(e,ye),b&&(te(ne),ie()))},onSpeechStart:()=>{var ye;r||(pe(),b=!0,S=performance.now(),(ye=e.onSpeechStart)==null||ye.call(e))},onSpeechEnd:ye=>{var ne;r||((ne=e.onStatusChange)==null||ne.call(e,"transcribing"),pe(),Q(ye))},onVADMisfire:()=>{var ye,ne;r||((ye=e.onStatusChange)==null||ye.call(e,"idle"),pe(),(ne=e.onMisfire)==null||ne.call(e))}}),i.start()}catch(le){const fe=le instanceof Error?le.message:"Microphone access denied",Me=le instanceof Error?le.stack:"";if(dt.error("speech","createRecognition.start: VAD init failed",{error:fe,stack:Me}),h){try{h.disconnect()}catch{}h=null}if(u){try{u.disconnect()}catch{}u=null}if(o){try{o.getTracks().forEach(je=>je.stop())}catch{}o=null}if(l){try{await l.close()}catch{}l=null}e.onError(fe)}}},stop:async()=>{if(i)try{await i.pause()}catch{}for(pe();m.size>0;)await Promise.all(Array.from(m));if(i){try{await i.destroy()}catch{}i=null}if(h){try{h.disconnect()}catch{}h=null}if(u){try{u.disconnect()}catch{}u=null}if(o){try{o.getTracks().forEach(le=>le.stop())}catch{}o=null}if(l){try{await l.close()}catch{}l=null}},setVadThresholds:(le,fe)=>{if(i)try{i.setOptions({positiveSpeechThreshold:le,negativeSpeechThreshold:fe})}catch(Me){dt.warn("speech","setVadThresholds failed",{error:Me instanceof Error?Me.message:String(Me)})}},getAnalyser:()=>h,destroy:()=>{if(r=!0,pe(),i){try{i.destroy()}catch{}i=null}if(h){try{h.disconnect()}catch{}h=null}if(u){try{u.disconnect()}catch{}u=null}if(l){try{l.close()}catch{}l=null}if(o){try{o.getTracks().forEach(le=>le.stop())}catch{}o=null}Ob.delete(ae),n.removeEventListener("message",J)}}}let Em=null;const Lb=new Set,zb=new Set;function aT(){for(const e of Lb)try{e()}catch{}}function Bb(){for(const e of zb)try{e()}catch{}}function lT(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 cT(e){if(!window.speechSynthesis)return;const n=lT(e);if(!n)return;const r=new SpeechSynthesisUtterance(n);r.rate=1,r.pitch=1,r.onstart=()=>{Em=performance.now(),aT()},r.onend=()=>{!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Em=null,Bb())},r.onerror=i=>{i.error!=="canceled"&&!window.speechSynthesis.speaking&&!window.speechSynthesis.pending&&(Em=null,Bb())},window.speechSynthesis.speak(r)}function I2(){window.speechSynthesis&&(window.speechSynthesis.cancel(),Em=null,Bb())}function P2(){var e;return((e=window.speechSynthesis)==null?void 0:e.speaking)??!1}function uT(){return Em}function dT(e){return Lb.add(e),()=>{Lb.delete(e)}}function hT(e){return zb.add(e),()=>{zb.delete(e)}}function fT(e){P2()&&(e.setVadThresholds(T_,$_),dt.info("voice","tts.duck.on",{reason:"already-speaking-on-attach"}));const n=dT(()=>{e.setVadThresholds(T_,$_),dt.info("voice","tts.duck.on")}),r=hT(()=>{e.setVadThresholds(T2,$2),dt.info("voice","tts.duck.off")});return()=>{n(),r()}}const pT=[{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 mT(e){const n=e.trim();return pT.find(r=>r.match.test(n))??null}const gT=4e4;let Nu=null;function Bh(){Nu&&clearTimeout(Nu),Nu=setTimeout(()=>{Nu=null,Tt.getState().stopRecording()},gT)}function ix(){Nu&&(clearTimeout(Nu),Nu=null)}let pc=null,dc=null;const xT=.04,yT=.3;let fy=0,Fb=0;function vT(e){dc!==null&&cancelAnimationFrame(dc);const n=()=>{if(pc===null||Tt.getState().submitCountdownStartAt===null){dc=null;return}const r=performance.now();if(r-Fb<200&&fy>yT){const o=r-e;dt.info("voice","submit.preempted_by_voice",{reason:"vad",prob:fy.toFixed(2),msIntoCountdown:Math.round(o)}),oc(),Bh();return}const i=D2();if(i){const o=new Uint8Array(i.fftSize);i.getByteTimeDomainData(o);let l=0;for(let u=0;u<o.length;u++){const d=(o[u]-128)/128;l+=d*d}const h=Math.sqrt(l/o.length);if(h>xT){const u=r-e;dt.info("voice","submit.preempted_by_voice",{reason:"rms",rms:h.toFixed(3),msIntoCountdown:Math.round(u)}),oc(),Bh();return}}dc=requestAnimationFrame(n)};dc=requestAnimationFrame(n)}function bT(e){pc&&clearTimeout(pc);const n=Tt.getState().submitDelayMs,r=performance.now();Tt.setState({submitCountdownStartAt:r}),pc=setTimeout(()=>{pc=null,Tt.setState({submitCountdownStartAt:null});try{window.api.pty.write({tabId:e,data:"\r"})}catch(i){dt.warn("voice","submit pty.write failed",{error:i instanceof Error?i.message:String(i)})}Bh()},n),vT(r)}function oc(){dc!==null&&(cancelAnimationFrame(dc),dc=null),pc&&(clearTimeout(pc),pc=null),Tt.getState().submitCountdownStartAt!==null&&Tt.setState({submitCountdownStartAt:null})}let rs=null,As=null;function D2(){var e;return((e=rs==null?void 0:rs.getAnalyser)==null?void 0:e.call(rs))??null}const ox=1e4;let Nm=null;function ax(){Nm&&(clearTimeout(Nm),Nm=null)}let Kx=null,Xx=null;function lx(){Kx=null,Xx&&(Xx(),Xx=null)}const wT=1500,_T=9e4;let cx=0,Yx=null,Ub=-1;function ux(){Yx&&(clearTimeout(Yx),Yx=null,Ub=-1)}const kT=new Set(["you","You","Thank you.","Thanks for watching.","Thanks for watching!","Thank you for watching.","Thank you for watching!",".","Bye.","Bye!"]),Tt=cr((e,n)=>({isRecording:!1,externalRecording:!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(n().modelStatus!=="idle")return;dt.info("voice","initModel: kicking off preload"),e({modelStatus:"loading",error:null,errorKind:null,loadingProgress:0});const r=++cx,i=()=>{r===cx&&(ux(),Ub=r,Yx=setTimeout(()=>{Ub===r&&n().modelStatus==="loading"&&(dt.warn("voice","mic.gate.timeout: no progress within 90s"),e({modelStatus:"error",error:"Model load timed out",errorKind:"timeout"}))},_T))};i(),sT((o,l)=>{r===cx&&(o==="ready"?(ux(),dt.info("voice","modelStatus -> ready"),e({modelStatus:"ready",loadingProgress:100,errorKind:null})):o==="error"?(ux(),dt.error("voice","modelStatus -> error",{msg:l}),e({modelStatus:"error",error:l,errorKind:"load"})):(i(),e({modelStatus:"loading"})))},o=>{r===cx&&(i(),e({loadingProgress:Math.round(o)}))})},resetAndRetryModel:()=>{dt.info("voice","mic.gate.retry"),ux(),iT(),e({modelStatus:"idle",error:null,errorKind:null,loadingProgress:0}),n().initModel()},startRecording:r=>{if(n().isRecording)return;if(rs){dt.warn("voice","startRecording: prior handle still draining, ignoring");return}if(!Gy()){e({error:"Microphone or Web Worker not available",errorKind:"recording"});return}const i=o=>{try{const l=M2({inputDeviceId:o,onStatusChange:h=>{e(h==="transcribing"?{statusPill:"transcribing"}:h==="restarting"?{statusPill:"restarting"}:{statusPill:"idle"})},onPartial:h=>{n().partialsEnabled&&e({lastPartial:h})},partialsEnabled:()=>n().partialsEnabled,onFrame:h=>{fy=h.isSpeech,Fb=performance.now()},onSpeechStart:()=>{if(e({statusPill:"listening",lastPartial:""}),ix(),oc(),P2()){const u=uT(),d=u!==null?performance.now()-u:null;I2(),e({lastBargeInAt:performance.now()}),dt.info("voice","barge-in",{tabId:r,utteranceOffsetMs:d})}else dt.debug("voice","barge-in.no-op",{tabId:r})},onMisfire:()=>{e({lastPartial:"",statusPill:"idle"}),Bh();const h=n().lastBargeInAt;h!==null&&performance.now()-h<600&&dt.warn("voice","barge-in.misfire",{tabId:r,sinceBargeInMs:Math.round(performance.now()-h)})},onFinal:h=>{Bh();const u=h.trim();if(!u||kT.has(u)){e({lastTranscript:"",lastPartial:"",statusPill:"idle"});return}const d=mT(u);if(d){dt.info("voice","voice-command",{tabId:r,label:d.label,transcript:u}),window.api.pty.write({tabId:r,data:d.data}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),oc();const x=window;x.__transcripts&&(x.__transcripts.push({tabId:r,text:u}),x.__transcripts.length>500&&x.__transcripts.shift());return}window.api.pty.write({tabId:r,data:u}),e({lastTranscript:"",lastPartial:"",statusPill:"idle"}),n().autoSubmit&&bT(r);const m=window;m.__transcripts&&(m.__transcripts.push({tabId:r,text:u}),m.__transcripts.length>500&&m.__transcripts.shift())},onError:h=>{dt.error("voice","recognition error",{err:h}),oc(),e({error:h,errorKind:"recording",isRecording:!1,lastPartial:"",statusPill:"idle"}),As==null||As(),As=null,ix(),rs==null||rs.destroy(),rs=null,ze.error(`Microphone error: ${h}`)},onModelStatus:h=>{h==="ready"?e({modelStatus:"ready",loadingProgress:100}):h==="loading"&&e({modelStatus:"loading"})},onProgress:h=>e({loadingProgress:Math.round(h)})});rs=l,e({isRecording:!0,error:null,lastTranscript:"",lastPartial:"",statusPill:"listening"}),Bh(),l.start().then(()=>{rs===l&&(As==null||As(),As=fT(l))}).catch(h=>{const u=h instanceof Error?h.message:String(h);dt.error("voice","handle.start() failed",{error:u}),ze.error(`Could not start mic: ${u}`)})}catch(l){e({error:l instanceof Error?l.message:"Failed to start recording",errorKind:"recording"})}};Promise.resolve().then(()=>{var o,l,h;return((h=(l=(o=window.api)==null?void 0:o.voice)==null?void 0:l.getDevicePref)==null?void 0:h.call(l))??Promise.resolve(null)}).then(o=>i((o==null?void 0:o.selectedDeviceId)??null)).catch(o=>{dt.warn("voice","getDevicePref failed; using default device",{error:o instanceof Error?o.message:String(o)}),i(null)})},stopRecording:()=>{const r=rs;r&&(ix(),oc(),fy=0,Fb=0,As==null||As(),As=null,e({isRecording:!1,lastTranscript:"",lastPartial:"",statusPill:"idle"}),r.stop().finally(()=>{r.destroy(),rs===r&&(rs=null),n().hotkeyState==="stopping"&&(ax(),e({hotkeyState:"idle"}))}))},restartWithDevice:async()=>{if(!n().isRecording)return;const r=rs;if(!r)return;ix(),As==null||As(),As=null,e({isRecording:!1,lastTranscript:"",lastPartial:""});try{await r.stop()}catch(l){dt.warn("voice","restartWithDevice: drain rejected",{error:l instanceof Error?l.message:String(l)})}r.destroy(),rs===r&&(rs=null);const{useSessions:i}=await Gm(async()=>{const{useSessions:l}=await Promise.resolve().then(()=>CN);return{useSessions:l}},[],import.meta.url),o=i.getState().activeTabId;o&&n().startRecording(o)},setExternalRecording:r=>e({externalRecording:r}),toggleTTS:()=>e(r=>({ttsEnabled:!r.ttsEnabled})),setAutoSubmit:r=>e({autoSubmit:r}),setSubmitDelayMs:r=>e({submitDelayMs:Math.max(500,Math.min(13e3,Math.floor(r)))}),cancelSubmit:()=>oc(),setPartialsEnabled:r=>{n().partialsEnabled!==r&&(e({partialsEnabled:r}),r||e({lastPartial:""}))},clearError:()=>e({error:null,errorKind:null}),setPermissionState:r=>{n().permissionState!==r&&(dt.info("voice","mic.gate.permission_changed",{from:n().permissionState,to:r}),e({permissionState:r}))},setLevelMeterEnabled:r=>{n().levelMeterEnabled!==r&&e({levelMeterEnabled:r})},setTurnDetectorRuntimeState:r=>{n().turnDetectorState!==r&&(e({turnDetectorState:r}),r==="load_failed"?dt.warn("voice-turn","voice-turn.load_failed"):r==="runtime_error"?dt.warn("voice-turn","voice-turn.runtime_error"):r==="disabled"&&dt.info("voice-turn","voice-turn.fallback_to_vad"))},setWizardArmed:r=>{n().wizardArmed!==r&&e({wizardArmed:r})},openWizard:()=>{n().wizardOpen||e({wizardOpen:!0})},closeWizard:()=>{n().wizardOpen&&e({wizardOpen:!1})},armHotkey:({phase:r,source:i,mode:o,tabId:l})=>{const h=n(),{canRecord:u,reason:d}=Hb(h);if(r==="down"){if(d==="error"||d==="load-timeout"){h.resetAndRetryModel(),dt.info("voice-hotkey","down.retry",{source:i,reason:d});return}if(!u&&d!=="loading"){dt.warn("voice-hotkey","miss-model-loading",{modelStatus:h.modelStatus,reason:d});return}if(h.hotkeyState==="recording"||h.isRecording){(o==="toggle"||i==="global")&&(e({hotkeyState:"stopping"}),ax(),Nm=setTimeout(()=>{n().hotkeyState==="stopping"&&(dt.warn("voice-hotkey","drain-timeout",{durationMs:ox}),e({hotkeyState:"aborted"}),setTimeout(()=>{n().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},ox),h.stopRecording());return}if(d==="loading"){h.hotkeyState!=="armed"&&(e({hotkeyState:"armed"}),dt.info("voice-hotkey","armed",{source:i,modelStatus:h.modelStatus})),lx(),Kx={tabId:l,source:i,mode:o},Xx=Tt.subscribe((m,x)=>{if(Kx&&m.modelStatus==="ready"&&x.modelStatus!=="ready"&&m.hotkeyState==="armed"){const g=Kx;if(lx(),!g.tabId){dt.warn("voice-hotkey","armed-promote-no-tab",{source:g.source}),e({hotkeyState:"idle"});return}dt.info("voice-hotkey","armed-promote",g),e({hotkeyState:"recording"}),Tt.getState().startRecording(g.tabId)}});return}if(!l){dt.warn("voice-hotkey","no-active-tab",{source:i});return}dt.info("voice-hotkey","start",{source:i,mode:o,tabId:l}),h.startRecording(l),n().isRecording?e({hotkeyState:"recording"}):(dt.warn("voice-hotkey","start: recording did not engage",{errorKind:n().errorKind}),e({hotkeyState:"idle"}));return}if(!(o!=="hold"||i==="global")){if(h.hotkeyState==="armed"){lx(),dt.info("voice-hotkey","miss-model-loading-armed-up"),e({hotkeyState:"idle"});return}h.hotkeyState==="recording"&&(e({hotkeyState:"stopping"}),ax(),Nm=setTimeout(()=>{n().hotkeyState==="stopping"&&(dt.warn("voice-hotkey","drain-timeout",{durationMs:ox}),e({hotkeyState:"aborted"}),setTimeout(()=>{n().hotkeyState==="aborted"&&e({hotkeyState:"idle"})},0))},ox),h.stopRecording())}},destroyHotkey:()=>{const r=n();if(lx(),oc(),r.hotkeyState==="recording"){dt.warn("voice-hotkey","destroyed-mid-recording"),e({hotkeyState:"destroyed"});try{r.stopRecording()}catch{}}else(r.hotkeyState==="armed"||r.hotkeyState==="stopping")&&(ax(),e({hotkeyState:"destroyed"}))}})),ST=e=>({isRecording:e.isRecording,statusPill:e.statusPill,lastPartial:e.lastPartial,lastTranscript:e.lastTranscript,submitCountdownStartAt:e.submitCountdownStartAt}),Hb=e=>Gy()?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=Tt,e.__transcripts=[]}function Ww(e,n,r){return new Promise((i,o)=>{const l=setTimeout(()=>o(new Error(`${r} timed out after ${n}ms`)),n);e.then(h=>{clearTimeout(l),i(h)},h=>{clearTimeout(l),o(h)})})}const CT=5e3,yc=cr(()=>({snapshot:null,loaded:!1}));let R_=!1,M_=!1,Gp;async function jT(){var e;if(!R_){R_=!0;try{const n=await Ww(window.api.schedule.state(),CT,"schedule.state");yc.setState({snapshot:n,loaded:!0}),Gp=((e=n.paused)==null?void 0:e.reason)??null}catch(n){if(!M_){M_=!0;const r=n instanceof Error?n.message:String(n);ze.error(`Scheduler state hydrate failed: ${r}`)}Gp=null}window.api.schedule.onState(n=>{var i;const r=((i=n.paused)==null?void 0:i.reason)??null;Gp!==void 0&&r!==Gp&&(r==="auth"?ze.error("Scheduler paused: Claude sign-in expired or invalid. Restart the app or re-run `claude login`, then Resume."):r==="network"&&ze.error("Scheduler paused: billing endpoint unreachable. Will auto-resume in 30 minutes.")),Gp=r,yc.setState({snapshot:n,loaded:!0})})}}const ET=6e4,NT=5e3,Fh=cr(()=>({data:null,refreshing:!1}));let I_=!1,Jx=null,P_=null,D_=!1;async function qw(){Fh.setState({refreshing:!0});let e=ET;try{const n=await Ww(window.api.billing.fetch(),NT,"billing.fetch");Fh.setState({data:n,refreshing:!1}),n.kind==="transient"?e=P_==="transient"?3e4:5e3:(n.kind==="auth"||n.kind==="meter_rate_limited")&&(e=3e4),P_=n.kind}catch(n){if(Fh.setState({refreshing:!1}),!D_){D_=!0;const r=n instanceof Error?n.message:String(n);ze.warn(`Billing usage fetch failed: ${r}`)}}Jx=setTimeout(qw,e)}function TT(){I_||(I_=!0,qw())}function Ky(e){return e?e.kind==="ok"||e.kind==="ok-stale"?e.data:(e.kind==="auth"||e.kind==="meter_rate_limited")&&e.cached?e.cached:null:null}function py(){Jx!==null&&(clearTimeout(Jx),Jx=null),qw()}function dn({name:e,size:n=17,stroke:r=1.6,className:i}){const o={width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round",className:i};switch(e){case"home":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M4 11l8-7 8 7"}),s.jsx("path",{d:"M6 10v9h12v-9"}),s.jsx("path",{d:"M10 19v-5h4v5"})]});case"terminal":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"M7 10l3 2-3 2"}),s.jsx("path",{d:"M13 14h4"})]});case"agents":case"subagents":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"7",cy:"9",r:"2.5"}),s.jsx("circle",{cx:"17",cy:"9",r:"2.5"}),s.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),s.jsx("path",{d:"M8.6 11l2.8 4M15.4 11l-2.8 4M9.5 9h5"})]});case"skills":return s.jsx("svg",{...o,children:s.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 s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("path",{d:"M12 7v5l3 2"}),s.jsx("path",{d:"M4 6l2 2"})]});case"usage":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M4 19V8M10 19V5M16 19v-7M22 19H2"})});case"hive":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M8 4h8l4 7-4 7H8l-4-7z"}),s.jsx("circle",{cx:"12",cy:"11",r:"2.5"})]});case"plugins":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M9 3v4M15 3v4M5 7h14v6a5 5 0 01-5 5h-4a5 5 0 01-5-5V7z"})});case"mcp":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1.5"}),s.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1.5"}),s.jsx("circle",{cx:"6.5",cy:"7",r:".5",fill:"currentColor"}),s.jsx("circle",{cx:"6.5",cy:"17",r:".5",fill:"currentColor"})]});case"hooks":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M12 4v9a3 3 0 003 3h5"}),s.jsx("path",{d:"M9 17l3 3 3-3"})]});case"keys":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"8",cy:"12",r:"4"}),s.jsx("path",{d:"M12 12h9M17 12v3M20 12v2"})]});case"plans":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),s.jsx("path",{d:"M8 9h8M8 13h8M8 17h5"})]});case"tasks":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"4",width:"7",height:"7",rx:"1.5"}),s.jsx("rect",{x:"3",y:"13",width:"7",height:"7",rx:"1.5"}),s.jsx("path",{d:"M14 6h7M14 10h5M14 15h7M14 19h5"})]});case"projects":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"memory":case"agent-memory":return s.jsxs("svg",{...o,children:[s.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"}),s.jsx("path",{d:"M9 9v6M12 6v12M15 9v6"})]});case"search":case"global-search":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"11",cy:"11",r:"6"}),s.jsx("path",{d:"M16 16l4 4"})]});case"chevron":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M9 6l6 6-6 6"})});case"caret":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M6 9l6 6 6-6"})});case"dot":return s.jsx("svg",{...o,children:s.jsx("circle",{cx:"12",cy:"12",r:"3",fill:"currentColor",stroke:"none"})});case"plus":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M12 5v14M5 12h14"})});case"folder":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M3 7l3-3h4l2 2h9v13H3z"})});case"file":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M7 3h7l4 4v14H7z"}),s.jsx("path",{d:"M14 3v4h4"})]});case"play":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M8 5l11 7-11 7z",fill:"currentColor",stroke:"none"})});case"pause":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"7",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"}),s.jsx("rect",{x:"13.5",y:"5",width:"3.5",height:"14",fill:"currentColor",stroke:"none",rx:"0.5"})]});case"sparkle":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M12 4v6M12 14v6M4 12h6M14 12h6"})});case"book":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M4 5a2 2 0 012-2h6v18H6a2 2 0 01-2-2zM12 3h6a2 2 0 012 2v14H12z"})});case"compass":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("path",{d:"M15 9l-2 5-5 2 2-5z",fill:"currentColor",stroke:"none"})]});case"scheduler":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"15",rx:"2"}),s.jsx("path",{d:"M3 10h18M8 3v4M16 3v4"}),s.jsx("path",{d:"M8 14l2 2 4-4"})]});case"settings":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.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 s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"9",y:"3",width:"6",height:"12",rx:"3"}),s.jsx("path",{d:"M5 11a7 7 0 0014 0M12 18v3M9 21h6"})]});case"clock":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("path",{d:"M12 7v5l3 2"})]});case"leaf":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M20 4c-9 0-14 5-14 11 0 3 2 5 5 5 6 0 9-5 9-14z"}),s.jsx("path",{d:"M6 20c2-5 5-8 11-11"})]});case"orchestrator":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"6",r:"2.5"}),s.jsx("circle",{cx:"5",cy:"17",r:"2.5"}),s.jsx("circle",{cx:"12",cy:"17",r:"2.5"}),s.jsx("circle",{cx:"19",cy:"17",r:"2.5"}),s.jsx("path",{d:"M12 8.5v6M12 14.5l-7 0M12 14.5l7 0"})]});case"race":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 4v16M5 5h7l-1 3h7v6h-7l-1 3H5"})});case"background":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M3 4h18v4H3zM3 10h18v4H3zM3 16h18v4H3z"}),s.jsx("circle",{cx:"6",cy:"6",r:".75",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"6",cy:"12",r:".75",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"6",cy:"18",r:".75",fill:"currentColor",stroke:"none"})]});case"repoviz":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"18",cy:"18",r:"3"}),s.jsx("path",{d:"M8.5 10.5L15.5 7.5M8.5 13.5L15.5 16.5"})]});case"system-prompt":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"4",y:"4",width:"16",height:"14",rx:"2"}),s.jsx("path",{d:"M8 10h8M8 14h5M9 18l-2 3M15 18l2 3"})]});case"permissions":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),s.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"}),s.jsx("circle",{cx:"12",cy:"15.5",r:"1.2",fill:"currentColor",stroke:"none"})]});case"tool":return s.jsx("svg",{...o,children:s.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 s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),s.jsx("path",{d:"M3 9h18M7 13h10M7 16h6"})]});case"remote":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M5 12.5a7 7 0 0114 0M1.5 9a11 11 0 0121 0M8.5 16a3.5 3.5 0 017 0"}),s.jsx("circle",{cx:"12",cy:"20",r:"1",fill:"currentColor",stroke:"none"})]});case"wifi":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 12.5a10 10 0 0114 0M8 15.5a6 6 0 018 0M12 18.5h.01"})});case"shield":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M12 3l7 3v5c0 4.5-3 8-7 10-4-2-7-5.5-7-10V6z"}),s.jsx("path",{d:"M9 12l2 2 4-4"})]});case"link":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M9 12h6"}),s.jsx("path",{d:"M10 8H7a4 4 0 000 8h3M14 8h3a4 4 0 010 8h-3"})]});case"copy":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"9",y:"9",width:"11",height:"11",rx:"2"}),s.jsx("path",{d:"M5 15V5a2 2 0 012-2h8"})]});case"check":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 12l5 5 9-10"})});case"x":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M6 6l12 12M18 6L6 18"})});case"send":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M4 11l17-7-7 17-3-7z"})});case"browser":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("ellipse",{cx:"12",cy:"12",rx:"3.2",ry:"8"}),s.jsx("path",{d:"M4 12h16"})]});case"target":return s.jsxs("svg",{...o,children:[s.jsx("circle",{cx:"12",cy:"12",r:"8"}),s.jsx("circle",{cx:"12",cy:"12",r:"3.5"}),s.jsx("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]});case"record":return s.jsx("svg",{...o,children:s.jsx("circle",{cx:"12",cy:"12",r:"7",fill:"currentColor",stroke:"none"})});case"eye":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]});case"camera":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M4 8h3l2-2h6l2 2h3v11H4z"}),s.jsx("circle",{cx:"12",cy:"13.5",r:"3.5"})]});case"arrowleft":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M19 12H5M11 6l-6 6 6 6"})});case"arrowright":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 12h14M13 6l6 6-6 6"})});case"reload":return s.jsxs("svg",{...o,children:[s.jsx("path",{d:"M4 12a8 8 0 0114-5.3M20 12a8 8 0 01-14 5.3"}),s.jsx("path",{d:"M18 3v4h-4M6 21v-4h4"})]});case"lock":return s.jsxs("svg",{...o,children:[s.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"2"}),s.jsx("path",{d:"M8 11V8a4 4 0 018 0v3"})]});case"stop":return s.jsx("svg",{...o,children:s.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5",fill:"currentColor",stroke:"none"})});case"star":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M12 3l2.6 5.6 6.1.6-4.6 4.1 1.3 6-5.4-3.2-5.4 3.2 1.3-6-4.6-4.1 6.1-.6z"})});case"minus":return s.jsx("svg",{...o,children:s.jsx("path",{d:"M5 12h14"})});default:return null}}function $T(e,n={}){switch(e){case"ready":return n.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 n.loadingPct=="number"?Math.round(n.loadingPct):0} percent`;case"error":return n.errorMessage?`Microphone — speech model error: ${n.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 O_=e=>Symbol.iterator in e,L_=e=>"entries"in e,z_=(e,n)=>{const r=e instanceof Map?e:new Map(e.entries()),i=n instanceof Map?n:new Map(n.entries());if(r.size!==i.size)return!1;for(const[o,l]of r)if(!i.has(o)||!Object.is(l,i.get(o)))return!1;return!0},AT=(e,n)=>{const r=e[Symbol.iterator](),i=n[Symbol.iterator]();let o=r.next(),l=i.next();for(;!o.done&&!l.done;){if(!Object.is(o.value,l.value))return!1;o=r.next(),l=i.next()}return!!o.done&&!!l.done};function RT(e,n){return Object.is(e,n)?!0:typeof e!="object"||e===null||typeof n!="object"||n===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(n)?!1:O_(e)&&O_(n)?L_(e)&&L_(n)?z_(e,n):AT(e,n):z_({entries:()=>Object.entries(e)},{entries:()=>Object.entries(n)})}function O2(e){const n=lo.useRef(void 0);return r=>{const i=e(r);return RT(n.current,i)?n.current:n.current=i}}let B_=0;const MT=1e3;function IT(e){const n=performance.now();n-B_<MT||(B_=n,dt.debug("voice","mic.gate.click_rejected",{reason:e}))}function L2(){const e=Tt(m=>m.isRecording),n=Tt(m=>m.error),r=Tt(m=>m.loadingProgress),i=Tt(O2(Hb)),o=()=>{const m=Tt.getState(),{canRecord:x,reason:g}=Hb(m);if(m.isRecording)return m.stopRecording();if(m.wizardArmed&&!m.wizardOpen){m.openWizard();return}if(g==="error"||g==="load-timeout"){m.resetAndRetryModel();return}if(!x)return IT(g);const b=kt.getState().activeTabId;b&&m.startRecording(b)},l=$T(i.reason,{loadingPct:r,errorMessage:n,isRecording:e}),h=i.reason==="unsupported",u=!i.canRecord,d=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 s.jsx("button",{onClick:o,disabled:h,"aria-disabled":u,"aria-label":l,title:l,"data-testid":"mic-button","data-state":i.reason,className:`p-1.5 rounded transition-colors ${d}`,children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),s.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),s.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),s.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function PT(){const e=Tt(r=>r.ttsEnabled),n=Tt(r=>r.toggleTTS);return s.jsxs("button",{onClick:n,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:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),e?s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),s.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),s.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),s.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}function Xm(e){if(!e||e==="—"||e==="unknown")return e;const n=/\[(\dm)\]/.exec(e),r=/(opus|sonnet|haiku)[-_](\d+)[-_.]?(\d+)?/i.exec(e);if(!r)return e;const i=r[1].charAt(0).toUpperCase()+r[1].slice(1).toLowerCase(),o=r[3]?`${r[2]}.${r[3]}`:r[2];return n?`${i} ${o} ${n[1]}`:`${i} ${o}`}const dx=new Map,DT=3e4;function z2(e){const[n,r]=L.useState(()=>{var i;return e?((i=dx.get(e))==null?void 0:i.value)??null:null});return L.useEffect(()=>{if(!e){r(null);return}let i=!1;return(async()=>{const l=dx.get(e);if(l&&Date.now()-l.ts<DT){i||r(l.value);return}try{const h=await window.api.app.gitBranch(e);if(i)return;dx.set(e,{value:h,ts:Date.now()}),r(h)}catch{if(i)return;dx.set(e,{value:null,ts:Date.now()}),r(null)}})(),()=>{i=!0}},[e]),n}const Xy=[{key:"overview",group:"Workspace",label:"Home",icon:"home",hint:"Today's sessions + the 5-hour window"},{key:"terminal",group:"Workspace",label:"Terminal",icon:"terminal",hint:"Live Claude Code, in-app"},{key:"browser",group:"Workspace",label:"Browser",icon:"browser",hint:"Embedded dev browser — capture DOM, record click-sequences"},{key:"projects",group:"Workspace",label:"File Explorer",icon:"projects",hint:"Browse files + edit, per project"},{key:"subagents",group:"Workspace",label:"Subagents",icon:"hive",liveKind:"subagents",hint:"Fan out work: Hive · Orchestrate · Race · Boss"},{key:"scheduler",group:"Workspace",label:"Scheduler",icon:"scheduler",liveKind:"scheduler",hint:"Author PRDs + run them as claude -p jobs"},{key:"history",group:"Workspace",label:"History",icon:"history",hint:"Every session, ever — resumable"},{key:"usage",group:"Workspace",label:"Usage",icon:"usage",hint:"Tokens, cost, sessions per day"},{key:"skills",group:"Configure",label:"Skills",icon:"skills",hint:"Reusable instructions Claude loads"},{key:"plugins",group:"Configure",label:"Plugins",icon:"plugins",hint:"Extensions for Claude Code"},{key:"mcp",group:"Configure",label:"MCP Servers",icon:"mcp",hint:"External tools and integrations"},{key:"hooks",group:"Configure",label:"Hooks",icon:"hooks",hint:"Run scripts on session events"},{key:"keybindings",group:"Configure",label:"Keybindings",icon:"keys",hint:"Shortcuts you can override"},{key:"memory",group:"Configure",label:"Memory",icon:"memory",hint:"Workspace memory store"},{key:"system-prompt",group:"Configure",label:"System Prompt",icon:"system-prompt",hint:"Personality and behavior"},{key:"permissions",group:"Configure",label:"Permissions",icon:"permissions",hint:"Allow / deny rules"},{key:"settings",group:"Configure",label:"Settings",icon:"settings",hint:"Theme, voice, billing window"},{key:"remote",group:"Configure",label:"Remote",icon:"remote",hint:"Web remote control — disabled by default"},{key:"voice",group:"Tools",label:"Voice",icon:"mic",hint:"Whisper transcription + push-to-talk"},{key:"repoviz",group:"Tools",label:"Repo Viz",icon:"repoviz",hint:"Language + directory map"},{key:"search",group:"Tools",label:"Search",icon:"global-search",hint:"⌘P file · ⌘⇧F content"}],OT=Object.fromEntries(Xy.map(e=>[e.key,e.group])),F_=Xy.filter(e=>e.group==="Workspace"),U_=Xy.filter(e=>e.group==="Configure"),H_=Xy.filter(e=>e.group==="Tools").map(({key:e,label:n,icon:r,hint:i})=>({key:e,label:n,icon:r,hint:i})),Wb="sm.almanac.sidebarWidth",B2=180,F2=480,qb=252;function LT(){try{const e=parseInt(localStorage.getItem(Wb)??"",10);if(Number.isFinite(e))return Math.min(F2,Math.max(B2,e))}catch{}return qb}const zT=52,U2="sm.almanac.sidebarCollapsed";function BT(){try{return localStorage.getItem(U2)==="1"}catch{}return!1}const H2="sm.almanac.collapsedGroups";function FT(){try{const e=localStorage.getItem(H2);if(!e)return new Set;const n=JSON.parse(e);return Array.isArray(n)?new Set(n.filter(r=>r==="Workspace"||r==="Configure"||r==="Tools")):new Set}catch{return new Set}}function UT(){const e=Vx(l=>l.tabs),n=yc(l=>{var h;return(((h=l.snapshot)==null?void 0:h.jobs)??[]).some(u=>u.status==="running")}),[r,i]=L.useState(()=>Date.now());return L.useEffect(()=>{const l=setInterval(()=>i(Date.now()),5e3);return()=>clearInterval(l)},[]),{subagents:Object.values(e).some(l=>l.agents.some(h=>r-h.at<6e4)),scheduler:n}}function HT({active:e,onNavigate:n,onNewSession:r}){const[i,o]=L.useState(()=>FT()),l=L.useCallback(_=>{o(j=>{const T=new Set(j);T.has(_)?T.delete(_):T.add(_);try{localStorage.setItem(H2,JSON.stringify(Array.from(T)))}catch{}return T})},[]),[h,u]=L.useState(()=>BT()),d=L.useCallback(()=>{u(_=>{const j=!_;try{localStorage.setItem(U2,j?"1":"0")}catch{}return j})},[]),m=kt(_=>_.tabs),x=kt(_=>_.activeTabId),g=m.find(_=>_.id===x)??null,b=UT(),[S,E]=L.useState(()=>LT()),C=L.useRef(S);C.current=S;const y=L.useCallback(_=>{_.preventDefault();const j=_.clientX,T=C.current;let A=T;const M=I=>{A=Math.min(F2,Math.max(B2,T+(I.clientX-j))),E(A)},O=()=>{window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",O),document.body.style.cursor="",document.body.style.userSelect="";try{localStorage.setItem(Wb,String(A))}catch{}};window.addEventListener("pointermove",M),window.addEventListener("pointerup",O),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]),v=L.useCallback(()=>{E(qb);try{localStorage.setItem(Wb,String(qb))}catch{}},[]);return s.jsxs("aside",{className:"shrink-0 bg-bg-elev border-r border-line flex flex-col relative transition-[width] duration-150",style:{width:h?zT:S},"data-testid":"tour-leftnav","aria-label":"Primary navigation",children:[s.jsx(WT,{tab:g,onNewSession:r,rail:h,onToggleRail:d}),s.jsx("div",{className:"flex-1 min-h-0 overflow-auto pb-3",style:{paddingInline:h?"4px":"8px"},children:s.jsxs(s.Fragment,{children:[!h&&s.jsx(Rv,{label:"Workspace",collapsed:i.has("Workspace"),count:F_.length,onToggle:()=>l("Workspace")}),(h||!i.has("Workspace"))&&F_.map(_=>s.jsx(W_,{item:_,active:e===_.key,live:_.liveKind?b[_.liveKind]:!1,onClick:()=>n(_.key),rail:h},_.key)),!h&&s.jsx(Rv,{label:"Configure",collapsed:i.has("Configure"),count:U_.length,onToggle:()=>l("Configure")}),(h||!i.has("Configure"))&&U_.map(_=>s.jsx(W_,{item:_,active:e===_.key,live:!1,onClick:()=>n(_.key),rail:h},_.key)),!h&&s.jsx(Rv,{label:"Tools",collapsed:i.has("Tools"),count:H_.length,onToggle:()=>l("Tools")}),(h||!i.has("Tools"))&&H_.map(_=>s.jsx(qT,{tool:_,active:e===_.key,onClick:()=>n(_.key),rail:h},_.key))]})}),s.jsx(VT,{rail:h}),!h&&s.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize · double-click to reset",onPointerDown:y,onDoubleClick:v,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 WT({tab:e,onNewSession:n,rail:r,onToggleRail:i}){const o=(e==null?void 0:e.label)??"no session",l=z2((e==null?void 0:e.cwd)??null);return r?s.jsxs("div",{className:"flex flex-col items-center gap-1.5 pt-2 pb-2 border-b border-rule",children:[s.jsx("button",{onClick:n,"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:s.jsx(dn,{name:"plus",size:15,stroke:1.8})}),s.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:s.jsx("span",{style:{display:"inline-flex",transform:"rotate(0deg)"},children:s.jsx(dn,{name:"chevron",size:15,stroke:1.8})})})]}):s.jsxs("div",{className:"px-[18px] pt-[14px] pb-[10px] border-b border-rule",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"text-[11px] font-semibold tracking-[0.06em] text-fg-faint uppercase",children:"Project"}),s.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:s.jsx("span",{style:{display:"inline-flex",transform:"rotate(180deg)"},children:s.jsx(dn,{name:"chevron",size:13,stroke:1.8})})})]}),s.jsxs("div",{className:"flex items-baseline gap-2 mt-1",children:[s.jsx("span",{className:"self-center w-2 h-2 rounded-full bg-sage"}),s.jsx("span",{className:"font-serif text-[18px] font-medium text-fg truncate",title:(e==null?void 0:e.cwd)??"",children:o})]}),s.jsx("div",{className:"text-[12px] text-fg-faint font-mono mt-0.5 truncate",children:l?`⌥${l}`:e?e.cwd:"—"}),s.jsxs("div",{className:"mt-3 flex items-stretch gap-1.5",children:[s.jsxs("button",{onClick:n,"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:[s.jsx(dn,{name:"plus",size:13,stroke:1.8}),"New session"]}),s.jsx("div",{className:"flex items-center rounded-md bg-bg-hi border border-line",children:s.jsx(L2,{})})]})]})}function Rv({label:e,collapsed:n,count:r,onToggle:i}){return s.jsxs("button",{onClick:i,"aria-expanded":!n,title:n?`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:[s.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 text-[9px] not-italic transition-transform",style:{transform:n?"rotate(-90deg)":"rotate(0deg)"},children:"▾"}),s.jsx("span",{className:"flex-1",children:e}),n&&s.jsx("span",{className:"not-italic text-[10px] font-mono text-fg-faint/70 normal-case tracking-normal",children:r})]})}function W_({item:e,active:n,live:r,onClick:i,rail:o}){return s.jsxs("button",{onClick:i,title:e.hint,"data-testid":e.key==="scheduler"?"tour-scheduler":void 0,className:`relative w-full flex items-center rounded-[10px] text-left mb-0.5 transition-colors ${o?"justify-center px-0 py-[9px]":"gap-3 px-3.5 py-[9px] text-[14px]"} ${n?"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:[n&&s.jsx("span",{"aria-hidden":!0,className:`absolute top-3 bottom-3 w-[3px] rounded-sm bg-accent ${o?"-left-[4px]":"-left-[10px]"}`}),s.jsx("span",{className:`inline-flex ${n?"text-accent":"text-fg-faint"}`,children:s.jsx(dn,{name:e.icon,size:17,stroke:1.6})}),!o&&s.jsx("span",{className:"flex-1 truncate",children:e.label}),!o&&r&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse",title:"live activity"}),o&&r&&s.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 qT({tool:e,active:n,onClick:r,rail:i}){return s.jsxs("button",{onClick:r,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]"} ${n?"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:[n&&s.jsx("span",{"aria-hidden":!0,className:`absolute top-2 bottom-2 w-[3px] rounded-sm bg-accent ${i?"-left-[4px]":"-left-[10px]"}`}),s.jsx("span",{className:`inline-flex ${n?"text-accent":"text-fg-faint"}`,children:s.jsx(dn,{name:e.icon,size:15,stroke:1.6})}),!i&&s.jsx("span",{className:"flex-1 truncate",children:e.label})]})}function VT({rail:e}){const n=Tt(u=>u.isRecording),r=kt(u=>u.tabs),i=kt(u=>u.activeTabId),o=r.find(u=>u.id===i)??null,[l,h]=L.useState(null);return L.useEffect(()=>{let u=!1;if(!(o!=null&&o.presetId)){h(null);return}return p2(o.presetId).then(d=>{u||h((d==null?void 0:d.model)??null)}).catch(()=>{u||h(null)}),()=>{u=!0}},[o==null?void 0:o.presetId]),e?s.jsx("div",{className:"py-2.5 border-t border-rule flex justify-center",children:s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n?"bg-red-500 animate-pulse":"bg-sage"}`,title:n?"recording":"idle"})}):s.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:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n?"bg-red-500 animate-pulse":"bg-sage"}`,title:n?"recording":"idle"}),s.jsx("span",{className:"truncate",title:l??"",children:n?"recording…":l?`Claude · ${Xm(l)}`:"Claude Code"})]})}function GT({onNavigate:e}){const n=kt(j=>j.tabs),r=kt(j=>j.activeTabId),i=n.find(j=>j.id===r)??null,o=w2(i),l=(o==null?void 0:o.lastEventAt)??0,h=Fh(j=>j.data),u=yc(j=>{var T;return((T=j.snapshot)==null?void 0:T.paused)??null}),d=z2((i==null?void 0:i.cwd)??null),[,m]=L.useState(0);L.useEffect(()=>{const j=setInterval(()=>m(T=>T+1),6e4);return()=>clearInterval(j)},[]);const x=(o==null?void 0:o.todos)??[],[g,b]=L.useState(!1),S=L.useRef(null);L.useEffect(()=>{if(!g)return;const j=T=>{S.current&&!S.current.contains(T.target)&&b(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[g]),L.useEffect(()=>{x.length===0&&b(!1)},[x.length]);const E=Ky(h),C=(E==null?void 0:E.usage.five_hour)??null,y=C?Math.round(C.utilization):null,v=(h==null?void 0:h.kind)==="ok"||(h==null?void 0:h.kind)==="ok-stale",_=l>0?YT(Date.now()-l):"—";return s.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:[s.jsxs("button",{onClick:()=>e==null?void 0:e("settings"),className:"flex items-center gap-1.5 hover:text-fg transition-colors",title:v?"Connected to Anthropic":"Disconnected",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${v?"bg-sage":"bg-fg-faint"}`}),s.jsx("span",{children:v?"connected":"offline"})]}),s.jsx("button",{onClick:()=>e==null?void 0:e("usage"),className:"hover:text-fg transition-colors",title:"Open Usage",children:y!=null?`${y}% of 5h window used`:"5h —"}),u&&s.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 ${u.reason==="auth"||u.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:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current opacity-80"}),"Scheduler paused · ",u.reason]}),i&&s.jsxs("span",{className:"text-fg-faint",title:i.cwd,children:[i.label,d&&s.jsxs("span",{className:"text-fg-dim",children:[" · ⌥",d]})]}),s.jsxs("span",{className:"text-fg-faint",children:["last activity: ",s.jsx("span",{className:"text-fg-dim",children:_})]}),x.length>0&&s.jsx(KT,{ref:S,todos:x,open:g,onToggle:()=>b(j=>!j)}),s.jsx("span",{className:"flex-1"}),s.jsxs("span",{className:"text-fg-faint",children:["v","0.37.1"]})]})}const KT=L.forwardRef(function({todos:n,open:r,onToggle:i},o){const l={completed:n.filter(h=>h.status==="completed").length,in_progress:n.filter(h=>h.status==="in_progress").length,pending:n.filter(h=>h.status==="pending").length};return s.jsxs("div",{ref:o,className:"relative",children:[s.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:[s.jsxs("span",{className:"text-green-400",children:["✓",l.completed]}),s.jsxs("span",{className:"text-accent",children:["●",l.in_progress]}),s.jsxs("span",{className:"text-fg-dim",children:["○",l.pending]}),s.jsxs("span",{className:"text-fg-faint",children:["todos ",r?"▾":"▴"]})]}),r&&s.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:s.jsx("ul",{className:"space-y-0.5",children:n.map((h,u)=>s.jsxs("li",{className:`flex items-start gap-2 py-1 px-1.5 rounded ${h.status==="in_progress"?"bg-bg-hi":""}`,children:[s.jsx(XT,{status:h.status}),s.jsx("span",{className:h.status==="completed"?"text-fg-faint line-through":h.status==="in_progress"?"text-fg":"text-fg-dim",children:h.status==="in_progress"&&h.activeForm?h.activeForm:h.content})]},u))})})]})});function XT({status:e}){return e==="completed"?s.jsx("span",{className:"text-green-400 w-3 shrink-0",children:"✓"}):e==="in_progress"?s.jsx("span",{className:"w-3 shrink-0",children:s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent animate-pulse"})}):s.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:"○"})}function YT(e){const n=Math.max(0,Math.floor(e/1e3));if(n<60)return`${n}s ago`;const r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}var Mv={exports:{}},q_;function JT(){return q_||(q_=1,(function(e,n){(function(r,i){e.exports=i()})(globalThis,(()=>(()=>{var r={4567:function(h,u,d){var m=this&&this.__decorate||function(_,j,T,A){var M,O=arguments.length,I=O<3?j:A===null?A=Object.getOwnPropertyDescriptor(j,T):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(_,j,T,A);else for(var z=_.length-1;z>=0;z--)(M=_[z])&&(I=(O<3?M(I):O>3?M(j,T,I):M(j,T))||I);return O>3&&I&&Object.defineProperty(j,T,I),I},x=this&&this.__param||function(_,j){return function(T,A){j(T,A,_)}};Object.defineProperty(u,"__esModule",{value:!0}),u.AccessibilityManager=void 0;const g=d(9042),b=d(9924),S=d(844),E=d(4725),C=d(2585),y=d(3656);let v=u.AccessibilityManager=class extends S.Disposable{constructor(_,j,T,A){super(),this._terminal=_,this._coreBrowserService=T,this._renderService=A,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 M=0;M<this._terminal.rows;M++)this._rowElements[M]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[M]);if(this._topBoundaryFocusListener=M=>this._handleBoundaryFocus(M,0),this._bottomBoundaryFocusListener=M=>this._handleBoundaryFocus(M,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((M=>this._handleResize(M.rows)))),this.register(this._terminal.onRender((M=>this._refreshRows(M.start,M.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((M=>this._handleChar(M)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
2896
2896
  `)))),this.register(this._terminal.onA11yTab((M=>this._handleTab(M)))),this.register(this._terminal.onKey((M=>this._handleKey(M.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,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(_){for(let j=0;j<_;j++)this._handleChar(" ")}_handleChar(_){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==_&&(this._charsToAnnounce+=_):this._charsToAnnounce+=_,_===`
2897
2897
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=g.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(_){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(_)||this._charsToConsume.push(_)}_refreshRows(_,j){this._liveRegionDebouncer.refresh(_,j,this._terminal.rows)}_renderRows(_,j){const T=this._terminal.buffer,A=T.lines.length.toString();for(let M=_;M<=j;M++){const O=T.lines.get(T.ydisp+M),I=[],z=(O==null?void 0:O.translateToString(!0,void 0,void 0,I))||"",U=(T.ydisp+M+1).toString(),W=this._rowElements[M];W&&(z.length===0?(W.innerText=" ",this._rowColumns.set(W,[0,1])):(W.textContent=z,this._rowColumns.set(W,I)),W.setAttribute("aria-posinset",U),W.setAttribute("aria-setsize",A))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(_,j){const T=_.target,A=this._rowElements[j===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(j===0?"1":`${this._terminal.buffer.lines.length}`)||_.relatedTarget!==A)return;let M,O;if(j===0?(M=T,O=this._rowElements.pop(),this._rowContainer.removeChild(O)):(M=this._rowElements.shift(),O=T,this._rowContainer.removeChild(M)),M.removeEventListener("focus",this._topBoundaryFocusListener),O.removeEventListener("focus",this._bottomBoundaryFocusListener),j===0){const I=this._createAccessibilityTreeNode();this._rowElements.unshift(I),this._rowContainer.insertAdjacentElement("afterbegin",I)}else{const I=this._createAccessibilityTreeNode();this._rowElements.push(I),this._rowContainer.appendChild(I)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(j===0?-1:1),this._rowElements[j===0?1:this._rowElements.length-2].focus(),_.preventDefault(),_.stopImmediatePropagation()}_handleSelectionChange(){var z;if(this._rowElements.length===0)return;const _=document.getSelection();if(!_)return;if(_.isCollapsed)return void(this._rowContainer.contains(_.anchorNode)&&this._terminal.clearSelection());if(!_.anchorNode||!_.focusNode)return void console.error("anchorNode and/or focusNode are null");let j={node:_.anchorNode,offset:_.anchorOffset},T={node:_.focusNode,offset:_.focusOffset};if((j.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||j.node===T.node&&j.offset>T.offset)&&([j,T]=[T,j]),j.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(j={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(j.node))return;const A=this._rowElements.slice(-1)[0];if(T.node.compareDocumentPosition(A)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(T={node:A,offset:((z=A.textContent)==null?void 0:z.length)??0}),!this._rowContainer.contains(T.node))return;const M=({node:U,offset:W})=>{const Y=U instanceof Text?U.parentNode:U;let V=parseInt(Y==null?void 0:Y.getAttribute("aria-posinset"),10)-1;if(isNaN(V))return console.warn("row is invalid. Race condition?"),null;const H=this._rowColumns.get(Y);if(!H)return console.warn("columns is null. Race condition?"),null;let te=W<H.length?H[W]:H.slice(-1)[0]+1;return te>=this._terminal.cols&&(++V,te=0),{row:V,column:te}},O=M(j),I=M(T);if(O&&I){if(O.row>I.row||O.row===I.row&&O.column>=I.column)throw new Error("invalid range");this._terminal.select(O.column,O.row,(I.row-O.row)*this._terminal.cols-O.column+I.column)}}_handleResize(_){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let j=this._rowContainer.children.length;j<this._terminal.rows;j++)this._rowElements[j]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[j]);for(;this._rowElements.length>_;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const _=this._coreBrowserService.mainDocument.createElement("div");return _.setAttribute("role","listitem"),_.tabIndex=-1,this._refreshRowDimensions(_),_}_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 _=0;_<this._terminal.rows;_++)this._refreshRowDimensions(this._rowElements[_])}}_refreshRowDimensions(_){_.style.height=`${this._renderService.dimensions.css.cell.height}px`}};u.AccessibilityManager=v=m([x(1,C.IInstantiationService),x(2,E.ICoreBrowserService),x(3,E.IRenderService)],v)},3614:(h,u)=>{function d(b){return b.replace(/\r?\n/g,"\r")}function m(b,S){return S?"\x1B[200~"+b+"\x1B[201~":b}function x(b,S,E,C){b=m(b=d(b),E.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),E.triggerDataEvent(b,!0),S.value=""}function g(b,S,E){const C=E.getBoundingClientRect(),y=b.clientX-C.left-10,v=b.clientY-C.top-10;S.style.width="20px",S.style.height="20px",S.style.left=`${y}px`,S.style.top=`${v}px`,S.style.zIndex="1000",S.focus()}Object.defineProperty(u,"__esModule",{value:!0}),u.rightClickHandler=u.moveTextAreaUnderMouseCursor=u.paste=u.handlePasteEvent=u.copyHandler=u.bracketTextForPaste=u.prepareTextForTerminal=void 0,u.prepareTextForTerminal=d,u.bracketTextForPaste=m,u.copyHandler=function(b,S){b.clipboardData&&b.clipboardData.setData("text/plain",S.selectionText),b.preventDefault()},u.handlePasteEvent=function(b,S,E,C){b.stopPropagation(),b.clipboardData&&x(b.clipboardData.getData("text/plain"),S,E,C)},u.paste=x,u.moveTextAreaUnderMouseCursor=g,u.rightClickHandler=function(b,S,E,C,y){g(b,S,E),y&&C.rightClickSelect(b),S.value=C.selectionText,S.select()}},7239:(h,u,d)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.ColorContrastCache=void 0;const m=d(1505);u.ColorContrastCache=class{constructor(){this._color=new m.TwoKeyMap,this._css=new m.TwoKeyMap}setCss(x,g,b){this._css.set(x,g,b)}getCss(x,g){return this._css.get(x,g)}setColor(x,g,b){this._color.set(x,g,b)}getColor(x,g){return this._color.get(x,g)}clear(){this._color.clear(),this._css.clear()}}},3656:(h,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.addDisposableDomListener=void 0,u.addDisposableDomListener=function(d,m,x,g){d.addEventListener(m,x,g);let b=!1;return{dispose:()=>{b||(b=!0,d.removeEventListener(m,x,g))}}}},3551:function(h,u,d){var m=this&&this.__decorate||function(v,_,j,T){var A,M=arguments.length,O=M<3?_:T===null?T=Object.getOwnPropertyDescriptor(_,j):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,_,j,T);else for(var I=v.length-1;I>=0;I--)(A=v[I])&&(O=(M<3?A(O):M>3?A(_,j,O):A(_,j))||O);return M>3&&O&&Object.defineProperty(_,j,O),O},x=this&&this.__param||function(v,_){return function(j,T){_(j,T,v)}};Object.defineProperty(u,"__esModule",{value:!0}),u.Linkifier=void 0;const g=d(3656),b=d(8460),S=d(844),E=d(2585),C=d(4725);let y=u.Linkifier=class extends S.Disposable{get currentLink(){return this._currentLink}constructor(v,_,j,T,A){super(),this._element=v,this._mouseService=_,this._renderService=j,this._bufferService=T,this._linkProviderService=A,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,S.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,S.toDisposable)((()=>{var M;this._lastMouseEvent=void 0,(M=this._activeProviderReplies)==null||M.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,g.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,g.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,g.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,g.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(v){this._lastMouseEvent=v;const _=this._positionFromMouseEvent(v,this._element,this._mouseService);if(!_)return;this._isMouseOut=!1;const j=v.composedPath();for(let T=0;T<j.length;T++){const A=j[T];if(A.classList.contains("xterm"))break;if(A.classList.contains("xterm-hover"))return}this._lastBufferCell&&_.x===this._lastBufferCell.x&&_.y===this._lastBufferCell.y||(this._handleHover(_),this._lastBufferCell=_)}_handleHover(v){if(this._activeLine!==v.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(v,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,v)||(this._clearCurrentLink(),this._askForLink(v,!0))}_askForLink(v,_){var T,A;this._activeProviderReplies&&_||((T=this._activeProviderReplies)==null||T.forEach((M=>{M==null||M.forEach((O=>{O.link.dispose&&O.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=v.y);let j=!1;for(const[M,O]of this._linkProviderService.linkProviders.entries())_?(A=this._activeProviderReplies)!=null&&A.get(M)&&(j=this._checkLinkProviderResult(M,v,j)):O.provideLinks(v.y,(I=>{var U,W;if(this._isMouseOut)return;const z=I==null?void 0:I.map((Y=>({link:Y})));(U=this._activeProviderReplies)==null||U.set(M,z),j=this._checkLinkProviderResult(M,v,j),((W=this._activeProviderReplies)==null?void 0:W.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(v.y,this._activeProviderReplies)}))}_removeIntersectingLinks(v,_){const j=new Set;for(let T=0;T<_.size;T++){const A=_.get(T);if(A)for(let M=0;M<A.length;M++){const O=A[M],I=O.link.range.start.y<v?0:O.link.range.start.x,z=O.link.range.end.y>v?this._bufferService.cols:O.link.range.end.x;for(let U=I;U<=z;U++){if(j.has(U)){A.splice(M--,1);break}j.add(U)}}}}_checkLinkProviderResult(v,_,j){var M;if(!this._activeProviderReplies)return j;const T=this._activeProviderReplies.get(v);let A=!1;for(let O=0;O<v;O++)this._activeProviderReplies.has(O)&&!this._activeProviderReplies.get(O)||(A=!0);if(!A&&T){const O=T.find((I=>this._linkAtPosition(I.link,_)));O&&(j=!0,this._handleNewLink(O))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!j)for(let O=0;O<this._activeProviderReplies.size;O++){const I=(M=this._activeProviderReplies.get(O))==null?void 0:M.find((z=>this._linkAtPosition(z.link,_)));if(I){j=!0,this._handleNewLink(I);break}}return j}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(v){if(!this._currentLink)return;const _=this._positionFromMouseEvent(v,this._element,this._mouseService);_&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,_)&&this._currentLink.link.activate(v,this._currentLink.link.text)}_clearCurrentLink(v,_){this._currentLink&&this._lastMouseEvent&&(!v||!_||this._currentLink.link.range.start.y>=v&&this._currentLink.link.range.end.y<=_)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,S.disposeArray)(this._linkCacheDisposables))}_handleNewLink(v){if(!this._lastMouseEvent)return;const _=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);_&&this._linkAtPosition(v.link,_)&&(this._currentLink=v,this._currentLink.state={decorations:{underline:v.link.decorations===void 0||v.link.decorations.underline,pointerCursor:v.link.decorations===void 0||v.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,v.link,this._lastMouseEvent),v.link.decorations={},Object.defineProperties(v.link.decorations,{pointerCursor:{get:()=>{var j,T;return(T=(j=this._currentLink)==null?void 0:j.state)==null?void 0:T.decorations.pointerCursor},set:j=>{var T;(T=this._currentLink)!=null&&T.state&&this._currentLink.state.decorations.pointerCursor!==j&&(this._currentLink.state.decorations.pointerCursor=j,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",j))}},underline:{get:()=>{var j,T;return(T=(j=this._currentLink)==null?void 0:j.state)==null?void 0:T.decorations.underline},set:j=>{var T,A,M;(T=this._currentLink)!=null&&T.state&&((M=(A=this._currentLink)==null?void 0:A.state)==null?void 0:M.decorations.underline)!==j&&(this._currentLink.state.decorations.underline=j,this._currentLink.state.isHovered&&this._fireUnderlineEvent(v.link,j))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((j=>{if(!this._currentLink)return;const T=j.start===0?0:j.start+1+this._bufferService.buffer.ydisp,A=this._bufferService.buffer.ydisp+1+j.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=A&&(this._clearCurrentLink(T,A),this._lastMouseEvent)){const M=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);M&&this._askForLink(M,!1)}}))))}_linkHover(v,_,j){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(_,!0),this._currentLink.state.decorations.pointerCursor&&v.classList.add("xterm-cursor-pointer")),_.hover&&_.hover(j,_.text)}_fireUnderlineEvent(v,_){const j=v.range,T=this._bufferService.buffer.ydisp,A=this._createLinkUnderlineEvent(j.start.x-1,j.start.y-T-1,j.end.x,j.end.y-T-1,void 0);(_?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(A)}_linkLeave(v,_,j){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(_,!1),this._currentLink.state.decorations.pointerCursor&&v.classList.remove("xterm-cursor-pointer")),_.leave&&_.leave(j,_.text)}_linkAtPosition(v,_){const j=v.range.start.y*this._bufferService.cols+v.range.start.x,T=v.range.end.y*this._bufferService.cols+v.range.end.x,A=_.y*this._bufferService.cols+_.x;return j<=A&&A<=T}_positionFromMouseEvent(v,_,j){const T=j.getCoords(v,_,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(v,_,j,T,A){return{x1:v,y1:_,x2:j,y2:T,cols:this._bufferService.cols,fg:A}}};u.Linkifier=y=m([x(1,C.IMouseService),x(2,C.IRenderService),x(3,E.IBufferService),x(4,C.ILinkProviderService)],y)},9042:(h,u)=>{Object.defineProperty(u,"__esModule",{value:!0}),u.tooMuchOutput=u.promptLabel=void 0,u.promptLabel="Terminal input",u.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(h,u,d){var m=this&&this.__decorate||function(C,y,v,_){var j,T=arguments.length,A=T<3?y:_===null?_=Object.getOwnPropertyDescriptor(y,v):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(C,y,v,_);else for(var M=C.length-1;M>=0;M--)(j=C[M])&&(A=(T<3?j(A):T>3?j(y,v,A):j(y,v))||A);return T>3&&A&&Object.defineProperty(y,v,A),A},x=this&&this.__param||function(C,y){return function(v,_){y(v,_,C)}};Object.defineProperty(u,"__esModule",{value:!0}),u.OscLinkProvider=void 0;const g=d(511),b=d(2585);let S=u.OscLinkProvider=class{constructor(C,y,v){this._bufferService=C,this._optionsService=y,this._oscLinkService=v}provideLinks(C,y){var z;const v=this._bufferService.buffer.lines.get(C-1);if(!v)return void y(void 0);const _=[],j=this._optionsService.rawOptions.linkHandler,T=new g.CellData,A=v.getTrimmedLength();let M=-1,O=-1,I=!1;for(let U=0;U<A;U++)if(O!==-1||v.hasContent(U)){if(v.loadCell(U,T),T.hasExtendedAttrs()&&T.extended.urlId){if(O===-1){O=U,M=T.extended.urlId;continue}I=T.extended.urlId!==M}else O!==-1&&(I=!0);if(I||O!==-1&&U===A-1){const W=(z=this._oscLinkService.getLinkData(M))==null?void 0:z.uri;if(W){const Y={start:{x:O+1,y:C},end:{x:U+(I||U!==A-1?0:1),y:C}};let V=!1;if(!(j!=null&&j.allowNonHttpProtocols))try{const H=new URL(W);["http:","https:"].includes(H.protocol)||(V=!0)}catch{V=!0}V||_.push({text:W,range:Y,activate:(H,te)=>j?j.activate(H,te,Y):E(0,te),hover:(H,te)=>{var oe;return(oe=j==null?void 0:j.hover)==null?void 0:oe.call(j,H,te,Y)},leave:(H,te)=>{var oe;return(oe=j==null?void 0:j.leave)==null?void 0:oe.call(j,H,te,Y)}})}I=!1,T.hasExtendedAttrs()&&T.extended.urlId?(O=U,M=T.extended.urlId):(O=-1,M=-1)}}y(_)}};function E(C,y){if(confirm(`Do you want to navigate to ${y}?
2898
2898
 
@@ -3382,7 +3382,7 @@ tools:
3382
3382
  }`),x(null),o(O=>new Set(O).add(M))},T=A=>o(M=>{const O=new Set(M);return O.has(A)?O.delete(A):O.add(A),O});return s.jsxs("div",{className:"h-full overflow-auto bg-bg text-xs",children:[s.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-3 px-3 py-1.5 bg-bg-elev border-b border-line",children:[s.jsxs("span",{className:"text-fg-faint tabular-nums",children:[b.length.toLocaleString()," record",b.length===1?"":"s"]}),s.jsx("button",{onClick:j,className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"+ Add record"}),S&&s.jsxs("span",{className:"text-[10px] text-amber-700",children:["Showing first ",lw.toLocaleString()," — switch to Edit for the full file."]})]}),b.length===0?s.jsx("div",{className:"p-6 text-fg-faint",children:"empty file"}):s.jsx("ul",{className:"divide-y divide-line",children:b.map((A,M)=>{const O=i.has(A.line)||l===A.line;return s.jsxs("li",{className:A.error?"bg-red-500/5":"",children:[s.jsxs("div",{className:"flex items-start gap-2 px-3 py-1.5",children:[s.jsx("span",{className:"w-10 shrink-0 text-right text-fg-faint tabular-nums select-none",children:M+1}),s.jsxs("button",{onClick:()=>T(A.line),className:"flex-1 min-w-0 text-left",title:O?"Collapse":"Expand",children:[s.jsx("span",{className:`mr-1 inline-block transition-transform ${O?"rotate-90":""}`,children:"›"}),s.jsx("span",{className:A.error?"text-red-400":"text-fg-dim",children:GD(A)})]}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[l!==A.line&&s.jsx("button",{onClick:()=>y(A),className:"text-fg-faint hover:text-fg",children:"Edit"}),s.jsx("button",{onClick:()=>_(A.line),className:"text-fg-faint hover:text-red-400",children:"Delete"})]})]}),O&&l===A.line&&s.jsxs("div",{className:"px-3 pb-2 pl-12",children:[s.jsx("textarea",{value:u,onChange:I=>{d(I.target.value),x(null)},spellCheck:!1,rows:Math.min(20,u.split(`
3383
3383
  `).length+1),className:"w-full font-mono text-[11px] bg-bg border border-line rounded p-2 text-fg outline-none focus:border-fg-faint resize-y"}),m&&s.jsxs("div",{className:"mt-1 text-[10px] text-red-400",children:["Invalid JSON: ",m]}),s.jsxs("div",{className:"mt-1 flex gap-2",children:[s.jsx("button",{onClick:()=>v(A.line),className:"px-2 py-0.5 text-[11px] text-white bg-blue-600 hover:bg-blue-500 rounded",children:"Save record"}),s.jsx("button",{onClick:()=>{h(null),x(null)},className:"px-2 py-0.5 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"})]})]}),O&&l!==A.line&&s.jsx("pre",{className:"px-3 pb-2 pl-12 font-mono text-[11px] text-fg-dim whitespace-pre-wrap break-all",children:A.error?A.raw:JSON.stringify(A.value,null,2)})]},A.line)})})]})}function XD(e){if(!e)return"0 B";const n=["B","KB","MB","GB"],r=Math.min(n.length-1,Math.floor(Math.log(e)/Math.log(1024)));return`${(e/1024**r).toFixed(r?1:0)} ${n[r]}`}function YD({path:e,name:n,size:r,mime:i,reason:o}){return s.jsx("div",{className:"h-full flex items-center justify-center bg-bg",children:s.jsxs("div",{className:"text-center max-w-sm px-6",children:[s.jsx("div",{className:"mx-auto mb-4 w-12 h-12 rounded-lg border border-line flex items-center justify-center text-fg-faint",children:s.jsxs("svg",{width:22,height:22,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("path",{d:"M14 2v6h6"})]})}),s.jsx("div",{className:"text-sm font-medium text-fg truncate",children:n}),s.jsxs("div",{className:"mt-1 text-[11px] text-fg-faint",children:[o," · ",i," · ",XD(r)]}),s.jsxs("div",{className:"mt-5 flex items-center justify-center gap-2",children:[s.jsx("button",{onClick:()=>window.api.shell.open({as:"openPath",path:e}),className:"px-3 py-1 text-xs text-fg rounded bg-bg-hi border border-line hover:bg-bg-elev",children:"Open in default app"}),s.jsx("button",{onClick:()=>window.api.shell.open({as:"revealPath",path:e}),className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Reveal"})]})]})})}function hk(e,n){if(!n)return 0;let r=0,i=0;for(;;){const o=e.indexOf(n,i);if(o===-1)break;r++,i=o+n.length}return r}function fk(e){let n="";const r=[],i=[];let o=0;for(;o<e.length;){const l=e[o];if(/\s/.test(l)){const h=o;for(;o<e.length&&/\s/.test(e[o]);)o++;n+=" ",r.push(h),i.push(o)}else n+=l,r.push(o),i.push(o+1),o++}return{norm:n,starts:r,ends:i}}function JD(e,n,r){const i=hk(e,n);if(i===1){const g=e.indexOf(n);return{ok:!0,next:e.slice(0,g)+r+e.slice(g+n.length)}}if(i>=2)return{ok:!1,reason:"ambiguous"};const o=fk(e),l=fk(n).norm.trim();if(!l)return{ok:!1,reason:"not-found"};if(hk(o.norm,l)!==1)return{ok:!1,reason:"not-found"};const u=o.norm.indexOf(l),d=u+l.length,m=o.starts[u],x=o.ends[d-1];return{ok:!0,next:e.slice(0,m)+r+e.slice(x)}}const bm={phase:"idle",selection:null,instruction:"",transcript:"",diff:null,editCount:0},QD=["popover","review","diff"],ij=["popover","review"];function ZD(e,n){switch(n.type){case"SELECT":return{...bm,editCount:e.editCount,phase:"popover",selection:n.selection};case"CANCEL":return{...bm,editCount:e.editCount};case"LISTEN":return ij.includes(e.phase)?{...e,phase:"listening",transcript:""}:e;case"HEARD":return e.phase!=="listening"?e:{...e,phase:"review",transcript:n.transcript};case"RUN":return QD.includes(e.phase)?{...e,phase:"thinking",instruction:n.recordInstruction?n.instruction:e.instruction}:e;case"RUN_OK":return e.phase!=="thinking"?e:{...e,phase:"diff",diff:n.diff};case"RUN_ERR":return e.phase!=="thinking"?e:{...e,phase:"popover",transcript:"",diff:null};case"ACCEPT":return e.phase!=="diff"?e:{...bm,editCount:e.editCount+1};case"RESET_FILE":return{...bm,editCount:0};default:return e}}const eO="sonnet";function tO(e){const[n,r]=L.useReducer(ZD,bm),i=L.useRef(0),o=L.useRef(null),l=L.useRef(e);L.useEffect(()=>{l.current!==e&&(l.current=e,i.current+=1,h(),r({type:"RESET_FILE"}))},[e]);function h(){const C=o.current;C&&(o.current=null,C.stop().catch(()=>{}),C.destroy(),Tt.setState({externalRecording:!1}))}const u=L.useCallback(C=>{i.current+=1,h(),r({type:"SELECT",selection:C})},[]),d=L.useCallback(()=>{i.current+=1,h(),r({type:"CANCEL"})},[]),m=L.useCallback(()=>{if(!ij.includes(n.phase))return;if(Tt.getState().isRecording){ze.error("Microphone is already in use");return}if(!Gy()){ze.error("Microphone or Web Worker not available");return}const C=++i.current;r({type:"LISTEN"}),Tt.setState({externalRecording:!0});const y=()=>{o.current===v&&(o.current=null),Tt.setState({externalRecording:!1})},v=M2({onFinal:_=>{if(i.current!==C)return;v.stop().catch(()=>{}),v.destroy(),y();const j=_.trim();if(!j){r({type:"CANCEL"});return}r({type:"HEARD",transcript:j})},onError:_=>{i.current===C&&(v.destroy(),y(),ze.error(`Microphone error: ${_}`),r({type:"CANCEL"}))}});o.current=v,v.start().catch(_=>{i.current===C&&(v.destroy(),y(),ze.error(`Could not start mic: ${_ instanceof Error?_.message:String(_)}`),r({type:"CANCEL"}))})},[n.phase]),x=L.useCallback(async(C,y)=>{const v=n.selection;if(!v)return;const _=++i.current;r({type:"RUN",instruction:C,recordInstruction:y});const j=await window.api.docEdit.run({path:e,before:v.text,instruction:C});if(i.current===_){if(!j.ok){ze.error(j.error||"Edit failed"),r({type:"RUN_ERR"});return}r({type:"RUN_OK",diff:{before:v.text,after:j.after??""}})}},[e,n.selection]),g=L.useCallback(C=>{x(C,!0)},[x]),b=L.useCallback(()=>{n.phase==="review"&&x(n.transcript,!0)},[x,n.phase,n.transcript]),S=L.useCallback(()=>{const C=n.instruction;C&&x(`${C}
3384
3384
 
3385
- (Give a different rewrite than the last one.)`,!1)},[x,n.instruction]),E=L.useCallback(C=>{const y=n.diff;if(!y)return{ok:!1,reason:"not-found"};const v=JD(C,y.before,y.after);return v.ok?(i.current+=1,r({type:"ACCEPT"})):ze.error(v.reason==="ambiguous"?"That text appears more than once — edit it manually instead.":"That text no longer matches the document — edit it manually instead."),v},[n.diff]);return{state:n,select:u,cancel:d,listen:m,sendHeard:b,run:g,retry:S,accept:E}}const nO=[{label:"Make concise",instruction:"Rewrite this text to be concise and specific. Preserve meaning and any markdown structure."},{label:"To bullet list",instruction:"Convert this text into a tight markdown bullet list."},{label:"Fix the tone",instruction:"Fix the tone: direct, professional, no hedging. Preserve meaning."}],pk=320,rm=8;function rO(){return s.jsxs("span",{className:"inline-flex items-center gap-0.5","aria-hidden":"true",children:[s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:0ms]"}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:150ms]"}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:300ms]"})]})}function sO(e){const n=typeof window<"u"?window.innerWidth:1024,r=Math.min(Math.max(e.left,rm),Math.max(rm,n-pk-rm)),i=Math.max(e.top-rm,rm);return{position:"fixed",left:r,top:i,width:pk,transform:"translateY(-100%)",zIndex:50}}function iO({phase:e,rect:n,diff:r,transcript:i,onQuickAction:o,onRunCustom:l,onListen:h,onSendHeard:u,onCancel:d,onAccept:m,onReject:x,onRetry:g}){const[b,S]=L.useState(""),E=()=>{const C=b.trim();C&&(l(C),S(""))};return s.jsxs("div",{"data-doc-edit-popover":!0,style:sO(n),className:"rounded-lg border border-line bg-bg-elev shadow-2xl text-xs text-fg",children:[e==="popover"&&s.jsxs("div",{className:"p-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("button",{onClick:h,"data-testid":"doc-edit-voice",className:"px-2 py-1 text-[11px] rounded border border-line bg-bg-hi text-fg hover:border-fg-faint font-medium",title:"Speak your edit instruction",children:"🎤 Voice edit"}),nO.map(C=>s.jsx("button",{onClick:()=>o(C.instruction),className:"px-2 py-1 text-[11px] rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:C.label},C.label))]}),s.jsx("button",{onClick:d,className:"ml-2 shrink-0 text-fg-faint hover:text-fg",title:"Dismiss","aria-label":"Dismiss",children:"×"})]}),s.jsx("input",{autoFocus:!0,value:b,onChange:C=>S(C.target.value),onKeyDown:C=>{C.key==="Enter"?E():C.key==="Escape"&&d()},placeholder:"tell Claude what to change…",className:"w-full px-2 py-1 text-[11px] bg-bg border border-line rounded outline-none focus:border-fg-faint text-fg placeholder:text-fg-faint"})]}),e==="listening"&&s.jsxs("div",{className:"p-3 flex items-center justify-between","data-testid":"doc-edit-listening",children:[s.jsxs("span",{className:"flex items-center gap-2 text-fg-dim",children:[s.jsx(rO,{}),"Listening…"]}),s.jsx("button",{onClick:d,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),e==="review"&&s.jsxs("div",{className:"p-3","data-testid":"doc-edit-review",children:[s.jsxs("p",{className:"italic text-fg mb-2",children:["«",i,"»"]}),s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsx("button",{onClick:d,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:h,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Re-record"}),s.jsx("button",{onClick:u,className:"px-2 py-1 text-[11px] text-white rounded bg-accent hover:opacity-90",children:"Send"})]})]}),e==="thinking"&&s.jsxs("div",{className:"p-3 flex items-center justify-between",children:[s.jsx("span",{className:"text-fg-dim animate-pulse",children:"Claude is editing…"}),s.jsx("button",{onClick:d,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),e==="diff"&&r&&s.jsxs("div",{className:"p-3",children:[s.jsxs("div",{className:"mb-2 max-h-40 overflow-auto space-y-1",children:[s.jsx("div",{className:"text-red-400 line-through whitespace-pre-wrap",children:r.before}),s.jsx("div",{className:"text-green-400 whitespace-pre-wrap",children:r.after})]}),s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsx("button",{onClick:x,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Reject"}),s.jsx("button",{onClick:g,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Retry"}),s.jsx("button",{onClick:m,className:"px-2 py-1 text-[11px] text-white rounded bg-green-600 hover:bg-green-500",children:"Accept"})]})]})]})}function oO(){return s.jsxs("span",{className:"inline-flex items-center gap-0.5","aria-hidden":"true",children:[s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:0ms]"}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:150ms]"}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:300ms]"})]})}function mk({phase:e,transcript:n,diff:r,editCount:i,onListen:o,onSendHeard:l,onCancel:h,onAccept:u,onReject:d,onRetry:m}){return s.jsxs("div",{"data-testid":"assistant-rail",className:"w-[300px] shrink-0 border-l border-line bg-bg-elev flex flex-col text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 h-8 border-b border-line shrink-0",children:[s.jsx("span",{className:"font-medium text-fg",children:"Assistant"}),s.jsx("span",{className:"text-[10px] text-fg-faint",title:"Model used for Document Experience edits",children:Xm(eO)})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[e==="idle"&&s.jsxs("div",{className:"text-fg-faint",children:[s.jsx("p",{children:"Select text in the doc…"}),s.jsxs("p",{className:"mt-2 text-[10px]",children:[i," edit",i===1?"":"s"," this session"]})]}),e==="popover"&&s.jsx("p",{className:"text-fg-faint",children:"Choose a quick action or speak an instruction from the popover."}),e==="listening"&&s.jsxs("div",{children:[s.jsxs("p",{className:"flex items-center gap-2 text-fg-dim mb-3",children:[s.jsx(oO,{}),"Listening…"]}),s.jsx("button",{onClick:h,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),e==="review"&&s.jsxs("div",{children:[s.jsxs("p",{className:"italic text-fg mb-3",children:["«",n,"»"]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx("button",{onClick:h,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:o,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Re-record"}),s.jsx("button",{onClick:l,className:"px-2 py-1 text-[11px] text-white rounded bg-accent hover:opacity-90",children:"Send"})]})]}),e==="thinking"&&s.jsx("p",{className:"text-fg-dim animate-pulse",children:"Claude is editing…"}),e==="diff"&&r&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-3 space-y-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] uppercase tracking-wide text-fg-faint mb-1",children:"Before"}),s.jsx("div",{className:"text-red-400 line-through whitespace-pre-wrap",children:r.before})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] uppercase tracking-wide text-fg-faint mb-1",children:"After"}),s.jsx("div",{className:"text-green-400 whitespace-pre-wrap",children:r.after})]})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx("button",{onClick:d,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Reject"}),s.jsx("button",{onClick:m,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Retry"}),s.jsx("button",{onClick:u,className:"px-2 py-1 text-[11px] text-white rounded bg-green-600 hover:bg-green-500",children:"Accept"})]})]})]})]})}function gk(e){return e.split("/").filter(Boolean).pop()||e}function aO({path:e,onRenamed:n,onDeleted:r}){const[i,o]=L.useState(!1),[l,h]=L.useState(!1),[u,d]=L.useState(""),[m,x]=L.useState(!1),g=An(U=>U.buffers[e]),b=An(U=>U.openFile),S=An(U=>U.renameOpenFile),E=An(U=>U.closeFile),C=co(),y=gk(e),v=()=>o(!1),_=()=>{d(y),h(!0),v()},j=async()=>{const U=u.trim();if(!U||U===y){h(!1);return}try{const W=await window.api.files.rename(e,U);if(W.ok){const Y=e.slice(0,e.lastIndexOf("/")),V=W.newPath??`${Y}/${U}`;S(e,V),n==null||n(e,V),ze.info(`Renamed to ${U}`)}else ze.error(W.error??`Couldn't rename ${y}`)}catch(W){ze.error(W instanceof Error?W.message:`Couldn't rename ${y}`)}h(!1)},T=async()=>{v();try{const U=await window.api.files.duplicate(e);U.ok&&U.path?(b(U.path),ze.info(`Duplicated as ${gk(U.path)}`)):ze.error(U.error??`Couldn't duplicate ${y}`)}catch(U){ze.error(U instanceof Error?U.message:`Couldn't duplicate ${y}`)}},A=async()=>{try{const U=await window.api.files.delete(e);U.ok?(E(e),r==null||r(e),ze.info(`Deleted ${y}`)):ze.error(U.error??`Couldn't delete ${y}`)}catch(U){ze.error(U instanceof Error?U.message:`Couldn't delete ${y}`)}x(!1)},M=async()=>{v();const U=g??"";try{await navigator.clipboard.writeText(U),ze.info(`Copied ${U.length} chars`)}catch(W){ze.error(W instanceof Error?W.message:`Couldn't copy ${y}`)}},O=()=>{if(v(),!C){ze.error("No terminal tab is active");return}window.api.pty.write({tabId:C.id,data:`@${e} `}),ze.info(`Added ${y} to Claude context`)},I=()=>{v(),window.api.shell.open({as:"openPath",path:e}).then(U=>{U.ok||ze.error(U.error??`Couldn't open ${y}`)}).catch(U=>ze.error(U instanceof Error?U.message:`Couldn't open ${y}`))},z=()=>{v(),window.api.shell.open({as:"revealPath",path:e}).then(U=>{U.ok||ze.error(U.error??`Couldn't reveal ${y}`)}).catch(U=>ze.error(U instanceof Error?U.message:`Couldn't reveal ${y}`))};return s.jsxs("div",{className:"relative inline-block mr-1",children:[s.jsx("button",{onClick:()=>o(U=>!U),className:`px-2 py-0.5 text-[10px] border border-line rounded ${i?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Document actions",children:"Document ▾"}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[390]",onMouseDown:v}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-[400] w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1",children:[s.jsx(rb,{children:"Edit"}),s.jsx(wu,{label:"Rename",onClick:_}),s.jsx(wu,{label:"Duplicate",onClick:T}),s.jsx(wu,{label:"Delete document",danger:!0,onClick:()=>{v(),x(!0)}}),s.jsx(xk,{}),s.jsx(rb,{children:"Open"}),s.jsx(wu,{label:"Open in default app",onClick:I}),s.jsx(wu,{label:"Reveal in OS",onClick:z}),s.jsx(xk,{}),s.jsx(rb,{children:"Export"}),s.jsx(wu,{label:"Copy as Markdown",onClick:M}),s.jsx(wu,{label:"Add to Claude context",onClick:O,disabled:!C,title:C?void 0:"No terminal tab is active"})]})]}),l&&s.jsx(lO,{value:u,onChange:d,onCancel:()=>h(!1),onConfirm:()=>void j()}),m&&s.jsx(cO,{name:y,onCancel:()=>x(!1),onConfirm:()=>void A()})]})}function rb({children:e}){return s.jsx("div",{className:"px-3 pt-1 pb-0.5 text-[9px] uppercase tracking-wide text-fg-faint",children:e})}function wu({label:e,onClick:n,danger:r,disabled:i,title:o}){return s.jsx("button",{onClick:n,disabled:i,title:o,className:`w-full text-left px-3 py-1.5 transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${r?"text-red-400 hover:bg-bg-hi":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:e})}function xk(){return s.jsx("div",{className:"my-1 border-t border-line"})}function lO({value:e,onChange:n,onCancel:r,onConfirm:i}){return s.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:o=>{o.target===o.currentTarget&&r()},children:s.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[s.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:"Rename"}),s.jsx("input",{autoFocus:!0,value:e,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"?i():o.key==="Escape"&&r()},className:"w-full px-2 py-1 text-xs bg-bg border border-line rounded text-fg mb-3"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:r,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:i,className:"px-3 py-1 text-xs text-white rounded bg-accent hover:bg-accent/90",children:"Rename"})]})]})})}function cO({name:e,onCancel:n,onConfirm:r}){return s.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:i=>{i.target===i.currentTarget&&n()},children:s.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[s.jsxs("h3",{className:"text-sm font-medium text-fg mb-3",children:["Delete ",e,"? This cannot be undone."]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:n,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:r,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Delete"})]})]})})}function uO(){const[e,n]=L.useState(!1),r=Dh();return s.jsxs("div",{className:"relative inline-block mr-1",children:[s.jsx("button",{onClick:()=>n(i=>!i),className:`px-2 py-0.5 text-[10px] border border-line rounded ${e?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Display preferences",children:"Display"}),e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[390]",onMouseDown:()=>n(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-[400] w-60 rounded-lg border border-line bg-bg-elev shadow-xl text-xs p-2 space-y-1.5",children:[s.jsx(Nh,{label:"Text size",children:s.jsxs("div",{className:"flex items-center rounded border border-line overflow-hidden",children:[s.jsx("button",{onClick:()=>r.bumpFontSize(-1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom out",children:"A−"}),s.jsx("span",{className:"px-2 text-[10px] text-fg-dim",children:r.fontSize}),s.jsx("button",{onClick:()=>r.bumpFontSize(1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom in",children:"A+"})]})}),s.jsx(Nh,{label:"Word wrap",children:s.jsx(jx,{on:r.wordWrap,onClick:r.toggleWordWrap})}),s.jsx(Nh,{label:"Minimap",children:s.jsx(jx,{on:r.minimap,onClick:r.toggleMinimap})}),s.jsx(Nh,{label:"Theme",children:s.jsx("button",{onClick:()=>r.setTheme(r.theme==="dark"?"paper":"dark"),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Toggle editor theme",children:r.theme==="dark"?"Dark":"Paper"})}),s.jsx(Nh,{label:"Autosave",children:s.jsx(jx,{on:r.autosave,onClick:r.toggleAutosave})}),s.jsx(Nh,{label:"Wide measure",children:s.jsx(jx,{on:r.wideMeasure,onClick:r.toggleWideMeasure})})]})]})]})}function Nh({label:e,children:n}){return s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-fg-faint",children:e}),n]})}function jx({on:e,onClick:n}){return s.jsx("button",{onClick:n,className:`px-2 py-0.5 text-[10px] rounded border border-line ${e?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:e?"On":"Off"})}const dO=L.lazy(()=>Gm(()=>import("./TiptapBody-Cg8YZhVZ.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.TiptapBody})));function Ex(e){return e.split("/").filter(Boolean).pop()||e}function Nx(e,n){if(!n.length)return e;const r=new Set(n),i={};for(const[o,l]of Object.entries(e))r.has(o)||(i[o]=l);return i}function Tx(e){return G2(e)||K2(e)}function cw(){const e=An(Ye=>Ye.openFiles),n=An(Ye=>Ye.activeFilePath),r=An(Ye=>Ye.dirty),i=An(Ye=>Ye.viewMode),o=An(Ye=>Ye.buffers),l=An(Ye=>Ye.setActive),h=An(Ye=>Ye.closeFile),u=An(Ye=>Ye.closeOthers),d=An(Ye=>Ye.closeToTheRight),m=An(Ye=>Ye.closeAll),x=An(Ye=>Ye.loadBuffer),g=An(Ye=>Ye.setBuffer),b=An(Ye=>Ye.markSaved),S=An(Ye=>Ye.setViewMode),E=Dh(),[C,y]=L.useState({}),[v,_]=L.useState({}),[j,T]=L.useState(null),[A,M]=L.useState(null),[O,I]=L.useState(!1),[z,U]=L.useState(!1),[W,Y]=L.useState(!0),V=L.useRef(null),H=L.useRef(null),te=L.useRef(void 0),oe=L.useRef(null),pe=L.useRef(null),ie=tO(n??""),X=L.useCallback(Ye=>{V.current=Ye},[]),Q=L.useCallback(()=>V.current,[]);L.useEffect(()=>{const Ye=n;if(!Ye||Tx(Ye))return;if(An.getState().hasBuffer(Ye)){y(_t=>_t[Ye]==="ready"?_t:{..._t,[Ye]:"ready"});return}let yt=!1;return y(_t=>({..._t,[Ye]:"loading"})),window.api.files.read(Ye).then(_t=>{yt||(_t.binary?y(Kt=>({...Kt,[Ye]:{binary:!0,size:_t.size??0,mime:_t.mime??"application/octet-stream",reason:_t.error??"Binary file"}})):_t.ok?(x(Ye,_t.text),y(Kt=>({...Kt,[Ye]:"ready"}))):y(Kt=>({...Kt,[Ye]:{error:_t.error??"failed to read"}})))}),()=>{yt=!0}},[n,x]),L.useEffect(()=>{M(null)},[n]);const J=L.useCallback(async(Ye,yt=!1)=>{const _t=An.getState().buffers[Ye];if(_t==null)return;yt&&I(!0);const Kt=await window.api.files.write(Ye,_t);Kt.ok?(b(Ye),_(On=>({...On,[Ye]:(On[Ye]??0)+1})),yt||ze.info(`Saved ${Ex(Ye)}`)):ze.error(Kt.error??`Couldn't save ${Ex(Ye)}`),yt&&I(!1)},[b]);L.useEffect(()=>{if(!E.autosave)return;const Ye=n;if(!(!Ye||Tx(Ye)||!r[Ye]))return window.clearTimeout(te.current),te.current=window.setTimeout(()=>{J(Ye,!0)},1200),()=>window.clearTimeout(te.current)},[E.autosave,n,r,o,J]);const ae=L.useCallback(Ye=>{Ye.length&&(y(yt=>Nx(yt,Ye)),_(yt=>Nx(yt,Ye)))},[]),le=L.useCallback((Ye,yt)=>{y(_t=>Ye in _t?{...Nx(_t,[Ye]),[yt]:_t[Ye]}:_t),_(_t=>Ye in _t?{...Nx(_t,[Ye]),[yt]:_t[Ye]}:_t)},[]),fe=L.useCallback(Ye=>{r[Ye]?T({kind:"one",path:Ye}):(h(Ye),ae([Ye]))},[r,h,ae]),Me=L.useCallback(Ye=>{e.some(_t=>_t.path!==Ye&&r[_t.path])?T({kind:"others",path:Ye}):(u(Ye),ae(e.filter(_t=>_t.path!==Ye).map(_t=>_t.path)))},[e,r,u,ae]),je=L.useCallback(Ye=>{const yt=e.findIndex(Kt=>Kt.path===Ye);yt!==-1&&e.slice(yt+1).some(Kt=>r[Kt.path])?T({kind:"right",path:Ye}):(d(Ye),ae(yt!==-1?e.slice(yt+1).map(Kt=>Kt.path):[]))},[e,r,d,ae]);L.useEffect(()=>{const Ye=yt=>{if((yt.metaKey||yt.ctrlKey)&&(yt.key==="s"||yt.key==="S")){const _t=An.getState().activeFilePath;_t&&!Tx(_t)&&(yt.preventDefault(),J(_t))}else if((yt.metaKey||yt.ctrlKey)&&yt.shiftKey&&(yt.key==="f"||yt.key==="F"))yt.preventDefault(),U(_t=>!_t);else if((yt.metaKey||yt.ctrlKey)&&yt.shiftKey&&(yt.key==="w"||yt.key==="W")){const _t=An.getState().activeFilePath;_t&&An.getState().openFiles.length>1&&(yt.preventDefault(),Me(_t))}else yt.key==="Escape"&&ie.state.phase!=="idle"?ie.cancel():yt.key==="Escape"&&z&&U(!1)};return window.addEventListener("keydown",Ye),()=>window.removeEventListener("keydown",Ye)},[J,z,Me,ie.state.phase,ie.cancel]),L.useEffect(()=>{if(ie.state.phase==="idle")return;const Ye=yt=>{var Kt,On;const _t=yt.target;(Kt=pe.current)!=null&&Kt.contains(_t)||(On=oe.current)!=null&&On.contains(_t)||ie.cancel()};return window.addEventListener("mousedown",Ye),()=>window.removeEventListener("mousedown",Ye)},[ie.state.phase,ie.cancel]),L.useEffect(()=>{ie.cancel()},[n,ie.cancel]);const ye=L.useCallback(()=>{e.some(yt=>r[yt.path])?T({kind:"all",path:""}):(m(),y({}),_({}))},[e,r,m]),ne=()=>{if(j){if(j.kind==="one")h(j.path),ae([j.path]);else if(j.kind==="others"){const Ye=e.filter(yt=>yt.path!==j.path).map(yt=>yt.path);u(j.path),ae(Ye)}else if(j.kind==="right"){const Ye=e.findIndex(_t=>_t.path===j.path),yt=Ye!==-1?e.slice(Ye+1).map(_t=>_t.path):[];d(j.path),ae(yt)}else m(),y({}),_({});T(null)}};if(e.length===0)return s.jsx("div",{className:"h-full flex items-center justify-center text-fg-faint text-xs",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-2",children:"no file open"}),s.jsxs("div",{children:["open the ",s.jsx("span",{className:"text-fg-dim",children:"File Explorer"})," tab and click a file to edit it here"]})]})});const we=n,Ne=we?Ex(we):"",Je=we?C[we]:void 0,lt=we?J2(we):!1,xt=we?l$(we):!1,At=we&&lt?i[we]??c$(we):"edit",He=!!we&&!Tx(we)&&Je==="ready",vt=He,st=xt?["edit","wysiwyg","preview","split"]:lt?["edit","preview"]:[],an=we&&s.jsx(AD,{path:we,name:Ne,value:o[we]??"",onChange:Ye=>g(we,Ye),onSave:()=>void J(we),onReady:X,onCursor:M}),sn=O?"Saving…":we&&r[we]?E.autosave?"Editing…":"Unsaved":"All changes saved";return s.jsxs("div",{className:"relative flex flex-col h-full bg-bg",children:[!z&&s.jsx(ED,{openFiles:e,activeFilePath:n,dirty:r,onSelectFile:l,onCloseFile:fe,onCloseOthers:Me,onCloseToTheRight:je,onCloseAll:ye}),we&&!z&&s.jsxs("div",{className:"flex items-center px-3 h-8 border-b border-line shrink-0 bg-bg-elev",children:[s.jsx("span",{className:"text-xs font-medium text-fg truncate",children:Ne}),s.jsx("span",{className:"ml-3 text-[10px] text-fg-faint truncate",children:we}),He&&s.jsxs("span",{className:"ml-3 text-[10px] text-fg-faint shrink-0",children:["· ",sn]}),al(we)&&(At==="preview"||At==="split")&&s.jsx("button",{onClick:()=>Y(Ye=>!Ye),className:`ml-3 px-2 py-0.5 text-[10px] border border-line rounded ${W?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),al(we)&&(At==="preview"||At==="split")&&s.jsx("button",{onClick:E.toggleAssistantRail,className:`ml-1 px-2 py-0.5 text-[10px] border border-line rounded ${E.assistantRail?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle Assistant rail",children:"Assistant"}),st.length>0&&s.jsx("div",{className:"flex items-center ml-2 rounded border border-line overflow-hidden",children:st.map(Ye=>s.jsx("button",{onClick:()=>S(we,Ye),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${At===Ye?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:Ye},Ye))}),s.jsx("div",{className:"flex-1"}),s.jsx(aO,{path:we,onRenamed:le,onDeleted:Ye=>ae([Ye])}),He&&s.jsx(uO,{}),s.jsx("button",{onClick:()=>U(!0),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Focus mode (Cmd/Ctrl-Shift-F)",children:"Focus"})]}),z&&s.jsx("button",{onClick:()=>U(!1),className:"absolute top-2 right-3 z-10 px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded bg-bg-elev/80",title:"Exit focus mode (Esc)",children:"Exit focus"}),s.jsx("div",{className:"flex-1 min-h-0",children:we?G2(we)?s.jsx(UD,{path:we,name:Ne}):K2(we)?s.jsx(HD,{path:we}):Je&&typeof Je=="object"&&"binary"in Je?s.jsx(YD,{path:we,name:Ne,size:Je.size,mime:Je.mime,reason:Je.reason}):Je&&typeof Je=="object"&&"error"in Je?s.jsx("div",{className:"p-6 text-xs text-red-400",children:Je.error}):Je!=="ready"?s.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"loading…"}):At==="wysiwyg"&&al(we)?s.jsx(L.Suspense,{fallback:s.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading editor…"}),children:s.jsx(dO,{value:o[we]??"",onChange:Ye=>g(we,Ye)},we)}):At==="split"&&al(we)?s.jsxs("div",{className:"flex h-full",children:[W&&s.jsx(dk,{text:o[we]??"",scrollRef:H}),s.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[s.jsx(uk,{getEditor:Q}),s.jsx("div",{className:"flex-1 min-h-0",children:an})]}),s.jsx("div",{ref:oe,className:"flex-1 min-w-0",children:s.jsx(ck,{ref:H,text:o[we]??"",flush:!0,wideMeasure:E.wideMeasure,onSelect:ie.select,onDismissSelection:ie.cancel})}),!z&&E.assistantRail&&s.jsx(mk,{phase:ie.state.phase,transcript:ie.state.transcript,diff:ie.state.diff,editCount:ie.state.editCount,onListen:ie.listen,onSendHeard:ie.sendHeard,onCancel:ie.cancel,onAccept:()=>{const Ye=ie.accept(o[we]??"");Ye.ok&&g(we,Ye.next)},onReject:ie.cancel,onRetry:ie.retry})]}):At==="preview"&&al(we)?s.jsxs("div",{className:"flex h-full",children:[W&&s.jsx(dk,{text:o[we]??"",scrollRef:H}),s.jsx("div",{ref:oe,className:"flex-1 min-w-0",children:s.jsx(ck,{ref:H,text:o[we]??"",wideMeasure:E.wideMeasure,onSelect:ie.select,onDismissSelection:ie.cancel})}),!z&&E.assistantRail&&s.jsx(mk,{phase:ie.state.phase,transcript:ie.state.transcript,diff:ie.state.diff,editCount:ie.state.editCount,onListen:ie.listen,onSendHeard:ie.sendHeard,onCancel:ie.cancel,onAccept:()=>{const Ye=ie.accept(o[we]??"");Ye.ok&&g(we,Ye.next)},onReject:ie.cancel,onRetry:ie.retry})]}):At==="preview"&&V2(we)?s.jsx(BD,{path:we,dirty:!!r[we],reloadToken:v[we]??0}):At==="preview"&&X2(we)?s.jsx(qD,{path:we,text:o[we]??""}):At==="preview"&&Y2(we)?s.jsx(KD,{path:we,text:o[we]??""}):al(we)?s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(uk,{getEditor:Q}),s.jsx("div",{className:"flex-1 min-h-0",children:an})]}):an:null}),vt&&s.jsx(zD,{text:o[we]??"",cursor:A,language:Li(we)||void 0}),we&&al(we)&&(At==="preview"||At==="split")&&ie.state.phase!=="idle"&&ie.state.selection&&s.jsx("div",{ref:pe,children:s.jsx(iO,{phase:ie.state.phase,rect:ie.state.selection.rect,diff:ie.state.diff,transcript:ie.state.transcript,onQuickAction:ie.run,onRunCustom:ie.run,onListen:ie.listen,onSendHeard:ie.sendHeard,onCancel:ie.cancel,onReject:ie.cancel,onRetry:ie.retry,onAccept:()=>{const Ye=ie.accept(o[we]??"");Ye.ok&&g(we,Ye.next)}})}),j&&s.jsx(hO,{message:j.kind==="one"?`Discard unsaved changes to ${Ex(j.path)}?`:j.kind==="others"?"Discard unsaved changes in the other open files?":j.kind==="right"?"Discard unsaved changes in the files to the right?":"Discard unsaved changes in all open files?",onCancel:()=>T(null),onConfirm:ne})]})}function hO({message:e,onCancel:n,onConfirm:r}){return s.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:i=>{i.target===i.currentTarget&&n()},children:s.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[s.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:e}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:n,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:r,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Discard"})]})]})})}const yk={ts:"#3178c6",tsx:"#61dafb",js:"#f7df1e",jsx:"#61dafb",cjs:"#f7df1e",mjs:"#f7df1e",json:"#5d5d5d",css:"#264de4",scss:"#cd6799",less:"#1d365d",html:"#e34c26",md:"#083fa1",mdx:"#083fa1",py:"#3776ab",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",c:"#555555",cpp:"#f34b7d",cc:"#f34b7d",h:"#555555",hpp:"#f34b7d",swift:"#fa7343",rb:"#cc342d",php:"#4f5d95",sql:"#e38c00",sh:"#89e051",bash:"#89e051",zsh:"#89e051",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4221",xml:"#0060ac",svg:"#ff9900",vue:"#41b883",svelte:"#ff3e00",other:"#6b7280"},fO={ts:"TypeScript",tsx:"TSX",js:"JavaScript",jsx:"JSX",cjs:"CommonJS",mjs:"ES Module",json:"JSON",css:"CSS",scss:"SCSS",less:"Less",html:"HTML",md:"Markdown",mdx:"MDX",py:"Python",go:"Go",rs:"Rust",java:"Java",kt:"Kotlin",c:"C",cpp:"C++",cc:"C++",h:"C/C++ Header",hpp:"C++ Header",swift:"Swift",rb:"Ruby",php:"PHP",sql:"SQL",sh:"Shell",bash:"Shell",zsh:"Shell",yaml:"YAML",yml:"YAML",toml:"TOML",xml:"XML",svg:"SVG",vue:"Vue",svelte:"Svelte",other:"Other"};function sb(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":String(e)}function pO({open:e,onClose:n,variant:r="overlay"}){const i=kt(A=>A.tabs.find(M=>M.id===A.activeTabId)??null),o=(i==null?void 0:i.cwd)??null,[l,h]=L.useState(null),[u,d]=L.useState(!1),[m,x]=L.useState(null),g=L.useRef(null),b=L.useCallback(async A=>{d(!0),x(null);try{const M=await window.api.repo.analyze(A);M.ok?h(M):(x(M.error||"Analysis failed"),h(null))}catch(M){x(M instanceof Error?M.message:String(M)),h(null)}finally{d(!1)}},[]);L.useEffect(()=>{if(e){if(!o){x("No active session — open a tab in a folder first.");return}b(o)}},[e,o,b]),L.useEffect(()=>{var M;if(!e)return;const A=O=>{O.key==="Escape"&&(O.stopPropagation(),n())};return window.addEventListener("keydown",A),(M=g.current)==null||M.focus(),()=>window.removeEventListener("keydown",A)},[e,n]);const S=L.useCallback(()=>{o&&b(o)},[o,b]),E=L.useMemo(()=>l?Object.entries(l.languageBreakdown).map(([M,O])=>[M,O.files,O.lines]).sort((M,O)=>O[1]-M[1]).slice(0,12):[],[l]),C=L.useMemo(()=>E.length===0?1:E[0][1],[E]),y=L.useMemo(()=>{if(!l)return[];const A=l.topDirectories;if(A.length===0)return[];const M=A.map(I=>Math.sqrt(Math.max(1,I.fileCount))),O=M.reduce((I,z)=>I+z,0)||1;return A.map((I,z)=>({path:I.path,fileCount:I.fileCount,totalLines:I.totalLines,basis:M[z]/O*100}))},[l]);if(!e)return null;const v=A=>{A.target===A.currentTarget&&n()},_=o?o.split("/").filter(Boolean).pop()||o:"no folder",j=r==="page",T=s.jsx("div",{className:j?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:j?void 0:v,"data-testid":"repoviz-backdrop",children:s.jsxs("div",{ref:g,role:j?void 0:"dialog","aria-modal":j?void 0:"true","aria-label":"Repository Visualization",tabIndex:-1,className:j?"h-full w-full flex flex-col outline-none bg-bg":"bg-bg-elev border border-line rounded-lg shadow-xl w-[900px] max-w-[95vw] max-h-[85vh] flex flex-col outline-none","data-testid":"repoviz-dialog",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-line",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("span",{className:"text-lg","aria-hidden":!0,children:"🗺"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-base font-medium text-fg leading-tight",children:"Repository Visualization"}),s.jsxs("div",{className:"text-xs text-fg-dim truncate",title:o??"",children:[_,(l==null?void 0:l.gitStatus.branch)&&s.jsxs("span",{className:"ml-2 font-mono text-fg-faint",children:["(",l.gitStatus.branch,")"]}),(l==null?void 0:l.truncated)&&s.jsx("span",{className:"ml-2 text-amber-400",children:"truncated"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[l&&l.gitStatus.uncommitted>0&&s.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-400 text-[11px] font-mono",title:`${l.gitStatus.uncommitted} uncommitted files`,children:[l.gitStatus.uncommitted," uncommitted"]}),s.jsxs("button",{type:"button",onClick:S,disabled:u||!o,className:"px-2 py-1 rounded text-fg-dim hover:bg-bg-hi hover:text-fg text-xs disabled:opacity-40 disabled:cursor-not-allowed",title:"Re-run analysis",children:[u?"…":"↻"," Refresh"]}),s.jsx("button",{type:"button",onClick:n,className:"px-2 py-1 rounded text-fg-dim hover:bg-bg-hi hover:text-fg text-xs","aria-label":"Close",children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-6",children:u&&!l?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-fg-dim",children:[s.jsx("div",{className:"text-3xl mb-3 animate-pulse","aria-hidden":!0,children:"⟳"}),s.jsx("div",{className:"text-sm",children:"Analyzing repository…"}),s.jsx("div",{className:"text-xs text-fg-faint mt-1",children:"Walking files, counting lines, reading git status"})]}):m?s.jsxs("div",{className:"py-16 text-center",children:[s.jsx("div",{className:"text-3xl mb-3 text-red-400","aria-hidden":!0,children:"⚠"}),s.jsx("div",{className:"text-sm text-red-400",children:m})]}):l?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsx(ib,{label:"Files",value:sb(l.totalFiles)}),s.jsx(ib,{label:"Lines of code",value:sb(l.totalLines)}),s.jsx(ib,{label:"Uncommitted",value:String(l.gitStatus.uncommitted),tone:l.gitStatus.uncommitted>0?"warn":"neutral"})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Languages"}),E.length===0?s.jsx("div",{className:"text-xs text-fg-dim",children:"No files detected."}):s.jsx("div",{className:"space-y-1.5",children:E.map(([A,M,O])=>{const I=yk[A]??yk.other,z=fO[A]??A,U=M/C*100;return s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"w-24 text-fg-dim truncate",title:z,children:z}),s.jsx("div",{className:"flex-1 h-4 bg-bg rounded overflow-hidden",children:s.jsx("div",{className:"h-full rounded",style:{width:`${U}%`,backgroundColor:I}})}),s.jsxs("span",{className:"w-16 text-right text-fg-dim font-mono",children:[M," files"]}),s.jsxs("span",{className:"w-20 text-right text-fg-faint font-mono",children:[sb(O)," L"]})]},A)})})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Top directories"}),y.length===0?s.jsx("div",{className:"text-xs text-fg-dim",children:"No directories."}):s.jsx("div",{className:"flex flex-wrap gap-1 min-h-[140px]",children:y.map(A=>s.jsxs("div",{className:"relative rounded bg-bg-hi border border-line hover:border-accent transition-colors cursor-default flex flex-col justify-end p-2 min-w-[80px] min-h-[60px]",style:{flexBasis:`${Math.max(A.basis,6)}%`,flexGrow:A.basis>15?1:0},title:`${A.path} — ${A.fileCount} files, ${A.totalLines.toLocaleString()} lines`,children:[s.jsx("div",{className:"text-[11px] font-mono text-fg truncate",children:A.path}),s.jsxs("div",{className:"text-[10px] text-fg-dim font-mono",children:[A.fileCount," files"]})]},A.path))})]}),s.jsxs("div",{className:"text-[10px] text-fg-faint text-right",children:["Analyzed in ",l.durationMs,"ms",l.truncated&&" — stopped early (5000-file cap or 30s timeout)"]})]}):s.jsx("div",{className:"py-16 text-center text-fg-dim text-sm",children:"No analysis yet. Click Refresh."})})]})});return!j&&typeof document<"u"&&document.body?Uu.createPortal(T,document.body):T}function ib({label:e,value:n,tone:r="neutral"}){const i=r==="warn"?"text-amber-400":"text-fg";return s.jsxs("div",{className:"bg-bg-hi/40 border border-line rounded-lg p-3",children:[s.jsx("div",{className:`text-xl font-medium ${i}`,children:n}),s.jsx("div",{className:"text-xs text-fg-dim mt-0.5",children:e})]})}function Wu({options:e,active:n,onChange:r}){return s.jsx("div",{className:"flex rounded border border-line overflow-hidden",children:e.map(({key:i,label:o})=>s.jsx("button",{onClick:()=>r(i),className:`px-2 py-0.5 text-xs ${n===i?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:o},i))})}const vk=e=>/[/\\\-_.\s]/.test(e),bk=e=>e>="A"&&e<="Z";function mO(e,n,r){if(!e)return{match:!0,score:0,matched:[]};const i=e.toLowerCase(),o=n.toLowerCase(),l=(r||n).toLowerCase(),h=n.split("/").pop()||n,u=h.toLowerCase();if(u===i)return{match:!0,score:1e3,matched:Array.from({length:h.length},(v,_)=>_)};if(u.startsWith(i))return{match:!0,score:900,matched:Array.from({length:e.length},(v,_)=>_)};let d=0;for(const v of l.split("/")){if(v===i)return{match:!0,score:800,matched:[]};v.startsWith(i)&&(d=Math.max(d,700))}const m=u.indexOf(i);if(m!==-1)return{match:!0,score:m===0||vk(u[m-1])||bk(h[m])?650:600,matched:Array.from({length:e.length},(_,j)=>m+j)};if(l.includes(i))return{match:!0,score:Math.max(500,d),matched:[]};let x=0,g=0,b=0,S=-1,E=0;const C=[];for(let v=0;v<o.length&&x<i.length;v++)o[v]===i[x]&&(C.push(v),g+=10,S===v-1?(b++,g+=b*8):b=0,(v===0||vk(o[v-1])||bk(n[v]))&&(E++,g+=15,v===0&&(g+=10)),S=v,x++);if(x!==i.length)return{match:!1,score:0,matched:[]};const y=Math.max(0,50-(o.length-i.length));if(g+=y,E>=i.length*.5&&(g+=30),C.length>1){const v=C[C.length-1]-C[0];v>i.length*3&&(g-=Math.min(50,(v-i.length*3)*2))}return{match:!0,score:Math.max(1,g),matched:C}}function ob(e,n){return e.startsWith(n+"/")?e.slice(n.length+1):e===n?"":e}function wk(e){const n=e.lastIndexOf("/");return n<0?"":e.slice(0,n)}const _k="session-manager.quickopen.recent",gO=8;function xO({open:e,onClose:n,variant:r="overlay"}){const i=kt(z=>z.tabs.find(U=>U.id===z.activeTabId)??null),o=(i==null?void 0:i.cwd)??"",[l,h]=L.useState(""),[u,d]=L.useState([]),[m,x]=L.useState(!1),[g,b]=L.useState(0),[S,E]=L.useState([]),C=L.useRef(null),y=L.useRef(null);L.useEffect(()=>{if(e)try{const z=localStorage.getItem(_k);z&&E(JSON.parse(z))}catch{}},[e]),L.useEffect(()=>{if(!e){h(""),b(0);return}const z=setTimeout(()=>{var U;return(U=C.current)==null?void 0:U.focus()},0);return()=>clearTimeout(z)},[e]),L.useEffect(()=>{if(!e||!o)return;let z=!1;return x(!0),window.api.search.files(o,"",{limit:5e3}).then(U=>{if(!z){if(!U.ok){ze.error(`File search failed: ${U.error??"unknown error"}`),d([]);return}d(U.files)}}).catch(U=>{const W=U instanceof Error?U.message:String(U);dt.error("quick-open","search.files threw",{error:W}),ze.error(`File search failed: ${W}`),d([])}).finally(()=>{z||x(!1)}),()=>{z=!0}},[e,o]);const v=L.useMemo(()=>{if(!l.trim())return[...u].sort((Y,V)=>Y.name.localeCompare(V.name)).slice(0,100).map(Y=>({file:Y,score:0,matched:[]}));const z=l.trim(),U=[];for(const W of u){const Y=mO(z,W.name,W.path);Y.match&&U.push({file:W,score:Y.score,matched:Y.matched})}return U.sort((W,Y)=>Y.score-W.score),U.slice(0,100)},[u,l]),_=L.useMemo(()=>l.trim()?[]:S.map(z=>u.find(U=>U.path===z)||null).filter(z=>z!==null).slice(0,5),[S,u,l]);L.useEffect(()=>{const z=_.length+v.length;g>=z&&b(Math.max(0,z-1))},[_.length,v.length,g]),L.useEffect(()=>{if(!y.current)return;const z=y.current.querySelector(`[data-row="${g}"]`);z&&z.scrollIntoView({block:"nearest"})},[g]);const j=L.useCallback(z=>{try{const V=[z,...S.filter(H=>H!==z)].slice(0,gO);E(V),localStorage.setItem(_k,JSON.stringify(V))}catch{}const U=i==null?void 0:i.id;if(!U){ze.error("No active tab to receive file path");return}const Y=(o?ob(z,o):z)||z;try{window.api.pty.write({tabId:U,data:Y})}catch(V){const H=V instanceof Error?V.message:String(V);dt.error("quick-open","pty.write failed",{error:H}),ze.error(`Failed to write to terminal: ${H}`);return}n()},[i==null?void 0:i.id,o,S,n]),T=L.useCallback(z=>{const U=_.length+v.length;if(z.key==="Escape"){z.preventDefault(),n();return}if(z.key==="ArrowDown"){if(z.preventDefault(),U===0)return;b(W=>Math.min(U-1,W+1));return}if(z.key==="ArrowUp"){if(z.preventDefault(),U===0)return;b(W=>Math.max(0,W-1));return}if(z.key==="Enter"){if(z.preventDefault(),g<_.length){const V=_[g];V&&j(V.path);return}const W=g-_.length,Y=v[W];Y&&j(Y.file.path)}},[g,v,_,j,n]);if(!e)return null;const A=(z,U)=>{if(U.length===0)return z;const W=new Set(U);return z.split("").map((Y,V)=>s.jsx("span",{className:W.has(V)?"text-accent font-semibold":"",children:Y},V))};let M=-1;const O=r==="page",I=s.jsx("div",{className:O?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-[55] flex items-start justify-center bg-black/60 pt-[12vh]",onClick:O?void 0:z=>{z.target===z.currentTarget&&n()},"data-testid":"quick-open-backdrop",children:s.jsxs("div",{role:O?void 0:"dialog","aria-modal":O?void 0:"true","aria-label":"Quick Open",className:O?"h-full w-full flex flex-col":"w-[640px] max-w-[90vw] max-h-[70vh] bg-bg-elev border border-line rounded shadow-xl flex flex-col","data-testid":"quick-open",onKeyDown:T,children:[s.jsx("div",{className:"border-b border-line p-2",children:s.jsx("input",{ref:C,type:"text",value:l,onChange:z=>{h(z.target.value),b(0)},placeholder:o?"Search files in this project…":"No active tab — open a terminal first",disabled:!o,spellCheck:!1,autoComplete:"off",className:"w-full bg-transparent text-fg placeholder:text-fg-dim outline-none px-2 py-1.5 text-sm","aria-label":"Search files"})}),s.jsx("div",{ref:y,className:"flex-1 min-h-0 overflow-y-auto",role:"listbox",children:m?s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Loading…"}):o?_.length===0&&v.length===0?s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:l?"No files match.":"No files found in this project."}):s.jsxs(s.Fragment,{children:[_.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-fg-dim",children:"Recent"}),_.map(z=>{M++;const U=M,W=U===g;return s.jsxs("button",{"data-row":U,role:"option","aria-selected":W,onClick:()=>j(z.path),onMouseEnter:()=>b(U),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${W?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[s.jsx("span",{className:"truncate",children:z.name}),s.jsx("span",{className:"text-xs text-fg-dim truncate",children:ob(wk(z.path),o)})]},`r:${z.path}`)})]}),v.length>0&&s.jsxs("div",{children:[_.length>0&&s.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-fg-dim border-t border-line",children:"Files"}),v.map(({file:z,matched:U})=>{M++;const W=M,Y=W===g;return s.jsxs("button",{"data-row":W,role:"option","aria-selected":Y,onClick:()=>j(z.path),onMouseEnter:()=>b(W),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${Y?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[s.jsx("span",{className:"truncate",children:A(z.name,U)}),s.jsx("span",{className:"text-xs text-fg-dim truncate",children:ob(wk(z.path),o)})]},z.path)})]})]}):s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Open a terminal tab to enable Quick Open."})}),s.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center justify-between text-[10px] text-fg-dim",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↑↓"})," navigate"," ",s.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↵"})," insert into terminal"," ",s.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"Esc"})," close"]}),s.jsxs("span",{children:[v.length+_.length," ",v.length+_.length===1?"file":"files"]})]})]})});return!O&&typeof document<"u"&&document.body?Uu.createPortal(I,document.body):I}function kk(e,n){return e.startsWith(n+"/")?e.slice(n.length+1):e===n?"":e}function yO(e,n,r){if(!n)return e;const i=r?e:e.toLowerCase(),o=r?n:n.toLowerCase(),l=i.indexOf(o);return l<0?e:s.jsxs(s.Fragment,{children:[e.slice(0,l),s.jsx("span",{className:"text-accent font-semibold",children:e.slice(l,l+n.length)}),e.slice(l+n.length)]})}function vO({open:e,onClose:n,variant:r="overlay"}){const i=kt(V=>V.tabs.find(H=>H.id===V.activeTabId)??null),o=(i==null?void 0:i.cwd)??"",[l,h]=L.useState(""),[u,d]=L.useState(!1),[m,x]=L.useState([]),[g,b]=L.useState(!1),[S,E]=L.useState(null),[C,y]=L.useState(0),[v,_]=L.useState(null),j=L.useRef(null),T=L.useRef(null),A=L.useRef(0);L.useEffect(()=>{if(!e){h(""),x([]),E(null),y(0);return}const V=setTimeout(()=>{var H;return(H=j.current)==null?void 0:H.focus()},0);return()=>clearTimeout(V)},[e]),L.useEffect(()=>{if(!e||!o)return;const V=l.trim();if(!V){x([]),E(null),b(!1);return}const H=++A.current;b(!0);const te=setTimeout(()=>{window.api.search.text(o,V,{caseSensitive:u,limit:500}).then(oe=>{H===A.current&&(oe.ok?(x(oe.matches),E(null)):(E(oe.error??"unknown error"),x([])),_(oe.usedRipgrep))}).catch(oe=>{if(H!==A.current)return;const pe=oe instanceof Error?oe.message:String(oe);dt.error("global-search","search.text threw",{error:pe}),E(pe),x([])}).finally(()=>{H===A.current&&b(!1)})},250);return()=>clearTimeout(te)},[e,o,l,u]);const M=L.useMemo(()=>{const V=new Map;for(const te of m){const oe=V.get(te.path);oe?oe.push(te):V.set(te.path,[te])}const H=[];for(const[te,oe]of V)H.push({path:te,matches:oe});return H.sort((te,oe)=>oe.matches.length-te.matches.length||te.path.localeCompare(oe.path)),H},[m]),O=L.useMemo(()=>m,[m]);L.useEffect(()=>{C>=O.length&&y(Math.max(0,O.length-1))},[O.length,C]),L.useEffect(()=>{if(!T.current)return;const V=T.current.querySelector(`[data-match="${C}"]`);V&&V.scrollIntoView({block:"nearest"})},[C]);const I=L.useCallback(V=>{const H=i==null?void 0:i.id;if(!H){ze.error("No active tab to receive path");return}const oe=`${(o?kk(V.path,o):V.path)||V.path}:${V.line}`;try{window.api.pty.write({tabId:H,data:oe})}catch(pe){const ie=pe instanceof Error?pe.message:String(pe);dt.error("global-search","pty.write failed",{error:ie}),ze.error(`Failed to write to terminal: ${ie}`);return}n()},[i==null?void 0:i.id,o,n]),z=L.useCallback(V=>{if(V.key==="Escape"){V.preventDefault(),n();return}if(V.key==="ArrowDown"){if(V.preventDefault(),O.length===0)return;y(H=>Math.min(O.length-1,H+1));return}if(V.key==="ArrowUp"){if(V.preventDefault(),O.length===0)return;y(H=>Math.max(0,H-1));return}if(V.key==="Enter"){V.preventDefault();const H=O[C];H&&I(H)}},[O,C,I,n]);if(!e)return null;const U=r==="page";let W=-1;const Y=s.jsx("div",{className:U?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-[55] flex items-start justify-center bg-black/60 pt-[8vh]",onClick:U?void 0:V=>{V.target===V.currentTarget&&n()},"data-testid":"global-search-backdrop",children:s.jsxs("div",{role:U?void 0:"dialog","aria-modal":U?void 0:"true","aria-label":"Search in project",className:U?"h-full w-full flex flex-col":"w-[840px] max-w-[95vw] h-[80vh] bg-bg-elev border border-line rounded shadow-xl flex flex-col","data-testid":"global-search",onKeyDown:z,children:[s.jsxs("div",{className:"border-b border-line p-2 flex items-center gap-2",children:[s.jsx("input",{ref:j,type:"text",value:l,onChange:V=>{h(V.target.value),y(0)},placeholder:o?"Search in this project…":"No active tab — open a terminal first",disabled:!o,spellCheck:!1,autoComplete:"off",className:"flex-1 bg-transparent text-fg placeholder:text-fg-dim outline-none px-2 py-1.5 text-sm","aria-label":"Search query"}),s.jsx("button",{type:"button",onClick:()=>d(V=>!V),className:`px-2 py-1 text-xs rounded border ${u?"bg-accent/20 border-accent text-accent":"bg-bg border-line text-fg-dim hover:text-fg"}`,title:"Match case","aria-pressed":u,children:"Aa"})]}),s.jsx("div",{ref:T,className:"flex-1 min-h-0 overflow-y-auto",role:"listbox",children:o?l.trim()?g?s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Searching…"}):S?s.jsx("div",{className:"px-4 py-6 text-sm text-red-400",children:S}):O.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm text-fg-dim",children:["No matches for ",JSON.stringify(l),"."]}):s.jsx("div",{children:M.map(V=>s.jsxs("div",{children:[s.jsxs("div",{className:"sticky top-0 bg-bg-elev border-b border-line px-3 py-1 text-xs text-fg-dim font-mono truncate",children:[kk(V.path,o)," ",s.jsxs("span",{className:"text-fg-faint",children:["(",V.matches.length,")"]})]}),V.matches.map(H=>{W++;const te=W,oe=te===C;return s.jsxs("button",{"data-match":te,role:"option","aria-selected":oe,onClick:()=>I(H),onMouseEnter:()=>y(te),className:`w-full text-left px-3 py-1 text-xs font-mono flex gap-3 ${oe?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[s.jsx("span",{className:"text-fg-dim shrink-0 w-12 text-right",children:H.line}),s.jsx("span",{className:"truncate",children:yO(H.text,l,u)})]},`${H.path}:${H.line}:${H.column}:${te}`)})]},V.path))}):s.jsxs("div",{className:"px-4 py-6 text-sm text-fg-dim",children:["Type to search files in ",s.jsx("span",{className:"font-mono",children:o}),"."]}):s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Open a terminal tab to enable project search."})}),s.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center justify-between text-[10px] text-fg-dim",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↑↓"})," navigate"," ",s.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↵"})," insert path"," ",s.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"Esc"})," close"]}),s.jsxs("span",{children:[O.length," ",O.length===1?"match":"matches",v===!1&&" · fs walk (rg missing)"]})]})]})});return!U&&typeof document<"u"&&document.body?Uu.createPortal(Y,document.body):Y}const bO=[{key:"files",label:"Files"},{key:"content",label:"Content"}];function wO({open:e,onClose:n,variant:r="page",initialMode:i="files"}){const[o,l]=L.useState(i);return L.useEffect(()=>{l(i)},[i]),e?s.jsxs("div",{className:"h-full w-full flex flex-col bg-bg",children:[s.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-2 border-b border-line",children:[s.jsx(Wu,{options:bO,active:o,onChange:l}),s.jsx("span",{className:"text-[11px] text-fg-faint",children:o==="files"?"⌘P · fuzzy-find a file in the active project":"⌘⇧F · ripgrep across the active project"})]}),s.jsx("div",{className:"flex-1 min-h-0",children:o==="files"?s.jsx(xO,{open:!0,onClose:n,variant:"page"}):s.jsx(vO,{open:!0,onClose:n,variant:"page"})})]}):null}class oj extends L.Component{constructor(){super(...arguments);Fn(this,"state",{error:null});Fn(this,"reset",()=>this.setState({error:null}))}static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,i){console.error("[ErrorBoundary]",r,i)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):s.jsxs("div",{className:"p-6 text-xs",children:[s.jsx("div",{className:"text-red-400 mb-2",children:"something broke in this panel"}),s.jsx("pre",{className:"text-fg-faint whitespace-pre-wrap mb-3",children:this.state.error.message}),s.jsx("button",{onClick:this.reset,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"retry"})]}):this.props.children}}function _O({open:e,onClose:n,title:r,children:i,variant:o="overlay"}){return s.jsxs(Hu,{open:e,onClose:n,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:o,children:[o==="overlay"&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[s.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:r}),s.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:s.jsx(oj,{children:i})})]})}function kO(e){return/^monitor of /i.test(e.trim())}function Sk(e){return e.replace(/\s*\([^)]*\)\s*$/,"").replace(/\s*#\d+\s*$/,"").replace(/\s+/g," ").trim().toLowerCase()}function Ck(e,n,r){if(e){const h=r.find(u=>u.deviceId===e);if(h)return h}if(!n)return null;const i=r.filter(h=>h.label===n);if(i.length===1)return i[0];if(i.length>1)return null;const o=Sk(n),l=r.filter(h=>h.label&&Sk(h.label)===o);return l.length===1?l[0]:null}async function jk(e){var r;return(r=navigator.mediaDevices)!=null&&r.enumerateDevices?(await navigator.mediaDevices.enumerateDevices()).filter(i=>!(i.kind!=="audioinput"||i.label&&kO(i.label))):[]}const Ek=!1;function aj(){const e=Tt(m=>m.isRecording);Tt(m=>m.startRecording),Tt(m=>m.stopRecording);const[n,r]=L.useState([]),[i,o]=L.useState(null),[l,h]=L.useState(null);L.useEffect(()=>{let m=!1;return(async()=>{try{const x=await window.api.voice.getDevicePref();if(m)return;const g=await jk(Ek);if(m)return;r(g),h(x.selectedLabel);const b=Ck(x.selectedDeviceId,x.selectedLabel,g);b?(o(b.deviceId),x.selectedDeviceId&&b.deviceId!==x.selectedDeviceId&&(dt.info("voice","device-picker rebind-by-label",{fromIdPrefix:x.selectedDeviceId.slice(0,8),toIdPrefix:b.deviceId.slice(0,8)}),await window.api.voice.setDevicePref({selectedDeviceId:b.deviceId,selectedLabel:b.label||x.selectedLabel}).catch(()=>{}))):((x.selectedDeviceId||x.selectedLabel)&&(console.warn("[MicDevicePicker] previously-selected device unavailable; falling back to OS default",{savedLabel:x.selectedLabel,hadId:!!x.selectedDeviceId}),dt.warn("voice","device-picker selected-unavailable",{hadId:!!x.selectedDeviceId})),o(null))}catch(x){dt.warn("voice","device-picker init failed",{error:x instanceof Error?x.message:String(x)})}})(),()=>{m=!0}},[]);const u=L.useCallback(async()=>{try{const m=await jk(Ek);if(r(m),i&&!m.some(x=>x.deviceId===i)){const x=Ck(null,l,m);x?(o(x.deviceId),await window.api.voice.setDevicePref({selectedDeviceId:x.deviceId,selectedLabel:x.label||l}).catch(()=>{})):o(null)}}catch(m){dt.warn("voice","device-picker refresh failed",{error:m instanceof Error?m.message:String(m)})}},[i,l]);L.useEffect(()=>{const m=()=>{u()};return window.addEventListener("mic-device-change",m),()=>window.removeEventListener("mic-device-change",m)},[u]);const d=async m=>{var S;const x=m.target.value,g=x===""?null:x,b=g?((S=n.find(E=>E.deviceId===g))==null?void 0:S.label)??null:null;o(g),h(b);try{await window.api.voice.setDevicePref({selectedDeviceId:g,selectedLabel:b}),dt.info("voice","device-picker selected",{deviceIdPrefix:g?g.slice(0,8):null})}catch(E){dt.warn("voice","setDevicePref failed",{error:E instanceof Error?E.message:String(E)})}if(e)try{await Tt.getState().restartWithDevice()}catch(E){dt.warn("voice","device-picker restart failed",{error:E instanceof Error?E.message:String(E)})}};return s.jsxs("select",{value:i??"",onChange:d,onFocus:()=>{u()},title:"Microphone input device","data-testid":"mic-device-picker",className:"text-[10px] bg-bg border border-line text-fg-dim hover:text-fg rounded px-1.5 py-1 max-w-[8rem] truncate",children:[s.jsx("option",{value:"",children:"Default"}),n.map(m=>s.jsx("option",{value:m.deviceId,children:m.label||`Mic ${m.deviceId.slice(0,6)}`},m.deviceId))]})}function SO(){const e=Tt(S=>S.isRecording),n=Tt(S=>S.levelMeterEnabled),[r,i]=L.useState(0),[o,l]=L.useState(0),h=L.useRef(0);h.current=o;const[u,d]=L.useState(0),[m,x]=L.useState(!1),g=L.useRef(null);if(L.useEffect(()=>{if(!e||!n){i(0),l(0);return}let S=0,E=!1,C=null,y=null;const v=()=>{if(E)return;const j=y??D2();if(!j){S=requestAnimationFrame(v);return}y!==j&&(y=j,C=new Uint8Array(new ArrayBuffer(j.fftSize)));const T=C;j.getByteTimeDomainData(T);let A=0;for(let z=0;z<T.length;z++){const U=T[z]-128;A+=U*U}const M=Math.sqrt(A/T.length)/128,O=M>0?20*Math.log10(M):-60,I=Math.max(0,Math.min(1,(O+60)/60));l(M),i(I),M>=.95&&(x(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>x(!1),150)),S=requestAnimationFrame(v)};S=requestAnimationFrame(v);const _=setInterval(()=>{E||d(Math.round(h.current*100))},250);return()=>{E=!0,cancelAnimationFrame(S),clearInterval(_),g.current&&(clearTimeout(g.current),g.current=null)}},[e,n]),!e||!n)return null;const b=m?"bg-red-500":o>=.7?"bg-amber-400":"bg-green-500";return s.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":u,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${m?"ring-1 ring-red-500":""}`,children:s.jsx("div",{className:`h-full ${b} transition-[width] duration-75 ease-out`,style:{width:`${r*100}%`}})})}function CO({open:e,onClose:n,variant:r="overlay"}){return s.jsx(_O,{open:e,onClose:n,title:"Voice / Microphone",variant:r,children:s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx(TO,{}),s.jsx(kC,{}),s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsx(L2,{}),s.jsx(aj,{}),s.jsx(PT,{})]}),s.jsx(jO,{}),s.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[s.jsx("button",{type:"button",onClick:()=>Tt.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),s.jsx(NO,{})]}),s.jsx(SO,{})]})})}function jO(){const e=Tt(l=>l.isRecording),[n,r]=L.useState(null);if(L.useEffect(()=>{let l=!1;window.api.voice.getHotkeyConfig().then(u=>{l||r(u)}).catch(()=>{});const h=window.api.voice.onHotkeyConfigChanged(u=>r(u));return()=>{l=!0,h()}},[]),e||!n)return null;const i=n.mode==="hold"?"Hold":"Press",o=EO(n.accelerator);return s.jsxs("div",{className:"text-[11px] text-fg-faint",children:[s.jsxs("span",{children:[i," "]}),s.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:o}),s.jsx("span",{children:" to record"})]})}function EO(e){const n=typeof navigator<"u"&&/Mac/.test(navigator.platform);return e.replace(/CommandOrControl/g,n?"⌘":"Ctrl").replace(/CmdOrCtrl/g,n?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,n?"⌥":"Alt").replace(/Shift/g,n?"⇧":"Shift")}function NO(){const[e,n]=L.useState(null);if(L.useEffect(()=>{let i=!1;window.api.voice.getHotkeyConfig().then(l=>{i||n(l)}).catch(l=>dt.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(l)}));const o=window.api.voice.onHotkeyConfigChanged(l=>{n(l)});return()=>{i=!0,o()}},[]),!e)return null;const r=async i=>{if(e.mode===i)return;const o={...e,mode:i};n(o);try{await window.api.voice.setHotkeyConfig(o)}catch(l){dt.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:l instanceof Error?l.message:String(l)})}};return s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[s.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[s.jsx("input",{type:"radio",name:"hotkey-mode",checked:e.mode==="toggle",onChange:()=>r("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),s.jsx("span",{children:"Tap on/off"})]}),s.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[s.jsx("input",{type:"radio",name:"hotkey-mode",checked:e.mode==="hold",onChange:()=>r("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),s.jsx("span",{children:"Hold to talk"})]})]})}function TO(){const e=Tt(l=>l.isRecording),n=Tt(l=>l.lastTranscript),r=Tt(l=>l.error),i=Tt(l=>l.modelStatus),o=Tt(l=>l.loadingProgress);return r?s.jsxs("div",{className:"text-[11px] text-red-400",title:r,children:["⚠ ",r]}):e?s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[s.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),s.jsx("span",{className:"truncate",title:n,children:n||"Listening…"})]}):i==="loading"?s.jsxs("div",{className:"text-[11px] text-fg-faint",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{children:"Loading speech model"}),s.jsxs("span",{className:"font-mono",children:[o,"%"]})]}),s.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${o}%`}})})]}):null}let ab=null;function $O(){return ab||(ab=Gm(()=>import("./monaco-editor-BW5C4Iv1.js").then(e=>e.b),__vite__mapDeps([1,2]),import.meta.url).then(e=>(n0.config({monaco:e}),e))),ab}function lj({value:e,onChange:n,path:r,readOnly:i}){const o=L.useRef(null),l=h=>{o.current=h};return s.jsx(r0,{path:`file://${r}`,defaultLanguage:"json",value:e,onChange:h=>n(h??""),onMount:l,theme:"vs",options:{minimap:{enabled:!1},fontSize:12,fontFamily:'"IBM Plex Mono", JetBrains Mono, ui-monospace, Menlo, monospace',lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,formatOnPaste:!0,readOnly:i,automaticLayout:!0,bracketPairColorization:{enabled:!0},wordWrap:"on"}})}let Nk=!1;async function AO(e){if(Nk)return;const n=await $O(),r=await Promise.all(e.map(async o=>{let l=o.schema;if(!l){const h=["https://json.schemastore.org","https://www.schemastore.org","https://code.claude.com"];try{const u=new URL(o.uri).origin;if(!h.includes(u))throw new Error("untrusted origin");const d=await fetch(o.uri);d.ok&&(l=await d.json())}catch{}}return{uri:o.uri,fileMatch:o.fileMatch,schema:l}}));n.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:r.filter(o=>o.schema),enableSchemaRequest:!0}),Nk=!0}function u0({node:e,targetScope:n,onOverride:r,schema:i,rootLabel:o}){const[l,h]=L.useState(""),[u,d]=L.useState(!0),m=[],x=e.kind==="object"&&Object.keys(e.children).length===0,b=((i==null?void 0:i.rootKeys())??[]).length>0;return s.jsxs("div",{className:"h-full flex flex-col",children:[s.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:[s.jsxs("span",{className:"text-fg-faint",children:["merged · overrides → ",s.jsx("span",{className:"text-fg-dim",children:os[n].label})]}),b&&s.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:S=>d(S.target.checked),className:"accent-accent"}),"show unset keys"]}),s.jsx("div",{className:"flex-1"}),s.jsx("input",{value:l,onChange:S=>h(S.target.value),placeholder:"filter keys or descriptions…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-56"})]}),s.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 font-mono text-xs",children:x&&!u?s.jsx("div",{className:"text-fg-faint italic px-2 py-4",children:"no settings resolved — all scope files empty or missing"}):s.jsx(cj,{node:e,path:m,label:o??"(root)",targetScope:n,onOverride:r,filter:l,depth:0,schema:i,showGhosts:u,defaultOpen:!0})})]})}function cj(e){return e.node.kind==="object"?s.jsx(RO,{...e,node:e.node}):e.node.kind==="array"?s.jsx(MO,{...e,node:e.node}):s.jsx(IO,{...e,node:e.node})}function Tk(e,n){return n.trim()?e.toLowerCase().includes(n.toLowerCase()):!0}function Qh(e,n,r){return!!(!r.trim()||e.some(i=>Tk(i,r))||n!=null&&n.description&&Tk(n.description,r))}function RO({node:e,path:n,label:r,targetScope:i,onOverride:o,filter:l,depth:h,schema:u,showGhosts:d,defaultOpen:m}){const[x,g]=L.useState(m??h<2),b=(u==null?void 0:u.at(n))??null,S=new Set(Object.keys(e.children)),E=d?(b==null?void 0:b.knownChildren)??[]:[],C=Array.from(new Set([...S,...E])).sort(),y=L.useMemo(()=>l.trim()?C.filter(_=>{const j=(u==null?void 0:u.at([...n,_]))??null;return Qh([...n,_],j,l)?!0:S.has(_)?uj(e.children[_],[...n,_],l,u):!1}):C,[C.join(","),l,e,n.join("."),u]);if(l.trim()&&y.length===0&&!Qh(n,b,l))return null;if(n.length===0)return s.jsx("div",{children:y.map(_=>v(_))});return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:h*14},onClick:()=>g(!x),children:[s.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:x?"▾":"▸"}),s.jsx("span",{className:"text-fg",children:r}),s.jsxs("span",{className:"text-fg-faint",children:[" {",S.size,E.length>S.size?`/${new Set([...S,...E]).size}`:"","}"]}),(b==null?void 0:b.description)&&s.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:b.description,children:["— ",b.description]})]}),x&&y.map(_=>v(_))]});function v(_){if(S.has(_))return s.jsx(cj,{node:e.children[_],path:[...n,_],label:_,targetScope:i,onOverride:o,filter:l,depth:h+1,schema:u,showGhosts:d},_);const j=(u==null?void 0:u.at([...n,_]))??null;return j?s.jsx(PO,{path:[...n,_],label:_,info:j,targetScope:i,onSet:o,depth:h+1,filter:l},_):null}}function uj(e,n,r,i){const o=(i==null?void 0:i.at(n))??null;if(Qh(n,o,r))return!0;if(e.kind!=="object")return!1;for(const l of Object.keys(e.children))if(uj(e.children[l],[...n,l],r,i))return!0;return!1}function MO({node:e,path:n,label:r,filter:i,depth:o,schema:l}){const[h,u]=L.useState(!0),d=(l==null?void 0:l.at(n))??null;return Qh(n,d,i)?s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:o*14},onClick:()=>u(!h),children:[s.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:h?"▾":"▸"}),s.jsx("span",{className:"text-fg",children:r}),s.jsxs("span",{className:"text-fg-faint",children:[" [",e.items.length,"]"]}),s.jsx(zm,{tone:"warn",children:"accumulated"}),(d==null?void 0:d.description)&&s.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:d.description,children:["— ",d.description]})]}),h&&e.items.map((m,x)=>s.jsxs("div",{className:"flex items-start gap-2 py-0.5",style:{paddingLeft:(o+1)*14},children:[s.jsx("span",{className:"text-fg-faint w-3 shrink-0"}),s.jsxs("span",{className:"text-fg-faint",children:[x,":"]}),s.jsx("span",{className:"text-fg-dim truncate max-w-xl",children:Ny(m.value)}),s.jsx(uw,{scope:m.fromScope})]},x))]}):null}function IO({node:e,path:n,label:r,targetScope:i,onOverride:o,filter:l,depth:h,schema:u}){const[d,m]=L.useState(!1),x=(u==null?void 0:u.at(n))??null;if(!Qh(n,x,l))return null;const g=e.winner!==i,b=e.shadowed.length>0;return s.jsxs("div",{children:[s.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded",style:{paddingLeft:h*14},children:[s.jsx("span",{className:`w-3 shrink-0 ${b?"text-fg-faint cursor-pointer":""}`,onClick:()=>b&&m(!d),children:b?d?"▾":"▸":""}),s.jsxs("span",{className:"text-fg",children:[r,":"]}),s.jsx("span",{className:"text-fg-dim truncate max-w-md",children:Ny(e.value)}),s.jsx(uw,{scope:e.winner}),(x==null?void 0:x.deprecated)&&s.jsx(zm,{tone:"warn",children:"deprecated"}),(x==null?void 0:x.default)!==void 0&&DO(e.value,x.default)&&s.jsx(zm,{tone:"dim",children:"= default"}),e.typeMismatch&&s.jsx("span",{className:"text-yellow-500/80",title:"shadowed scopes have a different value type",children:"⚠"}),(x==null?void 0:x.description)&&s.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:x.description,children:["— ",x.description]}),s.jsx("div",{className:"flex-1"}),(x==null?void 0:x.enum)&&s.jsx(dj,{values:x.enum}),s.jsx("button",{disabled:!g,onClick:()=>o(n,e.value),className:`opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border rounded transition-opacity ${g?"border-accent/50 text-accent hover:bg-accent hover:text-bg":"border-line text-fg-faint cursor-not-allowed"}`,title:g?`copy into ${os[i].label} draft`:`already winning in ${os[i].label}`,children:"override"})]}),d&&e.shadowed.map((S,E)=>s.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-fg-faint line-through",style:{paddingLeft:(h+1)*14+12},children:[s.jsx("span",{children:"shadowed:"}),s.jsx("span",{className:"truncate max-w-xl",children:Ny(S.value)}),s.jsx(uw,{scope:S.scope,dim:!0})]},E))]})}function PO({path:e,label:n,info:r,targetScope:i,onSet:o,depth:l,filter:h}){if(!Qh(e,r,h))return null;const u=r.default!==void 0?r.default:OO(r.type),d=Array.isArray(r.type)?r.type.join("|"):r.type??"?";return s.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded opacity-60",style:{paddingLeft:l*14},children:[s.jsx("span",{className:"w-3 shrink-0"}),s.jsx("span",{className:"text-fg-dim",children:n}),s.jsx(zm,{tone:"dim",children:d}),r.required&&s.jsx(zm,{tone:"warn",children:"required"}),r.default!==void 0&&s.jsxs("span",{className:"text-fg-faint",children:["default: ",Ny(r.default)]}),r.description&&s.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:r.description,children:["— ",r.description]}),s.jsx("div",{className:"flex-1"}),r.enum&&s.jsx(dj,{values:r.enum}),s.jsx("button",{onClick:()=>o(e,u),className:"opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg transition-opacity",title:`write to ${os[i].label} draft`,children:"set"})]})}function DO(e,n){return e===n?!0:typeof e!=typeof n?!1:e&&n&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(n):!1}function OO(e){switch(Array.isArray(e)?e[0]:e){case"boolean":return!1;case"integer":case"number":return 0;case"string":return"";case"array":return[];case"object":return{};case"null":return null;default:return null}}function Ny(e){if(typeof e=="string")return JSON.stringify(e);if(e===null)return"null";if(typeof e=="object"){const n=JSON.stringify(e);return n.length>100?n.slice(0,100)+"…":n}return String(e)}function uw({scope:e,dim:n}){const r=e==="user"?"bg-bg-hi text-fg-dim border-line":e==="project"?"bg-blue-950/30 text-blue-400/80 border-blue-900/40":"bg-purple-950/30 text-purple-400/80 border-purple-900/40";return s.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${r} ${n?"opacity-60":""}`,children:os[e].label})}function zm({children:e,tone:n="default"}){const r={default:"bg-bg-hi text-fg-dim border-line",warn:"bg-yellow-950/30 text-yellow-500/80 border-yellow-900/40",dim:"bg-bg-elev text-fg-faint border-line"}[n];return s.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${r}`,children:e})}function dj({values:e}){const n=e.map(r=>String(r)).join(" | ");return s.jsxs("span",{className:"text-[10px] text-fg-faint truncate max-w-xs",title:`allowed: ${n}`,children:["∈ ",n.length>30?n.slice(0,30)+"…":n]})}const LO=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Which model runs, how hard it thinks, and fast-mode toggles.",keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],zO={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function hj(e){return e.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((i,o)=>{const l=zO[i];return l||(o===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function BO(e){const n=new Set,r=[];for(const o of LO){const l=o.keys.filter(h=>e.has(h));l.forEach(h=>n.add(h)),l.length!==0&&r.push({id:o.id,title:o.title,summary:o.summary,advanced:!!o.advanced,keys:l})}const i=Array.from(e).filter(o=>!n.has(o)&&o!=="$schema").sort();return i.length>0&&r.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:i}),r}const FO=["user","project","local","default"],UO={user:"user",project:"project",local:"local",default:"default"};function HO({node:e,targetScope:n,onOverride:r,schema:i}){const[o,l]=L.useState(""),[h,u]=L.useState(!1),[d,m]=L.useState(!0),x=e.kind==="object"?e:null,g=x?Object.keys(x.children):[],b=i.rootKeys(),S=new Set([...g,...b]),E=L.useMemo(()=>BO(S),[Array.from(S).sort().join(",")]),C=L.useMemo(()=>E.filter(y=>h||!y.advanced).map(y=>({...y,keys:y.keys.filter(v=>{const _=(x==null?void 0:x.children[v])!==void 0;if(!d&&!_)return!1;if(!o.trim())return!0;const j=i.at([v]);return[v,hj(v),(j==null?void 0:j.description)??""].join(" ").toLowerCase().includes(o.toLowerCase())})})).filter(y=>y.keys.length>0),[E,o,h,d,x,i]);return s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[s.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",s.jsx("span",{className:"text-fg-dim font-medium",children:os[n].label})]}),s.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:d,onChange:y=>m(y.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),s.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:h,onChange:y=>u(y.target.checked),className:"accent-accent"}),"show advanced"]}),s.jsx("div",{className:"flex-1"}),s.jsx("input",{value:o,onChange:y=>l(y.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),s.jsxs("div",{className:"flex-1 overflow-auto",children:[C.map(y=>s.jsx(WO,{title:y.title,summary:y.summary,advanced:y.advanced,children:y.keys.map(v=>{const _=x==null?void 0:x.children[v],j=i.at([v]);return s.jsx(qO,{keyName:v,node:_,info:j,targetScope:n,onOverride:(T,A)=>r([v],T,A)},v)})},y.id)),C.length===0&&s.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',o,'"']})]})]})}function WO({title:e,summary:n,advanced:r,children:i}){const[o,l]=L.useState(!0);return s.jsxs("section",{className:"border-b border-line",children:[s.jsxs("header",{className:"px-4 py-2.5 bg-bg-elev/40 cursor-pointer hover:bg-bg-elev flex items-center gap-3",onClick:()=>l(!o),children:[s.jsx("span",{className:"text-fg-faint w-3",children:o?"▾":"▸"}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-fg text-sm font-medium",children:e}),r&&s.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),s.jsx("p",{className:"text-fg-faint text-xs",children:n})]})]}),o&&s.jsx("div",{className:"divide-y divide-line/60",children:i})]})}function qO({keyName:e,node:n,info:r,targetScope:i,onOverride:o}){const[l,h]=L.useState(!1),[u,d]=L.useState(!1),m=hj(e),x=n!==void 0,b=(n==null?void 0:n.kind)==="leaf"?n:null,S=(n==null?void 0:n.kind)==="object"||(n==null?void 0:n.kind)==="array",E=r==null?void 0:r.default,C=b&&E!==void 0&&pj(b.value,E),y=ZO({isSet:x,leafNode:b,defaultVal:E,isDefault:!!C,node:n}),v=VO(b,E),_=v.length>=2,j=!!b&&!C;return s.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>h(!l),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:l?"collapse":"expand",children:l?"▾":"▸"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-fg text-sm",children:m}),s.jsx(e5,{kind:y.kind,label:y.label}),_&&s.jsxs("button",{onClick:T=>{T.stopPropagation(),l||h(!0),d(A=>!A)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",v.map(T=>UO[T]).join(" · ")]}),j&&b&&s.jsx("button",{onClick:T=>{T.stopPropagation(),o(void 0,b.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${os[b.winner].label}`,children:"↺ reset"}),(r==null?void 0:r.deprecated)&&s.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(r==null?void 0:r.required)&&!x&&s.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),(r==null?void 0:r.description)&&s.jsx("p",{className:"text-fg-dim text-xs mt-0.5 leading-relaxed",children:t5(r.description)}),l&&u&&b&&s.jsx(GO,{leaf:b,defaultVal:E,onReset:T=>o(void 0,T)}),l&&s.jsx(KO,{keyName:e,node:n,info:r,targetScope:i,onOverride:T=>o(T)})]}),s.jsx("div",{className:"shrink-0",children:!l&&s.jsx(QO,{node:n,info:r,onSet:T=>{o(T)},disabled:S&&x})})]})})}function VO(e,n){if(!e)return[];const r=new Set;r.add(e.winner);for(const i of e.shadowed)r.add(i.scope);return n!==void 0&&r.add("default"),FO.filter(i=>r.has(i))}function GO({leaf:e,defaultVal:n,onReset:r}){const i={};i[e.winner]={value:e.value,winner:!0};for(const o of e.shadowed)i[o.scope]={value:o.value,winner:!1};return s.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[s.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),s.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(o=>{const l=i[o],h=l!==void 0;return s.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[s.jsx("span",{className:"text-fg-faint",children:os[o].label}),s.jsx("span",{className:`font-mono truncate ${l!=null&&l.winner?"text-accent":"text-fg-dim"}`,children:h?qh(l.value):s.jsx("span",{className:"text-fg-faint",children:"—"})}),h?s.jsx("button",{onClick:()=>r(o),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${os[o].label}`,children:"↺"}):s.jsx("span",{})]},o)}),s.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[s.jsx("span",{className:"text-fg-faint",children:"Default"}),s.jsx("span",{className:"font-mono text-fg-dim truncate",children:n!==void 0?qh(n):s.jsx("span",{className:"text-fg-faint",children:"—"})}),s.jsx("span",{})]})]})]})}function KO({keyName:e,node:n,info:r,targetScope:i,onOverride:o}){const h=(n==null?void 0:n.kind)==="leaf"?n:null;return s.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[(r==null?void 0:r.description)&&s.jsx("p",{className:"text-fg-dim leading-relaxed whitespace-pre-wrap",children:r.description}),s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(r==null?void 0:r.type)&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Type"}),s.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(r.type)?r.type.join(" | "):r.type})]}),(r==null?void 0:r.default)!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Default"}),s.jsx("dd",{className:"text-fg-dim font-mono",children:qh(r.default)})]}),(r==null?void 0:r.enum)&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Options"}),s.jsx("dd",{className:"text-fg-dim font-mono",children:r.enum.map(u=>String(u)).join(" | ")})]}),h&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Current"}),s.jsxs("dd",{className:"font-mono",children:[s.jsx("span",{className:"text-fg-dim",children:qh(h.value)}),s.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",os[h.winner].label]})]})]}),h&&h.shadowed.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Shadowed"}),s.jsx("dd",{className:"space-y-0.5",children:h.shadowed.map((u,d)=>s.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[qh(u.value)," —"," ",s.jsx("span",{className:"no-underline",children:os[u.scope].label})]},d))})]}),(n==null?void 0:n.kind)==="array"&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Accumulated"}),s.jsxs("dd",{className:"text-fg-dim",children:[n.items.length," items across all scopes"]})]})]}),s.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:s.jsx(XO,{keyName:e,node:n,info:r,onChange:o,targetScope:i})})]})}function XO({node:e,info:n,onChange:r,targetScope:i}){const l=(e==null?void 0:e.kind)==="leaf"?e.value:n==null?void 0:n.default,h=fj(n==null?void 0:n.type);if(h==="boolean"){const u=l===!0;return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-faint",children:"Set to:"}),s.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:d,label:m})=>s.jsx("button",{onClick:()=>r(d),className:`px-3 py-0.5 text-xs transition-colors ${u===d?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:m},m))}),s.jsxs("span",{className:"text-fg-faint",children:["→ ",os[i].label]})]})}return n!=null&&n.enum?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-fg-faint",children:"Choose:"}),n.enum.map(u=>{const d=pj(l,u);return s.jsx("button",{onClick:()=>r(u),className:`px-2 py-0.5 text-xs rounded border ${d?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(u)},String(u))}),s.jsxs("span",{className:"text-fg-faint",children:["→ ",os[i].label]})]}):h==="integer"||h==="number"?s.jsx(YO,{value:typeof l=="number"?l:void 0,integer:h==="integer",onCommit:r,target:os[i].label}):h==="string"?s.jsx(JO,{value:typeof l=="string"?l:"",onCommit:r,target:os[i].label}):s.jsxs("div",{className:"text-fg-faint",children:["Complex value (",h??"object/array",") — use the"," ",s.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function YO({value:e,integer:n,onCommit:r,target:i}){const[o,l]=L.useState(e!==void 0?String(e):""),h=()=>{const u=n?parseInt(o,10):parseFloat(o);Number.isNaN(u)||r(u)};return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-faint",children:"Set to:"}),s.jsx("input",{type:"number",value:o,onChange:u=>l(u.target.value),onBlur:h,onKeyDown:u=>{u.key==="Enter"&&u.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),s.jsxs("button",{onClick:h,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",i]})]})}function JO({value:e,onCommit:n,target:r}){const[i,o]=L.useState(e);return s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),s.jsx("input",{type:"text",value:i,onChange:l=>o(l.target.value),onKeyDown:l=>{l.key==="Enter"&&n(i)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),s.jsxs("button",{onClick:()=>n(i),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",r]})]})}function QO({node:e,info:n,onSet:r,disabled:i}){const o=(e==null?void 0:e.kind)==="leaf",l=fj(n==null?void 0:n.type);if(i)return null;if(l==="boolean"){const h=o&&e.value===!0;return s.jsx("button",{onClick:()=>r(!h),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${h?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:h?"on":"off"})}return null}function ZO({isSet:e,leafNode:n,defaultVal:r,isDefault:i,node:o}){return e?(o==null?void 0:o.kind)==="array"?{kind:"accumulated",label:`${o.items.length} items`}:(o==null?void 0:o.kind)==="object"?{kind:"set",label:"configured"}:n?i?{kind:"default",label:`= default · ${os[n.winner].label}`}:n.shadowed.length>0?{kind:"override",label:`overriding ${n.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${os[n.winner].label}`}:{kind:"set",label:"configured"}:r!==void 0?{kind:"default",label:`using default: ${qh(r)}`}:{kind:"unset",label:"not configured"}}function e5({kind:e,label:n}){const r={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[e];return s.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${r}`,children:n})}function fj(e){if(e)return Array.isArray(e)?e.find(r=>r!=="null")??e[0]:e}function pj(e,n){return e===n?!0:typeof e!=typeof n?!1:e&&n&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(n):!1}function t5(e){const n=e.trim().split(`
3385
+ (Give a different rewrite than the last one.)`,!1)},[x,n.instruction]),E=L.useCallback(C=>{const y=n.diff;if(!y)return{ok:!1,reason:"not-found"};const v=JD(C,y.before,y.after);return v.ok?(i.current+=1,r({type:"ACCEPT"})):ze.error(v.reason==="ambiguous"?"That text appears more than once — edit it manually instead.":"That text no longer matches the document — edit it manually instead."),v},[n.diff]);return{state:n,select:u,cancel:d,listen:m,sendHeard:b,run:g,retry:S,accept:E}}const nO=[{label:"Make concise",instruction:"Rewrite this text to be concise and specific. Preserve meaning and any markdown structure."},{label:"To bullet list",instruction:"Convert this text into a tight markdown bullet list."},{label:"Fix the tone",instruction:"Fix the tone: direct, professional, no hedging. Preserve meaning."}],pk=320,rm=8;function rO(){return s.jsxs("span",{className:"inline-flex items-center gap-0.5","aria-hidden":"true",children:[s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:0ms]"}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:150ms]"}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:300ms]"})]})}function sO(e){const n=typeof window<"u"?window.innerWidth:1024,r=Math.min(Math.max(e.left,rm),Math.max(rm,n-pk-rm)),i=Math.max(e.top-rm,rm);return{position:"fixed",left:r,top:i,width:pk,transform:"translateY(-100%)",zIndex:50}}function iO({phase:e,rect:n,diff:r,transcript:i,onQuickAction:o,onRunCustom:l,onListen:h,onSendHeard:u,onCancel:d,onAccept:m,onReject:x,onRetry:g}){const[b,S]=L.useState(""),E=()=>{const C=b.trim();C&&(l(C),S(""))};return s.jsxs("div",{"data-doc-edit-popover":!0,style:sO(n),className:"rounded-lg border border-line bg-bg-elev shadow-2xl text-xs text-fg",children:[e==="popover"&&s.jsxs("div",{className:"p-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("button",{onClick:h,"data-testid":"doc-edit-voice",className:"px-2 py-1 text-[11px] rounded border border-line bg-bg-hi text-fg hover:border-fg-faint font-medium",title:"Speak your edit instruction",children:"🎤 Voice edit"}),nO.map(C=>s.jsx("button",{onClick:()=>o(C.instruction),className:"px-2 py-1 text-[11px] rounded border border-line text-fg-dim hover:text-fg hover:bg-bg-hi",children:C.label},C.label))]}),s.jsx("button",{onClick:d,className:"ml-2 shrink-0 text-fg-faint hover:text-fg",title:"Dismiss","aria-label":"Dismiss",children:"×"})]}),s.jsx("input",{autoFocus:!0,value:b,onChange:C=>S(C.target.value),onKeyDown:C=>{C.key==="Enter"?E():C.key==="Escape"&&d()},placeholder:"tell Claude what to change…",className:"w-full px-2 py-1 text-[11px] bg-bg border border-line rounded outline-none focus:border-fg-faint text-fg placeholder:text-fg-faint"})]}),e==="listening"&&s.jsxs("div",{className:"p-3 flex items-center justify-between","data-testid":"doc-edit-listening",children:[s.jsxs("span",{className:"flex items-center gap-2 text-fg-dim",children:[s.jsx(rO,{}),"Listening…"]}),s.jsx("button",{onClick:d,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),e==="review"&&s.jsxs("div",{className:"p-3","data-testid":"doc-edit-review",children:[s.jsxs("p",{className:"italic text-fg mb-2",children:["«",i,"»"]}),s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsx("button",{onClick:d,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:h,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Re-record"}),s.jsx("button",{onClick:u,className:"px-2 py-1 text-[11px] text-white rounded bg-accent hover:opacity-90",children:"Send"})]})]}),e==="thinking"&&s.jsxs("div",{className:"p-3 flex items-center justify-between",children:[s.jsx("span",{className:"text-fg-dim animate-pulse",children:"Claude is editing…"}),s.jsx("button",{onClick:d,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),e==="diff"&&r&&s.jsxs("div",{className:"p-3",children:[s.jsxs("div",{className:"mb-2 max-h-40 overflow-auto space-y-1",children:[s.jsx("div",{className:"text-red-400 line-through whitespace-pre-wrap",children:r.before}),s.jsx("div",{className:"text-green-400 whitespace-pre-wrap",children:r.after})]}),s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsx("button",{onClick:x,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Reject"}),s.jsx("button",{onClick:g,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Retry"}),s.jsx("button",{onClick:m,className:"px-2 py-1 text-[11px] text-white rounded bg-green-600 hover:bg-green-500",children:"Accept"})]})]})]})}function oO(){return s.jsxs("span",{className:"inline-flex items-center gap-0.5","aria-hidden":"true",children:[s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:0ms]"}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:150ms]"}),s.jsx("span",{className:"w-1 h-1 rounded-full bg-red-400 animate-pulse [animation-delay:300ms]"})]})}function mk({phase:e,transcript:n,diff:r,editCount:i,onListen:o,onSendHeard:l,onCancel:h,onAccept:u,onReject:d,onRetry:m}){return s.jsxs("div",{"data-testid":"assistant-rail",className:"w-[300px] shrink-0 border-l border-line bg-bg-elev flex flex-col text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 h-8 border-b border-line shrink-0",children:[s.jsx("span",{className:"font-medium text-fg",children:"Assistant"}),s.jsx("span",{className:"text-[10px] text-fg-faint",title:"Model used for Document Experience edits",children:Xm(eO)})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-3",children:[e==="idle"&&s.jsxs("div",{className:"text-fg-faint",children:[s.jsx("p",{children:"Select text in the doc…"}),s.jsxs("p",{className:"mt-2 text-[10px]",children:[i," edit",i===1?"":"s"," this session"]})]}),e==="popover"&&s.jsx("p",{className:"text-fg-faint",children:"Choose a quick action or speak an instruction from the popover."}),e==="listening"&&s.jsxs("div",{children:[s.jsxs("p",{className:"flex items-center gap-2 text-fg-dim mb-3",children:[s.jsx(oO,{}),"Listening…"]}),s.jsx("button",{onClick:h,className:"px-2 py-0.5 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"})]}),e==="review"&&s.jsxs("div",{children:[s.jsxs("p",{className:"italic text-fg mb-3",children:["«",n,"»"]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx("button",{onClick:h,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:o,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Re-record"}),s.jsx("button",{onClick:l,className:"px-2 py-1 text-[11px] text-white rounded bg-accent hover:opacity-90",children:"Send"})]})]}),e==="thinking"&&s.jsx("p",{className:"text-fg-dim animate-pulse",children:"Claude is editing…"}),e==="diff"&&r&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-3 space-y-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] uppercase tracking-wide text-fg-faint mb-1",children:"Before"}),s.jsx("div",{className:"text-red-400 line-through whitespace-pre-wrap",children:r.before})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] uppercase tracking-wide text-fg-faint mb-1",children:"After"}),s.jsx("div",{className:"text-green-400 whitespace-pre-wrap",children:r.after})]})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsx("button",{onClick:d,className:"px-2 py-1 text-[11px] text-fg-faint hover:text-fg border border-line rounded",children:"Reject"}),s.jsx("button",{onClick:m,className:"px-2 py-1 text-[11px] text-fg-dim hover:text-fg border border-line rounded",children:"Retry"}),s.jsx("button",{onClick:u,className:"px-2 py-1 text-[11px] text-white rounded bg-green-600 hover:bg-green-500",children:"Accept"})]})]})]})]})}function gk(e){return e.split("/").filter(Boolean).pop()||e}function aO({path:e,onRenamed:n,onDeleted:r}){const[i,o]=L.useState(!1),[l,h]=L.useState(!1),[u,d]=L.useState(""),[m,x]=L.useState(!1),g=An(U=>U.buffers[e]),b=An(U=>U.openFile),S=An(U=>U.renameOpenFile),E=An(U=>U.closeFile),C=co(),y=gk(e),v=()=>o(!1),_=()=>{d(y),h(!0),v()},j=async()=>{const U=u.trim();if(!U||U===y){h(!1);return}try{const W=await window.api.files.rename(e,U);if(W.ok){const Y=e.slice(0,e.lastIndexOf("/")),V=W.newPath??`${Y}/${U}`;S(e,V),n==null||n(e,V),ze.info(`Renamed to ${U}`)}else ze.error(W.error??`Couldn't rename ${y}`)}catch(W){ze.error(W instanceof Error?W.message:`Couldn't rename ${y}`)}h(!1)},T=async()=>{v();try{const U=await window.api.files.duplicate(e);U.ok&&U.path?(b(U.path),ze.info(`Duplicated as ${gk(U.path)}`)):ze.error(U.error??`Couldn't duplicate ${y}`)}catch(U){ze.error(U instanceof Error?U.message:`Couldn't duplicate ${y}`)}},A=async()=>{try{const U=await window.api.files.delete(e);U.ok?(E(e),r==null||r(e),ze.info(`Deleted ${y}`)):ze.error(U.error??`Couldn't delete ${y}`)}catch(U){ze.error(U instanceof Error?U.message:`Couldn't delete ${y}`)}x(!1)},M=async()=>{v();const U=g??"";try{await navigator.clipboard.writeText(U),ze.info(`Copied ${U.length} chars`)}catch(W){ze.error(W instanceof Error?W.message:`Couldn't copy ${y}`)}},O=()=>{if(v(),!C){ze.error("No terminal tab is active");return}window.api.pty.write({tabId:C.id,data:`@${e} `}),ze.info(`Added ${y} to Claude context`)},I=()=>{v(),window.api.shell.open({as:"openPath",path:e}).then(U=>{U.ok||ze.error(U.error??`Couldn't open ${y}`)}).catch(U=>ze.error(U instanceof Error?U.message:`Couldn't open ${y}`))},z=()=>{v(),window.api.shell.open({as:"revealPath",path:e}).then(U=>{U.ok||ze.error(U.error??`Couldn't reveal ${y}`)}).catch(U=>ze.error(U instanceof Error?U.message:`Couldn't reveal ${y}`))};return s.jsxs("div",{className:"relative inline-block mr-1",children:[s.jsx("button",{onClick:()=>o(U=>!U),className:`px-2 py-0.5 text-[10px] border border-line rounded ${i?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Document actions",children:"Document ▾"}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[390]",onMouseDown:v}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-[400] w-56 rounded-lg border border-line bg-bg-elev shadow-xl text-xs py-1",children:[s.jsx(rb,{children:"Edit"}),s.jsx(wu,{label:"Rename",onClick:_}),s.jsx(wu,{label:"Duplicate",onClick:T}),s.jsx(wu,{label:"Delete document",danger:!0,onClick:()=>{v(),x(!0)}}),s.jsx(xk,{}),s.jsx(rb,{children:"Open"}),s.jsx(wu,{label:"Open in default app",onClick:I}),s.jsx(wu,{label:"Reveal in OS",onClick:z}),s.jsx(xk,{}),s.jsx(rb,{children:"Export"}),s.jsx(wu,{label:"Copy as Markdown",onClick:M}),s.jsx(wu,{label:"Add to Claude context",onClick:O,disabled:!C,title:C?void 0:"No terminal tab is active"})]})]}),l&&s.jsx(lO,{value:u,onChange:d,onCancel:()=>h(!1),onConfirm:()=>void j()}),m&&s.jsx(cO,{name:y,onCancel:()=>x(!1),onConfirm:()=>void A()})]})}function rb({children:e}){return s.jsx("div",{className:"px-3 pt-1 pb-0.5 text-[9px] uppercase tracking-wide text-fg-faint",children:e})}function wu({label:e,onClick:n,danger:r,disabled:i,title:o}){return s.jsx("button",{onClick:n,disabled:i,title:o,className:`w-full text-left px-3 py-1.5 transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${r?"text-red-400 hover:bg-bg-hi":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:e})}function xk(){return s.jsx("div",{className:"my-1 border-t border-line"})}function lO({value:e,onChange:n,onCancel:r,onConfirm:i}){return s.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:o=>{o.target===o.currentTarget&&r()},children:s.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[s.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:"Rename"}),s.jsx("input",{autoFocus:!0,value:e,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"?i():o.key==="Escape"&&r()},className:"w-full px-2 py-1 text-xs bg-bg border border-line rounded text-fg mb-3"}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:r,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:i,className:"px-3 py-1 text-xs text-white rounded bg-accent hover:bg-accent/90",children:"Rename"})]})]})})}function cO({name:e,onCancel:n,onConfirm:r}){return s.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:i=>{i.target===i.currentTarget&&n()},children:s.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[s.jsxs("h3",{className:"text-sm font-medium text-fg mb-3",children:["Delete ",e,"? This cannot be undone."]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:n,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:r,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Delete"})]})]})})}function uO(){const[e,n]=L.useState(!1),r=Dh();return s.jsxs("div",{className:"relative inline-block mr-1",children:[s.jsx("button",{onClick:()=>n(i=>!i),className:`px-2 py-0.5 text-[10px] border border-line rounded ${e?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Display preferences",children:"Display"}),e&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[390]",onMouseDown:()=>n(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1 z-[400] w-60 rounded-lg border border-line bg-bg-elev shadow-xl text-xs p-2 space-y-1.5",children:[s.jsx(Nh,{label:"Text size",children:s.jsxs("div",{className:"flex items-center rounded border border-line overflow-hidden",children:[s.jsx("button",{onClick:()=>r.bumpFontSize(-1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom out",children:"A−"}),s.jsx("span",{className:"px-2 text-[10px] text-fg-dim",children:r.fontSize}),s.jsx("button",{onClick:()=>r.bumpFontSize(1),className:"px-1.5 py-0.5 text-[11px] text-fg-faint hover:text-fg",title:"Zoom in",children:"A+"})]})}),s.jsx(Nh,{label:"Word wrap",children:s.jsx(jx,{on:r.wordWrap,onClick:r.toggleWordWrap})}),s.jsx(Nh,{label:"Minimap",children:s.jsx(jx,{on:r.minimap,onClick:r.toggleMinimap})}),s.jsx(Nh,{label:"Theme",children:s.jsx("button",{onClick:()=>r.setTheme(r.theme==="dark"?"paper":"dark"),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Toggle editor theme",children:r.theme==="dark"?"Dark":"Paper"})}),s.jsx(Nh,{label:"Autosave",children:s.jsx(jx,{on:r.autosave,onClick:r.toggleAutosave})}),s.jsx(Nh,{label:"Wide measure",children:s.jsx(jx,{on:r.wideMeasure,onClick:r.toggleWideMeasure})})]})]})]})}function Nh({label:e,children:n}){return s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-fg-faint",children:e}),n]})}function jx({on:e,onClick:n}){return s.jsx("button",{onClick:n,className:`px-2 py-0.5 text-[10px] rounded border border-line ${e?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:e?"On":"Off"})}const dO=L.lazy(()=>Gm(()=>import("./TiptapBody-DXQDiOUx.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(e=>({default:e.TiptapBody})));function Ex(e){return e.split("/").filter(Boolean).pop()||e}function Nx(e,n){if(!n.length)return e;const r=new Set(n),i={};for(const[o,l]of Object.entries(e))r.has(o)||(i[o]=l);return i}function Tx(e){return G2(e)||K2(e)}function cw(){const e=An(Ye=>Ye.openFiles),n=An(Ye=>Ye.activeFilePath),r=An(Ye=>Ye.dirty),i=An(Ye=>Ye.viewMode),o=An(Ye=>Ye.buffers),l=An(Ye=>Ye.setActive),h=An(Ye=>Ye.closeFile),u=An(Ye=>Ye.closeOthers),d=An(Ye=>Ye.closeToTheRight),m=An(Ye=>Ye.closeAll),x=An(Ye=>Ye.loadBuffer),g=An(Ye=>Ye.setBuffer),b=An(Ye=>Ye.markSaved),S=An(Ye=>Ye.setViewMode),E=Dh(),[C,y]=L.useState({}),[v,_]=L.useState({}),[j,T]=L.useState(null),[A,M]=L.useState(null),[O,I]=L.useState(!1),[z,U]=L.useState(!1),[W,Y]=L.useState(!0),V=L.useRef(null),H=L.useRef(null),te=L.useRef(void 0),oe=L.useRef(null),pe=L.useRef(null),ie=tO(n??""),X=L.useCallback(Ye=>{V.current=Ye},[]),Q=L.useCallback(()=>V.current,[]);L.useEffect(()=>{const Ye=n;if(!Ye||Tx(Ye))return;if(An.getState().hasBuffer(Ye)){y(_t=>_t[Ye]==="ready"?_t:{..._t,[Ye]:"ready"});return}let yt=!1;return y(_t=>({..._t,[Ye]:"loading"})),window.api.files.read(Ye).then(_t=>{yt||(_t.binary?y(Kt=>({...Kt,[Ye]:{binary:!0,size:_t.size??0,mime:_t.mime??"application/octet-stream",reason:_t.error??"Binary file"}})):_t.ok?(x(Ye,_t.text),y(Kt=>({...Kt,[Ye]:"ready"}))):y(Kt=>({...Kt,[Ye]:{error:_t.error??"failed to read"}})))}),()=>{yt=!0}},[n,x]),L.useEffect(()=>{M(null)},[n]);const J=L.useCallback(async(Ye,yt=!1)=>{const _t=An.getState().buffers[Ye];if(_t==null)return;yt&&I(!0);const Kt=await window.api.files.write(Ye,_t);Kt.ok?(b(Ye),_(On=>({...On,[Ye]:(On[Ye]??0)+1})),yt||ze.info(`Saved ${Ex(Ye)}`)):ze.error(Kt.error??`Couldn't save ${Ex(Ye)}`),yt&&I(!1)},[b]);L.useEffect(()=>{if(!E.autosave)return;const Ye=n;if(!(!Ye||Tx(Ye)||!r[Ye]))return window.clearTimeout(te.current),te.current=window.setTimeout(()=>{J(Ye,!0)},1200),()=>window.clearTimeout(te.current)},[E.autosave,n,r,o,J]);const ae=L.useCallback(Ye=>{Ye.length&&(y(yt=>Nx(yt,Ye)),_(yt=>Nx(yt,Ye)))},[]),le=L.useCallback((Ye,yt)=>{y(_t=>Ye in _t?{...Nx(_t,[Ye]),[yt]:_t[Ye]}:_t),_(_t=>Ye in _t?{...Nx(_t,[Ye]),[yt]:_t[Ye]}:_t)},[]),fe=L.useCallback(Ye=>{r[Ye]?T({kind:"one",path:Ye}):(h(Ye),ae([Ye]))},[r,h,ae]),Me=L.useCallback(Ye=>{e.some(_t=>_t.path!==Ye&&r[_t.path])?T({kind:"others",path:Ye}):(u(Ye),ae(e.filter(_t=>_t.path!==Ye).map(_t=>_t.path)))},[e,r,u,ae]),je=L.useCallback(Ye=>{const yt=e.findIndex(Kt=>Kt.path===Ye);yt!==-1&&e.slice(yt+1).some(Kt=>r[Kt.path])?T({kind:"right",path:Ye}):(d(Ye),ae(yt!==-1?e.slice(yt+1).map(Kt=>Kt.path):[]))},[e,r,d,ae]);L.useEffect(()=>{const Ye=yt=>{if((yt.metaKey||yt.ctrlKey)&&(yt.key==="s"||yt.key==="S")){const _t=An.getState().activeFilePath;_t&&!Tx(_t)&&(yt.preventDefault(),J(_t))}else if((yt.metaKey||yt.ctrlKey)&&yt.shiftKey&&(yt.key==="f"||yt.key==="F"))yt.preventDefault(),U(_t=>!_t);else if((yt.metaKey||yt.ctrlKey)&&yt.shiftKey&&(yt.key==="w"||yt.key==="W")){const _t=An.getState().activeFilePath;_t&&An.getState().openFiles.length>1&&(yt.preventDefault(),Me(_t))}else yt.key==="Escape"&&ie.state.phase!=="idle"?ie.cancel():yt.key==="Escape"&&z&&U(!1)};return window.addEventListener("keydown",Ye),()=>window.removeEventListener("keydown",Ye)},[J,z,Me,ie.state.phase,ie.cancel]),L.useEffect(()=>{if(ie.state.phase==="idle")return;const Ye=yt=>{var Kt,On;const _t=yt.target;(Kt=pe.current)!=null&&Kt.contains(_t)||(On=oe.current)!=null&&On.contains(_t)||ie.cancel()};return window.addEventListener("mousedown",Ye),()=>window.removeEventListener("mousedown",Ye)},[ie.state.phase,ie.cancel]),L.useEffect(()=>{ie.cancel()},[n,ie.cancel]);const ye=L.useCallback(()=>{e.some(yt=>r[yt.path])?T({kind:"all",path:""}):(m(),y({}),_({}))},[e,r,m]),ne=()=>{if(j){if(j.kind==="one")h(j.path),ae([j.path]);else if(j.kind==="others"){const Ye=e.filter(yt=>yt.path!==j.path).map(yt=>yt.path);u(j.path),ae(Ye)}else if(j.kind==="right"){const Ye=e.findIndex(_t=>_t.path===j.path),yt=Ye!==-1?e.slice(Ye+1).map(_t=>_t.path):[];d(j.path),ae(yt)}else m(),y({}),_({});T(null)}};if(e.length===0)return s.jsx("div",{className:"h-full flex items-center justify-center text-fg-faint text-xs",children:s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"mb-2",children:"no file open"}),s.jsxs("div",{children:["open the ",s.jsx("span",{className:"text-fg-dim",children:"File Explorer"})," tab and click a file to edit it here"]})]})});const we=n,Ne=we?Ex(we):"",Je=we?C[we]:void 0,lt=we?J2(we):!1,xt=we?l$(we):!1,At=we&&lt?i[we]??c$(we):"edit",He=!!we&&!Tx(we)&&Je==="ready",vt=He,st=xt?["edit","wysiwyg","preview","split"]:lt?["edit","preview"]:[],an=we&&s.jsx(AD,{path:we,name:Ne,value:o[we]??"",onChange:Ye=>g(we,Ye),onSave:()=>void J(we),onReady:X,onCursor:M}),sn=O?"Saving…":we&&r[we]?E.autosave?"Editing…":"Unsaved":"All changes saved";return s.jsxs("div",{className:"relative flex flex-col h-full bg-bg",children:[!z&&s.jsx(ED,{openFiles:e,activeFilePath:n,dirty:r,onSelectFile:l,onCloseFile:fe,onCloseOthers:Me,onCloseToTheRight:je,onCloseAll:ye}),we&&!z&&s.jsxs("div",{className:"flex items-center px-3 h-8 border-b border-line shrink-0 bg-bg-elev",children:[s.jsx("span",{className:"text-xs font-medium text-fg truncate",children:Ne}),s.jsx("span",{className:"ml-3 text-[10px] text-fg-faint truncate",children:we}),He&&s.jsxs("span",{className:"ml-3 text-[10px] text-fg-faint shrink-0",children:["· ",sn]}),al(we)&&(At==="preview"||At==="split")&&s.jsx("button",{onClick:()=>Y(Ye=>!Ye),className:`ml-3 px-2 py-0.5 text-[10px] border border-line rounded ${W?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle document outline",children:"Outline"}),al(we)&&(At==="preview"||At==="split")&&s.jsx("button",{onClick:E.toggleAssistantRail,className:`ml-1 px-2 py-0.5 text-[10px] border border-line rounded ${E.assistantRail?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,title:"Toggle Assistant rail",children:"Assistant"}),st.length>0&&s.jsx("div",{className:"flex items-center ml-2 rounded border border-line overflow-hidden",children:st.map(Ye=>s.jsx("button",{onClick:()=>S(we,Ye),className:`px-2 py-0.5 text-[10px] capitalize transition-colors ${At===Ye?"bg-bg-hi text-fg":"text-fg-faint hover:text-fg"}`,children:Ye},Ye))}),s.jsx("div",{className:"flex-1"}),s.jsx(aO,{path:we,onRenamed:le,onDeleted:Ye=>ae([Ye])}),He&&s.jsx(uO,{}),s.jsx("button",{onClick:()=>U(!0),className:"px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded",title:"Focus mode (Cmd/Ctrl-Shift-F)",children:"Focus"})]}),z&&s.jsx("button",{onClick:()=>U(!1),className:"absolute top-2 right-3 z-10 px-2 py-0.5 text-[10px] text-fg-faint hover:text-fg border border-line rounded bg-bg-elev/80",title:"Exit focus mode (Esc)",children:"Exit focus"}),s.jsx("div",{className:"flex-1 min-h-0",children:we?G2(we)?s.jsx(UD,{path:we,name:Ne}):K2(we)?s.jsx(HD,{path:we}):Je&&typeof Je=="object"&&"binary"in Je?s.jsx(YD,{path:we,name:Ne,size:Je.size,mime:Je.mime,reason:Je.reason}):Je&&typeof Je=="object"&&"error"in Je?s.jsx("div",{className:"p-6 text-xs text-red-400",children:Je.error}):Je!=="ready"?s.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"loading…"}):At==="wysiwyg"&&al(we)?s.jsx(L.Suspense,{fallback:s.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading editor…"}),children:s.jsx(dO,{value:o[we]??"",onChange:Ye=>g(we,Ye)},we)}):At==="split"&&al(we)?s.jsxs("div",{className:"flex h-full",children:[W&&s.jsx(dk,{text:o[we]??"",scrollRef:H}),s.jsxs("div",{className:"flex-1 min-w-0 flex flex-col border-r border-line",children:[s.jsx(uk,{getEditor:Q}),s.jsx("div",{className:"flex-1 min-h-0",children:an})]}),s.jsx("div",{ref:oe,className:"flex-1 min-w-0",children:s.jsx(ck,{ref:H,text:o[we]??"",flush:!0,wideMeasure:E.wideMeasure,onSelect:ie.select,onDismissSelection:ie.cancel})}),!z&&E.assistantRail&&s.jsx(mk,{phase:ie.state.phase,transcript:ie.state.transcript,diff:ie.state.diff,editCount:ie.state.editCount,onListen:ie.listen,onSendHeard:ie.sendHeard,onCancel:ie.cancel,onAccept:()=>{const Ye=ie.accept(o[we]??"");Ye.ok&&g(we,Ye.next)},onReject:ie.cancel,onRetry:ie.retry})]}):At==="preview"&&al(we)?s.jsxs("div",{className:"flex h-full",children:[W&&s.jsx(dk,{text:o[we]??"",scrollRef:H}),s.jsx("div",{ref:oe,className:"flex-1 min-w-0",children:s.jsx(ck,{ref:H,text:o[we]??"",wideMeasure:E.wideMeasure,onSelect:ie.select,onDismissSelection:ie.cancel})}),!z&&E.assistantRail&&s.jsx(mk,{phase:ie.state.phase,transcript:ie.state.transcript,diff:ie.state.diff,editCount:ie.state.editCount,onListen:ie.listen,onSendHeard:ie.sendHeard,onCancel:ie.cancel,onAccept:()=>{const Ye=ie.accept(o[we]??"");Ye.ok&&g(we,Ye.next)},onReject:ie.cancel,onRetry:ie.retry})]}):At==="preview"&&V2(we)?s.jsx(BD,{path:we,dirty:!!r[we],reloadToken:v[we]??0}):At==="preview"&&X2(we)?s.jsx(qD,{path:we,text:o[we]??""}):At==="preview"&&Y2(we)?s.jsx(KD,{path:we,text:o[we]??""}):al(we)?s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(uk,{getEditor:Q}),s.jsx("div",{className:"flex-1 min-h-0",children:an})]}):an:null}),vt&&s.jsx(zD,{text:o[we]??"",cursor:A,language:Li(we)||void 0}),we&&al(we)&&(At==="preview"||At==="split")&&ie.state.phase!=="idle"&&ie.state.selection&&s.jsx("div",{ref:pe,children:s.jsx(iO,{phase:ie.state.phase,rect:ie.state.selection.rect,diff:ie.state.diff,transcript:ie.state.transcript,onQuickAction:ie.run,onRunCustom:ie.run,onListen:ie.listen,onSendHeard:ie.sendHeard,onCancel:ie.cancel,onReject:ie.cancel,onRetry:ie.retry,onAccept:()=>{const Ye=ie.accept(o[we]??"");Ye.ok&&g(we,Ye.next)}})}),j&&s.jsx(hO,{message:j.kind==="one"?`Discard unsaved changes to ${Ex(j.path)}?`:j.kind==="others"?"Discard unsaved changes in the other open files?":j.kind==="right"?"Discard unsaved changes in the files to the right?":"Discard unsaved changes in all open files?",onCancel:()=>T(null),onConfirm:ne})]})}function hO({message:e,onCancel:n,onConfirm:r}){return s.jsx("div",{className:"fixed inset-0 z-[400] flex items-center justify-center bg-black/60",onMouseDown:i=>{i.target===i.currentTarget&&n()},children:s.jsxs("div",{className:"w-96 rounded-lg border border-line bg-bg-elev p-4 shadow-2xl",children:[s.jsx("h3",{className:"text-sm font-medium text-fg mb-3",children:e}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:n,className:"px-3 py-1 text-xs text-fg-dim hover:text-fg border border-line rounded",children:"Cancel"}),s.jsx("button",{onClick:r,className:"px-3 py-1 text-xs text-white rounded bg-red-600 hover:bg-red-500",children:"Discard"})]})]})})}const yk={ts:"#3178c6",tsx:"#61dafb",js:"#f7df1e",jsx:"#61dafb",cjs:"#f7df1e",mjs:"#f7df1e",json:"#5d5d5d",css:"#264de4",scss:"#cd6799",less:"#1d365d",html:"#e34c26",md:"#083fa1",mdx:"#083fa1",py:"#3776ab",go:"#00add8",rs:"#dea584",java:"#b07219",kt:"#a97bff",c:"#555555",cpp:"#f34b7d",cc:"#f34b7d",h:"#555555",hpp:"#f34b7d",swift:"#fa7343",rb:"#cc342d",php:"#4f5d95",sql:"#e38c00",sh:"#89e051",bash:"#89e051",zsh:"#89e051",yaml:"#cb171e",yml:"#cb171e",toml:"#9c4221",xml:"#0060ac",svg:"#ff9900",vue:"#41b883",svelte:"#ff3e00",other:"#6b7280"},fO={ts:"TypeScript",tsx:"TSX",js:"JavaScript",jsx:"JSX",cjs:"CommonJS",mjs:"ES Module",json:"JSON",css:"CSS",scss:"SCSS",less:"Less",html:"HTML",md:"Markdown",mdx:"MDX",py:"Python",go:"Go",rs:"Rust",java:"Java",kt:"Kotlin",c:"C",cpp:"C++",cc:"C++",h:"C/C++ Header",hpp:"C++ Header",swift:"Swift",rb:"Ruby",php:"PHP",sql:"SQL",sh:"Shell",bash:"Shell",zsh:"Shell",yaml:"YAML",yml:"YAML",toml:"TOML",xml:"XML",svg:"SVG",vue:"Vue",svelte:"Svelte",other:"Other"};function sb(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"K":String(e)}function pO({open:e,onClose:n,variant:r="overlay"}){const i=kt(A=>A.tabs.find(M=>M.id===A.activeTabId)??null),o=(i==null?void 0:i.cwd)??null,[l,h]=L.useState(null),[u,d]=L.useState(!1),[m,x]=L.useState(null),g=L.useRef(null),b=L.useCallback(async A=>{d(!0),x(null);try{const M=await window.api.repo.analyze(A);M.ok?h(M):(x(M.error||"Analysis failed"),h(null))}catch(M){x(M instanceof Error?M.message:String(M)),h(null)}finally{d(!1)}},[]);L.useEffect(()=>{if(e){if(!o){x("No active session — open a tab in a folder first.");return}b(o)}},[e,o,b]),L.useEffect(()=>{var M;if(!e)return;const A=O=>{O.key==="Escape"&&(O.stopPropagation(),n())};return window.addEventListener("keydown",A),(M=g.current)==null||M.focus(),()=>window.removeEventListener("keydown",A)},[e,n]);const S=L.useCallback(()=>{o&&b(o)},[o,b]),E=L.useMemo(()=>l?Object.entries(l.languageBreakdown).map(([M,O])=>[M,O.files,O.lines]).sort((M,O)=>O[1]-M[1]).slice(0,12):[],[l]),C=L.useMemo(()=>E.length===0?1:E[0][1],[E]),y=L.useMemo(()=>{if(!l)return[];const A=l.topDirectories;if(A.length===0)return[];const M=A.map(I=>Math.sqrt(Math.max(1,I.fileCount))),O=M.reduce((I,z)=>I+z,0)||1;return A.map((I,z)=>({path:I.path,fileCount:I.fileCount,totalLines:I.totalLines,basis:M[z]/O*100}))},[l]);if(!e)return null;const v=A=>{A.target===A.currentTarget&&n()},_=o?o.split("/").filter(Boolean).pop()||o:"no folder",j=r==="page",T=s.jsx("div",{className:j?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:j?void 0:v,"data-testid":"repoviz-backdrop",children:s.jsxs("div",{ref:g,role:j?void 0:"dialog","aria-modal":j?void 0:"true","aria-label":"Repository Visualization",tabIndex:-1,className:j?"h-full w-full flex flex-col outline-none bg-bg":"bg-bg-elev border border-line rounded-lg shadow-xl w-[900px] max-w-[95vw] max-h-[85vh] flex flex-col outline-none","data-testid":"repoviz-dialog",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-line",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx("span",{className:"text-lg","aria-hidden":!0,children:"🗺"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{className:"text-base font-medium text-fg leading-tight",children:"Repository Visualization"}),s.jsxs("div",{className:"text-xs text-fg-dim truncate",title:o??"",children:[_,(l==null?void 0:l.gitStatus.branch)&&s.jsxs("span",{className:"ml-2 font-mono text-fg-faint",children:["(",l.gitStatus.branch,")"]}),(l==null?void 0:l.truncated)&&s.jsx("span",{className:"ml-2 text-amber-400",children:"truncated"})]})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[l&&l.gitStatus.uncommitted>0&&s.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-amber-500/20 text-amber-400 text-[11px] font-mono",title:`${l.gitStatus.uncommitted} uncommitted files`,children:[l.gitStatus.uncommitted," uncommitted"]}),s.jsxs("button",{type:"button",onClick:S,disabled:u||!o,className:"px-2 py-1 rounded text-fg-dim hover:bg-bg-hi hover:text-fg text-xs disabled:opacity-40 disabled:cursor-not-allowed",title:"Re-run analysis",children:[u?"…":"↻"," Refresh"]}),s.jsx("button",{type:"button",onClick:n,className:"px-2 py-1 rounded text-fg-dim hover:bg-bg-hi hover:text-fg text-xs","aria-label":"Close",children:"✕"})]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-5 space-y-6",children:u&&!l?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-fg-dim",children:[s.jsx("div",{className:"text-3xl mb-3 animate-pulse","aria-hidden":!0,children:"⟳"}),s.jsx("div",{className:"text-sm",children:"Analyzing repository…"}),s.jsx("div",{className:"text-xs text-fg-faint mt-1",children:"Walking files, counting lines, reading git status"})]}):m?s.jsxs("div",{className:"py-16 text-center",children:[s.jsx("div",{className:"text-3xl mb-3 text-red-400","aria-hidden":!0,children:"⚠"}),s.jsx("div",{className:"text-sm text-red-400",children:m})]}):l?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsx(ib,{label:"Files",value:sb(l.totalFiles)}),s.jsx(ib,{label:"Lines of code",value:sb(l.totalLines)}),s.jsx(ib,{label:"Uncommitted",value:String(l.gitStatus.uncommitted),tone:l.gitStatus.uncommitted>0?"warn":"neutral"})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Languages"}),E.length===0?s.jsx("div",{className:"text-xs text-fg-dim",children:"No files detected."}):s.jsx("div",{className:"space-y-1.5",children:E.map(([A,M,O])=>{const I=yk[A]??yk.other,z=fO[A]??A,U=M/C*100;return s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"w-24 text-fg-dim truncate",title:z,children:z}),s.jsx("div",{className:"flex-1 h-4 bg-bg rounded overflow-hidden",children:s.jsx("div",{className:"h-full rounded",style:{width:`${U}%`,backgroundColor:I}})}),s.jsxs("span",{className:"w-16 text-right text-fg-dim font-mono",children:[M," files"]}),s.jsxs("span",{className:"w-20 text-right text-fg-faint font-mono",children:[sb(O)," L"]})]},A)})})]}),s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg-faint mb-2",children:"Top directories"}),y.length===0?s.jsx("div",{className:"text-xs text-fg-dim",children:"No directories."}):s.jsx("div",{className:"flex flex-wrap gap-1 min-h-[140px]",children:y.map(A=>s.jsxs("div",{className:"relative rounded bg-bg-hi border border-line hover:border-accent transition-colors cursor-default flex flex-col justify-end p-2 min-w-[80px] min-h-[60px]",style:{flexBasis:`${Math.max(A.basis,6)}%`,flexGrow:A.basis>15?1:0},title:`${A.path} — ${A.fileCount} files, ${A.totalLines.toLocaleString()} lines`,children:[s.jsx("div",{className:"text-[11px] font-mono text-fg truncate",children:A.path}),s.jsxs("div",{className:"text-[10px] text-fg-dim font-mono",children:[A.fileCount," files"]})]},A.path))})]}),s.jsxs("div",{className:"text-[10px] text-fg-faint text-right",children:["Analyzed in ",l.durationMs,"ms",l.truncated&&" — stopped early (5000-file cap or 30s timeout)"]})]}):s.jsx("div",{className:"py-16 text-center text-fg-dim text-sm",children:"No analysis yet. Click Refresh."})})]})});return!j&&typeof document<"u"&&document.body?Uu.createPortal(T,document.body):T}function ib({label:e,value:n,tone:r="neutral"}){const i=r==="warn"?"text-amber-400":"text-fg";return s.jsxs("div",{className:"bg-bg-hi/40 border border-line rounded-lg p-3",children:[s.jsx("div",{className:`text-xl font-medium ${i}`,children:n}),s.jsx("div",{className:"text-xs text-fg-dim mt-0.5",children:e})]})}function Wu({options:e,active:n,onChange:r}){return s.jsx("div",{className:"flex rounded border border-line overflow-hidden",children:e.map(({key:i,label:o})=>s.jsx("button",{onClick:()=>r(i),className:`px-2 py-0.5 text-xs ${n===i?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:o},i))})}const vk=e=>/[/\\\-_.\s]/.test(e),bk=e=>e>="A"&&e<="Z";function mO(e,n,r){if(!e)return{match:!0,score:0,matched:[]};const i=e.toLowerCase(),o=n.toLowerCase(),l=(r||n).toLowerCase(),h=n.split("/").pop()||n,u=h.toLowerCase();if(u===i)return{match:!0,score:1e3,matched:Array.from({length:h.length},(v,_)=>_)};if(u.startsWith(i))return{match:!0,score:900,matched:Array.from({length:e.length},(v,_)=>_)};let d=0;for(const v of l.split("/")){if(v===i)return{match:!0,score:800,matched:[]};v.startsWith(i)&&(d=Math.max(d,700))}const m=u.indexOf(i);if(m!==-1)return{match:!0,score:m===0||vk(u[m-1])||bk(h[m])?650:600,matched:Array.from({length:e.length},(_,j)=>m+j)};if(l.includes(i))return{match:!0,score:Math.max(500,d),matched:[]};let x=0,g=0,b=0,S=-1,E=0;const C=[];for(let v=0;v<o.length&&x<i.length;v++)o[v]===i[x]&&(C.push(v),g+=10,S===v-1?(b++,g+=b*8):b=0,(v===0||vk(o[v-1])||bk(n[v]))&&(E++,g+=15,v===0&&(g+=10)),S=v,x++);if(x!==i.length)return{match:!1,score:0,matched:[]};const y=Math.max(0,50-(o.length-i.length));if(g+=y,E>=i.length*.5&&(g+=30),C.length>1){const v=C[C.length-1]-C[0];v>i.length*3&&(g-=Math.min(50,(v-i.length*3)*2))}return{match:!0,score:Math.max(1,g),matched:C}}function ob(e,n){return e.startsWith(n+"/")?e.slice(n.length+1):e===n?"":e}function wk(e){const n=e.lastIndexOf("/");return n<0?"":e.slice(0,n)}const _k="session-manager.quickopen.recent",gO=8;function xO({open:e,onClose:n,variant:r="overlay"}){const i=kt(z=>z.tabs.find(U=>U.id===z.activeTabId)??null),o=(i==null?void 0:i.cwd)??"",[l,h]=L.useState(""),[u,d]=L.useState([]),[m,x]=L.useState(!1),[g,b]=L.useState(0),[S,E]=L.useState([]),C=L.useRef(null),y=L.useRef(null);L.useEffect(()=>{if(e)try{const z=localStorage.getItem(_k);z&&E(JSON.parse(z))}catch{}},[e]),L.useEffect(()=>{if(!e){h(""),b(0);return}const z=setTimeout(()=>{var U;return(U=C.current)==null?void 0:U.focus()},0);return()=>clearTimeout(z)},[e]),L.useEffect(()=>{if(!e||!o)return;let z=!1;return x(!0),window.api.search.files(o,"",{limit:5e3}).then(U=>{if(!z){if(!U.ok){ze.error(`File search failed: ${U.error??"unknown error"}`),d([]);return}d(U.files)}}).catch(U=>{const W=U instanceof Error?U.message:String(U);dt.error("quick-open","search.files threw",{error:W}),ze.error(`File search failed: ${W}`),d([])}).finally(()=>{z||x(!1)}),()=>{z=!0}},[e,o]);const v=L.useMemo(()=>{if(!l.trim())return[...u].sort((Y,V)=>Y.name.localeCompare(V.name)).slice(0,100).map(Y=>({file:Y,score:0,matched:[]}));const z=l.trim(),U=[];for(const W of u){const Y=mO(z,W.name,W.path);Y.match&&U.push({file:W,score:Y.score,matched:Y.matched})}return U.sort((W,Y)=>Y.score-W.score),U.slice(0,100)},[u,l]),_=L.useMemo(()=>l.trim()?[]:S.map(z=>u.find(U=>U.path===z)||null).filter(z=>z!==null).slice(0,5),[S,u,l]);L.useEffect(()=>{const z=_.length+v.length;g>=z&&b(Math.max(0,z-1))},[_.length,v.length,g]),L.useEffect(()=>{if(!y.current)return;const z=y.current.querySelector(`[data-row="${g}"]`);z&&z.scrollIntoView({block:"nearest"})},[g]);const j=L.useCallback(z=>{try{const V=[z,...S.filter(H=>H!==z)].slice(0,gO);E(V),localStorage.setItem(_k,JSON.stringify(V))}catch{}const U=i==null?void 0:i.id;if(!U){ze.error("No active tab to receive file path");return}const Y=(o?ob(z,o):z)||z;try{window.api.pty.write({tabId:U,data:Y})}catch(V){const H=V instanceof Error?V.message:String(V);dt.error("quick-open","pty.write failed",{error:H}),ze.error(`Failed to write to terminal: ${H}`);return}n()},[i==null?void 0:i.id,o,S,n]),T=L.useCallback(z=>{const U=_.length+v.length;if(z.key==="Escape"){z.preventDefault(),n();return}if(z.key==="ArrowDown"){if(z.preventDefault(),U===0)return;b(W=>Math.min(U-1,W+1));return}if(z.key==="ArrowUp"){if(z.preventDefault(),U===0)return;b(W=>Math.max(0,W-1));return}if(z.key==="Enter"){if(z.preventDefault(),g<_.length){const V=_[g];V&&j(V.path);return}const W=g-_.length,Y=v[W];Y&&j(Y.file.path)}},[g,v,_,j,n]);if(!e)return null;const A=(z,U)=>{if(U.length===0)return z;const W=new Set(U);return z.split("").map((Y,V)=>s.jsx("span",{className:W.has(V)?"text-accent font-semibold":"",children:Y},V))};let M=-1;const O=r==="page",I=s.jsx("div",{className:O?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-[55] flex items-start justify-center bg-black/60 pt-[12vh]",onClick:O?void 0:z=>{z.target===z.currentTarget&&n()},"data-testid":"quick-open-backdrop",children:s.jsxs("div",{role:O?void 0:"dialog","aria-modal":O?void 0:"true","aria-label":"Quick Open",className:O?"h-full w-full flex flex-col":"w-[640px] max-w-[90vw] max-h-[70vh] bg-bg-elev border border-line rounded shadow-xl flex flex-col","data-testid":"quick-open",onKeyDown:T,children:[s.jsx("div",{className:"border-b border-line p-2",children:s.jsx("input",{ref:C,type:"text",value:l,onChange:z=>{h(z.target.value),b(0)},placeholder:o?"Search files in this project…":"No active tab — open a terminal first",disabled:!o,spellCheck:!1,autoComplete:"off",className:"w-full bg-transparent text-fg placeholder:text-fg-dim outline-none px-2 py-1.5 text-sm","aria-label":"Search files"})}),s.jsx("div",{ref:y,className:"flex-1 min-h-0 overflow-y-auto",role:"listbox",children:m?s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Loading…"}):o?_.length===0&&v.length===0?s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:l?"No files match.":"No files found in this project."}):s.jsxs(s.Fragment,{children:[_.length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-fg-dim",children:"Recent"}),_.map(z=>{M++;const U=M,W=U===g;return s.jsxs("button",{"data-row":U,role:"option","aria-selected":W,onClick:()=>j(z.path),onMouseEnter:()=>b(U),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${W?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[s.jsx("span",{className:"truncate",children:z.name}),s.jsx("span",{className:"text-xs text-fg-dim truncate",children:ob(wk(z.path),o)})]},`r:${z.path}`)})]}),v.length>0&&s.jsxs("div",{children:[_.length>0&&s.jsx("div",{className:"px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-fg-dim border-t border-line",children:"Files"}),v.map(({file:z,matched:U})=>{M++;const W=M,Y=W===g;return s.jsxs("button",{"data-row":W,role:"option","aria-selected":Y,onClick:()=>j(z.path),onMouseEnter:()=>b(W),className:`w-full text-left px-3 py-1.5 text-sm flex flex-col gap-0.5 ${Y?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[s.jsx("span",{className:"truncate",children:A(z.name,U)}),s.jsx("span",{className:"text-xs text-fg-dim truncate",children:ob(wk(z.path),o)})]},z.path)})]})]}):s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Open a terminal tab to enable Quick Open."})}),s.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center justify-between text-[10px] text-fg-dim",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↑↓"})," navigate"," ",s.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↵"})," insert into terminal"," ",s.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"Esc"})," close"]}),s.jsxs("span",{children:[v.length+_.length," ",v.length+_.length===1?"file":"files"]})]})]})});return!O&&typeof document<"u"&&document.body?Uu.createPortal(I,document.body):I}function kk(e,n){return e.startsWith(n+"/")?e.slice(n.length+1):e===n?"":e}function yO(e,n,r){if(!n)return e;const i=r?e:e.toLowerCase(),o=r?n:n.toLowerCase(),l=i.indexOf(o);return l<0?e:s.jsxs(s.Fragment,{children:[e.slice(0,l),s.jsx("span",{className:"text-accent font-semibold",children:e.slice(l,l+n.length)}),e.slice(l+n.length)]})}function vO({open:e,onClose:n,variant:r="overlay"}){const i=kt(V=>V.tabs.find(H=>H.id===V.activeTabId)??null),o=(i==null?void 0:i.cwd)??"",[l,h]=L.useState(""),[u,d]=L.useState(!1),[m,x]=L.useState([]),[g,b]=L.useState(!1),[S,E]=L.useState(null),[C,y]=L.useState(0),[v,_]=L.useState(null),j=L.useRef(null),T=L.useRef(null),A=L.useRef(0);L.useEffect(()=>{if(!e){h(""),x([]),E(null),y(0);return}const V=setTimeout(()=>{var H;return(H=j.current)==null?void 0:H.focus()},0);return()=>clearTimeout(V)},[e]),L.useEffect(()=>{if(!e||!o)return;const V=l.trim();if(!V){x([]),E(null),b(!1);return}const H=++A.current;b(!0);const te=setTimeout(()=>{window.api.search.text(o,V,{caseSensitive:u,limit:500}).then(oe=>{H===A.current&&(oe.ok?(x(oe.matches),E(null)):(E(oe.error??"unknown error"),x([])),_(oe.usedRipgrep))}).catch(oe=>{if(H!==A.current)return;const pe=oe instanceof Error?oe.message:String(oe);dt.error("global-search","search.text threw",{error:pe}),E(pe),x([])}).finally(()=>{H===A.current&&b(!1)})},250);return()=>clearTimeout(te)},[e,o,l,u]);const M=L.useMemo(()=>{const V=new Map;for(const te of m){const oe=V.get(te.path);oe?oe.push(te):V.set(te.path,[te])}const H=[];for(const[te,oe]of V)H.push({path:te,matches:oe});return H.sort((te,oe)=>oe.matches.length-te.matches.length||te.path.localeCompare(oe.path)),H},[m]),O=L.useMemo(()=>m,[m]);L.useEffect(()=>{C>=O.length&&y(Math.max(0,O.length-1))},[O.length,C]),L.useEffect(()=>{if(!T.current)return;const V=T.current.querySelector(`[data-match="${C}"]`);V&&V.scrollIntoView({block:"nearest"})},[C]);const I=L.useCallback(V=>{const H=i==null?void 0:i.id;if(!H){ze.error("No active tab to receive path");return}const oe=`${(o?kk(V.path,o):V.path)||V.path}:${V.line}`;try{window.api.pty.write({tabId:H,data:oe})}catch(pe){const ie=pe instanceof Error?pe.message:String(pe);dt.error("global-search","pty.write failed",{error:ie}),ze.error(`Failed to write to terminal: ${ie}`);return}n()},[i==null?void 0:i.id,o,n]),z=L.useCallback(V=>{if(V.key==="Escape"){V.preventDefault(),n();return}if(V.key==="ArrowDown"){if(V.preventDefault(),O.length===0)return;y(H=>Math.min(O.length-1,H+1));return}if(V.key==="ArrowUp"){if(V.preventDefault(),O.length===0)return;y(H=>Math.max(0,H-1));return}if(V.key==="Enter"){V.preventDefault();const H=O[C];H&&I(H)}},[O,C,I,n]);if(!e)return null;const U=r==="page";let W=-1;const Y=s.jsx("div",{className:U?"h-full w-full flex flex-col bg-bg":"fixed inset-0 z-[55] flex items-start justify-center bg-black/60 pt-[8vh]",onClick:U?void 0:V=>{V.target===V.currentTarget&&n()},"data-testid":"global-search-backdrop",children:s.jsxs("div",{role:U?void 0:"dialog","aria-modal":U?void 0:"true","aria-label":"Search in project",className:U?"h-full w-full flex flex-col":"w-[840px] max-w-[95vw] h-[80vh] bg-bg-elev border border-line rounded shadow-xl flex flex-col","data-testid":"global-search",onKeyDown:z,children:[s.jsxs("div",{className:"border-b border-line p-2 flex items-center gap-2",children:[s.jsx("input",{ref:j,type:"text",value:l,onChange:V=>{h(V.target.value),y(0)},placeholder:o?"Search in this project…":"No active tab — open a terminal first",disabled:!o,spellCheck:!1,autoComplete:"off",className:"flex-1 bg-transparent text-fg placeholder:text-fg-dim outline-none px-2 py-1.5 text-sm","aria-label":"Search query"}),s.jsx("button",{type:"button",onClick:()=>d(V=>!V),className:`px-2 py-1 text-xs rounded border ${u?"bg-accent/20 border-accent text-accent":"bg-bg border-line text-fg-dim hover:text-fg"}`,title:"Match case","aria-pressed":u,children:"Aa"})]}),s.jsx("div",{ref:T,className:"flex-1 min-h-0 overflow-y-auto",role:"listbox",children:o?l.trim()?g?s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Searching…"}):S?s.jsx("div",{className:"px-4 py-6 text-sm text-red-400",children:S}):O.length===0?s.jsxs("div",{className:"px-4 py-6 text-sm text-fg-dim",children:["No matches for ",JSON.stringify(l),"."]}):s.jsx("div",{children:M.map(V=>s.jsxs("div",{children:[s.jsxs("div",{className:"sticky top-0 bg-bg-elev border-b border-line px-3 py-1 text-xs text-fg-dim font-mono truncate",children:[kk(V.path,o)," ",s.jsxs("span",{className:"text-fg-faint",children:["(",V.matches.length,")"]})]}),V.matches.map(H=>{W++;const te=W,oe=te===C;return s.jsxs("button",{"data-match":te,role:"option","aria-selected":oe,onClick:()=>I(H),onMouseEnter:()=>y(te),className:`w-full text-left px-3 py-1 text-xs font-mono flex gap-3 ${oe?"bg-bg-hi text-fg":"hover:bg-bg-hi/50 text-fg"}`,children:[s.jsx("span",{className:"text-fg-dim shrink-0 w-12 text-right",children:H.line}),s.jsx("span",{className:"truncate",children:yO(H.text,l,u)})]},`${H.path}:${H.line}:${H.column}:${te}`)})]},V.path))}):s.jsxs("div",{className:"px-4 py-6 text-sm text-fg-dim",children:["Type to search files in ",s.jsx("span",{className:"font-mono",children:o}),"."]}):s.jsx("div",{className:"px-4 py-6 text-sm text-fg-dim",children:"Open a terminal tab to enable project search."})}),s.jsxs("div",{className:"border-t border-line px-3 py-1.5 flex items-center justify-between text-[10px] text-fg-dim",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↑↓"})," navigate"," ",s.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"↵"})," insert path"," ",s.jsx("kbd",{className:"ml-2 px-1 py-0.5 rounded bg-bg-hi border border-line",children:"Esc"})," close"]}),s.jsxs("span",{children:[O.length," ",O.length===1?"match":"matches",v===!1&&" · fs walk (rg missing)"]})]})]})});return!U&&typeof document<"u"&&document.body?Uu.createPortal(Y,document.body):Y}const bO=[{key:"files",label:"Files"},{key:"content",label:"Content"}];function wO({open:e,onClose:n,variant:r="page",initialMode:i="files"}){const[o,l]=L.useState(i);return L.useEffect(()=>{l(i)},[i]),e?s.jsxs("div",{className:"h-full w-full flex flex-col bg-bg",children:[s.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-2 border-b border-line",children:[s.jsx(Wu,{options:bO,active:o,onChange:l}),s.jsx("span",{className:"text-[11px] text-fg-faint",children:o==="files"?"⌘P · fuzzy-find a file in the active project":"⌘⇧F · ripgrep across the active project"})]}),s.jsx("div",{className:"flex-1 min-h-0",children:o==="files"?s.jsx(xO,{open:!0,onClose:n,variant:"page"}):s.jsx(vO,{open:!0,onClose:n,variant:"page"})})]}):null}class oj extends L.Component{constructor(){super(...arguments);Fn(this,"state",{error:null});Fn(this,"reset",()=>this.setState({error:null}))}static getDerivedStateFromError(r){return{error:r}}componentDidCatch(r,i){console.error("[ErrorBoundary]",r,i)}render(){return this.state.error?this.props.fallback?this.props.fallback(this.state.error,this.reset):s.jsxs("div",{className:"p-6 text-xs",children:[s.jsx("div",{className:"text-red-400 mb-2",children:"something broke in this panel"}),s.jsx("pre",{className:"text-fg-faint whitespace-pre-wrap mb-3",children:this.state.error.message}),s.jsx("button",{onClick:this.reset,className:"px-2 py-0.5 border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"retry"})]}):this.props.children}}function _O({open:e,onClose:n,title:r,children:i,variant:o="overlay"}){return s.jsxs(Hu,{open:e,onClose:n,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:o,children:[o==="overlay"&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[s.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:r}),s.jsx("button",{type:"button",onClick:n,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:s.jsx(oj,{children:i})})]})}function kO(e){return/^monitor of /i.test(e.trim())}function Sk(e){return e.replace(/\s*\([^)]*\)\s*$/,"").replace(/\s*#\d+\s*$/,"").replace(/\s+/g," ").trim().toLowerCase()}function Ck(e,n,r){if(e){const h=r.find(u=>u.deviceId===e);if(h)return h}if(!n)return null;const i=r.filter(h=>h.label===n);if(i.length===1)return i[0];if(i.length>1)return null;const o=Sk(n),l=r.filter(h=>h.label&&Sk(h.label)===o);return l.length===1?l[0]:null}async function jk(e){var r;return(r=navigator.mediaDevices)!=null&&r.enumerateDevices?(await navigator.mediaDevices.enumerateDevices()).filter(i=>!(i.kind!=="audioinput"||i.label&&kO(i.label))):[]}const Ek=!1;function aj(){const e=Tt(m=>m.isRecording);Tt(m=>m.startRecording),Tt(m=>m.stopRecording);const[n,r]=L.useState([]),[i,o]=L.useState(null),[l,h]=L.useState(null);L.useEffect(()=>{let m=!1;return(async()=>{try{const x=await window.api.voice.getDevicePref();if(m)return;const g=await jk(Ek);if(m)return;r(g),h(x.selectedLabel);const b=Ck(x.selectedDeviceId,x.selectedLabel,g);b?(o(b.deviceId),x.selectedDeviceId&&b.deviceId!==x.selectedDeviceId&&(dt.info("voice","device-picker rebind-by-label",{fromIdPrefix:x.selectedDeviceId.slice(0,8),toIdPrefix:b.deviceId.slice(0,8)}),await window.api.voice.setDevicePref({selectedDeviceId:b.deviceId,selectedLabel:b.label||x.selectedLabel}).catch(()=>{}))):((x.selectedDeviceId||x.selectedLabel)&&(console.warn("[MicDevicePicker] previously-selected device unavailable; falling back to OS default",{savedLabel:x.selectedLabel,hadId:!!x.selectedDeviceId}),dt.warn("voice","device-picker selected-unavailable",{hadId:!!x.selectedDeviceId})),o(null))}catch(x){dt.warn("voice","device-picker init failed",{error:x instanceof Error?x.message:String(x)})}})(),()=>{m=!0}},[]);const u=L.useCallback(async()=>{try{const m=await jk(Ek);if(r(m),i&&!m.some(x=>x.deviceId===i)){const x=Ck(null,l,m);x?(o(x.deviceId),await window.api.voice.setDevicePref({selectedDeviceId:x.deviceId,selectedLabel:x.label||l}).catch(()=>{})):o(null)}}catch(m){dt.warn("voice","device-picker refresh failed",{error:m instanceof Error?m.message:String(m)})}},[i,l]);L.useEffect(()=>{const m=()=>{u()};return window.addEventListener("mic-device-change",m),()=>window.removeEventListener("mic-device-change",m)},[u]);const d=async m=>{var S;const x=m.target.value,g=x===""?null:x,b=g?((S=n.find(E=>E.deviceId===g))==null?void 0:S.label)??null:null;o(g),h(b);try{await window.api.voice.setDevicePref({selectedDeviceId:g,selectedLabel:b}),dt.info("voice","device-picker selected",{deviceIdPrefix:g?g.slice(0,8):null})}catch(E){dt.warn("voice","setDevicePref failed",{error:E instanceof Error?E.message:String(E)})}if(e)try{await Tt.getState().restartWithDevice()}catch(E){dt.warn("voice","device-picker restart failed",{error:E instanceof Error?E.message:String(E)})}};return s.jsxs("select",{value:i??"",onChange:d,onFocus:()=>{u()},title:"Microphone input device","data-testid":"mic-device-picker",className:"text-[10px] bg-bg border border-line text-fg-dim hover:text-fg rounded px-1.5 py-1 max-w-[8rem] truncate",children:[s.jsx("option",{value:"",children:"Default"}),n.map(m=>s.jsx("option",{value:m.deviceId,children:m.label||`Mic ${m.deviceId.slice(0,6)}`},m.deviceId))]})}function SO(){const e=Tt(S=>S.isRecording),n=Tt(S=>S.levelMeterEnabled),[r,i]=L.useState(0),[o,l]=L.useState(0),h=L.useRef(0);h.current=o;const[u,d]=L.useState(0),[m,x]=L.useState(!1),g=L.useRef(null);if(L.useEffect(()=>{if(!e||!n){i(0),l(0);return}let S=0,E=!1,C=null,y=null;const v=()=>{if(E)return;const j=y??D2();if(!j){S=requestAnimationFrame(v);return}y!==j&&(y=j,C=new Uint8Array(new ArrayBuffer(j.fftSize)));const T=C;j.getByteTimeDomainData(T);let A=0;for(let z=0;z<T.length;z++){const U=T[z]-128;A+=U*U}const M=Math.sqrt(A/T.length)/128,O=M>0?20*Math.log10(M):-60,I=Math.max(0,Math.min(1,(O+60)/60));l(M),i(I),M>=.95&&(x(!0),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>x(!1),150)),S=requestAnimationFrame(v)};S=requestAnimationFrame(v);const _=setInterval(()=>{E||d(Math.round(h.current*100))},250);return()=>{E=!0,cancelAnimationFrame(S),clearInterval(_),g.current&&(clearTimeout(g.current),g.current=null)}},[e,n]),!e||!n)return null;const b=m?"bg-red-500":o>=.7?"bg-amber-400":"bg-green-500";return s.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":u,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${m?"ring-1 ring-red-500":""}`,children:s.jsx("div",{className:`h-full ${b} transition-[width] duration-75 ease-out`,style:{width:`${r*100}%`}})})}function CO({open:e,onClose:n,variant:r="overlay"}){return s.jsx(_O,{open:e,onClose:n,title:"Voice / Microphone",variant:r,children:s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx(TO,{}),s.jsx(kC,{}),s.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[s.jsx(L2,{}),s.jsx(aj,{}),s.jsx(PT,{})]}),s.jsx(jO,{}),s.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[s.jsx("button",{type:"button",onClick:()=>Tt.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),s.jsx(NO,{})]}),s.jsx(SO,{})]})})}function jO(){const e=Tt(l=>l.isRecording),[n,r]=L.useState(null);if(L.useEffect(()=>{let l=!1;window.api.voice.getHotkeyConfig().then(u=>{l||r(u)}).catch(()=>{});const h=window.api.voice.onHotkeyConfigChanged(u=>r(u));return()=>{l=!0,h()}},[]),e||!n)return null;const i=n.mode==="hold"?"Hold":"Press",o=EO(n.accelerator);return s.jsxs("div",{className:"text-[11px] text-fg-faint",children:[s.jsxs("span",{children:[i," "]}),s.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:o}),s.jsx("span",{children:" to record"})]})}function EO(e){const n=typeof navigator<"u"&&/Mac/.test(navigator.platform);return e.replace(/CommandOrControl/g,n?"⌘":"Ctrl").replace(/CmdOrCtrl/g,n?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,n?"⌥":"Alt").replace(/Shift/g,n?"⇧":"Shift")}function NO(){const[e,n]=L.useState(null);if(L.useEffect(()=>{let i=!1;window.api.voice.getHotkeyConfig().then(l=>{i||n(l)}).catch(l=>dt.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(l)}));const o=window.api.voice.onHotkeyConfigChanged(l=>{n(l)});return()=>{i=!0,o()}},[]),!e)return null;const r=async i=>{if(e.mode===i)return;const o={...e,mode:i};n(o);try{await window.api.voice.setHotkeyConfig(o)}catch(l){dt.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:l instanceof Error?l.message:String(l)})}};return s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[s.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[s.jsx("input",{type:"radio",name:"hotkey-mode",checked:e.mode==="toggle",onChange:()=>r("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),s.jsx("span",{children:"Tap on/off"})]}),s.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[s.jsx("input",{type:"radio",name:"hotkey-mode",checked:e.mode==="hold",onChange:()=>r("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),s.jsx("span",{children:"Hold to talk"})]})]})}function TO(){const e=Tt(l=>l.isRecording),n=Tt(l=>l.lastTranscript),r=Tt(l=>l.error),i=Tt(l=>l.modelStatus),o=Tt(l=>l.loadingProgress);return r?s.jsxs("div",{className:"text-[11px] text-red-400",title:r,children:["⚠ ",r]}):e?s.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[s.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),s.jsx("span",{className:"truncate",title:n,children:n||"Listening…"})]}):i==="loading"?s.jsxs("div",{className:"text-[11px] text-fg-faint",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{children:"Loading speech model"}),s.jsxs("span",{className:"font-mono",children:[o,"%"]})]}),s.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${o}%`}})})]}):null}let ab=null;function $O(){return ab||(ab=Gm(()=>import("./monaco-editor-BW5C4Iv1.js").then(e=>e.b),__vite__mapDeps([1,2]),import.meta.url).then(e=>(n0.config({monaco:e}),e))),ab}function lj({value:e,onChange:n,path:r,readOnly:i}){const o=L.useRef(null),l=h=>{o.current=h};return s.jsx(r0,{path:`file://${r}`,defaultLanguage:"json",value:e,onChange:h=>n(h??""),onMount:l,theme:"vs",options:{minimap:{enabled:!1},fontSize:12,fontFamily:'"IBM Plex Mono", JetBrains Mono, ui-monospace, Menlo, monospace',lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,formatOnPaste:!0,readOnly:i,automaticLayout:!0,bracketPairColorization:{enabled:!0},wordWrap:"on"}})}let Nk=!1;async function AO(e){if(Nk)return;const n=await $O(),r=await Promise.all(e.map(async o=>{let l=o.schema;if(!l){const h=["https://json.schemastore.org","https://www.schemastore.org","https://code.claude.com"];try{const u=new URL(o.uri).origin;if(!h.includes(u))throw new Error("untrusted origin");const d=await fetch(o.uri);d.ok&&(l=await d.json())}catch{}}return{uri:o.uri,fileMatch:o.fileMatch,schema:l}}));n.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,allowComments:!1,schemas:r.filter(o=>o.schema),enableSchemaRequest:!0}),Nk=!0}function u0({node:e,targetScope:n,onOverride:r,schema:i,rootLabel:o}){const[l,h]=L.useState(""),[u,d]=L.useState(!0),m=[],x=e.kind==="object"&&Object.keys(e.children).length===0,b=((i==null?void 0:i.rootKeys())??[]).length>0;return s.jsxs("div",{className:"h-full flex flex-col",children:[s.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:[s.jsxs("span",{className:"text-fg-faint",children:["merged · overrides → ",s.jsx("span",{className:"text-fg-dim",children:os[n].label})]}),b&&s.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:S=>d(S.target.checked),className:"accent-accent"}),"show unset keys"]}),s.jsx("div",{className:"flex-1"}),s.jsx("input",{value:l,onChange:S=>h(S.target.value),placeholder:"filter keys or descriptions…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-56"})]}),s.jsx("div",{className:"flex-1 overflow-auto px-3 py-2 font-mono text-xs",children:x&&!u?s.jsx("div",{className:"text-fg-faint italic px-2 py-4",children:"no settings resolved — all scope files empty or missing"}):s.jsx(cj,{node:e,path:m,label:o??"(root)",targetScope:n,onOverride:r,filter:l,depth:0,schema:i,showGhosts:u,defaultOpen:!0})})]})}function cj(e){return e.node.kind==="object"?s.jsx(RO,{...e,node:e.node}):e.node.kind==="array"?s.jsx(MO,{...e,node:e.node}):s.jsx(IO,{...e,node:e.node})}function Tk(e,n){return n.trim()?e.toLowerCase().includes(n.toLowerCase()):!0}function Qh(e,n,r){return!!(!r.trim()||e.some(i=>Tk(i,r))||n!=null&&n.description&&Tk(n.description,r))}function RO({node:e,path:n,label:r,targetScope:i,onOverride:o,filter:l,depth:h,schema:u,showGhosts:d,defaultOpen:m}){const[x,g]=L.useState(m??h<2),b=(u==null?void 0:u.at(n))??null,S=new Set(Object.keys(e.children)),E=d?(b==null?void 0:b.knownChildren)??[]:[],C=Array.from(new Set([...S,...E])).sort(),y=L.useMemo(()=>l.trim()?C.filter(_=>{const j=(u==null?void 0:u.at([...n,_]))??null;return Qh([...n,_],j,l)?!0:S.has(_)?uj(e.children[_],[...n,_],l,u):!1}):C,[C.join(","),l,e,n.join("."),u]);if(l.trim()&&y.length===0&&!Qh(n,b,l))return null;if(n.length===0)return s.jsx("div",{children:y.map(_=>v(_))});return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:h*14},onClick:()=>g(!x),children:[s.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:x?"▾":"▸"}),s.jsx("span",{className:"text-fg",children:r}),s.jsxs("span",{className:"text-fg-faint",children:[" {",S.size,E.length>S.size?`/${new Set([...S,...E]).size}`:"","}"]}),(b==null?void 0:b.description)&&s.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:b.description,children:["— ",b.description]})]}),x&&y.map(_=>v(_))]});function v(_){if(S.has(_))return s.jsx(cj,{node:e.children[_],path:[...n,_],label:_,targetScope:i,onOverride:o,filter:l,depth:h+1,schema:u,showGhosts:d},_);const j=(u==null?void 0:u.at([...n,_]))??null;return j?s.jsx(PO,{path:[...n,_],label:_,info:j,targetScope:i,onSet:o,depth:h+1,filter:l},_):null}}function uj(e,n,r,i){const o=(i==null?void 0:i.at(n))??null;if(Qh(n,o,r))return!0;if(e.kind!=="object")return!1;for(const l of Object.keys(e.children))if(uj(e.children[l],[...n,l],r,i))return!0;return!1}function MO({node:e,path:n,label:r,filter:i,depth:o,schema:l}){const[h,u]=L.useState(!0),d=(l==null?void 0:l.at(n))??null;return Qh(n,d,i)?s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1 py-0.5 hover:bg-bg-elev/50 rounded cursor-pointer",style:{paddingLeft:o*14},onClick:()=>u(!h),children:[s.jsx("span",{className:"text-fg-faint w-3 shrink-0",children:h?"▾":"▸"}),s.jsx("span",{className:"text-fg",children:r}),s.jsxs("span",{className:"text-fg-faint",children:[" [",e.items.length,"]"]}),s.jsx(zm,{tone:"warn",children:"accumulated"}),(d==null?void 0:d.description)&&s.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:d.description,children:["— ",d.description]})]}),h&&e.items.map((m,x)=>s.jsxs("div",{className:"flex items-start gap-2 py-0.5",style:{paddingLeft:(o+1)*14},children:[s.jsx("span",{className:"text-fg-faint w-3 shrink-0"}),s.jsxs("span",{className:"text-fg-faint",children:[x,":"]}),s.jsx("span",{className:"text-fg-dim truncate max-w-xl",children:Ny(m.value)}),s.jsx(uw,{scope:m.fromScope})]},x))]}):null}function IO({node:e,path:n,label:r,targetScope:i,onOverride:o,filter:l,depth:h,schema:u}){const[d,m]=L.useState(!1),x=(u==null?void 0:u.at(n))??null;if(!Qh(n,x,l))return null;const g=e.winner!==i,b=e.shadowed.length>0;return s.jsxs("div",{children:[s.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded",style:{paddingLeft:h*14},children:[s.jsx("span",{className:`w-3 shrink-0 ${b?"text-fg-faint cursor-pointer":""}`,onClick:()=>b&&m(!d),children:b?d?"▾":"▸":""}),s.jsxs("span",{className:"text-fg",children:[r,":"]}),s.jsx("span",{className:"text-fg-dim truncate max-w-md",children:Ny(e.value)}),s.jsx(uw,{scope:e.winner}),(x==null?void 0:x.deprecated)&&s.jsx(zm,{tone:"warn",children:"deprecated"}),(x==null?void 0:x.default)!==void 0&&DO(e.value,x.default)&&s.jsx(zm,{tone:"dim",children:"= default"}),e.typeMismatch&&s.jsx("span",{className:"text-yellow-500/80",title:"shadowed scopes have a different value type",children:"⚠"}),(x==null?void 0:x.description)&&s.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:x.description,children:["— ",x.description]}),s.jsx("div",{className:"flex-1"}),(x==null?void 0:x.enum)&&s.jsx(dj,{values:x.enum}),s.jsx("button",{disabled:!g,onClick:()=>o(n,e.value),className:`opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border rounded transition-opacity ${g?"border-accent/50 text-accent hover:bg-accent hover:text-bg":"border-line text-fg-faint cursor-not-allowed"}`,title:g?`copy into ${os[i].label} draft`:`already winning in ${os[i].label}`,children:"override"})]}),d&&e.shadowed.map((S,E)=>s.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-fg-faint line-through",style:{paddingLeft:(h+1)*14+12},children:[s.jsx("span",{children:"shadowed:"}),s.jsx("span",{className:"truncate max-w-xl",children:Ny(S.value)}),s.jsx(uw,{scope:S.scope,dim:!0})]},E))]})}function PO({path:e,label:n,info:r,targetScope:i,onSet:o,depth:l,filter:h}){if(!Qh(e,r,h))return null;const u=r.default!==void 0?r.default:OO(r.type),d=Array.isArray(r.type)?r.type.join("|"):r.type??"?";return s.jsxs("div",{className:"group flex items-center gap-2 py-0.5 hover:bg-bg-elev/50 rounded opacity-60",style:{paddingLeft:l*14},children:[s.jsx("span",{className:"w-3 shrink-0"}),s.jsx("span",{className:"text-fg-dim",children:n}),s.jsx(zm,{tone:"dim",children:d}),r.required&&s.jsx(zm,{tone:"warn",children:"required"}),r.default!==void 0&&s.jsxs("span",{className:"text-fg-faint",children:["default: ",Ny(r.default)]}),r.description&&s.jsxs("span",{className:"text-fg-faint truncate max-w-md",title:r.description,children:["— ",r.description]}),s.jsx("div",{className:"flex-1"}),r.enum&&s.jsx(dj,{values:r.enum}),s.jsx("button",{onClick:()=>o(e,u),className:"opacity-0 group-hover:opacity-100 px-1.5 py-0 text-[10px] border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg transition-opacity",title:`write to ${os[i].label} draft`,children:"set"})]})}function DO(e,n){return e===n?!0:typeof e!=typeof n?!1:e&&n&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(n):!1}function OO(e){switch(Array.isArray(e)?e[0]:e){case"boolean":return!1;case"integer":case"number":return 0;case"string":return"";case"array":return[];case"object":return{};case"null":return null;default:return null}}function Ny(e){if(typeof e=="string")return JSON.stringify(e);if(e===null)return"null";if(typeof e=="object"){const n=JSON.stringify(e);return n.length>100?n.slice(0,100)+"…":n}return String(e)}function uw({scope:e,dim:n}){const r=e==="user"?"bg-bg-hi text-fg-dim border-line":e==="project"?"bg-blue-950/30 text-blue-400/80 border-blue-900/40":"bg-purple-950/30 text-purple-400/80 border-purple-900/40";return s.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${r} ${n?"opacity-60":""}`,children:os[e].label})}function zm({children:e,tone:n="default"}){const r={default:"bg-bg-hi text-fg-dim border-line",warn:"bg-yellow-950/30 text-yellow-500/80 border-yellow-900/40",dim:"bg-bg-elev text-fg-faint border-line"}[n];return s.jsx("span",{className:`text-[10px] px-1 py-0 rounded border uppercase tracking-wide shrink-0 ${r}`,children:e})}function dj({values:e}){const n=e.map(r=>String(r)).join(" | ");return s.jsxs("span",{className:"text-[10px] text-fg-faint truncate max-w-xs",title:`allowed: ${n}`,children:["∈ ",n.length>30?n.slice(0,30)+"…":n]})}const LO=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle","permissions"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Which model runs, how hard it thinks, and fast-mode toggles.",keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],zO={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function hj(e){return e.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((i,o)=>{const l=zO[i];return l||(o===0?i.charAt(0).toUpperCase()+i.slice(1):i)}).join(" ")}function BO(e){const n=new Set,r=[];for(const o of LO){const l=o.keys.filter(h=>e.has(h));l.forEach(h=>n.add(h)),l.length!==0&&r.push({id:o.id,title:o.title,summary:o.summary,advanced:!!o.advanced,keys:l})}const i=Array.from(e).filter(o=>!n.has(o)&&o!=="$schema").sort();return i.length>0&&r.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:i}),r}const FO=["user","project","local","default"],UO={user:"user",project:"project",local:"local",default:"default"};function HO({node:e,targetScope:n,onOverride:r,schema:i}){const[o,l]=L.useState(""),[h,u]=L.useState(!1),[d,m]=L.useState(!0),x=e.kind==="object"?e:null,g=x?Object.keys(x.children):[],b=i.rootKeys(),S=new Set([...g,...b]),E=L.useMemo(()=>BO(S),[Array.from(S).sort().join(",")]),C=L.useMemo(()=>E.filter(y=>h||!y.advanced).map(y=>({...y,keys:y.keys.filter(v=>{const _=(x==null?void 0:x.children[v])!==void 0;if(!d&&!_)return!1;if(!o.trim())return!0;const j=i.at([v]);return[v,hj(v),(j==null?void 0:j.description)??""].join(" ").toLowerCase().includes(o.toLowerCase())})})).filter(y=>y.keys.length>0),[E,o,h,d,x,i]);return s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[s.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",s.jsx("span",{className:"text-fg-dim font-medium",children:os[n].label})]}),s.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:d,onChange:y=>m(y.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),s.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:h,onChange:y=>u(y.target.checked),className:"accent-accent"}),"show advanced"]}),s.jsx("div",{className:"flex-1"}),s.jsx("input",{value:o,onChange:y=>l(y.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),s.jsxs("div",{className:"flex-1 overflow-auto",children:[C.map(y=>s.jsx(WO,{title:y.title,summary:y.summary,advanced:y.advanced,children:y.keys.map(v=>{const _=x==null?void 0:x.children[v],j=i.at([v]);return s.jsx(qO,{keyName:v,node:_,info:j,targetScope:n,onOverride:(T,A)=>r([v],T,A)},v)})},y.id)),C.length===0&&s.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',o,'"']})]})]})}function WO({title:e,summary:n,advanced:r,children:i}){const[o,l]=L.useState(!0);return s.jsxs("section",{className:"border-b border-line",children:[s.jsxs("header",{className:"px-4 py-2.5 bg-bg-elev/40 cursor-pointer hover:bg-bg-elev flex items-center gap-3",onClick:()=>l(!o),children:[s.jsx("span",{className:"text-fg-faint w-3",children:o?"▾":"▸"}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-fg text-sm font-medium",children:e}),r&&s.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),s.jsx("p",{className:"text-fg-faint text-xs",children:n})]})]}),o&&s.jsx("div",{className:"divide-y divide-line/60",children:i})]})}function qO({keyName:e,node:n,info:r,targetScope:i,onOverride:o}){const[l,h]=L.useState(!1),[u,d]=L.useState(!1),m=hj(e),x=n!==void 0,b=(n==null?void 0:n.kind)==="leaf"?n:null,S=(n==null?void 0:n.kind)==="object"||(n==null?void 0:n.kind)==="array",E=r==null?void 0:r.default,C=b&&E!==void 0&&pj(b.value,E),y=ZO({isSet:x,leafNode:b,defaultVal:E,isDefault:!!C,node:n}),v=VO(b,E),_=v.length>=2,j=!!b&&!C;return s.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>h(!l),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:l?"collapse":"expand",children:l?"▾":"▸"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-fg text-sm",children:m}),s.jsx(e5,{kind:y.kind,label:y.label}),_&&s.jsxs("button",{onClick:T=>{T.stopPropagation(),l||h(!0),d(A=>!A)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",v.map(T=>UO[T]).join(" · ")]}),j&&b&&s.jsx("button",{onClick:T=>{T.stopPropagation(),o(void 0,b.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${os[b.winner].label}`,children:"↺ reset"}),(r==null?void 0:r.deprecated)&&s.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(r==null?void 0:r.required)&&!x&&s.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),(r==null?void 0:r.description)&&s.jsx("p",{className:"text-fg-dim text-xs mt-0.5 leading-relaxed",children:t5(r.description)}),l&&u&&b&&s.jsx(GO,{leaf:b,defaultVal:E,onReset:T=>o(void 0,T)}),l&&s.jsx(KO,{keyName:e,node:n,info:r,targetScope:i,onOverride:T=>o(T)})]}),s.jsx("div",{className:"shrink-0",children:!l&&s.jsx(QO,{node:n,info:r,onSet:T=>{o(T)},disabled:S&&x})})]})})}function VO(e,n){if(!e)return[];const r=new Set;r.add(e.winner);for(const i of e.shadowed)r.add(i.scope);return n!==void 0&&r.add("default"),FO.filter(i=>r.has(i))}function GO({leaf:e,defaultVal:n,onReset:r}){const i={};i[e.winner]={value:e.value,winner:!0};for(const o of e.shadowed)i[o.scope]={value:o.value,winner:!1};return s.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[s.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),s.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(o=>{const l=i[o],h=l!==void 0;return s.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[s.jsx("span",{className:"text-fg-faint",children:os[o].label}),s.jsx("span",{className:`font-mono truncate ${l!=null&&l.winner?"text-accent":"text-fg-dim"}`,children:h?qh(l.value):s.jsx("span",{className:"text-fg-faint",children:"—"})}),h?s.jsx("button",{onClick:()=>r(o),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${os[o].label}`,children:"↺"}):s.jsx("span",{})]},o)}),s.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[s.jsx("span",{className:"text-fg-faint",children:"Default"}),s.jsx("span",{className:"font-mono text-fg-dim truncate",children:n!==void 0?qh(n):s.jsx("span",{className:"text-fg-faint",children:"—"})}),s.jsx("span",{})]})]})]})}function KO({keyName:e,node:n,info:r,targetScope:i,onOverride:o}){const h=(n==null?void 0:n.kind)==="leaf"?n:null;return s.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[(r==null?void 0:r.description)&&s.jsx("p",{className:"text-fg-dim leading-relaxed whitespace-pre-wrap",children:r.description}),s.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(r==null?void 0:r.type)&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Type"}),s.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(r.type)?r.type.join(" | "):r.type})]}),(r==null?void 0:r.default)!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Default"}),s.jsx("dd",{className:"text-fg-dim font-mono",children:qh(r.default)})]}),(r==null?void 0:r.enum)&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Options"}),s.jsx("dd",{className:"text-fg-dim font-mono",children:r.enum.map(u=>String(u)).join(" | ")})]}),h&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Current"}),s.jsxs("dd",{className:"font-mono",children:[s.jsx("span",{className:"text-fg-dim",children:qh(h.value)}),s.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",os[h.winner].label]})]})]}),h&&h.shadowed.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Shadowed"}),s.jsx("dd",{className:"space-y-0.5",children:h.shadowed.map((u,d)=>s.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[qh(u.value)," —"," ",s.jsx("span",{className:"no-underline",children:os[u.scope].label})]},d))})]}),(n==null?void 0:n.kind)==="array"&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Accumulated"}),s.jsxs("dd",{className:"text-fg-dim",children:[n.items.length," items across all scopes"]})]})]}),s.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:s.jsx(XO,{keyName:e,node:n,info:r,onChange:o,targetScope:i})})]})}function XO({node:e,info:n,onChange:r,targetScope:i}){const l=(e==null?void 0:e.kind)==="leaf"?e.value:n==null?void 0:n.default,h=fj(n==null?void 0:n.type);if(h==="boolean"){const u=l===!0;return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-faint",children:"Set to:"}),s.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:d,label:m})=>s.jsx("button",{onClick:()=>r(d),className:`px-3 py-0.5 text-xs transition-colors ${u===d?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:m},m))}),s.jsxs("span",{className:"text-fg-faint",children:["→ ",os[i].label]})]})}return n!=null&&n.enum?s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-fg-faint",children:"Choose:"}),n.enum.map(u=>{const d=pj(l,u);return s.jsx("button",{onClick:()=>r(u),className:`px-2 py-0.5 text-xs rounded border ${d?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(u)},String(u))}),s.jsxs("span",{className:"text-fg-faint",children:["→ ",os[i].label]})]}):h==="integer"||h==="number"?s.jsx(YO,{value:typeof l=="number"?l:void 0,integer:h==="integer",onCommit:r,target:os[i].label}):h==="string"?s.jsx(JO,{value:typeof l=="string"?l:"",onCommit:r,target:os[i].label}):s.jsxs("div",{className:"text-fg-faint",children:["Complex value (",h??"object/array",") — use the"," ",s.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function YO({value:e,integer:n,onCommit:r,target:i}){const[o,l]=L.useState(e!==void 0?String(e):""),h=()=>{const u=n?parseInt(o,10):parseFloat(o);Number.isNaN(u)||r(u)};return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-faint",children:"Set to:"}),s.jsx("input",{type:"number",value:o,onChange:u=>l(u.target.value),onBlur:h,onKeyDown:u=>{u.key==="Enter"&&u.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),s.jsxs("button",{onClick:h,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",i]})]})}function JO({value:e,onCommit:n,target:r}){const[i,o]=L.useState(e);return s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),s.jsx("input",{type:"text",value:i,onChange:l=>o(l.target.value),onKeyDown:l=>{l.key==="Enter"&&n(i)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),s.jsxs("button",{onClick:()=>n(i),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",r]})]})}function QO({node:e,info:n,onSet:r,disabled:i}){const o=(e==null?void 0:e.kind)==="leaf",l=fj(n==null?void 0:n.type);if(i)return null;if(l==="boolean"){const h=o&&e.value===!0;return s.jsx("button",{onClick:()=>r(!h),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${h?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:h?"on":"off"})}return null}function ZO({isSet:e,leafNode:n,defaultVal:r,isDefault:i,node:o}){return e?(o==null?void 0:o.kind)==="array"?{kind:"accumulated",label:`${o.items.length} items`}:(o==null?void 0:o.kind)==="object"?{kind:"set",label:"configured"}:n?i?{kind:"default",label:`= default · ${os[n.winner].label}`}:n.shadowed.length>0?{kind:"override",label:`overriding ${n.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${os[n.winner].label}`}:{kind:"set",label:"configured"}:r!==void 0?{kind:"default",label:`using default: ${qh(r)}`}:{kind:"unset",label:"not configured"}}function e5({kind:e,label:n}){const r={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[e];return s.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${r}`,children:n})}function fj(e){if(e)return Array.isArray(e)?e.find(r=>r!=="null")??e[0]:e}function pj(e,n){return e===n?!0:typeof e!=typeof n?!1:e&&n&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(n):!1}function t5(e){const n=e.trim().split(`
3386
3386
  `)[0],r=n.match(/^([^.!?]+[.!?])/);return r?r[1]:n.length>120?n.slice(0,120)+"…":n}function qh(e){if(typeof e=="string")return e===""?'""':JSON.stringify(e);if(e===null)return"null";if(e===void 0)return"—";if(typeof e=="object"){const n=JSON.stringify(e);return n.length>60?n.slice(0,60)+"…":n}return String(e)}function d0(e,n,r){const i=tn(d=>d.files),o=tn(d=>d.loadJson),l=tn(d=>d.watchFile),h=tn(d=>d.unwatchFile),u=L.useMemo(()=>{const d={};for(const m of e.scopes){const x=e.resolve(m,n??"",r);x&&(d[m]=x)}return d},[e,n,r]);return L.useEffect(()=>{const d=Object.values(u).filter(Boolean);return d.forEach(m=>{i[m]||o(m),l(m)}),()=>{d.forEach(m=>h(m))}},[JSON.stringify(u)]),u}const n5=[];function $x(e){return Array.isArray(e)?"array":e!==null&&typeof e=="object"?"object":"scalar"}function h0(e){const n=e.filter(r=>r.data!==void 0);return n.length===0?{kind:"object",children:{}}:mj(n,[])}function mj(e,n){const r=n5.includes(n.join(".")),i=e.every(x=>$x(x.data)==="object"),o=e.every(x=>$x(x.data)==="array");if(i){const x=new Set;for(const b of e)for(const S of Object.keys(b.data))x.add(S);const g={};for(const b of x){const S=e.filter(E=>b in E.data).map(E=>({scope:E.scope,data:E.data[b]}));g[b]=mj(S,[...n,b])}return{kind:"object",children:g}}if(o&&!r){const x=[];for(const g of[...e].reverse())for(const b of g.data)x.push({value:b,fromScope:g.scope,index:x.length});return{kind:"array",items:x}}const l=[...e].reverse(),h=l[0],u=l.slice(1).map(x=>({scope:x.scope,value:x.data})),d=$x(h.data),m=u.some(x=>$x(x.value)!==d);return{kind:"leaf",value:h.data,winner:h.scope,shadowed:u,...m?{typeMismatch:!0}:{}}}function f0(e,n){if(n.length===0)return e;if(e.kind!=="object")return null;const[r,...i]=n,o=e.children[r];return o?f0(o,i):null}function nv(e,n,r){if(n.length===0)return r;const[i,...o]=n,l=e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{};return l[i]=nv(l[i],o,r),l}const r5=["user","project","local"];function p0(e,n){const r=[];for(const i of r5){const o=n[i];if(!o)continue;const l=e[o];if(!l||!l.exists)continue;const h=l.draftRaw??"";if(h.trim())try{r.push({scope:i,data:JSON.parse(h)})}catch{}}return r}const s5="http://json-schema.org/draft-07/schema#",i5="https://json.schemastore.org/claude-code-settings.json",o5={permissionRule:{type:"string",description:`Tool permission rule.
3387
3387
  See https://code.claude.com/docs/en/settings#permission-rule-syntax
3388
3388
  See https://code.claude.com/docs/en/settings#tools-available-to-claude for full list of tools available to Claude.`,pattern:"^((Agent|Bash|Edit|ExitPlanMode|Glob|Grep|KillShell|LSP|NotebookEdit|Read|Skill|TaskCreate|TaskGet|TaskList|TaskOutput|TaskStop|TaskUpdate|TodoWrite|ToolSearch|WebFetch|WebSearch|Write)(\\((?=.*[^)*?])[^)]+\\))?|mcp__.*)$",examples:["Bash","Bash(npm run build)","Bash(git commit *)","Bash(npm run *)","Bash(ls*)","Bash(git * main)","Edit","Edit(/src/**/*.ts)","Read(./.env)","Read(./secrets/**)","Read(//Users/alice/secrets/**)","Read(~/Documents/*.pdf)","Agent(Explore)","WebFetch","WebFetch(domain:example.com)","mcp__puppeteer","mcp__github__search_repositories"]},hookCommand:{anyOf:[{type:"object",description:"Bash command hook",additionalProperties:!1,required:["type","command"],properties:{type:{type:"string",description:"Hook type",const:"command"},command:{type:"string",description:"Shell command to execute",minLength:1},timeout:{type:"number",description:"Optional timeout in seconds",exclusiveMinimum:0},async:{type:"boolean",description:"Run this hook asynchronously without blocking Claude Code"},statusMessage:{type:"string",description:"Custom spinner message displayed while the hook runs"}}},{type:"object",description:"LLM prompt hook. See https://code.claude.com/docs/en/hooks#prompt-based-hooks",additionalProperties:!1,required:["type","prompt"],properties:{type:{type:"string",description:"Hook type",const:"prompt"},prompt:{type:"string",description:"Prompt to evaluate with LLM. Use $ARGUMENTS placeholder for hook input JSON.",minLength:1},model:{type:"string",description:"Model to use for evaluation. Defaults to a fast model"},timeout:{type:"number",description:"Optional timeout in seconds (default: 30)",exclusiveMinimum:0},statusMessage:{type:"string",description:"Custom spinner message displayed while the hook runs"}}},{type:"object",description:"Agent hook with multi-turn tool access for verification. See https://code.claude.com/docs/en/hooks#agent-based-hooks",additionalProperties:!1,required:["type","prompt"],properties:{type:{type:"string",description:"Hook type",const:"agent"},prompt:{type:"string",description:"Prompt describing what to verify. Use $ARGUMENTS placeholder for hook input JSON.",minLength:1},model:{type:"string",description:"Model to use for evaluation. Defaults to a fast model"},timeout:{type:"number",description:"Optional timeout in seconds (default: 60)",exclusiveMinimum:0},statusMessage:{type:"string",description:"Custom spinner message displayed while the hook runs"}}},{type:"object",description:"HTTP webhook hook. POST JSON to a URL and receive JSON response. See https://code.claude.com/docs/en/hooks#http-hooks",additionalProperties:!1,required:["type","url"],properties:{type:{type:"string",description:"Hook type",const:"http"},url:{type:"string",description:"URL to POST hook input JSON to. Endpoint must accept POST requests and return JSON.",minLength:1},headers:{type:"object",additionalProperties:{type:"string"},description:"Custom HTTP headers (e.g., Authorization: Bearer token). Values support $VAR_NAME or ${VAR_NAME} interpolation."},allowedEnvVars:{type:"array",items:{type:"string",minLength:1},description:"List of environment variable names permitted for interpolation in headers. If not set, no env var interpolation is allowed."},timeout:{type:"number",description:"Optional timeout in seconds (default: 30)",exclusiveMinimum:0},statusMessage:{type:"string",description:"Custom spinner message displayed while the hook runs"}}}]},hookMatcher:{type:"object",description:"Hook matcher configuration with multiple hooks",additionalProperties:!1,required:["hooks"],properties:{matcher:{type:"string",description:"Optional pattern to match event contexts, case-sensitive. Behavior depends on event type. See https://code.claude.com/docs/en/hooks#matcher-patterns for event-specific details and examples"},hooks:{type:"array",description:"Array of hooks to execute",items:{$ref:"#/$defs/hookCommand"}}}}},a5="Configuration settings for Claude Code. Learn more: https://code.claude.com/docs/en/settings",l5=!0,c5=!0,u5="object",d5=JSON.parse(`{"$schema":{"type":"string","description":"JSON Schema reference for Claude Code settings"},"apiKeyHelper":{"type":"string","description":"Path to a script that outputs authentication values","examples":["/bin/generate_temp_api_key.sh"],"minLength":1},"autoMemoryEnabled":{"type":"boolean","description":"Enable automatic memory saves that capture useful context to .claude/memory/. Also configurable via CLAUDE_CODE_DISABLE_AUTO_MEMORY environment variable (set to 1 to disable, 0 to enable). See https://code.claude.com/docs/en/memory#auto-memory","default":true},"autoUpdatesChannel":{"type":"string","enum":["stable","latest"],"description":"Release channel to follow for updates. Use \\"stable\\" for a version that is typically about one week old and skips versions with major regressions, or \\"latest\\" (default) for the most recent release. Set DISABLE_AUTOUPDATER=1 to disable updates entirely.","default":"latest"},"awsCredentialExport":{"type":"string","description":"Path to a script that exports AWS credentials","examples":["/bin/generate_aws_grant.sh"],"minLength":1},"awsAuthRefresh":{"type":"string","description":"Path to a script that refreshes AWS authentication","examples":["aws sso login --profile myprofile"],"minLength":1},"claudeMdExcludes":{"type":"array","items":{"type":"string","minLength":1},"description":"Glob patterns for CLAUDE.md files to exclude from loading. Useful in monorepos to skip irrelevant instructions from other teams. Patterns match against absolute file paths. Arrays merge across settings layers. Managed policy CLAUDE.md files cannot be excluded. See https://code.claude.com/docs/en/memory#exclude-specific-claudemd-files","examples":[["**/monorepo/CLAUDE.md","/home/user/monorepo/other-team/.claude/rules/**"]]},"cleanupPeriodDays":{"type":"integer","minimum":0,"description":"Number of days to retain chat transcripts (0 to disable cleanup)","examples":[20,30,60],"default":30},"env":{"type":"object","additionalProperties":false,"description":"Environment variables to set for Claude Code sessions. Many environment variables provide settings dimensions not available as dedicated settings.json properties (e.g., thinking tokens, prompt caching, bash timeouts, shell configuration). See https://code.claude.com/docs/en/settings#environment-variables for the full list.\\nUNDOCUMENTED: CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS (plugin marketplace git timeout in ms, default 120000, see https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#2151).\\nUNDOCUMENTED: ENABLE_CLAUDEAI_MCP_SERVERS (set to false to opt out of claude.ai MCP servers, see https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#2163).","examples":[{"ANTHROPIC_MODEL":"claude-opus-4-1","ANTHROPIC_SMALL_FAST_MODEL":"claude-3-5-haiku-latest"}],"default":{},"patternProperties":{"^[A-Z_][A-Z0-9_]*$":{"type":"string","description":"Environment variable value"}}},"attribution":{"type":"object","description":"Customize attribution for git commits and pull requests. See https://code.claude.com/docs/en/settings#attribution-settings","additionalProperties":false,"properties":{"commit":{"type":"string","description":"Attribution for git commits, including any trailers. Empty string hides commit attribution"},"pr":{"type":"string","description":"Attribution for pull request descriptions. Empty string hides pull request attribution"}}},"includeGitInstructions":{"type":"boolean","description":"Include built-in git commit and PR workflow instructions in Claude's system prompt. Also configurable via CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS environment variable (set to 1 to disable). See https://code.claude.com/docs/en/settings#available-settings","default":true},"includeCoAuthoredBy":{"type":"boolean","description":"DEPRECATED. Use 'attribution' instead. Whether to include the co-authored-by Claude byline in git commits and pull requests (default: true)","default":true},"plansDirectory":{"type":"string","description":"Customize where plan files are stored. Path is relative to project root (default: ~/.claude/plans)","default":"~/.claude/plans","examples":["./plans"]},"respectGitignore":{"type":"boolean","description":"Control whether the @ file picker respects .gitignore patterns. When true (default), files matching .gitignore patterns are excluded from suggestions","default":true},"permissions":{"type":"object","properties":{"allow":{"type":"array","items":{"$ref":"#/$defs/permissionRule"},"description":"List of permission rules for allowed operations","uniqueItems":true},"deny":{"type":"array","items":{"$ref":"#/$defs/permissionRule"},"description":"List of permission rules for denied operations","uniqueItems":true},"ask":{"type":"array","items":{"$ref":"#/$defs/permissionRule"},"description":"List of permission rules that should always prompt for confirmation","uniqueItems":true},"defaultMode":{"type":"string","enum":["acceptEdits","bypassPermissions","default","delegate","dontAsk","plan"],"description":"Default permission mode.\\n\\"default\\": prompts on first use.\\n\\"acceptEdits\\": auto-accepts file edits.\\n\\"plan\\": read-only, no modifications.\\nUNDOCUMENTED. \\"delegate\\": coordination-only for agent team leads (agent teams are experimental; enable via CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS).\\n\\"dontAsk\\": auto-denies unless pre-approved via permissions.\\n\\"bypassPermissions\\": skips all prompts (use only in isolated environments).\\nSee https://code.claude.com/docs/en/permissions"},"disableBypassPermissionsMode":{"type":"string","enum":["disable"],"description":"Disable the ability to bypass permission prompts"},"additionalDirectories":{"type":"array","items":{"type":"string","minLength":1},"description":"Additional directories to include in the permission scope","examples":[["//Users/alice/Documents","~/projects"]],"uniqueItems":true}},"additionalProperties":false,"description":"Tool usage permissions configuration.\\nSee https://code.claude.com/docs/en/permissions and https://code.claude.com/docs/en/settings#permission-settings\\nSee https://code.claude.com/docs/en/settings#tools-available-to-claude for full list of tools available to Claude.","examples":[{"allow":["Bash(git add:*)"],"ask":["Bash(gh pr create:*)","Bash(git commit:*)"],"deny":["Read(*.env)","Bash(rm:*)","Bash(curl:*)"],"defaultMode":"default"}]},"language":{"type":"string","description":"Preferred language for Claude's responses","examples":["japanese","spanish","french"]},"model":{"type":"string","enum":["opus","sonnet","haiku","default"],"description":"Override the default model used by Claude Code. Accepts a short alias (opus|sonnet|haiku) or a full model ID. For finer control, use environment variables: ANTHROPIC_MODEL (runtime override), ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, ANTHROPIC_DEFAULT_HAIKU_MODEL (per-class pinning), CLAUDE_CODE_SUBAGENT_MODEL (subagent model). See https://code.claude.com/docs/en/model-config"},"availableModels":{"type":"array","items":{"type":"string"},"description":"Restrict which models users can select. When defined at multiple settings levels (user, project, etc.), arrays are merged and deduplicated. See https://code.claude.com/docs/en/model-config#restrict-model-selection","examples":[["sonnet","haiku"]]},"modelOverrides":{"type":"object","additionalProperties":{"type":"string"},"description":"Map Anthropic model IDs to provider-specific model IDs such as Bedrock inference profile ARNs, Vertex AI version names, or Foundry deployment names. Each model picker entry uses its mapped value when calling the provider API. Unknown keys are ignored. See https://code.claude.com/docs/en/model-config#override-model-ids-per-version","examples":[{"claude-opus-4-6":"arn:aws:bedrock:us-east-2:123456789012:application-inference-profile/opus-prod"}]},"effortLevel":{"type":"string","enum":["low","medium","high"],"description":"Control Opus 4.6 adaptive reasoning effort. Lower effort is faster and cheaper for straightforward tasks, higher effort provides deeper reasoning. Defaults vary by model and plan (Opus 4.6 defaults to medium for Max and Team subscribers). Use /effort auto to reset to model default. Also configurable via CLAUDE_CODE_EFFORT_LEVEL environment variable. See https://code.claude.com/docs/en/model-config#adjust-effort-level"},"fastMode":{"type":"boolean","description":"Enable fast mode for Opus 4.6 (research preview). Fast mode uses the same model with 2.5x faster output at higher per-token cost. Requires extra usage enabled. Alternatively, toggle with /fast command. See https://code.claude.com/docs/en/fast-mode","default":false},"fastModePerSessionOptIn":{"type":"boolean","description":"Require per-session opt-in for fast mode. When true, fast mode does not persist across sessions and users must enable it with /fast each session. Useful for controlling costs. See https://code.claude.com/docs/en/fast-mode","default":false},"feedbackSurveyRate":{"type":"number","minimum":0,"maximum":1,"description":"Probability (0–1) that the session quality survey appears when eligible. A value of 0.05 means 5% of eligible sessions. See https://code.claude.com/docs/en/settings","examples":[0.05]},"editorMode":{"type":"string","enum":["normal","vim"],"default":"normal","description":"Editor input mode for the Claude Code terminal prompt. 'vim' enables modal editing (Esc for normal mode, i for insert). See https://code.claude.com/docs/en/settings"},"skillOverrides":{"type":"object","additionalProperties":{"type":"string","enum":["on","name-only","user-invocable-only","off"]},"description":"Per-skill availability override map. Keys are skill names; values are one of 'on' (default), 'name-only' (skill name listed but not auto-loaded), 'user-invocable-only' (load only when user explicitly invokes), or 'off' (hidden). Requires Claude Code v2.1.129+. See https://code.claude.com/docs/en/settings","examples":[{"playwright-debug":"user-invocable-only","init":"off"}]},"disableAgentView":{"type":"boolean","default":false,"description":"Disable the Agent View feature (read-only inspection of sub-agent activity). Useful when administering managed deployments. Requires Claude Code v2.1.139+. See https://code.claude.com/docs/en/settings"},"disableRemoteControl":{"type":"boolean","default":false,"description":"Block the \`claude remote-control\` channel that allows external clients to drive this Claude Code instance. Recommended default for shared/CI environments. Requires Claude Code v2.1.128+. See https://code.claude.com/docs/en/settings"},"enableAllProjectMcpServers":{"type":"boolean","description":"Whether to automatically approve all MCP servers in the project. See https://code.claude.com/docs/en/mcp","examples":[true]},"enabledMcpjsonServers":{"type":"array","items":{"type":"string","minLength":1},"description":"List of approved MCP servers from .mcp.json. See https://code.claude.com/docs/en/mcp","examples":[["memory","github"]]},"disabledMcpjsonServers":{"type":"array","items":{"type":"string","minLength":1},"description":"List of rejected MCP servers from .mcp.json. See https://code.claude.com/docs/en/mcp","examples":[["filesystem"]]},"allowedMcpServers":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"serverName":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"Name of the MCP server that users are allowed to configure"}},"required":["serverName"],"additionalProperties":false},{"type":"object","properties":{"serverCommand":{"type":"array","items":{"type":"string"},"description":"Exact command and arguments used to start stdio servers"}},"required":["serverCommand"],"additionalProperties":false},{"type":"object","properties":{"serverUrl":{"type":"string","description":"URL pattern for remote servers, supports wildcards (e.g., https://*.example.com/*)"}},"required":["serverUrl"],"additionalProperties":false}]},"description":"Enterprise allowlist of MCP servers that can be used. Applies to all scopes including enterprise servers from managed-mcp.json. If undefined, all servers are allowed. If empty array, no servers are allowed. Denylist takes precedence - if a server is on both lists, it is denied. See https://code.claude.com/docs/en/mcp#restriction-options"},"deniedMcpServers":{"type":"array","items":{"anyOf":[{"type":"object","properties":{"serverName":{"type":"string","pattern":"^[a-zA-Z0-9_-]+$","description":"Name of the MCP server that is explicitly blocked"}},"required":["serverName"],"additionalProperties":false},{"type":"object","properties":{"serverCommand":{"type":"array","items":{"type":"string"},"description":"Exact command and arguments used to start stdio servers"}},"required":["serverCommand"],"additionalProperties":false},{"type":"object","properties":{"serverUrl":{"type":"string","description":"URL pattern for remote servers, supports wildcards (e.g., https://*.example.com/*)"}},"required":["serverUrl"],"additionalProperties":false}]},"description":"Enterprise denylist of MCP servers that are explicitly blocked. If a server is on the denylist, it will be blocked across all scopes including enterprise. Denylist takes precedence over allowlist - if a server is on both lists, it is denied. See https://code.claude.com/docs/en/mcp#restriction-options"},"httpHookAllowedEnvVars":{"type":"array","items":{"type":"string","minLength":1},"description":"Allowlist of environment variable names HTTP hooks may interpolate into headers. When set, each hook's effective allowedEnvVars is the intersection with this list. Undefined = no restriction. Arrays merge across settings sources. See https://code.claude.com/docs/en/settings#hook-configuration","examples":[["MY_TOKEN","HOOK_SECRET"]]},"hooks":{"type":"object","additionalProperties":false,"description":"Custom commands to run before/after tool executions. See https://code.claude.com/docs/en/hooks","examples":[{"PostToolUse":[{"matcher":"Edit|Write","hooks":[{"type":"command","command":"prettier --write","timeout":5}]}]}],"properties":{"PreToolUse":{"type":"array","description":"Hooks that run before tool calls","items":{"$ref":"#/$defs/hookMatcher"}},"PostToolUse":{"type":"array","description":"Hooks that run after tool completion","items":{"$ref":"#/$defs/hookMatcher"}},"PostToolUseFailure":{"type":"array","description":"Hooks that run after a tool fails","items":{"$ref":"#/$defs/hookMatcher"}},"PermissionRequest":{"type":"array","description":"Hooks that run when a permission dialog appears","items":{"$ref":"#/$defs/hookMatcher"}},"Notification":{"type":"array","description":"Hooks that trigger on notifications","items":{"$ref":"#/$defs/hookMatcher"}},"UserPromptSubmit":{"type":"array","description":"Hooks that run when a user submits a prompt","items":{"$ref":"#/$defs/hookMatcher"}},"Stop":{"type":"array","description":"Hooks that run when agents finish responding. Does not run on user interrupt","items":{"$ref":"#/$defs/hookMatcher"}},"SubagentStart":{"type":"array","description":"Hooks that run when a subagent is spawned","items":{"$ref":"#/$defs/hookMatcher"}},"SubagentStop":{"type":"array","description":"Hooks that run when subagents finish responding","items":{"$ref":"#/$defs/hookMatcher"}},"PreCompact":{"type":"array","description":"Hooks that run before the context is compacted","items":{"$ref":"#/$defs/hookMatcher"}},"PostCompact":{"type":"array","description":"Hooks that run after the context is compacted. See https://code.claude.com/docs/en/hooks","items":{"$ref":"#/$defs/hookMatcher"}},"Elicitation":{"type":"array","description":"Hooks that run when an MCP server requests user input during a tool call. See https://code.claude.com/docs/en/hooks","items":{"$ref":"#/$defs/hookMatcher"}},"ElicitationResult":{"type":"array","description":"Hooks that run after a user responds to an MCP elicitation, before the response is sent back to the server. See https://code.claude.com/docs/en/hooks","items":{"$ref":"#/$defs/hookMatcher"}},"TeammateIdle":{"type":"array","description":"Hooks that run when an agent team teammate is about to go idle. Exit code 2 sends feedback and keeps the teammate working. Does not support matchers. Agent teams are experimental. See https://code.claude.com/docs/en/hooks#teammateidle","items":{"$ref":"#/$defs/hookMatcher"}},"TaskCompleted":{"type":"array","description":"Hooks that run when a task is being marked as completed. Exit code 2 prevents completion and sends feedback. Does not support matchers. See https://code.claude.com/docs/en/hooks#taskcompleted","items":{"$ref":"#/$defs/hookMatcher"}},"Setup":{"type":"array","description":"UNDOCUMENTED. Hooks that run during repository initialization (--init, --init-only) or maintenance (--maintenance)","items":{"$ref":"#/$defs/hookMatcher"}},"InstructionsLoaded":{"type":"array","description":"Hooks that run when a CLAUDE.md or .claude/rules/*.md file is loaded into context. Fires at session start and when files are lazily loaded (e.g., nested traversal, path glob match). No decision control; used for audit logging and observability. Does not support matchers. See https://code.claude.com/docs/en/hooks#instructionsloaded","items":{"$ref":"#/$defs/hookMatcher"}},"ConfigChange":{"type":"array","description":"Hooks that run when settings, managed settings, or skill files change during a session. Supports matchers: user_settings, project_settings, local_settings, policy_settings, skills. Command handlers only. Exit code 2 blocks the change (except policy_settings which is audit-only). See https://code.claude.com/docs/en/hooks#configchange","items":{"$ref":"#/$defs/hookMatcher"}},"WorktreeCreate":{"type":"array","description":"Hooks that run when a worktree is created via --worktree or isolation: \\"worktree\\" in subagents. Command handlers only, no matchers. Hook must print absolute path to created worktree on stdout; non-zero exit fails creation. See https://code.claude.com/docs/en/hooks#worktreecreate","items":{"$ref":"#/$defs/hookMatcher"}},"WorktreeRemove":{"type":"array","description":"Hooks that run when a worktree is being removed at session exit or when a subagent finishes. Command handlers only, no matchers. Used for cleanup tasks; cannot block removal. See https://code.claude.com/docs/en/hooks#worktreeremove","items":{"$ref":"#/$defs/hookMatcher"}},"SessionStart":{"type":"array","description":"Hooks that run when a new session starts","items":{"$ref":"#/$defs/hookMatcher"}},"SessionEnd":{"type":"array","description":"Hooks that run when a session ends","items":{"$ref":"#/$defs/hookMatcher"}}}},"disableAllHooks":{"type":"boolean","description":"Disable all hooks and statusLine execution. When true in managed settings, user and project-level disableAllHooks cannot override it. See https://code.claude.com/docs/en/hooks#disable-or-remove-hooks"},"allowedHttpHookUrls":{"type":"array","items":{"type":"string","minLength":1},"description":"Allowlist of URL patterns that HTTP hooks may target. Supports * as a wildcard. When set, hooks with non-matching URLs are blocked. Undefined = no restriction, empty array = block all HTTP hooks. Arrays merge across settings sources. See https://code.claude.com/docs/en/settings#hook-configuration","examples":[["https://hooks.example.com/*","http://localhost:*"]]},"allowManagedHooksOnly":{"type":"boolean","description":"(Managed settings only) Prevent loading of user, project, and plugin hooks. Only allows managed hooks and SDK hooks. See https://code.claude.com/docs/en/settings#hook-configuration"},"allowManagedPermissionRulesOnly":{"type":"boolean","description":"(Managed settings only) Prevent user and project settings from defining allow, ask, or deny permission rules. Only rules in managed settings apply. See https://code.claude.com/docs/en/settings#permission-settings"},"statusLine":{"type":"object","properties":{"type":{"type":"string","description":"The type of status line handler; must be set to \\"command\\" to run a custom shell script that receives JSON session data via stdin.","const":"command"},"command":{"type":"string","description":"A shell command or path to a script that displays session information (context usage, costs, git status, etc.) by reading JSON data from stdin and writing output to stdout. See https://code.claude.com/docs/en/statusline"},"padding":{"type":"number","description":"Optional number of extra horizontal spacing characters added to the status line content; defaults to 0."}},"required":["type","command"],"additionalProperties":false,"description":"Custom status line display configuration. See https://code.claude.com/docs/en/statusline","examples":[{"type":"command","command":"~/.claude/statusline.sh"}]},"fileSuggestion":{"type":"object","properties":{"type":{"type":"string","description":"The type of file suggestion handler; must be set to \\"command\\" to execute a custom shell script that generates file suggestions for the @ file picker.","const":"command"},"command":{"type":"string","description":"Shell command to execute for file suggestions"}},"required":["type","command"],"additionalProperties":false,"description":"Configure a custom script for @ file autocomplete. See https://code.claude.com/docs/en/settings#file-suggestion-settings","examples":[{"type":"command","command":"~/.claude/file-suggestion.sh"}]},"enabledPlugins":{"type":"object","additionalProperties":{"anyOf":[{"type":"array","items":{"type":"string"}},{"type":"boolean"},{"not":{}}]},"description":"Enabled plugins using plugin-id@marketplace-id format. Example: { \\"formatter@anthropic-tools\\": true }. See https://code.claude.com/docs/en/plugins"},"extraKnownMarketplaces":{"type":"object","additionalProperties":{"type":"object","properties":{"source":{"anyOf":[{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"url"},"url":{"type":"string","format":"uri","description":"Direct URL to marketplace.json file"}},"required":["source","url"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"hostPattern"},"hostPattern":{"type":"string","description":"Git host pattern to trust for repositories in source specifications"}},"required":["source","hostPattern"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"github"},"repo":{"type":"string","description":"GitHub repository in owner/repo format"},"ref":{"type":"string","description":"Git branch or tag to use (e.g., \\"main\\", \\"v1.0.0\\"). Defaults to repository default branch."},"path":{"type":"string","description":"Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)"}},"required":["source","repo"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"git"},"url":{"type":"string","pattern":"\\\\.git$","description":"Full git repository URL"},"ref":{"type":"string","description":"Git branch or tag to use (e.g., \\"main\\", \\"v1.0.0\\"). Defaults to repository default branch."},"path":{"type":"string","description":"Path to marketplace.json within repo (defaults to .claude-plugin/marketplace.json)"}},"required":["source","url"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"npm"},"package":{"type":"string","description":"NPM package containing marketplace.json"}},"required":["source","package"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"file"},"path":{"type":"string","description":"Local file path to marketplace.json"}},"required":["source","path"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"directory"},"path":{"type":"string","description":"Local directory containing .claude-plugin/marketplace.json"}},"required":["source","path"],"additionalProperties":false}],"description":"Where to fetch the marketplace from"},"installLocation":{"type":"string","description":"Local cache path where marketplace manifest is stored (auto-generated if not provided)"}},"required":["source"],"additionalProperties":false},"description":"Additional marketplaces to make available for this repository. Typically used in repository .claude/settings.json to ensure team members have required plugin sources. See https://code.claude.com/docs/en/plugin-marketplaces"},"strictKnownMarketplaces":{"type":"array","description":"(Managed settings only) Allowlist of plugin marketplaces users can add. Undefined = no restrictions, empty array = lockdown. Uses exact matching for source specifications. See https://code.claude.com/docs/en/settings#strictknownmarketplaces","items":{"anyOf":[{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"hostPattern"},"hostPattern":{"type":"string","description":"Git host pattern to trust for repositories in source specifications"}},"required":["source","hostPattern"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"github"},"repo":{"type":"string","description":"GitHub repository in owner/repo format"},"ref":{"type":"string","description":"Git branch, tag, or SHA"},"path":{"type":"string","description":"Subdirectory path"}},"required":["source","repo"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"git"},"url":{"type":"string","description":"Full git repository URL"},"ref":{"type":"string","description":"Git branch, tag, or SHA"},"path":{"type":"string","description":"Subdirectory path"}},"required":["source","url"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"url"},"url":{"type":"string","format":"uri","description":"Direct URL to marketplace.json"},"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"HTTP headers for authenticated access"}},"required":["source","url"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"npm"},"package":{"type":"string","description":"NPM package name (supports scoped packages)"}},"required":["source","package"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"file"},"path":{"type":"string","description":"Absolute path to marketplace.json file"}},"required":["source","path"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"directory"},"path":{"type":"string","description":"Absolute path to directory containing .claude-plugin/marketplace.json"}},"required":["source","path"],"additionalProperties":false},{"type":"object","properties":{"source":{"type":"string","description":"Identifies the marketplace source type","const":"pathPattern"},"pathPattern":{"type":"string","description":"Regex pattern to match file or directory paths for marketplace sources"}},"required":["source","pathPattern"],"additionalProperties":false}]},"examples":[[{"source":"github","repo":"acme-corp/approved-plugins"},{"source":"npm","package":"@acme-corp/compliance-plugins"}]]},"skippedMarketplaces":{"type":"array","items":{"type":"string","minLength":1},"description":"List of marketplace names the user has chosen not to install when prompted"},"skippedPlugins":{"type":"array","items":{"type":"string","minLength":1},"description":"List of plugin IDs (plugin@marketplace format) the user has chosen not to install when prompted"},"forceLoginMethod":{"type":"string","enum":["claudeai","console"],"description":"Force a specific login method: \\"claudeai\\" for Claude Pro/Max, \\"console\\" for Console billing","examples":["claudeai"]},"forceLoginOrgUUID":{"type":"string","description":"Organization UUID to use for OAuth login","examples":["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"],"minLength":1},"otelHeadersHelper":{"type":"string","description":"Path to a script that outputs OpenTelemetry headers","minLength":1},"outputStyle":{"type":"string","description":"Controls the output style for assistant responses. Built-in styles: default, Explanatory, Learning. Custom styles can be added in ~/.claude/output-styles/ or .claude/output-styles/. See https://code.claude.com/docs/en/output-styles","examples":["default","Explanatory","Learning"],"minLength":1},"skipWebFetchPreflight":{"type":"boolean","description":"Skip the WebFetch blocklist check for enterprise environments with restrictive security policies"},"sandbox":{"type":"object","description":"Sandbox execution configuration. See https://code.claude.com/docs/en/sandboxing","properties":{"network":{"type":"object","description":"Configures network isolation settings for the sandboxed bash environment, including domain restrictions, Unix socket access, and custom proxy configuration.","properties":{"allowUnixSockets":{"type":"array","items":{"type":"string"},"description":"Allow Unix domain sockets for local IPC (SSH agent, Docker, etc.). Provide an array of specific paths. Defaults to blocking if not specified"},"allowLocalBinding":{"type":"boolean","description":"Allow binding to local network addresses (e.g., localhost ports). Defaults to false if not specified"},"httpProxyPort":{"type":"integer","minimum":1,"maximum":65535,"description":"HTTP proxy port to use for network filtering. If not specified, a proxy server will be started automatically"},"socksProxyPort":{"type":"integer","minimum":1,"maximum":65535,"description":"SOCKS proxy port to use for network filtering. If not specified, a proxy server will be started automatically"},"allowAllUnixSockets":{"type":"boolean","description":"Allow all Unix domain socket connections. If true, this overrides allowUnixSockets"},"allowedDomains":{"type":"array","items":{"type":"string","minLength":1},"description":"Allowlist of network domains for sandboxed commands. Supports wildcard patterns like *.example.com"},"allowManagedDomainsOnly":{"type":"boolean","description":"(Managed settings only) Only allowedDomains and WebFetch(domain:...) allow rules from managed settings are respected. User, project, local, and flag settings domains are ignored. Denied domains are still respected from all sources. Non-allowed domains are automatically blocked without user prompts."}},"additionalProperties":false},"ignoreViolations":{"type":"object","additionalProperties":{"type":"array","items":{"type":"string"},"description":"List of filesystem paths to ignore sandbox violations for when this command pattern matches"},"description":"Map of command patterns to filesystem paths to ignore violations for. Use \\"*\\" to match all commands"},"excludedCommands":{"type":"array","items":{"type":"string"},"description":"Commands that should never run in the sandbox (e.g., [\\"git\\", \\"docker\\"])"},"autoAllowBashIfSandboxed":{"type":"boolean","description":"Automatically allow bash commands without prompting when they run in the sandbox. Only applies to commands that will run sandboxed.","default":true},"enableWeakerNetworkIsolation":{"type":"boolean","description":"macOS only. Allow access to the system TLS trust service (com.apple.trustd.agent) in the sandbox. Required for Go-based tools like gh, gcloud, and terraform to verify TLS certificates when using httpProxyPort with a MITM proxy and custom CA. Reduces security by opening a potential data exfiltration path. Default: false. See https://code.claude.com/docs/en/settings#sandbox-settings","default":false},"enableWeakerNestedSandbox":{"type":"boolean","description":"Enable weaker sandbox mode for unprivileged docker environments where --proc mounting fails. This significantly reduces the strength of the sandbox and should only be used when this risk is acceptable.Default: false (secure)."},"allowUnsandboxedCommands":{"type":"boolean","description":"Allow commands to run outside the sandbox via the dangerouslyDisableSandbox parameter. When false, the dangerouslyDisableSandbox parameter is completely ignored and all commands must run sandboxed. Default: true."},"enabled":{"type":"boolean","description":"Enable sandboxed bash"},"filesystem":{"type":"object","description":"Filesystem access control for sandboxed commands. See https://code.claude.com/docs/en/sandboxing#filesystem-isolation","properties":{"allowWrite":{"type":"array","items":{"type":"string","minLength":1},"description":"Paths where subprocesses are allowed to write. Supports prefixes: // (absolute), ~/ (home directory), / (relative to settings file), ./ or no prefix (relative path)"},"denyWrite":{"type":"array","items":{"type":"string","minLength":1},"description":"Paths where subprocesses are explicitly denied write access. Takes precedence over allowWrite"},"denyRead":{"type":"array","items":{"type":"string","minLength":1},"description":"Paths where subprocesses are explicitly denied read access"},"allowRead":{"type":"array","items":{"type":"string","minLength":1},"description":"Paths to re-allow reading within denyRead regions. Takes precedence over denyRead for matching paths"},"allowManagedReadPathsOnly":{"type":"boolean","description":"When true (managed settings only), only allowRead paths from managed settings are used"}},"additionalProperties":false}},"additionalProperties":false},"spinnerVerbs":{"type":"object","description":"Customize the verbs shown in spinner progress messages","properties":{"mode":{"type":"string","enum":["append","replace"],"description":"How to combine custom verbs with default spinner verbs: 'append' adds custom verbs to the default list, 'replace' uses only custom verbs"},"verbs":{"type":"array","items":{"type":"string","minLength":1},"minItems":1,"description":"Custom verbs used in spinner progress text"}},"required":["verbs"],"additionalProperties":false},"spinnerTipsEnabled":{"type":"boolean","description":"Show tips in the spinner while Claude is working. Set to false to disable tips (default: true)","default":true},"spinnerTipsOverride":{"type":"object","description":"Customize the tips displayed in the spinner while Claude is working. See https://code.claude.com/docs/en/settings#available-settings","properties":{"excludeDefault":{"type":"boolean","description":"If true, only show custom tips. If false or absent, custom tips merge with built-in tips","default":false},"tips":{"type":"array","items":{"type":"string","minLength":1},"description":"Custom tip strings to display in the spinner","minItems":1}},"required":["tips"],"additionalProperties":false},"terminalProgressBarEnabled":{"type":"boolean","description":"Enable the terminal progress bar that shows progress in supported terminals like Windows Terminal and iTerm2 (default: true)","default":true},"showTurnDuration":{"type":"boolean","description":"Show turn duration messages after responses (e.g., \\"Cooked for 1m 6s\\"). Set to false to hide these messages (default: true)","default":true},"prefersReducedMotion":{"type":"boolean","description":"Reduce or disable UI animations (spinners, shimmer, flash effects) for accessibility","default":false},"alwaysThinkingEnabled":{"type":"boolean","description":"Enable extended thinking by default for all sessions. Typically configured via the /config command rather than editing directly. See https://code.claude.com/docs/en/common-workflows#use-extended-thinking-thinking-mode"},"companyAnnouncements":{"type":"array","items":{"type":"string","minLength":1},"description":"Company announcements to display at startup (one will be randomly selected if multiple are provided)"},"teammateMode":{"type":"string","enum":["auto","in-process","tmux"],"description":"How agent team teammates display: \\"auto\\" picks split panes in tmux or iTerm2, in-process otherwise. Agent teams are experimental and disabled by default. Enable them by adding CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS to your settings.json or environment. See https://code.claude.com/docs/en/agent-teams","default":"auto"},"worktree":{"type":"object","additionalProperties":false,"description":"Configuration for --worktree sessions. See https://code.claude.com/docs/en/settings","properties":{"sparsePaths":{"type":"array","items":{"type":"string","minLength":1},"description":"Directories to check out in each worktree via git sparse-checkout (cone mode). Only the listed paths are written to disk, which is faster in large monorepos.","examples":[["packages/my-app","shared/utils"]]}}},"pluginTrustMessage":{"type":"string","description":"(Managed settings only) Custom message appended to the plugin trust warning shown before installation. Use to provide organization-specific context about approved plugins. See https://code.claude.com/docs/en/settings#plugin-settings","minLength":1},"pluginConfigs":{"type":"object","additionalProperties":{"type":"object","properties":{"mcpServers":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"anyOf":[{"type":"string"},{"type":"number"},{"type":"boolean"},{"type":"array","items":{"type":"string"}}]}},"description":"User configuration values for MCP servers keyed by server name"}},"additionalProperties":false},"description":"Per-plugin configuration including MCP server user configs, keyed by plugin ID (plugin@marketplace format). See https://code.claude.com/docs/en/plugins"},"allowManagedMcpServersOnly":{"type":"boolean","description":"(Managed settings only) Only allowedMcpServers from managed settings are respected. deniedMcpServers still merges from all sources. Users can still add their own MCP servers, but only the admin-defined allowlist applies."},"blockedMarketplaces":{"type":"array","description":"(Managed settings only) Blocklist of marketplace sources. These exact sources are blocked from being added as marketplaces. The check happens before downloading, so blocked sources never touch the filesystem.","items":{"anyOf":[{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"url","description":"Block marketplace fetched from direct URL"},"url":{"type":"string","format":"uri","description":"Direct URL to marketplace.json file"},"headers":{"type":"object","additionalProperties":{"type":"string"},"description":"Custom HTTP headers (e.g., for authentication)"}},"required":["source","url"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"github","description":"Block marketplace from GitHub repository"},"repo":{"type":"string","description":"GitHub repository in owner/repo format"},"ref":{"type":"string","description":"Git branch or tag to use"},"path":{"type":"string","description":"Path to marketplace.json within repo"}},"required":["source","repo"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"git","description":"Block marketplace from git repository URL"},"url":{"type":"string","pattern":".*\\\\.git$","description":"Full git repository URL"},"ref":{"type":"string","description":"Git branch or tag to use"},"path":{"type":"string","description":"Path to marketplace.json within repo"}},"required":["source","url"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"npm","description":"Block marketplace from NPM package"},"package":{"type":"string","description":"NPM package containing marketplace.json"}},"required":["source","package"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"file","description":"Block marketplace from local file"},"path":{"type":"string","description":"Local file path to marketplace.json"}},"required":["source","path"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"directory","description":"Block marketplace from local directory"},"path":{"type":"string","description":"Local directory containing .claude-plugin/marketplace.json"}},"required":["source","path"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"hostPattern","description":"Block marketplace by host pattern matching"},"hostPattern":{"type":"string","description":"Regex pattern to match the host/domain extracted from any marketplace source type"}},"required":["source","hostPattern"]},{"type":"object","additionalProperties":false,"properties":{"source":{"type":"string","const":"pathPattern","description":"Block marketplace by file/directory path pattern matching"},"pathPattern":{"type":"string","description":"Regex pattern to match file or directory paths for marketplace sources"}},"required":["source","pathPattern"]}]}}}`),h5="Claude Code Settings",f5={$schema:s5,$id:i5,$defs:o5,description:a5,allowTrailingCommas:l5,additionalProperties:c5,type:u5,properties:d5,title:h5};function p5(e){const n=e??{},r={...n.$defs??{},...n.definitions??{}},i=S=>{if(!S)return{};if(!S.$ref)return h(S);const E=/^#\/(\$defs|definitions)\/(.+)$/.exec(S.$ref);if(!E)return h(S);const C=r[E[2]];return C?i({...C,...u(S)}):h(S)},o=new Set(["__proto__","constructor","prototype"]),l=S=>{if(!S)return{};const E={};for(const[C,y]of Object.entries(S))o.has(C)||(E[C]=y);return E},h=S=>{if(!S.allOf||S.allOf.length===0)return S;const E={...S};delete E.allOf;for(const C of S.allOf){const y=i(C);Object.assign(E,{properties:{...l(E.properties),...l(y.properties)},required:m5([...E.required??[],...y.required??[]])}),!E.description&&y.description&&(E.description=y.description),E.default===void 0&&y.default!==void 0&&(E.default=y.default),!E.type&&y.type&&(E.type=y.type)}return E},u=S=>{const{$ref:E,...C}=S;return C},d=(S,E)=>{let C=i(S);for(const y of E){if(!C)return null;if(/^\d+$/.test(y)){const j=Array.isArray(C.items)?C.items[Number(y)]:C.items;C=j?i(j):null;continue}const v=C.properties;if(v&&!o.has(y)&&y in v){C=i(v[y]);continue}const _=C.additionalProperties;if(_&&typeof _=="object"){C=i(_);continue}return null}return C},m=(S,E,C)=>{if(!S)return null;const y={};if(S.description&&(y.description=S.description),S.type&&(y.type=S.type),S.default!==void 0&&(y.default=S.default),S.enum&&(y.enum=S.enum),S.const!==void 0&&(y.const=S.const),S.deprecated&&(y.deprecated=!0),S.examples&&(y.examples=S.examples),S.properties&&(y.knownChildren=Object.keys(S.properties)),C&&(E!=null&&E.includes(C))&&(y.required=!0),S.items&&!Array.isArray(S.items)){const v=i(S.items),_=m(v,void 0,null);_&&(y.itemsInfo=_)}return(S.additionalProperties===!0||typeof S.additionalProperties=="object")&&(y.open=!0),y},x=S=>E=>{if(E.length===0)return m(i(S),void 0,null);const C=d(S,E.slice(0,-1));if(!C)return null;const y=E[E.length-1],v=d(C,[y]);return m(v,C.required,y)},g=S=>{const E=i(S);return Object.keys(E.properties??{})},b=S=>({at:x(S),rootKeys:()=>g(S),rootedAt:E=>{const C=d(S,E);return b(C??{})}});return b(n)}function m5(e){return Array.from(new Set(e))}let lb=null;function Ty(){return lb||(lb=p5(f5)),lb}function g5(){const[e,n]=L.useState(null),[r,i]=L.useState(null),[o,l]=L.useState(null),[h,u]=L.useState(null),[d,m]=L.useState(!1),[x,g]=L.useState(null),[b,S]=L.useState(null);if(L.useEffect(()=>{let _=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([j,T,A])=>{_||(n(j),l(j),i(T),u(A))}).catch(j=>{console.warn("[telemetry] load failed:",j==null?void 0:j.message)}),()=>{_=!0}},[]),!o||!e)return s.jsx(Vt,{title:"loading…"});const E=JSON.stringify(o)!==JSON.stringify(e),C=(_,j)=>{g(null),l({...o,[_]:j})},y=async()=>{m(!0),g(null);try{const _=await window.api.otel.setConfig(o);!_.ok&&_.error&&g(_.error),n(_.config),l(_.config),i(_.status),S(Date.now())}catch(_){g(_ instanceof Error?_.message:String(_))}finally{m(!1)}},v=()=>{g(null),l(e)};return s.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-fg text-base font-medium",children:"Telemetry — OpenTelemetry export"}),s.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),h&&s.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",s.jsx("span",{className:"font-mono",children:h})]})]}),s.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),s.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),s.jsx(_y,{checked:o.enabled,onChange:_=>C("enabled",_),label:o.enabled?"on":"off"})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),s.jsx("input",{type:"text",value:o.endpoint,onChange:_=>C("endpoint",_.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",s.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),s.jsx("textarea",{value:o.headers,onChange:_=>C("headers",_.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),s.jsx("input",{type:"text",value:o.serviceName,onChange:_=>C("serviceName",_.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),s.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-fg",children:"Include content (PII)"}),s.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",s.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),s.jsx(_y,{checked:o.includeContent,onChange:_=>C("includeContent",_),label:o.includeContent?"on":"off"})]})]}),r&&s.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[s.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",s.jsx("span",{className:r.enabled?"text-accent":"text-fg-dim",children:String(r.enabled)})]}),r.error&&s.jsxs("div",{className:"text-red-400 break-words",children:[s.jsx("span",{className:"text-fg-faint",children:"error:"})," ",r.error]}),!r.error&&r.enabled&&s.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),s.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[s.jsx("button",{onClick:y,disabled:!E||d,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:d?"saving…":"Save"}),s.jsx("button",{onClick:v,disabled:!E||d,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),x&&s.jsx("span",{className:"text-red-400 text-xs",children:x}),!x&&b&&!E&&s.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function x5(){const{model:e,setModel:n}=kN();return s.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[s.jsxs("header",{className:"space-y-1",children:[s.jsx("h2",{className:"text-fg text-base font-medium",children:"Session Manager preferences"}),s.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"Native app preferences, stored locally — not part of Claude Code's own settings."})]}),s.jsx("section",{className:"border border-line rounded p-3 space-y-3",children:s.jsxs("label",{className:"block space-y-1",children:[s.jsx("span",{className:"text-fg-dim text-xs",children:"Default model for raw sessions"}),s.jsx("select",{value:e,onChange:r=>n(r.target.value),className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs",children:Fw.map(r=>s.jsx("option",{value:r,children:r.charAt(0).toUpperCase()+r.slice(1)},r))}),s.jsx("span",{className:"text-fg-faint text-[11px]",children:"Used when opening a raw interactive session without an explicit per-launch override."})]})})]})}function y5(){const e=rr(),n=kt(A=>A.tabs),r=kt(A=>A.activeTabId),i=n.find(A=>A.id===r)??null,o=(i==null?void 0:i.cwd)??null,[l,h]=L.useState("user"),[u,d]=L.useState("effective"),m=d0(wy,e,o),x=m[l]??null,g=tn(A=>A.files),b=tn(A=>A.setDraft),S=tn(A=>A.saveJson),E=tn(A=>A.revert),[C,y]=L.useState(null),v=L.useMemo(()=>h0(p0(g,m)),[g,m]),_=(A,M,O)=>{var V;const z=m[O??l];if(!z)return;y(null);const U=((V=g[z])==null?void 0:V.draftRaw)??"";let W={};if(U.trim())try{W=JSON.parse(U)}catch{W={}}const Y=nv(W,A,M);b(z,JSON.stringify(Y,null,2)+`