tide-commander 0.53.4 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30,7 +30,7 @@ var kA=Object.defineProperty;var SA=(s,e,t)=>e in s?kA(s,e,{enumerable:!0,config
|
|
|
30
30
|
`+ie[b].replace(" at new "," at ");return l.displayName&&Ee.includes("<anonymous>")&&(Ee=Ee.replace("<anonymous>",l.displayName)),Ee}while(1<=b&&0<=k);break}}}finally{ue=!1,Error.prepareStackTrace=m}return(m=l?l.displayName||l.name:"")?Ae(m):""}function Z(l,u){switch(l.tag){case 26:case 27:case 5:return Ae(l.type);case 16:return Ae("Lazy");case 13:return l.child!==u&&u!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return le(l.type,!1);case 11:return le(l.type.render,!1);case 1:return le(l.type,!0);case 31:return Ae("Activity");default:return""}}function re(l){try{var u="",m=null;do u+=Z(l,m),m=l,l=l.return;while(l);return u}catch(b){return`
|
|
31
31
|
Error generating stack: `+b.message+`
|
|
32
32
|
`+b.stack}}var oe=Object.prototype.hasOwnProperty,_e=s.unstable_scheduleCallback,Le=s.unstable_cancelCallback,Ue=s.unstable_shouldYield,Xe=s.unstable_requestPaint,qe=s.unstable_now,Ge=s.unstable_getCurrentPriorityLevel,ee=s.unstable_ImmediatePriority,ge=s.unstable_UserBlockingPriority,Ie=s.unstable_NormalPriority,Be=s.unstable_LowPriority,ze=s.unstable_IdlePriority,mt=s.log,gt=s.unstable_setDisableYieldValue,ft=null,bt=null;function vt(l){if(typeof mt=="function"&>(l),bt&&typeof bt.setStrictMode=="function")try{bt.setStrictMode(ft,l)}catch{}}var Qe=Math.clz32?Math.clz32:it,qt=Math.log,Nt=Math.LN2;function it(l){return l>>>=0,l===0?32:31-(qt(l)/Nt|0)|0}var ye=256,se=262144,Me=4194304;function Je(l){var u=l&42;if(u!==0)return u;switch(l&-l){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return l&261888;case 262144:case 524288:case 1048576:case 2097152:return l&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return l&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return l}}function ct(l,u,m){var b=l.pendingLanes;if(b===0)return 0;var k=0,j=l.suspendedLanes,F=l.pingedLanes;l=l.warmLanes;var X=b&134217727;return X!==0?(b=X&~j,b!==0?k=Je(b):(F&=X,F!==0?k=Je(F):m||(m=X&~l,m!==0&&(k=Je(m))))):(X=b&~j,X!==0?k=Je(X):F!==0?k=Je(F):m||(m=b&~l,m!==0&&(k=Je(m)))),k===0?0:u!==0&&u!==k&&(u&j)===0&&(j=k&-k,m=u&-u,j>=m||j===32&&(m&4194048)!==0)?u:k}function wt(l,u){return(l.pendingLanes&~(l.suspendedLanes&~l.pingedLanes)&u)===0}function rs(l,u){switch(l){case 1:case 2:case 4:case 8:case 64:return u+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Vt(){var l=Me;return Me<<=1,(Me&62914560)===0&&(Me=4194304),l}function Ms(l){for(var u=[],m=0;31>m;m++)u.push(l);return u}function Se(l,u){l.pendingLanes|=u,u!==268435456&&(l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0)}function Fe(l,u,m,b,k,j){var F=l.pendingLanes;l.pendingLanes=m,l.suspendedLanes=0,l.pingedLanes=0,l.warmLanes=0,l.expiredLanes&=m,l.entangledLanes&=m,l.errorRecoveryDisabledLanes&=m,l.shellSuspendCounter=0;var X=l.entanglements,ie=l.expirationTimes,we=l.hiddenUpdates;for(m=F&~m;0<m;){var Ee=31-Qe(m),Oe=1<<Ee;X[Ee]=0,ie[Ee]=-1;var je=we[Ee];if(je!==null)for(we[Ee]=null,Ee=0;Ee<je.length;Ee++){var Te=je[Ee];Te!==null&&(Te.lane&=-536870913)}m&=~Oe}b!==0&&et(l,b,0),j!==0&&k===0&&l.tag!==0&&(l.suspendedLanes|=j&~(F&~u))}function et(l,u,m){l.pendingLanes|=u,l.suspendedLanes&=~u;var b=31-Qe(u);l.entangledLanes|=u,l.entanglements[b]=l.entanglements[b]|1073741824|m&261930}function zt(l,u){var m=l.entangledLanes|=u;for(l=l.entanglements;m;){var b=31-Qe(m),k=1<<b;k&u|l[b]&u&&(l[b]|=u),m&=~k}}function ms(l,u){var m=u&-u;return m=(m&42)!==0?1:ce(m),(m&(l.suspendedLanes|u))!==0?0:m}function ce(l){switch(l){case 2:l=1;break;case 8:l=4;break;case 32:l=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:l=128;break;case 268435456:l=134217728;break;default:l=0}return l}function Ce(l){return l&=-l,2<l?8<l?(l&134217727)!==0?32:268435456:8:2}function He(){var l=q.p;return l!==0?l:(l=window.event,l===void 0?32:Mx(l.type))}function Ve(l,u){var m=q.p;try{return q.p=l,u()}finally{q.p=m}}var Ze=Math.random().toString(36).slice(2),We="__reactFiber$"+Ze,Ye="__reactProps$"+Ze,Et="__reactContainer$"+Ze,Yt="__reactEvents$"+Ze,Es="__reactListeners$"+Ze,Qn="__reactHandles$"+Ze,Ua="__reactResources$"+Ze,zn="__reactMarker$"+Ze;function ot(l){delete l[We],delete l[Ye],delete l[Yt],delete l[Es],delete l[Qn]}function Ut(l){var u=l[We];if(u)return u;for(var m=l.parentNode;m;){if(u=m[Et]||m[We]){if(m=u.alternate,u.child!==null||m!==null&&m.child!==null)for(l=mx(l);l!==null;){if(m=l[We])return m;l=mx(l)}return u}l=m,m=l.parentNode}return null}function as(l){if(l=l[We]||l[Et]){var u=l.tag;if(u===5||u===6||u===13||u===31||u===26||u===27||u===3)return l}return null}function kn(l){var u=l.tag;if(u===5||u===26||u===27||u===6)return l.stateNode;throw Error(n(33))}function fa(l){var u=l[Ua];return u||(u=l[Ua]={hoistableStyles:new Map,hoistableScripts:new Map}),u}function bs(l){l[zn]=!0}var fr=new Set,gr={};function Jn(l,u){ga(l,u),ga(l+"Capture",u)}function ga(l,u){for(gr[l]=u,l=0;l<u.length;l++)fr.add(u[l])}var Yl=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),br={},yr={};function Xl(l){return oe.call(yr,l)?!0:oe.call(br,l)?!1:Yl.test(l)?yr[l]=!0:(br[l]=!0,!1)}function Mi(l,u,m){if(Xl(u))if(m===null)l.removeAttribute(u);else{switch(typeof m){case"undefined":case"function":case"symbol":l.removeAttribute(u);return;case"boolean":var b=u.toLowerCase().slice(0,5);if(b!=="data-"&&b!=="aria-"){l.removeAttribute(u);return}}l.setAttribute(u,""+m)}}function Ei(l,u,m){if(m===null)l.removeAttribute(u);else{switch(typeof m){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(u);return}l.setAttribute(u,""+m)}}function Sn(l,u,m,b){if(b===null)l.removeAttribute(m);else{switch(typeof b){case"undefined":case"function":case"symbol":case"boolean":l.removeAttribute(m);return}l.setAttributeNS(u,m,""+b)}}function Ks(l){switch(typeof l){case"bigint":case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function xr(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function Zl(l,u,m){var b=Object.getOwnPropertyDescriptor(l.constructor.prototype,u);if(!l.hasOwnProperty(u)&&typeof b<"u"&&typeof b.get=="function"&&typeof b.set=="function"){var k=b.get,j=b.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return k.call(this)},set:function(F){m=""+F,j.call(this,F)}}),Object.defineProperty(l,u,{enumerable:b.enumerable}),{getValue:function(){return m},setValue:function(F){m=""+F},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function po(l){if(!l._valueTracker){var u=xr(l)?"checked":"value";l._valueTracker=Zl(l,u,""+l[u])}}function vr(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var m=u.getValue(),b="";return l&&(b=xr(l)?l.checked?"true":"false":l.value),l=b,l!==m?(u.setValue(l),!0):!1}function _i(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}var Ql=/[\n"\\]/g;function Vs(l){return l.replace(Ql,function(u){return"\\"+u.charCodeAt(0).toString(16)+" "})}function fo(l,u,m,b,k,j,F,X){l.name="",F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"?l.type=F:l.removeAttribute("type"),u!=null?F==="number"?(u===0&&l.value===""||l.value!=u)&&(l.value=""+Ks(u)):l.value!==""+Ks(u)&&(l.value=""+Ks(u)):F!=="submit"&&F!=="reset"||l.removeAttribute("value"),u!=null?go(l,F,Ks(u)):m!=null?go(l,F,Ks(m)):b!=null&&l.removeAttribute("value"),k==null&&j!=null&&(l.defaultChecked=!!j),k!=null&&(l.checked=k&&typeof k!="function"&&typeof k!="symbol"),X!=null&&typeof X!="function"&&typeof X!="symbol"&&typeof X!="boolean"?l.name=""+Ks(X):l.removeAttribute("name")}function wr(l,u,m,b,k,j,F,X){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(l.type=j),u!=null||m!=null){if(!(j!=="submit"&&j!=="reset"||u!=null)){po(l);return}m=m!=null?""+Ks(m):"",u=u!=null?""+Ks(u):m,X||u===l.value||(l.value=u),l.defaultValue=u}b=b??k,b=typeof b!="function"&&typeof b!="symbol"&&!!b,l.checked=X?l.checked:!!b,l.defaultChecked=!!b,F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"&&(l.name=F),po(l)}function go(l,u,m){u==="number"&&_i(l.ownerDocument)===l||l.defaultValue===""+m||(l.defaultValue=""+m)}function ba(l,u,m,b){if(l=l.options,u){u={};for(var k=0;k<m.length;k++)u["$"+m[k]]=!0;for(m=0;m<l.length;m++)k=u.hasOwnProperty("$"+l[m].value),l[m].selected!==k&&(l[m].selected=k),k&&b&&(l[m].defaultSelected=!0)}else{for(m=""+Ks(m),u=null,k=0;k<l.length;k++){if(l[k].value===m){l[k].selected=!0,b&&(l[k].defaultSelected=!0);return}u!==null||l[k].disabled||(u=l[k])}u!==null&&(u.selected=!0)}}function ya(l,u,m){if(u!=null&&(u=""+Ks(u),u!==l.value&&(l.value=u),m==null)){l.defaultValue!==u&&(l.defaultValue=u);return}l.defaultValue=m!=null?""+Ks(m):""}function bo(l,u,m,b){if(u==null){if(b!=null){if(m!=null)throw Error(n(92));if($(b)){if(1<b.length)throw Error(n(93));b=b[0]}m=b}m==null&&(m=""),u=m}m=Ks(u),l.defaultValue=m,b=l.textContent,b===m&&b!==""&&b!==null&&(l.value=b),po(l)}function yo(l,u){if(u){var m=l.firstChild;if(m&&m===l.lastChild&&m.nodeType===3){m.nodeValue=u;return}}l.textContent=u}var b1=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function sg(l,u,m){var b=u.indexOf("--")===0;m==null||typeof m=="boolean"||m===""?b?l.setProperty(u,""):u==="float"?l.cssFloat="":l[u]="":b?l.setProperty(u,m):typeof m!="number"||m===0||b1.has(u)?u==="float"?l.cssFloat=m:l[u]=(""+m).trim():l[u]=m+"px"}function ng(l,u,m){if(u!=null&&typeof u!="object")throw Error(n(62));if(l=l.style,m!=null){for(var b in m)!m.hasOwnProperty(b)||u!=null&&u.hasOwnProperty(b)||(b.indexOf("--")===0?l.setProperty(b,""):b==="float"?l.cssFloat="":l[b]="");for(var k in u)b=u[k],u.hasOwnProperty(k)&&m[k]!==b&&sg(l,k,b)}else for(var j in u)u.hasOwnProperty(j)&&sg(l,j,u[j])}function dd(l){if(l.indexOf("-")===-1)return!1;switch(l){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 y1=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),x1=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Jl(l){return x1.test(""+l)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":l}function xa(){}var hd=null;function md(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var xo=null,vo=null;function ag(l){var u=as(l);if(u&&(l=u.stateNode)){var m=l[Ye]||null;e:switch(l=u.stateNode,u.type){case"input":if(fo(l,m.value,m.defaultValue,m.defaultValue,m.checked,m.defaultChecked,m.type,m.name),u=m.name,m.type==="radio"&&u!=null){for(m=l;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll('input[name="'+Vs(""+u)+'"][type="radio"]'),u=0;u<m.length;u++){var b=m[u];if(b!==l&&b.form===l.form){var k=b[Ye]||null;if(!k)throw Error(n(90));fo(b,k.value,k.defaultValue,k.defaultValue,k.checked,k.defaultChecked,k.type,k.name)}}for(u=0;u<m.length;u++)b=m[u],b.form===l.form&&vr(b)}break e;case"textarea":ya(l,m.value,m.defaultValue);break e;case"select":u=m.value,u!=null&&ba(l,!!m.multiple,u,!1)}}}var pd=!1;function ig(l,u,m){if(pd)return l(u,m);pd=!0;try{var b=l(u);return b}finally{if(pd=!1,(xo!==null||vo!==null)&&(Fc(),xo&&(u=xo,l=vo,vo=xo=null,ag(u),l)))for(u=0;u<l.length;u++)ag(l[u])}}function kr(l,u){var m=l.stateNode;if(m===null)return null;var b=m[Ye]||null;if(b===null)return null;m=b[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(b=!b.disabled)||(l=l.type,b=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!b;break e;default:l=!1}if(l)return null;if(m&&typeof m!="function")throw Error(n(231,u,typeof m));return m}var va=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),fd=!1;if(va)try{var Sr={};Object.defineProperty(Sr,"passive",{get:function(){fd=!0}}),window.addEventListener("test",Sr,Sr),window.removeEventListener("test",Sr,Sr)}catch{fd=!1}var Ga=null,gd=null,ec=null;function og(){if(ec)return ec;var l,u=gd,m=u.length,b,k="value"in Ga?Ga.value:Ga.textContent,j=k.length;for(l=0;l<m&&u[l]===k[l];l++);var F=m-l;for(b=1;b<=F&&u[m-b]===k[j-b];b++);return ec=k.slice(l,1<b?1-b:void 0)}function tc(l){var u=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&u===13&&(l=13)):l=u,l===10&&(l=13),32<=l||l===13?l:0}function sc(){return!0}function rg(){return!1}function Js(l){function u(m,b,k,j,F){this._reactName=m,this._targetInst=k,this.type=b,this.nativeEvent=j,this.target=F,this.currentTarget=null;for(var X in l)l.hasOwnProperty(X)&&(m=l[X],this[X]=m?m(j):j[X]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?sc:rg,this.isPropagationStopped=rg,this}return f(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=sc)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=sc)},persist:function(){},isPersistent:sc}),u}var Ri={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},nc=Js(Ri),jr=f({},Ri,{view:0,detail:0}),v1=Js(jr),bd,yd,Cr,ac=f({},jr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vd,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Cr&&(Cr&&l.type==="mousemove"?(bd=l.screenX-Cr.screenX,yd=l.screenY-Cr.screenY):yd=bd=0,Cr=l),bd)},movementY:function(l){return"movementY"in l?l.movementY:yd}}),lg=Js(ac),w1=f({},ac,{dataTransfer:0}),k1=Js(w1),S1=f({},jr,{relatedTarget:0}),xd=Js(S1),j1=f({},Ri,{animationName:0,elapsedTime:0,pseudoElement:0}),C1=Js(j1),A1=f({},Ri,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),N1=Js(A1),T1=f({},Ri,{data:0}),cg=Js(T1),M1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},E1={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"},_1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function R1(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=_1[l])?!!u[l]:!1}function vd(){return R1}var D1=f({},jr,{key:function(l){if(l.key){var u=M1[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=tc(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?E1[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vd,charCode:function(l){return l.type==="keypress"?tc(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?tc(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),L1=Js(D1),B1=f({},ac,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ug=Js(B1),O1=f({},jr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vd}),P1=Js(O1),I1=f({},Ri,{propertyName:0,elapsedTime:0,pseudoElement:0}),z1=Js(I1),F1=f({},ac,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),H1=Js(F1),$1=f({},Ri,{newState:0,oldState:0}),U1=Js($1),G1=[9,13,27,32],wd=va&&"CompositionEvent"in window,Ar=null;va&&"documentMode"in document&&(Ar=document.documentMode);var q1=va&&"TextEvent"in window&&!Ar,dg=va&&(!wd||Ar&&8<Ar&&11>=Ar),hg=" ",mg=!1;function pg(l,u){switch(l){case"keyup":return G1.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function fg(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var wo=!1;function W1(l,u){switch(l){case"compositionend":return fg(u);case"keypress":return u.which!==32?null:(mg=!0,hg);case"textInput":return l=u.data,l===hg&&mg?null:l;default:return null}}function K1(l,u){if(wo)return l==="compositionend"||!wd&&pg(l,u)?(l=og(),ec=gd=Ga=null,wo=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return dg&&u.locale!=="ko"?null:u.data;default:return null}}var V1={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 gg(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!V1[l.type]:u==="textarea"}function bg(l,u,m,b){xo?vo?vo.push(b):vo=[b]:xo=b,u=Kc(u,"onChange"),0<u.length&&(m=new nc("onChange","change",null,m,b),l.push({event:m,listeners:u}))}var Nr=null,Tr=null;function Y1(l){Jy(l,0)}function ic(l){var u=kn(l);if(vr(u))return l}function yg(l,u){if(l==="change")return u}var xg=!1;if(va){var kd;if(va){var Sd="oninput"in document;if(!Sd){var vg=document.createElement("div");vg.setAttribute("oninput","return;"),Sd=typeof vg.oninput=="function"}kd=Sd}else kd=!1;xg=kd&&(!document.documentMode||9<document.documentMode)}function wg(){Nr&&(Nr.detachEvent("onpropertychange",kg),Tr=Nr=null)}function kg(l){if(l.propertyName==="value"&&ic(Tr)){var u=[];bg(u,Tr,l,md(l)),ig(Y1,u)}}function X1(l,u,m){l==="focusin"?(wg(),Nr=u,Tr=m,Nr.attachEvent("onpropertychange",kg)):l==="focusout"&&wg()}function Z1(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return ic(Tr)}function Q1(l,u){if(l==="click")return ic(u)}function J1(l,u){if(l==="input"||l==="change")return ic(u)}function eC(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var dn=typeof Object.is=="function"?Object.is:eC;function Mr(l,u){if(dn(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var m=Object.keys(l),b=Object.keys(u);if(m.length!==b.length)return!1;for(b=0;b<m.length;b++){var k=m[b];if(!oe.call(u,k)||!dn(l[k],u[k]))return!1}return!0}function Sg(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function jg(l,u){var m=Sg(l);l=0;for(var b;m;){if(m.nodeType===3){if(b=l+m.textContent.length,l<=u&&b>=u)return{node:m,offset:u-l};l=b}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=Sg(m)}}function Cg(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?Cg(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function Ag(l){l=l!=null&&l.ownerDocument!=null&&l.ownerDocument.defaultView!=null?l.ownerDocument.defaultView:window;for(var u=_i(l.document);u instanceof l.HTMLIFrameElement;){try{var m=typeof u.contentWindow.location.href=="string"}catch{m=!1}if(m)l=u.contentWindow;else break;u=_i(l.document)}return u}function jd(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}var tC=va&&"documentMode"in document&&11>=document.documentMode,ko=null,Cd=null,Er=null,Ad=!1;function Ng(l,u,m){var b=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;Ad||ko==null||ko!==_i(b)||(b=ko,"selectionStart"in b&&jd(b)?b={start:b.selectionStart,end:b.selectionEnd}:(b=(b.ownerDocument&&b.ownerDocument.defaultView||window).getSelection(),b={anchorNode:b.anchorNode,anchorOffset:b.anchorOffset,focusNode:b.focusNode,focusOffset:b.focusOffset}),Er&&Mr(Er,b)||(Er=b,b=Kc(Cd,"onSelect"),0<b.length&&(u=new nc("onSelect","select",null,u,m),l.push({event:u,listeners:b}),u.target=ko)))}function Di(l,u){var m={};return m[l.toLowerCase()]=u.toLowerCase(),m["Webkit"+l]="webkit"+u,m["Moz"+l]="moz"+u,m}var So={animationend:Di("Animation","AnimationEnd"),animationiteration:Di("Animation","AnimationIteration"),animationstart:Di("Animation","AnimationStart"),transitionrun:Di("Transition","TransitionRun"),transitionstart:Di("Transition","TransitionStart"),transitioncancel:Di("Transition","TransitionCancel"),transitionend:Di("Transition","TransitionEnd")},Nd={},Tg={};va&&(Tg=document.createElement("div").style,"AnimationEvent"in window||(delete So.animationend.animation,delete So.animationiteration.animation,delete So.animationstart.animation),"TransitionEvent"in window||delete So.transitionend.transition);function Li(l){if(Nd[l])return Nd[l];if(!So[l])return l;var u=So[l],m;for(m in u)if(u.hasOwnProperty(m)&&m in Tg)return Nd[l]=u[m];return l}var Mg=Li("animationend"),Eg=Li("animationiteration"),_g=Li("animationstart"),sC=Li("transitionrun"),nC=Li("transitionstart"),aC=Li("transitioncancel"),Rg=Li("transitionend"),Dg=new Map,Td="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");Td.push("scrollEnd");function Fn(l,u){Dg.set(l,u),Jn(u,[l])}var oc=typeof reportError=="function"?reportError:function(l){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof l=="object"&&l!==null&&typeof l.message=="string"?String(l.message):String(l),error:l});if(!window.dispatchEvent(u))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",l);return}console.error(l)},jn=[],jo=0,Md=0;function rc(){for(var l=jo,u=Md=jo=0;u<l;){var m=jn[u];jn[u++]=null;var b=jn[u];jn[u++]=null;var k=jn[u];jn[u++]=null;var j=jn[u];if(jn[u++]=null,b!==null&&k!==null){var F=b.pending;F===null?k.next=k:(k.next=F.next,F.next=k),b.pending=k}j!==0&&Lg(m,k,j)}}function lc(l,u,m,b){jn[jo++]=l,jn[jo++]=u,jn[jo++]=m,jn[jo++]=b,Md|=b,l.lanes|=b,l=l.alternate,l!==null&&(l.lanes|=b)}function Ed(l,u,m,b){return lc(l,u,m,b),cc(l)}function Bi(l,u){return lc(l,null,null,u),cc(l)}function Lg(l,u,m){l.lanes|=m;var b=l.alternate;b!==null&&(b.lanes|=m);for(var k=!1,j=l.return;j!==null;)j.childLanes|=m,b=j.alternate,b!==null&&(b.childLanes|=m),j.tag===22&&(l=j.stateNode,l===null||l._visibility&1||(k=!0)),l=j,j=j.return;return l.tag===3?(j=l.stateNode,k&&u!==null&&(k=31-Qe(m),l=j.hiddenUpdates,b=l[k],b===null?l[k]=[u]:b.push(u),u.lane=m|536870912),j):null}function cc(l){if(50<Qr)throw Qr=0,zh=null,Error(n(185));for(var u=l.return;u!==null;)l=u,u=l.return;return l.tag===3?l.stateNode:null}var Co={};function iC(l,u,m,b){this.tag=l,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=b,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hn(l,u,m,b){return new iC(l,u,m,b)}function _d(l){return l=l.prototype,!(!l||!l.isReactComponent)}function wa(l,u){var m=l.alternate;return m===null?(m=hn(l.tag,u,l.key,l.mode),m.elementType=l.elementType,m.type=l.type,m.stateNode=l.stateNode,m.alternate=l,l.alternate=m):(m.pendingProps=u,m.type=l.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=l.flags&65011712,m.childLanes=l.childLanes,m.lanes=l.lanes,m.child=l.child,m.memoizedProps=l.memoizedProps,m.memoizedState=l.memoizedState,m.updateQueue=l.updateQueue,u=l.dependencies,m.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},m.sibling=l.sibling,m.index=l.index,m.ref=l.ref,m.refCleanup=l.refCleanup,m}function Bg(l,u){l.flags&=65011714;var m=l.alternate;return m===null?(l.childLanes=0,l.lanes=u,l.child=null,l.subtreeFlags=0,l.memoizedProps=null,l.memoizedState=null,l.updateQueue=null,l.dependencies=null,l.stateNode=null):(l.childLanes=m.childLanes,l.lanes=m.lanes,l.child=m.child,l.subtreeFlags=0,l.deletions=null,l.memoizedProps=m.memoizedProps,l.memoizedState=m.memoizedState,l.updateQueue=m.updateQueue,l.type=m.type,u=m.dependencies,l.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext}),l}function uc(l,u,m,b,k,j){var F=0;if(b=l,typeof l=="function")_d(l)&&(F=1);else if(typeof l=="string")F=uA(l,m,te.current)?26:l==="html"||l==="head"||l==="body"?27:5;else e:switch(l){case R:return l=hn(31,m,u,k),l.elementType=R,l.lanes=j,l;case w:return Oi(m.children,k,j,u);case S:F=8,k|=24;break;case C:return l=hn(12,m,u,k|2),l.elementType=C,l.lanes=j,l;case M:return l=hn(13,m,u,k),l.elementType=M,l.lanes=j,l;case E:return l=hn(19,m,u,k),l.elementType=E,l.lanes=j,l;default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case N:F=10;break e;case A:F=9;break e;case _:F=11;break e;case z:F=14;break e;case T:F=16,b=null;break e}F=29,m=Error(n(130,l===null?"null":typeof l,"")),b=null}return u=hn(F,m,u,k),u.elementType=l,u.type=b,u.lanes=j,u}function Oi(l,u,m,b){return l=hn(7,l,b,u),l.lanes=m,l}function Rd(l,u,m){return l=hn(6,l,null,u),l.lanes=m,l}function Og(l){var u=hn(18,null,null,0);return u.stateNode=l,u}function Dd(l,u,m){return u=hn(4,l.children!==null?l.children:[],l.key,u),u.lanes=m,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}var Pg=new WeakMap;function Cn(l,u){if(typeof l=="object"&&l!==null){var m=Pg.get(l);return m!==void 0?m:(u={value:l,source:u,stack:re(u)},Pg.set(l,u),u)}return{value:l,source:u,stack:re(u)}}var Ao=[],No=0,dc=null,_r=0,An=[],Nn=0,qa=null,ea=1,ta="";function ka(l,u){Ao[No++]=_r,Ao[No++]=dc,dc=l,_r=u}function Ig(l,u,m){An[Nn++]=ea,An[Nn++]=ta,An[Nn++]=qa,qa=l;var b=ea;l=ta;var k=32-Qe(b)-1;b&=~(1<<k),m+=1;var j=32-Qe(u)+k;if(30<j){var F=k-k%5;j=(b&(1<<F)-1).toString(32),b>>=F,k-=F,ea=1<<32-Qe(u)+k|m<<k|b,ta=j+l}else ea=1<<j|m<<k|b,ta=l}function Ld(l){l.return!==null&&(ka(l,1),Ig(l,1,0))}function Bd(l){for(;l===dc;)dc=Ao[--No],Ao[No]=null,_r=Ao[--No],Ao[No]=null;for(;l===qa;)qa=An[--Nn],An[Nn]=null,ta=An[--Nn],An[Nn]=null,ea=An[--Nn],An[Nn]=null}function zg(l,u){An[Nn++]=ea,An[Nn++]=ta,An[Nn++]=qa,ea=u.id,ta=u.overflow,qa=l}var Ps=null,ls=null,It=!1,Wa=null,Tn=!1,Od=Error(n(519));function Ka(l){var u=Error(n(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Rr(Cn(u,l)),Od}function Fg(l){var u=l.stateNode,m=l.type,b=l.memoizedProps;switch(u[We]=l,u[Ye]=b,m){case"dialog":Rt("cancel",u),Rt("close",u);break;case"iframe":case"object":case"embed":Rt("load",u);break;case"video":case"audio":for(m=0;m<el.length;m++)Rt(el[m],u);break;case"source":Rt("error",u);break;case"img":case"image":case"link":Rt("error",u),Rt("load",u);break;case"details":Rt("toggle",u);break;case"input":Rt("invalid",u),wr(u,b.value,b.defaultValue,b.checked,b.defaultChecked,b.type,b.name,!0);break;case"select":Rt("invalid",u);break;case"textarea":Rt("invalid",u),bo(u,b.value,b.defaultValue,b.children)}m=b.children,typeof m!="string"&&typeof m!="number"&&typeof m!="bigint"||u.textContent===""+m||b.suppressHydrationWarning===!0||nx(u.textContent,m)?(b.popover!=null&&(Rt("beforetoggle",u),Rt("toggle",u)),b.onScroll!=null&&Rt("scroll",u),b.onScrollEnd!=null&&Rt("scrollend",u),b.onClick!=null&&(u.onclick=xa),u=!0):u=!1,u||Ka(l,!0)}function Hg(l){for(Ps=l.return;Ps;)switch(Ps.tag){case 5:case 31:case 13:Tn=!1;return;case 27:case 3:Tn=!0;return;default:Ps=Ps.return}}function To(l){if(l!==Ps)return!1;if(!It)return Hg(l),It=!0,!1;var u=l.tag,m;if((m=u!==3&&u!==27)&&((m=u===5)&&(m=l.type,m=!(m!=="form"&&m!=="button")||em(l.type,l.memoizedProps)),m=!m),m&&ls&&Ka(l),Hg(l),u===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));ls=hx(l)}else if(u===31){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));ls=hx(l)}else u===27?(u=ls,ri(l.type)?(l=im,im=null,ls=l):ls=u):ls=Ps?En(l.stateNode.nextSibling):null;return!0}function Pi(){ls=Ps=null,It=!1}function Pd(){var l=Wa;return l!==null&&(nn===null?nn=l:nn.push.apply(nn,l),Wa=null),l}function Rr(l){Wa===null?Wa=[l]:Wa.push(l)}var Id=Q(null),Ii=null,Sa=null;function Va(l,u,m){H(Id,u._currentValue),u._currentValue=m}function ja(l){l._currentValue=Id.current,U(Id)}function zd(l,u,m){for(;l!==null;){var b=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,b!==null&&(b.childLanes|=u)):b!==null&&(b.childLanes&u)!==u&&(b.childLanes|=u),l===m)break;l=l.return}}function Fd(l,u,m,b){var k=l.child;for(k!==null&&(k.return=l);k!==null;){var j=k.dependencies;if(j!==null){var F=k.child;j=j.firstContext;e:for(;j!==null;){var X=j;j=k;for(var ie=0;ie<u.length;ie++)if(X.context===u[ie]){j.lanes|=m,X=j.alternate,X!==null&&(X.lanes|=m),zd(j.return,m,l),b||(F=null);break e}j=X.next}}else if(k.tag===18){if(F=k.return,F===null)throw Error(n(341));F.lanes|=m,j=F.alternate,j!==null&&(j.lanes|=m),zd(F,m,l),F=null}else F=k.child;if(F!==null)F.return=k;else for(F=k;F!==null;){if(F===l){F=null;break}if(k=F.sibling,k!==null){k.return=F.return,F=k;break}F=F.return}k=F}}function Mo(l,u,m,b){l=null;for(var k=u,j=!1;k!==null;){if(!j){if((k.flags&524288)!==0)j=!0;else if((k.flags&262144)!==0)break}if(k.tag===10){var F=k.alternate;if(F===null)throw Error(n(387));if(F=F.memoizedProps,F!==null){var X=k.type;dn(k.pendingProps.value,F.value)||(l!==null?l.push(X):l=[X])}}else if(k===he.current){if(F=k.alternate,F===null)throw Error(n(387));F.memoizedState.memoizedState!==k.memoizedState.memoizedState&&(l!==null?l.push(il):l=[il])}k=k.return}l!==null&&Fd(u,l,m,b),u.flags|=262144}function hc(l){for(l=l.firstContext;l!==null;){if(!dn(l.context._currentValue,l.memoizedValue))return!0;l=l.next}return!1}function zi(l){Ii=l,Sa=null,l=l.dependencies,l!==null&&(l.firstContext=null)}function Is(l){return $g(Ii,l)}function mc(l,u){return Ii===null&&zi(l),$g(l,u)}function $g(l,u){var m=u._currentValue;if(u={context:u,memoizedValue:m,next:null},Sa===null){if(l===null)throw Error(n(308));Sa=u,l.dependencies={lanes:0,firstContext:u},l.flags|=524288}else Sa=Sa.next=u;return m}var oC=typeof AbortController<"u"?AbortController:function(){var l=[],u=this.signal={aborted:!1,addEventListener:function(m,b){l.push(b)}};this.abort=function(){u.aborted=!0,l.forEach(function(m){return m()})}},rC=s.unstable_scheduleCallback,lC=s.unstable_NormalPriority,Ss={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Hd(){return{controller:new oC,data:new Map,refCount:0}}function Dr(l){l.refCount--,l.refCount===0&&rC(lC,function(){l.controller.abort()})}var Lr=null,$d=0,Eo=0,_o=null;function cC(l,u){if(Lr===null){var m=Lr=[];$d=0,Eo=qh(),_o={status:"pending",value:void 0,then:function(b){m.push(b)}}}return $d++,u.then(Ug,Ug),u}function Ug(){if(--$d===0&&Lr!==null){_o!==null&&(_o.status="fulfilled");var l=Lr;Lr=null,Eo=0,_o=null;for(var u=0;u<l.length;u++)(0,l[u])()}}function uC(l,u){var m=[],b={status:"pending",value:null,reason:null,then:function(k){m.push(k)}};return l.then(function(){b.status="fulfilled",b.value=u;for(var k=0;k<m.length;k++)(0,m[k])(u)},function(k){for(b.status="rejected",b.reason=k,k=0;k<m.length;k++)(0,m[k])(void 0)}),b}var Gg=L.S;L.S=function(l,u){Ny=qe(),typeof u=="object"&&u!==null&&typeof u.then=="function"&&cC(l,u),Gg!==null&&Gg(l,u)};var Fi=Q(null);function Ud(){var l=Fi.current;return l!==null?l:ts.pooledCache}function pc(l,u){u===null?H(Fi,Fi.current):H(Fi,u.pool)}function qg(){var l=Ud();return l===null?null:{parent:Ss._currentValue,pool:l}}var Ro=Error(n(460)),Gd=Error(n(474)),fc=Error(n(542)),gc={then:function(){}};function Wg(l){return l=l.status,l==="fulfilled"||l==="rejected"}function Kg(l,u,m){switch(m=l[m],m===void 0?l.push(u):m!==u&&(u.then(xa,xa),u=m),u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,Yg(l),l;default:if(typeof u.status=="string")u.then(xa,xa);else{if(l=ts,l!==null&&100<l.shellSuspendCounter)throw Error(n(482));l=u,l.status="pending",l.then(function(b){if(u.status==="pending"){var k=u;k.status="fulfilled",k.value=b}},function(b){if(u.status==="pending"){var k=u;k.status="rejected",k.reason=b}})}switch(u.status){case"fulfilled":return u.value;case"rejected":throw l=u.reason,Yg(l),l}throw $i=u,Ro}}function Hi(l){try{var u=l._init;return u(l._payload)}catch(m){throw m!==null&&typeof m=="object"&&typeof m.then=="function"?($i=m,Ro):m}}var $i=null;function Vg(){if($i===null)throw Error(n(459));var l=$i;return $i=null,l}function Yg(l){if(l===Ro||l===fc)throw Error(n(483))}var Do=null,Br=0;function bc(l){var u=Br;return Br+=1,Do===null&&(Do=[]),Kg(Do,l,u)}function Or(l,u){u=u.props.ref,l.ref=u!==void 0?u:null}function yc(l,u){throw u.$$typeof===g?Error(n(525)):(l=Object.prototype.toString.call(u),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l)))}function Xg(l){function u(be,de){if(l){var ve=be.deletions;ve===null?(be.deletions=[de],be.flags|=16):ve.push(de)}}function m(be,de){if(!l)return null;for(;de!==null;)u(be,de),de=de.sibling;return null}function b(be){for(var de=new Map;be!==null;)be.key!==null?de.set(be.key,be):de.set(be.index,be),be=be.sibling;return de}function k(be,de){return be=wa(be,de),be.index=0,be.sibling=null,be}function j(be,de,ve){return be.index=ve,l?(ve=be.alternate,ve!==null?(ve=ve.index,ve<de?(be.flags|=67108866,de):ve):(be.flags|=67108866,de)):(be.flags|=1048576,de)}function F(be){return l&&be.alternate===null&&(be.flags|=67108866),be}function X(be,de,ve,De){return de===null||de.tag!==6?(de=Rd(ve,be.mode,De),de.return=be,de):(de=k(de,ve),de.return=be,de)}function ie(be,de,ve,De){var rt=ve.type;return rt===w?Ee(be,de,ve.props.children,De,ve.key):de!==null&&(de.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===T&&Hi(rt)===de.type)?(de=k(de,ve.props),Or(de,ve),de.return=be,de):(de=uc(ve.type,ve.key,ve.props,null,be.mode,De),Or(de,ve),de.return=be,de)}function we(be,de,ve,De){return de===null||de.tag!==4||de.stateNode.containerInfo!==ve.containerInfo||de.stateNode.implementation!==ve.implementation?(de=Dd(ve,be.mode,De),de.return=be,de):(de=k(de,ve.children||[]),de.return=be,de)}function Ee(be,de,ve,De,rt){return de===null||de.tag!==7?(de=Oi(ve,be.mode,De,rt),de.return=be,de):(de=k(de,ve),de.return=be,de)}function Oe(be,de,ve){if(typeof de=="string"&&de!==""||typeof de=="number"||typeof de=="bigint")return de=Rd(""+de,be.mode,ve),de.return=be,de;if(typeof de=="object"&&de!==null){switch(de.$$typeof){case y:return ve=uc(de.type,de.key,de.props,null,be.mode,ve),Or(ve,de),ve.return=be,ve;case v:return de=Dd(de,be.mode,ve),de.return=be,de;case T:return de=Hi(de),Oe(be,de,ve)}if($(de)||P(de))return de=Oi(de,be.mode,ve,null),de.return=be,de;if(typeof de.then=="function")return Oe(be,bc(de),ve);if(de.$$typeof===N)return Oe(be,mc(be,de),ve);yc(be,de)}return null}function je(be,de,ve,De){var rt=de!==null?de.key:null;if(typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint")return rt!==null?null:X(be,de,""+ve,De);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case y:return ve.key===rt?ie(be,de,ve,De):null;case v:return ve.key===rt?we(be,de,ve,De):null;case T:return ve=Hi(ve),je(be,de,ve,De)}if($(ve)||P(ve))return rt!==null?null:Ee(be,de,ve,De,null);if(typeof ve.then=="function")return je(be,de,bc(ve),De);if(ve.$$typeof===N)return je(be,de,mc(be,ve),De);yc(be,ve)}return null}function Te(be,de,ve,De,rt){if(typeof De=="string"&&De!==""||typeof De=="number"||typeof De=="bigint")return be=be.get(ve)||null,X(de,be,""+De,rt);if(typeof De=="object"&&De!==null){switch(De.$$typeof){case y:return be=be.get(De.key===null?ve:De.key)||null,ie(de,be,De,rt);case v:return be=be.get(De.key===null?ve:De.key)||null,we(de,be,De,rt);case T:return De=Hi(De),Te(be,de,ve,De,rt)}if($(De)||P(De))return be=be.get(ve)||null,Ee(de,be,De,rt,null);if(typeof De.then=="function")return Te(be,de,ve,bc(De),rt);if(De.$$typeof===N)return Te(be,de,ve,mc(de,De),rt);yc(de,De)}return null}function tt(be,de,ve,De){for(var rt=null,Ht=null,st=de,kt=de=0,Ot=null;st!==null&&kt<ve.length;kt++){st.index>kt?(Ot=st,st=null):Ot=st.sibling;var $t=je(be,st,ve[kt],De);if($t===null){st===null&&(st=Ot);break}l&&st&&$t.alternate===null&&u(be,st),de=j($t,de,kt),Ht===null?rt=$t:Ht.sibling=$t,Ht=$t,st=Ot}if(kt===ve.length)return m(be,st),It&&ka(be,kt),rt;if(st===null){for(;kt<ve.length;kt++)st=Oe(be,ve[kt],De),st!==null&&(de=j(st,de,kt),Ht===null?rt=st:Ht.sibling=st,Ht=st);return It&&ka(be,kt),rt}for(st=b(st);kt<ve.length;kt++)Ot=Te(st,be,kt,ve[kt],De),Ot!==null&&(l&&Ot.alternate!==null&&st.delete(Ot.key===null?kt:Ot.key),de=j(Ot,de,kt),Ht===null?rt=Ot:Ht.sibling=Ot,Ht=Ot);return l&&st.forEach(function(hi){return u(be,hi)}),It&&ka(be,kt),rt}function ht(be,de,ve,De){if(ve==null)throw Error(n(151));for(var rt=null,Ht=null,st=de,kt=de=0,Ot=null,$t=ve.next();st!==null&&!$t.done;kt++,$t=ve.next()){st.index>kt?(Ot=st,st=null):Ot=st.sibling;var hi=je(be,st,$t.value,De);if(hi===null){st===null&&(st=Ot);break}l&&st&&hi.alternate===null&&u(be,st),de=j(hi,de,kt),Ht===null?rt=hi:Ht.sibling=hi,Ht=hi,st=Ot}if($t.done)return m(be,st),It&&ka(be,kt),rt;if(st===null){for(;!$t.done;kt++,$t=ve.next())$t=Oe(be,$t.value,De),$t!==null&&(de=j($t,de,kt),Ht===null?rt=$t:Ht.sibling=$t,Ht=$t);return It&&ka(be,kt),rt}for(st=b(st);!$t.done;kt++,$t=ve.next())$t=Te(st,be,kt,$t.value,De),$t!==null&&(l&&$t.alternate!==null&&st.delete($t.key===null?kt:$t.key),de=j($t,de,kt),Ht===null?rt=$t:Ht.sibling=$t,Ht=$t);return l&&st.forEach(function(wA){return u(be,wA)}),It&&ka(be,kt),rt}function Qt(be,de,ve,De){if(typeof ve=="object"&&ve!==null&&ve.type===w&&ve.key===null&&(ve=ve.props.children),typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case y:e:{for(var rt=ve.key;de!==null;){if(de.key===rt){if(rt=ve.type,rt===w){if(de.tag===7){m(be,de.sibling),De=k(de,ve.props.children),De.return=be,be=De;break e}}else if(de.elementType===rt||typeof rt=="object"&&rt!==null&&rt.$$typeof===T&&Hi(rt)===de.type){m(be,de.sibling),De=k(de,ve.props),Or(De,ve),De.return=be,be=De;break e}m(be,de);break}else u(be,de);de=de.sibling}ve.type===w?(De=Oi(ve.props.children,be.mode,De,ve.key),De.return=be,be=De):(De=uc(ve.type,ve.key,ve.props,null,be.mode,De),Or(De,ve),De.return=be,be=De)}return F(be);case v:e:{for(rt=ve.key;de!==null;){if(de.key===rt)if(de.tag===4&&de.stateNode.containerInfo===ve.containerInfo&&de.stateNode.implementation===ve.implementation){m(be,de.sibling),De=k(de,ve.children||[]),De.return=be,be=De;break e}else{m(be,de);break}else u(be,de);de=de.sibling}De=Dd(ve,be.mode,De),De.return=be,be=De}return F(be);case T:return ve=Hi(ve),Qt(be,de,ve,De)}if($(ve))return tt(be,de,ve,De);if(P(ve)){if(rt=P(ve),typeof rt!="function")throw Error(n(150));return ve=rt.call(ve),ht(be,de,ve,De)}if(typeof ve.then=="function")return Qt(be,de,bc(ve),De);if(ve.$$typeof===N)return Qt(be,de,mc(be,ve),De);yc(be,ve)}return typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint"?(ve=""+ve,de!==null&&de.tag===6?(m(be,de.sibling),De=k(de,ve),De.return=be,be=De):(m(be,de),De=Rd(ve,be.mode,De),De.return=be,be=De),F(be)):m(be,de)}return function(be,de,ve,De){try{Br=0;var rt=Qt(be,de,ve,De);return Do=null,rt}catch(st){if(st===Ro||st===fc)throw st;var Ht=hn(29,st,null,be.mode);return Ht.lanes=De,Ht.return=be,Ht}finally{}}}var Ui=Xg(!0),Zg=Xg(!1),Ya=!1;function qd(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wd(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,callbacks:null})}function Xa(l){return{lane:l,tag:0,payload:null,callback:null,next:null}}function Za(l,u,m){var b=l.updateQueue;if(b===null)return null;if(b=b.shared,(Gt&2)!==0){var k=b.pending;return k===null?u.next=u:(u.next=k.next,k.next=u),b.pending=u,u=cc(l),Lg(l,null,m),u}return lc(l,b,u,m),cc(l)}function Pr(l,u,m){if(u=u.updateQueue,u!==null&&(u=u.shared,(m&4194048)!==0)){var b=u.lanes;b&=l.pendingLanes,m|=b,u.lanes=m,zt(l,m)}}function Kd(l,u){var m=l.updateQueue,b=l.alternate;if(b!==null&&(b=b.updateQueue,m===b)){var k=null,j=null;if(m=m.firstBaseUpdate,m!==null){do{var F={lane:m.lane,tag:m.tag,payload:m.payload,callback:null,next:null};j===null?k=j=F:j=j.next=F,m=m.next}while(m!==null);j===null?k=j=u:j=j.next=u}else k=j=u;m={baseState:b.baseState,firstBaseUpdate:k,lastBaseUpdate:j,shared:b.shared,callbacks:b.callbacks},l.updateQueue=m;return}l=m.lastBaseUpdate,l===null?m.firstBaseUpdate=u:l.next=u,m.lastBaseUpdate=u}var Vd=!1;function Ir(){if(Vd){var l=_o;if(l!==null)throw l}}function zr(l,u,m,b){Vd=!1;var k=l.updateQueue;Ya=!1;var j=k.firstBaseUpdate,F=k.lastBaseUpdate,X=k.shared.pending;if(X!==null){k.shared.pending=null;var ie=X,we=ie.next;ie.next=null,F===null?j=we:F.next=we,F=ie;var Ee=l.alternate;Ee!==null&&(Ee=Ee.updateQueue,X=Ee.lastBaseUpdate,X!==F&&(X===null?Ee.firstBaseUpdate=we:X.next=we,Ee.lastBaseUpdate=ie))}if(j!==null){var Oe=k.baseState;F=0,Ee=we=ie=null,X=j;do{var je=X.lane&-536870913,Te=je!==X.lane;if(Te?(Bt&je)===je:(b&je)===je){je!==0&&je===Eo&&(Vd=!0),Ee!==null&&(Ee=Ee.next={lane:0,tag:X.tag,payload:X.payload,callback:null,next:null});e:{var tt=l,ht=X;je=u;var Qt=m;switch(ht.tag){case 1:if(tt=ht.payload,typeof tt=="function"){Oe=tt.call(Qt,Oe,je);break e}Oe=tt;break e;case 3:tt.flags=tt.flags&-65537|128;case 0:if(tt=ht.payload,je=typeof tt=="function"?tt.call(Qt,Oe,je):tt,je==null)break e;Oe=f({},Oe,je);break e;case 2:Ya=!0}}je=X.callback,je!==null&&(l.flags|=64,Te&&(l.flags|=8192),Te=k.callbacks,Te===null?k.callbacks=[je]:Te.push(je))}else Te={lane:je,tag:X.tag,payload:X.payload,callback:X.callback,next:null},Ee===null?(we=Ee=Te,ie=Oe):Ee=Ee.next=Te,F|=je;if(X=X.next,X===null){if(X=k.shared.pending,X===null)break;Te=X,X=Te.next,Te.next=null,k.lastBaseUpdate=Te,k.shared.pending=null}}while(!0);Ee===null&&(ie=Oe),k.baseState=ie,k.firstBaseUpdate=we,k.lastBaseUpdate=Ee,j===null&&(k.shared.lanes=0),si|=F,l.lanes=F,l.memoizedState=Oe}}function Qg(l,u){if(typeof l!="function")throw Error(n(191,l));l.call(u)}function Jg(l,u){var m=l.callbacks;if(m!==null)for(l.callbacks=null,l=0;l<m.length;l++)Qg(m[l],u)}var Lo=Q(null),xc=Q(0);function eb(l,u){l=Da,H(xc,l),H(Lo,u),Da=l|u.baseLanes}function Yd(){H(xc,Da),H(Lo,Lo.current)}function Xd(){Da=xc.current,U(Lo),U(xc)}var mn=Q(null),Mn=null;function Qa(l){var u=l.alternate;H(ys,ys.current&1),H(mn,l),Mn===null&&(u===null||Lo.current!==null||u.memoizedState!==null)&&(Mn=l)}function Zd(l){H(ys,ys.current),H(mn,l),Mn===null&&(Mn=l)}function tb(l){l.tag===22?(H(ys,ys.current),H(mn,l),Mn===null&&(Mn=l)):Ja()}function Ja(){H(ys,ys.current),H(mn,mn.current)}function pn(l){U(mn),Mn===l&&(Mn=null),U(ys)}var ys=Q(0);function vc(l){for(var u=l;u!==null;){if(u.tag===13){var m=u.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||nm(m)||am(m)))return u}else if(u.tag===19&&(u.memoizedProps.revealOrder==="forwards"||u.memoizedProps.revealOrder==="backwards"||u.memoizedProps.revealOrder==="unstable_legacy-backwards"||u.memoizedProps.revealOrder==="together")){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var Ca=0,yt=null,Xt=null,js=null,wc=!1,Bo=!1,Gi=!1,kc=0,Fr=0,Oo=null,dC=0;function ps(){throw Error(n(321))}function Qd(l,u){if(u===null)return!1;for(var m=0;m<u.length&&m<l.length;m++)if(!dn(l[m],u[m]))return!1;return!0}function Jd(l,u,m,b,k,j){return Ca=j,yt=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,L.H=l===null||l.memoizedState===null?Ib:ph,Gi=!1,j=m(b,k),Gi=!1,Bo&&(j=nb(u,m,b,k)),sb(l),j}function sb(l){L.H=Ur;var u=Xt!==null&&Xt.next!==null;if(Ca=0,js=Xt=yt=null,wc=!1,Fr=0,Oo=null,u)throw Error(n(300));l===null||Cs||(l=l.dependencies,l!==null&&hc(l)&&(Cs=!0))}function nb(l,u,m,b){yt=l;var k=0;do{if(Bo&&(Oo=null),Fr=0,Bo=!1,25<=k)throw Error(n(301));if(k+=1,js=Xt=null,l.updateQueue!=null){var j=l.updateQueue;j.lastEffect=null,j.events=null,j.stores=null,j.memoCache!=null&&(j.memoCache.index=0)}L.H=zb,j=u(m,b)}while(Bo);return j}function hC(){var l=L.H,u=l.useState()[0];return u=typeof u.then=="function"?Hr(u):u,l=l.useState()[0],(Xt!==null?Xt.memoizedState:null)!==l&&(yt.flags|=1024),u}function eh(){var l=kc!==0;return kc=0,l}function th(l,u,m){u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~m}function sh(l){if(wc){for(l=l.memoizedState;l!==null;){var u=l.queue;u!==null&&(u.pending=null),l=l.next}wc=!1}Ca=0,js=Xt=yt=null,Bo=!1,Fr=kc=0,Oo=null}function Ys(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return js===null?yt.memoizedState=js=l:js=js.next=l,js}function xs(){if(Xt===null){var l=yt.alternate;l=l!==null?l.memoizedState:null}else l=Xt.next;var u=js===null?yt.memoizedState:js.next;if(u!==null)js=u,Xt=l;else{if(l===null)throw yt.alternate===null?Error(n(467)):Error(n(310));Xt=l,l={memoizedState:Xt.memoizedState,baseState:Xt.baseState,baseQueue:Xt.baseQueue,queue:Xt.queue,next:null},js===null?yt.memoizedState=js=l:js=js.next=l}return js}function Sc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Hr(l){var u=Fr;return Fr+=1,Oo===null&&(Oo=[]),l=Kg(Oo,l,u),u=yt,(js===null?u.memoizedState:js.next)===null&&(u=u.alternate,L.H=u===null||u.memoizedState===null?Ib:ph),l}function jc(l){if(l!==null&&typeof l=="object"){if(typeof l.then=="function")return Hr(l);if(l.$$typeof===N)return Is(l)}throw Error(n(438,String(l)))}function nh(l){var u=null,m=yt.updateQueue;if(m!==null&&(u=m.memoCache),u==null){var b=yt.alternate;b!==null&&(b=b.updateQueue,b!==null&&(b=b.memoCache,b!=null&&(u={data:b.data.map(function(k){return k.slice()}),index:0})))}if(u==null&&(u={data:[],index:0}),m===null&&(m=Sc(),yt.updateQueue=m),m.memoCache=u,m=u.data[u.index],m===void 0)for(m=u.data[u.index]=Array(l),b=0;b<l;b++)m[b]=D;return u.index++,m}function Aa(l,u){return typeof u=="function"?u(l):u}function Cc(l){var u=xs();return ah(u,Xt,l)}function ah(l,u,m){var b=l.queue;if(b===null)throw Error(n(311));b.lastRenderedReducer=m;var k=l.baseQueue,j=b.pending;if(j!==null){if(k!==null){var F=k.next;k.next=j.next,j.next=F}u.baseQueue=k=j,b.pending=null}if(j=l.baseState,k===null)l.memoizedState=j;else{u=k.next;var X=F=null,ie=null,we=u,Ee=!1;do{var Oe=we.lane&-536870913;if(Oe!==we.lane?(Bt&Oe)===Oe:(Ca&Oe)===Oe){var je=we.revertLane;if(je===0)ie!==null&&(ie=ie.next={lane:0,revertLane:0,gesture:null,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null}),Oe===Eo&&(Ee=!0);else if((Ca&je)===je){we=we.next,je===Eo&&(Ee=!0);continue}else Oe={lane:0,revertLane:we.revertLane,gesture:null,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null},ie===null?(X=ie=Oe,F=j):ie=ie.next=Oe,yt.lanes|=je,si|=je;Oe=we.action,Gi&&m(j,Oe),j=we.hasEagerState?we.eagerState:m(j,Oe)}else je={lane:Oe,revertLane:we.revertLane,gesture:we.gesture,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null},ie===null?(X=ie=je,F=j):ie=ie.next=je,yt.lanes|=Oe,si|=Oe;we=we.next}while(we!==null&&we!==u);if(ie===null?F=j:ie.next=X,!dn(j,l.memoizedState)&&(Cs=!0,Ee&&(m=_o,m!==null)))throw m;l.memoizedState=j,l.baseState=F,l.baseQueue=ie,b.lastRenderedState=j}return k===null&&(b.lanes=0),[l.memoizedState,b.dispatch]}function ih(l){var u=xs(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=l;var b=m.dispatch,k=m.pending,j=u.memoizedState;if(k!==null){m.pending=null;var F=k=k.next;do j=l(j,F.action),F=F.next;while(F!==k);dn(j,u.memoizedState)||(Cs=!0),u.memoizedState=j,u.baseQueue===null&&(u.baseState=j),m.lastRenderedState=j}return[j,b]}function ab(l,u,m){var b=yt,k=xs(),j=It;if(j){if(m===void 0)throw Error(n(407));m=m()}else m=u();var F=!dn((Xt||k).memoizedState,m);if(F&&(k.memoizedState=m,Cs=!0),k=k.queue,lh(rb.bind(null,b,k,l),[l]),k.getSnapshot!==u||F||js!==null&&js.memoizedState.tag&1){if(b.flags|=2048,Po(9,{destroy:void 0},ob.bind(null,b,k,m,u),null),ts===null)throw Error(n(349));j||(Ca&127)!==0||ib(b,u,m)}return m}function ib(l,u,m){l.flags|=16384,l={getSnapshot:u,value:m},u=yt.updateQueue,u===null?(u=Sc(),yt.updateQueue=u,u.stores=[l]):(m=u.stores,m===null?u.stores=[l]:m.push(l))}function ob(l,u,m,b){u.value=m,u.getSnapshot=b,lb(u)&&cb(l)}function rb(l,u,m){return m(function(){lb(u)&&cb(l)})}function lb(l){var u=l.getSnapshot;l=l.value;try{var m=u();return!dn(l,m)}catch{return!0}}function cb(l){var u=Bi(l,2);u!==null&&an(u,l,2)}function oh(l){var u=Ys();if(typeof l=="function"){var m=l;if(l=m(),Gi){vt(!0);try{m()}finally{vt(!1)}}}return u.memoizedState=u.baseState=l,u.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Aa,lastRenderedState:l},u}function ub(l,u,m,b){return l.baseState=m,ah(l,Xt,typeof b=="function"?b:Aa)}function mC(l,u,m,b,k){if(Tc(l))throw Error(n(485));if(l=u.action,l!==null){var j={payload:k,action:l,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(F){j.listeners.push(F)}};L.T!==null?m(!0):j.isTransition=!1,b(j),m=u.pending,m===null?(j.next=u.pending=j,db(u,j)):(j.next=m.next,u.pending=m.next=j)}}function db(l,u){var m=u.action,b=u.payload,k=l.state;if(u.isTransition){var j=L.T,F={};L.T=F;try{var X=m(k,b),ie=L.S;ie!==null&&ie(F,X),hb(l,u,X)}catch(we){rh(l,u,we)}finally{j!==null&&F.types!==null&&(j.types=F.types),L.T=j}}else try{j=m(k,b),hb(l,u,j)}catch(we){rh(l,u,we)}}function hb(l,u,m){m!==null&&typeof m=="object"&&typeof m.then=="function"?m.then(function(b){mb(l,u,b)},function(b){return rh(l,u,b)}):mb(l,u,m)}function mb(l,u,m){u.status="fulfilled",u.value=m,pb(u),l.state=m,u=l.pending,u!==null&&(m=u.next,m===u?l.pending=null:(m=m.next,u.next=m,db(l,m)))}function rh(l,u,m){var b=l.pending;if(l.pending=null,b!==null){b=b.next;do u.status="rejected",u.reason=m,pb(u),u=u.next;while(u!==b)}l.action=null}function pb(l){l=l.listeners;for(var u=0;u<l.length;u++)(0,l[u])()}function fb(l,u){return u}function gb(l,u){if(It){var m=ts.formState;if(m!==null){e:{var b=yt;if(It){if(ls){t:{for(var k=ls,j=Tn;k.nodeType!==8;){if(!j){k=null;break t}if(k=En(k.nextSibling),k===null){k=null;break t}}j=k.data,k=j==="F!"||j==="F"?k:null}if(k){ls=En(k.nextSibling),b=k.data==="F!";break e}}Ka(b)}b=!1}b&&(u=m[0])}}return m=Ys(),m.memoizedState=m.baseState=u,b={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fb,lastRenderedState:u},m.queue=b,m=Bb.bind(null,yt,b),b.dispatch=m,b=oh(!1),j=mh.bind(null,yt,!1,b.queue),b=Ys(),k={state:u,dispatch:null,action:l,pending:null},b.queue=k,m=mC.bind(null,yt,k,j,m),k.dispatch=m,b.memoizedState=l,[u,m,!1]}function bb(l){var u=xs();return yb(u,Xt,l)}function yb(l,u,m){if(u=ah(l,u,fb)[0],l=Cc(Aa)[0],typeof u=="object"&&u!==null&&typeof u.then=="function")try{var b=Hr(u)}catch(F){throw F===Ro?fc:F}else b=u;u=xs();var k=u.queue,j=k.dispatch;return m!==u.memoizedState&&(yt.flags|=2048,Po(9,{destroy:void 0},pC.bind(null,k,m),null)),[b,j,l]}function pC(l,u){l.action=u}function xb(l){var u=xs(),m=Xt;if(m!==null)return yb(u,m,l);xs(),u=u.memoizedState,m=xs();var b=m.queue.dispatch;return m.memoizedState=l,[u,b,!1]}function Po(l,u,m,b){return l={tag:l,create:m,deps:b,inst:u,next:null},u=yt.updateQueue,u===null&&(u=Sc(),yt.updateQueue=u),m=u.lastEffect,m===null?u.lastEffect=l.next=l:(b=m.next,m.next=l,l.next=b,u.lastEffect=l),l}function vb(){return xs().memoizedState}function Ac(l,u,m,b){var k=Ys();yt.flags|=l,k.memoizedState=Po(1|u,{destroy:void 0},m,b===void 0?null:b)}function Nc(l,u,m,b){var k=xs();b=b===void 0?null:b;var j=k.memoizedState.inst;Xt!==null&&b!==null&&Qd(b,Xt.memoizedState.deps)?k.memoizedState=Po(u,j,m,b):(yt.flags|=l,k.memoizedState=Po(1|u,j,m,b))}function wb(l,u){Ac(8390656,8,l,u)}function lh(l,u){Nc(2048,8,l,u)}function fC(l){yt.flags|=4;var u=yt.updateQueue;if(u===null)u=Sc(),yt.updateQueue=u,u.events=[l];else{var m=u.events;m===null?u.events=[l]:m.push(l)}}function kb(l){var u=xs().memoizedState;return fC({ref:u,nextImpl:l}),function(){if((Gt&2)!==0)throw Error(n(440));return u.impl.apply(void 0,arguments)}}function Sb(l,u){return Nc(4,2,l,u)}function jb(l,u){return Nc(4,4,l,u)}function Cb(l,u){if(typeof u=="function"){l=l();var m=u(l);return function(){typeof m=="function"?m():u(null)}}if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function Ab(l,u,m){m=m!=null?m.concat([l]):null,Nc(4,4,Cb.bind(null,u,l),m)}function ch(){}function Nb(l,u){var m=xs();u=u===void 0?null:u;var b=m.memoizedState;return u!==null&&Qd(u,b[1])?b[0]:(m.memoizedState=[l,u],l)}function Tb(l,u){var m=xs();u=u===void 0?null:u;var b=m.memoizedState;if(u!==null&&Qd(u,b[1]))return b[0];if(b=l(),Gi){vt(!0);try{l()}finally{vt(!1)}}return m.memoizedState=[b,u],b}function uh(l,u,m){return m===void 0||(Ca&1073741824)!==0&&(Bt&261930)===0?l.memoizedState=u:(l.memoizedState=m,l=My(),yt.lanes|=l,si|=l,m)}function Mb(l,u,m,b){return dn(m,u)?m:Lo.current!==null?(l=uh(l,m,b),dn(l,u)||(Cs=!0),l):(Ca&42)===0||(Ca&1073741824)!==0&&(Bt&261930)===0?(Cs=!0,l.memoizedState=m):(l=My(),yt.lanes|=l,si|=l,u)}function Eb(l,u,m,b,k){var j=q.p;q.p=j!==0&&8>j?j:8;var F=L.T,X={};L.T=X,mh(l,!1,u,m);try{var ie=k(),we=L.S;if(we!==null&&we(X,ie),ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var Ee=uC(ie,b);$r(l,u,Ee,bn(l))}else $r(l,u,b,bn(l))}catch(Oe){$r(l,u,{then:function(){},status:"rejected",reason:Oe},bn())}finally{q.p=j,F!==null&&X.types!==null&&(F.types=X.types),L.T=F}}function gC(){}function dh(l,u,m,b){if(l.tag!==5)throw Error(n(476));var k=_b(l).queue;Eb(l,k,u,V,m===null?gC:function(){return Rb(l),m(b)})}function _b(l){var u=l.memoizedState;if(u!==null)return u;u={memoizedState:V,baseState:V,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Aa,lastRenderedState:V},next:null};var m={};return u.next={memoizedState:m,baseState:m,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Aa,lastRenderedState:m},next:null},l.memoizedState=u,l=l.alternate,l!==null&&(l.memoizedState=u),u}function Rb(l){var u=_b(l);u.next===null&&(u=l.alternate.memoizedState),$r(l,u.next.queue,{},bn())}function hh(){return Is(il)}function Db(){return xs().memoizedState}function Lb(){return xs().memoizedState}function bC(l){for(var u=l.return;u!==null;){switch(u.tag){case 24:case 3:var m=bn();l=Xa(m);var b=Za(u,l,m);b!==null&&(an(b,u,m),Pr(b,u,m)),u={cache:Hd()},l.payload=u;return}u=u.return}}function yC(l,u,m){var b=bn();m={lane:b,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null},Tc(l)?Ob(u,m):(m=Ed(l,u,m,b),m!==null&&(an(m,l,b),Pb(m,u,b)))}function Bb(l,u,m){var b=bn();$r(l,u,m,b)}function $r(l,u,m,b){var k={lane:b,revertLane:0,gesture:null,action:m,hasEagerState:!1,eagerState:null,next:null};if(Tc(l))Ob(u,k);else{var j=l.alternate;if(l.lanes===0&&(j===null||j.lanes===0)&&(j=u.lastRenderedReducer,j!==null))try{var F=u.lastRenderedState,X=j(F,m);if(k.hasEagerState=!0,k.eagerState=X,dn(X,F))return lc(l,u,k,0),ts===null&&rc(),!1}catch{}finally{}if(m=Ed(l,u,k,b),m!==null)return an(m,l,b),Pb(m,u,b),!0}return!1}function mh(l,u,m,b){if(b={lane:2,revertLane:qh(),gesture:null,action:b,hasEagerState:!1,eagerState:null,next:null},Tc(l)){if(u)throw Error(n(479))}else u=Ed(l,m,b,2),u!==null&&an(u,l,2)}function Tc(l){var u=l.alternate;return l===yt||u!==null&&u===yt}function Ob(l,u){Bo=wc=!0;var m=l.pending;m===null?u.next=u:(u.next=m.next,m.next=u),l.pending=u}function Pb(l,u,m){if((m&4194048)!==0){var b=u.lanes;b&=l.pendingLanes,m|=b,u.lanes=m,zt(l,m)}}var Ur={readContext:Is,use:jc,useCallback:ps,useContext:ps,useEffect:ps,useImperativeHandle:ps,useLayoutEffect:ps,useInsertionEffect:ps,useMemo:ps,useReducer:ps,useRef:ps,useState:ps,useDebugValue:ps,useDeferredValue:ps,useTransition:ps,useSyncExternalStore:ps,useId:ps,useHostTransitionStatus:ps,useFormState:ps,useActionState:ps,useOptimistic:ps,useMemoCache:ps,useCacheRefresh:ps};Ur.useEffectEvent=ps;var Ib={readContext:Is,use:jc,useCallback:function(l,u){return Ys().memoizedState=[l,u===void 0?null:u],l},useContext:Is,useEffect:wb,useImperativeHandle:function(l,u,m){m=m!=null?m.concat([l]):null,Ac(4194308,4,Cb.bind(null,u,l),m)},useLayoutEffect:function(l,u){return Ac(4194308,4,l,u)},useInsertionEffect:function(l,u){Ac(4,2,l,u)},useMemo:function(l,u){var m=Ys();u=u===void 0?null:u;var b=l();if(Gi){vt(!0);try{l()}finally{vt(!1)}}return m.memoizedState=[b,u],b},useReducer:function(l,u,m){var b=Ys();if(m!==void 0){var k=m(u);if(Gi){vt(!0);try{m(u)}finally{vt(!1)}}}else k=u;return b.memoizedState=b.baseState=k,l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:k},b.queue=l,l=l.dispatch=yC.bind(null,yt,l),[b.memoizedState,l]},useRef:function(l){var u=Ys();return l={current:l},u.memoizedState=l},useState:function(l){l=oh(l);var u=l.queue,m=Bb.bind(null,yt,u);return u.dispatch=m,[l.memoizedState,m]},useDebugValue:ch,useDeferredValue:function(l,u){var m=Ys();return uh(m,l,u)},useTransition:function(){var l=oh(!1);return l=Eb.bind(null,yt,l.queue,!0,!1),Ys().memoizedState=l,[!1,l]},useSyncExternalStore:function(l,u,m){var b=yt,k=Ys();if(It){if(m===void 0)throw Error(n(407));m=m()}else{if(m=u(),ts===null)throw Error(n(349));(Bt&127)!==0||ib(b,u,m)}k.memoizedState=m;var j={value:m,getSnapshot:u};return k.queue=j,wb(rb.bind(null,b,j,l),[l]),b.flags|=2048,Po(9,{destroy:void 0},ob.bind(null,b,j,m,u),null),m},useId:function(){var l=Ys(),u=ts.identifierPrefix;if(It){var m=ta,b=ea;m=(b&~(1<<32-Qe(b)-1)).toString(32)+m,u="_"+u+"R_"+m,m=kc++,0<m&&(u+="H"+m.toString(32)),u+="_"}else m=dC++,u="_"+u+"r_"+m.toString(32)+"_";return l.memoizedState=u},useHostTransitionStatus:hh,useFormState:gb,useActionState:gb,useOptimistic:function(l){var u=Ys();u.memoizedState=u.baseState=l;var m={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return u.queue=m,u=mh.bind(null,yt,!0,m),m.dispatch=u,[l,u]},useMemoCache:nh,useCacheRefresh:function(){return Ys().memoizedState=bC.bind(null,yt)},useEffectEvent:function(l){var u=Ys(),m={impl:l};return u.memoizedState=m,function(){if((Gt&2)!==0)throw Error(n(440));return m.impl.apply(void 0,arguments)}}},ph={readContext:Is,use:jc,useCallback:Nb,useContext:Is,useEffect:lh,useImperativeHandle:Ab,useInsertionEffect:Sb,useLayoutEffect:jb,useMemo:Tb,useReducer:Cc,useRef:vb,useState:function(){return Cc(Aa)},useDebugValue:ch,useDeferredValue:function(l,u){var m=xs();return Mb(m,Xt.memoizedState,l,u)},useTransition:function(){var l=Cc(Aa)[0],u=xs().memoizedState;return[typeof l=="boolean"?l:Hr(l),u]},useSyncExternalStore:ab,useId:Db,useHostTransitionStatus:hh,useFormState:bb,useActionState:bb,useOptimistic:function(l,u){var m=xs();return ub(m,Xt,l,u)},useMemoCache:nh,useCacheRefresh:Lb};ph.useEffectEvent=kb;var zb={readContext:Is,use:jc,useCallback:Nb,useContext:Is,useEffect:lh,useImperativeHandle:Ab,useInsertionEffect:Sb,useLayoutEffect:jb,useMemo:Tb,useReducer:ih,useRef:vb,useState:function(){return ih(Aa)},useDebugValue:ch,useDeferredValue:function(l,u){var m=xs();return Xt===null?uh(m,l,u):Mb(m,Xt.memoizedState,l,u)},useTransition:function(){var l=ih(Aa)[0],u=xs().memoizedState;return[typeof l=="boolean"?l:Hr(l),u]},useSyncExternalStore:ab,useId:Db,useHostTransitionStatus:hh,useFormState:xb,useActionState:xb,useOptimistic:function(l,u){var m=xs();return Xt!==null?ub(m,Xt,l,u):(m.baseState=l,[l,m.queue.dispatch])},useMemoCache:nh,useCacheRefresh:Lb};zb.useEffectEvent=kb;function fh(l,u,m,b){u=l.memoizedState,m=m(b,u),m=m==null?u:f({},u,m),l.memoizedState=m,l.lanes===0&&(l.updateQueue.baseState=m)}var gh={enqueueSetState:function(l,u,m){l=l._reactInternals;var b=bn(),k=Xa(b);k.payload=u,m!=null&&(k.callback=m),u=Za(l,k,b),u!==null&&(an(u,l,b),Pr(u,l,b))},enqueueReplaceState:function(l,u,m){l=l._reactInternals;var b=bn(),k=Xa(b);k.tag=1,k.payload=u,m!=null&&(k.callback=m),u=Za(l,k,b),u!==null&&(an(u,l,b),Pr(u,l,b))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var m=bn(),b=Xa(m);b.tag=2,u!=null&&(b.callback=u),u=Za(l,b,m),u!==null&&(an(u,l,m),Pr(u,l,m))}};function Fb(l,u,m,b,k,j,F){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(b,j,F):u.prototype&&u.prototype.isPureReactComponent?!Mr(m,b)||!Mr(k,j):!0}function Hb(l,u,m,b){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(m,b),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(m,b),u.state!==l&&gh.enqueueReplaceState(u,u.state,null)}function qi(l,u){var m=u;if("ref"in u){m={};for(var b in u)b!=="ref"&&(m[b]=u[b])}if(l=l.defaultProps){m===u&&(m=f({},m));for(var k in l)m[k]===void 0&&(m[k]=l[k])}return m}function $b(l){oc(l)}function Ub(l){console.error(l)}function Gb(l){oc(l)}function Mc(l,u){try{var m=l.onUncaughtError;m(u.value,{componentStack:u.stack})}catch(b){setTimeout(function(){throw b})}}function qb(l,u,m){try{var b=l.onCaughtError;b(m.value,{componentStack:m.stack,errorBoundary:u.tag===1?u.stateNode:null})}catch(k){setTimeout(function(){throw k})}}function bh(l,u,m){return m=Xa(m),m.tag=3,m.payload={element:null},m.callback=function(){Mc(l,u)},m}function Wb(l){return l=Xa(l),l.tag=3,l}function Kb(l,u,m,b){var k=m.type.getDerivedStateFromError;if(typeof k=="function"){var j=b.value;l.payload=function(){return k(j)},l.callback=function(){qb(u,m,b)}}var F=m.stateNode;F!==null&&typeof F.componentDidCatch=="function"&&(l.callback=function(){qb(u,m,b),typeof k!="function"&&(ni===null?ni=new Set([this]):ni.add(this));var X=b.stack;this.componentDidCatch(b.value,{componentStack:X!==null?X:""})})}function xC(l,u,m,b,k){if(m.flags|=32768,b!==null&&typeof b=="object"&&typeof b.then=="function"){if(u=m.alternate,u!==null&&Mo(u,m,k,!0),m=mn.current,m!==null){switch(m.tag){case 31:case 13:return Mn===null?Hc():m.alternate===null&&fs===0&&(fs=3),m.flags&=-257,m.flags|=65536,m.lanes=k,b===gc?m.flags|=16384:(u=m.updateQueue,u===null?m.updateQueue=new Set([b]):u.add(b),$h(l,b,k)),!1;case 22:return m.flags|=65536,b===gc?m.flags|=16384:(u=m.updateQueue,u===null?(u={transitions:null,markerInstances:null,retryQueue:new Set([b])},m.updateQueue=u):(m=u.retryQueue,m===null?u.retryQueue=new Set([b]):m.add(b)),$h(l,b,k)),!1}throw Error(n(435,m.tag))}return $h(l,b,k),Hc(),!1}if(It)return u=mn.current,u!==null?((u.flags&65536)===0&&(u.flags|=256),u.flags|=65536,u.lanes=k,b!==Od&&(l=Error(n(422),{cause:b}),Rr(Cn(l,m)))):(b!==Od&&(u=Error(n(423),{cause:b}),Rr(Cn(u,m))),l=l.current.alternate,l.flags|=65536,k&=-k,l.lanes|=k,b=Cn(b,m),k=bh(l.stateNode,b,k),Kd(l,k),fs!==4&&(fs=2)),!1;var j=Error(n(520),{cause:b});if(j=Cn(j,m),Zr===null?Zr=[j]:Zr.push(j),fs!==4&&(fs=2),u===null)return!0;b=Cn(b,m),m=u;do{switch(m.tag){case 3:return m.flags|=65536,l=k&-k,m.lanes|=l,l=bh(m.stateNode,b,l),Kd(m,l),!1;case 1:if(u=m.type,j=m.stateNode,(m.flags&128)===0&&(typeof u.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(ni===null||!ni.has(j))))return m.flags|=65536,k&=-k,m.lanes|=k,k=Wb(k),Kb(k,l,m,b),Kd(m,k),!1}m=m.return}while(m!==null);return!1}var yh=Error(n(461)),Cs=!1;function zs(l,u,m,b){u.child=l===null?Zg(u,null,m,b):Ui(u,l.child,m,b)}function Vb(l,u,m,b,k){m=m.render;var j=u.ref;if("ref"in b){var F={};for(var X in b)X!=="ref"&&(F[X]=b[X])}else F=b;return zi(u),b=Jd(l,u,m,F,j,k),X=eh(),l!==null&&!Cs?(th(l,u,k),Na(l,u,k)):(It&&X&&Ld(u),u.flags|=1,zs(l,u,b,k),u.child)}function Yb(l,u,m,b,k){if(l===null){var j=m.type;return typeof j=="function"&&!_d(j)&&j.defaultProps===void 0&&m.compare===null?(u.tag=15,u.type=j,Xb(l,u,j,b,k)):(l=uc(m.type,null,b,u,u.mode,k),l.ref=u.ref,l.return=u,u.child=l)}if(j=l.child,!Ah(l,k)){var F=j.memoizedProps;if(m=m.compare,m=m!==null?m:Mr,m(F,b)&&l.ref===u.ref)return Na(l,u,k)}return u.flags|=1,l=wa(j,b),l.ref=u.ref,l.return=u,u.child=l}function Xb(l,u,m,b,k){if(l!==null){var j=l.memoizedProps;if(Mr(j,b)&&l.ref===u.ref)if(Cs=!1,u.pendingProps=b=j,Ah(l,k))(l.flags&131072)!==0&&(Cs=!0);else return u.lanes=l.lanes,Na(l,u,k)}return xh(l,u,m,b,k)}function Zb(l,u,m,b){var k=b.children,j=l!==null?l.memoizedState:null;if(l===null&&u.stateNode===null&&(u.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),b.mode==="hidden"){if((u.flags&128)!==0){if(j=j!==null?j.baseLanes|m:m,l!==null){for(b=u.child=l.child,k=0;b!==null;)k=k|b.lanes|b.childLanes,b=b.sibling;b=k&~j}else b=0,u.child=null;return Qb(l,u,j,m,b)}if((m&536870912)!==0)u.memoizedState={baseLanes:0,cachePool:null},l!==null&&pc(u,j!==null?j.cachePool:null),j!==null?eb(u,j):Yd(),tb(u);else return b=u.lanes=536870912,Qb(l,u,j!==null?j.baseLanes|m:m,m,b)}else j!==null?(pc(u,j.cachePool),eb(u,j),Ja(),u.memoizedState=null):(l!==null&&pc(u,null),Yd(),Ja());return zs(l,u,k,m),u.child}function Gr(l,u){return l!==null&&l.tag===22||u.stateNode!==null||(u.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),u.sibling}function Qb(l,u,m,b,k){var j=Ud();return j=j===null?null:{parent:Ss._currentValue,pool:j},u.memoizedState={baseLanes:m,cachePool:j},l!==null&&pc(u,null),Yd(),tb(u),l!==null&&Mo(l,u,b,!0),u.childLanes=k,null}function Ec(l,u){return u=Rc({mode:u.mode,children:u.children},l.mode),u.ref=l.ref,l.child=u,u.return=l,u}function Jb(l,u,m){return Ui(u,l.child,null,m),l=Ec(u,u.pendingProps),l.flags|=2,pn(u),u.memoizedState=null,l}function vC(l,u,m){var b=u.pendingProps,k=(u.flags&128)!==0;if(u.flags&=-129,l===null){if(It){if(b.mode==="hidden")return l=Ec(u,b),u.lanes=536870912,Gr(null,l);if(Zd(u),(l=ls)?(l=dx(l,Tn),l=l!==null&&l.data==="&"?l:null,l!==null&&(u.memoizedState={dehydrated:l,treeContext:qa!==null?{id:ea,overflow:ta}:null,retryLane:536870912,hydrationErrors:null},m=Og(l),m.return=u,u.child=m,Ps=u,ls=null)):l=null,l===null)throw Ka(u);return u.lanes=536870912,null}return Ec(u,b)}var j=l.memoizedState;if(j!==null){var F=j.dehydrated;if(Zd(u),k)if(u.flags&256)u.flags&=-257,u=Jb(l,u,m);else if(u.memoizedState!==null)u.child=l.child,u.flags|=128,u=null;else throw Error(n(558));else if(Cs||Mo(l,u,m,!1),k=(m&l.childLanes)!==0,Cs||k){if(b=ts,b!==null&&(F=ms(b,m),F!==0&&F!==j.retryLane))throw j.retryLane=F,Bi(l,F),an(b,l,F),yh;Hc(),u=Jb(l,u,m)}else l=j.treeContext,ls=En(F.nextSibling),Ps=u,It=!0,Wa=null,Tn=!1,l!==null&&zg(u,l),u=Ec(u,b),u.flags|=4096;return u}return l=wa(l.child,{mode:b.mode,children:b.children}),l.ref=u.ref,u.child=l,l.return=u,l}function _c(l,u){var m=u.ref;if(m===null)l!==null&&l.ref!==null&&(u.flags|=4194816);else{if(typeof m!="function"&&typeof m!="object")throw Error(n(284));(l===null||l.ref!==m)&&(u.flags|=4194816)}}function xh(l,u,m,b,k){return zi(u),m=Jd(l,u,m,b,void 0,k),b=eh(),l!==null&&!Cs?(th(l,u,k),Na(l,u,k)):(It&&b&&Ld(u),u.flags|=1,zs(l,u,m,k),u.child)}function ey(l,u,m,b,k,j){return zi(u),u.updateQueue=null,m=nb(u,b,m,k),sb(l),b=eh(),l!==null&&!Cs?(th(l,u,j),Na(l,u,j)):(It&&b&&Ld(u),u.flags|=1,zs(l,u,m,j),u.child)}function ty(l,u,m,b,k){if(zi(u),u.stateNode===null){var j=Co,F=m.contextType;typeof F=="object"&&F!==null&&(j=Is(F)),j=new m(b,j),u.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=gh,u.stateNode=j,j._reactInternals=u,j=u.stateNode,j.props=b,j.state=u.memoizedState,j.refs={},qd(u),F=m.contextType,j.context=typeof F=="object"&&F!==null?Is(F):Co,j.state=u.memoizedState,F=m.getDerivedStateFromProps,typeof F=="function"&&(fh(u,m,F,b),j.state=u.memoizedState),typeof m.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(F=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),F!==j.state&&gh.enqueueReplaceState(j,j.state,null),zr(u,b,j,k),Ir(),j.state=u.memoizedState),typeof j.componentDidMount=="function"&&(u.flags|=4194308),b=!0}else if(l===null){j=u.stateNode;var X=u.memoizedProps,ie=qi(m,X);j.props=ie;var we=j.context,Ee=m.contextType;F=Co,typeof Ee=="object"&&Ee!==null&&(F=Is(Ee));var Oe=m.getDerivedStateFromProps;Ee=typeof Oe=="function"||typeof j.getSnapshotBeforeUpdate=="function",X=u.pendingProps!==X,Ee||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(X||we!==F)&&Hb(u,j,b,F),Ya=!1;var je=u.memoizedState;j.state=je,zr(u,b,j,k),Ir(),we=u.memoizedState,X||je!==we||Ya?(typeof Oe=="function"&&(fh(u,m,Oe,b),we=u.memoizedState),(ie=Ya||Fb(u,m,ie,b,je,we,F))?(Ee||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount()),typeof j.componentDidMount=="function"&&(u.flags|=4194308)):(typeof j.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=b,u.memoizedState=we),j.props=b,j.state=we,j.context=F,b=ie):(typeof j.componentDidMount=="function"&&(u.flags|=4194308),b=!1)}else{j=u.stateNode,Wd(l,u),F=u.memoizedProps,Ee=qi(m,F),j.props=Ee,Oe=u.pendingProps,je=j.context,we=m.contextType,ie=Co,typeof we=="object"&&we!==null&&(ie=Is(we)),X=m.getDerivedStateFromProps,(we=typeof X=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(F!==Oe||je!==ie)&&Hb(u,j,b,ie),Ya=!1,je=u.memoizedState,j.state=je,zr(u,b,j,k),Ir();var Te=u.memoizedState;F!==Oe||je!==Te||Ya||l!==null&&l.dependencies!==null&&hc(l.dependencies)?(typeof X=="function"&&(fh(u,m,X,b),Te=u.memoizedState),(Ee=Ya||Fb(u,m,Ee,b,je,Te,ie)||l!==null&&l.dependencies!==null&&hc(l.dependencies))?(we||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(b,Te,ie),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(b,Te,ie)),typeof j.componentDidUpdate=="function"&&(u.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof j.componentDidUpdate!="function"||F===l.memoizedProps&&je===l.memoizedState||(u.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||F===l.memoizedProps&&je===l.memoizedState||(u.flags|=1024),u.memoizedProps=b,u.memoizedState=Te),j.props=b,j.state=Te,j.context=ie,b=Ee):(typeof j.componentDidUpdate!="function"||F===l.memoizedProps&&je===l.memoizedState||(u.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||F===l.memoizedProps&&je===l.memoizedState||(u.flags|=1024),b=!1)}return j=b,_c(l,u),b=(u.flags&128)!==0,j||b?(j=u.stateNode,m=b&&typeof m.getDerivedStateFromError!="function"?null:j.render(),u.flags|=1,l!==null&&b?(u.child=Ui(u,l.child,null,k),u.child=Ui(u,null,m,k)):zs(l,u,m,k),u.memoizedState=j.state,l=u.child):l=Na(l,u,k),l}function sy(l,u,m,b){return Pi(),u.flags|=256,zs(l,u,m,b),u.child}var vh={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function wh(l){return{baseLanes:l,cachePool:qg()}}function kh(l,u,m){return l=l!==null?l.childLanes&~m:0,u&&(l|=gn),l}function ny(l,u,m){var b=u.pendingProps,k=!1,j=(u.flags&128)!==0,F;if((F=j)||(F=l!==null&&l.memoizedState===null?!1:(ys.current&2)!==0),F&&(k=!0,u.flags&=-129),F=(u.flags&32)!==0,u.flags&=-33,l===null){if(It){if(k?Qa(u):Ja(),(l=ls)?(l=dx(l,Tn),l=l!==null&&l.data!=="&"?l:null,l!==null&&(u.memoizedState={dehydrated:l,treeContext:qa!==null?{id:ea,overflow:ta}:null,retryLane:536870912,hydrationErrors:null},m=Og(l),m.return=u,u.child=m,Ps=u,ls=null)):l=null,l===null)throw Ka(u);return am(l)?u.lanes=32:u.lanes=536870912,null}var X=b.children;return b=b.fallback,k?(Ja(),k=u.mode,X=Rc({mode:"hidden",children:X},k),b=Oi(b,k,m,null),X.return=u,b.return=u,X.sibling=b,u.child=X,b=u.child,b.memoizedState=wh(m),b.childLanes=kh(l,F,m),u.memoizedState=vh,Gr(null,b)):(Qa(u),Sh(u,X))}var ie=l.memoizedState;if(ie!==null&&(X=ie.dehydrated,X!==null)){if(j)u.flags&256?(Qa(u),u.flags&=-257,u=jh(l,u,m)):u.memoizedState!==null?(Ja(),u.child=l.child,u.flags|=128,u=null):(Ja(),X=b.fallback,k=u.mode,b=Rc({mode:"visible",children:b.children},k),X=Oi(X,k,m,null),X.flags|=2,b.return=u,X.return=u,b.sibling=X,u.child=b,Ui(u,l.child,null,m),b=u.child,b.memoizedState=wh(m),b.childLanes=kh(l,F,m),u.memoizedState=vh,u=Gr(null,b));else if(Qa(u),am(X)){if(F=X.nextSibling&&X.nextSibling.dataset,F)var we=F.dgst;F=we,b=Error(n(419)),b.stack="",b.digest=F,Rr({value:b,source:null,stack:null}),u=jh(l,u,m)}else if(Cs||Mo(l,u,m,!1),F=(m&l.childLanes)!==0,Cs||F){if(F=ts,F!==null&&(b=ms(F,m),b!==0&&b!==ie.retryLane))throw ie.retryLane=b,Bi(l,b),an(F,l,b),yh;nm(X)||Hc(),u=jh(l,u,m)}else nm(X)?(u.flags|=192,u.child=l.child,u=null):(l=ie.treeContext,ls=En(X.nextSibling),Ps=u,It=!0,Wa=null,Tn=!1,l!==null&&zg(u,l),u=Sh(u,b.children),u.flags|=4096);return u}return k?(Ja(),X=b.fallback,k=u.mode,ie=l.child,we=ie.sibling,b=wa(ie,{mode:"hidden",children:b.children}),b.subtreeFlags=ie.subtreeFlags&65011712,we!==null?X=wa(we,X):(X=Oi(X,k,m,null),X.flags|=2),X.return=u,b.return=u,b.sibling=X,u.child=b,Gr(null,b),b=u.child,X=l.child.memoizedState,X===null?X=wh(m):(k=X.cachePool,k!==null?(ie=Ss._currentValue,k=k.parent!==ie?{parent:ie,pool:ie}:k):k=qg(),X={baseLanes:X.baseLanes|m,cachePool:k}),b.memoizedState=X,b.childLanes=kh(l,F,m),u.memoizedState=vh,Gr(l.child,b)):(Qa(u),m=l.child,l=m.sibling,m=wa(m,{mode:"visible",children:b.children}),m.return=u,m.sibling=null,l!==null&&(F=u.deletions,F===null?(u.deletions=[l],u.flags|=16):F.push(l)),u.child=m,u.memoizedState=null,m)}function Sh(l,u){return u=Rc({mode:"visible",children:u},l.mode),u.return=l,l.child=u}function Rc(l,u){return l=hn(22,l,null,u),l.lanes=0,l}function jh(l,u,m){return Ui(u,l.child,null,m),l=Sh(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function ay(l,u,m){l.lanes|=u;var b=l.alternate;b!==null&&(b.lanes|=u),zd(l.return,u,m)}function Ch(l,u,m,b,k,j){var F=l.memoizedState;F===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:b,tail:m,tailMode:k,treeForkCount:j}:(F.isBackwards=u,F.rendering=null,F.renderingStartTime=0,F.last=b,F.tail=m,F.tailMode=k,F.treeForkCount=j)}function iy(l,u,m){var b=u.pendingProps,k=b.revealOrder,j=b.tail;b=b.children;var F=ys.current,X=(F&2)!==0;if(X?(F=F&1|2,u.flags|=128):F&=1,H(ys,F),zs(l,u,b,m),b=It?_r:0,!X&&l!==null&&(l.flags&128)!==0)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&ay(l,m,u);else if(l.tag===19)ay(l,m,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}switch(k){case"forwards":for(m=u.child,k=null;m!==null;)l=m.alternate,l!==null&&vc(l)===null&&(k=m),m=m.sibling;m=k,m===null?(k=u.child,u.child=null):(k=m.sibling,m.sibling=null),Ch(u,!1,k,m,j,b);break;case"backwards":case"unstable_legacy-backwards":for(m=null,k=u.child,u.child=null;k!==null;){if(l=k.alternate,l!==null&&vc(l)===null){u.child=k;break}l=k.sibling,k.sibling=m,m=k,k=l}Ch(u,!0,m,null,j,b);break;case"together":Ch(u,!1,null,null,void 0,b);break;default:u.memoizedState=null}return u.child}function Na(l,u,m){if(l!==null&&(u.dependencies=l.dependencies),si|=u.lanes,(m&u.childLanes)===0)if(l!==null){if(Mo(l,u,m,!1),(m&u.childLanes)===0)return null}else return null;if(l!==null&&u.child!==l.child)throw Error(n(153));if(u.child!==null){for(l=u.child,m=wa(l,l.pendingProps),u.child=m,m.return=u;l.sibling!==null;)l=l.sibling,m=m.sibling=wa(l,l.pendingProps),m.return=u;m.sibling=null}return u.child}function Ah(l,u){return(l.lanes&u)!==0?!0:(l=l.dependencies,!!(l!==null&&hc(l)))}function wC(l,u,m){switch(u.tag){case 3:me(u,u.stateNode.containerInfo),Va(u,Ss,l.memoizedState.cache),Pi();break;case 27:case 5:ne(u);break;case 4:me(u,u.stateNode.containerInfo);break;case 10:Va(u,u.type,u.memoizedProps.value);break;case 31:if(u.memoizedState!==null)return u.flags|=128,Zd(u),null;break;case 13:var b=u.memoizedState;if(b!==null)return b.dehydrated!==null?(Qa(u),u.flags|=128,null):(m&u.child.childLanes)!==0?ny(l,u,m):(Qa(u),l=Na(l,u,m),l!==null?l.sibling:null);Qa(u);break;case 19:var k=(l.flags&128)!==0;if(b=(m&u.childLanes)!==0,b||(Mo(l,u,m,!1),b=(m&u.childLanes)!==0),k){if(b)return iy(l,u,m);u.flags|=128}if(k=u.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),H(ys,ys.current),b)break;return null;case 22:return u.lanes=0,Zb(l,u,m,u.pendingProps);case 24:Va(u,Ss,l.memoizedState.cache)}return Na(l,u,m)}function oy(l,u,m){if(l!==null)if(l.memoizedProps!==u.pendingProps)Cs=!0;else{if(!Ah(l,m)&&(u.flags&128)===0)return Cs=!1,wC(l,u,m);Cs=(l.flags&131072)!==0}else Cs=!1,It&&(u.flags&1048576)!==0&&Ig(u,_r,u.index);switch(u.lanes=0,u.tag){case 16:e:{var b=u.pendingProps;if(l=Hi(u.elementType),u.type=l,typeof l=="function")_d(l)?(b=qi(l,b),u.tag=1,u=ty(null,u,l,b,m)):(u.tag=0,u=xh(null,u,l,b,m));else{if(l!=null){var k=l.$$typeof;if(k===_){u.tag=11,u=Vb(null,u,l,b,m);break e}else if(k===z){u.tag=14,u=Yb(null,u,l,b,m);break e}}throw u=Y(l)||l,Error(n(306,u,""))}}return u;case 0:return xh(l,u,u.type,u.pendingProps,m);case 1:return b=u.type,k=qi(b,u.pendingProps),ty(l,u,b,k,m);case 3:e:{if(me(u,u.stateNode.containerInfo),l===null)throw Error(n(387));b=u.pendingProps;var j=u.memoizedState;k=j.element,Wd(l,u),zr(u,b,null,m);var F=u.memoizedState;if(b=F.cache,Va(u,Ss,b),b!==j.cache&&Fd(u,[Ss],m,!0),Ir(),b=F.element,j.isDehydrated)if(j={element:b,isDehydrated:!1,cache:F.cache},u.updateQueue.baseState=j,u.memoizedState=j,u.flags&256){u=sy(l,u,b,m);break e}else if(b!==k){k=Cn(Error(n(424)),u),Rr(k),u=sy(l,u,b,m);break e}else{switch(l=u.stateNode.containerInfo,l.nodeType){case 9:l=l.body;break;default:l=l.nodeName==="HTML"?l.ownerDocument.body:l}for(ls=En(l.firstChild),Ps=u,It=!0,Wa=null,Tn=!0,m=Zg(u,null,b,m),u.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling}else{if(Pi(),b===k){u=Na(l,u,m);break e}zs(l,u,b,m)}u=u.child}return u;case 26:return _c(l,u),l===null?(m=bx(u.type,null,u.pendingProps,null))?u.memoizedState=m:It||(m=u.type,l=u.pendingProps,b=Vc(J.current).createElement(m),b[We]=u,b[Ye]=l,Fs(b,m,l),bs(b),u.stateNode=b):u.memoizedState=bx(u.type,l.memoizedProps,u.pendingProps,l.memoizedState),null;case 27:return ne(u),l===null&&It&&(b=u.stateNode=px(u.type,u.pendingProps,J.current),Ps=u,Tn=!0,k=ls,ri(u.type)?(im=k,ls=En(b.firstChild)):ls=k),zs(l,u,u.pendingProps.children,m),_c(l,u),l===null&&(u.flags|=4194304),u.child;case 5:return l===null&&It&&((k=b=ls)&&(b=ZC(b,u.type,u.pendingProps,Tn),b!==null?(u.stateNode=b,Ps=u,ls=En(b.firstChild),Tn=!1,k=!0):k=!1),k||Ka(u)),ne(u),k=u.type,j=u.pendingProps,F=l!==null?l.memoizedProps:null,b=j.children,em(k,j)?b=null:F!==null&&em(k,F)&&(u.flags|=32),u.memoizedState!==null&&(k=Jd(l,u,hC,null,null,m),il._currentValue=k),_c(l,u),zs(l,u,b,m),u.child;case 6:return l===null&&It&&((l=m=ls)&&(m=QC(m,u.pendingProps,Tn),m!==null?(u.stateNode=m,Ps=u,ls=null,l=!0):l=!1),l||Ka(u)),null;case 13:return ny(l,u,m);case 4:return me(u,u.stateNode.containerInfo),b=u.pendingProps,l===null?u.child=Ui(u,null,b,m):zs(l,u,b,m),u.child;case 11:return Vb(l,u,u.type,u.pendingProps,m);case 7:return zs(l,u,u.pendingProps,m),u.child;case 8:return zs(l,u,u.pendingProps.children,m),u.child;case 12:return zs(l,u,u.pendingProps.children,m),u.child;case 10:return b=u.pendingProps,Va(u,u.type,b.value),zs(l,u,b.children,m),u.child;case 9:return k=u.type._context,b=u.pendingProps.children,zi(u),k=Is(k),b=b(k),u.flags|=1,zs(l,u,b,m),u.child;case 14:return Yb(l,u,u.type,u.pendingProps,m);case 15:return Xb(l,u,u.type,u.pendingProps,m);case 19:return iy(l,u,m);case 31:return vC(l,u,m);case 22:return Zb(l,u,m,u.pendingProps);case 24:return zi(u),b=Is(Ss),l===null?(k=Ud(),k===null&&(k=ts,j=Hd(),k.pooledCache=j,j.refCount++,j!==null&&(k.pooledCacheLanes|=m),k=j),u.memoizedState={parent:b,cache:k},qd(u),Va(u,Ss,k)):((l.lanes&m)!==0&&(Wd(l,u),zr(u,null,null,m),Ir()),k=l.memoizedState,j=u.memoizedState,k.parent!==b?(k={parent:b,cache:b},u.memoizedState=k,u.lanes===0&&(u.memoizedState=u.updateQueue.baseState=k),Va(u,Ss,b)):(b=j.cache,Va(u,Ss,b),b!==k.cache&&Fd(u,[Ss],m,!0))),zs(l,u,u.pendingProps.children,m),u.child;case 29:throw u.pendingProps}throw Error(n(156,u.tag))}function Ta(l){l.flags|=4}function Nh(l,u,m,b,k){if((u=(l.mode&32)!==0)&&(u=!1),u){if(l.flags|=16777216,(k&335544128)===k)if(l.stateNode.complete)l.flags|=8192;else if(Dy())l.flags|=8192;else throw $i=gc,Gd}else l.flags&=-16777217}function ry(l,u){if(u.type!=="stylesheet"||(u.state.loading&4)!==0)l.flags&=-16777217;else if(l.flags|=16777216,!kx(u))if(Dy())l.flags|=8192;else throw $i=gc,Gd}function Dc(l,u){u!==null&&(l.flags|=4),l.flags&16384&&(u=l.tag!==22?Vt():536870912,l.lanes|=u,Ho|=u)}function qr(l,u){if(!It)switch(l.tailMode){case"hidden":u=l.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?l.tail=null:m.sibling=null;break;case"collapsed":m=l.tail;for(var b=null;m!==null;)m.alternate!==null&&(b=m),m=m.sibling;b===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:b.sibling=null}}function cs(l){var u=l.alternate!==null&&l.alternate.child===l.child,m=0,b=0;if(u)for(var k=l.child;k!==null;)m|=k.lanes|k.childLanes,b|=k.subtreeFlags&65011712,b|=k.flags&65011712,k.return=l,k=k.sibling;else for(k=l.child;k!==null;)m|=k.lanes|k.childLanes,b|=k.subtreeFlags,b|=k.flags,k.return=l,k=k.sibling;return l.subtreeFlags|=b,l.childLanes=m,u}function kC(l,u,m){var b=u.pendingProps;switch(Bd(u),u.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return cs(u),null;case 1:return cs(u),null;case 3:return m=u.stateNode,b=null,l!==null&&(b=l.memoizedState.cache),u.memoizedState.cache!==b&&(u.flags|=2048),ja(Ss),pe(),m.pendingContext&&(m.context=m.pendingContext,m.pendingContext=null),(l===null||l.child===null)&&(To(u)?Ta(u):l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,Pd())),cs(u),null;case 26:var k=u.type,j=u.memoizedState;return l===null?(Ta(u),j!==null?(cs(u),ry(u,j)):(cs(u),Nh(u,k,null,b,m))):j?j!==l.memoizedState?(Ta(u),cs(u),ry(u,j)):(cs(u),u.flags&=-16777217):(l=l.memoizedProps,l!==b&&Ta(u),cs(u),Nh(u,k,l,b,m)),null;case 27:if(xe(u),m=J.current,k=u.type,l!==null&&u.stateNode!=null)l.memoizedProps!==b&&Ta(u);else{if(!b){if(u.stateNode===null)throw Error(n(166));return cs(u),null}l=te.current,To(u)?Fg(u):(l=px(k,b,m),u.stateNode=l,Ta(u))}return cs(u),null;case 5:if(xe(u),k=u.type,l!==null&&u.stateNode!=null)l.memoizedProps!==b&&Ta(u);else{if(!b){if(u.stateNode===null)throw Error(n(166));return cs(u),null}if(j=te.current,To(u))Fg(u);else{var F=Vc(J.current);switch(j){case 1:j=F.createElementNS("http://www.w3.org/2000/svg",k);break;case 2:j=F.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;default:switch(k){case"svg":j=F.createElementNS("http://www.w3.org/2000/svg",k);break;case"math":j=F.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;case"script":j=F.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof b.is=="string"?F.createElement("select",{is:b.is}):F.createElement("select"),b.multiple?j.multiple=!0:b.size&&(j.size=b.size);break;default:j=typeof b.is=="string"?F.createElement(k,{is:b.is}):F.createElement(k)}}j[We]=u,j[Ye]=b;e:for(F=u.child;F!==null;){if(F.tag===5||F.tag===6)j.appendChild(F.stateNode);else if(F.tag!==4&&F.tag!==27&&F.child!==null){F.child.return=F,F=F.child;continue}if(F===u)break e;for(;F.sibling===null;){if(F.return===null||F.return===u)break e;F=F.return}F.sibling.return=F.return,F=F.sibling}u.stateNode=j;e:switch(Fs(j,k,b),k){case"button":case"input":case"select":case"textarea":b=!!b.autoFocus;break e;case"img":b=!0;break e;default:b=!1}b&&Ta(u)}}return cs(u),Nh(u,u.type,l===null?null:l.memoizedProps,u.pendingProps,m),null;case 6:if(l&&u.stateNode!=null)l.memoizedProps!==b&&Ta(u);else{if(typeof b!="string"&&u.stateNode===null)throw Error(n(166));if(l=J.current,To(u)){if(l=u.stateNode,m=u.memoizedProps,b=null,k=Ps,k!==null)switch(k.tag){case 27:case 5:b=k.memoizedProps}l[We]=u,l=!!(l.nodeValue===m||b!==null&&b.suppressHydrationWarning===!0||nx(l.nodeValue,m)),l||Ka(u,!0)}else l=Vc(l).createTextNode(b),l[We]=u,u.stateNode=l}return cs(u),null;case 31:if(m=u.memoizedState,l===null||l.memoizedState!==null){if(b=To(u),m!==null){if(l===null){if(!b)throw Error(n(318));if(l=u.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(557));l[We]=u}else Pi(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;cs(u),l=!1}else m=Pd(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=m),l=!0;if(!l)return u.flags&256?(pn(u),u):(pn(u),null);if((u.flags&128)!==0)throw Error(n(558))}return cs(u),null;case 13:if(b=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(k=To(u),b!==null&&b.dehydrated!==null){if(l===null){if(!k)throw Error(n(318));if(k=u.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(n(317));k[We]=u}else Pi(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;cs(u),k=!1}else k=Pd(),l!==null&&l.memoizedState!==null&&(l.memoizedState.hydrationErrors=k),k=!0;if(!k)return u.flags&256?(pn(u),u):(pn(u),null)}return pn(u),(u.flags&128)!==0?(u.lanes=m,u):(m=b!==null,l=l!==null&&l.memoizedState!==null,m&&(b=u.child,k=null,b.alternate!==null&&b.alternate.memoizedState!==null&&b.alternate.memoizedState.cachePool!==null&&(k=b.alternate.memoizedState.cachePool.pool),j=null,b.memoizedState!==null&&b.memoizedState.cachePool!==null&&(j=b.memoizedState.cachePool.pool),j!==k&&(b.flags|=2048)),m!==l&&m&&(u.child.flags|=8192),Dc(u,u.updateQueue),cs(u),null);case 4:return pe(),l===null&&Yh(u.stateNode.containerInfo),cs(u),null;case 10:return ja(u.type),cs(u),null;case 19:if(U(ys),b=u.memoizedState,b===null)return cs(u),null;if(k=(u.flags&128)!==0,j=b.rendering,j===null)if(k)qr(b,!1);else{if(fs!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(j=vc(l),j!==null){for(u.flags|=128,qr(b,!1),l=j.updateQueue,u.updateQueue=l,Dc(u,l),u.subtreeFlags=0,l=m,m=u.child;m!==null;)Bg(m,l),m=m.sibling;return H(ys,ys.current&1|2),It&&ka(u,b.treeForkCount),u.child}l=l.sibling}b.tail!==null&&qe()>Ic&&(u.flags|=128,k=!0,qr(b,!1),u.lanes=4194304)}else{if(!k)if(l=vc(j),l!==null){if(u.flags|=128,k=!0,l=l.updateQueue,u.updateQueue=l,Dc(u,l),qr(b,!0),b.tail===null&&b.tailMode==="hidden"&&!j.alternate&&!It)return cs(u),null}else 2*qe()-b.renderingStartTime>Ic&&m!==536870912&&(u.flags|=128,k=!0,qr(b,!1),u.lanes=4194304);b.isBackwards?(j.sibling=u.child,u.child=j):(l=b.last,l!==null?l.sibling=j:u.child=j,b.last=j)}return b.tail!==null?(l=b.tail,b.rendering=l,b.tail=l.sibling,b.renderingStartTime=qe(),l.sibling=null,m=ys.current,H(ys,k?m&1|2:m&1),It&&ka(u,b.treeForkCount),l):(cs(u),null);case 22:case 23:return pn(u),Xd(),b=u.memoizedState!==null,l!==null?l.memoizedState!==null!==b&&(u.flags|=8192):b&&(u.flags|=8192),b?(m&536870912)!==0&&(u.flags&128)===0&&(cs(u),u.subtreeFlags&6&&(u.flags|=8192)):cs(u),m=u.updateQueue,m!==null&&Dc(u,m.retryQueue),m=null,l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),b=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(b=u.memoizedState.cachePool.pool),b!==m&&(u.flags|=2048),l!==null&&U(Fi),null;case 24:return m=null,l!==null&&(m=l.memoizedState.cache),u.memoizedState.cache!==m&&(u.flags|=2048),ja(Ss),cs(u),null;case 25:return null;case 30:return null}throw Error(n(156,u.tag))}function SC(l,u){switch(Bd(u),u.tag){case 1:return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return ja(Ss),pe(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 26:case 27:case 5:return xe(u),null;case 31:if(u.memoizedState!==null){if(pn(u),u.alternate===null)throw Error(n(340));Pi()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 13:if(pn(u),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Pi()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return U(ys),null;case 4:return pe(),null;case 10:return ja(u.type),null;case 22:case 23:return pn(u),Xd(),l!==null&&U(Fi),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 24:return ja(Ss),null;case 25:return null;default:return null}}function ly(l,u){switch(Bd(u),u.tag){case 3:ja(Ss),pe();break;case 26:case 27:case 5:xe(u);break;case 4:pe();break;case 31:u.memoizedState!==null&&pn(u);break;case 13:pn(u);break;case 19:U(ys);break;case 10:ja(u.type);break;case 22:case 23:pn(u),Xd(),l!==null&&U(Fi);break;case 24:ja(Ss)}}function Wr(l,u){try{var m=u.updateQueue,b=m!==null?m.lastEffect:null;if(b!==null){var k=b.next;m=k;do{if((m.tag&l)===l){b=void 0;var j=m.create,F=m.inst;b=j(),F.destroy=b}m=m.next}while(m!==k)}}catch(X){Kt(u,u.return,X)}}function ei(l,u,m){try{var b=u.updateQueue,k=b!==null?b.lastEffect:null;if(k!==null){var j=k.next;b=j;do{if((b.tag&l)===l){var F=b.inst,X=F.destroy;if(X!==void 0){F.destroy=void 0,k=u;var ie=m,we=X;try{we()}catch(Ee){Kt(k,ie,Ee)}}}b=b.next}while(b!==j)}}catch(Ee){Kt(u,u.return,Ee)}}function cy(l){var u=l.updateQueue;if(u!==null){var m=l.stateNode;try{Jg(u,m)}catch(b){Kt(l,l.return,b)}}}function uy(l,u,m){m.props=qi(l.type,l.memoizedProps),m.state=l.memoizedState;try{m.componentWillUnmount()}catch(b){Kt(l,u,b)}}function Kr(l,u){try{var m=l.ref;if(m!==null){switch(l.tag){case 26:case 27:case 5:var b=l.stateNode;break;case 30:b=l.stateNode;break;default:b=l.stateNode}typeof m=="function"?l.refCleanup=m(b):m.current=b}}catch(k){Kt(l,u,k)}}function sa(l,u){var m=l.ref,b=l.refCleanup;if(m!==null)if(typeof b=="function")try{b()}catch(k){Kt(l,u,k)}finally{l.refCleanup=null,l=l.alternate,l!=null&&(l.refCleanup=null)}else if(typeof m=="function")try{m(null)}catch(k){Kt(l,u,k)}else m.current=null}function dy(l){var u=l.type,m=l.memoizedProps,b=l.stateNode;try{e:switch(u){case"button":case"input":case"select":case"textarea":m.autoFocus&&b.focus();break e;case"img":m.src?b.src=m.src:m.srcSet&&(b.srcset=m.srcSet)}}catch(k){Kt(l,l.return,k)}}function Th(l,u,m){try{var b=l.stateNode;qC(b,l.type,m,u),b[Ye]=u}catch(k){Kt(l,l.return,k)}}function hy(l){return l.tag===5||l.tag===3||l.tag===26||l.tag===27&&ri(l.type)||l.tag===4}function Mh(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||hy(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.tag===27&&ri(l.type)||l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function Eh(l,u,m){var b=l.tag;if(b===5||b===6)l=l.stateNode,u?(m.nodeType===9?m.body:m.nodeName==="HTML"?m.ownerDocument.body:m).insertBefore(l,u):(u=m.nodeType===9?m.body:m.nodeName==="HTML"?m.ownerDocument.body:m,u.appendChild(l),m=m._reactRootContainer,m!=null||u.onclick!==null||(u.onclick=xa));else if(b!==4&&(b===27&&ri(l.type)&&(m=l.stateNode,u=null),l=l.child,l!==null))for(Eh(l,u,m),l=l.sibling;l!==null;)Eh(l,u,m),l=l.sibling}function Lc(l,u,m){var b=l.tag;if(b===5||b===6)l=l.stateNode,u?m.insertBefore(l,u):m.appendChild(l);else if(b!==4&&(b===27&&ri(l.type)&&(m=l.stateNode),l=l.child,l!==null))for(Lc(l,u,m),l=l.sibling;l!==null;)Lc(l,u,m),l=l.sibling}function my(l){var u=l.stateNode,m=l.memoizedProps;try{for(var b=l.type,k=u.attributes;k.length;)u.removeAttributeNode(k[0]);Fs(u,b,m),u[We]=l,u[Ye]=m}catch(j){Kt(l,l.return,j)}}var Ma=!1,As=!1,_h=!1,py=typeof WeakSet=="function"?WeakSet:Set,Bs=null;function jC(l,u){if(l=l.containerInfo,Qh=tu,l=Ag(l),jd(l)){if("selectionStart"in l)var m={start:l.selectionStart,end:l.selectionEnd};else e:{m=(m=l.ownerDocument)&&m.defaultView||window;var b=m.getSelection&&m.getSelection();if(b&&b.rangeCount!==0){m=b.anchorNode;var k=b.anchorOffset,j=b.focusNode;b=b.focusOffset;try{m.nodeType,j.nodeType}catch{m=null;break e}var F=0,X=-1,ie=-1,we=0,Ee=0,Oe=l,je=null;t:for(;;){for(var Te;Oe!==m||k!==0&&Oe.nodeType!==3||(X=F+k),Oe!==j||b!==0&&Oe.nodeType!==3||(ie=F+b),Oe.nodeType===3&&(F+=Oe.nodeValue.length),(Te=Oe.firstChild)!==null;)je=Oe,Oe=Te;for(;;){if(Oe===l)break t;if(je===m&&++we===k&&(X=F),je===j&&++Ee===b&&(ie=F),(Te=Oe.nextSibling)!==null)break;Oe=je,je=Oe.parentNode}Oe=Te}m=X===-1||ie===-1?null:{start:X,end:ie}}else m=null}m=m||{start:0,end:0}}else m=null;for(Jh={focusedElem:l,selectionRange:m},tu=!1,Bs=u;Bs!==null;)if(u=Bs,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,Bs=l;else for(;Bs!==null;){switch(u=Bs,j=u.alternate,l=u.flags,u.tag){case 0:if((l&4)!==0&&(l=u.updateQueue,l=l!==null?l.events:null,l!==null))for(m=0;m<l.length;m++)k=l[m],k.ref.impl=k.nextImpl;break;case 11:case 15:break;case 1:if((l&1024)!==0&&j!==null){l=void 0,m=u,k=j.memoizedProps,j=j.memoizedState,b=m.stateNode;try{var tt=qi(m.type,k);l=b.getSnapshotBeforeUpdate(tt,j),b.__reactInternalSnapshotBeforeUpdate=l}catch(ht){Kt(m,m.return,ht)}}break;case 3:if((l&1024)!==0){if(l=u.stateNode.containerInfo,m=l.nodeType,m===9)sm(l);else if(m===1)switch(l.nodeName){case"HEAD":case"HTML":case"BODY":sm(l);break;default:l.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((l&1024)!==0)throw Error(n(163))}if(l=u.sibling,l!==null){l.return=u.return,Bs=l;break}Bs=u.return}}function fy(l,u,m){var b=m.flags;switch(m.tag){case 0:case 11:case 15:_a(l,m),b&4&&Wr(5,m);break;case 1:if(_a(l,m),b&4)if(l=m.stateNode,u===null)try{l.componentDidMount()}catch(F){Kt(m,m.return,F)}else{var k=qi(m.type,u.memoizedProps);u=u.memoizedState;try{l.componentDidUpdate(k,u,l.__reactInternalSnapshotBeforeUpdate)}catch(F){Kt(m,m.return,F)}}b&64&&cy(m),b&512&&Kr(m,m.return);break;case 3:if(_a(l,m),b&64&&(l=m.updateQueue,l!==null)){if(u=null,m.child!==null)switch(m.child.tag){case 27:case 5:u=m.child.stateNode;break;case 1:u=m.child.stateNode}try{Jg(l,u)}catch(F){Kt(m,m.return,F)}}break;case 27:u===null&&b&4&&my(m);case 26:case 5:_a(l,m),u===null&&b&4&&dy(m),b&512&&Kr(m,m.return);break;case 12:_a(l,m);break;case 31:_a(l,m),b&4&&yy(l,m);break;case 13:_a(l,m),b&4&&xy(l,m),b&64&&(l=m.memoizedState,l!==null&&(l=l.dehydrated,l!==null&&(m=DC.bind(null,m),JC(l,m))));break;case 22:if(b=m.memoizedState!==null||Ma,!b){u=u!==null&&u.memoizedState!==null||As,k=Ma;var j=As;Ma=b,(As=u)&&!j?Ra(l,m,(m.subtreeFlags&8772)!==0):_a(l,m),Ma=k,As=j}break;case 30:break;default:_a(l,m)}}function gy(l){var u=l.alternate;u!==null&&(l.alternate=null,gy(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&ot(u)),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}var us=null,en=!1;function Ea(l,u,m){for(m=m.child;m!==null;)by(l,u,m),m=m.sibling}function by(l,u,m){if(bt&&typeof bt.onCommitFiberUnmount=="function")try{bt.onCommitFiberUnmount(ft,m)}catch{}switch(m.tag){case 26:As||sa(m,u),Ea(l,u,m),m.memoizedState?m.memoizedState.count--:m.stateNode&&(m=m.stateNode,m.parentNode.removeChild(m));break;case 27:As||sa(m,u);var b=us,k=en;ri(m.type)&&(us=m.stateNode,en=!1),Ea(l,u,m),sl(m.stateNode),us=b,en=k;break;case 5:As||sa(m,u);case 6:if(b=us,k=en,us=null,Ea(l,u,m),us=b,en=k,us!==null)if(en)try{(us.nodeType===9?us.body:us.nodeName==="HTML"?us.ownerDocument.body:us).removeChild(m.stateNode)}catch(j){Kt(m,u,j)}else try{us.removeChild(m.stateNode)}catch(j){Kt(m,u,j)}break;case 18:us!==null&&(en?(l=us,cx(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,m.stateNode),Yo(l)):cx(us,m.stateNode));break;case 4:b=us,k=en,us=m.stateNode.containerInfo,en=!0,Ea(l,u,m),us=b,en=k;break;case 0:case 11:case 14:case 15:ei(2,m,u),As||ei(4,m,u),Ea(l,u,m);break;case 1:As||(sa(m,u),b=m.stateNode,typeof b.componentWillUnmount=="function"&&uy(m,u,b)),Ea(l,u,m);break;case 21:Ea(l,u,m);break;case 22:As=(b=As)||m.memoizedState!==null,Ea(l,u,m),As=b;break;default:Ea(l,u,m)}}function yy(l,u){if(u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null))){l=l.dehydrated;try{Yo(l)}catch(m){Kt(u,u.return,m)}}}function xy(l,u){if(u.memoizedState===null&&(l=u.alternate,l!==null&&(l=l.memoizedState,l!==null&&(l=l.dehydrated,l!==null))))try{Yo(l)}catch(m){Kt(u,u.return,m)}}function CC(l){switch(l.tag){case 31:case 13:case 19:var u=l.stateNode;return u===null&&(u=l.stateNode=new py),u;case 22:return l=l.stateNode,u=l._retryCache,u===null&&(u=l._retryCache=new py),u;default:throw Error(n(435,l.tag))}}function Bc(l,u){var m=CC(l);u.forEach(function(b){if(!m.has(b)){m.add(b);var k=LC.bind(null,l,b);b.then(k,k)}})}function tn(l,u){var m=u.deletions;if(m!==null)for(var b=0;b<m.length;b++){var k=m[b],j=l,F=u,X=F;e:for(;X!==null;){switch(X.tag){case 27:if(ri(X.type)){us=X.stateNode,en=!1;break e}break;case 5:us=X.stateNode,en=!1;break e;case 3:case 4:us=X.stateNode.containerInfo,en=!0;break e}X=X.return}if(us===null)throw Error(n(160));by(j,F,k),us=null,en=!1,j=k.alternate,j!==null&&(j.return=null),k.return=null}if(u.subtreeFlags&13886)for(u=u.child;u!==null;)vy(u,l),u=u.sibling}var Hn=null;function vy(l,u){var m=l.alternate,b=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:tn(u,l),sn(l),b&4&&(ei(3,l,l.return),Wr(3,l),ei(5,l,l.return));break;case 1:tn(u,l),sn(l),b&512&&(As||m===null||sa(m,m.return)),b&64&&Ma&&(l=l.updateQueue,l!==null&&(b=l.callbacks,b!==null&&(m=l.shared.hiddenCallbacks,l.shared.hiddenCallbacks=m===null?b:m.concat(b))));break;case 26:var k=Hn;if(tn(u,l),sn(l),b&512&&(As||m===null||sa(m,m.return)),b&4){var j=m!==null?m.memoizedState:null;if(b=l.memoizedState,m===null)if(b===null)if(l.stateNode===null){e:{b=l.type,m=l.memoizedProps,k=k.ownerDocument||k;t:switch(b){case"title":j=k.getElementsByTagName("title")[0],(!j||j[zn]||j[We]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=k.createElement(b),k.head.insertBefore(j,k.querySelector("head > title"))),Fs(j,b,m),j[We]=l,bs(j),b=j;break e;case"link":var F=vx("link","href",k).get(b+(m.href||""));if(F){for(var X=0;X<F.length;X++)if(j=F[X],j.getAttribute("href")===(m.href==null||m.href===""?null:m.href)&&j.getAttribute("rel")===(m.rel==null?null:m.rel)&&j.getAttribute("title")===(m.title==null?null:m.title)&&j.getAttribute("crossorigin")===(m.crossOrigin==null?null:m.crossOrigin)){F.splice(X,1);break t}}j=k.createElement(b),Fs(j,b,m),k.head.appendChild(j);break;case"meta":if(F=vx("meta","content",k).get(b+(m.content||""))){for(X=0;X<F.length;X++)if(j=F[X],j.getAttribute("content")===(m.content==null?null:""+m.content)&&j.getAttribute("name")===(m.name==null?null:m.name)&&j.getAttribute("property")===(m.property==null?null:m.property)&&j.getAttribute("http-equiv")===(m.httpEquiv==null?null:m.httpEquiv)&&j.getAttribute("charset")===(m.charSet==null?null:m.charSet)){F.splice(X,1);break t}}j=k.createElement(b),Fs(j,b,m),k.head.appendChild(j);break;default:throw Error(n(468,b))}j[We]=l,bs(j),b=j}l.stateNode=b}else wx(k,l.type,l.stateNode);else l.stateNode=xx(k,b,l.memoizedProps);else j!==b?(j===null?m.stateNode!==null&&(m=m.stateNode,m.parentNode.removeChild(m)):j.count--,b===null?wx(k,l.type,l.stateNode):xx(k,b,l.memoizedProps)):b===null&&l.stateNode!==null&&Th(l,l.memoizedProps,m.memoizedProps)}break;case 27:tn(u,l),sn(l),b&512&&(As||m===null||sa(m,m.return)),m!==null&&b&4&&Th(l,l.memoizedProps,m.memoizedProps);break;case 5:if(tn(u,l),sn(l),b&512&&(As||m===null||sa(m,m.return)),l.flags&32){k=l.stateNode;try{yo(k,"")}catch(tt){Kt(l,l.return,tt)}}b&4&&l.stateNode!=null&&(k=l.memoizedProps,Th(l,k,m!==null?m.memoizedProps:k)),b&1024&&(_h=!0);break;case 6:if(tn(u,l),sn(l),b&4){if(l.stateNode===null)throw Error(n(162));b=l.memoizedProps,m=l.stateNode;try{m.nodeValue=b}catch(tt){Kt(l,l.return,tt)}}break;case 3:if(Zc=null,k=Hn,Hn=Yc(u.containerInfo),tn(u,l),Hn=k,sn(l),b&4&&m!==null&&m.memoizedState.isDehydrated)try{Yo(u.containerInfo)}catch(tt){Kt(l,l.return,tt)}_h&&(_h=!1,wy(l));break;case 4:b=Hn,Hn=Yc(l.stateNode.containerInfo),tn(u,l),sn(l),Hn=b;break;case 12:tn(u,l),sn(l);break;case 31:tn(u,l),sn(l),b&4&&(b=l.updateQueue,b!==null&&(l.updateQueue=null,Bc(l,b)));break;case 13:tn(u,l),sn(l),l.child.flags&8192&&l.memoizedState!==null!=(m!==null&&m.memoizedState!==null)&&(Pc=qe()),b&4&&(b=l.updateQueue,b!==null&&(l.updateQueue=null,Bc(l,b)));break;case 22:k=l.memoizedState!==null;var ie=m!==null&&m.memoizedState!==null,we=Ma,Ee=As;if(Ma=we||k,As=Ee||ie,tn(u,l),As=Ee,Ma=we,sn(l),b&8192)e:for(u=l.stateNode,u._visibility=k?u._visibility&-2:u._visibility|1,k&&(m===null||ie||Ma||As||Wi(l)),m=null,u=l;;){if(u.tag===5||u.tag===26){if(m===null){ie=m=u;try{if(j=ie.stateNode,k)F=j.style,typeof F.setProperty=="function"?F.setProperty("display","none","important"):F.display="none";else{X=ie.stateNode;var Oe=ie.memoizedProps.style,je=Oe!=null&&Oe.hasOwnProperty("display")?Oe.display:null;X.style.display=je==null||typeof je=="boolean"?"":(""+je).trim()}}catch(tt){Kt(ie,ie.return,tt)}}}else if(u.tag===6){if(m===null){ie=u;try{ie.stateNode.nodeValue=k?"":ie.memoizedProps}catch(tt){Kt(ie,ie.return,tt)}}}else if(u.tag===18){if(m===null){ie=u;try{var Te=ie.stateNode;k?ux(Te,!0):ux(ie.stateNode,!1)}catch(tt){Kt(ie,ie.return,tt)}}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===l)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break e;for(;u.sibling===null;){if(u.return===null||u.return===l)break e;m===u&&(m=null),u=u.return}m===u&&(m=null),u.sibling.return=u.return,u=u.sibling}b&4&&(b=l.updateQueue,b!==null&&(m=b.retryQueue,m!==null&&(b.retryQueue=null,Bc(l,m))));break;case 19:tn(u,l),sn(l),b&4&&(b=l.updateQueue,b!==null&&(l.updateQueue=null,Bc(l,b)));break;case 30:break;case 21:break;default:tn(u,l),sn(l)}}function sn(l){var u=l.flags;if(u&2){try{for(var m,b=l.return;b!==null;){if(hy(b)){m=b;break}b=b.return}if(m==null)throw Error(n(160));switch(m.tag){case 27:var k=m.stateNode,j=Mh(l);Lc(l,j,k);break;case 5:var F=m.stateNode;m.flags&32&&(yo(F,""),m.flags&=-33);var X=Mh(l);Lc(l,X,F);break;case 3:case 4:var ie=m.stateNode.containerInfo,we=Mh(l);Eh(l,we,ie);break;default:throw Error(n(161))}}catch(Ee){Kt(l,l.return,Ee)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function wy(l){if(l.subtreeFlags&1024)for(l=l.child;l!==null;){var u=l;wy(u),u.tag===5&&u.flags&1024&&u.stateNode.reset(),l=l.sibling}}function _a(l,u){if(u.subtreeFlags&8772)for(u=u.child;u!==null;)fy(l,u.alternate,u),u=u.sibling}function Wi(l){for(l=l.child;l!==null;){var u=l;switch(u.tag){case 0:case 11:case 14:case 15:ei(4,u,u.return),Wi(u);break;case 1:sa(u,u.return);var m=u.stateNode;typeof m.componentWillUnmount=="function"&&uy(u,u.return,m),Wi(u);break;case 27:sl(u.stateNode);case 26:case 5:sa(u,u.return),Wi(u);break;case 22:u.memoizedState===null&&Wi(u);break;case 30:Wi(u);break;default:Wi(u)}l=l.sibling}}function Ra(l,u,m){for(m=m&&(u.subtreeFlags&8772)!==0,u=u.child;u!==null;){var b=u.alternate,k=l,j=u,F=j.flags;switch(j.tag){case 0:case 11:case 15:Ra(k,j,m),Wr(4,j);break;case 1:if(Ra(k,j,m),b=j,k=b.stateNode,typeof k.componentDidMount=="function")try{k.componentDidMount()}catch(we){Kt(b,b.return,we)}if(b=j,k=b.updateQueue,k!==null){var X=b.stateNode;try{var ie=k.shared.hiddenCallbacks;if(ie!==null)for(k.shared.hiddenCallbacks=null,k=0;k<ie.length;k++)Qg(ie[k],X)}catch(we){Kt(b,b.return,we)}}m&&F&64&&cy(j),Kr(j,j.return);break;case 27:my(j);case 26:case 5:Ra(k,j,m),m&&b===null&&F&4&&dy(j),Kr(j,j.return);break;case 12:Ra(k,j,m);break;case 31:Ra(k,j,m),m&&F&4&&yy(k,j);break;case 13:Ra(k,j,m),m&&F&4&&xy(k,j);break;case 22:j.memoizedState===null&&Ra(k,j,m),Kr(j,j.return);break;case 30:break;default:Ra(k,j,m)}u=u.sibling}}function Rh(l,u){var m=null;l!==null&&l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(m=l.memoizedState.cachePool.pool),l=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(l=u.memoizedState.cachePool.pool),l!==m&&(l!=null&&l.refCount++,m!=null&&Dr(m))}function Dh(l,u){l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&Dr(l))}function $n(l,u,m,b){if(u.subtreeFlags&10256)for(u=u.child;u!==null;)ky(l,u,m,b),u=u.sibling}function ky(l,u,m,b){var k=u.flags;switch(u.tag){case 0:case 11:case 15:$n(l,u,m,b),k&2048&&Wr(9,u);break;case 1:$n(l,u,m,b);break;case 3:$n(l,u,m,b),k&2048&&(l=null,u.alternate!==null&&(l=u.alternate.memoizedState.cache),u=u.memoizedState.cache,u!==l&&(u.refCount++,l!=null&&Dr(l)));break;case 12:if(k&2048){$n(l,u,m,b),l=u.stateNode;try{var j=u.memoizedProps,F=j.id,X=j.onPostCommit;typeof X=="function"&&X(F,u.alternate===null?"mount":"update",l.passiveEffectDuration,-0)}catch(ie){Kt(u,u.return,ie)}}else $n(l,u,m,b);break;case 31:$n(l,u,m,b);break;case 13:$n(l,u,m,b);break;case 23:break;case 22:j=u.stateNode,F=u.alternate,u.memoizedState!==null?j._visibility&2?$n(l,u,m,b):Vr(l,u):j._visibility&2?$n(l,u,m,b):(j._visibility|=2,Io(l,u,m,b,(u.subtreeFlags&10256)!==0||!1)),k&2048&&Rh(F,u);break;case 24:$n(l,u,m,b),k&2048&&Dh(u.alternate,u);break;default:$n(l,u,m,b)}}function Io(l,u,m,b,k){for(k=k&&((u.subtreeFlags&10256)!==0||!1),u=u.child;u!==null;){var j=l,F=u,X=m,ie=b,we=F.flags;switch(F.tag){case 0:case 11:case 15:Io(j,F,X,ie,k),Wr(8,F);break;case 23:break;case 22:var Ee=F.stateNode;F.memoizedState!==null?Ee._visibility&2?Io(j,F,X,ie,k):Vr(j,F):(Ee._visibility|=2,Io(j,F,X,ie,k)),k&&we&2048&&Rh(F.alternate,F);break;case 24:Io(j,F,X,ie,k),k&&we&2048&&Dh(F.alternate,F);break;default:Io(j,F,X,ie,k)}u=u.sibling}}function Vr(l,u){if(u.subtreeFlags&10256)for(u=u.child;u!==null;){var m=l,b=u,k=b.flags;switch(b.tag){case 22:Vr(m,b),k&2048&&Rh(b.alternate,b);break;case 24:Vr(m,b),k&2048&&Dh(b.alternate,b);break;default:Vr(m,b)}u=u.sibling}}var Yr=8192;function zo(l,u,m){if(l.subtreeFlags&Yr)for(l=l.child;l!==null;)Sy(l,u,m),l=l.sibling}function Sy(l,u,m){switch(l.tag){case 26:zo(l,u,m),l.flags&Yr&&l.memoizedState!==null&&dA(m,Hn,l.memoizedState,l.memoizedProps);break;case 5:zo(l,u,m);break;case 3:case 4:var b=Hn;Hn=Yc(l.stateNode.containerInfo),zo(l,u,m),Hn=b;break;case 22:l.memoizedState===null&&(b=l.alternate,b!==null&&b.memoizedState!==null?(b=Yr,Yr=16777216,zo(l,u,m),Yr=b):zo(l,u,m));break;default:zo(l,u,m)}}function jy(l){var u=l.alternate;if(u!==null&&(l=u.child,l!==null)){u.child=null;do u=l.sibling,l.sibling=null,l=u;while(l!==null)}}function Xr(l){var u=l.deletions;if((l.flags&16)!==0){if(u!==null)for(var m=0;m<u.length;m++){var b=u[m];Bs=b,Ay(b,l)}jy(l)}if(l.subtreeFlags&10256)for(l=l.child;l!==null;)Cy(l),l=l.sibling}function Cy(l){switch(l.tag){case 0:case 11:case 15:Xr(l),l.flags&2048&&ei(9,l,l.return);break;case 3:Xr(l);break;case 12:Xr(l);break;case 22:var u=l.stateNode;l.memoizedState!==null&&u._visibility&2&&(l.return===null||l.return.tag!==13)?(u._visibility&=-3,Oc(l)):Xr(l);break;default:Xr(l)}}function Oc(l){var u=l.deletions;if((l.flags&16)!==0){if(u!==null)for(var m=0;m<u.length;m++){var b=u[m];Bs=b,Ay(b,l)}jy(l)}for(l=l.child;l!==null;){switch(u=l,u.tag){case 0:case 11:case 15:ei(8,u,u.return),Oc(u);break;case 22:m=u.stateNode,m._visibility&2&&(m._visibility&=-3,Oc(u));break;default:Oc(u)}l=l.sibling}}function Ay(l,u){for(;Bs!==null;){var m=Bs;switch(m.tag){case 0:case 11:case 15:ei(8,m,u);break;case 23:case 22:if(m.memoizedState!==null&&m.memoizedState.cachePool!==null){var b=m.memoizedState.cachePool.pool;b!=null&&b.refCount++}break;case 24:Dr(m.memoizedState.cache)}if(b=m.child,b!==null)b.return=m,Bs=b;else e:for(m=l;Bs!==null;){b=Bs;var k=b.sibling,j=b.return;if(gy(b),b===m){Bs=null;break e}if(k!==null){k.return=j,Bs=k;break e}Bs=j}}}var AC={getCacheForType:function(l){var u=Is(Ss),m=u.data.get(l);return m===void 0&&(m=l(),u.data.set(l,m)),m},cacheSignal:function(){return Is(Ss).controller.signal}},NC=typeof WeakMap=="function"?WeakMap:Map,Gt=0,ts=null,_t=null,Bt=0,Wt=0,fn=null,ti=!1,Fo=!1,Lh=!1,Da=0,fs=0,si=0,Ki=0,Bh=0,gn=0,Ho=0,Zr=null,nn=null,Oh=!1,Pc=0,Ny=0,Ic=1/0,zc=null,ni=null,_s=0,ai=null,$o=null,La=0,Ph=0,Ih=null,Ty=null,Qr=0,zh=null;function bn(){return(Gt&2)!==0&&Bt!==0?Bt&-Bt:L.T!==null?qh():He()}function My(){if(gn===0)if((Bt&536870912)===0||It){var l=se;se<<=1,(se&3932160)===0&&(se=262144),gn=l}else gn=536870912;return l=mn.current,l!==null&&(l.flags|=32),gn}function an(l,u,m){(l===ts&&(Wt===2||Wt===9)||l.cancelPendingCommit!==null)&&(Uo(l,0),ii(l,Bt,gn,!1)),Se(l,m),((Gt&2)===0||l!==ts)&&(l===ts&&((Gt&2)===0&&(Ki|=m),fs===4&&ii(l,Bt,gn,!1)),na(l))}function Ey(l,u,m){if((Gt&6)!==0)throw Error(n(327));var b=!m&&(u&127)===0&&(u&l.expiredLanes)===0||wt(l,u),k=b?EC(l,u):Hh(l,u,!0),j=b;do{if(k===0){Fo&&!b&&ii(l,u,0,!1);break}else{if(m=l.current.alternate,j&&!TC(m)){k=Hh(l,u,!1),j=!1;continue}if(k===2){if(j=u,l.errorRecoveryDisabledLanes&j)var F=0;else F=l.pendingLanes&-536870913,F=F!==0?F:F&536870912?536870912:0;if(F!==0){u=F;e:{var X=l;k=Zr;var ie=X.current.memoizedState.isDehydrated;if(ie&&(Uo(X,F).flags|=256),F=Hh(X,F,!1),F!==2){if(Lh&&!ie){X.errorRecoveryDisabledLanes|=j,Ki|=j,k=4;break e}j=nn,nn=k,j!==null&&(nn===null?nn=j:nn.push.apply(nn,j))}k=F}if(j=!1,k!==2)continue}}if(k===1){Uo(l,0),ii(l,u,0,!0);break}e:{switch(b=l,j=k,j){case 0:case 1:throw Error(n(345));case 4:if((u&4194048)!==u)break;case 6:ii(b,u,gn,!ti);break e;case 2:nn=null;break;case 3:case 5:break;default:throw Error(n(329))}if((u&62914560)===u&&(k=Pc+300-qe(),10<k)){if(ii(b,u,gn,!ti),ct(b,0,!0)!==0)break e;La=u,b.timeoutHandle=rx(_y.bind(null,b,m,nn,zc,Oh,u,gn,Ki,Ho,ti,j,"Throttled",-0,0),k);break e}_y(b,m,nn,zc,Oh,u,gn,Ki,Ho,ti,j,null,-0,0)}}break}while(!0);na(l)}function _y(l,u,m,b,k,j,F,X,ie,we,Ee,Oe,je,Te){if(l.timeoutHandle=-1,Oe=u.subtreeFlags,Oe&8192||(Oe&16785408)===16785408){Oe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:xa},Sy(u,j,Oe);var tt=(j&62914560)===j?Pc-qe():(j&4194048)===j?Ny-qe():0;if(tt=hA(Oe,tt),tt!==null){La=j,l.cancelPendingCommit=tt(zy.bind(null,l,u,j,m,b,k,F,X,ie,Ee,Oe,null,je,Te)),ii(l,j,F,!we);return}}zy(l,u,j,m,b,k,F,X,ie)}function TC(l){for(var u=l;;){var m=u.tag;if((m===0||m===11||m===15)&&u.flags&16384&&(m=u.updateQueue,m!==null&&(m=m.stores,m!==null)))for(var b=0;b<m.length;b++){var k=m[b],j=k.getSnapshot;k=k.value;try{if(!dn(j(),k))return!1}catch{return!1}}if(m=u.child,u.subtreeFlags&16384&&m!==null)m.return=u,u=m;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function ii(l,u,m,b){u&=~Bh,u&=~Ki,l.suspendedLanes|=u,l.pingedLanes&=~u,b&&(l.warmLanes|=u),b=l.expirationTimes;for(var k=u;0<k;){var j=31-Qe(k),F=1<<j;b[j]=-1,k&=~F}m!==0&&et(l,m,u)}function Fc(){return(Gt&6)===0?(Jr(0),!1):!0}function Fh(){if(_t!==null){if(Wt===0)var l=_t.return;else l=_t,Sa=Ii=null,sh(l),Do=null,Br=0,l=_t;for(;l!==null;)ly(l.alternate,l),l=l.return;_t=null}}function Uo(l,u){var m=l.timeoutHandle;m!==-1&&(l.timeoutHandle=-1,VC(m)),m=l.cancelPendingCommit,m!==null&&(l.cancelPendingCommit=null,m()),La=0,Fh(),ts=l,_t=m=wa(l.current,null),Bt=u,Wt=0,fn=null,ti=!1,Fo=wt(l,u),Lh=!1,Ho=gn=Bh=Ki=si=fs=0,nn=Zr=null,Oh=!1,(u&8)!==0&&(u|=u&32);var b=l.entangledLanes;if(b!==0)for(l=l.entanglements,b&=u;0<b;){var k=31-Qe(b),j=1<<k;u|=l[k],b&=~j}return Da=u,rc(),m}function Ry(l,u){yt=null,L.H=Ur,u===Ro||u===fc?(u=Vg(),Wt=3):u===Gd?(u=Vg(),Wt=4):Wt=u===yh?8:u!==null&&typeof u=="object"&&typeof u.then=="function"?6:1,fn=u,_t===null&&(fs=1,Mc(l,Cn(u,l.current)))}function Dy(){var l=mn.current;return l===null?!0:(Bt&4194048)===Bt?Mn===null:(Bt&62914560)===Bt||(Bt&536870912)!==0?l===Mn:!1}function Ly(){var l=L.H;return L.H=Ur,l===null?Ur:l}function By(){var l=L.A;return L.A=AC,l}function Hc(){fs=4,ti||(Bt&4194048)!==Bt&&mn.current!==null||(Fo=!0),(si&134217727)===0&&(Ki&134217727)===0||ts===null||ii(ts,Bt,gn,!1)}function Hh(l,u,m){var b=Gt;Gt|=2;var k=Ly(),j=By();(ts!==l||Bt!==u)&&(zc=null,Uo(l,u)),u=!1;var F=fs;e:do try{if(Wt!==0&&_t!==null){var X=_t,ie=fn;switch(Wt){case 8:Fh(),F=6;break e;case 3:case 2:case 9:case 6:mn.current===null&&(u=!0);var we=Wt;if(Wt=0,fn=null,Go(l,X,ie,we),m&&Fo){F=0;break e}break;default:we=Wt,Wt=0,fn=null,Go(l,X,ie,we)}}MC(),F=fs;break}catch(Ee){Ry(l,Ee)}while(!0);return u&&l.shellSuspendCounter++,Sa=Ii=null,Gt=b,L.H=k,L.A=j,_t===null&&(ts=null,Bt=0,rc()),F}function MC(){for(;_t!==null;)Oy(_t)}function EC(l,u){var m=Gt;Gt|=2;var b=Ly(),k=By();ts!==l||Bt!==u?(zc=null,Ic=qe()+500,Uo(l,u)):Fo=wt(l,u);e:do try{if(Wt!==0&&_t!==null){u=_t;var j=fn;t:switch(Wt){case 1:Wt=0,fn=null,Go(l,u,j,1);break;case 2:case 9:if(Wg(j)){Wt=0,fn=null,Py(u);break}u=function(){Wt!==2&&Wt!==9||ts!==l||(Wt=7),na(l)},j.then(u,u);break e;case 3:Wt=7;break e;case 4:Wt=5;break e;case 7:Wg(j)?(Wt=0,fn=null,Py(u)):(Wt=0,fn=null,Go(l,u,j,7));break;case 5:var F=null;switch(_t.tag){case 26:F=_t.memoizedState;case 5:case 27:var X=_t;if(F?kx(F):X.stateNode.complete){Wt=0,fn=null;var ie=X.sibling;if(ie!==null)_t=ie;else{var we=X.return;we!==null?(_t=we,$c(we)):_t=null}break t}}Wt=0,fn=null,Go(l,u,j,5);break;case 6:Wt=0,fn=null,Go(l,u,j,6);break;case 8:Fh(),fs=6;break e;default:throw Error(n(462))}}_C();break}catch(Ee){Ry(l,Ee)}while(!0);return Sa=Ii=null,L.H=b,L.A=k,Gt=m,_t!==null?0:(ts=null,Bt=0,rc(),fs)}function _C(){for(;_t!==null&&!Ue();)Oy(_t)}function Oy(l){var u=oy(l.alternate,l,Da);l.memoizedProps=l.pendingProps,u===null?$c(l):_t=u}function Py(l){var u=l,m=u.alternate;switch(u.tag){case 15:case 0:u=ey(m,u,u.pendingProps,u.type,void 0,Bt);break;case 11:u=ey(m,u,u.pendingProps,u.type.render,u.ref,Bt);break;case 5:sh(u);default:ly(m,u),u=_t=Bg(u,Da),u=oy(m,u,Da)}l.memoizedProps=l.pendingProps,u===null?$c(l):_t=u}function Go(l,u,m,b){Sa=Ii=null,sh(u),Do=null,Br=0;var k=u.return;try{if(xC(l,k,u,m,Bt)){fs=1,Mc(l,Cn(m,l.current)),_t=null;return}}catch(j){if(k!==null)throw _t=k,j;fs=1,Mc(l,Cn(m,l.current)),_t=null;return}u.flags&32768?(It||b===1?l=!0:Fo||(Bt&536870912)!==0?l=!1:(ti=l=!0,(b===2||b===9||b===3||b===6)&&(b=mn.current,b!==null&&b.tag===13&&(b.flags|=16384))),Iy(u,l)):$c(u)}function $c(l){var u=l;do{if((u.flags&32768)!==0){Iy(u,ti);return}l=u.return;var m=kC(u.alternate,u,Da);if(m!==null){_t=m;return}if(u=u.sibling,u!==null){_t=u;return}_t=u=l}while(u!==null);fs===0&&(fs=5)}function Iy(l,u){do{var m=SC(l.alternate,l);if(m!==null){m.flags&=32767,_t=m;return}if(m=l.return,m!==null&&(m.flags|=32768,m.subtreeFlags=0,m.deletions=null),!u&&(l=l.sibling,l!==null)){_t=l;return}_t=l=m}while(l!==null);fs=6,_t=null}function zy(l,u,m,b,k,j,F,X,ie){l.cancelPendingCommit=null;do Uc();while(_s!==0);if((Gt&6)!==0)throw Error(n(327));if(u!==null){if(u===l.current)throw Error(n(177));if(j=u.lanes|u.childLanes,j|=Md,Fe(l,m,j,F,X,ie),l===ts&&(_t=ts=null,Bt=0),$o=u,ai=l,La=m,Ph=j,Ih=k,Ty=b,(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?(l.callbackNode=null,l.callbackPriority=0,BC(Ie,function(){return Gy(),null})):(l.callbackNode=null,l.callbackPriority=0),b=(u.flags&13878)!==0,(u.subtreeFlags&13878)!==0||b){b=L.T,L.T=null,k=q.p,q.p=2,F=Gt,Gt|=4;try{jC(l,u,m)}finally{Gt=F,q.p=k,L.T=b}}_s=1,Fy(),Hy(),$y()}}function Fy(){if(_s===1){_s=0;var l=ai,u=$o,m=(u.flags&13878)!==0;if((u.subtreeFlags&13878)!==0||m){m=L.T,L.T=null;var b=q.p;q.p=2;var k=Gt;Gt|=4;try{vy(u,l);var j=Jh,F=Ag(l.containerInfo),X=j.focusedElem,ie=j.selectionRange;if(F!==X&&X&&X.ownerDocument&&Cg(X.ownerDocument.documentElement,X)){if(ie!==null&&jd(X)){var we=ie.start,Ee=ie.end;if(Ee===void 0&&(Ee=we),"selectionStart"in X)X.selectionStart=we,X.selectionEnd=Math.min(Ee,X.value.length);else{var Oe=X.ownerDocument||document,je=Oe&&Oe.defaultView||window;if(je.getSelection){var Te=je.getSelection(),tt=X.textContent.length,ht=Math.min(ie.start,tt),Qt=ie.end===void 0?ht:Math.min(ie.end,tt);!Te.extend&&ht>Qt&&(F=Qt,Qt=ht,ht=F);var be=jg(X,ht),de=jg(X,Qt);if(be&&de&&(Te.rangeCount!==1||Te.anchorNode!==be.node||Te.anchorOffset!==be.offset||Te.focusNode!==de.node||Te.focusOffset!==de.offset)){var ve=Oe.createRange();ve.setStart(be.node,be.offset),Te.removeAllRanges(),ht>Qt?(Te.addRange(ve),Te.extend(de.node,de.offset)):(ve.setEnd(de.node,de.offset),Te.addRange(ve))}}}}for(Oe=[],Te=X;Te=Te.parentNode;)Te.nodeType===1&&Oe.push({element:Te,left:Te.scrollLeft,top:Te.scrollTop});for(typeof X.focus=="function"&&X.focus(),X=0;X<Oe.length;X++){var De=Oe[X];De.element.scrollLeft=De.left,De.element.scrollTop=De.top}}tu=!!Qh,Jh=Qh=null}finally{Gt=k,q.p=b,L.T=m}}l.current=u,_s=2}}function Hy(){if(_s===2){_s=0;var l=ai,u=$o,m=(u.flags&8772)!==0;if((u.subtreeFlags&8772)!==0||m){m=L.T,L.T=null;var b=q.p;q.p=2;var k=Gt;Gt|=4;try{fy(l,u.alternate,u)}finally{Gt=k,q.p=b,L.T=m}}_s=3}}function $y(){if(_s===4||_s===3){_s=0,Xe();var l=ai,u=$o,m=La,b=Ty;(u.subtreeFlags&10256)!==0||(u.flags&10256)!==0?_s=5:(_s=0,$o=ai=null,Uy(l,l.pendingLanes));var k=l.pendingLanes;if(k===0&&(ni=null),Ce(m),u=u.stateNode,bt&&typeof bt.onCommitFiberRoot=="function")try{bt.onCommitFiberRoot(ft,u,void 0,(u.current.flags&128)===128)}catch{}if(b!==null){u=L.T,k=q.p,q.p=2,L.T=null;try{for(var j=l.onRecoverableError,F=0;F<b.length;F++){var X=b[F];j(X.value,{componentStack:X.stack})}}finally{L.T=u,q.p=k}}(La&3)!==0&&Uc(),na(l),k=l.pendingLanes,(m&261930)!==0&&(k&42)!==0?l===zh?Qr++:(Qr=0,zh=l):Qr=0,Jr(0)}}function Uy(l,u){(l.pooledCacheLanes&=u)===0&&(u=l.pooledCache,u!=null&&(l.pooledCache=null,Dr(u)))}function Uc(){return Fy(),Hy(),$y(),Gy()}function Gy(){if(_s!==5)return!1;var l=ai,u=Ph;Ph=0;var m=Ce(La),b=L.T,k=q.p;try{q.p=32>m?32:m,L.T=null,m=Ih,Ih=null;var j=ai,F=La;if(_s=0,$o=ai=null,La=0,(Gt&6)!==0)throw Error(n(331));var X=Gt;if(Gt|=4,Cy(j.current),ky(j,j.current,F,m),Gt=X,Jr(0,!1),bt&&typeof bt.onPostCommitFiberRoot=="function")try{bt.onPostCommitFiberRoot(ft,j)}catch{}return!0}finally{q.p=k,L.T=b,Uy(l,u)}}function qy(l,u,m){u=Cn(m,u),u=bh(l.stateNode,u,2),l=Za(l,u,2),l!==null&&(Se(l,2),na(l))}function Kt(l,u,m){if(l.tag===3)qy(l,l,m);else for(;u!==null;){if(u.tag===3){qy(u,l,m);break}else if(u.tag===1){var b=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof b.componentDidCatch=="function"&&(ni===null||!ni.has(b))){l=Cn(m,l),m=Wb(2),b=Za(u,m,2),b!==null&&(Kb(m,b,u,l),Se(b,2),na(b));break}}u=u.return}}function $h(l,u,m){var b=l.pingCache;if(b===null){b=l.pingCache=new NC;var k=new Set;b.set(u,k)}else k=b.get(u),k===void 0&&(k=new Set,b.set(u,k));k.has(m)||(Lh=!0,k.add(m),l=RC.bind(null,l,u,m),u.then(l,l))}function RC(l,u,m){var b=l.pingCache;b!==null&&b.delete(u),l.pingedLanes|=l.suspendedLanes&m,l.warmLanes&=~m,ts===l&&(Bt&m)===m&&(fs===4||fs===3&&(Bt&62914560)===Bt&&300>qe()-Pc?(Gt&2)===0&&Uo(l,0):Bh|=m,Ho===Bt&&(Ho=0)),na(l)}function Wy(l,u){u===0&&(u=Vt()),l=Bi(l,u),l!==null&&(Se(l,u),na(l))}function DC(l){var u=l.memoizedState,m=0;u!==null&&(m=u.retryLane),Wy(l,m)}function LC(l,u){var m=0;switch(l.tag){case 31:case 13:var b=l.stateNode,k=l.memoizedState;k!==null&&(m=k.retryLane);break;case 19:b=l.stateNode;break;case 22:b=l.stateNode._retryCache;break;default:throw Error(n(314))}b!==null&&b.delete(u),Wy(l,m)}function BC(l,u){return _e(l,u)}var Gc=null,qo=null,Uh=!1,qc=!1,Gh=!1,oi=0;function na(l){l!==qo&&l.next===null&&(qo===null?Gc=qo=l:qo=qo.next=l),qc=!0,Uh||(Uh=!0,PC())}function Jr(l,u){if(!Gh&&qc){Gh=!0;do for(var m=!1,b=Gc;b!==null;){if(l!==0){var k=b.pendingLanes;if(k===0)var j=0;else{var F=b.suspendedLanes,X=b.pingedLanes;j=(1<<31-Qe(42|l)+1)-1,j&=k&~(F&~X),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(m=!0,Xy(b,j))}else j=Bt,j=ct(b,b===ts?j:0,b.cancelPendingCommit!==null||b.timeoutHandle!==-1),(j&3)===0||wt(b,j)||(m=!0,Xy(b,j));b=b.next}while(m);Gh=!1}}function OC(){Ky()}function Ky(){qc=Uh=!1;var l=0;oi!==0&&KC()&&(l=oi);for(var u=qe(),m=null,b=Gc;b!==null;){var k=b.next,j=Vy(b,u);j===0?(b.next=null,m===null?Gc=k:m.next=k,k===null&&(qo=m)):(m=b,(l!==0||(j&3)!==0)&&(qc=!0)),b=k}_s!==0&&_s!==5||Jr(l),oi!==0&&(oi=0)}function Vy(l,u){for(var m=l.suspendedLanes,b=l.pingedLanes,k=l.expirationTimes,j=l.pendingLanes&-62914561;0<j;){var F=31-Qe(j),X=1<<F,ie=k[F];ie===-1?((X&m)===0||(X&b)!==0)&&(k[F]=rs(X,u)):ie<=u&&(l.expiredLanes|=X),j&=~X}if(u=ts,m=Bt,m=ct(l,l===u?m:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),b=l.callbackNode,m===0||l===u&&(Wt===2||Wt===9)||l.cancelPendingCommit!==null)return b!==null&&b!==null&&Le(b),l.callbackNode=null,l.callbackPriority=0;if((m&3)===0||wt(l,m)){if(u=m&-m,u===l.callbackPriority)return u;switch(b!==null&&Le(b),Ce(m)){case 2:case 8:m=ge;break;case 32:m=Ie;break;case 268435456:m=ze;break;default:m=Ie}return b=Yy.bind(null,l),m=_e(m,b),l.callbackPriority=u,l.callbackNode=m,u}return b!==null&&b!==null&&Le(b),l.callbackPriority=2,l.callbackNode=null,2}function Yy(l,u){if(_s!==0&&_s!==5)return l.callbackNode=null,l.callbackPriority=0,null;var m=l.callbackNode;if(Uc()&&l.callbackNode!==m)return null;var b=Bt;return b=ct(l,l===ts?b:0,l.cancelPendingCommit!==null||l.timeoutHandle!==-1),b===0?null:(Ey(l,b,u),Vy(l,qe()),l.callbackNode!=null&&l.callbackNode===m?Yy.bind(null,l):null)}function Xy(l,u){if(Uc())return null;Ey(l,u,!0)}function PC(){YC(function(){(Gt&6)!==0?_e(ee,OC):Ky()})}function qh(){if(oi===0){var l=Eo;l===0&&(l=ye,ye<<=1,(ye&261888)===0&&(ye=256)),oi=l}return oi}function Zy(l){return l==null||typeof l=="symbol"||typeof l=="boolean"?null:typeof l=="function"?l:Jl(""+l)}function Qy(l,u){var m=u.ownerDocument.createElement("input");return m.name=u.name,m.value=u.value,l.id&&m.setAttribute("form",l.id),u.parentNode.insertBefore(m,u),l=new FormData(l),m.parentNode.removeChild(m),l}function IC(l,u,m,b,k){if(u==="submit"&&m&&m.stateNode===k){var j=Zy((k[Ye]||null).action),F=b.submitter;F&&(u=(u=F[Ye]||null)?Zy(u.formAction):F.getAttribute("formAction"),u!==null&&(j=u,F=null));var X=new nc("action","action",null,b,k);l.push({event:X,listeners:[{instance:null,listener:function(){if(b.defaultPrevented){if(oi!==0){var ie=F?Qy(k,F):new FormData(k);dh(m,{pending:!0,data:ie,method:k.method,action:j},null,ie)}}else typeof j=="function"&&(X.preventDefault(),ie=F?Qy(k,F):new FormData(k),dh(m,{pending:!0,data:ie,method:k.method,action:j},j,ie))},currentTarget:k}]})}}for(var Wh=0;Wh<Td.length;Wh++){var Kh=Td[Wh],zC=Kh.toLowerCase(),FC=Kh[0].toUpperCase()+Kh.slice(1);Fn(zC,"on"+FC)}Fn(Mg,"onAnimationEnd"),Fn(Eg,"onAnimationIteration"),Fn(_g,"onAnimationStart"),Fn("dblclick","onDoubleClick"),Fn("focusin","onFocus"),Fn("focusout","onBlur"),Fn(sC,"onTransitionRun"),Fn(nC,"onTransitionStart"),Fn(aC,"onTransitionCancel"),Fn(Rg,"onTransitionEnd"),ga("onMouseEnter",["mouseout","mouseover"]),ga("onMouseLeave",["mouseout","mouseover"]),ga("onPointerEnter",["pointerout","pointerover"]),ga("onPointerLeave",["pointerout","pointerover"]),Jn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Jn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Jn("onBeforeInput",["compositionend","keypress","textInput","paste"]),Jn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Jn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Jn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var el="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(" "),HC=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(el));function Jy(l,u){u=(u&4)!==0;for(var m=0;m<l.length;m++){var b=l[m],k=b.event;b=b.listeners;e:{var j=void 0;if(u)for(var F=b.length-1;0<=F;F--){var X=b[F],ie=X.instance,we=X.currentTarget;if(X=X.listener,ie!==j&&k.isPropagationStopped())break e;j=X,k.currentTarget=we;try{j(k)}catch(Ee){oc(Ee)}k.currentTarget=null,j=ie}else for(F=0;F<b.length;F++){if(X=b[F],ie=X.instance,we=X.currentTarget,X=X.listener,ie!==j&&k.isPropagationStopped())break e;j=X,k.currentTarget=we;try{j(k)}catch(Ee){oc(Ee)}k.currentTarget=null,j=ie}}}}function Rt(l,u){var m=u[Yt];m===void 0&&(m=u[Yt]=new Set);var b=l+"__bubble";m.has(b)||(ex(u,l,2,!1),m.add(b))}function Vh(l,u,m){var b=0;u&&(b|=4),ex(m,l,b,u)}var Wc="_reactListening"+Math.random().toString(36).slice(2);function Yh(l){if(!l[Wc]){l[Wc]=!0,fr.forEach(function(m){m!=="selectionchange"&&(HC.has(m)||Vh(m,!1,l),Vh(m,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[Wc]||(u[Wc]=!0,Vh("selectionchange",!1,u))}}function ex(l,u,m,b){switch(Mx(u)){case 2:var k=fA;break;case 8:k=gA;break;default:k=um}m=k.bind(null,u,m,l),k=void 0,!fd||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(k=!0),b?k!==void 0?l.addEventListener(u,m,{capture:!0,passive:k}):l.addEventListener(u,m,!0):k!==void 0?l.addEventListener(u,m,{passive:k}):l.addEventListener(u,m,!1)}function Xh(l,u,m,b,k){var j=b;if((u&1)===0&&(u&2)===0&&b!==null)e:for(;;){if(b===null)return;var F=b.tag;if(F===3||F===4){var X=b.stateNode.containerInfo;if(X===k)break;if(F===4)for(F=b.return;F!==null;){var ie=F.tag;if((ie===3||ie===4)&&F.stateNode.containerInfo===k)return;F=F.return}for(;X!==null;){if(F=Ut(X),F===null)return;if(ie=F.tag,ie===5||ie===6||ie===26||ie===27){b=j=F;continue e}X=X.parentNode}}b=b.return}ig(function(){var we=j,Ee=md(m),Oe=[];e:{var je=Dg.get(l);if(je!==void 0){var Te=nc,tt=l;switch(l){case"keypress":if(tc(m)===0)break e;case"keydown":case"keyup":Te=L1;break;case"focusin":tt="focus",Te=xd;break;case"focusout":tt="blur",Te=xd;break;case"beforeblur":case"afterblur":Te=xd;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Te=lg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Te=k1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Te=P1;break;case Mg:case Eg:case _g:Te=C1;break;case Rg:Te=z1;break;case"scroll":case"scrollend":Te=v1;break;case"wheel":Te=H1;break;case"copy":case"cut":case"paste":Te=N1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Te=ug;break;case"toggle":case"beforetoggle":Te=U1}var ht=(u&4)!==0,Qt=!ht&&(l==="scroll"||l==="scrollend"),be=ht?je!==null?je+"Capture":null:je;ht=[];for(var de=we,ve;de!==null;){var De=de;if(ve=De.stateNode,De=De.tag,De!==5&&De!==26&&De!==27||ve===null||be===null||(De=kr(de,be),De!=null&&ht.push(tl(de,De,ve))),Qt)break;de=de.return}0<ht.length&&(je=new Te(je,tt,null,m,Ee),Oe.push({event:je,listeners:ht}))}}if((u&7)===0){e:{if(je=l==="mouseover"||l==="pointerover",Te=l==="mouseout"||l==="pointerout",je&&m!==hd&&(tt=m.relatedTarget||m.fromElement)&&(Ut(tt)||tt[Et]))break e;if((Te||je)&&(je=Ee.window===Ee?Ee:(je=Ee.ownerDocument)?je.defaultView||je.parentWindow:window,Te?(tt=m.relatedTarget||m.toElement,Te=we,tt=tt?Ut(tt):null,tt!==null&&(Qt=o(tt),ht=tt.tag,tt!==Qt||ht!==5&&ht!==27&&ht!==6)&&(tt=null)):(Te=null,tt=we),Te!==tt)){if(ht=lg,De="onMouseLeave",be="onMouseEnter",de="mouse",(l==="pointerout"||l==="pointerover")&&(ht=ug,De="onPointerLeave",be="onPointerEnter",de="pointer"),Qt=Te==null?je:kn(Te),ve=tt==null?je:kn(tt),je=new ht(De,de+"leave",Te,m,Ee),je.target=Qt,je.relatedTarget=ve,De=null,Ut(Ee)===we&&(ht=new ht(be,de+"enter",tt,m,Ee),ht.target=ve,ht.relatedTarget=Qt,De=ht),Qt=De,Te&&tt)t:{for(ht=$C,be=Te,de=tt,ve=0,De=be;De;De=ht(De))ve++;De=0;for(var rt=de;rt;rt=ht(rt))De++;for(;0<ve-De;)be=ht(be),ve--;for(;0<De-ve;)de=ht(de),De--;for(;ve--;){if(be===de||de!==null&&be===de.alternate){ht=be;break t}be=ht(be),de=ht(de)}ht=null}else ht=null;Te!==null&&tx(Oe,je,Te,ht,!1),tt!==null&&Qt!==null&&tx(Oe,Qt,tt,ht,!0)}}e:{if(je=we?kn(we):window,Te=je.nodeName&&je.nodeName.toLowerCase(),Te==="select"||Te==="input"&&je.type==="file")var Ht=yg;else if(gg(je))if(xg)Ht=J1;else{Ht=Z1;var st=X1}else Te=je.nodeName,!Te||Te.toLowerCase()!=="input"||je.type!=="checkbox"&&je.type!=="radio"?we&&dd(we.elementType)&&(Ht=yg):Ht=Q1;if(Ht&&(Ht=Ht(l,we))){bg(Oe,Ht,m,Ee);break e}st&&st(l,je,we),l==="focusout"&&we&&je.type==="number"&&we.memoizedProps.value!=null&&go(je,"number",je.value)}switch(st=we?kn(we):window,l){case"focusin":(gg(st)||st.contentEditable==="true")&&(ko=st,Cd=we,Er=null);break;case"focusout":Er=Cd=ko=null;break;case"mousedown":Ad=!0;break;case"contextmenu":case"mouseup":case"dragend":Ad=!1,Ng(Oe,m,Ee);break;case"selectionchange":if(tC)break;case"keydown":case"keyup":Ng(Oe,m,Ee)}var kt;if(wd)e:{switch(l){case"compositionstart":var Ot="onCompositionStart";break e;case"compositionend":Ot="onCompositionEnd";break e;case"compositionupdate":Ot="onCompositionUpdate";break e}Ot=void 0}else wo?pg(l,m)&&(Ot="onCompositionEnd"):l==="keydown"&&m.keyCode===229&&(Ot="onCompositionStart");Ot&&(dg&&m.locale!=="ko"&&(wo||Ot!=="onCompositionStart"?Ot==="onCompositionEnd"&&wo&&(kt=og()):(Ga=Ee,gd="value"in Ga?Ga.value:Ga.textContent,wo=!0)),st=Kc(we,Ot),0<st.length&&(Ot=new cg(Ot,l,null,m,Ee),Oe.push({event:Ot,listeners:st}),kt?Ot.data=kt:(kt=fg(m),kt!==null&&(Ot.data=kt)))),(kt=q1?W1(l,m):K1(l,m))&&(Ot=Kc(we,"onBeforeInput"),0<Ot.length&&(st=new cg("onBeforeInput","beforeinput",null,m,Ee),Oe.push({event:st,listeners:Ot}),st.data=kt)),IC(Oe,l,we,m,Ee)}Jy(Oe,u)})}function tl(l,u,m){return{instance:l,listener:u,currentTarget:m}}function Kc(l,u){for(var m=u+"Capture",b=[];l!==null;){var k=l,j=k.stateNode;if(k=k.tag,k!==5&&k!==26&&k!==27||j===null||(k=kr(l,m),k!=null&&b.unshift(tl(l,k,j)),k=kr(l,u),k!=null&&b.push(tl(l,k,j))),l.tag===3)return b;l=l.return}return[]}function $C(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5&&l.tag!==27);return l||null}function tx(l,u,m,b,k){for(var j=u._reactName,F=[];m!==null&&m!==b;){var X=m,ie=X.alternate,we=X.stateNode;if(X=X.tag,ie!==null&&ie===b)break;X!==5&&X!==26&&X!==27||we===null||(ie=we,k?(we=kr(m,j),we!=null&&F.unshift(tl(m,we,ie))):k||(we=kr(m,j),we!=null&&F.push(tl(m,we,ie)))),m=m.return}F.length!==0&&l.push({event:u,listeners:F})}var UC=/\r\n?/g,GC=/\u0000|\uFFFD/g;function sx(l){return(typeof l=="string"?l:""+l).replace(UC,`
|
|
33
|
-
`).replace(GC,"")}function nx(l,u){return u=sx(u),sx(l)===u}function Zt(l,u,m,b,k,j){switch(m){case"children":typeof b=="string"?u==="body"||u==="textarea"&&b===""||yo(l,b):(typeof b=="number"||typeof b=="bigint")&&u!=="body"&&yo(l,""+b);break;case"className":Ei(l,"class",b);break;case"tabIndex":Ei(l,"tabindex",b);break;case"dir":case"role":case"viewBox":case"width":case"height":Ei(l,m,b);break;case"style":ng(l,b,j);break;case"data":if(u!=="object"){Ei(l,"data",b);break}case"src":case"href":if(b===""&&(u!=="a"||m!=="href")){l.removeAttribute(m);break}if(b==null||typeof b=="function"||typeof b=="symbol"||typeof b=="boolean"){l.removeAttribute(m);break}b=Jl(""+b),l.setAttribute(m,b);break;case"action":case"formAction":if(typeof b=="function"){l.setAttribute(m,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof j=="function"&&(m==="formAction"?(u!=="input"&&Zt(l,u,"name",k.name,k,null),Zt(l,u,"formEncType",k.formEncType,k,null),Zt(l,u,"formMethod",k.formMethod,k,null),Zt(l,u,"formTarget",k.formTarget,k,null)):(Zt(l,u,"encType",k.encType,k,null),Zt(l,u,"method",k.method,k,null),Zt(l,u,"target",k.target,k,null)));if(b==null||typeof b=="symbol"||typeof b=="boolean"){l.removeAttribute(m);break}b=Jl(""+b),l.setAttribute(m,b);break;case"onClick":b!=null&&(l.onclick=xa);break;case"onScroll":b!=null&&Rt("scroll",l);break;case"onScrollEnd":b!=null&&Rt("scrollend",l);break;case"dangerouslySetInnerHTML":if(b!=null){if(typeof b!="object"||!("__html"in b))throw Error(n(61));if(m=b.__html,m!=null){if(k.children!=null)throw Error(n(60));l.innerHTML=m}}break;case"multiple":l.multiple=b&&typeof b!="function"&&typeof b!="symbol";break;case"muted":l.muted=b&&typeof b!="function"&&typeof b!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(b==null||typeof b=="function"||typeof b=="boolean"||typeof b=="symbol"){l.removeAttribute("xlink:href");break}m=Jl(""+b),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",m);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":b!=null&&typeof b!="function"&&typeof b!="symbol"?l.setAttribute(m,""+b):l.removeAttribute(m);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":b&&typeof b!="function"&&typeof b!="symbol"?l.setAttribute(m,""):l.removeAttribute(m);break;case"capture":case"download":b===!0?l.setAttribute(m,""):b!==!1&&b!=null&&typeof b!="function"&&typeof b!="symbol"?l.setAttribute(m,b):l.removeAttribute(m);break;case"cols":case"rows":case"size":case"span":b!=null&&typeof b!="function"&&typeof b!="symbol"&&!isNaN(b)&&1<=b?l.setAttribute(m,b):l.removeAttribute(m);break;case"rowSpan":case"start":b==null||typeof b=="function"||typeof b=="symbol"||isNaN(b)?l.removeAttribute(m):l.setAttribute(m,b);break;case"popover":Rt("beforetoggle",l),Rt("toggle",l),Mi(l,"popover",b);break;case"xlinkActuate":Sn(l,"http://www.w3.org/1999/xlink","xlink:actuate",b);break;case"xlinkArcrole":Sn(l,"http://www.w3.org/1999/xlink","xlink:arcrole",b);break;case"xlinkRole":Sn(l,"http://www.w3.org/1999/xlink","xlink:role",b);break;case"xlinkShow":Sn(l,"http://www.w3.org/1999/xlink","xlink:show",b);break;case"xlinkTitle":Sn(l,"http://www.w3.org/1999/xlink","xlink:title",b);break;case"xlinkType":Sn(l,"http://www.w3.org/1999/xlink","xlink:type",b);break;case"xmlBase":Sn(l,"http://www.w3.org/XML/1998/namespace","xml:base",b);break;case"xmlLang":Sn(l,"http://www.w3.org/XML/1998/namespace","xml:lang",b);break;case"xmlSpace":Sn(l,"http://www.w3.org/XML/1998/namespace","xml:space",b);break;case"is":Mi(l,"is",b);break;case"innerText":case"textContent":break;default:(!(2<m.length)||m[0]!=="o"&&m[0]!=="O"||m[1]!=="n"&&m[1]!=="N")&&(m=y1.get(m)||m,Mi(l,m,b))}}function Zh(l,u,m,b,k,j){switch(m){case"style":ng(l,b,j);break;case"dangerouslySetInnerHTML":if(b!=null){if(typeof b!="object"||!("__html"in b))throw Error(n(61));if(m=b.__html,m!=null){if(k.children!=null)throw Error(n(60));l.innerHTML=m}}break;case"children":typeof b=="string"?yo(l,b):(typeof b=="number"||typeof b=="bigint")&&yo(l,""+b);break;case"onScroll":b!=null&&Rt("scroll",l);break;case"onScrollEnd":b!=null&&Rt("scrollend",l);break;case"onClick":b!=null&&(l.onclick=xa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!gr.hasOwnProperty(m))e:{if(m[0]==="o"&&m[1]==="n"&&(k=m.endsWith("Capture"),u=m.slice(2,k?m.length-7:void 0),j=l[Ye]||null,j=j!=null?j[m]:null,typeof j=="function"&&l.removeEventListener(u,j,k),typeof b=="function")){typeof j!="function"&&j!==null&&(m in l?l[m]=null:l.hasAttribute(m)&&l.removeAttribute(m)),l.addEventListener(u,b,k);break e}m in l?l[m]=b:b===!0?l.setAttribute(m,""):Mi(l,m,b)}}}function Fs(l,u,m){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Rt("error",l),Rt("load",l);var b=!1,k=!1,j;for(j in m)if(m.hasOwnProperty(j)){var F=m[j];if(F!=null)switch(j){case"src":b=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(n(137,u));default:Zt(l,u,j,F,m,null)}}k&&Zt(l,u,"srcSet",m.srcSet,m,null),b&&Zt(l,u,"src",m.src,m,null);return;case"input":Rt("invalid",l);var X=j=F=k=null,ie=null,we=null;for(b in m)if(m.hasOwnProperty(b)){var Ee=m[b];if(Ee!=null)switch(b){case"name":k=Ee;break;case"type":F=Ee;break;case"checked":ie=Ee;break;case"defaultChecked":we=Ee;break;case"value":j=Ee;break;case"defaultValue":X=Ee;break;case"children":case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(n(137,u));break;default:Zt(l,u,b,Ee,m,null)}}wr(l,j,X,ie,we,F,k,!1);return;case"select":Rt("invalid",l),b=F=j=null;for(k in m)if(m.hasOwnProperty(k)&&(X=m[k],X!=null))switch(k){case"value":j=X;break;case"defaultValue":F=X;break;case"multiple":b=X;default:Zt(l,u,k,X,m,null)}u=j,m=F,l.multiple=!!b,u!=null?ba(l,!!b,u,!1):m!=null&&ba(l,!!b,m,!0);return;case"textarea":Rt("invalid",l),j=k=b=null;for(F in m)if(m.hasOwnProperty(F)&&(X=m[F],X!=null))switch(F){case"value":b=X;break;case"defaultValue":k=X;break;case"children":j=X;break;case"dangerouslySetInnerHTML":if(X!=null)throw Error(n(91));break;default:Zt(l,u,F,X,m,null)}bo(l,b,k,j);return;case"option":for(ie in m)if(m.hasOwnProperty(ie)&&(b=m[ie],b!=null))switch(ie){case"selected":l.selected=b&&typeof b!="function"&&typeof b!="symbol";break;default:Zt(l,u,ie,b,m,null)}return;case"dialog":Rt("beforetoggle",l),Rt("toggle",l),Rt("cancel",l),Rt("close",l);break;case"iframe":case"object":Rt("load",l);break;case"video":case"audio":for(b=0;b<el.length;b++)Rt(el[b],l);break;case"image":Rt("error",l),Rt("load",l);break;case"details":Rt("toggle",l);break;case"embed":case"source":case"link":Rt("error",l),Rt("load",l);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(we in m)if(m.hasOwnProperty(we)&&(b=m[we],b!=null))switch(we){case"children":case"dangerouslySetInnerHTML":throw Error(n(137,u));default:Zt(l,u,we,b,m,null)}return;default:if(dd(u)){for(Ee in m)m.hasOwnProperty(Ee)&&(b=m[Ee],b!==void 0&&Zh(l,u,Ee,b,m,void 0));return}}for(X in m)m.hasOwnProperty(X)&&(b=m[X],b!=null&&Zt(l,u,X,b,m,null))}function qC(l,u,m,b){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var k=null,j=null,F=null,X=null,ie=null,we=null,Ee=null;for(Te in m){var Oe=m[Te];if(m.hasOwnProperty(Te)&&Oe!=null)switch(Te){case"checked":break;case"value":break;case"defaultValue":ie=Oe;default:b.hasOwnProperty(Te)||Zt(l,u,Te,null,b,Oe)}}for(var je in b){var Te=b[je];if(Oe=m[je],b.hasOwnProperty(je)&&(Te!=null||Oe!=null))switch(je){case"type":j=Te;break;case"name":k=Te;break;case"checked":we=Te;break;case"defaultChecked":Ee=Te;break;case"value":F=Te;break;case"defaultValue":X=Te;break;case"children":case"dangerouslySetInnerHTML":if(Te!=null)throw Error(n(137,u));break;default:Te!==Oe&&Zt(l,u,je,Te,b,Oe)}}fo(l,F,X,ie,we,Ee,j,k);return;case"select":Te=F=X=je=null;for(j in m)if(ie=m[j],m.hasOwnProperty(j)&&ie!=null)switch(j){case"value":break;case"multiple":Te=ie;default:b.hasOwnProperty(j)||Zt(l,u,j,null,b,ie)}for(k in b)if(j=b[k],ie=m[k],b.hasOwnProperty(k)&&(j!=null||ie!=null))switch(k){case"value":je=j;break;case"defaultValue":X=j;break;case"multiple":F=j;default:j!==ie&&Zt(l,u,k,j,b,ie)}u=X,m=F,b=Te,je!=null?ba(l,!!m,je,!1):!!b!=!!m&&(u!=null?ba(l,!!m,u,!0):ba(l,!!m,m?[]:"",!1));return;case"textarea":Te=je=null;for(X in m)if(k=m[X],m.hasOwnProperty(X)&&k!=null&&!b.hasOwnProperty(X))switch(X){case"value":break;case"children":break;default:Zt(l,u,X,null,b,k)}for(F in b)if(k=b[F],j=m[F],b.hasOwnProperty(F)&&(k!=null||j!=null))switch(F){case"value":je=k;break;case"defaultValue":Te=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(n(91));break;default:k!==j&&Zt(l,u,F,k,b,j)}ya(l,je,Te);return;case"option":for(var tt in m)if(je=m[tt],m.hasOwnProperty(tt)&&je!=null&&!b.hasOwnProperty(tt))switch(tt){case"selected":l.selected=!1;break;default:Zt(l,u,tt,null,b,je)}for(ie in b)if(je=b[ie],Te=m[ie],b.hasOwnProperty(ie)&&je!==Te&&(je!=null||Te!=null))switch(ie){case"selected":l.selected=je&&typeof je!="function"&&typeof je!="symbol";break;default:Zt(l,u,ie,je,b,Te)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ht in m)je=m[ht],m.hasOwnProperty(ht)&&je!=null&&!b.hasOwnProperty(ht)&&Zt(l,u,ht,null,b,je);for(we in b)if(je=b[we],Te=m[we],b.hasOwnProperty(we)&&je!==Te&&(je!=null||Te!=null))switch(we){case"children":case"dangerouslySetInnerHTML":if(je!=null)throw Error(n(137,u));break;default:Zt(l,u,we,je,b,Te)}return;default:if(dd(u)){for(var Qt in m)je=m[Qt],m.hasOwnProperty(Qt)&&je!==void 0&&!b.hasOwnProperty(Qt)&&Zh(l,u,Qt,void 0,b,je);for(Ee in b)je=b[Ee],Te=m[Ee],!b.hasOwnProperty(Ee)||je===Te||je===void 0&&Te===void 0||Zh(l,u,Ee,je,b,Te);return}}for(var be in m)je=m[be],m.hasOwnProperty(be)&&je!=null&&!b.hasOwnProperty(be)&&Zt(l,u,be,null,b,je);for(Oe in b)je=b[Oe],Te=m[Oe],!b.hasOwnProperty(Oe)||je===Te||je==null&&Te==null||Zt(l,u,Oe,je,b,Te)}function ax(l){switch(l){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function WC(){if(typeof performance.getEntriesByType=="function"){for(var l=0,u=0,m=performance.getEntriesByType("resource"),b=0;b<m.length;b++){var k=m[b],j=k.transferSize,F=k.initiatorType,X=k.duration;if(j&&X&&ax(F)){for(F=0,X=k.responseEnd,b+=1;b<m.length;b++){var ie=m[b],we=ie.startTime;if(we>X)break;var Ee=ie.transferSize,Oe=ie.initiatorType;Ee&&ax(Oe)&&(ie=ie.responseEnd,F+=Ee*(ie<X?1:(X-we)/(ie-we)))}if(--b,u+=8*(j+F)/(k.duration/1e3),l++,10<l)break}}if(0<l)return u/l/1e6}return navigator.connection&&(l=navigator.connection.downlink,typeof l=="number")?l:5}var Qh=null,Jh=null;function Vc(l){return l.nodeType===9?l:l.ownerDocument}function ix(l){switch(l){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function ox(l,u){if(l===0)switch(u){case"svg":return 1;case"math":return 2;default:return 0}return l===1&&u==="foreignObject"?0:l}function em(l,u){return l==="textarea"||l==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.children=="bigint"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var tm=null;function KC(){var l=window.event;return l&&l.type==="popstate"?l===tm?!1:(tm=l,!0):(tm=null,!1)}var rx=typeof setTimeout=="function"?setTimeout:void 0,VC=typeof clearTimeout=="function"?clearTimeout:void 0,lx=typeof Promise=="function"?Promise:void 0,YC=typeof queueMicrotask=="function"?queueMicrotask:typeof lx<"u"?function(l){return lx.resolve(null).then(l).catch(XC)}:rx;function XC(l){setTimeout(function(){throw l})}function ri(l){return l==="head"}function cx(l,u){var m=u,b=0;do{var k=m.nextSibling;if(l.removeChild(m),k&&k.nodeType===8)if(m=k.data,m==="/$"||m==="/&"){if(b===0){l.removeChild(k),Yo(u);return}b--}else if(m==="$"||m==="$?"||m==="$~"||m==="$!"||m==="&")b++;else if(m==="html")sl(l.ownerDocument.documentElement);else if(m==="head"){m=l.ownerDocument.head,sl(m);for(var j=m.firstChild;j;){var F=j.nextSibling,X=j.nodeName;j[zn]||X==="SCRIPT"||X==="STYLE"||X==="LINK"&&j.rel.toLowerCase()==="stylesheet"||m.removeChild(j),j=F}}else m==="body"&&sl(l.ownerDocument.body);m=k}while(m);Yo(u)}function ux(l,u){var m=l;l=0;do{var b=m.nextSibling;if(m.nodeType===1?u?(m._stashedDisplay=m.style.display,m.style.display="none"):(m.style.display=m._stashedDisplay||"",m.getAttribute("style")===""&&m.removeAttribute("style")):m.nodeType===3&&(u?(m._stashedText=m.nodeValue,m.nodeValue=""):m.nodeValue=m._stashedText||""),b&&b.nodeType===8)if(m=b.data,m==="/$"){if(l===0)break;l--}else m!=="$"&&m!=="$?"&&m!=="$~"&&m!=="$!"||l++;m=b}while(m)}function sm(l){var u=l.firstChild;for(u&&u.nodeType===10&&(u=u.nextSibling);u;){var m=u;switch(u=u.nextSibling,m.nodeName){case"HTML":case"HEAD":case"BODY":sm(m),ot(m);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(m.rel.toLowerCase()==="stylesheet")continue}l.removeChild(m)}}function ZC(l,u,m,b){for(;l.nodeType===1;){var k=m;if(l.nodeName.toLowerCase()!==u.toLowerCase()){if(!b&&(l.nodeName!=="INPUT"||l.type!=="hidden"))break}else if(b){if(!l[zn])switch(u){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(j=l.getAttribute("rel"),j==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(j!==k.rel||l.getAttribute("href")!==(k.href==null||k.href===""?null:k.href)||l.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin)||l.getAttribute("title")!==(k.title==null?null:k.title))break;return l;case"style":if(l.hasAttribute("data-precedence"))break;return l;case"script":if(j=l.getAttribute("src"),(j!==(k.src==null?null:k.src)||l.getAttribute("type")!==(k.type==null?null:k.type)||l.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&j&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(u==="input"&&l.type==="hidden"){var j=k.name==null?null:""+k.name;if(k.type==="hidden"&&l.getAttribute("name")===j)return l}else return l;if(l=En(l.nextSibling),l===null)break}return null}function QC(l,u,m){if(u==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!m||(l=En(l.nextSibling),l===null))return null;return l}function dx(l,u){for(;l.nodeType!==8;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!u||(l=En(l.nextSibling),l===null))return null;return l}function nm(l){return l.data==="$?"||l.data==="$~"}function am(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState!=="loading"}function JC(l,u){var m=l.ownerDocument;if(l.data==="$~")l._reactRetry=u;else if(l.data!=="$?"||m.readyState!=="loading")u();else{var b=function(){u(),m.removeEventListener("DOMContentLoaded",b)};m.addEventListener("DOMContentLoaded",b),l._reactRetry=b}}function En(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"||u==="F!"||u==="F")break;if(u==="/$"||u==="/&")return null}}return l}var im=null;function hx(l){l=l.nextSibling;for(var u=0;l;){if(l.nodeType===8){var m=l.data;if(m==="/$"||m==="/&"){if(u===0)return En(l.nextSibling);u--}else m!=="$"&&m!=="$!"&&m!=="$?"&&m!=="$~"&&m!=="&"||u++}l=l.nextSibling}return null}function mx(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var m=l.data;if(m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"){if(u===0)return l;u--}else m!=="/$"&&m!=="/&"||u++}l=l.previousSibling}return null}function px(l,u,m){switch(u=Vc(m),l){case"html":if(l=u.documentElement,!l)throw Error(n(452));return l;case"head":if(l=u.head,!l)throw Error(n(453));return l;case"body":if(l=u.body,!l)throw Error(n(454));return l;default:throw Error(n(451))}}function sl(l){for(var u=l.attributes;u.length;)l.removeAttributeNode(u[0]);ot(l)}var _n=new Map,fx=new Set;function Yc(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var Ba=q.d;q.d={f:eA,r:tA,D:sA,C:nA,L:aA,m:iA,X:rA,S:oA,M:lA};function eA(){var l=Ba.f(),u=Fc();return l||u}function tA(l){var u=as(l);u!==null&&u.tag===5&&u.type==="form"?Rb(u):Ba.r(l)}var Wo=typeof document>"u"?null:document;function gx(l,u,m){var b=Wo;if(b&&typeof u=="string"&&u){var k=Vs(u);k='link[rel="'+l+'"][href="'+k+'"]',typeof m=="string"&&(k+='[crossorigin="'+m+'"]'),fx.has(k)||(fx.add(k),l={rel:l,crossOrigin:m,href:u},b.querySelector(k)===null&&(u=b.createElement("link"),Fs(u,"link",l),bs(u),b.head.appendChild(u)))}}function sA(l){Ba.D(l),gx("dns-prefetch",l,null)}function nA(l,u){Ba.C(l,u),gx("preconnect",l,u)}function aA(l,u,m){Ba.L(l,u,m);var b=Wo;if(b&&l&&u){var k='link[rel="preload"][as="'+Vs(u)+'"]';u==="image"&&m&&m.imageSrcSet?(k+='[imagesrcset="'+Vs(m.imageSrcSet)+'"]',typeof m.imageSizes=="string"&&(k+='[imagesizes="'+Vs(m.imageSizes)+'"]')):k+='[href="'+Vs(l)+'"]';var j=k;switch(u){case"style":j=Ko(l);break;case"script":j=Vo(l)}_n.has(j)||(l=f({rel:"preload",href:u==="image"&&m&&m.imageSrcSet?void 0:l,as:u},m),_n.set(j,l),b.querySelector(k)!==null||u==="style"&&b.querySelector(nl(j))||u==="script"&&b.querySelector(al(j))||(u=b.createElement("link"),Fs(u,"link",l),bs(u),b.head.appendChild(u)))}}function iA(l,u){Ba.m(l,u);var m=Wo;if(m&&l){var b=u&&typeof u.as=="string"?u.as:"script",k='link[rel="modulepreload"][as="'+Vs(b)+'"][href="'+Vs(l)+'"]',j=k;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Vo(l)}if(!_n.has(j)&&(l=f({rel:"modulepreload",href:l},u),_n.set(j,l),m.querySelector(k)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(m.querySelector(al(j)))return}b=m.createElement("link"),Fs(b,"link",l),bs(b),m.head.appendChild(b)}}}function oA(l,u,m){Ba.S(l,u,m);var b=Wo;if(b&&l){var k=fa(b).hoistableStyles,j=Ko(l);u=u||"default";var F=k.get(j);if(!F){var X={loading:0,preload:null};if(F=b.querySelector(nl(j)))X.loading=5;else{l=f({rel:"stylesheet",href:l,"data-precedence":u},m),(m=_n.get(j))&&om(l,m);var ie=F=b.createElement("link");bs(ie),Fs(ie,"link",l),ie._p=new Promise(function(we,Ee){ie.onload=we,ie.onerror=Ee}),ie.addEventListener("load",function(){X.loading|=1}),ie.addEventListener("error",function(){X.loading|=2}),X.loading|=4,Xc(F,u,b)}F={type:"stylesheet",instance:F,count:1,state:X},k.set(j,F)}}}function rA(l,u){Ba.X(l,u);var m=Wo;if(m&&l){var b=fa(m).hoistableScripts,k=Vo(l),j=b.get(k);j||(j=m.querySelector(al(k)),j||(l=f({src:l,async:!0},u),(u=_n.get(k))&&rm(l,u),j=m.createElement("script"),bs(j),Fs(j,"link",l),m.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},b.set(k,j))}}function lA(l,u){Ba.M(l,u);var m=Wo;if(m&&l){var b=fa(m).hoistableScripts,k=Vo(l),j=b.get(k);j||(j=m.querySelector(al(k)),j||(l=f({src:l,async:!0,type:"module"},u),(u=_n.get(k))&&rm(l,u),j=m.createElement("script"),bs(j),Fs(j,"link",l),m.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},b.set(k,j))}}function bx(l,u,m,b){var k=(k=J.current)?Yc(k):null;if(!k)throw Error(n(446));switch(l){case"meta":case"title":return null;case"style":return typeof m.precedence=="string"&&typeof m.href=="string"?(u=Ko(m.href),m=fa(k).hoistableStyles,b=m.get(u),b||(b={type:"style",instance:null,count:0,state:null},m.set(u,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(m.rel==="stylesheet"&&typeof m.href=="string"&&typeof m.precedence=="string"){l=Ko(m.href);var j=fa(k).hoistableStyles,F=j.get(l);if(F||(k=k.ownerDocument||k,F={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(l,F),(j=k.querySelector(nl(l)))&&!j._p&&(F.instance=j,F.state.loading=5),_n.has(l)||(m={rel:"preload",as:"style",href:m.href,crossOrigin:m.crossOrigin,integrity:m.integrity,media:m.media,hrefLang:m.hrefLang,referrerPolicy:m.referrerPolicy},_n.set(l,m),j||cA(k,l,m,F.state))),u&&b===null)throw Error(n(528,""));return F}if(u&&b!==null)throw Error(n(529,""));return null;case"script":return u=m.async,m=m.src,typeof m=="string"&&u&&typeof u!="function"&&typeof u!="symbol"?(u=Vo(m),m=fa(k).hoistableScripts,b=m.get(u),b||(b={type:"script",instance:null,count:0,state:null},m.set(u,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,l))}}function Ko(l){return'href="'+Vs(l)+'"'}function nl(l){return'link[rel="stylesheet"]['+l+"]"}function yx(l){return f({},l,{"data-precedence":l.precedence,precedence:null})}function cA(l,u,m,b){l.querySelector('link[rel="preload"][as="style"]['+u+"]")?b.loading=1:(u=l.createElement("link"),b.preload=u,u.addEventListener("load",function(){return b.loading|=1}),u.addEventListener("error",function(){return b.loading|=2}),Fs(u,"link",m),bs(u),l.head.appendChild(u))}function Vo(l){return'[src="'+Vs(l)+'"]'}function al(l){return"script[async]"+l}function xx(l,u,m){if(u.count++,u.instance===null)switch(u.type){case"style":var b=l.querySelector('style[data-href~="'+Vs(m.href)+'"]');if(b)return u.instance=b,bs(b),b;var k=f({},m,{"data-href":m.href,"data-precedence":m.precedence,href:null,precedence:null});return b=(l.ownerDocument||l).createElement("style"),bs(b),Fs(b,"style",k),Xc(b,m.precedence,l),u.instance=b;case"stylesheet":k=Ko(m.href);var j=l.querySelector(nl(k));if(j)return u.state.loading|=4,u.instance=j,bs(j),j;b=yx(m),(k=_n.get(k))&&om(b,k),j=(l.ownerDocument||l).createElement("link"),bs(j);var F=j;return F._p=new Promise(function(X,ie){F.onload=X,F.onerror=ie}),Fs(j,"link",b),u.state.loading|=4,Xc(j,m.precedence,l),u.instance=j;case"script":return j=Vo(m.src),(k=l.querySelector(al(j)))?(u.instance=k,bs(k),k):(b=m,(k=_n.get(j))&&(b=f({},m),rm(b,k)),l=l.ownerDocument||l,k=l.createElement("script"),bs(k),Fs(k,"link",b),l.head.appendChild(k),u.instance=k);case"void":return null;default:throw Error(n(443,u.type))}else u.type==="stylesheet"&&(u.state.loading&4)===0&&(b=u.instance,u.state.loading|=4,Xc(b,m.precedence,l));return u.instance}function Xc(l,u,m){for(var b=m.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=b.length?b[b.length-1]:null,j=k,F=0;F<b.length;F++){var X=b[F];if(X.dataset.precedence===u)j=X;else if(j!==k)break}j?j.parentNode.insertBefore(l,j.nextSibling):(u=m.nodeType===9?m.head:m,u.insertBefore(l,u.firstChild))}function om(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.title==null&&(l.title=u.title)}function rm(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.integrity==null&&(l.integrity=u.integrity)}var Zc=null;function vx(l,u,m){if(Zc===null){var b=new Map,k=Zc=new Map;k.set(m,b)}else k=Zc,b=k.get(m),b||(b=new Map,k.set(m,b));if(b.has(l))return b;for(b.set(l,null),m=m.getElementsByTagName(l),k=0;k<m.length;k++){var j=m[k];if(!(j[zn]||j[We]||l==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var F=j.getAttribute(u)||"";F=l+F;var X=b.get(F);X?X.push(j):b.set(F,[j])}}return b}function wx(l,u,m){l=l.ownerDocument||l,l.head.insertBefore(m,u==="title"?l.querySelector("head > title"):null)}function uA(l,u,m){if(m===1||u.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof u.precedence!="string"||typeof u.href!="string"||u.href==="")break;return!0;case"link":if(typeof u.rel!="string"||typeof u.href!="string"||u.href===""||u.onLoad||u.onError)break;switch(u.rel){case"stylesheet":return l=u.disabled,typeof u.precedence=="string"&&l==null;default:return!0}case"script":if(u.async&&typeof u.async!="function"&&typeof u.async!="symbol"&&!u.onLoad&&!u.onError&&u.src&&typeof u.src=="string")return!0}return!1}function kx(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function dA(l,u,m,b){if(m.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(m.state.loading&4)===0){if(m.instance===null){var k=Ko(b.href),j=u.querySelector(nl(k));if(j){u=j._p,u!==null&&typeof u=="object"&&typeof u.then=="function"&&(l.count++,l=Qc.bind(l),u.then(l,l)),m.state.loading|=4,m.instance=j,bs(j);return}j=u.ownerDocument||u,b=yx(b),(k=_n.get(k))&&om(b,k),j=j.createElement("link"),bs(j);var F=j;F._p=new Promise(function(X,ie){F.onload=X,F.onerror=ie}),Fs(j,"link",b),m.instance=j}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(m,u),(u=m.state.preload)&&(m.state.loading&3)===0&&(l.count++,m=Qc.bind(l),u.addEventListener("load",m),u.addEventListener("error",m))}}var lm=0;function hA(l,u){return l.stylesheets&&l.count===0&&eu(l,l.stylesheets),0<l.count||0<l.imgCount?function(m){var b=setTimeout(function(){if(l.stylesheets&&eu(l,l.stylesheets),l.unsuspend){var j=l.unsuspend;l.unsuspend=null,j()}},6e4+u);0<l.imgBytes&&lm===0&&(lm=62500*WC());var k=setTimeout(function(){if(l.waitingForImages=!1,l.count===0&&(l.stylesheets&&eu(l,l.stylesheets),l.unsuspend)){var j=l.unsuspend;l.unsuspend=null,j()}},(l.imgBytes>lm?50:800)+u);return l.unsuspend=m,function(){l.unsuspend=null,clearTimeout(b),clearTimeout(k)}}:null}function Qc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)eu(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Jc=null;function eu(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Jc=new Map,u.forEach(mA,l),Jc=null,Qc.call(l))}function mA(l,u){if(!(u.state.loading&4)){var m=Jc.get(l);if(m)var b=m.get(null);else{m=new Map,Jc.set(l,m);for(var k=l.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<k.length;j++){var F=k[j];(F.nodeName==="LINK"||F.getAttribute("media")!=="not all")&&(m.set(F.dataset.precedence,F),b=F)}b&&m.set(null,b)}k=u.instance,F=k.getAttribute("data-precedence"),j=m.get(F)||b,j===b&&m.set(null,k),m.set(F,k),this.count++,b=Qc.bind(this),k.addEventListener("load",b),k.addEventListener("error",b),j?j.parentNode.insertBefore(k,j.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(k,l.firstChild)),u.state.loading|=4}}var il={$$typeof:N,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function pA(l,u,m,b,k,j,F,X,ie){this.tag=1,this.containerInfo=l,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ms(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ms(0),this.hiddenUpdates=Ms(null),this.identifierPrefix=b,this.onUncaughtError=k,this.onCaughtError=j,this.onRecoverableError=F,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ie,this.incompleteTransitions=new Map}function Sx(l,u,m,b,k,j,F,X,ie,we,Ee,Oe){return l=new pA(l,u,m,F,ie,we,Ee,Oe,X),u=1,j===!0&&(u|=24),j=hn(3,null,null,u),l.current=j,j.stateNode=l,u=Hd(),u.refCount++,l.pooledCache=u,u.refCount++,j.memoizedState={element:b,isDehydrated:m,cache:u},qd(j),l}function jx(l){return l?(l=Co,l):Co}function Cx(l,u,m,b,k,j){k=jx(k),b.context===null?b.context=k:b.pendingContext=k,b=Xa(u),b.payload={element:m},j=j===void 0?null:j,j!==null&&(b.callback=j),m=Za(l,b,u),m!==null&&(an(m,l,u),Pr(m,l,u))}function Ax(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var m=l.retryLane;l.retryLane=m!==0&&m<u?m:u}}function cm(l,u){Ax(l,u),(l=l.alternate)&&Ax(l,u)}function Nx(l){if(l.tag===13||l.tag===31){var u=Bi(l,67108864);u!==null&&an(u,l,67108864),cm(l,67108864)}}function Tx(l){if(l.tag===13||l.tag===31){var u=bn();u=ce(u);var m=Bi(l,u);m!==null&&an(m,l,u),cm(l,u)}}var tu=!0;function fA(l,u,m,b){var k=L.T;L.T=null;var j=q.p;try{q.p=2,um(l,u,m,b)}finally{q.p=j,L.T=k}}function gA(l,u,m,b){var k=L.T;L.T=null;var j=q.p;try{q.p=8,um(l,u,m,b)}finally{q.p=j,L.T=k}}function um(l,u,m,b){if(tu){var k=dm(b);if(k===null)Xh(l,u,b,su,m),Ex(l,b);else if(yA(k,l,u,m,b))b.stopPropagation();else if(Ex(l,b),u&4&&-1<bA.indexOf(l)){for(;k!==null;){var j=as(k);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var F=Je(j.pendingLanes);if(F!==0){var X=j;for(X.pendingLanes|=2,X.entangledLanes|=2;F;){var ie=1<<31-Qe(F);X.entanglements[1]|=ie,F&=~ie}na(j),(Gt&6)===0&&(Ic=qe()+500,Jr(0))}}break;case 31:case 13:X=Bi(j,2),X!==null&&an(X,j,2),Fc(),cm(j,2)}if(j=dm(b),j===null&&Xh(l,u,b,su,m),j===k)break;k=j}k!==null&&b.stopPropagation()}else Xh(l,u,b,null,m)}}function dm(l){return l=md(l),hm(l)}var su=null;function hm(l){if(su=null,l=Ut(l),l!==null){var u=o(l);if(u===null)l=null;else{var m=u.tag;if(m===13){if(l=r(u),l!==null)return l;l=null}else if(m===31){if(l=c(u),l!==null)return l;l=null}else if(m===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null)}}return su=l,null}function Mx(l){switch(l){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ge()){case ee:return 2;case ge:return 8;case Ie:case Be:return 32;case ze:return 268435456;default:return 32}default:return 32}}var mm=!1,li=null,ci=null,ui=null,ol=new Map,rl=new Map,di=[],bA="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Ex(l,u){switch(l){case"focusin":case"focusout":li=null;break;case"dragenter":case"dragleave":ci=null;break;case"mouseover":case"mouseout":ui=null;break;case"pointerover":case"pointerout":ol.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":rl.delete(u.pointerId)}}function ll(l,u,m,b,k,j){return l===null||l.nativeEvent!==j?(l={blockedOn:u,domEventName:m,eventSystemFlags:b,nativeEvent:j,targetContainers:[k]},u!==null&&(u=as(u),u!==null&&Nx(u)),l):(l.eventSystemFlags|=b,u=l.targetContainers,k!==null&&u.indexOf(k)===-1&&u.push(k),l)}function yA(l,u,m,b,k){switch(u){case"focusin":return li=ll(li,l,u,m,b,k),!0;case"dragenter":return ci=ll(ci,l,u,m,b,k),!0;case"mouseover":return ui=ll(ui,l,u,m,b,k),!0;case"pointerover":var j=k.pointerId;return ol.set(j,ll(ol.get(j)||null,l,u,m,b,k)),!0;case"gotpointercapture":return j=k.pointerId,rl.set(j,ll(rl.get(j)||null,l,u,m,b,k)),!0}return!1}function _x(l){var u=Ut(l.target);if(u!==null){var m=o(u);if(m!==null){if(u=m.tag,u===13){if(u=r(m),u!==null){l.blockedOn=u,Ve(l.priority,function(){Tx(m)});return}}else if(u===31){if(u=c(m),u!==null){l.blockedOn=u,Ve(l.priority,function(){Tx(m)});return}}else if(u===3&&m.stateNode.current.memoizedState.isDehydrated){l.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}l.blockedOn=null}function nu(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var m=dm(l.nativeEvent);if(m===null){m=l.nativeEvent;var b=new m.constructor(m.type,m);hd=b,m.target.dispatchEvent(b),hd=null}else return u=as(m),u!==null&&Nx(u),l.blockedOn=m,!1;u.shift()}return!0}function Rx(l,u,m){nu(l)&&m.delete(u)}function xA(){mm=!1,li!==null&&nu(li)&&(li=null),ci!==null&&nu(ci)&&(ci=null),ui!==null&&nu(ui)&&(ui=null),ol.forEach(Rx),rl.forEach(Rx)}function au(l,u){l.blockedOn===u&&(l.blockedOn=null,mm||(mm=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,xA)))}var iu=null;function Dx(l){iu!==l&&(iu=l,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){iu===l&&(iu=null);for(var u=0;u<l.length;u+=3){var m=l[u],b=l[u+1],k=l[u+2];if(typeof b!="function"){if(hm(b||m)===null)continue;break}var j=as(m);j!==null&&(l.splice(u,3),u-=3,dh(j,{pending:!0,data:k,method:m.method,action:b},b,k))}}))}function Yo(l){function u(ie){return au(ie,l)}li!==null&&au(li,l),ci!==null&&au(ci,l),ui!==null&&au(ui,l),ol.forEach(u),rl.forEach(u);for(var m=0;m<di.length;m++){var b=di[m];b.blockedOn===l&&(b.blockedOn=null)}for(;0<di.length&&(m=di[0],m.blockedOn===null);)_x(m),m.blockedOn===null&&di.shift();if(m=(l.ownerDocument||l).$$reactFormReplay,m!=null)for(b=0;b<m.length;b+=3){var k=m[b],j=m[b+1],F=k[Ye]||null;if(typeof j=="function")F||Dx(m);else if(F){var X=null;if(j&&j.hasAttribute("formAction")){if(k=j,F=j[Ye]||null)X=F.formAction;else if(hm(k)!==null)continue}else X=F.action;typeof X=="function"?m[b+1]=X:(m.splice(b,3),b-=3),Dx(m)}}}function Lx(){function l(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(F){return k=F})},focusReset:"manual",scroll:"manual"})}function u(){k!==null&&(k(),k=null),b||setTimeout(m,20)}function m(){if(!b&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var b=!1,k=null;return navigation.addEventListener("navigate",l),navigation.addEventListener("navigatesuccess",u),navigation.addEventListener("navigateerror",u),setTimeout(m,100),function(){b=!0,navigation.removeEventListener("navigate",l),navigation.removeEventListener("navigatesuccess",u),navigation.removeEventListener("navigateerror",u),k!==null&&(k(),k=null)}}}function pm(l){this._internalRoot=l}ou.prototype.render=pm.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(n(409));var m=u.current,b=bn();Cx(m,b,l,u,null,null)},ou.prototype.unmount=pm.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;Cx(l.current,2,null,l,null,null),Fc(),u[Et]=null}};function ou(l){this._internalRoot=l}ou.prototype.unstable_scheduleHydration=function(l){if(l){var u=He();l={blockedOn:null,target:l,priority:u};for(var m=0;m<di.length&&u!==0&&u<di[m].priority;m++);di.splice(m,0,l),m===0&&_x(l)}};var Bx=e.version;if(Bx!=="19.2.3")throw Error(n(527,Bx,"19.2.3"));q.findDOMNode=function(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=h(u),l=l!==null?p(l):null,l=l===null?null:l.stateNode,l};var vA={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ru.isDisabled&&ru.supportsFiber)try{ft=ru.inject(vA),bt=ru}catch{}}return ul.createRoot=function(l,u){if(!i(l))throw Error(n(299));var m=!1,b="",k=$b,j=Ub,F=Gb;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(b=u.identifierPrefix),u.onUncaughtError!==void 0&&(k=u.onUncaughtError),u.onCaughtError!==void 0&&(j=u.onCaughtError),u.onRecoverableError!==void 0&&(F=u.onRecoverableError)),u=Sx(l,1,!1,null,null,m,b,null,k,j,F,Lx),l[Et]=u.current,Yh(l),new pm(u)},ul.hydrateRoot=function(l,u,m){if(!i(l))throw Error(n(299));var b=!1,k="",j=$b,F=Ub,X=Gb,ie=null;return m!=null&&(m.unstable_strictMode===!0&&(b=!0),m.identifierPrefix!==void 0&&(k=m.identifierPrefix),m.onUncaughtError!==void 0&&(j=m.onUncaughtError),m.onCaughtError!==void 0&&(F=m.onCaughtError),m.onRecoverableError!==void 0&&(X=m.onRecoverableError),m.formState!==void 0&&(ie=m.formState)),u=Sx(l,1,!0,u,m??null,b,k,ie,j,F,X,Lx),u.context=jx(null),m=u.current,b=bn(),b=ce(b),k=Xa(b),k.callback=null,Za(m,k,b),m=b,u.current.lanes=m,Se(u,m),na(u),l[Et]=u.current,Yh(l),new ou(u)},ul.version="19.2.3",ul}var Yx;function uN(){if(Yx)return gm.exports;Yx=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),gm.exports=cN(),gm.exports}var dN=uN();const at={CONFIG:"tide-commander-config",SETTINGS:"tide-settings",SHORTCUTS:"tide-shortcuts",MOUSE_CONTROLS:"tide-mouse-controls",BACKEND_URL:"tide-backend-url",AUTH_TOKEN:"tide-auth-token",SCENE_VIEW_MODE:"tide-scene-view-mode",CAMERA_STATE:"tide-camera-state",CAMERA_STATE_2D:"tide-camera-state-2d",VIEW_MODE:"guake-view-mode",ADVANCED_VIEW:"guake-advanced-view",TERMINAL_HEIGHT:"guake-terminal-height",INPUT_TEXT_PREFIX:"guake-input-",PASTED_TEXTS_PREFIX:"guake-pasted-",COMMANDER_TAB:"commander-active-tab",LAST_CWD:"tide-last-cwd",GLOBAL_SUPERVISOR_COLLAPSED:"tide-global-supervisor-collapsed",TOOLS_COLLAPSED:"tide-tool-history-collapsed",FILES_COLLAPSED:"tide-file-history-collapsed",MOBILE_VIEW:"tide-mobile-view",TREE_PANEL_WIDTH:"tide-tree-panel-width",AGENT_ORDER:"tide-agent-order",AOP_CONFIG:"tide-aop-config"};function ca(s,e){try{const t=localStorage.getItem(s);return t===null?e:JSON.parse(t)}catch{return e}}function Qs(s,e=""){try{return localStorage.getItem(s)??e}catch{return e}}function hp(s,e=!1){try{const t=localStorage.getItem(s);return t===null?e:t==="true"}catch{return e}}function jk(s,e){try{const t=localStorage.getItem(s);if(t===null)return e;const n=Number(t);return isNaN(n)?e:n}catch{return e}}function Ia(s,e){try{localStorage.setItem(s,JSON.stringify(e))}catch(t){console.error(`Failed to save to localStorage: ${s}`,t)}}function Yn(s,e){try{localStorage.setItem(s,e)}catch(t){console.error(`Failed to save to localStorage: ${s}`,t)}}function mp(s,e){try{localStorage.setItem(s,String(e))}catch(t){console.error(`Failed to save to localStorage: ${s}`,t)}}function Ck(s,e){try{localStorage.setItem(s,String(e))}catch(t){console.error(`Failed to save to localStorage: ${s}`,t)}}function Xx(s){try{localStorage.removeItem(s)}catch(e){console.error(`Failed to remove from localStorage: ${s}`,e)}}function Ak(){const s=Qs(at.BACKEND_URL,"");return s?s.replace(/\/$/,""):"http://localhost:5174"}function Xu(){return Qs(at.AUTH_TOKEN,"")}function lt(s){return`${Ak()}${s}`}async function Ct(s,e){const t=Xu(),n=new Headers(e==null?void 0:e.headers);return t&&n.set("X-Auth-Token",t),fetch(s,{...e,headers:n})}function Nk(s){const e=Xu();if(!e)return s;try{const t=!s.startsWith("http://")&&!s.startsWith("https://"),n=t?"http://dummy":void 0,i=new URL(s,n);return i.searchParams.set("token",e),t?i.pathname+i.search:i.toString()}catch{const t=s.includes("?")?"&":"?";return`${s}${t}token=${encodeURIComponent(e)}`}}function Xs(s=!1,e){const[t,n]=x.useState(s),[i,o]=x.useState(e),r=x.useCallback(h=>{h!==void 0&&o(h),n(!0)},[]),c=x.useCallback(()=>{n(!1)},[]),d=x.useCallback(()=>{n(h=>!h)},[]);return{isOpen:t,data:i,open:r,close:c,toggle:d,setData:o}}function hN(){const[s,e]=x.useState(null),t=x.useCallback(i=>{e(i)},[]),n=x.useCallback(()=>{e(null)},[]);return{isOpen:s!==null,id:s,open:t,close:n}}function mN(){const[s,e]=x.useState(!1),[t,n]=x.useState({x:0,y:0}),[i,o]=x.useState({x:0,z:0}),[r,c]=x.useState({type:"ground"}),d=x.useCallback((p,f,g)=>{n(p),o(f),c(g),e(!0)},[]),h=x.useCallback(()=>{e(!1)},[]);return{isOpen:s,screenPosition:t,worldPosition:i,target:r,open:d,close:h}}const Gn=[],pN=new Set;function Tu(){pN.forEach(s=>s())}function fN(s,e){const t=Gn.findIndex(n=>n.id===s);return t!==-1&&Gn.splice(t,1),Gn.push({id:s,close:e}),Tu(),()=>{const n=Gn.findIndex(i=>i.id===s);n!==-1&&(Gn.splice(n,1),Tu())}}function Zx(){return Gn.length===0?!1:(Gn.pop().close(),Tu(),!0)}function gN(...s){const e=new Set(s);for(;Gn.length>0;){const t=Gn[Gn.length-1];if(e.has(t.id))break;Gn.pop().close()}Tu()}function vs(s,e,t){const n=x.useRef(t);n.current=t,x.useEffect(()=>e?fN(s,()=>n.current()):void 0,[s,e])}let pp,fp;try{pp=require("@capacitor/haptics").Haptics,fp=require("@capacitor/haptics").ImpactStyle}catch{}function Qx(s,e){const{threshold:t=80,maxVerticalMovement:n=50,enabled:i=!0,onSwipeLeft:o,onSwipeRight:r,onSwipeMove:c,onSwipeCancel:d}=e,h=x.useRef({startX:0,startY:0,startTime:0,isTracking:!1,hasMovedEnough:!1}),p=x.useCallback(y=>{if(y.touches.length!==1)return;const v=y.touches[0];h.current={startX:v.clientX,startY:v.clientY,startTime:Date.now(),isTracking:!0,hasMovedEnough:!1}},[]),f=x.useCallback(y=>{if(!h.current.isTracking||y.touches.length!==1)return;const v=y.touches[0],w=v.clientX-h.current.startX;if(Math.abs(v.clientY-h.current.startY)>n){h.current.isTracking=!1,h.current.hasMovedEnough&&(d==null||d());return}const A=window.innerWidth*.4,N=Math.max(-1,Math.min(1,w/A));Math.abs(w)>=12&&(h.current.hasMovedEnough=!0,c==null||c(N))},[n,c,d]),g=x.useCallback(y=>{const v=h.current.isTracking,w=h.current.hasMovedEnough;if(!v)return;const S=y.changedTouches[0],C=S.clientX-h.current.startX,A=Math.abs(S.clientY-h.current.startY),N=Date.now()-h.current.startTime;h.current.isTracking=!1,h.current.hasMovedEnough=!1,Math.abs(C)>=t&&A<=n&&N<500?(pp&&fp?pp.impact({style:fp.Light}).catch(()=>{navigator.vibrate&&navigator.vibrate(8)}):navigator.vibrate&&navigator.vibrate(8),C>0?r==null||r():o==null||o()):w&&(d==null||d())},[t,n,o,r,d]);x.useEffect(()=>{const y=s.current;if(!(!y||!i||!(window.innerWidth<=768&&"ontouchstart"in window)))return y.addEventListener("touchstart",p,{passive:!0}),y.addEventListener("touchmove",f,{passive:!0}),y.addEventListener("touchend",g,{passive:!0}),()=>{y.removeEventListener("touchstart",p),y.removeEventListener("touchmove",f),y.removeEventListener("touchend",g)}},[s,i,p,f,g])}const bN={width:400,height:300,copyStyleSheets:!0,keepOnTop:"focus"};function yN(){return"documentPictureInPicture"in window}function xN(s,e){for(const o of s.styleSheets)try{if(o.cssRules){const r=e.createElement("style");for(const c of o.cssRules)r.appendChild(e.createTextNode(c.cssText));e.head.appendChild(r)}}catch{if(o.href){const r=e.createElement("link");r.rel="stylesheet",r.href=o.href,e.head.appendChild(r)}}const t=s.documentElement.style.cssText;t&&(e.documentElement.style.cssText=t);const n=getComputedStyle(s.documentElement),i=[];for(let o=0;o<n.length;o++){const r=n[o];r.startsWith("--")&&i.push(`${r}: ${n.getPropertyValue(r)}`)}if(i.length>0){const o=e.createElement("style");o.textContent=`:root { ${i.join("; ")} }`,e.head.appendChild(o)}}function vN(){const[s,e]=x.useState(!1),[t,n]=x.useState(null),[i,o]=x.useState(null),r=x.useRef(null),c=yN(),d=x.useCallback(()=>{if(r.current){const f=r.current.__cleanupFns;f&&f.forEach(g=>g()),r.current.close(),r.current=null}n(null),o(null),e(!1)},[]),h=x.useCallback(async f=>{if(!c)return console.warn("Document Picture-in-Picture is not supported in this browser"),!1;r.current&&d();const g={...bN,...f};try{const v=await window.documentPictureInPicture.requestWindow({width:g.width,height:g.height,disallowReturnToOpener:!0});r.current=v,g.copyStyleSheets&&xN(document,v.document);const w=v.document.createElement("div");w.id="pip-root",w.style.width="100%",w.style.height="100%",v.document.body.appendChild(w),v.document.body.style.margin="0",v.document.body.style.padding="0",v.document.body.style.overflow="hidden",v.addEventListener("pagehide",()=>{r.current=null,n(null),o(null),e(!1)});const S=[];if(g.keepOnTop&&g.keepOnTop!=="none"){const C=g.keepOnTop==="raise",A=()=>{r.current&&!r.current.closed&&setTimeout(()=>{r.current&&!r.current.closed&&(r.current.focus(),C&&setTimeout(()=>window.focus(),10))},50)},N=()=>{document.visibilityState==="visible"&&r.current&&!r.current.closed&&setTimeout(()=>{r.current&&!r.current.closed&&(r.current.focus(),C&&setTimeout(()=>window.focus(),10))},100)};window.addEventListener("focus",A),document.addEventListener("visibilitychange",N),S.push(()=>window.removeEventListener("focus",A),()=>document.removeEventListener("visibilitychange",N))}return v.__cleanupFns=S,n(v),o(w),e(!0),!0}catch(y){return console.error("Failed to open Picture-in-Picture window:",y),!1}},[c,d]),p=x.useCallback(async f=>{s?d():await h(f)},[s,h,d]);return x.useEffect(()=>()=>{r.current&&r.current.close()},[]),{isOpen:s,pipWindow:t,pipContainer:i,isSupported:c,open:h,close:d,toggle:p}}function dl(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}class wN{constructor(){W(this,"messages",new Map);W(this,"logs",[]);W(this,"maxMessagesPerAgent",200);W(this,"maxLogs",500);W(this,"enabled",!1);W(this,"listeners",new Set);W(this,"logListeners",new Set)}setEnabled(e){this.enabled=e,this.notifyListeners("all")}isEnabled(){return this.enabled}captureSent(e,t){if(this.enabled)try{const n=JSON.parse(t);console.log(`[AgentDebugger] SENT - agent: ${e.slice(0,4)}, type: ${n.type}, size: ${t.length}B`),this.addMessage(e,{id:dl(),agentId:e,direction:"sent",type:n.type||"unknown",payload:n.payload||n,timestamp:Date.now(),size:t.length,raw:t})}catch(n){console.error("[AgentDebugger] Failed to parse SENT message:",String(n).slice(0,80)),this.addMessage(e,{id:dl(),agentId:e,direction:"sent",type:"parse_error",payload:{error:String(n)},timestamp:Date.now(),size:t.length,raw:t})}}captureReceived(e,t){if(this.enabled)try{const n=JSON.parse(t);console.log(`[AgentDebugger] RECEIVED - agent: ${e.slice(0,4)}, type: ${n.type}, size: ${t.length}B`),this.addMessage(e,{id:dl(),agentId:e,direction:"received",type:n.type||"unknown",payload:n.payload||n,timestamp:Date.now(),size:t.length,raw:t})}catch(n){console.error("[AgentDebugger] Failed to parse RECEIVED message:",String(n).slice(0,80)),this.addMessage(e,{id:dl(),agentId:e,direction:"received",type:"parse_error",payload:{error:String(n)},timestamp:Date.now(),size:t.length,raw:t})}}addMessage(e,t){let n=this.messages.get(e);n||(n=[],this.messages.set(e,n)),n.push(t),console.log(`[AgentDebugger] Added message for ${e}, total: ${n.length}, type: ${t.type}, direction: ${t.direction}`),n.length>this.maxMessagesPerAgent&&n.shift(),this.notifyListeners(e)}getMessages(e){return this.messages.get(e)||[]}getStats(e){const t=this.getMessages(e),n=t.filter(r=>r.direction==="sent").length,i=t.filter(r=>r.direction==="received").length,o=[...new Set(t.map(r=>r.type))];return{total:t.length,sent:n,received:i,messageTypes:o}}clearMessages(e){this.messages.delete(e),this.notifyListeners(e)}clearAllMessages(){this.messages.clear(),this.notifyListeners("all")}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(e){this.listeners.forEach(t=>t(e))}getAgentIds(){return Array.from(this.messages.keys())}log(e,t,n,i){const o={id:dl(),level:e,message:t,data:n,timestamp:Date.now(),source:i};this.logs.push(o),this.logs.length>this.maxLogs&&this.logs.shift(),this.notifyLogListeners()}debug(e,t,n){this.log("debug",e,t,n)}info(e,t,n){this.log("info",e,t,n)}warn(e,t,n){this.log("warn",e,t,n)}error(e,t,n){this.log("error",e,t,n)}getLogs(){return this.logs}clearLogs(){this.logs=[],this.notifyLogListeners()}subscribeLogs(e){return this.logListeners.add(e),()=>this.logListeners.delete(e)}notifyLogListeners(){this.logListeners.forEach(e=>e())}}const Os=new wN,Bl={debug:(s,e,t)=>Os.debug(s,e,t),info:(s,e,t)=>Os.info(s,e,t),warn:(s,e,t)=>Os.warn(s,e,t),error:(s,e,t)=>Os.error(s,e,t)};window.__tideWsState||(window.__tideWsState={ws:null,isConnecting:!1,reconnectAttempts:0,reconnectTimeout:null});const af=()=>window.__tideWsState.ws,Jx=s=>{window.__tideWsState.ws=s},kN=()=>window.__tideWsState.isConnecting,hl=s=>{window.__tideWsState.isConnecting=s},gp=()=>window.__tideWsState.reconnectAttempts,bp=s=>{window.__tideWsState.reconnectAttempts=s},Tk=()=>window.__tideWsState.reconnectTimeout,Mk=s=>{window.__tideWsState.reconnectTimeout=s},e0=10,of="tide_ws_has_connected";function t0(){return sessionStorage.getItem(of)==="true"}function SN(s){sessionStorage.setItem(of,"true")}function jN(){sessionStorage.removeItem(of)}let Ek=null;const CN=s=>{Ek=s},s0=()=>Ek,Ne={onToast:null,onAgentCreated:null,onAgentUpdated:null,onAgentDeleted:null,onAgentsSync:null,onAreasSync:null,onSpawnError:null,onSpawnSuccess:null,onToolUse:null,onDirectoryNotFound:null,onDelegation:null,onCustomClassesSync:null,onReconnect:null,onAgentNotification:null,onBuildingUpdated:null,onSubagentStarted:null,onSubagentCompleted:null};function _k(s){s.onToast&&(Ne.onToast=s.onToast),s.onAgentCreated&&(Ne.onAgentCreated=s.onAgentCreated),s.onAgentUpdated&&(Ne.onAgentUpdated=s.onAgentUpdated),s.onAgentDeleted&&(Ne.onAgentDeleted=s.onAgentDeleted),s.onAgentsSync&&(Ne.onAgentsSync=s.onAgentsSync),s.onAreasSync&&(Ne.onAreasSync=s.onAreasSync),s.onSpawnError&&(Ne.onSpawnError=s.onSpawnError),s.onSpawnSuccess&&(Ne.onSpawnSuccess=s.onSpawnSuccess),s.onToolUse&&(Ne.onToolUse=s.onToolUse),s.onDirectoryNotFound&&(Ne.onDirectoryNotFound=s.onDirectoryNotFound),s.onDelegation&&(Ne.onDelegation=s.onDelegation),s.onCustomClassesSync&&(Ne.onCustomClassesSync=s.onCustomClassesSync),s.onReconnect&&(Ne.onReconnect=s.onReconnect),s.onAgentNotification&&(Ne.onAgentNotification=s.onAgentNotification),s.onBuildingUpdated&&(Ne.onBuildingUpdated=s.onBuildingUpdated),s.onSubagentStarted&&(Ne.onSubagentStarted=s.onSubagentStarted),s.onSubagentCompleted&&(Ne.onSubagentCompleted=s.onSubagentCompleted)}function AN(){Ne.onToast=null,Ne.onAgentCreated=null,Ne.onAgentUpdated=null,Ne.onAgentDeleted=null,Ne.onAgentsSync=null,Ne.onAreasSync=null,Ne.onSpawnError=null,Ne.onSpawnSuccess=null,Ne.onToolUse=null,Ne.onDirectoryNotFound=null,Ne.onDelegation=null,Ne.onCustomClassesSync=null,Ne.onReconnect=null,Ne.onAgentNotification=null,Ne.onSubagentStarted=null,Ne.onSubagentCompleted=null}function NN(){Ne.onAgentCreated=null,Ne.onAgentUpdated=null,Ne.onAgentDeleted=null,Ne.onAgentsSync=null,Ne.onAreasSync=null,Ne.onToolUse=null,Ne.onDelegation=null,Ne.onCustomClassesSync=null,Ne.onBuildingUpdated=null,Ne.onSubagentStarted=null,Ne.onSubagentCompleted=null}const lu=new Map,TN=new Map,n0={start(s){},end(s){},async measure(s,e){this.start(s);try{return await e()}finally{this.end(s)}},measureSync(s,e){this.start(s);try{return e()}finally{this.end(s)}},getMetrics(s){const e={},t=s?lu.has(s)?[[s,lu.get(s)]]:[]:Array.from(lu.entries());for(const[n,i]of t){const o=[...i.samples].sort((h,p)=>h-p),r=Math.floor(o.length*.5),c=Math.floor(o.length*.95),d=Math.floor(o.length*.99);e[n]={count:i.count,avgMs:i.totalMs/i.count,minMs:i.minMs,maxMs:i.maxMs,lastMs:i.lastMs,p50Ms:o[r]||0,p95Ms:o[c]||0,p99Ms:o[d]||0}}return e},clear(){lu.clear(),TN.clear()},report(){}};class MN{constructor(){W(this,"frames",[]);W(this,"lastFrameTime",0);W(this,"frameCount",0);W(this,"fps",0);W(this,"minFps",1/0);W(this,"maxFps",0);W(this,"fpsHistory",[]);W(this,"maxHistorySize",60)}tick(e=200){const t=performance.now();if(this.lastFrameTime>0){const n=t-this.lastFrameTime;n<e&&(this.frames.push(n),this.frames.length>60&&this.frames.shift())}this.lastFrameTime=t,this.frameCount++}update(){if(this.frames.length===0)return;const e=this.frames.reduce((t,n)=>t+n,0)/this.frames.length;this.fps=1e3/e,this.minFps=Math.min(this.minFps,this.fps),this.maxFps=Math.max(this.maxFps,this.fps),this.fpsHistory.push(this.fps),this.fpsHistory.length>this.maxHistorySize&&this.fpsHistory.shift()}getFPS(){return Math.round(this.fps)}getStats(){const e=this.fpsHistory.length>0?this.fpsHistory.reduce((t,n)=>t+n,0)/this.fpsHistory.length:this.fps;return{current:Math.round(this.fps),min:Math.round(this.minFps===1/0?0:this.minFps),max:Math.round(this.maxFps),avg:Math.round(e)}}reset(){this.frames=[],this.lastFrameTime=0,this.frameCount=0,this.fps=0,this.minFps=1/0,this.maxFps=0,this.fpsHistory=[]}}const Rk=new MN;class EN{constructor(){W(this,"snapshots",[]);W(this,"maxSnapshots",120);W(this,"intervalId",null);W(this,"leakThresholdMB",50);W(this,"baselineUsedMB",0)}getUsage(){const e=performance.memory;return e?{usedMB:Math.round(e.usedJSHeapSize/1024/1024),totalMB:Math.round(e.totalJSHeapSize/1024/1024),limitMB:Math.round(e.jsHeapSizeLimit/1024/1024)}:null}log(){const e=this.getUsage();e&&console.log(`[Memory] Used: ${e.usedMB}MB / ${e.totalMB}MB (limit: ${e.limitMB}MB)`)}startMonitoring(e=1e3){if(this.intervalId)return;const t=this.getUsage();t&&(this.baselineUsedMB=t.usedMB),this.intervalId=setInterval(()=>{this.takeSnapshot()},e),console.log("[Memory] Monitoring started. Use memory.report() to see analysis.")}stopMonitoring(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null,console.log("[Memory] Monitoring stopped."))}takeSnapshot(){const e=this.getUsage();if(!e)return;const t={timestamp:Date.now(),heapUsedMB:e.usedMB,heapTotalMB:e.totalMB,heapLimitMB:e.limitMB};this.snapshots.push(t),this.snapshots.length>this.maxSnapshots&&this.snapshots.shift();const n=e.usedMB-this.baselineUsedMB;n>this.leakThresholdMB&&console.warn(`[Memory] Warning: Heap grew by ${n}MB since monitoring started (baseline: ${this.baselineUsedMB}MB, current: ${e.usedMB}MB)`)}getGrowthRate(){if(this.snapshots.length<10)return null;const e=this.snapshots[0],t=this.snapshots[this.snapshots.length-1],n=(t.timestamp-e.timestamp)/1e3/60;return n<.1?null:(t.heapUsedMB-e.heapUsedMB)/n}report(){const e=this.getUsage();if(!e){console.log("[Memory] Memory API not available (Chrome only)");return}console.group("%c[Memory Report]","color: #ff6600; font-weight: bold"),console.log(`Current: ${e.usedMB}MB / ${e.totalMB}MB (limit: ${e.limitMB}MB)`),console.log(`Baseline: ${this.baselineUsedMB}MB`),console.log(`Growth: ${e.usedMB-this.baselineUsedMB}MB since monitoring started`);const t=this.getGrowthRate();if(t!==null&&(console.log(`Growth Rate: ${t.toFixed(2)}MB/min`),t>5&&console.warn("POTENTIAL MEMORY LEAK: Growth rate exceeds 5MB/min")),this.snapshots.length>1){const n=Math.min(...this.snapshots.map(o=>o.heapUsedMB)),i=Math.max(...this.snapshots.map(o=>o.heapUsedMB));console.log(`Range: ${n}MB - ${i}MB (${i-n}MB variance)`)}console.groupEnd()}getThreeJsInfo(e){var t;return(t=e==null?void 0:e.info)!=null&&t.memory?{geometries:e.info.memory.geometries,textures:e.info.memory.textures}:null}reset(){this.snapshots=[];const e=this.getUsage();e&&(this.baselineUsedMB=e.usedMB),console.log("[Memory] Reset. New baseline:",this.baselineUsedMB,"MB")}}const _N=new EN;function Sl(s,e,t,n,i,o){}function Dk(s){if(s.payload&&typeof s.payload=="object"){const e=s.payload;if(e.agentId)return e.agentId;if(e.id)return e.id}return null}function rf(s){var t,n,i,o,r,c;const e=af();if(!e){(t=s0())==null||t(),(n=Ne.onToast)==null||n.call(Ne,"error","Not Connected","Connecting to server... Please try again in a moment.");return}if(e.readyState!==WebSocket.OPEN){e.readyState===WebSocket.CONNECTING?(i=Ne.onToast)==null||i.call(Ne,"warning","Connecting...","WebSocket is still connecting. Please wait a moment and try again."):(e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING)&&((o=s0())==null||o(),(r=Ne.onToast)==null||r.call(Ne,"warning","Reconnecting...","Connection lost. Reconnecting to server..."));return}try{const d=JSON.stringify(s);if(Os.isEnabled()){const p=Dk(s);console.log("[AgentDebugger] SENT - type:",s.type,"agentId:",p,"payload:",s.payload),p&&Os.captureSent(p,d)}e.send(d)}catch(d){(c=Ne.onToast)==null||c.call(Ne,"error","Send Failed",`Failed to send message: ${d}`)}}const jl=new Set,RN=5e3;function a0(s){if(!s.isDetached||!s.sessionId){jl.delete(s.id);return}jl.has(s.id)||(jl.add(s.id),rf({type:"reattach_agent",payload:{agentId:s.id}}),setTimeout(()=>{jl.delete(s.id)},RN))}function DN(s){var e,t,n,i,o,r,c,d,h,p,f,g,y,v,w,S,C,A,N,_,M,E,z;switch(n0.start(`ws:${s.type}`),s.type){case"agents_update":{const T=s.payload,R=T.filter(D=>D.class==="boss"||D.isBoss);R.length>0&&console.log("[WS agents_update] Boss agents received:",R.map(D=>({id:D.id,name:D.name,subordinateIds:D.subordinateIds}))),I.setAgents(T),(e=Ne.onAgentsSync)==null||e.call(Ne,T),I.loadToolHistory();for(const D of T)a0(D);break}case"agent_created":{const T=s.payload;console.log("[WebSocket] Agent created:",T),I.addAgent(T),I.selectAgent(T.id),(t=Ne.onAgentCreated)==null||t.call(Ne,T),(n=Ne.onSpawnSuccess)==null||n.call(Ne),window.__spawnModalSuccess&&(console.log("[WebSocket] Calling __spawnModalSuccess"),window.__spawnModalSuccess()),(i=Ne.onToast)==null||i.call(Ne,"success","Agent Deployed",`${T.name} is ready for commands`);break}case"agent_updated":{const T=s.payload,D=I.getState().agents.get(T.id),O=(D==null?void 0:D.status)!==T.status;console.log(`[Tide] Agent updated: ${T.name} (${T.id}) status=${T.status} (was ${D==null?void 0:D.status})${O?" ⚡ STATUS CHANGED":""}`),O&&console.log(`[Tide] 🔔 Status change for ${T.name}: ${D==null?void 0:D.status} → ${T.status}`);const P=D?D.position.x!==T.position.x||D.position.z!==T.position.z:!1;I.updateAgent(T),a0(T),(o=Ne.onAgentUpdated)==null||o.call(Ne,T,P);break}case"agent_deleted":{const{id:T}=s.payload;jl.delete(T),I.removeAgent(T),(r=Ne.onAgentDeleted)==null||r.call(Ne,T);break}case"activity":{const T=s.payload;I.addActivity(T);break}case"event":{const T=s.payload;if(Bl.debug(`Event: ${T.type}`,{agentId:T.agentId,toolName:T.toolName},"ws:event"),T.type==="tool_start"&&T.toolName&&((c=Ne.onToolUse)==null||c.call(Ne,T.agentId,T.toolName,T.toolInput),I.addToolExecution(T.agentId,T.toolName,T.toolInput),T.toolInput)){const R=T.toolInput.file_path||T.toolInput.path;R&&(T.toolName==="Write"?I.addFileChange(T.agentId,"created",R):T.toolName==="Edit"?I.addFileChange(T.agentId,"modified",R):T.toolName==="Read"&&I.addFileChange(T.agentId,"read",R))}break}case"output":{const T=s.payload;Bl.debug(`Output: "${T.text.slice(0,80)}..."`,{agentId:T.agentId,isStreaming:T.isStreaming,length:T.text.length,hasSkillUpdate:!!T.skillUpdate,uuid:T.uuid,toolName:T.toolName},"ws:output"),I.addOutput(T.agentId,{text:T.text,isStreaming:T.isStreaming,timestamp:T.timestamp,isDelegation:T.isDelegation,skillUpdate:T.skillUpdate,subagentName:T.subagentName,uuid:T.uuid,toolName:T.toolName,toolInput:T.toolInput,toolOutput:T.toolOutput});break}case"context_stats":{const{agentId:T,stats:R}=s.payload;console.log(`[Tide] Received context stats for agent ${T}: ${R.usedPercent}% used`),I.updateAgentContextStats(T,R);break}case"error":{const T=s.payload;console.error("[WebSocket] Error from server:",T.message),(d=Ne.onToast)==null||d.call(Ne,"error","Error",T.message),(h=Ne.onSpawnError)==null||h.call(Ne),window.__spawnModalError&&(console.log("[WebSocket] Calling __spawnModalError"),window.__spawnModalError());break}case"directory_not_found":{const{path:T}=s.payload;console.log("[WebSocket] Directory not found:",T),(p=Ne.onDirectoryNotFound)==null||p.call(Ne,T),window.__spawnModalDirNotFound&&(console.log("[WebSocket] Calling __spawnModalDirNotFound"),window.__spawnModalDirNotFound(T));break}case"command_started":{const{agentId:T,command:R}=s.payload,D=R.trim();if(D==="/context"||D==="/cost"||D==="/compact")break;I.addUserPromptToOutput(T,R);break}case"session_updated":{const{agentId:T}=s.payload;I.loadToolHistory();const R=I.getState().agents.get(T);R&&I.updateAgent({...R});break}case"supervisor_report":{const T=s.payload;I.setSupervisorReport(T);break}case"narrative_update":{const{agentId:T,narrative:R}=s.payload;I.addNarrative(T,R);break}case"supervisor_status":{const T=s.payload;I.setSupervisorStatus(T);break}case"agent_supervisor_history":{const T=s.payload;I.setAgentSupervisorHistory(T);break}case"agent_analysis":{const{agentId:T,analysis:R}=s.payload;I.addAgentAnalysis(T,R);break}case"areas_update":{const T=s.payload;I.setAreasFromServer(T),(f=Ne.onAreasSync)==null||f.call(Ne);break}case"buildings_update":{const T=s.payload;I.setBuildingsFromServer(T);break}case"building_created":{const T=s.payload;I.addBuilding(T);break}case"building_updated":{const T=s.payload;I.updateBuildingFromServer(T),(g=Ne.onBuildingUpdated)==null||g.call(Ne,T);break}case"building_deleted":{const{id:T}=s.payload;I.removeBuildingFromServer(T);break}case"building_logs":{const{buildingId:T,logs:R}=s.payload;I.addBuildingLogs(T,R);break}case"pm2_logs_chunk":{const{buildingId:T,chunk:R}=s.payload;I.appendStreamingLogChunk(T,R);break}case"pm2_logs_streaming":{const{buildingId:T,streaming:R}=s.payload;I.setStreamingStatus(T,R);break}case"docker_logs_chunk":{const{buildingId:T,chunk:R}=s.payload;I.appendStreamingLogChunk(T,R);break}case"docker_logs_streaming":{const{buildingId:T,streaming:R}=s.payload;I.setStreamingStatus(T,R);break}case"docker_containers_list":{const{containers:T,composeProjects:R}=s.payload;console.log(`[WebSocket] Received ${T.length} containers, ${R.length} compose projects`),I.setDockerContainersList(T,R);break}case"boss_building_logs_chunk":{const{bossBuildingId:T,subordinateBuildingId:R,subordinateBuildingName:D,chunk:O,isError:P}=s.payload;I.appendBossStreamingLogChunk(T,R,D,O,P);break}case"boss_building_subordinates_updated":{const{bossBuildingId:T,subordinateBuildingIds:R}=s.payload;I.updateBuilding(T,{subordinateBuildingIds:R});break}case"permission_request":{const T=s.payload;I.addPermissionRequest(T);break}case"permission_resolved":{const{requestId:T,approved:R}=s.payload;I.resolvePermissionRequest(T,R);break}case"delegation_decision":{const T=s.payload;I.handleDelegationDecision(T),T.status==="sent"&&((y=Ne.onToast)==null||y.call(Ne,"info","Task Delegated",`Delegated to ${T.selectedAgentName}: ${T.reasoning.slice(0,80)}...`),T.bossId&&T.selectedAgentId&&((v=Ne.onDelegation)==null||v.call(Ne,T.bossId,T.selectedAgentId)));break}case"boss_subordinates_updated":{const{bossId:T,subordinateIds:R}=s.payload;I.updateBossSubordinates(T,R);break}case"delegation_history":{const{bossId:T,decisions:R}=s.payload;I.setDelegationHistory(T,R);break}case"boss_spawned_agent":{const{agent:T,bossPosition:R}=s.payload;console.log("[WebSocket] Boss spawned agent:",T.name,"- walking to boss at",R),I.addAgent(T),(w=Ne.onAgentCreated)==null||w.call(Ne,T),rf({type:"move_agent",payload:{agentId:T.id,position:R}}),(S=Ne.onToast)==null||S.call(Ne,"success","Agent Deployed",`${T.name} spawned by boss, walking to position`);break}case"agent_task_started":{const{bossId:T,subordinateId:R,subordinateName:D,taskDescription:O}=s.payload;console.log(`[WebSocket] Agent ${D} started task for boss ${T}: ${O.slice(0,50)}...`),I.handleAgentTaskStarted(T,R,D,O);break}case"agent_task_output":{const{bossId:T,subordinateId:R,output:D}=s.payload;I.handleAgentTaskOutput(T,R,D);break}case"agent_task_completed":{const{bossId:T,subordinateId:R,success:D}=s.payload;console.log(`[WebSocket] Agent task completed for boss ${T}, subordinate ${R}, success: ${D}`),I.handleAgentTaskCompleted(T,R,D);break}case"skills_update":{const T=s.payload;I.setSkillsFromServer(T);break}case"skill_created":{const T=s.payload;I.addSkillFromServer(T),console.log(`[WebSocket] Skill created: ${T.name}`);break}case"skill_updated":{const T=s.payload;I.updateSkillFromServer(T),console.log(`[WebSocket] Skill updated: ${T.name}`);break}case"skill_deleted":{const{id:T}=s.payload;I.removeSkillFromServer(T),console.log(`[WebSocket] Skill deleted: ${T}`);break}case"agent_skills":{const{agentId:T,skills:R}=s.payload;console.log(`[WebSocket] Agent ${T} has ${R.length} skills`);break}case"custom_agent_classes_update":{const T=s.payload;I.setCustomAgentClassesFromServer(T),console.log(`[WebSocket] Received ${T.length} custom agent classes`);const R=new Map;for(const D of T)R.set(D.id,D);(C=Ne.onCustomClassesSync)==null||C.call(Ne,R);break}case"custom_agent_class_created":{const T=s.payload;I.addCustomAgentClassFromServer(T),console.log(`[WebSocket] Custom agent class created: ${T.name}`),(A=Ne.onCustomClassesSync)==null||A.call(Ne,I.getState().customAgentClasses);break}case"custom_agent_class_updated":{const T=s.payload;I.updateCustomAgentClassFromServer(T),console.log(`[WebSocket] Custom agent class updated: ${T.name}`),(N=Ne.onCustomClassesSync)==null||N.call(Ne,I.getState().customAgentClasses);break}case"custom_agent_class_deleted":{const{id:T}=s.payload;I.removeCustomAgentClassFromServer(T),console.log(`[WebSocket] Custom agent class deleted: ${T}`),(_=Ne.onCustomClassesSync)==null||_.call(Ne,I.getState().customAgentClasses);break}case"global_usage":{const T=s.payload;console.log("[WebSocket] Global usage update:",T),I.setGlobalUsage(T);break}case"agent_notification":{const T=s.payload;console.log(`[WebSocket] Agent notification from ${T.agentName}: ${T.title}`),(M=Ne.onAgentNotification)==null||M.call(Ne,T);break}case"exec_task_started":{const{taskId:T,agentId:R,agentName:D,command:O,cwd:P}=s.payload;console.log(`[WebSocket] Exec task started: ${T} for agent ${D}: ${O.slice(0,50)}...`),I.handleExecTaskStarted(T,R,D,O,P);break}case"exec_task_output":{const{taskId:T,agentId:R,output:D,isError:O}=s.payload;I.handleExecTaskOutput(T,R,D,O);break}case"exec_task_completed":{const{taskId:T,agentId:R,exitCode:D,success:O}=s.payload;console.log(`[WebSocket] Exec task completed: ${T} for agent ${R}, success: ${O}`),I.handleExecTaskCompleted(T,R,D,O);break}case"subagent_started":{const T=s.payload;console.log(`[WebSocket] Subagent started: ${T.name} (${T.id}) for agent ${T.parentAgentId}`),I.addSubagent(T),(E=Ne.onSubagentStarted)==null||E.call(Ne,T),I.addOutput(T.parentAgentId,{text:`🔀 Spawned subagent: ${T.name} (${T.subagentType})`,isStreaming:!1,timestamp:T.startedAt,subagentName:T.name});break}case"subagent_output":{const{subagentId:T,parentAgentId:R,text:D,isStreaming:O,timestamp:P}=s.payload,K=I.getSubagent(T)||I.getSubagentByToolUseId(T),Y=(K==null?void 0:K.name)||T;I.addOutput(R,{text:`[${T}] ${D}`,isStreaming:O,timestamp:P,subagentName:Y});break}case"subagent_completed":{const{subagentId:T,parentAgentId:R,success:D,resultPreview:O,subagentName:P}=s.payload;console.log(`[WebSocket] Subagent completed: ${T} for agent ${R}, success: ${D}`),I.completeSubagent(T,R,D),(z=Ne.onSubagentCompleted)==null||z.call(Ne,T);const K=I.getSubagent(T)||I.getSubagentByToolUseId(T),Y=P||(K==null?void 0:K.name)||T,$=D?"✅":"❌",L=O?`: ${O.slice(0,100)}`:"";I.addOutput(R,{text:`${$} Subagent ${Y} ${D?"completed":"failed"}${L}`,isStreaming:!1,timestamp:Date.now(),subagentName:Y});break}case"secrets_update":{const T=s.payload;I.setSecretsFromServer(T),console.log(`[WebSocket] Received ${T.length} secrets`);break}case"secret_created":{const T=s.payload;I.addSecretFromServer(T),console.log(`[WebSocket] Secret created: ${T.name}`);break}case"secret_updated":{const T=s.payload;I.updateSecretFromServer(T),console.log(`[WebSocket] Secret updated: ${T.name}`);break}case"secret_deleted":{const{id:T}=s.payload;I.removeSecretFromServer(T),console.log(`[WebSocket] Secret deleted: ${T}`);break}case"database_connection_result":{const{buildingId:T,connectionId:R,success:D,error:O,serverVersion:P}=s.payload;I.setConnectionStatus(T,R,{connected:D,error:O,serverVersion:P}),console.log(`[WebSocket] Database connection ${D?"succeeded":"failed"}: ${R}`);break}case"databases_list":{const{buildingId:T,connectionId:R,databases:D}=s.payload;I.setDatabases(T,R,D),console.log(`[WebSocket] Received ${D.length} databases for ${R}`);break}case"tables_list":{const{buildingId:T,connectionId:R,database:D,tables:O}=s.payload;I.setTables(T,R,D,O),console.log(`[WebSocket] Received ${O.length} tables for ${D}`);break}case"table_schema":{const{buildingId:T,connectionId:R,database:D,table:O,columns:P,indexes:K,foreignKeys:Y}=s.payload;I.setTableSchema(T,R,D,O,{columns:P,indexes:K||[],foreignKeys:Y||[]}),console.log(`[WebSocket] Received schema for ${O}`);break}case"query_result":{const{buildingId:T,result:R}=s.payload;I.setQueryResult(T,R),console.log(`[WebSocket] Query ${R.status}: ${R.rowCount??R.affectedRows??0} rows in ${R.duration}ms`);break}case"query_history_update":{const{buildingId:T,history:R}=s.payload;I.setQueryHistory(T,R),console.log(`[WebSocket] Received ${R.length} query history entries for ${T}`);break}}n0.end(`ws:${s.type}`)}CN(()=>Ol());let i0=!1;function Lk(){const s=af();s&&s.readyState===WebSocket.OPEN&&s.close(1e3,"Page unloading");const e=Tk();e&&clearTimeout(e),window.__tideWsState&&(window.__tideWsState.ws=null,window.__tideWsState.reconnectTimeout=null,window.__tideWsState.isConnecting=!1,window.__tideWsState.reconnectAttempts=0),jN()}function LN(){i0||(window.addEventListener("beforeunload",Lk),i0=!0)}function Bk(){Lk(),I.setConnected(!1),I.stopStatusPolling()}function xm(){Bk(),bp(0),setTimeout(()=>Ol(),100)}function Ol(){LN();const s=Tk();s&&(clearTimeout(s),Mk(null));const e=af();if(kN()||e&&e.readyState===WebSocket.CONNECTING)return;if(e&&e.readyState===WebSocket.OPEN){t0()&&Ne.onReconnect&&Ne.onReconnect();return}bp(gp()+1),hl(!0);const t=Qs(at.BACKEND_URL,""),n=Xu(),i=5174;let o;if(t){const c=t.replace(/^https:\/\//,"wss://").replace(/^http:\/\//,"ws://");o=c.endsWith("/ws")?c:`${c.replace(/\/$/,"")}/ws`}else o=`ws://127.0.0.1:${i}/ws`;let r=null;try{n?r=new WebSocket(o,[`auth-${n}`]):r=new WebSocket(o)}catch{hl(!1),o0();return}Jx(r),r.onopen=()=>{var d,h,p;const c=t0();hl(!1),bp(0),SN(),I.setConnected(!0),I.startStatusPolling(),I.clearAllPermissions(),c?((d=Ne.onToast)==null||d.call(Ne,"success","Reconnected","Connection restored - refreshing data..."),(h=Ne.onReconnect)==null||h.call(Ne)):(p=Ne.onToast)==null||p.call(Ne,"success","Connected","Connected to Tide Commander server")},r.onmessage=c=>{try{const d=JSON.parse(c.data);if(Os.isEnabled()){const p=Dk(d);console.log("[AgentDebugger] RECEIVED - type:",d.type,"agentId:",p,"payload:",d.payload),p&&Os.captureReceived(p,c.data)}DN(d)}catch(d){const h=c.data.substring(0,200);console.error("[WS] Failed to parse message:",d),console.error("[WS] Raw data (first 200 chars):",h),console.error("[WS] Full data length:",c.data.length),c.data.length<5e3&&console.error("[WS] Full malformed message:",c.data)}},r.onclose=()=>{var d,h;hl(!1),Jx(null),I.setConnected(!1),I.stopStatusPolling();const c=gp();c<e0?((d=Ne.onToast)==null||d.call(Ne,"warning","Disconnected",`Connection lost. Reconnecting... (attempt ${c+1}/${e0})`),o0()):(h=Ne.onToast)==null||h.call(Ne,"error","Connection Failed",`Could not connect to server. Please check if the backend is running on port ${i}.`)},r.onerror=()=>{hl(!1)},I.setSendMessage(rf)}function o0(){const s=gp(),e=Math.min(1e3*Math.pow(2,s-1),3e4);Mk(setTimeout(Ol,e))}function r0(s,e){if(e===jA)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===op||e===lk){let t=s.getIndex();if(t===null){const r=[],c=s.getAttribute("position");if(c!==void 0){for(let d=0;d<c.count;d++)r.push(d);s.setIndex(r),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===op)for(let r=1;r<=n;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=s.clone();return o.setIndex(i),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}class lf extends ck{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new zN(t)}),this.register(function(t){return new FN(t)}),this.register(function(t){return new YN(t)}),this.register(function(t){return new XN(t)}),this.register(function(t){return new ZN(t)}),this.register(function(t){return new $N(t)}),this.register(function(t){return new UN(t)}),this.register(function(t){return new GN(t)}),this.register(function(t){return new qN(t)}),this.register(function(t){return new IN(t)}),this.register(function(t){return new WN(t)}),this.register(function(t){return new HN(t)}),this.register(function(t){return new VN(t)}),this.register(function(t){return new KN(t)}),this.register(function(t){return new ON(t)}),this.register(function(t){return new QN(t)}),this.register(function(t){return new JN(t)})}load(e,t,n,i){const o=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const h=Cl.extractUrlBase(e);r=Cl.resolveURL(h,this.path)}else r=Cl.extractUrlBase(e);this.manager.itemStart(e);const c=function(h){i?i(h):console.error(h),o.manager.itemError(e),o.manager.itemEnd(e)},d=new Cu(this.manager);d.setPath(this.path),d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setWithCredentials(this.withCredentials),d.load(e,function(h){try{o.parse(h,r,function(p){t(p),o.manager.itemEnd(e)},c)}catch(p){c(p)}},n,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let o;const r={},c={},d=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(d.decode(new Uint8Array(e,0,4))===Ok){try{r[Dt.KHR_BINARY_GLTF]=new eT(e)}catch(f){i&&i(f);return}o=JSON.parse(r[Dt.KHR_BINARY_GLTF].content)}else o=JSON.parse(d.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new mT(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const f=this.pluginCallbacks[p](h);f.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[f.name]=f,r[f.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const f=o.extensionsUsed[p],g=o.extensionsRequired||[];switch(f){case Dt.KHR_MATERIALS_UNLIT:r[f]=new PN;break;case Dt.KHR_DRACO_MESH_COMPRESSION:r[f]=new tT(o,this.dracoLoader);break;case Dt.KHR_TEXTURE_TRANSFORM:r[f]=new sT;break;case Dt.KHR_MESH_QUANTIZATION:r[f]=new nT;break;default:g.indexOf(f)>=0&&c[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}h.setExtensions(r),h.setPlugins(c),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,o){n.parse(e,t,i,o)})}}function BN(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const Dt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ON{constructor(e){this.parser=e,this.name=Dt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,d=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let h;const p=new At(16777215);d.color!==void 0&&p.setRGB(d.color[0],d.color[1],d.color[2],da);const f=d.range!==void 0?d.range:0;switch(d.type){case"directional":h=new ir(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new uk(p),h.distance=f;break;case"spot":h=new CA(p),h.distance=f,d.spot=d.spot||{},d.spot.innerConeAngle=d.spot.innerConeAngle!==void 0?d.spot.innerConeAngle:0,d.spot.outerConeAngle=d.spot.outerConeAngle!==void 0?d.spot.outerConeAngle:Math.PI/4,h.angle=d.spot.outerConeAngle,h.penumbra=1-d.spot.innerConeAngle/d.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+d.type)}return h.position.set(0,0,0),h.decay=2,Oa(h,d),d.intensity!==void 0&&(h.intensity=d.intensity),h.name=t.createUniqueName(d.name||"light_"+e),i=Promise.resolve(h),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],c=(o.extensions&&o.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(d){return n._getNodeRef(t.cache,c,d)})}}class PN{constructor(){this.name=Dt.KHR_MATERIALS_UNLIT}getMaterialType(){return Re}extendParams(e,t,n){const i=[];e.color=new At(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const r=o.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],da),e.opacity=r[3]}o.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",o.baseColorTexture,qn))}return Promise.all(i)}}class IN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class zN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const c=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Gs(c,c)}return Promise.all(o)}}class FN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class HN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(o)}}class $N{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new At(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const c=r.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],da)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,qn)),r.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(o)}}class UN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(o)}}class GN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const c=r.attenuationColor||[1,1,1];return t.attenuationColor=new At().setRGB(c[0],c[1],c[2],da),Promise.all(o)}}class qN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class WN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const c=r.specularColorFactor||[1,1,1];return t.specularColor=new At().setRGB(c[0],c[1],c[2],da),r.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,qn)),Promise.all(o)}}class KN{constructor(e){this.parser=e,this.name=Dt.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&o.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(o)}}class VN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(o)}}class YN{constructor(e){this.parser=e,this.name=Dt.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const o=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,r)}}class XN{constructor(e){this.parser=e,this.name=Dt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],c=i.images[r.source];let d=n.textureLoader;if(c.uri){const h=n.options.manager.getHandler(c.uri);h!==null&&(d=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,r.source,d);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ZN{constructor(e){this.parser=e,this.name=Dt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],c=i.images[r.source];let d=n.textureLoader;if(c.uri){const h=n.options.manager.getHandler(c.uri);h!==null&&(d=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,r.source,d);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class QN{constructor(e){this.name=Dt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],o=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(c){const d=i.byteOffset||0,h=i.byteLength||0,p=i.count,f=i.byteStride,g=new Uint8Array(c,d,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(p,f,g,i.mode,i.filter).then(function(y){return y.buffer}):r.ready.then(function(){const y=new ArrayBuffer(p*f);return r.decodeGltfBuffer(new Uint8Array(y),p,f,g,i.mode,i.filter),y})})}else return null}}class JN{constructor(e){this.name=Dt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const h of i.primitives)if(h.mode!==Dn.TRIANGLES&&h.mode!==Dn.TRIANGLE_STRIP&&h.mode!==Dn.TRIANGLE_FAN&&h.mode!==void 0)return null;const r=n.extensions[this.name].attributes,c=[],d={};for(const h in r)c.push(this.parser.getDependency("accessor",r[h]).then(p=>(d[h]=p,d[h])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(h=>{const p=h.pop(),f=p.isGroup?p.children:[p],g=h[0].count,y=[];for(const v of f){const w=new ao,S=new nt,C=new io,A=new nt(1,1,1),N=new Pa(v.geometry,v.material,g);for(let _=0;_<g;_++)d.TRANSLATION&&S.fromBufferAttribute(d.TRANSLATION,_),d.ROTATION&&C.fromBufferAttribute(d.ROTATION,_),d.SCALE&&A.fromBufferAttribute(d.SCALE,_),N.setMatrixAt(_,w.compose(S,C,A));for(const _ in d)if(_==="_COLOR_0"){const M=d[_];N.instanceColor=new AA(M.array,M.itemSize,M.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&v.geometry.setAttribute(_,d[_]);dk.prototype.copy.call(N,v),this.parser.assignFinalMaterial(N),y.push(N)}return p.isGroup?(p.clear(),p.add(...y),p):y[0]}))}}const Ok="glTF",ml=12,l0={JSON:1313821514,BIN:5130562};class eT{constructor(e){this.name=Dt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ml),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ok)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-ml,o=new DataView(e,ml);let r=0;for(;r<i;){const c=o.getUint32(r,!0);r+=4;const d=o.getUint32(r,!0);if(r+=4,d===l0.JSON){const h=new Uint8Array(e,ml+r,c);this.content=n.decode(h)}else if(d===l0.BIN){const h=ml+r;this.body=e.slice(h,h+c)}r+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tT{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Dt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,o=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,c={},d={},h={};for(const p in r){const f=yp[p]||p.toLowerCase();c[f]=r[p]}for(const p in e.attributes){const f=yp[p]||p.toLowerCase();if(r[p]!==void 0){const g=n.accessors[e.attributes[p]],y=rr[g.componentType];h[f]=y.name,d[f]=g.normalized===!0}}return t.getDependency("bufferView",o).then(function(p){return new Promise(function(f,g){i.decodeDracoFile(p,function(y){for(const v in y.attributes){const w=y.attributes[v],S=d[v];S!==void 0&&(w.normalized=S)}f(y)},c,h,da,g)})})}}class sT{constructor(){this.name=Dt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class nT{constructor(){this.name=Dt.KHR_MESH_QUANTIZATION}}class Pk extends HA{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,o=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[o+r];return t}interpolate_(e,t,n,i){const o=this.resultBuffer,r=this.sampleValues,c=this.valueSize,d=c*2,h=c*3,p=i-t,f=(n-t)/p,g=f*f,y=g*f,v=e*h,w=v-h,S=-2*y+3*g,C=y-g,A=1-S,N=C-g+f;for(let _=0;_!==c;_++){const M=r[w+_+c],E=r[w+_+d]*p,z=r[v+_+c],T=r[v+_]*p;o[_]=A*M+N*E+S*z+C*T}return o}}const aT=new io;class iT extends Pk{interpolate_(e,t,n,i){const o=super.interpolate_(e,t,n,i);return aT.fromArray(o).normalize().toArray(o),o}}const Dn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},rr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},c0={9728:mk,9729:ds,9984:_A,9985:EA,9986:MA,9987:Al},u0={33071:DA,33648:RA,10497:Qi},vm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yp={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},mi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},oT={CUBICSPLINE:void 0,LINEAR:gk,STEP:zA},wm={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function rT(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new Ke({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:bk})),s.DefaultMaterial}function Vi(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Oa(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function lT(s,e,t){let n=!1,i=!1,o=!1;for(let h=0,p=e.length;h<p;h++){const f=e[h];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(i=!0),f.COLOR_0!==void 0&&(o=!0),n&&i&&o)break}if(!n&&!i&&!o)return Promise.resolve(s);const r=[],c=[],d=[];for(let h=0,p=e.length;h<p;h++){const f=e[h];if(n){const g=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):s.attributes.position;r.push(g)}if(i){const g=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):s.attributes.normal;c.push(g)}if(o){const g=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):s.attributes.color;d.push(g)}}return Promise.all([Promise.all(r),Promise.all(c),Promise.all(d)]).then(function(h){const p=h[0],f=h[1],g=h[2];return n&&(s.morphAttributes.position=p),i&&(s.morphAttributes.normal=f),o&&(s.morphAttributes.color=g),s.morphTargetsRelative=!0,s})}function cT(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function uT(s){let e;const t=s.extensions&&s.extensions[Dt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+km(t.attributes):e=s.indices+":"+km(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+km(s.targets[n]);return e}function km(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function xp(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function dT(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const hT=new ao;class mT{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new BN,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,o=!1,r=-1;if(typeof navigator<"u"){const c=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(c)===!0;const d=c.match(/Version\/(\d+)/);i=n&&d?parseInt(d[1],10):-1,o=c.indexOf("Firefox")>-1,r=o?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||o&&r<98?this.textureLoader=new hk(this.options.manager):this.textureLoader=new NA(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Cu(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const c={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};return Vi(o,c,i),Oa(c,i),Promise.all(n._invokeAll(function(d){return d.afterRoot&&d.afterRoot(c)})).then(function(){for(const d of c.scenes)d.updateMatrixWorld();e(c)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,o=t.length;i<o;i++){const r=t[i].joints;for(let c=0,d=r.length;c<d;c++)e[r[c]].isBone=!0}for(let i=0,o=e.length;i<o;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),o=(r,c)=>{const d=this.associations.get(r);d!=null&&this.associations.set(c,d);for(const[h,p]of r.children.entries())o(p,c.children[h])};return o(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const o=e(t[i]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":i=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(o,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Dt.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(o,r){n.load(Cl.resolveURL(t.uri,i.path),o,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const r=vm[i.type],c=rr[i.componentType],d=i.normalized===!0,h=new c(i.count*r);return Promise.resolve(new Wn(h,r,d))}const o=[];return i.bufferView!==void 0?o.push(this.getDependency("bufferView",i.bufferView)):o.push(null),i.sparse!==void 0&&(o.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(o).then(function(r){const c=r[0],d=vm[i.type],h=rr[i.componentType],p=h.BYTES_PER_ELEMENT,f=p*d,g=i.byteOffset||0,y=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,v=i.normalized===!0;let w,S;if(y&&y!==f){const C=Math.floor(g/y),A="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+C+":"+i.count;let N=t.cache.get(A);N||(w=new h(c,C*y,i.count*y/p),N=new TA(w,y/p),t.cache.add(A,N)),S=new FA(N,d,g%y/p,v)}else c===null?w=new h(i.count*d):w=new h(c,g,i.count*d),S=new Wn(w,d,v);if(i.sparse!==void 0){const C=vm.SCALAR,A=rr[i.sparse.indices.componentType],N=i.sparse.indices.byteOffset||0,_=i.sparse.values.byteOffset||0,M=new A(r[1],N,i.sparse.count*C),E=new h(r[2],_,i.sparse.count*d);c!==null&&(S=new Wn(S.array.slice(),S.itemSize,S.normalized)),S.normalized=!1;for(let z=0,T=M.length;z<T;z++){const R=M[z];if(S.setX(R,E[z*d]),d>=2&&S.setY(R,E[z*d+1]),d>=3&&S.setZ(R,E[z*d+2]),d>=4&&S.setW(R,E[z*d+3]),d>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}S.normalized=v}return S})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,r=t.images[o];let c=this.textureLoader;if(r.uri){const d=n.manager.getHandler(r.uri);d!==null&&(c=d)}return this.loadTextureImage(e,o,c)}loadTextureImage(e,t,n){const i=this,o=this.json,r=o.textures[e],c=o.images[t],d=(c.uri||c.bufferView)+":"+r.sampler;if(this.textureCache[d])return this.textureCache[d];const h=this.loadImageSource(t,n).then(function(p){p.flipY=!1,p.name=r.name||c.name||"",p.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(p.name=c.uri);const g=(o.samplers||{})[r.sampler]||{};return p.magFilter=c0[g.magFilter]||ds,p.minFilter=c0[g.minFilter]||Al,p.wrapS=u0[g.wrapS]||Qi,p.wrapT=u0[g.wrapT]||Qi,p.generateMipmaps=!p.isCompressedTexture&&p.minFilter!==mk&&p.minFilter!==ds,i.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[d]=h,h}loadImageSource(e,t){const n=this,i=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const r=i.images[e],c=self.URL||self.webkitURL;let d=r.uri||"",h=!1;if(r.bufferView!==void 0)d=n.getDependency("bufferView",r.bufferView).then(function(f){h=!0;const g=new Blob([f],{type:r.mimeType});return d=c.createObjectURL(g),d});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(d).then(function(f){return new Promise(function(g,y){let v=g;t.isImageBitmapLoader===!0&&(v=function(w){const S=new Px(w);S.needsUpdate=!0,g(S)}),t.load(Cl.resolveURL(f,o.path),v,void 0,y)})}).then(function(f){return h===!0&&c.revokeObjectURL(d),Oa(f,r),f.userData.mimeType=r.mimeType||dT(r.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",d),f});return this.sourceCache[e]=p,p}assignTexture(e,t,n,i){const o=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),o.extensions[Dt.KHR_TEXTURE_TRANSFORM]){const c=n.extensions!==void 0?n.extensions[Dt.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const d=o.associations.get(r);r=o.extensions[Dt.KHR_TEXTURE_TRANSFORM].extendTexture(r,c),o.associations.set(r,d)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+n.uuid;let d=this.cache.get(c);d||(d=new Yu,yi.prototype.copy.call(d,n),d.color.copy(n.color),d.map=n.map,d.sizeAttenuation=!1,this.cache.add(c,d)),n=d}else if(e.isLine){const c="LineBasicMaterial:"+n.uuid;let d=this.cache.get(c);d||(d=new Ji,yi.prototype.copy.call(d,n),d.color.copy(n.color),d.map=n.map,this.cache.add(c,d)),n=d}if(i||o||r){let c="ClonedMaterial:"+n.uuid+":";i&&(c+="derivative-tangents:"),o&&(c+="vertex-colors:"),r&&(c+="flat-shading:");let d=this.cache.get(c);d||(d=n.clone(),o&&(d.vertexColors=!0),r&&(d.flatShading=!0),i&&(d.normalScale&&(d.normalScale.y*=-1),d.clearcoatNormalScale&&(d.clearcoatNormalScale.y*=-1)),this.cache.add(c,d),this.associations.set(d,this.associations.get(n))),n=d}e.material=n}getMaterialType(){return Ke}loadMaterial(e){const t=this,n=this.json,i=this.extensions,o=n.materials[e];let r;const c={},d=o.extensions||{},h=[];if(d[Dt.KHR_MATERIALS_UNLIT]){const f=i[Dt.KHR_MATERIALS_UNLIT];r=f.getMaterialType(),h.push(f.extendParams(c,o,t))}else{const f=o.pbrMetallicRoughness||{};if(c.color=new At(1,1,1),c.opacity=1,Array.isArray(f.baseColorFactor)){const g=f.baseColorFactor;c.color.setRGB(g[0],g[1],g[2],da),c.opacity=g[3]}f.baseColorTexture!==void 0&&h.push(t.assignTexture(c,"map",f.baseColorTexture,qn)),c.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,c.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(c,"metalnessMap",f.metallicRoughnessTexture)),h.push(t.assignTexture(c,"roughnessMap",f.metallicRoughnessTexture))),r=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,c)})))}o.doubleSided===!0&&(c.side=Hs);const p=o.alphaMode||wm.OPAQUE;if(p===wm.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,p===wm.MASK&&(c.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&r!==Re&&(h.push(t.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new Gs(1,1),o.normalTexture.scale!==void 0)){const f=o.normalTexture.scale;c.normalScale.set(f,f)}if(o.occlusionTexture!==void 0&&r!==Re&&(h.push(t.assignTexture(c,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&r!==Re){const f=o.emissiveFactor;c.emissive=new At().setRGB(f[0],f[1],f[2],da)}return o.emissiveTexture!==void 0&&r!==Re&&h.push(t.assignTexture(c,"emissiveMap",o.emissiveTexture,qn)),Promise.all(h).then(function(){const f=new r(c);return o.name&&(f.name=o.name),Oa(f,o),t.associations.set(f,{materials:e}),o.extensions&&Vi(i,f,o),f})}createUniqueName(e){const t=LA.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function o(c){return n[Dt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(d){return d0(d,c,t)})}const r=[];for(let c=0,d=e.length;c<d;c++){const h=e[c],p=uT(h),f=i[p];if(f)r.push(f.promise);else{let g;h.extensions&&h.extensions[Dt.KHR_DRACO_MESH_COMPRESSION]?g=o(h):g=d0(new Bn,h,t),i[p]={primitive:h,promise:g},r.push(g)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,o=n.meshes[e],r=o.primitives,c=[];for(let d=0,h=r.length;d<h;d++){const p=r[d].material===void 0?rT(this.cache):this.getDependency("material",r[d].material);c.push(p)}return c.push(t.loadGeometries(r)),Promise.all(c).then(function(d){const h=d.slice(0,d.length-1),p=d[d.length-1],f=[];for(let y=0,v=p.length;y<v;y++){const w=p[y],S=r[y];let C;const A=h[y];if(S.mode===Dn.TRIANGLES||S.mode===Dn.TRIANGLE_STRIP||S.mode===Dn.TRIANGLE_FAN||S.mode===void 0)C=o.isSkinnedMesh===!0?new rp(w,A):new ke(w,A),C.isSkinnedMesh===!0&&C.normalizeSkinWeights(),S.mode===Dn.TRIANGLE_STRIP?C.geometry=r0(C.geometry,lk):S.mode===Dn.TRIANGLE_FAN&&(C.geometry=r0(C.geometry,op));else if(S.mode===Dn.LINES)C=new ef(w,A);else if(S.mode===Dn.LINE_STRIP)C=new gi(w,A);else if(S.mode===Dn.LINE_LOOP)C=new BA(w,A);else if(S.mode===Dn.POINTS)C=new $l(w,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+S.mode);Object.keys(C.geometry.morphAttributes).length>0&&cT(C,o),C.name=t.createUniqueName(o.name||"mesh_"+e),Oa(C,o),S.extensions&&Vi(i,C,S),t.assignFinalMaterial(C),f.push(C)}for(let y=0,v=f.length;y<v;y++)t.associations.set(f[y],{meshes:e,primitives:y});if(f.length===1)return o.extensions&&Vi(i,f[0],o),f[0];const g=new os;o.extensions&&Vi(i,g,o),t.associations.set(g,{meshes:e});for(let y=0,v=f.length;y<v;y++)g.add(f[y]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new tf(pk.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new fk(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Oa(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,o=t.joints.length;i<o;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const o=i.pop(),r=i,c=[],d=[];for(let h=0,p=r.length;h<p;h++){const f=r[h];if(f){c.push(f);const g=new ao;o!==null&&g.fromArray(o.array,h*16),d.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new OA(c,d)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],o=i.name?i.name:"animation_"+e,r=[],c=[],d=[],h=[],p=[];for(let f=0,g=i.channels.length;f<g;f++){const y=i.channels[f],v=i.samplers[y.sampler],w=y.target,S=w.node,C=i.parameters!==void 0?i.parameters[v.input]:v.input,A=i.parameters!==void 0?i.parameters[v.output]:v.output;w.node!==void 0&&(r.push(this.getDependency("node",S)),c.push(this.getDependency("accessor",C)),d.push(this.getDependency("accessor",A)),h.push(v),p.push(w))}return Promise.all([Promise.all(r),Promise.all(c),Promise.all(d),Promise.all(h),Promise.all(p)]).then(function(f){const g=f[0],y=f[1],v=f[2],w=f[3],S=f[4],C=[];for(let A=0,N=g.length;A<N;A++){const _=g[A],M=y[A],E=v[A],z=w[A],T=S[A];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const R=n._createAnimationTracks(_,M,E,z,T);if(R)for(let D=0;D<R.length;D++)C.push(R[D])}return new PA(o,void 0,C)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(o){const r=n._getNodeRef(n.meshCache,i.mesh,o);return i.weights!==void 0&&r.traverse(function(c){if(c.isMesh)for(let d=0,h=i.weights.length;d<h;d++)c.morphTargetInfluences[d]=i.weights[d]}),r})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],o=n._loadNodeShallow(e),r=[],c=i.children||[];for(let h=0,p=c.length;h<p;h++)r.push(n.getDependency("node",c[h]));const d=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([o,Promise.all(r),d]).then(function(h){const p=h[0],f=h[1],g=h[2];g!==null&&p.traverse(function(y){y.isSkinnedMesh&&y.bind(g,hT)});for(let y=0,v=f.length;y<v;y++)p.add(f[y]);return p})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],r=o.name?i.createUniqueName(o.name):"",c=[],d=i._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return d&&c.push(d),o.camera!==void 0&&c.push(i.getDependency("camera",o.camera).then(function(h){return i._getNodeRef(i.cameraCache,o.camera,h)})),i._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){c.push(h)}),this.nodeCache[e]=Promise.all(c).then(function(h){let p;if(o.isBone===!0?p=new IA:h.length>1?p=new os:h.length===1?p=h[0]:p=new dk,p!==h[0])for(let f=0,g=h.length;f<g;f++)p.add(h[f]);if(o.name&&(p.userData.name=o.name,p.name=r),Oa(p,o),o.extensions&&Vi(n,p,o),o.matrix!==void 0){const f=new ao;f.fromArray(o.matrix),p.applyMatrix4(f)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return i.associations.has(p)||i.associations.set(p,{}),i.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,o=new os;n.name&&(o.name=i.createUniqueName(n.name)),Oa(o,n),n.extensions&&Vi(t,o,n);const r=n.nodes||[],c=[];for(let d=0,h=r.length;d<h;d++)c.push(i.getDependency("node",r[d]));return Promise.all(c).then(function(d){for(let p=0,f=d.length;p<f;p++)o.add(d[p]);const h=p=>{const f=new Map;for(const[g,y]of i.associations)(g instanceof yi||g instanceof Px)&&f.set(g,y);return p.traverse(g=>{const y=i.associations.get(g);y!=null&&f.set(g,y)}),f};return i.associations=h(o),o})}_createAnimationTracks(e,t,n,i,o){const r=[],c=e.name?e.name:e.uuid,d=[];mi[o.path]===mi.weights?e.traverse(function(g){g.morphTargetInfluences&&d.push(g.name?g.name:g.uuid)}):d.push(c);let h;switch(mi[o.path]){case mi.weights:h=zx;break;case mi.rotation:h=Fx;break;case mi.position:case mi.scale:h=Ix;break;default:switch(n.itemSize){case 1:h=zx;break;case 2:case 3:default:h=Ix;break}break}const p=i.interpolation!==void 0?oT[i.interpolation]:gk,f=this._getArrayFromAccessor(n);for(let g=0,y=d.length;g<y;g++){const v=new h(d[g]+"."+mi[o.path],t.array,f,p);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(v),r.push(v)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=xp(t.constructor),i=new Float32Array(t.length);for(let o=0,r=t.length;o<r;o++)i[o]=t[o]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof Fx?iT:Pk;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function pT(s,e,t){const n=e.attributes,i=new Au;if(n.POSITION!==void 0){const c=t.json.accessors[n.POSITION],d=c.min,h=c.max;if(d!==void 0&&h!==void 0){if(i.set(new nt(d[0],d[1],d[2]),new nt(h[0],h[1],h[2])),c.normalized){const p=xp(rr[c.componentType]);i.min.multiplyScalar(p),i.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const c=new nt,d=new nt;for(let h=0,p=o.length;h<p;h++){const f=o[h];if(f.POSITION!==void 0){const g=t.json.accessors[f.POSITION],y=g.min,v=g.max;if(y!==void 0&&v!==void 0){if(d.setX(Math.max(Math.abs(y[0]),Math.abs(v[0]))),d.setY(Math.max(Math.abs(y[1]),Math.abs(v[1]))),d.setZ(Math.max(Math.abs(y[2]),Math.abs(v[2]))),g.normalized){const w=xp(rr[g.componentType]);d.multiplyScalar(w)}c.max(d)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(c)}s.boundingBox=i;const r=new $A;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=r}function d0(s,e,t){const n=e.attributes,i=[];function o(r,c){return t.getDependency("accessor",r).then(function(d){s.setAttribute(c,d)})}for(const r in n){const c=yp[r]||r.toLowerCase();c in s.attributes||i.push(o(n[r],c))}if(e.indices!==void 0&&!s.index){const r=t.getDependency("accessor",e.indices).then(function(c){s.setIndex(c)});i.push(r)}return lp.workingColorSpace!==da&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${lp.workingColorSpace}" not supported.`),Oa(s,e),pT(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?lT(s,e.targets,t):s})}const Sm=new WeakMap;class cf extends ck{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const o=new Cu(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,r=>{this.parse(r,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,qn,n).catch(n)}decodeDracoFile(e,t,n,i,o=da,r=()=>{}){const c={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:o};return this.decodeGeometry(e,c).then(t).catch(r)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Sm.has(e)){const d=Sm.get(e);if(d.key===n)return d.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const o=this.workerNextTaskID++,r=e.byteLength,c=this._getWorker(o,r).then(d=>(i=d,new Promise((h,p)=>{i._callbacks[o]={resolve:h,reject:p},i.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(d=>this._createGeometry(d.geometry));return c.catch(()=>!0).then(()=>{i&&o&&this._releaseTask(i,o)}),Sm.set(e,{key:n,promise:c}),c}_createGeometry(e){const t=new Bn;e.index&&t.setIndex(new Wn(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],o=i.name,r=i.array,c=i.itemSize,d=new Wn(r,c);o==="color"&&(this._assignVertexColorSpace(d,i.vertexColorSpace),d.normalized=!(r instanceof Float32Array)),t.setAttribute(o,d)}return t}_assignVertexColorSpace(e,t){if(t!==qn)return;const n=new At;for(let i=0,o=e.count;i<o;i++)n.fromBufferAttribute(e,i),lp.toWorkingColorSpace(n,qn),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new Cu(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,o)=>{n.load(e,i,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=fT.toString(),r=["/* draco decoder */",i,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
|
|
33
|
+
`).replace(GC,"")}function nx(l,u){return u=sx(u),sx(l)===u}function Zt(l,u,m,b,k,j){switch(m){case"children":typeof b=="string"?u==="body"||u==="textarea"&&b===""||yo(l,b):(typeof b=="number"||typeof b=="bigint")&&u!=="body"&&yo(l,""+b);break;case"className":Ei(l,"class",b);break;case"tabIndex":Ei(l,"tabindex",b);break;case"dir":case"role":case"viewBox":case"width":case"height":Ei(l,m,b);break;case"style":ng(l,b,j);break;case"data":if(u!=="object"){Ei(l,"data",b);break}case"src":case"href":if(b===""&&(u!=="a"||m!=="href")){l.removeAttribute(m);break}if(b==null||typeof b=="function"||typeof b=="symbol"||typeof b=="boolean"){l.removeAttribute(m);break}b=Jl(""+b),l.setAttribute(m,b);break;case"action":case"formAction":if(typeof b=="function"){l.setAttribute(m,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof j=="function"&&(m==="formAction"?(u!=="input"&&Zt(l,u,"name",k.name,k,null),Zt(l,u,"formEncType",k.formEncType,k,null),Zt(l,u,"formMethod",k.formMethod,k,null),Zt(l,u,"formTarget",k.formTarget,k,null)):(Zt(l,u,"encType",k.encType,k,null),Zt(l,u,"method",k.method,k,null),Zt(l,u,"target",k.target,k,null)));if(b==null||typeof b=="symbol"||typeof b=="boolean"){l.removeAttribute(m);break}b=Jl(""+b),l.setAttribute(m,b);break;case"onClick":b!=null&&(l.onclick=xa);break;case"onScroll":b!=null&&Rt("scroll",l);break;case"onScrollEnd":b!=null&&Rt("scrollend",l);break;case"dangerouslySetInnerHTML":if(b!=null){if(typeof b!="object"||!("__html"in b))throw Error(n(61));if(m=b.__html,m!=null){if(k.children!=null)throw Error(n(60));l.innerHTML=m}}break;case"multiple":l.multiple=b&&typeof b!="function"&&typeof b!="symbol";break;case"muted":l.muted=b&&typeof b!="function"&&typeof b!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(b==null||typeof b=="function"||typeof b=="boolean"||typeof b=="symbol"){l.removeAttribute("xlink:href");break}m=Jl(""+b),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",m);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":b!=null&&typeof b!="function"&&typeof b!="symbol"?l.setAttribute(m,""+b):l.removeAttribute(m);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":b&&typeof b!="function"&&typeof b!="symbol"?l.setAttribute(m,""):l.removeAttribute(m);break;case"capture":case"download":b===!0?l.setAttribute(m,""):b!==!1&&b!=null&&typeof b!="function"&&typeof b!="symbol"?l.setAttribute(m,b):l.removeAttribute(m);break;case"cols":case"rows":case"size":case"span":b!=null&&typeof b!="function"&&typeof b!="symbol"&&!isNaN(b)&&1<=b?l.setAttribute(m,b):l.removeAttribute(m);break;case"rowSpan":case"start":b==null||typeof b=="function"||typeof b=="symbol"||isNaN(b)?l.removeAttribute(m):l.setAttribute(m,b);break;case"popover":Rt("beforetoggle",l),Rt("toggle",l),Mi(l,"popover",b);break;case"xlinkActuate":Sn(l,"http://www.w3.org/1999/xlink","xlink:actuate",b);break;case"xlinkArcrole":Sn(l,"http://www.w3.org/1999/xlink","xlink:arcrole",b);break;case"xlinkRole":Sn(l,"http://www.w3.org/1999/xlink","xlink:role",b);break;case"xlinkShow":Sn(l,"http://www.w3.org/1999/xlink","xlink:show",b);break;case"xlinkTitle":Sn(l,"http://www.w3.org/1999/xlink","xlink:title",b);break;case"xlinkType":Sn(l,"http://www.w3.org/1999/xlink","xlink:type",b);break;case"xmlBase":Sn(l,"http://www.w3.org/XML/1998/namespace","xml:base",b);break;case"xmlLang":Sn(l,"http://www.w3.org/XML/1998/namespace","xml:lang",b);break;case"xmlSpace":Sn(l,"http://www.w3.org/XML/1998/namespace","xml:space",b);break;case"is":Mi(l,"is",b);break;case"innerText":case"textContent":break;default:(!(2<m.length)||m[0]!=="o"&&m[0]!=="O"||m[1]!=="n"&&m[1]!=="N")&&(m=y1.get(m)||m,Mi(l,m,b))}}function Zh(l,u,m,b,k,j){switch(m){case"style":ng(l,b,j);break;case"dangerouslySetInnerHTML":if(b!=null){if(typeof b!="object"||!("__html"in b))throw Error(n(61));if(m=b.__html,m!=null){if(k.children!=null)throw Error(n(60));l.innerHTML=m}}break;case"children":typeof b=="string"?yo(l,b):(typeof b=="number"||typeof b=="bigint")&&yo(l,""+b);break;case"onScroll":b!=null&&Rt("scroll",l);break;case"onScrollEnd":b!=null&&Rt("scrollend",l);break;case"onClick":b!=null&&(l.onclick=xa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!gr.hasOwnProperty(m))e:{if(m[0]==="o"&&m[1]==="n"&&(k=m.endsWith("Capture"),u=m.slice(2,k?m.length-7:void 0),j=l[Ye]||null,j=j!=null?j[m]:null,typeof j=="function"&&l.removeEventListener(u,j,k),typeof b=="function")){typeof j!="function"&&j!==null&&(m in l?l[m]=null:l.hasAttribute(m)&&l.removeAttribute(m)),l.addEventListener(u,b,k);break e}m in l?l[m]=b:b===!0?l.setAttribute(m,""):Mi(l,m,b)}}}function Fs(l,u,m){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Rt("error",l),Rt("load",l);var b=!1,k=!1,j;for(j in m)if(m.hasOwnProperty(j)){var F=m[j];if(F!=null)switch(j){case"src":b=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(n(137,u));default:Zt(l,u,j,F,m,null)}}k&&Zt(l,u,"srcSet",m.srcSet,m,null),b&&Zt(l,u,"src",m.src,m,null);return;case"input":Rt("invalid",l);var X=j=F=k=null,ie=null,we=null;for(b in m)if(m.hasOwnProperty(b)){var Ee=m[b];if(Ee!=null)switch(b){case"name":k=Ee;break;case"type":F=Ee;break;case"checked":ie=Ee;break;case"defaultChecked":we=Ee;break;case"value":j=Ee;break;case"defaultValue":X=Ee;break;case"children":case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(n(137,u));break;default:Zt(l,u,b,Ee,m,null)}}wr(l,j,X,ie,we,F,k,!1);return;case"select":Rt("invalid",l),b=F=j=null;for(k in m)if(m.hasOwnProperty(k)&&(X=m[k],X!=null))switch(k){case"value":j=X;break;case"defaultValue":F=X;break;case"multiple":b=X;default:Zt(l,u,k,X,m,null)}u=j,m=F,l.multiple=!!b,u!=null?ba(l,!!b,u,!1):m!=null&&ba(l,!!b,m,!0);return;case"textarea":Rt("invalid",l),j=k=b=null;for(F in m)if(m.hasOwnProperty(F)&&(X=m[F],X!=null))switch(F){case"value":b=X;break;case"defaultValue":k=X;break;case"children":j=X;break;case"dangerouslySetInnerHTML":if(X!=null)throw Error(n(91));break;default:Zt(l,u,F,X,m,null)}bo(l,b,k,j);return;case"option":for(ie in m)if(m.hasOwnProperty(ie)&&(b=m[ie],b!=null))switch(ie){case"selected":l.selected=b&&typeof b!="function"&&typeof b!="symbol";break;default:Zt(l,u,ie,b,m,null)}return;case"dialog":Rt("beforetoggle",l),Rt("toggle",l),Rt("cancel",l),Rt("close",l);break;case"iframe":case"object":Rt("load",l);break;case"video":case"audio":for(b=0;b<el.length;b++)Rt(el[b],l);break;case"image":Rt("error",l),Rt("load",l);break;case"details":Rt("toggle",l);break;case"embed":case"source":case"link":Rt("error",l),Rt("load",l);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(we in m)if(m.hasOwnProperty(we)&&(b=m[we],b!=null))switch(we){case"children":case"dangerouslySetInnerHTML":throw Error(n(137,u));default:Zt(l,u,we,b,m,null)}return;default:if(dd(u)){for(Ee in m)m.hasOwnProperty(Ee)&&(b=m[Ee],b!==void 0&&Zh(l,u,Ee,b,m,void 0));return}}for(X in m)m.hasOwnProperty(X)&&(b=m[X],b!=null&&Zt(l,u,X,b,m,null))}function qC(l,u,m,b){switch(u){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var k=null,j=null,F=null,X=null,ie=null,we=null,Ee=null;for(Te in m){var Oe=m[Te];if(m.hasOwnProperty(Te)&&Oe!=null)switch(Te){case"checked":break;case"value":break;case"defaultValue":ie=Oe;default:b.hasOwnProperty(Te)||Zt(l,u,Te,null,b,Oe)}}for(var je in b){var Te=b[je];if(Oe=m[je],b.hasOwnProperty(je)&&(Te!=null||Oe!=null))switch(je){case"type":j=Te;break;case"name":k=Te;break;case"checked":we=Te;break;case"defaultChecked":Ee=Te;break;case"value":F=Te;break;case"defaultValue":X=Te;break;case"children":case"dangerouslySetInnerHTML":if(Te!=null)throw Error(n(137,u));break;default:Te!==Oe&&Zt(l,u,je,Te,b,Oe)}}fo(l,F,X,ie,we,Ee,j,k);return;case"select":Te=F=X=je=null;for(j in m)if(ie=m[j],m.hasOwnProperty(j)&&ie!=null)switch(j){case"value":break;case"multiple":Te=ie;default:b.hasOwnProperty(j)||Zt(l,u,j,null,b,ie)}for(k in b)if(j=b[k],ie=m[k],b.hasOwnProperty(k)&&(j!=null||ie!=null))switch(k){case"value":je=j;break;case"defaultValue":X=j;break;case"multiple":F=j;default:j!==ie&&Zt(l,u,k,j,b,ie)}u=X,m=F,b=Te,je!=null?ba(l,!!m,je,!1):!!b!=!!m&&(u!=null?ba(l,!!m,u,!0):ba(l,!!m,m?[]:"",!1));return;case"textarea":Te=je=null;for(X in m)if(k=m[X],m.hasOwnProperty(X)&&k!=null&&!b.hasOwnProperty(X))switch(X){case"value":break;case"children":break;default:Zt(l,u,X,null,b,k)}for(F in b)if(k=b[F],j=m[F],b.hasOwnProperty(F)&&(k!=null||j!=null))switch(F){case"value":je=k;break;case"defaultValue":Te=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(n(91));break;default:k!==j&&Zt(l,u,F,k,b,j)}ya(l,je,Te);return;case"option":for(var tt in m)if(je=m[tt],m.hasOwnProperty(tt)&&je!=null&&!b.hasOwnProperty(tt))switch(tt){case"selected":l.selected=!1;break;default:Zt(l,u,tt,null,b,je)}for(ie in b)if(je=b[ie],Te=m[ie],b.hasOwnProperty(ie)&&je!==Te&&(je!=null||Te!=null))switch(ie){case"selected":l.selected=je&&typeof je!="function"&&typeof je!="symbol";break;default:Zt(l,u,ie,je,b,Te)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var ht in m)je=m[ht],m.hasOwnProperty(ht)&&je!=null&&!b.hasOwnProperty(ht)&&Zt(l,u,ht,null,b,je);for(we in b)if(je=b[we],Te=m[we],b.hasOwnProperty(we)&&je!==Te&&(je!=null||Te!=null))switch(we){case"children":case"dangerouslySetInnerHTML":if(je!=null)throw Error(n(137,u));break;default:Zt(l,u,we,je,b,Te)}return;default:if(dd(u)){for(var Qt in m)je=m[Qt],m.hasOwnProperty(Qt)&&je!==void 0&&!b.hasOwnProperty(Qt)&&Zh(l,u,Qt,void 0,b,je);for(Ee in b)je=b[Ee],Te=m[Ee],!b.hasOwnProperty(Ee)||je===Te||je===void 0&&Te===void 0||Zh(l,u,Ee,je,b,Te);return}}for(var be in m)je=m[be],m.hasOwnProperty(be)&&je!=null&&!b.hasOwnProperty(be)&&Zt(l,u,be,null,b,je);for(Oe in b)je=b[Oe],Te=m[Oe],!b.hasOwnProperty(Oe)||je===Te||je==null&&Te==null||Zt(l,u,Oe,je,b,Te)}function ax(l){switch(l){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function WC(){if(typeof performance.getEntriesByType=="function"){for(var l=0,u=0,m=performance.getEntriesByType("resource"),b=0;b<m.length;b++){var k=m[b],j=k.transferSize,F=k.initiatorType,X=k.duration;if(j&&X&&ax(F)){for(F=0,X=k.responseEnd,b+=1;b<m.length;b++){var ie=m[b],we=ie.startTime;if(we>X)break;var Ee=ie.transferSize,Oe=ie.initiatorType;Ee&&ax(Oe)&&(ie=ie.responseEnd,F+=Ee*(ie<X?1:(X-we)/(ie-we)))}if(--b,u+=8*(j+F)/(k.duration/1e3),l++,10<l)break}}if(0<l)return u/l/1e6}return navigator.connection&&(l=navigator.connection.downlink,typeof l=="number")?l:5}var Qh=null,Jh=null;function Vc(l){return l.nodeType===9?l:l.ownerDocument}function ix(l){switch(l){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function ox(l,u){if(l===0)switch(u){case"svg":return 1;case"math":return 2;default:return 0}return l===1&&u==="foreignObject"?0:l}function em(l,u){return l==="textarea"||l==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.children=="bigint"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var tm=null;function KC(){var l=window.event;return l&&l.type==="popstate"?l===tm?!1:(tm=l,!0):(tm=null,!1)}var rx=typeof setTimeout=="function"?setTimeout:void 0,VC=typeof clearTimeout=="function"?clearTimeout:void 0,lx=typeof Promise=="function"?Promise:void 0,YC=typeof queueMicrotask=="function"?queueMicrotask:typeof lx<"u"?function(l){return lx.resolve(null).then(l).catch(XC)}:rx;function XC(l){setTimeout(function(){throw l})}function ri(l){return l==="head"}function cx(l,u){var m=u,b=0;do{var k=m.nextSibling;if(l.removeChild(m),k&&k.nodeType===8)if(m=k.data,m==="/$"||m==="/&"){if(b===0){l.removeChild(k),Yo(u);return}b--}else if(m==="$"||m==="$?"||m==="$~"||m==="$!"||m==="&")b++;else if(m==="html")sl(l.ownerDocument.documentElement);else if(m==="head"){m=l.ownerDocument.head,sl(m);for(var j=m.firstChild;j;){var F=j.nextSibling,X=j.nodeName;j[zn]||X==="SCRIPT"||X==="STYLE"||X==="LINK"&&j.rel.toLowerCase()==="stylesheet"||m.removeChild(j),j=F}}else m==="body"&&sl(l.ownerDocument.body);m=k}while(m);Yo(u)}function ux(l,u){var m=l;l=0;do{var b=m.nextSibling;if(m.nodeType===1?u?(m._stashedDisplay=m.style.display,m.style.display="none"):(m.style.display=m._stashedDisplay||"",m.getAttribute("style")===""&&m.removeAttribute("style")):m.nodeType===3&&(u?(m._stashedText=m.nodeValue,m.nodeValue=""):m.nodeValue=m._stashedText||""),b&&b.nodeType===8)if(m=b.data,m==="/$"){if(l===0)break;l--}else m!=="$"&&m!=="$?"&&m!=="$~"&&m!=="$!"||l++;m=b}while(m)}function sm(l){var u=l.firstChild;for(u&&u.nodeType===10&&(u=u.nextSibling);u;){var m=u;switch(u=u.nextSibling,m.nodeName){case"HTML":case"HEAD":case"BODY":sm(m),ot(m);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(m.rel.toLowerCase()==="stylesheet")continue}l.removeChild(m)}}function ZC(l,u,m,b){for(;l.nodeType===1;){var k=m;if(l.nodeName.toLowerCase()!==u.toLowerCase()){if(!b&&(l.nodeName!=="INPUT"||l.type!=="hidden"))break}else if(b){if(!l[zn])switch(u){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(j=l.getAttribute("rel"),j==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(j!==k.rel||l.getAttribute("href")!==(k.href==null||k.href===""?null:k.href)||l.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin)||l.getAttribute("title")!==(k.title==null?null:k.title))break;return l;case"style":if(l.hasAttribute("data-precedence"))break;return l;case"script":if(j=l.getAttribute("src"),(j!==(k.src==null?null:k.src)||l.getAttribute("type")!==(k.type==null?null:k.type)||l.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&j&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(u==="input"&&l.type==="hidden"){var j=k.name==null?null:""+k.name;if(k.type==="hidden"&&l.getAttribute("name")===j)return l}else return l;if(l=En(l.nextSibling),l===null)break}return null}function QC(l,u,m){if(u==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!m||(l=En(l.nextSibling),l===null))return null;return l}function dx(l,u){for(;l.nodeType!==8;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!u||(l=En(l.nextSibling),l===null))return null;return l}function nm(l){return l.data==="$?"||l.data==="$~"}function am(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState!=="loading"}function JC(l,u){var m=l.ownerDocument;if(l.data==="$~")l._reactRetry=u;else if(l.data!=="$?"||m.readyState!=="loading")u();else{var b=function(){u(),m.removeEventListener("DOMContentLoaded",b)};m.addEventListener("DOMContentLoaded",b),l._reactRetry=b}}function En(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"||u==="F!"||u==="F")break;if(u==="/$"||u==="/&")return null}}return l}var im=null;function hx(l){l=l.nextSibling;for(var u=0;l;){if(l.nodeType===8){var m=l.data;if(m==="/$"||m==="/&"){if(u===0)return En(l.nextSibling);u--}else m!=="$"&&m!=="$!"&&m!=="$?"&&m!=="$~"&&m!=="&"||u++}l=l.nextSibling}return null}function mx(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var m=l.data;if(m==="$"||m==="$!"||m==="$?"||m==="$~"||m==="&"){if(u===0)return l;u--}else m!=="/$"&&m!=="/&"||u++}l=l.previousSibling}return null}function px(l,u,m){switch(u=Vc(m),l){case"html":if(l=u.documentElement,!l)throw Error(n(452));return l;case"head":if(l=u.head,!l)throw Error(n(453));return l;case"body":if(l=u.body,!l)throw Error(n(454));return l;default:throw Error(n(451))}}function sl(l){for(var u=l.attributes;u.length;)l.removeAttributeNode(u[0]);ot(l)}var _n=new Map,fx=new Set;function Yc(l){return typeof l.getRootNode=="function"?l.getRootNode():l.nodeType===9?l:l.ownerDocument}var Ba=q.d;q.d={f:eA,r:tA,D:sA,C:nA,L:aA,m:iA,X:rA,S:oA,M:lA};function eA(){var l=Ba.f(),u=Fc();return l||u}function tA(l){var u=as(l);u!==null&&u.tag===5&&u.type==="form"?Rb(u):Ba.r(l)}var Wo=typeof document>"u"?null:document;function gx(l,u,m){var b=Wo;if(b&&typeof u=="string"&&u){var k=Vs(u);k='link[rel="'+l+'"][href="'+k+'"]',typeof m=="string"&&(k+='[crossorigin="'+m+'"]'),fx.has(k)||(fx.add(k),l={rel:l,crossOrigin:m,href:u},b.querySelector(k)===null&&(u=b.createElement("link"),Fs(u,"link",l),bs(u),b.head.appendChild(u)))}}function sA(l){Ba.D(l),gx("dns-prefetch",l,null)}function nA(l,u){Ba.C(l,u),gx("preconnect",l,u)}function aA(l,u,m){Ba.L(l,u,m);var b=Wo;if(b&&l&&u){var k='link[rel="preload"][as="'+Vs(u)+'"]';u==="image"&&m&&m.imageSrcSet?(k+='[imagesrcset="'+Vs(m.imageSrcSet)+'"]',typeof m.imageSizes=="string"&&(k+='[imagesizes="'+Vs(m.imageSizes)+'"]')):k+='[href="'+Vs(l)+'"]';var j=k;switch(u){case"style":j=Ko(l);break;case"script":j=Vo(l)}_n.has(j)||(l=f({rel:"preload",href:u==="image"&&m&&m.imageSrcSet?void 0:l,as:u},m),_n.set(j,l),b.querySelector(k)!==null||u==="style"&&b.querySelector(nl(j))||u==="script"&&b.querySelector(al(j))||(u=b.createElement("link"),Fs(u,"link",l),bs(u),b.head.appendChild(u)))}}function iA(l,u){Ba.m(l,u);var m=Wo;if(m&&l){var b=u&&typeof u.as=="string"?u.as:"script",k='link[rel="modulepreload"][as="'+Vs(b)+'"][href="'+Vs(l)+'"]',j=k;switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=Vo(l)}if(!_n.has(j)&&(l=f({rel:"modulepreload",href:l},u),_n.set(j,l),m.querySelector(k)===null)){switch(b){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(m.querySelector(al(j)))return}b=m.createElement("link"),Fs(b,"link",l),bs(b),m.head.appendChild(b)}}}function oA(l,u,m){Ba.S(l,u,m);var b=Wo;if(b&&l){var k=fa(b).hoistableStyles,j=Ko(l);u=u||"default";var F=k.get(j);if(!F){var X={loading:0,preload:null};if(F=b.querySelector(nl(j)))X.loading=5;else{l=f({rel:"stylesheet",href:l,"data-precedence":u},m),(m=_n.get(j))&&om(l,m);var ie=F=b.createElement("link");bs(ie),Fs(ie,"link",l),ie._p=new Promise(function(we,Ee){ie.onload=we,ie.onerror=Ee}),ie.addEventListener("load",function(){X.loading|=1}),ie.addEventListener("error",function(){X.loading|=2}),X.loading|=4,Xc(F,u,b)}F={type:"stylesheet",instance:F,count:1,state:X},k.set(j,F)}}}function rA(l,u){Ba.X(l,u);var m=Wo;if(m&&l){var b=fa(m).hoistableScripts,k=Vo(l),j=b.get(k);j||(j=m.querySelector(al(k)),j||(l=f({src:l,async:!0},u),(u=_n.get(k))&&rm(l,u),j=m.createElement("script"),bs(j),Fs(j,"link",l),m.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},b.set(k,j))}}function lA(l,u){Ba.M(l,u);var m=Wo;if(m&&l){var b=fa(m).hoistableScripts,k=Vo(l),j=b.get(k);j||(j=m.querySelector(al(k)),j||(l=f({src:l,async:!0,type:"module"},u),(u=_n.get(k))&&rm(l,u),j=m.createElement("script"),bs(j),Fs(j,"link",l),m.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},b.set(k,j))}}function bx(l,u,m,b){var k=(k=J.current)?Yc(k):null;if(!k)throw Error(n(446));switch(l){case"meta":case"title":return null;case"style":return typeof m.precedence=="string"&&typeof m.href=="string"?(u=Ko(m.href),m=fa(k).hoistableStyles,b=m.get(u),b||(b={type:"style",instance:null,count:0,state:null},m.set(u,b)),b):{type:"void",instance:null,count:0,state:null};case"link":if(m.rel==="stylesheet"&&typeof m.href=="string"&&typeof m.precedence=="string"){l=Ko(m.href);var j=fa(k).hoistableStyles,F=j.get(l);if(F||(k=k.ownerDocument||k,F={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(l,F),(j=k.querySelector(nl(l)))&&!j._p&&(F.instance=j,F.state.loading=5),_n.has(l)||(m={rel:"preload",as:"style",href:m.href,crossOrigin:m.crossOrigin,integrity:m.integrity,media:m.media,hrefLang:m.hrefLang,referrerPolicy:m.referrerPolicy},_n.set(l,m),j||cA(k,l,m,F.state))),u&&b===null)throw Error(n(528,""));return F}if(u&&b!==null)throw Error(n(529,""));return null;case"script":return u=m.async,m=m.src,typeof m=="string"&&u&&typeof u!="function"&&typeof u!="symbol"?(u=Vo(m),m=fa(k).hoistableScripts,b=m.get(u),b||(b={type:"script",instance:null,count:0,state:null},m.set(u,b)),b):{type:"void",instance:null,count:0,state:null};default:throw Error(n(444,l))}}function Ko(l){return'href="'+Vs(l)+'"'}function nl(l){return'link[rel="stylesheet"]['+l+"]"}function yx(l){return f({},l,{"data-precedence":l.precedence,precedence:null})}function cA(l,u,m,b){l.querySelector('link[rel="preload"][as="style"]['+u+"]")?b.loading=1:(u=l.createElement("link"),b.preload=u,u.addEventListener("load",function(){return b.loading|=1}),u.addEventListener("error",function(){return b.loading|=2}),Fs(u,"link",m),bs(u),l.head.appendChild(u))}function Vo(l){return'[src="'+Vs(l)+'"]'}function al(l){return"script[async]"+l}function xx(l,u,m){if(u.count++,u.instance===null)switch(u.type){case"style":var b=l.querySelector('style[data-href~="'+Vs(m.href)+'"]');if(b)return u.instance=b,bs(b),b;var k=f({},m,{"data-href":m.href,"data-precedence":m.precedence,href:null,precedence:null});return b=(l.ownerDocument||l).createElement("style"),bs(b),Fs(b,"style",k),Xc(b,m.precedence,l),u.instance=b;case"stylesheet":k=Ko(m.href);var j=l.querySelector(nl(k));if(j)return u.state.loading|=4,u.instance=j,bs(j),j;b=yx(m),(k=_n.get(k))&&om(b,k),j=(l.ownerDocument||l).createElement("link"),bs(j);var F=j;return F._p=new Promise(function(X,ie){F.onload=X,F.onerror=ie}),Fs(j,"link",b),u.state.loading|=4,Xc(j,m.precedence,l),u.instance=j;case"script":return j=Vo(m.src),(k=l.querySelector(al(j)))?(u.instance=k,bs(k),k):(b=m,(k=_n.get(j))&&(b=f({},m),rm(b,k)),l=l.ownerDocument||l,k=l.createElement("script"),bs(k),Fs(k,"link",b),l.head.appendChild(k),u.instance=k);case"void":return null;default:throw Error(n(443,u.type))}else u.type==="stylesheet"&&(u.state.loading&4)===0&&(b=u.instance,u.state.loading|=4,Xc(b,m.precedence,l));return u.instance}function Xc(l,u,m){for(var b=m.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=b.length?b[b.length-1]:null,j=k,F=0;F<b.length;F++){var X=b[F];if(X.dataset.precedence===u)j=X;else if(j!==k)break}j?j.parentNode.insertBefore(l,j.nextSibling):(u=m.nodeType===9?m.head:m,u.insertBefore(l,u.firstChild))}function om(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.title==null&&(l.title=u.title)}function rm(l,u){l.crossOrigin==null&&(l.crossOrigin=u.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=u.referrerPolicy),l.integrity==null&&(l.integrity=u.integrity)}var Zc=null;function vx(l,u,m){if(Zc===null){var b=new Map,k=Zc=new Map;k.set(m,b)}else k=Zc,b=k.get(m),b||(b=new Map,k.set(m,b));if(b.has(l))return b;for(b.set(l,null),m=m.getElementsByTagName(l),k=0;k<m.length;k++){var j=m[k];if(!(j[zn]||j[We]||l==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var F=j.getAttribute(u)||"";F=l+F;var X=b.get(F);X?X.push(j):b.set(F,[j])}}return b}function wx(l,u,m){l=l.ownerDocument||l,l.head.insertBefore(m,u==="title"?l.querySelector("head > title"):null)}function uA(l,u,m){if(m===1||u.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof u.precedence!="string"||typeof u.href!="string"||u.href==="")break;return!0;case"link":if(typeof u.rel!="string"||typeof u.href!="string"||u.href===""||u.onLoad||u.onError)break;switch(u.rel){case"stylesheet":return l=u.disabled,typeof u.precedence=="string"&&l==null;default:return!0}case"script":if(u.async&&typeof u.async!="function"&&typeof u.async!="symbol"&&!u.onLoad&&!u.onError&&u.src&&typeof u.src=="string")return!0}return!1}function kx(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function dA(l,u,m,b){if(m.type==="stylesheet"&&(typeof b.media!="string"||matchMedia(b.media).matches!==!1)&&(m.state.loading&4)===0){if(m.instance===null){var k=Ko(b.href),j=u.querySelector(nl(k));if(j){u=j._p,u!==null&&typeof u=="object"&&typeof u.then=="function"&&(l.count++,l=Qc.bind(l),u.then(l,l)),m.state.loading|=4,m.instance=j,bs(j);return}j=u.ownerDocument||u,b=yx(b),(k=_n.get(k))&&om(b,k),j=j.createElement("link"),bs(j);var F=j;F._p=new Promise(function(X,ie){F.onload=X,F.onerror=ie}),Fs(j,"link",b),m.instance=j}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(m,u),(u=m.state.preload)&&(m.state.loading&3)===0&&(l.count++,m=Qc.bind(l),u.addEventListener("load",m),u.addEventListener("error",m))}}var lm=0;function hA(l,u){return l.stylesheets&&l.count===0&&eu(l,l.stylesheets),0<l.count||0<l.imgCount?function(m){var b=setTimeout(function(){if(l.stylesheets&&eu(l,l.stylesheets),l.unsuspend){var j=l.unsuspend;l.unsuspend=null,j()}},6e4+u);0<l.imgBytes&&lm===0&&(lm=62500*WC());var k=setTimeout(function(){if(l.waitingForImages=!1,l.count===0&&(l.stylesheets&&eu(l,l.stylesheets),l.unsuspend)){var j=l.unsuspend;l.unsuspend=null,j()}},(l.imgBytes>lm?50:800)+u);return l.unsuspend=m,function(){l.unsuspend=null,clearTimeout(b),clearTimeout(k)}}:null}function Qc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)eu(this,this.stylesheets);else if(this.unsuspend){var l=this.unsuspend;this.unsuspend=null,l()}}}var Jc=null;function eu(l,u){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Jc=new Map,u.forEach(mA,l),Jc=null,Qc.call(l))}function mA(l,u){if(!(u.state.loading&4)){var m=Jc.get(l);if(m)var b=m.get(null);else{m=new Map,Jc.set(l,m);for(var k=l.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<k.length;j++){var F=k[j];(F.nodeName==="LINK"||F.getAttribute("media")!=="not all")&&(m.set(F.dataset.precedence,F),b=F)}b&&m.set(null,b)}k=u.instance,F=k.getAttribute("data-precedence"),j=m.get(F)||b,j===b&&m.set(null,k),m.set(F,k),this.count++,b=Qc.bind(this),k.addEventListener("load",b),k.addEventListener("error",b),j?j.parentNode.insertBefore(k,j.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(k,l.firstChild)),u.state.loading|=4}}var il={$$typeof:N,Provider:null,Consumer:null,_currentValue:V,_currentValue2:V,_threadCount:0};function pA(l,u,m,b,k,j,F,X,ie){this.tag=1,this.containerInfo=l,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ms(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ms(0),this.hiddenUpdates=Ms(null),this.identifierPrefix=b,this.onUncaughtError=k,this.onCaughtError=j,this.onRecoverableError=F,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ie,this.incompleteTransitions=new Map}function Sx(l,u,m,b,k,j,F,X,ie,we,Ee,Oe){return l=new pA(l,u,m,F,ie,we,Ee,Oe,X),u=1,j===!0&&(u|=24),j=hn(3,null,null,u),l.current=j,j.stateNode=l,u=Hd(),u.refCount++,l.pooledCache=u,u.refCount++,j.memoizedState={element:b,isDehydrated:m,cache:u},qd(j),l}function jx(l){return l?(l=Co,l):Co}function Cx(l,u,m,b,k,j){k=jx(k),b.context===null?b.context=k:b.pendingContext=k,b=Xa(u),b.payload={element:m},j=j===void 0?null:j,j!==null&&(b.callback=j),m=Za(l,b,u),m!==null&&(an(m,l,u),Pr(m,l,u))}function Ax(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var m=l.retryLane;l.retryLane=m!==0&&m<u?m:u}}function cm(l,u){Ax(l,u),(l=l.alternate)&&Ax(l,u)}function Nx(l){if(l.tag===13||l.tag===31){var u=Bi(l,67108864);u!==null&&an(u,l,67108864),cm(l,67108864)}}function Tx(l){if(l.tag===13||l.tag===31){var u=bn();u=ce(u);var m=Bi(l,u);m!==null&&an(m,l,u),cm(l,u)}}var tu=!0;function fA(l,u,m,b){var k=L.T;L.T=null;var j=q.p;try{q.p=2,um(l,u,m,b)}finally{q.p=j,L.T=k}}function gA(l,u,m,b){var k=L.T;L.T=null;var j=q.p;try{q.p=8,um(l,u,m,b)}finally{q.p=j,L.T=k}}function um(l,u,m,b){if(tu){var k=dm(b);if(k===null)Xh(l,u,b,su,m),Ex(l,b);else if(yA(k,l,u,m,b))b.stopPropagation();else if(Ex(l,b),u&4&&-1<bA.indexOf(l)){for(;k!==null;){var j=as(k);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var F=Je(j.pendingLanes);if(F!==0){var X=j;for(X.pendingLanes|=2,X.entangledLanes|=2;F;){var ie=1<<31-Qe(F);X.entanglements[1]|=ie,F&=~ie}na(j),(Gt&6)===0&&(Ic=qe()+500,Jr(0))}}break;case 31:case 13:X=Bi(j,2),X!==null&&an(X,j,2),Fc(),cm(j,2)}if(j=dm(b),j===null&&Xh(l,u,b,su,m),j===k)break;k=j}k!==null&&b.stopPropagation()}else Xh(l,u,b,null,m)}}function dm(l){return l=md(l),hm(l)}var su=null;function hm(l){if(su=null,l=Ut(l),l!==null){var u=o(l);if(u===null)l=null;else{var m=u.tag;if(m===13){if(l=r(u),l!==null)return l;l=null}else if(m===31){if(l=c(u),l!==null)return l;l=null}else if(m===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null)}}return su=l,null}function Mx(l){switch(l){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Ge()){case ee:return 2;case ge:return 8;case Ie:case Be:return 32;case ze:return 268435456;default:return 32}default:return 32}}var mm=!1,li=null,ci=null,ui=null,ol=new Map,rl=new Map,di=[],bA="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Ex(l,u){switch(l){case"focusin":case"focusout":li=null;break;case"dragenter":case"dragleave":ci=null;break;case"mouseover":case"mouseout":ui=null;break;case"pointerover":case"pointerout":ol.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":rl.delete(u.pointerId)}}function ll(l,u,m,b,k,j){return l===null||l.nativeEvent!==j?(l={blockedOn:u,domEventName:m,eventSystemFlags:b,nativeEvent:j,targetContainers:[k]},u!==null&&(u=as(u),u!==null&&Nx(u)),l):(l.eventSystemFlags|=b,u=l.targetContainers,k!==null&&u.indexOf(k)===-1&&u.push(k),l)}function yA(l,u,m,b,k){switch(u){case"focusin":return li=ll(li,l,u,m,b,k),!0;case"dragenter":return ci=ll(ci,l,u,m,b,k),!0;case"mouseover":return ui=ll(ui,l,u,m,b,k),!0;case"pointerover":var j=k.pointerId;return ol.set(j,ll(ol.get(j)||null,l,u,m,b,k)),!0;case"gotpointercapture":return j=k.pointerId,rl.set(j,ll(rl.get(j)||null,l,u,m,b,k)),!0}return!1}function _x(l){var u=Ut(l.target);if(u!==null){var m=o(u);if(m!==null){if(u=m.tag,u===13){if(u=r(m),u!==null){l.blockedOn=u,Ve(l.priority,function(){Tx(m)});return}}else if(u===31){if(u=c(m),u!==null){l.blockedOn=u,Ve(l.priority,function(){Tx(m)});return}}else if(u===3&&m.stateNode.current.memoizedState.isDehydrated){l.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}l.blockedOn=null}function nu(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var m=dm(l.nativeEvent);if(m===null){m=l.nativeEvent;var b=new m.constructor(m.type,m);hd=b,m.target.dispatchEvent(b),hd=null}else return u=as(m),u!==null&&Nx(u),l.blockedOn=m,!1;u.shift()}return!0}function Rx(l,u,m){nu(l)&&m.delete(u)}function xA(){mm=!1,li!==null&&nu(li)&&(li=null),ci!==null&&nu(ci)&&(ci=null),ui!==null&&nu(ui)&&(ui=null),ol.forEach(Rx),rl.forEach(Rx)}function au(l,u){l.blockedOn===u&&(l.blockedOn=null,mm||(mm=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,xA)))}var iu=null;function Dx(l){iu!==l&&(iu=l,s.unstable_scheduleCallback(s.unstable_NormalPriority,function(){iu===l&&(iu=null);for(var u=0;u<l.length;u+=3){var m=l[u],b=l[u+1],k=l[u+2];if(typeof b!="function"){if(hm(b||m)===null)continue;break}var j=as(m);j!==null&&(l.splice(u,3),u-=3,dh(j,{pending:!0,data:k,method:m.method,action:b},b,k))}}))}function Yo(l){function u(ie){return au(ie,l)}li!==null&&au(li,l),ci!==null&&au(ci,l),ui!==null&&au(ui,l),ol.forEach(u),rl.forEach(u);for(var m=0;m<di.length;m++){var b=di[m];b.blockedOn===l&&(b.blockedOn=null)}for(;0<di.length&&(m=di[0],m.blockedOn===null);)_x(m),m.blockedOn===null&&di.shift();if(m=(l.ownerDocument||l).$$reactFormReplay,m!=null)for(b=0;b<m.length;b+=3){var k=m[b],j=m[b+1],F=k[Ye]||null;if(typeof j=="function")F||Dx(m);else if(F){var X=null;if(j&&j.hasAttribute("formAction")){if(k=j,F=j[Ye]||null)X=F.formAction;else if(hm(k)!==null)continue}else X=F.action;typeof X=="function"?m[b+1]=X:(m.splice(b,3),b-=3),Dx(m)}}}function Lx(){function l(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(F){return k=F})},focusReset:"manual",scroll:"manual"})}function u(){k!==null&&(k(),k=null),b||setTimeout(m,20)}function m(){if(!b&&!navigation.transition){var j=navigation.currentEntry;j&&j.url!=null&&navigation.navigate(j.url,{state:j.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var b=!1,k=null;return navigation.addEventListener("navigate",l),navigation.addEventListener("navigatesuccess",u),navigation.addEventListener("navigateerror",u),setTimeout(m,100),function(){b=!0,navigation.removeEventListener("navigate",l),navigation.removeEventListener("navigatesuccess",u),navigation.removeEventListener("navigateerror",u),k!==null&&(k(),k=null)}}}function pm(l){this._internalRoot=l}ou.prototype.render=pm.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(n(409));var m=u.current,b=bn();Cx(m,b,l,u,null,null)},ou.prototype.unmount=pm.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;Cx(l.current,2,null,l,null,null),Fc(),u[Et]=null}};function ou(l){this._internalRoot=l}ou.prototype.unstable_scheduleHydration=function(l){if(l){var u=He();l={blockedOn:null,target:l,priority:u};for(var m=0;m<di.length&&u!==0&&u<di[m].priority;m++);di.splice(m,0,l),m===0&&_x(l)}};var Bx=e.version;if(Bx!=="19.2.3")throw Error(n(527,Bx,"19.2.3"));q.findDOMNode=function(l){var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=h(u),l=l!==null?p(l):null,l=l===null?null:l.stateNode,l};var vA={bundleType:0,version:"19.2.3",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.3"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ru.isDisabled&&ru.supportsFiber)try{ft=ru.inject(vA),bt=ru}catch{}}return ul.createRoot=function(l,u){if(!i(l))throw Error(n(299));var m=!1,b="",k=$b,j=Ub,F=Gb;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(b=u.identifierPrefix),u.onUncaughtError!==void 0&&(k=u.onUncaughtError),u.onCaughtError!==void 0&&(j=u.onCaughtError),u.onRecoverableError!==void 0&&(F=u.onRecoverableError)),u=Sx(l,1,!1,null,null,m,b,null,k,j,F,Lx),l[Et]=u.current,Yh(l),new pm(u)},ul.hydrateRoot=function(l,u,m){if(!i(l))throw Error(n(299));var b=!1,k="",j=$b,F=Ub,X=Gb,ie=null;return m!=null&&(m.unstable_strictMode===!0&&(b=!0),m.identifierPrefix!==void 0&&(k=m.identifierPrefix),m.onUncaughtError!==void 0&&(j=m.onUncaughtError),m.onCaughtError!==void 0&&(F=m.onCaughtError),m.onRecoverableError!==void 0&&(X=m.onRecoverableError),m.formState!==void 0&&(ie=m.formState)),u=Sx(l,1,!0,u,m??null,b,k,ie,j,F,X,Lx),u.context=jx(null),m=u.current,b=bn(),b=ce(b),k=Xa(b),k.callback=null,Za(m,k,b),m=b,u.current.lanes=m,Se(u,m),na(u),l[Et]=u.current,Yh(l),new ou(u)},ul.version="19.2.3",ul}var Yx;function uN(){if(Yx)return gm.exports;Yx=1;function s(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(s)}catch(e){console.error(e)}}return s(),gm.exports=cN(),gm.exports}var dN=uN();const at={CONFIG:"tide-commander-config",SETTINGS:"tide-settings",SHORTCUTS:"tide-shortcuts",MOUSE_CONTROLS:"tide-mouse-controls",BACKEND_URL:"tide-backend-url",AUTH_TOKEN:"tide-auth-token",SCENE_VIEW_MODE:"tide-scene-view-mode",CAMERA_STATE:"tide-camera-state",CAMERA_STATE_2D:"tide-camera-state-2d",VIEW_MODE:"guake-view-mode",ADVANCED_VIEW:"guake-advanced-view",TERMINAL_HEIGHT:"guake-terminal-height",INPUT_TEXT_PREFIX:"guake-input-",PASTED_TEXTS_PREFIX:"guake-pasted-",COMMANDER_TAB:"commander-active-tab",LAST_CWD:"tide-last-cwd",GLOBAL_SUPERVISOR_COLLAPSED:"tide-global-supervisor-collapsed",TOOLS_COLLAPSED:"tide-tool-history-collapsed",FILES_COLLAPSED:"tide-file-history-collapsed",MOBILE_VIEW:"tide-mobile-view",TREE_PANEL_WIDTH:"tide-tree-panel-width",AGENT_ORDER:"tide-agent-order",AOP_CONFIG:"tide-aop-config"};function ca(s,e){try{const t=localStorage.getItem(s);return t===null?e:JSON.parse(t)}catch{return e}}function Qs(s,e=""){try{return localStorage.getItem(s)??e}catch{return e}}function hp(s,e=!1){try{const t=localStorage.getItem(s);return t===null?e:t==="true"}catch{return e}}function jk(s,e){try{const t=localStorage.getItem(s);if(t===null)return e;const n=Number(t);return isNaN(n)?e:n}catch{return e}}function Ia(s,e){try{localStorage.setItem(s,JSON.stringify(e))}catch(t){console.error(`Failed to save to localStorage: ${s}`,t)}}function Yn(s,e){try{localStorage.setItem(s,e)}catch(t){console.error(`Failed to save to localStorage: ${s}`,t)}}function mp(s,e){try{localStorage.setItem(s,String(e))}catch(t){console.error(`Failed to save to localStorage: ${s}`,t)}}function Ck(s,e){try{localStorage.setItem(s,String(e))}catch(t){console.error(`Failed to save to localStorage: ${s}`,t)}}function Xx(s){try{localStorage.removeItem(s)}catch(e){console.error(`Failed to remove from localStorage: ${s}`,e)}}function Ak(){const s=Qs(at.BACKEND_URL,"");return s?s.replace(/\/$/,""):`${window.location.protocol}//${window.location.host}`}function Xu(){return Qs(at.AUTH_TOKEN,"")}function lt(s){return`${Ak()}${s}`}async function Ct(s,e){const t=Xu(),n=new Headers(e==null?void 0:e.headers);return t&&n.set("X-Auth-Token",t),fetch(s,{...e,headers:n})}function Nk(s){const e=Xu();if(!e)return s;try{const t=!s.startsWith("http://")&&!s.startsWith("https://"),n=t?"http://dummy":void 0,i=new URL(s,n);return i.searchParams.set("token",e),t?i.pathname+i.search:i.toString()}catch{const t=s.includes("?")?"&":"?";return`${s}${t}token=${encodeURIComponent(e)}`}}function Xs(s=!1,e){const[t,n]=x.useState(s),[i,o]=x.useState(e),r=x.useCallback(h=>{h!==void 0&&o(h),n(!0)},[]),c=x.useCallback(()=>{n(!1)},[]),d=x.useCallback(()=>{n(h=>!h)},[]);return{isOpen:t,data:i,open:r,close:c,toggle:d,setData:o}}function hN(){const[s,e]=x.useState(null),t=x.useCallback(i=>{e(i)},[]),n=x.useCallback(()=>{e(null)},[]);return{isOpen:s!==null,id:s,open:t,close:n}}function mN(){const[s,e]=x.useState(!1),[t,n]=x.useState({x:0,y:0}),[i,o]=x.useState({x:0,z:0}),[r,c]=x.useState({type:"ground"}),d=x.useCallback((p,f,g)=>{n(p),o(f),c(g),e(!0)},[]),h=x.useCallback(()=>{e(!1)},[]);return{isOpen:s,screenPosition:t,worldPosition:i,target:r,open:d,close:h}}const Gn=[],pN=new Set;function Tu(){pN.forEach(s=>s())}function fN(s,e){const t=Gn.findIndex(n=>n.id===s);return t!==-1&&Gn.splice(t,1),Gn.push({id:s,close:e}),Tu(),()=>{const n=Gn.findIndex(i=>i.id===s);n!==-1&&(Gn.splice(n,1),Tu())}}function Zx(){return Gn.length===0?!1:(Gn.pop().close(),Tu(),!0)}function gN(...s){const e=new Set(s);for(;Gn.length>0;){const t=Gn[Gn.length-1];if(e.has(t.id))break;Gn.pop().close()}Tu()}function vs(s,e,t){const n=x.useRef(t);n.current=t,x.useEffect(()=>e?fN(s,()=>n.current()):void 0,[s,e])}let pp,fp;try{pp=require("@capacitor/haptics").Haptics,fp=require("@capacitor/haptics").ImpactStyle}catch{}function Qx(s,e){const{threshold:t=80,maxVerticalMovement:n=50,enabled:i=!0,onSwipeLeft:o,onSwipeRight:r,onSwipeMove:c,onSwipeCancel:d}=e,h=x.useRef({startX:0,startY:0,startTime:0,isTracking:!1,hasMovedEnough:!1}),p=x.useCallback(y=>{if(y.touches.length!==1)return;const v=y.touches[0];h.current={startX:v.clientX,startY:v.clientY,startTime:Date.now(),isTracking:!0,hasMovedEnough:!1}},[]),f=x.useCallback(y=>{if(!h.current.isTracking||y.touches.length!==1)return;const v=y.touches[0],w=v.clientX-h.current.startX;if(Math.abs(v.clientY-h.current.startY)>n){h.current.isTracking=!1,h.current.hasMovedEnough&&(d==null||d());return}const A=window.innerWidth*.4,N=Math.max(-1,Math.min(1,w/A));Math.abs(w)>=12&&(h.current.hasMovedEnough=!0,c==null||c(N))},[n,c,d]),g=x.useCallback(y=>{const v=h.current.isTracking,w=h.current.hasMovedEnough;if(!v)return;const S=y.changedTouches[0],C=S.clientX-h.current.startX,A=Math.abs(S.clientY-h.current.startY),N=Date.now()-h.current.startTime;h.current.isTracking=!1,h.current.hasMovedEnough=!1,Math.abs(C)>=t&&A<=n&&N<500?(pp&&fp?pp.impact({style:fp.Light}).catch(()=>{navigator.vibrate&&navigator.vibrate(8)}):navigator.vibrate&&navigator.vibrate(8),C>0?r==null||r():o==null||o()):w&&(d==null||d())},[t,n,o,r,d]);x.useEffect(()=>{const y=s.current;if(!(!y||!i||!(window.innerWidth<=768&&"ontouchstart"in window)))return y.addEventListener("touchstart",p,{passive:!0}),y.addEventListener("touchmove",f,{passive:!0}),y.addEventListener("touchend",g,{passive:!0}),()=>{y.removeEventListener("touchstart",p),y.removeEventListener("touchmove",f),y.removeEventListener("touchend",g)}},[s,i,p,f,g])}const bN={width:400,height:300,copyStyleSheets:!0,keepOnTop:"focus"};function yN(){return"documentPictureInPicture"in window}function xN(s,e){for(const o of s.styleSheets)try{if(o.cssRules){const r=e.createElement("style");for(const c of o.cssRules)r.appendChild(e.createTextNode(c.cssText));e.head.appendChild(r)}}catch{if(o.href){const r=e.createElement("link");r.rel="stylesheet",r.href=o.href,e.head.appendChild(r)}}const t=s.documentElement.style.cssText;t&&(e.documentElement.style.cssText=t);const n=getComputedStyle(s.documentElement),i=[];for(let o=0;o<n.length;o++){const r=n[o];r.startsWith("--")&&i.push(`${r}: ${n.getPropertyValue(r)}`)}if(i.length>0){const o=e.createElement("style");o.textContent=`:root { ${i.join("; ")} }`,e.head.appendChild(o)}}function vN(){const[s,e]=x.useState(!1),[t,n]=x.useState(null),[i,o]=x.useState(null),r=x.useRef(null),c=yN(),d=x.useCallback(()=>{if(r.current){const f=r.current.__cleanupFns;f&&f.forEach(g=>g()),r.current.close(),r.current=null}n(null),o(null),e(!1)},[]),h=x.useCallback(async f=>{if(!c)return console.warn("Document Picture-in-Picture is not supported in this browser"),!1;r.current&&d();const g={...bN,...f};try{const v=await window.documentPictureInPicture.requestWindow({width:g.width,height:g.height,disallowReturnToOpener:!0});r.current=v,g.copyStyleSheets&&xN(document,v.document);const w=v.document.createElement("div");w.id="pip-root",w.style.width="100%",w.style.height="100%",v.document.body.appendChild(w),v.document.body.style.margin="0",v.document.body.style.padding="0",v.document.body.style.overflow="hidden",v.addEventListener("pagehide",()=>{r.current=null,n(null),o(null),e(!1)});const S=[];if(g.keepOnTop&&g.keepOnTop!=="none"){const C=g.keepOnTop==="raise",A=()=>{r.current&&!r.current.closed&&setTimeout(()=>{r.current&&!r.current.closed&&(r.current.focus(),C&&setTimeout(()=>window.focus(),10))},50)},N=()=>{document.visibilityState==="visible"&&r.current&&!r.current.closed&&setTimeout(()=>{r.current&&!r.current.closed&&(r.current.focus(),C&&setTimeout(()=>window.focus(),10))},100)};window.addEventListener("focus",A),document.addEventListener("visibilitychange",N),S.push(()=>window.removeEventListener("focus",A),()=>document.removeEventListener("visibilitychange",N))}return v.__cleanupFns=S,n(v),o(w),e(!0),!0}catch(y){return console.error("Failed to open Picture-in-Picture window:",y),!1}},[c,d]),p=x.useCallback(async f=>{s?d():await h(f)},[s,h,d]);return x.useEffect(()=>()=>{r.current&&r.current.close()},[]),{isOpen:s,pipWindow:t,pipContainer:i,isSupported:c,open:h,close:d,toggle:p}}function dl(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}class wN{constructor(){W(this,"messages",new Map);W(this,"logs",[]);W(this,"maxMessagesPerAgent",200);W(this,"maxLogs",500);W(this,"enabled",!1);W(this,"listeners",new Set);W(this,"logListeners",new Set)}setEnabled(e){this.enabled=e,this.notifyListeners("all")}isEnabled(){return this.enabled}captureSent(e,t){if(this.enabled)try{const n=JSON.parse(t);console.log(`[AgentDebugger] SENT - agent: ${e.slice(0,4)}, type: ${n.type}, size: ${t.length}B`),this.addMessage(e,{id:dl(),agentId:e,direction:"sent",type:n.type||"unknown",payload:n.payload||n,timestamp:Date.now(),size:t.length,raw:t})}catch(n){console.error("[AgentDebugger] Failed to parse SENT message:",String(n).slice(0,80)),this.addMessage(e,{id:dl(),agentId:e,direction:"sent",type:"parse_error",payload:{error:String(n)},timestamp:Date.now(),size:t.length,raw:t})}}captureReceived(e,t){if(this.enabled)try{const n=JSON.parse(t);console.log(`[AgentDebugger] RECEIVED - agent: ${e.slice(0,4)}, type: ${n.type}, size: ${t.length}B`),this.addMessage(e,{id:dl(),agentId:e,direction:"received",type:n.type||"unknown",payload:n.payload||n,timestamp:Date.now(),size:t.length,raw:t})}catch(n){console.error("[AgentDebugger] Failed to parse RECEIVED message:",String(n).slice(0,80)),this.addMessage(e,{id:dl(),agentId:e,direction:"received",type:"parse_error",payload:{error:String(n)},timestamp:Date.now(),size:t.length,raw:t})}}addMessage(e,t){let n=this.messages.get(e);n||(n=[],this.messages.set(e,n)),n.push(t),console.log(`[AgentDebugger] Added message for ${e}, total: ${n.length}, type: ${t.type}, direction: ${t.direction}`),n.length>this.maxMessagesPerAgent&&n.shift(),this.notifyListeners(e)}getMessages(e){return this.messages.get(e)||[]}getStats(e){const t=this.getMessages(e),n=t.filter(r=>r.direction==="sent").length,i=t.filter(r=>r.direction==="received").length,o=[...new Set(t.map(r=>r.type))];return{total:t.length,sent:n,received:i,messageTypes:o}}clearMessages(e){this.messages.delete(e),this.notifyListeners(e)}clearAllMessages(){this.messages.clear(),this.notifyListeners("all")}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(e){this.listeners.forEach(t=>t(e))}getAgentIds(){return Array.from(this.messages.keys())}log(e,t,n,i){const o={id:dl(),level:e,message:t,data:n,timestamp:Date.now(),source:i};this.logs.push(o),this.logs.length>this.maxLogs&&this.logs.shift(),this.notifyLogListeners()}debug(e,t,n){this.log("debug",e,t,n)}info(e,t,n){this.log("info",e,t,n)}warn(e,t,n){this.log("warn",e,t,n)}error(e,t,n){this.log("error",e,t,n)}getLogs(){return this.logs}clearLogs(){this.logs=[],this.notifyLogListeners()}subscribeLogs(e){return this.logListeners.add(e),()=>this.logListeners.delete(e)}notifyLogListeners(){this.logListeners.forEach(e=>e())}}const Os=new wN,Bl={debug:(s,e,t)=>Os.debug(s,e,t),info:(s,e,t)=>Os.info(s,e,t),warn:(s,e,t)=>Os.warn(s,e,t),error:(s,e,t)=>Os.error(s,e,t)};window.__tideWsState||(window.__tideWsState={ws:null,isConnecting:!1,reconnectAttempts:0,reconnectTimeout:null});const af=()=>window.__tideWsState.ws,Jx=s=>{window.__tideWsState.ws=s},kN=()=>window.__tideWsState.isConnecting,hl=s=>{window.__tideWsState.isConnecting=s},gp=()=>window.__tideWsState.reconnectAttempts,bp=s=>{window.__tideWsState.reconnectAttempts=s},Tk=()=>window.__tideWsState.reconnectTimeout,Mk=s=>{window.__tideWsState.reconnectTimeout=s},e0=10,of="tide_ws_has_connected";function t0(){return sessionStorage.getItem(of)==="true"}function SN(s){sessionStorage.setItem(of,"true")}function jN(){sessionStorage.removeItem(of)}let Ek=null;const CN=s=>{Ek=s},s0=()=>Ek,Ne={onToast:null,onAgentCreated:null,onAgentUpdated:null,onAgentDeleted:null,onAgentsSync:null,onAreasSync:null,onSpawnError:null,onSpawnSuccess:null,onToolUse:null,onDirectoryNotFound:null,onDelegation:null,onCustomClassesSync:null,onReconnect:null,onAgentNotification:null,onBuildingUpdated:null,onSubagentStarted:null,onSubagentCompleted:null};function _k(s){s.onToast&&(Ne.onToast=s.onToast),s.onAgentCreated&&(Ne.onAgentCreated=s.onAgentCreated),s.onAgentUpdated&&(Ne.onAgentUpdated=s.onAgentUpdated),s.onAgentDeleted&&(Ne.onAgentDeleted=s.onAgentDeleted),s.onAgentsSync&&(Ne.onAgentsSync=s.onAgentsSync),s.onAreasSync&&(Ne.onAreasSync=s.onAreasSync),s.onSpawnError&&(Ne.onSpawnError=s.onSpawnError),s.onSpawnSuccess&&(Ne.onSpawnSuccess=s.onSpawnSuccess),s.onToolUse&&(Ne.onToolUse=s.onToolUse),s.onDirectoryNotFound&&(Ne.onDirectoryNotFound=s.onDirectoryNotFound),s.onDelegation&&(Ne.onDelegation=s.onDelegation),s.onCustomClassesSync&&(Ne.onCustomClassesSync=s.onCustomClassesSync),s.onReconnect&&(Ne.onReconnect=s.onReconnect),s.onAgentNotification&&(Ne.onAgentNotification=s.onAgentNotification),s.onBuildingUpdated&&(Ne.onBuildingUpdated=s.onBuildingUpdated),s.onSubagentStarted&&(Ne.onSubagentStarted=s.onSubagentStarted),s.onSubagentCompleted&&(Ne.onSubagentCompleted=s.onSubagentCompleted)}function AN(){Ne.onToast=null,Ne.onAgentCreated=null,Ne.onAgentUpdated=null,Ne.onAgentDeleted=null,Ne.onAgentsSync=null,Ne.onAreasSync=null,Ne.onSpawnError=null,Ne.onSpawnSuccess=null,Ne.onToolUse=null,Ne.onDirectoryNotFound=null,Ne.onDelegation=null,Ne.onCustomClassesSync=null,Ne.onReconnect=null,Ne.onAgentNotification=null,Ne.onSubagentStarted=null,Ne.onSubagentCompleted=null}function NN(){Ne.onAgentCreated=null,Ne.onAgentUpdated=null,Ne.onAgentDeleted=null,Ne.onAgentsSync=null,Ne.onAreasSync=null,Ne.onToolUse=null,Ne.onDelegation=null,Ne.onCustomClassesSync=null,Ne.onBuildingUpdated=null,Ne.onSubagentStarted=null,Ne.onSubagentCompleted=null}const lu=new Map,TN=new Map,n0={start(s){},end(s){},async measure(s,e){this.start(s);try{return await e()}finally{this.end(s)}},measureSync(s,e){this.start(s);try{return e()}finally{this.end(s)}},getMetrics(s){const e={},t=s?lu.has(s)?[[s,lu.get(s)]]:[]:Array.from(lu.entries());for(const[n,i]of t){const o=[...i.samples].sort((h,p)=>h-p),r=Math.floor(o.length*.5),c=Math.floor(o.length*.95),d=Math.floor(o.length*.99);e[n]={count:i.count,avgMs:i.totalMs/i.count,minMs:i.minMs,maxMs:i.maxMs,lastMs:i.lastMs,p50Ms:o[r]||0,p95Ms:o[c]||0,p99Ms:o[d]||0}}return e},clear(){lu.clear(),TN.clear()},report(){}};class MN{constructor(){W(this,"frames",[]);W(this,"lastFrameTime",0);W(this,"frameCount",0);W(this,"fps",0);W(this,"minFps",1/0);W(this,"maxFps",0);W(this,"fpsHistory",[]);W(this,"maxHistorySize",60)}tick(e=200){const t=performance.now();if(this.lastFrameTime>0){const n=t-this.lastFrameTime;n<e&&(this.frames.push(n),this.frames.length>60&&this.frames.shift())}this.lastFrameTime=t,this.frameCount++}update(){if(this.frames.length===0)return;const e=this.frames.reduce((t,n)=>t+n,0)/this.frames.length;this.fps=1e3/e,this.minFps=Math.min(this.minFps,this.fps),this.maxFps=Math.max(this.maxFps,this.fps),this.fpsHistory.push(this.fps),this.fpsHistory.length>this.maxHistorySize&&this.fpsHistory.shift()}getFPS(){return Math.round(this.fps)}getStats(){const e=this.fpsHistory.length>0?this.fpsHistory.reduce((t,n)=>t+n,0)/this.fpsHistory.length:this.fps;return{current:Math.round(this.fps),min:Math.round(this.minFps===1/0?0:this.minFps),max:Math.round(this.maxFps),avg:Math.round(e)}}reset(){this.frames=[],this.lastFrameTime=0,this.frameCount=0,this.fps=0,this.minFps=1/0,this.maxFps=0,this.fpsHistory=[]}}const Rk=new MN;class EN{constructor(){W(this,"snapshots",[]);W(this,"maxSnapshots",120);W(this,"intervalId",null);W(this,"leakThresholdMB",50);W(this,"baselineUsedMB",0)}getUsage(){const e=performance.memory;return e?{usedMB:Math.round(e.usedJSHeapSize/1024/1024),totalMB:Math.round(e.totalJSHeapSize/1024/1024),limitMB:Math.round(e.jsHeapSizeLimit/1024/1024)}:null}log(){const e=this.getUsage();e&&console.log(`[Memory] Used: ${e.usedMB}MB / ${e.totalMB}MB (limit: ${e.limitMB}MB)`)}startMonitoring(e=1e3){if(this.intervalId)return;const t=this.getUsage();t&&(this.baselineUsedMB=t.usedMB),this.intervalId=setInterval(()=>{this.takeSnapshot()},e),console.log("[Memory] Monitoring started. Use memory.report() to see analysis.")}stopMonitoring(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null,console.log("[Memory] Monitoring stopped."))}takeSnapshot(){const e=this.getUsage();if(!e)return;const t={timestamp:Date.now(),heapUsedMB:e.usedMB,heapTotalMB:e.totalMB,heapLimitMB:e.limitMB};this.snapshots.push(t),this.snapshots.length>this.maxSnapshots&&this.snapshots.shift();const n=e.usedMB-this.baselineUsedMB;n>this.leakThresholdMB&&console.warn(`[Memory] Warning: Heap grew by ${n}MB since monitoring started (baseline: ${this.baselineUsedMB}MB, current: ${e.usedMB}MB)`)}getGrowthRate(){if(this.snapshots.length<10)return null;const e=this.snapshots[0],t=this.snapshots[this.snapshots.length-1],n=(t.timestamp-e.timestamp)/1e3/60;return n<.1?null:(t.heapUsedMB-e.heapUsedMB)/n}report(){const e=this.getUsage();if(!e){console.log("[Memory] Memory API not available (Chrome only)");return}console.group("%c[Memory Report]","color: #ff6600; font-weight: bold"),console.log(`Current: ${e.usedMB}MB / ${e.totalMB}MB (limit: ${e.limitMB}MB)`),console.log(`Baseline: ${this.baselineUsedMB}MB`),console.log(`Growth: ${e.usedMB-this.baselineUsedMB}MB since monitoring started`);const t=this.getGrowthRate();if(t!==null&&(console.log(`Growth Rate: ${t.toFixed(2)}MB/min`),t>5&&console.warn("POTENTIAL MEMORY LEAK: Growth rate exceeds 5MB/min")),this.snapshots.length>1){const n=Math.min(...this.snapshots.map(o=>o.heapUsedMB)),i=Math.max(...this.snapshots.map(o=>o.heapUsedMB));console.log(`Range: ${n}MB - ${i}MB (${i-n}MB variance)`)}console.groupEnd()}getThreeJsInfo(e){var t;return(t=e==null?void 0:e.info)!=null&&t.memory?{geometries:e.info.memory.geometries,textures:e.info.memory.textures}:null}reset(){this.snapshots=[];const e=this.getUsage();e&&(this.baselineUsedMB=e.usedMB),console.log("[Memory] Reset. New baseline:",this.baselineUsedMB,"MB")}}const _N=new EN;function Sl(s,e,t,n,i,o){}function Dk(s){if(s.payload&&typeof s.payload=="object"){const e=s.payload;if(e.agentId)return e.agentId;if(e.id)return e.id}return null}function rf(s){var t,n,i,o,r,c;const e=af();if(!e){(t=s0())==null||t(),(n=Ne.onToast)==null||n.call(Ne,"error","Not Connected","Connecting to server... Please try again in a moment.");return}if(e.readyState!==WebSocket.OPEN){e.readyState===WebSocket.CONNECTING?(i=Ne.onToast)==null||i.call(Ne,"warning","Connecting...","WebSocket is still connecting. Please wait a moment and try again."):(e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING)&&((o=s0())==null||o(),(r=Ne.onToast)==null||r.call(Ne,"warning","Reconnecting...","Connection lost. Reconnecting to server..."));return}try{const d=JSON.stringify(s);if(Os.isEnabled()){const p=Dk(s);console.log("[AgentDebugger] SENT - type:",s.type,"agentId:",p,"payload:",s.payload),p&&Os.captureSent(p,d)}e.send(d)}catch(d){(c=Ne.onToast)==null||c.call(Ne,"error","Send Failed",`Failed to send message: ${d}`)}}const jl=new Set,RN=5e3;function a0(s){if(!s.isDetached||!s.sessionId){jl.delete(s.id);return}jl.has(s.id)||(jl.add(s.id),rf({type:"reattach_agent",payload:{agentId:s.id}}),setTimeout(()=>{jl.delete(s.id)},RN))}function DN(s){var e,t,n,i,o,r,c,d,h,p,f,g,y,v,w,S,C,A,N,_,M,E,z;switch(n0.start(`ws:${s.type}`),s.type){case"agents_update":{const T=s.payload,R=T.filter(D=>D.class==="boss"||D.isBoss);R.length>0&&console.log("[WS agents_update] Boss agents received:",R.map(D=>({id:D.id,name:D.name,subordinateIds:D.subordinateIds}))),I.setAgents(T),(e=Ne.onAgentsSync)==null||e.call(Ne,T),I.loadToolHistory();for(const D of T)a0(D);break}case"agent_created":{const T=s.payload;console.log("[WebSocket] Agent created:",T),I.addAgent(T),I.selectAgent(T.id),(t=Ne.onAgentCreated)==null||t.call(Ne,T),(n=Ne.onSpawnSuccess)==null||n.call(Ne),window.__spawnModalSuccess&&(console.log("[WebSocket] Calling __spawnModalSuccess"),window.__spawnModalSuccess()),(i=Ne.onToast)==null||i.call(Ne,"success","Agent Deployed",`${T.name} is ready for commands`);break}case"agent_updated":{const T=s.payload,D=I.getState().agents.get(T.id),O=(D==null?void 0:D.status)!==T.status;console.log(`[Tide] Agent updated: ${T.name} (${T.id}) status=${T.status} (was ${D==null?void 0:D.status})${O?" ⚡ STATUS CHANGED":""}`),O&&console.log(`[Tide] 🔔 Status change for ${T.name}: ${D==null?void 0:D.status} → ${T.status}`);const P=D?D.position.x!==T.position.x||D.position.z!==T.position.z:!1;I.updateAgent(T),a0(T),(o=Ne.onAgentUpdated)==null||o.call(Ne,T,P);break}case"agent_deleted":{const{id:T}=s.payload;jl.delete(T),I.removeAgent(T),(r=Ne.onAgentDeleted)==null||r.call(Ne,T);break}case"activity":{const T=s.payload;I.addActivity(T);break}case"event":{const T=s.payload;if(Bl.debug(`Event: ${T.type}`,{agentId:T.agentId,toolName:T.toolName},"ws:event"),T.type==="tool_start"&&T.toolName&&((c=Ne.onToolUse)==null||c.call(Ne,T.agentId,T.toolName,T.toolInput),I.addToolExecution(T.agentId,T.toolName,T.toolInput),T.toolInput)){const R=T.toolInput.file_path||T.toolInput.path;R&&(T.toolName==="Write"?I.addFileChange(T.agentId,"created",R):T.toolName==="Edit"?I.addFileChange(T.agentId,"modified",R):T.toolName==="Read"&&I.addFileChange(T.agentId,"read",R))}break}case"output":{const T=s.payload;Bl.debug(`Output: "${T.text.slice(0,80)}..."`,{agentId:T.agentId,isStreaming:T.isStreaming,length:T.text.length,hasSkillUpdate:!!T.skillUpdate,uuid:T.uuid,toolName:T.toolName},"ws:output"),I.addOutput(T.agentId,{text:T.text,isStreaming:T.isStreaming,timestamp:T.timestamp,isDelegation:T.isDelegation,skillUpdate:T.skillUpdate,subagentName:T.subagentName,uuid:T.uuid,toolName:T.toolName,toolInput:T.toolInput,toolOutput:T.toolOutput});break}case"context_stats":{const{agentId:T,stats:R}=s.payload;console.log(`[Tide] Received context stats for agent ${T}: ${R.usedPercent}% used`),I.updateAgentContextStats(T,R);break}case"error":{const T=s.payload;console.error("[WebSocket] Error from server:",T.message),(d=Ne.onToast)==null||d.call(Ne,"error","Error",T.message),(h=Ne.onSpawnError)==null||h.call(Ne),window.__spawnModalError&&(console.log("[WebSocket] Calling __spawnModalError"),window.__spawnModalError());break}case"directory_not_found":{const{path:T}=s.payload;console.log("[WebSocket] Directory not found:",T),(p=Ne.onDirectoryNotFound)==null||p.call(Ne,T),window.__spawnModalDirNotFound&&(console.log("[WebSocket] Calling __spawnModalDirNotFound"),window.__spawnModalDirNotFound(T));break}case"command_started":{const{agentId:T,command:R}=s.payload,D=R.trim();if(D==="/context"||D==="/cost"||D==="/compact")break;I.addUserPromptToOutput(T,R);break}case"session_updated":{const{agentId:T}=s.payload;I.loadToolHistory();const R=I.getState().agents.get(T);R&&I.updateAgent({...R});break}case"supervisor_report":{const T=s.payload;I.setSupervisorReport(T);break}case"narrative_update":{const{agentId:T,narrative:R}=s.payload;I.addNarrative(T,R);break}case"supervisor_status":{const T=s.payload;I.setSupervisorStatus(T);break}case"agent_supervisor_history":{const T=s.payload;I.setAgentSupervisorHistory(T);break}case"agent_analysis":{const{agentId:T,analysis:R}=s.payload;I.addAgentAnalysis(T,R);break}case"areas_update":{const T=s.payload;I.setAreasFromServer(T),(f=Ne.onAreasSync)==null||f.call(Ne);break}case"buildings_update":{const T=s.payload;I.setBuildingsFromServer(T);break}case"building_created":{const T=s.payload;I.addBuilding(T);break}case"building_updated":{const T=s.payload;I.updateBuildingFromServer(T),(g=Ne.onBuildingUpdated)==null||g.call(Ne,T);break}case"building_deleted":{const{id:T}=s.payload;I.removeBuildingFromServer(T);break}case"building_logs":{const{buildingId:T,logs:R}=s.payload;I.addBuildingLogs(T,R);break}case"pm2_logs_chunk":{const{buildingId:T,chunk:R}=s.payload;I.appendStreamingLogChunk(T,R);break}case"pm2_logs_streaming":{const{buildingId:T,streaming:R}=s.payload;I.setStreamingStatus(T,R);break}case"docker_logs_chunk":{const{buildingId:T,chunk:R}=s.payload;I.appendStreamingLogChunk(T,R);break}case"docker_logs_streaming":{const{buildingId:T,streaming:R}=s.payload;I.setStreamingStatus(T,R);break}case"docker_containers_list":{const{containers:T,composeProjects:R}=s.payload;console.log(`[WebSocket] Received ${T.length} containers, ${R.length} compose projects`),I.setDockerContainersList(T,R);break}case"boss_building_logs_chunk":{const{bossBuildingId:T,subordinateBuildingId:R,subordinateBuildingName:D,chunk:O,isError:P}=s.payload;I.appendBossStreamingLogChunk(T,R,D,O,P);break}case"boss_building_subordinates_updated":{const{bossBuildingId:T,subordinateBuildingIds:R}=s.payload;I.updateBuilding(T,{subordinateBuildingIds:R});break}case"permission_request":{const T=s.payload;I.addPermissionRequest(T);break}case"permission_resolved":{const{requestId:T,approved:R}=s.payload;I.resolvePermissionRequest(T,R);break}case"delegation_decision":{const T=s.payload;I.handleDelegationDecision(T),T.status==="sent"&&((y=Ne.onToast)==null||y.call(Ne,"info","Task Delegated",`Delegated to ${T.selectedAgentName}: ${T.reasoning.slice(0,80)}...`),T.bossId&&T.selectedAgentId&&((v=Ne.onDelegation)==null||v.call(Ne,T.bossId,T.selectedAgentId)));break}case"boss_subordinates_updated":{const{bossId:T,subordinateIds:R}=s.payload;I.updateBossSubordinates(T,R);break}case"delegation_history":{const{bossId:T,decisions:R}=s.payload;I.setDelegationHistory(T,R);break}case"boss_spawned_agent":{const{agent:T,bossPosition:R}=s.payload;console.log("[WebSocket] Boss spawned agent:",T.name,"- walking to boss at",R),I.addAgent(T),(w=Ne.onAgentCreated)==null||w.call(Ne,T),rf({type:"move_agent",payload:{agentId:T.id,position:R}}),(S=Ne.onToast)==null||S.call(Ne,"success","Agent Deployed",`${T.name} spawned by boss, walking to position`);break}case"agent_task_started":{const{bossId:T,subordinateId:R,subordinateName:D,taskDescription:O}=s.payload;console.log(`[WebSocket] Agent ${D} started task for boss ${T}: ${O.slice(0,50)}...`),I.handleAgentTaskStarted(T,R,D,O);break}case"agent_task_output":{const{bossId:T,subordinateId:R,output:D}=s.payload;I.handleAgentTaskOutput(T,R,D);break}case"agent_task_completed":{const{bossId:T,subordinateId:R,success:D}=s.payload;console.log(`[WebSocket] Agent task completed for boss ${T}, subordinate ${R}, success: ${D}`),I.handleAgentTaskCompleted(T,R,D);break}case"skills_update":{const T=s.payload;I.setSkillsFromServer(T);break}case"skill_created":{const T=s.payload;I.addSkillFromServer(T),console.log(`[WebSocket] Skill created: ${T.name}`);break}case"skill_updated":{const T=s.payload;I.updateSkillFromServer(T),console.log(`[WebSocket] Skill updated: ${T.name}`);break}case"skill_deleted":{const{id:T}=s.payload;I.removeSkillFromServer(T),console.log(`[WebSocket] Skill deleted: ${T}`);break}case"agent_skills":{const{agentId:T,skills:R}=s.payload;console.log(`[WebSocket] Agent ${T} has ${R.length} skills`);break}case"custom_agent_classes_update":{const T=s.payload;I.setCustomAgentClassesFromServer(T),console.log(`[WebSocket] Received ${T.length} custom agent classes`);const R=new Map;for(const D of T)R.set(D.id,D);(C=Ne.onCustomClassesSync)==null||C.call(Ne,R);break}case"custom_agent_class_created":{const T=s.payload;I.addCustomAgentClassFromServer(T),console.log(`[WebSocket] Custom agent class created: ${T.name}`),(A=Ne.onCustomClassesSync)==null||A.call(Ne,I.getState().customAgentClasses);break}case"custom_agent_class_updated":{const T=s.payload;I.updateCustomAgentClassFromServer(T),console.log(`[WebSocket] Custom agent class updated: ${T.name}`),(N=Ne.onCustomClassesSync)==null||N.call(Ne,I.getState().customAgentClasses);break}case"custom_agent_class_deleted":{const{id:T}=s.payload;I.removeCustomAgentClassFromServer(T),console.log(`[WebSocket] Custom agent class deleted: ${T}`),(_=Ne.onCustomClassesSync)==null||_.call(Ne,I.getState().customAgentClasses);break}case"global_usage":{const T=s.payload;console.log("[WebSocket] Global usage update:",T),I.setGlobalUsage(T);break}case"agent_notification":{const T=s.payload;console.log(`[WebSocket] Agent notification from ${T.agentName}: ${T.title}`),(M=Ne.onAgentNotification)==null||M.call(Ne,T);break}case"exec_task_started":{const{taskId:T,agentId:R,agentName:D,command:O,cwd:P}=s.payload;console.log(`[WebSocket] Exec task started: ${T} for agent ${D}: ${O.slice(0,50)}...`),I.handleExecTaskStarted(T,R,D,O,P);break}case"exec_task_output":{const{taskId:T,agentId:R,output:D,isError:O}=s.payload;I.handleExecTaskOutput(T,R,D,O);break}case"exec_task_completed":{const{taskId:T,agentId:R,exitCode:D,success:O}=s.payload;console.log(`[WebSocket] Exec task completed: ${T} for agent ${R}, success: ${O}`),I.handleExecTaskCompleted(T,R,D,O);break}case"subagent_started":{const T=s.payload;console.log(`[WebSocket] Subagent started: ${T.name} (${T.id}) for agent ${T.parentAgentId}`),I.addSubagent(T),(E=Ne.onSubagentStarted)==null||E.call(Ne,T),I.addOutput(T.parentAgentId,{text:`🔀 Spawned subagent: ${T.name} (${T.subagentType})`,isStreaming:!1,timestamp:T.startedAt,subagentName:T.name});break}case"subagent_output":{const{subagentId:T,parentAgentId:R,text:D,isStreaming:O,timestamp:P}=s.payload,K=I.getSubagent(T)||I.getSubagentByToolUseId(T),Y=(K==null?void 0:K.name)||T;I.addOutput(R,{text:`[${T}] ${D}`,isStreaming:O,timestamp:P,subagentName:Y});break}case"subagent_completed":{const{subagentId:T,parentAgentId:R,success:D,resultPreview:O,subagentName:P}=s.payload;console.log(`[WebSocket] Subagent completed: ${T} for agent ${R}, success: ${D}`),I.completeSubagent(T,R,D),(z=Ne.onSubagentCompleted)==null||z.call(Ne,T);const K=I.getSubagent(T)||I.getSubagentByToolUseId(T),Y=P||(K==null?void 0:K.name)||T,$=D?"✅":"❌",L=O?`: ${O.slice(0,100)}`:"";I.addOutput(R,{text:`${$} Subagent ${Y} ${D?"completed":"failed"}${L}`,isStreaming:!1,timestamp:Date.now(),subagentName:Y});break}case"secrets_update":{const T=s.payload;I.setSecretsFromServer(T),console.log(`[WebSocket] Received ${T.length} secrets`);break}case"secret_created":{const T=s.payload;I.addSecretFromServer(T),console.log(`[WebSocket] Secret created: ${T.name}`);break}case"secret_updated":{const T=s.payload;I.updateSecretFromServer(T),console.log(`[WebSocket] Secret updated: ${T.name}`);break}case"secret_deleted":{const{id:T}=s.payload;I.removeSecretFromServer(T),console.log(`[WebSocket] Secret deleted: ${T}`);break}case"database_connection_result":{const{buildingId:T,connectionId:R,success:D,error:O,serverVersion:P}=s.payload;I.setConnectionStatus(T,R,{connected:D,error:O,serverVersion:P}),console.log(`[WebSocket] Database connection ${D?"succeeded":"failed"}: ${R}`);break}case"databases_list":{const{buildingId:T,connectionId:R,databases:D}=s.payload;I.setDatabases(T,R,D),console.log(`[WebSocket] Received ${D.length} databases for ${R}`);break}case"tables_list":{const{buildingId:T,connectionId:R,database:D,tables:O}=s.payload;I.setTables(T,R,D,O),console.log(`[WebSocket] Received ${O.length} tables for ${D}`);break}case"table_schema":{const{buildingId:T,connectionId:R,database:D,table:O,columns:P,indexes:K,foreignKeys:Y}=s.payload;I.setTableSchema(T,R,D,O,{columns:P,indexes:K||[],foreignKeys:Y||[]}),console.log(`[WebSocket] Received schema for ${O}`);break}case"query_result":{const{buildingId:T,result:R}=s.payload;I.setQueryResult(T,R),console.log(`[WebSocket] Query ${R.status}: ${R.rowCount??R.affectedRows??0} rows in ${R.duration}ms`);break}case"query_history_update":{const{buildingId:T,history:R}=s.payload;I.setQueryHistory(T,R),console.log(`[WebSocket] Received ${R.length} query history entries for ${T}`);break}}n0.end(`ws:${s.type}`)}CN(()=>Ol());let i0=!1;function Lk(){const s=af();s&&s.readyState===WebSocket.OPEN&&s.close(1e3,"Page unloading");const e=Tk();e&&clearTimeout(e),window.__tideWsState&&(window.__tideWsState.ws=null,window.__tideWsState.reconnectTimeout=null,window.__tideWsState.isConnecting=!1,window.__tideWsState.reconnectAttempts=0),jN()}function LN(){i0||(window.addEventListener("beforeunload",Lk),i0=!0)}function Bk(){Lk(),I.setConnected(!1),I.stopStatusPolling()}function xm(){Bk(),bp(0),setTimeout(()=>Ol(),100)}function Ol(){LN();const s=Tk();s&&(clearTimeout(s),Mk(null));const e=af();if(kN()||e&&e.readyState===WebSocket.CONNECTING)return;if(e&&e.readyState===WebSocket.OPEN){t0()&&Ne.onReconnect&&Ne.onReconnect();return}bp(gp()+1),hl(!0);const t=Qs(at.BACKEND_URL,""),n=Xu(),i=6200;let o;if(t){const c=t.replace(/^https:\/\//,"wss://").replace(/^http:\/\//,"ws://");o=c.endsWith("/ws")?c:`${c.replace(/\/$/,"")}/ws`}else o=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let r=null;try{n?r=new WebSocket(o,[`auth-${n}`]):r=new WebSocket(o)}catch{hl(!1),o0();return}Jx(r),r.onopen=()=>{var d,h,p;const c=t0();hl(!1),bp(0),SN(),I.setConnected(!0),I.startStatusPolling(),I.clearAllPermissions(),c?((d=Ne.onToast)==null||d.call(Ne,"success","Reconnected","Connection restored - refreshing data..."),(h=Ne.onReconnect)==null||h.call(Ne)):(p=Ne.onToast)==null||p.call(Ne,"success","Connected","Connected to Tide Commander server")},r.onmessage=c=>{try{const d=JSON.parse(c.data);if(Os.isEnabled()){const p=Dk(d);console.log("[AgentDebugger] RECEIVED - type:",d.type,"agentId:",p,"payload:",d.payload),p&&Os.captureReceived(p,c.data)}DN(d)}catch(d){const h=c.data.substring(0,200);console.error("[WS] Failed to parse message:",d),console.error("[WS] Raw data (first 200 chars):",h),console.error("[WS] Full data length:",c.data.length),c.data.length<5e3&&console.error("[WS] Full malformed message:",c.data)}},r.onclose=()=>{var d,h;hl(!1),Jx(null),I.setConnected(!1),I.stopStatusPolling();const c=gp();c<e0?((d=Ne.onToast)==null||d.call(Ne,"warning","Disconnected",`Connection lost. Reconnecting... (attempt ${c+1}/${e0})`),o0()):(h=Ne.onToast)==null||h.call(Ne,"error","Connection Failed",`Could not connect to server. Please check if the backend is running on port ${i}.`)},r.onerror=()=>{hl(!1)},I.setSendMessage(rf)}function o0(){const s=gp(),e=Math.min(1e3*Math.pow(2,s-1),3e4);Mk(setTimeout(Ol,e))}function r0(s,e){if(e===jA)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===op||e===lk){let t=s.getIndex();if(t===null){const r=[],c=s.getAttribute("position");if(c!==void 0){for(let d=0;d<c.count;d++)r.push(d);s.setIndex(r),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===op)for(let r=1;r<=n;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=s.clone();return o.setIndex(i),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}class lf extends ck{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new zN(t)}),this.register(function(t){return new FN(t)}),this.register(function(t){return new YN(t)}),this.register(function(t){return new XN(t)}),this.register(function(t){return new ZN(t)}),this.register(function(t){return new $N(t)}),this.register(function(t){return new UN(t)}),this.register(function(t){return new GN(t)}),this.register(function(t){return new qN(t)}),this.register(function(t){return new IN(t)}),this.register(function(t){return new WN(t)}),this.register(function(t){return new HN(t)}),this.register(function(t){return new VN(t)}),this.register(function(t){return new KN(t)}),this.register(function(t){return new ON(t)}),this.register(function(t){return new QN(t)}),this.register(function(t){return new JN(t)})}load(e,t,n,i){const o=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const h=Cl.extractUrlBase(e);r=Cl.resolveURL(h,this.path)}else r=Cl.extractUrlBase(e);this.manager.itemStart(e);const c=function(h){i?i(h):console.error(h),o.manager.itemError(e),o.manager.itemEnd(e)},d=new Cu(this.manager);d.setPath(this.path),d.setResponseType("arraybuffer"),d.setRequestHeader(this.requestHeader),d.setWithCredentials(this.withCredentials),d.load(e,function(h){try{o.parse(h,r,function(p){t(p),o.manager.itemEnd(e)},c)}catch(p){c(p)}},n,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let o;const r={},c={},d=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(d.decode(new Uint8Array(e,0,4))===Ok){try{r[Dt.KHR_BINARY_GLTF]=new eT(e)}catch(f){i&&i(f);return}o=JSON.parse(r[Dt.KHR_BINARY_GLTF].content)}else o=JSON.parse(d.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new mT(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const f=this.pluginCallbacks[p](h);f.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[f.name]=f,r[f.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const f=o.extensionsUsed[p],g=o.extensionsRequired||[];switch(f){case Dt.KHR_MATERIALS_UNLIT:r[f]=new PN;break;case Dt.KHR_DRACO_MESH_COMPRESSION:r[f]=new tT(o,this.dracoLoader);break;case Dt.KHR_TEXTURE_TRANSFORM:r[f]=new sT;break;case Dt.KHR_MESH_QUANTIZATION:r[f]=new nT;break;default:g.indexOf(f)>=0&&c[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}h.setExtensions(r),h.setPlugins(c),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,o){n.parse(e,t,i,o)})}}function BN(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}const Dt={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class ON{constructor(e){this.parser=e,this.name=Dt.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,d=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let h;const p=new At(16777215);d.color!==void 0&&p.setRGB(d.color[0],d.color[1],d.color[2],da);const f=d.range!==void 0?d.range:0;switch(d.type){case"directional":h=new ir(p),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new uk(p),h.distance=f;break;case"spot":h=new CA(p),h.distance=f,d.spot=d.spot||{},d.spot.innerConeAngle=d.spot.innerConeAngle!==void 0?d.spot.innerConeAngle:0,d.spot.outerConeAngle=d.spot.outerConeAngle!==void 0?d.spot.outerConeAngle:Math.PI/4,h.angle=d.spot.outerConeAngle,h.penumbra=1-d.spot.innerConeAngle/d.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+d.type)}return h.position.set(0,0,0),h.decay=2,Oa(h,d),d.intensity!==void 0&&(h.intensity=d.intensity),h.name=t.createUniqueName(d.name||"light_"+e),i=Promise.resolve(h),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],c=(o.extensions&&o.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(d){return n._getNodeRef(t.cache,c,d)})}}class PN{constructor(){this.name=Dt.KHR_MATERIALS_UNLIT}getMaterialType(){return Re}extendParams(e,t,n){const i=[];e.color=new At(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const r=o.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],da),e.opacity=r[3]}o.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",o.baseColorTexture,qn))}return Promise.all(i)}}class IN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class zN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const c=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Gs(c,c)}return Promise.all(o)}}class FN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class HN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(o)}}class $N{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new At(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const c=r.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],da)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,qn)),r.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(o)}}class UN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(o)}}class GN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const c=r.attenuationColor||[1,1,1];return t.attenuationColor=new At().setRGB(c[0],c[1],c[2],da),Promise.all(o)}}class qN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class WN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const c=r.specularColorFactor||[1,1,1];return t.specularColor=new At().setRGB(c[0],c[1],c[2],da),r.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,qn)),Promise.all(o)}}class KN{constructor(e){this.parser=e,this.name=Dt.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&o.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(o)}}class VN{constructor(e){this.parser=e,this.name=Dt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:ha}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(o)}}class YN{constructor(e){this.parser=e,this.name=Dt.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const o=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,r)}}class XN{constructor(e){this.parser=e,this.name=Dt.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],c=i.images[r.source];let d=n.textureLoader;if(c.uri){const h=n.options.manager.getHandler(c.uri);h!==null&&(d=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,r.source,d);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ZN{constructor(e){this.parser=e,this.name=Dt.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],c=i.images[r.source];let d=n.textureLoader;if(c.uri){const h=n.options.manager.getHandler(c.uri);h!==null&&(d=h)}return this.detectSupport().then(function(h){if(h)return n.loadTextureImage(e,r.source,d);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return n.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class QN{constructor(e){this.name=Dt.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],o=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(c){const d=i.byteOffset||0,h=i.byteLength||0,p=i.count,f=i.byteStride,g=new Uint8Array(c,d,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(p,f,g,i.mode,i.filter).then(function(y){return y.buffer}):r.ready.then(function(){const y=new ArrayBuffer(p*f);return r.decodeGltfBuffer(new Uint8Array(y),p,f,g,i.mode,i.filter),y})})}else return null}}class JN{constructor(e){this.name=Dt.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const h of i.primitives)if(h.mode!==Dn.TRIANGLES&&h.mode!==Dn.TRIANGLE_STRIP&&h.mode!==Dn.TRIANGLE_FAN&&h.mode!==void 0)return null;const r=n.extensions[this.name].attributes,c=[],d={};for(const h in r)c.push(this.parser.getDependency("accessor",r[h]).then(p=>(d[h]=p,d[h])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(h=>{const p=h.pop(),f=p.isGroup?p.children:[p],g=h[0].count,y=[];for(const v of f){const w=new ao,S=new nt,C=new io,A=new nt(1,1,1),N=new Pa(v.geometry,v.material,g);for(let _=0;_<g;_++)d.TRANSLATION&&S.fromBufferAttribute(d.TRANSLATION,_),d.ROTATION&&C.fromBufferAttribute(d.ROTATION,_),d.SCALE&&A.fromBufferAttribute(d.SCALE,_),N.setMatrixAt(_,w.compose(S,C,A));for(const _ in d)if(_==="_COLOR_0"){const M=d[_];N.instanceColor=new AA(M.array,M.itemSize,M.normalized)}else _!=="TRANSLATION"&&_!=="ROTATION"&&_!=="SCALE"&&v.geometry.setAttribute(_,d[_]);dk.prototype.copy.call(N,v),this.parser.assignFinalMaterial(N),y.push(N)}return p.isGroup?(p.clear(),p.add(...y),p):y[0]}))}}const Ok="glTF",ml=12,l0={JSON:1313821514,BIN:5130562};class eT{constructor(e){this.name=Dt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ml),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ok)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-ml,o=new DataView(e,ml);let r=0;for(;r<i;){const c=o.getUint32(r,!0);r+=4;const d=o.getUint32(r,!0);if(r+=4,d===l0.JSON){const h=new Uint8Array(e,ml+r,c);this.content=n.decode(h)}else if(d===l0.BIN){const h=ml+r;this.body=e.slice(h,h+c)}r+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class tT{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Dt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,o=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,c={},d={},h={};for(const p in r){const f=yp[p]||p.toLowerCase();c[f]=r[p]}for(const p in e.attributes){const f=yp[p]||p.toLowerCase();if(r[p]!==void 0){const g=n.accessors[e.attributes[p]],y=rr[g.componentType];h[f]=y.name,d[f]=g.normalized===!0}}return t.getDependency("bufferView",o).then(function(p){return new Promise(function(f,g){i.decodeDracoFile(p,function(y){for(const v in y.attributes){const w=y.attributes[v],S=d[v];S!==void 0&&(w.normalized=S)}f(y)},c,h,da,g)})})}}class sT{constructor(){this.name=Dt.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class nT{constructor(){this.name=Dt.KHR_MESH_QUANTIZATION}}class Pk extends HA{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,o=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[o+r];return t}interpolate_(e,t,n,i){const o=this.resultBuffer,r=this.sampleValues,c=this.valueSize,d=c*2,h=c*3,p=i-t,f=(n-t)/p,g=f*f,y=g*f,v=e*h,w=v-h,S=-2*y+3*g,C=y-g,A=1-S,N=C-g+f;for(let _=0;_!==c;_++){const M=r[w+_+c],E=r[w+_+d]*p,z=r[v+_+c],T=r[v+_]*p;o[_]=A*M+N*E+S*z+C*T}return o}}const aT=new io;class iT extends Pk{interpolate_(e,t,n,i){const o=super.interpolate_(e,t,n,i);return aT.fromArray(o).normalize().toArray(o),o}}const Dn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},rr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},c0={9728:mk,9729:ds,9984:_A,9985:EA,9986:MA,9987:Al},u0={33071:DA,33648:RA,10497:Qi},vm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yp={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},mi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},oT={CUBICSPLINE:void 0,LINEAR:gk,STEP:zA},wm={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function rT(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new Ke({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:bk})),s.DefaultMaterial}function Vi(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Oa(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function lT(s,e,t){let n=!1,i=!1,o=!1;for(let h=0,p=e.length;h<p;h++){const f=e[h];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(i=!0),f.COLOR_0!==void 0&&(o=!0),n&&i&&o)break}if(!n&&!i&&!o)return Promise.resolve(s);const r=[],c=[],d=[];for(let h=0,p=e.length;h<p;h++){const f=e[h];if(n){const g=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):s.attributes.position;r.push(g)}if(i){const g=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):s.attributes.normal;c.push(g)}if(o){const g=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):s.attributes.color;d.push(g)}}return Promise.all([Promise.all(r),Promise.all(c),Promise.all(d)]).then(function(h){const p=h[0],f=h[1],g=h[2];return n&&(s.morphAttributes.position=p),i&&(s.morphAttributes.normal=f),o&&(s.morphAttributes.color=g),s.morphTargetsRelative=!0,s})}function cT(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function uT(s){let e;const t=s.extensions&&s.extensions[Dt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+km(t.attributes):e=s.indices+":"+km(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+km(s.targets[n]);return e}function km(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function xp(s){switch(s){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function dT(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const hT=new ao;class mT{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new BN,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,o=!1,r=-1;if(typeof navigator<"u"){const c=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(c)===!0;const d=c.match(/Version\/(\d+)/);i=n&&d?parseInt(d[1],10):-1,o=c.indexOf("Firefox")>-1,r=o?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||o&&r<98?this.textureLoader=new hk(this.options.manager):this.textureLoader=new NA(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new Cu(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const c={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};return Vi(o,c,i),Oa(c,i),Promise.all(n._invokeAll(function(d){return d.afterRoot&&d.afterRoot(c)})).then(function(){for(const d of c.scenes)d.updateMatrixWorld();e(c)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,o=t.length;i<o;i++){const r=t[i].joints;for(let c=0,d=r.length;c<d;c++)e[r[c]].isBone=!0}for(let i=0,o=e.length;i<o;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),o=(r,c)=>{const d=this.associations.get(r);d!=null&&this.associations.set(c,d);for(const[h,p]of r.children.entries())o(p,c.children[h])};return o(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const o=e(t[i]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":i=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(o,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[Dt.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(o,r){n.load(Cl.resolveURL(t.uri,i.path),o,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,o=t.byteOffset||0;return n.slice(o,o+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const r=vm[i.type],c=rr[i.componentType],d=i.normalized===!0,h=new c(i.count*r);return Promise.resolve(new Wn(h,r,d))}const o=[];return i.bufferView!==void 0?o.push(this.getDependency("bufferView",i.bufferView)):o.push(null),i.sparse!==void 0&&(o.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(o).then(function(r){const c=r[0],d=vm[i.type],h=rr[i.componentType],p=h.BYTES_PER_ELEMENT,f=p*d,g=i.byteOffset||0,y=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,v=i.normalized===!0;let w,S;if(y&&y!==f){const C=Math.floor(g/y),A="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+C+":"+i.count;let N=t.cache.get(A);N||(w=new h(c,C*y,i.count*y/p),N=new TA(w,y/p),t.cache.add(A,N)),S=new FA(N,d,g%y/p,v)}else c===null?w=new h(i.count*d):w=new h(c,g,i.count*d),S=new Wn(w,d,v);if(i.sparse!==void 0){const C=vm.SCALAR,A=rr[i.sparse.indices.componentType],N=i.sparse.indices.byteOffset||0,_=i.sparse.values.byteOffset||0,M=new A(r[1],N,i.sparse.count*C),E=new h(r[2],_,i.sparse.count*d);c!==null&&(S=new Wn(S.array.slice(),S.itemSize,S.normalized)),S.normalized=!1;for(let z=0,T=M.length;z<T;z++){const R=M[z];if(S.setX(R,E[z*d]),d>=2&&S.setY(R,E[z*d+1]),d>=3&&S.setZ(R,E[z*d+2]),d>=4&&S.setW(R,E[z*d+3]),d>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}S.normalized=v}return S})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,r=t.images[o];let c=this.textureLoader;if(r.uri){const d=n.manager.getHandler(r.uri);d!==null&&(c=d)}return this.loadTextureImage(e,o,c)}loadTextureImage(e,t,n){const i=this,o=this.json,r=o.textures[e],c=o.images[t],d=(c.uri||c.bufferView)+":"+r.sampler;if(this.textureCache[d])return this.textureCache[d];const h=this.loadImageSource(t,n).then(function(p){p.flipY=!1,p.name=r.name||c.name||"",p.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(p.name=c.uri);const g=(o.samplers||{})[r.sampler]||{};return p.magFilter=c0[g.magFilter]||ds,p.minFilter=c0[g.minFilter]||Al,p.wrapS=u0[g.wrapS]||Qi,p.wrapT=u0[g.wrapT]||Qi,p.generateMipmaps=!p.isCompressedTexture&&p.minFilter!==mk&&p.minFilter!==ds,i.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[d]=h,h}loadImageSource(e,t){const n=this,i=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const r=i.images[e],c=self.URL||self.webkitURL;let d=r.uri||"",h=!1;if(r.bufferView!==void 0)d=n.getDependency("bufferView",r.bufferView).then(function(f){h=!0;const g=new Blob([f],{type:r.mimeType});return d=c.createObjectURL(g),d});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(d).then(function(f){return new Promise(function(g,y){let v=g;t.isImageBitmapLoader===!0&&(v=function(w){const S=new Px(w);S.needsUpdate=!0,g(S)}),t.load(Cl.resolveURL(f,o.path),v,void 0,y)})}).then(function(f){return h===!0&&c.revokeObjectURL(d),Oa(f,r),f.userData.mimeType=r.mimeType||dT(r.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",d),f});return this.sourceCache[e]=p,p}assignTexture(e,t,n,i){const o=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),o.extensions[Dt.KHR_TEXTURE_TRANSFORM]){const c=n.extensions!==void 0?n.extensions[Dt.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const d=o.associations.get(r);r=o.extensions[Dt.KHR_TEXTURE_TRANSFORM].extendTexture(r,c),o.associations.set(r,d)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+n.uuid;let d=this.cache.get(c);d||(d=new Yu,yi.prototype.copy.call(d,n),d.color.copy(n.color),d.map=n.map,d.sizeAttenuation=!1,this.cache.add(c,d)),n=d}else if(e.isLine){const c="LineBasicMaterial:"+n.uuid;let d=this.cache.get(c);d||(d=new Ji,yi.prototype.copy.call(d,n),d.color.copy(n.color),d.map=n.map,this.cache.add(c,d)),n=d}if(i||o||r){let c="ClonedMaterial:"+n.uuid+":";i&&(c+="derivative-tangents:"),o&&(c+="vertex-colors:"),r&&(c+="flat-shading:");let d=this.cache.get(c);d||(d=n.clone(),o&&(d.vertexColors=!0),r&&(d.flatShading=!0),i&&(d.normalScale&&(d.normalScale.y*=-1),d.clearcoatNormalScale&&(d.clearcoatNormalScale.y*=-1)),this.cache.add(c,d),this.associations.set(d,this.associations.get(n))),n=d}e.material=n}getMaterialType(){return Ke}loadMaterial(e){const t=this,n=this.json,i=this.extensions,o=n.materials[e];let r;const c={},d=o.extensions||{},h=[];if(d[Dt.KHR_MATERIALS_UNLIT]){const f=i[Dt.KHR_MATERIALS_UNLIT];r=f.getMaterialType(),h.push(f.extendParams(c,o,t))}else{const f=o.pbrMetallicRoughness||{};if(c.color=new At(1,1,1),c.opacity=1,Array.isArray(f.baseColorFactor)){const g=f.baseColorFactor;c.color.setRGB(g[0],g[1],g[2],da),c.opacity=g[3]}f.baseColorTexture!==void 0&&h.push(t.assignTexture(c,"map",f.baseColorTexture,qn)),c.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,c.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(c,"metalnessMap",f.metallicRoughnessTexture)),h.push(t.assignTexture(c,"roughnessMap",f.metallicRoughnessTexture))),r=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,c)})))}o.doubleSided===!0&&(c.side=Hs);const p=o.alphaMode||wm.OPAQUE;if(p===wm.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,p===wm.MASK&&(c.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&r!==Re&&(h.push(t.assignTexture(c,"normalMap",o.normalTexture)),c.normalScale=new Gs(1,1),o.normalTexture.scale!==void 0)){const f=o.normalTexture.scale;c.normalScale.set(f,f)}if(o.occlusionTexture!==void 0&&r!==Re&&(h.push(t.assignTexture(c,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&r!==Re){const f=o.emissiveFactor;c.emissive=new At().setRGB(f[0],f[1],f[2],da)}return o.emissiveTexture!==void 0&&r!==Re&&h.push(t.assignTexture(c,"emissiveMap",o.emissiveTexture,qn)),Promise.all(h).then(function(){const f=new r(c);return o.name&&(f.name=o.name),Oa(f,o),t.associations.set(f,{materials:e}),o.extensions&&Vi(i,f,o),f})}createUniqueName(e){const t=LA.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function o(c){return n[Dt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(d){return d0(d,c,t)})}const r=[];for(let c=0,d=e.length;c<d;c++){const h=e[c],p=uT(h),f=i[p];if(f)r.push(f.promise);else{let g;h.extensions&&h.extensions[Dt.KHR_DRACO_MESH_COMPRESSION]?g=o(h):g=d0(new Bn,h,t),i[p]={primitive:h,promise:g},r.push(g)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,o=n.meshes[e],r=o.primitives,c=[];for(let d=0,h=r.length;d<h;d++){const p=r[d].material===void 0?rT(this.cache):this.getDependency("material",r[d].material);c.push(p)}return c.push(t.loadGeometries(r)),Promise.all(c).then(function(d){const h=d.slice(0,d.length-1),p=d[d.length-1],f=[];for(let y=0,v=p.length;y<v;y++){const w=p[y],S=r[y];let C;const A=h[y];if(S.mode===Dn.TRIANGLES||S.mode===Dn.TRIANGLE_STRIP||S.mode===Dn.TRIANGLE_FAN||S.mode===void 0)C=o.isSkinnedMesh===!0?new rp(w,A):new ke(w,A),C.isSkinnedMesh===!0&&C.normalizeSkinWeights(),S.mode===Dn.TRIANGLE_STRIP?C.geometry=r0(C.geometry,lk):S.mode===Dn.TRIANGLE_FAN&&(C.geometry=r0(C.geometry,op));else if(S.mode===Dn.LINES)C=new ef(w,A);else if(S.mode===Dn.LINE_STRIP)C=new gi(w,A);else if(S.mode===Dn.LINE_LOOP)C=new BA(w,A);else if(S.mode===Dn.POINTS)C=new $l(w,A);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+S.mode);Object.keys(C.geometry.morphAttributes).length>0&&cT(C,o),C.name=t.createUniqueName(o.name||"mesh_"+e),Oa(C,o),S.extensions&&Vi(i,C,S),t.assignFinalMaterial(C),f.push(C)}for(let y=0,v=f.length;y<v;y++)t.associations.set(f[y],{meshes:e,primitives:y});if(f.length===1)return o.extensions&&Vi(i,f[0],o),f[0];const g=new os;o.extensions&&Vi(i,g,o),t.associations.set(g,{meshes:e});for(let y=0,v=f.length;y<v;y++)g.add(f[y]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new tf(pk.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new fk(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Oa(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,o=t.joints.length;i<o;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const o=i.pop(),r=i,c=[],d=[];for(let h=0,p=r.length;h<p;h++){const f=r[h];if(f){c.push(f);const g=new ao;o!==null&&g.fromArray(o.array,h*16),d.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new OA(c,d)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],o=i.name?i.name:"animation_"+e,r=[],c=[],d=[],h=[],p=[];for(let f=0,g=i.channels.length;f<g;f++){const y=i.channels[f],v=i.samplers[y.sampler],w=y.target,S=w.node,C=i.parameters!==void 0?i.parameters[v.input]:v.input,A=i.parameters!==void 0?i.parameters[v.output]:v.output;w.node!==void 0&&(r.push(this.getDependency("node",S)),c.push(this.getDependency("accessor",C)),d.push(this.getDependency("accessor",A)),h.push(v),p.push(w))}return Promise.all([Promise.all(r),Promise.all(c),Promise.all(d),Promise.all(h),Promise.all(p)]).then(function(f){const g=f[0],y=f[1],v=f[2],w=f[3],S=f[4],C=[];for(let A=0,N=g.length;A<N;A++){const _=g[A],M=y[A],E=v[A],z=w[A],T=S[A];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const R=n._createAnimationTracks(_,M,E,z,T);if(R)for(let D=0;D<R.length;D++)C.push(R[D])}return new PA(o,void 0,C)})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(o){const r=n._getNodeRef(n.meshCache,i.mesh,o);return i.weights!==void 0&&r.traverse(function(c){if(c.isMesh)for(let d=0,h=i.weights.length;d<h;d++)c.morphTargetInfluences[d]=i.weights[d]}),r})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],o=n._loadNodeShallow(e),r=[],c=i.children||[];for(let h=0,p=c.length;h<p;h++)r.push(n.getDependency("node",c[h]));const d=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([o,Promise.all(r),d]).then(function(h){const p=h[0],f=h[1],g=h[2];g!==null&&p.traverse(function(y){y.isSkinnedMesh&&y.bind(g,hT)});for(let y=0,v=f.length;y<v;y++)p.add(f[y]);return p})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],r=o.name?i.createUniqueName(o.name):"",c=[],d=i._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return d&&c.push(d),o.camera!==void 0&&c.push(i.getDependency("camera",o.camera).then(function(h){return i._getNodeRef(i.cameraCache,o.camera,h)})),i._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){c.push(h)}),this.nodeCache[e]=Promise.all(c).then(function(h){let p;if(o.isBone===!0?p=new IA:h.length>1?p=new os:h.length===1?p=h[0]:p=new dk,p!==h[0])for(let f=0,g=h.length;f<g;f++)p.add(h[f]);if(o.name&&(p.userData.name=o.name,p.name=r),Oa(p,o),o.extensions&&Vi(n,p,o),o.matrix!==void 0){const f=new ao;f.fromArray(o.matrix),p.applyMatrix4(f)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return i.associations.has(p)||i.associations.set(p,{}),i.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,o=new os;n.name&&(o.name=i.createUniqueName(n.name)),Oa(o,n),n.extensions&&Vi(t,o,n);const r=n.nodes||[],c=[];for(let d=0,h=r.length;d<h;d++)c.push(i.getDependency("node",r[d]));return Promise.all(c).then(function(d){for(let p=0,f=d.length;p<f;p++)o.add(d[p]);const h=p=>{const f=new Map;for(const[g,y]of i.associations)(g instanceof yi||g instanceof Px)&&f.set(g,y);return p.traverse(g=>{const y=i.associations.get(g);y!=null&&f.set(g,y)}),f};return i.associations=h(o),o})}_createAnimationTracks(e,t,n,i,o){const r=[],c=e.name?e.name:e.uuid,d=[];mi[o.path]===mi.weights?e.traverse(function(g){g.morphTargetInfluences&&d.push(g.name?g.name:g.uuid)}):d.push(c);let h;switch(mi[o.path]){case mi.weights:h=zx;break;case mi.rotation:h=Fx;break;case mi.position:case mi.scale:h=Ix;break;default:switch(n.itemSize){case 1:h=zx;break;case 2:case 3:default:h=Ix;break}break}const p=i.interpolation!==void 0?oT[i.interpolation]:gk,f=this._getArrayFromAccessor(n);for(let g=0,y=d.length;g<y;g++){const v=new h(d[g]+"."+mi[o.path],t.array,f,p);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(v),r.push(v)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=xp(t.constructor),i=new Float32Array(t.length);for(let o=0,r=t.length;o<r;o++)i[o]=t[o]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof Fx?iT:Pk;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function pT(s,e,t){const n=e.attributes,i=new Au;if(n.POSITION!==void 0){const c=t.json.accessors[n.POSITION],d=c.min,h=c.max;if(d!==void 0&&h!==void 0){if(i.set(new nt(d[0],d[1],d[2]),new nt(h[0],h[1],h[2])),c.normalized){const p=xp(rr[c.componentType]);i.min.multiplyScalar(p),i.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const c=new nt,d=new nt;for(let h=0,p=o.length;h<p;h++){const f=o[h];if(f.POSITION!==void 0){const g=t.json.accessors[f.POSITION],y=g.min,v=g.max;if(y!==void 0&&v!==void 0){if(d.setX(Math.max(Math.abs(y[0]),Math.abs(v[0]))),d.setY(Math.max(Math.abs(y[1]),Math.abs(v[1]))),d.setZ(Math.max(Math.abs(y[2]),Math.abs(v[2]))),g.normalized){const w=xp(rr[g.componentType]);d.multiplyScalar(w)}c.max(d)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(c)}s.boundingBox=i;const r=new $A;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=r}function d0(s,e,t){const n=e.attributes,i=[];function o(r,c){return t.getDependency("accessor",r).then(function(d){s.setAttribute(c,d)})}for(const r in n){const c=yp[r]||r.toLowerCase();c in s.attributes||i.push(o(n[r],c))}if(e.indices!==void 0&&!s.index){const r=t.getDependency("accessor",e.indices).then(function(c){s.setIndex(c)});i.push(r)}return lp.workingColorSpace!==da&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${lp.workingColorSpace}" not supported.`),Oa(s,e),pT(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?lT(s,e.targets,t):s})}const Sm=new WeakMap;class cf extends ck{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const o=new Cu(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,r=>{this.parse(r,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,qn,n).catch(n)}decodeDracoFile(e,t,n,i,o=da,r=()=>{}){const c={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:o};return this.decodeGeometry(e,c).then(t).catch(r)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Sm.has(e)){const d=Sm.get(e);if(d.key===n)return d.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const o=this.workerNextTaskID++,r=e.byteLength,c=this._getWorker(o,r).then(d=>(i=d,new Promise((h,p)=>{i._callbacks[o]={resolve:h,reject:p},i.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(d=>this._createGeometry(d.geometry));return c.catch(()=>!0).then(()=>{i&&o&&this._releaseTask(i,o)}),Sm.set(e,{key:n,promise:c}),c}_createGeometry(e){const t=new Bn;e.index&&t.setIndex(new Wn(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const i=e.attributes[n],o=i.name,r=i.array,c=i.itemSize,d=new Wn(r,c);o==="color"&&(this._assignVertexColorSpace(d,i.vertexColorSpace),d.normalized=!(r instanceof Float32Array)),t.setAttribute(o,d)}return t}_assignVertexColorSpace(e,t){if(t!==qn)return;const n=new At;for(let i=0,o=e.count;i<o;i++)n.fromBufferAttribute(e,i),lp.toWorkingColorSpace(n,qn),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new Cu(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,o)=>{n.load(e,i,void 0,o)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const o=fT.toString(),r=["/* draco decoder */",i,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
|
|
34
34
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(o){const r=o.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,o){return i._taskLoad>o._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function fT(){let s,e;onmessage=function(r){const c=r.data;switch(c.type){case"init":s=c.decoderConfig,e=new Promise(function(p){s.onModuleLoaded=function(f){p({draco:f})},DracoDecoderModule(s)});break;case"decode":const d=c.buffer,h=c.taskConfig;e.then(p=>{const f=p.draco,g=new f.Decoder;try{const y=t(f,g,new Int8Array(d),h),v=y.attributes.map(w=>w.array.buffer);y.index&&v.push(y.index.array.buffer),self.postMessage({type:"decode",id:c.id,geometry:y},v)}catch(y){console.error(y),self.postMessage({type:"error",id:c.id,error:y.message})}finally{f.destroy(g)}});break}};function t(r,c,d,h){const p=h.attributeIDs,f=h.attributeTypes;let g,y;const v=c.GetEncodedGeometryType(d);if(v===r.TRIANGULAR_MESH)g=new r.Mesh,y=c.DecodeArrayToMesh(d,d.byteLength,g);else if(v===r.POINT_CLOUD)g=new r.PointCloud,y=c.DecodeArrayToPointCloud(d,d.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!y.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+y.error_msg());const w={index:null,attributes:[]};for(const S in p){const C=self[f[S]];let A,N;if(h.useUniqueIDs)N=p[S],A=c.GetAttributeByUniqueId(g,N);else{if(N=c.GetAttributeId(g,r[p[S]]),N===-1)continue;A=c.GetAttribute(g,N)}const _=i(r,c,g,S,C,A);S==="color"&&(_.vertexColorSpace=h.vertexColorSpace),w.attributes.push(_)}return v===r.TRIANGULAR_MESH&&(w.index=n(r,c,g)),r.destroy(g),w}function n(r,c,d){const p=d.num_faces()*3,f=p*4,g=r._malloc(f);c.GetTrianglesUInt32Array(d,f,g);const y=new Uint32Array(r.HEAPF32.buffer,g,p).slice();return r._free(g),{array:y,itemSize:1}}function i(r,c,d,h,p,f){const g=f.num_components(),v=d.num_points()*g,w=v*p.BYTES_PER_ELEMENT,S=o(r,p),C=r._malloc(w);c.GetAttributeDataArrayForAllPoints(d,f,S,w,C);const A=new p(r.HEAPF32.buffer,C,v).slice();return r._free(C),{name:h,array:A,itemSize:g}}function o(r,c){switch(c){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}var uf=(function(){var s="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuikqbeeedddillviebeoweuec:q;iekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbol79IV9Rbrq:P8Yqdbk;3sezu8Jjjjjbcj;eb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Radz1jjjbhwcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhDcbhqinaqae9pmeaDaeaq9RaqaDfae6Egkcsfgocl4cifcd4hxdndndndnaoc9WGgmTmbcbhPcehsawcjdfhzalhHinaraH9Rax6midnaraHaxfgl9RcK6mbczhoinawcj;cbfaogifgoc9WfhOdndndndndnaHaic9WfgAco4fRbbaAci4coG4ciGPlbedibkaO9cb83ibaOcwf9cb83ibxikaOalRblalRbbgAco4gCaCciSgCE86bbaocGfalclfaCfgORbbaAcl4ciGgCaCciSgCE86bbaocVfaOaCfgORbbaAcd4ciGgCaCciSgCE86bbaoc7faOaCfgORbbaAciGgAaAciSgAE86bbaoctfaOaAfgARbbalRbegOco4gCaCciSgCE86bbaoc91faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc4faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc93faAaCfgARbbaOciGgOaOciSgOE86bbaoc94faAaOfgARbbalRbdgOco4gCaCciSgCE86bbaoc95faAaCfgARbbaOcl4ciGgCaCciSgCE86bbaoc96faAaCfgARbbaOcd4ciGgCaCciSgCE86bbaoc97faAaCfgARbbaOciGgOaOciSgOE86bbaoc98faAaOfgORbbalRbiglco4gAaAciSgAE86bbaoc99faOaAfgORbbalcl4ciGgAaAciSgAE86bbaoc9:faOaAfgORbbalcd4ciGgAaAciSgAE86bbaocufaOaAfgoRbbalciGglalciSglE86bbaoalfhlxdkaOalRbwalRbbgAcl4gCaCcsSgCE86bbaocGfalcwfaCfgORbbaAcsGgAaAcsSgAE86bbaocVfaOaAfgORbbalRbegAcl4gCaCcsSgCE86bbaoc7faOaCfgORbbaAcsGgAaAcsSgAE86bbaoctfaOaAfgORbbalRbdgAcl4gCaCcsSgCE86bbaoc91faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc4faOaAfgORbbalRbigAcl4gCaCcsSgCE86bbaoc93faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc94faOaAfgORbbalRblgAcl4gCaCcsSgCE86bbaoc95faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc96faOaAfgORbbalRbvgAcl4gCaCcsSgCE86bbaoc97faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc98faOaAfgORbbalRbogAcl4gCaCcsSgCE86bbaoc99faOaCfgORbbaAcsGgAaAcsSgAE86bbaoc9:faOaAfgORbbalRbrglcl4gAaAcsSgAE86bbaocufaOaAfgoRbbalcsGglalcsSglE86bbaoalfhlxekaOal8Pbb83bbaOcwfalcwf8Pbb83bbalczfhlkdnaiam9pmbaiczfhoaral9RcL0mekkaiam6mialTmidnakTmbawaPfRbbhOcbhoazhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkkazcefhzaPcefgPad6hsalhHaPad9hmexvkkcbhlasceGmdxikalaxad2fhCdnakTmbcbhHcehsawcjdfhminaral9Rax6mialTmdalaxfhlawaHfRbbhOcbhoamhiinaiawcj;cbfaofRbbgAce4cbaAceG9R7aOfgO86bbaiadfhiaocefgoak9hmbkamcefhmaHcefgHad6hsaHad9hmbkaChlxikcbhocehsinaral9Rax6mdalTmealaxfhlaocefgoad6hsadao9hmbkaChlxdkcbhlasceGTmekc9:hoxikabaqad2fawcjdfakad2z1jjjb8Aawawcjdfakcufad2fadz1jjjb8Aakaqfhqalmbkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;ebf8Kjjjjbaok;yzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:jjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk;siliui99iue99dnaeTmbcbhiabhlindndnJ;Zl81Zalcof8UebgvciV:Y:vgoal8Ueb:YNgrJb;:FSNJbbbZJbbb:;arJbbbb9GEMgw:lJbbb9p9DTmbaw:OhDxekcjjjj94hDkalclf8Uebhqalcdf8UebhkabavcefciGaiVcetfaD87ebdndnaoak:YNgwJb;:FSNJbbbZJbbb:;awJbbbb9GEMgx:lJbbb9p9DTmbax:Ohkxekcjjjj94hkkabavcdfciGaiVcetfak87ebdndnaoaq:YNgoJb;:FSNJbbbZJbbb:;aoJbbbb9GEMgx:lJbbb9p9DTmbax:Ohqxekcjjjj94hqkabavcufciGaiVcetfaq87ebdndnJbbjZararN:tawawN:taoaoN:tgrJbbbbarJbbbb9GE:rJb;:FSNJbbbZMgr:lJbbb9p9DTmbar:Ohqxekcjjjj94hqkabavciGaiVcetfaq87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2geTmbinababydbgdcwtcw91:Yadce91cjjj;8ifcjjj98G::NUdbabclfhbaecufgembkkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaiczfhiaeczfheadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkkkebcjwklz9Kbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuikqbbebeedddilve9Weeeviebeoweuec:q;Aekr;leDo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949Wbwl79IV9RbDq;t9tqlbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk;h8JlHud97euo978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnadcefal0mbcuhoaiRbbc:Ge9hmbavaialfgrad9Rad;8qbbcj;abad9UhoaicefhldnadTmbaoc;WFbGgocjdaocjd6EhwcbhDinaDae9pmeawaeaD9RaDawfae6Egqcsfgoc9WGgkci2hxakcethmaocl4cifcd4hPabaDad2fhscbhzdnincehHalhOcbhAdninaraO9RaP6miavcj;cbfaAak2fhCaOaPfhlcbhidnakc;ab6mbaral9Rc;Gb6mbcbhoinaCaofhidndndndndnaOaoco4fRbbgXciGPlbedibkaipxbbbbbbbbbbbbbbbbpklbxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklbalczfhlkdndndndndnaXcd4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklzxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklzalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklzalczfhlkdndndndndnaXcl4ciGPlbedibkaipxbbbbbbbbbbbbbbbbpklaxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklaalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaialpbbbpklaalczfhlkdndndndndnaXco4Plbedibkaipxbbbbbbbbbbbbbbbbpkl8WxikaialpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalclfaYpQbfaXc:q:yjjbfRbbfhlxdkaialpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibaXc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgXcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spkl8WalcwfaYpQbfaXc:q:yjjbfRbbfhlxekaialpbbbpkl8Walczfhlkaoc;abfhiaocjefak0meaihoaral9Rc;Fb0mbkkdndnaiak9pmbaici4hoinaral9RcK6mdaCaifhXdndndndndnaOaico4fRbbaocoG4ciGPlbedibkaXpxbbbbbbbbbbbbbbbbpklbxikaXalpbblalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLgQcdp:meaQpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogLpxiiiiiiiiiiiiiiiip8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalclfaYpQbfaKc:q:yjjbfRbbfhlxdkaXalpbbwalpbbbgQclp:meaQpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogLpxssssssssssssssssp8JgQp5b9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibaKc:q:yjjbfpbbbgYaYpmbbbbbbbbbbbbbbbbaQp5e9cjF;8;4;W;G;ab9:9cU1:NgKcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPaLaQp9spklbalcwfaYpQbfaKc:q:yjjbfRbbfhlxekaXalpbbbpklbalczfhlkaocdfhoaiczfgiak6mbkkalTmbaAci6hHalhOaAcefgohAaoclSmdxekkcbhlaHceGmdkdnakTmbavcjdfazfhiavazfpbdbhYcbhXinaiavcj;cbfaXfgopblbgLcep9TaLpxeeeeeeeeeeeeeeeegQp9op9Hp9rgLaoakfpblbg8Acep9Ta8AaQp9op9Hp9rg8ApmbzeHdOiAlCvXoQrLgEaoamfpblbg3cep9Ta3aQp9op9Hp9rg3aoaxfpblbg5cep9Ta5aQp9op9Hp9rg5pmbzeHdOiAlCvXoQrLg8EpmbezHdiOAlvCXorQLgQaQpmbedibedibedibediaYp9UgYp9AdbbaiadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaEa8EpmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwKDYq8AkEx3m5P8Es8FgLa3a5pmwKDYq8AkEx3m5P8Es8Fg8ApmbezHdiOAlvCXorQLgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfgoaYaLa8ApmwDKYqk8AExm35Ps8E8FgQaQpmbedibedibedibedip9UgYp9AdbbaoadfgoaYaQaQpmlvorlvorlvorlvorp9UgYp9AdbbaoadfgoaYaQaQpmwDqkwDqkwDqkwDqkp9UgYp9AdbbaoadfgoaYaQaQpmxmPsxmPsxmPsxmPsp9UgYp9AdbbaoadfhiaXczfgXak6mbkkazclfgzad6mbkasavcjdfaqad2;8qbbavavcjdfaqcufad2fad;8qbbaqaDfhDc9:hoalmexikkc9:hoxekcbc99aral9Radcaadca0ESEhokavcj;kbf8Kjjjjbaokwbz:bjjjbk;uzeHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhodnaeTmbcmcsaDceSEhkcbhxcbhmcbhDcbhicbhlindnaoaq9nmbc9:hoxikdndnawRbbgrc;Ve0mbavc;abfalarcl4cu7fcsGcitfgPydlhsaPydbhzdnarcsGgPak9pmbavaiarcu7fcsGcdtfydbaxaPEhraPThPdndnadcd9hmbabaDcetfgHaz87ebaHcdfas87ebaHclfar87ebxekabaDcdtfgHazBdbaHclfasBdbaHcwfarBdbkaxaPfhxavc;abfalcitfgHarBdbaHasBdlavaicdtfarBdbavc;abfalcefcsGglcitfgHazBdbaHarBdlaiaPfhialcefhlxdkdndnaPcsSmbamaPfaPc987fcefhmxekaocefhrao8SbbgPcFeGhHdndnaPcu9mmbarhoxekaocvfhoaHcFbGhHcrhPdninar8SbbgOcFbGaPtaHVhHaOcu9kmearcefhraPcrfgPc8J9hmbxdkkarcefhokaHce4cbaHceG9R7amfhmkdndnadcd9hmbabaDcetfgraz87ebarcdfas87ebarclfam87ebxekabaDcdtfgrazBdbarclfasBdbarcwfamBdbkavc;abfalcitfgramBdbarasBdlavaicdtfamBdbavc;abfalcefcsGglcitfgrazBdbaramBdlaicefhialcefhlxekdnarcpe0mbaxcefgOavaiaqarcsGfRbbgPcl49RcsGcdtfydbaPcz6gHEhravaiaP9RcsGcdtfydbaOaHfgsaPcsGgOEhPaOThOdndnadcd9hmbabaDcetfgzax87ebazcdfar87ebazclfaP87ebxekabaDcdtfgzaxBdbazclfarBdbazcwfaPBdbkavaicdtfaxBdbavc;abfalcitfgzarBdbazaxBdlavaicefgicsGcdtfarBdbavc;abfalcefcsGcitfgzaPBdbazarBdlavaiaHfcsGgicdtfaPBdbavc;abfalcdfcsGglcitfgraxBdbaraPBdlalcefhlaiaOfhiasaOfhxxekaxcbaoRbbgzEgAarc;:eSgrfhsazcsGhCazcl4hXdndnazcs0mbascefhOxekashOavaiaX9RcsGcdtfydbhskdndnaCmbaOcefhxxekaOhxavaiaz9RcsGcdtfydbhOkdndnarTmbaocefhrxekaocdfhrao8SbegHcFeGhPdnaHcu9kmbaocofhAaPcFbGhPcrhodninar8SbbgHcFbGaotaPVhPaHcu9kmearcefhraocrfgoc8J9hmbkaAhrxekarcefhrkaPce4cbaPceG9R7amfgmhAkdndnaXcsSmbarhPxekarcefhPar8SbbgocFeGhHdnaocu9kmbarcvfhsaHcFbGhHcrhodninaP8SbbgrcFbGaotaHVhHarcu9kmeaPcefhPaocrfgoc8J9hmbkashPxekaPcefhPkaHce4cbaHceG9R7amfgmhskdndnaCcsSmbaPhoxekaPcefhoaP8SbbgrcFeGhHdnarcu9kmbaPcvfhOaHcFbGhHcrhrdninao8SbbgPcFbGartaHVhHaPcu9kmeaocefhoarcrfgrc8J9hmbkaOhoxekaocefhokaHce4cbaHceG9R7amfgmhOkdndnadcd9hmbabaDcetfgraA87ebarcdfas87ebarclfaO87ebxekabaDcdtfgraABdbarclfasBdbarcwfaOBdbkavc;abfalcitfgrasBdbaraABdlavaicdtfaABdbavc;abfalcefcsGcitfgraOBdbarasBdlavaicefgicsGcdtfasBdbavc;abfalcdfcsGcitfgraABdbaraOBdlavaiazcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhialcifhlkawcefhwalcsGhlaicsGhiaDcifgDae6mbkkcbc99aoaqSEhokavc;aef8Kjjjjbaok:llevu8Jjjjjbcz9Rhvc9:hodnaecvfal0mbcuhoaiRbbc;:eGc;qe9hmbav9cb83iwaicefhraialfc98fhwdnaeTmbdnadcdSmbcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcdtfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfglBdbaoalBdbaDcefgDae9hmbxdkkcbhDindnaraw6mbc9:skarcefhoar8SbbglcFeGhidndnalcu9mmbaohrxekarcvfhraicFbGhicrhldninao8SbbgdcFbGaltaiVhiadcu9kmeaocefhoalcrfglc8J9hmbxdkkaocefhrkabaDcetfaicd4cbaice4ceG9R7avcwfaiceGcdtVgoydbfgl87ebaoalBdbaDcefgDae9hmbkkcbc99arawSEhokaok:EPliuo97eue978Jjjjjbca9Rhidndnadcl9hmbdnaec98GglTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalae9pmeaiaeciGgvcdtgdVcbczad9R;8kbaiabalcdtfglad;8qbbdnavTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkalaiad;8qbbskdnaec98GgxTmbcbhvabhdinadczfglalpbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oawaopmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgvax6mbkkaxae9pmbaiaeciGgvcitgdfcbcaad9R;8kbaiabaxcitfglad;8qbbdnavTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eaDaopmbediwDqkzHOAKY8AEgoczp:Sep;6egrp;Geaoczp:Reczp:Sep;6egwp;Gep;Kep;Legopxb;:FSb;:FSb;:FSb;:FSawaopxbbbbbbbbbbbbbbbbp:2egqawpxbbbjbbbjbbbjbbbjgmp9op9rp;Kegwawp;Meaoaop;Mearaqaramp9op9rp;Kegoaop;Mep;Kep;Kep;Jep;Negrp;Mepxbbn0bbn0bbn0bbn0gqp;Keczp:Reawarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9op9qgwaoarp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogopmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oawaopmbezHdiOAlvCXorQLp9qpklbkalaiad;8qbbkk;4wllue97euv978Jjjjjbc8W9Rhidnaec98GglTmbcbhvabhoinaiaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklbaopxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblbpEb:T:j83ibaocwfarp5eaipblbpEe:T:j83ibawaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblbpEd:T:j83ibaocKfakp5eaipblbpEi:T:j83ibaocafhoavclfgval6mbkkdnalae9pmbaiaeciGgvcitgofcbcaao9R;8kbaiabalcitfgwao;8qbbdnavTmbaiaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkclp:RepklaaipxbbjZbbjZbbjZbbjZpx;Zl81Z;Zl81Z;Zl81Z;Zl81Zakpxibbbibbbibbbibbbp9qp;6ep;NegkaraDpmbediwDqkzHOAKY8AEgrczp:Reczp:Sep;6ep;MegDaDp;Meakarczp:Sep;6ep;Megxaxp;Meakaqczp:Reczp:Sep;6ep;Megqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jepxb;:FSb;:FSb;:FSb;:FSgkp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbgmp9oaxakp;Mearp;Keczp:Rep9qgxaqakp;Mearp;Keczp:ReaDakp;Mearp;Keamp9op9qgkpmbezHdiOAlvCXorQLgrp5baipblapEb:T:j83ibaiarp5eaipblapEe:T:j83iwaiaxakpmwDKYqk8AExm35Ps8E8Fgkp5baipblapEd:T:j83izaiakp5eaipblapEi:T:j83iKkawaiao;8qbbkk:Pddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbhdabheinaeaepbbbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepkbbaeczfheadclfgdav6mbkkdnaval9pmbaialciGgdcdtgeVcbc;abae9R;8kbaiabavcdtfgvae;8qbbdnadTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjZbbjZbbjZbbjZp:UepxbbjFbbjFbbjFbbjFp9op;Mepklbkavaiae;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz9Tbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var i=WebAssembly.validate(t)?e:s,o,r=WebAssembly.instantiate(c(i),{}).then(function(C){o=C.instance,o.exports.__wasm_call_ctors()});function c(C){for(var A=new Uint8Array(C.length),N=0;N<C.length;++N){var _=C.charCodeAt(N);A[N]=_>96?_-97:_>64?_-39:_+4}for(var M=0,N=0;N<C.length;++N)A[M++]=A[N]<60?n[A[N]]:(A[N]-60)*64+A[++N];return A.buffer.slice(0,M)}function d(C,A,N,_,M,E){var z=o.exports.sbrk,T=N+3&-4,R=z(T*_),D=z(M.length),O=new Uint8Array(o.exports.memory.buffer);O.set(M,D);var P=C(R,N,_,D,M.length);if(P==0&&E&&E(R,T,_),A.set(O.subarray(R,R+N*_)),z(R-z(0)),P!=0)throw new Error("Malformed buffer data: "+P)}var h={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},p={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},f=[],g=0;function y(C){var A={object:new Worker(C),pending:0,requests:{}};return A.object.onmessage=function(N){var _=N.data;A.pending-=_.count,A.requests[_.id][_.action](_.value),delete A.requests[_.id]},A}function v(C){for(var A="var instance; var ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(c(i))+"]), {}).then(function(result) { instance = result.instance; instance.exports.__wasm_call_ctors(); });self.onmessage = workerProcess;"+d.toString()+S.toString(),N=new Blob([A],{type:"text/javascript"}),_=URL.createObjectURL(N),M=0;M<C;++M)f[M]=y(_);URL.revokeObjectURL(_)}function w(C,A,N,_,M){for(var E=f[0],z=1;z<f.length;++z)f[z].pending<E.pending&&(E=f[z]);return new Promise(function(T,R){var D=new Uint8Array(N),O=g++;E.pending+=C,E.requests[O]={resolve:T,reject:R},E.object.postMessage({id:O,count:C,size:A,source:D,mode:_,filter:M},[D.buffer])})}function S(C){r.then(function(){var A=C.data;try{var N=new Uint8Array(A.count*A.size);d(o.exports[A.mode],N,A.count,A.size,A.source,o.exports[A.filter]),self.postMessage({id:A.id,count:A.count,action:"resolve",value:N},[N.buffer])}catch(_){self.postMessage({id:A.id,count:A.count,action:"reject",value:_})}})}return{ready:r,supported:!0,useWorkers:function(C){v(C)},decodeVertexBuffer:function(C,A,N,_,M){d(o.exports.meshopt_decodeVertexBuffer,C,A,N,_,o.exports[h[M]])},decodeIndexBuffer:function(C,A,N,_){d(o.exports.meshopt_decodeIndexBuffer,C,A,N,_)},decodeIndexSequence:function(C,A,N,_){d(o.exports.meshopt_decodeIndexSequence,C,A,N,_)},decodeGltfBuffer:function(C,A,N,_,M,E){d(o.exports[p[M]],C,A,N,_,o.exports[h[E]])},decodeGltfBufferAsync:function(C,A,N,_,M){return f.length>0?w(C,A,N,p[_],h[M]):r.then(function(){var E=new Uint8Array(C*A);return d(o.exports[p[_]],E,C,A,N,o.exports[h[M]]),E})}}})();function h0(s){const e=new Map,t=new Map,n=s.clone();return Ik(s,n,function(i,o){e.set(o,i),t.set(i,o)}),n.traverse(function(i){if(!i.isSkinnedMesh)return;const o=i,r=e.get(i),c=r.skeleton.bones;o.skeleton=r.skeleton.clone(),o.bindMatrix.copy(r.bindMatrix),o.skeleton.bones=c.map(function(d){return t.get(d)}),o.bind(o.skeleton,o.bindMatrix)}),n}function Ik(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)Ik(s.children[n],e.children[n],t)}const In={scout:{icon:"🔍",color:4890367,description:"Explores and searches codebase"},builder:{icon:"🔨",color:16752202,description:"Creates and builds features"},debugger:{icon:"🐛",color:16730698,description:"Finds and fixes bugs"},architect:{icon:"📐",color:10373887,description:"Plans and designs systems"},warrior:{icon:"⚔️",color:16730782,description:"Tackles tough problems"},support:{icon:"💚",color:4915102,description:"Helps and assists others"},boss:{icon:"👑",color:16766720,description:"Manages and delegates to subordinates"}},df=["Alex","Sam","Jordan","Taylor","Casey","Morgan","Riley","Quinn","Avery","Blake","Cameron","Drew","Emery","Finley","Harper","Jamie","Kai","Logan","Max","Nico","Parker","Reese","Sage","Sky"],to=df,nr={scout:"character-male-a.glb",builder:"character-male-b.glb",debugger:"character-female-a.glb",architect:"character-male-c.glb",warrior:"character-female-b.glb",support:"character-female-c.glb",boss:"character-male-c.glb"},so=[{id:"scout",model:"character-male-a.glb",name:"Explorer",gender:"Male"},{id:"builder",model:"character-male-b.glb",name:"Crafter",gender:"Male"},{id:"architect",model:"character-male-c.glb",name:"Planner",gender:"Male"},{id:"debugger",model:"character-female-a.glb",name:"Analyst",gender:"Female"},{id:"warrior",model:"character-female-b.glb",name:"Fighter",gender:"Female"},{id:"support",model:"character-female-c.glb",name:"Healer",gender:"Female"}],aa=[{file:"character-male-a.glb",name:"Male A (Explorer)",gender:"Male"},{file:"character-male-b.glb",name:"Male B (Crafter)",gender:"Male"},{file:"character-male-c.glb",name:"Male C (Planner)",gender:"Male"},{file:"character-male-d.glb",name:"Male D",gender:"Male"},{file:"character-male-e.glb",name:"Male E",gender:"Male"},{file:"character-male-f.glb",name:"Male F",gender:"Male"},{file:"character-female-a.glb",name:"Female A (Analyst)",gender:"Female"},{file:"character-female-b.glb",name:"Female B (Fighter)",gender:"Female"},{file:"character-female-c.glb",name:"Female C (Healer)",gender:"Female"},{file:"character-female-d.glb",name:"Female D",gender:"Female"},{file:"character-female-e.glb",name:"Female E",gender:"Female"},{file:"character-female-f.glb",name:"Female F",gender:"Female"}],gT=3,ar=5,bT=1e3,ra=1.2;class yT{constructor(){W(this,"models",new Map);W(this,"customModels",new Map);W(this,"loaded",!1);W(this,"loadingPromise",null);W(this,"loader");W(this,"dracoLoader");W(this,"loadingCustomModels",new Map);this.loader=new lf,this.dracoLoader=new cf,this.dracoLoader.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.7/"),this.loader.setDRACOLoader(this.dracoLoader),this.loader.setMeshoptDecoder(uf)}get isLoaded(){return this.loaded}async loadAll(){if(this.loaded){console.log("[CharacterLoader] Already loaded, skipping");return}if(this.loadingPromise)return console.log("[CharacterLoader] Already loading, waiting for existing promise"),this.loadingPromise;const e=[...new Set([...Object.values(nr),...aa.map(t=>t.file)])];return console.log(`[CharacterLoader] Starting to load ${e.length} models`),this.loadingPromise=Promise.all(e.map(t=>this.loadModel(t))).then(()=>{this.loaded=!0,console.log(`[CharacterLoader] All models loaded. Cache size: ${this.models.size}`)}),this.loadingPromise}loadModel(e){return new Promise(t=>{const n=`/assets/characters/${e}`;console.log(`[CharacterLoader] Loading model: ${n}`),this.loader.load(n,i=>{console.log(`[CharacterLoader] Successfully loaded: ${e}`);const o=this.prepareModel(i.scene);this.models.set(e,{scene:o,animations:i.animations}),t()},i=>{},i=>{console.error(`[CharacterLoader] Failed to load ${e}:`,i),t()})})}prepareModel(e){return e.scale.setScalar(1),e.position.set(0,0,0),e.rotation.set(0,0,0),e.visible=!1,e.traverse(t=>{if(t instanceof ke&&(t.castShadow=!0,t.receiveShadow=!0,t.material)){const n=t.material;n.map&&(n.map.colorSpace=qn),n.isMeshStandardMaterial&&(n.roughness=n.roughness??.6,n.metalness=n.metalness??0,n.envMapIntensity=.8,n.needsUpdate=!0)}}),e}clone(e){const t=nr[e];return this.cloneByModelFile(t)}cloneByModelFile(e){const t=this.models.get(e);if(!t)return console.warn(`[CharacterLoader] Model not found: ${e}`),null;const n=h0(t.scene);return n.visible=!0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.traverse(i=>{i.visible=!0,i instanceof ke&&i.material&&(Array.isArray(i.material)?i.material=i.material.map(o=>o.clone()):i.material=i.material.clone())}),{mesh:n,animations:t.animations}}getAnimations(e){const t=nr[e],n=this.models.get(t);return(n==null?void 0:n.animations)??null}hasModel(e){const t=nr[e];return this.models.has(t)}async loadCustomModel(e){if(this.customModels.has(e))return;const t=this.loadingCustomModels.get(e);if(t)return t;const n=new Promise(i=>{this.loader.load(Nk(lt(`/api/custom-models/${e}`)),o=>{const r=this.prepareModel(o.scene);this.customModels.set(e,{scene:r,animations:o.animations}),console.log(`[CharacterLoader] Loaded custom model for class: ${e} (${o.animations.length} animations)`),i()},void 0,o=>{console.error(`[CharacterLoader] Failed to load custom model for ${e}:`,o),i()})});this.loadingCustomModels.set(e,n);try{await n}finally{this.loadingCustomModels.delete(e)}}hasCustomModel(e){return this.customModels.has(e)}cloneCustomModel(e){const t=this.customModels.get(e);if(!t)return null;const n=h0(t.scene);return n.visible=!0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.traverse(i=>{i.visible=!0,i instanceof ke&&i.material&&(Array.isArray(i.material)?i.material=i.material.map(o=>o.clone()):i.material=i.material.clone())}),{mesh:n,animations:t.animations}}getCustomModelAnimations(e){const t=this.customModels.get(e);return(t==null?void 0:t.animations)??null}unloadCustomModel(e){const t=this.customModels.get(e);t&&(this.disposeCachedModel(t),this.customModels.delete(e),console.log(`[CharacterLoader] Unloaded custom model for class: ${e}`))}disposeCachedModel(e){e.scene.traverse(t=>{var n;t instanceof ke&&((n=t.geometry)==null||n.dispose(),Array.isArray(t.material)?t.material.forEach(i=>this.disposeMaterial(i)):t.material&&this.disposeMaterial(t.material))})}disposeMaterial(e){var t,n,i,o,r,c,d,h,p,f,g;(e instanceof Ke||e instanceof Re||e instanceof UA)&&((t=e.map)==null||t.dispose(),"normalMap"in e&&((n=e.normalMap)==null||n.dispose()),"roughnessMap"in e&&((i=e.roughnessMap)==null||i.dispose()),"metalnessMap"in e&&((o=e.metalnessMap)==null||o.dispose()),"emissiveMap"in e&&((r=e.emissiveMap)==null||r.dispose()),"aoMap"in e&&((c=e.aoMap)==null||c.dispose()),"lightMap"in e&&((d=e.lightMap)==null||d.dispose()),"bumpMap"in e&&((h=e.bumpMap)==null||h.dispose()),"displacementMap"in e&&((p=e.displacementMap)==null||p.dispose()),"alphaMap"in e&&((f=e.alphaMap)==null||f.dispose()),"envMap"in e&&((g=e.envMap)==null||g.dispose())),e.dispose()}dispose(){for(const[e,t]of this.models)this.disposeCachedModel(t),console.log(`[CharacterLoader] Disposed model template: ${e}`);this.models.clear();for(const[e,t]of this.customModels)this.disposeCachedModel(t),console.log(`[CharacterLoader] Disposed custom model: ${e}`);this.customModels.clear(),this.dracoLoader.dispose(),this.loaded=!1,this.loadingPromise=null,this.loadingCustomModels.clear(),console.log("[CharacterLoader] All model caches disposed")}getCacheStats(){return{builtInModels:this.models.size,customModels:this.customModels.size,modelNames:Array.from(this.models.keys()),customModelIds:Array.from(this.customModels.keys())}}}const xT="character-male-a.glb";class vT{constructor(e){W(this,"customClasses",new Map);this.characterLoader=e}setCustomClasses(e){this.customClasses=e}getClassConfig(e){const t=In[e];if(t)return t;const n=this.customClasses.get(e);if(n){const i=parseInt(n.color.replace("#",""),16);return{icon:n.icon,color:isNaN(i)?8947848:i,description:n.description}}return{icon:"❓",color:8947848,description:"Unknown class"}}getModelInfo(e){const t=nr[e];if(t)return{file:t,isCustomModel:!1};const n=this.customClasses.get(e);if(n){if(n.customModelPath)return{file:n.customModelPath,isCustomModel:!0,customClassId:n.id,scale:n.modelScale,offset:n.modelOffset};if(n.model)return{file:n.model,isCustomModel:!1,scale:n.modelScale,offset:n.modelOffset}}return{file:xT,isCustomModel:!1}}createCharacterBody(e,t){const n=this.getModelInfo(e.class);let i=null;if(n.isCustomModel&&n.customClassId&&(i=this.characterLoader.cloneCustomModel(n.customClassId)),i||(i=this.characterLoader.cloneByModelFile(n.file)),i){i.mesh.name="characterBody";const d=n.scale??1;i.mesh.userData.customModelScale=d,i.mesh.userData.isCustomModel=n.isCustomModel,n.offset&&(n.offset.x!==0||n.offset.y!==0||n.offset.z!==0)&&i.mesh.position.set(n.offset.x,n.offset.z,n.offset.y);const h=this.customClasses.get(e.class);h!=null&&h.animationMapping&&(i.mesh.userData.animationMapping=h.animationMapping);const p=new Nl(i.mesh),f=new Map;for(const g of i.animations){const y=g.name.toLowerCase();f.set(y,g),f.set(g.name,g)}return{body:i.mesh,mixer:p,animations:f}}const o=new cp(.5,1,4,16),r=new Ke({color:t,roughness:.4,metalness:.3}),c=new ke(o,r);return c.position.y=1,c.castShadow=!0,c.receiveShadow=!0,c.name="characterBody",{body:c,mixer:null,animations:new Map}}calculateModelHeight(e,t){return t?2:1.5}upgradeToCharacterModel(e,t){const n=e.getObjectByName("characterBody");if(!(n instanceof ke)||!(n.geometry instanceof cp))return null;const i=this.characterLoader.clone(t.class);if(!i)return null;e.remove(n),n.geometry.dispose(),n.material.dispose(),i.mesh.name="characterBody",e.add(i.mesh);const o=new Nl(i.mesh),r=new Map;for(const c of i.animations){const d=c.name.toLowerCase();r.set(d,c)}return{group:e,mixer:o,animations:r,currentAction:null}}replaceAgentModel(e,t){const{group:n}=e,i=this.getModelInfo(t.class);let o=null;if(i.isCustomModel&&i.customClassId&&(o=this.characterLoader.cloneCustomModel(i.customClassId)),o||(o=this.characterLoader.cloneByModelFile(i.file)),!o)return console.warn(`[ModelLoader] Could not load model for class ${t.class}, keeping current model`),n.userData.agentClass=t.class,null;const r=n.getObjectByName("characterBody");r&&(n.remove(r),r.traverse(f=>{var g;(f instanceof ke||f instanceof rp)&&((g=f.geometry)==null||g.dispose(),Array.isArray(f.material)?f.material.forEach(y=>this.disposeMaterial(y)):f.material&&this.disposeMaterial(f.material))})),e.mixer&&(e.mixer.stopAllAction(),e.mixer.uncacheRoot(n)),o.mesh.name="characterBody";const c=i.scale??1;o.mesh.userData.customModelScale=c,o.mesh.userData.isCustomModel=i.isCustomModel,i.offset&&(i.offset.x!==0||i.offset.y!==0||i.offset.z!==0)&&o.mesh.position.set(i.offset.x,i.offset.z,i.offset.y);const d=this.customClasses.get(t.class);d!=null&&d.animationMapping&&(o.mesh.userData.animationMapping=d.animationMapping),n.add(o.mesh);const h=new Nl(o.mesh),p=new Map;for(const f of o.animations){const g=f.name.toLowerCase();p.set(g,f),p.set(f.name,f)}return n.userData.agentClass=t.class,console.log(`[ModelLoader] Agent ${t.name} model updated to ${i.file}`),{group:n,mixer:h,animations:p,currentAction:null}}disposeAgentMesh(e){for(e.mixer&&(e.mixer.stopAllAction(),e.mixer.uncacheRoot(e.group)),e.group.traverse(t=>{var n,i;t instanceof ke?((n=t.geometry)==null||n.dispose(),Array.isArray(t.material)?t.material.forEach(o=>this.disposeMaterial(o)):t.material&&this.disposeMaterial(t.material)):t instanceof ws?this.disposeMaterial(t.material):t instanceof rp&&((i=t.geometry)==null||i.dispose(),Array.isArray(t.material)?t.material.forEach(o=>this.disposeMaterial(o)):t.material&&this.disposeMaterial(t.material))});e.group.children.length>0;)e.group.remove(e.group.children[0]);e.animations.clear()}disposeMaterial(e){var t,n,i,o,r;(e instanceof Ke||e instanceof Re||e instanceof Ts)&&((t=e.map)==null||t.dispose(),"normalMap"in e&&((n=e.normalMap)==null||n.dispose()),"roughnessMap"in e&&((i=e.roughnessMap)==null||i.dispose()),"metalnessMap"in e&&((o=e.metalnessMap)==null||o.dispose()),"emissiveMap"in e&&((r=e.emissiveMap)==null||r.dispose())),e.dispose()}}class wT{createAnimationSetup(e,t,n){n!=null&&n.animationMapping&&(e.userData.animationMapping=n.animationMapping);const i=new Nl(e),o=new Map;for(const r of t)o.set(r.name.toLowerCase(),r),o.set(r.name,r);return{mixer:i,animations:o}}getIdleTimerColor(e){const i=Math.min(e/60,60)/60,o=Math.pow(i,.7),r=120*(1-o),c=80+20*o,d=60-10*o,h=`hsl(${Math.round(r)}, ${Math.round(c)}%, ${Math.round(d)}%)`;return{text:h,border:h}}formatIdleTimeShort(e){if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60){const r=e%60;return r>0?`${t}m ${r}s`:`${t}m`}const n=Math.floor(t/60),i=t%60;return n<24?i>0?`${n}h ${i}m`:`${n}h`:`${Math.floor(n/24)}d`}}const m0={idle:4915102,working:4890367,waiting:16752202,waiting_permission:16763904,error:16730698,orphaned:16711935,default:8947848};function zk(s){if(s.contextStats)return 100-s.contextStats.usedPercent;const e=s.contextUsed||0,t=s.contextLimit||2e5;return Math.max(0,t-e)/t*100}class kT{constructor(e){W(this,"idleTimerCanvas",null);W(this,"idleTimerCtx",null);W(this,"manaBarCanvas",null);W(this,"manaBarCtx",null);this.animConfig=e}getStatusColor(e){return m0[e]??m0.default}createSelectionRing(e,t=!1){const n=t?1.5:1,i=new oo(.8*n,.95*n,32),o=new Re({color:e,side:Hs,transparent:!0,opacity:0,depthTest:!1}),r=new ke(i,o);return r.rotation.x=-Math.PI/2,r.position.y=.05,r.renderOrder=999,r.name="selectionRing",r}createStatusBarSprite(e,t,n,i,o=2){const r=document.createElement("canvas"),c=r.getContext("2d");r.width=4096,r.height=2560,this.drawStatusBar(c,r.width,r.height,e,t,n,i);const d=new Ls(r);d.minFilter=Al,d.magFilter=ds,d.generateMipmaps=!0,d.anisotropy=16,d.needsUpdate=!0;const h=new Ts({map:d,transparent:!0,depthTest:!1}),p=new ws(h),f=i?.8:.5;p.position.y=o+f;const g=i?2:1.6;return p.scale.set(g,g*(r.height/r.width),1),p.name="statusBar",p.userData.modelHeight=o,p}createNameLabelSprite(e,t,n){const i=document.createElement("canvas"),o=i.getContext("2d");i.width=8192,i.height=1024,this.drawNameLabel(o,i.width,i.height,e,t);const r=new Ls(i);r.minFilter=Al,r.magFilter=ds,r.generateMipmaps=!0,r.anisotropy=16,r.needsUpdate=!0;const c=new Ts({map:r,transparent:!0,depthTest:!1}),d=new ws(c);d.position.y=n?-.8:-.6;const h=n?2.5:2;return d.scale.set(h,h*(i.height/i.width),1),d.name="nameLabelSprite",d}drawNameLabel(e,t,n,i,o){e.clearRect(0,0,t,n);const r=`#${o.toString(16).padStart(6,"0")}`;let c=800;const d=300,h=t-400;e.font=`bold ${c}px Arial`;let p=e.measureText(i).width;for(;p>h&&c>d;)c-=40,e.font=`bold ${c}px Arial`,p=e.measureText(i).width;e.textAlign="center",e.textBaseline="middle",e.shadowColor="rgba(0, 0, 0, 0.9)",e.shadowBlur=c*.12,e.shadowOffsetX=c*.04,e.shadowOffsetY=c*.04,e.strokeStyle="#000",e.lineWidth=c*.14,e.lineJoin="round",e.strokeText(i,t/2,n/2),e.shadowColor="transparent",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.fillStyle=r,e.fillText(i,t/2,n/2)}drawStatusBar(e,t,n,i,o,r,c){e.clearRect(0,0,t,n);const d=t/2048;let h=80*d;c&&(e.font=`${400*d}px serif`,e.textAlign="center",e.textBaseline="top",e.fillText("👑",t/2,h),h+=440*d);const p=200*d,f=1350*d,g=(t-f)/2,y=h,v=200*d,w=g+v/2+30*d,S=y+p/2;let C;switch(o){case"working":C="#4a9eff";break;case"orphaned":C="#c060e0";break;case"error":C="#e05050";break;case"waiting":case"waiting_permission":C="#e0a030";break;default:C="#40c090"}e.beginPath(),e.arc(w,S,v/2,0,Math.PI*2),e.fillStyle=C,e.shadowColor=C,e.shadowBlur=20*d,e.fill(),e.shadowBlur=0,e.strokeStyle="rgba(0, 0, 0, 0.4)",e.lineWidth=4*d,e.stroke();const A=g+v+60*d,N=f-v-90*d,_=p-80*d,M=y+40*d,E=30*d;e.fillStyle="#0d0d14",e.beginPath(),e.roundRect(A,M,N,_,E),e.fill(),e.strokeStyle="rgba(80, 90, 110, 0.5)",e.lineWidth=4*d,e.stroke();const z=Math.max(0,Math.min(100,i))/100,T=8*d,R=Math.max(0,(N-T*2)*z);if(R>0){let K;z>.5?K="#00c896":z>.2?K="#e8a020":K="#e84040",e.fillStyle=K,e.beginPath(),e.roundRect(A+T,M+T,R,_-T*2,E-T),e.fill(),e.shadowColor=K,e.shadowBlur=12*d,e.fill(),e.shadowBlur=0}const D=`${Math.round(z*100)}%`;e.font=`bold ${180*d}px "Segoe UI", Arial, sans-serif`,e.textAlign="center",e.textBaseline="middle";const O=A+N/2,P=M+_/2;if(e.shadowColor="rgba(0, 0, 0, 0.8)",e.shadowBlur=8*d,e.shadowOffsetX=2*d,e.shadowOffsetY=2*d,e.strokeStyle="rgba(0, 0, 0, 0.9)",e.lineWidth=24*d,e.lineJoin="round",e.strokeText(D,O,P),e.shadowColor="transparent",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0,e.fillStyle="rgba(255, 255, 255, 0.95)",e.fillText(D,O,P),h+=p+60*d,o==="idle"&&r>0){const K=Math.floor((Date.now()-r)/1e3),Y=this.animConfig.formatIdleTimeShort(K),$=this.animConfig.getIdleTimerColor(K);e.font=`bold ${140*d}px Arial`;const q=e.measureText(`⏱ ${Y}`).width+140*d,V=180*d,G=(t-q)/2,B=h;e.fillStyle="rgba(0, 0, 0, 0.85)",e.beginPath(),e.roundRect(G,B,q,V,28*d),e.fill(),e.strokeStyle=$.border,e.lineWidth=12*d,e.stroke(),e.textAlign="center",e.textBaseline="middle",e.strokeStyle="#000",e.lineWidth=14*d,e.strokeText(`⏱ ${Y}`,t/2,B+V/2),e.fillStyle=$.text,e.fillText(`⏱ ${Y}`,t/2,B+V/2)}}createCombinedUISprite(e,t,n,i,o,r){const c=document.createElement("canvas"),d=c.getContext("2d");c.width=4096,c.height=2048,this.drawCombinedUI(d,c.width,c.height,e,t,n,i,o,r);const h=new Ls(c);h.minFilter=Al,h.magFilter=ds,h.generateMipmaps=!0,h.anisotropy=16,h.needsUpdate=!0;const p=new Ts({map:h,transparent:!0,depthTest:!1}),f=new ws(p);f.position.y=r?3.2:2.2;const g=r?3:2.4;return f.scale.set(g,g*(c.height/c.width),1),f.name="combinedUI",f}drawCombinedUI(e,t,n,i,o,r,c,d,h){e.clearRect(0,0,t,n);const p=`#${o.toString(16).padStart(6,"0")}`,f=t/2048;let g=80*f;h&&(e.font=`${288*f}px serif`,e.textAlign="center",e.textBaseline="top",e.fillText("👑",t/2,g),g+=320*f);const y=224*f,v=t-240*f;e.font=`bold ${y}px Arial`;let w=i;if(e.measureText(w).width>v){for(;w.length>3&&e.measureText(w+"...").width>v;)w=w.slice(0,-1);w+="..."}e.textAlign="center",e.textBaseline="middle";const C=g+y/2;e.strokeStyle="#000",e.lineWidth=24*f,e.lineJoin="round",e.strokeText(w,t/2,C),e.fillStyle=p,e.fillText(w,t/2,C),g+=y+64*f;const A=200*f,N=1350*f,_=(t-N)/2,M=g,E=176*f,z=_+E/2+24*f,T=M+A/2;let R;switch(c){case"working":R="#00a8ff";break;case"orphaned":R="#e040ff";break;case"error":R="#ff3030";break;case"waiting":case"waiting_permission":R="#ffc000";break;default:R="#00e090"}e.beginPath(),e.arc(z,T,E/2,0,Math.PI*2),e.fillStyle=R,e.fill(),e.shadowColor=R,e.shadowBlur=32*f,e.fill(),e.shadowBlur=0,e.strokeStyle="#000",e.lineWidth=12*f,e.stroke();const D=_+E+64*f,O=N-E-88*f,P=A-48*f,K=M+24*f;e.fillStyle="#000",e.beginPath(),e.roundRect(D,K,O,P,24*f),e.fill(),e.strokeStyle="#5a8a8a",e.lineWidth=8*f,e.stroke();const Y=Math.max(0,Math.min(100,r))/100,$=16*f,L=Math.max(0,(O-$*2)*Y);if(L>0){let B;Y>.5?B="#00ff88":Y>.2?B="#ffaa00":B="#ff3366",e.fillStyle=B,e.beginPath(),e.roundRect(D+$,K+$,L,P-$*2,16*f),e.fill(),e.shadowColor=B,e.shadowBlur=32*f,e.fill(),e.shadowBlur=0}const q=`${Math.round(Y*100)}%`;e.font=`bold ${128*f}px Arial`,e.textAlign="center",e.textBaseline="middle";const V=D+O/2,G=K+P/2;if(e.strokeStyle="#000",e.lineWidth=28*f,e.lineJoin="round",e.strokeText(q,V,G),e.fillStyle="#fff",e.shadowColor="#000",e.shadowBlur=8*f,e.fillText(q,V,G),e.shadowBlur=0,g+=A+48*f,c==="idle"&&d>0){const B=Math.floor((Date.now()-d)/1e3),Q=this.animConfig.formatIdleTimeShort(B),U=this.animConfig.getIdleTimerColor(B);e.font=`bold ${160*f}px Arial`;const te=e.measureText(`⏱ ${Q}`).width+160*f,ae=216*f,J=(t-te)/2,he=g;e.fillStyle="rgba(0, 0, 0, 0.85)",e.beginPath(),e.roundRect(J,he,te,ae,32*f),e.fill(),e.strokeStyle=U.border,e.lineWidth=12*f,e.stroke(),e.textAlign="center",e.textBaseline="middle",e.strokeStyle="#000",e.lineWidth=16*f,e.strokeText(`⏱ ${Q}`,t/2,he+ae/2),e.fillStyle=U.text,e.fillText(`⏱ ${Q}`,t/2,he+ae/2)}}createNameLabel(e,t,n=!1){const i=document.createElement("canvas"),o=i.getContext("2d"),r=72,c=32,d=100,h=256;i.width=2048,i.height=h,o.font=`bold ${r}px Arial`;const p=o.measureText(e).width,f=512,g=p+c*2+16;i.width=Math.max(f,g),o.clearRect(0,0,i.width,i.height),o.font=`bold ${r}px Arial`;const y=p+c*2,v=(i.width-y)/2,w=(i.height-d)/2;o.fillStyle="rgba(0, 0, 0, 0.8)",o.beginPath(),o.roundRect(v,w,y,d,12),o.fill(),o.fillStyle=`#${t.toString(16).padStart(6,"0")}`,o.textAlign="center",o.textBaseline="middle",o.fillText(e,i.width/2,i.height/2);const S=new Ls(i);S.minFilter=ds,S.magFilter=ds,S.needsUpdate=!0;const C=new Ts({map:S,transparent:!0,depthTest:!1}),A=new ws(C);A.position.y=n?-.2:-.3;const N=n?.75:.6,M=(n?1.5:1.2)*(i.width/512);return A.scale.set(M,N,1),A.name="nameLabel",A.userData.aspectRatio=i.width/i.height,A}createManaBar(e,t,n=!1){const i=document.createElement("canvas"),o=i.getContext("2d");i.width=400,i.height=64,this.drawManaBar(o,i.width,i.height,e,t);const r=new Ls(i);r.minFilter=ds,r.magFilter=ds,r.needsUpdate=!0;const c=new Ts({map:r,transparent:!0,depthTest:!1}),d=new ws(c);return d.position.y=n?3:2,d.scale.set(n?1.4:1.1,n?.22:.18,1),d.name="manaBar",d}drawManaBar(e,t,n,i,o){const r=Math.max(0,Math.min(100,i))/100;e.clearRect(0,0,t,n);const c=n/32,d=20*c,h=6*c,p=d+h+4*c,f=6*c,g=t-p-10*c,y=n-12*c,v=6*c;let w;switch(o){case"working":w="#4a9eff";break;case"orphaned":w="#ff00ff";break;case"error":w="#ff4a4a";break;case"waiting":case"waiting_permission":w="#ffcc00";break;default:w="#4aff9e"}const S=d/2+4*c,C=n/2;e.beginPath(),e.arc(S,C,d/2,0,Math.PI*2),e.fillStyle=w,e.fill(),e.shadowColor=w,e.shadowBlur=8*c,e.fill(),e.shadowBlur=0,e.strokeStyle="#000000",e.lineWidth=2*c,e.stroke(),e.fillStyle="#000000",e.beginPath(),e.roundRect(p,f,g,y,v),e.fill(),e.strokeStyle="#5a8a8a",e.lineWidth=2*c,e.stroke();const A=Math.max(0,(g-4*c)*r);if(A>0){let _,M;r>.5?(_="#00ff88",M="#00ff88"):r>.2?(_="#ffaa00",M="#ffaa00"):(_="#ff3366",M="#ff3366"),e.fillStyle=_,e.beginPath(),e.roundRect(p+2*c,f+2*c,A,y-4*c,v-2),e.fill(),e.shadowColor=M,e.shadowBlur=8*c,e.fill(),e.shadowBlur=0}const N=`${Math.round(r*100)}%`;e.font=`bold ${Math.round(24*c)}px Arial`,e.textAlign="center",e.textBaseline="middle",e.strokeStyle="#000000",e.lineWidth=4*c,e.strokeText(N,t/2,n/2),e.fillStyle="#ffffff",e.shadowColor="#ffffff",e.shadowBlur=2*c,e.fillText(N,t/2,n/2),e.shadowBlur=0}createIdleTimer(e,t,n=!1){const i=document.createElement("canvas"),o=i.getContext("2d");i.width=400,i.height=64,this.drawIdleTimer(o,i.width,i.height,e,t);const r=new Ls(i);r.minFilter=ds,r.magFilter=ds,r.needsUpdate=!0;const c=new Ts({map:r,transparent:!0,depthTest:!1}),d=new ws(c);return d.position.set(0,n?3.5:2.4,0),d.scale.set(n?1.4:1.1,n?.22:.18,1),d.name="idleTimer",d}createBossCrown(){const e=document.createElement("canvas"),t=e.getContext("2d");e.width=128,e.height=128,t.clearRect(0,0,e.width,e.height),t.font="96px serif",t.textAlign="center",t.textBaseline="middle",t.fillText("👑",e.width/2,e.height/2);const n=new Ls(e);n.minFilter=ds,n.magFilter=ds,n.needsUpdate=!0;const i=new Ts({map:n,transparent:!0,depthTest:!1}),o=new ws(i);return o.position.set(0,4,0),o.scale.set(.8,.8,1),o.name="bossCrown",o}drawIdleTimer(e,t,n,i,o){if(e.clearRect(0,0,t,n),i!=="idle"||o<=0)return;const r=Math.floor((Date.now()-o)/1e3),c=this.animConfig.formatIdleTimeShort(r),d=this.animConfig.getIdleTimerColor(r),h=n/80,p=24*h;e.font=`bold ${Math.round(44*h)}px Arial`;const g=e.measureText(`⏱ ${c}`).width+p*2,y=n-12*h,v=(t-g)/2,w=6*h;e.fillStyle="rgba(0, 0, 0, 0.9)",e.beginPath(),e.roundRect(v,w,g,y,10*h),e.fill(),e.strokeStyle=d.border,e.lineWidth=3*h,e.stroke(),e.textAlign="center",e.textBaseline="middle",e.strokeStyle="#000000",e.lineWidth=4*h,e.strokeText(`⏱ ${c}`,t/2,n/2),e.fillStyle=d.text,e.fillText(`⏱ ${c}`,t/2,n/2)}getIdleTimerCanvas(){return this.idleTimerCanvas||(this.idleTimerCanvas=document.createElement("canvas"),this.idleTimerCanvas.width=400,this.idleTimerCanvas.height=64,this.idleTimerCtx=this.idleTimerCanvas.getContext("2d")),{canvas:this.idleTimerCanvas,ctx:this.idleTimerCtx}}getManaBarCanvas(){return this.manaBarCanvas||(this.manaBarCanvas=document.createElement("canvas"),this.manaBarCanvas.width=400,this.manaBarCanvas.height=64,this.manaBarCtx=this.manaBarCanvas.getContext("2d")),{canvas:this.manaBarCanvas,ctx:this.manaBarCtx}}updateIdleTimer(e,t,n){const i=e.getObjectByName("idleTimer");if(!i)return;const o=i.material;if(!o.map)return;const r=o.map.image;if(!r||!(r instanceof HTMLCanvasElement))return;const c=r.getContext("2d");c&&(this.drawIdleTimer(c,r.width,r.height,t,n),o.map.needsUpdate=!0)}updateManaBar(e,t,n){const i=e.getObjectByName("manaBar");if(!i)return;const o=i.material;if(!o.map)return;const r=o.map.image;if(!r||!(r instanceof HTMLCanvasElement))return;const c=r.getContext("2d");c&&(this.drawManaBar(c,r.width,r.height,t,n),o.map.needsUpdate=!0)}updateNameLabel(e,t,n){var d;const i=e.getObjectByName("nameLabel");i&&((d=i.material.map)==null||d.dispose(),i.material.dispose(),e.remove(i));const o=In[n],r=(o==null?void 0:o.color)??16777215,c=this.createNameLabel(t,r);e.add(c)}updateVisuals(e,t,n,i,o){const r=t.isBoss===!0||t.class==="boss",c=zk(t),d=e.getObjectByName("statusBar");if(d){const g=d.material;if(g.map){const y=g.map.image;if(y instanceof HTMLCanvasElement){const v=y.getContext("2d");v&&(this.drawStatusBar(v,y.width,y.height,c,t.status,t.lastActivity,r),g.map.needsUpdate=!0)}}}const h=e.getObjectByName("nameLabelSprite");if(h&&e.userData.agentName!==t.name){const g=h.material;if(g.map){const y=g.map.image;if(y instanceof HTMLCanvasElement){const v=y.getContext("2d");v&&(this.drawNameLabel(v,y.width,y.height,t.name,o),g.map.needsUpdate=!0,e.userData.agentName=t.name)}}}const p=e.getObjectByName("combinedUI");if(p){const g=p.material;if(g.map){const y=g.map.image;if(y instanceof HTMLCanvasElement){const v=y.getContext("2d");v&&(this.drawCombinedUI(v,y.width,y.height,t.name,o,c,t.status,t.lastActivity,r),g.map.needsUpdate=!0)}}}!d&&!p&&(e.userData.agentName!==t.name&&(this.updateNameLabel(e,t.name,t.class),e.userData.agentName=t.name),this.updateManaBar(e,c,t.status),this.updateIdleTimer(e,t.status,t.lastActivity));const f=e.getObjectByName("selectionRing");if(f){const g=f.material;if(n){const y=In[t.class];g.color.setHex((y==null?void 0:y.color)??o),g.opacity=.8}else i?(g.color.setHex(16766720),g.opacity=.5):g.opacity=0}}}class ST{constructor(e){W(this,"modelLoader");W(this,"animConfig");W(this,"visualConfig");this.modelLoader=new vT(e),this.animConfig=new wT,this.visualConfig=new kT(this.animConfig)}setCustomClasses(e){this.modelLoader.setCustomClasses(e)}createAgentMesh(e){const t=new os;t.userData.agentId=e.id;const n=this.modelLoader.getClassConfig(e.class),i=e.isBoss===!0||e.class==="boss",{body:o,mixer:r,animations:c}=this.modelLoader.createCharacterBody(e,n.color);t.add(o);const d=this.modelLoader.calculateModelHeight(o,i),h=this.visualConfig.createSelectionRing(n.color,i);t.add(h);const p=zk(e),f=this.visualConfig.createStatusBarSprite(p,e.status,e.lastActivity,i,d);t.add(f);const g=this.visualConfig.createNameLabelSprite(e.name,n.color,i);t.add(g),t.userData.agentName=e.name,t.userData.agentClass=e.class,t.userData.isBoss=i,t.position.set(e.position.x,e.position.y,e.position.z);const y=i?.9:.65,v=new Mt(y,8,6),w=new Re({visible:!1,transparent:!0,opacity:0}),S=new ke(v,w);return S.position.y=y,S.name="clickHitbox",t.add(S),{group:t,mixer:r,animations:c,currentAction:null}}updateAgentClass(e,t){const{group:n}=e,i=n.userData.agentClass;if(i===t.class)return null;console.log(`[CharacterFactory] Agent ${t.name} class changed: ${i} -> ${t.class}`);const o=this.modelLoader.replaceAgentModel(e,t);return o&&this.visualConfig.updateNameLabel(n,t.name,t.class),o}updateVisuals(e,t,n,i=!1){const o=this.modelLoader.getClassConfig(t.class);this.visualConfig.updateVisuals(e,t,n,i,o.color)}upgradeToCharacterModel(e,t){return this.modelLoader.upgradeToCharacterModel(e,t)}disposeAgentMesh(e){this.modelLoader.disposeAgentMesh(e)}getStatusColor(e){return this.visualConfig.getStatusColor(e)}updateIdleTimer(e,t,n){this.visualConfig.updateIdleTimer(e,t,n)}updateManaBar(e,t,n){this.visualConfig.updateManaBar(e,t,n)}}const gs={STATIC:"static",IDLE:"idle",WALK:"walk",JUMP:"jump",SIT:"sit",DIE:"die",EMOTE_YES:"emote-yes",EMOTE_NO:"emote-no"},p0={height:.5,speed:1.5};class jT{constructor(){W(this,"movements",new Map);W(this,"jumpingAgents",new Map);W(this,"animatingAgents",new Set);W(this,"jumpTime",0)}isMoving(e){return this.movements.has(e)}hasActiveMovements(){return this.movements.size>0}resolveAnimationName(e,t){var o;const n=e.group.getObjectByName("characterBody"),i=(o=n==null?void 0:n.userData)==null?void 0:o.animationMapping;if(i){const r=i[t];if(r&&e.animations.has(r))return r;if(r&&e.animations.has(r.toLowerCase()))return r.toLowerCase()}switch(t){case"idle":return gs.IDLE;case"walk":return gs.WALK;case"working":return gs.JUMP;default:return gs.IDLE}}playAnimationForState(e,t,n){const i=this.resolveAnimationName(e,t);this.playAnimation(e,i,n)}startMovement(e,t,n){const i=t.group.position.clone(),o=new nt(n.x,n.y,n.z),c=i.distanceTo(o)/gT*1e3;this.movements.delete(e),this.movements.set(e,{agentId:e,startPos:i,endPos:o,startTime:performance.now(),duration:Math.max(c,200)});const d=this.resolveAnimationName(t,"walk");this.playAnimation(t,d),this.faceDirection(t,i,o)}cancelMovement(e,t){this.movements.delete(e);const n=this.resolveAnimationName(t,"idle");this.playAnimation(t,n)}playAnimation(e,t,n){if(!e.mixer)return;const i=e.group.userData.agentId;let o=e.animations.get(t);if(o||(o=e.animations.get(t.toLowerCase())),!o){console.warn(`[MovementAnimator] Animation not found: ${t}, available:`,Array.from(e.animations.keys()));const p=this.jumpingAgents.get(i);if(this.jumpingAgents.delete(i),p!==void 0){const f=e.group.getObjectByName("characterBody");f&&(f.position.y=p)}e.currentAction&&(e.currentAction.fadeOut(.2),e.currentAction=null);return}console.log(`[MovementAnimator] Playing: ${t}`);const{loop:r=!0,fadeTime:c=.2,timeScale:d=1}=n??{},h=e.mixer.clipAction(o);if(h.setLoop(r?GA:yk,1/0),h.clampWhenFinished=!r,h.timeScale=d,e.currentAction&&e.currentAction!==h?(e.currentAction.fadeOut(c),h.reset().fadeIn(c).play()):h.reset().play(),e.currentAction=h,this.animatingAgents.add(i),t===gs.JUMP&&r){if(!this.jumpingAgents.has(i)){const p=e.group.getObjectByName("characterBody"),f=(p==null?void 0:p.position.y)??0;this.jumpingAgents.set(i,f)}}else{const p=this.jumpingAgents.get(i);if(this.jumpingAgents.delete(i),p!==void 0){const f=e.group.getObjectByName("characterBody");f&&(f.position.y=p)}}}stopAnimation(e){this.animatingAgents.delete(e),this.jumpingAgents.delete(e)}faceDirection(e,t,n){const i=new nt().subVectors(n,t).normalize();if(i.x!==0||i.z!==0){const o=e.group.getObjectByName("characterBody");if(o){const r=Math.atan2(i.x,i.z);o.rotation.y=r}}}update(e,t){var o;const n=performance.now(),i=[];this.jumpTime+=t;for(const r of this.animatingAgents){const c=e.get(r);(o=c==null?void 0:c.mixer)==null||o.update(t)}for(const[r,c]of this.jumpingAgents){const d=e.get(r);if(!d)continue;const h=d.group.getObjectByName("characterBody");if(h){const p=Math.abs(Math.sin(this.jumpTime*p0.speed*Math.PI*2))*p0.height;h.position.y=c+p}}for(const[r,c]of this.movements){const d=e.get(r);if(!d){i.push(r);continue}const h=n-c.startTime;let p=Math.min(h/c.duration,1);p=this.easeOutCubic(p),d.group.position.lerpVectors(c.startPos,c.endPos,p),this.smoothRotateToDirection(d,c.startPos,c.endPos,t),p>=1&&(i.push(r),d.group.position.copy(c.endPos))}for(const r of i)this.movements.delete(r);return i}smoothRotateToDirection(e,t,n,i){const o=new nt().subVectors(n,t).normalize();if(o.x===0&&o.z===0)return;const r=e.group.getObjectByName("characterBody");if(!r)return;const c=Math.atan2(o.x,o.z),d=r.rotation.y,h=c-d,p=Math.atan2(Math.sin(h),Math.cos(h)),f=10;r.rotation.y+=p*Math.min(1,f*i)}easeOutCubic(e){return 1-Math.pow(1-e,3)}get activeCount(){return this.movements.size}clear(){this.movements.clear(),this.jumpingAgents.clear(),this.animatingAgents.clear(),this.jumpTime=0}}const Mu={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a",default:"#888888"},ji={running:"#4aff9e",stopped:"#888888",error:"#ff4a4a",unknown:"#ffaa00",starting:"#4a9eff",stopping:"#ffaa00"},Fk={on_track:"#4aff9e",stalled:"#ff9e4a",blocked:"#ff4a4a",completed:"#4a9eff",idle:"#888888"},CT=["#4a9eff","#4aff9e","#ff9e4a","#ff4a9e","#9e4aff","#ff4a4a","#4affff","#ffff4a","#1a3a6e","#1a5e3a","#6e3a1a","#6e1a4a","#4a1a6e","#6e1a1a","#1a5e5e","#5e5e1a"],cu={recent:"#50fa7b",short:"#f1fa8c",medium:"#ffb86c",long:"#ff5555"};function hf(s){const t=Math.floor((Date.now()-s)/1e3)/60;return t<1?cu.recent:t<5?cu.short:t<30?cu.medium:cu.long}function vp(s){return Mu[s]??Mu.default}const $s={Read:"📖",Write:"✏️",Edit:"📝",Bash:"💻",Glob:"🔍",Grep:"🔎",Task:"📋",WebFetch:"🌐",WebSearch:"🌍",TodoWrite:"✅",NotebookEdit:"📓",AskFollowupQuestion:"❓",AskUserQuestion:"❓",AttemptCompletion:"✨",ListFiles:"📂",SearchFiles:"🔎",ExecuteCommand:"⚙️",default:"⚡"};function AT(s){switch(s){case"completed":return"✓";case"in_progress":return"►";default:return"○"}}function Eu(s){return(typeof s=="string"?new Date(s):new Date(s)).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function Hk(s,e){var t;try{const n=JSON.parse(e);switch(s){case"Read":case"Write":case"Edit":case"NotebookEdit":{const i=n.file_path||n.path||n.notebook_path;if(i)return i;break}case"Bash":{const i=n.command;if(i){if(i.includes("curl")&&i.includes("/api/exec"))try{const o=i.match(/-d\s+'({[^}]+})'/);if(o){const r=JSON.parse(o[1]);if(r.command)return r.command}}catch{return i}return i}break}case"Grep":{const i=n.pattern,o=n.path;if(i&&o)return`"${i}" in ${o}`;if(i)return`"${i}"`;break}case"Glob":{const i=n.pattern,o=n.path;if(i&&o)return`${i} in ${o}`;if(i)return i;break}case"WebFetch":{const i=n.url;if(i)return i;break}case"WebSearch":{const i=n.query;if(i)return`"${i}"`;break}case"Task":{const i=n.description||n.prompt;if(i)return i;break}case"TodoWrite":{const i=n.todos;if(Array.isArray(i)&&i.length>0)return i.map(r=>`${AT(r.status||"pending")} ${r.content||""}`).join(`
|
|
35
35
|
`);break}case"AskUserQuestion":case"AskFollowupQuestion":{const i=n.questions||n.question;if(i){const o=Array.isArray(i)?(t=i[0])==null?void 0:t.question:i;if(o)return o}break}default:{for(const[,i]of Object.entries(n))if(typeof i=="string"&&i.length>0)return i;break}}}catch{}return null}const _u="tide-file://",NT=/(^|[\s(>])((?:\.\.?\/|\/)?(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)+(?:#L\d+(?:C\d+)?)?(?::\d+(?::\d+)?)?)(?=$|[\s),.;])/g,TT=/`((?:\.\.?\/|\/)?(?:[A-Za-z0-9._-]+\/)*[A-Za-z0-9._-]+(?:\.[A-Za-z0-9._-]+)+(?:#L\d+(?:C\d+)?)?(?::\d+(?::\d+)?)?)`/g;function f0(s){return!s||s.includes("://")||s.startsWith("www.")||s.includes("@")?!1:s.includes(".")&&!s.endsWith(".")}function jm(s){if(!s||!s.includes("."))return s;const e=s.split(`
|
|
36
36
|
`);let t=!1;return e.map(i=>{if(i.trimStart().startsWith("```"))return t=!t,i;if(t)return i;const r=i.replace(TT,(c,d)=>{if(!f0(d))return c;const h=encodeURIComponent(d);return`[\`${d}\`](${_u}${h})`});return r.replace(NT,(c,d,h,p)=>{const f=p+d.length,g=f>0?r[f-1]:"",y=f+h.length<r.length?r[f+h.length]:"";if(g==="("&&f>1&&r[f-2]==="]"||g==="["||y==="]"||!f0(h))return c;const v=encodeURIComponent(h);return`${d}[${h}](${_u}${v})`})}).join(`
|
|
@@ -137,7 +137,7 @@ Error generating stack: `+b.message+`
|
|
|
137
137
|
float h = normalize(vWorldPosition + offset).y;
|
|
138
138
|
gl_FragColor = vec4(mix(bottomColor, topColor, max(pow(max(h, 0.0), exponent), 0.0)), 1.0);
|
|
139
139
|
}
|
|
140
|
-
`,side:wk});i.add(new ke(o,r)),i.add(new sf(16777215,1));const c=n.fromScene(i,.04).texture;t.environment=c,n.dispose(),o.dispose(),r.dispose()}createInputCallbacks(){return{onAgentClick:(e,t)=>this.inputEventHandlers.handleAgentClick(e,t),onAgentDoubleClick:e=>this.inputEventHandlers.handleAgentDoubleClick(e),onAgentHover:(e,t)=>this.inputEventHandlers.handleAgentHover(e,t),onGroundClick:()=>this.inputEventHandlers.handleGroundClick(),onMoveCommand:(e,t)=>this.inputEventHandlers.handleMoveCommand(e,t),onSelectionBox:(e,t)=>this.inputEventHandlers.handleSelectionBox(e,t),onDrawStart:e=>this.drawingManager.startDrawing(e),onDrawMove:e=>this.drawingManager.updateDrawing(e),onDrawEnd:e=>this.drawingManager.finishDrawing(e),onAreaRightClick:e=>this.inputEventHandlers.handleAreaRightClick(e),onResizeStart:(e,t)=>this.drawingManager.startResize(e,t),onResizeMove:e=>this.drawingManager.updateResize(e),onResizeEnd:()=>this.drawingManager.finishResize(),onGroundClickOutsideArea:()=>this.inputEventHandlers.handleGroundClickOutsideArea(),onBuildingClick:(e,t)=>this.inputEventHandlers.handleBuildingClick(e,t),onBuildingDoubleClick:e=>this.inputEventHandlers.handleBuildingDoubleClick(e),onBuildingHover:(e,t)=>this.inputEventHandlers.handleBuildingHover(e,t),onBuildingDragStart:()=>{},onBuildingDragMove:(e,t)=>this.buildingManager.setBuildingPosition(e,t),onBuildingDragEnd:(e,t)=>I.updateBuildingPosition(e,t),onContextMenu:(e,t,n)=>this.callbackManager.triggerContextMenu(e,t,n),onActivity:()=>this.renderLoop.markActivity(),onToggleTerminal:()=>I.toggleTerminal()}}setupInputHandlerHelpers(){this.inputHandler.setDrawingModeChecker(()=>this.drawingManager.isInDrawingMode()),this.inputHandler.setResizeHandlers(()=>this.drawingManager.getResizeHandles(),()=>this.drawingManager.isCurrentlyResizing()),this.inputHandler.setAreaAtPositionGetter(e=>this.drawingManager.getAreaAtPosition(e)),this.inputHandler.setBuildingAtPositionGetter(e=>{const t=this.buildingManager.getBuildingAtPosition(e);return t?{id:t.id}:null}),this.inputHandler.setBuildingPositionsGetter(()=>{const e=new Map;for(const[t,n]of this.buildingManager.getBuildingMeshData())e.set(t,n.group.position.clone());return e})}setupEventListeners(e){window.addEventListener("resize",this.onWindowResize),this.resizeObserver=new ResizeObserver(()=>this.onWindowResize()),e.parentElement&&this.resizeObserver.observe(e.parentElement),e.addEventListener("webglcontextlost",this.onContextLost),e.addEventListener("webglcontextrestored",this.onContextRestored)}updateInputHandlerReferences(){this.inputHandler.setReferences(this.battlefield.getGround(),this.agentManager.getAgentMeshes())}updateBattlefield(e,t){t-this.lastTimeUpdate>6e4&&(this.battlefield.updateTimeOfDay(),this.lastTimeUpdate=t),this.battlefield.updateGalacticAnimation(e),this.battlefield.updateCloudAnimation(e)}updateAnimations(e){const t=this.movementAnimator.update(this.agentManager.getAgentMeshes(),e);return this.effectsManager.update(),this.buildingManager.update(e),t}updateProceduralAnimations(e){if(this.proceduralBodiesDirty){this.proceduralBodiesCache.clear();for(const[t,n]of this.agentManager.getAgentMeshes())if(this.proceduralAnimator.has(t)&&n.animations.size===0){const i=n.group.getObjectByName("characterBody");i&&this.proceduralBodiesCache.set(t,i)}this.proceduralBodiesDirty=!1}this.proceduralBodiesCache.size>0&&this.proceduralAnimator.update(e,this.proceduralBodiesCache)}updateIndicatorScales(e,t,n){for(const[,i]of t){const o=e.position.distanceTo(i.group.position),r=Math.max(.5,Math.min(2.5,o/15))*n,c=i.group.userData.isBoss===!0,d=i.group.getObjectByName("statusBar"),h=i.group.getObjectByName("nameLabelSprite");if(d){const f=c?2:1.6,g=2560/4096;d.scale.set(f*r,f*g*r,1)}if(h){const f=c?2.5:2,g=1024/8192;h.scale.set(f*r,f*g*r,1)}const p=i.group.getObjectByName("combinedUI");if(p){const f=c?2:1.6,g=1024/2048;p.scale.set(f*r,f*g*r,1)}if(!d&&!p){const f=i.group.getObjectByName("nameLabel");if(f){const v=.3*r;f.scale.set(v*(f.userData.aspectRatio||2),v,1)}const g=i.group.getObjectByName("manaBar");g&&g.scale.set(.9,.14,1);const y=i.group.getObjectByName("idleTimer");y&&y.scale.set(.9*r,.14*r,1)}}for(const[,i]of this.buildingManager.getBuildingMeshData()){const o=e.position.distanceTo(i.group.position),r=Math.max(.5,Math.min(2.5,o/15))*n,c=i.group.getObjectByName("buildingLabel");if(c){const d=.3*r;c.scale.set(d*(c.userData.aspectRatio||2),d,1)}}this.effectsManager.updateWithCamera(e)}async loadCharacterModels(){await this.agentManager.loadCharacterModels()}upgradeAgentModels(){this.agentManager.upgradeAgentModels(),this.updateInputHandlerReferences()}addAgent(e){this.agentManager.addAgent(e)}removeAgent(e){this.agentManager.removeAgent(e),this.updateInputHandlerReferences()}updateAgent(e,t=!1){this.agentManager.updateAgent(e,t)}syncAgents(e){this.agentManager.syncAgents(e)}setCustomAgentClasses(e){this.agentManager.setCustomAgentClasses(e)}refreshSelectionVisuals(){this.selectionManager.refreshSelectionVisuals()}createMoveOrderEffect(e){this.effectsManager.createMoveOrderEffect(e)}showToolBubble(e,t,n){this.effectsManager.setAgentMeshes(this.agentManager.getAgentMeshes()),this.effectsManager.createSpeechBubble(e,t,n)}showDelegationEffect(e,t){this.effectsManager.setAgentMeshes(this.agentManager.getAgentMeshes()),this.effectsManager.createDelegationEffect(e,t)}addSubagentEffect(e,t,n,i){this.effectsManager.setAgentMeshes(this.agentManager.getAgentMeshes()),this.effectsManager.addSubagentEffect(e,t,n,i)}completeSubagentEffect(e){this.effectsManager.completeSubagentEffect(e)}removeSubagentEffect(e){this.effectsManager.removeSubagentEffect(e)}focusAgent(e){this.cameraManager.focusAgent(e)}callSubordinates(e){var r;const n=I.getState().agents.get(e);if(!n||!(n.isBoss||n.class==="boss")||!((r=n.subordinateIds)!=null&&r.length))return;const i=new nt(n.position.x,n.position.y,n.position.z),o=this.inputHandler.calculateFormationPositions(i,n.subordinateIds.length);this.effectsManager.createMoveOrderEffect(i.clone()),n.subordinateIds.forEach((c,d)=>{const h=this.agentManager.getAgentMeshes().get(c);I.moveAgent(c,o[d]),h&&this.movementAnimator.startMovement(c,h,o[d])})}setDrawingTool(e){this.drawingManager.setTool(e),I.setActiveTool(e)}syncAreas(){this.drawingManager.syncFromStore()}highlightArea(e){this.drawingManager.highlightArea(e)}clearAreaSelection(){this.drawingManager.highlightArea(null)}addBuilding(e){this.buildingManager.addBuilding(e)}removeBuilding(e){this.buildingManager.removeBuilding(e)}updateBuilding(e){this.buildingManager.updateBuilding(e)}syncBuildings(){this.buildingManager.syncFromStore()}highlightBuilding(e){this.buildingManager.highlightBuilding(e)}setOnBuildingClick(e){this.callbackManager.setOnBuildingClick(e)}setOnBuildingDoubleClick(e){this.callbackManager.setOnBuildingDoubleClick(e)}setOnContextMenu(e){this.callbackManager.setOnContextMenu(e)}setOnAgentHover(e){this.callbackManager.setOnAgentHover(e)}setOnBuildingHover(e){this.callbackManager.setOnBuildingHover(e)}setOnGroundClick(e){this.callbackManager.setOnGroundClick(e)}setOnToast(e){this.agentManager.setOnToast(e)}setCharacterScale(e){this.agentManager.setCharacterScale(e),this.selectionManager.setCharacterScale(e)}setIndicatorScale(e){this.renderLoop.setIndicatorScale(e),this.effectsManager.setIndicatorScale(e)}setFpsLimit(e){this.renderLoop.setFpsLimit(e)}setPowerSaving(e){this.renderLoop.setPowerSaving(e)}setGridVisible(e){this.battlefield.setGridVisible(e)}setDebugTime(e){this.battlefield.setDebugTime(e)}setTimeMode(e){this.battlefield.setTimeMode(e)}setTerrainConfig(e){this.battlefield.setTerrainConfig(e),e.brightness!==void 0&&(this.drawingManager.setBrightness(e.brightness),this.buildingManager.setBrightness(e.brightness),this.agentManager.setBrightness(e.brightness))}setFloorStyle(e,t=!1){this.battlefield.setFloorStyle(e,t)}setIdleAnimation(e){this.agentManager.setIdleAnimation(e)}setWorkingAnimation(e){this.agentManager.setWorkingAnimation(e)}setAgentModelStyle(e){this.agentManager.setModelStyle(e)}getAgentModelStyle(){return this.agentManager.getModelStyle()}setGlobalSaturation(e){this.sceneCore.setSaturation(e)}getGlobalSaturation(){return this.sceneCore.getSaturation()}setPostProcessingEnabled(e){this.sceneCore.setPostProcessingEnabled(e)}reattach(e,t){var o,r;console.log("[SceneManager] Reattaching to new canvas (HMR)"),this.isReattaching=!0,this.renderLoop.stop(),(o=this.resizeObserver)==null||o.disconnect();const n=this.sceneCore.getCanvas();n.removeEventListener("webglcontextlost",this.onContextLost),n.removeEventListener("webglcontextrestored",this.onContextRestored),this.sceneCore.reattach(e),this.cameraManager.recreateControls(this.sceneCore.getRenderer()),this.sceneCore.updateCamera(this.cameraManager.getCamera()),e.addEventListener("webglcontextlost",this.onContextLost),e.addEventListener("webglcontextrestored",this.onContextRestored),this.inputHandler.reattach(e,t,this.cameraManager.getControls()),this.updateInputHandlerReferences(),e.parentElement&&((r=this.resizeObserver)==null||r.observe(e.parentElement)),this.onWindowResize();const i=(c=0)=>{this.isReattaching=!1,e.isConnected&&this.sceneCore.getRenderer()?(console.log("[SceneManager] Restarting animation loop after HMR reattach"),this.renderLoop.start()):c<10?(console.log(`[SceneManager] Canvas not connected, retrying... (attempt ${c+1})`),this.isReattaching=!0,requestAnimationFrame(()=>i(c+1))):console.warn("[SceneManager] Failed to restart animation loop - canvas never connected")};requestAnimationFrame(()=>i())}getMemoryDiagnostics(){var t;const e=this.sceneCore.getRenderer().info;return{threeJs:e!=null&&e.memory?{geometries:e.memory.geometries,textures:e.memory.textures,programs:((t=e.programs)==null?void 0:t.length)??0}:null,heap:_N.getUsage(),agentMeshCount:this.agentManager.getAgentMeshes().size,bossLineCount:0}}getRenderStats(){var t,n;const e=(n=(t=this.sceneCore.getRenderer())==null?void 0:t.info)==null?void 0:n.render;return e?{calls:e.calls,triangles:e.triangles,points:e.points,lines:e.lines}:null}get renderer(){return this.sceneCore.getRenderer()}logMemoryDiagnostics(){const e=this.getMemoryDiagnostics(),t=this.characterLoader.getCacheStats();console.group("%c[SceneManager Memory]","color: #ff6600; font-weight: bold"),e.threeJs&&console.log(`Three.js: ${e.threeJs.geometries} geometries, ${e.threeJs.textures} textures, ${e.threeJs.programs} programs`),e.heap&&console.log(`Heap: ${e.heap.usedMB}MB / ${e.heap.totalMB}MB (limit: ${e.heap.limitMB}MB)`),console.log(`Agent meshes: ${e.agentMeshCount}`),console.log(`CharacterLoader cache: ${t.builtInModels} built-in, ${t.customModels} custom`),t.modelNames.length>0&&console.log(` Built-in models: ${t.modelNames.join(", ")}`),t.customModelIds.length>0&&console.log(` Custom models: ${t.customModelIds.join(", ")}`),console.groupEnd()}dispose(){var n;console.log("%c[SceneManager] dispose() called - starting cleanup","color: #ff0000; font-weight: bold");const e=this.characterLoader.getCacheStats();console.log(`[SceneManager] Pre-dispose: ${e.builtInModels} built-in models, ${e.customModels} custom models`),this.renderLoop.stop(),window.removeEventListener("resize",this.onWindowResize);const t=this.sceneCore.getCanvas();t.removeEventListener("webglcontextlost",this.onContextLost),t.removeEventListener("webglcontextrestored",this.onContextRestored),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.inputHandler.dispose(),this.drawingManager.dispose(),this.buildingManager.dispose(),this.effectsManager.dispose(),this.agentManager.dispose(),this.selectionManager.dispose(),this.battlefield.dispose(),this.characterLoader.dispose(),this.cameraManager.dispose(),this.sceneCore.dispose(),console.log("%c[SceneManager] dispose() complete - all resources freed","color: #00ff00; font-weight: bold")}}const Du="tide_webgl_active";typeof window<"u"&&(window.__tidePersistedScene===void 0&&(window.__tidePersistedScene=null),window.__tidePersistedCanvas===void 0&&(window.__tidePersistedCanvas=null),window.__tideWsConnected===void 0&&(window.__tideWsConnected=!1),window.__tideIsPageUnloading===void 0&&(window.__tideIsPageUnloading=!1));function Qu(){return typeof window<"u"?window.__tidePersistedScene??null:null}function Wk(){return typeof window<"u"?window.__tidePersistedCanvas??null:null}function E2(){return typeof window<"u"?window.__tideWsConnected??!1:!1}function Pl(s){typeof window<"u"&&(window.__tidePersistedScene=s)}function Lu(s){typeof window<"u"&&(window.__tidePersistedCanvas=s)}function Kk(s){typeof window<"u"&&(window.__tideWsConnected=s)}function _2(s){typeof window<"u"&&(window.__tideIsPageUnloading=s)}function R2(){sessionStorage.setItem(Du,"true")}function pu(s){_2(!0),sessionStorage.removeItem(Du),Bk(),AN(),window.__tideScene&&(window.__tideScene=null);const e=Qu();e?(console.log("[App] Calling persistedScene.dispose()"),e.dispose(),Pl(null)):console.log("[App] No persistedScene to dispose"),Lu(null),Kk(!1);const t=document.getElementById("battlefield");t&&t.remove();const n=document.getElementById("app");n&&(n.innerHTML="")}function D2(){var i,o;if(window.__tideAppInitialized)return;if(window.__tideAppInitialized=!0,sessionStorage.getItem(Du)==="true"&&console.log("[App] Detected unclean shutdown from previous session - forcing cleanup"),window.__tideScene){console.log("[App] Cleaning up stale __tideScene reference");try{(o=(i=window.__tideScene).dispose)==null||o.call(i)}catch{}window.__tideScene=null}const e=Qu();if(e){console.log("[App] Cleaning up stale persistedScene");try{e.dispose()}catch{}Pl(null)}const t=document.getElementById("battlefield"),n=Wk();t&&t!==n&&t.remove(),sessionStorage.removeItem(Du)}function L2(){typeof window>"u"||(D2(),window.addEventListener("pageshow",s=>{s.persisted&&(console.log("[App] Page restored from bfcache - cleaning up"),pu(),window.location.reload())}),window.onunload=()=>pu(),window.onbeforeunload=s=>{if(pu(),window.innerWidth<=768)return s.preventDefault(),""},window.addEventListener("pagehide",s=>{pu(`pagehide (persisted=${s.persisted})`)}))}L2();const R0={showTrees:!0,showBushes:!0,showHouse:!0,showLamps:!0,showGrass:!0,showClouds:!0,fogDensity:1,floorStyle:"concrete",brightness:1,skyColor:null},D0={saturation:2,roughness:.5,metalness:-1,emissiveBoost:0,envMapIntensity:1,wireframe:!1,colorMode:"normal"},L0={idleAnimation:"sit",workingAnimation:"sprint"},B2=0;function Vk(){const s={characterScale:2,indicatorScale:1,gridVisible:!0,timeMode:"day",terrain:R0,modelStyle:D0,animations:L0,fpsLimit:B2},e=ca(at.CONFIG,null);return e?{characterScale:e.characterScale??s.characterScale,indicatorScale:e.indicatorScale??s.indicatorScale,gridVisible:e.gridVisible??s.gridVisible,timeMode:e.timeMode??s.timeMode,terrain:{...R0,...e.terrain},modelStyle:{...D0,...e.modelStyle},animations:{...L0,...e.animations},fpsLimit:e.fpsLimit??s.fpsLimit}:s}function O2(s){Ia(at.CONFIG,s)}typeof window<"u"&&!window.__tideHmrRefreshListeners&&(window.__tideHmrRefreshListeners=new Set);function Yk(){console.log("[Tide HMR] Manual scene refresh triggered");const s=Qu();if(s){try{s.dispose()}catch(t){console.warn("[Tide HMR] Error disposing scene:",t)}Pl(null)}Lu(null),window.__tideScene&&(window.__tideScene=null);const e=document.getElementById("battlefield");if(e){const t=e.getContext("webgl2")||e.getContext("webgl");if(t){const n=t.getExtension("WEBGL_lose_context");n&&n.loseContext()}}window.__tideHmrPendingSceneChanges=!1,window.location.reload()}typeof window<"u"&&(window.__tideHmrSceneRefresh=Yk);function P2({canvasRef:s,selectionBoxRef:e,showToast:t,showAgentNotification:n,toolboxModal:i,contextMenu:o,setHoveredAgentPopup:r,setBuildingPopup:c,getBuildingPopup:d,openBuildingModal:h,openPM2LogsModal:p,openBossLogsModal:f,openDatabasePanel:g}){const y=x.useRef(null),v=x.useRef(null),w=x.useRef(null);return x.useEffect(()=>{if(!s.current||!e.current)return;let S=!1;const C=Qu(),N=Wk()===s.current;function _(){var M,E,z,T,R,D,O;(M=y.current)==null||M.setOnToast(t),(E=y.current)==null||E.setOnBuildingClick((P,K)=>{I.selectBuilding(P);const Y=I.getState().buildings.get(P);(Y==null?void 0:Y.type)==="folder"&&Y.folderPath?I.openFileExplorer(Y.folderPath):(Y==null?void 0:Y.type)==="server"||(Y==null?void 0:Y.type)==="boss"||(Y==null?void 0:Y.type)==="database"?(v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{c({buildingId:P,screenPos:K,fromClick:!0}),v.current=null},150)):h(P)}),(z=y.current)==null||z.setOnContextMenu((P,K,Y)=>{o.open(P,K,Y)}),(T=y.current)==null||T.setOnAgentHover(()=>{}),(R=y.current)==null||R.setOnBuildingHover((P,K)=>{const Y=d();if(P&&K){const $=I.getState().buildings.get(P);(($==null?void 0:$.type)==="server"||($==null?void 0:$.type)==="boss"||($==null?void 0:$.type)==="database")&&!(Y!=null&&Y.fromClick)&&c({buildingId:P,screenPos:K,fromClick:!1})}else Y!=null&&Y.fromClick||c(null)}),(D=y.current)==null||D.setOnGroundClick(()=>{c(null)}),(O=y.current)==null||O.setOnBuildingDoubleClick(P=>{var Y;v.current&&(clearTimeout(v.current),v.current=null),c(null);const K=I.getState().buildings.get(P);(K==null?void 0:K.type)==="server"&&((Y=K.pm2)!=null&&Y.enabled)?p==null||p(P):(K==null?void 0:K.type)==="boss"?f==null||f(P):(K==null?void 0:K.type)==="database"?g==null||g(P):(K==null?void 0:K.type)==="folder"&&K.folderPath?I.openFileExplorer(K.folderPath):h(P)})}if(C&&N){y.current=C,console.log("[Tide] Reusing existing scene (StrictMode remount)");const M=I.getState();C.syncAreas(),C.syncBuildings(),M.agents.size>0&&(console.log("[Tide] Re-syncing agents from store after remount:",M.agents.size),C.syncAgents(Array.from(M.agents.values()))),_()}else{const M=s.current,E=e.current,z=()=>{if(S){console.log("[Tide] Effect cleaned up before scene init, skipping");return}if(!M.isConnected||!E.isConnected){console.warn("[Tide] Canvas disconnected before initialization");return}(!M.clientWidth||!M.clientHeight)&&(console.log("[Tide] Canvas has no CSS dimensions, using window fallback"),M.style.width="100%",M.style.height="100%",M.offsetHeight),(!M.clientWidth||!M.clientHeight)&&(M.width=window.innerWidth,M.height=window.innerHeight),R2();try{const T=new M2(M,E);y.current=T,Pl(T),Lu(M);const R=Vk();T.setCharacterScale(R.characterScale),T.setIndicatorScale(R.indicatorScale),T.setGridVisible(R.gridVisible),T.setTimeMode(R.timeMode),T.setTerrainConfig(R.terrain),T.setFloorStyle(R.terrain.floorStyle,!0),T.setAgentModelStyle(R.modelStyle),T.setIdleAnimation(R.animations.idleAnimation),T.setWorkingAnimation(R.animations.workingAnimation),T.setFpsLimit(R.fpsLimit),T.syncAreas(),T.syncBuildings(),T.loadCharacterModels().then(()=>{console.log("[Tide] Character models ready");const D=I.getState();D.customAgentClasses.size>0&&(console.log("[Tide] Applying custom classes from store:",D.customAgentClasses.size),T.setCustomAgentClasses(D.customAgentClasses)),D.agents.size>0&&(console.log("[Tide] Syncing agents from store:",D.agents.size),T.syncAgents(Array.from(D.agents.values()))),T.upgradeAgentModels()}).catch(D=>{console.warn("[Tide] Some models failed to load, using fallback:",D)}),_()}catch(T){console.error("[Tide] Failed to initialize 3D scene:",T)}};w.current=requestAnimationFrame(z)}return _k({onAgentCreated:M=>{var E,z;(E=y.current)==null||E.addAgent(M),(z=window.__spawnModalSuccess)==null||z.call(window)},onAgentUpdated:(M,E)=>{var z;(z=y.current)==null||z.updateAgent(M,E)},onAgentDeleted:M=>{var E;(E=y.current)==null||E.removeAgent(M)},onAgentsSync:M=>{var E;(E=y.current)==null||E.syncAgents(M)},onAreasSync:()=>{var E,z;(E=y.current)==null||E.syncAreas();const M=Array.from(I.getState().agents.values());(z=y.current)==null||z.syncAgents(M)},onSpawnError:()=>{var M;(M=window.__spawnModalError)==null||M.call(window)},onSpawnSuccess:()=>{var M;(M=window.__spawnModalSuccess)==null||M.call(window)},onDirectoryNotFound:M=>{var E;(E=window.__spawnModalDirNotFound)==null||E.call(window,M)},onToolUse:(M,E,z)=>{var T;(T=y.current)==null||T.showToolBubble(M,E,z)},onDelegation:(M,E)=>{var z;(z=y.current)==null||z.showDelegationEffect(M,E)},onCustomClassesSync:M=>{var E,z;(E=y.current)==null||E.setCustomAgentClasses(M),(z=y.current)==null||z.upgradeAgentModels()},onBuildingUpdated:M=>{var E;(E=y.current)==null||E.updateBuilding(M)},onSubagentStarted:M=>{var E;(E=y.current)==null||E.addSubagentEffect(M.id,M.parentAgentId,M.name,M.subagentType)},onSubagentCompleted:M=>{var T;const E=I.getSubagent(M)||I.getSubagentByToolUseId(M),z=(E==null?void 0:E.id)||M;(T=y.current)==null||T.completeSubagentEffect(z),setTimeout(()=>{var R;(R=y.current)==null||R.removeSubagentEffect(z)},3e4)}}),()=>{var M;S=!0,w.current!==null&&(cancelAnimationFrame(w.current),w.current=null),!((M=s.current)!=null&&M.isConnected)&&y.current&&(console.log("[Tide] 3D canvas unmounted - disposing scene to free memory"),NN(),y.current.dispose(),y.current=null,Pl(null),Lu(null))}},[s.current,e.current]),y}let Il,er;try{Il=require("@capacitor/local-notifications").LocalNotifications,er=require("@capacitor/core").Capacitor}catch{}let I2=1;const z2="agent_alerts";function pf(){var s;return((s=er==null?void 0:er.isNativePlatform)==null?void 0:s.call(er))??!1}async function F2(){return pf()?(await Il.requestPermissions()).display==="granted":"Notification"in window?await Notification.requestPermission()==="granted":!1}async function H2(s){const{title:e,body:t,icon:n,data:i}=s;pf()?await Il.schedule({notifications:[{id:I2++,title:e,body:t,schedule:{at:new Date(Date.now()+100)},extra:i,channelId:z2,smallIcon:"ic_launcher",autoCancel:!0}]}):"Notification"in window&&Notification.permission==="granted"&&new Notification(e,{body:t,icon:n,data:i})}async function $2(s){pf()&&Il&&await Il.addListener("localNotificationActionPerformed",e=>{s&&e.notification.extra&&s(e.notification.extra)})}function U2({showToast:s,showAgentNotification:e}){const t=x.useRef(!1);x.useEffect(()=>{if(t.current||E2())return;t.current=!0,_k({onToast:s,onReconnect:()=>{I.triggerReconnect()},onAgentNotification:i=>{e(i)}}),Ol(),Kk(!0),F2(),$2(i=>{i.agentId&&typeof i.agentId=="string"&&I.selectAgent(i.agentId)});const n=()=>{console.log("[Tide] App resumed from background, reconnecting..."),setTimeout(()=>Ol(),100)};return window.addEventListener("tideAppResume",n),()=>{window.removeEventListener("tideAppResume",n)}},[s,e])}function G2(s){x.useEffect(()=>{let e="",t="",n=new Map;const i=o=>{var d;let r=!1;const c=new Map;for(const[h,p]of o){const g=`${p.position.x.toFixed(2)},${p.position.z.toFixed(2)},${p.status},${p.class},${p.isBoss},${((d=p.subordinateIds)==null?void 0:d.length)??0}`.split("").reduce((y,v)=>(y<<5)-y+v.charCodeAt(0),0);c.set(h,g),n.get(h)!==g&&(r=!0)}return c.size!==n.size&&(r=!0),{newVersion:c,changed:r}};return I.subscribe(()=>{var g;const o=I.getState(),r=Array.from(o.selectedAgentIds).sort().join(","),c=Array.from(o.selectedBuildingIds).sort().join(","),d=r!==e,h=c!==t,{newVersion:p,changed:f}=i(o.agents);(d||h||f)&&(e=r,t=c,n=p,(g=s.current)==null||g.refreshSelectionVisuals())})},[s])}function q2(s){x.useEffect(()=>{var n;(n=s.current)==null||n.syncAreas();let e=0,t=0;return I.subscribe(()=>{var c,d;const o=I.getState().areas;if(o.size!==e){e=o.size,t=Date.now(),(c=s.current)==null||c.syncAreas();return}let r=0;for(const[h,p]of o){let f=h.charCodeAt(0);f+=(p.width??0)+(p.height??0)+(p.radius??0),f+=Math.floor(p.center.x*100)+Math.floor(p.center.z*100),f+=(p.zIndex??0)*1e3;for(let g=0;g<p.name.length;g++)f+=p.name.charCodeAt(g);for(let g=0;g<p.color.length;g++)f+=p.color.charCodeAt(g);r^=f|0}r!==t&&(t=r,(d=s.current)==null||d.syncAreas())})},[s])}function W2(s){x.useEffect(()=>{var n;(n=s.current)==null||n.syncBuildings();let e=0,t=0;return I.subscribe(()=>{var c,d;const o=I.getState().buildings;if(o.size!==e){e=o.size,t=Date.now(),(c=s.current)==null||c.syncBuildings();return}let r=0;for(const[h,p]of o){r^=p.position.x*1e3+p.position.z|0,r^=(p.scale||1)*1e4|0;const f=`${p.style||""}${p.name}${p.status}`;for(let g=0;g<f.length;g++)r=(r<<5)-r+f.charCodeAt(g)|0}r!==t&&(t=r,(d=s.current)==null||d.syncBuildings())})},[s])}function K2(s,e){x.useEffect(()=>{var t;(t=s.current)==null||t.highlightArea(e)},[s,e])}function V2(s,e){x.useEffect(()=>{var t;(t=s.current)==null||t.setPowerSaving(e)},[s,e])}function Y2({sceneRef:s,spawnModal:e,commanderModal:t,explorerModal:n,spotlightModal:i,deleteConfirmModal:o,onRequestBuildingDelete:r}){x.useEffect(()=>{const c=d=>{var z,T,R,D;const h=I.getShortcuts(),p=d.target,f=p.tagName==="INPUT"||p.tagName==="TEXTAREA",g=h.find(O=>O.id==="deselect-all");if(ut(d,g)){const O=I.getState();if(O.activeTool==="rectangle"||O.activeTool==="circle"){(z=s.current)==null||z.setDrawingTool(null),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(null);return}e.isOpen?e.close():O.terminalOpen?(I.setTerminalOpen(!1),document.activeElement instanceof HTMLElement&&document.activeElement.blur()):(I.deselectAll(),(T=s.current)==null||T.refreshSelectionVisuals())}for(let O=1;O<=9;O++){const P=h.find(K=>K.id===`select-agent-${O}`);if(ut(d,P)){d.preventDefault();const K=I.getState(),Y=O-1,$=Array.from(K.agents.keys());Y<$.length&&(I.selectAgent($[Y]),(R=s.current)==null||R.refreshSelectionVisuals());return}}const y=h.find(O=>O.id==="spawn-agent");if(ut(d,y)){d.preventDefault(),e.open();return}const v=h.find(O=>O.id==="toggle-commander-tab");if(ut(d,v)&&!f){d.preventDefault(),t.toggle();return}const w=h.find(O=>O.id==="toggle-commander");if(ut(d,w)){d.preventDefault(),t.toggle();return}const S=h.find(O=>O.id==="toggle-file-explorer");if(ut(d,S)){if(d.preventDefault(),n.isOpen)n.close();else{const O=Array.from(I.getState().areas.values()).filter(P=>P.directories&&P.directories.length>0);O.length>0&&n.open(O[0].id)}return}const C=h.find(O=>O.id==="toggle-spotlight");if(ut(d,C)||d.altKey&&!d.ctrlKey&&!d.metaKey&&d.code==="KeyP"){console.log("[useKeyboardShortcuts] Spotlight shortcut matched!",{spotlightShortcut:C,altKey:d.altKey,code:d.code}),d.preventDefault(),i.toggle();return}const A=h.find(O=>O.id==="toggle-2d-view");if(ut(d,A)){d.preventDefault();const O=I.getState().viewMode,P=O==="3d"?"2d":O==="2d"?"dashboard":"3d";I.setViewMode(P);return}const N=h.find(O=>O.id==="next-working-agent"),_=h.find(O=>O.id==="prev-working-agent");if((ut(d,N)||ut(d,_))&&!f){const O=I.getState();if(O.terminalOpen)return;const K=Array.from(O.agents.values()).filter(q=>q.status==="working");if(K.length===0)return;d.preventDefault();const Y=O.selectedAgentIds.size===1?Array.from(O.selectedAgentIds)[0]:null,$=Y?K.findIndex(q=>q.id===Y):-1;let L;ut(d,N)?L=$===-1?0:($+1)%K.length:L=$===-1?K.length-1:($-1+K.length)%K.length,I.selectAgent(K[L].id),(D=s.current)==null||D.refreshSelectionVisuals();return}const M=h.find(O=>O.id==="delete-selected"),E=h.find(O=>O.id==="delete-selected-backspace");if((ut(d,M)||ut(d,E))&&!f){const O=I.getState();if(O.selectedAgentIds.size>0){d.preventDefault(),o.open();return}if(O.selectedBuildingIds.size>0){d.preventDefault(),r();return}return}};return document.addEventListener("keydown",c,!0),()=>document.removeEventListener("keydown",c,!0)},[s,e,t,n,i,o,r])}function X2(){const[s,e]=x.useState(!1);return window.__tideSetBackNavModal=e,x.useEffect(()=>{if(!(window.innerWidth<=768))return;if(window.__tideBackNavSetup){window.location.hash.includes("app")||(window.location.hash="#app");return}window.__tideBackNavSetup=!0,window.location.hash.includes("app")||(window.location.hash="#app");const i=()=>{var r;window.innerWidth>768||window.location.hash.includes("app")||(window.location.hash="#app",Zx()||(r=window.__tideSetBackNavModal)==null||r.call(window,!0))},o=()=>{var r;window.innerWidth>768||(window.location.hash.includes("app")||(window.location.hash="#app"),window.location.hash==="#app"&&setTimeout(()=>{window.location.hash==="#app"&&!window.location.hash.includes("app2")&&(window.history.pushState(null,"","#app2"),window.history.pushState(null,"","#app"))},50),Zx()||(r=window.__tideSetBackNavModal)==null||r.call(window,!0))};window.history.pushState(null,"","#app1"),window.history.pushState(null,"","#app2"),window.history.pushState(null,"","#app"),window.addEventListener("hashchange",i),window.addEventListener("popstate",o)},[]),{showBackNavModal:s,setShowBackNavModal:e,handleLeave:()=>{e(!1);const n=window.__tideHistoryDepth??2;window.history.go(-(n+1))}}}const _m="agent-order-change";function Xk(s){const e=x.useMemo(()=>new Set(s.map(d=>d.id)),[s]),[t,n]=x.useState(()=>ca(at.AGENT_ORDER,[]));x.useEffect(()=>{const d=h=>{n(h.detail)};return window.addEventListener(_m,d),()=>{window.removeEventListener(_m,d)}},[]);const i=x.useMemo(()=>{const d=t.filter(g=>e.has(g)),h=s.filter(g=>!d.includes(g.id)).map(g=>g.id),p=[...d,...h],f=new Map(s.map(g=>[g.id,g]));return p.map(g=>f.get(g)).filter(g=>g!==void 0)},[s,t,e]),o=x.useCallback(d=>{n(d),Ia(at.AGENT_ORDER,d),window.dispatchEvent(new CustomEvent(_m,{detail:d}))},[]),r=x.useCallback((d,h)=>{const p=i.map(g=>g.id),[f]=p.splice(d,1);p.splice(h,0,f),o(p)},[i,o]),c=x.useCallback(()=>{n([]),Ia(at.AGENT_ORDER,[])},[]);return x.useEffect(()=>{if(e.size===0)return;const d=t.filter(h=>e.has(h));d.length!==t.length&&o(d)},[e,t,o]),{orderedAgents:i,moveAgent:r,resetOrder:c}}let ia,Ap;try{ia=require("@capacitor/core").Capacitor,Ap=require("@capacitor/core").CapacitorHttp}catch{}const ff="deivid11/tide-commander",Z2=`https://api.github.com/repos/${ff}/releases/latest`,Q2=`https://api.github.com/repos/${ff}/releases?per_page=3`,J2=3600*1e3,B0="app_update_dismissed_version",O0="0.53.4";function Zk(){var p;const[s,e]=x.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:O0}),t=((p=ia==null?void 0:ia.getPlatform)==null?void 0:p.call(ia))==="android"||!1,n=f=>f.replace(/^v/,"").split(".").map(y=>parseInt(y,10)||0),i=(f,g)=>{const y=n(f),v=n(g),w=Math.max(y.length,v.length);for(let S=0;S<w;S++){const C=y[S]||0,A=v[S]||0;if(C>A)return 1;if(C<A)return-1}return 0},o=async f=>{var y;if(ia&&Ap&&((y=ia.isNativePlatform)==null?void 0:y.call(ia))===!0){const v=await Ap.get({url:f,headers:{Accept:"application/vnd.github.v3+json"}});return{data:v.data,status:v.status}}else{const v=await fetch(f,{headers:{Accept:"application/vnd.github.v3+json"}});return v.ok?{data:await v.json(),status:v.status}:{data:null,status:v.status}}},r=x.useCallback(async(f=!1)=>{e(g=>({...g,isChecking:!0,error:null}));try{const[g,y]=await Promise.all([o(Z2),o(Q2)]);if(g.status!==200)throw new Error(`GitHub API error: ${g.status}`);const v=g.data,w=v.tag_name;let S=[];y.status===200&&y.data&&(S=y.data.map(M=>({version:M.tag_name,name:M.name,publishedAt:M.published_at,releaseUrl:M.html_url})));const C=localStorage.getItem(B0);if(!f&&C===w)return e(M=>({...M,isChecking:!1,updateAvailable:!1,recentReleases:S})),null;if(!(i(w,O0)>0))return e(M=>({...M,isChecking:!1,updateAvailable:!1,recentReleases:S})),null;const N=v.assets.find(M=>M.name.endsWith(".apk")&&M.content_type==="application/vnd.android.package-archive"),_={version:w,name:v.name,changelog:v.body,releaseUrl:v.html_url,apkUrl:(N==null?void 0:N.browser_download_url)||null,apkSize:(N==null?void 0:N.size)||null,publishedAt:v.published_at};return e(M=>({...M,isChecking:!1,updateAvailable:!0,updateInfo:_,recentReleases:S})),_}catch(g){const y=g instanceof Error?g.message:"Failed to check for updates";return e(v=>({...v,isChecking:!1,error:y})),null}},[]),c=x.useCallback(async()=>{var f,g,y;if(!((f=s.updateInfo)!=null&&f.apkUrl)){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!t){(y=s.updateInfo)!=null&&y.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),e(v=>({...v,error:null}))}catch(v){const w=v instanceof Error?v.message:"Failed to open download";e(S=>({...S,error:w}))}},[s.updateInfo,t]),d=x.useCallback(()=>{s.updateInfo&&localStorage.setItem(B0,s.updateInfo.version),e(f=>({...f,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),h=x.useCallback(()=>{var f;(f=s.updateInfo)!=null&&f.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${ff}/releases`,"_blank")},[s.updateInfo]);return x.useEffect(()=>{if(!t)return;const f=setTimeout(()=>{r()},5e3),g=setInterval(()=>{r()},J2);return()=>{clearTimeout(f),clearInterval(g)}},[t,r]),{...s,isAndroid:t,checkForUpdate:r,downloadAndInstall:c,dismissUpdate:d,openReleasePage:h}}function Us(s){const e=x.useRef(null),t=x.useCallback(i=>{e.current=i.target,i.target===i.currentTarget&&i.stopPropagation()},[]),n=x.useCallback(i=>{i.target===i.currentTarget&&e.current===i.currentTarget&&(i.stopPropagation(),s()),e.current=null},[s]);return{handleMouseDown:t,handleClick:n}}const P0={historyLimit:500,hideCost:!0,showFPS:!1,powerSaving:!1,customAgentNames:[],experimental2DView:!1,experimentalVoiceAssistant:!1,experimentalTTS:!1};function eE(s,e,t,n){return{setAgents(i){const o=new Map;for(const c of i)o.set(c.id,c),(c.class==="boss"||c.isBoss)&&console.log("[Store.setAgents] Boss agent:",c.name,"subordinateIds:",c.subordinateIds);const r=i.find(c=>c.status==="working");e(c=>{c.agents=o,r&&c.selectedAgentIds.size===0&&(c.selectedAgentIds.add(r.id),c.terminalOpen=!0)}),t()},addAgent(i){e(o=>{const r=new Map(o.agents);r.set(i.id,i),o.agents=r}),t()},updateAgent(i){var d;const r=s().agents.get(i.id),c=(r==null?void 0:r.status)!==i.status;c&&console.log(`[Store] Agent ${i.name} status update: ${r==null?void 0:r.status} → ${i.status}`),e(h=>{const p=new Map(h.agents);p.set(i.id,i),h.agents=p}),t(),c&&console.log(`[Store] Agent ${i.name} status now in store: ${(d=s().agents.get(i.id))==null?void 0:d.status}`)},updateAgentContextStats(i,o){const c=s().agents.get(i);c&&(e(d=>{const h=new Map(d.agents);h.set(i,{...c,contextStats:o,contextUsed:o.totalTokens,contextLimit:o.contextWindow}),d.agents=h}),t())},removeAgent(i){e(o=>{const r=new Map(o.agents);r.delete(i),o.agents=r,o.selectedAgentIds.delete(i),o.agentOutputs.delete(i)}),t()},selectAgent(i){e(o=>{o.selectedAgentIds.clear(),i&&(o.selectedAgentIds.add(i),o.lastSelectedAgentId=i),o.currentSnapshot=null}),t()},addToSelection(i){e(o=>{o.selectedAgentIds.has(i)?o.selectedAgentIds.delete(i):o.selectedAgentIds.add(i)}),t()},selectMultiple(i){e(o=>{o.selectedAgentIds.clear();for(const r of i)o.selectedAgentIds.add(r)}),t()},deselectAll(){e(i=>{i.selectedAgentIds.clear()}),t()},spawnAgent(i,o,r,c,d,h,p,f,g,y,v,w,S){console.log("[Store] spawnAgent called with:",{name:i,agentClass:o,cwd:r,position:c,sessionId:d,useChrome:h,permissionMode:p,initialSkillIds:f,provider:g,codexConfig:y,codexModel:v,model:w,customInstructions:S?`${S.length} chars`:void 0});const C=c?{x:c.x,y:0,z:c.z}:void 0,A={type:"spawn_agent",payload:{name:i,class:o,cwd:r,position:C,sessionId:d,useChrome:h,permissionMode:p,initialSkillIds:f,provider:g,codexConfig:y,codexModel:v,model:w,customInstructions:S}},N=n();if(!N){console.error("[Store] sendMessage is not defined! WebSocket may not be connected");return}N(A),console.log("[Store] Message sent to WebSocket")},createDirectoryAndSpawn(i,o,r){var c;(c=n())==null||c({type:"create_directory",payload:{path:i,name:o,class:r}})},sendCommand(i,o){var r;e(c=>{c.lastPrompts.set(i,{text:o,timestamp:Date.now()})}),t(),(r=n())==null||r({type:"send_command",payload:{agentId:i,command:o}})},refreshAgentContext(i){var o;(o=n())==null||o({type:"request_context_stats",payload:{agentId:i}})},moveAgent(i,o){var d;const c=s().agents.get(i);c&&(e(h=>{const p={...c,position:o},f=new Map(h.agents);f.set(i,p),h.agents=f}),t()),(d=n())==null||d({type:"move_agent",payload:{agentId:i,position:o}})},killAgent(i){var o;(o=n())==null||o({type:"kill_agent",payload:{agentId:i}})},stopAgent(i){var o;(o=n())==null||o({type:"stop_agent",payload:{agentId:i}})},clearContext(i){var o;(o=n())==null||o({type:"clear_context",payload:{agentId:i}}),e(r=>{const c=new Map(r.agentOutputs);c.delete(i),r.agentOutputs=c}),t()},collapseContext(i){var o;(o=n())==null||o({type:"collapse_context",payload:{agentId:i}})},removeAgentFromServer(i){var o;(o=n())==null||o({type:"remove_agent",payload:{agentId:i}})},renameAgent(i,o){var d;const c=s().agents.get(i);c&&(e(h=>{const p={...c,name:o},f=new Map(h.agents);f.set(i,p),h.agents=f}),t()),(d=n())==null||d({type:"rename_agent",payload:{agentId:i,name:o}})},updateAgentProperties(i,o){var d;const c=s().agents.get(i);c&&(e(h=>{const p={...c};o.class!==void 0&&(p.class=o.class),o.permissionMode!==void 0&&(p.permissionMode=o.permissionMode),o.model!==void 0&&(p.model=o.model),o.provider!==void 0&&(p.provider=o.provider),o.codexConfig!==void 0&&(p.codexConfig=o.codexConfig),o.codexModel!==void 0&&(p.codexModel=o.codexModel),o.useChrome!==void 0&&(p.useChrome=o.useChrome),o.cwd!==void 0&&(p.cwd=o.cwd);const f=new Map(h.agents);f.set(i,p),h.agents=f}),t()),(d=n())==null||d({type:"update_agent_properties",payload:{agentId:i,updates:o}})},getTotalTokens(){let i=0;for(const o of s().agents.values())i+=o.tokensUsed;return i},getSelectedAgents(){const i=s(),o=[];for(const r of i.selectedAgentIds){const c=i.agents.get(r);c&&o.push(c)}return o},addActivity(i){e(o=>{o.activities.unshift(i),o.activities.length>100&&o.activities.pop()}),t()},addToolExecution(i,o,r){const d=s().agents.get(i);e(h=>{h.toolExecutions.unshift({agentId:i,agentName:(d==null?void 0:d.name)||"Unknown",toolName:o,toolInput:r,timestamp:Date.now()}),h.toolExecutions.length>200&&h.toolExecutions.pop()}),t()},addFileChange(i,o,r){const d=s().agents.get(i);e(h=>{h.fileChanges.unshift({agentId:i,agentName:(d==null?void 0:d.name)||"Unknown",action:o,filePath:r,timestamp:Date.now()}),h.fileChanges.length>200&&h.fileChanges.pop()}),t()},async loadToolHistory(){try{const o=await(await Ct(lt("/api/agents/tool-history?limit=100"))).json();e(r=>{o.toolExecutions&&(r.toolExecutions=o.toolExecutions),o.fileChanges&&(r.fileChanges=o.fileChanges)}),t()}catch(i){console.error("[Store] Failed to load tool history:",i)}}}}function tE(s,e,t,n){return{addOutput(i,o){const r=n();e(c=>{const d=c.agentOutputs.get(i)||[];if(o.uuid&&d.some(g=>g.uuid===o.uuid))return;let h=[...d,o];h.length>200&&(h=h.slice(-200)),Bl.info(`Store: ${d.length} -> ${h.length}`,{agentId:i,text:o.text.slice(0,60),isStreaming:o.isStreaming,listeners:r},"store:addOutput");const p=new Map(c.agentOutputs);p.set(i,h),c.agentOutputs=p}),t()},clearOutputs(i){e(o=>{const r=new Map(o.agentOutputs);r.delete(i),o.agentOutputs=r}),t()},getOutputs(i){return s().agentOutputs.get(i)||[]},addUserPromptToOutput(i,o){this.addOutput(i,{text:o,isStreaming:!1,timestamp:Date.now(),isUserPrompt:!0})},getLastPrompt(i){return s().lastPrompts.get(i)},setLastPrompt(i,o){e(r=>{r.lastPrompts.set(i,{text:o,timestamp:Date.now()})}),t()},preserveOutputs(){const i=s(),o=new Map;for(const[r,c]of i.agentOutputs)o.set(r,c.map(d=>({...d})));return o},mergeOutputsWithHistory(i,o,r){const c=[...o,...r];return c.sort((d,h)=>d.timestamp-h.timestamp),e(d=>{const h=new Map(d.agentOutputs);h.set(i,c),d.agentOutputs=h}),t(),c}}}function sE(s,e,t,n){return{setSupervisorReport(i){e(o=>{o.supervisor.lastReport=i,o.supervisor.lastReportTime=i.timestamp;const r=new Map(o.supervisor.agentHistories);for(const c of i.agentSummaries){const d=r.get(c.agentId)||[],h={id:`${i.id}-${c.agentId}`,timestamp:i.timestamp,reportId:i.id,analysis:c};if(!d.some(p=>p.reportId===i.id)){const p=[h,...d];p.length>50&&p.pop(),r.set(c.agentId,p)}}o.supervisor.agentHistories=r,o.supervisor.generatingReport=!1}),t()},addNarrative(i,o){e(r=>{const c=r.supervisor.narratives.get(i)||[];c.unshift(o),c.length>50&&c.pop();const d=new Map(r.supervisor.narratives);d.set(i,c),r.supervisor.narratives=d}),t()},getNarratives(i){return s().supervisor.narratives.get(i)||[]},setSupervisorStatus(i){e(o=>{o.supervisor.enabled=i.enabled,i.autoReportOnComplete!==void 0&&(o.supervisor.autoReportOnComplete=i.autoReportOnComplete),o.supervisor.lastReportTime=i.lastReportTime,o.supervisor.nextReportTime=i.nextReportTime}),t()},setSupervisorConfig(i){var o;(o=n())==null||o({type:"set_supervisor_config",payload:i})},requestSupervisorReport(){var i;e(o=>{o.supervisor.generatingReport=!0}),t(),(i=n())==null||i({type:"request_supervisor_report",payload:{}})},requestAgentSupervisorHistory(i){var o;e(r=>{r.supervisor.loadingHistoryForAgent=i}),t(),(o=n())==null||o({type:"request_agent_supervisor_history",payload:{agentId:i}})},setAgentSupervisorHistory(i){e(o=>{const r=new Map(o.supervisor.agentHistories);r.set(i.agentId,i.entries),o.supervisor.agentHistories=r,o.supervisor.historyFetchedForAgents.add(i.agentId),o.supervisor.loadingHistoryForAgent===i.agentId&&(o.supervisor.loadingHistoryForAgent=null)}),t()},getAgentSupervisorHistory(i){return s().supervisor.agentHistories.get(i)||[]},addAgentAnalysis(i,o){e(r=>{const c=new Map(r.supervisor.agentHistories),d=c.get(i)||[],h={id:`single-${Date.now()}-${i}`,timestamp:Date.now(),reportId:`single-${Date.now()}`,analysis:o};if(!d.some(f=>Math.abs(f.timestamp-h.timestamp)<5e3&&f.analysis.statusDescription===o.statusDescription)){const f=[h,...d];f.length>50&&f.pop(),c.set(i,f),r.supervisor.agentHistories=c}}),t()},isLoadingHistoryForAgent(i){return s().supervisor.loadingHistoryForAgent===i},hasHistoryBeenFetched(i){return s().supervisor.historyFetchedForAgents.has(i)},setGlobalUsage(i){console.log("[Supervisor] setGlobalUsage called with:",i),e(o=>{o.supervisor.globalUsage=i,o.supervisor.refreshingUsage=!1}),t()},requestGlobalUsage(){console.log("[Supervisor] requestGlobalUsage called"),e(o=>{o.supervisor.refreshingUsage=!0}),t();const i=n();console.log("[Supervisor] sendMessage function:",i?"available":"null"),i?(console.log("[Supervisor] Sending request_global_usage message"),i({type:"request_global_usage",payload:{}})):console.warn("[Supervisor] Cannot send request_global_usage - no sendMessage function")},getGlobalUsage(){return s().supervisor.globalUsage}}}function nE(s,e,t,n){const i=()=>{var r;const o=Array.from(s().areas.values());(r=n())==null||r({type:"sync_areas",payload:o})};return{setActiveTool(o){e(r=>{r.activeTool=o,o!=="select"&&(r.selectedAreaId=null)}),t()},selectArea(o){e(r=>{r.selectedAreaId=o}),t()},addArea(o){if(o.zIndex===void 0||o.zIndex===null){const r=Array.from(s().areas.values()),c=r.length===0?-1:Math.max(...r.map(d=>d.zIndex??0));o.zIndex=c+1}e(r=>{r.areas.set(o.id,o)}),i(),t()},updateArea(o,r){s().areas.get(o)&&(e(h=>{Object.assign(h.areas.get(o),r)}),i(),t())},deleteArea(o){e(r=>{r.areas.delete(o),r.selectedAreaId===o&&(r.selectedAreaId=null)}),i(),t()},assignAgentToArea(o,r){const d=s().areas.get(r);d&&!d.assignedAgentIds.includes(o)&&(e(h=>{for(const p of h.areas.values()){const f=p.assignedAgentIds.indexOf(o);f!==-1&&p.assignedAgentIds.splice(f,1)}h.areas.get(r).assignedAgentIds.push(o)}),i(),t())},unassignAgentFromArea(o,r){const d=s().areas.get(r);if(d){const h=d.assignedAgentIds.indexOf(o);h!==-1&&(e(p=>{p.areas.get(r).assignedAgentIds.splice(h,1)}),i(),t())}},addDirectoryToArea(o,r){const d=s().areas.get(o);d&&!d.directories.includes(r)&&(e(h=>{h.areas.get(o).directories.push(r)}),i(),t())},removeDirectoryFromArea(o,r){const d=s().areas.get(o);if(d){const h=d.directories.indexOf(r);h!==-1&&(e(p=>{p.areas.get(o).directories.splice(h,1)}),i(),t())}},getAreaDirectories(o){const r=s().areas.get(o);return(r==null?void 0:r.directories)||[]},isPositionInArea(o,r){if(r.type==="rectangle"&&r.width&&r.height){const c=r.width/2,d=r.height/2;return o.x>=r.center.x-c&&o.x<=r.center.x+c&&o.z>=r.center.z-d&&o.z<=r.center.z+d}else if(r.type==="circle"&&r.radius){const c=o.x-r.center.x,d=o.z-r.center.z;return c*c+d*d<=r.radius*r.radius}return!1},getAreaForAgent(o){const r=s(),c=r.agents.get(o);if(!c)return null;for(const d of r.areas.values())if(this.isPositionInArea({x:c.position.x,z:c.position.z},d))return d;return null},setAreasFromServer(o){e(r=>{const c=new Map;for(let d=0;d<o.length;d++){const h=o[d];h.directories||(h.directories=[]),(h.zIndex===void 0||h.zIndex===null)&&(h.zIndex=d),h.archived===void 0&&(h.archived=!1),c.set(h.id,h)}r.areas=c}),t()},getAreasInZOrder(){return Array.from(s().areas.values()).sort((r,c)=>(r.zIndex??0)-(c.zIndex??0))},getNextZIndex(){const o=Array.from(s().areas.values());return o.length===0?0:Math.max(...o.map(c=>c.zIndex??0))+1},bringAreaToFront(o){const r=s(),c=r.areas.get(o);if(!c)return;const d=Array.from(r.areas.values()),h=d.length===0?-1:Math.max(...d.map(y=>y.zIndex??0)),p=h+1,f=c.zIndex??0,g=d.filter(y=>(y.zIndex??0)===h);f===h&&g.length===1||(e(y=>{y.areas.get(o).zIndex=p}),i(),t())},sendAreaToBack(o){const r=s(),c=r.areas.get(o);if(!c)return;const d=Array.from(r.areas.values()),h=Math.min(...d.map(g=>g.zIndex??0)),p=c.zIndex??0,f=d.filter(g=>(g.zIndex??0)===h);p===h&&f.length===1||(e(g=>{for(const y of g.areas.values())y.id!==o&&(y.zIndex=(y.zIndex??0)+1);g.areas.get(o).zIndex=0}),i(),t())},setAreaZIndex(o,r){s().areas.get(o)&&(e(h=>{h.areas.get(o).zIndex=r}),i(),t())},archiveArea(o,r){const d=s().areas.get(o);if(!(!d||d.archived)){if(r)for(const h of d.assignedAgentIds)r(h);e(h=>{const p=h.areas.get(o);p.archived=!0,p.archivedAt=Date.now(),p.originalCenter={...p.center},h.selectedAreaId===o&&(h.selectedAreaId=null)}),i(),t()}},restoreArchivedArea(o,r){const c=s(),d=c.areas.get(o);if(!d||!d.archived)return;const h=d.center,p=r||d.originalCenter||d.center,f=p.x-h.x,g=p.z-h.z,y=Array.from(c.areas.values()),w=(y.length===0?-1:Math.max(...y.map(S=>S.zIndex??0)))+1;e(S=>{const C=S.areas.get(o);if(C.archived=!1,C.archivedAt=void 0,C.center=p,C.zIndex=w,f!==0||g!==0)for(const A of C.assignedAgentIds){const N=S.agents.get(A);N&&(N.position={x:N.position.x+f,y:N.position.y,z:N.position.z+g})}}),i(),t()},getArchivedAreas(){return Array.from(s().areas.values()).filter(o=>o.archived===!0)},getVisibleAreas(){return Array.from(s().areas.values()).filter(o=>!o.archived)},isAgentInArchivedArea(o){const r=s();for(const c of r.areas.values())if(c.archived&&c.assignedAgentIds.includes(o))return!0;return!1}}}function aE(s,e,t,n){const i=()=>{var c;const r=Array.from(s().buildings.values());(c=n())==null||c({type:"sync_buildings",payload:r})},o={selectBuilding(r){e(c=>{c.selectedBuildingIds.clear(),r&&c.selectedBuildingIds.add(r)}),t()},selectMultipleBuildings(r){e(c=>{c.selectedBuildingIds.clear();for(const d of r)c.selectedBuildingIds.add(d)}),t()},toggleBuildingSelection(r){e(c=>{c.selectedBuildingIds.has(r)?c.selectedBuildingIds.delete(r):c.selectedBuildingIds.add(r)}),t()},isBuildingSelected(r){return s().selectedBuildingIds.has(r)},getSelectedBuildingIds(){return Array.from(s().selectedBuildingIds)},deleteSelectedBuildings(){var c,d,h;const r=s();for(const p of r.selectedBuildingIds){const f=r.buildings.get(p);((c=f==null?void 0:f.pm2)!=null&&c.enabled||(d=f==null?void 0:f.docker)!=null&&d.enabled)&&((h=n())==null||h({type:"building_command",payload:{buildingId:p,command:"delete"}}))}e(p=>{const f=new Map(p.buildings);for(const g of p.selectedBuildingIds)f.delete(g);p.buildings=f,p.selectedBuildingIds.clear()}),i(),t()},addBuilding(r){e(c=>{const d=new Map(c.buildings);d.set(r.id,r),c.buildings=d}),i(),t()},updateBuilding(r,c){const h=s().buildings.get(r);h&&(e(p=>{const f=new Map(p.buildings);f.set(r,{...h,...c}),p.buildings=f}),i(),t())},deleteBuilding(r){var h,p,f;const d=s().buildings.get(r);((h=d==null?void 0:d.pm2)!=null&&h.enabled||(p=d==null?void 0:d.docker)!=null&&p.enabled)&&((f=n())==null||f({type:"building_command",payload:{buildingId:r,command:"delete"}})),e(g=>{const y=new Map(g.buildings);y.delete(r),g.buildings=y,g.selectedBuildingIds.delete(r)}),i(),t()},moveBuilding(r,c){const h=s().buildings.get(r);h&&(e(p=>{const f=new Map(p.buildings);f.set(r,{...h,position:c}),p.buildings=f}),i(),t())},updateBuildingPosition(r,c){o.moveBuilding(r,c)},createBuilding(r){const c={...r,id:`building_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,status:"stopped",createdAt:Date.now()};o.addBuilding(c)},sendBuildingCommand(r,c){var d;(d=n())==null||d({type:"building_command",payload:{buildingId:r,command:c}})},addBuildingLogs(r,c){e(d=>{const p=[...d.buildingLogs.get(r)||[],c];p.length>500&&p.splice(0,p.length-500);const f=new Map(d.buildingLogs);f.set(r,p),d.buildingLogs=f}),t()},getBuildingLogs(r){return s().buildingLogs.get(r)||[]},clearBuildingLogs(r){e(c=>{const d=new Map(c.buildingLogs);d.delete(r),c.buildingLogs=d}),t()},setBuildingsFromServer(r){e(c=>{const d=new Map;for(const h of r)d.set(h.id,h);c.buildings=d}),t()},updateBuildingFromServer(r){e(c=>{const d=new Map(c.buildings);d.set(r.id,r),c.buildings=d}),t()},removeBuildingFromServer(r){e(c=>{const d=new Map(c.buildings);d.delete(r),c.buildings=d,c.selectedBuildingIds.delete(r)}),t()},startLogStreaming(r,c=100){var h,p,f;const d=s().buildings.get(r);e(g=>{const y=new Map(g.streamingBuildingLogs);y.set(r,""),g.streamingBuildingLogs=y}),(h=d==null?void 0:d.docker)!=null&&h.enabled?(p=n())==null||p({type:"docker_logs_start",payload:{buildingId:r,lines:c}}):(f=n())==null||f({type:"pm2_logs_start",payload:{buildingId:r,lines:c}})},stopLogStreaming(r){var d,h,p;const c=s().buildings.get(r);(d=c==null?void 0:c.docker)!=null&&d.enabled?(h=n())==null||h({type:"docker_logs_stop",payload:{buildingId:r}}):(p=n())==null||p({type:"pm2_logs_stop",payload:{buildingId:r}})},appendStreamingLogChunk(r,c){e(d=>{const h=d.streamingBuildingLogs.get(r)||"",p=500*1024;let f=h+c;if(f.length>p){const y=f.indexOf(`
|
|
140
|
+
`,side:wk});i.add(new ke(o,r)),i.add(new sf(16777215,1));const c=n.fromScene(i,.04).texture;t.environment=c,n.dispose(),o.dispose(),r.dispose()}createInputCallbacks(){return{onAgentClick:(e,t)=>this.inputEventHandlers.handleAgentClick(e,t),onAgentDoubleClick:e=>this.inputEventHandlers.handleAgentDoubleClick(e),onAgentHover:(e,t)=>this.inputEventHandlers.handleAgentHover(e,t),onGroundClick:()=>this.inputEventHandlers.handleGroundClick(),onMoveCommand:(e,t)=>this.inputEventHandlers.handleMoveCommand(e,t),onSelectionBox:(e,t)=>this.inputEventHandlers.handleSelectionBox(e,t),onDrawStart:e=>this.drawingManager.startDrawing(e),onDrawMove:e=>this.drawingManager.updateDrawing(e),onDrawEnd:e=>this.drawingManager.finishDrawing(e),onAreaRightClick:e=>this.inputEventHandlers.handleAreaRightClick(e),onResizeStart:(e,t)=>this.drawingManager.startResize(e,t),onResizeMove:e=>this.drawingManager.updateResize(e),onResizeEnd:()=>this.drawingManager.finishResize(),onGroundClickOutsideArea:()=>this.inputEventHandlers.handleGroundClickOutsideArea(),onBuildingClick:(e,t)=>this.inputEventHandlers.handleBuildingClick(e,t),onBuildingDoubleClick:e=>this.inputEventHandlers.handleBuildingDoubleClick(e),onBuildingHover:(e,t)=>this.inputEventHandlers.handleBuildingHover(e,t),onBuildingDragStart:()=>{},onBuildingDragMove:(e,t)=>this.buildingManager.setBuildingPosition(e,t),onBuildingDragEnd:(e,t)=>I.updateBuildingPosition(e,t),onContextMenu:(e,t,n)=>this.callbackManager.triggerContextMenu(e,t,n),onActivity:()=>this.renderLoop.markActivity(),onToggleTerminal:()=>I.toggleTerminal()}}setupInputHandlerHelpers(){this.inputHandler.setDrawingModeChecker(()=>this.drawingManager.isInDrawingMode()),this.inputHandler.setResizeHandlers(()=>this.drawingManager.getResizeHandles(),()=>this.drawingManager.isCurrentlyResizing()),this.inputHandler.setAreaAtPositionGetter(e=>this.drawingManager.getAreaAtPosition(e)),this.inputHandler.setBuildingAtPositionGetter(e=>{const t=this.buildingManager.getBuildingAtPosition(e);return t?{id:t.id}:null}),this.inputHandler.setBuildingPositionsGetter(()=>{const e=new Map;for(const[t,n]of this.buildingManager.getBuildingMeshData())e.set(t,n.group.position.clone());return e})}setupEventListeners(e){window.addEventListener("resize",this.onWindowResize),this.resizeObserver=new ResizeObserver(()=>this.onWindowResize()),e.parentElement&&this.resizeObserver.observe(e.parentElement),e.addEventListener("webglcontextlost",this.onContextLost),e.addEventListener("webglcontextrestored",this.onContextRestored)}updateInputHandlerReferences(){this.inputHandler.setReferences(this.battlefield.getGround(),this.agentManager.getAgentMeshes())}updateBattlefield(e,t){t-this.lastTimeUpdate>6e4&&(this.battlefield.updateTimeOfDay(),this.lastTimeUpdate=t),this.battlefield.updateGalacticAnimation(e),this.battlefield.updateCloudAnimation(e)}updateAnimations(e){const t=this.movementAnimator.update(this.agentManager.getAgentMeshes(),e);return this.effectsManager.update(),this.buildingManager.update(e),t}updateProceduralAnimations(e){if(this.proceduralBodiesDirty){this.proceduralBodiesCache.clear();for(const[t,n]of this.agentManager.getAgentMeshes())if(this.proceduralAnimator.has(t)&&n.animations.size===0){const i=n.group.getObjectByName("characterBody");i&&this.proceduralBodiesCache.set(t,i)}this.proceduralBodiesDirty=!1}this.proceduralBodiesCache.size>0&&this.proceduralAnimator.update(e,this.proceduralBodiesCache)}updateIndicatorScales(e,t,n){for(const[,i]of t){const o=e.position.distanceTo(i.group.position),r=Math.max(.5,Math.min(2.5,o/15))*n,c=i.group.userData.isBoss===!0,d=i.group.getObjectByName("statusBar"),h=i.group.getObjectByName("nameLabelSprite");if(d){const f=c?2:1.6,g=2560/4096;d.scale.set(f*r,f*g*r,1)}if(h){const f=c?2.5:2,g=1024/8192;h.scale.set(f*r,f*g*r,1)}const p=i.group.getObjectByName("combinedUI");if(p){const f=c?2:1.6,g=1024/2048;p.scale.set(f*r,f*g*r,1)}if(!d&&!p){const f=i.group.getObjectByName("nameLabel");if(f){const v=.3*r;f.scale.set(v*(f.userData.aspectRatio||2),v,1)}const g=i.group.getObjectByName("manaBar");g&&g.scale.set(.9,.14,1);const y=i.group.getObjectByName("idleTimer");y&&y.scale.set(.9*r,.14*r,1)}}for(const[,i]of this.buildingManager.getBuildingMeshData()){const o=e.position.distanceTo(i.group.position),r=Math.max(.5,Math.min(2.5,o/15))*n,c=i.group.getObjectByName("buildingLabel");if(c){const d=.3*r;c.scale.set(d*(c.userData.aspectRatio||2),d,1)}}this.effectsManager.updateWithCamera(e)}async loadCharacterModels(){await this.agentManager.loadCharacterModels()}upgradeAgentModels(){this.agentManager.upgradeAgentModels(),this.updateInputHandlerReferences()}addAgent(e){this.agentManager.addAgent(e)}removeAgent(e){this.agentManager.removeAgent(e),this.updateInputHandlerReferences()}updateAgent(e,t=!1){this.agentManager.updateAgent(e,t)}syncAgents(e){this.agentManager.syncAgents(e)}setCustomAgentClasses(e){this.agentManager.setCustomAgentClasses(e)}refreshSelectionVisuals(){this.selectionManager.refreshSelectionVisuals()}createMoveOrderEffect(e){this.effectsManager.createMoveOrderEffect(e)}showToolBubble(e,t,n){this.effectsManager.setAgentMeshes(this.agentManager.getAgentMeshes()),this.effectsManager.createSpeechBubble(e,t,n)}showDelegationEffect(e,t){this.effectsManager.setAgentMeshes(this.agentManager.getAgentMeshes()),this.effectsManager.createDelegationEffect(e,t)}addSubagentEffect(e,t,n,i){this.effectsManager.setAgentMeshes(this.agentManager.getAgentMeshes()),this.effectsManager.addSubagentEffect(e,t,n,i)}completeSubagentEffect(e){this.effectsManager.completeSubagentEffect(e)}removeSubagentEffect(e){this.effectsManager.removeSubagentEffect(e)}focusAgent(e){this.cameraManager.focusAgent(e)}callSubordinates(e){var r;const n=I.getState().agents.get(e);if(!n||!(n.isBoss||n.class==="boss")||!((r=n.subordinateIds)!=null&&r.length))return;const i=new nt(n.position.x,n.position.y,n.position.z),o=this.inputHandler.calculateFormationPositions(i,n.subordinateIds.length);this.effectsManager.createMoveOrderEffect(i.clone()),n.subordinateIds.forEach((c,d)=>{const h=this.agentManager.getAgentMeshes().get(c);I.moveAgent(c,o[d]),h&&this.movementAnimator.startMovement(c,h,o[d])})}setDrawingTool(e){this.drawingManager.setTool(e),I.setActiveTool(e)}syncAreas(){this.drawingManager.syncFromStore()}highlightArea(e){this.drawingManager.highlightArea(e)}clearAreaSelection(){this.drawingManager.highlightArea(null)}addBuilding(e){this.buildingManager.addBuilding(e)}removeBuilding(e){this.buildingManager.removeBuilding(e)}updateBuilding(e){this.buildingManager.updateBuilding(e)}syncBuildings(){this.buildingManager.syncFromStore()}highlightBuilding(e){this.buildingManager.highlightBuilding(e)}setOnBuildingClick(e){this.callbackManager.setOnBuildingClick(e)}setOnBuildingDoubleClick(e){this.callbackManager.setOnBuildingDoubleClick(e)}setOnContextMenu(e){this.callbackManager.setOnContextMenu(e)}setOnAgentHover(e){this.callbackManager.setOnAgentHover(e)}setOnBuildingHover(e){this.callbackManager.setOnBuildingHover(e)}setOnGroundClick(e){this.callbackManager.setOnGroundClick(e)}setOnToast(e){this.agentManager.setOnToast(e)}setCharacterScale(e){this.agentManager.setCharacterScale(e),this.selectionManager.setCharacterScale(e)}setIndicatorScale(e){this.renderLoop.setIndicatorScale(e),this.effectsManager.setIndicatorScale(e)}setFpsLimit(e){this.renderLoop.setFpsLimit(e)}setPowerSaving(e){this.renderLoop.setPowerSaving(e)}setGridVisible(e){this.battlefield.setGridVisible(e)}setDebugTime(e){this.battlefield.setDebugTime(e)}setTimeMode(e){this.battlefield.setTimeMode(e)}setTerrainConfig(e){this.battlefield.setTerrainConfig(e),e.brightness!==void 0&&(this.drawingManager.setBrightness(e.brightness),this.buildingManager.setBrightness(e.brightness),this.agentManager.setBrightness(e.brightness))}setFloorStyle(e,t=!1){this.battlefield.setFloorStyle(e,t)}setIdleAnimation(e){this.agentManager.setIdleAnimation(e)}setWorkingAnimation(e){this.agentManager.setWorkingAnimation(e)}setAgentModelStyle(e){this.agentManager.setModelStyle(e)}getAgentModelStyle(){return this.agentManager.getModelStyle()}setGlobalSaturation(e){this.sceneCore.setSaturation(e)}getGlobalSaturation(){return this.sceneCore.getSaturation()}setPostProcessingEnabled(e){this.sceneCore.setPostProcessingEnabled(e)}reattach(e,t){var o,r;console.log("[SceneManager] Reattaching to new canvas (HMR)"),this.isReattaching=!0,this.renderLoop.stop(),(o=this.resizeObserver)==null||o.disconnect();const n=this.sceneCore.getCanvas();n.removeEventListener("webglcontextlost",this.onContextLost),n.removeEventListener("webglcontextrestored",this.onContextRestored),this.sceneCore.reattach(e),this.cameraManager.recreateControls(this.sceneCore.getRenderer()),this.sceneCore.updateCamera(this.cameraManager.getCamera()),e.addEventListener("webglcontextlost",this.onContextLost),e.addEventListener("webglcontextrestored",this.onContextRestored),this.inputHandler.reattach(e,t,this.cameraManager.getControls()),this.updateInputHandlerReferences(),e.parentElement&&((r=this.resizeObserver)==null||r.observe(e.parentElement)),this.onWindowResize();const i=(c=0)=>{this.isReattaching=!1,e.isConnected&&this.sceneCore.getRenderer()?(console.log("[SceneManager] Restarting animation loop after HMR reattach"),this.renderLoop.start()):c<10?(console.log(`[SceneManager] Canvas not connected, retrying... (attempt ${c+1})`),this.isReattaching=!0,requestAnimationFrame(()=>i(c+1))):console.warn("[SceneManager] Failed to restart animation loop - canvas never connected")};requestAnimationFrame(()=>i())}getMemoryDiagnostics(){var t;const e=this.sceneCore.getRenderer().info;return{threeJs:e!=null&&e.memory?{geometries:e.memory.geometries,textures:e.memory.textures,programs:((t=e.programs)==null?void 0:t.length)??0}:null,heap:_N.getUsage(),agentMeshCount:this.agentManager.getAgentMeshes().size,bossLineCount:0}}getRenderStats(){var t,n;const e=(n=(t=this.sceneCore.getRenderer())==null?void 0:t.info)==null?void 0:n.render;return e?{calls:e.calls,triangles:e.triangles,points:e.points,lines:e.lines}:null}get renderer(){return this.sceneCore.getRenderer()}logMemoryDiagnostics(){const e=this.getMemoryDiagnostics(),t=this.characterLoader.getCacheStats();console.group("%c[SceneManager Memory]","color: #ff6600; font-weight: bold"),e.threeJs&&console.log(`Three.js: ${e.threeJs.geometries} geometries, ${e.threeJs.textures} textures, ${e.threeJs.programs} programs`),e.heap&&console.log(`Heap: ${e.heap.usedMB}MB / ${e.heap.totalMB}MB (limit: ${e.heap.limitMB}MB)`),console.log(`Agent meshes: ${e.agentMeshCount}`),console.log(`CharacterLoader cache: ${t.builtInModels} built-in, ${t.customModels} custom`),t.modelNames.length>0&&console.log(` Built-in models: ${t.modelNames.join(", ")}`),t.customModelIds.length>0&&console.log(` Custom models: ${t.customModelIds.join(", ")}`),console.groupEnd()}dispose(){var n;console.log("%c[SceneManager] dispose() called - starting cleanup","color: #ff0000; font-weight: bold");const e=this.characterLoader.getCacheStats();console.log(`[SceneManager] Pre-dispose: ${e.builtInModels} built-in models, ${e.customModels} custom models`),this.renderLoop.stop(),window.removeEventListener("resize",this.onWindowResize);const t=this.sceneCore.getCanvas();t.removeEventListener("webglcontextlost",this.onContextLost),t.removeEventListener("webglcontextrestored",this.onContextRestored),(n=this.resizeObserver)==null||n.disconnect(),this.resizeObserver=null,this.inputHandler.dispose(),this.drawingManager.dispose(),this.buildingManager.dispose(),this.effectsManager.dispose(),this.agentManager.dispose(),this.selectionManager.dispose(),this.battlefield.dispose(),this.characterLoader.dispose(),this.cameraManager.dispose(),this.sceneCore.dispose(),console.log("%c[SceneManager] dispose() complete - all resources freed","color: #00ff00; font-weight: bold")}}const Du="tide_webgl_active";typeof window<"u"&&(window.__tidePersistedScene===void 0&&(window.__tidePersistedScene=null),window.__tidePersistedCanvas===void 0&&(window.__tidePersistedCanvas=null),window.__tideWsConnected===void 0&&(window.__tideWsConnected=!1),window.__tideIsPageUnloading===void 0&&(window.__tideIsPageUnloading=!1));function Qu(){return typeof window<"u"?window.__tidePersistedScene??null:null}function Wk(){return typeof window<"u"?window.__tidePersistedCanvas??null:null}function E2(){return typeof window<"u"?window.__tideWsConnected??!1:!1}function Pl(s){typeof window<"u"&&(window.__tidePersistedScene=s)}function Lu(s){typeof window<"u"&&(window.__tidePersistedCanvas=s)}function Kk(s){typeof window<"u"&&(window.__tideWsConnected=s)}function _2(s){typeof window<"u"&&(window.__tideIsPageUnloading=s)}function R2(){sessionStorage.setItem(Du,"true")}function pu(s){_2(!0),sessionStorage.removeItem(Du),Bk(),AN(),window.__tideScene&&(window.__tideScene=null);const e=Qu();e?(console.log("[App] Calling persistedScene.dispose()"),e.dispose(),Pl(null)):console.log("[App] No persistedScene to dispose"),Lu(null),Kk(!1);const t=document.getElementById("battlefield");t&&t.remove();const n=document.getElementById("app");n&&(n.innerHTML="")}function D2(){var i,o;if(window.__tideAppInitialized)return;if(window.__tideAppInitialized=!0,sessionStorage.getItem(Du)==="true"&&console.log("[App] Detected unclean shutdown from previous session - forcing cleanup"),window.__tideScene){console.log("[App] Cleaning up stale __tideScene reference");try{(o=(i=window.__tideScene).dispose)==null||o.call(i)}catch{}window.__tideScene=null}const e=Qu();if(e){console.log("[App] Cleaning up stale persistedScene");try{e.dispose()}catch{}Pl(null)}const t=document.getElementById("battlefield"),n=Wk();t&&t!==n&&t.remove(),sessionStorage.removeItem(Du)}function L2(){typeof window>"u"||(D2(),window.addEventListener("pageshow",s=>{s.persisted&&(console.log("[App] Page restored from bfcache - cleaning up"),pu(),window.location.reload())}),window.onunload=()=>pu(),window.onbeforeunload=s=>{if(pu(),window.innerWidth<=768)return s.preventDefault(),""},window.addEventListener("pagehide",s=>{pu(`pagehide (persisted=${s.persisted})`)}))}L2();const R0={showTrees:!0,showBushes:!0,showHouse:!0,showLamps:!0,showGrass:!0,showClouds:!0,fogDensity:1,floorStyle:"concrete",brightness:1,skyColor:null},D0={saturation:2,roughness:.5,metalness:-1,emissiveBoost:0,envMapIntensity:1,wireframe:!1,colorMode:"normal"},L0={idleAnimation:"sit",workingAnimation:"sprint"},B2=0;function Vk(){const s={characterScale:2,indicatorScale:1,gridVisible:!0,timeMode:"day",terrain:R0,modelStyle:D0,animations:L0,fpsLimit:B2},e=ca(at.CONFIG,null);return e?{characterScale:e.characterScale??s.characterScale,indicatorScale:e.indicatorScale??s.indicatorScale,gridVisible:e.gridVisible??s.gridVisible,timeMode:e.timeMode??s.timeMode,terrain:{...R0,...e.terrain},modelStyle:{...D0,...e.modelStyle},animations:{...L0,...e.animations},fpsLimit:e.fpsLimit??s.fpsLimit}:s}function O2(s){Ia(at.CONFIG,s)}typeof window<"u"&&!window.__tideHmrRefreshListeners&&(window.__tideHmrRefreshListeners=new Set);function Yk(){console.log("[Tide HMR] Manual scene refresh triggered");const s=Qu();if(s){try{s.dispose()}catch(t){console.warn("[Tide HMR] Error disposing scene:",t)}Pl(null)}Lu(null),window.__tideScene&&(window.__tideScene=null);const e=document.getElementById("battlefield");if(e){const t=e.getContext("webgl2")||e.getContext("webgl");if(t){const n=t.getExtension("WEBGL_lose_context");n&&n.loseContext()}}window.__tideHmrPendingSceneChanges=!1,window.location.reload()}typeof window<"u"&&(window.__tideHmrSceneRefresh=Yk);function P2({canvasRef:s,selectionBoxRef:e,showToast:t,showAgentNotification:n,toolboxModal:i,contextMenu:o,setHoveredAgentPopup:r,setBuildingPopup:c,getBuildingPopup:d,openBuildingModal:h,openPM2LogsModal:p,openBossLogsModal:f,openDatabasePanel:g}){const y=x.useRef(null),v=x.useRef(null),w=x.useRef(null);return x.useEffect(()=>{if(!s.current||!e.current)return;let S=!1;const C=Qu(),N=Wk()===s.current;function _(){var M,E,z,T,R,D,O;(M=y.current)==null||M.setOnToast(t),(E=y.current)==null||E.setOnBuildingClick((P,K)=>{I.selectBuilding(P);const Y=I.getState().buildings.get(P);(Y==null?void 0:Y.type)==="folder"&&Y.folderPath?I.openFileExplorer(Y.folderPath):(Y==null?void 0:Y.type)==="server"||(Y==null?void 0:Y.type)==="boss"||(Y==null?void 0:Y.type)==="database"?(v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{c({buildingId:P,screenPos:K,fromClick:!0}),v.current=null},150)):h(P)}),(z=y.current)==null||z.setOnContextMenu((P,K,Y)=>{o.open(P,K,Y)}),(T=y.current)==null||T.setOnAgentHover(()=>{}),(R=y.current)==null||R.setOnBuildingHover((P,K)=>{const Y=d();if(P&&K){const $=I.getState().buildings.get(P);(($==null?void 0:$.type)==="server"||($==null?void 0:$.type)==="boss"||($==null?void 0:$.type)==="database")&&!(Y!=null&&Y.fromClick)&&c({buildingId:P,screenPos:K,fromClick:!1})}else Y!=null&&Y.fromClick||c(null)}),(D=y.current)==null||D.setOnGroundClick(()=>{c(null)}),(O=y.current)==null||O.setOnBuildingDoubleClick(P=>{var Y;v.current&&(clearTimeout(v.current),v.current=null),c(null);const K=I.getState().buildings.get(P);(K==null?void 0:K.type)==="server"&&((Y=K.pm2)!=null&&Y.enabled)?p==null||p(P):(K==null?void 0:K.type)==="boss"?f==null||f(P):(K==null?void 0:K.type)==="database"?g==null||g(P):(K==null?void 0:K.type)==="folder"&&K.folderPath?I.openFileExplorer(K.folderPath):h(P)})}if(C&&N){y.current=C,console.log("[Tide] Reusing existing scene (StrictMode remount)");const M=I.getState();C.syncAreas(),C.syncBuildings(),M.agents.size>0&&(console.log("[Tide] Re-syncing agents from store after remount:",M.agents.size),C.syncAgents(Array.from(M.agents.values()))),_()}else{const M=s.current,E=e.current,z=()=>{if(S){console.log("[Tide] Effect cleaned up before scene init, skipping");return}if(!M.isConnected||!E.isConnected){console.warn("[Tide] Canvas disconnected before initialization");return}(!M.clientWidth||!M.clientHeight)&&(console.log("[Tide] Canvas has no CSS dimensions, using window fallback"),M.style.width="100%",M.style.height="100%",M.offsetHeight),(!M.clientWidth||!M.clientHeight)&&(M.width=window.innerWidth,M.height=window.innerHeight),R2();try{const T=new M2(M,E);y.current=T,Pl(T),Lu(M);const R=Vk();T.setCharacterScale(R.characterScale),T.setIndicatorScale(R.indicatorScale),T.setGridVisible(R.gridVisible),T.setTimeMode(R.timeMode),T.setTerrainConfig(R.terrain),T.setFloorStyle(R.terrain.floorStyle,!0),T.setAgentModelStyle(R.modelStyle),T.setIdleAnimation(R.animations.idleAnimation),T.setWorkingAnimation(R.animations.workingAnimation),T.setFpsLimit(R.fpsLimit),T.syncAreas(),T.syncBuildings(),T.loadCharacterModels().then(()=>{console.log("[Tide] Character models ready");const D=I.getState();D.customAgentClasses.size>0&&(console.log("[Tide] Applying custom classes from store:",D.customAgentClasses.size),T.setCustomAgentClasses(D.customAgentClasses)),D.agents.size>0&&(console.log("[Tide] Syncing agents from store:",D.agents.size),T.syncAgents(Array.from(D.agents.values()))),T.upgradeAgentModels()}).catch(D=>{console.warn("[Tide] Some models failed to load, using fallback:",D)}),_()}catch(T){console.error("[Tide] Failed to initialize 3D scene:",T)}};w.current=requestAnimationFrame(z)}return _k({onAgentCreated:M=>{var E,z;(E=y.current)==null||E.addAgent(M),(z=window.__spawnModalSuccess)==null||z.call(window)},onAgentUpdated:(M,E)=>{var z;(z=y.current)==null||z.updateAgent(M,E)},onAgentDeleted:M=>{var E;(E=y.current)==null||E.removeAgent(M)},onAgentsSync:M=>{var E;(E=y.current)==null||E.syncAgents(M)},onAreasSync:()=>{var E,z;(E=y.current)==null||E.syncAreas();const M=Array.from(I.getState().agents.values());(z=y.current)==null||z.syncAgents(M)},onSpawnError:()=>{var M;(M=window.__spawnModalError)==null||M.call(window)},onSpawnSuccess:()=>{var M;(M=window.__spawnModalSuccess)==null||M.call(window)},onDirectoryNotFound:M=>{var E;(E=window.__spawnModalDirNotFound)==null||E.call(window,M)},onToolUse:(M,E,z)=>{var T;(T=y.current)==null||T.showToolBubble(M,E,z)},onDelegation:(M,E)=>{var z;(z=y.current)==null||z.showDelegationEffect(M,E)},onCustomClassesSync:M=>{var E,z;(E=y.current)==null||E.setCustomAgentClasses(M),(z=y.current)==null||z.upgradeAgentModels()},onBuildingUpdated:M=>{var E;(E=y.current)==null||E.updateBuilding(M)},onSubagentStarted:M=>{var E;(E=y.current)==null||E.addSubagentEffect(M.id,M.parentAgentId,M.name,M.subagentType)},onSubagentCompleted:M=>{var T;const E=I.getSubagent(M)||I.getSubagentByToolUseId(M),z=(E==null?void 0:E.id)||M;(T=y.current)==null||T.completeSubagentEffect(z),setTimeout(()=>{var R;(R=y.current)==null||R.removeSubagentEffect(z)},3e4)}}),()=>{var M;S=!0,w.current!==null&&(cancelAnimationFrame(w.current),w.current=null),!((M=s.current)!=null&&M.isConnected)&&y.current&&(console.log("[Tide] 3D canvas unmounted - disposing scene to free memory"),NN(),y.current.dispose(),y.current=null,Pl(null),Lu(null))}},[s.current,e.current]),y}let Il,er;try{Il=require("@capacitor/local-notifications").LocalNotifications,er=require("@capacitor/core").Capacitor}catch{}let I2=1;const z2="agent_alerts";function pf(){var s;return((s=er==null?void 0:er.isNativePlatform)==null?void 0:s.call(er))??!1}async function F2(){return pf()?(await Il.requestPermissions()).display==="granted":"Notification"in window?await Notification.requestPermission()==="granted":!1}async function H2(s){const{title:e,body:t,icon:n,data:i}=s;pf()?await Il.schedule({notifications:[{id:I2++,title:e,body:t,schedule:{at:new Date(Date.now()+100)},extra:i,channelId:z2,smallIcon:"ic_launcher",autoCancel:!0}]}):"Notification"in window&&Notification.permission==="granted"&&new Notification(e,{body:t,icon:n,data:i})}async function $2(s){pf()&&Il&&await Il.addListener("localNotificationActionPerformed",e=>{s&&e.notification.extra&&s(e.notification.extra)})}function U2({showToast:s,showAgentNotification:e}){const t=x.useRef(!1);x.useEffect(()=>{if(t.current||E2())return;t.current=!0,_k({onToast:s,onReconnect:()=>{I.triggerReconnect()},onAgentNotification:i=>{e(i)}}),Ol(),Kk(!0),F2(),$2(i=>{i.agentId&&typeof i.agentId=="string"&&I.selectAgent(i.agentId)});const n=()=>{console.log("[Tide] App resumed from background, reconnecting..."),setTimeout(()=>Ol(),100)};return window.addEventListener("tideAppResume",n),()=>{window.removeEventListener("tideAppResume",n)}},[s,e])}function G2(s){x.useEffect(()=>{let e="",t="",n=new Map;const i=o=>{var d;let r=!1;const c=new Map;for(const[h,p]of o){const g=`${p.position.x.toFixed(2)},${p.position.z.toFixed(2)},${p.status},${p.class},${p.isBoss},${((d=p.subordinateIds)==null?void 0:d.length)??0}`.split("").reduce((y,v)=>(y<<5)-y+v.charCodeAt(0),0);c.set(h,g),n.get(h)!==g&&(r=!0)}return c.size!==n.size&&(r=!0),{newVersion:c,changed:r}};return I.subscribe(()=>{var g;const o=I.getState(),r=Array.from(o.selectedAgentIds).sort().join(","),c=Array.from(o.selectedBuildingIds).sort().join(","),d=r!==e,h=c!==t,{newVersion:p,changed:f}=i(o.agents);(d||h||f)&&(e=r,t=c,n=p,(g=s.current)==null||g.refreshSelectionVisuals())})},[s])}function q2(s){x.useEffect(()=>{var n;(n=s.current)==null||n.syncAreas();let e=0,t=0;return I.subscribe(()=>{var c,d;const o=I.getState().areas;if(o.size!==e){e=o.size,t=Date.now(),(c=s.current)==null||c.syncAreas();return}let r=0;for(const[h,p]of o){let f=h.charCodeAt(0);f+=(p.width??0)+(p.height??0)+(p.radius??0),f+=Math.floor(p.center.x*100)+Math.floor(p.center.z*100),f+=(p.zIndex??0)*1e3;for(let g=0;g<p.name.length;g++)f+=p.name.charCodeAt(g);for(let g=0;g<p.color.length;g++)f+=p.color.charCodeAt(g);r^=f|0}r!==t&&(t=r,(d=s.current)==null||d.syncAreas())})},[s])}function W2(s){x.useEffect(()=>{var n;(n=s.current)==null||n.syncBuildings();let e=0,t=0;return I.subscribe(()=>{var c,d;const o=I.getState().buildings;if(o.size!==e){e=o.size,t=Date.now(),(c=s.current)==null||c.syncBuildings();return}let r=0;for(const[h,p]of o){r^=p.position.x*1e3+p.position.z|0,r^=(p.scale||1)*1e4|0;const f=`${p.style||""}${p.name}${p.status}`;for(let g=0;g<f.length;g++)r=(r<<5)-r+f.charCodeAt(g)|0}r!==t&&(t=r,(d=s.current)==null||d.syncBuildings())})},[s])}function K2(s,e){x.useEffect(()=>{var t;(t=s.current)==null||t.highlightArea(e)},[s,e])}function V2(s,e){x.useEffect(()=>{var t;(t=s.current)==null||t.setPowerSaving(e)},[s,e])}function Y2({sceneRef:s,spawnModal:e,commanderModal:t,explorerModal:n,spotlightModal:i,deleteConfirmModal:o,onRequestBuildingDelete:r}){x.useEffect(()=>{const c=d=>{var z,T,R,D;const h=I.getShortcuts(),p=d.target,f=p.tagName==="INPUT"||p.tagName==="TEXTAREA",g=h.find(O=>O.id==="deselect-all");if(ut(d,g)){const O=I.getState();if(O.activeTool==="rectangle"||O.activeTool==="circle"){(z=s.current)==null||z.setDrawingTool(null),typeof window<"u"&&window.__tideScene2D_setDrawingTool&&window.__tideScene2D_setDrawingTool(null);return}e.isOpen?e.close():O.terminalOpen?(I.setTerminalOpen(!1),document.activeElement instanceof HTMLElement&&document.activeElement.blur()):(I.deselectAll(),(T=s.current)==null||T.refreshSelectionVisuals())}for(let O=1;O<=9;O++){const P=h.find(K=>K.id===`select-agent-${O}`);if(ut(d,P)){d.preventDefault();const K=I.getState(),Y=O-1,$=Array.from(K.agents.keys());Y<$.length&&(I.selectAgent($[Y]),(R=s.current)==null||R.refreshSelectionVisuals());return}}const y=h.find(O=>O.id==="spawn-agent");if(ut(d,y)){d.preventDefault(),e.open();return}const v=h.find(O=>O.id==="toggle-commander-tab");if(ut(d,v)&&!f){d.preventDefault(),t.toggle();return}const w=h.find(O=>O.id==="toggle-commander");if(ut(d,w)){d.preventDefault(),t.toggle();return}const S=h.find(O=>O.id==="toggle-file-explorer");if(ut(d,S)){if(d.preventDefault(),n.isOpen)n.close();else{const O=Array.from(I.getState().areas.values()).filter(P=>P.directories&&P.directories.length>0);O.length>0&&n.open(O[0].id)}return}const C=h.find(O=>O.id==="toggle-spotlight");if(ut(d,C)||d.altKey&&!d.ctrlKey&&!d.metaKey&&d.code==="KeyP"){console.log("[useKeyboardShortcuts] Spotlight shortcut matched!",{spotlightShortcut:C,altKey:d.altKey,code:d.code}),d.preventDefault(),i.toggle();return}const A=h.find(O=>O.id==="toggle-2d-view");if(ut(d,A)){d.preventDefault();const O=I.getState().viewMode,P=O==="3d"?"2d":O==="2d"?"dashboard":"3d";I.setViewMode(P);return}const N=h.find(O=>O.id==="next-working-agent"),_=h.find(O=>O.id==="prev-working-agent");if((ut(d,N)||ut(d,_))&&!f){const O=I.getState();if(O.terminalOpen)return;const K=Array.from(O.agents.values()).filter(q=>q.status==="working");if(K.length===0)return;d.preventDefault();const Y=O.selectedAgentIds.size===1?Array.from(O.selectedAgentIds)[0]:null,$=Y?K.findIndex(q=>q.id===Y):-1;let L;ut(d,N)?L=$===-1?0:($+1)%K.length:L=$===-1?K.length-1:($-1+K.length)%K.length,I.selectAgent(K[L].id),(D=s.current)==null||D.refreshSelectionVisuals();return}const M=h.find(O=>O.id==="delete-selected"),E=h.find(O=>O.id==="delete-selected-backspace");if((ut(d,M)||ut(d,E))&&!f){const O=I.getState();if(O.selectedAgentIds.size>0){d.preventDefault(),o.open();return}if(O.selectedBuildingIds.size>0){d.preventDefault(),r();return}return}};return document.addEventListener("keydown",c,!0),()=>document.removeEventListener("keydown",c,!0)},[s,e,t,n,i,o,r])}function X2(){const[s,e]=x.useState(!1);return window.__tideSetBackNavModal=e,x.useEffect(()=>{if(!(window.innerWidth<=768))return;if(window.__tideBackNavSetup){window.location.hash.includes("app")||(window.location.hash="#app");return}window.__tideBackNavSetup=!0,window.location.hash.includes("app")||(window.location.hash="#app");const i=()=>{var r;window.innerWidth>768||window.location.hash.includes("app")||(window.location.hash="#app",Zx()||(r=window.__tideSetBackNavModal)==null||r.call(window,!0))},o=()=>{var r;window.innerWidth>768||(window.location.hash.includes("app")||(window.location.hash="#app"),window.location.hash==="#app"&&setTimeout(()=>{window.location.hash==="#app"&&!window.location.hash.includes("app2")&&(window.history.pushState(null,"","#app2"),window.history.pushState(null,"","#app"))},50),Zx()||(r=window.__tideSetBackNavModal)==null||r.call(window,!0))};window.history.pushState(null,"","#app1"),window.history.pushState(null,"","#app2"),window.history.pushState(null,"","#app"),window.addEventListener("hashchange",i),window.addEventListener("popstate",o)},[]),{showBackNavModal:s,setShowBackNavModal:e,handleLeave:()=>{e(!1);const n=window.__tideHistoryDepth??2;window.history.go(-(n+1))}}}const _m="agent-order-change";function Xk(s){const e=x.useMemo(()=>new Set(s.map(d=>d.id)),[s]),[t,n]=x.useState(()=>ca(at.AGENT_ORDER,[]));x.useEffect(()=>{const d=h=>{n(h.detail)};return window.addEventListener(_m,d),()=>{window.removeEventListener(_m,d)}},[]);const i=x.useMemo(()=>{const d=t.filter(g=>e.has(g)),h=s.filter(g=>!d.includes(g.id)).map(g=>g.id),p=[...d,...h],f=new Map(s.map(g=>[g.id,g]));return p.map(g=>f.get(g)).filter(g=>g!==void 0)},[s,t,e]),o=x.useCallback(d=>{n(d),Ia(at.AGENT_ORDER,d),window.dispatchEvent(new CustomEvent(_m,{detail:d}))},[]),r=x.useCallback((d,h)=>{const p=i.map(g=>g.id),[f]=p.splice(d,1);p.splice(h,0,f),o(p)},[i,o]),c=x.useCallback(()=>{n([]),Ia(at.AGENT_ORDER,[])},[]);return x.useEffect(()=>{if(e.size===0)return;const d=t.filter(h=>e.has(h));d.length!==t.length&&o(d)},[e,t,o]),{orderedAgents:i,moveAgent:r,resetOrder:c}}let ia,Ap;try{ia=require("@capacitor/core").Capacitor,Ap=require("@capacitor/core").CapacitorHttp}catch{}const ff="deivid11/tide-commander",Z2=`https://api.github.com/repos/${ff}/releases/latest`,Q2=`https://api.github.com/repos/${ff}/releases?per_page=3`,J2=3600*1e3,B0="app_update_dismissed_version",O0="0.54.0";function Zk(){var p;const[s,e]=x.useState({isChecking:!1,updateAvailable:!1,updateInfo:null,recentReleases:[],error:null,currentVersion:O0}),t=((p=ia==null?void 0:ia.getPlatform)==null?void 0:p.call(ia))==="android"||!1,n=f=>f.replace(/^v/,"").split(".").map(y=>parseInt(y,10)||0),i=(f,g)=>{const y=n(f),v=n(g),w=Math.max(y.length,v.length);for(let S=0;S<w;S++){const C=y[S]||0,A=v[S]||0;if(C>A)return 1;if(C<A)return-1}return 0},o=async f=>{var y;if(ia&&Ap&&((y=ia.isNativePlatform)==null?void 0:y.call(ia))===!0){const v=await Ap.get({url:f,headers:{Accept:"application/vnd.github.v3+json"}});return{data:v.data,status:v.status}}else{const v=await fetch(f,{headers:{Accept:"application/vnd.github.v3+json"}});return v.ok?{data:await v.json(),status:v.status}:{data:null,status:v.status}}},r=x.useCallback(async(f=!1)=>{e(g=>({...g,isChecking:!0,error:null}));try{const[g,y]=await Promise.all([o(Z2),o(Q2)]);if(g.status!==200)throw new Error(`GitHub API error: ${g.status}`);const v=g.data,w=v.tag_name;let S=[];y.status===200&&y.data&&(S=y.data.map(M=>({version:M.tag_name,name:M.name,publishedAt:M.published_at,releaseUrl:M.html_url})));const C=localStorage.getItem(B0);if(!f&&C===w)return e(M=>({...M,isChecking:!1,updateAvailable:!1,recentReleases:S})),null;if(!(i(w,O0)>0))return e(M=>({...M,isChecking:!1,updateAvailable:!1,recentReleases:S})),null;const N=v.assets.find(M=>M.name.endsWith(".apk")&&M.content_type==="application/vnd.android.package-archive"),_={version:w,name:v.name,changelog:v.body,releaseUrl:v.html_url,apkUrl:(N==null?void 0:N.browser_download_url)||null,apkSize:(N==null?void 0:N.size)||null,publishedAt:v.published_at};return e(M=>({...M,isChecking:!1,updateAvailable:!0,updateInfo:_,recentReleases:S})),_}catch(g){const y=g instanceof Error?g.message:"Failed to check for updates";return e(v=>({...v,isChecking:!1,error:y})),null}},[]),c=x.useCallback(async()=>{var f,g,y;if(!((f=s.updateInfo)!=null&&f.apkUrl)){(g=s.updateInfo)!=null&&g.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}if(!t){(y=s.updateInfo)!=null&&y.releaseUrl&&window.open(s.updateInfo.releaseUrl,"_blank");return}try{window.open(s.updateInfo.apkUrl,"_system"),e(v=>({...v,error:null}))}catch(v){const w=v instanceof Error?v.message:"Failed to open download";e(S=>({...S,error:w}))}},[s.updateInfo,t]),d=x.useCallback(()=>{s.updateInfo&&localStorage.setItem(B0,s.updateInfo.version),e(f=>({...f,updateAvailable:!1,updateInfo:null}))},[s.updateInfo]),h=x.useCallback(()=>{var f;(f=s.updateInfo)!=null&&f.releaseUrl?window.open(s.updateInfo.releaseUrl,"_blank"):window.open(`https://github.com/${ff}/releases`,"_blank")},[s.updateInfo]);return x.useEffect(()=>{if(!t)return;const f=setTimeout(()=>{r()},5e3),g=setInterval(()=>{r()},J2);return()=>{clearTimeout(f),clearInterval(g)}},[t,r]),{...s,isAndroid:t,checkForUpdate:r,downloadAndInstall:c,dismissUpdate:d,openReleasePage:h}}function Us(s){const e=x.useRef(null),t=x.useCallback(i=>{e.current=i.target,i.target===i.currentTarget&&i.stopPropagation()},[]),n=x.useCallback(i=>{i.target===i.currentTarget&&e.current===i.currentTarget&&(i.stopPropagation(),s()),e.current=null},[s]);return{handleMouseDown:t,handleClick:n}}const P0={historyLimit:500,hideCost:!0,showFPS:!1,powerSaving:!1,customAgentNames:[],experimental2DView:!1,experimentalVoiceAssistant:!1,experimentalTTS:!1};function eE(s,e,t,n){return{setAgents(i){const o=new Map;for(const c of i)o.set(c.id,c),(c.class==="boss"||c.isBoss)&&console.log("[Store.setAgents] Boss agent:",c.name,"subordinateIds:",c.subordinateIds);const r=i.find(c=>c.status==="working");e(c=>{c.agents=o,r&&c.selectedAgentIds.size===0&&(c.selectedAgentIds.add(r.id),c.terminalOpen=!0)}),t()},addAgent(i){e(o=>{const r=new Map(o.agents);r.set(i.id,i),o.agents=r}),t()},updateAgent(i){var d;const r=s().agents.get(i.id),c=(r==null?void 0:r.status)!==i.status;c&&console.log(`[Store] Agent ${i.name} status update: ${r==null?void 0:r.status} → ${i.status}`),e(h=>{const p=new Map(h.agents);p.set(i.id,i),h.agents=p}),t(),c&&console.log(`[Store] Agent ${i.name} status now in store: ${(d=s().agents.get(i.id))==null?void 0:d.status}`)},updateAgentContextStats(i,o){const c=s().agents.get(i);c&&(e(d=>{const h=new Map(d.agents);h.set(i,{...c,contextStats:o,contextUsed:o.totalTokens,contextLimit:o.contextWindow}),d.agents=h}),t())},removeAgent(i){e(o=>{const r=new Map(o.agents);r.delete(i),o.agents=r,o.selectedAgentIds.delete(i),o.agentOutputs.delete(i)}),t()},selectAgent(i){e(o=>{o.selectedAgentIds.clear(),i&&(o.selectedAgentIds.add(i),o.lastSelectedAgentId=i),o.currentSnapshot=null}),t()},addToSelection(i){e(o=>{o.selectedAgentIds.has(i)?o.selectedAgentIds.delete(i):o.selectedAgentIds.add(i)}),t()},selectMultiple(i){e(o=>{o.selectedAgentIds.clear();for(const r of i)o.selectedAgentIds.add(r)}),t()},deselectAll(){e(i=>{i.selectedAgentIds.clear()}),t()},spawnAgent(i,o,r,c,d,h,p,f,g,y,v,w,S){console.log("[Store] spawnAgent called with:",{name:i,agentClass:o,cwd:r,position:c,sessionId:d,useChrome:h,permissionMode:p,initialSkillIds:f,provider:g,codexConfig:y,codexModel:v,model:w,customInstructions:S?`${S.length} chars`:void 0});const C=c?{x:c.x,y:0,z:c.z}:void 0,A={type:"spawn_agent",payload:{name:i,class:o,cwd:r,position:C,sessionId:d,useChrome:h,permissionMode:p,initialSkillIds:f,provider:g,codexConfig:y,codexModel:v,model:w,customInstructions:S}},N=n();if(!N){console.error("[Store] sendMessage is not defined! WebSocket may not be connected");return}N(A),console.log("[Store] Message sent to WebSocket")},createDirectoryAndSpawn(i,o,r){var c;(c=n())==null||c({type:"create_directory",payload:{path:i,name:o,class:r}})},sendCommand(i,o){var r;e(c=>{c.lastPrompts.set(i,{text:o,timestamp:Date.now()})}),t(),(r=n())==null||r({type:"send_command",payload:{agentId:i,command:o}})},refreshAgentContext(i){var o;(o=n())==null||o({type:"request_context_stats",payload:{agentId:i}})},moveAgent(i,o){var d;const c=s().agents.get(i);c&&(e(h=>{const p={...c,position:o},f=new Map(h.agents);f.set(i,p),h.agents=f}),t()),(d=n())==null||d({type:"move_agent",payload:{agentId:i,position:o}})},killAgent(i){var o;(o=n())==null||o({type:"kill_agent",payload:{agentId:i}})},stopAgent(i){var o;(o=n())==null||o({type:"stop_agent",payload:{agentId:i}})},clearContext(i){var o;(o=n())==null||o({type:"clear_context",payload:{agentId:i}}),e(r=>{const c=new Map(r.agentOutputs);c.delete(i),r.agentOutputs=c}),t()},collapseContext(i){var o;(o=n())==null||o({type:"collapse_context",payload:{agentId:i}})},removeAgentFromServer(i){var o;(o=n())==null||o({type:"remove_agent",payload:{agentId:i}})},renameAgent(i,o){var d;const c=s().agents.get(i);c&&(e(h=>{const p={...c,name:o},f=new Map(h.agents);f.set(i,p),h.agents=f}),t()),(d=n())==null||d({type:"rename_agent",payload:{agentId:i,name:o}})},updateAgentProperties(i,o){var d;const c=s().agents.get(i);c&&(e(h=>{const p={...c};o.class!==void 0&&(p.class=o.class),o.permissionMode!==void 0&&(p.permissionMode=o.permissionMode),o.model!==void 0&&(p.model=o.model),o.provider!==void 0&&(p.provider=o.provider),o.codexConfig!==void 0&&(p.codexConfig=o.codexConfig),o.codexModel!==void 0&&(p.codexModel=o.codexModel),o.useChrome!==void 0&&(p.useChrome=o.useChrome),o.cwd!==void 0&&(p.cwd=o.cwd);const f=new Map(h.agents);f.set(i,p),h.agents=f}),t()),(d=n())==null||d({type:"update_agent_properties",payload:{agentId:i,updates:o}})},getTotalTokens(){let i=0;for(const o of s().agents.values())i+=o.tokensUsed;return i},getSelectedAgents(){const i=s(),o=[];for(const r of i.selectedAgentIds){const c=i.agents.get(r);c&&o.push(c)}return o},addActivity(i){e(o=>{o.activities.unshift(i),o.activities.length>100&&o.activities.pop()}),t()},addToolExecution(i,o,r){const d=s().agents.get(i);e(h=>{h.toolExecutions.unshift({agentId:i,agentName:(d==null?void 0:d.name)||"Unknown",toolName:o,toolInput:r,timestamp:Date.now()}),h.toolExecutions.length>200&&h.toolExecutions.pop()}),t()},addFileChange(i,o,r){const d=s().agents.get(i);e(h=>{h.fileChanges.unshift({agentId:i,agentName:(d==null?void 0:d.name)||"Unknown",action:o,filePath:r,timestamp:Date.now()}),h.fileChanges.length>200&&h.fileChanges.pop()}),t()},async loadToolHistory(){try{const o=await(await Ct(lt("/api/agents/tool-history?limit=100"))).json();e(r=>{o.toolExecutions&&(r.toolExecutions=o.toolExecutions),o.fileChanges&&(r.fileChanges=o.fileChanges)}),t()}catch(i){console.error("[Store] Failed to load tool history:",i)}}}}function tE(s,e,t,n){return{addOutput(i,o){const r=n();e(c=>{const d=c.agentOutputs.get(i)||[];if(o.uuid&&d.some(g=>g.uuid===o.uuid))return;let h=[...d,o];h.length>200&&(h=h.slice(-200)),Bl.info(`Store: ${d.length} -> ${h.length}`,{agentId:i,text:o.text.slice(0,60),isStreaming:o.isStreaming,listeners:r},"store:addOutput");const p=new Map(c.agentOutputs);p.set(i,h),c.agentOutputs=p}),t()},clearOutputs(i){e(o=>{const r=new Map(o.agentOutputs);r.delete(i),o.agentOutputs=r}),t()},getOutputs(i){return s().agentOutputs.get(i)||[]},addUserPromptToOutput(i,o){this.addOutput(i,{text:o,isStreaming:!1,timestamp:Date.now(),isUserPrompt:!0})},getLastPrompt(i){return s().lastPrompts.get(i)},setLastPrompt(i,o){e(r=>{r.lastPrompts.set(i,{text:o,timestamp:Date.now()})}),t()},preserveOutputs(){const i=s(),o=new Map;for(const[r,c]of i.agentOutputs)o.set(r,c.map(d=>({...d})));return o},mergeOutputsWithHistory(i,o,r){const c=[...o,...r];return c.sort((d,h)=>d.timestamp-h.timestamp),e(d=>{const h=new Map(d.agentOutputs);h.set(i,c),d.agentOutputs=h}),t(),c}}}function sE(s,e,t,n){return{setSupervisorReport(i){e(o=>{o.supervisor.lastReport=i,o.supervisor.lastReportTime=i.timestamp;const r=new Map(o.supervisor.agentHistories);for(const c of i.agentSummaries){const d=r.get(c.agentId)||[],h={id:`${i.id}-${c.agentId}`,timestamp:i.timestamp,reportId:i.id,analysis:c};if(!d.some(p=>p.reportId===i.id)){const p=[h,...d];p.length>50&&p.pop(),r.set(c.agentId,p)}}o.supervisor.agentHistories=r,o.supervisor.generatingReport=!1}),t()},addNarrative(i,o){e(r=>{const c=r.supervisor.narratives.get(i)||[];c.unshift(o),c.length>50&&c.pop();const d=new Map(r.supervisor.narratives);d.set(i,c),r.supervisor.narratives=d}),t()},getNarratives(i){return s().supervisor.narratives.get(i)||[]},setSupervisorStatus(i){e(o=>{o.supervisor.enabled=i.enabled,i.autoReportOnComplete!==void 0&&(o.supervisor.autoReportOnComplete=i.autoReportOnComplete),o.supervisor.lastReportTime=i.lastReportTime,o.supervisor.nextReportTime=i.nextReportTime}),t()},setSupervisorConfig(i){var o;(o=n())==null||o({type:"set_supervisor_config",payload:i})},requestSupervisorReport(){var i;e(o=>{o.supervisor.generatingReport=!0}),t(),(i=n())==null||i({type:"request_supervisor_report",payload:{}})},requestAgentSupervisorHistory(i){var o;e(r=>{r.supervisor.loadingHistoryForAgent=i}),t(),(o=n())==null||o({type:"request_agent_supervisor_history",payload:{agentId:i}})},setAgentSupervisorHistory(i){e(o=>{const r=new Map(o.supervisor.agentHistories);r.set(i.agentId,i.entries),o.supervisor.agentHistories=r,o.supervisor.historyFetchedForAgents.add(i.agentId),o.supervisor.loadingHistoryForAgent===i.agentId&&(o.supervisor.loadingHistoryForAgent=null)}),t()},getAgentSupervisorHistory(i){return s().supervisor.agentHistories.get(i)||[]},addAgentAnalysis(i,o){e(r=>{const c=new Map(r.supervisor.agentHistories),d=c.get(i)||[],h={id:`single-${Date.now()}-${i}`,timestamp:Date.now(),reportId:`single-${Date.now()}`,analysis:o};if(!d.some(f=>Math.abs(f.timestamp-h.timestamp)<5e3&&f.analysis.statusDescription===o.statusDescription)){const f=[h,...d];f.length>50&&f.pop(),c.set(i,f),r.supervisor.agentHistories=c}}),t()},isLoadingHistoryForAgent(i){return s().supervisor.loadingHistoryForAgent===i},hasHistoryBeenFetched(i){return s().supervisor.historyFetchedForAgents.has(i)},setGlobalUsage(i){console.log("[Supervisor] setGlobalUsage called with:",i),e(o=>{o.supervisor.globalUsage=i,o.supervisor.refreshingUsage=!1}),t()},requestGlobalUsage(){console.log("[Supervisor] requestGlobalUsage called"),e(o=>{o.supervisor.refreshingUsage=!0}),t();const i=n();console.log("[Supervisor] sendMessage function:",i?"available":"null"),i?(console.log("[Supervisor] Sending request_global_usage message"),i({type:"request_global_usage",payload:{}})):console.warn("[Supervisor] Cannot send request_global_usage - no sendMessage function")},getGlobalUsage(){return s().supervisor.globalUsage}}}function nE(s,e,t,n){const i=()=>{var r;const o=Array.from(s().areas.values());(r=n())==null||r({type:"sync_areas",payload:o})};return{setActiveTool(o){e(r=>{r.activeTool=o,o!=="select"&&(r.selectedAreaId=null)}),t()},selectArea(o){e(r=>{r.selectedAreaId=o}),t()},addArea(o){if(o.zIndex===void 0||o.zIndex===null){const r=Array.from(s().areas.values()),c=r.length===0?-1:Math.max(...r.map(d=>d.zIndex??0));o.zIndex=c+1}e(r=>{r.areas.set(o.id,o)}),i(),t()},updateArea(o,r){s().areas.get(o)&&(e(h=>{Object.assign(h.areas.get(o),r)}),i(),t())},deleteArea(o){e(r=>{r.areas.delete(o),r.selectedAreaId===o&&(r.selectedAreaId=null)}),i(),t()},assignAgentToArea(o,r){const d=s().areas.get(r);d&&!d.assignedAgentIds.includes(o)&&(e(h=>{for(const p of h.areas.values()){const f=p.assignedAgentIds.indexOf(o);f!==-1&&p.assignedAgentIds.splice(f,1)}h.areas.get(r).assignedAgentIds.push(o)}),i(),t())},unassignAgentFromArea(o,r){const d=s().areas.get(r);if(d){const h=d.assignedAgentIds.indexOf(o);h!==-1&&(e(p=>{p.areas.get(r).assignedAgentIds.splice(h,1)}),i(),t())}},addDirectoryToArea(o,r){const d=s().areas.get(o);d&&!d.directories.includes(r)&&(e(h=>{h.areas.get(o).directories.push(r)}),i(),t())},removeDirectoryFromArea(o,r){const d=s().areas.get(o);if(d){const h=d.directories.indexOf(r);h!==-1&&(e(p=>{p.areas.get(o).directories.splice(h,1)}),i(),t())}},getAreaDirectories(o){const r=s().areas.get(o);return(r==null?void 0:r.directories)||[]},isPositionInArea(o,r){if(r.type==="rectangle"&&r.width&&r.height){const c=r.width/2,d=r.height/2;return o.x>=r.center.x-c&&o.x<=r.center.x+c&&o.z>=r.center.z-d&&o.z<=r.center.z+d}else if(r.type==="circle"&&r.radius){const c=o.x-r.center.x,d=o.z-r.center.z;return c*c+d*d<=r.radius*r.radius}return!1},getAreaForAgent(o){const r=s(),c=r.agents.get(o);if(!c)return null;for(const d of r.areas.values())if(this.isPositionInArea({x:c.position.x,z:c.position.z},d))return d;return null},setAreasFromServer(o){e(r=>{const c=new Map;for(let d=0;d<o.length;d++){const h=o[d];h.directories||(h.directories=[]),(h.zIndex===void 0||h.zIndex===null)&&(h.zIndex=d),h.archived===void 0&&(h.archived=!1),c.set(h.id,h)}r.areas=c}),t()},getAreasInZOrder(){return Array.from(s().areas.values()).sort((r,c)=>(r.zIndex??0)-(c.zIndex??0))},getNextZIndex(){const o=Array.from(s().areas.values());return o.length===0?0:Math.max(...o.map(c=>c.zIndex??0))+1},bringAreaToFront(o){const r=s(),c=r.areas.get(o);if(!c)return;const d=Array.from(r.areas.values()),h=d.length===0?-1:Math.max(...d.map(y=>y.zIndex??0)),p=h+1,f=c.zIndex??0,g=d.filter(y=>(y.zIndex??0)===h);f===h&&g.length===1||(e(y=>{y.areas.get(o).zIndex=p}),i(),t())},sendAreaToBack(o){const r=s(),c=r.areas.get(o);if(!c)return;const d=Array.from(r.areas.values()),h=Math.min(...d.map(g=>g.zIndex??0)),p=c.zIndex??0,f=d.filter(g=>(g.zIndex??0)===h);p===h&&f.length===1||(e(g=>{for(const y of g.areas.values())y.id!==o&&(y.zIndex=(y.zIndex??0)+1);g.areas.get(o).zIndex=0}),i(),t())},setAreaZIndex(o,r){s().areas.get(o)&&(e(h=>{h.areas.get(o).zIndex=r}),i(),t())},archiveArea(o,r){const d=s().areas.get(o);if(!(!d||d.archived)){if(r)for(const h of d.assignedAgentIds)r(h);e(h=>{const p=h.areas.get(o);p.archived=!0,p.archivedAt=Date.now(),p.originalCenter={...p.center},h.selectedAreaId===o&&(h.selectedAreaId=null)}),i(),t()}},restoreArchivedArea(o,r){const c=s(),d=c.areas.get(o);if(!d||!d.archived)return;const h=d.center,p=r||d.originalCenter||d.center,f=p.x-h.x,g=p.z-h.z,y=Array.from(c.areas.values()),w=(y.length===0?-1:Math.max(...y.map(S=>S.zIndex??0)))+1;e(S=>{const C=S.areas.get(o);if(C.archived=!1,C.archivedAt=void 0,C.center=p,C.zIndex=w,f!==0||g!==0)for(const A of C.assignedAgentIds){const N=S.agents.get(A);N&&(N.position={x:N.position.x+f,y:N.position.y,z:N.position.z+g})}}),i(),t()},getArchivedAreas(){return Array.from(s().areas.values()).filter(o=>o.archived===!0)},getVisibleAreas(){return Array.from(s().areas.values()).filter(o=>!o.archived)},isAgentInArchivedArea(o){const r=s();for(const c of r.areas.values())if(c.archived&&c.assignedAgentIds.includes(o))return!0;return!1}}}function aE(s,e,t,n){const i=()=>{var c;const r=Array.from(s().buildings.values());(c=n())==null||c({type:"sync_buildings",payload:r})},o={selectBuilding(r){e(c=>{c.selectedBuildingIds.clear(),r&&c.selectedBuildingIds.add(r)}),t()},selectMultipleBuildings(r){e(c=>{c.selectedBuildingIds.clear();for(const d of r)c.selectedBuildingIds.add(d)}),t()},toggleBuildingSelection(r){e(c=>{c.selectedBuildingIds.has(r)?c.selectedBuildingIds.delete(r):c.selectedBuildingIds.add(r)}),t()},isBuildingSelected(r){return s().selectedBuildingIds.has(r)},getSelectedBuildingIds(){return Array.from(s().selectedBuildingIds)},deleteSelectedBuildings(){var c,d,h;const r=s();for(const p of r.selectedBuildingIds){const f=r.buildings.get(p);((c=f==null?void 0:f.pm2)!=null&&c.enabled||(d=f==null?void 0:f.docker)!=null&&d.enabled)&&((h=n())==null||h({type:"building_command",payload:{buildingId:p,command:"delete"}}))}e(p=>{const f=new Map(p.buildings);for(const g of p.selectedBuildingIds)f.delete(g);p.buildings=f,p.selectedBuildingIds.clear()}),i(),t()},addBuilding(r){e(c=>{const d=new Map(c.buildings);d.set(r.id,r),c.buildings=d}),i(),t()},updateBuilding(r,c){const h=s().buildings.get(r);h&&(e(p=>{const f=new Map(p.buildings);f.set(r,{...h,...c}),p.buildings=f}),i(),t())},deleteBuilding(r){var h,p,f;const d=s().buildings.get(r);((h=d==null?void 0:d.pm2)!=null&&h.enabled||(p=d==null?void 0:d.docker)!=null&&p.enabled)&&((f=n())==null||f({type:"building_command",payload:{buildingId:r,command:"delete"}})),e(g=>{const y=new Map(g.buildings);y.delete(r),g.buildings=y,g.selectedBuildingIds.delete(r)}),i(),t()},moveBuilding(r,c){const h=s().buildings.get(r);h&&(e(p=>{const f=new Map(p.buildings);f.set(r,{...h,position:c}),p.buildings=f}),i(),t())},updateBuildingPosition(r,c){o.moveBuilding(r,c)},createBuilding(r){const c={...r,id:`building_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,status:"stopped",createdAt:Date.now()};o.addBuilding(c)},sendBuildingCommand(r,c){var d;(d=n())==null||d({type:"building_command",payload:{buildingId:r,command:c}})},addBuildingLogs(r,c){e(d=>{const p=[...d.buildingLogs.get(r)||[],c];p.length>500&&p.splice(0,p.length-500);const f=new Map(d.buildingLogs);f.set(r,p),d.buildingLogs=f}),t()},getBuildingLogs(r){return s().buildingLogs.get(r)||[]},clearBuildingLogs(r){e(c=>{const d=new Map(c.buildingLogs);d.delete(r),c.buildingLogs=d}),t()},setBuildingsFromServer(r){e(c=>{const d=new Map;for(const h of r)d.set(h.id,h);c.buildings=d}),t()},updateBuildingFromServer(r){e(c=>{const d=new Map(c.buildings);d.set(r.id,r),c.buildings=d}),t()},removeBuildingFromServer(r){e(c=>{const d=new Map(c.buildings);d.delete(r),c.buildings=d,c.selectedBuildingIds.delete(r)}),t()},startLogStreaming(r,c=100){var h,p,f;const d=s().buildings.get(r);e(g=>{const y=new Map(g.streamingBuildingLogs);y.set(r,""),g.streamingBuildingLogs=y}),(h=d==null?void 0:d.docker)!=null&&h.enabled?(p=n())==null||p({type:"docker_logs_start",payload:{buildingId:r,lines:c}}):(f=n())==null||f({type:"pm2_logs_start",payload:{buildingId:r,lines:c}})},stopLogStreaming(r){var d,h,p;const c=s().buildings.get(r);(d=c==null?void 0:c.docker)!=null&&d.enabled?(h=n())==null||h({type:"docker_logs_stop",payload:{buildingId:r}}):(p=n())==null||p({type:"pm2_logs_stop",payload:{buildingId:r}})},appendStreamingLogChunk(r,c){e(d=>{const h=d.streamingBuildingLogs.get(r)||"",p=500*1024;let f=h+c;if(f.length>p){const y=f.indexOf(`
|
|
141
141
|
`,f.length-p);y>0?f=f.slice(y+1):f=f.slice(-p)}const g=new Map(d.streamingBuildingLogs);g.set(r,f),d.streamingBuildingLogs=g}),t()},setStreamingStatus(r,c){e(d=>{const h=new Set(d.streamingBuildingIds);c?h.add(r):h.delete(r),d.streamingBuildingIds=h}),t()},getStreamingLogs(r){return s().streamingBuildingLogs.get(r)||""},clearStreamingLogs(r){e(c=>{const d=new Map(c.streamingBuildingLogs);d.delete(r),c.streamingBuildingLogs=d}),t()},isLogStreaming(r){return s().streamingBuildingIds.has(r)},sendBossBuildingCommand(r,c){var d;(d=n())==null||d({type:"boss_building_command",payload:{buildingId:r,command:c}})},assignBuildingsToBoSS(r,c){var p;const h=s().buildings.get(r);h&&(e(f=>{const g=new Map(f.buildings);g.set(r,{...h,subordinateBuildingIds:c}),f.buildings=g}),i(),t()),(p=n())==null||p({type:"assign_buildings",payload:{bossBuildingId:r,subordinateBuildingIds:c}})},startBossLogStreaming(r,c=50){var d;e(h=>{const p=new Map(h.bossStreamingLogs);p.set(r,[]),h.bossStreamingLogs=p}),(d=n())==null||d({type:"boss_building_logs_start",payload:{buildingId:r,lines:c}})},stopBossLogStreaming(r){var c;(c=n())==null||c({type:"boss_building_logs_stop",payload:{buildingId:r}})},appendBossStreamingLogChunk(r,c,d,h,p){e(f=>{const g=f.bossStreamingLogs.get(r)||[],y={subordinateId:c,subordinateName:d,chunk:h,timestamp:Date.now(),isError:p},v=[...g,y];v.length>1e3&&v.splice(0,v.length-1e3);const w=new Map(f.bossStreamingLogs);w.set(r,v),f.bossStreamingLogs=w}),t()},getBossStreamingLogs(r){return s().bossStreamingLogs.get(r)||[]},clearBossStreamingLogs(r){e(c=>{const d=new Map(c.bossStreamingLogs);d.delete(r),c.bossStreamingLogs=d}),t()},requestDockerContainersList(){var r;(r=n())==null||r({type:"docker_list_containers",payload:{}})},setDockerContainersList(r,c){e(d=>{d.dockerContainersList=r,d.dockerComposeProjectsList=c}),t()},getDockerContainersList(){return s().dockerContainersList},getDockerComposeProjectsList(){return s().dockerComposeProjectsList}};return o}function iE(s,e,t,n){return{addPermissionRequest(i){e(o=>{const r=new Map(o.permissionRequests);r.set(i.id,i),o.permissionRequests=r}),t()},resolvePermissionRequest(i,o){const c=s().permissionRequests.get(i);c&&(e(d=>{const h=new Map(d.permissionRequests);h.set(i,{...c,status:o?"approved":"denied"}),d.permissionRequests=h}),t(),setTimeout(()=>{e(d=>{const h=new Map(d.permissionRequests);h.delete(i),d.permissionRequests=h}),t()},2e3))},respondToPermissionRequest(i,o,r,c){var d;(d=n())==null||d({type:"permission_response",payload:{requestId:i,approved:o,reason:r,remember:c}})},getPendingPermissionsForAgent(i){return Array.from(s().permissionRequests.values()).filter(o=>o.agentId===i&&o.status==="pending")},clearAllPermissions(){e(i=>{i.permissionRequests=new Map}),t()}}}function oE(s,e,t,n){return{spawnBossAgent(i,o,r,c,d,h,p,f,g,y,v,w,S){var A;const C=c?{x:c.x,y:0,z:c.z}:void 0;(A=n())==null||A({type:"spawn_boss_agent",payload:{name:i,class:o,cwd:r,position:C,subordinateIds:d,useChrome:h,permissionMode:p,provider:f,codexConfig:g,codexModel:y,model:v,customInstructions:w,initialSkillIds:S}})},assignSubordinates(i,o){var r;(r=n())==null||r({type:"assign_subordinates",payload:{bossId:i,subordinateIds:o}})},removeSubordinate(i,o){var r;(r=n())==null||r({type:"remove_subordinate",payload:{bossId:i,subordinateId:o}})},sendBossCommand(i,o){var r;e(c=>{c.pendingDelegation={bossId:i,command:o}}),t(),(r=n())==null||r({type:"send_boss_command",payload:{bossId:i,command:o}})},requestDelegationHistory(i){var o;(o=n())==null||o({type:"request_delegation_history",payload:{bossId:i}})},handleDelegationDecision(i){e(o=>{var h;const r=new Map(o.delegationHistories),c=r.get(i.bossId)||[],d=c.findIndex(p=>p.id===i.id);if(d!==-1?c[d]=i:(c.unshift(i),c.length>100&&c.pop()),r.set(i.bossId,c),o.delegationHistories=r,i.status==="sent"&&i.selectedAgentId){const p=o.agents.get(i.bossId),f=new Map(o.lastDelegationReceived);f.set(i.selectedAgentId,{bossName:(p==null?void 0:p.name)||"Boss",taskCommand:i.userCommand,timestamp:Date.now()}),o.lastDelegationReceived=f}((h=o.pendingDelegation)==null?void 0:h.bossId)===i.bossId&&i.status!=="pending"&&(o.pendingDelegation=null)}),t()},setDelegationHistory(i,o){e(r=>{const c=new Map(r.delegationHistories);c.set(i,o),r.delegationHistories=c}),t()},getDelegationHistory(i){return s().delegationHistories.get(i)||[]},getLastDelegationReceived(i){return s().lastDelegationReceived.get(i)||null},clearLastDelegationReceived(i){s().lastDelegationReceived.has(i)&&(e(r=>{const c=new Map(r.lastDelegationReceived);c.delete(i),r.lastDelegationReceived=c}),t())},updateBossSubordinates(i,o){const c=s().agents.get(i);c&&(e(d=>{const h={...c,subordinateIds:o},p=new Map(d.agents);p.set(i,h),d.agents=p}),t())},getSubordinates(i){const o=s(),r=o.agents.get(i),c=(r==null?void 0:r.isBoss)===!0||(r==null?void 0:r.class)==="boss";return!r||!c||!r.subordinateIds?[]:r.subordinateIds.map(d=>o.agents.get(d)).filter(d=>d!==void 0)},isBossAgent(i){const o=s().agents.get(i);return(o==null?void 0:o.isBoss)===!0||(o==null?void 0:o.class)==="boss"},getBossForAgent(i){const o=s(),r=o.agents.get(i);return r!=null&&r.bossId&&o.agents.get(r.bossId)||null},getAvailableSubordinates(){return Array.from(s().agents.values()).filter(i=>i.class!=="boss")},handleAgentTaskStarted(i,o,r,c){e(d=>{const h=new Map(d.agentTaskProgress);let p=h.get(i);p||(p=new Map,h.set(i,p)),p.set(o,{agentId:o,agentName:r,taskDescription:c,status:"working",output:[],startedAt:Date.now()}),d.agentTaskProgress=h}),t()},handleAgentTaskOutput(i,o,r){e(c=>{const d=c.agentTaskProgress.get(i);if(!d)return;const h=d.get(o);if(!h)return;const p=new Map(c.agentTaskProgress),f=new Map(d);f.set(o,{...h,output:[...h.output,r]}),p.set(i,f),c.agentTaskProgress=p}),t()},handleAgentTaskCompleted(i,o,r){e(c=>{const d=c.agentTaskProgress.get(i);if(!d)return;const h=d.get(o);if(!h)return;const p=new Map(c.agentTaskProgress),f=new Map(d);f.set(o,{...h,status:r?"completed":"failed",completedAt:Date.now()}),p.set(i,f),c.agentTaskProgress=p}),t()},getAgentTaskProgress(i){return s().agentTaskProgress.get(i)||new Map},clearAgentTaskProgress(i,o){e(r=>{if(o){const c=r.agentTaskProgress.get(i);if(c){const d=new Map(r.agentTaskProgress),h=new Map(c);h.delete(o),d.set(i,h),r.agentTaskProgress=d}}else{const c=new Map(r.agentTaskProgress);c.delete(i),r.agentTaskProgress=c}}),t()},clearAllSubordinatesContext(i){const r=s().agents.get(i),c=(r==null?void 0:r.isBoss)===!0||(r==null?void 0:r.class)==="boss";if(console.log("[Store] clearAllSubordinatesContext called:",{bossId:i,bossName:r==null?void 0:r.name,isBoss:c,subordinateIds:r==null?void 0:r.subordinateIds}),!r||!c||!r.subordinateIds||r.subordinateIds.length===0){console.log("[Store] clearAllSubordinatesContext: No boss or subordinates found, returning early");return}const d=n();console.log("[Store] clearAllSubordinatesContext: sendMessage available:",!!d);for(const h of r.subordinateIds)console.log("[Store] clearAllSubordinatesContext: Sending clear_context for subordinate:",h),d==null||d({type:"clear_context",payload:{agentId:h}});e(h=>{const p=new Map(h.agentOutputs);for(const f of r.subordinateIds||[])p.delete(f);h.agentOutputs=p}),t(),console.log("[Store] clearAllSubordinatesContext: Completed")}}}function rE(s,e,t,n){return{setSkillsFromServer(i){e(o=>{const r=new Map;for(const c of i)r.set(c.id,c);o.skills=r}),t()},addSkillFromServer(i){e(o=>{const r=new Map(o.skills);r.set(i.id,i),o.skills=r}),t()},updateSkillFromServer(i){e(o=>{const r=new Map(o.skills);r.set(i.id,i),o.skills=r}),t()},removeSkillFromServer(i){e(o=>{const r=new Map(o.skills);r.delete(i),o.skills=r}),t()},getSkill(i){return s().skills.get(i)},getAllSkills(){return Array.from(s().skills.values())},getSkillsForAgent(i){const o=s(),r=o.agents.get(i);return r?Array.from(o.skills.values()).filter(c=>c.enabled?!!(c.assignedAgentIds.includes(i)||c.assignedAgentClasses.includes(r.class)):!1):[]},createSkill(i){var o;(o=n())==null||o({type:"create_skill",payload:i})},updateSkill(i,o){var r;(r=n())==null||r({type:"update_skill",payload:{id:i,updates:o}})},deleteSkill(i){var o;(o=n())==null||o({type:"delete_skill",payload:{id:i}})},assignSkillToAgent(i,o){var r;(r=n())==null||r({type:"assign_skill",payload:{skillId:i,agentId:o}})},unassignSkillFromAgent(i,o){var r;(r=n())==null||r({type:"unassign_skill",payload:{skillId:i,agentId:o}})},requestAgentSkills(i){var o;(o=n())==null||o({type:"request_agent_skills",payload:{agentId:i}})},setCustomAgentClassesFromServer(i){e(o=>{const r=new Map;for(const c of i)r.set(c.id,c);o.customAgentClasses=r}),t()},addCustomAgentClassFromServer(i){e(o=>{const r=new Map(o.customAgentClasses);r.set(i.id,i),o.customAgentClasses=r}),t()},updateCustomAgentClassFromServer(i){e(o=>{const r=new Map(o.customAgentClasses);r.set(i.id,i),o.customAgentClasses=r}),t()},removeCustomAgentClassFromServer(i){e(o=>{const r=new Map(o.customAgentClasses);r.delete(i),o.customAgentClasses=r}),t()},getCustomAgentClass(i){return s().customAgentClasses.get(i)},getAllCustomAgentClasses(){return Array.from(s().customAgentClasses.values())},createCustomAgentClass(i){var o;(o=n())==null||o({type:"create_custom_agent_class",payload:i})},updateCustomAgentClass(i,o){var r;(r=n())==null||r({type:"update_custom_agent_class",payload:{id:i,updates:o}})},deleteCustomAgentClass(i){var o;(o=n())==null||o({type:"delete_custom_agent_class",payload:{id:i}})}}}function lE(s,e,t){return{handleExecTaskStarted(n,i,o,r,c){e(d=>{const h={taskId:n,agentId:i,agentName:o,command:r,cwd:c,status:"running",output:[],startedAt:Date.now()};d.execTasks||(d.execTasks=new Map),d.execTasks.set(n,h)}),t()},handleExecTaskOutput(n,i,o,r){e(c=>{var h;const d=(h=c.execTasks)==null?void 0:h.get(n);if(d){const p=o.split(`
|
|
142
142
|
`);for(const f of p)f.length>0&&d.output.push(r?`[stderr] ${f}`:f);d.output.length>500&&(d.output=d.output.slice(-500))}}),t()},handleExecTaskCompleted(n,i,o,r){e(c=>{var h;const d=(h=c.execTasks)==null?void 0:h.get(n);d&&(d.status=r?"completed":"failed",d.exitCode=o,d.completedAt=Date.now())}),t()},async stopExecTask(n){try{return(await fetch(`/api/exec/tasks/${n}`,{method:"DELETE"})).ok?(e(o=>{var c;const r=(c=o.execTasks)==null?void 0:c.get(n);r&&r.status==="running"&&(r.status="failed",r.exitCode=-15,r.completedAt=Date.now(),r.output.push("[Task stopped by user]"))}),t(),!0):!1}catch(i){return console.error("Failed to stop exec task:",i),!1}},getExecTasks(n){const i=s();return i.execTasks?Array.from(i.execTasks.values()).filter(o=>o.agentId===n):[]},getAllExecTasks(){const n=s();return n.execTasks?Array.from(n.execTasks.values()):[]},getExecTask(n){var o;return(o=s().execTasks)==null?void 0:o.get(n)},clearCompletedExecTasks(n){e(i=>{if(i.execTasks)for(const[o,r]of i.execTasks.entries())r.agentId===n&&r.status!=="running"&&i.execTasks.delete(o)}),t()},clearAllExecTasks(n){e(i=>{if(i.execTasks)for(const[o,r]of i.execTasks.entries())r.agentId===n&&i.execTasks.delete(o)}),t()},removeExecTask(n){e(i=>{i.execTasks&&i.execTasks.delete(n)}),t()}}}function cE(s,e,t,n){return{setSecretsFromServer(i){e(o=>{const r=new Map;for(const c of i)r.set(c.id,c);o.secrets=r}),t()},addSecretFromServer(i){e(o=>{const r=new Map(o.secrets);r.set(i.id,i),o.secrets=r}),t()},updateSecretFromServer(i){e(o=>{const r=new Map(o.secrets);r.set(i.id,i),o.secrets=r}),t()},removeSecretFromServer(i){e(o=>{const r=new Map(o.secrets);r.delete(i),o.secrets=r}),t()},getSecret(i){return s().secrets.get(i)},getSecretByKey(i){return Array.from(s().secrets.values()).find(o=>o.key===i)},getAllSecrets(){return Array.from(s().secrets.values())},createSecret(i){var o;(o=n())==null||o({type:"create_secret",payload:i})},updateSecret(i,o){var r;(r=n())==null||r({type:"update_secret",payload:{id:i,updates:o}})},deleteSecret(i){var o;(o=n())==null||o({type:"delete_secret",payload:{id:i}})}}}function I0(){return{connectionStatus:new Map,databases:new Map,tables:new Map,tableSchemas:new Map,queryResults:[],queryHistory:[],executingQuery:!1,activeConnectionId:null,activeDatabase:null}}function uE(s,e,t,n){const i=r=>{s().databaseState.has(r)||e(d=>{const h=new Map(d.databaseState);h.set(r,I0()),d.databaseState=h})};return{testDatabaseConnection(r,c){var d;(d=n())==null||d({type:"test_database_connection",payload:{buildingId:r,connectionId:c}})},setConnectionStatus(r,c,d){i(r),e(h=>{const p=h.databaseState.get(r);if(p){const f=new Map(p.connectionStatus);f.set(c,d);const g={...p,connectionStatus:f},y=new Map(h.databaseState);y.set(r,g),h.databaseState=y}}),t()},listDatabases(r,c){var d;(d=n())==null||d({type:"list_databases",payload:{buildingId:r,connectionId:c}})},setDatabases(r,c,d){i(r),e(h=>{const p=h.databaseState.get(r);if(p){const f=new Map(p.databases);f.set(c,d);const g={...p,databases:f},y=new Map(h.databaseState);y.set(r,g),h.databaseState=y}}),t()},listTables(r,c,d){var h;(h=n())==null||h({type:"list_tables",payload:{buildingId:r,connectionId:c,database:d}})},setTables(r,c,d,h){i(r);const p=`${c}:${d}`;e(f=>{const g=f.databaseState.get(r);if(g){const y=new Map(g.tables);y.set(p,h);const v={...g,tables:y},w=new Map(f.databaseState);w.set(r,v),f.databaseState=w}}),t()},getTableSchema(r,c,d,h){var p;(p=n())==null||p({type:"get_table_schema",payload:{buildingId:r,connectionId:c,database:d,table:h}})},setTableSchema(r,c,d,h,p){i(r);const f=`${c}:${d}:${h}`;e(g=>{const y=g.databaseState.get(r);if(y){const v=new Map(y.tableSchemas);v.set(f,p);const w={...y,tableSchemas:v},S=new Map(g.databaseState);S.set(r,w),g.databaseState=S}}),t()},executeQuery(r,c,d,h,p=1e3){var f;i(r),e(g=>{const y=g.databaseState.get(r);if(y){const v={...y,executingQuery:!0},w=new Map(g.databaseState);w.set(r,v),g.databaseState=w}}),t(),(f=n())==null||f({type:"execute_query",payload:{buildingId:r,connectionId:c,database:d,query:h,limit:p}})},setQueryResult(r,c){i(r),e(d=>{const h=d.databaseState.get(r);if(h){const p=[c,...h.queryResults].slice(0,20),f={...h,queryResults:p,executingQuery:!1},g=new Map(d.databaseState);g.set(r,f),d.databaseState=g}}),t()},setExecutingQuery(r,c){i(r),e(d=>{const h=d.databaseState.get(r);if(h){const p={...h,executingQuery:c},f=new Map(d.databaseState);f.set(r,p),d.databaseState=f}}),t()},requestQueryHistory(r,c=100){var d;(d=n())==null||d({type:"request_query_history",payload:{buildingId:r,limit:c}})},setQueryHistory(r,c){i(r),e(d=>{const h=d.databaseState.get(r);if(h){const p={...h,queryHistory:c},f=new Map(d.databaseState);f.set(r,p),d.databaseState=f}}),t()},toggleQueryFavorite(r,c){var d;(d=n())==null||d({type:"toggle_query_favorite",payload:{buildingId:r,queryId:c}})},deleteQueryFromHistory(r,c){var d;(d=n())==null||d({type:"delete_query_history",payload:{buildingId:r,queryId:c}})},clearQueryHistory(r){var c;(c=n())==null||c({type:"clear_query_history",payload:{buildingId:r}})},setActiveConnection(r,c){i(r),e(d=>{const h=d.databaseState.get(r);if(h){const p={...h,activeConnectionId:c,activeDatabase:null},f=new Map(d.databaseState);f.set(r,p),d.databaseState=f}}),t()},setActiveDatabase(r,c){i(r),e(d=>{const h=d.databaseState.get(r);if(h){const p={...h,activeDatabase:c},f=new Map(d.databaseState);f.set(r,p),d.databaseState=f}}),t()},getDatabaseState(r){return s().databaseState.get(r)||I0()},clearDatabaseState(r){e(c=>{const d=new Map(c.databaseState);d.delete(r),c.databaseState=d}),t()}}}function dE(s,e,t){return{async fetchSnapshots(){e(n=>{n.snapshotsLoading=!0,n.snapshotsError=null}),t();try{const n=await Ct(lt("/api/snapshots"));if(!n.ok)throw new Error(`Failed to fetch snapshots: ${n.statusText}`);const i=await n.json(),o=Array.isArray(i)?i:i.snapshots||[];this.setSnapshots(o)}catch(n){const i=n instanceof Error?n.message:"Failed to fetch snapshots";this.setError(i),console.error("Snapshot fetch error:",n)}finally{e(n=>{n.snapshotsLoading=!1}),t()}},setSnapshots(n){e(i=>{const o=new Map;n.forEach(r=>{o.set(r.id,r)}),i.snapshots=o}),t()},async createSnapshot(n,i,o,r,c,d){e(h=>{h.snapshotsLoading=!0,h.snapshotsError=null}),t();try{const h={agentId:n,agentName:i,title:o,description:r,outputs:c||[],files:d||[]},p=await Ct(lt("/api/snapshots"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(!p.ok)throw new Error(`Failed to create snapshot: ${p.statusText}`);const f=await p.json();return await this.fetchSnapshots(),f}catch(h){const p=h instanceof Error?h.message:"Failed to create snapshot";throw this.setError(p),console.error("Snapshot creation error:",h),h}finally{e(h=>{h.snapshotsLoading=!1}),t()}},async loadSnapshot(n){e(i=>{i.snapshotsLoading=!0,i.snapshotsError=null}),t();try{const i=await Ct(lt(`/api/snapshots/${n}`));if(!i.ok)throw new Error(`Failed to load snapshot: ${i.statusText}`);const o=await i.json();this.setCurrentSnapshot(o)}catch(i){const o=i instanceof Error?i.message:"Failed to load snapshot";this.setError(o),console.error("Snapshot load error:",i)}finally{e(i=>{i.snapshotsLoading=!1}),t()}},setCurrentSnapshot(n){e(i=>{i.currentSnapshot=n}),t()},async deleteSnapshot(n){var i;e(o=>{o.snapshotsLoading=!0,o.snapshotsError=null}),t();try{const o=await Ct(lt(`/api/snapshots/${n}`),{method:"DELETE"});if(!o.ok)throw new Error(`Failed to delete snapshot: ${o.statusText}`);await this.fetchSnapshots(),((i=s().currentSnapshot)==null?void 0:i.id)===n&&this.setCurrentSnapshot(null)}catch(o){const r=o instanceof Error?o.message:"Failed to delete snapshot";throw this.setError(r),console.error("Snapshot deletion error:",o),o}finally{e(o=>{o.snapshotsLoading=!1}),t()}},async restoreFiles(n,i){e(o=>{o.snapshotsLoading=!0,o.snapshotsError=null}),t();try{const o=i?{filePaths:i}:{},r=await Ct(lt(`/api/snapshots/${n}/restore`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!r.ok)throw new Error(`Failed to restore files: ${r.statusText}`)}catch(o){const r=o instanceof Error?o.message:"Failed to restore files";throw this.setError(r),console.error("File restoration error:",o),o}finally{e(o=>{o.snapshotsLoading=!1}),t()}},setLoading(n){e(i=>{i.snapshotsLoading=n}),t()},setError(n){e(i=>{i.snapshotsError=n}),t()},clearError(){this.setError(null)},reset(){e(n=>{n.snapshots=new Map,n.currentSnapshot=null,n.snapshotsLoading=!1,n.snapshotsError=null}),t()}}}function hE(s,e,t){return{addSubagent(n){e(i=>{const o=new Map(i.subagents);o.set(n.id,n),i.subagents=o}),t(),console.log(`[Subagent] Added: ${n.name} (${n.id}) for agent ${n.parentAgentId}`)},completeSubagent(n,i,o){e(r=>{let c=r.subagents.get(n);if(!c){for(const[,d]of r.subagents)if(d.toolUseId===n&&d.parentAgentId===i){c=d;break}}if(c){const d=new Map(r.subagents);d.set(c.id,{...c,status:o?"completed":"failed",completedAt:Date.now()}),r.subagents=d,console.log(`[Subagent] Completed: ${c.name} (${c.id}) success=${o}`),setTimeout(()=>{e(h=>{const p=h.subagents.get(c.id);if(p&&(p.status==="completed"||p.status==="failed")){const f=new Map(h.subagents);f.delete(c.id),h.subagents=f}}),t()},3e4)}}),t()},getSubagentsForAgent(n){const i=s();return Array.from(i.subagents.values()).filter(o=>o.parentAgentId===n)},getSubagent(n){return s().subagents.get(n)},removeSubagent(n){e(i=>{const o=new Map(i.subagents);o.delete(n),i.subagents=o}),t()},getSubagentByToolUseId(n){const i=s();for(const[,o]of i.subagents)if(o.toolUseId===n)return o}}}function cn(s,e){if(s===e)return!0;if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++)if(s[t]!==e[t])return!1;return!0}function Fa(s,e){if(s===e)return!0;if(s.size!==e.size)return!1;for(const[t,n]of s)if(e.get(t)!==n)return!1;return!0}function mE(s,e){if(s===e)return!0;if(s.size!==e.size)return!1;for(const t of s)if(!e.has(t))return!1;return!0}function xt(s,e=Object.is){const[t,n]=x.useState(()=>s(I.getState())),i=x.useRef(t);return x.useEffect(()=>{i.current=t},[t]),x.useEffect(()=>{const o=()=>{const r=s(I.getState());e(i.current,r)||(i.current=r,n(r))};return o(),I.subscribe(o)},[s,e]),t}function ns(){const[,s]=x.useState({});return x.useEffect(()=>I.subscribe(()=>s({})),[]),I.getState()}function Ha(){return xt(x.useCallback(s=>s.agents,[]),Fa)}function Ju(){const s=Ha(),e=x.useRef([]),t=Array.from(s.values());return cn(e.current,t)||(e.current=t),e.current}function gf(s){return xt(x.useCallback(e=>s?e.agents.get(s):void 0,[s]))}function Qk(){return xt(x.useCallback(s=>s.selectedAgentIds,[]),mE)}function bf(s){const e=x.useRef([]),t=x.useRef(0),n=xt(x.useCallback(i=>s&&i.agentOutputs.get(s)||e.current,[s]),cn);return n.length!==t.current&&(Bl.info(`Selector: ${t.current} -> ${n.length}`,{agentId:s,lastText:n.length>0?n[n.length-1].text.slice(0,40):null},"useAgentOutputs"),t.current=n.length),n}function yf(){return xt(x.useCallback(s=>s.lastPrompts,[]),Fa)}function ed(){return xt(x.useCallback(s=>s.areas,[]),Fa)}function pE(){return xt(x.useCallback(s=>s.buildings,[]),Fa)}function Jk(){return xt(x.useCallback(s=>s.supervisor,[]))}function ho(){return xt(x.useCallback(s=>s.settings,[]))}function eS(){return xt(x.useCallback(s=>s.settings.hideCost,[]))}function fE(){return xt(x.useCallback(s=>s.settings.customAgentNames,[]),cn)}function gE(){return xt(x.useCallback(s=>s.shortcuts,[]),cn)}function tS(){return xt(x.useCallback(s=>s.mouseControls,[]))}function bE(){return xt(x.useCallback(s=>s.mouseControls.trackpad,[]))}function sS(){return xt(x.useCallback(s=>s.terminalOpen,[]))}function nS(){return xt(x.useCallback(s=>s.mobileView,[]))}function xf(){return xt(x.useCallback(s=>s.fileViewerPath,[]))}function yE(){return xt(x.useCallback(s=>s.fileViewerEditData,[]))}function xE(){return xt(x.useCallback(s=>s.explorerFolderPath,[]))}function vf(){return xt(x.useCallback(s=>s.contextModalAgentId,[]))}function aS(){return xt(x.useCallback(s=>s.toolExecutions,[]),cn)}function vE(){return xt(x.useCallback(s=>s.fileChanges,[]),cn)}function iS(){return xt(x.useCallback(s=>s.skills,[]),Fa)}function td(){const s=iS(),e=x.useRef([]),t=Array.from(s.values());return cn(e.current,t)||(e.current=t),e.current}function wE(s){return xt(x.useCallback(e=>s?e.skills.get(s):void 0,[s]))}function kE(s){const e=x.useRef([]),t=Ha(),n=iS();if(!s)return e.current;const i=t.get(s);return i?Array.from(n.values()).filter(r=>r.enabled?!!(r.assignedAgentIds.includes(s)||r.assignedAgentClasses.includes(i.class)):!1):e.current}function SE(){return xt(x.useCallback(s=>s.customAgentClasses,[]),Fa)}function Zn(){const s=SE(),e=x.useRef([]),t=Array.from(s.values());return cn(e.current,t)||(e.current=t),e.current}function jE(s){return xt(x.useCallback(e=>s?e.customAgentClasses.get(s):void 0,[s]))}function wf(){return xt(x.useCallback(s=>s.reconnectCount,[]))}function CE(){return xt(x.useCallback(s=>s.supervisor.globalUsage,[]))}function AE(){return xt(x.useCallback(s=>s.supervisor.refreshingUsage,[]))}function NE(s){const e=x.useRef(new Map);return xt(x.useCallback(t=>s&&t.agentTaskProgress.get(s)||e.current,[s]),Fa)}function TE(s){return xt(x.useCallback(e=>!s||!e.execTasks?[]:Array.from(e.execTasks.values()).filter(t=>t.agentId===s),[s]),cn)}function ME(){return xt(x.useCallback(s=>s.secrets,[]),Fa)}function EE(){const s=ME(),e=x.useRef([]),t=Array.from(s.values());return cn(e.current,t)||(e.current=t),e.current}const _E={connectionStatus:new Map,databases:new Map,tables:new Map,tableSchemas:new Map,queryResults:[],queryHistory:[],executingQuery:!1,activeConnectionId:null,activeDatabase:null};function kf(s){return xt(x.useCallback(e=>(s?e.databaseState.get(s):void 0)??_E,[s]))}function RE(s){return xt(x.useCallback(e=>{if(!s)return[];const t=e.databaseState.get(s);return(t==null?void 0:t.queryResults)??[]},[s]),cn)}function DE(s){return xt(x.useCallback(e=>{if(!s)return[];const t=e.databaseState.get(s);return(t==null?void 0:t.queryHistory)??[]},[s]),cn)}function LE(s){return xt(x.useCallback(e=>{if(!s)return!1;const t=e.databaseState.get(s);return(t==null?void 0:t.executingQuery)??!1},[s]))}function BE(){return xt(s=>s.dockerContainersList,cn)}function OE(){return xt(s=>s.currentSnapshot)}function PE(){return xt(s=>s.subagents,Fa)}function IE(s){return xt(x.useCallback(e=>s?Array.from(e.subagents.values()).filter(t=>t.parentAgentId===s):[],[s]),cn)}function zE(){return xt(s=>s.viewMode)}function FE(){return xt(x.useCallback(s=>s.overviewPanelOpen,[]))}class z0{constructor(){W(this,"state");W(this,"listeners",new Set);W(this,"sendMessage",null);W(this,"agentActions");W(this,"outputActions");W(this,"supervisorActions");W(this,"areaActions");W(this,"buildingActions");W(this,"permissionActions");W(this,"delegationActions");W(this,"skillActions");W(this,"execTaskActions");W(this,"secretActions");W(this,"databaseActions");W(this,"snapshotActions");W(this,"subagentActions");W(this,"statusPollInterval",null);this.state={agents:new Map,selectedAgentIds:new Set,lastSelectedAgentId:null,activities:[],isConnected:!1,areas:new Map,activeTool:null,selectedAreaId:null,buildings:new Map,selectedBuildingIds:new Set,buildingLogs:new Map,streamingBuildingLogs:new Map,streamingBuildingIds:new Set,bossStreamingLogs:new Map,agentOutputs:new Map,lastPrompts:new Map,toolExecutions:[],fileChanges:[],terminalOpen:!1,terminalResizing:!1,mobileView:this.loadMobileView(),settings:this.loadSettings(),shortcuts:this.loadShortcuts(),mouseControls:this.loadMouseControls(),fileViewerPath:null,fileViewerEditData:null,explorerFolderPath:null,contextModalAgentId:null,supervisor:{enabled:!0,autoReportOnComplete:!1,lastReport:null,narratives:new Map,lastReportTime:null,nextReportTime:null,agentHistories:new Map,loadingHistoryForAgent:null,historyFetchedForAgents:new Set,generatingReport:!1,globalUsage:null,refreshingUsage:!1},permissionRequests:new Map,delegationHistories:new Map,pendingDelegation:null,lastDelegationReceived:new Map,agentTaskProgress:new Map,skills:new Map,customAgentClasses:new Map,reconnectCount:0,execTasks:new Map,secrets:new Map,databaseState:new Map,dockerContainersList:[],dockerComposeProjectsList:[],snapshots:new Map,currentSnapshot:null,snapshotsLoading:!1,snapshotsError:null,lastSelectionViaSwipe:!1,lastSelectionViaDirectClick:!1,subagents:new Map,viewMode:(()=>{const r=Qs(at.SCENE_VIEW_MODE,"3d");return r==="2d"||r==="3d"||r==="dashboard"?r:"3d"})(),overviewPanelOpen:!1};const e=()=>this.state,t=r=>{r(this.state)},n=()=>this.notify(),i=()=>this.sendMessage,o=()=>this.listeners.size;this.agentActions=eE(e,t,n,i),this.outputActions=tE(e,t,n,o),this.supervisorActions=sE(e,t,n,i),this.areaActions=nE(e,t,n,i),this.buildingActions=aE(e,t,n,i),this.permissionActions=iE(e,t,n,i),this.delegationActions=oE(e,t,n,i),this.skillActions=rE(e,t,n,i),this.execTaskActions=lE(e,t,n),this.secretActions=cE(e,t,n,i),this.databaseActions=uE(e,t,n,i),this.snapshotActions=dE(e,t,n),this.subagentActions=hE(e,t,n)}loadSettings(){const e=ca(at.SETTINGS,null);return e?{...P0,...e}:{...P0}}loadShortcuts(){const e=ca(at.SHORTCUTS,null);return e?Nm.map(n=>{const i=e.find(o=>o.id===n.id);return i?{...n,...i}:n}):[...Nm]}loadMouseControls(){var t;const e=ca(at.MOUSE_CONTROLS,null);return e?{bindings:Mm.map(i=>{var r;const o=(r=e.bindings)==null?void 0:r.find(c=>c.id===i.id);return o?{...i,...o}:i}),sensitivity:{...Tm,...e.sensitivity},trackpad:{...hu,...e.trackpad,sensitivity:{...hu.sensitivity,...(t=e.trackpad)==null?void 0:t.sensitivity}}}:{bindings:[...Mm],sensitivity:{...Tm},trackpad:{...hu}}}loadMobileView(){const e=Qs(at.MOBILE_VIEW,"");return e==="terminal"||e==="3d"?e:typeof window<"u"&&window.innerWidth<=768&&"ontouchstart"in window?"3d":"terminal"}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){this.listeners.forEach(e=>e())}getState(){return this.state}setSendMessage(e){this.sendMessage=e}setConnected(e){this.state.isConnected=e,this.notify()}triggerReconnect(){this.state.reconnectCount++,this.notify()}toggleTerminal(e){e&&!this.state.selectedAgentIds.has(e)&&(this.state.selectedAgentIds.clear(),this.state.selectedAgentIds.add(e)),this.state.terminalOpen=!this.state.terminalOpen,this.notify()}setTerminalOpen(e){if(console.log("[Store] setTerminalOpen called with:",e,"current:",this.state.terminalOpen),!e&&this.state.terminalOpen&&console.trace("[Store] Closing terminal - stack trace:"),this.state.terminalOpen=e,e&&(this.state.mobileView="terminal",this.state.selectedAgentIds.size===0&&this.state.agents.size>0&&!this.state.currentSnapshot)){const t=Array.from(this.state.agents.keys())[0];console.log("[Store] Auto-selecting first agent for terminal open:",t),this.state.selectedAgentIds=new Set([t])}this.notify(),console.log("[Store] After notify, terminalOpen:",this.state.terminalOpen)}setOverviewPanelOpen(e){this.state.overviewPanelOpen=e,this.notify()}setMobileView(e){if(console.log("[Store] setMobileView called:",e,"previous:",this.state.mobileView),this.state.mobileView=e,Yn(at.MOBILE_VIEW,e),e==="terminal"&&this.state.selectedAgentIds.size===0&&this.state.agents.size>0&&!this.state.currentSnapshot){const t=Array.from(this.state.agents.keys())[0];console.log("[Store] Auto-selecting first agent for terminal view:",t),this.state.selectedAgentIds=new Set([t]),this.state.terminalOpen=!0}this.notify()}setViewMode(e){this.state.viewMode=e,Yn(at.SCENE_VIEW_MODE,e),this.state.settings.experimental2DView=e==="2d",this.notify()}openTerminalOnMobile(e){console.log("[Store] openTerminalOnMobile called for agent:",e),gN("terminal"),this.state.selectedAgentIds.clear(),this.state.selectedAgentIds.add(e),this.state.terminalOpen=!0,this.state.mobileView="terminal",this.notify()}setTerminalResizing(e){this.state.terminalResizing=e,this.notify()}setLastSelectionViaSwipe(e){this.state.lastSelectionViaSwipe=e}consumeSwipeSelectionFlag(){const e=this.state.lastSelectionViaSwipe;return this.state.lastSelectionViaSwipe=!1,e}setLastSelectionViaDirectClick(e){this.state.lastSelectionViaDirectClick=e}consumeDirectClickSelectionFlag(){const e=this.state.lastSelectionViaDirectClick;return this.state.lastSelectionViaDirectClick=!1,e}setFileViewerPath(e,t){this.state.fileViewerPath=e,this.state.fileViewerEditData=t||null,this.notify()}clearFileViewerPath(){this.state.fileViewerPath=null,this.state.fileViewerEditData=null,this.notify()}setExplorerFolderPath(e){this.state.explorerFolderPath=e,this.notify()}openFileExplorer(e){this.state.explorerFolderPath=e,this.notify()}closeFileExplorer(){this.state.explorerFolderPath=null,this.notify()}setContextModalAgentId(e){this.state.contextModalAgentId=e,this.notify()}closeContextModal(){this.state.contextModalAgentId=null,this.notify()}updateSettings(e){this.state.settings={...this.state.settings,...e},Ia(at.SETTINGS,this.state.settings),this.notify()}getSettings(){return this.state.settings}getShortcuts(){return this.state.shortcuts}getShortcut(e){return this.state.shortcuts.find(t=>t.id===e)}updateShortcut(e,t){const n=this.state.shortcuts.findIndex(i=>i.id===e);n!==-1&&(this.state.shortcuts=[...this.state.shortcuts.slice(0,n),{...this.state.shortcuts[n],...t},...this.state.shortcuts.slice(n+1)],this.saveShortcuts(),this.notify())}resetShortcuts(){this.state.shortcuts=[...Nm],this.saveShortcuts(),this.notify()}saveShortcuts(){Ia(at.SHORTCUTS,this.state.shortcuts)}getMouseControls(){return this.state.mouseControls}getMouseBinding(e){return this.state.mouseControls.bindings.find(t=>t.id===e)}updateMouseBinding(e,t){const n=this.state.mouseControls.bindings.findIndex(i=>i.id===e);n!==-1&&(this.state.mouseControls.bindings=[...this.state.mouseControls.bindings.slice(0,n),{...this.state.mouseControls.bindings[n],...t},...this.state.mouseControls.bindings.slice(n+1)],this.saveMouseControls(),this.notify())}updateCameraSensitivity(e){this.state.mouseControls.sensitivity={...this.state.mouseControls.sensitivity,...e},this.saveMouseControls(),this.notify()}resetMouseControls(){this.state.mouseControls={bindings:[...Mm],sensitivity:{...Tm},trackpad:{...hu}},this.saveMouseControls(),this.notify()}getTrackpadConfig(){return this.state.mouseControls.trackpad}updateTrackpadConfig(e){this.state.mouseControls.trackpad={...this.state.mouseControls.trackpad,...e,sensitivity:{...this.state.mouseControls.trackpad.sensitivity,...e.sensitivity||{}}},this.saveMouseControls(),this.notify()}saveMouseControls(){Ia(at.MOUSE_CONTROLS,this.state.mouseControls)}startStatusPolling(){}stopStatusPolling(){this.statusPollInterval&&(clearInterval(this.statusPollInterval),this.statusPollInterval=null)}setAgents(...e){return this.agentActions.setAgents(...e)}addAgent(...e){return this.agentActions.addAgent(...e)}updateAgent(...e){return this.agentActions.updateAgent(...e)}updateAgentContextStats(...e){return this.agentActions.updateAgentContextStats(...e)}removeAgent(...e){return this.agentActions.removeAgent(...e)}selectAgent(...e){return this.agentActions.selectAgent(...e)}addToSelection(...e){return this.agentActions.addToSelection(...e)}selectMultiple(...e){return this.agentActions.selectMultiple(...e)}deselectAll(...e){return this.agentActions.deselectAll(...e)}spawnAgent(...e){return this.agentActions.spawnAgent(...e)}createDirectoryAndSpawn(...e){return this.agentActions.createDirectoryAndSpawn(...e)}sendCommand(...e){return this.agentActions.sendCommand(...e)}refreshAgentContext(...e){return this.agentActions.refreshAgentContext(...e)}moveAgent(...e){return this.agentActions.moveAgent(...e)}killAgent(...e){return this.agentActions.killAgent(...e)}stopAgent(...e){return this.agentActions.stopAgent(...e)}clearContext(...e){return this.agentActions.clearContext(...e)}collapseContext(...e){return this.agentActions.collapseContext(...e)}removeAgentFromServer(...e){return this.agentActions.removeAgentFromServer(...e)}renameAgent(...e){return this.agentActions.renameAgent(...e)}updateAgentProperties(...e){return this.agentActions.updateAgentProperties(...e)}getTotalTokens(){return this.agentActions.getTotalTokens()}getSelectedAgents(){return this.agentActions.getSelectedAgents()}addActivity(...e){return this.agentActions.addActivity(...e)}addToolExecution(...e){return this.agentActions.addToolExecution(...e)}addFileChange(...e){return this.agentActions.addFileChange(...e)}loadToolHistory(){return this.agentActions.loadToolHistory()}addOutput(...e){return this.outputActions.addOutput(...e)}clearOutputs(...e){return this.outputActions.clearOutputs(...e)}getOutputs(...e){return this.outputActions.getOutputs(...e)}addUserPromptToOutput(...e){return this.outputActions.addUserPromptToOutput(...e)}getLastPrompt(...e){return this.outputActions.getLastPrompt(...e)}setLastPrompt(...e){return this.outputActions.setLastPrompt(...e)}preserveOutputs(){return this.outputActions.preserveOutputs()}mergeOutputsWithHistory(...e){return this.outputActions.mergeOutputsWithHistory(...e)}setSupervisorReport(...e){return this.supervisorActions.setSupervisorReport(...e)}addNarrative(...e){return this.supervisorActions.addNarrative(...e)}getNarratives(...e){return this.supervisorActions.getNarratives(...e)}setSupervisorStatus(...e){return this.supervisorActions.setSupervisorStatus(...e)}setSupervisorConfig(...e){return this.supervisorActions.setSupervisorConfig(...e)}requestSupervisorReport(){return this.supervisorActions.requestSupervisorReport()}requestAgentSupervisorHistory(...e){return this.supervisorActions.requestAgentSupervisorHistory(...e)}setAgentSupervisorHistory(...e){return this.supervisorActions.setAgentSupervisorHistory(...e)}getAgentSupervisorHistory(...e){return this.supervisorActions.getAgentSupervisorHistory(...e)}addAgentAnalysis(...e){return this.supervisorActions.addAgentAnalysis(...e)}isLoadingHistoryForAgent(...e){return this.supervisorActions.isLoadingHistoryForAgent(...e)}hasHistoryBeenFetched(...e){return this.supervisorActions.hasHistoryBeenFetched(...e)}setGlobalUsage(...e){return this.supervisorActions.setGlobalUsage(...e)}requestGlobalUsage(){return this.supervisorActions.requestGlobalUsage()}getGlobalUsage(){return this.supervisorActions.getGlobalUsage()}setActiveTool(...e){return this.areaActions.setActiveTool(...e)}selectArea(...e){return this.areaActions.selectArea(...e)}addArea(...e){return this.areaActions.addArea(...e)}updateArea(...e){return this.areaActions.updateArea(...e)}deleteArea(...e){return this.areaActions.deleteArea(...e)}assignAgentToArea(...e){return this.areaActions.assignAgentToArea(...e)}unassignAgentFromArea(...e){return this.areaActions.unassignAgentFromArea(...e)}addDirectoryToArea(...e){return this.areaActions.addDirectoryToArea(...e)}removeDirectoryFromArea(...e){return this.areaActions.removeDirectoryFromArea(...e)}getAreaDirectories(...e){return this.areaActions.getAreaDirectories(...e)}isPositionInArea(...e){return this.areaActions.isPositionInArea(...e)}getAreaForAgent(...e){return this.areaActions.getAreaForAgent(...e)}setAreasFromServer(...e){return this.areaActions.setAreasFromServer(...e)}getAreasInZOrder(...e){return this.areaActions.getAreasInZOrder(...e)}getNextZIndex(...e){return this.areaActions.getNextZIndex(...e)}bringAreaToFront(...e){return this.areaActions.bringAreaToFront(...e)}sendAreaToBack(...e){return this.areaActions.sendAreaToBack(...e)}setAreaZIndex(...e){return this.areaActions.setAreaZIndex(...e)}archiveArea(...e){return this.areaActions.archiveArea(...e)}restoreArchivedArea(...e){return this.areaActions.restoreArchivedArea(...e)}getArchivedAreas(...e){return this.areaActions.getArchivedAreas(...e)}getVisibleAreas(...e){return this.areaActions.getVisibleAreas(...e)}isAgentInArchivedArea(...e){return this.areaActions.isAgentInArchivedArea(...e)}selectBuilding(...e){return this.buildingActions.selectBuilding(...e)}selectMultipleBuildings(...e){return this.buildingActions.selectMultipleBuildings(...e)}toggleBuildingSelection(...e){return this.buildingActions.toggleBuildingSelection(...e)}isBuildingSelected(...e){return this.buildingActions.isBuildingSelected(...e)}getSelectedBuildingIds(){return this.buildingActions.getSelectedBuildingIds()}deleteSelectedBuildings(){return this.buildingActions.deleteSelectedBuildings()}addBuilding(...e){return this.buildingActions.addBuilding(...e)}updateBuilding(...e){return this.buildingActions.updateBuilding(...e)}deleteBuilding(...e){return this.buildingActions.deleteBuilding(...e)}moveBuilding(...e){return this.buildingActions.moveBuilding(...e)}updateBuildingPosition(...e){return this.buildingActions.updateBuildingPosition(...e)}createBuilding(...e){return this.buildingActions.createBuilding(...e)}sendBuildingCommand(...e){return this.buildingActions.sendBuildingCommand(...e)}addBuildingLogs(...e){return this.buildingActions.addBuildingLogs(...e)}getBuildingLogs(...e){return this.buildingActions.getBuildingLogs(...e)}clearBuildingLogs(...e){return this.buildingActions.clearBuildingLogs(...e)}setBuildingsFromServer(...e){return this.buildingActions.setBuildingsFromServer(...e)}updateBuildingFromServer(...e){return this.buildingActions.updateBuildingFromServer(...e)}removeBuildingFromServer(...e){return this.buildingActions.removeBuildingFromServer(...e)}startLogStreaming(...e){return this.buildingActions.startLogStreaming(...e)}stopLogStreaming(...e){return this.buildingActions.stopLogStreaming(...e)}appendStreamingLogChunk(...e){return this.buildingActions.appendStreamingLogChunk(...e)}setStreamingStatus(...e){return this.buildingActions.setStreamingStatus(...e)}getStreamingLogs(...e){return this.buildingActions.getStreamingLogs(...e)}clearStreamingLogs(...e){return this.buildingActions.clearStreamingLogs(...e)}isLogStreaming(...e){return this.buildingActions.isLogStreaming(...e)}sendBossBuildingCommand(...e){return this.buildingActions.sendBossBuildingCommand(...e)}assignBuildingsToBoSS(...e){return this.buildingActions.assignBuildingsToBoSS(...e)}startBossLogStreaming(...e){return this.buildingActions.startBossLogStreaming(...e)}stopBossLogStreaming(...e){return this.buildingActions.stopBossLogStreaming(...e)}appendBossStreamingLogChunk(...e){return this.buildingActions.appendBossStreamingLogChunk(...e)}getBossStreamingLogs(...e){return this.buildingActions.getBossStreamingLogs(...e)}clearBossStreamingLogs(...e){return this.buildingActions.clearBossStreamingLogs(...e)}requestDockerContainersList(){return this.buildingActions.requestDockerContainersList()}setDockerContainersList(...e){return this.buildingActions.setDockerContainersList(...e)}getDockerContainersList(){return this.buildingActions.getDockerContainersList()}getDockerComposeProjectsList(){return this.buildingActions.getDockerComposeProjectsList()}addPermissionRequest(...e){return this.permissionActions.addPermissionRequest(...e)}resolvePermissionRequest(...e){return this.permissionActions.resolvePermissionRequest(...e)}respondToPermissionRequest(...e){return this.permissionActions.respondToPermissionRequest(...e)}getPendingPermissionsForAgent(...e){return this.permissionActions.getPendingPermissionsForAgent(...e)}clearAllPermissions(...e){return this.permissionActions.clearAllPermissions(...e)}spawnBossAgent(...e){return this.delegationActions.spawnBossAgent(...e)}assignSubordinates(...e){return this.delegationActions.assignSubordinates(...e)}removeSubordinate(...e){return this.delegationActions.removeSubordinate(...e)}sendBossCommand(...e){return this.delegationActions.sendBossCommand(...e)}requestDelegationHistory(...e){return this.delegationActions.requestDelegationHistory(...e)}handleDelegationDecision(...e){return this.delegationActions.handleDelegationDecision(...e)}setDelegationHistory(...e){return this.delegationActions.setDelegationHistory(...e)}getDelegationHistory(...e){return this.delegationActions.getDelegationHistory(...e)}getLastDelegationReceived(...e){return this.delegationActions.getLastDelegationReceived(...e)}clearLastDelegationReceived(...e){return this.delegationActions.clearLastDelegationReceived(...e)}updateBossSubordinates(...e){return this.delegationActions.updateBossSubordinates(...e)}getSubordinates(...e){return this.delegationActions.getSubordinates(...e)}isBossAgent(...e){return this.delegationActions.isBossAgent(...e)}getBossForAgent(...e){return this.delegationActions.getBossForAgent(...e)}getAvailableSubordinates(){return this.delegationActions.getAvailableSubordinates()}handleAgentTaskStarted(...e){return this.delegationActions.handleAgentTaskStarted(...e)}handleAgentTaskOutput(...e){return this.delegationActions.handleAgentTaskOutput(...e)}handleAgentTaskCompleted(...e){return this.delegationActions.handleAgentTaskCompleted(...e)}getAgentTaskProgress(...e){return this.delegationActions.getAgentTaskProgress(...e)}clearAgentTaskProgress(...e){return this.delegationActions.clearAgentTaskProgress(...e)}clearAllSubordinatesContext(...e){return this.delegationActions.clearAllSubordinatesContext(...e)}setSkillsFromServer(...e){return this.skillActions.setSkillsFromServer(...e)}addSkillFromServer(...e){return this.skillActions.addSkillFromServer(...e)}updateSkillFromServer(...e){return this.skillActions.updateSkillFromServer(...e)}removeSkillFromServer(...e){return this.skillActions.removeSkillFromServer(...e)}getSkill(...e){return this.skillActions.getSkill(...e)}getAllSkills(){return this.skillActions.getAllSkills()}getSkillsForAgent(...e){return this.skillActions.getSkillsForAgent(...e)}createSkill(...e){return this.skillActions.createSkill(...e)}updateSkill(...e){return this.skillActions.updateSkill(...e)}deleteSkill(...e){return this.skillActions.deleteSkill(...e)}assignSkillToAgent(...e){return this.skillActions.assignSkillToAgent(...e)}unassignSkillFromAgent(...e){return this.skillActions.unassignSkillFromAgent(...e)}requestAgentSkills(...e){return this.skillActions.requestAgentSkills(...e)}setCustomAgentClassesFromServer(...e){return this.skillActions.setCustomAgentClassesFromServer(...e)}addCustomAgentClassFromServer(...e){return this.skillActions.addCustomAgentClassFromServer(...e)}updateCustomAgentClassFromServer(...e){return this.skillActions.updateCustomAgentClassFromServer(...e)}removeCustomAgentClassFromServer(...e){return this.skillActions.removeCustomAgentClassFromServer(...e)}getCustomAgentClass(...e){return this.skillActions.getCustomAgentClass(...e)}getAllCustomAgentClasses(){return this.skillActions.getAllCustomAgentClasses()}createCustomAgentClass(...e){return this.skillActions.createCustomAgentClass(...e)}updateCustomAgentClass(...e){return this.skillActions.updateCustomAgentClass(...e)}deleteCustomAgentClass(...e){return this.skillActions.deleteCustomAgentClass(...e)}handleExecTaskStarted(...e){return this.execTaskActions.handleExecTaskStarted(...e)}handleExecTaskOutput(...e){return this.execTaskActions.handleExecTaskOutput(...e)}handleExecTaskCompleted(...e){return this.execTaskActions.handleExecTaskCompleted(...e)}stopExecTask(...e){return this.execTaskActions.stopExecTask(...e)}getExecTasks(...e){return this.execTaskActions.getExecTasks(...e)}getAllExecTasks(){return this.execTaskActions.getAllExecTasks()}getExecTask(...e){return this.execTaskActions.getExecTask(...e)}clearCompletedExecTasks(...e){return this.execTaskActions.clearCompletedExecTasks(...e)}clearAllExecTasks(...e){return this.execTaskActions.clearAllExecTasks(...e)}removeExecTask(...e){return this.execTaskActions.removeExecTask(...e)}setSecretsFromServer(...e){return this.secretActions.setSecretsFromServer(...e)}addSecretFromServer(...e){return this.secretActions.addSecretFromServer(...e)}updateSecretFromServer(...e){return this.secretActions.updateSecretFromServer(...e)}removeSecretFromServer(...e){return this.secretActions.removeSecretFromServer(...e)}getSecret(...e){return this.secretActions.getSecret(...e)}getSecretByKey(...e){return this.secretActions.getSecretByKey(...e)}getAllSecrets(){return this.secretActions.getAllSecrets()}createSecret(...e){return this.secretActions.createSecret(...e)}updateSecret(...e){return this.secretActions.updateSecret(...e)}deleteSecret(...e){return this.secretActions.deleteSecret(...e)}testDatabaseConnection(...e){return this.databaseActions.testDatabaseConnection(...e)}setConnectionStatus(...e){return this.databaseActions.setConnectionStatus(...e)}listDatabases(...e){return this.databaseActions.listDatabases(...e)}setDatabases(...e){return this.databaseActions.setDatabases(...e)}listTables(...e){return this.databaseActions.listTables(...e)}setTables(...e){return this.databaseActions.setTables(...e)}getTableSchema(...e){return this.databaseActions.getTableSchema(...e)}setTableSchema(...e){return this.databaseActions.setTableSchema(...e)}executeQuery(...e){return this.databaseActions.executeQuery(...e)}setQueryResult(...e){return this.databaseActions.setQueryResult(...e)}setExecutingQuery(...e){return this.databaseActions.setExecutingQuery(...e)}requestQueryHistory(...e){return this.databaseActions.requestQueryHistory(...e)}setQueryHistory(...e){return this.databaseActions.setQueryHistory(...e)}toggleQueryFavorite(...e){return this.databaseActions.toggleQueryFavorite(...e)}deleteQueryFromHistory(...e){return this.databaseActions.deleteQueryFromHistory(...e)}clearQueryHistory(...e){return this.databaseActions.clearQueryHistory(...e)}setActiveConnection(...e){return this.databaseActions.setActiveConnection(...e)}setActiveDatabase(...e){return this.databaseActions.setActiveDatabase(...e)}getDatabaseState(...e){return this.databaseActions.getDatabaseState(...e)}clearDatabaseState(...e){return this.databaseActions.clearDatabaseState(...e)}fetchSnapshots(...e){return this.snapshotActions.fetchSnapshots(...e)}setSnapshots(...e){return this.snapshotActions.setSnapshots(...e)}createSnapshot(...e){return this.snapshotActions.createSnapshot(...e)}loadSnapshot(...e){return this.snapshotActions.loadSnapshot(...e)}setCurrentSnapshot(...e){return this.snapshotActions.setCurrentSnapshot(...e)}deleteSnapshot(...e){return this.snapshotActions.deleteSnapshot(...e)}restoreFiles(...e){return this.snapshotActions.restoreFiles(...e)}setLoading(...e){return this.snapshotActions.setLoading(...e)}setError(...e){return this.snapshotActions.setError(...e)}clearError(...e){return this.snapshotActions.clearError(...e)}reset(...e){return this.snapshotActions.reset(...e)}addSubagent(...e){return this.subagentActions.addSubagent(...e)}completeSubagent(...e){return this.subagentActions.completeSubagent(...e)}getSubagentsForAgent(...e){return this.subagentActions.getSubagentsForAgent(...e)}getSubagent(...e){return this.subagentActions.getSubagent(...e)}removeSubagent(...e){return this.subagentActions.removeSubagent(...e)}getSubagentByToolUseId(...e){return this.subagentActions.getSubagentByToolUseId(...e)}}const F0=1;function HE(){return typeof window<"u"?(window.__tideStore&&window.__tideStoreVersion===F0||(window.__tideStore=new z0,window.__tideStoreVersion=F0),window.__tideStore):new z0}const I=HE(),oS=x.createContext(null),$E={error:"❌",success:"✅",warning:"⚠️",info:"ℹ️"};let UE=0;function GE({children:s}){const[e,t]=x.useState(null),n=x.useRef([]),i=x.useRef(null),o=x.useCallback(()=>{if(n.current.length>0&&!e){const d=n.current.shift();t(d)}},[e]);x.useEffect(()=>{e||o()},[e,o]),x.useEffect(()=>{if(e&&e.duration>0)return i.current=window.setTimeout(()=>{t(null)},e.duration),()=>{i.current&&clearTimeout(i.current)}},[e]);const r=x.useCallback((d,h,p,f=5e3)=>{const y={id:++UE,type:d,title:h,message:p,duration:f};if(n.current.push(y),!e){const v=n.current.shift();t(v)}},[e]),c=x.useCallback(()=>{i.current&&clearTimeout(i.current),t(null)},[]);return a.jsxs(oS.Provider,{value:{showToast:r},children:[s,a.jsx("div",{id:"toast-container",children:e&&a.jsxs("div",{className:`toast ${e.type}`,children:[a.jsx("span",{className:"toast-icon",children:$E[e.type]}),a.jsxs("div",{className:"toast-content",children:[a.jsx("div",{className:"toast-title",children:e.title}),a.jsx("div",{className:"toast-message",children:e.message})]}),a.jsx("button",{className:"toast-close",onClick:c,children:"×"})]},e.id)})]})}function rS(){const s=x.useContext(oS);if(!s)throw new Error("useToast must be used within ToastProvider");return s}const lo={scout:{icon:"🔍",color:"#4a9eff",description:"Codebase exploration, file discovery"},builder:{icon:"🔨",color:"#ff9e4a",description:"Feature implementation, writing code"},debugger:{icon:"🐛",color:"#ff4a4a",description:"Bug hunting, fixing issues"},architect:{icon:"📐",color:"#9e4aff",description:"Planning, design decisions"},warrior:{icon:"⚔️",color:"#ff4a9e",description:"Aggressive refactoring, migrations"},support:{icon:"💚",color:"#4aff9e",description:"Documentation, tests, cleanup"},boss:{icon:"👑",color:"#ffd700",description:"Team leader, delegates tasks to subordinates"}},ua=lo,Kn={bypass:{label:"Permissionless",description:"Skip all permission prompts (less safe, faster)"},interactive:{label:"Interactive",description:"Ask for approval before sensitive operations"}},On={"gpt-5.3-codex":{label:"GPT-5.3 Codex",description:"Latest frontier agentic coding model",icon:"⚙️"},"gpt-5.2-codex":{label:"GPT-5.2 Codex",description:"Frontier agentic coding model",icon:"🧠"},"gpt-5.1-codex-max":{label:"GPT-5.1 Codex Max",description:"Codex-optimized flagship for deep and fast reasoning",icon:"🚀"},"gpt-5.1-codex-mini":{label:"GPT-5.1 Codex Mini",description:"Optimized for codex, cheaper and faster",icon:"⚡"},"gpt-5.2":{label:"GPT-5.2",description:"General frontier model with strong reasoning and coding",icon:"🧩"}},Pn={sonnet:{label:"Sonnet",description:"Balanced performance and cost (recommended)",icon:"⚡"},opus:{label:"Opus",description:"Most capable, higher cost",icon:"🧠"},haiku:{label:"Haiku",description:"Fast and economical",icon:"🚀"}},Np="<<<BOSS_CONTEXT_START>>>",H0="<<<BOSS_CONTEXT_END>>>",lr={server:{icon:"🖥️",color:"#4aff9e",description:"Service with start/stop commands and logs"},link:{icon:"🔗",color:"#4a9eff",description:"Quick links to URLs"},database:{icon:"🗄️",color:"#ff9e4a",description:"Database connection and queries"},docker:{icon:"🐳",color:"#4ac1ff",description:"Docker container management"},monitor:{icon:"📊",color:"#ff4a9e",description:"System metrics and monitoring"},folder:{icon:"📁",color:"#ffd700",description:"Folder shortcut - opens file explorer on click"},boss:{icon:"👑",color:"#ffd700",description:"Boss building - manages multiple buildings with unified controls"}},Su={"server-rack":{label:"Server Rack",description:"Classic server rack with blinking LEDs"},tower:{label:"Control Tower",description:"Tall tower with rotating antenna"},dome:{label:"Data Dome",description:"Futuristic dome with energy ring"},pyramid:{label:"Power Pyramid",description:"Egyptian-style pyramid with glowing core"},desktop:{label:"Desktop PC",description:"Retro computer with monitor and keyboard"},"filing-cabinet":{label:"Filing Cabinet",description:"Office cabinet with sliding drawers"},satellite:{label:"Satellite Dish",description:"Communication dish with rotating receiver"},crystal:{label:"Data Crystal",description:"Floating crystal with energy particles"},factory:{label:"Mini Factory",description:"Industrial building with smoking chimney"},"command-center":{label:"Command Center",description:"Grand central hub for boss buildings with holographic rings"}},$0={"":{label:"Auto-detect",description:"Let PM2 detect the interpreter"},node:{label:"Node.js",description:"JavaScript/TypeScript runtime"},bun:{label:"Bun",description:"Bun JavaScript runtime"},python3:{label:"Python 3",description:"Python 3 interpreter"},python:{label:"Python 2",description:"Python 2 interpreter (legacy)"},java:{label:"Java",description:"Java runtime (use with -jar args)"},php:{label:"PHP",description:"PHP interpreter"},bash:{label:"Bash",description:"Bash shell script"},none:{label:"None (Binary)",description:"Direct execution (compiled binaries)"}},U0={no:{label:"No",description:"Do not automatically restart"},always:{label:"Always",description:"Always restart when stopped"},"unless-stopped":{label:"Unless Stopped",description:"Restart unless manually stopped"},"on-failure":{label:"On Failure",description:"Restart only on failure"}},G0={always:{label:"Always",description:"Always pull the image"},missing:{label:"If Missing",description:"Pull only if image not present"},never:{label:"Never",description:"Never pull, use local only"}},pl={mysql:{label:"MySQL",icon:"🐬",defaultPort:3306},postgresql:{label:"PostgreSQL",icon:"🐘",defaultPort:5432},oracle:{label:"Oracle",icon:"🔶",defaultPort:1521}},lS=x.createContext(null);function qE(s){const e=lo[s];if(e)return e.icon;const n=I.getState().customAgentClasses.get(s);return n?n.icon:"🤖"}function WE(s){const e=lo[s];if(e)return e.color;const n=I.getState().customAgentClasses.get(s);return n?n.color:"#888888"}const KE=3;function VE({children:s}){const[e,t]=x.useState([]),n=x.useRef(new Map);x.useEffect(()=>()=>{n.current.forEach(c=>clearTimeout(c))},[]);const i=x.useCallback(c=>{t(h=>h.filter(p=>p.id!==c));const d=n.current.get(c);d&&(clearTimeout(d),n.current.delete(c))},[]),o=x.useCallback(c=>{t(h=>{const p=[...h,c];if(p.length>KE){const f=p.shift();if(f){const g=n.current.get(f.id);g&&(clearTimeout(g),n.current.delete(f.id))}}return p});const d=window.setTimeout(()=>{i(c.id)},8e3);n.current.set(c.id,d),H2({title:`${c.agentName}: ${c.title}`,body:c.message,data:{type:"agent_notification",agentId:c.agentId,notificationId:c.id}})},[i]),r=x.useCallback(c=>{I.selectAgent(c.agentId),i(c.id)},[i]);return a.jsxs(lS.Provider,{value:{showAgentNotification:o},children:[s,a.jsx("div",{id:"agent-notification-container",children:e.map(c=>{const d=qE(c.agentClass),h=WE(c.agentClass);return a.jsxs("div",{className:"agent-notification",onClick:()=>r(c),style:{"--agent-color":h},children:[a.jsx("div",{className:"agent-notification-avatar",children:a.jsx("span",{className:"agent-notification-icon",children:d})}),a.jsxs("div",{className:"agent-notification-content",children:[a.jsxs("div",{className:"agent-notification-header",children:[a.jsx("span",{className:"agent-notification-name",children:c.agentName}),a.jsx("span",{className:"agent-notification-hint",children:"Click to focus"})]}),a.jsx("div",{className:"agent-notification-title",children:c.title}),a.jsx("div",{className:"agent-notification-message",children:c.message})]}),a.jsx("button",{className:"agent-notification-close",onClick:p=>{p.stopPropagation(),i(c.id)},children:"×"})]},c.id)})})]})}function YE(){const s=x.useContext(lS);if(!s)throw new Error("useAgentNotification must be used within AgentNotificationProvider");return s}function XE(s){return typeof s=="string"?s:"#"+s.toString(16).padStart(6,"0")}function Ci(s,e){const t=In[s];if(t)return{icon:t.icon,color:XE(t.color),description:t.description};const n=e.find(i=>i.id===s);return n?{icon:n.icon,color:n.color,description:n.description}:{icon:"🤖",color:"#888888"}}function ZE(s){return s>=1e6?(s/1e6).toFixed(1)+"M":s>=1e3?(s/1e3).toFixed(1)+"K":s.toString()}function Tp(s){return s>=1e6?(s/1e6).toFixed(1)+"M":s>=1e3?(s/1e3).toFixed(1)+"K":s.toString()}function QE(s){const e=Math.floor((Date.now()-s)/1e3);return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function Sf(s){const e=Math.floor((Date.now()-s)/1e3);if(e<5)return"just now";if(e<60)return`${e}s ago`;const t=Math.floor(e/60);if(t<60){const c=e%60;return c>0?`${t}m ${c}s ago`:`${t}m ago`}const n=Math.floor(t/60),i=t%60;if(n<24)return i>0?`${n}h ${i}m ago`:`${n}h ago`;const o=Math.floor(n/24),r=n%24;return r>0?`${o}d ${r}h ago`:`${o}d ago`}function vi(s,e){return s?e?s.replace(/\s*\(?\s*~?\$[\d,.]+\s*\)?/g,"").replace(/\s*cost[:\s]+~?\$[\d,.]+/gi,"").replace(/\s*price[:\s]+~?\$[\d,.]+/gi,"").replace(/\s*\(~?\$[\d,.]+\s*(?:USD|cost|spent)?\)/gi,"").replace(/\s*-\s*~?\$[\d,.]+\s*$/g,"").replace(/[^\S\n]+/g," ").trim():s:""}function JE(s){const e=Math.floor((Date.now()-s)/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60);if(t<60)return`${t}m`;const n=Math.floor(t/60);return n<24?`${n}h`:`${Math.floor(n/24)}d`}function Bu(s){const e=Math.floor((Date.now()-s)/1e3);if(e<60)return"just now";const t=Math.floor(e/60);if(t<60)return`${t}m ago`;const n=Math.floor(t/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function cS(s){const e=s.contextStats;if(e){const o=e.usedPercent,r=100-o,c=e.contextWindow-e.totalTokens;return{remainingPercent:r,usedPercent:o,hasData:!0,totalTokens:e.totalTokens,contextWindow:e.contextWindow,freeTokens:c}}const t=s.contextUsed||0,n=s.contextLimit||2e5,i=Math.max(0,n-t);return{remainingPercent:i/n*100,usedPercent:t/n*100,hasData:!1,totalTokens:t,contextWindow:n,freeTokens:i}}function e_(s){return s<20?"#c85858":s<50?"#c89858":"#6a9a78"}function t_(s,e){const t=new Map;for(const n of s){const i=e(n.id),o=(i==null?void 0:i.id)||null;t.has(o)||t.set(o,[]),t.get(o).push(n)}return t}function s_(s,e){return[...s].sort((t,n)=>{if(t===null)return 1;if(n===null)return-1;const i=t?e(t):void 0,o=n?e(n):void 0;return((i==null?void 0:i.name)||"").localeCompare((o==null?void 0:o.name)||"")})}function q0({onOpenAreaExplorer:s}){const e=ns(),t=Array.from(e.agents.values()),n=Array.from(e.areas.values()),i=x.useMemo(()=>t.map(d=>d.id).sort().join(","),[t]),o=x.useRef(new Set);x.useEffect(()=>{for(const d of t){if(o.current.has(d.id))continue;I.getAgentSupervisorHistory(d.id).length===0&&!I.isLoadingHistoryForAgent(d.id)&&(o.current.add(d.id),I.requestAgentSupervisorHistory(d.id))}},[i]);const r=t_(t,d=>I.getAreaForAgent(d));for(const d of n)r.has(d.id)||r.set(d.id,[]);const c=s_(Array.from(r.keys()),d=>e.areas.get(d));return t.length===0&&n.length===0?a.jsxs("div",{className:"empty-state",children:[a.jsx("div",{className:"empty-state-icon",children:"⚔️"}),a.jsx("div",{className:"empty-state-title",children:"No Agents Deployed"}),a.jsx("div",{className:"empty-state-desc",children:'Click "+ New Agent" to deploy your first agent'})]}):a.jsxs("div",{className:"agents-list",children:[a.jsx("div",{className:"agents-list-header",children:"Areas & Agents"}),c.map(d=>{const h=r.get(d),p=d?e.areas.get(d):null;return a.jsxs("div",{className:"agents-group",children:[a.jsxs("div",{className:"agents-group-header",style:p?{borderLeftColor:p.color,background:`${p.color}15`}:void 0,children:[p?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"agents-group-dot",style:{background:p.color}}),a.jsx("span",{className:"agents-group-name",children:p.name}),p.directories.length>0&&a.jsx("button",{className:"area-browse-btn",onClick:()=>s==null?void 0:s(p.id),title:"Browse files",children:"📂"})]}):a.jsx("span",{className:"agents-group-name unassigned",children:"Unassigned"}),a.jsx("span",{className:"agents-group-count",children:h.length})]}),h.length>0&&a.jsx("div",{className:"agents-group-items",style:p?{background:`${p.color}08`}:void 0,children:h.map(f=>a.jsx(n_,{agent:f,area:p},f.id))})]},d||"unassigned")}),t.length>0&&a.jsx(a_,{agents:t})]})}const n_=x.memo(function({agent:e,area:t}){const n=ns(),i=Zn(),o=Ci(e.class,i),r=n.selectedAgentIds.has(e.id),[,c]=x.useState(0);x.useEffect(()=>{if(e.status==="idle"){const f=setInterval(()=>{c(g=>g+1)},15e3);return()=>clearInterval(f)}},[e.status]);const d=()=>{I.selectAgent(e.id)},h=e.status==="idle"&&e.lastActivity>0,p=e.lastActivity>0?hf(e.lastActivity):void 0;return a.jsxs("div",{className:`agent-item ${r?"selected":""}`,onClick:d,children:[a.jsx("div",{className:"agent-item-icon",style:{background:`${o.color}20`},children:o.icon}),a.jsxs("div",{className:"agent-item-info",children:[a.jsx("div",{className:"agent-item-name",children:e.name}),a.jsxs("div",{className:"agent-item-status",children:[e.status,e.currentTool?` • ${e.currentTool}`:"",h&&a.jsxs("span",{className:"agent-item-idle",style:{color:p},title:Sf(e.lastActivity),children:[" ","⏱ ",JE(e.lastActivity)]})]})]}),a.jsx("div",{className:`agent-status-dot ${e.status}`})]})}),a_=x.memo(function({agents:e}){const t=ns(),n=Zn(),i=t.settings.hideCost,[o,r]=x.useState(()=>hp(at.GLOBAL_SUPERVISOR_COLLAPSED)),c=()=>{const p=!o;r(p),mp(at.GLOBAL_SUPERVISOR_COLLAPSED,p)},d=x.useMemo(()=>e.map(p=>{const f=I.getAgentSupervisorHistory(p.id),g=f.length>0?f[0]:null;return{agent:p,entry:g,timestamp:(g==null?void 0:g.timestamp)||p.lastActivity||0}}).filter(p=>p.entry!==null).sort((p,f)=>f.timestamp-p.timestamp),[e,t.supervisor.agentHistories]),h=d.length>0?d[0].timestamp:Date.now();return d.length===0?null:a.jsxs("div",{className:"global-supervisor-status",children:[a.jsxs("div",{className:"global-supervisor-header",onClick:c,children:[a.jsx("span",{className:"global-supervisor-toggle",children:o?"▶":"▼"}),a.jsx("span",{className:"global-supervisor-title",children:"Supervisor Status"}),a.jsx("span",{className:"global-supervisor-time",children:Bu(h)})]}),!o&&a.jsx("div",{className:"global-supervisor-list",children:d.map(({agent:p,entry:f})=>{const g=Ci(p.class,n),y=f.analysis;return a.jsxs("div",{className:"global-supervisor-item",onClick:()=>I.selectAgent(p.id),children:[a.jsxs("div",{className:"global-supervisor-item-header",children:[a.jsx("span",{className:"global-supervisor-progress-dot",style:{background:Fk[y.progress]||"#888"}}),a.jsx("span",{className:"global-supervisor-agent-icon",children:g.icon}),a.jsx("span",{className:"global-supervisor-agent-name",children:p.name}),a.jsx("span",{className:"global-supervisor-item-time",children:Bu(f.timestamp)})]}),a.jsx("div",{className:"global-supervisor-status-line",children:vi(y.statusDescription,i)}),a.jsx("div",{className:"global-supervisor-summary-text",children:vi(y.recentWorkSummary,i)})]},p.id)})})]})}),i_={idle:"idle",working:"walk",waiting:"sit",waiting_permission:"idle",error:"emote-no",offline:"static",orphaned:"idle"},W0={idle:4915102,working:4890367,waiting:16752202,waiting_permission:16763904,error:16730698,offline:8947848,orphaned:16752202};function dr({agentClass:s,modelFile:e,customModelFile:t,customModelUrl:n,modelScale:i=1,modelOffset:o,idleAnimation:r,status:c="idle",width:d=150,height:h=200}){const p=x.useRef(null),f=x.useRef(null),g=x.useRef(null),y=x.useRef(null),v=x.useRef(null),w=x.useRef(null),S=x.useRef(new Map),C=x.useRef(null),A=x.useRef(null),N=x.useRef(0),_=x.useRef(new kk),[M,E]=x.useState(!1),[z,T]=x.useState(!1),R=x.useRef(!1),D=x.useRef(0),O=x.useRef(new nt),P=x.useRef(!1),K=x.useRef({x:0,y:0}),Y=x.useRef({x:0,y:0});x.useEffect(()=>{const L=p.current;if(!L)return;T(!1);const q=new nf;q.background=new At(1710628),g.current=q;const V=new tf(45,d/h,.1,100);V.position.set(0,1.2,1.4),V.lookAt(0,.4,0),y.current=V;let G;try{G=new Sk({antialias:!0,alpha:!0})}catch{console.warn("[ModelPreview] WebGL context creation failed — too many active contexts"),T(!0);return}G.setSize(d,h),G.setPixelRatio(Math.min(window.devicePixelRatio,2)),G.setClearColor(1710628,1),L.appendChild(G.domElement),f.current=G;const B=new sf(16777215,1);q.add(B);const Q=new ir(16777215,1.5);Q.position.set(2,3,2),q.add(Q);const U=new ir(4890367,.6);U.position.set(-2,1,-1),q.add(U);const H=new up(1,32),te=new Ke({color:2763322,roughness:.8}),ae=new ke(H,te);ae.rotation.x=-Math.PI/2,ae.position.y=0,q.add(ae);const J=new oo(.35,.42,32),he=new Re({color:W0.idle,side:Hs,transparent:!0,opacity:.8}),me=new ke(J,he);me.rotation.x=-Math.PI/2,me.position.y=.01,q.add(me),A.current=me,E(!0);const pe=Ae=>{P.current=!0,K.current={x:Ae.clientX,y:Ae.clientY},L.style.cursor="grabbing"},ne=Ae=>{if(!P.current||!v.current)return;const ue=Ae.clientX-K.current.x,le=Ae.clientY-K.current.y;Y.current.y+=ue*.01,Y.current.x+=le*.01,Y.current.x=Math.max(-Math.PI/4,Math.min(Math.PI/4,Y.current.x)),v.current.rotation.y=Y.current.y,v.current.rotation.x=Y.current.x,K.current={x:Ae.clientX,y:Ae.clientY}},xe=()=>{P.current=!1,L.style.cursor="grab"},fe=()=>{P.current=!1,L.style.cursor="grab"};L.addEventListener("mousedown",pe),window.addEventListener("mousemove",ne),window.addEventListener("mouseup",xe),L.addEventListener("mouseleave",fe),L.style.cursor="grab";const Pe=()=>{N.current=requestAnimationFrame(Pe);const Ae=_.current.getDelta();if(w.current)w.current.update(Ae);else if(v.current&&!R.current){D.current+=Ae;const ue=D.current,re=Math.sin(ue*1.5)*.02,Le=Math.sin(ue*.8)*.01;v.current.position.set(O.current.x+Le,O.current.y+re,O.current.z)}f.current&&g.current&&y.current&&f.current.render(g.current,y.current)};return Pe(),()=>{if(cancelAnimationFrame(N.current),L.removeEventListener("mousedown",pe),window.removeEventListener("mousemove",ne),window.removeEventListener("mouseup",xe),L.removeEventListener("mouseleave",fe),v.current&&g.current&&(g.current.remove(v.current),v.current.traverse(Ae=>{var ue,le;Ae instanceof ke&&((ue=Ae.geometry)==null||ue.dispose(),Array.isArray(Ae.material)?Ae.material.forEach(Z=>{Z.map&&Z.map.dispose(),Z.dispose()}):Ae.material&&(Ae.material.map&&((le=Ae.material.map)==null||le.dispose()),Ae.material.dispose()))}),v.current=null),A.current&&g.current&&(g.current.remove(A.current),A.current.geometry.dispose(),A.current.material.dispose(),A.current=null),g.current&&(g.current.traverse(Ae=>{var ue;Ae instanceof ke&&((ue=Ae.geometry)==null||ue.dispose(),Ae.material instanceof yi&&Ae.material.dispose())}),g.current.clear()),w.current=null,C.current=null,S.current.clear(),f.current){try{const ue=f.current.getContext().getExtension("WEBGL_lose_context");ue&&ue.loseContext()}catch{}f.current.dispose(),L.contains(f.current.domElement)&&L.removeChild(f.current.domElement),f.current=null}g.current=null,y.current=null,E(!1)}},[d,h]),x.useEffect(()=>{if(!M||!g.current)return;const L=new lf,q=new cf;q.setDecoderPath("https://www.gstatic.com/draco/versioned/decoders/1.5.7/"),L.setDRACOLoader(q),L.setMeshoptDecoder(uf);let V=null;const G=B=>{v.current&&g.current&&(g.current.remove(v.current),v.current=null,w.current=null,C.current=null);const Q=B.scene;Q.scale.setScalar(i);const U=(o==null?void 0:o.x)??0,H=(o==null?void 0:o.y)??0,te=(o==null?void 0:o.z)??0;if(Q.position.set(U,te,H),Q.visible=!0,Y.current={x:0,y:0},Q.rotation.set(0,0,0),Q.traverse(ae=>{if(ae instanceof ke&&(ae.castShadow=!0,ae.receiveShadow=!0,ae.material)){const J=ae.material;J.map&&(J.map.colorSpace=qn)}}),g.current)if(g.current.add(Q),v.current=Q,O.current.copy(Q.position),B.animations.length>0){R.current=!0;const ae=new Nl(Q);w.current=ae,S.current.clear();for(const J of B.animations)S.current.set(J.name.toLowerCase(),J);if(r!==""){const J=r?S.current.get(r.toLowerCase())||B.animations[0]:S.current.get("idle")||B.animations[0];if(J){const he=ae.clipAction(J);he.reset().play(),C.current=he}}}else R.current=!1,w.current=null,S.current.clear()};if(t)V=URL.createObjectURL(t),console.log("[ModelPreview] Loading custom model from file:",t.name,"blob URL:",V),L.load(V,B=>{console.log("[ModelPreview] Successfully loaded custom model file, animations:",B.animations.length),G(B)},void 0,B=>{console.error("[ModelPreview] Failed to load custom model file:",B)});else if(n){const B=Nk(n);console.log("[ModelPreview] Loading custom model from URL:",n),L.load(B,Q=>{console.log("[ModelPreview] Successfully loaded custom model URL, animations:",Q.animations.length),G(Q)},void 0,Q=>{console.error("[ModelPreview] Failed to load custom model URL:",n,Q)})}else{const B=e||(s?nr[s]:void 0)||"character-male-a.glb";L.load(`/assets/characters/${B}`,G,void 0,Q=>{console.error("[ModelPreview] Failed to load model:",B,Q)})}return()=>{V&&URL.revokeObjectURL(V),q.dispose()}},[s,e,t,n,i,o,M]);const $=L=>{if(!w.current)return;const q=i_[L],V=S.current.get(q);if(!V){const B=S.current.get("idle");if(B){const Q=w.current.clipAction(B);Q.reset().play(),C.current=Q}return}const G=w.current.clipAction(V);L==="working"?G.timeScale=1.5:L==="error"&&(G.setLoop(yk,1),G.clampWhenFinished=!0),C.current&&C.current!==G?(C.current.fadeOut(.3),G.reset().fadeIn(.3).play()):G.reset().play(),C.current=G};return x.useEffect(()=>{if(M){if(A.current){const L=A.current.material;L.color.setHex(W0[c]),c==="working"?L.opacity=.6+Math.sin(Date.now()*.005)*.4:L.opacity=.8}$(c)}},[c,M]),x.useEffect(()=>{if(!M||!w.current||c!=="idle")return;if(r===""){C.current&&(C.current.stop(),C.current=null);return}const L=r?r.toLowerCase():"idle",q=S.current.get(L);if(q){const V=w.current.clipAction(q);C.current&&C.current!==V?(C.current.fadeOut(.3),V.reset().fadeIn(.3).play()):V.reset().play(),C.current=V}else C.current&&(C.current.stop(),C.current=null)},[r,M,c]),z?a.jsx("div",{className:"model-preview",style:{width:d,height:h,borderRadius:8,overflow:"hidden",background:"#1a1a24",display:"flex",alignItems:"center",justifyContent:"center",color:"#666",fontSize:12,textAlign:"center",padding:8},children:"3D preview unavailable"}):a.jsx("div",{ref:p,className:"model-preview",style:{width:d,height:h,borderRadius:8,overflow:"hidden",background:"#1a1a24"}})}function Ai({value:s,onChange:e,onSubmit:t,placeholder:n="/path/to/folder",className:i="",directoriesOnly:o=!0,autoFocus:r=!1,hasError:c=!1,disabled:d=!1}){const[h,p]=x.useState([]),[f,g]=x.useState(-1),[y,v]=x.useState(!1),[w,S]=x.useState(!1),C=x.useRef(null),A=x.useRef(null),N=x.useRef(null),_=x.useCallback(async O=>{if(!O){p([]);return}S(!0);try{const P=new URLSearchParams({path:O,dirs:o?"true":"false",limit:"15"}),K=await Ct(lt(`/api/files/autocomplete?${P}`));if(K.ok){const Y=await K.json();p(Y.suggestions||[]),g(-1)}}catch(P){console.error("Failed to fetch path suggestions:",P)}finally{S(!1)}},[o]);x.useEffect(()=>(N.current&&clearTimeout(N.current),s&&y?N.current=setTimeout(()=>{_(s)},150):p([]),()=>{N.current&&clearTimeout(N.current)}),[s,y,_]);const M=O=>{e(O.target.value),v(!0)},E=x.useCallback(O=>{var K;const P=O.isDirectory?O.path+"/":O.path;e(P),v(O.isDirectory),g(-1),(K=C.current)==null||K.focus(),O.isDirectory&&_(P)},[e,_]),z=O=>{if(!y||h.length===0){O.key==="Enter"&&t&&(O.preventDefault(),t()),O.key==="Escape"&&v(!1);return}switch(O.key){case"ArrowDown":O.preventDefault(),g(P=>P<h.length-1?P+1:P);break;case"ArrowUp":O.preventDefault(),g(P=>P>0?P-1:-1);break;case"Tab":if(O.preventDefault(),h.length>0){const P=f>=0?f:0;E(h[P])}break;case"Enter":O.preventDefault(),f>=0&&h[f]?E(h[f]):t&&(v(!1),t());break;case"Escape":O.preventDefault(),v(!1),g(-1);break}},T=()=>{v(!0),s&&_(s)},R=()=>{setTimeout(()=>{v(!1),g(-1)},200)};x.useEffect(()=>{if(f>=0&&A.current){const P=A.current.querySelectorAll(".folder-input-suggestion")[f];P&&P.scrollIntoView({block:"nearest"})}},[f]);const D=["folder-input",i,c?"error":""].filter(Boolean).join(" ");return a.jsxs("div",{className:"folder-input-container",children:[a.jsx("input",{ref:C,type:"text",className:D,value:s,onChange:M,onKeyDown:z,onFocus:T,onBlur:R,placeholder:n,autoFocus:r,disabled:d,autoComplete:"off",spellCheck:!1}),y&&(h.length>0||w)&&a.jsx("div",{ref:A,className:"folder-input-suggestions",children:w&&h.length===0?a.jsx("div",{className:"folder-input-loading",children:"Loading..."}):h.map((O,P)=>a.jsxs("div",{className:`folder-input-suggestion ${P===f?"selected":""}`,onClick:()=>E(O),onMouseEnter:()=>g(P),children:[a.jsx("span",{className:"folder-input-suggestion-icon",children:O.isDirectory?"📁":"📄"}),a.jsx("span",{className:"folder-input-suggestion-name",children:O.name}),O.isDirectory&&a.jsx("span",{className:"folder-input-suggestion-hint",children:"/"})]},O.path))})]})}function uS({agent:s,isOpen:e,onClose:t}){const n=td(),i=Zn(),[o,r]=x.useState(s.class),[c,d]=x.useState(s.permissionMode),[h,p]=x.useState(s.provider||"claude"),[f,g]=x.useState(s.codexConfig||{fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),[y,v]=x.useState(s.model||"sonnet"),[w,S]=x.useState(s.codexModel||"gpt-5.3-codex"),[C,A]=x.useState(s.useChrome||!1),[N,_]=x.useState(s.cwd),[M,E]=x.useState(new Set),[z,T]=x.useState("");x.useMemo(()=>n.filter(U=>U.enabled&&(U.assignedAgentIds.includes(s.id)||U.assignedAgentClasses.includes(s.class))),[n,s.id,s.class]),x.useEffect(()=>{const U=n.filter(H=>H.assignedAgentIds.includes(s.id)).map(H=>H.id);E(new Set(U))},[n,s.id]),x.useEffect(()=>{if(e){r(s.class),d(s.permissionMode),p(s.provider||"claude"),g(s.codexConfig||{fullAuto:!0,sandbox:"workspace-write",approvalMode:"on-request",search:!1}),v(s.model||"sonnet"),S(s.codexModel||"gpt-5.3-codex"),A(s.useChrome||!1),_(s.cwd);const U=n.filter(H=>H.assignedAgentIds.includes(s.id)).map(H=>H.id);E(new Set(U))}},[e,s,n]);const R=x.useMemo(()=>n.filter(U=>U.enabled),[n]),D=x.useMemo(()=>{if(!z.trim())return R;const U=z.toLowerCase();return R.filter(H=>H.name.toLowerCase().includes(U)||H.description.toLowerCase().includes(U)||H.slug.toLowerCase().includes(U))},[R,z]),O=x.useMemo(()=>R.filter(U=>U.assignedAgentClasses.includes(o)),[R,o]),P=x.useCallback(U=>{E(H=>{const te=new Set(H);return te.has(U)?te.delete(U):te.add(U),te})},[]),K=x.useMemo(()=>{const U=i.find(H=>H.id===o);if(U!=null&&U.model)return U.model},[i,o]),Y=x.useMemo(()=>{const U=i.find(H=>H.id===o);if(U!=null&&U.customModelPath)return lt(`/api/custom-models/${U.id}`)},[i,o]),$=x.useMemo(()=>{const U=i.find(H=>H.id===o);return U==null?void 0:U.modelScale},[i,o]),L=x.useMemo(()=>i.find(U=>U.id===o),[i,o]),q=x.useMemo(()=>i.find(H=>H.id===o)?"scout":o,[i,o]),V=x.useMemo(()=>{if(o!==s.class||c!==s.permissionMode||h!==(s.provider||"claude")||h==="claude"&&y!==(s.model||"sonnet")||h==="codex"&&w!==(s.codexModel||"gpt-5.3-codex")||h==="codex"&&JSON.stringify(f||{})!==JSON.stringify(s.codexConfig||{})||C!==(s.useChrome||!1)||N!==s.cwd)return!0;const U=n.filter(te=>te.assignedAgentIds.includes(s.id)).map(te=>te.id).sort().join(","),H=Array.from(M).sort().join(",");return U!==H},[o,c,h,y,w,f,C,N,M,s,n]),G=()=>{const U={};o!==s.class&&(U.class=o),c!==s.permissionMode&&(U.permissionMode=c),h!==(s.provider||"claude")&&(U.provider=h),h==="codex"&&JSON.stringify(f||{})!==JSON.stringify(s.codexConfig||{})&&(U.codexConfig=f),h==="codex"&&w!==(s.codexModel||"gpt-5.3-codex")&&(U.codexModel=w),h==="claude"&&y!==(s.model||"sonnet")&&(U.model=y),C!==(s.useChrome||!1)&&(U.useChrome=C),N!==s.cwd&&(U.cwd=N);const H=n.filter(ae=>ae.assignedAgentIds.includes(s.id)).map(ae=>ae.id).sort().join(","),te=Array.from(M).sort().join(",");H!==te&&(U.skillIds=Array.from(M)),Object.keys(U).length>0&&I.updateAgentProperties(s.id,U),t()},{handleMouseDown:B,handleClick:Q}=Us(t);return e?a.jsx("div",{className:"modal-overlay visible",onMouseDown:B,onClick:Q,children:a.jsxs("div",{className:"modal agent-edit-modal",children:[a.jsxs("div",{className:"modal-header",children:["Edit Agent: ",s.name]}),a.jsxs("div",{className:"modal-body spawn-modal-body",children:[a.jsxs("div",{className:"spawn-top-section",children:[a.jsx("div",{className:"spawn-preview-compact",children:a.jsx(dr,{agentClass:q,modelFile:K,customModelUrl:Y,modelScale:$,width:100,height:120})}),a.jsxs("div",{className:"spawn-class-section",children:[a.jsx("div",{className:"spawn-class-label",children:"Agent Class"}),a.jsxs("div",{className:"class-selector-inline",children:[i.map(U=>a.jsxs("button",{className:`class-chip ${o===U.id?"selected":""}`,onClick:()=>r(U.id),title:U.description,children:[a.jsx("span",{className:"class-chip-icon",children:U.icon}),a.jsx("span",{className:"class-chip-name",children:U.name})]},U.id)),Object.entries(lo).filter(([U])=>U!=="boss").map(([U,H])=>a.jsxs("button",{className:`class-chip ${o===U?"selected":""}`,onClick:()=>r(U),title:H.description,children:[a.jsx("span",{className:"class-chip-icon",children:H.icon}),a.jsx("span",{className:"class-chip-name",children:U.charAt(0).toUpperCase()+U.slice(1)})]},U))]})]})]}),(L==null?void 0:L.instructions)&&a.jsxs("div",{className:"custom-class-notice",children:[a.jsxs("div",{className:"custom-class-notice-header",children:[a.jsx("span",{children:"📋"}),a.jsx("span",{children:"This class has custom instructions"})]}),a.jsxs("div",{className:"custom-class-notice-info",children:[L.instructions.length," characters of CLAUDE.md instructions will be injected as system prompt"]})]}),a.jsxs("div",{className:"spawn-form-section",children:[a.jsxs("div",{className:"spawn-form-row",children:[a.jsxs("div",{className:"spawn-field",children:[a.jsx("label",{className:"spawn-label",children:"Runtime"}),a.jsxs("div",{className:"spawn-select-row",children:[a.jsxs("button",{className:`spawn-select-btn ${h==="claude"?"selected":""}`,onClick:()=>p("claude"),children:[a.jsx("span",{children:"🧠"}),a.jsx("span",{children:"Claude"})]}),a.jsxs("button",{className:`spawn-select-btn ${h==="codex"?"selected":""}`,onClick:()=>p("codex"),children:[a.jsx("span",{children:"⚙️"}),a.jsx("span",{children:"Codex"})]})]})]}),a.jsxs("div",{className:"spawn-field",children:[a.jsx("label",{className:"spawn-label",children:"Permissions"}),a.jsx("div",{className:"spawn-select-row",children:Object.keys(Kn).map(U=>a.jsxs("button",{className:`spawn-select-btn ${c===U?"selected":""}`,onClick:()=>d(U),title:Kn[U].description,children:[a.jsx("span",{children:U==="bypass"?"⚡":"🔐"}),a.jsx("span",{children:Kn[U].label})]},U))})]})]}),a.jsx("div",{className:"spawn-form-row",children:a.jsxs("div",{className:"spawn-field",children:[a.jsx("label",{className:"spawn-label",children:"Model"}),h==="claude"?a.jsx("div",{className:"spawn-select-row",children:Object.keys(Pn).map(U=>a.jsxs("button",{className:`spawn-select-btn ${y===U?"selected":""}`,onClick:()=>v(U),title:Pn[U].description,children:[a.jsx("span",{children:Pn[U].icon}),a.jsx("span",{children:Pn[U].label})]},U))}):h==="codex"?a.jsx("div",{className:"spawn-select-row spawn-select-row--codex-models",children:Object.keys(On).map(U=>a.jsxs("button",{className:`spawn-select-btn ${w===U?"selected":""}`,onClick:()=>S(U),title:On[U].description,children:[a.jsx("span",{children:On[U].icon}),a.jsx("span",{children:On[U].label})]},U))}):a.jsx("div",{className:"spawn-inline-hint",children:"Choose the Codex model for this agent."})]})}),h==="codex"&&a.jsx("div",{className:"spawn-form-row",children:a.jsxs("div",{className:"spawn-field",children:[a.jsx("label",{className:"spawn-label",children:"Codex Config"}),a.jsxs("div",{className:"spawn-options-row",style:{display:"flex",flexDirection:"column",gap:8},children:[a.jsxs("label",{className:"spawn-checkbox",children:[a.jsx("input",{type:"checkbox",checked:f.fullAuto!==!1,onChange:U=>g(H=>({...H,fullAuto:U.target.checked}))}),a.jsx("span",{children:"Use `--full-auto`"})]}),a.jsxs("label",{className:"spawn-checkbox",children:[a.jsx("input",{type:"checkbox",checked:!!f.search,onChange:U=>g(H=>({...H,search:U.target.checked}))}),a.jsx("span",{children:"Enable live web search (`--search`)"})]}),f.fullAuto===!1&&a.jsxs(a.Fragment,{children:[a.jsxs("select",{className:"spawn-input",value:f.sandbox||"workspace-write",onChange:U=>g(H=>({...H,sandbox:U.target.value})),children:[a.jsx("option",{value:"read-only",children:"Sandbox: read-only"}),a.jsx("option",{value:"workspace-write",children:"Sandbox: workspace-write"}),a.jsx("option",{value:"danger-full-access",children:"Sandbox: danger-full-access"})]}),a.jsxs("select",{className:"spawn-input",value:f.approvalMode||"on-request",onChange:U=>g(H=>({...H,approvalMode:U.target.value})),children:[a.jsx("option",{value:"untrusted",children:"Approvals: untrusted"}),a.jsx("option",{value:"on-failure",children:"Approvals: on-failure"}),a.jsx("option",{value:"on-request",children:"Approvals: on-request"}),a.jsx("option",{value:"never",children:"Approvals: never"})]})]}),a.jsx("input",{type:"text",className:"spawn-input",placeholder:"Profile (optional)",value:f.profile||"",onChange:U=>g(H=>({...H,profile:U.target.value||void 0}))})]})]})}),h==="claude"&&y!==(s.model||"sonnet")&&a.jsx("div",{className:"model-change-notice",children:"Context preserved - will resume with new model"}),a.jsx("div",{className:"spawn-form-row spawn-options-row",children:a.jsxs("label",{className:"spawn-checkbox",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:U=>A(U.target.checked),disabled:h!=="claude"}),a.jsx("span",{children:"🌐 Chrome Browser"})]})}),a.jsx("div",{className:"spawn-form-row",children:a.jsxs("div",{className:"spawn-field",children:[a.jsx("label",{className:"spawn-label",children:"Working Directory"}),a.jsx(Ai,{value:N,onChange:_,placeholder:"/path/to/directory",className:"spawn-input",directoriesOnly:!0})]})}),N!==s.cwd&&a.jsx("div",{className:"model-change-notice warning",children:"New session will start - context cannot be preserved across directory changes"}),a.jsxs("div",{className:"spawn-skills-section",children:[a.jsxs("label",{className:"spawn-label",children:["Skills ",a.jsx("span",{className:"spawn-label-hint",children:"(click to toggle)"})]}),R.length>6&&a.jsx("input",{type:"text",className:"spawn-input skill-search-input",placeholder:"Filter skills...",value:z,onChange:U=>T(U.target.value)}),a.jsx("div",{className:"skills-chips-compact",children:R.length===0?a.jsx("div",{className:"skills-empty",children:"No enabled skills available"}):D.length===0?a.jsxs("div",{className:"skills-empty",children:['No skills match "',z,'"']}):D.map(U=>{const H=O.includes(U),ae=M.has(U.id)||H;return a.jsxs("button",{className:`skill-chip ${ae?"selected":""} ${H?"class-based":""}`,onClick:()=>!H&&P(U.id),title:H?"Assigned via class":U.name,children:[ae&&a.jsx("span",{className:"skill-check",children:"✓"}),a.jsx("span",{className:"skill-chip-name",children:U.name}),U.builtin&&a.jsx("span",{className:"skill-chip-badge builtin",children:"TC"}),H&&a.jsx("span",{className:"skill-chip-badge",children:"class"})]},U.id)})})]})]})]}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),a.jsx("button",{className:"btn btn-primary",onClick:G,disabled:!V,children:"Save Changes"})]})]})}):null}function fl(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toString()}function K0(s){return`${s.toFixed(1)}%`}function o_(s){return s>=80?"#ff4a4a":s>=60?"#ff9e4a":s>=40?"#ffd700":"#4aff9e"}const r_={systemPrompt:"#4a9eff",systemTools:"#9e4aff",messages:"#4aff9e",freeSpace:"rgba(255,255,255,0.1)",autocompactBuffer:"#ff9e4a"},l_={systemPrompt:"System Prompt",systemTools:"System Tools",messages:"Messages",freeSpace:"Free Space",autocompactBuffer:"Autocompact Buffer"},c_={systemPrompt:"Base instructions and persona for the agent",systemTools:"Tool definitions and capabilities available",messages:"Conversation history and user messages",freeSpace:"Available space for more conversation",autocompactBuffer:"Reserved for automatic context compaction"};function dS({agent:s,isOpen:e,onClose:t,onRefresh:n}){const i=s.contextStats,[o,r]=x.useState(!1),c=()=>{n&&!o&&(r(!0),n(),setTimeout(()=>r(!1),3e3))},d=["systemPrompt","systemTools","messages","autocompactBuffer","freeSpace"],h=x.useMemo(()=>i?d.map(y=>({key:y,...i.categories[y],label:l_[y],description:c_[y],color:r_[y]})):[],[i]),p=x.useMemo(()=>h.filter(y=>y.key!=="freeSpace"),[h]),{handleMouseDown:f,handleClick:g}=Us(t);return e?a.jsx("div",{className:"modal-overlay visible",onMouseDown:f,onClick:g,children:a.jsxs("div",{className:"modal context-view-modal",style:{maxWidth:"520px"},children:[a.jsxs("div",{className:"modal-header",style:{display:"flex",alignItems:"center",gap:"12px"},children:[a.jsxs("span",{style:{flex:1},children:["Context Window: ",s.name]}),n&&a.jsxs("button",{className:"btn btn-primary",onClick:c,disabled:o||s.status!=="idle",style:{padding:"6px 12px",fontSize:"12px",display:"flex",alignItems:"center",gap:"6px"},title:s.status!=="idle"?"Agent must be idle to refresh":"Fetch context stats via /context command",children:[a.jsx("span",{style:{display:"inline-block",animation:o?"spin 1s linear infinite":"none"},children:o?"⟳":"↻"}),o?"Loading...":"Refresh"]})]}),a.jsx("div",{className:"modal-body",style:{padding:"16px"},children:i?a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px",padding:"8px 12px",background:"var(--bg-secondary)",borderRadius:"6px"},children:[a.jsxs("div",{children:[a.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"Model"}),a.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:i.model})]}),a.jsxs("div",{style:{textAlign:"right"},children:[a.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"Context Window"}),a.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:fl(i.contextWindow)})]})]}),a.jsxs("div",{style:{marginBottom:"24px"},children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"8px",fontSize:"13px"},children:[a.jsx("span",{children:"Context Usage"}),a.jsxs("span",{style:{color:o_(i.usedPercent)},children:[fl(i.totalTokens)," / ",fl(i.contextWindow)," (",i.usedPercent,"%)"]})]}),a.jsx("div",{style:{height:"28px",background:"var(--bg-tertiary)",borderRadius:"6px",overflow:"hidden",display:"flex"},children:p.map(y=>y.percent>0&&a.jsx("div",{style:{width:`${y.percent}%`,background:y.color,height:"100%",minWidth:y.percent>.5?"2px":"0",transition:"width 0.3s ease"},title:`${y.label}: ${fl(y.tokens)} (${K0(y.percent)})`},y.key))})]}),a.jsxs("div",{style:{marginBottom:"16px"},children:[a.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Token Breakdown"}),a.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:h.map(y=>a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",background:y.key==="freeSpace"?"transparent":"var(--bg-secondary)",borderRadius:"6px",borderLeft:y.key==="freeSpace"?"3px dashed rgba(255,255,255,0.2)":`3px solid ${y.color}`,opacity:y.key==="freeSpace"?.7:1},children:[a.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"3px",background:y.color,flexShrink:0,border:y.key==="freeSpace"?"1px dashed rgba(255,255,255,0.3)":"none"}}),a.jsxs("div",{style:{flex:1},children:[a.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:y.label}),a.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:y.description})]}),a.jsxs("div",{style:{textAlign:"right"},children:[a.jsx("div",{style:{fontSize:"13px",fontWeight:500},children:fl(y.tokens)}),a.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:K0(y.percent)})]})]},y.key))})]}),a.jsxs("div",{style:{fontSize:"11px",color:"var(--text-muted)",textAlign:"center"},children:["Last updated: ",new Date(i.lastUpdated).toLocaleTimeString()]})]}):a.jsxs("div",{style:{textAlign:"center",color:"var(--text-secondary)",padding:"32px"},children:[a.jsx("div",{style:{fontSize:"48px",marginBottom:"16px",opacity:.5},children:"📊"}),a.jsx("div",{style:{fontSize:"14px",marginBottom:"8px"},children:"No context data available yet"}),a.jsx("div",{style:{fontSize:"12px",marginBottom:"20px",opacity:.7},children:"Click the Refresh button above to fetch detailed stats"}),n&&a.jsxs("button",{className:"btn btn-primary",onClick:c,disabled:o||s.status!=="idle",style:{padding:"10px 24px",fontSize:"14px",display:"inline-flex",alignItems:"center",gap:"8px"},children:[a.jsx("span",{style:{display:"inline-block",animation:o?"spin 1s linear infinite":"none"},children:o?"⟳":"↻"}),o?"Fetching Stats...":"Fetch Context Stats"]}),s.status!=="idle"&&a.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",marginTop:"12px"},children:"Agent must be idle to fetch stats"})]})}),a.jsx("div",{className:"modal-footer",style:{display:"flex",justifyContent:"flex-end",padding:"12px 16px",borderTop:"1px solid var(--border-color)"},children:a.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Close"})})]})}):null}const u_=x.memo(function({tokensUsed:e,createdAt:t}){return a.jsxs("div",{className:"unit-stats",children:[a.jsxs("div",{className:"unit-stat",children:[a.jsx("div",{className:"unit-stat-label",children:"Tokens"}),a.jsx("div",{className:"unit-stat-value",children:Tp(e)})]}),a.jsxs("div",{className:"unit-stat",children:[a.jsx("div",{className:"unit-stat-label",children:"Uptime"}),a.jsx("div",{className:"unit-stat-value",children:QE(t)})]})]})}),hS=x.memo(function({contextInfo:e,onClick:t}){const{remainingPercent:n,hasData:i}=e;return a.jsxs("div",{className:"unit-context unit-context-clickable",onClick:t,title:i?"Click for detailed context breakdown":"Click to fetch context stats",style:{cursor:"pointer"},children:[a.jsxs("div",{className:"unit-stat-label",style:{display:"flex",alignItems:"center",gap:"4px"},children:[a.jsx("span",{children:"Remaining Context"}),i?a.jsx("span",{style:{fontSize:"10px",opacity:.6},children:"📊"}):a.jsx("span",{style:{fontSize:"9px",color:"#ff9e4a",opacity:.8},title:"Click to fetch accurate stats",children:"⚠️"})]}),i?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"unit-context-bar",children:a.jsx("div",{className:"unit-context-fill",style:{width:`${n}%`,background:e_(n)}})}),a.jsxs("span",{className:"unit-context-value",children:[Math.round(n),"%"]})]}):a.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",fontStyle:"italic"},children:"Not retrieved yet"})]})}),d_=x.memo(function({lastActivity:e}){return a.jsxs("div",{className:"unit-idle-timer",title:"Time since last activity",style:{color:hf(e)},children:["⏱ ",Sf(e)]})}),h_=x.memo(function({toolName:e}){return a.jsxs("div",{className:"unit-current-tool",children:[a.jsx("span",{className:"unit-stat-label",children:"Using:"}),a.jsx("span",{className:"unit-tool-name",children:e})]})}),m_=x.memo(function({task:e}){return a.jsxs("div",{className:"unit-task",children:[a.jsx("div",{className:"unit-stat-label",children:"Task"}),a.jsx("div",{className:"unit-task-text",children:e})]})}),p_=x.memo(function({cwd:e}){return a.jsxs("div",{className:"unit-cwd",children:[a.jsx("div",{className:"unit-stat-label",children:"CWD"}),a.jsx("div",{className:"unit-cwd-path",title:e,children:e})]})}),f_=x.memo(function({text:e,maxLength:t=150}){return a.jsxs("div",{className:"unit-last-prompt",children:[a.jsx("div",{className:"unit-stat-label",children:"Last Prompt"}),a.jsx("div",{className:"unit-last-prompt-text",children:e.length>t?e.slice(0,t)+"...":e})]})}),g_=x.memo(function({text:e,maxLength:t=200}){return a.jsxs("div",{className:"unit-last-message",children:[a.jsx("div",{className:"unit-stat-label",children:"Last Response"}),a.jsx("div",{className:"unit-last-message-text",children:e.length>t?e.slice(0,t)+"...":e})]})});function b_({agent:s,onFocusAgent:e,onKillAgent:t,onCallSubordinates:n,onOpenAreaExplorer:i}){var me,pe;const o=ns(),r=Zn(),{showToast:c}=rS(),d=o.agents.get(s.id)||s,h=Ci(d.class,r),p=r.find(ne=>ne.id===d.class),f=p==null?void 0:p.model,g=p!=null&&p.customModelPath?lt(`/api/custom-models/${p.id}`):void 0,y=p==null?void 0:p.modelScale,[v,w]=x.useState(!1),[S,C]=x.useState(d.name),A=x.useRef(null),[,N]=x.useState(0),[_,M]=x.useState(!0),[E,z]=x.useState(!1),[T,R]=x.useState([]),[D,O]=x.useState(null),[P,K]=x.useState(!1),[Y,$]=x.useState(!1),L=I.getAgentSupervisorHistory(d.id),q=I.isLoadingHistoryForAgent(d.id);x.useEffect(()=>{!I.hasHistoryBeenFetched(d.id)&&!q&&I.requestAgentSupervisorHistory(d.id)},[d.id,q]),x.useEffect(()=>{C(d.name)},[d.name]),x.useEffect(()=>{v&&A.current&&(A.current.focus(),A.current.select())},[v]),x.useEffect(()=>{if(d.status==="idle"){const ne=setInterval(()=>{N(xe=>xe+1)},15e3);return()=>clearInterval(ne)}},[d.status]),x.useEffect(()=>{d.permissionMode==="interactive"&&Ct(lt("/api/remembered-patterns")).then(ne=>ne.json()).then(R).catch(ne=>console.error("Failed to fetch remembered patterns:",ne))},[d.permissionMode]);const V=x.useMemo(()=>cS(d),[d.contextStats,d.contextUsed,d.contextLimit]),G=I.getAreaForAgent(d.id),B=o.agentOutputs.get(d.id)||[],Q=B.length>0?B[B.length-1]:null,U=o.lastPrompts.get(d.id),H=async(ne,xe)=>{try{(await Ct(lt(`/api/remembered-patterns/${ne}/${encodeURIComponent(xe)}`),{method:"DELETE"})).ok&&R(Pe=>Pe.filter(Ae=>!(Ae.tool===ne&&Ae.pattern===xe)))}catch(fe){console.error("Failed to remove pattern:",fe)}},te=async()=>{if(confirm("Clear all remembered permission patterns?"))try{(await Ct(lt("/api/remembered-patterns"),{method:"DELETE"})).ok&&R([])}catch(ne){console.error("Failed to clear patterns:",ne)}},ae=()=>{confirm("Are you sure you want to terminate this agent?")&&t(d.id)},J=()=>{const ne=S.trim();ne&&ne!==d.name?I.renameAgent(d.id,ne):C(d.name),w(!1)},he=ne=>{ne.key==="Enter"?J():ne.key==="Escape"&&(C(d.name),w(!1))};return a.jsxs("div",{className:"unit-panel",children:[a.jsx("div",{className:"unit-model-preview",children:a.jsx(dr,{agentClass:d.class,modelFile:f,customModelUrl:g,modelScale:y,status:d.status,width:80,height:80})}),a.jsxs("div",{className:"unit-panel-header",children:[a.jsx("div",{className:"unit-class-icon",style:{background:`${h.color}20`},children:h.icon}),a.jsxs("div",{className:"unit-header-info",children:[v?a.jsx("input",{ref:A,type:"text",className:"unit-name-input",value:S,onChange:ne=>C(ne.target.value),onBlur:J,onKeyDown:he}):a.jsx("div",{className:"unit-name unit-name-editable",onClick:()=>w(!0),title:"Click to rename",children:d.name}),a.jsxs("div",{className:"unit-status",children:[a.jsx("span",{style:{color:Mu[d.status]||Mu.default},children:d.status}),a.jsxs("span",{children:[" • ",d.class," • ",d.provider]})]}),d.status==="idle"&&d.lastActivity>0&&a.jsx(d_,{lastActivity:d.lastActivity})]}),a.jsxs("div",{className:"unit-header-actions",children:[a.jsx("button",{className:"unit-action-icon",onClick:()=>e(d.id),title:"Focus on agent",children:"🎯"}),a.jsx("button",{className:"unit-action-icon",onClick:()=>K(!0),title:"Edit agent properties",children:"✏️"}),(d.isBoss||d.class==="boss")&&d.subordinateIds&&d.subordinateIds.length>0&&a.jsx("button",{className:"unit-action-icon",onClick:()=>n==null?void 0:n(d.id),title:"Call subordinates",children:"📢"}),a.jsx("button",{className:"unit-action-icon",onClick:()=>O("collapse"),title:"Collapse context",disabled:d.status!=="idle",children:"📦"}),a.jsx("button",{className:"unit-action-icon warning",onClick:()=>O("clear"),title:"Clear context",children:"🗑️"}),a.jsx("button",{className:"unit-action-icon danger",onClick:ae,title:"Kill agent",children:"☠️"})]})]}),G&&a.jsxs("div",{className:"unit-area",children:[a.jsx("span",{className:"unit-area-dot",style:{background:G.color}}),a.jsx("span",{className:"unit-area-name",children:G.name})]}),U&&a.jsx(f_,{text:U.text}),Q&&a.jsx(g_,{text:Q.text}),a.jsx(u_,{tokensUsed:d.tokensUsed,createdAt:d.createdAt}),a.jsx(hS,{contextInfo:V,onClick:()=>$(!0)}),d.currentTool&&a.jsx(h_,{toolName:d.currentTool}),d.currentTask&&a.jsx(m_,{task:d.currentTask}),a.jsx(p_,{cwd:d.cwd}),a.jsxs("div",{className:"unit-permission-mode",children:[a.jsx("div",{className:"unit-stat-label",children:"Permissions"}),a.jsxs("div",{className:"unit-permission-mode-value",title:(me=Kn[d.permissionMode])==null?void 0:me.description,children:[a.jsx("span",{className:"unit-permission-mode-icon",children:d.permissionMode==="bypass"?"⚡":"🔐"}),a.jsx("span",{className:"unit-permission-mode-label",children:((pe=Kn[d.permissionMode])==null?void 0:pe.label)||d.permissionMode})]})]}),d.permissionMode==="interactive"&&a.jsx(y_,{patterns:T,showPatterns:E,onToggle:()=>z(!E),onRemovePattern:H,onClearAll:te}),d.sessionId?a.jsxs("div",{className:"unit-resume-cmd",children:[a.jsx("div",{className:"unit-stat-label",children:"Resume Session"}),a.jsxs("div",{className:"unit-resume-cmd-text",title:"Click to copy",onClick:async()=>{try{await navigator.clipboard.writeText(`codex resume ${d.sessionId}`),c("success","Copied!","Resume command copied to clipboard",2e3)}catch{c("error","Error","Failed to copy to clipboard",3e3)}},children:["codex resume ",d.sessionId]})]}):a.jsxs("div",{className:"unit-resume-cmd",children:[a.jsx("div",{className:"unit-stat-label",children:"Session"}),a.jsx("div",{className:"unit-new-session-indicator",children:"New agent, new session"})]}),a.jsxs("div",{className:"unit-supervisor-history",children:[a.jsxs("div",{className:"unit-supervisor-history-header",onClick:()=>M(!_),children:[a.jsx("div",{className:"unit-stat-label",children:"Supervisor History"}),a.jsxs("span",{className:"unit-supervisor-history-toggle",children:[L.length>0&&a.jsx("span",{className:"unit-supervisor-history-count",children:L.length}),_?"▼":"▶"]})]}),_&&a.jsx("div",{className:"unit-supervisor-history-list",children:q?a.jsx("div",{className:"unit-supervisor-history-loading",children:"Loading..."}):L.length===0?a.jsx("div",{className:"unit-supervisor-history-empty",children:"No supervisor reports yet"}):L.slice(0,10).map((ne,xe)=>a.jsx(v_,{entry:ne,defaultExpanded:xe===0},ne.id))})]}),(d.isBoss||d.class==="boss")&&a.jsx(w_,{agent:d}),d.bossId&&a.jsx(S_,{agentId:d.id,bossId:d.bossId}),d.class!=="boss"&&!d.isBoss&&!d.bossId&&a.jsx(j_,{agentId:d.id}),D&&a.jsx(x_,{action:D,agentName:d.name,onClose:()=>O(null),onConfirm:()=>{D==="collapse"?I.collapseContext(d.id):I.clearContext(d.id),O(null)}}),a.jsx(uS,{agent:d,isOpen:P,onClose:()=>K(!1)}),a.jsx(dS,{agent:d,isOpen:Y,onClose:()=>$(!1),onRefresh:()=>{I.refreshAgentContext(d.id)}})]})}const y_=x.memo(function({patterns:e,showPatterns:t,onToggle:n,onRemovePattern:i,onClearAll:o}){return a.jsxs("div",{className:"unit-remembered-patterns",children:[a.jsxs("div",{className:"unit-remembered-patterns-header",onClick:n,children:[a.jsx("div",{className:"unit-stat-label",children:"Allowed Patterns"}),a.jsxs("span",{className:"unit-remembered-patterns-toggle",children:[e.length>0&&a.jsx("span",{className:"unit-remembered-patterns-count",children:e.length}),t?"▼":"▶"]})]}),t&&a.jsx("div",{className:"unit-remembered-patterns-list",children:e.length===0?a.jsx("div",{className:"unit-remembered-patterns-empty",children:"No patterns remembered yet. Click ✓+ when approving to remember."}):a.jsxs(a.Fragment,{children:[e.map((r,c)=>a.jsxs("div",{className:"unit-remembered-pattern-item",children:[a.jsx("span",{className:"unit-pattern-tool",children:r.tool}),a.jsx("span",{className:"unit-pattern-desc",title:r.pattern,children:r.description}),a.jsx("button",{className:"unit-pattern-remove",onClick:()=>i(r.tool,r.pattern),title:"Remove this pattern",children:"×"})]},c)),a.jsx("button",{className:"unit-patterns-clear-all",onClick:o,children:"Clear All"})]})})]})}),x_=x.memo(function({action:e,agentName:t,onClose:n,onConfirm:i}){const{handleMouseDown:o,handleClick:r}=Us(n);return a.jsx("div",{className:"modal-overlay visible",onMouseDown:o,onClick:r,children:a.jsxs("div",{className:"modal confirm-modal",children:[a.jsx("div",{className:"modal-header",children:e==="collapse"?"Collapse Context":"Clear Context"}),a.jsx("div",{className:"modal-body confirm-modal-body",children:e==="collapse"?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Collapse the conversation context for ",a.jsx("strong",{children:t}),"?"]}),a.jsx("p",{className:"confirm-modal-note",children:"This will summarize the conversation to save tokens while preserving important information."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Clear all context for ",a.jsx("strong",{children:t}),"?"]}),a.jsx("p",{className:"confirm-modal-note",children:"This will start a fresh session on the next command. All conversation history will be lost."})]})}),a.jsxs("div",{className:"modal-footer",children:[a.jsx("button",{className:"btn btn-secondary",onClick:n,children:"Cancel"}),a.jsx("button",{className:`btn ${e==="clear"?"btn-danger":"btn-primary"}`,onClick:i,autoFocus:!0,children:e==="collapse"?"Collapse":"Clear Context"})]})]})})}),v_=x.memo(function({entry:e,defaultExpanded:t=!1}){var f;const[n,i]=x.useState(t),o=ns(),{analysis:r}=e,c=o.settings.hideCost,d=vi(r.statusDescription,c),h=vi(r.recentWorkSummary,c),p=(f=r.concerns)==null?void 0:f.map(g=>vi(g,c)).filter(g=>g.length>0);return a.jsxs("div",{className:"supervisor-history-item",children:[a.jsxs("div",{className:"supervisor-history-item-header",onClick:()=>i(!n),children:[a.jsx("span",{className:"supervisor-history-progress-dot",style:{background:Fk[r.progress]||"#888"},title:r.progress}),a.jsx("span",{className:"supervisor-history-status",children:d}),a.jsx("span",{className:"supervisor-history-time",children:Bu(e.timestamp)})]}),n&&a.jsxs("div",{className:"supervisor-history-item-details",children:[a.jsxs("div",{className:"supervisor-history-summary",children:[a.jsx("strong",{children:"Summary:"})," ",h]}),p&&p.length>0&&a.jsxs("div",{className:"supervisor-history-concerns",children:[a.jsx("strong",{children:"Concerns:"}),a.jsx("ul",{children:p.map((g,y)=>a.jsx("li",{children:g},y))})]})]})]})}),w_=x.memo(function({agent:e}){const t=ns(),n=Zn(),[i,o]=x.useState(!0),[r,c]=x.useState(!0),d=x.useMemo(()=>{const y=t.agents.get(e.id);return!y||!y.isBoss&&y.class!=="boss"||!y.subordinateIds?[]:y.subordinateIds.map(v=>t.agents.get(v)).filter(v=>v!==void 0)},[t.agents,e.id]),h=I.getDelegationHistory(e.id),p=t.pendingDelegation,f=(p==null?void 0:p.bossId)===e.id;x.useEffect(()=>{I.requestDelegationHistory(e.id)},[e.id]);const g=ua.boss;return a.jsxs("div",{className:"boss-section",children:[a.jsxs("div",{className:"boss-header",children:[a.jsx("span",{className:"boss-crown-icon",style:{color:g.color},children:g.icon}),a.jsx("span",{className:"boss-title",children:"Boss Agent"})]}),a.jsxs("div",{className:"boss-subordinates",children:[a.jsxs("div",{className:"boss-subordinates-header",onClick:()=>o(!i),children:[a.jsxs("div",{className:"unit-stat-label",children:["Team (",d.length,")"]}),a.jsx("span",{className:"boss-toggle",children:i?"▼":"▶"})]}),i&&a.jsx("div",{className:"boss-subordinates-list",children:d.length===0?a.jsx("div",{className:"boss-subordinates-empty",children:'No subordinates assigned. Use "Manage Team" to add agents.'}):d.map(y=>{const v=Ci(y.class,n);return a.jsxs("div",{className:"boss-subordinate-item",onClick:()=>I.selectAgent(y.id),children:[a.jsx("span",{className:"boss-subordinate-icon",style:{color:v.color},children:v.icon}),a.jsx("span",{className:"boss-subordinate-name",children:y.name}),a.jsx("span",{className:`boss-subordinate-status status-${y.status}`,children:y.status}),a.jsx("button",{className:"boss-subordinate-unlink",onClick:w=>{w.stopPropagation(),I.removeSubordinate(e.id,y.id)},title:"Unlink subordinate",children:"✕"})]},y.id)})})]}),a.jsxs("div",{className:"boss-delegation-history",children:[a.jsxs("div",{className:"boss-delegation-history-header",onClick:()=>c(!r),children:[a.jsxs("div",{className:"unit-stat-label",children:["Delegation History (",h.length,")"]}),a.jsx("span",{className:"boss-toggle",children:r?"▼":"▶"})]}),r&&a.jsxs("div",{className:"boss-delegation-history-list",children:[f&&a.jsxs("div",{className:"boss-delegation-pending",children:[a.jsx("span",{className:"delegation-spinner",children:"⏳"}),"Analyzing request..."]}),h.length===0&&!f?a.jsx("div",{className:"boss-delegation-empty",children:"No delegation history yet. Send commands to this boss to delegate tasks."}):h.slice(0,10).map(y=>a.jsx(k_,{decision:y},y.id))]})]})]})}),k_=x.memo(function({decision:e}){const[t,n]=x.useState(!1),o=ns().agents.get(e.selectedAgentId),r=o?ua[o.class]:null,c={high:"#4aff9e",medium:"#ff9e4a",low:"#ff4a4a"};return a.jsxs("div",{className:"delegation-decision-item",children:[a.jsxs("div",{className:"delegation-decision-header",onClick:()=>n(!t),children:[a.jsx("span",{className:"delegation-decision-arrow",children:t?"▼":"▶"}),r&&a.jsx("span",{className:"delegation-decision-icon",style:{color:r.color},children:r.icon}),a.jsxs("span",{className:"delegation-decision-agent",children:["→ ",e.selectedAgentName]}),a.jsx("span",{className:"delegation-decision-confidence",style:{color:c[e.confidence]},title:`Confidence: ${e.confidence}`,children:e.confidence==="high"?"●●●":e.confidence==="medium"?"●●○":"●○○"}),a.jsx("span",{className:"delegation-decision-time",children:Bu(e.timestamp)})]}),t&&a.jsxs("div",{className:"delegation-decision-details",children:[a.jsxs("div",{className:"delegation-decision-command",children:[a.jsx("strong",{children:"Command:"}),a.jsx("div",{className:"delegation-command-text",children:e.userCommand.length>200?e.userCommand.slice(0,200)+"...":e.userCommand})]}),a.jsxs("div",{className:"delegation-decision-reasoning",children:[a.jsx("strong",{children:"Reasoning:"})," ",e.reasoning]}),e.alternativeAgents.length>0&&a.jsxs("div",{className:"delegation-decision-alternatives",children:[a.jsx("strong",{children:"Alternatives:"})," ",e.alternativeAgents.join(", ")]})]})]})}),S_=x.memo(function({agentId:e,bossId:t}){const i=ns().agents.get(t);if(!i)return null;const o=ua.boss,r=c=>{c.stopPropagation(),I.removeSubordinate(t,e)};return a.jsxs("div",{className:"subordinate-badge",children:[a.jsx("span",{className:"subordinate-badge-icon",style:{color:o.color},children:o.icon}),a.jsxs("span",{className:"subordinate-badge-text",children:["Reports to: ",a.jsx("strong",{children:i.name})]}),a.jsx("button",{className:"subordinate-badge-goto",onClick:()=>I.selectAgent(t),title:"Go to boss",children:"→"}),a.jsx("button",{className:"subordinate-badge-unlink",onClick:r,title:"Unlink from boss",children:"✕"})]})}),j_=x.memo(function({agentId:e}){const t=ns(),[n,i]=x.useState(!1),o=Array.from(t.agents.values()).filter(d=>d.isBoss===!0||d.class==="boss");if(o.length===0)return null;const r=ua.boss,c=d=>{const h=t.agents.get(d);if(!h)return;const p=h.subordinateIds||[];I.assignSubordinates(d,[...p,e]),i(!1)};return a.jsx("div",{className:"link-to-boss-section",children:n?a.jsxs("div",{className:"link-to-boss-dropdown",children:[a.jsxs("div",{className:"link-to-boss-header",children:[a.jsx("span",{children:"Select a Boss"}),a.jsx("button",{className:"link-to-boss-close",onClick:()=>i(!1),children:"✕"})]}),a.jsx("div",{className:"link-to-boss-list",children:o.map(d=>{var h;return a.jsxs("div",{className:"link-to-boss-item",onClick:()=>c(d.id),children:[a.jsx("span",{className:"link-to-boss-item-icon",style:{color:r.color},children:r.icon}),a.jsx("span",{className:"link-to-boss-item-name",children:d.name}),a.jsxs("span",{className:"link-to-boss-item-count",children:[((h=d.subordinateIds)==null?void 0:h.length)||0," agents"]})]},d.id)})})]}):a.jsxs("button",{className:"link-to-boss-btn",onClick:()=>i(!0),children:[a.jsx("span",{className:"link-to-boss-icon",style:{color:r.color},children:r.icon}),a.jsx("span",{children:"Link to Boss"})]})})}),C_=x.memo(function({agents:e}){const t=Zn(),n=e.reduce((o,r)=>o+r.tokensUsed,0),i=e.filter(o=>o.status==="working").length;return a.jsxs("div",{className:"unit-panel",children:[a.jsxs("div",{className:"unit-panel-header",children:[a.jsx("div",{className:"unit-class-icon",style:{background:"#4a9eff20"},children:"👥"}),a.jsxs("div",{children:[a.jsxs("div",{className:"unit-name",children:[e.length," Agents Selected"]}),a.jsx("div",{className:"unit-status",children:"Group selection"})]})]}),a.jsxs("div",{className:"unit-stats",children:[a.jsxs("div",{className:"unit-stat",children:[a.jsx("div",{className:"unit-stat-label",children:"Total Tokens"}),a.jsx("div",{className:"unit-stat-value",children:ZE(n)})]}),a.jsxs("div",{className:"unit-stat",children:[a.jsx("div",{className:"unit-stat-label",children:"Working"}),a.jsx("div",{className:"unit-stat-value",children:i})]})]}),a.jsx("div",{style:{padding:"8px 0",maxHeight:100,overflowY:"auto"},children:e.map(o=>a.jsx(A_,{agent:o,customClasses:t},o.id))}),a.jsx("div",{className:"unit-actions",children:a.jsx("button",{className:"unit-action-btn",onClick:()=>I.deselectAll(),children:"Deselect All"})})]})}),A_=x.memo(function({agent:e,customClasses:t}){const n=Ci(e.class,t);return a.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0",fontSize:12},children:[a.jsx("span",{children:n.icon}),a.jsx("span",{style:{flex:1},children:e.name}),a.jsx("span",{style:{color:"var(--text-secondary)"},children:e.status})]})});function V0({onFocusAgent:s,onKillAgent:e,onCallSubordinates:t,onOpenAreaExplorer:n}){const i=ns(),o=I.getSelectedAgents();if(i.selectedAgentIds.size===0)return a.jsx(q0,{onOpenAreaExplorer:n});if(i.selectedAgentIds.size===1){const r=o[0];return r?a.jsx(b_,{agent:r,onFocusAgent:s,onKillAgent:e,onCallSubordinates:t,onOpenAreaExplorer:n}):a.jsx(q0,{onOpenAreaExplorer:n})}return a.jsx(C_,{agents:o})}function N_(s,e){const t={};return(s[s.length-1]===""?[...s,""]:s).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}const T_=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,M_=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,E_={};function Y0(s,e){return(E_.jsx?M_:T_).test(s)}const __=/[ \t\n\f\r]/g;function R_(s){return typeof s=="object"?s.type==="text"?X0(s.value):!1:X0(s)}function X0(s){return s.replace(__,"")===""}class Gl{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}}Gl.prototype.normal={};Gl.prototype.property={};Gl.prototype.space=void 0;function mS(s,e){const t={},n={};for(const i of s)Object.assign(t,i.property),Object.assign(n,i.normal);return new Gl(t,n,e)}function Mp(s){return s.toLowerCase()}class un{constructor(e,t){this.attribute=t,this.property=e}}un.prototype.attribute="";un.prototype.booleanish=!1;un.prototype.boolean=!1;un.prototype.commaOrSpaceSeparated=!1;un.prototype.commaSeparated=!1;un.prototype.defined=!1;un.prototype.mustUseProperty=!1;un.prototype.number=!1;un.prototype.overloadedBoolean=!1;un.prototype.property="";un.prototype.spaceSeparated=!1;un.prototype.space=void 0;let D_=0;const jt=mo(),Ns=mo(),Ep=mo(),$e=mo(),is=mo(),cr=mo(),yn=mo();function mo(){return 2**++D_}const _p=Object.freeze(Object.defineProperty({__proto__:null,boolean:jt,booleanish:Ns,commaOrSpaceSeparated:yn,commaSeparated:cr,number:$e,overloadedBoolean:Ep,spaceSeparated:is},Symbol.toStringTag,{value:"Module"})),Rm=Object.keys(_p);class jf extends un{constructor(e,t,n,i){let o=-1;if(super(e,t),Z0(this,"space",i),typeof n=="number")for(;++o<Rm.length;){const r=Rm[o];Z0(this,Rm[o],(n&_p[r])===_p[r])}}}jf.prototype.defined=!0;function Z0(s,e,t){t&&(s[e]=t)}function mr(s){const e={},t={};for(const[n,i]of Object.entries(s.properties)){const o=new jf(n,s.transform(s.attributes||{},n),i,s.space);s.mustUseProperty&&s.mustUseProperty.includes(n)&&(o.mustUseProperty=!0),e[n]=o,t[Mp(n)]=n,t[Mp(o.attribute)]=n}return new Gl(e,t,s.space)}const pS=mr({properties:{ariaActiveDescendant:null,ariaAtomic:Ns,ariaAutoComplete:null,ariaBusy:Ns,ariaChecked:Ns,ariaColCount:$e,ariaColIndex:$e,ariaColSpan:$e,ariaControls:is,ariaCurrent:null,ariaDescribedBy:is,ariaDetails:null,ariaDisabled:Ns,ariaDropEffect:is,ariaErrorMessage:null,ariaExpanded:Ns,ariaFlowTo:is,ariaGrabbed:Ns,ariaHasPopup:null,ariaHidden:Ns,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:is,ariaLevel:$e,ariaLive:null,ariaModal:Ns,ariaMultiLine:Ns,ariaMultiSelectable:Ns,ariaOrientation:null,ariaOwns:is,ariaPlaceholder:null,ariaPosInSet:$e,ariaPressed:Ns,ariaReadOnly:Ns,ariaRelevant:null,ariaRequired:Ns,ariaRoleDescription:is,ariaRowCount:$e,ariaRowIndex:$e,ariaRowSpan:$e,ariaSelected:Ns,ariaSetSize:$e,ariaSort:null,ariaValueMax:$e,ariaValueMin:$e,ariaValueNow:$e,ariaValueText:null,role:null},transform(s,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function fS(s,e){return e in s?s[e]:e}function gS(s,e){return fS(s,e.toLowerCase())}const L_=mr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:cr,acceptCharset:is,accessKey:is,action:null,allow:null,allowFullScreen:jt,allowPaymentRequest:jt,allowUserMedia:jt,alt:null,as:null,async:jt,autoCapitalize:null,autoComplete:is,autoFocus:jt,autoPlay:jt,blocking:is,capture:null,charSet:null,checked:jt,cite:null,className:is,cols:$e,colSpan:null,content:null,contentEditable:Ns,controls:jt,controlsList:is,coords:$e|cr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:jt,defer:jt,dir:null,dirName:null,disabled:jt,download:Ep,draggable:Ns,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:jt,formTarget:null,headers:is,height:$e,hidden:Ep,high:$e,href:null,hrefLang:null,htmlFor:is,httpEquiv:is,id:null,imageSizes:null,imageSrcSet:null,inert:jt,inputMode:null,integrity:null,is:null,isMap:jt,itemId:null,itemProp:is,itemRef:is,itemScope:jt,itemType:is,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:jt,low:$e,manifest:null,max:null,maxLength:$e,media:null,method:null,min:null,minLength:$e,multiple:jt,muted:jt,name:null,nonce:null,noModule:jt,noValidate:jt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:jt,optimum:$e,pattern:null,ping:is,placeholder:null,playsInline:jt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:jt,referrerPolicy:null,rel:is,required:jt,reversed:jt,rows:$e,rowSpan:$e,sandbox:is,scope:null,scoped:jt,seamless:jt,selected:jt,shadowRootClonable:jt,shadowRootDelegatesFocus:jt,shadowRootMode:null,shape:null,size:$e,sizes:null,slot:null,span:$e,spellCheck:Ns,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$e,step:null,style:null,tabIndex:$e,target:null,title:null,translate:null,type:null,typeMustMatch:jt,useMap:null,value:Ns,width:$e,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:is,axis:null,background:null,bgColor:null,border:$e,borderColor:null,bottomMargin:$e,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:jt,declare:jt,event:null,face:null,frame:null,frameBorder:null,hSpace:$e,leftMargin:$e,link:null,longDesc:null,lowSrc:null,marginHeight:$e,marginWidth:$e,noResize:jt,noHref:jt,noShade:jt,noWrap:jt,object:null,profile:null,prompt:null,rev:null,rightMargin:$e,rules:null,scheme:null,scrolling:Ns,standby:null,summary:null,text:null,topMargin:$e,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$e,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:jt,disableRemotePlayback:jt,prefix:null,property:null,results:$e,security:null,unselectable:null},space:"html",transform:gS}),B_=mr({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:yn,accentHeight:$e,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$e,amplitude:$e,arabicForm:null,ascent:$e,attributeName:null,attributeType:null,azimuth:$e,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$e,by:null,calcMode:null,capHeight:$e,className:is,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$e,diffuseConstant:$e,direction:null,display:null,dur:null,divisor:$e,dominantBaseline:null,download:jt,dx:null,dy:null,edgeMode:null,editable:null,elevation:$e,enableBackground:null,end:null,event:null,exponent:$e,externalResourcesRequired:null,fill:null,fillOpacity:$e,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:cr,g2:cr,glyphName:cr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$e,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$e,horizOriginX:$e,horizOriginY:$e,id:null,ideographic:$e,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$e,k:$e,k1:$e,k2:$e,k3:$e,k4:$e,kernelMatrix:yn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$e,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$e,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$e,overlineThickness:$e,paintOrder:null,panose1:null,path:null,pathLength:$e,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:is,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$e,pointsAtY:$e,pointsAtZ:$e,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:yn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:yn,rev:yn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:yn,requiredFeatures:yn,requiredFonts:yn,requiredFormats:yn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$e,specularExponent:$e,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$e,strikethroughThickness:$e,string:null,stroke:null,strokeDashArray:yn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$e,strokeOpacity:$e,strokeWidth:null,style:null,surfaceScale:$e,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:yn,tabIndex:$e,tableValues:null,target:null,targetX:$e,targetY:$e,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:yn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$e,underlineThickness:$e,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$e,values:null,vAlphabetic:$e,vMathematical:$e,vectorEffect:null,vHanging:$e,vIdeographic:$e,version:null,vertAdvY:$e,vertOriginX:$e,vertOriginY:$e,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$e,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:fS}),bS=mr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(s,e){return"xlink:"+e.slice(5).toLowerCase()}}),yS=mr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:gS}),xS=mr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(s,e){return"xml:"+e.slice(3).toLowerCase()}}),O_={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},P_=/[A-Z]/g,Q0=/-[a-z]/g,I_=/^data[-\w.:]+$/i;function z_(s,e){const t=Mp(e);let n=e,i=un;if(t in s.normal)return s.property[s.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&I_.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(Q0,H_);n="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!Q0.test(o)){let r=o.replace(P_,F_);r.charAt(0)!=="-"&&(r="-"+r),e="data"+r}}i=jf}return new i(n,e)}function F_(s){return"-"+s.toLowerCase()}function H_(s){return s.charAt(1).toUpperCase()}const $_=mS([pS,L_,bS,yS,xS],"html"),Cf=mS([pS,B_,bS,yS,xS],"svg");function U_(s){return s.join(" ").trim()}var Xo={},Dm,J0;function G_(){if(J0)return Dm;J0=1;var s=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,t=/^\s*/,n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,r=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
|
|
143
143
|
`,h="/",p="*",f="",g="comment",y="declaration";function v(S,C){if(typeof S!="string")throw new TypeError("First argument must be a string");if(!S)return[];C=C||{};var A=1,N=1;function _(Y){var $=Y.match(e);$&&(A+=$.length);var L=Y.lastIndexOf(d);N=~L?Y.length-L:N+Y.length}function M(){var Y={line:A,column:N};return function($){return $.position=new E(Y),R(),$}}function E(Y){this.start=Y,this.end={line:A,column:N},this.source=C.source}E.prototype.content=S;function z(Y){var $=new Error(C.source+":"+A+":"+N+": "+Y);if($.reason=Y,$.filename=C.source,$.line=A,$.column=N,$.source=S,!C.silent)throw $}function T(Y){var $=Y.exec(S);if($){var L=$[0];return _(L),S=S.slice(L.length),$}}function R(){T(t)}function D(Y){var $;for(Y=Y||[];$=O();)$!==!1&&Y.push($);return Y}function O(){var Y=M();if(!(h!=S.charAt(0)||p!=S.charAt(1))){for(var $=2;f!=S.charAt($)&&(p!=S.charAt($)||h!=S.charAt($+1));)++$;if($+=2,f===S.charAt($-1))return z("End of comment missing");var L=S.slice(2,$-2);return N+=2,_(L),S=S.slice($),N+=2,Y({type:g,comment:L})}}function P(){var Y=M(),$=T(n);if($){if(O(),!T(i))return z("property missing ':'");var L=T(o),q=Y({type:y,property:w($[0].replace(s,f)),value:L?w(L[0].replace(s,f)):f});return T(r),q}}function K(){var Y=[];D(Y);for(var $;$=P();)$!==!1&&(Y.push($),D(Y));return Y}return R(),K()}function w(S){return S?S.replace(c,f):f}return Dm=v,Dm}var ev;function q_(){if(ev)return Xo;ev=1;var s=Xo&&Xo.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(Xo,"__esModule",{value:!0}),Xo.default=t;const e=s(G_());function t(n,i){let o=null;if(!n||typeof n!="string")return o;const r=(0,e.default)(n),c=typeof i=="function";return r.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:p}=d;c?i(h,p,d):p&&(o=o||{},o[h]=p)}),o}return Xo}var gl={},tv;function W_(){if(tv)return gl;tv=1,Object.defineProperty(gl,"__esModule",{value:!0}),gl.camelCase=void 0;var s=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,t=/^[^-]+$/,n=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,o=function(h){return!h||t.test(h)||s.test(h)},r=function(h,p){return p.toUpperCase()},c=function(h,p){return"".concat(p,"-")},d=function(h,p){return p===void 0&&(p={}),o(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(i,c):h=h.replace(n,c),h.replace(e,r))};return gl.camelCase=d,gl}var bl,sv;function K_(){if(sv)return bl;sv=1;var s=bl&&bl.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},e=s(q_()),t=W_();function n(i,o){var r={};return!i||typeof i!="string"||(0,e.default)(i,function(c,d){c&&d&&(r[(0,t.camelCase)(c,o)]=d)}),r}return n.default=n,bl=n,bl}var V_=K_();const Y_=Vu(V_),vS=wS("end"),Af=wS("start");function wS(s){return e;function e(t){const n=t&&t.position&&t.position[s]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function X_(s){const e=Af(s),t=vS(s);if(e&&t)return{start:e,end:t}}function Tl(s){return!s||typeof s!="object"?"":"position"in s||"type"in s?nv(s.position):"start"in s||"end"in s?nv(s):"line"in s||"column"in s?Rp(s):""}function Rp(s){return av(s&&s.line)+":"+av(s&&s.column)}function nv(s){return Rp(s&&s.start)+"-"+Rp(s&&s.end)}function av(s){return s&&typeof s=="number"?s:1}class Ws extends Error{constructor(e,t,n){super(),typeof t=="string"&&(n=t,t=void 0);let i="",o={},r=!1;if(t&&("line"in t&&"column"in t?o={place:t}:"start"in t&&"end"in t?o={place:t}:"type"in t?o={ancestors:[t],place:t.position}:o={...t}),typeof e=="string"?i=e:!o.cause&&e&&(r=!0,i=e.message,o.cause=e),!o.ruleId&&!o.source&&typeof n=="string"){const d=n.indexOf(":");d===-1?o.ruleId=n:(o.source=n.slice(0,d),o.ruleId=n.slice(d+1))}if(!o.place&&o.ancestors&&o.ancestors){const d=o.ancestors[o.ancestors.length-1];d&&(o.place=d.position)}const c=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=c?c.line:void 0,this.name=Tl(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=r&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ws.prototype.file="";Ws.prototype.name="";Ws.prototype.reason="";Ws.prototype.message="";Ws.prototype.stack="";Ws.prototype.column=void 0;Ws.prototype.line=void 0;Ws.prototype.ancestors=void 0;Ws.prototype.cause=void 0;Ws.prototype.fatal=void 0;Ws.prototype.place=void 0;Ws.prototype.ruleId=void 0;Ws.prototype.source=void 0;const Nf={}.hasOwnProperty,Z_=new Map,Q_=/[A-Z]/g,J_=new Set(["table","tbody","thead","tfoot","tr"]),eR=new Set(["td","th"]),kS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function tR(s,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const t=e.filePath||void 0;let n;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");n=cR(t,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");n=lR(t,e.jsx,e.jsxs)}const i={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:n,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:t,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?Cf:$_,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},o=SS(i,s,void 0);return o&&typeof o!="string"?o:i.create(s,i.Fragment,{children:o||void 0},void 0)}function SS(s,e,t){if(e.type==="element")return sR(s,e,t);if(e.type==="mdxFlowExpression"||e.type==="mdxTextExpression")return nR(s,e);if(e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement")return iR(s,e,t);if(e.type==="mdxjsEsm")return aR(s,e);if(e.type==="root")return oR(s,e,t);if(e.type==="text")return rR(s,e)}function sR(s,e,t){const n=s.schema;let i=n;e.tagName.toLowerCase()==="svg"&&n.space==="html"&&(i=Cf,s.schema=i),s.ancestors.push(e);const o=CS(s,e.tagName,!1),r=uR(s,e);let c=Mf(s,e);return J_.has(e.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!R_(d):!0})),jS(s,r,o,e),Tf(r,c),s.ancestors.pop(),s.schema=n,s.create(e,o,r,t)}function nR(s,e){if(e.data&&e.data.estree&&s.evaluater){const n=e.data.estree.body[0];return n.type,s.evaluater.evaluateExpression(n.expression)}zl(s,e.position)}function aR(s,e){if(e.data&&e.data.estree&&s.evaluater)return s.evaluater.evaluateProgram(e.data.estree);zl(s,e.position)}function iR(s,e,t){const n=s.schema;let i=n;e.name==="svg"&&n.space==="html"&&(i=Cf,s.schema=i),s.ancestors.push(e);const o=e.name===null?s.Fragment:CS(s,e.name,!0),r=dR(s,e),c=Mf(s,e);return jS(s,r,o,e),Tf(r,c),s.ancestors.pop(),s.schema=n,s.create(e,o,r,t)}function oR(s,e,t){const n={};return Tf(n,Mf(s,e)),s.create(e,s.Fragment,n,t)}function rR(s,e){return e.value}function jS(s,e,t,n){typeof t!="string"&&t!==s.Fragment&&s.passNode&&(e.node=n)}function Tf(s,e){if(e.length>0){const t=e.length>1?e:e[0];t&&(s.children=t)}}function lR(s,e,t){return n;function n(i,o,r,c){const h=Array.isArray(r.children)?t:e;return c?h(o,r,c):h(o,r)}}function cR(s,e){return t;function t(n,i,o,r){const c=Array.isArray(o.children),d=Af(n);return e(i,o,r,c,{columnNumber:d?d.column-1:void 0,fileName:s,lineNumber:d?d.line:void 0},void 0)}}function uR(s,e){const t={};let n,i;for(i in e.properties)if(i!=="children"&&Nf.call(e.properties,i)){const o=hR(s,i,e.properties[i]);if(o){const[r,c]=o;s.tableCellAlignToStyle&&r==="align"&&typeof c=="string"&&eR.has(e.tagName)?n=c:t[r]=c}}if(n){const o=t.style||(t.style={});o[s.stylePropertyNameCase==="css"?"text-align":"textAlign"]=n}return t}function dR(s,e){const t={};for(const n of e.attributes)if(n.type==="mdxJsxExpressionAttribute")if(n.data&&n.data.estree&&s.evaluater){const o=n.data.estree.body[0];o.type;const r=o.expression;r.type;const c=r.properties[0];c.type,Object.assign(t,s.evaluater.evaluateExpression(c.argument))}else zl(s,e.position);else{const i=n.name;let o;if(n.value&&typeof n.value=="object")if(n.value.data&&n.value.data.estree&&s.evaluater){const c=n.value.data.estree.body[0];c.type,o=s.evaluater.evaluateExpression(c.expression)}else zl(s,e.position);else o=n.value===null?!0:n.value;t[i]=o}return t}function Mf(s,e){const t=[];let n=-1;const i=s.passKeys?new Map:Z_;for(;++n<e.children.length;){const o=e.children[n];let r;if(s.passKeys){const d=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(d){const h=i.get(d)||0;r=d+"-"+h,i.set(d,h+1)}}const c=SS(s,o,r);c!==void 0&&t.push(c)}return t}function hR(s,e,t){const n=z_(s.schema,e);if(!(t==null||typeof t=="number"&&Number.isNaN(t))){if(Array.isArray(t)&&(t=n.commaSeparated?N_(t):U_(t)),n.property==="style"){let i=typeof t=="object"?t:mR(s,String(t));return s.stylePropertyNameCase==="css"&&(i=pR(i)),["style",i]}return[s.elementAttributeNameCase==="react"&&n.space?O_[n.property]||n.property:n.attribute,t]}}function mR(s,e){try{return Y_(e,{reactCompat:!0})}catch(t){if(s.ignoreInvalidStyle)return{};const n=t,i=new Ws("Cannot parse `style` attribute",{ancestors:s.ancestors,cause:n,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=s.filePath||void 0,i.url=kS+"#cannot-parse-style-attribute",i}}function CS(s,e,t){let n;if(!t)n={type:"Literal",value:e};else if(e.includes(".")){const i=e.split(".");let o=-1,r;for(;++o<i.length;){const c=Y0(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};r=r?{type:"MemberExpression",object:r,property:c,computed:!!(o&&c.type==="Literal"),optional:!1}:c}n=r}else n=Y0(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};if(n.type==="Literal"){const i=n.value;return Nf.call(s.components,i)?s.components[i]:i}if(s.evaluater)return s.evaluater.evaluateExpression(n);zl(s)}function zl(s,e){const t=new Ws("Cannot handle MDX estrees without `createEvaluater`",{ancestors:s.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw t.file=s.filePath||void 0,t.url=kS+"#cannot-handle-mdx-estrees-without-createevaluater",t}function pR(s){const e={};let t;for(t in s)Nf.call(s,t)&&(e[fR(t)]=s[t]);return e}function fR(s){let e=s.replace(Q_,gR);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function gR(s){return"-"+s.toLowerCase()}const Lm={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},bR={};function Ef(s,e){const t=bR,n=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return AS(s,n,i)}function AS(s,e,t){if(yR(s)){if("value"in s)return s.type==="html"&&!t?"":s.value;if(e&&"alt"in s&&s.alt)return s.alt;if("children"in s)return iv(s.children,e,t)}return Array.isArray(s)?iv(s,e,t):""}function iv(s,e,t){const n=[];let i=-1;for(;++i<s.length;)n[i]=AS(s[i],e,t);return n.join("")}function yR(s){return!!(s&&typeof s=="object")}const ov=document.createElement("i");function _f(s){const e="&"+s+";";ov.innerHTML=e;const t=ov.textContent;return t.charCodeAt(t.length-1)===59&&s!=="semi"||t===e?!1:t}function wn(s,e,t,n){const i=s.length;let o=0,r;if(e<0?e=-e>i?0:i+e:e=e>i?i:e,t=t>0?t:0,n.length<1e4)r=Array.from(n),r.unshift(e,t),s.splice(...r);else for(t&&s.splice(e,t);o<n.length;)r=n.slice(o,o+1e4),r.unshift(e,0),s.splice(...r),o+=1e4,e+=1e4}function Ln(s,e){return s.length>0?(wn(s,s.length,0,e),s):e}const rv={}.hasOwnProperty;function NS(s){const e={};let t=-1;for(;++t<s.length;)xR(e,s[t]);return e}function xR(s,e){let t;for(t in e){const i=(rv.call(s,t)?s[t]:void 0)||(s[t]={}),o=e[t];let r;if(o)for(r in o){rv.call(i,r)||(i[r]=[]);const c=o[r];vR(i[r],Array.isArray(c)?c:c?[c]:[])}}}function vR(s,e){let t=-1;const n=[];for(;++t<e.length;)(e[t].add==="after"?s:n).push(e[t]);wn(s,0,0,n)}function TS(s,e){const t=Number.parseInt(s,e);return t<9||t===11||t>13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCodePoint(t)}function Vn(s){return s.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Zs=Ni(/[A-Za-z]/),qs=Ni(/[\dA-Za-z]/),wR=Ni(/[#-'*+\--9=?A-Z^-~]/);function Ou(s){return s!==null&&(s<32||s===127)}const Dp=Ni(/\d/),kR=Ni(/[\dA-Fa-f]/),SR=Ni(/[!-/:-@[-`{-~]/);function dt(s){return s!==null&&s<-2}function ss(s){return s!==null&&(s<0||s===32)}function Lt(s){return s===-2||s===-1||s===32}const sd=Ni(new RegExp("\\p{P}|\\p{S}","u")),co=Ni(/\s/);function Ni(s){return e;function e(t){return t!==null&&t>-1&&s.test(String.fromCharCode(t))}}function pr(s){const e=[];let t=-1,n=0,i=0;for(;++t<s.length;){const o=s.charCodeAt(t);let r="";if(o===37&&qs(s.charCodeAt(t+1))&&qs(s.charCodeAt(t+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(r=String.fromCharCode(o));else if(o>55295&&o<57344){const c=s.charCodeAt(t+1);o<56320&&c>56319&&c<57344?(r=String.fromCharCode(o,c),i=1):r="�"}else r=String.fromCharCode(o);r&&(e.push(s.slice(n,t),encodeURIComponent(r)),n=t+i+1,r=""),i&&(t+=i,i=0)}return e.join("")+s.slice(n)}function Ft(s,e,t,n){const i=n?n-1:Number.POSITIVE_INFINITY;let o=0;return r;function r(d){return Lt(d)?(s.enter(t),c(d)):e(d)}function c(d){return Lt(d)&&o++<i?(s.consume(d),c):(s.exit(t),e(d))}}const jR={tokenize:CR};function CR(s){const e=s.attempt(this.parser.constructs.contentInitial,n,i);let t;return e;function n(c){if(c===null){s.consume(c);return}return s.enter("lineEnding"),s.consume(c),s.exit("lineEnding"),Ft(s,e,"linePrefix")}function i(c){return s.enter("paragraph"),o(c)}function o(c){const d=s.enter("chunkText",{contentType:"text",previous:t});return t&&(t.next=d),t=d,r(c)}function r(c){if(c===null){s.exit("chunkText"),s.exit("paragraph"),s.consume(c);return}return dt(c)?(s.consume(c),s.exit("chunkText"),o):(s.consume(c),r)}}const AR={tokenize:NR},lv={tokenize:TR};function NR(s){const e=this,t=[];let n=0,i,o,r;return c;function c(N){if(n<t.length){const _=t[n];return e.containerState=_[1],s.attempt(_[0].continuation,d,h)(N)}return h(N)}function d(N){if(n++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,i&&A();const _=e.events.length;let M=_,E;for(;M--;)if(e.events[M][0]==="exit"&&e.events[M][1].type==="chunkFlow"){E=e.events[M][1].end;break}C(n);let z=_;for(;z<e.events.length;)e.events[z][1].end={...E},z++;return wn(e.events,M+1,0,e.events.slice(_)),e.events.length=z,h(N)}return c(N)}function h(N){if(n===t.length){if(!i)return g(N);if(i.currentConstruct&&i.currentConstruct.concrete)return v(N);e.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return e.containerState={},s.check(lv,p,f)(N)}function p(N){return i&&A(),C(n),g(N)}function f(N){return e.parser.lazy[e.now().line]=n!==t.length,r=e.now().offset,v(N)}function g(N){return e.containerState={},s.attempt(lv,y,v)(N)}function y(N){return n++,t.push([e.currentConstruct,e.containerState]),g(N)}function v(N){if(N===null){i&&A(),C(0),s.consume(N);return}return i=i||e.parser.flow(e.now()),s.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),w(N)}function w(N){if(N===null){S(s.exit("chunkFlow"),!0),C(0),s.consume(N);return}return dt(N)?(s.consume(N),S(s.exit("chunkFlow")),n=0,e.interrupt=void 0,c):(s.consume(N),w)}function S(N,_){const M=e.sliceStream(N);if(_&&M.push(null),N.previous=o,o&&(o.next=N),o=N,i.defineSkip(N.start),i.write(M),e.parser.lazy[N.start.line]){let E=i.events.length;for(;E--;)if(i.events[E][1].start.offset<r&&(!i.events[E][1].end||i.events[E][1].end.offset>r))return;const z=e.events.length;let T=z,R,D;for(;T--;)if(e.events[T][0]==="exit"&&e.events[T][1].type==="chunkFlow"){if(R){D=e.events[T][1].end;break}R=!0}for(C(n),E=z;E<e.events.length;)e.events[E][1].end={...D},E++;wn(e.events,T+1,0,e.events.slice(z)),e.events.length=E}}function C(N){let _=t.length;for(;_-- >N;){const M=t[_];e.containerState=M[1],M[0].exit.call(e,s)}t.length=N}function A(){i.write([null]),o=void 0,i=void 0,e.containerState._closeFlow=void 0}}function TR(s,e,t){return Ft(s,s.attempt(this.parser.constructs.document,e,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function hr(s){if(s===null||ss(s)||co(s))return 1;if(sd(s))return 2}function nd(s,e,t){const n=[];let i=-1;for(;++i<s.length;){const o=s[i].resolveAll;o&&!n.includes(o)&&(e=o(e,t),n.push(o))}return e}const Lp={name:"attention",resolveAll:MR,tokenize:ER};function MR(s,e){let t=-1,n,i,o,r,c,d,h,p;for(;++t<s.length;)if(s[t][0]==="enter"&&s[t][1].type==="attentionSequence"&&s[t][1]._close){for(n=t;n--;)if(s[n][0]==="exit"&&s[n][1].type==="attentionSequence"&&s[n][1]._open&&e.sliceSerialize(s[n][1]).charCodeAt(0)===e.sliceSerialize(s[t][1]).charCodeAt(0)){if((s[n][1]._close||s[t][1]._open)&&(s[t][1].end.offset-s[t][1].start.offset)%3&&!((s[n][1].end.offset-s[n][1].start.offset+s[t][1].end.offset-s[t][1].start.offset)%3))continue;d=s[n][1].end.offset-s[n][1].start.offset>1&&s[t][1].end.offset-s[t][1].start.offset>1?2:1;const f={...s[n][1].end},g={...s[t][1].start};cv(f,-d),cv(g,d),r={type:d>1?"strongSequence":"emphasisSequence",start:f,end:{...s[n][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...s[t][1].start},end:g},o={type:d>1?"strongText":"emphasisText",start:{...s[n][1].end},end:{...s[t][1].start}},i={type:d>1?"strong":"emphasis",start:{...r.start},end:{...c.end}},s[n][1].end={...r.start},s[t][1].start={...c.end},h=[],s[n][1].end.offset-s[n][1].start.offset&&(h=Ln(h,[["enter",s[n][1],e],["exit",s[n][1],e]])),h=Ln(h,[["enter",i,e],["enter",r,e],["exit",r,e],["enter",o,e]]),h=Ln(h,nd(e.parser.constructs.insideSpan.null,s.slice(n+1,t),e)),h=Ln(h,[["exit",o,e],["enter",c,e],["exit",c,e],["exit",i,e]]),s[t][1].end.offset-s[t][1].start.offset?(p=2,h=Ln(h,[["enter",s[t][1],e],["exit",s[t][1],e]])):p=0,wn(s,n-1,t-n+3,h),t=n+h.length-p-2;break}}for(t=-1;++t<s.length;)s[t][1].type==="attentionSequence"&&(s[t][1].type="data");return s}function ER(s,e){const t=this.parser.constructs.attentionMarkers.null,n=this.previous,i=hr(n);let o;return r;function r(d){return o=d,s.enter("attentionSequence"),c(d)}function c(d){if(d===o)return s.consume(d),c;const h=s.exit("attentionSequence"),p=hr(d),f=!p||p===2&&i||t.includes(d),g=!i||i===2&&p||t.includes(n);return h._open=!!(o===42?f:f&&(i||!g)),h._close=!!(o===42?g:g&&(p||!f)),e(d)}}function cv(s,e){s.column+=e,s.offset+=e,s._bufferIndex+=e}const _R={name:"autolink",tokenize:RR};function RR(s,e,t){let n=0;return i;function i(y){return s.enter("autolink"),s.enter("autolinkMarker"),s.consume(y),s.exit("autolinkMarker"),s.enter("autolinkProtocol"),o}function o(y){return Zs(y)?(s.consume(y),r):y===64?t(y):h(y)}function r(y){return y===43||y===45||y===46||qs(y)?(n=1,c(y)):h(y)}function c(y){return y===58?(s.consume(y),n=0,d):(y===43||y===45||y===46||qs(y))&&n++<32?(s.consume(y),c):(n=0,h(y))}function d(y){return y===62?(s.exit("autolinkProtocol"),s.enter("autolinkMarker"),s.consume(y),s.exit("autolinkMarker"),s.exit("autolink"),e):y===null||y===32||y===60||Ou(y)?t(y):(s.consume(y),d)}function h(y){return y===64?(s.consume(y),p):wR(y)?(s.consume(y),h):t(y)}function p(y){return qs(y)?f(y):t(y)}function f(y){return y===46?(s.consume(y),n=0,p):y===62?(s.exit("autolinkProtocol").type="autolinkEmail",s.enter("autolinkMarker"),s.consume(y),s.exit("autolinkMarker"),s.exit("autolink"),e):g(y)}function g(y){if((y===45||qs(y))&&n++<63){const v=y===45?g:f;return s.consume(y),v}return t(y)}}const ql={partial:!0,tokenize:DR};function DR(s,e,t){return n;function n(o){return Lt(o)?Ft(s,i,"linePrefix")(o):i(o)}function i(o){return o===null||dt(o)?e(o):t(o)}}const MS={continuation:{tokenize:BR},exit:OR,name:"blockQuote",tokenize:LR};function LR(s,e,t){const n=this;return i;function i(r){if(r===62){const c=n.containerState;return c.open||(s.enter("blockQuote",{_container:!0}),c.open=!0),s.enter("blockQuotePrefix"),s.enter("blockQuoteMarker"),s.consume(r),s.exit("blockQuoteMarker"),o}return t(r)}function o(r){return Lt(r)?(s.enter("blockQuotePrefixWhitespace"),s.consume(r),s.exit("blockQuotePrefixWhitespace"),s.exit("blockQuotePrefix"),e):(s.exit("blockQuotePrefix"),e(r))}}function BR(s,e,t){const n=this;return i;function i(r){return Lt(r)?Ft(s,o,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(r):o(r)}function o(r){return s.attempt(MS,e,t)(r)}}function OR(s){s.exit("blockQuote")}const ES={name:"characterEscape",tokenize:PR};function PR(s,e,t){return n;function n(o){return s.enter("characterEscape"),s.enter("escapeMarker"),s.consume(o),s.exit("escapeMarker"),i}function i(o){return SR(o)?(s.enter("characterEscapeValue"),s.consume(o),s.exit("characterEscapeValue"),s.exit("characterEscape"),e):t(o)}}const _S={name:"characterReference",tokenize:IR};function IR(s,e,t){const n=this;let i=0,o,r;return c;function c(f){return s.enter("characterReference"),s.enter("characterReferenceMarker"),s.consume(f),s.exit("characterReferenceMarker"),d}function d(f){return f===35?(s.enter("characterReferenceMarkerNumeric"),s.consume(f),s.exit("characterReferenceMarkerNumeric"),h):(s.enter("characterReferenceValue"),o=31,r=qs,p(f))}function h(f){return f===88||f===120?(s.enter("characterReferenceMarkerHexadecimal"),s.consume(f),s.exit("characterReferenceMarkerHexadecimal"),s.enter("characterReferenceValue"),o=6,r=kR,p):(s.enter("characterReferenceValue"),o=7,r=Dp,p(f))}function p(f){if(f===59&&i){const g=s.exit("characterReferenceValue");return r===qs&&!_f(n.sliceSerialize(g))?t(f):(s.enter("characterReferenceMarker"),s.consume(f),s.exit("characterReferenceMarker"),s.exit("characterReference"),e)}return r(f)&&i++<o?(s.consume(f),p):t(f)}}const uv={partial:!0,tokenize:FR},dv={concrete:!0,name:"codeFenced",tokenize:zR};function zR(s,e,t){const n=this,i={partial:!0,tokenize:M};let o=0,r=0,c;return d;function d(E){return h(E)}function h(E){const z=n.events[n.events.length-1];return o=z&&z[1].type==="linePrefix"?z[2].sliceSerialize(z[1],!0).length:0,c=E,s.enter("codeFenced"),s.enter("codeFencedFence"),s.enter("codeFencedFenceSequence"),p(E)}function p(E){return E===c?(r++,s.consume(E),p):r<3?t(E):(s.exit("codeFencedFenceSequence"),Lt(E)?Ft(s,f,"whitespace")(E):f(E))}function f(E){return E===null||dt(E)?(s.exit("codeFencedFence"),n.interrupt?e(E):s.check(uv,w,_)(E)):(s.enter("codeFencedFenceInfo"),s.enter("chunkString",{contentType:"string"}),g(E))}function g(E){return E===null||dt(E)?(s.exit("chunkString"),s.exit("codeFencedFenceInfo"),f(E)):Lt(E)?(s.exit("chunkString"),s.exit("codeFencedFenceInfo"),Ft(s,y,"whitespace")(E)):E===96&&E===c?t(E):(s.consume(E),g)}function y(E){return E===null||dt(E)?f(E):(s.enter("codeFencedFenceMeta"),s.enter("chunkString",{contentType:"string"}),v(E))}function v(E){return E===null||dt(E)?(s.exit("chunkString"),s.exit("codeFencedFenceMeta"),f(E)):E===96&&E===c?t(E):(s.consume(E),v)}function w(E){return s.attempt(i,_,S)(E)}function S(E){return s.enter("lineEnding"),s.consume(E),s.exit("lineEnding"),C}function C(E){return o>0&&Lt(E)?Ft(s,A,"linePrefix",o+1)(E):A(E)}function A(E){return E===null||dt(E)?s.check(uv,w,_)(E):(s.enter("codeFlowValue"),N(E))}function N(E){return E===null||dt(E)?(s.exit("codeFlowValue"),A(E)):(s.consume(E),N)}function _(E){return s.exit("codeFenced"),e(E)}function M(E,z,T){let R=0;return D;function D($){return E.enter("lineEnding"),E.consume($),E.exit("lineEnding"),O}function O($){return E.enter("codeFencedFence"),Lt($)?Ft(E,P,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):P($)}function P($){return $===c?(E.enter("codeFencedFenceSequence"),K($)):T($)}function K($){return $===c?(R++,E.consume($),K):R>=r?(E.exit("codeFencedFenceSequence"),Lt($)?Ft(E,Y,"whitespace")($):Y($)):T($)}function Y($){return $===null||dt($)?(E.exit("codeFencedFence"),z($)):T($)}}}function FR(s,e,t){const n=this;return i;function i(r){return r===null?t(r):(s.enter("lineEnding"),s.consume(r),s.exit("lineEnding"),o)}function o(r){return n.parser.lazy[n.now().line]?t(r):e(r)}}const Bm={name:"codeIndented",tokenize:$R},HR={partial:!0,tokenize:UR};function $R(s,e,t){const n=this;return i;function i(h){return s.enter("codeIndented"),Ft(s,o,"linePrefix",5)(h)}function o(h){const p=n.events[n.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?r(h):t(h)}function r(h){return h===null?d(h):dt(h)?s.attempt(HR,r,d)(h):(s.enter("codeFlowValue"),c(h))}function c(h){return h===null||dt(h)?(s.exit("codeFlowValue"),r(h)):(s.consume(h),c)}function d(h){return s.exit("codeIndented"),e(h)}}function UR(s,e,t){const n=this;return i;function i(r){return n.parser.lazy[n.now().line]?t(r):dt(r)?(s.enter("lineEnding"),s.consume(r),s.exit("lineEnding"),i):Ft(s,o,"linePrefix",5)(r)}function o(r){const c=n.events[n.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?e(r):dt(r)?i(r):t(r)}}const GR={name:"codeText",previous:WR,resolve:qR,tokenize:KR};function qR(s){let e=s.length-4,t=3,n,i;if((s[t][1].type==="lineEnding"||s[t][1].type==="space")&&(s[e][1].type==="lineEnding"||s[e][1].type==="space")){for(n=t;++n<e;)if(s[n][1].type==="codeTextData"){s[t][1].type="codeTextPadding",s[e][1].type="codeTextPadding",t+=2,e-=2;break}}for(n=t-1,e++;++n<=e;)i===void 0?n!==e&&s[n][1].type!=="lineEnding"&&(i=n):(n===e||s[n][1].type==="lineEnding")&&(s[i][1].type="codeTextData",n!==i+2&&(s[i][1].end=s[n-1][1].end,s.splice(i+2,n-i-2),e-=n-i-2,n=i+2),i=void 0);return s}function WR(s){return s!==96||this.events[this.events.length-1][1].type==="characterEscape"}function KR(s,e,t){let n=0,i,o;return r;function r(f){return s.enter("codeText"),s.enter("codeTextSequence"),c(f)}function c(f){return f===96?(s.consume(f),n++,c):(s.exit("codeTextSequence"),d(f))}function d(f){return f===null?t(f):f===32?(s.enter("space"),s.consume(f),s.exit("space"),d):f===96?(o=s.enter("codeTextSequence"),i=0,p(f)):dt(f)?(s.enter("lineEnding"),s.consume(f),s.exit("lineEnding"),d):(s.enter("codeTextData"),h(f))}function h(f){return f===null||f===32||f===96||dt(f)?(s.exit("codeTextData"),d(f)):(s.consume(f),h)}function p(f){return f===96?(s.consume(f),i++,p):i===n?(s.exit("codeTextSequence"),s.exit("codeText"),e(f)):(o.type="codeTextData",h(f))}}class VR{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=t??Number.POSITIVE_INFINITY;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const i=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return n&&yl(this.left,n),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),yl(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),yl(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);yl(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);yl(this.left,t.reverse())}}}function yl(s,e){let t=0;if(e.length<1e4)s.push(...e);else for(;t<e.length;)s.push(...e.slice(t,t+1e4)),t+=1e4}function RS(s){const e={};let t=-1,n,i,o,r,c,d,h;const p=new VR(s);for(;++t<p.length;){for(;t in e;)t=e[t];if(n=p.get(t),t&&n[1].type==="chunkFlow"&&p.get(t-1)[1].type==="listItemPrefix"&&(d=n[1]._tokenizer.events,o=0,o<d.length&&d[o][1].type==="lineEndingBlank"&&(o+=2),o<d.length&&d[o][1].type==="content"))for(;++o<d.length&&d[o][1].type!=="content";)d[o][1].type==="chunkText"&&(d[o][1]._isInFirstContentOfListItem=!0,o++);if(n[0]==="enter")n[1].contentType&&(Object.assign(e,YR(p,t)),t=e[t],h=!0);else if(n[1]._container){for(o=t,i=void 0;o--;)if(r=p.get(o),r[1].type==="lineEnding"||r[1].type==="lineEndingBlank")r[0]==="enter"&&(i&&(p.get(i)[1].type="lineEndingBlank"),r[1].type="lineEnding",i=o);else if(!(r[1].type==="linePrefix"||r[1].type==="listItemIndent"))break;i&&(n[1].end={...p.get(i)[1].start},c=p.slice(i,t),c.unshift(n),p.splice(i,t-i+1,c))}}return wn(s,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function YR(s,e){const t=s.get(e)[1],n=s.get(e)[2];let i=e-1;const o=[];let r=t._tokenizer;r||(r=n.parser[t.contentType](t.start),t._contentTypeTextTrailing&&(r._contentTypeTextTrailing=!0));const c=r.events,d=[],h={};let p,f,g=-1,y=t,v=0,w=0;const S=[w];for(;y;){for(;s.get(++i)[1]!==y;);o.push(i),y._tokenizer||(p=n.sliceStream(y),y.next||p.push(null),f&&r.defineSkip(y.start),y._isInFirstContentOfListItem&&(r._gfmTasklistFirstContentOfListItem=!0),r.write(p),y._isInFirstContentOfListItem&&(r._gfmTasklistFirstContentOfListItem=void 0)),f=y,y=y.next}for(y=t;++g<c.length;)c[g][0]==="exit"&&c[g-1][0]==="enter"&&c[g][1].type===c[g-1][1].type&&c[g][1].start.line!==c[g][1].end.line&&(w=g+1,S.push(w),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(r.events=[],y?(y._tokenizer=void 0,y.previous=void 0):S.pop(),g=S.length;g--;){const C=c.slice(S[g],S[g+1]),A=o.pop();d.push([A,A+C.length-1]),s.splice(A,2,C)}for(d.reverse(),g=-1;++g<d.length;)h[v+d[g][0]]=v+d[g][1],v+=d[g][1]-d[g][0]-1;return h}const XR={resolve:QR,tokenize:JR},ZR={partial:!0,tokenize:eD};function QR(s){return RS(s),s}function JR(s,e){let t;return n;function n(c){return s.enter("content"),t=s.enter("chunkContent",{contentType:"content"}),i(c)}function i(c){return c===null?o(c):dt(c)?s.check(ZR,r,o)(c):(s.consume(c),i)}function o(c){return s.exit("chunkContent"),s.exit("content"),e(c)}function r(c){return s.consume(c),s.exit("chunkContent"),t.next=s.enter("chunkContent",{contentType:"content",previous:t}),t=t.next,i}}function eD(s,e,t){const n=this;return i;function i(r){return s.exit("chunkContent"),s.enter("lineEnding"),s.consume(r),s.exit("lineEnding"),Ft(s,o,"linePrefix")}function o(r){if(r===null||dt(r))return t(r);const c=n.events[n.events.length-1];return!n.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?e(r):s.interrupt(n.parser.constructs.flow,t,e)(r)}}function DS(s,e,t,n,i,o,r,c,d){const h=d||Number.POSITIVE_INFINITY;let p=0;return f;function f(C){return C===60?(s.enter(n),s.enter(i),s.enter(o),s.consume(C),s.exit(o),g):C===null||C===32||C===41||Ou(C)?t(C):(s.enter(n),s.enter(r),s.enter(c),s.enter("chunkString",{contentType:"string"}),w(C))}function g(C){return C===62?(s.enter(o),s.consume(C),s.exit(o),s.exit(i),s.exit(n),e):(s.enter(c),s.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===62?(s.exit("chunkString"),s.exit(c),g(C)):C===null||C===60||dt(C)?t(C):(s.consume(C),C===92?v:y)}function v(C){return C===60||C===62||C===92?(s.consume(C),y):y(C)}function w(C){return!p&&(C===null||C===41||ss(C))?(s.exit("chunkString"),s.exit(c),s.exit(r),s.exit(n),e(C)):p<h&&C===40?(s.consume(C),p++,w):C===41?(s.consume(C),p--,w):C===null||C===32||C===40||Ou(C)?t(C):(s.consume(C),C===92?S:w)}function S(C){return C===40||C===41||C===92?(s.consume(C),w):w(C)}}function LS(s,e,t,n,i,o){const r=this;let c=0,d;return h;function h(y){return s.enter(n),s.enter(i),s.consume(y),s.exit(i),s.enter(o),p}function p(y){return c>999||y===null||y===91||y===93&&!d||y===94&&!c&&"_hiddenFootnoteSupport"in r.parser.constructs?t(y):y===93?(s.exit(o),s.enter(i),s.consume(y),s.exit(i),s.exit(n),e):dt(y)?(s.enter("lineEnding"),s.consume(y),s.exit("lineEnding"),p):(s.enter("chunkString",{contentType:"string"}),f(y))}function f(y){return y===null||y===91||y===93||dt(y)||c++>999?(s.exit("chunkString"),p(y)):(s.consume(y),d||(d=!Lt(y)),y===92?g:f)}function g(y){return y===91||y===92||y===93?(s.consume(y),c++,f):f(y)}}function BS(s,e,t,n,i,o){let r;return c;function c(g){return g===34||g===39||g===40?(s.enter(n),s.enter(i),s.consume(g),s.exit(i),r=g===40?41:g,d):t(g)}function d(g){return g===r?(s.enter(i),s.consume(g),s.exit(i),s.exit(n),e):(s.enter(o),h(g))}function h(g){return g===r?(s.exit(o),d(r)):g===null?t(g):dt(g)?(s.enter("lineEnding"),s.consume(g),s.exit("lineEnding"),Ft(s,h,"linePrefix")):(s.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===r||g===null||dt(g)?(s.exit("chunkString"),h(g)):(s.consume(g),g===92?f:p)}function f(g){return g===r||g===92?(s.consume(g),p):p(g)}}function Ml(s,e){let t;return n;function n(i){return dt(i)?(s.enter("lineEnding"),s.consume(i),s.exit("lineEnding"),t=!0,n):Lt(i)?Ft(s,n,t?"linePrefix":"lineSuffix")(i):e(i)}}const tD={name:"definition",tokenize:nD},sD={partial:!0,tokenize:aD};function nD(s,e,t){const n=this;let i;return o;function o(y){return s.enter("definition"),r(y)}function r(y){return LS.call(n,s,c,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return i=Vn(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)),y===58?(s.enter("definitionMarker"),s.consume(y),s.exit("definitionMarker"),d):t(y)}function d(y){return ss(y)?Ml(s,h)(y):h(y)}function h(y){return DS(s,p,t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return s.attempt(sD,f,f)(y)}function f(y){return Lt(y)?Ft(s,g,"whitespace")(y):g(y)}function g(y){return y===null||dt(y)?(s.exit("definition"),n.parser.defined.push(i),e(y)):t(y)}}function aD(s,e,t){return n;function n(c){return ss(c)?Ml(s,i)(c):t(c)}function i(c){return BS(s,o,t,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return Lt(c)?Ft(s,r,"whitespace")(c):r(c)}function r(c){return c===null||dt(c)?e(c):t(c)}}const iD={name:"hardBreakEscape",tokenize:oD};function oD(s,e,t){return n;function n(o){return s.enter("hardBreakEscape"),s.consume(o),i}function i(o){return dt(o)?(s.exit("hardBreakEscape"),e(o)):t(o)}}const rD={name:"headingAtx",resolve:lD,tokenize:cD};function lD(s,e){let t=s.length-2,n=3,i,o;return s[n][1].type==="whitespace"&&(n+=2),t-2>n&&s[t][1].type==="whitespace"&&(t-=2),s[t][1].type==="atxHeadingSequence"&&(n===t-1||t-4>n&&s[t-2][1].type==="whitespace")&&(t-=n+1===t?2:4),t>n&&(i={type:"atxHeadingText",start:s[n][1].start,end:s[t][1].end},o={type:"chunkText",start:s[n][1].start,end:s[t][1].end,contentType:"text"},wn(s,n,t-n+1,[["enter",i,e],["enter",o,e],["exit",o,e],["exit",i,e]])),s}function cD(s,e,t){let n=0;return i;function i(p){return s.enter("atxHeading"),o(p)}function o(p){return s.enter("atxHeadingSequence"),r(p)}function r(p){return p===35&&n++<6?(s.consume(p),r):p===null||ss(p)?(s.exit("atxHeadingSequence"),c(p)):t(p)}function c(p){return p===35?(s.enter("atxHeadingSequence"),d(p)):p===null||dt(p)?(s.exit("atxHeading"),e(p)):Lt(p)?Ft(s,c,"whitespace")(p):(s.enter("atxHeadingText"),h(p))}function d(p){return p===35?(s.consume(p),d):(s.exit("atxHeadingSequence"),c(p))}function h(p){return p===null||p===35||ss(p)?(s.exit("atxHeadingText"),c(p)):(s.consume(p),h)}}const uD=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],hv=["pre","script","style","textarea"],dD={concrete:!0,name:"htmlFlow",resolveTo:pD,tokenize:fD},hD={partial:!0,tokenize:bD},mD={partial:!0,tokenize:gD};function pD(s){let e=s.length;for(;e--&&!(s[e][0]==="enter"&&s[e][1].type==="htmlFlow"););return e>1&&s[e-2][1].type==="linePrefix"&&(s[e][1].start=s[e-2][1].start,s[e+1][1].start=s[e-2][1].start,s.splice(e-2,2)),s}function fD(s,e,t){const n=this;let i,o,r,c,d;return h;function h(H){return p(H)}function p(H){return s.enter("htmlFlow"),s.enter("htmlFlowData"),s.consume(H),f}function f(H){return H===33?(s.consume(H),g):H===47?(s.consume(H),o=!0,w):H===63?(s.consume(H),i=3,n.interrupt?e:B):Zs(H)?(s.consume(H),r=String.fromCharCode(H),S):t(H)}function g(H){return H===45?(s.consume(H),i=2,y):H===91?(s.consume(H),i=5,c=0,v):Zs(H)?(s.consume(H),i=4,n.interrupt?e:B):t(H)}function y(H){return H===45?(s.consume(H),n.interrupt?e:B):t(H)}function v(H){const te="CDATA[";return H===te.charCodeAt(c++)?(s.consume(H),c===te.length?n.interrupt?e:P:v):t(H)}function w(H){return Zs(H)?(s.consume(H),r=String.fromCharCode(H),S):t(H)}function S(H){if(H===null||H===47||H===62||ss(H)){const te=H===47,ae=r.toLowerCase();return!te&&!o&&hv.includes(ae)?(i=1,n.interrupt?e(H):P(H)):uD.includes(r.toLowerCase())?(i=6,te?(s.consume(H),C):n.interrupt?e(H):P(H)):(i=7,n.interrupt&&!n.parser.lazy[n.now().line]?t(H):o?A(H):N(H))}return H===45||qs(H)?(s.consume(H),r+=String.fromCharCode(H),S):t(H)}function C(H){return H===62?(s.consume(H),n.interrupt?e:P):t(H)}function A(H){return Lt(H)?(s.consume(H),A):D(H)}function N(H){return H===47?(s.consume(H),D):H===58||H===95||Zs(H)?(s.consume(H),_):Lt(H)?(s.consume(H),N):D(H)}function _(H){return H===45||H===46||H===58||H===95||qs(H)?(s.consume(H),_):M(H)}function M(H){return H===61?(s.consume(H),E):Lt(H)?(s.consume(H),M):N(H)}function E(H){return H===null||H===60||H===61||H===62||H===96?t(H):H===34||H===39?(s.consume(H),d=H,z):Lt(H)?(s.consume(H),E):T(H)}function z(H){return H===d?(s.consume(H),d=null,R):H===null||dt(H)?t(H):(s.consume(H),z)}function T(H){return H===null||H===34||H===39||H===47||H===60||H===61||H===62||H===96||ss(H)?M(H):(s.consume(H),T)}function R(H){return H===47||H===62||Lt(H)?N(H):t(H)}function D(H){return H===62?(s.consume(H),O):t(H)}function O(H){return H===null||dt(H)?P(H):Lt(H)?(s.consume(H),O):t(H)}function P(H){return H===45&&i===2?(s.consume(H),L):H===60&&i===1?(s.consume(H),q):H===62&&i===4?(s.consume(H),Q):H===63&&i===3?(s.consume(H),B):H===93&&i===5?(s.consume(H),G):dt(H)&&(i===6||i===7)?(s.exit("htmlFlowData"),s.check(hD,U,K)(H)):H===null||dt(H)?(s.exit("htmlFlowData"),K(H)):(s.consume(H),P)}function K(H){return s.check(mD,Y,U)(H)}function Y(H){return s.enter("lineEnding"),s.consume(H),s.exit("lineEnding"),$}function $(H){return H===null||dt(H)?K(H):(s.enter("htmlFlowData"),P(H))}function L(H){return H===45?(s.consume(H),B):P(H)}function q(H){return H===47?(s.consume(H),r="",V):P(H)}function V(H){if(H===62){const te=r.toLowerCase();return hv.includes(te)?(s.consume(H),Q):P(H)}return Zs(H)&&r.length<8?(s.consume(H),r+=String.fromCharCode(H),V):P(H)}function G(H){return H===93?(s.consume(H),B):P(H)}function B(H){return H===62?(s.consume(H),Q):H===45&&i===2?(s.consume(H),B):P(H)}function Q(H){return H===null||dt(H)?(s.exit("htmlFlowData"),U(H)):(s.consume(H),Q)}function U(H){return s.exit("htmlFlow"),e(H)}}function gD(s,e,t){const n=this;return i;function i(r){return dt(r)?(s.enter("lineEnding"),s.consume(r),s.exit("lineEnding"),o):t(r)}function o(r){return n.parser.lazy[n.now().line]?t(r):e(r)}}function bD(s,e,t){return n;function n(i){return s.enter("lineEnding"),s.consume(i),s.exit("lineEnding"),s.attempt(ql,e,t)}}const yD={name:"htmlText",tokenize:xD};function xD(s,e,t){const n=this;let i,o,r;return c;function c(B){return s.enter("htmlText"),s.enter("htmlTextData"),s.consume(B),d}function d(B){return B===33?(s.consume(B),h):B===47?(s.consume(B),M):B===63?(s.consume(B),N):Zs(B)?(s.consume(B),T):t(B)}function h(B){return B===45?(s.consume(B),p):B===91?(s.consume(B),o=0,v):Zs(B)?(s.consume(B),A):t(B)}function p(B){return B===45?(s.consume(B),y):t(B)}function f(B){return B===null?t(B):B===45?(s.consume(B),g):dt(B)?(r=f,q(B)):(s.consume(B),f)}function g(B){return B===45?(s.consume(B),y):f(B)}function y(B){return B===62?L(B):B===45?g(B):f(B)}function v(B){const Q="CDATA[";return B===Q.charCodeAt(o++)?(s.consume(B),o===Q.length?w:v):t(B)}function w(B){return B===null?t(B):B===93?(s.consume(B),S):dt(B)?(r=w,q(B)):(s.consume(B),w)}function S(B){return B===93?(s.consume(B),C):w(B)}function C(B){return B===62?L(B):B===93?(s.consume(B),C):w(B)}function A(B){return B===null||B===62?L(B):dt(B)?(r=A,q(B)):(s.consume(B),A)}function N(B){return B===null?t(B):B===63?(s.consume(B),_):dt(B)?(r=N,q(B)):(s.consume(B),N)}function _(B){return B===62?L(B):N(B)}function M(B){return Zs(B)?(s.consume(B),E):t(B)}function E(B){return B===45||qs(B)?(s.consume(B),E):z(B)}function z(B){return dt(B)?(r=z,q(B)):Lt(B)?(s.consume(B),z):L(B)}function T(B){return B===45||qs(B)?(s.consume(B),T):B===47||B===62||ss(B)?R(B):t(B)}function R(B){return B===47?(s.consume(B),L):B===58||B===95||Zs(B)?(s.consume(B),D):dt(B)?(r=R,q(B)):Lt(B)?(s.consume(B),R):L(B)}function D(B){return B===45||B===46||B===58||B===95||qs(B)?(s.consume(B),D):O(B)}function O(B){return B===61?(s.consume(B),P):dt(B)?(r=O,q(B)):Lt(B)?(s.consume(B),O):R(B)}function P(B){return B===null||B===60||B===61||B===62||B===96?t(B):B===34||B===39?(s.consume(B),i=B,K):dt(B)?(r=P,q(B)):Lt(B)?(s.consume(B),P):(s.consume(B),Y)}function K(B){return B===i?(s.consume(B),i=void 0,$):B===null?t(B):dt(B)?(r=K,q(B)):(s.consume(B),K)}function Y(B){return B===null||B===34||B===39||B===60||B===61||B===96?t(B):B===47||B===62||ss(B)?R(B):(s.consume(B),Y)}function $(B){return B===47||B===62||ss(B)?R(B):t(B)}function L(B){return B===62?(s.consume(B),s.exit("htmlTextData"),s.exit("htmlText"),e):t(B)}function q(B){return s.exit("htmlTextData"),s.enter("lineEnding"),s.consume(B),s.exit("lineEnding"),V}function V(B){return Lt(B)?Ft(s,G,"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(B):G(B)}function G(B){return s.enter("htmlTextData"),r(B)}}const Rf={name:"labelEnd",resolveAll:SD,resolveTo:jD,tokenize:CD},vD={tokenize:AD},wD={tokenize:ND},kD={tokenize:TD};function SD(s){let e=-1;const t=[];for(;++e<s.length;){const n=s[e][1];if(t.push(s[e]),n.type==="labelImage"||n.type==="labelLink"||n.type==="labelEnd"){const i=n.type==="labelImage"?4:2;n.type="data",e+=i}}return s.length!==t.length&&wn(s,0,s.length,t),s}function jD(s,e){let t=s.length,n=0,i,o,r,c;for(;t--;)if(i=s[t][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;s[t][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(r){if(s[t][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=t,i.type!=="labelLink")){n=2;break}}else i.type==="labelEnd"&&(r=t);const d={type:s[o][1].type==="labelLink"?"link":"image",start:{...s[o][1].start},end:{...s[s.length-1][1].end}},h={type:"label",start:{...s[o][1].start},end:{...s[r][1].end}},p={type:"labelText",start:{...s[o+n+2][1].end},end:{...s[r-2][1].start}};return c=[["enter",d,e],["enter",h,e]],c=Ln(c,s.slice(o+1,o+n+3)),c=Ln(c,[["enter",p,e]]),c=Ln(c,nd(e.parser.constructs.insideSpan.null,s.slice(o+n+4,r-3),e)),c=Ln(c,[["exit",p,e],s[r-2],s[r-1],["exit",h,e]]),c=Ln(c,s.slice(r+1)),c=Ln(c,[["exit",d,e]]),wn(s,o,s.length,c),s}function CD(s,e,t){const n=this;let i=n.events.length,o,r;for(;i--;)if((n.events[i][1].type==="labelImage"||n.events[i][1].type==="labelLink")&&!n.events[i][1]._balanced){o=n.events[i][1];break}return c;function c(g){return o?o._inactive?f(g):(r=n.parser.defined.includes(Vn(n.sliceSerialize({start:o.end,end:n.now()}))),s.enter("labelEnd"),s.enter("labelMarker"),s.consume(g),s.exit("labelMarker"),s.exit("labelEnd"),d):t(g)}function d(g){return g===40?s.attempt(vD,p,r?p:f)(g):g===91?s.attempt(wD,p,r?h:f)(g):r?p(g):f(g)}function h(g){return s.attempt(kD,p,f)(g)}function p(g){return e(g)}function f(g){return o._balanced=!0,t(g)}}function AD(s,e,t){return n;function n(f){return s.enter("resource"),s.enter("resourceMarker"),s.consume(f),s.exit("resourceMarker"),i}function i(f){return ss(f)?Ml(s,o)(f):o(f)}function o(f){return f===41?p(f):DS(s,r,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function r(f){return ss(f)?Ml(s,d)(f):p(f)}function c(f){return t(f)}function d(f){return f===34||f===39||f===40?BS(s,h,t,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):p(f)}function h(f){return ss(f)?Ml(s,p)(f):p(f)}function p(f){return f===41?(s.enter("resourceMarker"),s.consume(f),s.exit("resourceMarker"),s.exit("resource"),e):t(f)}}function ND(s,e,t){const n=this;return i;function i(c){return LS.call(n,s,o,r,"reference","referenceMarker","referenceString")(c)}function o(c){return n.parser.defined.includes(Vn(n.sliceSerialize(n.events[n.events.length-1][1]).slice(1,-1)))?e(c):t(c)}function r(c){return t(c)}}function TD(s,e,t){return n;function n(o){return s.enter("reference"),s.enter("referenceMarker"),s.consume(o),s.exit("referenceMarker"),i}function i(o){return o===93?(s.enter("referenceMarker"),s.consume(o),s.exit("referenceMarker"),s.exit("reference"),e):t(o)}}const MD={name:"labelStartImage",resolveAll:Rf.resolveAll,tokenize:ED};function ED(s,e,t){const n=this;return i;function i(c){return s.enter("labelImage"),s.enter("labelImageMarker"),s.consume(c),s.exit("labelImageMarker"),o}function o(c){return c===91?(s.enter("labelMarker"),s.consume(c),s.exit("labelMarker"),s.exit("labelImage"),r):t(c)}function r(c){return c===94&&"_hiddenFootnoteSupport"in n.parser.constructs?t(c):e(c)}}const _D={name:"labelStartLink",resolveAll:Rf.resolveAll,tokenize:RD};function RD(s,e,t){const n=this;return i;function i(r){return s.enter("labelLink"),s.enter("labelMarker"),s.consume(r),s.exit("labelMarker"),s.exit("labelLink"),o}function o(r){return r===94&&"_hiddenFootnoteSupport"in n.parser.constructs?t(r):e(r)}}const Om={name:"lineEnding",tokenize:DD};function DD(s,e){return t;function t(n){return s.enter("lineEnding"),s.consume(n),s.exit("lineEnding"),Ft(s,e,"linePrefix")}}const ju={name:"thematicBreak",tokenize:LD};function LD(s,e,t){let n=0,i;return o;function o(h){return s.enter("thematicBreak"),r(h)}function r(h){return i=h,c(h)}function c(h){return h===i?(s.enter("thematicBreakSequence"),d(h)):n>=3&&(h===null||dt(h))?(s.exit("thematicBreak"),e(h)):t(h)}function d(h){return h===i?(s.consume(h),n++,d):(s.exit("thematicBreakSequence"),Lt(h)?Ft(s,c,"whitespace")(h):c(h))}}const rn={continuation:{tokenize:ID},exit:FD,name:"list",tokenize:PD},BD={partial:!0,tokenize:HD},OD={partial:!0,tokenize:zD};function PD(s,e,t){const n=this,i=n.events[n.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,r=0;return c;function c(y){const v=n.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(v==="listUnordered"?!n.containerState.marker||y===n.containerState.marker:Dp(y)){if(n.containerState.type||(n.containerState.type=v,s.enter(v,{_container:!0})),v==="listUnordered")return s.enter("listItemPrefix"),y===42||y===45?s.check(ju,t,h)(y):h(y);if(!n.interrupt||y===49)return s.enter("listItemPrefix"),s.enter("listItemValue"),d(y)}return t(y)}function d(y){return Dp(y)&&++r<10?(s.consume(y),d):(!n.interrupt||r<2)&&(n.containerState.marker?y===n.containerState.marker:y===41||y===46)?(s.exit("listItemValue"),h(y)):t(y)}function h(y){return s.enter("listItemMarker"),s.consume(y),s.exit("listItemMarker"),n.containerState.marker=n.containerState.marker||y,s.check(ql,n.interrupt?t:p,s.attempt(BD,g,f))}function p(y){return n.containerState.initialBlankLine=!0,o++,g(y)}function f(y){return Lt(y)?(s.enter("listItemPrefixWhitespace"),s.consume(y),s.exit("listItemPrefixWhitespace"),g):t(y)}function g(y){return n.containerState.size=o+n.sliceSerialize(s.exit("listItemPrefix"),!0).length,e(y)}}function ID(s,e,t){const n=this;return n.containerState._closeFlow=void 0,s.check(ql,i,o);function i(c){return n.containerState.furtherBlankLines=n.containerState.furtherBlankLines||n.containerState.initialBlankLine,Ft(s,e,"listItemIndent",n.containerState.size+1)(c)}function o(c){return n.containerState.furtherBlankLines||!Lt(c)?(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,r(c)):(n.containerState.furtherBlankLines=void 0,n.containerState.initialBlankLine=void 0,s.attempt(OD,e,r)(c))}function r(c){return n.containerState._closeFlow=!0,n.interrupt=void 0,Ft(s,s.attempt(rn,e,t),"linePrefix",n.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function zD(s,e,t){const n=this;return Ft(s,i,"listItemIndent",n.containerState.size+1);function i(o){const r=n.events[n.events.length-1];return r&&r[1].type==="listItemIndent"&&r[2].sliceSerialize(r[1],!0).length===n.containerState.size?e(o):t(o)}}function FD(s){s.exit(this.containerState.type)}function HD(s,e,t){const n=this;return Ft(s,i,"listItemPrefixWhitespace",n.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const r=n.events[n.events.length-1];return!Lt(o)&&r&&r[1].type==="listItemPrefixWhitespace"?e(o):t(o)}}const mv={name:"setextUnderline",resolveTo:$D,tokenize:UD};function $D(s,e){let t=s.length,n,i,o;for(;t--;)if(s[t][0]==="enter"){if(s[t][1].type==="content"){n=t;break}s[t][1].type==="paragraph"&&(i=t)}else s[t][1].type==="content"&&s.splice(t,1),!o&&s[t][1].type==="definition"&&(o=t);const r={type:"setextHeading",start:{...s[n][1].start},end:{...s[s.length-1][1].end}};return s[i][1].type="setextHeadingText",o?(s.splice(i,0,["enter",r,e]),s.splice(o+1,0,["exit",s[n][1],e]),s[n][1].end={...s[o][1].end}):s[n][1]=r,s.push(["exit",r,e]),s}function UD(s,e,t){const n=this;let i;return o;function o(h){let p=n.events.length,f;for(;p--;)if(n.events[p][1].type!=="lineEnding"&&n.events[p][1].type!=="linePrefix"&&n.events[p][1].type!=="content"){f=n.events[p][1].type==="paragraph";break}return!n.parser.lazy[n.now().line]&&(n.interrupt||f)?(s.enter("setextHeadingLine"),i=h,r(h)):t(h)}function r(h){return s.enter("setextHeadingLineSequence"),c(h)}function c(h){return h===i?(s.consume(h),c):(s.exit("setextHeadingLineSequence"),Lt(h)?Ft(s,d,"lineSuffix")(h):d(h))}function d(h){return h===null||dt(h)?(s.exit("setextHeadingLine"),e(h)):t(h)}}const GD={tokenize:qD};function qD(s){const e=this,t=s.attempt(ql,n,s.attempt(this.parser.constructs.flowInitial,i,Ft(s,s.attempt(this.parser.constructs.flow,i,s.attempt(XR,i)),"linePrefix")));return t;function n(o){if(o===null){s.consume(o);return}return s.enter("lineEndingBlank"),s.consume(o),s.exit("lineEndingBlank"),e.currentConstruct=void 0,t}function i(o){if(o===null){s.consume(o);return}return s.enter("lineEnding"),s.consume(o),s.exit("lineEnding"),e.currentConstruct=void 0,t}}const WD={resolveAll:PS()},KD=OS("string"),VD=OS("text");function OS(s){return{resolveAll:PS(s==="text"?YD:void 0),tokenize:e};function e(t){const n=this,i=this.parser.constructs[s],o=t.attempt(i,r,c);return r;function r(p){return h(p)?o(p):c(p)}function c(p){if(p===null){t.consume(p);return}return t.enter("data"),t.consume(p),d}function d(p){return h(p)?(t.exit("data"),o(p)):(t.consume(p),d)}function h(p){if(p===null)return!0;const f=i[p];let g=-1;if(f)for(;++g<f.length;){const y=f[g];if(!y.previous||y.previous.call(n,n.previous))return!0}return!1}}}function PS(s){return e;function e(t,n){let i=-1,o;for(;++i<=t.length;)o===void 0?t[i]&&t[i][1].type==="data"&&(o=i,i++):(!t[i]||t[i][1].type!=="data")&&(i!==o+2&&(t[o][1].end=t[i-1][1].end,t.splice(o+2,i-o-2),i=o+2),o=void 0);return s?s(t,n):t}}function YD(s,e){let t=0;for(;++t<=s.length;)if((t===s.length||s[t][1].type==="lineEnding")&&s[t-1][1].type==="data"){const n=s[t-1][1],i=e.sliceStream(n);let o=i.length,r=-1,c=0,d;for(;o--;){const h=i[o];if(typeof h=="string"){for(r=h.length;h.charCodeAt(r-1)===32;)c++,r--;if(r)break;r=-1}else if(h===-2)d=!0,c++;else if(h!==-1){o++;break}}if(e._contentTypeTextTrailing&&t===s.length&&(c=0),c){const h={type:t===s.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?r:n.start._bufferIndex+r,_index:n.start._index+o,line:n.end.line,column:n.end.column-c,offset:n.end.offset-c},end:{...n.end}};n.end={...h.start},n.start.offset===n.end.offset?Object.assign(n,h):(s.splice(t,0,["enter",h,e],["exit",h,e]),t+=2)}t++}return s}const XD={42:rn,43:rn,45:rn,48:rn,49:rn,50:rn,51:rn,52:rn,53:rn,54:rn,55:rn,56:rn,57:rn,62:MS},ZD={91:tD},QD={[-2]:Bm,[-1]:Bm,32:Bm},JD={35:rD,42:ju,45:[mv,ju],60:dD,61:mv,95:ju,96:dv,126:dv},eL={38:_S,92:ES},tL={[-5]:Om,[-4]:Om,[-3]:Om,33:MD,38:_S,42:Lp,60:[_R,yD],91:_D,92:[iD,ES],93:Rf,95:Lp,96:GR},sL={null:[Lp,WD]},nL={null:[42,95]},aL={null:[]},iL=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:nL,contentInitial:ZD,disable:aL,document:XD,flow:JD,flowInitial:QD,insideSpan:sL,string:eL,text:tL},Symbol.toStringTag,{value:"Module"}));function oL(s,e,t){let n={_bufferIndex:-1,_index:0,line:t&&t.line||1,column:t&&t.column||1,offset:t&&t.offset||0};const i={},o=[];let r=[],c=[];const d={attempt:z(M),check:z(E),consume:A,enter:N,exit:_,interrupt:z(E,{interrupt:!0})},h={code:null,containerState:{},defineSkip:w,events:[],now:v,parser:s,previous:null,sliceSerialize:g,sliceStream:y,write:f};let p=e.tokenize.call(h,d);return e.resolveAll&&o.push(e),h;function f(O){return r=Ln(r,O),S(),r[r.length-1]!==null?[]:(T(e,0),h.events=nd(o,h.events,h),h.events)}function g(O,P){return lL(y(O),P)}function y(O){return rL(r,O)}function v(){const{_bufferIndex:O,_index:P,line:K,column:Y,offset:$}=n;return{_bufferIndex:O,_index:P,line:K,column:Y,offset:$}}function w(O){i[O.line]=O.column,D()}function S(){let O;for(;n._index<r.length;){const P=r[n._index];if(typeof P=="string")for(O=n._index,n._bufferIndex<0&&(n._bufferIndex=0);n._index===O&&n._bufferIndex<P.length;)C(P.charCodeAt(n._bufferIndex));else C(P)}}function C(O){p=p(O)}function A(O){dt(O)?(n.line++,n.column=1,n.offset+=O===-3?2:1,D()):O!==-1&&(n.column++,n.offset++),n._bufferIndex<0?n._index++:(n._bufferIndex++,n._bufferIndex===r[n._index].length&&(n._bufferIndex=-1,n._index++)),h.previous=O}function N(O,P){const K=P||{};return K.type=O,K.start=v(),h.events.push(["enter",K,h]),c.push(K),K}function _(O){const P=c.pop();return P.end=v(),h.events.push(["exit",P,h]),P}function M(O,P){T(O,P.from)}function E(O,P){P.restore()}function z(O,P){return K;function K(Y,$,L){let q,V,G,B;return Array.isArray(Y)?U(Y):"tokenize"in Y?U([Y]):Q(Y);function Q(J){return he;function he(me){const pe=me!==null&&J[me],ne=me!==null&&J.null,xe=[...Array.isArray(pe)?pe:pe?[pe]:[],...Array.isArray(ne)?ne:ne?[ne]:[]];return U(xe)(me)}}function U(J){return q=J,V=0,J.length===0?L:H(J[V])}function H(J){return he;function he(me){return B=R(),G=J,J.partial||(h.currentConstruct=J),J.name&&h.parser.constructs.disable.null.includes(J.name)?ae():J.tokenize.call(P?Object.assign(Object.create(h),P):h,d,te,ae)(me)}}function te(J){return O(G,B),$}function ae(J){return B.restore(),++V<q.length?H(q[V]):L}}}function T(O,P){O.resolveAll&&!o.includes(O)&&o.push(O),O.resolve&&wn(h.events,P,h.events.length-P,O.resolve(h.events.slice(P),h)),O.resolveTo&&(h.events=O.resolveTo(h.events,h))}function R(){const O=v(),P=h.previous,K=h.currentConstruct,Y=h.events.length,$=Array.from(c);return{from:Y,restore:L};function L(){n=O,h.previous=P,h.currentConstruct=K,h.events.length=Y,c=$,D()}}function D(){n.line in i&&n.column<2&&(n.column=i[n.line],n.offset+=i[n.line]-1)}}function rL(s,e){const t=e.start._index,n=e.start._bufferIndex,i=e.end._index,o=e.end._bufferIndex;let r;if(t===i)r=[s[t].slice(n,o)];else{if(r=s.slice(t,i),n>-1){const c=r[0];typeof c=="string"?r[0]=c.slice(n):r.shift()}o>0&&r.push(s[i].slice(0,o))}return r}function lL(s,e){let t=-1;const n=[];let i;for(;++t<s.length;){const o=s[t];let r;if(typeof o=="string")r=o;else switch(o){case-5:{r="\r";break}case-4:{r=`
|