livedesk 0.1.394 → 0.1.396
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.
- package/bin/livedesk.js +26 -8
- package/bootstrap/hub-auth-handoff.js +97 -0
- package/client/bin/livedesk-client.js +112 -32
- package/client/src/runtime/client-runtime-server.js +1 -0
- package/hub/src/server.js +18 -2
- package/package.json +1 -1
- package/web/dist/assets/{index-NPl8KozM.js → index-CxlGjz9d.js} +1 -1
- package/web/dist/index.html +1 -1
|
@@ -8,7 +8,7 @@ Error generating stack: `+o.message+`
|
|
|
8
8
|
`+o.stack}}var he=Object.prototype.hasOwnProperty,Me=n.unstable_scheduleCallback,de=n.unstable_cancelCallback,be=n.unstable_shouldYield,We=n.unstable_requestPaint,at=n.unstable_now,wn=n.unstable_getCurrentPriorityLevel,Xe=n.unstable_ImmediatePriority,ht=n.unstable_UserBlockingPriority,St=n.unstable_NormalPriority,Rn=n.unstable_LowPriority,He=n.unstable_IdlePriority,Ct=n.log,Gt=n.unstable_setDisableYieldValue,pt=null,rt=null;function tn(e){if(typeof Ct=="function"&&Gt(e),rt&&typeof rt.setStrictMode=="function")try{rt.setStrictMode(pt,e)}catch{}}var kt=Math.clz32?Math.clz32:Zi,ze=Math.log,Dn=Math.LN2;function Zi(e){return e>>>=0,e===0?32:31-(ze(e)/Dn|0)|0}var hn=256,$n=262144,ga=4194304;function ts(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ln(e,t,i){var o=e.pendingLanes;if(o===0)return 0;var f=0,h=e.suspendedLanes,C=e.pingedLanes;e=e.warmLanes;var T=o&134217727;return T!==0?(o=T&~h,o!==0?f=ts(o):(C&=T,C!==0?f=ts(C):i||(i=T&~e,i!==0&&(f=ts(i))))):(T=o&~h,T!==0?f=ts(T):C!==0?f=ts(C):i||(i=o&~e,i!==0&&(f=ts(i)))),f===0?0:t!==0&&t!==f&&(t&h)===0&&(h=f&-f,i=t&-t,h>=i||h===32&&(i&4194048)!==0)?t:f}function ns(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Be(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 hi(){var e=ga;return ga<<=1,(ga&62914560)===0&&(ga=4194304),e}function ft(e){for(var t=[],i=0;31>i;i++)t.push(e);return t}function as(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Vt(e,t,i,o,f,h){var C=e.pendingLanes;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=i,e.entangledLanes&=i,e.errorRecoveryDisabledLanes&=i,e.shellSuspendCounter=0;var T=e.entanglements,F=e.expirationTimes,re=e.hiddenUpdates;for(i=C&~i;0<i;){var ye=31-kt(i),Ce=1<<ye;T[ye]=0,F[ye]=-1;var ue=re[ye];if(ue!==null)for(re[ye]=null,ye=0;ye<ue.length;ye++){var fe=ue[ye];fe!==null&&(fe.lane&=-536870913)}i&=~Ce}o!==0&&Bs(e,o,0),h!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=h&~(C&~t))}function Bs(e,t,i){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-kt(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|i&261930}function I(e,t){var i=e.entangledLanes|=t;for(e=e.entanglements;i;){var o=31-kt(i),f=1<<o;f&t|e[o]&t&&(e[o]|=t),i&=~f}}function Fe(e,t){var i=t&-t;return i=(i&42)!==0?1:mt(i),(i&(e.suspendedLanes|t))!==0?0:i}function mt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function nn(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function pn(){var e=Y.p;return e!==0?e:(e=window.event,e===void 0?32:Kv(e.type))}function Fs(e,t){var i=Y.p;try{return Y.p=e,t()}finally{Y.p=i}}var ra=Math.random().toString(36).slice(2),ee="__reactFiber$"+ra,Te="__reactProps$"+ra,qe="__reactContainer$"+ra,it="__reactEvents$"+ra,Kt="__reactListeners$"+ra,Tt="__reactHandles$"+ra,Ze="__reactResources$"+ra,lt="__reactMarker$"+ra;function Qt(e){delete e[ee],delete e[Te],delete e[it],delete e[Kt],delete e[Tt]}function $t(e){var t=e[ee];if(t)return t;for(var i=e.parentNode;i;){if(t=i[qe]||i[ee]){if(i=t.alternate,t.child!==null||i!==null&&i.child!==null)for(e=Lv(e);e!==null;){if(i=e[ee])return i;e=Lv(e)}return t}e=i,i=e.parentNode}return null}function _t(e){if(e=e[ee]||e[qe]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Ft(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(l(33))}function Ut(e){var t=e[Ze];return t||(t=e[Ze]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function zt(e){e[lt]=!0}var gn=new Set,ss={};function un(e,t){Xt(e,t),Xt(e+"Capture",t)}function Xt(e,t){for(ss[e]=t,e=0;e<t.length;e++)gn.add(t[e])}var bs=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]*$"),ws={},pi={};function $o(e){return he.call(pi,e)?!0:he.call(ws,e)?!1:bs.test(e)?pi[e]=!0:(ws[e]=!0,!1)}function Ji(e,t,i){if($o(t))if(i===null)e.removeAttribute(t);else{switch(typeof i){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var o=t.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+i)}}function Pl(e,t,i){if(i===null)e.removeAttribute(t);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+i)}}function Oa(e,t,i,o){if(o===null)e.removeAttribute(i);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(i);return}e.setAttributeNS(t,i,""+o)}}function Qn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function cu(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function uu(e,t,i){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var f=o.get,h=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return f.call(this)},set:function(C){i=""+C,h.call(this,C)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return i},setValue:function(C){i=""+C},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Xn(e){if(!e._valueTracker){var t=cu(e)?"checked":"value";e._valueTracker=uu(e,t,""+e[t])}}function $l(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),o="";return e&&(o=cu(e)?e.checked?"true":"false":e.value),e=o,e!==i?(t.setValue(e),!0):!1}function la(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var va=/[\n"\\]/g;function Sn(e){return e.replace(va,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function gi(e,t,i,o,f,h,C,T){e.name="",C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"?e.type=C:e.removeAttribute("type"),t!=null?C==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Qn(t)):e.value!==""+Qn(t)&&(e.value=""+Qn(t)):C!=="submit"&&C!=="reset"||e.removeAttribute("value"),t!=null?tr(e,C,Qn(t)):i!=null?tr(e,C,Qn(i)):o!=null&&e.removeAttribute("value"),f==null&&h!=null&&(e.defaultChecked=!!h),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?e.name=""+Qn(T):e.removeAttribute("name")}function er(e,t,i,o,f,h,C,T){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(e.type=h),t!=null||i!=null){if(!(h!=="submit"&&h!=="reset"||t!=null)){Xn(e);return}i=i!=null?""+Qn(i):"",t=t!=null?""+Qn(t):i,T||t===e.value||(e.value=t),e.defaultValue=t}o=o??f,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=T?e.checked:!!o,e.defaultChecked=!!o,C!=null&&typeof C!="function"&&typeof C!="symbol"&&typeof C!="boolean"&&(e.name=C),Xn(e)}function tr(e,t,i){t==="number"&&la(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function is(e,t,i,o){if(e=e.options,t){t={};for(var f=0;f<i.length;f++)t["$"+i[f]]=!0;for(i=0;i<e.length;i++)f=t.hasOwnProperty("$"+e[i].value),e[i].selected!==f&&(e[i].selected=f),f&&o&&(e[i].defaultSelected=!0)}else{for(i=""+Qn(i),t=null,f=0;f<e.length;f++){if(e[f].value===i){e[f].selected=!0,o&&(e[f].defaultSelected=!0);return}t!==null||e[f].disabled||(t=e[f])}t!==null&&(t.selected=!0)}}function vi(e,t,i){if(t!=null&&(t=""+Qn(t),t!==e.value&&(e.value=t),i==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=i!=null?""+Qn(i):""}function xi(e,t,i,o){if(t==null){if(o!=null){if(i!=null)throw Error(l(92));if(V(o)){if(1<o.length)throw Error(l(93));o=o[0]}i=o}i==null&&(i=""),t=i}i=Qn(t),e.defaultValue=i,o=e.textContent,o===i&&o!==""&&o!==null&&(e.value=o),Xn(e)}function Ps(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}var Yr=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 Kr(e,t,i){var o=t.indexOf("--")===0;i==null||typeof i=="boolean"||i===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,i):typeof i!="number"||i===0||Yr.has(t)?t==="float"?e.cssFloat=i:e[t]=(""+i).trim():e[t]=i+"px"}function Qr(e,t,i){if(t!=null&&typeof t!="object")throw Error(l(62));if(e=e.style,i!=null){for(var o in i)!i.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var f in t)o=t[f],t.hasOwnProperty(f)&&i[f]!==o&&Kr(e,f,o)}else for(var h in t)t.hasOwnProperty(h)&&Kr(e,h,t[h])}function nr(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Uo=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"]]),du=/^[\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 Ha(e){return du.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Un(){}var rs=null;function qo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $s=null,Xr=null;function fu(e){var t=_t(e);if(t&&(e=t.stateNode)){var i=e[Te]||null;e:switch(e=t.stateNode,t.type){case"input":if(gi(e,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name),t=i.name,i.type==="radio"&&t!=null){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll('input[name="'+Sn(""+t)+'"][type="radio"]'),t=0;t<i.length;t++){var o=i[t];if(o!==e&&o.form===e.form){var f=o[Te]||null;if(!f)throw Error(l(90));gi(o,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(t=0;t<i.length;t++)o=i[t],o.form===e.form&&$l(o)}break e;case"textarea":vi(e,i.value,i.defaultValue);break e;case"select":t=i.value,t!=null&&is(e,!!i.multiple,t,!1)}}}var Us=!1;function mu(e,t,i){if(Us)return e(t,i);Us=!0;try{var o=e(t);return o}finally{if(Us=!1,($s!==null||Xr!==null)&&(sd(),$s&&(t=$s,e=Xr,Xr=$s=null,fu(t),e)))for(t=0;t<e.length;t++)fu(e[t])}}function ls(e,t){var i=e.stateNode;if(i===null)return null;var o=i[Te]||null;if(o===null)return null;i=o[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(i&&typeof i!="function")throw Error(l(231,t,typeof i));return i}var Ba=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),hu=!1;if(Ba)try{var Ul={};Object.defineProperty(Ul,"passive",{get:function(){hu=!0}}),window.addEventListener("test",Ul,Ul),window.removeEventListener("test",Ul,Ul)}catch{hu=!1}var yi=null,Go=null,Zr=null;function Vo(){if(Zr)return Zr;var e,t=Go,i=t.length,o,f="value"in yi?yi.value:yi.textContent,h=f.length;for(e=0;e<i&&t[e]===f[e];e++);var C=i-e;for(o=1;o<=C&&t[i-o]===f[h-o];o++);return Zr=f.slice(e,1<o?1-o:void 0)}function ql(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Gl(){return!0}function pu(){return!1}function _n(e){function t(i,o,f,h,C){this._reactName=i,this._targetInst=f,this.type=o,this.nativeEvent=h,this.target=C,this.currentTarget=null;for(var T in e)e.hasOwnProperty(T)&&(i=e[T],this[T]=i?i(h):h[T]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Gl:pu,this.isPropagationStopped=pu,this}return y(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=Gl)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=Gl)},persist:function(){},isPersistent:Gl}),t}var Ss={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qs=_n(Ss),xa=y({},Ss,{view:0,detail:0}),Vl=_n(xa),Wl,Yl,ar,Gs=y({},xa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ws,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ar&&(ar&&e.type==="mousemove"?(Wl=e.screenX-ar.screenX,Yl=e.screenY-ar.screenY):Yl=Wl=0,ar=e),Wl)},movementY:function(e){return"movementY"in e?e.movementY:Yl}}),Kl=_n(Gs),gu=y({},Gs,{dataTransfer:0}),nt=_n(gu),ut=y({},xa,{relatedTarget:0}),Zn=_n(ut),sr=y({},Ss,{animationName:0,elapsedTime:0,pseudoElement:0}),Vs=_n(sr),et=y({},Ss,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),vu=_n(et),kf=y({},Ss,{data:0}),Jr=_n(kf),el={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Wo={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"},ir={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Fa(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ir[e])?!!t[e]:!1}function Ws(){return Fa}var qn=y({},xa,{key:function(e){if(e.key){var t=el[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ql(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Wo[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ws,charCode:function(e){return e.type==="keypress"?ql(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ql(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ys=_n(qn),Ee=y({},Gs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Yo=_n(Ee),Af=y({},xa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ws}),os=_n(Af),Nf=y({},Ss,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ko=_n(Nf),tl=y({},Gs,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),xu=_n(tl),Ql=y({},Ss,{newState:0,oldState:0}),yu=_n(Ql),qt=[9,13,27,32],Xl=Ba&&"CompositionEvent"in window,Ks=null;Ba&&"documentMode"in document&&(Ks=document.documentMode);var bi=Ba&&"TextEvent"in window&&!Ks,bu=Ba&&(!Xl||Ks&&8<Ks&&11>=Ks),wu=" ",Wt=!1;function wi(e,t){switch(e){case"keyup":return qt.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Su(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Si=!1;function Cs(e,t){switch(e){case"compositionend":return Su(t);case"keypress":return t.which!==32?null:(Wt=!0,wu);case"textInput":return e=t.data,e===wu&&Wt?null:e;default:return null}}function Cu(e,t){if(Si)return e==="compositionend"||!Xl&&wi(e,t)?(e=Vo(),Zr=Go=yi=null,Si=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return bu&&t.locale!=="ko"?null:t.data;default:return null}}var Zl={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 nl(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Zl[e.type]:t==="textarea"}function ya(e,t,i,o){$s?Xr?Xr.push(o):Xr=[o]:$s=o,t=dd(t,"onChange"),0<t.length&&(i=new qs("onChange","change",null,i,o),e.push({event:i,listeners:t}))}var ba=null,Qs=null;function cs(e){yv(e,0)}function Gn(e){var t=Ft(e);if($l(t))return e}function Jn(e,t){if(e==="change")return t}var ju=!1;if(Ba){var Jl;if(Ba){var Xs="oninput"in document;if(!Xs){var ku=document.createElement("div");ku.setAttribute("oninput","return;"),Xs=typeof ku.oninput=="function"}Jl=Xs}else Jl=!1;ju=Jl&&(!document.documentMode||9<document.documentMode)}function zn(){ba&&(ba.detachEvent("onpropertychange",Ci),Qs=ba=null)}function Ci(e){if(e.propertyName==="value"&&Gn(Qs)){var t=[];ya(t,Qs,e,qo(e)),mu(cs,t)}}function js(e,t,i){e==="focusin"?(zn(),ba=t,Qs=i,ba.attachEvent("onpropertychange",Ci)):e==="focusout"&&zn()}function rr(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Gn(Qs)}function eo(e,t){if(e==="click")return Gn(t)}function to(e,t){if(e==="input"||e==="change")return Gn(t)}function ks(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ea=typeof Object.is=="function"?Object.is:ks;function al(e,t){if(ea(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(o=0;o<i.length;o++){var f=i[o];if(!he.call(t,f)||!ea(e[f],t[f]))return!1}return!0}function sl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function il(e,t){var i=sl(e);e=0;for(var o;i;){if(i.nodeType===3){if(o=e+i.textContent.length,e<=t&&o>=t)return{node:i,offset:t-e};e=o}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=sl(i)}}function Qo(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Qo(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ji(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=la(e.document);t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=la(e.document)}return t}function no(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var Au=Ba&&"documentMode"in document&&11>=document.documentMode,lr=null,Zs=null,rl=null,ao=!1;function Nu(e,t,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;ao||lr==null||lr!==la(o)||(o=lr,"selectionStart"in o&&no(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),rl&&al(rl,o)||(rl=o,o=dd(Zs,"onSelect"),0<o.length&&(t=new qs("onSelect","select",null,t,i),e.push({event:t,listeners:o}),t.target=lr)))}function ki(e,t){var i={};return i[e.toLowerCase()]=t.toLowerCase(),i["Webkit"+e]="webkit"+t,i["Moz"+e]="moz"+t,i}var Ai={animationend:ki("Animation","AnimationEnd"),animationiteration:ki("Animation","AnimationIteration"),animationstart:ki("Animation","AnimationStart"),transitionrun:ki("Transition","TransitionRun"),transitionstart:ki("Transition","TransitionStart"),transitioncancel:ki("Transition","TransitionCancel"),transitionend:ki("Transition","TransitionEnd")},Xo={},Zo={};Ba&&(Zo=document.createElement("div").style,"AnimationEvent"in window||(delete Ai.animationend.animation,delete Ai.animationiteration.animation,delete Ai.animationstart.animation),"TransitionEvent"in window||delete Ai.transitionend.transition);function Pa(e){if(Xo[e])return Xo[e];if(!Ai[e])return e;var t=Ai[e],i;for(i in t)if(t.hasOwnProperty(i)&&i in Zo)return Xo[e]=t[i];return e}var Jo=Pa("animationend"),As=Pa("animationiteration"),ll=Pa("animationstart"),or=Pa("transitionrun"),Ni=Pa("transitionstart"),ec=Pa("transitioncancel"),Mu=Pa("transitionend"),tc=new Map,ol="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(" ");ol.push("scrollEnd");function oa(e,t){tc.set(e,t),un(t,[e])}var Js=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},wa=[],Ns=0,so=0;function Mi(){for(var e=Ns,t=so=Ns=0;t<e;){var i=wa[t];wa[t++]=null;var o=wa[t];wa[t++]=null;var f=wa[t];wa[t++]=null;var h=wa[t];if(wa[t++]=null,o!==null&&f!==null){var C=o.pending;C===null?f.next=f:(f.next=C.next,C.next=f),o.pending=f}h!==0&&ul(i,f,h)}}function cr(e,t,i,o){wa[Ns++]=e,wa[Ns++]=t,wa[Ns++]=i,wa[Ns++]=o,so|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function cl(e,t,i,o){return cr(e,t,i,o),ei(e)}function us(e,t){return cr(e,null,null,t),ei(e)}function ul(e,t,i){e.lanes|=i;var o=e.alternate;o!==null&&(o.lanes|=i);for(var f=!1,h=e.return;h!==null;)h.childLanes|=i,o=h.alternate,o!==null&&(o.childLanes|=i),h.tag===22&&(e=h.stateNode,e===null||e._visibility&1||(f=!0)),e=h,h=h.return;return e.tag===3?(h=e.stateNode,f&&t!==null&&(f=31-kt(i),e=h.hiddenUpdates,o=e[f],o===null?e[f]=[t]:o.push(t),t.lane=i|536870912),h):null}function ei(e){if(50<Nc)throw Nc=0,fm=null,Error(l(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Ms={};function ur(e,t,i,o){this.tag=e,this.key=i,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Cn(e,t,i,o){return new ur(e,t,i,o)}function io(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Vn(e,t){var i=e.alternate;return i===null?(i=Cn(e.tag,t,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=t,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&65011712,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,t=e.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i.refCleanup=e.refCleanup,i}function dl(e,t){e.flags&=65011714;var i=e.alternate;return i===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=i.childLanes,e.lanes=i.lanes,e.child=i.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=i.memoizedProps,e.memoizedState=i.memoizedState,e.updateQueue=i.updateQueue,e.type=i.type,t=i.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ti(e,t,i,o,f,h){var C=0;if(o=e,typeof e=="function")io(e)&&(C=1);else if(typeof e=="string")C=kS(e,i,pe.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case le:return e=Cn(31,i,t,f),e.elementType=le,e.lanes=h,e;case N:return ti(i.children,f,h,t);case M:C=8,f|=24;break;case k:return e=Cn(12,i,t,f|2),e.elementType=k,e.lanes=h,e;case H:return e=Cn(13,i,t,f),e.elementType=H,e.lanes=h,e;case W:return e=Cn(19,i,t,f),e.elementType=W,e.lanes=h,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:C=10;break e;case E:C=9;break e;case U:C=11;break e;case _:C=14;break e;case L:C=16,o=null;break e}C=29,i=Error(l(130,e===null?"null":typeof e,"")),o=null}return t=Cn(C,i,t,f),t.elementType=e,t.type=o,t.lanes=h,t}function ti(e,t,i,o){return e=Cn(7,e,o,t),e.lanes=i,e}function Sa(e,t,i){return e=Cn(6,e,null,t),e.lanes=i,e}function nc(e){var t=Cn(18,null,null,0);return t.stateNode=e,t}function Ei(e,t,i){return t=Cn(4,e.children!==null?e.children:[],e.key,t),t.lanes=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var dr=new WeakMap;function Ca(e,t){if(typeof e=="object"&&e!==null){var i=dr.get(e);return i!==void 0?i:(t={value:e,source:t,stack:$e(t)},dr.set(e,t),t)}return{value:e,source:t,stack:$e(t)}}var Ri=[],dn=0,fl=null,ni=0,ta=[],In=0,ai=null,$a=1,ds="";function Ts(e,t){Ri[dn++]=ni,Ri[dn++]=fl,fl=e,ni=t}function ro(e,t,i){ta[In++]=$a,ta[In++]=ds,ta[In++]=ai,ai=e;var o=$a;e=ds;var f=32-kt(o)-1;o&=~(1<<f),i+=1;var h=32-kt(t)+f;if(30<h){var C=f-f%5;h=(o&(1<<C)-1).toString(32),o>>=C,f-=C,$a=1<<32-kt(t)+f|i<<f|o,ds=h+e}else $a=1<<h|i<<f|o,ds=e}function lo(e){e.return!==null&&(Ts(e,1),ro(e,1,0))}function Di(e){for(;e===fl;)fl=Ri[--dn],Ri[dn]=null,ni=Ri[--dn],Ri[dn]=null;for(;e===ai;)ai=ta[--In],ta[In]=null,ds=ta[--In],ta[In]=null,$a=ta[--In],ta[In]=null}function ac(e,t){ta[In++]=$a,ta[In++]=ds,ta[In++]=ai,$a=t.id,ds=t.overflow,ai=e}var vn=null,It=null,gt=!1,Ua=null,ja=!1,sc=Error(l(519));function qa(e){var t=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ii(Ca(t,e)),sc}function Tu(e){var t=e.stateNode,i=e.type,o=e.memoizedProps;switch(t[ee]=e,t[Te]=o,i){case"dialog":yt("cancel",t),yt("close",t);break;case"iframe":case"object":case"embed":yt("load",t);break;case"video":case"audio":for(i=0;i<Tc.length;i++)yt(Tc[i],t);break;case"source":yt("error",t);break;case"img":case"image":case"link":yt("error",t),yt("load",t);break;case"details":yt("toggle",t);break;case"input":yt("invalid",t),er(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":yt("invalid",t);break;case"textarea":yt("invalid",t),xi(t,o.value,o.defaultValue,o.children)}i=o.children,typeof i!="string"&&typeof i!="number"&&typeof i!="bigint"||t.textContent===""+i||o.suppressHydrationWarning===!0||Cv(t.textContent,i)?(o.popover!=null&&(yt("beforetoggle",t),yt("toggle",t)),o.onScroll!=null&&yt("scroll",t),o.onScrollEnd!=null&&yt("scrollend",t),o.onClick!=null&&(t.onclick=Un),t=!0):t=!1,t||qa(e,!0)}function ic(e){for(vn=e.return;vn;)switch(vn.tag){case 5:case 31:case 13:ja=!1;return;case 27:case 3:ja=!0;return;default:vn=vn.return}}function Li(e){if(e!==vn)return!1;if(!gt)return ic(e),gt=!0,!1;var t=e.tag,i;if((i=t!==3&&t!==27)&&((i=t===5)&&(i=e.type,i=!(i!=="form"&&i!=="button")||Nm(e.type,e.memoizedProps)),i=!i),i&&It&&qa(e),ic(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));It=Dv(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));It=Dv(e)}else t===27?(t=It,Dr(e.type)?(e=Dm,Dm=null,It=e):It=t):It=vn?gs(e.stateNode.nextSibling):null;return!0}function si(){It=vn=null,gt=!1}function rc(){var e=Ua;return e!==null&&(Ta===null?Ta=e:Ta.push.apply(Ta,e),Ua=null),e}function ii(e){Ua===null?Ua=[e]:Ua.push(e)}var fs=we(null),ms=null,Es=null;function hs(e,t,i){B(fs,t._currentValue),t._currentValue=i}function Ga(e){e._currentValue=fs.current,J(fs)}function Re(e,t,i){for(;e!==null;){var o=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,o!==null&&(o.childLanes|=t)):o!==null&&(o.childLanes&t)!==t&&(o.childLanes|=t),e===i)break;e=e.return}}function fr(e,t,i,o){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var h=f.dependencies;if(h!==null){var C=f.child;h=h.firstContext;e:for(;h!==null;){var T=h;h=f;for(var F=0;F<t.length;F++)if(T.context===t[F]){h.lanes|=i,T=h.alternate,T!==null&&(T.lanes|=i),Re(h.return,i,e),o||(C=null);break e}h=T.next}}else if(f.tag===18){if(C=f.return,C===null)throw Error(l(341));C.lanes|=i,h=C.alternate,h!==null&&(h.lanes|=i),Re(C,i,e),C=null}else C=f.child;if(C!==null)C.return=f;else for(C=f;C!==null;){if(C===e){C=null;break}if(f=C.sibling,f!==null){f.return=C.return,C=f;break}C=C.return}f=C}}function _i(e,t,i,o){e=null;for(var f=t,h=!1;f!==null;){if(!h){if((f.flags&524288)!==0)h=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var C=f.alternate;if(C===null)throw Error(l(387));if(C=C.memoizedProps,C!==null){var T=f.type;ea(f.pendingProps.value,C.value)||(e!==null?e.push(T):e=[T])}}else if(f===Ae.current){if(C=f.alternate,C===null)throw Error(l(387));C.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(_c):e=[_c])}f=f.return}e!==null&&fr(t,e,i,o),t.flags|=262144}function oo(e){for(e=e.firstContext;e!==null;){if(!ea(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function mr(e){ms=e,Es=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function xn(e){return ml(ms,e)}function co(e,t){return ms===null&&mr(e),ml(e,t)}function ml(e,t){var i=t._currentValue;if(t={context:t,memoizedValue:i,next:null},Es===null){if(e===null)throw Error(l(308));Es=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Es=Es.next=t;return i}var Mn=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(i,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(i){return i()})}},ca=n.unstable_scheduleCallback,vt=n.unstable_NormalPriority,fn={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function lc(){return{controller:new Mn,data:new Map,refCount:0}}function hl(e){e.refCount--,e.refCount===0&&ca(vt,function(){e.controller.abort()})}var pl=null,oc=0,hr=0,pr=null;function Mf(e,t){if(pl===null){var i=pl=[];oc=0,hr=xm(),pr={status:"pending",value:void 0,then:function(o){i.push(o)}}}return oc++,t.then(Eu,Eu),t}function Eu(){if(--oc===0&&pl!==null){pr!==null&&(pr.status="fulfilled");var e=pl;pl=null,hr=0,pr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Tf(e,t){var i=[],o={status:"pending",value:null,reason:null,then:function(f){i.push(f)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var f=0;f<i.length;f++)(0,i[f])(t)},function(f){for(o.status="rejected",o.reason=f,f=0;f<i.length;f++)(0,i[f])(void 0)}),o}var Ru=O.S;O.S=function(e,t){Wg=at(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Mf(e,t),Ru!==null&&Ru(e,t)};var zi=we(null);function cc(){var e=zi.current;return e!==null?e:Pt.pooledCache}function uo(e,t){t===null?B(zi,zi.current):B(zi,t.pool)}function Du(){var e=cc();return e===null?null:{parent:fn._currentValue,pool:e}}var gr=Error(l(460)),gl=Error(l(474)),vr=Error(l(542)),fo={then:function(){}};function Lu(e){return e=e.status,e==="fulfilled"||e==="rejected"}function _u(e,t,i){switch(i=e[i],i===void 0?e.push(t):i!==t&&(t.then(Un,Un),t=i),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Iu(e),e;default:if(typeof t.status=="string")t.then(Un,Un);else{if(e=Pt,e!==null&&100<e.shellSuspendCounter)throw Error(l(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var f=t;f.status="fulfilled",f.value=o}},function(o){if(t.status==="pending"){var f=t;f.status="rejected",f.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,Iu(e),e}throw Oi=t,gr}}function Ii(e){try{var t=e._init;return t(e._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(Oi=i,gr):i}}var Oi=null;function zu(){if(Oi===null)throw Error(l(459));var e=Oi;return Oi=null,e}function Iu(e){if(e===gr||e===vr)throw Error(l(483))}var xr=null,vl=0;function Rs(e){var t=vl;return vl+=1,xr===null&&(xr=[]),_u(xr,e,t)}function yr(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function br(e,t){throw t.$$typeof===w?Error(l(525)):(e=Object.prototype.toString.call(t),Error(l(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Ou(e){function t(Z,G){if(e){var se=Z.deletions;se===null?(Z.deletions=[G],Z.flags|=16):se.push(G)}}function i(Z,G){if(!e)return null;for(;G!==null;)t(Z,G),G=G.sibling;return null}function o(Z){for(var G=new Map;Z!==null;)Z.key!==null?G.set(Z.key,Z):G.set(Z.index,Z),Z=Z.sibling;return G}function f(Z,G){return Z=Vn(Z,G),Z.index=0,Z.sibling=null,Z}function h(Z,G,se){return Z.index=se,e?(se=Z.alternate,se!==null?(se=se.index,se<G?(Z.flags|=67108866,G):se):(Z.flags|=67108866,G)):(Z.flags|=1048576,G)}function C(Z){return e&&Z.alternate===null&&(Z.flags|=67108866),Z}function T(Z,G,se,Se){return G===null||G.tag!==6?(G=Sa(se,Z.mode,Se),G.return=Z,G):(G=f(G,se),G.return=Z,G)}function F(Z,G,se,Se){var Qe=se.type;return Qe===N?ye(Z,G,se.props.children,Se,se.key):G!==null&&(G.elementType===Qe||typeof Qe=="object"&&Qe!==null&&Qe.$$typeof===L&&Ii(Qe)===G.type)?(G=f(G,se.props),yr(G,se),G.return=Z,G):(G=Ti(se.type,se.key,se.props,null,Z.mode,Se),yr(G,se),G.return=Z,G)}function re(Z,G,se,Se){return G===null||G.tag!==4||G.stateNode.containerInfo!==se.containerInfo||G.stateNode.implementation!==se.implementation?(G=Ei(se,Z.mode,Se),G.return=Z,G):(G=f(G,se.children||[]),G.return=Z,G)}function ye(Z,G,se,Se,Qe){return G===null||G.tag!==7?(G=ti(se,Z.mode,Se,Qe),G.return=Z,G):(G=f(G,se),G.return=Z,G)}function Ce(Z,G,se){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Sa(""+G,Z.mode,se),G.return=Z,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case S:return se=Ti(G.type,G.key,G.props,null,Z.mode,se),yr(se,G),se.return=Z,se;case j:return G=Ei(G,Z.mode,se),G.return=Z,G;case L:return G=Ii(G),Ce(Z,G,se)}if(V(G)||K(G))return G=ti(G,Z.mode,se,null),G.return=Z,G;if(typeof G.then=="function")return Ce(Z,Rs(G),se);if(G.$$typeof===R)return Ce(Z,co(Z,G),se);br(Z,G)}return null}function ue(Z,G,se,Se){var Qe=G!==null?G.key:null;if(typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint")return Qe!==null?null:T(Z,G,""+se,Se);if(typeof se=="object"&&se!==null){switch(se.$$typeof){case S:return se.key===Qe?F(Z,G,se,Se):null;case j:return se.key===Qe?re(Z,G,se,Se):null;case L:return se=Ii(se),ue(Z,G,se,Se)}if(V(se)||K(se))return Qe!==null?null:ye(Z,G,se,Se,null);if(typeof se.then=="function")return ue(Z,G,Rs(se),Se);if(se.$$typeof===R)return ue(Z,G,co(Z,se),Se);br(Z,se)}return null}function fe(Z,G,se,Se,Qe){if(typeof Se=="string"&&Se!==""||typeof Se=="number"||typeof Se=="bigint")return Z=Z.get(se)||null,T(G,Z,""+Se,Qe);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case S:return Z=Z.get(Se.key===null?se:Se.key)||null,F(G,Z,Se,Qe);case j:return Z=Z.get(Se.key===null?se:Se.key)||null,re(G,Z,Se,Qe);case L:return Se=Ii(Se),fe(Z,G,se,Se,Qe)}if(V(Se)||K(Se))return Z=Z.get(se)||null,ye(G,Z,Se,Qe,null);if(typeof Se.then=="function")return fe(Z,G,se,Rs(Se),Qe);if(Se.$$typeof===R)return fe(Z,G,se,co(G,Se),Qe);br(G,Se)}return null}function Ve(Z,G,se,Se){for(var Qe=null,At=null,Ye=G,dt=G=0,wt=null;Ye!==null&&dt<se.length;dt++){Ye.index>dt?(wt=Ye,Ye=null):wt=Ye.sibling;var Nt=ue(Z,Ye,se[dt],Se);if(Nt===null){Ye===null&&(Ye=wt);break}e&&Ye&&Nt.alternate===null&&t(Z,Ye),G=h(Nt,G,dt),At===null?Qe=Nt:At.sibling=Nt,At=Nt,Ye=wt}if(dt===se.length)return i(Z,Ye),gt&&Ts(Z,dt),Qe;if(Ye===null){for(;dt<se.length;dt++)Ye=Ce(Z,se[dt],Se),Ye!==null&&(G=h(Ye,G,dt),At===null?Qe=Ye:At.sibling=Ye,At=Ye);return gt&&Ts(Z,dt),Qe}for(Ye=o(Ye);dt<se.length;dt++)wt=fe(Ye,Z,dt,se[dt],Se),wt!==null&&(e&&wt.alternate!==null&&Ye.delete(wt.key===null?dt:wt.key),G=h(wt,G,dt),At===null?Qe=wt:At.sibling=wt,At=wt);return e&&Ye.forEach(function(Or){return t(Z,Or)}),gt&&Ts(Z,dt),Qe}function Je(Z,G,se,Se){if(se==null)throw Error(l(151));for(var Qe=null,At=null,Ye=G,dt=G=0,wt=null,Nt=se.next();Ye!==null&&!Nt.done;dt++,Nt=se.next()){Ye.index>dt?(wt=Ye,Ye=null):wt=Ye.sibling;var Or=ue(Z,Ye,Nt.value,Se);if(Or===null){Ye===null&&(Ye=wt);break}e&&Ye&&Or.alternate===null&&t(Z,Ye),G=h(Or,G,dt),At===null?Qe=Or:At.sibling=Or,At=Or,Ye=wt}if(Nt.done)return i(Z,Ye),gt&&Ts(Z,dt),Qe;if(Ye===null){for(;!Nt.done;dt++,Nt=se.next())Nt=Ce(Z,Nt.value,Se),Nt!==null&&(G=h(Nt,G,dt),At===null?Qe=Nt:At.sibling=Nt,At=Nt);return gt&&Ts(Z,dt),Qe}for(Ye=o(Ye);!Nt.done;dt++,Nt=se.next())Nt=fe(Ye,Z,dt,Nt.value,Se),Nt!==null&&(e&&Nt.alternate!==null&&Ye.delete(Nt.key===null?dt:Nt.key),G=h(Nt,G,dt),At===null?Qe=Nt:At.sibling=Nt,At=Nt);return e&&Ye.forEach(function(IS){return t(Z,IS)}),gt&&Ts(Z,dt),Qe}function Bt(Z,G,se,Se){if(typeof se=="object"&&se!==null&&se.type===N&&se.key===null&&(se=se.props.children),typeof se=="object"&&se!==null){switch(se.$$typeof){case S:e:{for(var Qe=se.key;G!==null;){if(G.key===Qe){if(Qe=se.type,Qe===N){if(G.tag===7){i(Z,G.sibling),Se=f(G,se.props.children),Se.return=Z,Z=Se;break e}}else if(G.elementType===Qe||typeof Qe=="object"&&Qe!==null&&Qe.$$typeof===L&&Ii(Qe)===G.type){i(Z,G.sibling),Se=f(G,se.props),yr(Se,se),Se.return=Z,Z=Se;break e}i(Z,G);break}else t(Z,G);G=G.sibling}se.type===N?(Se=ti(se.props.children,Z.mode,Se,se.key),Se.return=Z,Z=Se):(Se=Ti(se.type,se.key,se.props,null,Z.mode,Se),yr(Se,se),Se.return=Z,Z=Se)}return C(Z);case j:e:{for(Qe=se.key;G!==null;){if(G.key===Qe)if(G.tag===4&&G.stateNode.containerInfo===se.containerInfo&&G.stateNode.implementation===se.implementation){i(Z,G.sibling),Se=f(G,se.children||[]),Se.return=Z,Z=Se;break e}else{i(Z,G);break}else t(Z,G);G=G.sibling}Se=Ei(se,Z.mode,Se),Se.return=Z,Z=Se}return C(Z);case L:return se=Ii(se),Bt(Z,G,se,Se)}if(V(se))return Ve(Z,G,se,Se);if(K(se)){if(Qe=K(se),typeof Qe!="function")throw Error(l(150));return se=Qe.call(se),Je(Z,G,se,Se)}if(typeof se.then=="function")return Bt(Z,G,Rs(se),Se);if(se.$$typeof===R)return Bt(Z,G,co(Z,se),Se);br(Z,se)}return typeof se=="string"&&se!==""||typeof se=="number"||typeof se=="bigint"?(se=""+se,G!==null&&G.tag===6?(i(Z,G.sibling),Se=f(G,se),Se.return=Z,Z=Se):(i(Z,G),Se=Sa(se,Z.mode,Se),Se.return=Z,Z=Se),C(Z)):i(Z,G)}return function(Z,G,se,Se){try{vl=0;var Qe=Bt(Z,G,se,Se);return xr=null,Qe}catch(Ye){if(Ye===gr||Ye===vr)throw Ye;var At=Cn(29,Ye,null,Z.mode);return At.lanes=Se,At.return=Z,At}}}var ri=Ou(!0),Hu=Ou(!1),Ds=!1;function wr(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Zt(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Va(e,t,i){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(Mt&2)!==0){var f=o.pending;return f===null?t.next=t:(t.next=f.next,f.next=t),o.pending=t,t=ei(e),ul(e,null,i),t}return cr(e,o,t,i),ei(e)}function Sr(e,t,i){if(t=t.updateQueue,t!==null&&(t=t.shared,(i&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,i|=o,t.lanes=i,I(e,i)}}function uc(e,t){var i=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,i===o)){var f=null,h=null;if(i=i.firstBaseUpdate,i!==null){do{var C={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};h===null?f=h=C:h=h.next=C,i=i.next}while(i!==null);h===null?f=h=t:h=h.next=t}else f=h=t;i={baseState:o.baseState,firstBaseUpdate:f,lastBaseUpdate:h,shared:o.shared,callbacks:o.callbacks},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=t:e.next=t,i.lastBaseUpdate=t}var Bu=!1;function xl(){if(Bu){var e=pr;if(e!==null)throw e}}function yl(e,t,i,o){Bu=!1;var f=e.updateQueue;Ds=!1;var h=f.firstBaseUpdate,C=f.lastBaseUpdate,T=f.shared.pending;if(T!==null){f.shared.pending=null;var F=T,re=F.next;F.next=null,C===null?h=re:C.next=re,C=F;var ye=e.alternate;ye!==null&&(ye=ye.updateQueue,T=ye.lastBaseUpdate,T!==C&&(T===null?ye.firstBaseUpdate=re:T.next=re,ye.lastBaseUpdate=F))}if(h!==null){var Ce=f.baseState;C=0,ye=re=F=null,T=h;do{var ue=T.lane&-536870913,fe=ue!==T.lane;if(fe?(bt&ue)===ue:(o&ue)===ue){ue!==0&&ue===hr&&(Bu=!0),ye!==null&&(ye=ye.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var Ve=e,Je=T;ue=t;var Bt=i;switch(Je.tag){case 1:if(Ve=Je.payload,typeof Ve=="function"){Ce=Ve.call(Bt,Ce,ue);break e}Ce=Ve;break e;case 3:Ve.flags=Ve.flags&-65537|128;case 0:if(Ve=Je.payload,ue=typeof Ve=="function"?Ve.call(Bt,Ce,ue):Ve,ue==null)break e;Ce=y({},Ce,ue);break e;case 2:Ds=!0}}ue=T.callback,ue!==null&&(e.flags|=64,fe&&(e.flags|=8192),fe=f.callbacks,fe===null?f.callbacks=[ue]:fe.push(ue))}else fe={lane:ue,tag:T.tag,payload:T.payload,callback:T.callback,next:null},ye===null?(re=ye=fe,F=Ce):ye=ye.next=fe,C|=ue;if(T=T.next,T===null){if(T=f.shared.pending,T===null)break;fe=T,T=fe.next,fe.next=null,f.lastBaseUpdate=fe,f.shared.pending=null}}while(!0);ye===null&&(F=Ce),f.baseState=F,f.firstBaseUpdate=re,f.lastBaseUpdate=ye,h===null&&(f.shared.lanes=0),Nr|=C,e.lanes=C,e.memoizedState=Ce}}function dc(e,t){if(typeof e!="function")throw Error(l(191,e));e.call(t)}function bl(e,t){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;e<i.length;e++)dc(i[e],t)}var ps=we(null),wl=we(0);function Fu(e,t){e=Gi,B(wl,e),B(ps,t),Gi=e|t.baseLanes}function fc(){B(wl,Gi),B(ps,ps.current)}function mc(){Gi=wl.current,J(ps),J(wl)}var ua=we(null),ka=null;function li(e){var t=e.alternate;B(Ot,Ot.current&1),B(ua,e),ka===null&&(t===null||ps.current!==null||t.memoizedState!==null)&&(ka=e)}function hc(e){B(Ot,Ot.current),B(ua,e),ka===null&&(ka=e)}function da(e){e.tag===22?(B(Ot,Ot.current),B(ua,e),ka===null&&(ka=e)):oi()}function oi(){B(Ot,Ot.current),B(ua,ua.current)}function fa(e){J(ua),ka===e&&(ka=null),J(Ot)}var Ot=we(0);function ho(e){for(var t=e;t!==null;){if(t.tag===13){var i=t.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||Em(i)||Rm(i)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Wa=0,tt=null,Et=null,an=null,x=!1,A=!1,D=!1,$=0,z=0,me=null,ve=0;function Ne(){throw Error(l(321))}function Ue(e,t){if(t===null)return!1;for(var i=0;i<t.length&&i<e.length;i++)if(!ea(e[i],t[i]))return!1;return!0}function Ke(e,t,i,o,f,h){return Wa=h,tt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,O.H=e===null||e.memoizedState===null?sg:Pf,D=!1,h=i(o,f),D=!1,A&&(h=Tn(t,i,o,f)),sn(e),h}function sn(e){O.H=xc;var t=Et!==null&&Et.next!==null;if(Wa=0,an=Et=tt=null,x=!1,z=0,me=null,t)throw Error(l(300));e===null||kn||(e=e.dependencies,e!==null&&oo(e)&&(kn=!0))}function Tn(e,t,i,o){tt=e;var f=0;do{if(A&&(me=null),z=0,A=!1,25<=f)throw Error(l(301));if(f+=1,an=Et=null,e.updateQueue!=null){var h=e.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}O.H=ig,h=t(i,o)}while(A);return h}function Ya(){var e=O.H,t=e.useState()[0];return t=typeof t.then=="function"?gc(t):t,e=e.useState()[0],(Et!==null?Et.memoizedState:null)!==e&&(tt.flags|=1024),t}function Cr(){var e=$!==0;return $=0,e}function jr(e,t,i){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i}function pc(e){if(x){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}x=!1}Wa=0,an=Et=tt=null,A=!1,z=$=0,me=null}function jn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return an===null?tt.memoizedState=an=e:an=an.next=e,an}function rn(){if(Et===null){var e=tt.alternate;e=e!==null?e.memoizedState:null}else e=Et.next;var t=an===null?tt.memoizedState:an.next;if(t!==null)an=t,Et=e;else{if(e===null)throw tt.alternate===null?Error(l(467)):Error(l(310));Et=e,e={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},an===null?tt.memoizedState=an=e:an=an.next=e}return an}function Pu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function gc(e){var t=z;return z+=1,me===null&&(me=[]),e=_u(me,e,t),t=tt,(an===null?t.memoizedState:an.next)===null&&(t=t.alternate,O.H=t===null||t.memoizedState===null?sg:Pf),e}function $u(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return gc(e);if(e.$$typeof===R)return xn(e)}throw Error(l(438,String(e)))}function Ef(e){var t=null,i=tt.updateQueue;if(i!==null&&(t=i.memoCache),t==null){var o=tt.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(f){return f.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),i===null&&(i=Pu(),tt.updateQueue=i),i.memoCache=t,i=t.data[t.index],i===void 0)for(i=t.data[t.index]=Array(e),o=0;o<e;o++)i[o]=q;return t.index++,i}function Hi(e,t){return typeof t=="function"?t(e):t}function Uu(e){var t=rn();return Rf(t,Et,e)}function Rf(e,t,i){var o=e.queue;if(o===null)throw Error(l(311));o.lastRenderedReducer=i;var f=e.baseQueue,h=o.pending;if(h!==null){if(f!==null){var C=f.next;f.next=h.next,h.next=C}t.baseQueue=f=h,o.pending=null}if(h=e.baseState,f===null)e.memoizedState=h;else{t=f.next;var T=C=null,F=null,re=t,ye=!1;do{var Ce=re.lane&-536870913;if(Ce!==re.lane?(bt&Ce)===Ce:(Wa&Ce)===Ce){var ue=re.revertLane;if(ue===0)F!==null&&(F=F.next={lane:0,revertLane:0,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),Ce===hr&&(ye=!0);else if((Wa&ue)===ue){re=re.next,ue===hr&&(ye=!0);continue}else Ce={lane:0,revertLane:re.revertLane,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},F===null?(T=F=Ce,C=h):F=F.next=Ce,tt.lanes|=ue,Nr|=ue;Ce=re.action,D&&i(h,Ce),h=re.hasEagerState?re.eagerState:i(h,Ce)}else ue={lane:Ce,revertLane:re.revertLane,gesture:re.gesture,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},F===null?(T=F=ue,C=h):F=F.next=ue,tt.lanes|=Ce,Nr|=Ce;re=re.next}while(re!==null&&re!==t);if(F===null?C=h:F.next=T,!ea(h,e.memoizedState)&&(kn=!0,ye&&(i=pr,i!==null)))throw i;e.memoizedState=h,e.baseState=C,e.baseQueue=F,o.lastRenderedState=h}return f===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function Df(e){var t=rn(),i=t.queue;if(i===null)throw Error(l(311));i.lastRenderedReducer=e;var o=i.dispatch,f=i.pending,h=t.memoizedState;if(f!==null){i.pending=null;var C=f=f.next;do h=e(h,C.action),C=C.next;while(C!==f);ea(h,t.memoizedState)||(kn=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),i.lastRenderedState=h}return[h,o]}function jp(e,t,i){var o=tt,f=rn(),h=gt;if(h){if(i===void 0)throw Error(l(407));i=i()}else i=t();var C=!ea((Et||f).memoizedState,i);if(C&&(f.memoizedState=i,kn=!0),f=f.queue,zf(Np.bind(null,o,f,e),[e]),f.getSnapshot!==t||C||an!==null&&an.memoizedState.tag&1){if(o.flags|=2048,po(9,{destroy:void 0},Ap.bind(null,o,f,i,t),null),Pt===null)throw Error(l(349));h||(Wa&127)!==0||kp(o,t,i)}return i}function kp(e,t,i){e.flags|=16384,e={getSnapshot:t,value:i},t=tt.updateQueue,t===null?(t=Pu(),tt.updateQueue=t,t.stores=[e]):(i=t.stores,i===null?t.stores=[e]:i.push(e))}function Ap(e,t,i,o){t.value=i,t.getSnapshot=o,Mp(t)&&Tp(e)}function Np(e,t,i){return i(function(){Mp(t)&&Tp(e)})}function Mp(e){var t=e.getSnapshot;e=e.value;try{var i=t();return!ea(e,i)}catch{return!0}}function Tp(e){var t=us(e,2);t!==null&&Ea(t,e,2)}function Lf(e){var t=jn();if(typeof e=="function"){var i=e;if(e=i(),D){tn(!0);try{i()}finally{tn(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hi,lastRenderedState:e},t}function Ep(e,t,i,o){return e.baseState=i,Rf(e,Et,typeof o=="function"?o:Hi)}function Mw(e,t,i,o,f){if(Vu(e))throw Error(l(485));if(e=t.action,e!==null){var h={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(C){h.listeners.push(C)}};O.T!==null?i(!0):h.isTransition=!1,o(h),i=t.pending,i===null?(h.next=t.pending=h,Rp(t,h)):(h.next=i.next,t.pending=i.next=h)}}function Rp(e,t){var i=t.action,o=t.payload,f=e.state;if(t.isTransition){var h=O.T,C={};O.T=C;try{var T=i(f,o),F=O.S;F!==null&&F(C,T),Dp(e,t,T)}catch(re){_f(e,t,re)}finally{h!==null&&C.types!==null&&(h.types=C.types),O.T=h}}else try{h=i(f,o),Dp(e,t,h)}catch(re){_f(e,t,re)}}function Dp(e,t,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(o){Lp(e,t,o)},function(o){return _f(e,t,o)}):Lp(e,t,i)}function Lp(e,t,i){t.status="fulfilled",t.value=i,_p(t),e.state=i,t=e.pending,t!==null&&(i=t.next,i===t?e.pending=null:(i=i.next,t.next=i,Rp(e,i)))}function _f(e,t,i){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=i,_p(t),t=t.next;while(t!==o)}e.action=null}function _p(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function zp(e,t){return t}function Ip(e,t){if(gt){var i=Pt.formState;if(i!==null){e:{var o=tt;if(gt){if(It){t:{for(var f=It,h=ja;f.nodeType!==8;){if(!h){f=null;break t}if(f=gs(f.nextSibling),f===null){f=null;break t}}h=f.data,f=h==="F!"||h==="F"?f:null}if(f){It=gs(f.nextSibling),o=f.data==="F!";break e}}qa(o)}o=!1}o&&(t=i[0])}}return i=jn(),i.memoizedState=i.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zp,lastRenderedState:t},i.queue=o,i=tg.bind(null,tt,o),o.dispatch=i,o=Lf(!1),h=Ff.bind(null,tt,!1,o.queue),o=jn(),f={state:t,dispatch:null,action:e,pending:null},o.queue=f,i=Mw.bind(null,tt,f,h,i),f.dispatch=i,o.memoizedState=e,[t,i,!1]}function Op(e){var t=rn();return Hp(t,Et,e)}function Hp(e,t,i){if(t=Rf(e,t,zp)[0],e=Uu(Hi)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=gc(t)}catch(C){throw C===gr?vr:C}else o=t;t=rn();var f=t.queue,h=f.dispatch;return i!==t.memoizedState&&(tt.flags|=2048,po(9,{destroy:void 0},Tw.bind(null,f,i),null)),[o,h,e]}function Tw(e,t){e.action=t}function Bp(e){var t=rn(),i=Et;if(i!==null)return Hp(t,i,e);rn(),t=t.memoizedState,i=rn();var o=i.queue.dispatch;return i.memoizedState=e,[t,o,!1]}function po(e,t,i,o){return e={tag:e,create:i,deps:o,inst:t,next:null},t=tt.updateQueue,t===null&&(t=Pu(),tt.updateQueue=t),i=t.lastEffect,i===null?t.lastEffect=e.next=e:(o=i.next,i.next=e,e.next=o,t.lastEffect=e),e}function Fp(){return rn().memoizedState}function qu(e,t,i,o){var f=jn();tt.flags|=e,f.memoizedState=po(1|t,{destroy:void 0},i,o===void 0?null:o)}function Gu(e,t,i,o){var f=rn();o=o===void 0?null:o;var h=f.memoizedState.inst;Et!==null&&o!==null&&Ue(o,Et.memoizedState.deps)?f.memoizedState=po(t,h,i,o):(tt.flags|=e,f.memoizedState=po(1|t,h,i,o))}function Pp(e,t){qu(8390656,8,e,t)}function zf(e,t){Gu(2048,8,e,t)}function Ew(e){tt.flags|=4;var t=tt.updateQueue;if(t===null)t=Pu(),tt.updateQueue=t,t.events=[e];else{var i=t.events;i===null?t.events=[e]:i.push(e)}}function $p(e){var t=rn().memoizedState;return Ew({ref:t,nextImpl:e}),function(){if((Mt&2)!==0)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function Up(e,t){return Gu(4,2,e,t)}function qp(e,t){return Gu(4,4,e,t)}function Gp(e,t){if(typeof t=="function"){e=e();var i=t(e);return function(){typeof i=="function"?i():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Vp(e,t,i){i=i!=null?i.concat([e]):null,Gu(4,4,Gp.bind(null,t,e),i)}function If(){}function Wp(e,t){var i=rn();t=t===void 0?null:t;var o=i.memoizedState;return t!==null&&Ue(t,o[1])?o[0]:(i.memoizedState=[e,t],e)}function Yp(e,t){var i=rn();t=t===void 0?null:t;var o=i.memoizedState;if(t!==null&&Ue(t,o[1]))return o[0];if(o=e(),D){tn(!0);try{e()}finally{tn(!1)}}return i.memoizedState=[o,t],o}function Of(e,t,i){return i===void 0||(Wa&1073741824)!==0&&(bt&261930)===0?e.memoizedState=t:(e.memoizedState=i,e=Kg(),tt.lanes|=e,Nr|=e,i)}function Kp(e,t,i,o){return ea(i,t)?i:ps.current!==null?(e=Of(e,i,o),ea(e,t)||(kn=!0),e):(Wa&42)===0||(Wa&1073741824)!==0&&(bt&261930)===0?(kn=!0,e.memoizedState=i):(e=Kg(),tt.lanes|=e,Nr|=e,t)}function Qp(e,t,i,o,f){var h=Y.p;Y.p=h!==0&&8>h?h:8;var C=O.T,T={};O.T=T,Ff(e,!1,t,i);try{var F=f(),re=O.S;if(re!==null&&re(T,F),F!==null&&typeof F=="object"&&typeof F.then=="function"){var ye=Tf(F,o);vc(e,t,ye,Xa(e))}else vc(e,t,o,Xa(e))}catch(Ce){vc(e,t,{then:function(){},status:"rejected",reason:Ce},Xa())}finally{Y.p=h,C!==null&&T.types!==null&&(C.types=T.types),O.T=C}}function Rw(){}function Hf(e,t,i,o){if(e.tag!==5)throw Error(l(476));var f=Xp(e).queue;Qp(e,f,t,X,i===null?Rw:function(){return Zp(e),i(o)})}function Xp(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hi,lastRenderedState:X},next:null};var i={};return t.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hi,lastRenderedState:i},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Zp(e){var t=Xp(e);t.next===null&&(t=e.alternate.memoizedState),vc(e,t.next.queue,{},Xa())}function Bf(){return xn(_c)}function Jp(){return rn().memoizedState}function eg(){return rn().memoizedState}function Dw(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var i=Xa();e=Zt(i);var o=Va(t,e,i);o!==null&&(Ea(o,t,i),Sr(o,t,i)),t={cache:lc()},e.payload=t;return}t=t.return}}function Lw(e,t,i){var o=Xa();i={lane:o,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Vu(e)?ng(t,i):(i=cl(e,t,i,o),i!==null&&(Ea(i,e,o),ag(i,t,o)))}function tg(e,t,i){var o=Xa();vc(e,t,i,o)}function vc(e,t,i,o){var f={lane:o,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Vu(e))ng(t,f);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=t.lastRenderedReducer,h!==null))try{var C=t.lastRenderedState,T=h(C,i);if(f.hasEagerState=!0,f.eagerState=T,ea(T,C))return cr(e,t,f,0),Pt===null&&Mi(),!1}catch{}if(i=cl(e,t,f,o),i!==null)return Ea(i,e,o),ag(i,t,o),!0}return!1}function Ff(e,t,i,o){if(o={lane:2,revertLane:xm(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Vu(e)){if(t)throw Error(l(479))}else t=cl(e,i,o,2),t!==null&&Ea(t,e,2)}function Vu(e){var t=e.alternate;return e===tt||t!==null&&t===tt}function ng(e,t){A=x=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function ag(e,t,i){if((i&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,i|=o,t.lanes=i,I(e,i)}}var xc={readContext:xn,use:$u,useCallback:Ne,useContext:Ne,useEffect:Ne,useImperativeHandle:Ne,useLayoutEffect:Ne,useInsertionEffect:Ne,useMemo:Ne,useReducer:Ne,useRef:Ne,useState:Ne,useDebugValue:Ne,useDeferredValue:Ne,useTransition:Ne,useSyncExternalStore:Ne,useId:Ne,useHostTransitionStatus:Ne,useFormState:Ne,useActionState:Ne,useOptimistic:Ne,useMemoCache:Ne,useCacheRefresh:Ne};xc.useEffectEvent=Ne;var sg={readContext:xn,use:$u,useCallback:function(e,t){return jn().memoizedState=[e,t===void 0?null:t],e},useContext:xn,useEffect:Pp,useImperativeHandle:function(e,t,i){i=i!=null?i.concat([e]):null,qu(4194308,4,Gp.bind(null,t,e),i)},useLayoutEffect:function(e,t){return qu(4194308,4,e,t)},useInsertionEffect:function(e,t){qu(4,2,e,t)},useMemo:function(e,t){var i=jn();t=t===void 0?null:t;var o=e();if(D){tn(!0);try{e()}finally{tn(!1)}}return i.memoizedState=[o,t],o},useReducer:function(e,t,i){var o=jn();if(i!==void 0){var f=i(t);if(D){tn(!0);try{i(t)}finally{tn(!1)}}}else f=t;return o.memoizedState=o.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},o.queue=e,e=e.dispatch=Lw.bind(null,tt,e),[o.memoizedState,e]},useRef:function(e){var t=jn();return e={current:e},t.memoizedState=e},useState:function(e){e=Lf(e);var t=e.queue,i=tg.bind(null,tt,t);return t.dispatch=i,[e.memoizedState,i]},useDebugValue:If,useDeferredValue:function(e,t){var i=jn();return Of(i,e,t)},useTransition:function(){var e=Lf(!1);return e=Qp.bind(null,tt,e.queue,!0,!1),jn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,i){var o=tt,f=jn();if(gt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=t(),Pt===null)throw Error(l(349));(bt&127)!==0||kp(o,t,i)}f.memoizedState=i;var h={value:i,getSnapshot:t};return f.queue=h,Pp(Np.bind(null,o,h,e),[e]),o.flags|=2048,po(9,{destroy:void 0},Ap.bind(null,o,h,i,t),null),i},useId:function(){var e=jn(),t=Pt.identifierPrefix;if(gt){var i=ds,o=$a;i=(o&~(1<<32-kt(o)-1)).toString(32)+i,t="_"+t+"R_"+i,i=$++,0<i&&(t+="H"+i.toString(32)),t+="_"}else i=ve++,t="_"+t+"r_"+i.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Bf,useFormState:Ip,useActionState:Ip,useOptimistic:function(e){var t=jn();t.memoizedState=t.baseState=e;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=i,t=Ff.bind(null,tt,!0,i),i.dispatch=t,[e,t]},useMemoCache:Ef,useCacheRefresh:function(){return jn().memoizedState=Dw.bind(null,tt)},useEffectEvent:function(e){var t=jn(),i={impl:e};return t.memoizedState=i,function(){if((Mt&2)!==0)throw Error(l(440));return i.impl.apply(void 0,arguments)}}},Pf={readContext:xn,use:$u,useCallback:Wp,useContext:xn,useEffect:zf,useImperativeHandle:Vp,useInsertionEffect:Up,useLayoutEffect:qp,useMemo:Yp,useReducer:Uu,useRef:Fp,useState:function(){return Uu(Hi)},useDebugValue:If,useDeferredValue:function(e,t){var i=rn();return Kp(i,Et.memoizedState,e,t)},useTransition:function(){var e=Uu(Hi)[0],t=rn().memoizedState;return[typeof e=="boolean"?e:gc(e),t]},useSyncExternalStore:jp,useId:Jp,useHostTransitionStatus:Bf,useFormState:Op,useActionState:Op,useOptimistic:function(e,t){var i=rn();return Ep(i,Et,e,t)},useMemoCache:Ef,useCacheRefresh:eg};Pf.useEffectEvent=$p;var ig={readContext:xn,use:$u,useCallback:Wp,useContext:xn,useEffect:zf,useImperativeHandle:Vp,useInsertionEffect:Up,useLayoutEffect:qp,useMemo:Yp,useReducer:Df,useRef:Fp,useState:function(){return Df(Hi)},useDebugValue:If,useDeferredValue:function(e,t){var i=rn();return Et===null?Of(i,e,t):Kp(i,Et.memoizedState,e,t)},useTransition:function(){var e=Df(Hi)[0],t=rn().memoizedState;return[typeof e=="boolean"?e:gc(e),t]},useSyncExternalStore:jp,useId:Jp,useHostTransitionStatus:Bf,useFormState:Bp,useActionState:Bp,useOptimistic:function(e,t){var i=rn();return Et!==null?Ep(i,Et,e,t):(i.baseState=e,[e,i.queue.dispatch])},useMemoCache:Ef,useCacheRefresh:eg};ig.useEffectEvent=$p;function $f(e,t,i,o){t=e.memoizedState,i=i(o,t),i=i==null?t:y({},t,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var Uf={enqueueSetState:function(e,t,i){e=e._reactInternals;var o=Xa(),f=Zt(o);f.payload=t,i!=null&&(f.callback=i),t=Va(e,f,o),t!==null&&(Ea(t,e,o),Sr(t,e,o))},enqueueReplaceState:function(e,t,i){e=e._reactInternals;var o=Xa(),f=Zt(o);f.tag=1,f.payload=t,i!=null&&(f.callback=i),t=Va(e,f,o),t!==null&&(Ea(t,e,o),Sr(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var i=Xa(),o=Zt(i);o.tag=2,t!=null&&(o.callback=t),t=Va(e,o,i),t!==null&&(Ea(t,e,i),Sr(t,e,i))}};function rg(e,t,i,o,f,h,C){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,h,C):t.prototype&&t.prototype.isPureReactComponent?!al(i,o)||!al(f,h):!0}function lg(e,t,i,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(i,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(i,o),t.state!==e&&Uf.enqueueReplaceState(t,t.state,null)}function Sl(e,t){var i=t;if("ref"in t){i={};for(var o in t)o!=="ref"&&(i[o]=t[o])}if(e=e.defaultProps){i===t&&(i=y({},i));for(var f in e)i[f]===void 0&&(i[f]=e[f])}return i}function og(e){Js(e)}function cg(e){console.error(e)}function ug(e){Js(e)}function Wu(e,t){try{var i=e.onUncaughtError;i(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function dg(e,t,i){try{var o=e.onCaughtError;o(i.value,{componentStack:i.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function qf(e,t,i){return i=Zt(i),i.tag=3,i.payload={element:null},i.callback=function(){Wu(e,t)},i}function fg(e){return e=Zt(e),e.tag=3,e}function mg(e,t,i,o){var f=i.type.getDerivedStateFromError;if(typeof f=="function"){var h=o.value;e.payload=function(){return f(h)},e.callback=function(){dg(t,i,o)}}var C=i.stateNode;C!==null&&typeof C.componentDidCatch=="function"&&(e.callback=function(){dg(t,i,o),typeof f!="function"&&(Mr===null?Mr=new Set([this]):Mr.add(this));var T=o.stack;this.componentDidCatch(o.value,{componentStack:T!==null?T:""})})}function _w(e,t,i,o,f){if(i.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=i.alternate,t!==null&&_i(t,i,f,!0),i=ua.current,i!==null){switch(i.tag){case 31:case 13:return ka===null?id():i.alternate===null&&mn===0&&(mn=3),i.flags&=-257,i.flags|=65536,i.lanes=f,o===fo?i.flags|=16384:(t=i.updateQueue,t===null?i.updateQueue=new Set([o]):t.add(o),pm(e,o,f)),!1;case 22:return i.flags|=65536,o===fo?i.flags|=16384:(t=i.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},i.updateQueue=t):(i=t.retryQueue,i===null?t.retryQueue=new Set([o]):i.add(o)),pm(e,o,f)),!1}throw Error(l(435,i.tag))}return pm(e,o,f),id(),!1}if(gt)return t=ua.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=f,o!==sc&&(e=Error(l(422),{cause:o}),ii(Ca(e,i)))):(o!==sc&&(t=Error(l(423),{cause:o}),ii(Ca(t,i))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,o=Ca(o,i),f=qf(e.stateNode,o,f),uc(e,f),mn!==4&&(mn=2)),!1;var h=Error(l(520),{cause:o});if(h=Ca(h,i),Ac===null?Ac=[h]:Ac.push(h),mn!==4&&(mn=2),t===null)return!0;o=Ca(o,i),i=t;do{switch(i.tag){case 3:return i.flags|=65536,e=f&-f,i.lanes|=e,e=qf(i.stateNode,o,e),uc(i,e),!1;case 1:if(t=i.type,h=i.stateNode,(i.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(Mr===null||!Mr.has(h))))return i.flags|=65536,f&=-f,i.lanes|=f,f=fg(f),mg(f,e,i,o),uc(i,f),!1}i=i.return}while(i!==null);return!1}var Gf=Error(l(461)),kn=!1;function Wn(e,t,i,o){t.child=e===null?Hu(t,null,i,o):ri(t,e.child,i,o)}function hg(e,t,i,o,f){i=i.render;var h=t.ref;if("ref"in o){var C={};for(var T in o)T!=="ref"&&(C[T]=o[T])}else C=o;return mr(t),o=Ke(e,t,i,C,h,f),T=Cr(),e!==null&&!kn?(jr(e,t,f),Bi(e,t,f)):(gt&&T&&lo(t),t.flags|=1,Wn(e,t,o,f),t.child)}function pg(e,t,i,o,f){if(e===null){var h=i.type;return typeof h=="function"&&!io(h)&&h.defaultProps===void 0&&i.compare===null?(t.tag=15,t.type=h,gg(e,t,h,o,f)):(e=Ti(i.type,null,o,t,t.mode,f),e.ref=t.ref,e.return=t,t.child=e)}if(h=e.child,!Jf(e,f)){var C=h.memoizedProps;if(i=i.compare,i=i!==null?i:al,i(C,o)&&e.ref===t.ref)return Bi(e,t,f)}return t.flags|=1,e=Vn(h,o),e.ref=t.ref,e.return=t,t.child=e}function gg(e,t,i,o,f){if(e!==null){var h=e.memoizedProps;if(al(h,o)&&e.ref===t.ref)if(kn=!1,t.pendingProps=o=h,Jf(e,f))(e.flags&131072)!==0&&(kn=!0);else return t.lanes=e.lanes,Bi(e,t,f)}return Vf(e,t,i,o,f)}function vg(e,t,i,o){var f=o.children,h=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((t.flags&128)!==0){if(h=h!==null?h.baseLanes|i:i,e!==null){for(o=t.child=e.child,f=0;o!==null;)f=f|o.lanes|o.childLanes,o=o.sibling;o=f&~h}else o=0,t.child=null;return xg(e,t,h,i,o)}if((i&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&uo(t,h!==null?h.cachePool:null),h!==null?Fu(t,h):fc(),da(t);else return o=t.lanes=536870912,xg(e,t,h!==null?h.baseLanes|i:i,i,o)}else h!==null?(uo(t,h.cachePool),Fu(t,h),oi(),t.memoizedState=null):(e!==null&&uo(t,null),fc(),oi());return Wn(e,t,f,i),t.child}function yc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function xg(e,t,i,o,f){var h=cc();return h=h===null?null:{parent:fn._currentValue,pool:h},t.memoizedState={baseLanes:i,cachePool:h},e!==null&&uo(t,null),fc(),da(t),e!==null&&_i(e,t,o,!0),t.childLanes=f,null}function Yu(e,t){return t=Qu({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function yg(e,t,i){return ri(t,e.child,null,i),e=Yu(t,t.pendingProps),e.flags|=2,fa(t),t.memoizedState=null,e}function zw(e,t,i){var o=t.pendingProps,f=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(gt){if(o.mode==="hidden")return e=Yu(t,o),t.lanes=536870912,yc(null,e);if(hc(t),(e=It)?(e=Rv(e,ja),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ai!==null?{id:$a,overflow:ds}:null,retryLane:536870912,hydrationErrors:null},i=nc(e),i.return=t,t.child=i,vn=t,It=null)):e=null,e===null)throw qa(t);return t.lanes=536870912,null}return Yu(t,o)}var h=e.memoizedState;if(h!==null){var C=h.dehydrated;if(hc(t),f)if(t.flags&256)t.flags&=-257,t=yg(e,t,i);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(l(558));else if(kn||_i(e,t,i,!1),f=(i&e.childLanes)!==0,kn||f){if(o=Pt,o!==null&&(C=Fe(o,i),C!==0&&C!==h.retryLane))throw h.retryLane=C,us(e,C),Ea(o,e,C),Gf;id(),t=yg(e,t,i)}else e=h.treeContext,It=gs(C.nextSibling),vn=t,gt=!0,Ua=null,ja=!1,e!==null&&ac(t,e),t=Yu(t,o),t.flags|=4096;return t}return e=Vn(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Ku(e,t){var i=t.ref;if(i===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof i!="function"&&typeof i!="object")throw Error(l(284));(e===null||e.ref!==i)&&(t.flags|=4194816)}}function Vf(e,t,i,o,f){return mr(t),i=Ke(e,t,i,o,void 0,f),o=Cr(),e!==null&&!kn?(jr(e,t,f),Bi(e,t,f)):(gt&&o&&lo(t),t.flags|=1,Wn(e,t,i,f),t.child)}function bg(e,t,i,o,f,h){return mr(t),t.updateQueue=null,i=Tn(t,o,i,f),sn(e),o=Cr(),e!==null&&!kn?(jr(e,t,h),Bi(e,t,h)):(gt&&o&&lo(t),t.flags|=1,Wn(e,t,i,h),t.child)}function wg(e,t,i,o,f){if(mr(t),t.stateNode===null){var h=Ms,C=i.contextType;typeof C=="object"&&C!==null&&(h=xn(C)),h=new i(o,h),t.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Uf,t.stateNode=h,h._reactInternals=t,h=t.stateNode,h.props=o,h.state=t.memoizedState,h.refs={},wr(t),C=i.contextType,h.context=typeof C=="object"&&C!==null?xn(C):Ms,h.state=t.memoizedState,C=i.getDerivedStateFromProps,typeof C=="function"&&($f(t,i,C,o),h.state=t.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(C=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),C!==h.state&&Uf.enqueueReplaceState(h,h.state,null),yl(t,o,h,f),xl(),h.state=t.memoizedState),typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){h=t.stateNode;var T=t.memoizedProps,F=Sl(i,T);h.props=F;var re=h.context,ye=i.contextType;C=Ms,typeof ye=="object"&&ye!==null&&(C=xn(ye));var Ce=i.getDerivedStateFromProps;ye=typeof Ce=="function"||typeof h.getSnapshotBeforeUpdate=="function",T=t.pendingProps!==T,ye||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(T||re!==C)&&lg(t,h,o,C),Ds=!1;var ue=t.memoizedState;h.state=ue,yl(t,o,h,f),xl(),re=t.memoizedState,T||ue!==re||Ds?(typeof Ce=="function"&&($f(t,i,Ce,o),re=t.memoizedState),(F=Ds||rg(t,i,F,o,ue,re,C))?(ye||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(t.flags|=4194308)):(typeof h.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=re),h.props=o,h.state=re,h.context=C,o=F):(typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{h=t.stateNode,mo(e,t),C=t.memoizedProps,ye=Sl(i,C),h.props=ye,Ce=t.pendingProps,ue=h.context,re=i.contextType,F=Ms,typeof re=="object"&&re!==null&&(F=xn(re)),T=i.getDerivedStateFromProps,(re=typeof T=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(C!==Ce||ue!==F)&&lg(t,h,o,F),Ds=!1,ue=t.memoizedState,h.state=ue,yl(t,o,h,f),xl();var fe=t.memoizedState;C!==Ce||ue!==fe||Ds||e!==null&&e.dependencies!==null&&oo(e.dependencies)?(typeof T=="function"&&($f(t,i,T,o),fe=t.memoizedState),(ye=Ds||rg(t,i,ye,o,ue,fe,F)||e!==null&&e.dependencies!==null&&oo(e.dependencies))?(re||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(o,fe,F),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(o,fe,F)),typeof h.componentDidUpdate=="function"&&(t.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof h.componentDidUpdate!="function"||C===e.memoizedProps&&ue===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||C===e.memoizedProps&&ue===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=fe),h.props=o,h.state=fe,h.context=F,o=ye):(typeof h.componentDidUpdate!="function"||C===e.memoizedProps&&ue===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||C===e.memoizedProps&&ue===e.memoizedState||(t.flags|=1024),o=!1)}return h=o,Ku(e,t),o=(t.flags&128)!==0,h||o?(h=t.stateNode,i=o&&typeof i.getDerivedStateFromError!="function"?null:h.render(),t.flags|=1,e!==null&&o?(t.child=ri(t,e.child,null,f),t.child=ri(t,null,i,f)):Wn(e,t,i,f),t.memoizedState=h.state,e=t.child):e=Bi(e,t,f),e}function Sg(e,t,i,o){return si(),t.flags|=256,Wn(e,t,i,o),t.child}var Wf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Yf(e){return{baseLanes:e,cachePool:Du()}}function Kf(e,t,i){return e=e!==null?e.childLanes&~i:0,t&&(e|=Qa),e}function Cg(e,t,i){var o=t.pendingProps,f=!1,h=(t.flags&128)!==0,C;if((C=h)||(C=e!==null&&e.memoizedState===null?!1:(Ot.current&2)!==0),C&&(f=!0,t.flags&=-129),C=(t.flags&32)!==0,t.flags&=-33,e===null){if(gt){if(f?li(t):oi(),(e=It)?(e=Rv(e,ja),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ai!==null?{id:$a,overflow:ds}:null,retryLane:536870912,hydrationErrors:null},i=nc(e),i.return=t,t.child=i,vn=t,It=null)):e=null,e===null)throw qa(t);return Rm(e)?t.lanes=32:t.lanes=536870912,null}var T=o.children;return o=o.fallback,f?(oi(),f=t.mode,T=Qu({mode:"hidden",children:T},f),o=ti(o,f,i,null),T.return=t,o.return=t,T.sibling=o,t.child=T,o=t.child,o.memoizedState=Yf(i),o.childLanes=Kf(e,C,i),t.memoizedState=Wf,yc(null,o)):(li(t),Qf(t,T))}var F=e.memoizedState;if(F!==null&&(T=F.dehydrated,T!==null)){if(h)t.flags&256?(li(t),t.flags&=-257,t=Xf(e,t,i)):t.memoizedState!==null?(oi(),t.child=e.child,t.flags|=128,t=null):(oi(),T=o.fallback,f=t.mode,o=Qu({mode:"visible",children:o.children},f),T=ti(T,f,i,null),T.flags|=2,o.return=t,T.return=t,o.sibling=T,t.child=o,ri(t,e.child,null,i),o=t.child,o.memoizedState=Yf(i),o.childLanes=Kf(e,C,i),t.memoizedState=Wf,t=yc(null,o));else if(li(t),Rm(T)){if(C=T.nextSibling&&T.nextSibling.dataset,C)var re=C.dgst;C=re,o=Error(l(419)),o.stack="",o.digest=C,ii({value:o,source:null,stack:null}),t=Xf(e,t,i)}else if(kn||_i(e,t,i,!1),C=(i&e.childLanes)!==0,kn||C){if(C=Pt,C!==null&&(o=Fe(C,i),o!==0&&o!==F.retryLane))throw F.retryLane=o,us(e,o),Ea(C,e,o),Gf;Em(T)||id(),t=Xf(e,t,i)}else Em(T)?(t.flags|=192,t.child=e.child,t=null):(e=F.treeContext,It=gs(T.nextSibling),vn=t,gt=!0,Ua=null,ja=!1,e!==null&&ac(t,e),t=Qf(t,o.children),t.flags|=4096);return t}return f?(oi(),T=o.fallback,f=t.mode,F=e.child,re=F.sibling,o=Vn(F,{mode:"hidden",children:o.children}),o.subtreeFlags=F.subtreeFlags&65011712,re!==null?T=Vn(re,T):(T=ti(T,f,i,null),T.flags|=2),T.return=t,o.return=t,o.sibling=T,t.child=o,yc(null,o),o=t.child,T=e.child.memoizedState,T===null?T=Yf(i):(f=T.cachePool,f!==null?(F=fn._currentValue,f=f.parent!==F?{parent:F,pool:F}:f):f=Du(),T={baseLanes:T.baseLanes|i,cachePool:f}),o.memoizedState=T,o.childLanes=Kf(e,C,i),t.memoizedState=Wf,yc(e.child,o)):(li(t),i=e.child,e=i.sibling,i=Vn(i,{mode:"visible",children:o.children}),i.return=t,i.sibling=null,e!==null&&(C=t.deletions,C===null?(t.deletions=[e],t.flags|=16):C.push(e)),t.child=i,t.memoizedState=null,i)}function Qf(e,t){return t=Qu({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Qu(e,t){return e=Cn(22,e,null,t),e.lanes=0,e}function Xf(e,t,i){return ri(t,e.child,null,i),e=Qf(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function jg(e,t,i){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),Re(e.return,t,i)}function Zf(e,t,i,o,f,h){var C=e.memoizedState;C===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:i,tailMode:f,treeForkCount:h}:(C.isBackwards=t,C.rendering=null,C.renderingStartTime=0,C.last=o,C.tail=i,C.tailMode=f,C.treeForkCount=h)}function kg(e,t,i){var o=t.pendingProps,f=o.revealOrder,h=o.tail;o=o.children;var C=Ot.current,T=(C&2)!==0;if(T?(C=C&1|2,t.flags|=128):C&=1,B(Ot,C),Wn(e,t,o,i),o=gt?ni:0,!T&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&jg(e,i,t);else if(e.tag===19)jg(e,i,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(i=t.child,f=null;i!==null;)e=i.alternate,e!==null&&ho(e)===null&&(f=i),i=i.sibling;i=f,i===null?(f=t.child,t.child=null):(f=i.sibling,i.sibling=null),Zf(t,!1,f,i,h,o);break;case"backwards":case"unstable_legacy-backwards":for(i=null,f=t.child,t.child=null;f!==null;){if(e=f.alternate,e!==null&&ho(e)===null){t.child=f;break}e=f.sibling,f.sibling=i,i=f,f=e}Zf(t,!0,i,null,h,o);break;case"together":Zf(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function Bi(e,t,i){if(e!==null&&(t.dependencies=e.dependencies),Nr|=t.lanes,(i&t.childLanes)===0)if(e!==null){if(_i(e,t,i,!1),(i&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(l(153));if(t.child!==null){for(e=t.child,i=Vn(e,e.pendingProps),t.child=i,i.return=t;e.sibling!==null;)e=e.sibling,i=i.sibling=Vn(e,e.pendingProps),i.return=t;i.sibling=null}return t.child}function Jf(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&oo(e)))}function Iw(e,t,i){switch(t.tag){case 3:_e(t,t.stateNode.containerInfo),hs(t,fn,e.memoizedState.cache),si();break;case 27:case 5:Q(t);break;case 4:_e(t,t.stateNode.containerInfo);break;case 10:hs(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,hc(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(li(t),t.flags|=128,null):(i&t.child.childLanes)!==0?Cg(e,t,i):(li(t),e=Bi(e,t,i),e!==null?e.sibling:null);li(t);break;case 19:var f=(e.flags&128)!==0;if(o=(i&t.childLanes)!==0,o||(_i(e,t,i,!1),o=(i&t.childLanes)!==0),f){if(o)return kg(e,t,i);t.flags|=128}if(f=t.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),B(Ot,Ot.current),o)break;return null;case 22:return t.lanes=0,vg(e,t,i,t.pendingProps);case 24:hs(t,fn,e.memoizedState.cache)}return Bi(e,t,i)}function Ag(e,t,i){if(e!==null)if(e.memoizedProps!==t.pendingProps)kn=!0;else{if(!Jf(e,i)&&(t.flags&128)===0)return kn=!1,Iw(e,t,i);kn=(e.flags&131072)!==0}else kn=!1,gt&&(t.flags&1048576)!==0&&ro(t,ni,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Ii(t.elementType),t.type=e,typeof e=="function")io(e)?(o=Sl(e,o),t.tag=1,t=wg(null,t,e,o,i)):(t.tag=0,t=Vf(null,t,e,o,i));else{if(e!=null){var f=e.$$typeof;if(f===U){t.tag=11,t=hg(null,t,e,o,i);break e}else if(f===_){t.tag=14,t=pg(null,t,e,o,i);break e}}throw t=ce(e)||e,Error(l(306,t,""))}}return t;case 0:return Vf(e,t,t.type,t.pendingProps,i);case 1:return o=t.type,f=Sl(o,t.pendingProps),wg(e,t,o,f,i);case 3:e:{if(_e(t,t.stateNode.containerInfo),e===null)throw Error(l(387));o=t.pendingProps;var h=t.memoizedState;f=h.element,mo(e,t),yl(t,o,null,i);var C=t.memoizedState;if(o=C.cache,hs(t,fn,o),o!==h.cache&&fr(t,[fn],i,!0),xl(),o=C.element,h.isDehydrated)if(h={element:o,isDehydrated:!1,cache:C.cache},t.updateQueue.baseState=h,t.memoizedState=h,t.flags&256){t=Sg(e,t,o,i);break e}else if(o!==f){f=Ca(Error(l(424)),t),ii(f),t=Sg(e,t,o,i);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,It=gs(e.firstChild),vn=t,gt=!0,Ua=null,ja=!0,i=Hu(t,null,o,i),t.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(si(),o===f){t=Bi(e,t,i);break e}Wn(e,t,o,i)}t=t.child}return t;case 26:return Ku(e,t),e===null?(i=Ov(t.type,null,t.pendingProps,null))?t.memoizedState=i:gt||(i=t.type,e=t.pendingProps,o=fd(xe.current).createElement(i),o[ee]=t,o[Te]=e,Yn(o,i,e),zt(o),t.stateNode=o):t.memoizedState=Ov(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Q(t),e===null&>&&(o=t.stateNode=_v(t.type,t.pendingProps,xe.current),vn=t,ja=!0,f=It,Dr(t.type)?(Dm=f,It=gs(o.firstChild)):It=f),Wn(e,t,t.pendingProps.children,i),Ku(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&>&&((f=o=It)&&(o=fS(o,t.type,t.pendingProps,ja),o!==null?(t.stateNode=o,vn=t,It=gs(o.firstChild),ja=!1,f=!0):f=!1),f||qa(t)),Q(t),f=t.type,h=t.pendingProps,C=e!==null?e.memoizedProps:null,o=h.children,Nm(f,h)?o=null:C!==null&&Nm(f,C)&&(t.flags|=32),t.memoizedState!==null&&(f=Ke(e,t,Ya,null,null,i),_c._currentValue=f),Ku(e,t),Wn(e,t,o,i),t.child;case 6:return e===null&>&&((e=i=It)&&(i=mS(i,t.pendingProps,ja),i!==null?(t.stateNode=i,vn=t,It=null,e=!0):e=!1),e||qa(t)),null;case 13:return Cg(e,t,i);case 4:return _e(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=ri(t,null,o,i):Wn(e,t,o,i),t.child;case 11:return hg(e,t,t.type,t.pendingProps,i);case 7:return Wn(e,t,t.pendingProps,i),t.child;case 8:return Wn(e,t,t.pendingProps.children,i),t.child;case 12:return Wn(e,t,t.pendingProps.children,i),t.child;case 10:return o=t.pendingProps,hs(t,t.type,o.value),Wn(e,t,o.children,i),t.child;case 9:return f=t.type._context,o=t.pendingProps.children,mr(t),f=xn(f),o=o(f),t.flags|=1,Wn(e,t,o,i),t.child;case 14:return pg(e,t,t.type,t.pendingProps,i);case 15:return gg(e,t,t.type,t.pendingProps,i);case 19:return kg(e,t,i);case 31:return zw(e,t,i);case 22:return vg(e,t,i,t.pendingProps);case 24:return mr(t),o=xn(fn),e===null?(f=cc(),f===null&&(f=Pt,h=lc(),f.pooledCache=h,h.refCount++,h!==null&&(f.pooledCacheLanes|=i),f=h),t.memoizedState={parent:o,cache:f},wr(t),hs(t,fn,f)):((e.lanes&i)!==0&&(mo(e,t),yl(t,null,null,i),xl()),f=e.memoizedState,h=t.memoizedState,f.parent!==o?(f={parent:o,cache:o},t.memoizedState=f,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=f),hs(t,fn,o)):(o=h.cache,hs(t,fn,o),o!==f.cache&&fr(t,[fn],i,!0))),Wn(e,t,t.pendingProps.children,i),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function Fi(e){e.flags|=4}function em(e,t,i,o,f){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(Jg())e.flags|=8192;else throw Oi=fo,gl}else e.flags&=-16777217}function Ng(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!$v(t))if(Jg())e.flags|=8192;else throw Oi=fo,gl}function Xu(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?hi():536870912,e.lanes|=t,yo|=t)}function bc(e,t){if(!gt)switch(e.tailMode){case"hidden":t=e.tail;for(var i=null;t!==null;)t.alternate!==null&&(i=t),t=t.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var o=null;i!==null;)i.alternate!==null&&(o=i),i=i.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Yt(e){var t=e.alternate!==null&&e.alternate.child===e.child,i=0,o=0;if(t)for(var f=e.child;f!==null;)i|=f.lanes|f.childLanes,o|=f.subtreeFlags&65011712,o|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)i|=f.lanes|f.childLanes,o|=f.subtreeFlags,o|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=o,e.childLanes=i,t}function Ow(e,t,i){var o=t.pendingProps;switch(Di(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yt(t),null;case 1:return Yt(t),null;case 3:return i=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),Ga(fn),ie(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Li(t)?Fi(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,rc())),Yt(t),null;case 26:var f=t.type,h=t.memoizedState;return e===null?(Fi(t),h!==null?(Yt(t),Ng(t,h)):(Yt(t),em(t,f,null,o,i))):h?h!==e.memoizedState?(Fi(t),Yt(t),Ng(t,h)):(Yt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&Fi(t),Yt(t),em(t,f,e,o,i)),null;case 27:if(Ie(t),i=xe.current,f=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&Fi(t);else{if(!o){if(t.stateNode===null)throw Error(l(166));return Yt(t),null}e=pe.current,Li(t)?Tu(t):(e=_v(f,o,i),t.stateNode=e,Fi(t))}return Yt(t),null;case 5:if(Ie(t),f=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&Fi(t);else{if(!o){if(t.stateNode===null)throw Error(l(166));return Yt(t),null}if(h=pe.current,Li(t))Tu(t);else{var C=fd(xe.current);switch(h){case 1:h=C.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:h=C.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":h=C.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":h=C.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":h=C.createElement("div"),h.innerHTML="<script><\/script>",h=h.removeChild(h.firstChild);break;case"select":h=typeof o.is=="string"?C.createElement("select",{is:o.is}):C.createElement("select"),o.multiple?h.multiple=!0:o.size&&(h.size=o.size);break;default:h=typeof o.is=="string"?C.createElement(f,{is:o.is}):C.createElement(f)}}h[ee]=t,h[Te]=o;e:for(C=t.child;C!==null;){if(C.tag===5||C.tag===6)h.appendChild(C.stateNode);else if(C.tag!==4&&C.tag!==27&&C.child!==null){C.child.return=C,C=C.child;continue}if(C===t)break e;for(;C.sibling===null;){if(C.return===null||C.return===t)break e;C=C.return}C.sibling.return=C.return,C=C.sibling}t.stateNode=h;e:switch(Yn(h,f,o),f){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Fi(t)}}return Yt(t),em(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,i),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&Fi(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(l(166));if(e=xe.current,Li(t)){if(e=t.stateNode,i=t.memoizedProps,o=null,f=vn,f!==null)switch(f.tag){case 27:case 5:o=f.memoizedProps}e[ee]=t,e=!!(e.nodeValue===i||o!==null&&o.suppressHydrationWarning===!0||Cv(e.nodeValue,i)),e||qa(t,!0)}else e=fd(e).createTextNode(o),e[ee]=t,t.stateNode=e}return Yt(t),null;case 31:if(i=t.memoizedState,e===null||e.memoizedState!==null){if(o=Li(t),i!==null){if(e===null){if(!o)throw Error(l(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(557));e[ee]=t}else si(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Yt(t),e=!1}else i=rc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return t.flags&256?(fa(t),t):(fa(t),null);if((t.flags&128)!==0)throw Error(l(558))}return Yt(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=Li(t),o!==null&&o.dehydrated!==null){if(e===null){if(!f)throw Error(l(318));if(f=t.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(l(317));f[ee]=t}else si(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Yt(t),f=!1}else f=rc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return t.flags&256?(fa(t),t):(fa(t),null)}return fa(t),(t.flags&128)!==0?(t.lanes=i,t):(i=o!==null,e=e!==null&&e.memoizedState!==null,i&&(o=t.child,f=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(f=o.alternate.memoizedState.cachePool.pool),h=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(h=o.memoizedState.cachePool.pool),h!==f&&(o.flags|=2048)),i!==e&&i&&(t.child.flags|=8192),Xu(t,t.updateQueue),Yt(t),null);case 4:return ie(),e===null&&Sm(t.stateNode.containerInfo),Yt(t),null;case 10:return Ga(t.type),Yt(t),null;case 19:if(J(Ot),o=t.memoizedState,o===null)return Yt(t),null;if(f=(t.flags&128)!==0,h=o.rendering,h===null)if(f)bc(o,!1);else{if(mn!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(h=ho(e),h!==null){for(t.flags|=128,bc(o,!1),e=h.updateQueue,t.updateQueue=e,Xu(t,e),t.subtreeFlags=0,e=i,i=t.child;i!==null;)dl(i,e),i=i.sibling;return B(Ot,Ot.current&1|2),gt&&Ts(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&at()>nd&&(t.flags|=128,f=!0,bc(o,!1),t.lanes=4194304)}else{if(!f)if(e=ho(h),e!==null){if(t.flags|=128,f=!0,e=e.updateQueue,t.updateQueue=e,Xu(t,e),bc(o,!0),o.tail===null&&o.tailMode==="hidden"&&!h.alternate&&!gt)return Yt(t),null}else 2*at()-o.renderingStartTime>nd&&i!==536870912&&(t.flags|=128,f=!0,bc(o,!1),t.lanes=4194304);o.isBackwards?(h.sibling=t.child,t.child=h):(e=o.last,e!==null?e.sibling=h:t.child=h,o.last=h)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=at(),e.sibling=null,i=Ot.current,B(Ot,f?i&1|2:i&1),gt&&Ts(t,o.treeForkCount),e):(Yt(t),null);case 22:case 23:return fa(t),mc(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(i&536870912)!==0&&(t.flags&128)===0&&(Yt(t),t.subtreeFlags&6&&(t.flags|=8192)):Yt(t),i=t.updateQueue,i!==null&&Xu(t,i.retryQueue),i=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==i&&(t.flags|=2048),e!==null&&J(zi),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Ga(fn),Yt(t),null;case 25:return null;case 30:return null}throw Error(l(156,t.tag))}function Hw(e,t){switch(Di(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ga(fn),ie(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ie(t),null;case 31:if(t.memoizedState!==null){if(fa(t),t.alternate===null)throw Error(l(340));si()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(fa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(l(340));si()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return J(Ot),null;case 4:return ie(),null;case 10:return Ga(t.type),null;case 22:case 23:return fa(t),mc(),e!==null&&J(zi),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ga(fn),null;case 25:return null;default:return null}}function Mg(e,t){switch(Di(t),t.tag){case 3:Ga(fn),ie();break;case 26:case 27:case 5:Ie(t);break;case 4:ie();break;case 31:t.memoizedState!==null&&fa(t);break;case 13:fa(t);break;case 19:J(Ot);break;case 10:Ga(t.type);break;case 22:case 23:fa(t),mc(),e!==null&&J(zi);break;case 24:Ga(fn)}}function wc(e,t){try{var i=t.updateQueue,o=i!==null?i.lastEffect:null;if(o!==null){var f=o.next;i=f;do{if((i.tag&e)===e){o=void 0;var h=i.create,C=i.inst;o=h(),C.destroy=o}i=i.next}while(i!==f)}}catch(T){Dt(t,t.return,T)}}function kr(e,t,i){try{var o=t.updateQueue,f=o!==null?o.lastEffect:null;if(f!==null){var h=f.next;o=h;do{if((o.tag&e)===e){var C=o.inst,T=C.destroy;if(T!==void 0){C.destroy=void 0,f=t;var F=i,re=T;try{re()}catch(ye){Dt(f,F,ye)}}}o=o.next}while(o!==h)}}catch(ye){Dt(t,t.return,ye)}}function Tg(e){var t=e.updateQueue;if(t!==null){var i=e.stateNode;try{bl(t,i)}catch(o){Dt(e,e.return,o)}}}function Eg(e,t,i){i.props=Sl(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(o){Dt(e,t,o)}}function Sc(e,t){try{var i=e.ref;if(i!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof i=="function"?e.refCleanup=i(o):i.current=o}}catch(f){Dt(e,t,f)}}function ci(e,t){var i=e.ref,o=e.refCleanup;if(i!==null)if(typeof o=="function")try{o()}catch(f){Dt(e,t,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(f){Dt(e,t,f)}else i.current=null}function Rg(e){var t=e.type,i=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":i.autoFocus&&o.focus();break e;case"img":i.src?o.src=i.src:i.srcSet&&(o.srcset=i.srcSet)}}catch(f){Dt(e,e.return,f)}}function tm(e,t,i){try{var o=e.stateNode;rS(o,e.type,i,t),o[Te]=t}catch(f){Dt(e,e.return,f)}}function Dg(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Dr(e.type)||e.tag===4}function nm(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Dg(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Dr(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function am(e,t,i){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(e,t):(t=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,t.appendChild(e),i=i._reactRootContainer,i!=null||t.onclick!==null||(t.onclick=Un));else if(o!==4&&(o===27&&Dr(e.type)&&(i=e.stateNode,t=null),e=e.child,e!==null))for(am(e,t,i),e=e.sibling;e!==null;)am(e,t,i),e=e.sibling}function Zu(e,t,i){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?i.insertBefore(e,t):i.appendChild(e);else if(o!==4&&(o===27&&Dr(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(Zu(e,t,i),e=e.sibling;e!==null;)Zu(e,t,i),e=e.sibling}function Lg(e){var t=e.stateNode,i=e.memoizedProps;try{for(var o=e.type,f=t.attributes;f.length;)t.removeAttributeNode(f[0]);Yn(t,o,i),t[ee]=e,t[Te]=i}catch(h){Dt(e,e.return,h)}}var Pi=!1,An=!1,sm=!1,_g=typeof WeakSet=="function"?WeakSet:Set,On=null;function Bw(e,t){if(e=e.containerInfo,km=yd,e=ji(e),no(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var o=i.getSelection&&i.getSelection();if(o&&o.rangeCount!==0){i=o.anchorNode;var f=o.anchorOffset,h=o.focusNode;o=o.focusOffset;try{i.nodeType,h.nodeType}catch{i=null;break e}var C=0,T=-1,F=-1,re=0,ye=0,Ce=e,ue=null;t:for(;;){for(var fe;Ce!==i||f!==0&&Ce.nodeType!==3||(T=C+f),Ce!==h||o!==0&&Ce.nodeType!==3||(F=C+o),Ce.nodeType===3&&(C+=Ce.nodeValue.length),(fe=Ce.firstChild)!==null;)ue=Ce,Ce=fe;for(;;){if(Ce===e)break t;if(ue===i&&++re===f&&(T=C),ue===h&&++ye===o&&(F=C),(fe=Ce.nextSibling)!==null)break;Ce=ue,ue=Ce.parentNode}Ce=fe}i=T===-1||F===-1?null:{start:T,end:F}}else i=null}i=i||{start:0,end:0}}else i=null;for(Am={focusedElem:e,selectionRange:i},yd=!1,On=t;On!==null;)if(t=On,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,On=e;else for(;On!==null;){switch(t=On,h=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(i=0;i<e.length;i++)f=e[i],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&h!==null){e=void 0,i=t,f=h.memoizedProps,h=h.memoizedState,o=i.stateNode;try{var Ve=Sl(i.type,f);e=o.getSnapshotBeforeUpdate(Ve,h),o.__reactInternalSnapshotBeforeUpdate=e}catch(Je){Dt(i,i.return,Je)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,i=e.nodeType,i===9)Tm(e);else if(i===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Tm(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(l(163))}if(e=t.sibling,e!==null){e.return=t.return,On=e;break}On=t.return}}function zg(e,t,i){var o=i.flags;switch(i.tag){case 0:case 11:case 15:Ui(e,i),o&4&&wc(5,i);break;case 1:if(Ui(e,i),o&4)if(e=i.stateNode,t===null)try{e.componentDidMount()}catch(C){Dt(i,i.return,C)}else{var f=Sl(i.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(f,t,e.__reactInternalSnapshotBeforeUpdate)}catch(C){Dt(i,i.return,C)}}o&64&&Tg(i),o&512&&Sc(i,i.return);break;case 3:if(Ui(e,i),o&64&&(e=i.updateQueue,e!==null)){if(t=null,i.child!==null)switch(i.child.tag){case 27:case 5:t=i.child.stateNode;break;case 1:t=i.child.stateNode}try{bl(e,t)}catch(C){Dt(i,i.return,C)}}break;case 27:t===null&&o&4&&Lg(i);case 26:case 5:Ui(e,i),t===null&&o&4&&Rg(i),o&512&&Sc(i,i.return);break;case 12:Ui(e,i);break;case 31:Ui(e,i),o&4&&Hg(e,i);break;case 13:Ui(e,i),o&4&&Bg(e,i),o&64&&(e=i.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(i=Yw.bind(null,i),hS(e,i))));break;case 22:if(o=i.memoizedState!==null||Pi,!o){t=t!==null&&t.memoizedState!==null||An,f=Pi;var h=An;Pi=o,(An=t)&&!h?qi(e,i,(i.subtreeFlags&8772)!==0):Ui(e,i),Pi=f,An=h}break;case 30:break;default:Ui(e,i)}}function Ig(e){var t=e.alternate;t!==null&&(e.alternate=null,Ig(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Qt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Jt=null,Aa=!1;function $i(e,t,i){for(i=i.child;i!==null;)Og(e,t,i),i=i.sibling}function Og(e,t,i){if(rt&&typeof rt.onCommitFiberUnmount=="function")try{rt.onCommitFiberUnmount(pt,i)}catch{}switch(i.tag){case 26:An||ci(i,t),$i(e,t,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:An||ci(i,t);var o=Jt,f=Aa;Dr(i.type)&&(Jt=i.stateNode,Aa=!1),$i(e,t,i),Rc(i.stateNode),Jt=o,Aa=f;break;case 5:An||ci(i,t);case 6:if(o=Jt,f=Aa,Jt=null,$i(e,t,i),Jt=o,Aa=f,Jt!==null)if(Aa)try{(Jt.nodeType===9?Jt.body:Jt.nodeName==="HTML"?Jt.ownerDocument.body:Jt).removeChild(i.stateNode)}catch(h){Dt(i,t,h)}else try{Jt.removeChild(i.stateNode)}catch(h){Dt(i,t,h)}break;case 18:Jt!==null&&(Aa?(e=Jt,Tv(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,i.stateNode),No(e)):Tv(Jt,i.stateNode));break;case 4:o=Jt,f=Aa,Jt=i.stateNode.containerInfo,Aa=!0,$i(e,t,i),Jt=o,Aa=f;break;case 0:case 11:case 14:case 15:kr(2,i,t),An||kr(4,i,t),$i(e,t,i);break;case 1:An||(ci(i,t),o=i.stateNode,typeof o.componentWillUnmount=="function"&&Eg(i,t,o)),$i(e,t,i);break;case 21:$i(e,t,i);break;case 22:An=(o=An)||i.memoizedState!==null,$i(e,t,i),An=o;break;default:$i(e,t,i)}}function Hg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{No(e)}catch(i){Dt(t,t.return,i)}}}function Bg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{No(e)}catch(i){Dt(t,t.return,i)}}function Fw(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new _g),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new _g),t;default:throw Error(l(435,e.tag))}}function Ju(e,t){var i=Fw(e);t.forEach(function(o){if(!i.has(o)){i.add(o);var f=Kw.bind(null,e,o);o.then(f,f)}})}function Na(e,t){var i=t.deletions;if(i!==null)for(var o=0;o<i.length;o++){var f=i[o],h=e,C=t,T=C;e:for(;T!==null;){switch(T.tag){case 27:if(Dr(T.type)){Jt=T.stateNode,Aa=!1;break e}break;case 5:Jt=T.stateNode,Aa=!1;break e;case 3:case 4:Jt=T.stateNode.containerInfo,Aa=!0;break e}T=T.return}if(Jt===null)throw Error(l(160));Og(h,C,f),Jt=null,Aa=!1,h=f.alternate,h!==null&&(h.return=null),f.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Fg(t,e),t=t.sibling}var Ls=null;function Fg(e,t){var i=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Na(t,e),Ma(e),o&4&&(kr(3,e,e.return),wc(3,e),kr(5,e,e.return));break;case 1:Na(t,e),Ma(e),o&512&&(An||i===null||ci(i,i.return)),o&64&&Pi&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(i=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=i===null?o:i.concat(o))));break;case 26:var f=Ls;if(Na(t,e),Ma(e),o&512&&(An||i===null||ci(i,i.return)),o&4){var h=i!==null?i.memoizedState:null;if(o=e.memoizedState,i===null)if(o===null)if(e.stateNode===null){e:{o=e.type,i=e.memoizedProps,f=f.ownerDocument||f;t:switch(o){case"title":h=f.getElementsByTagName("title")[0],(!h||h[lt]||h[ee]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=f.createElement(o),f.head.insertBefore(h,f.querySelector("head > title"))),Yn(h,o,i),h[ee]=e,zt(h),o=h;break e;case"link":var C=Fv("link","href",f).get(o+(i.href||""));if(C){for(var T=0;T<C.length;T++)if(h=C[T],h.getAttribute("href")===(i.href==null||i.href===""?null:i.href)&&h.getAttribute("rel")===(i.rel==null?null:i.rel)&&h.getAttribute("title")===(i.title==null?null:i.title)&&h.getAttribute("crossorigin")===(i.crossOrigin==null?null:i.crossOrigin)){C.splice(T,1);break t}}h=f.createElement(o),Yn(h,o,i),f.head.appendChild(h);break;case"meta":if(C=Fv("meta","content",f).get(o+(i.content||""))){for(T=0;T<C.length;T++)if(h=C[T],h.getAttribute("content")===(i.content==null?null:""+i.content)&&h.getAttribute("name")===(i.name==null?null:i.name)&&h.getAttribute("property")===(i.property==null?null:i.property)&&h.getAttribute("http-equiv")===(i.httpEquiv==null?null:i.httpEquiv)&&h.getAttribute("charset")===(i.charSet==null?null:i.charSet)){C.splice(T,1);break t}}h=f.createElement(o),Yn(h,o,i),f.head.appendChild(h);break;default:throw Error(l(468,o))}h[ee]=e,zt(h),o=h}e.stateNode=o}else Pv(f,e.type,e.stateNode);else e.stateNode=Bv(f,o,e.memoizedProps);else h!==o?(h===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):h.count--,o===null?Pv(f,e.type,e.stateNode):Bv(f,o,e.memoizedProps)):o===null&&e.stateNode!==null&&tm(e,e.memoizedProps,i.memoizedProps)}break;case 27:Na(t,e),Ma(e),o&512&&(An||i===null||ci(i,i.return)),i!==null&&o&4&&tm(e,e.memoizedProps,i.memoizedProps);break;case 5:if(Na(t,e),Ma(e),o&512&&(An||i===null||ci(i,i.return)),e.flags&32){f=e.stateNode;try{Ps(f,"")}catch(Ve){Dt(e,e.return,Ve)}}o&4&&e.stateNode!=null&&(f=e.memoizedProps,tm(e,f,i!==null?i.memoizedProps:f)),o&1024&&(sm=!0);break;case 6:if(Na(t,e),Ma(e),o&4){if(e.stateNode===null)throw Error(l(162));o=e.memoizedProps,i=e.stateNode;try{i.nodeValue=o}catch(Ve){Dt(e,e.return,Ve)}}break;case 3:if(pd=null,f=Ls,Ls=md(t.containerInfo),Na(t,e),Ls=f,Ma(e),o&4&&i!==null&&i.memoizedState.isDehydrated)try{No(t.containerInfo)}catch(Ve){Dt(e,e.return,Ve)}sm&&(sm=!1,Pg(e));break;case 4:o=Ls,Ls=md(e.stateNode.containerInfo),Na(t,e),Ma(e),Ls=o;break;case 12:Na(t,e),Ma(e);break;case 31:Na(t,e),Ma(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Ju(e,o)));break;case 13:Na(t,e),Ma(e),e.child.flags&8192&&e.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(td=at()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Ju(e,o)));break;case 22:f=e.memoizedState!==null;var F=i!==null&&i.memoizedState!==null,re=Pi,ye=An;if(Pi=re||f,An=ye||F,Na(t,e),An=ye,Pi=re,Ma(e),o&8192)e:for(t=e.stateNode,t._visibility=f?t._visibility&-2:t._visibility|1,f&&(i===null||F||Pi||An||Cl(e)),i=null,t=e;;){if(t.tag===5||t.tag===26){if(i===null){F=i=t;try{if(h=F.stateNode,f)C=h.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none";else{T=F.stateNode;var Ce=F.memoizedProps.style,ue=Ce!=null&&Ce.hasOwnProperty("display")?Ce.display:null;T.style.display=ue==null||typeof ue=="boolean"?"":(""+ue).trim()}}catch(Ve){Dt(F,F.return,Ve)}}}else if(t.tag===6){if(i===null){F=t;try{F.stateNode.nodeValue=f?"":F.memoizedProps}catch(Ve){Dt(F,F.return,Ve)}}}else if(t.tag===18){if(i===null){F=t;try{var fe=F.stateNode;f?Ev(fe,!0):Ev(F.stateNode,!1)}catch(Ve){Dt(F,F.return,Ve)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;i===t&&(i=null),t=t.return}i===t&&(i=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(i=o.retryQueue,i!==null&&(o.retryQueue=null,Ju(e,i))));break;case 19:Na(t,e),Ma(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Ju(e,o)));break;case 30:break;case 21:break;default:Na(t,e),Ma(e)}}function Ma(e){var t=e.flags;if(t&2){try{for(var i,o=e.return;o!==null;){if(Dg(o)){i=o;break}o=o.return}if(i==null)throw Error(l(160));switch(i.tag){case 27:var f=i.stateNode,h=nm(e);Zu(e,h,f);break;case 5:var C=i.stateNode;i.flags&32&&(Ps(C,""),i.flags&=-33);var T=nm(e);Zu(e,T,C);break;case 3:case 4:var F=i.stateNode.containerInfo,re=nm(e);am(e,re,F);break;default:throw Error(l(161))}}catch(ye){Dt(e,e.return,ye)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Pg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Pg(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Ui(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)zg(e,t.alternate,t),t=t.sibling}function Cl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:kr(4,t,t.return),Cl(t);break;case 1:ci(t,t.return);var i=t.stateNode;typeof i.componentWillUnmount=="function"&&Eg(t,t.return,i),Cl(t);break;case 27:Rc(t.stateNode);case 26:case 5:ci(t,t.return),Cl(t);break;case 22:t.memoizedState===null&&Cl(t);break;case 30:Cl(t);break;default:Cl(t)}e=e.sibling}}function qi(e,t,i){for(i=i&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,f=e,h=t,C=h.flags;switch(h.tag){case 0:case 11:case 15:qi(f,h,i),wc(4,h);break;case 1:if(qi(f,h,i),o=h,f=o.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(re){Dt(o,o.return,re)}if(o=h,f=o.updateQueue,f!==null){var T=o.stateNode;try{var F=f.shared.hiddenCallbacks;if(F!==null)for(f.shared.hiddenCallbacks=null,f=0;f<F.length;f++)dc(F[f],T)}catch(re){Dt(o,o.return,re)}}i&&C&64&&Tg(h),Sc(h,h.return);break;case 27:Lg(h);case 26:case 5:qi(f,h,i),i&&o===null&&C&4&&Rg(h),Sc(h,h.return);break;case 12:qi(f,h,i);break;case 31:qi(f,h,i),i&&C&4&&Hg(f,h);break;case 13:qi(f,h,i),i&&C&4&&Bg(f,h);break;case 22:h.memoizedState===null&&qi(f,h,i),Sc(h,h.return);break;case 30:break;default:qi(f,h,i)}t=t.sibling}}function im(e,t){var i=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==i&&(e!=null&&e.refCount++,i!=null&&hl(i))}function rm(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&hl(e))}function _s(e,t,i,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)$g(e,t,i,o),t=t.sibling}function $g(e,t,i,o){var f=t.flags;switch(t.tag){case 0:case 11:case 15:_s(e,t,i,o),f&2048&&wc(9,t);break;case 1:_s(e,t,i,o);break;case 3:_s(e,t,i,o),f&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&hl(e)));break;case 12:if(f&2048){_s(e,t,i,o),e=t.stateNode;try{var h=t.memoizedProps,C=h.id,T=h.onPostCommit;typeof T=="function"&&T(C,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(F){Dt(t,t.return,F)}}else _s(e,t,i,o);break;case 31:_s(e,t,i,o);break;case 13:_s(e,t,i,o);break;case 23:break;case 22:h=t.stateNode,C=t.alternate,t.memoizedState!==null?h._visibility&2?_s(e,t,i,o):Cc(e,t):h._visibility&2?_s(e,t,i,o):(h._visibility|=2,go(e,t,i,o,(t.subtreeFlags&10256)!==0||!1)),f&2048&&im(C,t);break;case 24:_s(e,t,i,o),f&2048&&rm(t.alternate,t);break;default:_s(e,t,i,o)}}function go(e,t,i,o,f){for(f=f&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var h=e,C=t,T=i,F=o,re=C.flags;switch(C.tag){case 0:case 11:case 15:go(h,C,T,F,f),wc(8,C);break;case 23:break;case 22:var ye=C.stateNode;C.memoizedState!==null?ye._visibility&2?go(h,C,T,F,f):Cc(h,C):(ye._visibility|=2,go(h,C,T,F,f)),f&&re&2048&&im(C.alternate,C);break;case 24:go(h,C,T,F,f),f&&re&2048&&rm(C.alternate,C);break;default:go(h,C,T,F,f)}t=t.sibling}}function Cc(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var i=e,o=t,f=o.flags;switch(o.tag){case 22:Cc(i,o),f&2048&&im(o.alternate,o);break;case 24:Cc(i,o),f&2048&&rm(o.alternate,o);break;default:Cc(i,o)}t=t.sibling}}var jc=8192;function vo(e,t,i){if(e.subtreeFlags&jc)for(e=e.child;e!==null;)Ug(e,t,i),e=e.sibling}function Ug(e,t,i){switch(e.tag){case 26:vo(e,t,i),e.flags&jc&&e.memoizedState!==null&&AS(i,Ls,e.memoizedState,e.memoizedProps);break;case 5:vo(e,t,i);break;case 3:case 4:var o=Ls;Ls=md(e.stateNode.containerInfo),vo(e,t,i),Ls=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=jc,jc=16777216,vo(e,t,i),jc=o):vo(e,t,i));break;default:vo(e,t,i)}}function qg(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function kc(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var i=0;i<t.length;i++){var o=t[i];On=o,Vg(o,e)}qg(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Gg(e),e=e.sibling}function Gg(e){switch(e.tag){case 0:case 11:case 15:kc(e),e.flags&2048&&kr(9,e,e.return);break;case 3:kc(e);break;case 12:kc(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,ed(e)):kc(e);break;default:kc(e)}}function ed(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var i=0;i<t.length;i++){var o=t[i];On=o,Vg(o,e)}qg(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:kr(8,t,t.return),ed(t);break;case 22:i=t.stateNode,i._visibility&2&&(i._visibility&=-3,ed(t));break;default:ed(t)}e=e.sibling}}function Vg(e,t){for(;On!==null;){var i=On;switch(i.tag){case 0:case 11:case 15:kr(8,i,t);break;case 23:case 22:if(i.memoizedState!==null&&i.memoizedState.cachePool!==null){var o=i.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:hl(i.memoizedState.cache)}if(o=i.child,o!==null)o.return=i,On=o;else e:for(i=e;On!==null;){o=On;var f=o.sibling,h=o.return;if(Ig(o),o===i){On=null;break e}if(f!==null){f.return=h,On=f;break e}On=h}}}var Pw={getCacheForType:function(e){var t=xn(fn),i=t.data.get(e);return i===void 0&&(i=e(),t.data.set(e,i)),i},cacheSignal:function(){return xn(fn).controller.signal}},$w=typeof WeakMap=="function"?WeakMap:Map,Mt=0,Pt=null,xt=null,bt=0,Rt=0,Ka=null,Ar=!1,xo=!1,lm=!1,Gi=0,mn=0,Nr=0,jl=0,om=0,Qa=0,yo=0,Ac=null,Ta=null,cm=!1,td=0,Wg=0,nd=1/0,ad=null,Mr=null,En=0,Tr=null,bo=null,Vi=0,um=0,dm=null,Yg=null,Nc=0,fm=null;function Xa(){return(Mt&2)!==0&&bt!==0?bt&-bt:O.T!==null?xm():pn()}function Kg(){if(Qa===0)if((bt&536870912)===0||gt){var e=$n;$n<<=1,($n&3932160)===0&&($n=262144),Qa=e}else Qa=536870912;return e=ua.current,e!==null&&(e.flags|=32),Qa}function Ea(e,t,i){(e===Pt&&(Rt===2||Rt===9)||e.cancelPendingCommit!==null)&&(wo(e,0),Er(e,bt,Qa,!1)),as(e,i),((Mt&2)===0||e!==Pt)&&(e===Pt&&((Mt&2)===0&&(jl|=i),mn===4&&Er(e,bt,Qa,!1)),ui(e))}function Qg(e,t,i){if((Mt&6)!==0)throw Error(l(327));var o=!i&&(t&127)===0&&(t&e.expiredLanes)===0||ns(e,t),f=o?Gw(e,t):hm(e,t,!0),h=o;do{if(f===0){xo&&!o&&Er(e,t,0,!1);break}else{if(i=e.current.alternate,h&&!Uw(i)){f=hm(e,t,!1),h=!1;continue}if(f===2){if(h=t,e.errorRecoveryDisabledLanes&h)var C=0;else C=e.pendingLanes&-536870913,C=C!==0?C:C&536870912?536870912:0;if(C!==0){t=C;e:{var T=e;f=Ac;var F=T.current.memoizedState.isDehydrated;if(F&&(wo(T,C).flags|=256),C=hm(T,C,!1),C!==2){if(lm&&!F){T.errorRecoveryDisabledLanes|=h,jl|=h,f=4;break e}h=Ta,Ta=f,h!==null&&(Ta===null?Ta=h:Ta.push.apply(Ta,h))}f=C}if(h=!1,f!==2)continue}}if(f===1){wo(e,0),Er(e,t,0,!0);break}e:{switch(o=e,h=f,h){case 0:case 1:throw Error(l(345));case 4:if((t&4194048)!==t)break;case 6:Er(o,t,Qa,!Ar);break e;case 2:Ta=null;break;case 3:case 5:break;default:throw Error(l(329))}if((t&62914560)===t&&(f=td+300-at(),10<f)){if(Er(o,t,Qa,!Ar),Ln(o,0,!0)!==0)break e;Vi=t,o.timeoutHandle=Nv(Xg.bind(null,o,i,Ta,ad,cm,t,Qa,jl,yo,Ar,h,"Throttled",-0,0),f);break e}Xg(o,i,Ta,ad,cm,t,Qa,jl,yo,Ar,h,null,-0,0)}}break}while(!0);ui(e)}function Xg(e,t,i,o,f,h,C,T,F,re,ye,Ce,ue,fe){if(e.timeoutHandle=-1,Ce=t.subtreeFlags,Ce&8192||(Ce&16785408)===16785408){Ce={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Un},Ug(t,h,Ce);var Ve=(h&62914560)===h?td-at():(h&4194048)===h?Wg-at():0;if(Ve=NS(Ce,Ve),Ve!==null){Vi=h,e.cancelPendingCommit=Ve(iv.bind(null,e,t,h,i,o,f,C,T,F,ye,Ce,null,ue,fe)),Er(e,h,C,!re);return}}iv(e,t,h,i,o,f,C,T,F)}function Uw(e){for(var t=e;;){var i=t.tag;if((i===0||i===11||i===15)&&t.flags&16384&&(i=t.updateQueue,i!==null&&(i=i.stores,i!==null)))for(var o=0;o<i.length;o++){var f=i[o],h=f.getSnapshot;f=f.value;try{if(!ea(h(),f))return!1}catch{return!1}}if(i=t.child,t.subtreeFlags&16384&&i!==null)i.return=t,t=i;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Er(e,t,i,o){t&=~om,t&=~jl,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var f=t;0<f;){var h=31-kt(f),C=1<<h;o[h]=-1,f&=~C}i!==0&&Bs(e,i,t)}function sd(){return(Mt&6)===0?(Mc(0),!1):!0}function mm(){if(xt!==null){if(Rt===0)var e=xt.return;else e=xt,Es=ms=null,pc(e),xr=null,vl=0,e=xt;for(;e!==null;)Mg(e.alternate,e),e=e.return;xt=null}}function wo(e,t){var i=e.timeoutHandle;i!==-1&&(e.timeoutHandle=-1,cS(i)),i=e.cancelPendingCommit,i!==null&&(e.cancelPendingCommit=null,i()),Vi=0,mm(),Pt=e,xt=i=Vn(e.current,null),bt=t,Rt=0,Ka=null,Ar=!1,xo=ns(e,t),lm=!1,yo=Qa=om=jl=Nr=mn=0,Ta=Ac=null,cm=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var f=31-kt(o),h=1<<f;t|=e[f],o&=~h}return Gi=t,Mi(),i}function Zg(e,t){tt=null,O.H=xc,t===gr||t===vr?(t=zu(),Rt=3):t===gl?(t=zu(),Rt=4):Rt=t===Gf?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ka=t,xt===null&&(mn=1,Wu(e,Ca(t,e.current)))}function Jg(){var e=ua.current;return e===null?!0:(bt&4194048)===bt?ka===null:(bt&62914560)===bt||(bt&536870912)!==0?e===ka:!1}function ev(){var e=O.H;return O.H=xc,e===null?xc:e}function tv(){var e=O.A;return O.A=Pw,e}function id(){mn=4,Ar||(bt&4194048)!==bt&&ua.current!==null||(xo=!0),(Nr&134217727)===0&&(jl&134217727)===0||Pt===null||Er(Pt,bt,Qa,!1)}function hm(e,t,i){var o=Mt;Mt|=2;var f=ev(),h=tv();(Pt!==e||bt!==t)&&(ad=null,wo(e,t)),t=!1;var C=mn;e:do try{if(Rt!==0&&xt!==null){var T=xt,F=Ka;switch(Rt){case 8:mm(),C=6;break e;case 3:case 2:case 9:case 6:ua.current===null&&(t=!0);var re=Rt;if(Rt=0,Ka=null,So(e,T,F,re),i&&xo){C=0;break e}break;default:re=Rt,Rt=0,Ka=null,So(e,T,F,re)}}qw(),C=mn;break}catch(ye){Zg(e,ye)}while(!0);return t&&e.shellSuspendCounter++,Es=ms=null,Mt=o,O.H=f,O.A=h,xt===null&&(Pt=null,bt=0,Mi()),C}function qw(){for(;xt!==null;)nv(xt)}function Gw(e,t){var i=Mt;Mt|=2;var o=ev(),f=tv();Pt!==e||bt!==t?(ad=null,nd=at()+500,wo(e,t)):xo=ns(e,t);e:do try{if(Rt!==0&&xt!==null){t=xt;var h=Ka;t:switch(Rt){case 1:Rt=0,Ka=null,So(e,t,h,1);break;case 2:case 9:if(Lu(h)){Rt=0,Ka=null,av(t);break}t=function(){Rt!==2&&Rt!==9||Pt!==e||(Rt=7),ui(e)},h.then(t,t);break e;case 3:Rt=7;break e;case 4:Rt=5;break e;case 7:Lu(h)?(Rt=0,Ka=null,av(t)):(Rt=0,Ka=null,So(e,t,h,7));break;case 5:var C=null;switch(xt.tag){case 26:C=xt.memoizedState;case 5:case 27:var T=xt;if(C?$v(C):T.stateNode.complete){Rt=0,Ka=null;var F=T.sibling;if(F!==null)xt=F;else{var re=T.return;re!==null?(xt=re,rd(re)):xt=null}break t}}Rt=0,Ka=null,So(e,t,h,5);break;case 6:Rt=0,Ka=null,So(e,t,h,6);break;case 8:mm(),mn=6;break e;default:throw Error(l(462))}}Vw();break}catch(ye){Zg(e,ye)}while(!0);return Es=ms=null,O.H=o,O.A=f,Mt=i,xt!==null?0:(Pt=null,bt=0,Mi(),mn)}function Vw(){for(;xt!==null&&!be();)nv(xt)}function nv(e){var t=Ag(e.alternate,e,Gi);e.memoizedProps=e.pendingProps,t===null?rd(e):xt=t}function av(e){var t=e,i=t.alternate;switch(t.tag){case 15:case 0:t=bg(i,t,t.pendingProps,t.type,void 0,bt);break;case 11:t=bg(i,t,t.pendingProps,t.type.render,t.ref,bt);break;case 5:pc(t);default:Mg(i,t),t=xt=dl(t,Gi),t=Ag(i,t,Gi)}e.memoizedProps=e.pendingProps,t===null?rd(e):xt=t}function So(e,t,i,o){Es=ms=null,pc(t),xr=null,vl=0;var f=t.return;try{if(_w(e,f,t,i,bt)){mn=1,Wu(e,Ca(i,e.current)),xt=null;return}}catch(h){if(f!==null)throw xt=f,h;mn=1,Wu(e,Ca(i,e.current)),xt=null;return}t.flags&32768?(gt||o===1?e=!0:xo||(bt&536870912)!==0?e=!1:(Ar=e=!0,(o===2||o===9||o===3||o===6)&&(o=ua.current,o!==null&&o.tag===13&&(o.flags|=16384))),sv(t,e)):rd(t)}function rd(e){var t=e;do{if((t.flags&32768)!==0){sv(t,Ar);return}e=t.return;var i=Ow(t.alternate,t,Gi);if(i!==null){xt=i;return}if(t=t.sibling,t!==null){xt=t;return}xt=t=e}while(t!==null);mn===0&&(mn=5)}function sv(e,t){do{var i=Hw(e.alternate,e);if(i!==null){i.flags&=32767,xt=i;return}if(i=e.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!t&&(e=e.sibling,e!==null)){xt=e;return}xt=e=i}while(e!==null);mn=6,xt=null}function iv(e,t,i,o,f,h,C,T,F){e.cancelPendingCommit=null;do ld();while(En!==0);if((Mt&6)!==0)throw Error(l(327));if(t!==null){if(t===e.current)throw Error(l(177));if(h=t.lanes|t.childLanes,h|=so,Vt(e,i,h,C,T,F),e===Pt&&(xt=Pt=null,bt=0),bo=t,Tr=e,Vi=i,um=h,dm=f,Yg=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Qw(St,function(){return uv(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=O.T,O.T=null,f=Y.p,Y.p=2,C=Mt,Mt|=4;try{Bw(e,t,i)}finally{Mt=C,Y.p=f,O.T=o}}En=1,rv(),lv(),ov()}}function rv(){if(En===1){En=0;var e=Tr,t=bo,i=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||i){i=O.T,O.T=null;var o=Y.p;Y.p=2;var f=Mt;Mt|=4;try{Fg(t,e);var h=Am,C=ji(e.containerInfo),T=h.focusedElem,F=h.selectionRange;if(C!==T&&T&&T.ownerDocument&&Qo(T.ownerDocument.documentElement,T)){if(F!==null&&no(T)){var re=F.start,ye=F.end;if(ye===void 0&&(ye=re),"selectionStart"in T)T.selectionStart=re,T.selectionEnd=Math.min(ye,T.value.length);else{var Ce=T.ownerDocument||document,ue=Ce&&Ce.defaultView||window;if(ue.getSelection){var fe=ue.getSelection(),Ve=T.textContent.length,Je=Math.min(F.start,Ve),Bt=F.end===void 0?Je:Math.min(F.end,Ve);!fe.extend&&Je>Bt&&(C=Bt,Bt=Je,Je=C);var Z=il(T,Je),G=il(T,Bt);if(Z&&G&&(fe.rangeCount!==1||fe.anchorNode!==Z.node||fe.anchorOffset!==Z.offset||fe.focusNode!==G.node||fe.focusOffset!==G.offset)){var se=Ce.createRange();se.setStart(Z.node,Z.offset),fe.removeAllRanges(),Je>Bt?(fe.addRange(se),fe.extend(G.node,G.offset)):(se.setEnd(G.node,G.offset),fe.addRange(se))}}}}for(Ce=[],fe=T;fe=fe.parentNode;)fe.nodeType===1&&Ce.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;T<Ce.length;T++){var Se=Ce[T];Se.element.scrollLeft=Se.left,Se.element.scrollTop=Se.top}}yd=!!km,Am=km=null}finally{Mt=f,Y.p=o,O.T=i}}e.current=t,En=2}}function lv(){if(En===2){En=0;var e=Tr,t=bo,i=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||i){i=O.T,O.T=null;var o=Y.p;Y.p=2;var f=Mt;Mt|=4;try{zg(e,t.alternate,t)}finally{Mt=f,Y.p=o,O.T=i}}En=3}}function ov(){if(En===4||En===3){En=0,We();var e=Tr,t=bo,i=Vi,o=Yg;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?En=5:(En=0,bo=Tr=null,cv(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Mr=null),nn(i),t=t.stateNode,rt&&typeof rt.onCommitFiberRoot=="function")try{rt.onCommitFiberRoot(pt,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=O.T,f=Y.p,Y.p=2,O.T=null;try{for(var h=e.onRecoverableError,C=0;C<o.length;C++){var T=o[C];h(T.value,{componentStack:T.stack})}}finally{O.T=t,Y.p=f}}(Vi&3)!==0&&ld(),ui(e),f=e.pendingLanes,(i&261930)!==0&&(f&42)!==0?e===fm?Nc++:(Nc=0,fm=e):Nc=0,Mc(0)}}function cv(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,hl(t)))}function ld(){return rv(),lv(),ov(),uv()}function uv(){if(En!==5)return!1;var e=Tr,t=um;um=0;var i=nn(Vi),o=O.T,f=Y.p;try{Y.p=32>i?32:i,O.T=null,i=dm,dm=null;var h=Tr,C=Vi;if(En=0,bo=Tr=null,Vi=0,(Mt&6)!==0)throw Error(l(331));var T=Mt;if(Mt|=4,Gg(h.current),$g(h,h.current,C,i),Mt=T,Mc(0,!1),rt&&typeof rt.onPostCommitFiberRoot=="function")try{rt.onPostCommitFiberRoot(pt,h)}catch{}return!0}finally{Y.p=f,O.T=o,cv(e,t)}}function dv(e,t,i){t=Ca(i,t),t=qf(e.stateNode,t,2),e=Va(e,t,2),e!==null&&(as(e,2),ui(e))}function Dt(e,t,i){if(e.tag===3)dv(e,e,i);else for(;t!==null;){if(t.tag===3){dv(t,e,i);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Mr===null||!Mr.has(o))){e=Ca(i,e),i=fg(2),o=Va(t,i,2),o!==null&&(mg(i,o,t,e),as(o,2),ui(o));break}}t=t.return}}function pm(e,t,i){var o=e.pingCache;if(o===null){o=e.pingCache=new $w;var f=new Set;o.set(t,f)}else f=o.get(t),f===void 0&&(f=new Set,o.set(t,f));f.has(i)||(lm=!0,f.add(i),e=Ww.bind(null,e,t,i),t.then(e,e))}function Ww(e,t,i){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,Pt===e&&(bt&i)===i&&(mn===4||mn===3&&(bt&62914560)===bt&&300>at()-td?(Mt&2)===0&&wo(e,0):om|=i,yo===bt&&(yo=0)),ui(e)}function fv(e,t){t===0&&(t=hi()),e=us(e,t),e!==null&&(as(e,t),ui(e))}function Yw(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),fv(e,i)}function Kw(e,t){var i=0;switch(e.tag){case 31:case 13:var o=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(l(314))}o!==null&&o.delete(t),fv(e,i)}function Qw(e,t){return Me(e,t)}var od=null,Co=null,gm=!1,cd=!1,vm=!1,Rr=0;function ui(e){e!==Co&&e.next===null&&(Co===null?od=Co=e:Co=Co.next=e),cd=!0,gm||(gm=!0,Zw())}function Mc(e,t){if(!vm&&cd){vm=!0;do for(var i=!1,o=od;o!==null;){if(e!==0){var f=o.pendingLanes;if(f===0)var h=0;else{var C=o.suspendedLanes,T=o.pingedLanes;h=(1<<31-kt(42|e)+1)-1,h&=f&~(C&~T),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(i=!0,gv(o,h))}else h=bt,h=Ln(o,o===Pt?h:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(h&3)===0||ns(o,h)||(i=!0,gv(o,h));o=o.next}while(i);vm=!1}}function Xw(){mv()}function mv(){cd=gm=!1;var e=0;Rr!==0&&oS()&&(e=Rr);for(var t=at(),i=null,o=od;o!==null;){var f=o.next,h=hv(o,t);h===0?(o.next=null,i===null?od=f:i.next=f,f===null&&(Co=i)):(i=o,(e!==0||(h&3)!==0)&&(cd=!0)),o=f}En!==0&&En!==5||Mc(e),Rr!==0&&(Rr=0)}function hv(e,t){for(var i=e.suspendedLanes,o=e.pingedLanes,f=e.expirationTimes,h=e.pendingLanes&-62914561;0<h;){var C=31-kt(h),T=1<<C,F=f[C];F===-1?((T&i)===0||(T&o)!==0)&&(f[C]=Be(T,t)):F<=t&&(e.expiredLanes|=T),h&=~T}if(t=Pt,i=bt,i=Ln(e,e===t?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,i===0||e===t&&(Rt===2||Rt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&de(o),e.callbackNode=null,e.callbackPriority=0;if((i&3)===0||ns(e,i)){if(t=i&-i,t===e.callbackPriority)return t;switch(o!==null&&de(o),nn(i)){case 2:case 8:i=ht;break;case 32:i=St;break;case 268435456:i=He;break;default:i=St}return o=pv.bind(null,e),i=Me(i,o),e.callbackPriority=t,e.callbackNode=i,t}return o!==null&&o!==null&&de(o),e.callbackPriority=2,e.callbackNode=null,2}function pv(e,t){if(En!==0&&En!==5)return e.callbackNode=null,e.callbackPriority=0,null;var i=e.callbackNode;if(ld()&&e.callbackNode!==i)return null;var o=bt;return o=Ln(e,e===Pt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Qg(e,o,t),hv(e,at()),e.callbackNode!=null&&e.callbackNode===i?pv.bind(null,e):null)}function gv(e,t){if(ld())return null;Qg(e,t,!0)}function Zw(){uS(function(){(Mt&6)!==0?Me(Xe,Xw):mv()})}function xm(){if(Rr===0){var e=hr;e===0&&(e=hn,hn<<=1,(hn&261888)===0&&(hn=256)),Rr=e}return Rr}function vv(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ha(""+e)}function xv(e,t){var i=t.ownerDocument.createElement("input");return i.name=t.name,i.value=t.value,e.id&&i.setAttribute("form",e.id),t.parentNode.insertBefore(i,t),e=new FormData(e),i.parentNode.removeChild(i),e}function Jw(e,t,i,o,f){if(t==="submit"&&i&&i.stateNode===f){var h=vv((f[Te]||null).action),C=o.submitter;C&&(t=(t=C[Te]||null)?vv(t.formAction):C.getAttribute("formAction"),t!==null&&(h=t,C=null));var T=new qs("action","action",null,o,f);e.push({event:T,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Rr!==0){var F=C?xv(f,C):new FormData(f);Hf(i,{pending:!0,data:F,method:f.method,action:h},null,F)}}else typeof h=="function"&&(T.preventDefault(),F=C?xv(f,C):new FormData(f),Hf(i,{pending:!0,data:F,method:f.method,action:h},h,F))},currentTarget:f}]})}}for(var ym=0;ym<ol.length;ym++){var bm=ol[ym],eS=bm.toLowerCase(),tS=bm[0].toUpperCase()+bm.slice(1);oa(eS,"on"+tS)}oa(Jo,"onAnimationEnd"),oa(As,"onAnimationIteration"),oa(ll,"onAnimationStart"),oa("dblclick","onDoubleClick"),oa("focusin","onFocus"),oa("focusout","onBlur"),oa(or,"onTransitionRun"),oa(Ni,"onTransitionStart"),oa(ec,"onTransitionCancel"),oa(Mu,"onTransitionEnd"),Xt("onMouseEnter",["mouseout","mouseover"]),Xt("onMouseLeave",["mouseout","mouseover"]),Xt("onPointerEnter",["pointerout","pointerover"]),Xt("onPointerLeave",["pointerout","pointerover"]),un("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),un("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),un("onBeforeInput",["compositionend","keypress","textInput","paste"]),un("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),un("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),un("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Tc="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(" "),nS=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Tc));function yv(e,t){t=(t&4)!==0;for(var i=0;i<e.length;i++){var o=e[i],f=o.event;o=o.listeners;e:{var h=void 0;if(t)for(var C=o.length-1;0<=C;C--){var T=o[C],F=T.instance,re=T.currentTarget;if(T=T.listener,F!==h&&f.isPropagationStopped())break e;h=T,f.currentTarget=re;try{h(f)}catch(ye){Js(ye)}f.currentTarget=null,h=F}else for(C=0;C<o.length;C++){if(T=o[C],F=T.instance,re=T.currentTarget,T=T.listener,F!==h&&f.isPropagationStopped())break e;h=T,f.currentTarget=re;try{h(f)}catch(ye){Js(ye)}f.currentTarget=null,h=F}}}}function yt(e,t){var i=t[it];i===void 0&&(i=t[it]=new Set);var o=e+"__bubble";i.has(o)||(bv(t,e,2,!1),i.add(o))}function wm(e,t,i){var o=0;t&&(o|=4),bv(i,e,o,t)}var ud="_reactListening"+Math.random().toString(36).slice(2);function Sm(e){if(!e[ud]){e[ud]=!0,gn.forEach(function(i){i!=="selectionchange"&&(nS.has(i)||wm(i,!1,e),wm(i,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[ud]||(t[ud]=!0,wm("selectionchange",!1,t))}}function bv(e,t,i,o){switch(Kv(t)){case 2:var f=ES;break;case 8:f=RS;break;default:f=Om}i=f.bind(null,t,i,e),f=void 0,!hu||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(f=!0),o?f!==void 0?e.addEventListener(t,i,{capture:!0,passive:f}):e.addEventListener(t,i,!0):f!==void 0?e.addEventListener(t,i,{passive:f}):e.addEventListener(t,i,!1)}function Cm(e,t,i,o,f){var h=o;if((t&1)===0&&(t&2)===0&&o!==null)e:for(;;){if(o===null)return;var C=o.tag;if(C===3||C===4){var T=o.stateNode.containerInfo;if(T===f)break;if(C===4)for(C=o.return;C!==null;){var F=C.tag;if((F===3||F===4)&&C.stateNode.containerInfo===f)return;C=C.return}for(;T!==null;){if(C=$t(T),C===null)return;if(F=C.tag,F===5||F===6||F===26||F===27){o=h=C;continue e}T=T.parentNode}}o=o.return}mu(function(){var re=h,ye=qo(i),Ce=[];e:{var ue=tc.get(e);if(ue!==void 0){var fe=qs,Ve=e;switch(e){case"keypress":if(ql(i)===0)break e;case"keydown":case"keyup":fe=Ys;break;case"focusin":Ve="focus",fe=Zn;break;case"focusout":Ve="blur",fe=Zn;break;case"beforeblur":case"afterblur":fe=Zn;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=Kl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=nt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=os;break;case Jo:case As:case ll:fe=Vs;break;case Mu:fe=Ko;break;case"scroll":case"scrollend":fe=Vl;break;case"wheel":fe=xu;break;case"copy":case"cut":case"paste":fe=vu;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=Yo;break;case"toggle":case"beforetoggle":fe=yu}var Je=(t&4)!==0,Bt=!Je&&(e==="scroll"||e==="scrollend"),Z=Je?ue!==null?ue+"Capture":null:ue;Je=[];for(var G=re,se;G!==null;){var Se=G;if(se=Se.stateNode,Se=Se.tag,Se!==5&&Se!==26&&Se!==27||se===null||Z===null||(Se=ls(G,Z),Se!=null&&Je.push(Ec(G,Se,se))),Bt)break;G=G.return}0<Je.length&&(ue=new fe(ue,Ve,null,i,ye),Ce.push({event:ue,listeners:Je}))}}if((t&7)===0){e:{if(ue=e==="mouseover"||e==="pointerover",fe=e==="mouseout"||e==="pointerout",ue&&i!==rs&&(Ve=i.relatedTarget||i.fromElement)&&($t(Ve)||Ve[qe]))break e;if((fe||ue)&&(ue=ye.window===ye?ye:(ue=ye.ownerDocument)?ue.defaultView||ue.parentWindow:window,fe?(Ve=i.relatedTarget||i.toElement,fe=re,Ve=Ve?$t(Ve):null,Ve!==null&&(Bt=d(Ve),Je=Ve.tag,Ve!==Bt||Je!==5&&Je!==27&&Je!==6)&&(Ve=null)):(fe=null,Ve=re),fe!==Ve)){if(Je=Kl,Se="onMouseLeave",Z="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Je=Yo,Se="onPointerLeave",Z="onPointerEnter",G="pointer"),Bt=fe==null?ue:Ft(fe),se=Ve==null?ue:Ft(Ve),ue=new Je(Se,G+"leave",fe,i,ye),ue.target=Bt,ue.relatedTarget=se,Se=null,$t(ye)===re&&(Je=new Je(Z,G+"enter",Ve,i,ye),Je.target=se,Je.relatedTarget=Bt,Se=Je),Bt=Se,fe&&Ve)t:{for(Je=aS,Z=fe,G=Ve,se=0,Se=Z;Se;Se=Je(Se))se++;Se=0;for(var Qe=G;Qe;Qe=Je(Qe))Se++;for(;0<se-Se;)Z=Je(Z),se--;for(;0<Se-se;)G=Je(G),Se--;for(;se--;){if(Z===G||G!==null&&Z===G.alternate){Je=Z;break t}Z=Je(Z),G=Je(G)}Je=null}else Je=null;fe!==null&&wv(Ce,ue,fe,Je,!1),Ve!==null&&Bt!==null&&wv(Ce,Bt,Ve,Je,!0)}}e:{if(ue=re?Ft(re):window,fe=ue.nodeName&&ue.nodeName.toLowerCase(),fe==="select"||fe==="input"&&ue.type==="file")var At=Jn;else if(nl(ue))if(ju)At=to;else{At=rr;var Ye=js}else fe=ue.nodeName,!fe||fe.toLowerCase()!=="input"||ue.type!=="checkbox"&&ue.type!=="radio"?re&&nr(re.elementType)&&(At=Jn):At=eo;if(At&&(At=At(e,re))){ya(Ce,At,i,ye);break e}Ye&&Ye(e,ue,re),e==="focusout"&&re&&ue.type==="number"&&re.memoizedProps.value!=null&&tr(ue,"number",ue.value)}switch(Ye=re?Ft(re):window,e){case"focusin":(nl(Ye)||Ye.contentEditable==="true")&&(lr=Ye,Zs=re,rl=null);break;case"focusout":rl=Zs=lr=null;break;case"mousedown":ao=!0;break;case"contextmenu":case"mouseup":case"dragend":ao=!1,Nu(Ce,i,ye);break;case"selectionchange":if(Au)break;case"keydown":case"keyup":Nu(Ce,i,ye)}var dt;if(Xl)e:{switch(e){case"compositionstart":var wt="onCompositionStart";break e;case"compositionend":wt="onCompositionEnd";break e;case"compositionupdate":wt="onCompositionUpdate";break e}wt=void 0}else Si?wi(e,i)&&(wt="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(wt="onCompositionStart");wt&&(bu&&i.locale!=="ko"&&(Si||wt!=="onCompositionStart"?wt==="onCompositionEnd"&&Si&&(dt=Vo()):(yi=ye,Go="value"in yi?yi.value:yi.textContent,Si=!0)),Ye=dd(re,wt),0<Ye.length&&(wt=new Jr(wt,e,null,i,ye),Ce.push({event:wt,listeners:Ye}),dt?wt.data=dt:(dt=Su(i),dt!==null&&(wt.data=dt)))),(dt=bi?Cs(e,i):Cu(e,i))&&(wt=dd(re,"onBeforeInput"),0<wt.length&&(Ye=new Jr("onBeforeInput","beforeinput",null,i,ye),Ce.push({event:Ye,listeners:wt}),Ye.data=dt)),Jw(Ce,e,re,i,ye)}yv(Ce,t)})}function Ec(e,t,i){return{instance:e,listener:t,currentTarget:i}}function dd(e,t){for(var i=t+"Capture",o=[];e!==null;){var f=e,h=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||h===null||(f=ls(e,i),f!=null&&o.unshift(Ec(e,f,h)),f=ls(e,t),f!=null&&o.push(Ec(e,f,h))),e.tag===3)return o;e=e.return}return[]}function aS(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function wv(e,t,i,o,f){for(var h=t._reactName,C=[];i!==null&&i!==o;){var T=i,F=T.alternate,re=T.stateNode;if(T=T.tag,F!==null&&F===o)break;T!==5&&T!==26&&T!==27||re===null||(F=re,f?(re=ls(i,h),re!=null&&C.unshift(Ec(i,re,F))):f||(re=ls(i,h),re!=null&&C.push(Ec(i,re,F)))),i=i.return}C.length!==0&&e.push({event:t,listeners:C})}var sS=/\r\n?/g,iS=/\u0000|\uFFFD/g;function Sv(e){return(typeof e=="string"?e:""+e).replace(sS,`
|
|
9
9
|
`).replace(iS,"")}function Cv(e,t){return t=Sv(t),Sv(e)===t}function Ht(e,t,i,o,f,h){switch(i){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Ps(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Ps(e,""+o);break;case"className":Pl(e,"class",o);break;case"tabIndex":Pl(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Pl(e,i,o);break;case"style":Qr(e,o,h);break;case"data":if(t!=="object"){Pl(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||i!=="href")){e.removeAttribute(i);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(i);break}o=Ha(""+o),e.setAttribute(i,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(i,"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 h=="function"&&(i==="formAction"?(t!=="input"&&Ht(e,t,"name",f.name,f,null),Ht(e,t,"formEncType",f.formEncType,f,null),Ht(e,t,"formMethod",f.formMethod,f,null),Ht(e,t,"formTarget",f.formTarget,f,null)):(Ht(e,t,"encType",f.encType,f,null),Ht(e,t,"method",f.method,f,null),Ht(e,t,"target",f.target,f,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(i);break}o=Ha(""+o),e.setAttribute(i,o);break;case"onClick":o!=null&&(e.onclick=Un);break;case"onScroll":o!=null&&yt("scroll",e);break;case"onScrollEnd":o!=null&&yt("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(l(61));if(i=o.__html,i!=null){if(f.children!=null)throw Error(l(60));e.innerHTML=i}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}i=Ha(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(i,""+o):e.removeAttribute(i);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":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(i,""):e.removeAttribute(i);break;case"capture":case"download":o===!0?e.setAttribute(i,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(i,o):e.removeAttribute(i);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(i,o):e.removeAttribute(i);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(i):e.setAttribute(i,o);break;case"popover":yt("beforetoggle",e),yt("toggle",e),Ji(e,"popover",o);break;case"xlinkActuate":Oa(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Oa(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Oa(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Oa(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Oa(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Oa(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Oa(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Oa(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Oa(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Ji(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(i=Uo.get(i)||i,Ji(e,i,o))}}function jm(e,t,i,o,f,h){switch(i){case"style":Qr(e,o,h);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(l(61));if(i=o.__html,i!=null){if(f.children!=null)throw Error(l(60));e.innerHTML=i}}break;case"children":typeof o=="string"?Ps(e,o):(typeof o=="number"||typeof o=="bigint")&&Ps(e,""+o);break;case"onScroll":o!=null&&yt("scroll",e);break;case"onScrollEnd":o!=null&&yt("scrollend",e);break;case"onClick":o!=null&&(e.onclick=Un);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ss.hasOwnProperty(i))e:{if(i[0]==="o"&&i[1]==="n"&&(f=i.endsWith("Capture"),t=i.slice(2,f?i.length-7:void 0),h=e[Te]||null,h=h!=null?h[i]:null,typeof h=="function"&&e.removeEventListener(t,h,f),typeof o=="function")){typeof h!="function"&&h!==null&&(i in e?e[i]=null:e.hasAttribute(i)&&e.removeAttribute(i)),e.addEventListener(t,o,f);break e}i in e?e[i]=o:o===!0?e.setAttribute(i,""):Ji(e,i,o)}}}function Yn(e,t,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":yt("error",e),yt("load",e);var o=!1,f=!1,h;for(h in i)if(i.hasOwnProperty(h)){var C=i[h];if(C!=null)switch(h){case"src":o=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:Ht(e,t,h,C,i,null)}}f&&Ht(e,t,"srcSet",i.srcSet,i,null),o&&Ht(e,t,"src",i.src,i,null);return;case"input":yt("invalid",e);var T=h=C=f=null,F=null,re=null;for(o in i)if(i.hasOwnProperty(o)){var ye=i[o];if(ye!=null)switch(o){case"name":f=ye;break;case"type":C=ye;break;case"checked":F=ye;break;case"defaultChecked":re=ye;break;case"value":h=ye;break;case"defaultValue":T=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(l(137,t));break;default:Ht(e,t,o,ye,i,null)}}er(e,h,T,F,re,C,f,!1);return;case"select":yt("invalid",e),o=C=h=null;for(f in i)if(i.hasOwnProperty(f)&&(T=i[f],T!=null))switch(f){case"value":h=T;break;case"defaultValue":C=T;break;case"multiple":o=T;default:Ht(e,t,f,T,i,null)}t=h,i=C,e.multiple=!!o,t!=null?is(e,!!o,t,!1):i!=null&&is(e,!!o,i,!0);return;case"textarea":yt("invalid",e),h=f=o=null;for(C in i)if(i.hasOwnProperty(C)&&(T=i[C],T!=null))switch(C){case"value":o=T;break;case"defaultValue":f=T;break;case"children":h=T;break;case"dangerouslySetInnerHTML":if(T!=null)throw Error(l(91));break;default:Ht(e,t,C,T,i,null)}xi(e,o,f,h);return;case"option":for(F in i)i.hasOwnProperty(F)&&(o=i[F],o!=null)&&(F==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":Ht(e,t,F,o,i,null));return;case"dialog":yt("beforetoggle",e),yt("toggle",e),yt("cancel",e),yt("close",e);break;case"iframe":case"object":yt("load",e);break;case"video":case"audio":for(o=0;o<Tc.length;o++)yt(Tc[o],e);break;case"image":yt("error",e),yt("load",e);break;case"details":yt("toggle",e);break;case"embed":case"source":case"link":yt("error",e),yt("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(re in i)if(i.hasOwnProperty(re)&&(o=i[re],o!=null))switch(re){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:Ht(e,t,re,o,i,null)}return;default:if(nr(t)){for(ye in i)i.hasOwnProperty(ye)&&(o=i[ye],o!==void 0&&jm(e,t,ye,o,i,void 0));return}}for(T in i)i.hasOwnProperty(T)&&(o=i[T],o!=null&&Ht(e,t,T,o,i,null))}function rS(e,t,i,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,h=null,C=null,T=null,F=null,re=null,ye=null;for(fe in i){var Ce=i[fe];if(i.hasOwnProperty(fe)&&Ce!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":F=Ce;default:o.hasOwnProperty(fe)||Ht(e,t,fe,null,o,Ce)}}for(var ue in o){var fe=o[ue];if(Ce=i[ue],o.hasOwnProperty(ue)&&(fe!=null||Ce!=null))switch(ue){case"type":h=fe;break;case"name":f=fe;break;case"checked":re=fe;break;case"defaultChecked":ye=fe;break;case"value":C=fe;break;case"defaultValue":T=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(l(137,t));break;default:fe!==Ce&&Ht(e,t,ue,fe,o,Ce)}}gi(e,C,T,F,re,ye,h,f);return;case"select":fe=C=T=ue=null;for(h in i)if(F=i[h],i.hasOwnProperty(h)&&F!=null)switch(h){case"value":break;case"multiple":fe=F;default:o.hasOwnProperty(h)||Ht(e,t,h,null,o,F)}for(f in o)if(h=o[f],F=i[f],o.hasOwnProperty(f)&&(h!=null||F!=null))switch(f){case"value":ue=h;break;case"defaultValue":T=h;break;case"multiple":C=h;default:h!==F&&Ht(e,t,f,h,o,F)}t=T,i=C,o=fe,ue!=null?is(e,!!i,ue,!1):!!o!=!!i&&(t!=null?is(e,!!i,t,!0):is(e,!!i,i?[]:"",!1));return;case"textarea":fe=ue=null;for(T in i)if(f=i[T],i.hasOwnProperty(T)&&f!=null&&!o.hasOwnProperty(T))switch(T){case"value":break;case"children":break;default:Ht(e,t,T,null,o,f)}for(C in o)if(f=o[C],h=i[C],o.hasOwnProperty(C)&&(f!=null||h!=null))switch(C){case"value":ue=f;break;case"defaultValue":fe=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(l(91));break;default:f!==h&&Ht(e,t,C,f,o,h)}vi(e,ue,fe);return;case"option":for(var Ve in i)ue=i[Ve],i.hasOwnProperty(Ve)&&ue!=null&&!o.hasOwnProperty(Ve)&&(Ve==="selected"?e.selected=!1:Ht(e,t,Ve,null,o,ue));for(F in o)ue=o[F],fe=i[F],o.hasOwnProperty(F)&&ue!==fe&&(ue!=null||fe!=null)&&(F==="selected"?e.selected=ue&&typeof ue!="function"&&typeof ue!="symbol":Ht(e,t,F,ue,o,fe));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 Je in i)ue=i[Je],i.hasOwnProperty(Je)&&ue!=null&&!o.hasOwnProperty(Je)&&Ht(e,t,Je,null,o,ue);for(re in o)if(ue=o[re],fe=i[re],o.hasOwnProperty(re)&&ue!==fe&&(ue!=null||fe!=null))switch(re){case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(l(137,t));break;default:Ht(e,t,re,ue,o,fe)}return;default:if(nr(t)){for(var Bt in i)ue=i[Bt],i.hasOwnProperty(Bt)&&ue!==void 0&&!o.hasOwnProperty(Bt)&&jm(e,t,Bt,void 0,o,ue);for(ye in o)ue=o[ye],fe=i[ye],!o.hasOwnProperty(ye)||ue===fe||ue===void 0&&fe===void 0||jm(e,t,ye,ue,o,fe);return}}for(var Z in i)ue=i[Z],i.hasOwnProperty(Z)&&ue!=null&&!o.hasOwnProperty(Z)&&Ht(e,t,Z,null,o,ue);for(Ce in o)ue=o[Ce],fe=i[Ce],!o.hasOwnProperty(Ce)||ue===fe||ue==null&&fe==null||Ht(e,t,Ce,ue,o,fe)}function jv(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function lS(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,i=performance.getEntriesByType("resource"),o=0;o<i.length;o++){var f=i[o],h=f.transferSize,C=f.initiatorType,T=f.duration;if(h&&T&&jv(C)){for(C=0,T=f.responseEnd,o+=1;o<i.length;o++){var F=i[o],re=F.startTime;if(re>T)break;var ye=F.transferSize,Ce=F.initiatorType;ye&&jv(Ce)&&(F=F.responseEnd,C+=ye*(F<T?1:(T-re)/(F-re)))}if(--o,t+=8*(h+C)/(f.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var km=null,Am=null;function fd(e){return e.nodeType===9?e:e.ownerDocument}function kv(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Av(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function Nm(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Mm=null;function oS(){var e=window.event;return e&&e.type==="popstate"?e===Mm?!1:(Mm=e,!0):(Mm=null,!1)}var Nv=typeof setTimeout=="function"?setTimeout:void 0,cS=typeof clearTimeout=="function"?clearTimeout:void 0,Mv=typeof Promise=="function"?Promise:void 0,uS=typeof queueMicrotask=="function"?queueMicrotask:typeof Mv<"u"?function(e){return Mv.resolve(null).then(e).catch(dS)}:Nv;function dS(e){setTimeout(function(){throw e})}function Dr(e){return e==="head"}function Tv(e,t){var i=t,o=0;do{var f=i.nextSibling;if(e.removeChild(i),f&&f.nodeType===8)if(i=f.data,i==="/$"||i==="/&"){if(o===0){e.removeChild(f),No(t);return}o--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")o++;else if(i==="html")Rc(e.ownerDocument.documentElement);else if(i==="head"){i=e.ownerDocument.head,Rc(i);for(var h=i.firstChild;h;){var C=h.nextSibling,T=h.nodeName;h[lt]||T==="SCRIPT"||T==="STYLE"||T==="LINK"&&h.rel.toLowerCase()==="stylesheet"||i.removeChild(h),h=C}}else i==="body"&&Rc(e.ownerDocument.body);i=f}while(i);No(t)}function Ev(e,t){var i=e;e=0;do{var o=i.nextSibling;if(i.nodeType===1?t?(i._stashedDisplay=i.style.display,i.style.display="none"):(i.style.display=i._stashedDisplay||"",i.getAttribute("style")===""&&i.removeAttribute("style")):i.nodeType===3&&(t?(i._stashedText=i.nodeValue,i.nodeValue=""):i.nodeValue=i._stashedText||""),o&&o.nodeType===8)if(i=o.data,i==="/$"){if(e===0)break;e--}else i!=="$"&&i!=="$?"&&i!=="$~"&&i!=="$!"||e++;i=o}while(i)}function Tm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var i=t;switch(t=t.nextSibling,i.nodeName){case"HTML":case"HEAD":case"BODY":Tm(i),Qt(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}e.removeChild(i)}}function fS(e,t,i,o){for(;e.nodeType===1;){var f=i;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[lt])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(h=e.getAttribute("rel"),h==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(h!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(h=e.getAttribute("src"),(h!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&h&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var h=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===h)return e}else return e;if(e=gs(e.nextSibling),e===null)break}return null}function mS(e,t,i){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!i||(e=gs(e.nextSibling),e===null))return null;return e}function Rv(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=gs(e.nextSibling),e===null))return null;return e}function Em(e){return e.data==="$?"||e.data==="$~"}function Rm(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function hS(e,t){var i=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||i.readyState!=="loading")t();else{var o=function(){t(),i.removeEventListener("DOMContentLoaded",o)};i.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function gs(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Dm=null;function Dv(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"||i==="/&"){if(t===0)return gs(e.nextSibling);t--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||t++}e=e.nextSibling}return null}function Lv(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"){if(t===0)return e;t--}else i!=="/$"&&i!=="/&"||t++}e=e.previousSibling}return null}function _v(e,t,i){switch(t=fd(i),e){case"html":if(e=t.documentElement,!e)throw Error(l(452));return e;case"head":if(e=t.head,!e)throw Error(l(453));return e;case"body":if(e=t.body,!e)throw Error(l(454));return e;default:throw Error(l(451))}}function Rc(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Qt(e)}var vs=new Map,zv=new Set;function md(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Wi=Y.d;Y.d={f:pS,r:gS,D:vS,C:xS,L:yS,m:bS,X:SS,S:wS,M:CS};function pS(){var e=Wi.f(),t=sd();return e||t}function gS(e){var t=_t(e);t!==null&&t.tag===5&&t.type==="form"?Zp(t):Wi.r(e)}var jo=typeof document>"u"?null:document;function Iv(e,t,i){var o=jo;if(o&&typeof t=="string"&&t){var f=Sn(t);f='link[rel="'+e+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),zv.has(f)||(zv.add(f),e={rel:e,crossOrigin:i,href:t},o.querySelector(f)===null&&(t=o.createElement("link"),Yn(t,"link",e),zt(t),o.head.appendChild(t)))}}function vS(e){Wi.D(e),Iv("dns-prefetch",e,null)}function xS(e,t){Wi.C(e,t),Iv("preconnect",e,t)}function yS(e,t,i){Wi.L(e,t,i);var o=jo;if(o&&e&&t){var f='link[rel="preload"][as="'+Sn(t)+'"]';t==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+Sn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+Sn(i.imageSizes)+'"]')):f+='[href="'+Sn(e)+'"]';var h=f;switch(t){case"style":h=ko(e);break;case"script":h=Ao(e)}vs.has(h)||(e=y({rel:"preload",href:t==="image"&&i&&i.imageSrcSet?void 0:e,as:t},i),vs.set(h,e),o.querySelector(f)!==null||t==="style"&&o.querySelector(Dc(h))||t==="script"&&o.querySelector(Lc(h))||(t=o.createElement("link"),Yn(t,"link",e),zt(t),o.head.appendChild(t)))}}function bS(e,t){Wi.m(e,t);var i=jo;if(i&&e){var o=t&&typeof t.as=="string"?t.as:"script",f='link[rel="modulepreload"][as="'+Sn(o)+'"][href="'+Sn(e)+'"]',h=f;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=Ao(e)}if(!vs.has(h)&&(e=y({rel:"modulepreload",href:e},t),vs.set(h,e),i.querySelector(f)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(Lc(h)))return}o=i.createElement("link"),Yn(o,"link",e),zt(o),i.head.appendChild(o)}}}function wS(e,t,i){Wi.S(e,t,i);var o=jo;if(o&&e){var f=Ut(o).hoistableStyles,h=ko(e);t=t||"default";var C=f.get(h);if(!C){var T={loading:0,preload:null};if(C=o.querySelector(Dc(h)))T.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},i),(i=vs.get(h))&&Lm(e,i);var F=C=o.createElement("link");zt(F),Yn(F,"link",e),F._p=new Promise(function(re,ye){F.onload=re,F.onerror=ye}),F.addEventListener("load",function(){T.loading|=1}),F.addEventListener("error",function(){T.loading|=2}),T.loading|=4,hd(C,t,o)}C={type:"stylesheet",instance:C,count:1,state:T},f.set(h,C)}}}function SS(e,t){Wi.X(e,t);var i=jo;if(i&&e){var o=Ut(i).hoistableScripts,f=Ao(e),h=o.get(f);h||(h=i.querySelector(Lc(f)),h||(e=y({src:e,async:!0},t),(t=vs.get(f))&&_m(e,t),h=i.createElement("script"),zt(h),Yn(h,"link",e),i.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(f,h))}}function CS(e,t){Wi.M(e,t);var i=jo;if(i&&e){var o=Ut(i).hoistableScripts,f=Ao(e),h=o.get(f);h||(h=i.querySelector(Lc(f)),h||(e=y({src:e,async:!0,type:"module"},t),(t=vs.get(f))&&_m(e,t),h=i.createElement("script"),zt(h),Yn(h,"link",e),i.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(f,h))}}function Ov(e,t,i,o){var f=(f=xe.current)?md(f):null;if(!f)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(t=ko(i.href),i=Ut(f).hoistableStyles,o=i.get(t),o||(o={type:"style",instance:null,count:0,state:null},i.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){e=ko(i.href);var h=Ut(f).hoistableStyles,C=h.get(e);if(C||(f=f.ownerDocument||f,C={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(e,C),(h=f.querySelector(Dc(e)))&&!h._p&&(C.instance=h,C.state.loading=5),vs.has(e)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},vs.set(e,i),h||jS(f,e,i,C.state))),t&&o===null)throw Error(l(528,""));return C}if(t&&o!==null)throw Error(l(529,""));return null;case"script":return t=i.async,i=i.src,typeof i=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Ao(i),i=Ut(f).hoistableScripts,o=i.get(t),o||(o={type:"script",instance:null,count:0,state:null},i.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function ko(e){return'href="'+Sn(e)+'"'}function Dc(e){return'link[rel="stylesheet"]['+e+"]"}function Hv(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function jS(e,t,i,o){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?o.loading=1:(t=e.createElement("link"),o.preload=t,t.addEventListener("load",function(){return o.loading|=1}),t.addEventListener("error",function(){return o.loading|=2}),Yn(t,"link",i),zt(t),e.head.appendChild(t))}function Ao(e){return'[src="'+Sn(e)+'"]'}function Lc(e){return"script[async]"+e}function Bv(e,t,i){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Sn(i.href)+'"]');if(o)return t.instance=o,zt(o),o;var f=y({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),zt(o),Yn(o,"style",f),hd(o,i.precedence,e),t.instance=o;case"stylesheet":f=ko(i.href);var h=e.querySelector(Dc(f));if(h)return t.state.loading|=4,t.instance=h,zt(h),h;o=Hv(i),(f=vs.get(f))&&Lm(o,f),h=(e.ownerDocument||e).createElement("link"),zt(h);var C=h;return C._p=new Promise(function(T,F){C.onload=T,C.onerror=F}),Yn(h,"link",o),t.state.loading|=4,hd(h,i.precedence,e),t.instance=h;case"script":return h=Ao(i.src),(f=e.querySelector(Lc(h)))?(t.instance=f,zt(f),f):(o=i,(f=vs.get(h))&&(o=y({},i),_m(o,f)),e=e.ownerDocument||e,f=e.createElement("script"),zt(f),Yn(f,"link",o),e.head.appendChild(f),t.instance=f);case"void":return null;default:throw Error(l(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,hd(o,i.precedence,e));return t.instance}function hd(e,t,i){for(var o=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=o.length?o[o.length-1]:null,h=f,C=0;C<o.length;C++){var T=o[C];if(T.dataset.precedence===t)h=T;else if(h!==f)break}h?h.parentNode.insertBefore(e,h.nextSibling):(t=i.nodeType===9?i.head:i,t.insertBefore(e,t.firstChild))}function Lm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function _m(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var pd=null;function Fv(e,t,i){if(pd===null){var o=new Map,f=pd=new Map;f.set(i,o)}else f=pd,o=f.get(i),o||(o=new Map,f.set(i,o));if(o.has(e))return o;for(o.set(e,null),i=i.getElementsByTagName(e),f=0;f<i.length;f++){var h=i[f];if(!(h[lt]||h[ee]||e==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var C=h.getAttribute(t)||"";C=e+C;var T=o.get(C);T?T.push(h):o.set(C,[h])}}return o}function Pv(e,t,i){e=e.ownerDocument||e,e.head.insertBefore(i,t==="title"?e.querySelector("head > title"):null)}function kS(e,t,i){if(i===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function $v(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function AS(e,t,i,o){if(i.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var f=ko(o.href),h=t.querySelector(Dc(f));if(h){t=h._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=gd.bind(e),t.then(e,e)),i.state.loading|=4,i.instance=h,zt(h);return}h=t.ownerDocument||t,o=Hv(o),(f=vs.get(f))&&Lm(o,f),h=h.createElement("link"),zt(h);var C=h;C._p=new Promise(function(T,F){C.onload=T,C.onerror=F}),Yn(h,"link",o),i.instance=h}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(i,t),(t=i.state.preload)&&(i.state.loading&3)===0&&(e.count++,i=gd.bind(e),t.addEventListener("load",i),t.addEventListener("error",i))}}var zm=0;function NS(e,t){return e.stylesheets&&e.count===0&&xd(e,e.stylesheets),0<e.count||0<e.imgCount?function(i){var o=setTimeout(function(){if(e.stylesheets&&xd(e,e.stylesheets),e.unsuspend){var h=e.unsuspend;e.unsuspend=null,h()}},6e4+t);0<e.imgBytes&&zm===0&&(zm=62500*lS());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&xd(e,e.stylesheets),e.unsuspend)){var h=e.unsuspend;e.unsuspend=null,h()}},(e.imgBytes>zm?50:800)+t);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(f)}}:null}function gd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)xd(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var vd=null;function xd(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,vd=new Map,t.forEach(MS,e),vd=null,gd.call(e))}function MS(e,t){if(!(t.state.loading&4)){var i=vd.get(e);if(i)var o=i.get(null);else{i=new Map,vd.set(e,i);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<f.length;h++){var C=f[h];(C.nodeName==="LINK"||C.getAttribute("media")!=="not all")&&(i.set(C.dataset.precedence,C),o=C)}o&&i.set(null,o)}f=t.instance,C=f.getAttribute("data-precedence"),h=i.get(C)||o,h===o&&i.set(null,f),i.set(C,f),this.count++,o=gd.bind(this),f.addEventListener("load",o),f.addEventListener("error",o),h?h.parentNode.insertBefore(f,h.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),t.state.loading|=4}}var _c={$$typeof:R,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function TS(e,t,i,o,f,h,C,T,F){this.tag=1,this.containerInfo=e,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=ft(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ft(0),this.hiddenUpdates=ft(null),this.identifierPrefix=o,this.onUncaughtError=f,this.onCaughtError=h,this.onRecoverableError=C,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=F,this.incompleteTransitions=new Map}function Uv(e,t,i,o,f,h,C,T,F,re,ye,Ce){return e=new TS(e,t,i,C,F,re,ye,Ce,T),t=1,h===!0&&(t|=24),h=Cn(3,null,null,t),e.current=h,h.stateNode=e,t=lc(),t.refCount++,e.pooledCache=t,t.refCount++,h.memoizedState={element:o,isDehydrated:i,cache:t},wr(h),e}function qv(e){return e?(e=Ms,e):Ms}function Gv(e,t,i,o,f,h){f=qv(f),o.context===null?o.context=f:o.pendingContext=f,o=Zt(t),o.payload={element:i},h=h===void 0?null:h,h!==null&&(o.callback=h),i=Va(e,o,t),i!==null&&(Ea(i,e,t),Sr(i,e,t))}function Vv(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<t?i:t}}function Im(e,t){Vv(e,t),(e=e.alternate)&&Vv(e,t)}function Wv(e){if(e.tag===13||e.tag===31){var t=us(e,67108864);t!==null&&Ea(t,e,67108864),Im(e,67108864)}}function Yv(e){if(e.tag===13||e.tag===31){var t=Xa();t=mt(t);var i=us(e,t);i!==null&&Ea(i,e,t),Im(e,t)}}var yd=!0;function ES(e,t,i,o){var f=O.T;O.T=null;var h=Y.p;try{Y.p=2,Om(e,t,i,o)}finally{Y.p=h,O.T=f}}function RS(e,t,i,o){var f=O.T;O.T=null;var h=Y.p;try{Y.p=8,Om(e,t,i,o)}finally{Y.p=h,O.T=f}}function Om(e,t,i,o){if(yd){var f=Hm(o);if(f===null)Cm(e,t,o,bd,i),Qv(e,o);else if(LS(f,e,t,i,o))o.stopPropagation();else if(Qv(e,o),t&4&&-1<DS.indexOf(e)){for(;f!==null;){var h=_t(f);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var C=ts(h.pendingLanes);if(C!==0){var T=h;for(T.pendingLanes|=2,T.entangledLanes|=2;C;){var F=1<<31-kt(C);T.entanglements[1]|=F,C&=~F}ui(h),(Mt&6)===0&&(nd=at()+500,Mc(0))}}break;case 31:case 13:T=us(h,2),T!==null&&Ea(T,h,2),sd(),Im(h,2)}if(h=Hm(o),h===null&&Cm(e,t,o,bd,i),h===f)break;f=h}f!==null&&o.stopPropagation()}else Cm(e,t,o,null,i)}}function Hm(e){return e=qo(e),Bm(e)}var bd=null;function Bm(e){if(bd=null,e=$t(e),e!==null){var t=d(e);if(t===null)e=null;else{var i=t.tag;if(i===13){if(e=m(t),e!==null)return e;e=null}else if(i===31){if(e=p(t),e!==null)return e;e=null}else if(i===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return bd=e,null}function Kv(e){switch(e){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(wn()){case Xe:return 2;case ht:return 8;case St:case Rn:return 32;case He:return 268435456;default:return 32}default:return 32}}var Fm=!1,Lr=null,_r=null,zr=null,zc=new Map,Ic=new Map,Ir=[],DS="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 Qv(e,t){switch(e){case"focusin":case"focusout":Lr=null;break;case"dragenter":case"dragleave":_r=null;break;case"mouseover":case"mouseout":zr=null;break;case"pointerover":case"pointerout":zc.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ic.delete(t.pointerId)}}function Oc(e,t,i,o,f,h){return e===null||e.nativeEvent!==h?(e={blockedOn:t,domEventName:i,eventSystemFlags:o,nativeEvent:h,targetContainers:[f]},t!==null&&(t=_t(t),t!==null&&Wv(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,f!==null&&t.indexOf(f)===-1&&t.push(f),e)}function LS(e,t,i,o,f){switch(t){case"focusin":return Lr=Oc(Lr,e,t,i,o,f),!0;case"dragenter":return _r=Oc(_r,e,t,i,o,f),!0;case"mouseover":return zr=Oc(zr,e,t,i,o,f),!0;case"pointerover":var h=f.pointerId;return zc.set(h,Oc(zc.get(h)||null,e,t,i,o,f)),!0;case"gotpointercapture":return h=f.pointerId,Ic.set(h,Oc(Ic.get(h)||null,e,t,i,o,f)),!0}return!1}function Xv(e){var t=$t(e.target);if(t!==null){var i=d(t);if(i!==null){if(t=i.tag,t===13){if(t=m(i),t!==null){e.blockedOn=t,Fs(e.priority,function(){Yv(i)});return}}else if(t===31){if(t=p(i),t!==null){e.blockedOn=t,Fs(e.priority,function(){Yv(i)});return}}else if(t===3&&i.stateNode.current.memoizedState.isDehydrated){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function wd(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var i=Hm(e.nativeEvent);if(i===null){i=e.nativeEvent;var o=new i.constructor(i.type,i);rs=o,i.target.dispatchEvent(o),rs=null}else return t=_t(i),t!==null&&Wv(t),e.blockedOn=i,!1;t.shift()}return!0}function Zv(e,t,i){wd(e)&&i.delete(t)}function _S(){Fm=!1,Lr!==null&&wd(Lr)&&(Lr=null),_r!==null&&wd(_r)&&(_r=null),zr!==null&&wd(zr)&&(zr=null),zc.forEach(Zv),Ic.forEach(Zv)}function Sd(e,t){e.blockedOn===t&&(e.blockedOn=null,Fm||(Fm=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,_S)))}var Cd=null;function Jv(e){Cd!==e&&(Cd=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Cd===e&&(Cd=null);for(var t=0;t<e.length;t+=3){var i=e[t],o=e[t+1],f=e[t+2];if(typeof o!="function"){if(Bm(o||i)===null)continue;break}var h=_t(i);h!==null&&(e.splice(t,3),t-=3,Hf(h,{pending:!0,data:f,method:i.method,action:o},o,f))}}))}function No(e){function t(F){return Sd(F,e)}Lr!==null&&Sd(Lr,e),_r!==null&&Sd(_r,e),zr!==null&&Sd(zr,e),zc.forEach(t),Ic.forEach(t);for(var i=0;i<Ir.length;i++){var o=Ir[i];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Ir.length&&(i=Ir[0],i.blockedOn===null);)Xv(i),i.blockedOn===null&&Ir.shift();if(i=(e.ownerDocument||e).$$reactFormReplay,i!=null)for(o=0;o<i.length;o+=3){var f=i[o],h=i[o+1],C=f[Te]||null;if(typeof h=="function")C||Jv(i);else if(C){var T=null;if(h&&h.hasAttribute("formAction")){if(f=h,C=h[Te]||null)T=C.formAction;else if(Bm(f)!==null)continue}else T=C.action;typeof T=="function"?i[o+1]=T:(i.splice(o,3),o-=3),Jv(i)}}}function ex(){function e(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(C){return f=C})},focusReset:"manual",scroll:"manual"})}function t(){f!==null&&(f(),f=null),o||setTimeout(i,20)}function i(){if(!o&&!navigation.transition){var h=navigation.currentEntry;h&&h.url!=null&&navigation.navigate(h.url,{state:h.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(i,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),f!==null&&(f(),f=null)}}}function Pm(e){this._internalRoot=e}jd.prototype.render=Pm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(l(409));var i=t.current,o=Xa();Gv(i,o,e,t,null,null)},jd.prototype.unmount=Pm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Gv(e.current,2,null,e,null,null),sd(),t[qe]=null}};function jd(e){this._internalRoot=e}jd.prototype.unstable_scheduleHydration=function(e){if(e){var t=pn();e={blockedOn:null,target:e,priority:t};for(var i=0;i<Ir.length&&t!==0&&t<Ir[i].priority;i++);Ir.splice(i,0,e),i===0&&Xv(e)}};var tx=a.version;if(tx!=="19.2.7")throw Error(l(527,tx,"19.2.7"));Y.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(l(188)):(e=Object.keys(e).join(","),Error(l(268,e)));return e=v(t),e=e!==null?b(e):null,e=e===null?null:e.stateNode,e};var zS={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var kd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!kd.isDisabled&&kd.supportsFiber)try{pt=kd.inject(zS),rt=kd}catch{}}return Bc.createRoot=function(e,t){if(!c(e))throw Error(l(299));var i=!1,o="",f=og,h=cg,C=ug;return t!=null&&(t.unstable_strictMode===!0&&(i=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(f=t.onUncaughtError),t.onCaughtError!==void 0&&(h=t.onCaughtError),t.onRecoverableError!==void 0&&(C=t.onRecoverableError)),t=Uv(e,1,!1,null,null,i,o,null,f,h,C,ex),e[qe]=t.current,Sm(e),new Pm(t)},Bc.hydrateRoot=function(e,t,i){if(!c(e))throw Error(l(299));var o=!1,f="",h=og,C=cg,T=ug,F=null;return i!=null&&(i.unstable_strictMode===!0&&(o=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onUncaughtError!==void 0&&(h=i.onUncaughtError),i.onCaughtError!==void 0&&(C=i.onCaughtError),i.onRecoverableError!==void 0&&(T=i.onRecoverableError),i.formState!==void 0&&(F=i.formState)),t=Uv(e,1,!0,t,i??null,o,f,F,h,C,T,ex),t.context=qv(null),i=t.current,o=Xa(),o=mt(o),f=Zt(o),f.callback=null,Va(i,f,o),i=o,t.current.lanes=i,as(t,i),ui(t),e[qe]=t.current,Sm(e),new jd(t)},Bc.version="19.2.7",Bc}var gx;function C0(){if(gx)return Gm.exports;gx=1;function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Gm.exports=S0(),Gm.exports}var j0=C0();const k0="https://otbyfkjxrkngvjziawki.supabase.co",A0="sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ",N0={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},vx=typeof window<"u"&&!!window.liveDesk,ct=v0(k0,A0,{auth:{autoRefreshToken:!0,persistSession:!vx,storage:vx?N0:void 0,detectSessionInUrl:!0,flowType:"pkce",storageKey:"livedesk.mindexec.supabase.auth"}}),M0=new Set(["browserLanguage","platform","online","viewport","timezone","screen"]),T0={id:"browser-safe-v1",collect(){if(typeof navigator>"u")return{};const n={browserLanguage:navigator.language||"",platform:navigator.platform||"",online:navigator.onLine,timezone:typeof Intl>"u"?"":Intl.DateTimeFormat().resolvedOptions().timeZone||"",viewport:typeof window>"u"?void 0:{width:window.innerWidth,height:window.innerHeight},screen:typeof window>"u"?void 0:{width:window.screen.width,height:window.screen.height}};return Object.fromEntries(Object.entries(n).filter(([a,r])=>M0.has(a)&&r!==void 0))}};function E0(n,a="Support request failed."){if(n&&typeof n=="object"&&"message"in n){const r=String(n.message||"").trim();if(r)return r.replace(/^.*Support request failed:\s*/i,"")}return n instanceof Error?n.message:a}function R0(n=T0){return n.collect()}async function D0(n,a="livedesk"){const{data:r,error:l}=await ct.from("app_admins").select("role").eq("user_id",n).limit(1);if(l)throw l;const c=r?.[0]?.role||"user";if(c!=="owner"){const{error:S}=await ct.rpc("register_product_access",{p_product_key:a,p_access_type:"free"});if(S)throw S}const[d,m,p]=await Promise.all([ct.from("products").select("id, product_key, name, description, sort_order").order("sort_order"),ct.from("product_admins").select("product_id, role").eq("user_id",n),ct.from("user_products").select("product_id").eq("user_id",n).eq("is_active",!0)]);if(d.error)throw d.error;if(m.error)throw m.error;if(p.error)throw p.error;const g=d.data||[],v=(m.data||[]).map(S=>String(S.product_id)),b=(p.data||[]).map(S=>String(S.product_id)),y=c==="owner",w=y?g.map(S=>S.id):[...new Set([...v,...b])];return{products:g,access:{userId:n,globalRole:c,accessibleProductIds:w,managedProductIds:y?g.map(S=>S.id):v,canViewAllProducts:y,canViewAllPrivatePosts:y,canManageAllProducts:y,canCreateAnnouncements:y||v.length>0}}}async function L0(n=""){const{data:a,error:r}=await ct.rpc("search_support_posts",{p_query:n.trim()||null,p_limit:250});if(r)throw r;return a||[]}async function _0(n){const{data:a,error:r}=await ct.from("support_attachments").select("*").eq("post_id",n).order("created_at");if(r)throw r;const l=a||[];return Promise.all(l.map(async c=>{const d=await ct.storage.from("support-attachments").createSignedUrl(c.storage_path,3600);return{...c,signed_url:d.data?.signedUrl||void 0}}))}async function z0(){const{data:n,error:a}=await ct.from("support_notifications").select("*").order("created_at",{ascending:!1}).limit(30);if(a)throw a;return n||[]}async function I0(n){const{error:a}=await ct.rpc("mark_support_notification_read",{p_notification_id:n});if(a)throw a}async function xx(n){const{data:a,error:r}=await ct.from("support_comments").select("*").eq("post_id",n).order("created_at");if(r)throw r;return a||[]}async function O0(n){const{data:a,error:r}=await ct.from("support_votes").select("post_id").eq("user_id",n);if(r)throw r;return new Set((a||[]).map(l=>String(l.post_id)))}async function H0(n){const{data:a,error:r}=await ct.rpc("create_support_post",{p_product_id:n.productId,p_post_type:n.postType,p_title:n.title,p_body:n.body,p_visibility:n.visibility,p_app_version:n.appVersion||null,p_platform:typeof navigator>"u"?null:navigator.platform||null,p_os_version:typeof navigator>"u"?null:navigator.platform||null,p_environment:n.includeEnvironment?R0():{}});if(r)throw r;const l=Array.isArray(a)?a[0]?.post_id:a?.post_id;if(!l)throw new Error("Support post was not created.");return String(l)}const B0=new Set(["image/png","image/jpeg","image/webp","text/plain","text/markdown","application/json","application/pdf"]);async function F0(n,a){if(!B0.has(a.type))throw new Error("This file type is not allowed.");if(a.size<=0||a.size>10*1024*1024)throw new Error("Attachments must be smaller than 10 MB.");const r=a.name.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"attachment",l=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,c=`${n}/${l}-${r}`,d=await ct.storage.from("support-attachments").upload(c,a,{contentType:a.type,upsert:!1});if(d.error)throw d.error;const{data:m,error:p}=await ct.rpc("add_support_attachment",{p_post_id:n,p_storage_path:c,p_file_name:r,p_mime_type:a.type,p_size_bytes:a.size});if(p)throw await ct.storage.from("support-attachments").remove([c]),p;const g=Array.isArray(m)?m[0]?.attachment_id:m?.attachment_id;if(!g)throw new Error("Attachment metadata was not created.");return String(g)}async function P0(n,a,r,l){const{error:c}=await ct.rpc("update_support_post",{p_post_id:n,p_title:a,p_body:r,p_visibility:l});if(c)throw c}async function $0(n,a){const{error:r}=await ct.rpc("add_support_comment",{p_post_id:n,p_body:a});if(r)throw r}async function U0(n){const{data:a,error:r}=await ct.rpc("toggle_support_vote",{p_post_id:n});if(r)throw r;const l=Array.isArray(a)?a[0]:a;return{voted:!!l?.voted,totalVotes:Number(l?.total_votes||0)}}async function q0(n,a){const{error:r}=await ct.rpc("change_support_post_status",{p_post_id:n,p_target_status:a});if(r)throw r}async function G0(n){const{error:a}=await ct.rpc("set_support_post_hidden",{p_post_id:n,p_hidden:!0});if(a)throw a}async function V0(n,a){const{error:r}=await ct.rpc("set_support_post_locked",{p_post_id:n,p_locked:a});if(r)throw r}async function W0(n,a){const{error:r}=await ct.rpc("set_support_post_pinned",{p_post_id:n,p_pinned:a});if(r)throw r}async function Y0(n,a){const{error:r}=await ct.rpc("mark_support_duplicate",{p_post_id:n,p_duplicate_of_post_id:a});if(r)throw r}async function K0(n,a){const{error:r}=await ct.rpc("accept_support_answer",{p_post_id:n,p_comment_id:a});if(r)throw r}async function Q0(n,a=!0){const{error:r}=await ct.rpc("hide_support_comment",{p_comment_id:n,p_hidden:a});if(r)throw r}const Ah=[{id:"question",label:"Questions",shortLabel:"Question"},{id:"issue",label:"Issues",shortLabel:"Issue"},{id:"feature",label:"Feature Requests",shortLabel:"Feature"},{id:"announcement",label:"Announcements",shortLabel:"Announcement"}],X0=[{id:"all",label:"All statuses"},{id:"needs-response",label:"Needs response"},{id:"open",label:"Open"},{id:"needs-info",label:"Needs more information"},{id:"in-progress",label:"In progress"},{id:"planned",label:"Planned"},{id:"released",label:"Released"},{id:"closed",label:"Closed"}],Z0={question:["open","answered","resolved","closed"],issue:["open","needs-info","confirmed","in-progress","fixed","closed"],feature:["under-review","planned","in-progress","released","declined","closed"],announcement:["published","archived"]},J0={type:"all",product:"",status:"all",visibility:"all",sort:"recent",query:""};function Ym(){if(typeof window>"u")return J0;const n=new URLSearchParams(window.location.search),a=window.location.pathname.match(/^\/support\/(questions|issues|features|announcements)$/)?.[1],r=n.get("type")||a||"",l=r==="questions"||r==="question"?"question":r==="issues"||r==="issue"?"issue":r==="features"||r==="feature"?"feature":r==="announcements"||r==="announcement"?"announcement":"all",c=n.get("visibility"),d=n.get("sort");return{type:l,product:n.get("product")||"",status:n.get("status")||"all",visibility:c==="public"||c==="private"?c:"all",sort:d==="votes"||d==="newest"?d:"recent",query:n.get("q")||""}}function eC(n){return n==="all"?"":n==="question"?"questions":n==="issue"?"issues":n==="feature"?"features":"announcements"}function tC(n,a){const r={...n,...a},l=new URLSearchParams;r.product&&l.set("product",r.product),r.status!=="all"&&l.set("status",r.status),r.visibility!=="all"&&l.set("visibility",r.visibility),r.sort!=="recent"&&l.set("sort",r.sort),r.query&&l.set("q",r.query);const c=eC(r.type),d=l.toString();return`/support${c?`/${c}`:""}${d?`?${d}`:""}`}function Ad(n){const a=new Date(n);return Number.isFinite(a.getTime())?a.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):n}function Km(n){return n.replaceAll("-"," ").replace(/\b\w/g,a=>a.toUpperCase())}function yx(n){return n==="question"?PS:n==="issue"?$S:n==="feature"?US:qS}function bx(n){return Ah.find(a=>a.id===n)?.shortLabel||n}function Qm(n,a){return n.find(r=>r.id===a)?.name||"Product"}function Ra(n){const a=E0(n);return/relation .* does not exist|function .* does not exist|schema cache/i.test(a)?"Support Board database is not installed yet. Apply the latest Supabase migration first.":/not-authenticated|jwt/i.test(a)?"Sign in again to use Support.":/product-access-denied|product-not-found/i.test(a)?"You do not have access to this product.":a}function ib({session:n,currentProductKey:a="livedesk",appVersion:r="",onSignIn:l}){const[c,d]=u.useState(()=>Ym()),[m,p]=u.useState(null),[g,v]=u.useState([]),[b,y]=u.useState([]),[w,S]=u.useState(""),[j,N]=u.useState([]),[M,k]=u.useState([]),[E,R]=u.useState([]),[U,H]=u.useState(()=>new Set),[W,_]=u.useState(!0),[L,le]=u.useState(""),[q,te]=u.useState(""),[K,ne]=u.useState(!1),[ce,V]=u.useState(!1),[O,Y]=u.useState(""),[X,P]=u.useState(()=>Ym().query),[oe,we]=u.useState(!1),[J,B]=u.useState(!1),[pe,ge]=u.useState(""),[xe,Ae]=u.useState(""),[_e,ie]=u.useState("free"),[Q,Ie]=u.useState(""),[Oe,ae]=u.useState(""),[ke,je]=u.useState("admin"),[De,Le]=u.useState(""),[$e,he]=u.useState(""),[Me,de]=u.useState(""),[be,We]=u.useState(""),[at,wn]=u.useState(""),[Xe,ht]=u.useState([]),[St,Rn]=u.useState({productId:"",postType:"question",title:"",body:"",visibility:"public",includeEnvironment:!0,files:[]}),He=u.useCallback(I=>{const Fe={...c,...I};d(Fe),typeof window<"u"&&window.history.pushState({},"",tC(c,I))},[c]);u.useEffect(()=>{const I=()=>d(Ym());return window.addEventListener("popstate",I),()=>window.removeEventListener("popstate",I)},[]);const Ct=u.useCallback(async()=>{const I=await L0(c.query);return y(I),n?.user.id&&H(await O0(n.user.id)),I},[c.query,n?.user.id]),Gt=u.useCallback(async()=>{if(!n?.user.id){p(null),v([]),y([]),S(""),R([]),_(!1);return}_(!0),te("");try{const I=await D0(n.user.id,a);p(I.access),v(I.products),await Ct(),R(await z0())}catch(I){te(Ra(I))}finally{_(!1)}},[a,Ct,n?.user.id]);u.useEffect(()=>{Gt()},[Gt]);const pt=u.useMemo(()=>m?m.canViewAllProducts?g:g.filter(I=>m.accessibleProductIds.includes(I.id)):[],[m,g]),rt=u.useMemo(()=>{const I=pt.find(Fe=>Fe.product_key===c.product);return m?.canViewAllProducts&&!c.product||c.product==="all"&&m?.canViewAllProducts?"all":I?I.product_key:pt.some(Fe=>Fe.product_key===a)?a:pt[0]?.product_key||""},[m?.canViewAllProducts,pt,a,c.product]),tn=rt==="all"?"":pt.find(I=>I.product_key===rt)?.id||"",kt=u.useMemo(()=>{const I=new Map(g.map(mt=>[mt.id,mt.product_key]));return[...b.filter(mt=>c.type!=="all"&&mt.post_type!==c.type||rt!=="all"&&tn&&mt.product_id!==tn||c.status==="needs-response"&&!["open","needs-info"].includes(mt.status)||c.status!=="all"&&c.status!=="needs-response"&&mt.status!==c.status||c.visibility!=="all"&&mt.visibility!==c.visibility?!1:I.has(mt.product_id))].sort((mt,nn)=>c.sort==="votes"?nn.vote_count-mt.vote_count||nn.updated_at.localeCompare(mt.updated_at):c.sort==="newest"?nn.created_at.localeCompare(mt.created_at):Number(nn.is_pinned)-Number(mt.is_pinned)||nn.updated_at.localeCompare(mt.updated_at))},[b,g,c.sort,c.status,c.type,c.visibility,tn,rt]),ze=kt.find(I=>I.id===w)||kt[0]||null,Dn=!!(ze&&m&&(m.canViewAllProducts||m.managedProductIds.includes(ze.product_id))),Zi=!!(ze&&n?.user.id===ze.author_id)||Dn;u.useEffect(()=>{if(!ze){S(""),N([]),V(!1);return}ze.id!==w&&S(ze.id)},[ze,w]),u.useEffect(()=>{let I=!0;return w?(xx(w).then(Fe=>{I&&N(Fe)}).catch(Fe=>{I&&te(Ra(Fe))}),_0(w).then(Fe=>{I&&k(Fe)}).catch(Fe=>{I&&te(Ra(Fe))}),()=>{I=!1}):(N([]),k([]),()=>{I=!1})},[w]),u.useEffect(()=>{!St.productId&&pt[0]&&Rn(I=>({...I,productId:tn||pt[0].id}))},[pt,St.productId,tn]),u.useEffect(()=>{P(c.query)},[c.query]),u.useEffect(()=>{!xe&&pt[0]&&Ae(pt[0].id),!Oe&&pt[0]&&ae(pt[0].id)},[pt,xe,Oe]);const hn=I=>{ze&&y(Fe=>Fe.map(mt=>mt.id===ze.id?{...mt,...I}:mt))},$n=async I=>{if(I.preventDefault(),!(!n||!St.productId)){le("create"),te("");try{const Fe=await H0({productId:St.productId,postType:St.postType,title:St.title,body:St.body,visibility:St.postType==="announcement"?"public":St.visibility,appVersion:r,includeEnvironment:St.postType==="issue"&&St.includeEnvironment});for(const nn of Xe)await F0(Fe,nn);const mt=await Ct();ne(!1),ht([]),Rn(nn=>({...nn,title:"",body:"",files:[]})),S(Fe),mt.some(nn=>nn.id===Fe)||await Gt()}catch(Fe){te(Ra(Fe))}finally{le("")}}},ga=async I=>{if(I.preventDefault(),!!ze){le("edit"),te("");try{await P0(ze.id,ze.title,ze.body,ze.visibility),V(!1),await Ct()}catch(Fe){te(Ra(Fe))}finally{le("")}}},ts=async I=>{if(I.preventDefault(),!(!ze||!O.trim())){le("comment"),te("");try{await $0(ze.id,O),Y(""),N(await xx(ze.id)),await Ct()}catch(Fe){te(Ra(Fe))}finally{le("")}}},Ln=async()=>{if(!(!ze||ze.post_type!=="feature")){le("vote"),te("");try{const I=await U0(ze.id);H(Fe=>{const mt=new Set(Fe);return I.voted?mt.add(ze.id):mt.delete(ze.id),mt}),hn({vote_count:I.totalVotes})}catch(I){te(Ra(I))}finally{le("")}}},ns=async I=>{if(ze){le("status"),te("");try{await q0(ze.id,I),hn({status:I}),await Ct()}catch(Fe){te(Ra(Fe))}finally{le("")}}},Be=async()=>{if(!(!ze||!window.confirm("Hide this Support post from the board?"))){le("hide"),te("");try{await G0(ze.id),S(""),await Ct()}catch(I){te(Ra(I))}finally{le("")}}},hi=async()=>{if(ze){le("lock"),te("");try{await V0(ze.id,!ze.is_locked),hn({is_locked:!ze.is_locked}),await Ct()}catch(I){te(Ra(I))}finally{le("")}}},ft=async()=>{if(ze){le("pin"),te("");try{await W0(ze.id,!ze.is_pinned),hn({is_pinned:!ze.is_pinned}),await Ct()}catch(I){te(Ra(I))}finally{le("")}}},as=async I=>{if(ze){le(`accept-${I}`),te("");try{await K0(ze.id,I),hn({accepted_comment_id:I,status:ze.post_type==="question"?"answered":ze.status}),await Ct()}catch(Fe){te(Ra(Fe))}finally{le("")}}},Vt=async()=>{if(!(!ze||!be||be===ze.id)){le("duplicate"),te("");try{await Y0(ze.id,be),S(""),We(""),await Ct()}catch(I){te(Ra(I))}finally{le("")}}},Bs=async I=>{if(!I.read_at)try{await I0(I.id),R(Fe=>Fe.map(mt=>mt.id===I.id?{...mt,read_at:new Date().toISOString()}:mt))}catch(Fe){te(Ra(Fe))}I.post_id&&S(I.post_id),we(!1)};return n?W&&!m?s.jsxs("section",{className:"support-page support-loading",children:[s.jsx(Ho,{className:"support-spin",size:23})," Loading Support Board..."]}):s.jsxs("section",{className:"support-page",children:[s.jsx("header",{className:"support-page-header support-page-actions-only",children:s.jsxs("div",{className:"support-header-actions",children:[s.jsxs("div",{className:"support-notification-wrap",children:[s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>we(I=>!I),title:"Notifications",children:[s.jsx(HS,{size:16})," ",E.filter(I=>!I.read_at).length>0&&s.jsx("b",{children:E.filter(I=>!I.read_at).length})]}),oe&&s.jsxs("div",{className:"support-notification-popover",children:[s.jsx("strong",{children:"Notifications"}),E.length===0?s.jsx("span",{className:"support-muted",children:"No notifications yet."}):E.map(I=>s.jsxs("button",{type:"button",className:I.read_at?"":"unread",onClick:()=>{Bs(I)},children:[s.jsx("b",{children:I.title}),s.jsx("span",{children:I.body}),s.jsx("small",{children:Ad(I.created_at)})]},I.id))]})]}),m?.canViewAllProducts&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>B(I=>!I),children:[s.jsx(Lt,{size:16})," Admin"]}),s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{Gt()},disabled:W,children:[s.jsx(Ho,{size:16,className:W?"support-spin":""})," Refresh"]}),s.jsxs("button",{className:"support-primary-button",type:"button",onClick:()=>ne(!0),disabled:pt.length===0,children:[s.jsx($m,{size:17})," New request"]})]})}),q&&s.jsxs("div",{className:"support-error",role:"alert",children:[s.jsx(Ja,{size:17})," ",s.jsx("span",{children:q}),s.jsx("button",{type:"button",onClick:()=>te(""),"aria-label":"Dismiss error",children:s.jsx(Ja,{size:15})})]}),K&&s.jsxs("form",{className:"support-composer",onSubmit:I=>{$n(I)},children:[s.jsxs("div",{className:"support-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"New Support request"}),s.jsx("strong",{children:"Describe one actionable problem or idea."})]}),s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>ne(!1),"aria-label":"Close composer",children:s.jsx(Ja,{size:18})})]}),s.jsxs("div",{className:"support-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"Product"}),s.jsx("select",{value:St.productId,onChange:I=>Rn(Fe=>({...Fe,productId:I.target.value})),children:pt.map(I=>s.jsx("option",{value:I.id,children:I.name},I.id))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Type"}),s.jsx("select",{value:St.postType,onChange:I=>Rn(Fe=>({...Fe,postType:I.target.value})),children:Ah.filter(I=>I.id!=="announcement"||m?.canCreateAnnouncements).map(I=>s.jsx("option",{value:I.id,children:I.label},I.id))})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:"Title"}),s.jsx("input",{required:!0,minLength:3,maxLength:180,value:St.title,onChange:I=>Rn(Fe=>({...Fe,title:I.target.value})),placeholder:"A short, searchable summary"})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:St.postType==="issue"?"What happened?":St.postType==="feature"?"Describe the desired behavior":St.postType==="announcement"?"Announcement":"Question"}),s.jsx("textarea",{required:!0,value:St.body,onChange:I=>Rn(Fe=>({...Fe,body:I.target.value})),placeholder:"Include the context another person needs to respond.",rows:6})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Visibility"}),s.jsxs("select",{value:St.visibility,disabled:St.postType==="announcement",onChange:I=>Rn(Fe=>({...Fe,visibility:I.target.value})),children:[s.jsx("option",{value:"public",children:"Public"}),s.jsx("option",{value:"private",children:"Private"})]})]}),St.postType==="issue"&&s.jsxs("label",{className:"support-checkbox",children:[s.jsx("input",{type:"checkbox",checked:St.includeEnvironment,onChange:I=>Rn(Fe=>({...Fe,includeEnvironment:I.target.checked}))}),s.jsx("span",{children:"Attach safe browser/runtime details"})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:"Attachments"}),s.jsx("input",{type:"file",multiple:!0,accept:"image/png,image/jpeg,image/webp,text/plain,text/markdown,application/json,application/pdf",onChange:I=>ht(Array.from(I.target.files||[]).slice(0,5))}),s.jsx("small",{className:"support-muted",children:"Up to 5 files, 10 MB each. Images, text, JSON, Markdown, and PDF."})]})]}),s.jsxs("div",{className:"support-composer-footer",children:[s.jsx("span",{children:Xe.length>0?`${Xe.length} attachment${Xe.length===1?"":"s"} selected.`:"Private posts are visible only to you and the product support staff."}),s.jsxs("button",{className:"support-primary-button",type:"submit",disabled:L==="create",children:[s.jsx(Bo,{size:16})," ",L==="create"?"Submitting...":"Submit request"]})]})]}),s.jsxs("div",{className:"support-tabs",role:"tablist","aria-label":"Support post type",children:[s.jsx("button",{className:c.type==="all"?"active":"",type:"button",onClick:()=>He({type:"all"}),children:"All"}),Ah.map(I=>{const Fe=yx(I.id);return s.jsxs("button",{className:c.type===I.id?"active":"",type:"button",onClick:()=>He({type:I.id}),children:[s.jsx(Fe,{size:15})," ",I.label]},I.id)})]}),J&&m?.canViewAllProducts&&s.jsxs("section",{className:"support-admin-panel",children:[s.jsxs("div",{className:"support-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Owner controls"}),s.jsx("strong",{children:"Products and access are managed by immutable user IDs behind these email lookup forms."})]}),s.jsx(Lt,{size:19})]}),s.jsxs("div",{className:"support-admin-grid",children:[s.jsxs("form",{onSubmit:I=>{},children:[s.jsx("strong",{children:"Grant product access"}),s.jsx("input",{type:"email",required:!0,placeholder:"User email",value:pe,onChange:I=>ge(I.target.value)}),s.jsx("select",{value:xe,onChange:I=>Ae(I.target.value),children:pt.map(I=>s.jsx("option",{value:I.id,children:I.name},I.id))}),s.jsxs("select",{value:_e,onChange:I=>ie(I.target.value),children:[s.jsx("option",{value:"free",children:"Free"}),s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"paid",children:"Paid"}),s.jsx("option",{value:"beta",children:"Beta"}),s.jsx("option",{value:"staff",children:"Staff"})]}),s.jsxs("button",{className:"support-secondary-button",type:"submit",disabled:at==="access",children:[s.jsx($r,{size:15})," Grant access"]})]}),s.jsxs("form",{onSubmit:I=>{},children:[s.jsx("strong",{children:"Assign product admin"}),s.jsx("input",{type:"email",required:!0,placeholder:"Admin email",value:Q,onChange:I=>Ie(I.target.value)}),s.jsx("select",{value:Oe,onChange:I=>ae(I.target.value),children:pt.map(I=>s.jsx("option",{value:I.id,children:I.name},I.id))}),s.jsxs("select",{value:ke,onChange:I=>je(I.target.value),children:[s.jsx("option",{value:"admin",children:"Admin"}),s.jsx("option",{value:"support",children:"Support"}),s.jsx("option",{value:"moderator",children:"Moderator"})]}),s.jsxs("button",{className:"support-secondary-button",type:"submit",disabled:at==="product-admin",children:[s.jsx(Lt,{size:15})," Assign admin"]})]}),s.jsxs("form",{onSubmit:I=>{},children:[s.jsx("strong",{children:"Add a product"}),s.jsx("input",{required:!0,pattern:"[a-z0-9][a-z0-9_-]{1,48}",placeholder:"product-key",value:De,onChange:I=>Le(I.target.value)}),s.jsx("input",{required:!0,placeholder:"Product name",value:$e,onChange:I=>he(I.target.value)}),s.jsx("input",{placeholder:"Description",value:Me,onChange:I=>de(I.target.value)}),s.jsxs("button",{className:"support-secondary-button",type:"submit",disabled:at==="product",children:[s.jsx($m,{size:15})," Add product"]})]})]})]}),s.jsxs("form",{className:"support-search-bar",onSubmit:I=>{I.preventDefault(),He({query:X.trim()})},children:[s.jsxs("label",{children:[s.jsx("span",{children:"Search Support"}),s.jsx("input",{value:X,onChange:I=>P(I.target.value),placeholder:"Search titles and request details"})]}),s.jsxs("button",{className:"support-secondary-button",type:"submit",children:[s.jsx(nx,{size:15})," Search"]}),c.query&&s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{P(""),He({query:""})},"aria-label":"Clear search",children:s.jsx(Ja,{size:16})})]}),s.jsxs("div",{className:"support-filter-bar",children:[s.jsxs("div",{className:"support-filter-title",children:[s.jsx(nx,{size:16}),s.jsx("span",{children:"Filter"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Product"}),s.jsxs("select",{value:rt,onChange:I=>He({product:I.target.value}),disabled:!m?.canViewAllProducts&&pt.length<=1,children:[s.jsx("option",{value:"all",children:"All products"}),pt.map(I=>s.jsx("option",{value:I.product_key,children:I.name},I.id))]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Status"}),s.jsx("select",{value:c.status,onChange:I=>He({status:I.target.value}),children:X0.map(I=>s.jsx("option",{value:I.id,children:I.label},I.id))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Visibility"}),s.jsxs("select",{value:c.visibility,onChange:I=>He({visibility:I.target.value}),children:[s.jsx("option",{value:"all",children:"All visibility"}),s.jsx("option",{value:"public",children:"Public"}),s.jsx("option",{value:"private",children:"Private"})]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Sort"}),s.jsxs("select",{value:c.sort,onChange:I=>He({sort:I.target.value}),children:[s.jsx("option",{value:"recent",children:"Recently updated"}),s.jsx("option",{value:"newest",children:"Newest"}),s.jsx("option",{value:"votes",children:"Most votes"})]})]})]}),m?.canViewAllProducts&&s.jsxs("div",{className:"support-admin-shortcuts",children:[s.jsxs("span",{children:[s.jsx(Lt,{size:15})," Owner view"]}),s.jsx("button",{type:"button",onClick:()=>He({status:"needs-response"}),children:"Needs response"}),s.jsx("button",{type:"button",onClick:()=>He({visibility:"private"}),children:"Private requests"}),s.jsx("button",{type:"button",onClick:()=>He({type:"feature",status:"all",sort:"votes"}),children:"High-vote features"})]}),s.jsxs("div",{className:"support-board-layout",children:[s.jsxs("section",{className:"support-post-list","aria-label":"Support posts",children:[s.jsxs("div",{className:"support-list-heading",children:[s.jsxs("span",{children:[kt.length," request",kt.length===1?"":"s"]}),s.jsx("small",{children:rt==="all"?"All products":Qm(pt,tn)})]}),kt.length===0?s.jsxs("div",{className:"support-list-empty",children:[s.jsx(Kc,{size:25}),s.jsx("strong",{children:"No posts match these filters."}),s.jsx("span",{children:"Start with a focused question, issue report, or feature request."}),pt.length>0&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>ne(!0),children:[s.jsx($m,{size:16})," Create the first request"]})]}):kt.map(I=>{const Fe=yx(I.post_type);return s.jsxs("button",{type:"button",className:`support-post-row ${I.id===ze?.id?"active":""}`,onClick:()=>{S(I.id),V(!1)},children:[s.jsx("span",{className:"support-post-row-icon",children:s.jsx(Fe,{size:17})}),s.jsxs("span",{className:"support-post-row-copy",children:[s.jsxs("span",{className:"support-post-row-meta",children:[s.jsx("b",{children:Qm(g,I.product_id)}),s.jsx("em",{children:bx(I.post_type)}),I.visibility==="private"&&s.jsx(Is,{size:13})]}),s.jsx("strong",{children:I.title}),s.jsxs("small",{children:[Km(I.status)," · ",Ad(I.updated_at)," · ",I.comment_count," comments"]})]}),I.post_type==="feature"&&s.jsxs("span",{className:"support-vote-count",children:[s.jsx(Vy,{size:14})," ",I.vote_count]})]},I.id)})]}),s.jsx("section",{className:"support-post-detail","aria-label":"Support post detail",children:ze?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"support-detail-head",children:[s.jsxs("div",{className:"support-detail-badges",children:[s.jsx("span",{className:"support-product-badge",children:Qm(g,ze.product_id)}),s.jsx("span",{className:"support-type-badge",children:bx(ze.post_type)}),s.jsx("span",{className:`support-status-badge status-${ze.status}`,children:Km(ze.status)}),ze.visibility==="private"&&s.jsxs("span",{className:"support-private-badge",children:[s.jsx(Is,{size:13})," Private"]})]}),s.jsxs("div",{className:"support-detail-actions",children:[Zi&&s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>V(I=>!I),title:"Edit post",children:s.jsx(BS,{size:16})}),Dn&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{ft()},disabled:L==="pin",title:ze.is_pinned?"Unpin post":"Pin post",children:s.jsx(ax,{size:16})}),s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{hi()},disabled:L==="lock",title:ze.is_locked?"Unlock post":"Lock post",children:s.jsx(Is,{size:16})}),s.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{Be()},disabled:L==="hide",title:"Hide post",children:s.jsx(sx,{size:16})})]})]})]}),ce?s.jsxs("form",{className:"support-edit-form",onSubmit:I=>{ga(I)},children:[s.jsx("input",{value:ze.title,onChange:I=>hn({title:I.target.value}),minLength:3,maxLength:180,required:!0}),s.jsx("textarea",{value:ze.body,onChange:I=>hn({body:I.target.value}),rows:9,required:!0}),s.jsxs("div",{className:"support-edit-actions",children:[s.jsxs("select",{value:ze.visibility,onChange:I=>hn({visibility:I.target.value}),children:[s.jsx("option",{value:"public",children:"Public"}),s.jsx("option",{value:"private",children:"Private"})]}),s.jsxs("button",{className:"support-primary-button",type:"submit",disabled:L==="edit",children:[s.jsx($r,{size:16})," Save changes"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:ze.title}),s.jsx("div",{className:"support-detail-body",children:ze.body.split(`
|
|
10
10
|
`).map((I,Fe)=>s.jsx("p",{children:I||" "},`${ze.id}-body-${Fe}`))})]}),s.jsxs("div",{className:"support-detail-meta",children:[s.jsxs("span",{children:["Opened ",Ad(ze.created_at)]}),ze.app_version&&s.jsxs("span",{children:["Version ",ze.app_version]}),ze.platform&&s.jsx("span",{children:ze.platform}),ze.is_locked&&s.jsxs("span",{children:[s.jsx(Is,{size:13})," Locked"]}),ze.is_pinned&&s.jsxs("span",{children:[s.jsx(ax,{size:13})," Pinned"]})]}),s.jsxs("div",{className:"support-detail-controls",children:[ze.post_type==="feature"&&s.jsxs("button",{className:`support-vote-button ${U.has(ze.id)?"voted":""}`,type:"button",onClick:()=>{Ln()},disabled:L==="vote",children:[s.jsx(FS,{size:16})," ",U.has(ze.id)?"Voted":"Vote"," ",s.jsx("b",{children:ze.vote_count})]}),Dn&&s.jsxs("label",{className:"support-status-control",children:[s.jsx("span",{children:"Change status"}),s.jsx("select",{value:ze.status,onChange:I=>{ns(I.target.value)},disabled:L==="status",children:(Z0[ze.post_type]||[]).map(I=>s.jsx("option",{value:I,children:Km(I)},I))})]}),Dn&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"support-status-control",value:be,onChange:I=>We(I.target.value),children:[s.jsx("option",{value:"",children:"Duplicate of..."}),kt.filter(I=>I.id!==ze.id&&I.product_id===ze.product_id).map(I=>s.jsx("option",{value:I.id,children:I.title.slice(0,55)},I.id))]}),s.jsx("button",{className:"support-secondary-button",type:"button",onClick:()=>{Vt()},disabled:!be||L==="duplicate",children:"Merge duplicate"})]})]}),M.length>0&&s.jsxs("div",{className:"support-attachments",children:[s.jsx("div",{className:"support-section-heading",children:s.jsxs("div",{children:[s.jsx("span",{children:"Attachments"}),s.jsxs("strong",{children:[M.length," file",M.length===1?"":"s"]})]})}),M.map(I=>s.jsxs("a",{href:I.signed_url,target:"_blank",rel:"noreferrer",children:[s.jsx(Xh,{size:14})," ",I.file_name,s.jsxs("small",{children:[Math.ceil(I.size_bytes/1024)," KB"]})]},I.id))]}),s.jsxs("div",{className:"support-comments",children:[s.jsxs("div",{className:"support-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Discussion"}),s.jsxs("strong",{children:[j.length," comment",j.length===1?"":"s"]})]}),ze.is_locked&&s.jsxs("span",{className:"support-locked-label",children:[s.jsx(Is,{size:14})," Locked"]})]}),j.length===0?s.jsx("p",{className:"support-muted",children:"No response yet. Keep the conversation focused on this request."}):s.jsx("div",{className:"support-comment-list",children:j.map(I=>s.jsxs("article",{className:`support-comment ${I.is_staff_answer?"staff":""} ${ze.accepted_comment_id===I.id?"accepted":""}`,children:[s.jsxs("div",{className:"support-comment-head",children:[s.jsx("strong",{children:I.is_staff_answer?"LiveDesk Support":I.author_id===n.user.id?"You":"Support user"}),I.is_staff_answer&&s.jsxs("span",{children:[s.jsx(Lt,{size:13})," Staff answer"]}),ze.accepted_comment_id===I.id&&s.jsxs("span",{children:[s.jsx(Hn,{size:13})," Accepted"]}),s.jsx("time",{children:Ad(I.created_at)})]}),s.jsx("p",{children:I.body}),s.jsxs("div",{className:"support-comment-actions",children:[(n.user.id===ze.author_id||Dn)&&ze.post_type==="question"&&ze.accepted_comment_id!==I.id&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{as(I.id)},disabled:L===`accept-${I.id}`,children:[s.jsx($r,{size:14})," Accept answer"]}),Dn&&s.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{Q0(I.id)},title:"Hide comment",children:s.jsx(sx,{size:14})})]})]},I.id))}),!ze.is_locked&&s.jsxs("form",{className:"support-comment-form",onSubmit:I=>{ts(I)},children:[s.jsx("textarea",{value:O,onChange:I=>Y(I.target.value),placeholder:"Add a focused reply...",rows:3}),s.jsxs("button",{className:"support-primary-button",type:"submit",disabled:L==="comment"||!O.trim(),children:[s.jsx(Bo,{size:15})," Reply"]})]})]})]}):s.jsxs("div",{className:"support-detail-empty",children:[s.jsx(Kc,{size:28}),s.jsx("strong",{children:"Select a Support request"}),s.jsx("span",{children:"Its discussion and staff actions will appear here."})]})})]})]}):s.jsx("section",{className:"support-page support-auth-page",children:s.jsxs("div",{className:"support-empty-hero",children:[s.jsx("span",{className:"support-hero-icon",children:s.jsx(Kc,{size:28})}),s.jsx("p",{className:"support-eyebrow",children:"LiveDesk Support"}),s.jsx("h2",{children:"Get help, report issues, and shape the product."}),s.jsx("p",{children:"Sign in to see the products attached to your account and submit a private or public request."}),s.jsxs("button",{className:"support-primary-button",type:"button",onClick:l,children:[s.jsx(Lt,{size:17})," Sign in with Google"]})]})})}function Nd(n){return!!n&&typeof n=="object"}function rb(n){let a=n;return Nd(a)&&"data"in a&&(a=a.data),Nd(a)&&"session"in a&&(a=a.session),!Nd(a)||typeof a.access_token!="string"||!a.access_token||!Nd(a.user)||typeof a.user.id!="string"||!a.user.id?null:a}function wx(n){return n?.access_token?n.refresh_token?"":"refresh-token-required":"access-token-required"}const Xc=5179,bn=Wr(`http://127.0.0.1:${Xc}`);function nC(n){const a=n.split(".").map(r=>Number(r));return a.length===4&&a.every(r=>Number.isInteger(r)&&r>=0&&r<=255)?a:[]}function aC(n){const a=n.trim().toLowerCase();return a==="localhost"||a==="127.0.0.1"||a==="::1"||a==="[::1]"}function sC(n){const a=n.trim().toLowerCase();return!a||a==="0.0.0.0"||a==="::"||a==="[::]"}function iC(n){const a=nC(n);return a.length===0?!1:a[0]===10||a[0]===172&&a[1]>=16&&a[1]<=31||a[0]===192&&a[1]===168}function rC(n){return n.includes(":")&&!n.startsWith("[")?`[${n}]`:n}function lC(n){const a=String(n||"").trim();if(!a)return null;const r=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`tcp://${a}`;try{const l=new URL(r),c=l.hostname.replace(/^\[|\]$/g,""),d=Number(l.port);return!c||!Number.isInteger(d)||d<1||d>65535||sC(c)?null:{host:c,port:d}}catch{return null}}function Wr(n){const a=String(n||"").trim()||`http://127.0.0.1:${Xc}`,r=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`http://${a}`;try{const l=new URL(r);return l.port||(l.port=String(Xc)),l.hash="",l.search="",l.toString().replace(/\/+$/,"")}catch{return`http://127.0.0.1:${Xc}`}}function oC(n){const a=lC(n);return a?Wr(`http://${rC(a.host)}:${Xc}`):""}function Sx(n){const r=[n?.endpoint,...Array.isArray(n?.endpoint_candidates)?n.endpoint_candidates:[]].map(l=>oC(String(l||""))).filter(Boolean);return[...new Set(r)]}function Zc(n=bn){if(!(typeof window>"u"||window.location.protocol!=="https:"))try{const a=new URL(n);if(a.protocol!=="http:")return;if(aC(a.hostname))return"loopback";if(iC(a.hostname))return"local"}catch{return}}function vf(n,a=bn){const r=new URL(n,Wr(a));return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.toString()}async function Ge(n,a,r=bn){const l=Wr(r),c={...a,headers:{"Content-Type":"application/json",...a?.headers||{}},cache:"no-store"},d=Zc(l);d&&(c.targetAddressSpace=d);let m;try{m=await fetch(`${l}${n}`,c)}catch(g){throw d?new Error("LiveDesk Hub is not reachable at this local network address. If Chrome shows a local network prompt, allow it; otherwise restart the Hub so port 5179 is open on the network."):g}let p=null;try{p=await m.json()}catch{p=null}if(!m.ok){const g=p&&typeof p=="object"&&"error"in p?String(p.error||""):"";throw new Error(`${m.status} ${g||m.statusText}`)}return p}async function lb({baseUrl:n=bn,targetRole:a,previousRuntimePid:r=0,allowedStates:l=["running","waiting-auth"],timeoutMs:c=3e4}){const d=Date.now()+c;let m=null;for(;Date.now()<d;){try{const g=await Ge("/api/runtime/status",void 0,n),v=String(g.role||"").toLowerCase(),b=String(g.state||"").toLowerCase(),y=Number(g.runtimePid||0),w=r>1?y>1&&y!==r:y>1;if(v===a&&l.map(S=>S.toLowerCase()).includes(b)&&w)return g}catch(g){m=g}await new Promise(g=>setTimeout(g,300))}const p=m instanceof Error?` ${m.message}`:"";throw new Error(`LiveDesk runtime did not become ${a} with a new process.${p}`)}function cC(n,a=120){if(typeof window>"u")return;const r=new URL(window.location.href);r.port=String(n),r.pathname="/",r.search="",r.hash="";const l=r.toString();let c=0;const d=()=>{fetch(l,{cache:"no-store",mode:"no-cors"}).then(()=>window.location.replace(l)).catch(()=>{if(c+=1,c>=a){window.location.replace(l);return}window.setTimeout(d,250)})};d()}function Nh(n){if(!n)return"-";const a=Date.now()-Date.parse(n);return Number.isFinite(a)?a<1e3?"now":a<6e4?`${Math.round(a/1e3)}s`:a<36e5?`${Math.round(a/6e4)}m`:`${Math.round(a/36e5)}h`:"-"}async function Rl(n){await navigator.clipboard.writeText(n)}function ob({size:n=22}){return s.jsxs("svg",{width:n,height:n,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[s.jsx("rect",{x:"2.5",y:"4",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.42"}),s.jsx("path",{d:"M7 16v1.5h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.42"}),s.jsx("rect",{x:"10.5",y:"2.5",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.62"}),s.jsx("path",{d:"M15 14.5V16h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.62"}),s.jsx("rect",{x:"6.5",y:"8.5",width:"15",height:"10",rx:"1.7",fill:"currentColor",fillOpacity:"0.12",stroke:"currentColor",strokeWidth:"1.9"}),s.jsx("path",{d:"M12 21v1.5H9.5M16 21v1.5h2.5M9.5 22.5h9",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round"})]})}const cb={hub:"Use this computer as the LiveDesk Hub. Hub is the unified control center for Client connections, Wall, Control, file sharing, and Agents; press it after network changes to refresh secure access.","switch-to-hub":"Switch this computer from Client to Hub. LiveDesk saves the new role, restarts the same desktop runtime, and opens the Wall; this computer stops sharing as a Client.",client:"Keep this computer in Client mode so its screens, files, audio, and remote controls remain available to the active Hub.",wall:"Show live thumbnails from every connected Client. Choose a display, change tile size, or move into Control without opening another connection.",control:"Open the selected Client at full resolution and send mouse and keyboard input through the existing Hub session.","share-files":"Browse files on the Hub, send files to selected Clients, and manage shared folders and transfer progress.",agents:"Run Hub-hosted Codex tasks on connected Clients within the selected permissions, timeouts, and audit controls."},Mh={en:cb,ko:{hub:"이 컴퓨터를 LiveDesk Hub로 운영합니다. Hub는 Client 연결, Wall, Control, 파일 공유와 Agents를 한곳에서 관리하는 통합 제어 공간이며, 네트워크 변경 후 누르면 보안 접속 정보도 갱신됩니다.","switch-to-hub":"이 컴퓨터를 Client에서 Hub로 전환합니다. 새 역할을 저장한 뒤 같은 데스크톱 런타임을 재시작하고 Wall을 열며, 이 컴퓨터의 Client 화면 공유는 중지됩니다.",client:"이 컴퓨터를 Client 모드로 유지합니다. 화면, 파일, 오디오와 원격 제어 기능이 활성 Hub에서 계속 사용 가능하도록 연결합니다.",wall:"연결된 모든 Client의 실시간 화면을 한곳에 표시합니다. 모니터와 타일 크기를 선택하고 새 연결 없이 Control로 이동할 수 있습니다.",control:"선택한 Client 화면을 전체 해상도로 열고 기존 Hub 세션을 통해 마우스와 키보드 입력을 전송합니다.","share-files":"Hub의 파일을 탐색하고 선택한 Client로 전송하며 공유 폴더와 전송 진행 상태를 관리합니다.",agents:"Hub에서 실행되는 Codex 작업을 연결된 Client에 전달합니다. 선택한 권한, 제한 시간과 감사 기록 범위 안에서만 실행됩니다."},ja:{hub:"このコンピューターを LiveDesk Hub として運用します。Hub は Client 接続、Wall、Control、ファイル共有、Agents を一か所で管理する統合コントロールセンターで、ネットワーク変更後に押すと安全な接続情報も更新します。","switch-to-hub":"このコンピューターを Client から Hub に切り替えます。新しい役割を保存して同じデスクトップランタイムを再起動し、Wall を開きます。Client としての共有は停止します。",client:"このコンピューターを Client モードで維持し、画面、ファイル、音声、リモート操作をアクティブ Hub から利用できるようにします。",wall:"接続中のすべての Client のライブ画面を一覧表示します。ディスプレイやタイルサイズを選び、新しい接続なしで Control に移動できます。",control:"選択した Client をフル解像度で開き、既存の Hub セッションからマウスとキーボード入力を送信します。","share-files":"Hub のファイルを参照し、選択した Client への送信、共有フォルダー、転送状況を管理します。",agents:"Hub 上の Codex タスクを接続中の Client で実行します。選択した権限、タイムアウト、監査設定が適用されます。"},zh:{hub:"将此电脑作为 LiveDesk Hub 运行。Hub 是统一控制中心,可集中管理 Client 连接、Wall、Control、文件共享和 Agents;网络变化后按下此按钮还会刷新安全连接信息。","switch-to-hub":"将此电脑从 Client 切换为 Hub。LiveDesk 保存新角色、重启同一桌面运行时并打开 Wall;此电脑将停止作为 Client 共享。",client:"让此电脑保持 Client 模式,使活动 Hub 可以继续使用它的屏幕、文件、音频和远程控制。",wall:"集中显示所有已连接 Client 的实时缩略图。可以选择显示器、调整磁贴大小,并在不新建连接的情况下进入 Control。",control:"以完整分辨率打开所选 Client,并通过现有 Hub 会话发送鼠标和键盘输入。","share-files":"浏览 Hub 文件、向所选 Client 发送文件,并管理共享文件夹和传输进度。",agents:"在已连接 Client 上运行由 Hub 托管的 Codex 任务,并遵守所选权限、超时和审计控制。"},"zh-TW":{hub:"將此電腦作為 LiveDesk Hub 運作。Hub 是統一控制中心,可集中管理 Client 連線、Wall、Control、檔案分享與 Agents;網路變更後按下此按鈕也會更新安全連線資訊。","switch-to-hub":"將此電腦從 Client 切換為 Hub。LiveDesk 會儲存新角色、重新啟動同一桌面執行階段並開啟 Wall;此電腦將停止以 Client 身分共享。",client:"讓此電腦維持 Client 模式,使作用中 Hub 可繼續使用它的畫面、檔案、音訊與遠端控制。",wall:"集中顯示所有已連線 Client 的即時縮圖。可選擇顯示器、調整圖塊大小,並在不建立新連線的情況下進入 Control。",control:"以完整解析度開啟所選 Client,並透過現有 Hub 工作階段傳送滑鼠與鍵盤輸入。","share-files":"瀏覽 Hub 檔案、傳送檔案到所選 Client,並管理共享資料夾與傳輸進度。",agents:"在已連線 Client 上執行由 Hub 託管的 Codex 工作,並遵守所選權限、逾時與稽核控制。"},es:{hub:"Usa este equipo como LiveDesk Hub. Hub es el centro de control unificado para conexiones Client, Wall, Control, archivos y Agents; púlsalo tras cambios de red para actualizar el acceso seguro.","switch-to-hub":"Cambia este equipo de Client a Hub. LiveDesk guarda el nuevo rol, reinicia el mismo entorno de escritorio y abre Wall; el equipo deja de compartirse como Client.",client:"Mantiene este equipo en modo Client para que sus pantallas, archivos, audio y control remoto sigan disponibles desde el Hub activo.",wall:"Muestra miniaturas en vivo de todos los Clients conectados. Elige pantalla y tamaño, o entra en Control sin abrir otra conexión.",control:"Abre el Client seleccionado a resolución completa y envía ratón y teclado por la sesión Hub existente.","share-files":"Explora archivos del Hub, envíalos a los Clients seleccionados y administra carpetas compartidas y transferencias.",agents:"Ejecuta tareas Codex alojadas en el Hub sobre Clients conectados, respetando permisos, límites de tiempo y auditoría."},fr:{hub:"Utilise cet ordinateur comme LiveDesk Hub. Hub est le centre de contrôle unifié des connexions Client, de Wall, Control, des fichiers et des Agents ; appuyez après un changement réseau pour actualiser l’accès sécurisé.","switch-to-hub":"Bascule cet ordinateur de Client vers Hub. LiveDesk enregistre le nouveau rôle, redémarre le même environnement de bureau et ouvre Wall ; le partage Client s’arrête.",client:"Maintient cet ordinateur en mode Client afin que ses écrans, fichiers, sons et commandes à distance restent disponibles depuis le Hub actif.",wall:"Affiche les miniatures en direct de tous les Clients connectés. Choisissez l’écran et la taille, ou passez à Control sans nouvelle connexion.",control:"Ouvre le Client sélectionné en pleine résolution et transmet souris et clavier via la session Hub existante.","share-files":"Parcourez les fichiers du Hub, envoyez-les aux Clients sélectionnés et gérez dossiers partagés et transferts.",agents:"Exécute des tâches Codex hébergées par le Hub sur les Clients connectés, selon les permissions, délais et règles d’audit."},de:{hub:"Verwendet diesen Computer als LiveDesk Hub. Hub ist die gemeinsame Steuerzentrale für Client-Verbindungen, Wall, Control, Dateien und Agents; nach Netzwerkänderungen aktualisiert ein Klick den sicheren Zugriff.","switch-to-hub":"Wechselt diesen Computer von Client zu Hub. LiveDesk speichert die neue Rolle, startet dieselbe Desktop-Laufzeit neu und öffnet Wall; die Client-Freigabe endet.",client:"Hält diesen Computer im Client-Modus, damit Bildschirme, Dateien, Audio und Fernsteuerung am aktiven Hub verfügbar bleiben.",wall:"Zeigt Live-Vorschaubilder aller verbundenen Clients. Display und Kachelgröße wählen oder ohne neue Verbindung zu Control wechseln.",control:"Öffnet den gewählten Client in voller Auflösung und sendet Maus- und Tastatureingaben über die bestehende Hub-Sitzung.","share-files":"Dateien auf dem Hub durchsuchen, an gewählte Clients senden sowie Freigaben und Übertragungen verwalten.",agents:"Führt Hub-gehostete Codex-Aufgaben auf verbundenen Clients innerhalb der gewählten Berechtigungen, Zeitlimits und Auditregeln aus."},"pt-BR":{hub:"Usa este computador como LiveDesk Hub. Hub é o centro de controle unificado para conexões Client, Wall, Control, arquivos e Agents; após mudanças de rede, pressione para atualizar o acesso seguro.","switch-to-hub":"Muda este computador de Client para Hub. O LiveDesk salva a nova função, reinicia o mesmo runtime de desktop e abre o Wall; o compartilhamento como Client é encerrado.",client:"Mantém este computador no modo Client para que telas, arquivos, áudio e controle remoto continuem disponíveis no Hub ativo.",wall:"Mostra miniaturas ao vivo de todos os Clients conectados. Escolha a tela e o tamanho ou entre em Control sem criar outra conexão.",control:"Abre o Client selecionado em resolução total e envia mouse e teclado pela sessão Hub existente.","share-files":"Navegue pelos arquivos do Hub, envie para Clients selecionados e gerencie pastas compartilhadas e transferências.",agents:"Executa tarefas Codex hospedadas no Hub em Clients conectados, respeitando permissões, limites de tempo e auditoria."},it:{hub:"Usa questo computer come LiveDesk Hub. Hub è il centro di controllo unificato per connessioni Client, Wall, Control, file e Agents; dopo modifiche di rete, premilo per aggiornare l’accesso sicuro.","switch-to-hub":"Passa questo computer da Client a Hub. LiveDesk salva il nuovo ruolo, riavvia lo stesso runtime desktop e apre Wall; la condivisione come Client termina.",client:"Mantiene questo computer in modalità Client, rendendo schermi, file, audio e controllo remoto disponibili all’Hub attivo.",wall:"Mostra le anteprime live di tutti i Client connessi. Scegli display e dimensione oppure passa a Control senza una nuova connessione.",control:"Apre il Client selezionato a piena risoluzione e invia mouse e tastiera tramite la sessione Hub esistente.","share-files":"Esplora i file dell’Hub, inviali ai Client selezionati e gestisci cartelle condivise e trasferimenti.",agents:"Esegue attività Codex ospitate dall’Hub sui Client connessi rispettando permessi, timeout e controlli di audit."},id:{hub:"Gunakan komputer ini sebagai LiveDesk Hub. Hub adalah pusat kendali terpadu untuk koneksi Client, Wall, Control, file, dan Agents; tekan setelah perubahan jaringan untuk memperbarui akses aman.","switch-to-hub":"Alihkan komputer ini dari Client menjadi Hub. LiveDesk menyimpan peran baru, memulai ulang runtime desktop yang sama, lalu membuka Wall; berbagi sebagai Client berhenti.",client:"Pertahankan komputer ini dalam mode Client agar layar, file, audio, dan kendali jarak jauh tetap tersedia bagi Hub aktif.",wall:"Tampilkan thumbnail live semua Client yang terhubung. Pilih layar dan ukuran tile atau masuk ke Control tanpa koneksi baru.",control:"Buka Client terpilih pada resolusi penuh dan kirim input mouse serta keyboard melalui sesi Hub yang ada.","share-files":"Jelajahi file Hub, kirim ke Client terpilih, serta kelola folder bersama dan progres transfer.",agents:"Jalankan tugas Codex yang di-host Hub pada Client terhubung sesuai izin, batas waktu, dan kontrol audit."},vi:{hub:"Dùng máy tính này làm LiveDesk Hub. Hub là trung tâm điều khiển hợp nhất cho kết nối Client, Wall, Control, tệp và Agents; nhấn sau khi đổi mạng để làm mới quyền truy cập an toàn.","switch-to-hub":"Chuyển máy tính này từ Client sang Hub. LiveDesk lưu vai trò mới, khởi động lại cùng môi trường desktop và mở Wall; việc chia sẻ dưới dạng Client sẽ dừng.",client:"Giữ máy tính này ở chế độ Client để màn hình, tệp, âm thanh và điều khiển từ xa luôn sẵn sàng cho Hub đang hoạt động.",wall:"Hiển thị ảnh thu nhỏ trực tiếp của mọi Client đã kết nối. Chọn màn hình, cỡ ô hoặc vào Control mà không tạo kết nối mới.",control:"Mở Client đã chọn ở độ phân giải đầy đủ và gửi chuột, bàn phím qua phiên Hub hiện có.","share-files":"Duyệt tệp trên Hub, gửi tới Client đã chọn và quản lý thư mục chia sẻ cùng tiến trình truyền.",agents:"Chạy tác vụ Codex do Hub lưu trữ trên các Client đã kết nối trong phạm vi quyền, thời gian chờ và kiểm toán đã chọn."},th:{hub:"ใช้คอมพิวเตอร์เครื่องนี้เป็น LiveDesk Hub โดย Hub คือศูนย์ควบคุมรวมสำหรับการเชื่อมต่อ Client, Wall, Control, ไฟล์ และ Agents และกดหลังเปลี่ยนเครือข่ายเพื่อรีเฟรชการเข้าถึงที่ปลอดภัย","switch-to-hub":"เปลี่ยนคอมพิวเตอร์นี้จาก Client เป็น Hub โดย LiveDesk จะบันทึกบทบาทใหม่ รีสตาร์ต desktop runtime เดิม และเปิด Wall พร้อมหยุดแชร์ในฐานะ Client",client:"ให้คอมพิวเตอร์นี้อยู่ในโหมด Client เพื่อให้ Hub ที่ใช้งานเข้าถึงหน้าจอ ไฟล์ เสียง และการควบคุมระยะไกลได้ต่อเนื่อง",wall:"แสดงภาพสดแบบย่อของ Client ที่เชื่อมต่อทั้งหมด เลือกจอและขนาด tile หรือเข้า Control ได้โดยไม่เปิดการเชื่อมต่อใหม่",control:"เปิด Client ที่เลือกแบบความละเอียดเต็ม และส่งเมาส์กับคีย์บอร์ดผ่าน session ของ Hub ที่มีอยู่","share-files":"เรียกดูไฟล์บน Hub ส่งไปยัง Client ที่เลือก และจัดการโฟลเดอร์แชร์กับความคืบหน้าการโอน",agents:"เรียกใช้งาน Codex ที่โฮสต์บน Hub กับ Client ที่เชื่อมต่อ ภายใต้สิทธิ์ timeout และการตรวจสอบที่เลือก"},hi:{hub:"इस कंप्यूटर को LiveDesk Hub के रूप में उपयोग करें। Hub, Client कनेक्शन, Wall, Control, फ़ाइल और Agents का एकीकृत नियंत्रण केंद्र है; नेटवर्क बदलने के बाद सुरक्षित पहुँच ताज़ा करने के लिए इसे दबाएँ।","switch-to-hub":"इस कंप्यूटर को Client से Hub में बदलता है। LiveDesk नई भूमिका सहेजता है, उसी desktop runtime को restart करके Wall खोलता है और Client sharing रोक देता है।",client:"इस कंप्यूटर को Client मोड में रखता है ताकि इसकी स्क्रीन, फ़ाइलें, ऑडियो और remote control सक्रिय Hub पर उपलब्ध रहें।",wall:"सभी जुड़े Clients के live thumbnail दिखाता है। स्क्रीन और tile आकार चुनें या नया connection खोले बिना Control में जाएँ।",control:"चुने हुए Client को पूर्ण resolution में खोलता है और मौजूदा Hub session से mouse तथा keyboard input भेजता है।","share-files":"Hub की फ़ाइलें देखें, चुने हुए Clients को भेजें और shared folders तथा transfer progress प्रबंधित करें।",agents:"चुनी हुई permissions, timeout और audit controls के भीतर जुड़े Clients पर Hub-hosted Codex tasks चलाता है।"},ar:{hub:"استخدم هذا الكمبيوتر بوصفه LiveDesk Hub. يمثّل Hub مركز التحكم الموحّد لاتصالات Client وWall وControl والملفات وAgents؛ اضغط عليه بعد تغييرات الشبكة لتحديث الوصول الآمن.","switch-to-hub":"يحوّل هذا الكمبيوتر من Client إلى Hub. يحفظ LiveDesk الدور الجديد ويعيد تشغيل بيئة سطح المكتب نفسها ويفتح Wall، ويتوقف الجهاز عن المشاركة كـ Client.",client:"يبقي هذا الكمبيوتر في وضع Client لتظل شاشاته وملفاته وصوته والتحكم عن بعد متاحة من Hub النشط.",wall:"يعرض صورا حية مصغرة لكل Clients المتصلين. اختر الشاشة وحجم البلاطات أو انتقل إلى Control من دون اتصال جديد.",control:"يفتح Client المحدد بالدقة الكاملة ويرسل إدخال الماوس ولوحة المفاتيح عبر جلسة Hub الحالية.","share-files":"استعرض ملفات Hub وأرسلها إلى Clients المحددين وأدر المجلدات المشتركة وتقدم النقل.",agents:"يشغّل مهام Codex المستضافة على Hub في Clients المتصلين ضمن الصلاحيات والمهل وضوابط التدقيق المحددة."},tr:{hub:"Bu bilgisayarı LiveDesk Hub olarak kullanır. Hub; Client bağlantıları, Wall, Control, dosyalar ve Agents için birleşik kontrol merkezidir; ağ değişikliklerinden sonra güvenli erişimi yenilemek için basın.","switch-to-hub":"Bu bilgisayarı Client rolünden Hub rolüne geçirir. LiveDesk yeni rolü kaydeder, aynı masaüstü runtime’ını yeniden başlatıp Wall’u açar; Client paylaşımı durur.",client:"Bu bilgisayarı Client modunda tutar; ekran, dosya, ses ve uzaktan kontrol özellikleri etkin Hub tarafından kullanılabilir kalır.",wall:"Bağlı tüm Client ekranlarının canlı küçük görüntülerini gösterir. Ekran ve kutu boyutunu seçin veya yeni bağlantı açmadan Control’e geçin.",control:"Seçili Client’ı tam çözünürlükte açar ve mevcut Hub oturumu üzerinden fare ile klavye girdisi gönderir.","share-files":"Hub dosyalarını gezin, seçili Client’lara gönderin ve paylaşılan klasörlerle aktarım ilerlemesini yönetin.",agents:"Hub üzerinde barındırılan Codex görevlerini seçili izinler, zaman aşımları ve denetim kontrolleri içinde bağlı Client’larda çalıştırır."}};function np(n){const a=n?[n]:typeof navigator>"u"?["en"]:navigator.languages?.length?navigator.languages:[navigator.language];for(const r of a){const l=String(r||"").trim(),c=l.toLowerCase();if(!c)continue;if(c.startsWith("zh-tw")||c.startsWith("zh-hk"))return"zh-TW";if(c.startsWith("zh"))return"zh";if(c.startsWith("pt"))return"pt-BR";const d=c.split("-")[0];if(Mh[l])return l;if(Mh[d])return d}return"en"}function rf(n,a){const r=np(a);return Mh[r]?.[n]||cb[n]}function Th(n,a,r){return`${n}
|
|
11
|
-
${rf(a,r)}`}const ub={eyebrow:"Change computer role",title:"Switch this computer to Hub?",description:"LiveDesk will stop sharing this computer as a Client, save the Hub role, restart the local runtime, and open Wall in this same window.",restartNotice:"Remote streams from this computer will end while LiveDesk restarts.",cancel:"Cancel",confirm:"Switch to Hub",closeLabel:"Close Hub switch confirmation"},uC={en:ub,ko:{eyebrow:"컴퓨터 역할 변경",title:"이 컴퓨터를 Hub로 전환하시겠습니까?",description:"이 컴퓨터의 Client 공유를 중지하고 Hub 역할을 저장한 뒤 로컬 런타임을 재시작하여 같은 창에서 Wall을 엽니다.",restartNotice:"LiveDesk가 재시작되는 동안 이 컴퓨터의 원격 스트림이 종료됩니다.",cancel:"취소",confirm:"Hub로 전환",closeLabel:"Hub 전환 확인 닫기"},ja:{eyebrow:"コンピューターの役割を変更",title:"このコンピューターを Hub に切り替えますか?",description:"このコンピューターの Client 共有を停止し、Hub の役割を保存してローカルランタイムを再起動し、同じウィンドウで Wall を開きます。",restartNotice:"LiveDesk の再起動中、このコンピューターのリモートストリームは終了します。",cancel:"キャンセル",confirm:"Hub に切り替える",closeLabel:"Hub 切り替え確認を閉じる"},zh:{eyebrow:"更改电脑角色",title:"将此电脑切换为 Hub?",description:"LiveDesk 将停止此电脑的 Client 共享,保存 Hub 角色,重启本地运行时,并在同一窗口中打开 Wall。",restartNotice:"LiveDesk 重启期间,此电脑的远程流将会结束。",cancel:"取消",confirm:"切换为 Hub",closeLabel:"关闭 Hub 切换确认"},"zh-TW":{eyebrow:"變更電腦角色",title:"要將此電腦切換為 Hub 嗎?",description:"LiveDesk 將停止此電腦的 Client 分享、儲存 Hub 角色、重新啟動本機執行階段,並在同一視窗中開啟 Wall。",restartNotice:"LiveDesk 重新啟動期間,此電腦的遠端串流將會結束。",cancel:"取消",confirm:"切換為 Hub",closeLabel:"關閉 Hub 切換確認"},es:{eyebrow:"Cambiar función del equipo",title:"¿Cambiar este equipo a Hub?",description:"LiveDesk dejará de compartir este equipo como Client, guardará la función Hub, reiniciará el entorno local y abrirá Wall en esta misma ventana.",restartNotice:"Los streams remotos de este equipo terminarán mientras LiveDesk se reinicia.",cancel:"Cancelar",confirm:"Cambiar a Hub",closeLabel:"Cerrar confirmación de cambio a Hub"},fr:{eyebrow:"Changer le rôle de l’ordinateur",title:"Basculer cet ordinateur vers Hub ?",description:"LiveDesk arrêtera le partage Client de cet ordinateur, enregistrera le rôle Hub, redémarrera le runtime local et ouvrira Wall dans cette même fenêtre.",restartNotice:"Les flux distants de cet ordinateur prendront fin pendant le redémarrage de LiveDesk.",cancel:"Annuler",confirm:"Basculer vers Hub",closeLabel:"Fermer la confirmation de bascule vers Hub"},de:{eyebrow:"Computerrolle ändern",title:"Diesen Computer auf Hub umstellen?",description:"LiveDesk beendet die Client-Freigabe dieses Computers, speichert die Hub-Rolle, startet die lokale Laufzeit neu und öffnet Wall im selben Fenster.",restartNotice:"Die Remote-Streams dieses Computers enden während des LiveDesk-Neustarts.",cancel:"Abbrechen",confirm:"Auf Hub umstellen",closeLabel:"Bestätigung für Hub-Wechsel schließen"},"pt-BR":{eyebrow:"Alterar função do computador",title:"Mudar este computador para Hub?",description:"O LiveDesk interromperá o compartilhamento deste computador como Client, salvará a função Hub, reiniciará o runtime local e abrirá o Wall nesta mesma janela.",restartNotice:"Os streams remotos deste computador serão encerrados enquanto o LiveDesk reinicia.",cancel:"Cancelar",confirm:"Mudar para Hub",closeLabel:"Fechar confirmação de mudança para Hub"},it:{eyebrow:"Cambia ruolo del computer",title:"Passare questo computer a Hub?",description:"LiveDesk interromperà la condivisione Client di questo computer, salverà il ruolo Hub, riavvierà il runtime locale e aprirà Wall nella stessa finestra.",restartNotice:"Gli stream remoti di questo computer termineranno durante il riavvio di LiveDesk.",cancel:"Annulla",confirm:"Passa a Hub",closeLabel:"Chiudi la conferma del passaggio a Hub"},id:{eyebrow:"Ubah peran komputer",title:"Alihkan komputer ini menjadi Hub?",description:"LiveDesk akan menghentikan berbagi komputer ini sebagai Client, menyimpan peran Hub, memulai ulang runtime lokal, lalu membuka Wall di jendela yang sama.",restartNotice:"Stream jarak jauh dari komputer ini akan berakhir saat LiveDesk dimulai ulang.",cancel:"Batal",confirm:"Alihkan ke Hub",closeLabel:"Tutup konfirmasi peralihan Hub"},vi:{eyebrow:"Đổi vai trò máy tính",title:"Chuyển máy tính này thành Hub?",description:"LiveDesk sẽ dừng chia sẻ máy tính này dưới dạng Client, lưu vai trò Hub, khởi động lại runtime cục bộ và mở Wall trong cùng cửa sổ.",restartNotice:"Các luồng từ xa của máy tính này sẽ kết thúc trong khi LiveDesk khởi động lại.",cancel:"Hủy",confirm:"Chuyển sang Hub",closeLabel:"Đóng xác nhận chuyển sang Hub"},th:{eyebrow:"เปลี่ยนบทบาทคอมพิวเตอร์",title:"เปลี่ยนคอมพิวเตอร์เครื่องนี้เป็น Hub หรือไม่",description:"LiveDesk จะหยุดแชร์คอมพิวเตอร์เครื่องนี้ในฐานะ Client บันทึกบทบาท Hub รีสตาร์ทรันไทม์ภายในเครื่อง และเปิด Wall ในหน้าต่างเดิม",restartNotice:"สตรีมระยะไกลจากคอมพิวเตอร์เครื่องนี้จะสิ้นสุดลงระหว่างที่ LiveDesk รีสตาร์ท",cancel:"ยกเลิก",confirm:"เปลี่ยนเป็น Hub",closeLabel:"ปิดการยืนยันการเปลี่ยนเป็น Hub"},hi:{eyebrow:"कंप्यूटर की भूमिका बदलें",title:"इस कंप्यूटर को Hub में बदलें?",description:"LiveDesk इस कंप्यूटर की Client साझेदारी बंद करेगा, Hub भूमिका सहेजेगा, स्थानीय रनटाइम पुनः आरंभ करेगा और इसी विंडो में Wall खोलेगा।",restartNotice:"LiveDesk के पुनः आरंभ होने के दौरान इस कंप्यूटर की रिमोट स्ट्रीम समाप्त हो जाएँगी।",cancel:"रद्द करें",confirm:"Hub में बदलें",closeLabel:"Hub परिवर्तन की पुष्टि बंद करें"},ar:{eyebrow:"تغيير دور الكمبيوتر",title:"هل تريد تحويل هذا الكمبيوتر إلى Hub؟",description:"سيوقف LiveDesk مشاركة هذا الكمبيوتر كـ Client، ويحفظ دور Hub، ويعيد تشغيل وقت التشغيل المحلي، ثم يفتح Wall في النافذة نفسها.",restartNotice:"ستنتهي التدفقات البعيدة من هذا الكمبيوتر أثناء إعادة تشغيل LiveDesk.",cancel:"إلغاء",confirm:"التحويل إلى Hub",closeLabel:"إغلاق تأكيد التحويل إلى Hub"},tr:{eyebrow:"Bilgisayar rolünü değiştir",title:"Bu bilgisayar Hub rolüne geçirilsin mi?",description:"LiveDesk bu bilgisayarın Client paylaşımını durdurur, Hub rolünü kaydeder, yerel çalışma zamanını yeniden başlatır ve Wall’u aynı pencerede açar.",restartNotice:"LiveDesk yeniden başlatılırken bu bilgisayarın uzak akışları sona erer.",cancel:"İptal",confirm:"Hub’a geçir",closeLabel:"Hub geçişi onayını kapat"}};function dC(n){const a=np(n);return uC[a]||ub}const fC=[{id:"docs",label:"Doc",icon:af},{id:"support",label:"Support",icon:Kc},{id:"pricing",label:"Pricing",icon:Do},{id:"settings",label:"Settings",icon:Wy}],Cx=[0,1e3,2e3,5e3,1e4,2e4,3e4];function mC(){return typeof window>"u"?"":window.location.port==="5179"?window.location.origin:"http://127.0.0.1:5179"}async function Fc(n,a=!1){const r=a?"":sessionStorage.getItem("livedesk.client.csrf");if(r)return r;const l=await fetch(`${n}/api/runtime/status`,{cache:"no-store"}),c=await l.json().catch(()=>({}));if(!l.ok)throw new Error(c.error||`Client runtime returned HTTP ${l.status}.`);const d=String(c.csrfToken||"");return d&&sessionStorage.setItem("livedesk.client.csrf",d),d}function Eh(n){return`${Math.max(0,Math.min(100,Number(n||0))).toFixed(0)}%`}function Xm(n){return Number.isFinite(n)?`${Math.max(0,Math.min(100,Number(n))).toFixed(0)}%`:"—"}function db(n){return Number.isFinite(n)?Eh(Number(n)):"0%"}function _l(n){const a=Number(n);return!Number.isFinite(a)||a<0?"—":a>=1024**4?`${(a/1024**4).toFixed(a>=10*1024**4?0:1)} TB`:a>=1024**3?`${(a/1024**3).toFixed(a>=10*1024**3?0:1)} GB`:`${(a/1024**2).toFixed(0)} MB`}function jx(n){const a=Math.max(0,Number(n||0));return a>=1024**3?`${(a/1024**3).toFixed(1)} GB/s`:a>=1024**2?`${(a/1024**2).toFixed(1)} MB/s`:a>=1024?`${(a/1024).toFixed(1)} KB/s`:`${a.toFixed(0)} B/s`}function hC(n,a){const r=Number(n||0)/1073741824,l=Number(a||0)/1024**3;return l>0?`${r.toFixed(1)} / ${l.toFixed(1)} GB`:"Checking..."}function pC(n,a){return!Number.isFinite(a)||Number(a)<=0?"Dedicated memory unavailable":Number.isFinite(n)?`${_l(n)} / ${_l(a)}`:`${_l(a)} available`}function gC(n){const a=Math.max(0,Math.floor(Number(n||0)/60)),r=Math.floor(a/1440),l=Math.floor(a%1440/60),c=a%60;return r>0?`${r}d ${l}h`:l>0?`${l}h ${c}m`:`${c}m`}function Md({icon:n,label:a,value:r,detail:l,percent:c}){return s.jsxs("article",{className:"client-resource-metric",children:[s.jsxs("div",{className:"client-resource-metric-head",children:[s.jsx(n,{size:17}),s.jsx("span",{children:a}),s.jsx("strong",{children:r})]}),s.jsx("small",{title:l,children:l}),s.jsx("i",{"aria-hidden":"true",children:s.jsx("b",{style:{width:db(c)}})})]})}function vC(n){const a=n?.user.user_metadata||{},r=a.full_name||a.name||a.preferred_username||n?.user.email||n?.user.id||"Account";return String(r).trim()||"Account"}function xC(n){const a=n?.user.user_metadata||{},r=a.avatar_url||a.picture;return typeof r=="string"?r.trim():""}function yC({page:n,status:a}){const l={docs:{label:"DOC",title:"Using this computer",body:"This computer connects to its assigned Hub automatically. Keep LiveDesk running and manage screens, files, and remote control from the Hub."},pricing:{label:"PRICING",title:"LiveDesk plans",body:"Plans are based on how many computers the Hub manages. This Client computer does not need a separate subscription or setup."},settings:{label:"SETTINGS",title:"Computer preferences",body:"LiveDesk keeps the verified sign-in on this computer and reconnects to the assigned Hub automatically."}}[n];return s.jsxs("section",{className:"client-service-page",children:[s.jsx("span",{className:"client-unified-section-label",children:l.label}),s.jsx("h2",{children:l.title}),s.jsx("p",{children:l.body}),s.jsxs("div",{className:"client-service-page-card",children:[n==="docs"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Automatic connection"}),s.jsx("span",{children:"Start LiveDesk. This computer signs in, finds the Hub, and becomes available without another action."})]}),n==="pricing"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"One plan, managed at the Hub"}),s.jsx("span",{children:"Computer access follows the account and plan used by the Hub."})]}),n==="settings"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Saved sign-in"}),s.jsx("span",{children:a?.auth?.persisted?"Enabled on this computer":"Sign in once to enable automatic reconnection"})]})]})]})}function bC({session:n,status:a,pin:r,error:l,roleChangeMessage:c,roleChangeBusy:d,onSignIn:m,onPinChange:p,onSubmitPin:g,onSwitchToHub:v}){const b=a?.connectionState==="connected",y=a?.system?.memoryTotalBytes?Number(a.system.memoryUsedBytes||0)/a.system.memoryTotalBytes*100:0,w=a?.system?.gpus||[],S=w.find(H=>Number.isFinite(H.usagePercent)||Number.isFinite(H.memoryTotalBytes))||w[0],j=Number.isFinite(S?.usagePercent)?Number(S?.usagePercent):null,N=Number.isFinite(S?.memoryTotalBytes)&&Number(S?.memoryTotalBytes)>0&&Number.isFinite(S?.memoryUsedBytes)?Number(S?.memoryUsedBytes)/Number(S?.memoryTotalBytes)*100:null,M=a?.system?.disks||[],k=a?.system?.network,E=k?.interfaces||[],R=[...new Set(E.map(H=>H.name).filter(Boolean))],U=E.map(H=>H.address).filter(Boolean);return s.jsxs("section",{className:"client-home-page",children:[s.jsxs("header",{className:"client-home-heading",children:[s.jsxs("div",{children:[s.jsx("p",{className:"client-unified-eyebrow",children:"THIS COMPUTER"}),s.jsx("h2",{children:a?.deviceName||"This Computer"})]}),s.jsxs("span",{className:`client-unified-role-chip ${b?"connected":""}`,children:[s.jsx(en,{size:15})," ",b?"Online":"Connecting"]})]}),s.jsxs("div",{className:"client-home-layout",children:[s.jsxs("section",{className:"client-main-surface","aria-label":"Client computer",children:[s.jsxs("div",{className:"client-main-surface-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"SYSTEM STATUS"}),s.jsx("strong",{children:"Hardware at a glance"})]}),s.jsxs("small",{children:[s.jsx(Ky,{size:14})," Uptime ",gC(a?.system?.uptimeSeconds)]})]}),s.jsxs("div",{className:"client-system-dashboard",children:[s.jsxs("section",{className:"client-performance-panel","aria-label":"Performance",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"PERFORMANCE"}),s.jsx("strong",{children:"Live resources"})]}),s.jsx("small",{children:"Live updates"})]}),s.jsxs("div",{className:"client-live-metrics",children:[s.jsx(Md,{icon:Qy,label:"CPU",value:Eh(a?.system?.cpuUsagePercent),detail:"Current processor usage",percent:a?.system?.cpuUsagePercent}),s.jsx(Md,{icon:GS,label:"Memory",value:Eh(y),detail:hC(a?.system?.memoryUsedBytes,a?.system?.memoryTotalBytes),percent:y}),s.jsx(Md,{icon:VS,label:"GPU",value:Xm(j),detail:S?.name||(a?.system?.hardwareCollecting?"Detecting graphics hardware…":"Graphics usage unavailable"),percent:j}),s.jsx(Md,{icon:Ur,label:"VRAM",value:Xm(N),detail:pC(S?.memoryUsedBytes,S?.memoryTotalBytes),percent:N})]})]}),s.jsxs("section",{className:"client-storage-panel","aria-label":"Local storage",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"STORAGE"}),s.jsx("strong",{children:"Local drives"})]}),s.jsx("small",{children:M.length>0?`${M.length} ${M.length===1?"drive":"drives"}`:a?.system?.hardwareCollecting?"Detecting…":"Unavailable"})]}),s.jsxs("div",{className:"client-disk-list",children:[M.map(H=>s.jsxs("article",{className:"client-disk-row",children:[s.jsxs("div",{className:"client-disk-row-head",children:[s.jsxs("span",{children:[s.jsx(Ll,{size:16}),s.jsx("strong",{children:H.mount||"Disk"}),s.jsx("small",{children:H.name||"Local disk"})]}),s.jsx("strong",{children:Xm(H.usedPercent)})]}),s.jsxs("small",{children:[_l(H.freeBytes)," free · ",_l(H.totalBytes)," total"]}),s.jsx("i",{"aria-hidden":"true",children:s.jsx("b",{style:{width:db(H.usedPercent)}})})]},`${H.mount}-${H.name||""}`)),M.length===0&&s.jsxs("div",{className:"client-disk-empty",children:[s.jsx(Ll,{size:18}),s.jsx("span",{children:a?.system?.hardwareCollecting?"Detecting local drives…":"Storage information is not available."})]})]})]}),s.jsxs("section",{className:"client-network-panel","aria-label":"Network activity",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"NETWORK"}),s.jsx("strong",{children:"Live traffic"})]}),s.jsx("small",{children:R.length>0?R.join(", "):"Detecting adapter"})]}),s.jsxs("div",{className:"client-network-live",children:[s.jsxs("div",{className:"client-network-adapter",children:[s.jsx(Il,{size:18}),s.jsxs("span",{children:[s.jsx("strong",{children:R.join(", ")||"Network"}),s.jsx("small",{children:U.join(" / ")||"Checking active connection"})]})]}),s.jsxs("div",{className:"client-network-rate download",children:[s.jsx(WS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Receive"}),s.jsx("strong",{children:jx(k?.receiveBytesPerSecond)})]})]}),s.jsxs("div",{className:"client-network-rate upload",children:[s.jsx(YS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Send"}),s.jsx("strong",{children:jx(k?.sendBytesPerSecond)})]})]}),s.jsxs("small",{className:"client-network-total",children:["Total ",_l(k?.receivedBytes)," received / ",_l(k?.sentBytes)," sent"]})]})]})]})]}),s.jsxs("aside",{className:"client-connection-panel",children:[s.jsx("span",{className:"client-unified-section-label",children:"LIVEDESK SERVICES"}),s.jsx("h3",{children:b?"Connected to the Hub":a?.authenticated?"Finding the Hub":"Connect this computer"}),b?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"client-unified-copy",children:"This computer is available from the LiveDesk Hub."}),s.jsxs("div",{className:"client-service-status-list",children:[s.jsxs("div",{children:[s.jsx(en,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Screen sharing"}),s.jsx("small",{children:a?.permissions?.screenCapture?"Active":"Waiting"})]})]}),s.jsxs("div",{children:[s.jsx(Lt,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Remote control"}),s.jsx("small",{children:a?.permissions?.remoteInput?"Available":"Unavailable"})]})]}),s.jsxs("div",{children:[s.jsx(Lo,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"File delivery"}),s.jsx("small",{children:a?.permissions?.files?"Ready to receive":"Unavailable"})]})]}),s.jsxs("div",{children:[s.jsx(cn,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Computer audio"}),s.jsx("small",{children:a?.permissions?.audio?"Available":"Unavailable"})]})]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"client-unified-copy",children:a?.authenticated?"LiveDesk is checking the registered Hub endpoints. A temporary Hub PIN can be used as a fallback.":"Sign in once on this computer. LiveDesk saves the verified session, finds the Hub, and starts screen sharing automatically."}),!n&&!a?.authenticated?s.jsxs("button",{className:"client-unified-primary",type:"button",onClick:m,children:[s.jsx(zl,{size:16})," Sign in with Google"]}):s.jsxs("p",{className:"client-unified-success",children:[s.jsx(Hn,{size:16})," Signed in as ",n?.user.email||n?.user.id||a?.userEmail||a?.userId||"saved account"]}),s.jsxs("div",{className:"client-unified-pin-row",children:[s.jsx(_o,{size:16}),s.jsx("input",{value:r,onChange:H=>p(H.target.value),placeholder:"6-digit Hub PIN",inputMode:"numeric","aria-label":"6-digit Hub PIN"}),s.jsx("button",{className:"client-unified-secondary",type:"button",onClick:g,disabled:r.length!==6,children:"Connect"})]})]}),(l||a?.lastError)&&s.jsxs("p",{className:"client-unified-error",role:"alert",children:[s.jsx(Xy,{size:15})," ",l||a?.lastError]}),c&&s.jsx("p",{className:"client-unified-success",children:c}),s.jsxs("button",{className:"client-unified-secondary full client-hub-switch-trigger",type:"button",onClick:v,disabled:d||!a?.authenticated,children:[s.jsx(Ur,{size:16})," ",d?"Switching to Hub…":"Switch this computer to Hub"]})]})]})]})}function wC(){const[n,a]=u.useState(null),[r,l]=u.useState(null),[c,d]=u.useState(!1),[m,p]=u.useState(""),[g,v]=u.useState(""),[b,y]=u.useState(""),[w,S]=u.useState(!1),[j,N]=u.useState(!1),[M,k]=u.useState("computer"),[E,R]=u.useState(!1),U=u.useRef(null),H=u.useRef(null),W=u.useRef(!1),_=u.useRef(!1),L=u.useRef(!1),le=u.useRef(0),q=u.useMemo(mC,[]),te=u.useMemo(()=>vC(r),[r]),K=u.useMemo(()=>xC(r),[r]),ne=te.slice(0,1).toUpperCase()||"L",ce=u.useCallback(async()=>{if(v(""),window.liveDesk?.auth?.signInWithGoogle){const ie=await window.liveDesk.auth.signInWithGoogle();return ie?.ok===!1?(v(ie.error||"LiveDesk could not open the system browser for Google sign-in."),!1):!0}return window.location.assign(`${q}/auth/google`),!0},[q]),V=u.useCallback(async()=>{L.current||(L.current=!0,v("Your saved Google sign-in is incomplete. LiveDesk is reopening sign-in once to repair it."),await ct.auth.signOut({scope:"local"}).catch(()=>{}),l(null),await ce()||(L.current=!1))},[ce]),O=u.useCallback(async ie=>{const Q=wx(ie);if(Q)throw new Error(Q);if(W.current)return!1;W.current=!0;try{const Ie=await window.liveDesk?.auth?.persistSession?.(ie);if(Ie?.ok===!1)throw new Error(Ie.error||"LiveDesk could not validate the desktop session.");for(let Oe=0;Oe<2;Oe+=1){const ae=await Fc(q,Oe>0),ke=await fetch(`${q}/api/auth/session`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":ae},signal:AbortSignal.timeout(1e4),body:JSON.stringify({accessToken:ie.access_token,refreshToken:ie.refresh_token,expiresAt:ie.expires_at,user:{id:ie.user.id,email:ie.user.email}})}),je=await ke.json().catch(()=>({}));if(ke.status===403&&Oe===0){sessionStorage.removeItem("livedesk.client.csrf");continue}if(!ke.ok)throw new Error(je.error||`Client runtime returned HTTP ${ke.status}.`);return v(""),!0}throw new Error("Client runtime rejected the session transfer.")}finally{W.current=!1}},[q]),Y=u.useCallback(async()=>{try{const ie=await fetch(`${q}/api/client/status`,{cache:"no-store"}),Q=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(Q.error||`Client runtime returned HTTP ${ie.status}.`);if(Q.csrfToken&&sessionStorage.setItem("livedesk.client.csrf",Q.csrfToken),String(Q.role||"").toLowerCase()==="hub")throw new Error("This computer is assigned to the Hub role.");a(Q)}catch(ie){v(ie instanceof Error?ie.message:String(ie))}},[q]);u.useEffect(()=>{Y();const ie=window.setInterval(()=>{Y()},2e3);return()=>window.clearInterval(ie)},[Y]);const X=u.useCallback(async()=>{const ie=Date.now();if(!(!n?.authenticated||n.connectionState==="connected"||!["waiting","reconnecting"].includes(String(n.agent?.state||""))||ie-le.current<4e3)){le.current=ie;try{const Q=await fetch(`${q}/api/client/reconnect`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({onlyIfWaiting:!0,reason:"app-active"})});if(!Q.ok)throw new Error(`Client reconnect returned HTTP ${Q.status}.`);await Y()}catch(Q){v(Q instanceof Error?Q.message:String(Q))}}},[q,Y,n]);u.useEffect(()=>{const ie=()=>{X()},Q=()=>{X()},Ie=()=>{document.visibilityState==="visible"&&X()};return window.addEventListener("online",ie),window.addEventListener("focus",Q),document.addEventListener("visibilitychange",Ie),()=>{window.removeEventListener("online",ie),window.removeEventListener("focus",Q),document.removeEventListener("visibilitychange",Ie)}},[X]),u.useEffect(()=>{if(!c||!n||!r?.access_token||n.authenticated)return;if(wx(r)==="refresh-token-required"){V().catch(ae=>{L.current=!1,v(ae instanceof Error?ae.message:String(ae))});return}let ie=!1,Q,Ie=0;const Oe=async()=>{if(ie)return;try{const ke=await O(r);if(await Y(),ke)return}catch(ke){v(ke instanceof Error?ke.message:String(ke))}if(ie)return;const ae=Cx[Math.min(Ie,Cx.length-1)];Ie+=1,Q=window.setTimeout(()=>{Oe()},ae)};return Oe(),()=>{ie=!0,Q!==void 0&&window.clearTimeout(Q)}},[c,Y,V,r,n,O]),u.useEffect(()=>{const ie=new URLSearchParams(window.location.search),Q=ie.get("auth_error");if(!Q)return;v(Q),ie.delete("auth_error");const Ie=ie.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${Ie?`?${Ie}`:""}${window.location.hash}`)},[]),u.useEffect(()=>{let ie=!0;if(!window.liveDesk?.auth)return l(null),d(!0),Y(),()=>{ie=!1};const Q=window.liveDesk?.auth?.onComplete?.(Oe=>{Oe.ok&&Oe.session?ct.auth.setSession(Oe.session).catch(ae=>v(ae instanceof Error?ae.message:String(ae))):Oe.error&&v(Oe.error)});(async()=>{try{const Oe=window.liveDesk?.auth?.getSession?await window.liveDesk.auth.getSession():await ct.auth.getSession();if(!ie)return;const ae=rb(Oe);l(ae),Y()}catch(Oe){ie&&v(Oe instanceof Error?Oe.message:String(Oe))}finally{ie&&d(!0)}})();const{data:Ie}=ct.auth.onAuthStateChange((Oe,ae)=>{ie&&(l(ae),d(!0),Y())});return()=>{ie=!1,Q?.(),Ie.subscription.unsubscribe()}},[Y]),u.useEffect(()=>{if(!c||!n||_.current||L.current||r||n.authenticated)return;const ie=new URLSearchParams(window.location.search);if(!ie.has("livedesk_launch"))return;_.current=!0,ie.delete("livedesk_launch");const Q=ie.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${Q?`?${Q}`:""}${window.location.hash}`),ce().catch(Ie=>v(Ie instanceof Error?Ie.message:String(Ie)))},[c,r,ce,n]);const P=async()=>{R(!1),window.liveDesk?.auth?.persistSession?(await ct.auth.signOut(),(await window.liveDesk.auth.persistSession(null))?.runtimeCleared===!1&&v("Signed out locally. The LiveDesk runtime could not be reached to clear its session.")):await fetch(`${q}/api/auth/session`,{method:"DELETE",headers:{"X-LiveDesk-CSRF":await Fc(q)}}).catch(()=>{}),l(null),await Y()};u.useEffect(()=>{if(!E)return;const ie=Ie=>{Ie.target instanceof Element&&Ie.target.closest(".account-popover, .rail-account")||R(!1)},Q=Ie=>{Ie.key==="Escape"&&R(!1)};return window.addEventListener("pointerdown",ie),window.addEventListener("keydown",Q),()=>{window.removeEventListener("pointerdown",ie),window.removeEventListener("keydown",Q)}},[E]);const oe=u.useCallback((ie=!0)=>{w||(N(!1),ie&&window.requestAnimationFrame(()=>H.current?.focus()))},[w]),we=u.useCallback(()=>{w||!n?.authenticated||(H.current=document.activeElement instanceof HTMLElement?document.activeElement:null,y(""),N(!0))},[w,n?.authenticated]);u.useEffect(()=>{if(!j)return;const ie=window.requestAnimationFrame(()=>U.current?.focus()),Q=Oe=>{Oe.target instanceof Element&&Oe.target.closest(".client-hub-switch-popover, .client-hub-switch-trigger")||oe(!1)},Ie=Oe=>{Oe.key==="Escape"&&oe()};return window.addEventListener("pointerdown",Q),window.addEventListener("keydown",Ie),()=>{window.cancelAnimationFrame(ie),window.removeEventListener("pointerdown",Q),window.removeEventListener("keydown",Ie)}},[oe,j]);const J=async()=>{v("");try{const ie=await fetch(`${q}/api/client/pin`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({pin:m})}),Q=await ie.json().catch(()=>({}));if(!ie.ok||Q?.ok===!1)throw new Error(Q?.error||"PIN could not be accepted.");p(""),await Y()}catch(ie){v(ie instanceof Error?ie.message:String(ie))}},B=async()=>{N(!1),S(!0),y(""),v("");try{const ie=await fetch(`${q}/api/runtime/switch-role`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({role:"hub"})}),Q=await ie.json().catch(()=>({}));if(!ie.ok||Q?.ok===!1)throw new Error(Q?.error||`Role change failed with HTTP ${ie.status}.`);y("Hub role accepted. LiveDesk is restarting this computer with the Hub Wall.");const Ie=Number(n?.runtimePid||0);await lb({baseUrl:q,targetRole:"hub",previousRuntimePid:Ie,allowedStates:["running"]}),window.location.reload()}catch(ie){v(ie instanceof Error?ie.message:String(ie)),S(!1)}},pe=!!(n?.authenticated||r),ge=u.useMemo(()=>np(),[]),xe=rf("switch-to-hub",ge),Ae=rf("client",ge),_e=dC(ge);return s.jsxs("main",{className:"app-shell client-unified-shell",children:[s.jsxs("aside",{className:"tool-rail","aria-label":"LiveDesk Client tools",children:[s.jsx("div",{className:"rail-brand",title:"LiveDesk",children:s.jsx(ob,{size:25})}),s.jsx("nav",{className:"rail-tools","aria-label":"Client navigation",children:s.jsxs("div",{className:"client-main-tool-slot",children:[s.jsxs("button",{className:"rail-tool client-main-tool client-hub-tool client-hub-switch-trigger accent-blue",type:"button",onClick:we,disabled:w||!n?.authenticated,"aria-busy":w,"aria-expanded":j,"aria-haspopup":"dialog","aria-controls":j?"client-hub-switch-popover":void 0,"aria-label":`Hub. ${xe}`,"data-tooltip":j?void 0:Th("Hub","switch-to-hub",ge),children:[s.jsx(Ur,{size:19}),s.jsx("span",{children:w?"Switching…":"Hub"})]}),s.jsxs("button",{className:`rail-tool client-main-tool accent-blue ${M==="computer"?"active":""}`,type:"button",onClick:()=>k("computer"),"aria-current":M==="computer"?"page":void 0,"aria-label":`Client. ${Ae}`,"data-tooltip":Th("Client","client",ge),children:[s.jsx(en,{size:19}),s.jsx("span",{children:"Client"})]})]})}),s.jsxs("div",{className:"rail-footer",children:[fC.map(ie=>{const Q=ie.icon;return s.jsxs("button",{className:`rail-tool compact ${M===ie.id?"active":""}`,type:"button",onClick:()=>k(ie.id),title:ie.label,children:[s.jsx(Q,{size:18}),s.jsx("span",{children:ie.label})]},ie.id)}),s.jsxs("button",{className:`rail-account ${pe?"signed-in":""}`,type:"button",onClick:()=>R(ie=>!ie),"aria-expanded":E,"aria-haspopup":"dialog",title:pe?"Account":"Sign in",children:[r&&K?s.jsx("img",{src:K,alt:te,referrerPolicy:"no-referrer"}):r?s.jsx("span",{className:"avatar-fallback",children:ne}):pe?s.jsx(Lt,{size:18}):s.jsx(zl,{size:18}),s.jsx("span",{children:pe?"Account":"Sign in"})]})]})]}),j&&s.jsxs("section",{id:"client-hub-switch-popover",className:"client-hub-switch-popover",role:"dialog","aria-modal":"false","aria-labelledby":"client-hub-switch-title","aria-describedby":"client-hub-switch-description client-hub-switch-restart",children:[s.jsxs("header",{className:"client-hub-switch-head",children:[s.jsx("span",{className:"client-hub-switch-mark","aria-hidden":"true",children:s.jsx(Ur,{size:19})}),s.jsx("span",{className:"client-hub-switch-eyebrow",children:_e.eyebrow}),s.jsx("button",{className:"client-hub-switch-close",type:"button",onClick:()=>oe(),"aria-label":_e.closeLabel,children:s.jsx(Ja,{size:17})})]}),s.jsx("h2",{id:"client-hub-switch-title",children:_e.title}),s.jsx("p",{id:"client-hub-switch-description",children:_e.description}),s.jsxs("p",{id:"client-hub-switch-restart",className:"client-hub-switch-notice",children:[s.jsx(Lt,{size:16,"aria-hidden":"true"}),s.jsx("span",{children:_e.restartNotice})]}),s.jsxs("div",{className:"client-hub-switch-actions",children:[s.jsx("button",{type:"button",onClick:()=>oe(),children:_e.cancel}),s.jsxs("button",{ref:U,className:"primary",type:"button",onClick:()=>{B()},disabled:w||!n?.authenticated,children:[s.jsx(Ur,{size:16}),_e.confirm]})]})]}),E&&s.jsxs("section",{className:"account-popover",role:"dialog","aria-label":"LiveDesk account",children:[s.jsxs("div",{className:"account-popover-head",children:[s.jsx("div",{className:"account-popover-avatar",children:r&&K?s.jsx("img",{src:K,alt:te,referrerPolicy:"no-referrer"}):r?s.jsx("span",{children:ne}):s.jsx(zl,{size:18})}),s.jsxs("div",{children:[s.jsx("strong",{children:r?te:pe?"Saved account":"Account"}),s.jsx("p",{children:r?.user.email||n?.userEmail||n?.userId||"Not signed in"})]})]}),s.jsxs("dl",{className:"account-popover-facts",children:[s.jsx("dt",{children:"User"}),s.jsx("dd",{children:r?.user.email||n?.userEmail||n?.userId||"Not signed in"}),s.jsx("dt",{children:"Runtime"}),s.jsx("dd",{children:n?"Local app ready":"Checking local app"}),s.jsx("dt",{children:"Session"}),s.jsx("dd",{children:n?.auth?.persisted?"Saved on this computer":pe?"Active for this run":"Not saved"}),s.jsx("dt",{children:"Role"}),s.jsx("dd",{children:"Client"})]}),pe?s.jsxs("button",{className:"account-popover-action",onClick:()=>{P()},type:"button",children:[s.jsx(Yy,{size:16}),"Logout"]}):s.jsxs("button",{className:"account-popover-action primary",onClick:()=>{R(!1),ce()},type:"button",children:[s.jsx(zl,{size:16}),"Sign in with Google"]})]}),s.jsxs("section",{className:"desk-stage client-unified-stage",children:[s.jsx("header",{className:"topbar",children:s.jsxs("div",{className:"brand",children:[s.jsx("span",{className:"brand-mark",children:s.jsx(cn,{size:18})}),s.jsxs("div",{children:[s.jsx("h1",{children:"LiveDesk"}),s.jsx("p",{children:"Client workspace"})]})]})}),M==="support"?s.jsx("section",{className:"client-unified-page",children:s.jsx(ib,{session:r,currentProductKey:"livedesk",appVersion:n?.appVersion||"",onSignIn:()=>{ce()}})}):M!=="computer"?s.jsx("section",{className:"client-unified-page",children:s.jsx(yC,{page:M,status:n})}):s.jsx(bC,{session:r,status:n,pin:m,error:g,roleChangeMessage:b,roleChangeBusy:w,onSignIn:()=>{ce()},onPinChange:ie=>p(ie.replace(/\D/g,"").slice(0,6)),onSubmitPin:()=>{J()},onSwitchToHub:we})]})]})}function Br(n,a,r){if(r<0||a<0||a+r>n.length)throw new Error("Invalid LZO1X block: input overrun.")}function Zm(n,a,r){let l=0;for(;Br(n,a.inputIndex,1),n[a.inputIndex]===0;)l+=1,a.inputIndex+=1;const c=l*255+r+n[a.inputIndex];return a.inputIndex+=1,c}function Td(n,a,r,l){if(Br(n,a.inputIndex,l),a.outputIndex+l>r.length)throw new Error("Invalid LZO1X block: output overrun.");r.set(n.subarray(a.inputIndex,a.inputIndex+l),a.outputIndex),a.inputIndex+=l,a.outputIndex+=l}function SC(n,a,r,l){const c=a-r;if(c<=0||l<=0)throw new Error("Invalid LZO1X block: invalid match distance.");let d=Math.min(c,l);for(n.set(n.subarray(r,r+d),a);d<l;){const m=Math.min(d,l-d);n.copyWithin(a+d,a,a+m),d+=m}return a+l}function fb(n,a){if(!(n instanceof Uint8Array)||n.length<3||a<0)throw new Error("Invalid LZO1X block.");const r=new Uint8Array(a),l={inputIndex:0,outputIndex:0};let c=0,d=0;if(n[l.inputIndex]>=22){const m=n[l.inputIndex]-17;l.inputIndex+=1,Td(n,l,r,m),c=4}else n[l.inputIndex]>=18&&(c=n[l.inputIndex]-17,l.inputIndex+=1,Td(n,l,r,c));for(;;){Br(n,l.inputIndex,1);const m=n[l.inputIndex];l.inputIndex+=1;let p,g;if((m&192)!==0)Br(n,l.inputIndex,1),g=l.outputIndex-((n[l.inputIndex]<<3)+(m>>2&7)+1),l.inputIndex+=1,d=(m>>5)+1,p=m&3;else if((m&32)!==0){d=(m&31)+2,d===2&&(d+=Zm(n,l,31)),Br(n,l.inputIndex,2);const v=n[l.inputIndex]|n[l.inputIndex+1]<<8;l.inputIndex+=2,g=l.outputIndex-((v>>2)+1),p=v&3}else if((m&16)!==0){d=(m&7)+2,d===2&&(d+=Zm(n,l,7)),Br(n,l.inputIndex,2);const v=n[l.inputIndex]|n[l.inputIndex+1]<<8;if(l.inputIndex+=2,g=l.outputIndex-(((m&8)<<11)+(v>>2)),p=v&3,g===l.outputIndex)break;g-=16384}else if(c===0){let v=m+3;v===3&&(v+=Zm(n,l,15)),Td(n,l,r,v),c=4;continue}else c!==4?(Br(n,l.inputIndex,1),p=m&3,g=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+1),l.inputIndex+=1,d=2):(Br(n,l.inputIndex,1),p=m&3,g=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+2049),l.inputIndex+=1,d=3);if(g<0||l.outputIndex+d+p>r.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");l.outputIndex=SC(r,l.outputIndex,g,d),c=p,Td(n,l,r,p)}if(d!==3||l.inputIndex!==n.length||l.outputIndex!==r.length)throw new Error("Invalid LZO1X block: incomplete output.");return r}const kx=16,Ax=8,CC=24*1024*1024,mb=new Uint8Array(new Uint32Array([16909060]).buffer)[0]===4,Rh=new Uint32Array(65536);for(let n=0;n<Rh.length;n+=1){const a=Math.round((n>>11&31)*255/31),r=Math.round((n>>5&63)*255/63),l=Math.round((n&31)*255/31);Rh[n]=mb?(a|r<<8|l<<16|4278190080)>>>0:(a<<24|r<<16|l<<8|255)>>>0}function Hr(n,a){return n[a]|n[a+1]<<8}function jC(n,a){const r=Number(a);if(!Number.isSafeInteger(r)||r<kx||r>CC)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const l=n instanceof Uint8Array?n:new Uint8Array(n),c=fb(l,r);if(c[0]!==76||c[1]!==68||c[2]!==53||c[3]!==68)throw new Error("Invalid Mode 5 packet magic.");if(c[4]!==1)throw new Error(`Unsupported Mode 5 packet version: ${c[4]}.`);const d=(c[5]&1)!==0,m=Hr(c,6),p=Hr(c,8),g=Hr(c,10),v=Hr(c,12);if(m<=0||p<=0||m>3840||p>2160)throw new Error(`Invalid Mode 5 frame size: ${m}x${p}.`);if(g<=0||g>256||v>8192)throw new Error(`Invalid Mode 5 tile header: ${g}/${v}.`);const b=[];let y=kx;for(let w=0;w<v;w+=1){if(y+Ax>c.length)throw new Error("Mode 5 tile header is truncated.");const S=Hr(c,y),j=Hr(c,y+2),N=Hr(c,y+4),M=Hr(c,y+6);y+=Ax;const k=N*M*2;if(N<=0||M<=0||N>g||M>g||S+N>m||j+M>p||y+k>c.length)throw new Error(`Invalid Mode 5 tile ${w}.`);b.push({x:S,y:j,width:N,height:M,pixels:c.subarray(y,y+k)}),y+=k}if(y!==c.length)throw new Error(`Mode 5 packet has ${c.length-y} trailing bytes.`);return{keyFrame:d,width:m,height:p,tileSize:g,tiles:b}}function kC(n,a,r,l){if(!(n instanceof Uint8ClampedArray)||n.length!==a*r*4||l.width!==a||l.height!==r)throw new Error("Mode 5 canvas state does not match the packet dimensions.");let c=a,d=r,m=0,p=0;const g=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const v of l.tiles){const b=mb&&(v.pixels.byteOffset&1)===0?new Uint16Array(v.pixels.buffer,v.pixels.byteOffset,v.pixels.byteLength>>>1):null;let y=0;for(let w=0;w<v.height;w+=1){let S=(v.y+w)*a+v.x;for(let j=0;j<v.width;j+=1){const N=y<<1,M=b?b[y]:v.pixels[N]|v.pixels[N+1]<<8;g[S]=Rh[M],y+=1,S+=1}}c=Math.min(c,v.x),d=Math.min(d,v.y),m=Math.max(m,v.x+v.width),p=Math.max(p,v.y+v.height)}return l.tiles.length>0?{x:c,y:d,width:m-c,height:p-d}:null}const za=new WeakMap,au=new WeakMap,Dh=new WeakMap,su=new Set,Dl=new Set,lf=new WeakMap,Lh=new WeakMap,_h=new WeakMap,of=new WeakMap,hb=4,AC=2,NC=2,MC=2,TC=18,EC=40,RC=0,DC=250,pb=80,Nx=5,LC=150,_C=24,zC=180,IC=1200,OC=18,HC=.65,BC=2e3,FC=500,ap=250,PC=globalThis.LIVEDESK_ENABLE_CANVAS_VISUAL_SAMPLING===!0;let cf=!1;function $C(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function UC(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let Hl={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:UC()};function qC(n){n.h264DecodeAcceleration&&(Hl={...Hl,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(Hl.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function gb(n,a=Hl.h264DecodeAcceleration){const r=lf.get(n);return r?.requested===a?(r.actual!=="prefer-hardware"&&Dl.delete(n),r.actual):(r&&lf.delete(n),a!=="prefer-hardware"?(Dl.delete(n),a):Dl.has(n)?"prefer-hardware":Dl.size<Hl.h264HardwareDecoderBudget?(Dl.add(n),"prefer-hardware"):"prefer-software")}function xf(n,a){return a!=="prefer-hardware"?!1:(lf.set(n,{requested:a,actual:"prefer-software"}),Dl.delete(n),!0)}function GC(n,a,r,l=64){try{let c=Lh.get(n);c||(c={canvas:document.createElement("canvas"),lastHash:"",initialized:!1},Lh.set(n,c));const d=Math.max(8,Math.min(64,Math.round(l))),m=Math.max(1,Math.round(d*Math.max(1,r)/Math.max(1,a)));(c.canvas.width!==d||c.canvas.height!==m)&&(c.canvas.width=d,c.canvas.height=m);const p=c.canvas.getContext("2d",{willReadFrequently:!0});if(!p)return{visualHash:"",visualChanged:!0};p.drawImage(n,0,0,Math.max(1,a),Math.max(1,r),0,0,d,m);const g=p.getImageData(0,0,d,m).data;let v=2166136261;for(let w=0;w<g.length;w+=4)v^=g[w],v=Math.imul(v,16777619),v^=g[w+1],v=Math.imul(v,16777619),v^=g[w+2],v=Math.imul(v,16777619);const b=(v>>>0).toString(16).padStart(8,"0"),y=!c.initialized||b!==c.lastHash;return c.initialized=!0,c.lastHash=b,{visualHash:b,visualChanged:y}}catch{return{visualHash:"",visualChanged:!0}}}function zh(n,a,r,l=ap,c=64,d){if(!PC&&d)return vb(n,d);let m=_h.get(n);m||(m={lastHash:"",initialized:!1,lastCanvasSampleAt:0},_h.set(n,m));const p=performance.now();if(m.initialized&&l>0&&p-m.lastCanvasSampleAt<l)return{visualHash:m.lastHash,visualChanged:!1};const g=GC(n,a,r,c);return m.initialized=!0,m.lastHash=g.visualHash,m.lastCanvasSampleAt=p,g}function vb(n,a){let r=of.get(n);r||(r={lastHash:"",initialized:!1},of.set(n,r));const l=String(a.contentHash||""),c=!r.initialized||!l||l!==r.lastHash;return r.initialized=!0,r.lastHash=l,{visualHash:l,visualChanged:c}}function xb(n,a){const r=Dh.get(n);if(r)return r;const l=n.getContext("2d",{alpha:!1,desynchronized:a==="interactive"});if(l){const c=l.getContextAttributes?.(),d={context:l,presentation:c?.desynchronized?"desync":"sync"};return Dh.set(n,d),d}return null}function VC(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),r=String(n.compression||"").toLowerCase(),l=String(n.mimeType||"").toLowerCase();return a==="mode2-lzo"||r==="lzo1x"||l==="application/vnd.livedesk.lzo-rgb565"||a==="mode2-lz4"||String(n.compression||"").toLowerCase()==="lz4"||l==="application/vnd.livedesk.lz4-raw"}function WC(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function YC(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),r=String(n.mimeType||"").toLowerCase();return a==="mode5-lzo-delta"||r==="application/vnd.livedesk.lzo-rgb565-delta"}function Mx(n,a,r){let l=r,c=a;if(l===15){let d=255;for(;d===255;){if(c>=n.length)throw new Error("Invalid LZ4 block: length overrun.");d=n[c],c+=1,l+=d}}return{length:l,cursor:c}}function KC(n,a){const r=new Uint8Array(a);let l=0,c=0;for(;l<n.length;){const d=n[l];l+=1;const m=Mx(n,l,d>>4);l=m.cursor;const p=m.length;if(l+p>n.length||c+p>r.length)throw new Error("Invalid LZ4 block: literal overrun.");if(r.set(n.subarray(l,l+p),c),l+=p,c+=p,l>=n.length)break;if(l+2>n.length)throw new Error("Invalid LZ4 block: missing offset.");const g=n[l]|n[l+1]<<8;if(l+=2,g<=0||g>c)throw new Error("Invalid LZ4 block: bad match offset.");const v=Mx(n,l,d&15);l=v.cursor;const b=v.length+4;if(c+b>r.length)throw new Error("Invalid LZ4 block: match overrun.");let y=c-g;for(let w=0;w<b;w+=1)r[c]=r[y],c+=1,y+=1}if(c!==r.length)throw new Error("Invalid LZ4 block: incomplete output.");return r}function QC(n){const a=Math.max(1,Math.floor(n.width||0)),r=Math.max(1,Math.floor(n.height||0)),l=String(n.compression||"").toLowerCase(),c=String(n.pixelFormat||n.codec||"").toLowerCase();if(l==="lzo1x"||String(n.frameMode||n.mode||"").toLowerCase()==="mode2-lzo"||String(n.mimeType||"").toLowerCase()==="application/vnd.livedesk.lzo-rgb565"){const b=Math.max(1,Math.floor(n.bytesPerPixel||2)),y=a*r*2,w=Math.floor(n.uncompressedByteLength||y);if(b!==2||w!==y)throw new Error(`Invalid mode2 RGB565 frame size: ${w} for ${a}x${r}.`);if(c&&c!=="rgb565le"&&c!=="rgb565")throw new Error(`Unsupported mode2 pixel format: ${c}`);const S=fb(n.payload,y),j=new Uint8ClampedArray(a*r*4);for(let N=0,M=0;N<S.length;N+=2,M+=4){const k=S[N]|S[N+1]<<8,E=k>>11&31,R=k>>5&63,U=k&31;j[M]=E<<3|E>>2,j[M+1]=R<<2|R>>4,j[M+2]=U<<3|U>>2,j[M+3]=255}return new ImageData(j,a,r)}const m=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*r*m,Math.floor(n.uncompressedByteLength||0)),g=KC(n.payload,p);if(m!==4)throw new Error(`Unsupported mode2 pixel size: ${m}`);const v=new Uint8ClampedArray(a*r*4);if(c==="rgba32"||c==="rgba")v.set(g.subarray(0,v.length));else for(let b=0,y=0;y<v.length;b+=4,y+=4)v[y]=g[b+2],v[y+1]=g[b+1],v[y+2]=g[b],v[y+3]=g[b+3];return new ImageData(v,a,r)}function Tx(n,a="smooth"){const r=window.VideoDecoder;if(!r||!window.EncodedVideoChunk)throw new Error("WebCodecs H.264 decode is not supported in this browser.");const l=za.get(n);if(l&&l.decoder.state!=="closed"&&l.latencyMode===a)return l;l&&Os(n);let c;return c={decoder:new r({output:m=>{if(za.get(n)!==c){m.close();return}const p=Number(m.timestamp||0);c.outputSerial+=1;let g=c.pendingFrames.get(p);if(g)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const j=c.pendingFrames.entries().next().value;j&&(c.pendingFrames.delete(j[0]),g=j[1],c.timestampFallbacks+=1)}const v=m.displayWidth||m.codedWidth||n.width||960,b=m.displayHeight||m.codedHeight||n.height||540,y=Number(g?.frame.durationUs||0),w=Number(m.duration||0),S=Math.max(16,Math.min(250,(y>0?y:w||83333)/1e3));for(c.targetPaintIntervalMs=S,c.decodedFrames.push({videoFrame:m,pending:g,decodedAt:performance.now(),width:v,height:b,durationMs:S}),c.lastOutputAt=performance.now();c.decodedFrames.length>ip(c);)uf(c,c.decodedFrames.shift());yb(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>FC&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=hb&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),df(n,c)},error:()=>{za.get(n)===c&&(xf(n,c.hardwareAcceleration),sp(c),su.delete(n),za.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:gb(n),latencyMode:a,keyFrameSeen:!1,droppedForLatency:0,pendingFrames:new Map,decodedFrames:[],renderTimer:null,renderScheduledAt:0,flushTimer:null,flushInFlight:!1,flushCount:0,timestampFallbacks:0,inputSerial:0,outputSerial:0,lastFlushInputSerial:0,lastOutputAt:0,lastPaintAt:0,lastInputAt:0,interactiveBufferPrimed:!1,interactiveBufferStartedAt:0,interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,lastInputFrameSeq:void 0,targetPaintIntervalMs:1e3/12,nextChunkTimestampUs:0,healthSampleStartedAt:performance.now(),healthInputSerial:0,healthOutputSerial:0},za.set(n,c),su.add(n),c}function sp(n){n.renderTimer!==null&&(window.cancelAnimationFrame(n.renderTimer),n.renderTimer=null),n.renderScheduledAt=0,n.flushTimer!==null&&(window.clearTimeout(n.flushTimer),n.flushTimer=null),n.flushInFlight=!1;for(const a of n.decodedFrames)a.videoFrame.close();n.decodedFrames=[],n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0}function uf(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function ip(n){return n.latencyMode==="interactive"?NC:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?AC:hb}function yb(n,a=performance.now()){const r=ip(n);for(;n.decodedFrames.length>r;)uf(n,n.decodedFrames.shift());const l=n.latencyMode==="interactive"?pb:DC;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>l;)uf(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function bb(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const r=a.latencyMode==="interactive"?_C:LC,l=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,g]of a.pendingFrames.entries())c-g.queuedAt>BC&&a.pendingFrames.delete(p);if(za.get(n)!==a||a.decoder.state!=="configured"||a.pendingFrames.size===0||a.inputSerial<=a.lastFlushInputSerial||!l&&a.lastOutputAt>0&&c-a.lastOutputAt<r)return;const d=a.inputSerial,m=performance.now();a.flushInFlight=!0,a.flushCount+=1;try{await a.decoder.flush(),a.lastFlushInputSerial=Math.max(a.lastFlushInputSerial,d)}catch{za.get(n)===a&&Xd(a)}finally{a.flushInFlight=!1;const p=performance.now()-m;if(l&&p>=zC&&a.hardwareAcceleration==="prefer-hardware"){cf=!0,xf(n,a.hardwareAcceleration),Os(n);return}za.get(n)===a&&a.inputSerial>d&&a.pendingFrames.size>0&&(l||performance.now()-a.lastOutputAt>=r)&&bb(n,a)}},r)}function Ex(n,a,r){const l=performance.now();try{(n.width!==r.width||n.height!==r.height)&&(n.width=r.width,n.height=r.height);const c=xb(n,a.latencyMode);if(c?.context.drawImage(r.videoFrame,0,0,r.width,r.height),r.pending){const d=performance.now(),p=a.latencyMode==="interactive"?vb(n,r.pending.frame):zh(n,r.width,r.height,ap,64,r.pending.frame);try{a.onPaint?.(r.pending.frame,{deviceId:r.pending.frame.deviceId,frameSeq:r.pending.frame.frameSeq,mode:r.pending.frame.frameMode||r.pending.frame.mode||r.pending.frame.codec||r.pending.frame.mimeType,width:r.width,height:r.height,byteLength:r.pending.frame.byteLength,queuedForMs:Math.max(0,l-r.pending.queuedAt),decodedForMs:Math.max(0,r.decodedAt-r.pending.queuedAt),scheduledForMs:Math.max(0,l-r.decodedAt),drawMs:Math.max(0,d-l),queueSize:r.pending.queueSize,renderQueueSize:a.decodedFrames.length,droppedForLatency:a.droppedForLatency,h264DecodeAcceleration:a.hardwareAcceleration,decoderLabel:a.hardwareAcceleration,decoderFlushCount:a.flushCount,decoderTimestampFallbacks:a.timestampFallbacks,decoderInputCount:a.inputSerial,decoderOutputCount:a.outputSerial,targetPaintIntervalMs:a.targetPaintIntervalMs,canvasPresentation:c?.presentation||"sync",interactiveBufferWaitCount:a.interactiveBufferWaitCount,interactiveBufferWaitMs:a.interactiveBufferWaitMs,interactiveQueueDrainCount:a.interactiveQueueDrainCount,visualHash:p.visualHash,visualChanged:p.visualChanged,paintedAt:d})}catch{}}a.lastPaintAt=performance.now()}finally{r.videoFrame.close()}}function df(n,a){if(a.renderTimer!==null||a.decodedFrames.length===0)return;const r=Math.max(16,Math.min(250,a.targetPaintIntervalMs||1e3/12)),l=()=>{if(a.renderTimer=null,a.renderScheduledAt=0,a.decodedFrames.length===0)return;const c=performance.now();if(yb(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const g=a.targetPaintIntervalMs<=EC,v=a.targetPaintIntervalMs<=20;if(v&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const N=a.decodedFrames.length>=MC,M=c-a.interactiveBufferStartedAt>=TC;if(!N&&!M){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else v||(a.interactiveBufferPrimed=!0);const b=a.decodedFrames[0],y=b?.pending?Math.max(0,c-b.pending.queuedAt):0,w=a.lastPaintAt>0?a.lastPaintAt+r:c;if(!(!g||c+Nx>=w||y>=pb)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const j=a.decodedFrames.shift();if(j)try{Ex(n,a,j)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),df(n,a);return}const d=a.lastPaintAt>0?a.lastPaintAt+r:c+RC;if(!(c+Nx>=d||a.decodedFrames.length>=Math.max(1,ip(a)-1))){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const p=a.decodedFrames.shift();if(p)try{Ex(n,a,p)}catch{}df(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l)}function wb(n,a){if(za.get(n)!==a||a.decoder.state==="closed")return!1;for(a.renderTimer!==null&&(window.cancelAnimationFrame(a.renderTimer),a.renderTimer=null),a.renderScheduledAt=0;a.decodedFrames.length>1;)uf(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,df(n,a),!0}function Jm(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of su){const a=za.get(n);if(!a||a.decoder.state==="closed"){su.delete(n);continue}wb(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",Jm),window.addEventListener("focus",Jm),window.addEventListener("pageshow",Jm));function Os(n){Dl.delete(n),su.delete(n),of.delete(n);const a=za.get(n);if(a){za.delete(n);try{sp(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function Pc(n){n&&(lf.delete(n),Dh.delete(n),_h.delete(n),Lh.delete(n),of.delete(n),au.delete(n),Os(n))}function Xd(n,a=1){try{n.decoder.state!=="closed"&&n.decoder.reset()}catch{}n.configured=!1,n.configKey="",n.keyFrameSeen=!1,n.pendingFrames.clear(),sp(n),n.lastPaintAt=0,n.lastOutputAt=0,n.lastInputAt=0,n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0,n.lastInputFrameSeq=void 0,n.nextChunkTimestampUs=0,n.healthSampleStartedAt=performance.now(),n.healthInputSerial=n.inputSerial,n.healthOutputSerial=n.outputSerial,n.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a)))}function Ed(n,a,r,l){n.decoder.configure(a),n.configured=!0,n.configKey=r,n.codec=a.codec,n.hardwareAcceleration=l,n.keyFrameSeen=!1,n.nextChunkTimestampUs=0,n.lastInputFrameSeq=void 0}function XC(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const r=performance.now();if(r-a.healthSampleStartedAt<IC)return!1;const l=a.inputSerial-a.healthInputSerial,c=a.outputSerial-a.healthOutputSerial;return a.healthSampleStartedAt=r,a.healthInputSerial=a.inputSerial,a.healthOutputSerial=a.outputSerial,l<OC||c/Math.max(1,l)>=HC?!1:(cf=!0,xf(n,a.hardwareAcceleration),Os(n),!0)}function eh(n,a=1){if(!n)return!1;const r=za.get(n);return r?(r.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),Os(n),!0):!1}function ZC(n){if(!n)return!1;const a=za.get(n);return a?wb(n,a):!1}function JC(n,a,r,l="interactive"){Os(n);const c=performance.now(),d=jC(a.payload,a.uncompressedByteLength||0),m=String(a.streamId||"mode5");let p=au.get(n);if(!p||p.streamId!==m||p.width!==d.width||p.height!==d.height){const N=new Uint8ClampedArray(d.width*d.height*4);for(let M=3;M<N.length;M+=4)N[M]=255;p={streamId:m,width:d.width,height:d.height,rgba:N,imageData:new ImageData(N,d.width,d.height),keyFrameSeen:!1,inputSerial:0,outputSerial:0},au.set(n,p)}if(!p)throw new Error("Mode 5 canvas state could not be initialized.");p.inputSerial+=1;const v=Number(a.streamFrameSeq||0);if(v>0&&(p.lastStreamFrameSeq=v),!d.keyFrame&&!p.keyFrameSeen)return;d.keyFrame&&(p.keyFrameSeen=!0);const b=kC(p.rgba,p.width,p.height,d),y=performance.now();(n.width!==p.width||n.height!==p.height)&&(n.width=p.width,n.height=p.height);const w=xb(n,l),S=performance.now();b&&w?.context.putImageData(p.imageData,0,0,b.x,b.y,b.width,b.height);const j=performance.now();p.outputSerial+=1,r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.mimeType,width:p.width,height:p.height,byteLength:a.byteLength,queuedForMs:Math.max(0,j-c),decodedForMs:Math.max(0,y-c),scheduledForMs:0,drawMs:Math.max(0,j-S),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:"prefer-software",decoderLabel:"lzo-rgb565-delta",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:p.inputSerial,decoderOutputCount:p.outputSerial,targetPaintIntervalMs:Math.max(1,Number(a.durationUs||0)/1e3||1e3/30),canvasPresentation:w?.presentation||"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:String(a.contentHash||""),visualChanged:Number(a.deltaVisualTileCount||0)>0,paintedAt:j})}const th=[{code:30,maxFrameSize:1620,maxMacroblocksPerSecond:40500},{code:31,maxFrameSize:3600,maxMacroblocksPerSecond:108e3},{code:32,maxFrameSize:5120,maxMacroblocksPerSecond:216e3},{code:40,maxFrameSize:8192,maxMacroblocksPerSecond:245760},{code:41,maxFrameSize:8192,maxMacroblocksPerSecond:245760},{code:42,maxFrameSize:8704,maxMacroblocksPerSecond:522240},{code:50,maxFrameSize:22080,maxMacroblocksPerSecond:589824},{code:51,maxFrameSize:36864,maxMacroblocksPerSecond:983040},{code:52,maxFrameSize:36864,maxMacroblocksPerSecond:2073600}];function Rx(n,a){for(let r=Math.max(0,a);r+3<n.length;r+=1)if(!(n[r]!==0||n[r+1]!==0)){if(n[r+2]===1)return{index:r,length:3};if(n[r+2]===0&&n[r+3]===1)return{index:r,length:4}}return null}function ej(n){let a=0;for(;a<n.length;){const r=Rx(n,a);if(!r)break;const l=r.index+r.length,c=Rx(n,l),d=c?.index??n.length;if(l<d&&(n[l]&31)===7){const m=[];let p=0;for(let g=l+1;g<d;g+=1){const v=n[g];if(p>=2&&v===3){p=0;continue}m.push(v),p=v===0?p+1:0}if(m.length>=3)return`avc1.${m.slice(0,3).map(g=>g.toString(16).toUpperCase().padStart(2,"0")).join("")}`}a=c?c.index:n.length}return""}function tj(n,a,r,l,c=""){const d=Math.ceil(n/16)*Math.ceil(a/16),m=r>0?1e6/r:30,p=d*m,g=th.find(v=>d<=v.maxFrameSize&&p<=v.maxMacroblocksPerSecond)||th[th.length-1];return ej(l)||c||`avc1.42E0${g.code.toString(16).toUpperCase().padStart(2,"0")}`}function nj(n,a,r,l,c="smooth"){au.delete(n);const d=String(a.h264Format||"").toLowerCase()==="avc"?"avc":"annexb",m=Math.max(1,Math.floor(a.width||960)),p=Math.max(1,Math.floor(a.height||540)),g=Math.max(1,Math.floor(a.durationUs||1e6/12));let v=Tx(n,c);const b=tj(m,p,g,a.payload,v.codec),y=String(a.frameMode||a.mode||"").toLowerCase(),w=c==="interactive"&&l==="prefer-hardware"&&$C(),j=y==="mode4-h264-atlas"?"prefer-software":gb(n,c==="interactive"&&(cf||w)?"prefer-software":l),N=[a.streamId||"",a.commandId||"",m,p,b,d,j,c].join("|");v.onPaint=r,v.configured&&v.decoder.state!=="configured"&&(v.configured=!1,v.configKey=""),v.configured&&v.configKey!==N&&(Os(n),v=Tx(n,c),v.onPaint=r);const M={codec:b,codedWidth:m,codedHeight:p,hardwareAcceleration:j,optimizeForLatency:!0,avc:{format:d}};v.configured||Ed(v,M,N,j);const k=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const E=Number(a.streamFrameSeq||0);if(E>0&&v.lastInputFrameSeq!==void 0){if(E<=v.lastInputFrameSeq){if(!k||E===v.lastInputFrameSeq)return;Xd(v,v.lastInputFrameSeq-E+1),Ed(v,M,N,j)}if(E>v.lastInputFrameSeq+1){if(Xd(v,E-v.lastInputFrameSeq-1),!k)return;Ed(v,M,N,j)}}if(E>0&&(v.lastInputFrameSeq=E),!k&&!v.keyFrameSeen)return;k&&(v.keyFrameSeen=!0);const R=Number(v.decoder.decodeQueueSize||0);if(R>8){if(v.latencyMode==="interactive"&&v.hardwareAcceleration==="prefer-hardware"){cf=!0,xf(n,v.hardwareAcceleration),Os(n);return}if(Xd(v),!k)return;Ed(v,M,N,j),v.keyFrameSeen=!0}const U=v.nextChunkTimestampUs;v.nextChunkTimestampUs+=g,v.pendingFrames.set(U,{frame:a,queuedAt:performance.now(),queueSize:R}),v.inputSerial+=1,v.lastInputAt=performance.now();const H=new EncodedVideoChunk({type:k?"key":"delta",timestamp:U,duration:g,data:a.payload});try{v.decoder.decode(H)}catch(W){throw Os(n),W}bb(n,v),XC(n,v)}async function nh(n,a,r,l,c,d="smooth"){if(YC(a)){r()||JC(n,a,l,d);return}if(WC(a)){r()||nj(n,a,l,c,d);return}if(au.delete(n),VC(a)){Os(n);const y=QC(a);if(r())return;(n.width!==y.width||n.height!==y.height)&&(n.width=y.width,n.height=y.height);const w=n.getContext("2d"),S=performance.now();w?.putImageData(y,0,0);const j=performance.now(),N=zh(n,y.width,y.height,ap,64,a);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:y.width,height:y.height,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,j-S),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Hl.h264DecodeAcceleration,decoderLabel:"lzo-rgb565",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:N.visualHash,visualChanged:N.visualChanged,paintedAt:j});return}Os(n);const m=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(m);if(r()){p.close();return}const g=a.width||p.width||960,v=a.height||p.height||540;(n.width!==g||n.height!==v)&&(n.width=g,n.height=v);const b=n.getContext("2d");if(b){const y=performance.now();b.clearRect(0,0,g,v),b.drawImage(p,0,0,g,v);const w=performance.now(),S=zh(n,g,v);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:g,height:v,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,w-y),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Hl.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:S.visualHash,visualChanged:S.visualChanged,paintedAt:w})}p.close()}const Dx="livedesk_remote_host_targets",aj="livedesk_entitlements",rp=new TextDecoder;function sj(n){const r=(Array.isArray(n)?n:[n||bn]).map(l=>Wr(l||bn));return[...new Set(r.filter(Boolean))]}function ij(){const[n,a]=u.useState(null),[r,l]=u.useState(!0);return u.useEffect(()=>{let c=!0;const d=window.liveDesk?.auth?.onComplete?.(p=>{p.ok&&p.session&&ct.auth.setSession(p.session)});(window.liveDesk?.auth?.getSession?.()||ct.auth.getSession()).then(p=>{c&&(a(rb(p)),l(!1))});const{data:{subscription:m}}=ct.auth.onAuthStateChange((p,g)=>{a(g),l(!1),window.liveDesk?.auth?.persistSession?.(g)});return()=>{c=!1,d?.(),m.unsubscribe()}},[]),{session:n,loading:r}}function rj(n,a=!0){const[r,l]=u.useState(null),[c,d]=u.useState([]),[m,p]=u.useState(""),[g,v]=u.useState(""),[b,y]=u.useState(0),w=u.useRef(new Map),S=Array.isArray(n)?n.join(`
|
|
11
|
+
${rf(a,r)}`}const ub={eyebrow:"Change computer role",title:"Switch this computer to Hub?",description:"LiveDesk will stop sharing this computer as a Client, save the Hub role, restart the local runtime, and open Wall in this same window.",restartNotice:"Remote streams from this computer will end while LiveDesk restarts.",cancel:"Cancel",confirm:"Switch to Hub",closeLabel:"Close Hub switch confirmation"},uC={en:ub,ko:{eyebrow:"컴퓨터 역할 변경",title:"이 컴퓨터를 Hub로 전환하시겠습니까?",description:"이 컴퓨터의 Client 공유를 중지하고 Hub 역할을 저장한 뒤 로컬 런타임을 재시작하여 같은 창에서 Wall을 엽니다.",restartNotice:"LiveDesk가 재시작되는 동안 이 컴퓨터의 원격 스트림이 종료됩니다.",cancel:"취소",confirm:"Hub로 전환",closeLabel:"Hub 전환 확인 닫기"},ja:{eyebrow:"コンピューターの役割を変更",title:"このコンピューターを Hub に切り替えますか?",description:"このコンピューターの Client 共有を停止し、Hub の役割を保存してローカルランタイムを再起動し、同じウィンドウで Wall を開きます。",restartNotice:"LiveDesk の再起動中、このコンピューターのリモートストリームは終了します。",cancel:"キャンセル",confirm:"Hub に切り替える",closeLabel:"Hub 切り替え確認を閉じる"},zh:{eyebrow:"更改电脑角色",title:"将此电脑切换为 Hub?",description:"LiveDesk 将停止此电脑的 Client 共享,保存 Hub 角色,重启本地运行时,并在同一窗口中打开 Wall。",restartNotice:"LiveDesk 重启期间,此电脑的远程流将会结束。",cancel:"取消",confirm:"切换为 Hub",closeLabel:"关闭 Hub 切换确认"},"zh-TW":{eyebrow:"變更電腦角色",title:"要將此電腦切換為 Hub 嗎?",description:"LiveDesk 將停止此電腦的 Client 分享、儲存 Hub 角色、重新啟動本機執行階段,並在同一視窗中開啟 Wall。",restartNotice:"LiveDesk 重新啟動期間,此電腦的遠端串流將會結束。",cancel:"取消",confirm:"切換為 Hub",closeLabel:"關閉 Hub 切換確認"},es:{eyebrow:"Cambiar función del equipo",title:"¿Cambiar este equipo a Hub?",description:"LiveDesk dejará de compartir este equipo como Client, guardará la función Hub, reiniciará el entorno local y abrirá Wall en esta misma ventana.",restartNotice:"Los streams remotos de este equipo terminarán mientras LiveDesk se reinicia.",cancel:"Cancelar",confirm:"Cambiar a Hub",closeLabel:"Cerrar confirmación de cambio a Hub"},fr:{eyebrow:"Changer le rôle de l’ordinateur",title:"Basculer cet ordinateur vers Hub ?",description:"LiveDesk arrêtera le partage Client de cet ordinateur, enregistrera le rôle Hub, redémarrera le runtime local et ouvrira Wall dans cette même fenêtre.",restartNotice:"Les flux distants de cet ordinateur prendront fin pendant le redémarrage de LiveDesk.",cancel:"Annuler",confirm:"Basculer vers Hub",closeLabel:"Fermer la confirmation de bascule vers Hub"},de:{eyebrow:"Computerrolle ändern",title:"Diesen Computer auf Hub umstellen?",description:"LiveDesk beendet die Client-Freigabe dieses Computers, speichert die Hub-Rolle, startet die lokale Laufzeit neu und öffnet Wall im selben Fenster.",restartNotice:"Die Remote-Streams dieses Computers enden während des LiveDesk-Neustarts.",cancel:"Abbrechen",confirm:"Auf Hub umstellen",closeLabel:"Bestätigung für Hub-Wechsel schließen"},"pt-BR":{eyebrow:"Alterar função do computador",title:"Mudar este computador para Hub?",description:"O LiveDesk interromperá o compartilhamento deste computador como Client, salvará a função Hub, reiniciará o runtime local e abrirá o Wall nesta mesma janela.",restartNotice:"Os streams remotos deste computador serão encerrados enquanto o LiveDesk reinicia.",cancel:"Cancelar",confirm:"Mudar para Hub",closeLabel:"Fechar confirmação de mudança para Hub"},it:{eyebrow:"Cambia ruolo del computer",title:"Passare questo computer a Hub?",description:"LiveDesk interromperà la condivisione Client di questo computer, salverà il ruolo Hub, riavvierà il runtime locale e aprirà Wall nella stessa finestra.",restartNotice:"Gli stream remoti di questo computer termineranno durante il riavvio di LiveDesk.",cancel:"Annulla",confirm:"Passa a Hub",closeLabel:"Chiudi la conferma del passaggio a Hub"},id:{eyebrow:"Ubah peran komputer",title:"Alihkan komputer ini menjadi Hub?",description:"LiveDesk akan menghentikan berbagi komputer ini sebagai Client, menyimpan peran Hub, memulai ulang runtime lokal, lalu membuka Wall di jendela yang sama.",restartNotice:"Stream jarak jauh dari komputer ini akan berakhir saat LiveDesk dimulai ulang.",cancel:"Batal",confirm:"Alihkan ke Hub",closeLabel:"Tutup konfirmasi peralihan Hub"},vi:{eyebrow:"Đổi vai trò máy tính",title:"Chuyển máy tính này thành Hub?",description:"LiveDesk sẽ dừng chia sẻ máy tính này dưới dạng Client, lưu vai trò Hub, khởi động lại runtime cục bộ và mở Wall trong cùng cửa sổ.",restartNotice:"Các luồng từ xa của máy tính này sẽ kết thúc trong khi LiveDesk khởi động lại.",cancel:"Hủy",confirm:"Chuyển sang Hub",closeLabel:"Đóng xác nhận chuyển sang Hub"},th:{eyebrow:"เปลี่ยนบทบาทคอมพิวเตอร์",title:"เปลี่ยนคอมพิวเตอร์เครื่องนี้เป็น Hub หรือไม่",description:"LiveDesk จะหยุดแชร์คอมพิวเตอร์เครื่องนี้ในฐานะ Client บันทึกบทบาท Hub รีสตาร์ทรันไทม์ภายในเครื่อง และเปิด Wall ในหน้าต่างเดิม",restartNotice:"สตรีมระยะไกลจากคอมพิวเตอร์เครื่องนี้จะสิ้นสุดลงระหว่างที่ LiveDesk รีสตาร์ท",cancel:"ยกเลิก",confirm:"เปลี่ยนเป็น Hub",closeLabel:"ปิดการยืนยันการเปลี่ยนเป็น Hub"},hi:{eyebrow:"कंप्यूटर की भूमिका बदलें",title:"इस कंप्यूटर को Hub में बदलें?",description:"LiveDesk इस कंप्यूटर की Client साझेदारी बंद करेगा, Hub भूमिका सहेजेगा, स्थानीय रनटाइम पुनः आरंभ करेगा और इसी विंडो में Wall खोलेगा।",restartNotice:"LiveDesk के पुनः आरंभ होने के दौरान इस कंप्यूटर की रिमोट स्ट्रीम समाप्त हो जाएँगी।",cancel:"रद्द करें",confirm:"Hub में बदलें",closeLabel:"Hub परिवर्तन की पुष्टि बंद करें"},ar:{eyebrow:"تغيير دور الكمبيوتر",title:"هل تريد تحويل هذا الكمبيوتر إلى Hub؟",description:"سيوقف LiveDesk مشاركة هذا الكمبيوتر كـ Client، ويحفظ دور Hub، ويعيد تشغيل وقت التشغيل المحلي، ثم يفتح Wall في النافذة نفسها.",restartNotice:"ستنتهي التدفقات البعيدة من هذا الكمبيوتر أثناء إعادة تشغيل LiveDesk.",cancel:"إلغاء",confirm:"التحويل إلى Hub",closeLabel:"إغلاق تأكيد التحويل إلى Hub"},tr:{eyebrow:"Bilgisayar rolünü değiştir",title:"Bu bilgisayar Hub rolüne geçirilsin mi?",description:"LiveDesk bu bilgisayarın Client paylaşımını durdurur, Hub rolünü kaydeder, yerel çalışma zamanını yeniden başlatır ve Wall’u aynı pencerede açar.",restartNotice:"LiveDesk yeniden başlatılırken bu bilgisayarın uzak akışları sona erer.",cancel:"İptal",confirm:"Hub’a geçir",closeLabel:"Hub geçişi onayını kapat"}};function dC(n){const a=np(n);return uC[a]||ub}const fC=[{id:"docs",label:"Doc",icon:af},{id:"support",label:"Support",icon:Kc},{id:"pricing",label:"Pricing",icon:Do},{id:"settings",label:"Settings",icon:Wy}],Cx=[0,1e3,2e3,5e3,1e4,2e4,3e4];function mC(){return typeof window>"u"?"":window.location.port==="5179"?window.location.origin:"http://127.0.0.1:5179"}async function Fc(n,a=!1){const r=a?"":sessionStorage.getItem("livedesk.client.csrf");if(r)return r;const l=await fetch(`${n}/api/runtime/status`,{cache:"no-store"}),c=await l.json().catch(()=>({}));if(!l.ok)throw new Error(c.error||`Client runtime returned HTTP ${l.status}.`);const d=String(c.csrfToken||"");return d&&sessionStorage.setItem("livedesk.client.csrf",d),d}function Eh(n){return`${Math.max(0,Math.min(100,Number(n||0))).toFixed(0)}%`}function Xm(n){return Number.isFinite(n)?`${Math.max(0,Math.min(100,Number(n))).toFixed(0)}%`:"—"}function db(n){return Number.isFinite(n)?Eh(Number(n)):"0%"}function _l(n){const a=Number(n);return!Number.isFinite(a)||a<0?"—":a>=1024**4?`${(a/1024**4).toFixed(a>=10*1024**4?0:1)} TB`:a>=1024**3?`${(a/1024**3).toFixed(a>=10*1024**3?0:1)} GB`:`${(a/1024**2).toFixed(0)} MB`}function jx(n){const a=Math.max(0,Number(n||0));return a>=1024**3?`${(a/1024**3).toFixed(1)} GB/s`:a>=1024**2?`${(a/1024**2).toFixed(1)} MB/s`:a>=1024?`${(a/1024).toFixed(1)} KB/s`:`${a.toFixed(0)} B/s`}function hC(n,a){const r=Number(n||0)/1073741824,l=Number(a||0)/1024**3;return l>0?`${r.toFixed(1)} / ${l.toFixed(1)} GB`:"Checking..."}function pC(n,a){return!Number.isFinite(a)||Number(a)<=0?"Dedicated memory unavailable":Number.isFinite(n)?`${_l(n)} / ${_l(a)}`:`${_l(a)} available`}function gC(n){const a=Math.max(0,Math.floor(Number(n||0)/60)),r=Math.floor(a/1440),l=Math.floor(a%1440/60),c=a%60;return r>0?`${r}d ${l}h`:l>0?`${l}h ${c}m`:`${c}m`}function Md({icon:n,label:a,value:r,detail:l,percent:c}){return s.jsxs("article",{className:"client-resource-metric",children:[s.jsxs("div",{className:"client-resource-metric-head",children:[s.jsx(n,{size:17}),s.jsx("span",{children:a}),s.jsx("strong",{children:r})]}),s.jsx("small",{title:l,children:l}),s.jsx("i",{"aria-hidden":"true",children:s.jsx("b",{style:{width:db(c)}})})]})}function vC(n){const a=n?.user.user_metadata||{},r=a.full_name||a.name||a.preferred_username||n?.user.email||n?.user.id||"Account";return String(r).trim()||"Account"}function xC(n){const a=n?.user.user_metadata||{},r=a.avatar_url||a.picture;return typeof r=="string"?r.trim():""}function yC({page:n,status:a}){const l={docs:{label:"DOC",title:"Using this computer",body:"This computer connects to its assigned Hub automatically. Keep LiveDesk running and manage screens, files, and remote control from the Hub."},pricing:{label:"PRICING",title:"LiveDesk plans",body:"Plans are based on how many computers the Hub manages. This Client computer does not need a separate subscription or setup."},settings:{label:"SETTINGS",title:"Computer preferences",body:"LiveDesk keeps the verified sign-in on this computer and reconnects to the assigned Hub automatically."}}[n];return s.jsxs("section",{className:"client-service-page",children:[s.jsx("span",{className:"client-unified-section-label",children:l.label}),s.jsx("h2",{children:l.title}),s.jsx("p",{children:l.body}),s.jsxs("div",{className:"client-service-page-card",children:[n==="docs"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Automatic connection"}),s.jsx("span",{children:"Start LiveDesk. This computer signs in, finds the Hub, and becomes available without another action."})]}),n==="pricing"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"One plan, managed at the Hub"}),s.jsx("span",{children:"Computer access follows the account and plan used by the Hub."})]}),n==="settings"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Saved sign-in"}),s.jsx("span",{children:a?.auth?.persisted?"Enabled on this computer":"Sign in once to enable automatic reconnection"})]})]})]})}function bC({session:n,status:a,pin:r,error:l,roleChangeMessage:c,roleChangeBusy:d,onSignIn:m,onPinChange:p,onSubmitPin:g,onSwitchToHub:v}){const b=a?.connectionState==="connected",y=a?.system?.memoryTotalBytes?Number(a.system.memoryUsedBytes||0)/a.system.memoryTotalBytes*100:0,w=a?.system?.gpus||[],S=w.find(H=>Number.isFinite(H.usagePercent)||Number.isFinite(H.memoryTotalBytes))||w[0],j=Number.isFinite(S?.usagePercent)?Number(S?.usagePercent):null,N=Number.isFinite(S?.memoryTotalBytes)&&Number(S?.memoryTotalBytes)>0&&Number.isFinite(S?.memoryUsedBytes)?Number(S?.memoryUsedBytes)/Number(S?.memoryTotalBytes)*100:null,M=a?.system?.disks||[],k=a?.system?.network,E=k?.interfaces||[],R=[...new Set(E.map(H=>H.name).filter(Boolean))],U=E.map(H=>H.address).filter(Boolean);return s.jsxs("section",{className:"client-home-page",children:[s.jsxs("header",{className:"client-home-heading",children:[s.jsxs("div",{children:[s.jsx("p",{className:"client-unified-eyebrow",children:"THIS COMPUTER"}),s.jsx("h2",{children:a?.deviceName||"This Computer"})]}),s.jsxs("span",{className:`client-unified-role-chip ${b?"connected":""}`,children:[s.jsx(en,{size:15})," ",b?"Online":"Connecting"]})]}),s.jsxs("div",{className:"client-home-layout",children:[s.jsxs("section",{className:"client-main-surface","aria-label":"Client computer",children:[s.jsxs("div",{className:"client-main-surface-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"SYSTEM STATUS"}),s.jsx("strong",{children:"Hardware at a glance"})]}),s.jsxs("small",{children:[s.jsx(Ky,{size:14})," Uptime ",gC(a?.system?.uptimeSeconds)]})]}),s.jsxs("div",{className:"client-system-dashboard",children:[s.jsxs("section",{className:"client-performance-panel","aria-label":"Performance",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"PERFORMANCE"}),s.jsx("strong",{children:"Live resources"})]}),s.jsx("small",{children:"Live updates"})]}),s.jsxs("div",{className:"client-live-metrics",children:[s.jsx(Md,{icon:Qy,label:"CPU",value:Eh(a?.system?.cpuUsagePercent),detail:a?.system?.cpuLogicalCores?`${a.system.cpuLogicalCores} logical cores · Current processor usage`:"Current processor usage",percent:a?.system?.cpuUsagePercent}),s.jsx(Md,{icon:GS,label:"Memory",value:Eh(y),detail:hC(a?.system?.memoryUsedBytes,a?.system?.memoryTotalBytes),percent:y}),s.jsx(Md,{icon:VS,label:"GPU",value:Xm(j),detail:S?.name||(a?.system?.hardwareCollecting?"Detecting graphics hardware…":"Graphics usage unavailable"),percent:j}),s.jsx(Md,{icon:Ur,label:"VRAM",value:Xm(N),detail:pC(S?.memoryUsedBytes,S?.memoryTotalBytes),percent:N})]})]}),s.jsxs("section",{className:"client-storage-panel","aria-label":"Local storage",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"STORAGE"}),s.jsx("strong",{children:"Local drives"})]}),s.jsx("small",{children:M.length>0?`${M.length} ${M.length===1?"drive":"drives"}`:a?.system?.hardwareCollecting?"Detecting…":"Unavailable"})]}),s.jsxs("div",{className:"client-disk-list",children:[M.map(H=>s.jsxs("article",{className:"client-disk-row",children:[s.jsxs("div",{className:"client-disk-row-head",children:[s.jsxs("span",{children:[s.jsx(Ll,{size:16}),s.jsx("strong",{children:H.mount||"Disk"}),s.jsx("small",{children:H.name||"Local disk"})]}),s.jsx("strong",{children:Xm(H.usedPercent)})]}),s.jsxs("small",{children:[_l(H.freeBytes)," free · ",_l(H.totalBytes)," total"]}),s.jsx("i",{"aria-hidden":"true",children:s.jsx("b",{style:{width:db(H.usedPercent)}})})]},`${H.mount}-${H.name||""}`)),M.length===0&&s.jsxs("div",{className:"client-disk-empty",children:[s.jsx(Ll,{size:18}),s.jsx("span",{children:a?.system?.hardwareCollecting?"Detecting local drives…":"Storage information is not available."})]})]})]}),s.jsxs("section",{className:"client-network-panel","aria-label":"Network activity",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"NETWORK"}),s.jsx("strong",{children:"Live traffic"})]}),s.jsx("small",{children:R.length>0?R.join(", "):"Detecting adapter"})]}),s.jsxs("div",{className:"client-network-live",children:[s.jsxs("div",{className:"client-network-adapter",children:[s.jsx(Il,{size:18}),s.jsxs("span",{children:[s.jsx("strong",{children:R.join(", ")||"Network"}),s.jsx("small",{children:U.join(" / ")||"Checking active connection"})]})]}),s.jsxs("div",{className:"client-network-rate download",children:[s.jsx(WS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Receive"}),s.jsx("strong",{children:jx(k?.receiveBytesPerSecond)})]})]}),s.jsxs("div",{className:"client-network-rate upload",children:[s.jsx(YS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Send"}),s.jsx("strong",{children:jx(k?.sendBytesPerSecond)})]})]}),s.jsxs("small",{className:"client-network-total",children:["Total ",_l(k?.receivedBytes)," received / ",_l(k?.sentBytes)," sent"]})]})]})]})]}),s.jsxs("aside",{className:"client-connection-panel",children:[s.jsx("span",{className:"client-unified-section-label",children:"LIVEDESK SERVICES"}),s.jsx("h3",{children:b?"Connected to the Hub":a?.authenticated?"Finding the Hub":"Connect this computer"}),b?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"client-unified-copy",children:"This computer is available from the LiveDesk Hub."}),s.jsxs("div",{className:"client-service-status-list",children:[s.jsxs("div",{children:[s.jsx(en,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Screen sharing"}),s.jsx("small",{children:a?.permissions?.screenCapture?"Active":"Waiting"})]})]}),s.jsxs("div",{children:[s.jsx(Lt,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Remote control"}),s.jsx("small",{children:a?.permissions?.remoteInput?"Available":"Unavailable"})]})]}),s.jsxs("div",{children:[s.jsx(Lo,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"File delivery"}),s.jsx("small",{children:a?.permissions?.files?"Ready to receive":"Unavailable"})]})]}),s.jsxs("div",{children:[s.jsx(cn,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Computer audio"}),s.jsx("small",{children:a?.permissions?.audio?"Available":"Unavailable"})]})]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"client-unified-copy",children:a?.authenticated?"LiveDesk is checking the registered Hub endpoints. A temporary Hub PIN can be used as a fallback.":"Sign in once on this computer. LiveDesk saves the verified session, finds the Hub, and starts screen sharing automatically."}),!n&&!a?.authenticated?s.jsxs("button",{className:"client-unified-primary",type:"button",onClick:m,children:[s.jsx(zl,{size:16})," Sign in with Google"]}):s.jsxs("p",{className:"client-unified-success",children:[s.jsx(Hn,{size:16})," Signed in as ",n?.user.email||n?.user.id||a?.userEmail||a?.userId||"saved account"]}),s.jsxs("div",{className:"client-unified-pin-row",children:[s.jsx(_o,{size:16}),s.jsx("input",{value:r,onChange:H=>p(H.target.value),placeholder:"6-digit Hub PIN",inputMode:"numeric","aria-label":"6-digit Hub PIN"}),s.jsx("button",{className:"client-unified-secondary",type:"button",onClick:g,disabled:r.length!==6,children:"Connect"})]})]}),(l||a?.lastError)&&s.jsxs("p",{className:"client-unified-error",role:"alert",children:[s.jsx(Xy,{size:15})," ",l||a?.lastError]}),c&&s.jsx("p",{className:"client-unified-success",children:c}),s.jsxs("button",{className:"client-unified-secondary full client-hub-switch-trigger",type:"button",onClick:v,disabled:d||!a?.authenticated,children:[s.jsx(Ur,{size:16})," ",d?"Switching to Hub…":"Switch this computer to Hub"]})]})]})]})}function wC(){const[n,a]=u.useState(null),[r,l]=u.useState(null),[c,d]=u.useState(!1),[m,p]=u.useState(""),[g,v]=u.useState(""),[b,y]=u.useState(""),[w,S]=u.useState(!1),[j,N]=u.useState(!1),[M,k]=u.useState("computer"),[E,R]=u.useState(!1),U=u.useRef(null),H=u.useRef(null),W=u.useRef(!1),_=u.useRef(!1),L=u.useRef(!1),le=u.useRef(0),q=u.useMemo(mC,[]),te=u.useMemo(()=>vC(r),[r]),K=u.useMemo(()=>xC(r),[r]),ne=te.slice(0,1).toUpperCase()||"L",ce=u.useCallback(async()=>{if(v(""),window.liveDesk?.auth?.signInWithGoogle){const ie=await window.liveDesk.auth.signInWithGoogle();return ie?.ok===!1?(v(ie.error||"LiveDesk could not open the system browser for Google sign-in."),!1):!0}return window.location.assign(`${q}/auth/google`),!0},[q]),V=u.useCallback(async()=>{L.current||(L.current=!0,v("Your saved Google sign-in is incomplete. LiveDesk is reopening sign-in once to repair it."),await ct.auth.signOut({scope:"local"}).catch(()=>{}),l(null),await ce()||(L.current=!1))},[ce]),O=u.useCallback(async ie=>{const Q=wx(ie);if(Q)throw new Error(Q);if(W.current)return!1;W.current=!0;try{const Ie=await window.liveDesk?.auth?.persistSession?.(ie);if(Ie?.ok===!1)throw new Error(Ie.error||"LiveDesk could not validate the desktop session.");for(let Oe=0;Oe<2;Oe+=1){const ae=await Fc(q,Oe>0),ke=await fetch(`${q}/api/auth/session`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":ae},signal:AbortSignal.timeout(1e4),body:JSON.stringify({accessToken:ie.access_token,refreshToken:ie.refresh_token,expiresAt:ie.expires_at,user:{id:ie.user.id,email:ie.user.email}})}),je=await ke.json().catch(()=>({}));if(ke.status===403&&Oe===0){sessionStorage.removeItem("livedesk.client.csrf");continue}if(!ke.ok)throw new Error(je.error||`Client runtime returned HTTP ${ke.status}.`);return v(""),!0}throw new Error("Client runtime rejected the session transfer.")}finally{W.current=!1}},[q]),Y=u.useCallback(async()=>{try{const ie=await fetch(`${q}/api/client/status`,{cache:"no-store"}),Q=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(Q.error||`Client runtime returned HTTP ${ie.status}.`);if(Q.csrfToken&&sessionStorage.setItem("livedesk.client.csrf",Q.csrfToken),String(Q.role||"").toLowerCase()==="hub")throw new Error("This computer is assigned to the Hub role.");a(Q)}catch(ie){v(ie instanceof Error?ie.message:String(ie))}},[q]);u.useEffect(()=>{Y();const ie=window.setInterval(()=>{Y()},2e3);return()=>window.clearInterval(ie)},[Y]);const X=u.useCallback(async()=>{const ie=Date.now();if(!(!n?.authenticated||n.connectionState==="connected"||!["waiting","reconnecting"].includes(String(n.agent?.state||""))||ie-le.current<4e3)){le.current=ie;try{const Q=await fetch(`${q}/api/client/reconnect`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({onlyIfWaiting:!0,reason:"app-active"})});if(!Q.ok)throw new Error(`Client reconnect returned HTTP ${Q.status}.`);await Y()}catch(Q){v(Q instanceof Error?Q.message:String(Q))}}},[q,Y,n]);u.useEffect(()=>{const ie=()=>{X()},Q=()=>{X()},Ie=()=>{document.visibilityState==="visible"&&X()};return window.addEventListener("online",ie),window.addEventListener("focus",Q),document.addEventListener("visibilitychange",Ie),()=>{window.removeEventListener("online",ie),window.removeEventListener("focus",Q),document.removeEventListener("visibilitychange",Ie)}},[X]),u.useEffect(()=>{if(!c||!n||!r?.access_token||n.authenticated)return;if(wx(r)==="refresh-token-required"){V().catch(ae=>{L.current=!1,v(ae instanceof Error?ae.message:String(ae))});return}let ie=!1,Q,Ie=0;const Oe=async()=>{if(ie)return;try{const ke=await O(r);if(await Y(),ke)return}catch(ke){v(ke instanceof Error?ke.message:String(ke))}if(ie)return;const ae=Cx[Math.min(Ie,Cx.length-1)];Ie+=1,Q=window.setTimeout(()=>{Oe()},ae)};return Oe(),()=>{ie=!0,Q!==void 0&&window.clearTimeout(Q)}},[c,Y,V,r,n,O]),u.useEffect(()=>{const ie=new URLSearchParams(window.location.search),Q=ie.get("auth_error");if(!Q)return;v(Q),ie.delete("auth_error");const Ie=ie.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${Ie?`?${Ie}`:""}${window.location.hash}`)},[]),u.useEffect(()=>{let ie=!0;if(!window.liveDesk?.auth)return l(null),d(!0),Y(),()=>{ie=!1};const Q=window.liveDesk?.auth?.onComplete?.(Oe=>{Oe.ok&&Oe.session?ct.auth.setSession(Oe.session).catch(ae=>v(ae instanceof Error?ae.message:String(ae))):Oe.error&&v(Oe.error)});(async()=>{try{const Oe=window.liveDesk?.auth?.getSession?await window.liveDesk.auth.getSession():await ct.auth.getSession();if(!ie)return;const ae=rb(Oe);l(ae),Y()}catch(Oe){ie&&v(Oe instanceof Error?Oe.message:String(Oe))}finally{ie&&d(!0)}})();const{data:Ie}=ct.auth.onAuthStateChange((Oe,ae)=>{ie&&(l(ae),d(!0),Y())});return()=>{ie=!1,Q?.(),Ie.subscription.unsubscribe()}},[Y]),u.useEffect(()=>{if(!c||!n||_.current||L.current||r||n.authenticated)return;const ie=new URLSearchParams(window.location.search);if(!ie.has("livedesk_launch"))return;_.current=!0,ie.delete("livedesk_launch");const Q=ie.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${Q?`?${Q}`:""}${window.location.hash}`),ce().catch(Ie=>v(Ie instanceof Error?Ie.message:String(Ie)))},[c,r,ce,n]);const P=async()=>{R(!1),window.liveDesk?.auth?.persistSession?(await ct.auth.signOut(),(await window.liveDesk.auth.persistSession(null))?.runtimeCleared===!1&&v("Signed out locally. The LiveDesk runtime could not be reached to clear its session.")):await fetch(`${q}/api/auth/session`,{method:"DELETE",headers:{"X-LiveDesk-CSRF":await Fc(q)}}).catch(()=>{}),l(null),await Y()};u.useEffect(()=>{if(!E)return;const ie=Ie=>{Ie.target instanceof Element&&Ie.target.closest(".account-popover, .rail-account")||R(!1)},Q=Ie=>{Ie.key==="Escape"&&R(!1)};return window.addEventListener("pointerdown",ie),window.addEventListener("keydown",Q),()=>{window.removeEventListener("pointerdown",ie),window.removeEventListener("keydown",Q)}},[E]);const oe=u.useCallback((ie=!0)=>{w||(N(!1),ie&&window.requestAnimationFrame(()=>H.current?.focus()))},[w]),we=u.useCallback(()=>{w||!n?.authenticated||(H.current=document.activeElement instanceof HTMLElement?document.activeElement:null,y(""),N(!0))},[w,n?.authenticated]);u.useEffect(()=>{if(!j)return;const ie=window.requestAnimationFrame(()=>U.current?.focus()),Q=Oe=>{Oe.target instanceof Element&&Oe.target.closest(".client-hub-switch-popover, .client-hub-switch-trigger")||oe(!1)},Ie=Oe=>{Oe.key==="Escape"&&oe()};return window.addEventListener("pointerdown",Q),window.addEventListener("keydown",Ie),()=>{window.cancelAnimationFrame(ie),window.removeEventListener("pointerdown",Q),window.removeEventListener("keydown",Ie)}},[oe,j]);const J=async()=>{v("");try{const ie=await fetch(`${q}/api/client/pin`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({pin:m})}),Q=await ie.json().catch(()=>({}));if(!ie.ok||Q?.ok===!1)throw new Error(Q?.error||"PIN could not be accepted.");p(""),await Y()}catch(ie){v(ie instanceof Error?ie.message:String(ie))}},B=async()=>{N(!1),S(!0),y(""),v("");try{const ie=await fetch(`${q}/api/runtime/switch-role`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({role:"hub"})}),Q=await ie.json().catch(()=>({}));if(!ie.ok||Q?.ok===!1)throw new Error(Q?.error||`Role change failed with HTTP ${ie.status}.`);y("Hub role accepted. LiveDesk is restarting this computer with the Hub Wall.");const Ie=Number(n?.runtimePid||0);await lb({baseUrl:q,targetRole:"hub",previousRuntimePid:Ie,allowedStates:["running"]}),window.location.reload()}catch(ie){v(ie instanceof Error?ie.message:String(ie)),S(!1)}},pe=!!(n?.authenticated||r),ge=u.useMemo(()=>np(),[]),xe=rf("switch-to-hub",ge),Ae=rf("client",ge),_e=dC(ge);return s.jsxs("main",{className:"app-shell client-unified-shell",children:[s.jsxs("aside",{className:"tool-rail","aria-label":"LiveDesk Client tools",children:[s.jsx("div",{className:"rail-brand",title:"LiveDesk",children:s.jsx(ob,{size:25})}),s.jsx("nav",{className:"rail-tools","aria-label":"Client navigation",children:s.jsxs("div",{className:"client-main-tool-slot",children:[s.jsxs("button",{className:"rail-tool client-main-tool client-hub-tool client-hub-switch-trigger accent-blue",type:"button",onClick:we,disabled:w||!n?.authenticated,"aria-busy":w,"aria-expanded":j,"aria-haspopup":"dialog","aria-controls":j?"client-hub-switch-popover":void 0,"aria-label":`Hub. ${xe}`,"data-tooltip":j?void 0:Th("Hub","switch-to-hub",ge),children:[s.jsx(Ur,{size:19}),s.jsx("span",{children:w?"Switching…":"Hub"})]}),s.jsxs("button",{className:`rail-tool client-main-tool accent-blue ${M==="computer"?"active":""}`,type:"button",onClick:()=>k("computer"),"aria-current":M==="computer"?"page":void 0,"aria-label":`Client. ${Ae}`,"data-tooltip":Th("Client","client",ge),children:[s.jsx(en,{size:19}),s.jsx("span",{children:"Client"})]})]})}),s.jsxs("div",{className:"rail-footer",children:[fC.map(ie=>{const Q=ie.icon;return s.jsxs("button",{className:`rail-tool compact ${M===ie.id?"active":""}`,type:"button",onClick:()=>k(ie.id),title:ie.label,children:[s.jsx(Q,{size:18}),s.jsx("span",{children:ie.label})]},ie.id)}),s.jsxs("button",{className:`rail-account ${pe?"signed-in":""}`,type:"button",onClick:()=>R(ie=>!ie),"aria-expanded":E,"aria-haspopup":"dialog",title:pe?"Account":"Sign in",children:[r&&K?s.jsx("img",{src:K,alt:te,referrerPolicy:"no-referrer"}):r?s.jsx("span",{className:"avatar-fallback",children:ne}):pe?s.jsx(Lt,{size:18}):s.jsx(zl,{size:18}),s.jsx("span",{children:pe?"Account":"Sign in"})]})]})]}),j&&s.jsxs("section",{id:"client-hub-switch-popover",className:"client-hub-switch-popover",role:"dialog","aria-modal":"false","aria-labelledby":"client-hub-switch-title","aria-describedby":"client-hub-switch-description client-hub-switch-restart",children:[s.jsxs("header",{className:"client-hub-switch-head",children:[s.jsx("span",{className:"client-hub-switch-mark","aria-hidden":"true",children:s.jsx(Ur,{size:19})}),s.jsx("span",{className:"client-hub-switch-eyebrow",children:_e.eyebrow}),s.jsx("button",{className:"client-hub-switch-close",type:"button",onClick:()=>oe(),"aria-label":_e.closeLabel,children:s.jsx(Ja,{size:17})})]}),s.jsx("h2",{id:"client-hub-switch-title",children:_e.title}),s.jsx("p",{id:"client-hub-switch-description",children:_e.description}),s.jsxs("p",{id:"client-hub-switch-restart",className:"client-hub-switch-notice",children:[s.jsx(Lt,{size:16,"aria-hidden":"true"}),s.jsx("span",{children:_e.restartNotice})]}),s.jsxs("div",{className:"client-hub-switch-actions",children:[s.jsx("button",{type:"button",onClick:()=>oe(),children:_e.cancel}),s.jsxs("button",{ref:U,className:"primary",type:"button",onClick:()=>{B()},disabled:w||!n?.authenticated,children:[s.jsx(Ur,{size:16}),_e.confirm]})]})]}),E&&s.jsxs("section",{className:"account-popover",role:"dialog","aria-label":"LiveDesk account",children:[s.jsxs("div",{className:"account-popover-head",children:[s.jsx("div",{className:"account-popover-avatar",children:r&&K?s.jsx("img",{src:K,alt:te,referrerPolicy:"no-referrer"}):r?s.jsx("span",{children:ne}):s.jsx(zl,{size:18})}),s.jsxs("div",{children:[s.jsx("strong",{children:r?te:pe?"Saved account":"Account"}),s.jsx("p",{children:r?.user.email||n?.userEmail||n?.userId||"Not signed in"})]})]}),s.jsxs("dl",{className:"account-popover-facts",children:[s.jsx("dt",{children:"User"}),s.jsx("dd",{children:r?.user.email||n?.userEmail||n?.userId||"Not signed in"}),s.jsx("dt",{children:"Runtime"}),s.jsx("dd",{children:n?"Local app ready":"Checking local app"}),s.jsx("dt",{children:"Session"}),s.jsx("dd",{children:n?.auth?.persisted?"Saved on this computer":pe?"Active for this run":"Not saved"}),s.jsx("dt",{children:"Role"}),s.jsx("dd",{children:"Client"})]}),pe?s.jsxs("button",{className:"account-popover-action",onClick:()=>{P()},type:"button",children:[s.jsx(Yy,{size:16}),"Logout"]}):s.jsxs("button",{className:"account-popover-action primary",onClick:()=>{R(!1),ce()},type:"button",children:[s.jsx(zl,{size:16}),"Sign in with Google"]})]}),s.jsxs("section",{className:"desk-stage client-unified-stage",children:[s.jsx("header",{className:"topbar",children:s.jsxs("div",{className:"brand",children:[s.jsx("span",{className:"brand-mark",children:s.jsx(cn,{size:18})}),s.jsxs("div",{children:[s.jsx("h1",{children:"LiveDesk"}),s.jsx("p",{children:"Client workspace"})]})]})}),M==="support"?s.jsx("section",{className:"client-unified-page",children:s.jsx(ib,{session:r,currentProductKey:"livedesk",appVersion:n?.appVersion||"",onSignIn:()=>{ce()}})}):M!=="computer"?s.jsx("section",{className:"client-unified-page",children:s.jsx(yC,{page:M,status:n})}):s.jsx(bC,{session:r,status:n,pin:m,error:g,roleChangeMessage:b,roleChangeBusy:w,onSignIn:()=>{ce()},onPinChange:ie=>p(ie.replace(/\D/g,"").slice(0,6)),onSubmitPin:()=>{J()},onSwitchToHub:we})]})]})}function Br(n,a,r){if(r<0||a<0||a+r>n.length)throw new Error("Invalid LZO1X block: input overrun.")}function Zm(n,a,r){let l=0;for(;Br(n,a.inputIndex,1),n[a.inputIndex]===0;)l+=1,a.inputIndex+=1;const c=l*255+r+n[a.inputIndex];return a.inputIndex+=1,c}function Td(n,a,r,l){if(Br(n,a.inputIndex,l),a.outputIndex+l>r.length)throw new Error("Invalid LZO1X block: output overrun.");r.set(n.subarray(a.inputIndex,a.inputIndex+l),a.outputIndex),a.inputIndex+=l,a.outputIndex+=l}function SC(n,a,r,l){const c=a-r;if(c<=0||l<=0)throw new Error("Invalid LZO1X block: invalid match distance.");let d=Math.min(c,l);for(n.set(n.subarray(r,r+d),a);d<l;){const m=Math.min(d,l-d);n.copyWithin(a+d,a,a+m),d+=m}return a+l}function fb(n,a){if(!(n instanceof Uint8Array)||n.length<3||a<0)throw new Error("Invalid LZO1X block.");const r=new Uint8Array(a),l={inputIndex:0,outputIndex:0};let c=0,d=0;if(n[l.inputIndex]>=22){const m=n[l.inputIndex]-17;l.inputIndex+=1,Td(n,l,r,m),c=4}else n[l.inputIndex]>=18&&(c=n[l.inputIndex]-17,l.inputIndex+=1,Td(n,l,r,c));for(;;){Br(n,l.inputIndex,1);const m=n[l.inputIndex];l.inputIndex+=1;let p,g;if((m&192)!==0)Br(n,l.inputIndex,1),g=l.outputIndex-((n[l.inputIndex]<<3)+(m>>2&7)+1),l.inputIndex+=1,d=(m>>5)+1,p=m&3;else if((m&32)!==0){d=(m&31)+2,d===2&&(d+=Zm(n,l,31)),Br(n,l.inputIndex,2);const v=n[l.inputIndex]|n[l.inputIndex+1]<<8;l.inputIndex+=2,g=l.outputIndex-((v>>2)+1),p=v&3}else if((m&16)!==0){d=(m&7)+2,d===2&&(d+=Zm(n,l,7)),Br(n,l.inputIndex,2);const v=n[l.inputIndex]|n[l.inputIndex+1]<<8;if(l.inputIndex+=2,g=l.outputIndex-(((m&8)<<11)+(v>>2)),p=v&3,g===l.outputIndex)break;g-=16384}else if(c===0){let v=m+3;v===3&&(v+=Zm(n,l,15)),Td(n,l,r,v),c=4;continue}else c!==4?(Br(n,l.inputIndex,1),p=m&3,g=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+1),l.inputIndex+=1,d=2):(Br(n,l.inputIndex,1),p=m&3,g=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+2049),l.inputIndex+=1,d=3);if(g<0||l.outputIndex+d+p>r.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");l.outputIndex=SC(r,l.outputIndex,g,d),c=p,Td(n,l,r,p)}if(d!==3||l.inputIndex!==n.length||l.outputIndex!==r.length)throw new Error("Invalid LZO1X block: incomplete output.");return r}const kx=16,Ax=8,CC=24*1024*1024,mb=new Uint8Array(new Uint32Array([16909060]).buffer)[0]===4,Rh=new Uint32Array(65536);for(let n=0;n<Rh.length;n+=1){const a=Math.round((n>>11&31)*255/31),r=Math.round((n>>5&63)*255/63),l=Math.round((n&31)*255/31);Rh[n]=mb?(a|r<<8|l<<16|4278190080)>>>0:(a<<24|r<<16|l<<8|255)>>>0}function Hr(n,a){return n[a]|n[a+1]<<8}function jC(n,a){const r=Number(a);if(!Number.isSafeInteger(r)||r<kx||r>CC)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const l=n instanceof Uint8Array?n:new Uint8Array(n),c=fb(l,r);if(c[0]!==76||c[1]!==68||c[2]!==53||c[3]!==68)throw new Error("Invalid Mode 5 packet magic.");if(c[4]!==1)throw new Error(`Unsupported Mode 5 packet version: ${c[4]}.`);const d=(c[5]&1)!==0,m=Hr(c,6),p=Hr(c,8),g=Hr(c,10),v=Hr(c,12);if(m<=0||p<=0||m>3840||p>2160)throw new Error(`Invalid Mode 5 frame size: ${m}x${p}.`);if(g<=0||g>256||v>8192)throw new Error(`Invalid Mode 5 tile header: ${g}/${v}.`);const b=[];let y=kx;for(let w=0;w<v;w+=1){if(y+Ax>c.length)throw new Error("Mode 5 tile header is truncated.");const S=Hr(c,y),j=Hr(c,y+2),N=Hr(c,y+4),M=Hr(c,y+6);y+=Ax;const k=N*M*2;if(N<=0||M<=0||N>g||M>g||S+N>m||j+M>p||y+k>c.length)throw new Error(`Invalid Mode 5 tile ${w}.`);b.push({x:S,y:j,width:N,height:M,pixels:c.subarray(y,y+k)}),y+=k}if(y!==c.length)throw new Error(`Mode 5 packet has ${c.length-y} trailing bytes.`);return{keyFrame:d,width:m,height:p,tileSize:g,tiles:b}}function kC(n,a,r,l){if(!(n instanceof Uint8ClampedArray)||n.length!==a*r*4||l.width!==a||l.height!==r)throw new Error("Mode 5 canvas state does not match the packet dimensions.");let c=a,d=r,m=0,p=0;const g=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const v of l.tiles){const b=mb&&(v.pixels.byteOffset&1)===0?new Uint16Array(v.pixels.buffer,v.pixels.byteOffset,v.pixels.byteLength>>>1):null;let y=0;for(let w=0;w<v.height;w+=1){let S=(v.y+w)*a+v.x;for(let j=0;j<v.width;j+=1){const N=y<<1,M=b?b[y]:v.pixels[N]|v.pixels[N+1]<<8;g[S]=Rh[M],y+=1,S+=1}}c=Math.min(c,v.x),d=Math.min(d,v.y),m=Math.max(m,v.x+v.width),p=Math.max(p,v.y+v.height)}return l.tiles.length>0?{x:c,y:d,width:m-c,height:p-d}:null}const za=new WeakMap,au=new WeakMap,Dh=new WeakMap,su=new Set,Dl=new Set,lf=new WeakMap,Lh=new WeakMap,_h=new WeakMap,of=new WeakMap,hb=4,AC=2,NC=2,MC=2,TC=18,EC=40,RC=0,DC=250,pb=80,Nx=5,LC=150,_C=24,zC=180,IC=1200,OC=18,HC=.65,BC=2e3,FC=500,ap=250,PC=globalThis.LIVEDESK_ENABLE_CANVAS_VISUAL_SAMPLING===!0;let cf=!1;function $C(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function UC(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let Hl={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:UC()};function qC(n){n.h264DecodeAcceleration&&(Hl={...Hl,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(Hl.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function gb(n,a=Hl.h264DecodeAcceleration){const r=lf.get(n);return r?.requested===a?(r.actual!=="prefer-hardware"&&Dl.delete(n),r.actual):(r&&lf.delete(n),a!=="prefer-hardware"?(Dl.delete(n),a):Dl.has(n)?"prefer-hardware":Dl.size<Hl.h264HardwareDecoderBudget?(Dl.add(n),"prefer-hardware"):"prefer-software")}function xf(n,a){return a!=="prefer-hardware"?!1:(lf.set(n,{requested:a,actual:"prefer-software"}),Dl.delete(n),!0)}function GC(n,a,r,l=64){try{let c=Lh.get(n);c||(c={canvas:document.createElement("canvas"),lastHash:"",initialized:!1},Lh.set(n,c));const d=Math.max(8,Math.min(64,Math.round(l))),m=Math.max(1,Math.round(d*Math.max(1,r)/Math.max(1,a)));(c.canvas.width!==d||c.canvas.height!==m)&&(c.canvas.width=d,c.canvas.height=m);const p=c.canvas.getContext("2d",{willReadFrequently:!0});if(!p)return{visualHash:"",visualChanged:!0};p.drawImage(n,0,0,Math.max(1,a),Math.max(1,r),0,0,d,m);const g=p.getImageData(0,0,d,m).data;let v=2166136261;for(let w=0;w<g.length;w+=4)v^=g[w],v=Math.imul(v,16777619),v^=g[w+1],v=Math.imul(v,16777619),v^=g[w+2],v=Math.imul(v,16777619);const b=(v>>>0).toString(16).padStart(8,"0"),y=!c.initialized||b!==c.lastHash;return c.initialized=!0,c.lastHash=b,{visualHash:b,visualChanged:y}}catch{return{visualHash:"",visualChanged:!0}}}function zh(n,a,r,l=ap,c=64,d){if(!PC&&d)return vb(n,d);let m=_h.get(n);m||(m={lastHash:"",initialized:!1,lastCanvasSampleAt:0},_h.set(n,m));const p=performance.now();if(m.initialized&&l>0&&p-m.lastCanvasSampleAt<l)return{visualHash:m.lastHash,visualChanged:!1};const g=GC(n,a,r,c);return m.initialized=!0,m.lastHash=g.visualHash,m.lastCanvasSampleAt=p,g}function vb(n,a){let r=of.get(n);r||(r={lastHash:"",initialized:!1},of.set(n,r));const l=String(a.contentHash||""),c=!r.initialized||!l||l!==r.lastHash;return r.initialized=!0,r.lastHash=l,{visualHash:l,visualChanged:c}}function xb(n,a){const r=Dh.get(n);if(r)return r;const l=n.getContext("2d",{alpha:!1,desynchronized:a==="interactive"});if(l){const c=l.getContextAttributes?.(),d={context:l,presentation:c?.desynchronized?"desync":"sync"};return Dh.set(n,d),d}return null}function VC(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),r=String(n.compression||"").toLowerCase(),l=String(n.mimeType||"").toLowerCase();return a==="mode2-lzo"||r==="lzo1x"||l==="application/vnd.livedesk.lzo-rgb565"||a==="mode2-lz4"||String(n.compression||"").toLowerCase()==="lz4"||l==="application/vnd.livedesk.lz4-raw"}function WC(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function YC(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),r=String(n.mimeType||"").toLowerCase();return a==="mode5-lzo-delta"||r==="application/vnd.livedesk.lzo-rgb565-delta"}function Mx(n,a,r){let l=r,c=a;if(l===15){let d=255;for(;d===255;){if(c>=n.length)throw new Error("Invalid LZ4 block: length overrun.");d=n[c],c+=1,l+=d}}return{length:l,cursor:c}}function KC(n,a){const r=new Uint8Array(a);let l=0,c=0;for(;l<n.length;){const d=n[l];l+=1;const m=Mx(n,l,d>>4);l=m.cursor;const p=m.length;if(l+p>n.length||c+p>r.length)throw new Error("Invalid LZ4 block: literal overrun.");if(r.set(n.subarray(l,l+p),c),l+=p,c+=p,l>=n.length)break;if(l+2>n.length)throw new Error("Invalid LZ4 block: missing offset.");const g=n[l]|n[l+1]<<8;if(l+=2,g<=0||g>c)throw new Error("Invalid LZ4 block: bad match offset.");const v=Mx(n,l,d&15);l=v.cursor;const b=v.length+4;if(c+b>r.length)throw new Error("Invalid LZ4 block: match overrun.");let y=c-g;for(let w=0;w<b;w+=1)r[c]=r[y],c+=1,y+=1}if(c!==r.length)throw new Error("Invalid LZ4 block: incomplete output.");return r}function QC(n){const a=Math.max(1,Math.floor(n.width||0)),r=Math.max(1,Math.floor(n.height||0)),l=String(n.compression||"").toLowerCase(),c=String(n.pixelFormat||n.codec||"").toLowerCase();if(l==="lzo1x"||String(n.frameMode||n.mode||"").toLowerCase()==="mode2-lzo"||String(n.mimeType||"").toLowerCase()==="application/vnd.livedesk.lzo-rgb565"){const b=Math.max(1,Math.floor(n.bytesPerPixel||2)),y=a*r*2,w=Math.floor(n.uncompressedByteLength||y);if(b!==2||w!==y)throw new Error(`Invalid mode2 RGB565 frame size: ${w} for ${a}x${r}.`);if(c&&c!=="rgb565le"&&c!=="rgb565")throw new Error(`Unsupported mode2 pixel format: ${c}`);const S=fb(n.payload,y),j=new Uint8ClampedArray(a*r*4);for(let N=0,M=0;N<S.length;N+=2,M+=4){const k=S[N]|S[N+1]<<8,E=k>>11&31,R=k>>5&63,U=k&31;j[M]=E<<3|E>>2,j[M+1]=R<<2|R>>4,j[M+2]=U<<3|U>>2,j[M+3]=255}return new ImageData(j,a,r)}const m=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*r*m,Math.floor(n.uncompressedByteLength||0)),g=KC(n.payload,p);if(m!==4)throw new Error(`Unsupported mode2 pixel size: ${m}`);const v=new Uint8ClampedArray(a*r*4);if(c==="rgba32"||c==="rgba")v.set(g.subarray(0,v.length));else for(let b=0,y=0;y<v.length;b+=4,y+=4)v[y]=g[b+2],v[y+1]=g[b+1],v[y+2]=g[b],v[y+3]=g[b+3];return new ImageData(v,a,r)}function Tx(n,a="smooth"){const r=window.VideoDecoder;if(!r||!window.EncodedVideoChunk)throw new Error("WebCodecs H.264 decode is not supported in this browser.");const l=za.get(n);if(l&&l.decoder.state!=="closed"&&l.latencyMode===a)return l;l&&Os(n);let c;return c={decoder:new r({output:m=>{if(za.get(n)!==c){m.close();return}const p=Number(m.timestamp||0);c.outputSerial+=1;let g=c.pendingFrames.get(p);if(g)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const j=c.pendingFrames.entries().next().value;j&&(c.pendingFrames.delete(j[0]),g=j[1],c.timestampFallbacks+=1)}const v=m.displayWidth||m.codedWidth||n.width||960,b=m.displayHeight||m.codedHeight||n.height||540,y=Number(g?.frame.durationUs||0),w=Number(m.duration||0),S=Math.max(16,Math.min(250,(y>0?y:w||83333)/1e3));for(c.targetPaintIntervalMs=S,c.decodedFrames.push({videoFrame:m,pending:g,decodedAt:performance.now(),width:v,height:b,durationMs:S}),c.lastOutputAt=performance.now();c.decodedFrames.length>ip(c);)uf(c,c.decodedFrames.shift());yb(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>FC&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=hb&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),df(n,c)},error:()=>{za.get(n)===c&&(xf(n,c.hardwareAcceleration),sp(c),su.delete(n),za.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:gb(n),latencyMode:a,keyFrameSeen:!1,droppedForLatency:0,pendingFrames:new Map,decodedFrames:[],renderTimer:null,renderScheduledAt:0,flushTimer:null,flushInFlight:!1,flushCount:0,timestampFallbacks:0,inputSerial:0,outputSerial:0,lastFlushInputSerial:0,lastOutputAt:0,lastPaintAt:0,lastInputAt:0,interactiveBufferPrimed:!1,interactiveBufferStartedAt:0,interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,lastInputFrameSeq:void 0,targetPaintIntervalMs:1e3/12,nextChunkTimestampUs:0,healthSampleStartedAt:performance.now(),healthInputSerial:0,healthOutputSerial:0},za.set(n,c),su.add(n),c}function sp(n){n.renderTimer!==null&&(window.cancelAnimationFrame(n.renderTimer),n.renderTimer=null),n.renderScheduledAt=0,n.flushTimer!==null&&(window.clearTimeout(n.flushTimer),n.flushTimer=null),n.flushInFlight=!1;for(const a of n.decodedFrames)a.videoFrame.close();n.decodedFrames=[],n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0}function uf(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function ip(n){return n.latencyMode==="interactive"?NC:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?AC:hb}function yb(n,a=performance.now()){const r=ip(n);for(;n.decodedFrames.length>r;)uf(n,n.decodedFrames.shift());const l=n.latencyMode==="interactive"?pb:DC;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>l;)uf(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function bb(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const r=a.latencyMode==="interactive"?_C:LC,l=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,g]of a.pendingFrames.entries())c-g.queuedAt>BC&&a.pendingFrames.delete(p);if(za.get(n)!==a||a.decoder.state!=="configured"||a.pendingFrames.size===0||a.inputSerial<=a.lastFlushInputSerial||!l&&a.lastOutputAt>0&&c-a.lastOutputAt<r)return;const d=a.inputSerial,m=performance.now();a.flushInFlight=!0,a.flushCount+=1;try{await a.decoder.flush(),a.lastFlushInputSerial=Math.max(a.lastFlushInputSerial,d)}catch{za.get(n)===a&&Xd(a)}finally{a.flushInFlight=!1;const p=performance.now()-m;if(l&&p>=zC&&a.hardwareAcceleration==="prefer-hardware"){cf=!0,xf(n,a.hardwareAcceleration),Os(n);return}za.get(n)===a&&a.inputSerial>d&&a.pendingFrames.size>0&&(l||performance.now()-a.lastOutputAt>=r)&&bb(n,a)}},r)}function Ex(n,a,r){const l=performance.now();try{(n.width!==r.width||n.height!==r.height)&&(n.width=r.width,n.height=r.height);const c=xb(n,a.latencyMode);if(c?.context.drawImage(r.videoFrame,0,0,r.width,r.height),r.pending){const d=performance.now(),p=a.latencyMode==="interactive"?vb(n,r.pending.frame):zh(n,r.width,r.height,ap,64,r.pending.frame);try{a.onPaint?.(r.pending.frame,{deviceId:r.pending.frame.deviceId,frameSeq:r.pending.frame.frameSeq,mode:r.pending.frame.frameMode||r.pending.frame.mode||r.pending.frame.codec||r.pending.frame.mimeType,width:r.width,height:r.height,byteLength:r.pending.frame.byteLength,queuedForMs:Math.max(0,l-r.pending.queuedAt),decodedForMs:Math.max(0,r.decodedAt-r.pending.queuedAt),scheduledForMs:Math.max(0,l-r.decodedAt),drawMs:Math.max(0,d-l),queueSize:r.pending.queueSize,renderQueueSize:a.decodedFrames.length,droppedForLatency:a.droppedForLatency,h264DecodeAcceleration:a.hardwareAcceleration,decoderLabel:a.hardwareAcceleration,decoderFlushCount:a.flushCount,decoderTimestampFallbacks:a.timestampFallbacks,decoderInputCount:a.inputSerial,decoderOutputCount:a.outputSerial,targetPaintIntervalMs:a.targetPaintIntervalMs,canvasPresentation:c?.presentation||"sync",interactiveBufferWaitCount:a.interactiveBufferWaitCount,interactiveBufferWaitMs:a.interactiveBufferWaitMs,interactiveQueueDrainCount:a.interactiveQueueDrainCount,visualHash:p.visualHash,visualChanged:p.visualChanged,paintedAt:d})}catch{}}a.lastPaintAt=performance.now()}finally{r.videoFrame.close()}}function df(n,a){if(a.renderTimer!==null||a.decodedFrames.length===0)return;const r=Math.max(16,Math.min(250,a.targetPaintIntervalMs||1e3/12)),l=()=>{if(a.renderTimer=null,a.renderScheduledAt=0,a.decodedFrames.length===0)return;const c=performance.now();if(yb(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const g=a.targetPaintIntervalMs<=EC,v=a.targetPaintIntervalMs<=20;if(v&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const N=a.decodedFrames.length>=MC,M=c-a.interactiveBufferStartedAt>=TC;if(!N&&!M){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else v||(a.interactiveBufferPrimed=!0);const b=a.decodedFrames[0],y=b?.pending?Math.max(0,c-b.pending.queuedAt):0,w=a.lastPaintAt>0?a.lastPaintAt+r:c;if(!(!g||c+Nx>=w||y>=pb)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const j=a.decodedFrames.shift();if(j)try{Ex(n,a,j)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),df(n,a);return}const d=a.lastPaintAt>0?a.lastPaintAt+r:c+RC;if(!(c+Nx>=d||a.decodedFrames.length>=Math.max(1,ip(a)-1))){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const p=a.decodedFrames.shift();if(p)try{Ex(n,a,p)}catch{}df(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l)}function wb(n,a){if(za.get(n)!==a||a.decoder.state==="closed")return!1;for(a.renderTimer!==null&&(window.cancelAnimationFrame(a.renderTimer),a.renderTimer=null),a.renderScheduledAt=0;a.decodedFrames.length>1;)uf(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,df(n,a),!0}function Jm(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of su){const a=za.get(n);if(!a||a.decoder.state==="closed"){su.delete(n);continue}wb(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",Jm),window.addEventListener("focus",Jm),window.addEventListener("pageshow",Jm));function Os(n){Dl.delete(n),su.delete(n),of.delete(n);const a=za.get(n);if(a){za.delete(n);try{sp(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function Pc(n){n&&(lf.delete(n),Dh.delete(n),_h.delete(n),Lh.delete(n),of.delete(n),au.delete(n),Os(n))}function Xd(n,a=1){try{n.decoder.state!=="closed"&&n.decoder.reset()}catch{}n.configured=!1,n.configKey="",n.keyFrameSeen=!1,n.pendingFrames.clear(),sp(n),n.lastPaintAt=0,n.lastOutputAt=0,n.lastInputAt=0,n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0,n.lastInputFrameSeq=void 0,n.nextChunkTimestampUs=0,n.healthSampleStartedAt=performance.now(),n.healthInputSerial=n.inputSerial,n.healthOutputSerial=n.outputSerial,n.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a)))}function Ed(n,a,r,l){n.decoder.configure(a),n.configured=!0,n.configKey=r,n.codec=a.codec,n.hardwareAcceleration=l,n.keyFrameSeen=!1,n.nextChunkTimestampUs=0,n.lastInputFrameSeq=void 0}function XC(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const r=performance.now();if(r-a.healthSampleStartedAt<IC)return!1;const l=a.inputSerial-a.healthInputSerial,c=a.outputSerial-a.healthOutputSerial;return a.healthSampleStartedAt=r,a.healthInputSerial=a.inputSerial,a.healthOutputSerial=a.outputSerial,l<OC||c/Math.max(1,l)>=HC?!1:(cf=!0,xf(n,a.hardwareAcceleration),Os(n),!0)}function eh(n,a=1){if(!n)return!1;const r=za.get(n);return r?(r.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),Os(n),!0):!1}function ZC(n){if(!n)return!1;const a=za.get(n);return a?wb(n,a):!1}function JC(n,a,r,l="interactive"){Os(n);const c=performance.now(),d=jC(a.payload,a.uncompressedByteLength||0),m=String(a.streamId||"mode5");let p=au.get(n);if(!p||p.streamId!==m||p.width!==d.width||p.height!==d.height){const N=new Uint8ClampedArray(d.width*d.height*4);for(let M=3;M<N.length;M+=4)N[M]=255;p={streamId:m,width:d.width,height:d.height,rgba:N,imageData:new ImageData(N,d.width,d.height),keyFrameSeen:!1,inputSerial:0,outputSerial:0},au.set(n,p)}if(!p)throw new Error("Mode 5 canvas state could not be initialized.");p.inputSerial+=1;const v=Number(a.streamFrameSeq||0);if(v>0&&(p.lastStreamFrameSeq=v),!d.keyFrame&&!p.keyFrameSeen)return;d.keyFrame&&(p.keyFrameSeen=!0);const b=kC(p.rgba,p.width,p.height,d),y=performance.now();(n.width!==p.width||n.height!==p.height)&&(n.width=p.width,n.height=p.height);const w=xb(n,l),S=performance.now();b&&w?.context.putImageData(p.imageData,0,0,b.x,b.y,b.width,b.height);const j=performance.now();p.outputSerial+=1,r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.mimeType,width:p.width,height:p.height,byteLength:a.byteLength,queuedForMs:Math.max(0,j-c),decodedForMs:Math.max(0,y-c),scheduledForMs:0,drawMs:Math.max(0,j-S),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:"prefer-software",decoderLabel:"lzo-rgb565-delta",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:p.inputSerial,decoderOutputCount:p.outputSerial,targetPaintIntervalMs:Math.max(1,Number(a.durationUs||0)/1e3||1e3/30),canvasPresentation:w?.presentation||"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:String(a.contentHash||""),visualChanged:Number(a.deltaVisualTileCount||0)>0,paintedAt:j})}const th=[{code:30,maxFrameSize:1620,maxMacroblocksPerSecond:40500},{code:31,maxFrameSize:3600,maxMacroblocksPerSecond:108e3},{code:32,maxFrameSize:5120,maxMacroblocksPerSecond:216e3},{code:40,maxFrameSize:8192,maxMacroblocksPerSecond:245760},{code:41,maxFrameSize:8192,maxMacroblocksPerSecond:245760},{code:42,maxFrameSize:8704,maxMacroblocksPerSecond:522240},{code:50,maxFrameSize:22080,maxMacroblocksPerSecond:589824},{code:51,maxFrameSize:36864,maxMacroblocksPerSecond:983040},{code:52,maxFrameSize:36864,maxMacroblocksPerSecond:2073600}];function Rx(n,a){for(let r=Math.max(0,a);r+3<n.length;r+=1)if(!(n[r]!==0||n[r+1]!==0)){if(n[r+2]===1)return{index:r,length:3};if(n[r+2]===0&&n[r+3]===1)return{index:r,length:4}}return null}function ej(n){let a=0;for(;a<n.length;){const r=Rx(n,a);if(!r)break;const l=r.index+r.length,c=Rx(n,l),d=c?.index??n.length;if(l<d&&(n[l]&31)===7){const m=[];let p=0;for(let g=l+1;g<d;g+=1){const v=n[g];if(p>=2&&v===3){p=0;continue}m.push(v),p=v===0?p+1:0}if(m.length>=3)return`avc1.${m.slice(0,3).map(g=>g.toString(16).toUpperCase().padStart(2,"0")).join("")}`}a=c?c.index:n.length}return""}function tj(n,a,r,l,c=""){const d=Math.ceil(n/16)*Math.ceil(a/16),m=r>0?1e6/r:30,p=d*m,g=th.find(v=>d<=v.maxFrameSize&&p<=v.maxMacroblocksPerSecond)||th[th.length-1];return ej(l)||c||`avc1.42E0${g.code.toString(16).toUpperCase().padStart(2,"0")}`}function nj(n,a,r,l,c="smooth"){au.delete(n);const d=String(a.h264Format||"").toLowerCase()==="avc"?"avc":"annexb",m=Math.max(1,Math.floor(a.width||960)),p=Math.max(1,Math.floor(a.height||540)),g=Math.max(1,Math.floor(a.durationUs||1e6/12));let v=Tx(n,c);const b=tj(m,p,g,a.payload,v.codec),y=String(a.frameMode||a.mode||"").toLowerCase(),w=c==="interactive"&&l==="prefer-hardware"&&$C(),j=y==="mode4-h264-atlas"?"prefer-software":gb(n,c==="interactive"&&(cf||w)?"prefer-software":l),N=[a.streamId||"",a.commandId||"",m,p,b,d,j,c].join("|");v.onPaint=r,v.configured&&v.decoder.state!=="configured"&&(v.configured=!1,v.configKey=""),v.configured&&v.configKey!==N&&(Os(n),v=Tx(n,c),v.onPaint=r);const M={codec:b,codedWidth:m,codedHeight:p,hardwareAcceleration:j,optimizeForLatency:!0,avc:{format:d}};v.configured||Ed(v,M,N,j);const k=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const E=Number(a.streamFrameSeq||0);if(E>0&&v.lastInputFrameSeq!==void 0){if(E<=v.lastInputFrameSeq){if(!k||E===v.lastInputFrameSeq)return;Xd(v,v.lastInputFrameSeq-E+1),Ed(v,M,N,j)}if(E>v.lastInputFrameSeq+1){if(Xd(v,E-v.lastInputFrameSeq-1),!k)return;Ed(v,M,N,j)}}if(E>0&&(v.lastInputFrameSeq=E),!k&&!v.keyFrameSeen)return;k&&(v.keyFrameSeen=!0);const R=Number(v.decoder.decodeQueueSize||0);if(R>8){if(v.latencyMode==="interactive"&&v.hardwareAcceleration==="prefer-hardware"){cf=!0,xf(n,v.hardwareAcceleration),Os(n);return}if(Xd(v),!k)return;Ed(v,M,N,j),v.keyFrameSeen=!0}const U=v.nextChunkTimestampUs;v.nextChunkTimestampUs+=g,v.pendingFrames.set(U,{frame:a,queuedAt:performance.now(),queueSize:R}),v.inputSerial+=1,v.lastInputAt=performance.now();const H=new EncodedVideoChunk({type:k?"key":"delta",timestamp:U,duration:g,data:a.payload});try{v.decoder.decode(H)}catch(W){throw Os(n),W}bb(n,v),XC(n,v)}async function nh(n,a,r,l,c,d="smooth"){if(YC(a)){r()||JC(n,a,l,d);return}if(WC(a)){r()||nj(n,a,l,c,d);return}if(au.delete(n),VC(a)){Os(n);const y=QC(a);if(r())return;(n.width!==y.width||n.height!==y.height)&&(n.width=y.width,n.height=y.height);const w=n.getContext("2d"),S=performance.now();w?.putImageData(y,0,0);const j=performance.now(),N=zh(n,y.width,y.height,ap,64,a);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:y.width,height:y.height,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,j-S),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Hl.h264DecodeAcceleration,decoderLabel:"lzo-rgb565",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:N.visualHash,visualChanged:N.visualChanged,paintedAt:j});return}Os(n);const m=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(m);if(r()){p.close();return}const g=a.width||p.width||960,v=a.height||p.height||540;(n.width!==g||n.height!==v)&&(n.width=g,n.height=v);const b=n.getContext("2d");if(b){const y=performance.now();b.clearRect(0,0,g,v),b.drawImage(p,0,0,g,v);const w=performance.now(),S=zh(n,g,v);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:g,height:v,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,w-y),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Hl.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:S.visualHash,visualChanged:S.visualChanged,paintedAt:w})}p.close()}const Dx="livedesk_remote_host_targets",aj="livedesk_entitlements",rp=new TextDecoder;function sj(n){const r=(Array.isArray(n)?n:[n||bn]).map(l=>Wr(l||bn));return[...new Set(r.filter(Boolean))]}function ij(){const[n,a]=u.useState(null),[r,l]=u.useState(!0);return u.useEffect(()=>{let c=!0;const d=window.liveDesk?.auth?.onComplete?.(p=>{p.ok&&p.session&&ct.auth.setSession(p.session)});(window.liveDesk?.auth?.getSession?.()||ct.auth.getSession()).then(p=>{c&&(a(rb(p)),l(!1))});const{data:{subscription:m}}=ct.auth.onAuthStateChange((p,g)=>{a(g),l(!1),window.liveDesk?.auth?.persistSession?.(g)});return()=>{c=!1,d?.(),m.unsubscribe()}},[]),{session:n,loading:r}}function rj(n,a=!0){const[r,l]=u.useState(null),[c,d]=u.useState([]),[m,p]=u.useState(""),[g,v]=u.useState(""),[b,y]=u.useState(0),w=u.useRef(new Map),S=Array.isArray(n)?n.join(`
|
|
12
12
|
`):String(n||""),j=u.useMemo(()=>sj(n),[S]),N=u.useMemo(()=>j.find(E=>Zc(E)==="loopback")||j[0]||bn,[j]),M=u.useCallback(async()=>{if(!a){l(null),d([]),v(""),p("");return}let E=null;const R=Date.now(),U=j.filter(H=>(w.current.get(H)||0)<=R);if(U.length===0)throw new Error("No LiveDesk Hub endpoint is reachable. Retrying shortly.");for(const H of U)try{const[W,_]=await Promise.all([Ge("/api/remote/status",void 0,H),Ge("/api/remote/devices",void 0,H)]);if(!Array.isArray(_.devices))throw new Error("Invalid Hub devices response.");w.current.delete(H),l(W),d(_.devices),v(H),p("");return}catch(W){E=W,w.current.set(H,Date.now()+1e4)}throw v(""),E||new Error("No LiveDesk Hub endpoint is reachable.")},[a,j]),k=u.useCallback(()=>{w.current.clear(),M().catch(E=>{p(E instanceof Error?E.message:String(E))}),y(E=>E+1)},[M]);return u.useEffect(()=>{if(!a){l(null),d([]),v(""),p("");return}let E=!0;const R=async()=>{try{await M()}catch(H){E&&p(H instanceof Error?H.message:String(H))}};R();const U=window.setInterval(R,2500);return()=>{E=!1,window.clearInterval(U)}},[a,M,b]),{status:r,devices:c,error:m,refresh:k,hubBaseUrl:g||N,hubCandidates:j}}function lj(n){const[a,r]=u.useState(null),[l,c]=u.useState(""),d=n?.user?.id||"",m=u.useCallback(async()=>{if(!d){r(null);return}const{data:p,error:g}=await ct.from(Dx).select("*").eq("user_id",d).maybeSingle();if(g){c(g.message);return}r(p),c("")},[d]);return u.useEffect(()=>{m()},[m]),u.useEffect(()=>{if(!d)return;const p=ct.channel(`livedesk-remote-host-targets-${d.replace(/[^a-zA-Z0-9]/g,"")}`).on("postgres_changes",{event:"*",schema:"public",table:Dx,filter:`user_id=eq.${d}`},g=>r(g.new)).subscribe();return()=>{ct.removeChannel(p)}},[d]),{target:a,error:l,refresh:m}}function oj(n){const[a,r]=u.useState(null),[l,c]=u.useState(!1),[d,m]=u.useState(""),p=n?.user?.id||"",g=u.useCallback(async()=>{if(!p){r(null),m(""),c(!1);return}c(!0);const{data:b,error:y}=await ct.from(aj).select("*").eq("user_id",p).eq("product_key","livedesk").maybeSingle();if(y){m(y.message),c(!1);return}r(b),m(""),c(!1)},[p]);u.useEffect(()=>{g()},[g]);const v=u.useMemo(()=>!a||a.status!=="active"?!1:a.expires_at?new Date(a.expires_at).getTime()>Date.now():!0,[a]);return{entitlement:a,licensed:v,loading:l,error:d,refresh:g}}const Jc={totalFrames:0,totalBytes:0,framesPerSecond:0,bytesPerSecond:0,sampleMs:0,lastUpdatedAt:0},cj=2500,uj=3e4,dj=64*1024,fj=6,mj=fj,Sb=new Map;function hj(n){return Sb.get(n)}const Lx={totalSent:0,totalDropped:0,sentPerSecond:0,droppedPerSecond:0,bufferedAmount:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0,lastUpdatedAt:0};function _x(n){const a=Date.parse(String(n||""));if(!Number.isFinite(a))return 0;const r=Date.now()-a;return r>0&&r<=uj?r:0}function zx(n,a,r=bn,l={}){const[c,d]=u.useState(new Map),[m,p]=u.useState("idle"),[g,v]=u.useState(""),[b,y]=u.useState(Jc),w=u.useRef(new Map),S=u.useRef(new Map),j=u.useRef(0),N=u.useRef(new Map),M=u.useRef({enabled:!1,token:"",reason:""}),k=u.useRef(new Set),[E,R]=u.useState(0),U=u.useRef(l.onFrame),H=u.useRef(l.onStreamReady),W=u.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),_=u.useMemo(()=>[...n].sort().join(","),[n]),L=Number.isFinite(l.fps)?Number(l.fps):2,le=Number.isFinite(l.maxWidth)?Number(l.maxWidth):640,q=Number.isFinite(l.maxHeight)?Number(l.maxHeight):360,te=Number.isFinite(l.quality)?Number(l.quality):45,K=String(l.frameMode||l.mode||"mode3-h264-hw").trim()||"mode3-h264-hw",ne=l.streamPurpose==="control"?"control":"wall",ce=l.forceRestart===!0,V=String(l.forceRestartToken||"").trim(),O=String(l.restartReason||"").trim();M.current={enabled:ce,token:V,reason:O};const Y=u.useMemo(()=>{const pe=Object.entries(l.monitorSelections||{}).filter(([ge])=>!!ge).sort(([ge],[xe])=>ge.localeCompare(xe));return JSON.stringify(Object.fromEntries(pe))},[l.monitorSelections]);u.useEffect(()=>{U.current=l.onFrame},[l.onFrame]),u.useEffect(()=>{H.current=l.onStreamReady},[l.onStreamReady]);const X=u.useCallback((pe,ge="livedesk-frame-socket-release")=>{pe.disposed=!0;try{pe.socket.readyState===WebSocket.CONNECTING||pe.socket.readyState===WebSocket.OPEN?pe.socket.close(1e3,ge):pe.socket.close()}catch{}},[]),P=u.useCallback(()=>{const pe=[...S.current.values()].map(ge=>ge.socket);if(pe.length===0){p("idle");return}if(pe.some(ge=>ge.readyState===WebSocket.OPEN)){p("open");return}if(pe.some(ge=>ge.readyState===WebSocket.CONNECTING)){p("connecting");return}p("closed")},[]),oe=u.useCallback((pe,ge,xe,Ae)=>{if(ge.disposed||ge.socket.readyState!==WebSocket.OPEN)return!1;try{return ge.socket.send(JSON.stringify({...ge.payload,type:"restart-live",deviceIds:[pe],forceRestart:!0,restartReason:xe,restartToken:Ae})),!0}catch{return!1}},[]),we=u.useCallback((pe,ge)=>{if(!pe||pe.byteLength<5)return;const xe=Date.now(),_e=new DataView(pe).getUint32(0,!1);if(_e<=0||_e+4>pe.byteLength)return;const ie=new Uint8Array(pe,4,_e),Q=JSON.parse(rp.decode(ie));if(Math.max(_x(Q.receivedAt),_x(Q.capturedAt))>cj)return;const Oe=new Uint8Array(pe,4+_e),ae={deviceId:String(Q.deviceId||""),kind:Q.kind==="thumbnail"?"thumbnail":"live",frameSeq:Number(Q.frameSeq||0),streamFrameSeq:Number(Q.streamFrameSeq||0)||void 0,streamId:String(Q.streamId||""),commandId:Q.commandId?String(Q.commandId):void 0,sessionId:Q.sessionId?String(Q.sessionId):void 0,captureGeneration:Number(Q.captureGeneration||0)||void 0,streamPurpose:Q.streamPurpose?String(Q.streamPurpose):void 0,width:Number(Q.width||0),height:Number(Q.height||0),sourceWidth:Number(Q.sourceWidth||0)||void 0,sourceHeight:Number(Q.sourceHeight||0)||void 0,mimeType:String(Q.mimeType||"image/jpeg"),mode:Q.mode?String(Q.mode):void 0,frameMode:Q.frameMode?String(Q.frameMode):void 0,frameProfile:Q.frameProfile?String(Q.frameProfile):void 0,encoding:Q.encoding?String(Q.encoding):void 0,codec:Q.codec?String(Q.codec):void 0,compression:Q.compression?String(Q.compression):void 0,pixelFormat:Q.pixelFormat?String(Q.pixelFormat):void 0,bytesPerPixel:Number(Q.bytesPerPixel||0)||0,uncompressedByteLength:Number(Q.uncompressedByteLength||0)||0,h264Format:Q.h264Format?String(Q.h264Format):void 0,isKeyFrame:Q.isKeyFrame===!0,chunkType:Q.chunkType?String(Q.chunkType):void 0,timestampUs:Number(Q.timestampUs||0)||0,durationUs:Number(Q.durationUs||0)||0,sourceGapMs:Number(Q.sourceGapMs||0)||0,agentSendGapMs:Number(Q.agentSendGapMs||0)||0,agentSendDurationMs:Number(Q.agentSendDurationMs||0)||0,agentSendDurationFrameSeq:Number(Q.agentSendDurationFrameSeq||0)||0,agentPaceMs:Number(Q.agentPaceMs||0)||0,agentQueueBeforePaceMs:Number(Q.agentQueueBeforePaceMs||0)||0,agentFrameAgeMs:Number(Q.agentFrameAgeMs||0)||0,droppedByAgent:Number(Q.droppedByAgent||0)||0,hubIngressDropped:Number(Q.hubIngressDropped||0)||0,hubClientDropped:Number(Q.hubClientDropped||0)||0,hardwareEncoder:Q.hardwareEncoder?String(Q.hardwareEncoder):void 0,platformProfile:Q.platformProfile?String(Q.platformProfile):void 0,monitorIndex:Number.isFinite(Number(Q.monitorIndex))?Number(Q.monitorIndex):void 0,monitorCount:Number.isFinite(Number(Q.monitorCount))?Number(Q.monitorCount):void 0,requestedFps:Number(Q.requestedFps||0)||0,effectiveFps:Number(Q.effectiveFps||0)||0,captureAverageMs:Number(Q.captureAverageMs||0)||0,captureP95Ms:Number(Q.captureP95Ms||0)||0,slowFrameCount:Number(Q.slowFrameCount||0)||0,captureHelperRestarts:Number(Q.captureHelperRestarts||0)||0,capturedAt:String(Q.capturedAt||""),receivedAt:String(Q.receivedAt||""),hubPacketAt:Q.hubPacketAt?String(Q.hubPacketAt):void 0,hubPacketEpochMs:Number.isFinite(Number(Q.hubPacketEpochMs))?Number(Q.hubPacketEpochMs):void 0,browserReceivedEpochMs:xe,byteLength:Number(Q.byteLength||Oe.byteLength),contentHash:Q.contentHash?String(Q.contentHash):void 0,captureMs:Number(Q.captureMs||0)||0,captureStageMs:Number(Q.captureStageMs||0)||0,convertMs:Number(Q.convertMs||0)||0,compressMs:Number(Q.compressMs||0)||0,captureSourceSerial:Number(Q.captureSourceSerial||0)||0,captureSourceSkipped:Number(Q.captureSourceSkipped||0)||0,deltaTileSize:Number(Q.deltaTileSize||0)||0,deltaTileCount:Number(Q.deltaTileCount||0)||0,deltaVisualTileCount:Number(Q.deltaVisualTileCount||0)||0,deltaRefreshTileCount:Number(Q.deltaRefreshTileCount||0)||0,deltaTotalTiles:Number(Q.deltaTotalTiles||0)||0,payload:Oe};if(!ae.deviceId)return;const ke={streamId:ge.lastFrameStreamId,commandId:ge.lastFrameCommandId,order:ge.lastFrameOrder},je=Number(ae.streamFrameSeq||ae.frameSeq||0),De=!!ke.commandId&&!!ae.commandId,Le=ke.streamId===ae.streamId&&(!De||ke.commandId===ae.commandId),$e=ke.order;if(Le&&$e>=je&&($e===je||De))return;ge.lastFrameStreamId=ae.streamId,ge.lastFrameCommandId=ae.commandId||"",ge.lastFrameOrder=je;const he=W.current;he.totalFrames+=1,he.totalBytes+=Oe.byteLength,he.sampleFrames+=1,he.sampleBytes+=Oe.byteLength;const Me=!w.current.has(ae.deviceId);w.current.set(ae.deviceId,ae),Me&&d(new Map(w.current)),U.current?.(ae)},[]);u.useEffect(()=>{const pe=window.setInterval(()=>{const ge=performance.now(),xe=W.current,Ae=Math.max(1,ge-xe.sampleStartedAt);y({totalFrames:xe.totalFrames,totalBytes:xe.totalBytes,framesPerSecond:xe.sampleFrames*1e3/Ae,bytesPerSecond:xe.sampleBytes*1e3/Ae,sampleMs:Ae,lastUpdatedAt:Date.now()}),d(new Map(w.current)),xe.sampleFrames=0,xe.sampleBytes=0,xe.sampleStartedAt=ge},2e3);return()=>{window.clearInterval(pe)}},[]),u.useEffect(()=>{const pe=_?_.split(",").filter(Boolean):[],ge=new Set(pe),xe=performance.now();for(const[Ae,_e]of S.current.entries())ge.has(Ae)||(X(_e,"livedesk-device-unsubscribed"),S.current.delete(Ae),N.current.delete(Ae),w.current.delete(Ae));if(pe.length===0){for(const Ae of S.current.values())X(Ae,"livedesk-no-devices");S.current.clear(),N.current.clear(),w.current=new Map,d(new Map),v(""),W.current={totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0},y(Jc),P();return}W.current.sampleStartedAt<=0&&(W.current.sampleStartedAt=xe,y({...Jc,lastUpdatedAt:Date.now()}));for(const Ae of pe){const _e=l.monitorSelections?.[Ae],ie=Number.isFinite(Number(_e))?{[Ae]:Number(_e)}:{},Q={type:"subscribe",deviceIds:[Ae],autoStartLive:a,fps:L,maxWidth:le,maxHeight:q,quality:te,mode:K,frameMode:K,streamPurpose:ne,monitorSelections:ie},Ie=JSON.stringify(Q),Oe=S.current.get(Ae);if(Oe){const De=Oe.socket.readyState===WebSocket.CONNECTING||Oe.socket.readyState===WebSocket.OPEN;if(Oe.payloadKey===Ie&&De&&!Oe.disposed)continue}const ae=Oe&&(Oe.socket.readyState===WebSocket.CONNECTING||Oe.socket.readyState===WebSocket.OPEN)&&!Oe.disposed?Oe.handoffFrom&&!Oe.handoffCompleted?Oe.handoffFrom:Oe:void 0;Oe&&Oe!==ae&&X(Oe,"livedesk-subscription-superseded");const ke=new WebSocket(vf(`/api/remote/frames/ws?devices=${encodeURIComponent(Ae)}`,r));ke.binaryType="arraybuffer";const je={socket:ke,payload:Q,payloadKey:Ie,generation:j.current+1,disposed:!1,handoffFrom:ae,handoffCompleted:!1,lastFrameStreamId:"",lastFrameCommandId:"",lastFrameOrder:-1};j.current=je.generation,S.current.set(Ae,je),ke.addEventListener("open",()=>{if(je.disposed||S.current.get(Ae)!==je){X(je,"livedesk-stale-frame-socket");return}v("");const De=M.current,Le=De.enabled&&(!De.token||N.current.get(Ae)!==De.token);ke.send(JSON.stringify({...je.payload,forceRestart:Le,restartReason:Le?De.reason:"",restartToken:Le?De.token:""})),Le&&De.token&&N.current.set(Ae,De.token);const $e=je.handoffFrom;je.handoffFrom=void 0,je.handoffCompleted=!0,$e&&!$e.disposed&&X($e,"livedesk-subscription-replaced"),P()}),ke.addEventListener("message",De=>{if(je.disposed||S.current.get(Ae)!==je)return;if(typeof De.data=="string"){try{const $e=JSON.parse(De.data);if($e?.type==="RemoteFrameSubscriptionError")v(String($e.error||"control-stream-start-failed"));else if($e?.type==="RemoteFrameLiveAutoStart"){const Me=(Array.isArray($e.skipped)?$e.skipped:[]).find(de=>de?.deviceId===Ae);if(Me)v(String(Me.reason||"control-stream-start-failed"));else if(Array.isArray($e.started)){const de=$e.started.find(be=>be?.deviceId===Ae);de&&(v(""),de.ready===!0&&de.streamPurpose==="control"&&de.sessionId&&de.commandId&&Number(de.captureGeneration||0)>0&&H.current?.({deviceId:Ae,sessionId:String(de.sessionId),streamId:String(de.streamId||""),streamPurpose:"control",commandId:String(de.commandId),captureGeneration:Number(de.captureGeneration),monitorIndex:Number(de.monitorIndex||0)}))}}else $e?.type==="RemoteFrameStreamReady"&&$e.deviceId===Ae&&$e.streamPurpose==="control"&&$e.sessionId&&$e.commandId&&Number($e.captureGeneration||0)>0&&(v(""),H.current?.({deviceId:Ae,sessionId:String($e.sessionId),streamId:String($e.streamId||""),streamPurpose:"control",commandId:String($e.commandId),captureGeneration:Number($e.captureGeneration),monitorIndex:Number($e.monitorIndex||0)}))}catch{}return}const Le=De.data instanceof ArrayBuffer?De.data:null;Le&&(v(""),we(Le,je))}),ke.addEventListener("error",()=>{je.disposed||S.current.get(Ae)!==je||p("connecting")}),ke.addEventListener("close",()=>{const De=!je.disposed;je.disposed=!0;const Le=S.current.get(Ae);let $e=!1;if(Le===je){const he=je.handoffFrom;je.handoffFrom=void 0,he&&!he.disposed&&(he.socket.readyState===WebSocket.CONNECTING||he.socket.readyState===WebSocket.OPEN)?(S.current.set(Ae,he),$e=!0):S.current.delete(Ae)}if(P(),De&&Le===je&&!$e){const he=window.setTimeout(()=>{k.current.delete(he),R(Me=>Me+1)},750);k.current.add(he)}})}P()},[a,X,_,L,K,we,r,q,le,Y,l.monitorSelections,te,E,ne,P]),u.useEffect(()=>{if(!ce||!V)return;const pe=_?_.split(",").filter(Boolean):[];for(const ge of pe){if(N.current.get(ge)===V)continue;const xe=S.current.get(ge);!xe||!oe(ge,xe,O,V)||N.current.set(ge,V)}},[_,ce,V,O,oe]),u.useEffect(()=>()=>{for(const pe of S.current.values())X(pe,"livedesk-hook-unmount");S.current.clear();for(const pe of k.current)window.clearTimeout(pe);k.current.clear()},[X]);const J=u.useCallback((pe,ge="browser-stale")=>{const xe=Array.isArray(pe)&&pe.length>0?pe:_.split(",").filter(Boolean);if(xe.length===0)return!1;let Ae=!1;for(const _e of xe){const ie=S.current.get(_e);!ie||ie.socket.readyState!==WebSocket.OPEN||(Ae=oe(_e,ie,ge,`${Date.now()}-${Math.random().toString(36).slice(2)}`)||Ae)}return Ae},[_,oe]),B=u.useCallback((pe,ge="browser-reconnect")=>{const xe=Array.isArray(pe)&&pe.length>0?pe:_.split(",").filter(Boolean);if(xe.length===0)return!1;let Ae=!1;for(const _e of xe){const ie=S.current.get(_e);ie&&(X(ie,`livedesk-${ge}`),S.current.delete(_e),N.current.delete(_e),w.current.delete(_e),Ae=!0)}return Ae&&d(new Map(w.current)),R(_e=>_e+1),P(),!0},[X,_,P]);return{frames:c,state:m,error:g,stats:b,restartLive:J,reconnectLive:B}}function pj(n,a,r=bn,l={}){const[c,d]=u.useState(null),[m,p]=u.useState(null),[g,v]=u.useState("idle"),[b,y]=u.useState(Jc),w=u.useRef(null),S=u.useRef(l.onFrame),j=u.useRef(null),N=u.useRef(0),M=u.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),k=u.useMemo(()=>[...new Set(n.filter(Boolean))].join(","),[n]),E=u.useMemo(()=>[...new Set((l.captureDeviceIds||n).filter(Boolean))].join(","),[n,l.captureDeviceIds]),R=u.useMemo(()=>JSON.stringify(l.monitorSelections||{}),[l.monitorSelections]),U=u.useMemo(()=>({deviceIds:k.split(",").filter(Boolean),captureDeviceIds:E.split(",").filter(Boolean),fps:Number(l.fps||20),width:Number(l.width||1920),height:Number(l.height||1080),tileWidth:Number(l.tileWidth||320),tileHeight:Number(l.tileHeight||180),monitorSelections:l.monitorSelections||{}}),[E,k,R,l.fps,l.height,l.monitorSelections,l.tileHeight,l.tileWidth,l.width]),H=u.useMemo(()=>JSON.stringify(U),[U]),W=u.useRef(U);W.current=U;const _=a&&U.deviceIds.length>0,L=u.useCallback(q=>q.readyState!==WebSocket.OPEN?!1:(q.send(JSON.stringify({type:"configure",...W.current})),!0),[]);u.useEffect(()=>{S.current=l.onFrame},[l.onFrame]),u.useEffect(()=>{const q=window.setInterval(()=>{const te=M.current,K=performance.now(),ne=Math.max(1,K-te.sampleStartedAt);y({totalFrames:te.totalFrames,totalBytes:te.totalBytes,framesPerSecond:te.sampleFrames*1e3/ne,bytesPerSecond:te.sampleBytes*1e3/ne,sampleMs:ne,lastUpdatedAt:Date.now()});const ce=j.current;ce&&ce.frameSeq!==N.current&&(N.current=ce.frameSeq,d(ce)),te.sampleFrames=0,te.sampleBytes=0,te.sampleStartedAt=K},1e3);return()=>window.clearInterval(q)},[]),u.useEffect(()=>{if(!_){w.current?.close(),w.current=null,d(null),j.current=null,N.current=0,p(null),v("idle"),y(Jc);return}let q=!1,te=0;const K=()=>{if(q)return;const ne=new WebSocket(vf("/api/remote/atlas/ws",r));ne.binaryType="arraybuffer",w.current=ne,v("connecting"),ne.addEventListener("open",()=>{M.current.sampleStartedAt=performance.now(),v("open"),L(ne)}),ne.addEventListener("message",ce=>{if(typeof ce.data=="string"){try{const O=JSON.parse(ce.data);O?.type==="Mode4AtlasLayout"&&p({layoutVersion:Number(O.layoutVersion||0),width:Number(O.width||1920),height:Number(O.height||1080),columns:Number(O.columns||1),rows:Number(O.rows||1),tiles:Array.isArray(O.tiles)?O.tiles:[]})}catch{}return}const V=ce.data instanceof ArrayBuffer?ce.data:null;if(!(!V||V.byteLength<5))try{const O=Date.now(),X=new DataView(V).getUint32(0,!1);if(X<=0||X+4>V.byteLength)return;const P=JSON.parse(rp.decode(new Uint8Array(V,4,X))),oe=new Uint8Array(V,4+X),we={deviceId:String(P.deviceId||"__livedesk_mode4_atlas__"),kind:"live",frameSeq:Number(P.frameSeq||0),streamFrameSeq:Number(P.streamFrameSeq||0)||void 0,streamId:String(P.streamId||"mode4-atlas"),commandId:P.commandId?String(P.commandId):void 0,width:Number(P.width||1920),height:Number(P.height||1080),sourceWidth:Number(P.sourceWidth||P.width||1920),sourceHeight:Number(P.sourceHeight||P.height||1080),mimeType:String(P.mimeType||"video/h264"),mode:String(P.mode||"mode4-h264-atlas"),frameMode:String(P.frameMode||"mode4-h264-atlas"),frameProfile:String(P.frameProfile||"mode4-h264-atlas-v1"),encoding:String(P.encoding||"video-atlas"),codec:String(P.codec||"h264"),compression:String(P.compression||"video/h264"),h264Format:String(P.h264Format||"annexb"),isKeyFrame:P.isKeyFrame===!0,chunkType:String(P.chunkType||""),timestampUs:Number(P.timestampUs||0),durationUs:Number(P.durationUs||0),hardwareEncoder:P.hardwareEncoder?String(P.hardwareEncoder):void 0,platformProfile:P.platformProfile?String(P.platformProfile):void 0,capturedAt:String(P.capturedAt||""),receivedAt:String(P.receivedAt||""),hubPacketAt:P.hubPacketAt?String(P.hubPacketAt):void 0,hubPacketEpochMs:Number(P.hubPacketEpochMs||0)||void 0,browserReceivedEpochMs:O,byteLength:oe.byteLength,layoutVersion:Number(P.layoutVersion||0),atlasComposeMs:Number(P.atlasComposeMs||0),atlasPoolStarved:Number(P.atlasPoolStarved||0),atlasReadyTiles:Number(P.atlasReadyTiles||0),atlasTileCount:Number(P.atlasTileCount||0),atlasInputRevision:Number(P.atlasInputRevision||0),atlasSourceNewestAtEpochMs:Number(P.atlasSourceNewestAtEpochMs||0),atlasSourceOldestAtEpochMs:Number(P.atlasSourceOldestAtEpochMs||0),atlasSourceMaxAgeMs:Number(P.atlasSourceMaxAgeMs||0),payload:oe},J=M.current;J.totalFrames+=1,J.totalBytes+=oe.byteLength,J.sampleFrames+=1,J.sampleBytes+=oe.byteLength,j.current=we,N.current===0&&(N.current=we.frameSeq,d(we)),S.current?.(we)}catch{}}),ne.addEventListener("error",()=>v("error")),ne.addEventListener("close",()=>{w.current===ne&&(w.current=null),!q&&(v("closed"),te=window.setTimeout(K,1200))})};return K(),()=>{q=!0,window.clearTimeout(te),w.current?.close(),w.current=null}},[_,r,L]),u.useEffect(()=>{if(!_)return;const q=w.current;q&&L(q)},[H,_,L]);const le=u.useCallback(()=>{const q=w.current;return q?L(q):!1},[L]);return{frame:c,layout:m,state:g,stats:b,refreshInputs:le}}function gj(n,a=bn){const r=u.useRef(null),l=u.useRef(0),c=u.useRef(0),d=u.useRef(new Map),[m,p]=u.useState("idle"),[g,v]=u.useState(""),[b,y]=u.useState(Lx),w=u.useRef({totalSent:0,totalDropped:0,sampleSent:0,sampleDropped:0,sampleStartedAt:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0});u.useEffect(()=>{if(!n){r.current?.close(),r.current=null,c.current=0,p("idle"),v(""),y(Lx);return}let j=!1,N=0;const M=()=>{if(j)return;const k=new WebSocket(vf("/api/remote/input/ws",a));r.current=k,w.current.sampleStartedAt=performance.now(),p("connecting"),v(""),k.addEventListener("open",()=>{j||r.current!==k||(v(""),p("open"))}),k.addEventListener("message",E=>{if(!(j||r.current!==k||typeof E.data!="string"))try{const R=JSON.parse(E.data);if(R?.type==="RemoteInputError"){v(String(R.error||R.result?.error||"Remote input failed.")),p("error");return}if(R?.type!=="RemoteInputApplied")return;const U=Number(R.inputSeq||0),H=d.current.get(U);H!==void 0&&(w.current.lastRoundTripMs=Math.max(0,performance.now()-H),d.current.delete(U)),w.current.lastInputSeq=U,w.current.lastAgentApplyMs=Math.max(0,Number(R.agentApplyMs||0))}catch{}}),k.addEventListener("close",()=>{j||r.current!==k||(r.current=null,p("closed"),N=window.setTimeout(M,1200))}),k.addEventListener("error",()=>{!j&&r.current===k&&p("error")})};return M(),()=>{j=!0,window.clearTimeout(N);const k=r.current;r.current=null,k?.close(),d.current.clear()}},[n,a]),u.useEffect(()=>{if(!n)return;const j=window.setInterval(()=>{const N=performance.now(),M=w.current,k=Math.max(1,N-M.sampleStartedAt);y({totalSent:M.totalSent,totalDropped:M.totalDropped,sentPerSecond:M.sampleSent*1e3/k,droppedPerSecond:M.sampleDropped*1e3/k,bufferedAmount:r.current?.bufferedAmount||0,lastInputType:M.lastInputType,lastInputSeq:M.lastInputSeq,lastRoundTripMs:M.lastRoundTripMs,lastAgentApplyMs:M.lastAgentApplyMs,lastUpdatedAt:Date.now()}),M.sampleSent=0,M.sampleDropped=0,M.sampleStartedAt=N},1e3);return()=>window.clearInterval(j)},[n]);const S=u.useCallback((j,N)=>{const M=r.current;if(!M||M.readyState!==WebSocket.OPEN||!j)return!1;const k=String(N.type||"").toLowerCase(),E=k==="pointermove",U=E||k==="wheel",H=w.current;if(E&&M.bufferedAmount>dj)return H.totalDropped+=1,H.sampleDropped+=1,H.lastInputType="pointermove-drop",!1;const W=l.current+1;l.current=W;const _=Date.now(),L=!U||W-c.current>=mj;for(L&&(d.current.set(W,performance.now()),U&&(c.current=W)),E||Sb.set(j,{inputSeq:W,inputType:k||"input",sentAt:performance.now()});d.current.size>256;){const le=d.current.keys().next().value;if(le===void 0)break;d.current.delete(le)}return M.send(JSON.stringify({type:"input",requestId:U?"":crypto.randomUUID(),fireAndForget:U,deviceId:j,input:{...N,inputSeq:W,requestAck:L,issuedAtEpochMs:_,issuedAt:new Date(_).toISOString()}})),H.totalSent+=1,H.sampleSent+=1,H.lastInputType=k||"input",!0},[]);return{state:m,sendInput:S,stats:b,error:g}}function vj(n){const a=String(n||"").toLowerCase();return a.includes("audio/pcm")||a.includes("audio/l16")||a.includes("f32le")||a.includes("s16le")}const Rd={queuedMs:0,browserAgeMs:0,captureAgeMs:0,captureStatusAgeMs:0,silentForMs:0,captureAlive:!1,helperAlive:!1,captureRestartCount:0,localProcessingAgeMs:0,lastPacketAgeMs:0,lastAcceptedAgeMs:0,framesReceived:0,drops:0,resyncs:0,pendingDecodes:0,lastFrameSeq:0,audioContextState:"closed",stalledCount:0,automaticRestarts:0,lastUpdatedAt:0},xj=.08,yj=.25,bj=.02,Ix=300,wj=4,Dd=1500,ah=5e3,Sj=2e3,Cj=1e4,Ld=[0,1e3,3e3];function Ox(n){const a=Date.parse(String(n||""));return Number.isFinite(a)?Math.max(0,Date.now()-a):0}function jj(n,a,r){const l=Math.max(1,Math.min(8,Math.floor(a.channels||2))),c=Math.max(8e3,Math.min(192e3,Math.floor(a.sampleRate||48e3))),d=String(a.mimeType||"").toLowerCase(),m=d.includes("s16le")||d.includes("audio/l16"),p=m?2:4,g=Math.floor(r.byteLength/p),v=Math.floor(g/l),b=n.createBuffer(l,v,c),y=new DataView(r);for(let w=0;w<l;w+=1){const S=b.getChannelData(w);for(let j=0;j<v;j+=1){const M=(j*l+w)*p;S[j]=m?Math.max(-1,Math.min(1,y.getInt16(M,!0)/32768)):Math.max(-1,Math.min(1,y.getFloat32(M,!0)))}}return b}function kj(n,a,r=bn){const l=u.useRef(null),c=u.useRef(0),[d,m]=u.useState("idle"),[p,g]=u.useState(null),[v,b]=u.useState(Rd),[y,w]=u.useState("");return u.useEffect(()=>{if(!a||!n){m("idle"),g(null),b(Rd),w("");return}m("connecting"),g(null),b(Rd),w("");const S=window.AudioContext||window.webkitAudioContext;if(!S){m("unsupported"),b(Rd),w("Audio playback is not supported in this browser.");return}const j=new S;l.current=j,c.current=j.currentTime;const N=new WebSocket(vf("/api/remote/audio/ws?devices="+encodeURIComponent(n),r));N.binaryType="arraybuffer";const M=new Set,k={browserAgeMs:0,captureAgeMs:0,captureStatusAgeMs:0,silentForMs:0,captureAlive:!1,helperAlive:!1,captureRestartCount:0,localProcessingAgeMs:0,lastPacketAt:0,lastAcceptedAt:0,framesReceived:0,drops:0,resyncs:0,pendingDecodes:0,lastFrameSeq:0,audioContextState:String(j.state),stalledCount:0,automaticRestarts:0,activeStreamId:"",lastCaptureStatusAt:0,lastPcmAtEpochMs:0};let E=!1,R=0,U=!1,H=0,W=0;const _=(O=!0)=>{for(const Y of M)try{Y.stop()}catch{}M.clear(),O&&(c.current=j.currentTime+xj)},L=()=>{k.audioContextState=String(j.state),!E&&(k.audioContextState==="suspended"||k.audioContextState==="interrupted"?m("suspended"):k.audioContextState==="closed"&&(m("error"),w("The browser audio context is closed. Toggle Remote Audio off and on to recover.")))},le=async()=>{if(E||String(j.state)==="closed")return!1;try{if(String(j.state)!=="running"&&await j.resume(),k.audioContextState=String(j.state),!E&&!U&&k.audioContextState==="running"){const O=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=Dd,Y=k.lastCaptureStatusAt>0&&performance.now()-k.lastCaptureStatusAt<=ah&&k.captureAlive&&k.helperAlive;m(O?"playing":Y?"silent":"open")}return k.audioContextState==="running"}catch(O){return E||(m("suspended"),w(O instanceof Error?"Audio playback is suspended: "+O.message:"Audio playback is suspended.")),!1}},q=async()=>{if(E||U||N.readyState!==WebSocket.OPEN)return;if(H>=Ld.length){m("error"),w("Remote audio stopped sending frames. Toggle Audio off and on to retry.");return}const O=H;H+=1,U=!0,k.stalledCount+=1,k.automaticRestarts+=1,m("reconnecting");try{const Y=await Ge("/api/remote/devices/"+encodeURIComponent(n)+"/audio/stop",{method:"POST",body:JSON.stringify({})},r);if(Y.ok===!1)throw new Error(Y.error||"Remote audio stop failed.");if(E)return;const X=await Ge("/api/remote/devices/"+encodeURIComponent(n)+"/audio/start",{method:"POST",body:JSON.stringify({streamId:"audio-restart-"+Date.now(),mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},r);if(X.ok===!1)throw new Error(X.error||"Remote audio start failed.");const P=performance.now();R=P,k.lastPacketAt=P,k.lastAcceptedAt=0,k.lastCaptureStatusAt=0,k.lastPcmAtEpochMs=0,k.captureAlive=!1,k.helperAlive=!1,k.silentForMs=0,W=P+(Ld[O+1]??3e3),w(""),E||m("open")}catch(Y){E||(W=performance.now()+(Ld[O+1]??3e3),m("error"),w(Y instanceof Error?"Remote audio restart failed: "+Y.message:"Remote audio restart failed."))}finally{U=!1}},te=()=>{k.drops+=1},K=window.setInterval(()=>{if(E)return;const O=performance.now(),Y=k.lastPacketAt>0?Math.max(0,O-k.lastPacketAt):R>0?Math.max(0,O-R):0,X=k.lastAcceptedAt>0?Math.max(0,O-k.lastAcceptedAt):0,P=k.lastCaptureStatusAt>0?Math.max(0,O-k.lastCaptureStatusAt):0,oe=N.readyState===WebSocket.OPEN,we=k.lastCaptureStatusAt>0,J=we&&P<=ah,B=we&&(!k.captureAlive||!k.helperAlive)&&P>Sj,pe=we&&P>ah,ge=!we&&R>0&&O-R>Cj,xe=R>0&&(k.lastAcceptedAt<=0?O-R>Dd:X>Dd);oe&&R>0&&(B||pe||ge)?H>=Ld.length&&!U?(m("error"),w("Remote audio capture heartbeat stopped. Toggle Audio off and on to retry.")):!U&&O>=W?q():U||m("stalled"):oe&&xe&&!U&&k.audioContextState!=="suspended"&&k.audioContextState!=="interrupted"&&m(J?"silent":"open"),b({queuedMs:Math.max(0,(c.current-j.currentTime)*1e3),browserAgeMs:k.browserAgeMs,captureAgeMs:k.captureAgeMs,captureStatusAgeMs:P,silentForMs:k.silentForMs,captureAlive:k.captureAlive,helperAlive:k.helperAlive,captureRestartCount:k.captureRestartCount,localProcessingAgeMs:k.localProcessingAgeMs,lastPacketAgeMs:Y,lastAcceptedAgeMs:X,framesReceived:k.framesReceived,drops:k.drops,resyncs:k.resyncs,pendingDecodes:k.pendingDecodes,lastFrameSeq:k.lastFrameSeq,audioContextState:k.audioContextState,stalledCount:k.stalledCount,automaticRestarts:k.automaticRestarts,lastUpdatedAt:Date.now()})},250),ne=()=>{L(),(String(j.state)==="suspended"||String(j.state)==="interrupted")&&le()},ce=()=>{document.visibilityState==="visible"&&le()},V=()=>{le()};return j.addEventListener("statechange",ne),document.addEventListener("visibilitychange",ce),window.addEventListener("pageshow",V),window.addEventListener("pointerdown",V),window.addEventListener("keydown",V),m("connecting"),w(""),L(),N.addEventListener("open",()=>{E||(R=performance.now(),k.lastPacketAt=R,k.lastAcceptedAt=0,k.lastCaptureStatusAt=0,k.lastPcmAtEpochMs=0,k.captureAlive=!1,k.helperAlive=!1,k.silentForMs=0,m("open"),N.send(JSON.stringify({type:"subscribe",deviceIds:[n]})),le())}),N.addEventListener("message",O=>{if(typeof O.data=="string")return;const Y=O.data instanceof ArrayBuffer?O.data:null;if(!Y||Y.byteLength<5)return;const X=performance.now();k.lastPacketAt=X,(async()=>{try{const oe=new DataView(Y).getUint32(0,!1);if(oe<=0||oe+4>Y.byteLength){te();return}const we=new Uint8Array(Y,4,oe),J=JSON.parse(rp.decode(we)),B=Y.slice(4+oe),pe=String(J.frameKind||J.kind||"").toLowerCase();if(J.type==="remote.audio.status"||pe==="audio-status"){if(k.lastCaptureStatusAt=X,k.captureAlive=J.captureAlive===!0,k.helperAlive=J.helperAlive===!0,k.captureRestartCount=Math.max(0,Number(J.restartCount||0)||0),k.lastPcmAtEpochMs=Math.max(0,Number(J.lastPcmAtEpochMs||0)||0),k.silentForMs=Math.max(0,Number(J.silentForMs||0)||0),k.captureAgeMs=k.lastPcmAtEpochMs>0?Math.max(0,Date.now()-k.lastPcmAtEpochMs):k.silentForMs,k.captureAlive&&k.helperAlive){if(H=0,W=0,!U){w("");const xe=String(j.state)==="running",Ae=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=Dd;m(xe?Ae?"playing":"silent":"suspended")}}else U||m("stalled");return}const ge={deviceId:String(J.deviceId||""),frameSeq:Number(J.frameSeq||0),streamId:String(J.streamId||""),mimeType:String(J.mimeType||"audio/webm;codecs=opus"),sampleRate:Number(J.sampleRate||48e3),channels:Number(J.channels||2),capturedAt:String(J.capturedAt||""),receivedAt:String(J.receivedAt||""),byteLength:Number(J.byteLength||B.byteLength),payload:B};if(!ge.deviceId||E)return;if(performance.now()-X>Ix){te();return}if(k.pendingDecodes>=wj){te();return}k.pendingDecodes+=1;try{const xe=vj(ge.mimeType)?jj(j,ge,B):await j.decodeAudioData(B.slice(0));if(k.localProcessingAgeMs=Math.max(0,performance.now()-X),E)return;if(k.localProcessingAgeMs>Ix){te();return}if(ge.frameSeq>0&&ge.frameSeq<=k.lastFrameSeq){te();return}if(k.activeStreamId&&ge.streamId!==k.activeStreamId&&ge.frameSeq<=k.lastFrameSeq){te();return}ge.streamId&&ge.streamId!==k.activeStreamId&&(k.activeStreamId=ge.streamId,k.lastFrameSeq=0,_());const Ae=j.currentTime;Math.max(0,c.current-Ae)>yj&&(_(),k.resyncs+=1);const ie=j.createBufferSource();ie.buffer=xe,ie.connect(j.destination),M.add(ie),ie.onended=()=>{M.delete(ie),ie.onended=null};const Q=Math.max(j.currentTime+bj,c.current);ie.start(Q),c.current=Q+xe.duration,k.browserAgeMs=Ox(ge.receivedAt),k.captureAgeMs=Ox(ge.capturedAt),k.lastAcceptedAt=performance.now(),k.framesReceived+=1,k.lastFrameSeq=ge.frameSeq,H=0,W=0,g(ge),le();const Ie=String(j.state)==="running";Ie&&w(""),m(Ie?"playing":"suspended")}finally{k.pendingDecodes=Math.max(0,k.pendingDecodes-1)}}catch(P){E||(m("error"),w(P instanceof Error?P.message:String(P)))}})()}),N.addEventListener("error",()=>{E||(m("error"),w("Remote audio WebSocket error."))}),N.addEventListener("close",()=>{E||m("closed")}),()=>{E=!0,window.clearInterval(K),j.removeEventListener("statechange",ne),document.removeEventListener("visibilitychange",ce),window.removeEventListener("pageshow",V),window.removeEventListener("pointerdown",V),window.removeEventListener("keydown",V),_(!1),N.close(),j.close().catch(()=>{}),l.current===j&&(l.current=null)}},[n,a,r]),{state:d,lastFrame:p,stats:v,error:y}}const Aj=3;function Hx(n,a,r){const l=Math.max(1,Number(r)||1),c=Math.max(0,Math.min(l,Number(n)-Number(a))),d=Math.min(l/2,Aj);return c<=d?0:c>=l-d?1:c/l}function Nj(n,a,r){return{normalizedX:Hx(n,r.left,r.width),normalizedY:Hx(a,r.top,r.height)}}const di=Object.freeze({smallDirectDeviceLimit:4,interactiveDirectFps:30,controlWallReuseMaxFps:30,scalableAtlasInputFps:8,atlasOutputFps:20,maxDirectFramesPerSecond:96,directDecodeAcceleration:"prefer-software",directLatencyMode:"interactive",configuredLatencyMode:"smooth"});function Mj(n,a){const r=Math.max(0,Math.floor(Number(a)||0));return n===!0&&r>0&&r<=di.smallDirectDeviceLimit}function $c({mode4Enabled:n,directMode4WallEnabled:a,isMac:r}){return!n||a||r?"direct":"atlas"}function Tj({mode4Enabled:n,directMode4WallEnabled:a,adaptiveFps:r,directDeviceCount:l}){const c=Math.max(1,Math.floor(Number(r)||1));if(!n)return c;if(a)return Math.max(di.interactiveDirectFps,c);const d=Math.max(1,Math.floor(Number(l)||1));return Math.max(1,Math.min(c,Math.floor(di.maxDirectFramesPerSecond/d)))}function Ej(n,a){return n?{acceleration:di.directDecodeAcceleration,latencyMode:di.directLatencyMode}:{acceleration:a,latencyMode:di.configuredLatencyMode}}const Ih={revision:0,settings:{connection:{usePinToAddDevices:!0,pinValidityMinutes:30,rotatePinAfterPairing:!0,allowNewDevices:!0,approveNewDevices:!0,startWithComputer:!0,keepRunningInTray:!0,showConnectionNotifications:!0},security:{accessMode:"trusted-only",requireEncryptedConnections:!0,allowInternetConnections:!1,allowLanConnections:!0,allowUnencryptedLanFallback:!1,requireNewDeviceApproval:!0,requireAdministratorForSecurityChanges:!0,visibleControlIndicator:!0,lockOnControlEnd:!0,disconnectIdleControlSessions:!0,idleControlMinutes:30,keepSessionHistory:!0,sessionHistoryDays:30},control:{allowKeyboardMouse:!0,allowSystemShortcuts:!0,allowClipboardText:!0,allowRemoteRestart:!1,reconnectAfterRemoteRestart:!0,allowSwitchingMonitors:!0,showConnectionToolbar:!0,showRemoteCursor:!0,openControlOnDoubleClick:!0,startRemoteAudioWithControl:!1,fitRemoteScreen:!0,rememberLastMonitor:!0,keepControlReadyBetweenPages:!0},wall:{performanceMode:"auto",autoStart:!0,connectedOnly:!1,keepEmptySlots:!0,showDeviceStatus:!0,showPerformanceDetails:!1,pauseHiddenTiles:!0,reduceWhenHidden:!0,autoAdjustTileQuality:!0,rememberDevicePositions:!0},filesAudio:{allowFileTransfer:!0,allowFolderSync:!1,askBeforeReceivingFiles:!0,openReceivedFolder:!1,notifyTransferComplete:!0,allowOverwrite:!1,defaultReceiveFolder:"Desktop/LiveDeskFiles",maxFileSizeBytes:1073741824,allowRemoteAudio:!0,startAudioMuted:!1,rememberVolume:!0,automaticallyRecoverAudio:!0,showAudioTroubleshooting:!1,rollingBufferEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0,captureSaveLocation:"LiveDesk Captures",captureAutoDelete:"never"},agent:{enabled:!1,defaultPermissionMode:"safe-auto",askBeforeDestructive:!0,allowProcessManagement:!0,allowServiceManagement:!0,allowFileChanges:!0,allowCommandExecution:!1,allowSoftwareInstallation:!1,allowPowerActions:!1,keepAuditHistory:!0,timeoutMinutes:10},advanced:{wallFrameMode:"auto",wallFps:20,wallMaxWidth:960,wallMaxHeight:540,wallQuality:55,controlFrameMode:"mode3-h264-hw",controlFps:30,controlMaxWidth:1920,controlMaxHeight:1080,controlQuality:60,transport:"auto",allowPlainLanFallback:!1,verboseLogs:!1,frameStatistics:!1}}},Rj=[{id:"connection",label:"Connection",icon:Il},{id:"security",label:"Security",icon:Lt},{id:"control",label:"Control",icon:en},{id:"wall",label:"Wall",icon:nu},{id:"files-audio",label:"Files & Audio",icon:Ro},{id:"agent",label:"Agent",icon:Ol},{id:"advanced",label:"Advanced",icon:sf}];function Al(n,a){return n?.settings?.[a]||Ih.settings[a]}function ot({icon:n,title:a,description:r,children:l,disabled:c=!1,recommended:d=!1}){return s.jsxs("div",{className:`product-setting-row ${c?"disabled":""}`,children:[s.jsx("div",{className:"product-setting-control",children:l}),n&&s.jsx("span",{className:"product-setting-icon",children:s.jsx(n,{size:17})}),s.jsxs("div",{className:"product-setting-copy",children:[s.jsx("strong",{children:a}),d&&s.jsx("em",{children:"Recommended"}),s.jsx("small",{children:r})]})]})}function jt({checked:n,onChange:a,disabled:r=!1,label:l}){return s.jsxs("label",{className:"product-switch",children:[s.jsx("input",{"aria-label":l,type:"checkbox",checked:n,disabled:r,onChange:c=>a(c.target.checked)}),s.jsx("span",{})]})}function Yi({value:n,onChange:a,options:r,disabled:l=!1,label:c}){return s.jsx("select",{"aria-label":c,value:String(n),disabled:l,onChange:d=>a(d.target.value),children:r.map(([d,m])=>s.jsx("option",{value:d,children:m},d))})}function Dj({hubUrl:n="",runtimeRole:a="hub",runtimeDeviceId:r="",sessionAccessToken:l="",initialTab:c="connection",pin:d,wall:m,control:p,agent:g,advancedExtras:v,captureGallery:b}){const[y,w]=u.useState(c),[S,j]=u.useState(null),[N,M]=u.useState("loading"),[k,E]=u.useState(""),[R,U]=u.useState("idle"),[H,W]=u.useState("");u.useEffect(()=>{let xe=!0;return M("loading"),Ge("/api/settings",void 0,n).then(Ae=>{xe&&(j({revision:Number(Ae.revision||0),updatedAt:Ae.updatedAt,settings:Ae.settings}),M("saved"))}).catch(Ae=>{xe&&(E(Ae instanceof Error?Ae.message:String(Ae)),j(Ih),M("failed"))}),()=>{xe=!1}},[n]);const _=async(xe,Ae,_e)=>{const ie=S||Ih,Q=ie,Ie={...ie,settings:{...ie.settings,[xe]:{...Al(ie,xe),[Ae]:_e}}};j(Ie),M("saving"),E("");try{const Oe=await Ge("/api/settings",{method:"PATCH",body:JSON.stringify({revision:ie.revision,[xe]:{[Ae]:_e}})},n);j({revision:Oe.revision,updatedAt:Oe.updatedAt,settings:Oe.settings}),M("saved")}catch(Oe){j(Q),M("failed"),E(Oe instanceof Error?Oe.message:String(Oe))}},L=(xe,Ae)=>_e=>{_(xe,Ae,_e)},le=async()=>{if(a!=="hub"||!r||!l){U("failed"),W("Sign in to this Hub before changing its runtime role.");return}U("changing"),W("");try{const xe=await Ge("/api/runtime/status",void 0,n);await Ge("/api/runtime/role",{method:"POST",headers:{Authorization:`Bearer ${l}`},body:JSON.stringify({role:"client"})},n),U("accepted"),await lb({baseUrl:n,targetRole:"client",previousRuntimePid:Number(xe.runtimePid||0),allowedStates:["running","waiting-auth"]}),cC(5179)}catch(xe){U("failed"),W(xe instanceof Error?xe.message:String(xe))}},q=Al(S,"security"),te=Al(S,"connection"),K=Al(S,"control"),ne=Al(S,"wall"),ce=Al(S,"filesAudio"),V=Al(S,"agent"),O=u.useMemo(()=>q.allowInternetConnections===!1?{label:"Local only",tone:"local",detail:"Internet connections are disabled."}:q.requireEncryptedConnections&&q.requireNewDeviceApproval&&q.accessMode==="trusted-only"?{label:"Protected",tone:"protected",detail:"Encrypted connections and trusted-device approval are active."}:{label:"Needs attention",tone:"attention",detail:"Review access and encryption settings before sharing this Hub."},[q]),Y=`settings-panel-${y}`,X=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"product-settings-hero",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"settings-eyebrow",children:[s.jsx(Il,{size:14})," Connection"]}),s.jsx("h2",{children:"Connect a device"}),s.jsx("p",{children:"Use the short PIN on the computer you want to add. The PIN is temporary and can be replaced at any time."})]}),s.jsxs("div",{className:"product-save-state",role:"status",children:[s.jsx(Zy,{size:14})," ",N==="saving"?"Saving":N==="failed"?"Failed":N==="loading"?"Loading":"Saved"]})]}),d,s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Connection behavior"}),s.jsx("h3",{children:"New device access"})]}),s.jsx(_o,{size:20})]}),s.jsx(ot,{icon:_o,title:"Use PIN to add new devices",description:"Allow temporary PIN pairing from the client.",recommended:!0,children:s.jsx(jt,{checked:!!te.usePinToAddDevices,onChange:L("connection","usePinToAddDevices"),label:"Use PIN to add new devices"})}),s.jsx(ot,{icon:Lt,title:"Approve new devices on this Hub",description:"Ask for approval before an unfamiliar computer becomes trusted.",children:s.jsx(jt,{checked:!!te.approveNewDevices,onChange:L("connection","approveNewDevices"),label:"Approve new devices"})}),s.jsx(ot,{icon:cn,title:"Show connection notifications",description:"Show a short notice when a computer connects or leaves.",children:s.jsx(jt,{checked:!!te.showConnectionNotifications,onChange:L("connection","showConnectionNotifications"),label:"Show connection notifications"})})]}),s.jsxs("section",{className:"settings-section-card runtime-role-settings",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Runtime role"}),s.jsx("h3",{children:"Use this computer as a Client"})]}),s.jsx(sf,{size:20})]}),s.jsx("p",{className:"settings-help",children:"This stops the Hub listener, saves the Client role in Supabase, and restarts LiveDesk through the unified launcher."}),R==="accepted"?s.jsx("p",{className:"settings-help runtime-role-success",children:"Role change accepted. LiveDesk is restarting as Client."}):H?s.jsx("p",{className:"settings-help runtime-role-error",role:"alert",children:H}):null,s.jsx("button",{className:"settings-reset",onClick:()=>{le()},disabled:R==="changing"||a!=="hub",type:"button",children:R==="changing"?"Switching role…":"Switch this computer to Client"})]})]}),P=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:`security-status-card ${O.tone}`,children:[s.jsxs("div",{children:[s.jsx("span",{children:"Security status"}),s.jsx("strong",{children:O.label}),s.jsx("small",{children:O.detail})]}),s.jsx(Lt,{size:28})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Access mode"}),s.jsx("h3",{children:"Who may use this Hub?"})]}),s.jsx(Is,{size:20})]}),s.jsx(ot,{icon:Lt,title:"Access mode",description:"Choose the default boundary for remote sessions.",recommended:!0,children:s.jsx(Yi,{value:String(q.accessMode),onChange:L("security","accessMode"),label:"Access mode",options:[["trusted-only","Trusted devices only"],["ask-every-time","Ask every time"],["view-only","View only"],["block-remote-access","Block remote access"]]})}),s.jsx(ot,{icon:Il,title:"Require encrypted connections",description:"External connections cannot disable this protection.",recommended:!0,children:s.jsx(jt,{checked:!!q.requireEncryptedConnections,onChange:L("security","requireEncryptedConnections"),label:"Require encrypted connections"})}),s.jsx(ot,{icon:Il,title:"Allow internet connections",description:"Keep off unless you intentionally expose this Hub beyond the LAN.",children:s.jsx(jt,{checked:!!q.allowInternetConnections,onChange:L("security","allowInternetConnections"),label:"Allow internet connections"})}),s.jsx(ot,{icon:en,title:"Allow LAN connections",description:"Permit connections from the local network.",children:s.jsx(jt,{checked:!!q.allowLanConnections,onChange:L("security","allowLanConnections"),label:"Allow LAN connections"})}),s.jsx(ot,{icon:Lt,title:"Require approval for new devices",description:"New computers must be approved before remote access is granted.",children:s.jsx(jt,{checked:!!q.requireNewDeviceApproval,onChange:L("security","requireNewDeviceApproval"),label:"Require approval for new devices"})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Session protection"}),s.jsx("h3",{children:"End sessions safely"})]}),s.jsx(cn,{size:20})]}),s.jsx(ot,{icon:en,title:"Show an indicator while Control is active",description:"Make active remote control visible on the local computer.",children:s.jsx(jt,{checked:!!q.visibleControlIndicator,onChange:L("security","visibleControlIndicator"),label:"Show Control indicator"})}),s.jsx(ot,{icon:Is,title:"Lock the remote computer when Control ends",description:"Protect the local screen after a Control session.",children:s.jsx(jt,{checked:!!q.lockOnControlEnd,onChange:L("security","lockOnControlEnd"),label:"Lock after Control ends"})}),s.jsx(ot,{icon:cn,title:"Disconnect idle Control sessions",description:"Automatically close inactive Control sessions.",children:s.jsx(jt,{checked:!!q.disconnectIdleControlSessions,onChange:L("security","disconnectIdleControlSessions"),label:"Disconnect idle sessions"})}),s.jsx(ot,{icon:cn,title:"Idle timeout",description:"Time before an inactive Control session closes.",disabled:!q.disconnectIdleControlSessions,children:s.jsx(Yi,{value:Number(q.idleControlMinutes),onChange:xe=>L("security","idleControlMinutes")(Number(xe)),disabled:!q.disconnectIdleControlSessions,label:"Idle timeout",options:[["5","5 minutes"],["15","15 minutes"],["30","30 minutes"],["60","1 hour"],["1440","Never"]]})})]})]}),oe=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Remote use"}),s.jsx("h3",{children:"What can a connected user do?"})]}),s.jsx(en,{size:20})]}),s.jsx(ot,{icon:en,title:"Keyboard and mouse control",description:"Allow the Hub to send keyboard and pointer input.",recommended:!0,children:s.jsx(jt,{checked:!!K.allowKeyboardMouse,onChange:L("control","allowKeyboardMouse"),label:"Keyboard and mouse control"})}),s.jsx(ot,{icon:KS,title:"System shortcuts",description:"Allow shortcut keys such as Alt-Tab and the system key.",children:s.jsx(jt,{checked:!!K.allowSystemShortcuts,onChange:L("control","allowSystemShortcuts"),label:"System shortcuts"})}),s.jsx(ot,{icon:_o,title:"Clipboard text sharing",description:"Share plain text through the remote session.",children:s.jsx(jt,{checked:!!K.allowClipboardText,onChange:L("control","allowClipboardText"),label:"Clipboard text sharing"})}),s.jsx(ot,{icon:cn,title:"Remote restart",description:"Allow restart requests from Control.",disabled:!K.allowKeyboardMouse,children:s.jsx(jt,{checked:!!K.allowRemoteRestart,onChange:L("control","allowRemoteRestart"),disabled:!K.allowKeyboardMouse,label:"Remote restart"})}),s.jsx(ot,{icon:en,title:"Switching monitors",description:"Allow the viewer to select another connected display.",children:s.jsx(jt,{checked:!!K.allowSwitchingMonitors,onChange:L("control","allowSwitchingMonitors"),label:"Switching monitors"})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Session behavior"}),s.jsx("h3",{children:"Make Control predictable"})]}),s.jsx(Hn,{size:20})]}),s.jsx(ot,{icon:en,title:"Open Control on double-click",description:"Double-clicking a Wall tile opens its Control view.",children:s.jsx(jt,{checked:!!K.openControlOnDoubleClick,onChange:L("control","openControlOnDoubleClick"),label:"Open Control on double-click"})}),s.jsx(ot,{icon:cn,title:"Start audio with Control",description:"Keep audio muted by default for new sessions.",children:s.jsx(jt,{checked:!!K.startRemoteAudioWithControl,onChange:L("control","startRemoteAudioWithControl"),label:"Start audio with Control"})}),s.jsx(ot,{icon:en,title:"Fit remote screen to window",description:"Scale the remote display to the available Control area.",children:s.jsx(jt,{checked:!!K.fitRemoteScreen,onChange:L("control","fitRemoteScreen"),label:"Fit remote screen"})}),s.jsx(ot,{icon:cn,title:"Keep Control ready between pages",description:"Faster reconnection for 1 minute.",recommended:!0,children:s.jsx(jt,{checked:!!K.keepControlReadyBetweenPages,onChange:L("control","keepControlReadyBetweenPages"),label:"Keep Control ready between pages"})})]})]}),we=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Performance mode"}),s.jsx("h3",{children:"Let LiveDesk choose the best path"})]}),s.jsx(nu,{size:20})]}),s.jsx(ot,{icon:Ol,title:"Performance mode",description:"Automatic mode balances responsiveness and image quality.",recommended:!0,children:s.jsx(Yi,{value:String(ne.performanceMode),onChange:L("wall","performanceMode"),label:"Performance mode",options:[["auto","Auto"],["responsive","Prioritize responsiveness"],["quality","Prioritize image quality"],["custom","Custom"]]})}),s.jsx("p",{className:"settings-help",children:"Streaming details are available under Advanced for diagnostics and development."})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Wall behavior"}),s.jsx("h3",{children:"What should the Wall show?"})]}),s.jsx(cn,{size:20})]}),[["autoStart","Start Wall automatically","Start a live view when a computer connects."],["connectedOnly","Show only connected devices","Hide disconnected slots."],["keepEmptySlots","Keep empty slots visible","Preserve the layout when a device leaves."],["showDeviceStatus","Show device status on tiles","Display compact machine status."],["showPerformanceDetails","Show performance details","Show advanced frame diagnostics on tiles."],["pauseHiddenTiles","Pause hidden tiles","Reduce capture work for tiles outside the visible area."],["reduceWhenHidden","Reduce activity when the window is hidden","Lower background work when the browser is not visible."],["autoAdjustTileQuality","Automatically adjust tile quality","Adapt tile quality to Wall size and load."]].map(([xe,Ae,_e])=>s.jsx(ot,{icon:en,title:Ae,description:_e,children:s.jsx(jt,{checked:!!ne[xe],onChange:L("wall",xe),label:Ae})},xe))]})]}),J=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"File permissions"}),s.jsx("h3",{children:"Move files deliberately"})]}),s.jsx(Ro,{size:20})]}),s.jsx(ot,{icon:Ro,title:"Allow file transfer",description:"Permit Hub-to-device file delivery.",recommended:!0,children:s.jsx(jt,{checked:!!ce.allowFileTransfer,onChange:L("filesAudio","allowFileTransfer"),label:"Allow file transfer"})}),s.jsx(ot,{icon:nu,title:"Allow folder sync",description:"Enable recurring folder synchronization.",disabled:!ce.allowFileTransfer,children:s.jsx(jt,{checked:!!ce.allowFolderSync,onChange:L("filesAudio","allowFolderSync"),disabled:!ce.allowFileTransfer,label:"Allow folder sync"})}),s.jsx(ot,{icon:Lt,title:"Ask before receiving files",description:"Require local confirmation before a transfer is written.",children:s.jsx(jt,{checked:!!ce.askBeforeReceivingFiles,onChange:L("filesAudio","askBeforeReceivingFiles"),label:"Ask before receiving files"})}),s.jsx(ot,{icon:Ro,title:"Allow overwrite",description:"Permit replacing an existing destination file.",children:s.jsx(jt,{checked:!!ce.allowOverwrite,onChange:L("filesAudio","allowOverwrite"),label:"Allow overwrite"})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Audio permissions"}),s.jsx("h3",{children:"Remote sound"})]}),s.jsx(cn,{size:20})]}),s.jsx(ot,{icon:cn,title:"Allow remote audio",description:"Permit audio capture from connected computers.",recommended:!0,children:s.jsx(jt,{checked:!!ce.allowRemoteAudio,onChange:L("filesAudio","allowRemoteAudio"),label:"Allow remote audio"})}),s.jsx(ot,{icon:cn,title:"Start audio muted",description:"New audio sessions begin silent.",children:s.jsx(jt,{checked:!!ce.startAudioMuted,onChange:L("filesAudio","startAudioMuted"),label:"Start audio muted"})}),s.jsx(ot,{icon:cn,title:"Automatically recover audio",description:"Recover from temporary capture or transport stalls.",children:s.jsx(jt,{checked:!!ce.automaticallyRecoverAudio,onChange:L("filesAudio","automaticallyRecoverAudio"),label:"Automatically recover audio"})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Capture defaults"}),s.jsx("h3",{children:"Screen recording"})]}),s.jsx(en,{size:20})]}),s.jsx(ot,{icon:cn,title:"Keep a Last 30s buffer",description:"Keep recent video in memory only until you explicitly save it.",children:s.jsx(jt,{checked:!!ce.rollingBufferEnabled,onChange:L("filesAudio","rollingBufferEnabled"),label:"Keep a Last 30s buffer"})}),s.jsx(ot,{icon:cn,title:"Recording quality",description:"Choose the WebM bitrate profile.",children:s.jsx(Yi,{value:String(ce.recordingQuality),onChange:L("filesAudio","recordingQuality"),label:"Recording quality",options:[["standard","Standard"],["high","High"]]})}),s.jsx(ot,{icon:cn,title:"Timelapse interval",description:"Capture one frame at the selected interval.",children:s.jsx(Yi,{value:Number(ce.timelapseIntervalSeconds),onChange:xe=>L("filesAudio","timelapseIntervalSeconds")(Number(xe)),label:"Timelapse interval",options:[["5","5 seconds"],["10","10 seconds"],["30","30 seconds"],["60","60 seconds"]]})}),s.jsx(ot,{icon:en,title:"Include remote cursor",description:"Include the cursor indicator when the source provides it.",children:s.jsx(jt,{checked:!!ce.includeRemoteCursor,onChange:L("filesAudio","includeRemoteCursor"),label:"Include remote cursor"})}),s.jsx(ot,{icon:Ro,title:"Capture save location",description:"Captures are stored inside the Hub capture library.",children:s.jsx(Yi,{value:String(ce.captureSaveLocation),onChange:L("filesAudio","captureSaveLocation"),label:"Capture save location",options:[[String(ce.captureSaveLocation||"LiveDesk Captures"),"LiveDesk Captures"]]})}),s.jsx(ot,{icon:Ro,title:"Automatic deletion",description:"Keep saved captures until you delete them.",children:s.jsx(Yi,{value:String(ce.captureAutoDelete),onChange:L("filesAudio","captureAutoDelete"),label:"Automatic deletion",options:[["never","Never"],["7-days","After 7 days"],["30-days","After 30 days"]]})})]}),b]}),B=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Agent safety"}),s.jsx("h3",{children:"AI workstation operations"})]}),s.jsx(Ol,{size:20})]}),s.jsx(ot,{icon:Ol,title:"Enable AI Agent on devices",description:"Allow Agent runs to reach connected workstations.",recommended:!0,children:s.jsx(jt,{checked:!!V.enabled,onChange:L("agent","enabled"),label:"Enable AI Agent"})}),s.jsx(ot,{icon:Lt,title:"Default permission mode",description:"Safe Auto keeps destructive operations behind approval.",children:s.jsx(Yi,{value:String(V.defaultPermissionMode),onChange:L("agent","defaultPermissionMode"),label:"Default Agent permission mode",options:[["ask","Ask"],["safe-auto","Safe Auto"],["full-access","Full Access"],["custom","Custom"]]})}),s.jsx(ot,{icon:Lt,title:"Ask before destructive operations",description:"Locked on for Safe Auto and destructive actions.",disabled:!V.enabled,children:s.jsx(jt,{checked:!!V.askBeforeDestructive,onChange:L("agent","askBeforeDestructive"),disabled:!V.enabled,label:"Ask before destructive operations"})}),s.jsx(ot,{icon:cn,title:"Keep Agent audit history",description:"Retain an inspectable record of Agent runs.",children:s.jsx(jt,{checked:!!V.keepAuditHistory,onChange:L("agent","keepAuditHistory"),label:"Keep Agent audit history"})}),s.jsx(ot,{icon:cn,title:"Stop Agent tasks after timeout",description:"Maximum runtime for one task.",children:s.jsx(Yi,{value:Number(V.timeoutMinutes),onChange:xe=>L("agent","timeoutMinutes")(Number(xe)),label:"Agent task timeout",options:[["1","1 minute"],["5","5 minutes"],["10","10 minutes"],["30","30 minutes"],["60","1 hour"]]})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Detailed permissions"}),s.jsx("h3",{children:"Capabilities"})]}),s.jsx(Lt,{size:20})]}),[["allowProcessManagement","Allow process management"],["allowServiceManagement","Allow service management"],["allowFileChanges","Allow file changes"],["allowCommandExecution","Allow command execution"],["allowSoftwareInstallation","Allow software installation"],["allowPowerActions","Allow power actions"]].map(([xe,Ae])=>s.jsx(ot,{icon:Lt,title:Ae,description:xe.includes("allowCommand")||xe.includes("Installation")||xe.includes("Power")?"Disabled by default for safety.":"Applied by the Hub and checked again by the Client.",children:s.jsx(jt,{checked:!!V[xe],onChange:L("agent",xe),label:Ae})},xe))]}),s.jsx("p",{className:"settings-help",children:"The existing Codex runtime and audit controls remain available below in Advanced and the Agent diagnostics panel."})]}),ge=y==="connection"?X:y==="security"?P:y==="control"?oe:y==="wall"?we:y==="files-audio"?J:y==="agent"?s.jsxs(s.Fragment,{children:[B,g]}):s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[v,s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Developer controls"}),s.jsx("h3",{children:"Streaming and diagnostics"})]}),s.jsx(sf,{size:20})]}),s.jsx("p",{className:"settings-help",children:"Codec, frame rate, resolution, quality, Atlas layout, and decoder preferences are intentionally kept here."}),m,p]})]});return s.jsxs("section",{className:"settings-page",children:[s.jsx("div",{className:"settings-page-tabs",role:"tablist","aria-label":"LiveDesk settings",children:Rj.map(({id:xe,label:Ae,icon:_e})=>s.jsxs("button",{className:y===xe?"active":"",id:`settings-tab-${xe}`,role:"tab","aria-selected":y===xe,"aria-controls":`settings-panel-${xe}`,tabIndex:y===xe?0:-1,onClick:()=>w(xe),type:"button",children:[s.jsx(_e,{size:16}),Ae]},xe))}),k&&s.jsx("div",{className:"agent-settings-alert error",role:"alert",children:k}),s.jsx("section",{className:"settings-page-panel",id:Y,role:"tabpanel","aria-labelledby":`settings-tab-${y}`,tabIndex:0,children:ge})]})}function Lj({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}function _j({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}function zj({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}const Cb={enabled:!0,provider:"codex",codexModelId:"",codexReasoningEffort:"medium",codexTaskTimeoutMs:6e5,codexMaxToolCalls:20,codexWorkingDirectory:"",codexResumeSessions:!0,codexShowDetailedEvents:!0,deterministicParserFirst:!0,generateSummary:!0,fallbackSummary:!0,includeRawDeviceDetails:!1,baseUrl:"https://opencode.ai/zen/go/v1",defaultModelId:"deepseek-v4-flash"};function Bx(n){return{...Cb,...n||{}}}function Ij({hubUrl:n}){const[a,r]=u.useState(Cb),[l,c]=u.useState(null),[d,m]=u.useState(""),[p,g]=u.useState(""),[v,b]=u.useState(""),[y,w]=u.useState("");u.useEffect(()=>{let L=!0;return Ge("/api/settings/agent",void 0,n).then(le=>{L&&(c(le.settings),r(Bx(le.settings)))}).catch(le=>{L&&w(le instanceof Error?le.message:String(le))}),()=>{L=!1}},[n]);const S=(L,le)=>r(q=>({...q,[L]:le})),j=L=>{c(L),r(Bx(L))},N=async()=>{g("save"),w(""),b("");try{const L={...a};d.trim()&&(L.apiKey=d.trim());const le=await Ge("/api/settings/agent",{method:"PUT",body:JSON.stringify(L)},n);j(le.settings),m(""),b("Agent settings saved.")}catch(L){w(L instanceof Error?L.message:String(L))}finally{g("")}},M=async()=>{g("reset"),w("");try{const L=await Ge("/api/settings/agent/reset",{method:"POST",body:JSON.stringify({})},n);j(L.settings),b("Codex defaults restored.")}catch(L){w(L instanceof Error?L.message:String(L))}finally{g("")}},k=async()=>{g("test"),w(""),b("");try{const L=await Ge("/api/settings/agent/test",{method:"POST",body:JSON.stringify({})},n),le=await Ge("/api/settings/agent",void 0,n);j(le.settings),b(`Codex connection verified with ${L.connection?.modelName||"the configured model"}${L.connection?.latencyMs?` in ${L.connection.latencyMs} ms.`:"."}`)}catch(L){w(L instanceof Error?L.message:String(L))}finally{g("")}},E=async()=>{g("clear-key"),w("");try{const L=await Ge("/api/settings/agent/api-key",{method:"DELETE"},n);j(L.settings),m(""),b("The optional OpenCode Go key was removed.")}catch(L){w(L instanceof Error?L.message:String(L))}finally{g("")}},R=l?.codexInstallation==="installed"&&l.codexAuth==="signed-in",U=l?.securityStatus,H=U?.state||"unavailable",W=H==="verified"?"Verified":H==="configured"?"Configured":"Unavailable",_=[["Codex home",U?.isolatedCodexHome],["Environment variables",U?.restrictedEnvironment],["LiveDesk MCP only",U?.livedeskMcpOnly],["Selected-device scope",U?.selectedDeviceScopeEnforced],["Fail-closed execution",U?.failClosed]];return s.jsxs("div",{className:"settings-tab-content agent-settings-content",children:[s.jsxs("header",{className:"agent-settings-header",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"settings-eyebrow",children:[s.jsx(ix,{size:14})," Agent AI"]}),s.jsx("h2",{children:"Codex SDK"}),s.jsx("p",{children:"Codex owns the agent reasoning loop. LiveDesk keeps the existing task manager and exposes only safe, read-only workstation tools."})]}),s.jsxs("label",{className:"settings-toggle agent-enable-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.enabled,onChange:L=>S("enabled",L.target.checked)}),s.jsx("span",{children:"Enable Agent AI"})]})]}),y&&s.jsx("div",{className:"agent-settings-alert error",role:"alert",children:y}),v&&s.jsx("div",{className:"agent-settings-alert success",role:"status",children:v}),s.jsxs("div",{className:"settings-section-grid",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Provider"}),s.jsx("h3",{children:"Codex is the default"})]}),s.jsx(_o,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Agent provider"}),s.jsxs("select",{value:a.provider,onChange:L=>S("provider",L.target.value),children:[s.jsx("option",{value:"codex",children:"Codex SDK"}),s.jsx("option",{value:"opencode-go",children:"OpenCode Go (optional legacy)"})]})]}),s.jsxs("div",{className:"agent-connection-row",children:[s.jsx("span",{className:`agent-connection-dot ${R?"connected":l?.codexAuth==="not-signed-in"?"unavailable":""}`}),s.jsx("span",{children:l?.codexInstallation==="not-installed"?"Codex SDK not installed":l?.codexAuth==="signed-in"?"Codex CLI signed in":l?.codexAuth==="not-signed-in"?"Codex CLI sign-in required":"Codex status not tested"}),s.jsxs("button",{className:"settings-reset",onClick:()=>{k()},disabled:p!==""||a.provider!=="codex",type:"button",children:[s.jsx(QS,{size:15})," ",p==="test"?"Testing":"Test connection"]})]}),s.jsxs("p",{className:"settings-help",children:[s.jsx(XS,{size:12})," Authentication is owned by the installed Codex CLI. LiveDesk never asks for or stores a ChatGPT token."]}),l?.codexPath&&s.jsxs("p",{className:"settings-help",children:["CLI: ",l.codexPath]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Codex runtime"}),s.jsx("h3",{children:"Model and reasoning"})]}),s.jsx(ix,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Model"}),s.jsx("input",{value:a.codexModelId,onChange:L=>S("codexModelId",L.target.value),placeholder:"Codex default",disabled:a.provider!=="codex"})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Reasoning effort"}),s.jsxs("select",{value:a.codexReasoningEffort,onChange:L=>S("codexReasoningEffort",L.target.value),disabled:a.provider!=="codex",children:[s.jsx("option",{value:"minimal",children:"Minimal"}),s.jsx("option",{value:"low",children:"Low"}),s.jsx("option",{value:"medium",children:"Medium"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"xhigh",children:"Extra high"})]})]}),s.jsxs("div",{className:"settings-field-grid",children:[s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Task timeout (ms)"}),s.jsx("input",{type:"number",min:"30000",max:"1800000",step:"10000",value:a.codexTaskTimeoutMs,onChange:L=>S("codexTaskTimeoutMs",Number(L.target.value)),disabled:a.provider!=="codex"})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Max tool calls"}),s.jsx("input",{type:"number",min:"1",max:"100",value:a.codexMaxToolCalls,onChange:L=>S("codexMaxToolCalls",Number(L.target.value)),disabled:a.provider!=="codex"})]})]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Workspace"}),s.jsx("h3",{children:"Restricted execution context"})]}),s.jsx(Lt,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Working directory"}),s.jsx("input",{value:l?.agentWorkspacePath||a.codexWorkingDirectory,readOnly:!0})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.codexResumeSessions,onChange:L=>S("codexResumeSessions",L.target.checked),disabled:a.provider!=="codex"}),s.jsx("span",{children:"Allow session resume"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.codexShowDetailedEvents,onChange:L=>S("codexShowDetailedEvents",L.target.checked),disabled:a.provider!=="codex"}),s.jsx("span",{children:"Show detailed Codex events"})]}),s.jsx("p",{className:"settings-help",children:"The agent receives no project path or arbitrary filesystem directory. It can call LiveDesk MCP tools only."})]})]}),a.provider==="opencode-go"&&s.jsxs("section",{className:"settings-section-card agent-legacy-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Developer fallback"}),s.jsx("h3",{children:"OpenCode Go"})]}),s.jsx(_o,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Base URL"}),s.jsx("input",{value:a.baseUrl,onChange:L=>S("baseUrl",L.target.value)})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"API key"}),s.jsx("input",{type:"password",value:d,onChange:L=>m(L.target.value),placeholder:l?.hasApiKey?l.apiKeyPreview:"Stored only in the Hub",autoComplete:"new-password"})]}),s.jsxs("div",{className:"settings-action-row",children:[s.jsxs("button",{className:"settings-reset",onClick:()=>{E()},disabled:p!==""||!l?.hasApiKey,type:"button",children:[s.jsx(Zh,{size:15})," Clear key"]}),s.jsx("span",{className:"settings-help",children:"This provider does not run the Codex MCP tool loop."})]})]}),s.jsxs("div",{className:"settings-section-grid",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Agent behavior"}),s.jsx("h3",{children:"Predictable operation"})]}),s.jsx(Hn,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.deterministicParserFirst,onChange:L=>S("deterministicParserFirst",L.target.checked)}),s.jsx("span",{children:"Use deterministic parser before Codex"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.generateSummary,onChange:L=>S("generateSummary",L.target.checked)}),s.jsx("span",{children:"Generate task summaries"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.fallbackSummary,onChange:L=>S("fallbackSummary",L.target.checked)}),s.jsx("span",{children:"Fallback to deterministic summaries"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.includeRawDeviceDetails,onChange:L=>S("includeRawDeviceDetails",L.target.checked)}),s.jsx("span",{children:"Include raw device details in summaries"})]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Safety"}),s.jsx("h3",{children:"Locked execution boundary"})]}),s.jsx(Lt,{size:20})]}),["Arbitrary shell commands","PowerShell and Bash","Filesystem writes, deletes, and installs","Reboot, shutdown, and process termination","Network access and web search"].map(L=>s.jsxs("div",{className:"agent-safety-row",children:[s.jsx(Xy,{size:15}),s.jsx("span",{children:L}),s.jsx("strong",{children:"Blocked"})]},L)),_.map(([L])=>s.jsxs("div",{className:"agent-safety-row",children:[s.jsx(Lt,{size:15}),s.jsx("span",{children:L}),s.jsx("strong",{className:H==="unavailable"?"agent-safety-failed":H==="configured"?"agent-safety-configured":"agent-safety-verified",children:W})]},L)),s.jsx("p",{className:"settings-help",children:"Configured means the boundary is present but has not completed runtime verification. Test the connection or start an Agent run to verify it."})]})]}),s.jsxs("div",{className:"settings-action-row agent-settings-actions",children:[s.jsxs("button",{className:"settings-reset",onClick:()=>{M()},disabled:p!=="",type:"button",children:[s.jsx(Qc,{size:15})," Reset defaults"]}),s.jsxs("button",{className:"text-button primary",onClick:()=>{N()},disabled:p!=="",type:"button",children:[s.jsx(Zy,{size:15})," ",p==="save"?"Saving":"Save Agent settings"]})]})]})}new Date().valueOf();function fi(n){const[a,r]=u.useState(n),l=u.useRef(n);return u.useEffect(()=>{if(l.current!==n){if(Array.isArray(l.current)&&Array.isArray(n)&&l.current.length===0&&n.length===0)return;l.current=n,r(n)}},[n]),[a,r]}function lp(n,a){return typeof n=="function"?typeof a=="object"?n(a):n():n}function Fo(n,a="data-id"){let r=n;for(!r.tagName&&n.target&&(r=n.target);r;){if(r.getAttribute&&r.getAttribute(a))return r;r=r.parentNode}return null}function Oj(n,a="data-id"){const r=Fo(n,a);return r?r.getAttribute(a):null}function iu(n,a="data-id"){const r=Fo(n,a);return r?yf(r,a):null}function yf(n,a="data-id"){const r=n.getAttribute(a);return r?Hj(r):null}function Bn(n){return typeof n=="string"?":"+n:n}function Hj(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function Bj(){return{detect:()=>!0,addEvent:function(n,a,r){return n.addEventListener(a,r),()=>n.removeEventListener(a,r)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var Ia=Bj();function op(n){Object.assign(Ia,n)}function Fx(n,a,r){function l(c){const d=Fo(c);if(!d)return;const m=yf(d);if(typeof a=="function")return a(m,c);let p,g=c.target;for(;g!=d;){if(p=g.dataset?g.dataset.action:null,p&&a[p]){a[p](m,c);return}g=g.parentNode}a[r]&&a[r](m,c)}Ia.addEvent(n,r,l)}function Po(n,a){Fx(n,a,"click"),a.dblclick&&Fx(n,a.dblclick,"dblclick")}function Fj(n,a){for(let r=n.length-1;r>=0;r--)if(n[r]===a){n.splice(r,1);break}}function Pj(n,a,r){for(let l=0;l<Xi.length;l++){if(l===r)continue;const c=Xi[l],d=c.props.parent?.();if(d&&n.contains(d)&&c.node.contains(a))return!0}return!1}var jb=new Date,ff=!1,_d=[],Xi=[],Px=n=>{const a=n.target;if(ff||!a.isConnected){ff=!1;return}for(let r=Xi.length-1;r>=0;r--){const{node:l,date:c,props:d}=Xi[r];if(!(c>jb)&&!l.contains(a)&&l!==a&&(Pj(l,a,r)||(d.callback&&d.callback(n),d.modal||n.defaultPrevented)))break}},$j=n=>{jb=new Date,ff=!0;for(let a=Xi.length-1;a>=0;a--){const{node:r}=Xi[a];if(!r.contains(n.target)&&r!==n.target){ff=!1;break}}};function mi(n,a){_d.length||(_d=[Ia.addGlobalEvent("click",Px,n),Ia.addGlobalEvent("contextmenu",Px,n),Ia.addGlobalEvent("mousedown",$j,n)]),typeof a!="object"&&(a={callback:a});const r={node:n,date:new Date,props:a};return Xi.push(r),{destroy(){Fj(Xi,r),Xi.length||(_d.forEach(l=>l()),_d=[])}}}var zd=n=>n.indexOf("bottom")!==-1,Id=n=>n.indexOf("left")!==-1,Od=n=>n.indexOf("right")!==-1,sh=n=>n.indexOf("top")!==-1,$x=n=>n.indexOf("fit")!==-1,Uc=n=>n.indexOf("overlap")!==-1,Uj=n=>n.split("-").every(a=>["center","fit"].indexOf(a)>-1),qj=n=>{const a=n.match(/(start|center|end)/);return a?a[0]:null};function Gj(n,a){let r=0;const l=Ia.getTopNode(n);for(;n&&n!==l;){const c=getComputedStyle(n).position;if((c==="absolute"||c==="relative"||c==="fixed")&&(r=parseInt(getComputedStyle(n).zIndex)||0),n=n.parentNode,n===a)break}return r}var Nn,na,qc,Kn;function kb(n,a,r="bottom",l=0,c=0){if(!n)return null;Nn=l,na=c,qc="auto";let d=0,m=0,p=r;const g=Ab(n),v=Uc(r)?Ia.getTopNode(n):g;if(!g)return null;const b=g.getBoundingClientRect(),y=n.getBoundingClientRect(),w=v.getBoundingClientRect(),S=window.getComputedStyle(v),j={left:0,top:0,bottom:0,right:0};for(const U in j){const H=`border-${U}-width`;j[U]=parseFloat(S.getPropertyValue(H))}if(a){const U=Gj(a,g);d=Math.max(U+1,20)}if(a){if(Kn=a.getBoundingClientRect(),$x(r)&&(qc=Kn.width+"px"),r!=="point")if(Uj(r))$x(r)?Nn=0:(Nn=w.width/2,m=1),na=(w.height-y.height)/2;else{const U=Uc(r)?0:1;Nn=Od(r)?Kn.right+U:Kn.left-U,na=zd(r)?Kn.bottom+1:Kn.top;const H=qj(r);H&&(Od(r)||Id(r)?H==="center"?na-=(y.height-Kn.height)/2:H==="end"&&(na-=y.height-Kn.height):(zd(r)||sh(r))&&(H==="center"?Nn-=(y.width-Kn.width)/2:H==="end"&&(Nn-=y.width-Kn.width),Uc(r)||(Nn+=1)))}}else Kn={left:l,right:l,top:c,bottom:c};const N=(Id(r)||Od(r))&&(zd(r)||sh(r));Id(r)&&(m=2);const M=Nn-y.width-w.left;a&&Id(r)&&!N&&M<0&&(Nn=Kn.right,m=0,p=p.replace("left","right"));const k=Nn+y.width*(1-m/2)-w.right;if(k>0)if(!Od(r))Nn=w.right-j.right-y.width;else{const U=Kn.left-w.x-y.width;a&&!N&&U>=0?(Nn=Kn.left-y.width,p=p.replace("right","left")):Nn-=k+j.right}m&&(Nn=Math.round(Nn-y.width*m/2));const E=M<0||k>0||!N;sh(r)&&(na=Kn.top-y.height,a&&na<w.y&&E&&(na=Kn.bottom,p=p.replace("top","bottom")));const R=na+y.height-w.bottom;return R>0&&(a&&zd(r)&&E?(na-=y.height+Kn.height+1,p=p.replace("bottom","top")):na-=R+j.bottom),Nn-=b.left+j.left,na-=b.top+j.top,Nn=(Uc(r)?Nn:Math.max(Nn,0))+v.scrollLeft,na=(Uc(r)?na:Math.max(na,0))+v.scrollTop,qc=qc||"auto",{at:p,x:Nn,y:na,z:d,width:qc}}function Ab(n){const a=Ia.getTopNode(n);for(n&&(n=n.parentElement);n;){const r=getComputedStyle(n).position;if(n===a||r==="relative"||r==="absolute"||r==="fixed")return n;n=n.parentNode}return null}function Vj(n){const a=[];let r=n;const l=Ia.getTopNode(n);for(;r&&r!==l&&!r.getAttribute("data-wx-portal-root");)getComputedStyle(r).position==="absolute"&&a.push(r),r=r.parentNode;return a}var Ux=new Date().valueOf();function cp(){return Ux+=1,Ux}function sa(n){return n<10?"0"+n:n.toString()}function Wj(n){const a=sa(n);return a.length==2?"0"+a:a}function Nb(n){const a=Math.floor(n/11)*11;return{start:a,end:a+11}}function ih(n){const a=(n.getDay()+6)%7,r=new Date(n.valueOf());r.setDate(n.getDate()+(3-a)),r.setHours(0,0,0,0);const l=new Date(r.getFullYear(),0,1),c=Math.round((r.getTime()-l.getTime())/864e5);return 1+Math.floor(c/7)}var qx=["",""];function Yj(n,a,r){switch(n){case"%d":return sa(a.getDate());case"%m":return sa(a.getMonth()+1);case"%j":return a.getDate();case"%n":return a.getMonth()+1;case"%y":return sa(a.getFullYear()%100);case"%Y":return a.getFullYear();case"%D":return r.dayShort[a.getDay()];case"%l":return r.dayFull[a.getDay()];case"%M":return r.monthShort[a.getMonth()];case"%F":return r.monthFull[a.getMonth()];case"%h":return sa((a.getHours()+11)%12+1);case"%g":return(a.getHours()+11)%12+1;case"%G":return a.getHours();case"%H":return sa(a.getHours());case"%i":return sa(a.getMinutes());case"%a":return((a.getHours()>11?r.pm:r.am)||qx)[0];case"%A":return((a.getHours()>11?r.pm:r.am)||qx)[1];case"%s":return sa(a.getSeconds());case"%S":return Wj(a.getMilliseconds());case"%W":return sa(ih(a));case"%w":{const l=r.weekStart??1;if(l===1)return sa(ih(a));const c=(a.getDay()-l+7)%7,d=(1-l+7)%7,m=new Date(a.valueOf());return m.setDate(a.getDate()+(d-c)),sa(ih(m))}case"%c":{let l=a.getFullYear()+"";return l+="-"+sa(a.getMonth()+1),l+="-"+sa(a.getDate()),l+="T",l+=sa(a.getHours()),l+=":"+sa(a.getMinutes()),l+=":"+sa(a.getSeconds()),l}case"%Q":return Math.floor(a.getMonth()/3)+1;default:return n}}var Kj=/%[a-zA-Z]/g;function zo(n,a){return typeof n=="function"?n:function(r){return r?(r.getMonth||(r=new Date(r)),n.replace(Kj,l=>Yj(l,r,a))):""}}function Gx(n){return n&&typeof n=="object"&&!Array.isArray(n)}function Oh(n,a){for(const r in a){const l=a[r];Gx(n[r])&&Gx(l)?n[r]=Oh({...n[r]},a[r]):n[r]=a[r]}return n}function lu(n){return{getGroup(a){const r=n[a];return l=>r&&r[l]||l},getRaw(){return n},extend(a,r){if(!a)return this;let l;return r?l=Oh({...a},n):l=Oh({...n},a),lu(l)}}}var Qj=sb();const Xj="en-US",Zj={monthFull:["January","February","March","April","May","June","July","August","September","October","November","December"],monthShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayFull:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],hours:"Hours",minutes:"Minutes",done:"Done",clear:"Clear",today:"Today",am:["am","AM"],pm:["pm","PM"],weekStart:0,clockFormat:24},Jj={ok:"OK",cancel:"Cancel",select:"Select","No data":"No data","Rows per page":"Rows per page","Total pages":"Total pages"},ek={timeFormat:"%H:%i",dateFormat:"%m/%d/%Y",monthYearFormat:"%F %Y",yearFormat:"%Y"},Mb={core:Jj,calendar:Zj,formats:ek,lang:Xj},up=u.createContext(""),Tb=u.createContext({}),Hs=u.createContext(null),Eb=u.createContext(null),Pn=Object.freeze(Object.defineProperty({__proto__:null,fieldId:Eb,helpers:Tb,i18n:Hs,theme:up},Symbol.toStringTag,{value:"Module"}));function Rb(n){const a=u.useContext(Eb),[r]=u.useState(()=>n||a||cp());return r}function eu({type:n="",css:a="",icon:r="",disabled:l=!1,title:c="",tooltip:d,text:m="",children:p,onClick:g}){const v=u.useMemo(()=>{let y=n?n.split(" ").filter(w=>w!=="").map(w=>"wx-"+w).join(" "):"";return a+(a?" ":"")+y},[n,a]),b=y=>{g&&g(y)};return s.jsxs("button",{title:c,className:`wx-2ZWgb4 wx-button ${v} ${r&&!p?"wx-icon":""}`,disabled:l,onClick:b,"data-tooltip-text":d,children:[r&&s.jsx("i",{className:"wx-2ZWgb4 "+r}),p||m||" "]})}function tk({id:n,label:a="",inputValue:r="",value:l=!1,onChange:c,disabled:d=!1,css:m=""}){const p=Rb(n),[g,v]=fi(l),b=({target:y})=>{const w=y.checked;v(w),c&&c({value:w,inputValue:r})};return s.jsxs("div",{className:`wx-2IvefP wx-checkbox ${m}`,children:[s.jsx("input",{type:"checkbox",id:p,disabled:d,className:"wx-2IvefP wx-check",checked:g,value:r,onChange:b}),s.jsxs("label",{htmlFor:p,className:"wx-2IvefP wx-label",children:[s.jsx("span",{className:"wx-2IvefP wx-before"}),a&&s.jsx("span",{className:"wx-2IvefP wx-after",children:a})]})]})}function dp({theme:n="",target:a,children:r}){const l=u.useRef(null),c=u.useRef(null),[d,m]=u.useState(null);l.current||(l.current=document.createElement("div"));const p=u.useContext(up);return u.useEffect(()=>{m(a||nk(c.current)||Ia.getTopNode(c.current))},[c.current]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:c,style:{display:"none"}}),c.current&&d?Qj.createPortal(s.jsx("div",{className:`wx-3ZWsT0 wx-${n||p}-theme`,children:r}),d):null]})}function nk(n){const a=Ia.getTopNode(n);for(;n&&n!==a&&!n.getAttribute("data-wx-portal-root");)n=n.parentNode;return n}function ak({left:n=0,top:a=0,at:r="bottom",parent:l=null,width:c="auto",css:d="",onCancel:m,children:p,trackScroll:g=!1}){const[v,b]=u.useState(0),[y,w]=u.useState(0),[S,j]=u.useState("auto"),[N,M]=u.useState(!1),k=u.useRef(null),E=u.useRef(null),R=u.useRef(m);u.useEffect(()=>{R.current=m},[m]);function U(W){return l&&(c+"").indexOf("%")>-1?c.replace(/(\d+)%/,(_,L)=>(L=L*l.offsetWidth/100+"px",c.replace(_,L))):c&&c!=="auto"?c:W}const H=u.useCallback(()=>{if(!k.current)return;const W=kb(k.current,l,r,n,a);W&&(b(W.x),w(W.y),j(U(W.width)))},[k,l,r,n,a,c]);return u.useLayoutEffect(()=>{const W=L=>{R.current&&L.target!==E.current&&k.current&&!k.current.contains(L.target)&&R.current(L)};let _;return requestAnimationFrame(()=>{H(),M(!0),g&&k.current&&(E.current=Ab(k.current),E.current&&E.current.addEventListener("scroll",W,!0)),l&&(_=new ResizeObserver(H),_.observe(l))}),()=>{g&&E.current&&E.current.removeEventListener("scroll",W,!0),_?.disconnect()}},[]),u.useLayoutEffect(()=>{H()},[l,r,n,a]),u.useEffect(()=>{const W=_=>{R.current&&R.current(_)};if(k.current)return mi(k.current,{callback:W,parent:()=>l}).destroy},[l]),s.jsx("div",{ref:k,className:["wx-37M6Fj","wx-popup",d].filter(Boolean).join(" "),style:{position:"absolute",visibility:N?"visible":"hidden",top:y+"px",left:v+"px",width:S},children:p})}function sk({position:n="bottom",align:a="start",autoFit:r=!0,onCancel:l=null,width:c="100%",css:d="",children:m}){const p=u.useRef(null),[g,v]=u.useState(n),[b,y]=u.useState(a),w=u.useRef(l);return u.useEffect(()=>{w.current=l},[l]),u.useEffect(()=>{if(r){const S=p.current;if(S){const j=S.getBoundingClientRect(),N=document.body.getBoundingClientRect();j.right>=N.right&&y("end"),j.bottom>=N.bottom&&v("top")}}},[]),u.useEffect(()=>{if(p.current){const S=j=>{w.current&&w.current(j)};return mi(p.current,S).destroy}},[]),s.jsx("div",{ref:p,className:["wx-dropdown",`wx-${g}-${b}`,d||"","wx-aaaVytZW"].filter(Boolean).join(" "),style:{width:c},children:m})}function fp({position:n="bottom",align:a="start",autoFit:r=!0,inline:l=!1,onCancel:c,width:d="100%",children:m,...p}){const[g,v]=u.useState(void 0),b=u.useRef(null),y=u.useMemo(()=>`${n}-${a}`,[n,a]);return u.useLayoutEffect(()=>{b.current&&v(b.current.parentNode)},[]),s.jsxs(s.Fragment,{children:[g&&(l?s.jsx(sk,{onCancel:c,position:n,align:a,autoFit:r,width:d,...p,children:m}):s.jsx(dp,{children:s.jsx(ak,{parent:g,at:y,onCancel:c,width:d,...p,children:m})})),s.jsx("span",{ref:b,className:"wx-portal-node wx-32GZ52"})]})}function bf(){return lu(Mb)}function ik(){let n=null,a=!1,r=!1,l,c,d,m;const p=(y,w,S,j,N)=>{l=y,c=w,d=S,m=j,r=N},g=y=>{n=y,a=n!==null,d(n)},v=(y,w)=>{if(!r&&y!==null&&l){const S=l.querySelectorAll(".wx-list > .wx-item")[y];S&&(S.scrollIntoView({block:"nearest"}),w&&w.preventDefault())}},b=(y,w)=>{const S=y===null?null:Math.max(0,Math.min(n+y,c.length-1));S!==n&&(g(S),l?v(S,w):requestAnimationFrame(()=>v(S,w)))};return{move:y=>{const w=iu(y),S=c.findIndex(j=>j.id===w);S!==n&&g(S)},keydown:(y,w)=>{switch(y.code){case"Enter":a?m():g(0);break;case"Space":a||g(0);break;case"Escape":d(n=null);break;case"Tab":d(n=null);break;case"ArrowDown":b(a?1:w||0,y);break;case"ArrowUp":b(a?-1:w||0,y);break}},init:p,navigate:b}}const Vx=10,rk=u.memo(function({data:n,checkboxes:a,itemTemplate:r,value:l}){return s.jsxs(s.Fragment,{children:[a&&s.jsx(tk,{id:n.id,css:"wx-list-checkbox",value:l&&l.includes(n.id)}),r?lp(r,{option:n}):n.label]})});function Wx({visibleItems:n,visibleRange:a,navIndex:r,checkboxes:l,itemTemplate:c,value:d,measureRefCallback:m}){return n.map((p,g)=>{const v=a.start+g;return s.jsx("div",{ref:g===0?m:void 0,className:`wx-233fr7 wx-item ${v===r?"wx-focus":""}`,"data-id":p.id,children:s.jsx(rk,{data:p,checkboxes:l,itemTemplate:c,value:d})},p.id)})}function wf({items:n=[],children:a,onSelect:r,onReady:l,virtualized:c=!1,checkboxes:d,multiselect:m,value:p,...g}){const v=u.useRef(),b=u.useRef(!1),y=u.useRef(ik()),[w,S]=u.useState(null),j=u.useRef(w),[N,M]=u.useState(0),[k,E]=u.useState(24),R=u.useRef(!1),U=(u.useContext(Hs)||bf()).getGroup("core"),H=u.useRef(n);u.useEffect(()=>{H.current=n},[n]);const W=u.useRef(p);u.useEffect(()=>{W.current=p},[p]);const _=u.useRef(0);u.useEffect(()=>{_.current=k},[k]);const L=u.useCallback(J=>{J&&J.stopPropagation();const B=H.current,pe=W.current,ge=j.current;let xe;const Ae=B[ge]?.id;m?pe&&pe.includes(Ae)?xe=pe.filter(_e=>_e!==Ae):xe=[...pe||[],Ae]:xe=Ae,r&&r({id:xe})},[m,r]),le=u.useRef(L);u.useEffect(()=>{le.current=L},[L]);const q=u.useCallback(J=>{if(v.current){let B=J*_.current-v.current.clientHeight+_.current;M(B),v.current.scrollTop=B}},[_.current]),te=u.useCallback(J=>{v.current=J,c&&(J&&!b.current&&j.current!==null&&requestAnimationFrame(()=>{v.current&&(q(j.current),b.current=!0)}),J||(b.current=!1))},[q]),K=u.useCallback(J=>{if(!J||R.current)return;const B=J.getBoundingClientRect().height;B&&(E(B),_.current=B,R.current=!0)},[]);u.useEffect(()=>{y.current.init(v.current,n,J=>{S(J),j.current=J},J=>le.current(J),c)},[n,v.current,c]),u.useEffect(()=>{const J=(pe,ge)=>{y.current.navigate(pe,ge),q(j.current)},B=(pe,ge)=>{const xe=j.current,Ae=H.current;if(xe!==0&&xe!==Ae.length-1&&(pe.key==="ArrowDown"||pe.key==="ArrowUp")&&pe.preventDefault(),y.current.keydown(pe,ge),v.current){const _e=v.current.scrollTop<=j.current*_.current,ie=v.current.scrollTop+v.current.clientHeight>=j.current*_.current+_.current;_e?ie||q(j.current):(v.current.scrollTop=j.current*_.current,M(v.current.scrollTop))}};l&&l({navigate:c?J:y.current.navigate,keydown:c?B:y.current.keydown,move:y.current.move})},[]);const ne=u.useRef(0),ce=u.useRef(n);ce.current!==n&&(ce.current=n,ne.current+=1);const V=u.useCallback(()=>{y.current.navigate(null)},[y]),O=u.useCallback(J=>{c&&M(J.target.scrollTop)},[c]),Y=u.useMemo(()=>Math.ceil((v.current?.clientHeight||0)/k),[k,N]),X=u.useMemo(()=>{if(!c)return{start:0,end:n.length};if(!n.length)return{start:0,end:0};const J=Math.floor(N/k),B=J+Y;return{start:Math.max(0,J-Vx),end:Math.min(n.length,B+Vx)}},[c,n,N,k,Y]),P=u.useMemo(()=>{if(!c)return n;const{start:J,end:B}=X;return n.slice(J,B).map(pe=>({...pe}))},[c,n,X]),oe=X.start*k,we=n.length*k;return u.useEffect(()=>{c&&M(0)},[n,c]),u.useEffect(()=>{w===null&&(b.current=!1)},[w]),w===null?null:s.jsx(fp,{onCancel:V,...g,children:s.jsx("div",{className:"wx-233fr7 wx-list",ref:te,onClick:L,onMouseMove:y.current.move,onScroll:O,children:n.length?c?s.jsx("div",{className:"wx-233fr7 wx-list-wrapper",style:{height:`${we}px`},children:s.jsx("div",{className:"wx-233fr7 wx-list-content",style:{transform:`translateY(${oe}px)`},children:s.jsx(Wx,{visibleRange:X,visibleItems:P,navIndex:w,measureRefCallback:K,checkboxes:d,itemTemplate:a,value:p})})}):s.jsx(Wx,{visibleRange:X,visibleItems:P,navIndex:w,measureRefCallback:K,checkboxes:d,itemTemplate:a,value:p}):s.jsx("div",{className:"wx-233fr7 wx-no-data",children:U("No data")})})},ne.current)}function mp({value:n="",id:a,readonly:r=!1,focus:l=!1,select:c=!1,type:d="text",placeholder:m="",disabled:p=!1,error:g=!1,title:v="",tooltip:b,css:y="",icon:w="",clear:S=!1,onChange:j}){const N=Rb(a),[M,k]=fi(n),E=u.useRef(null),R=u.useMemo(()=>w&&y.indexOf("wx-icon-left")===-1?"wx-icon-right "+y:y,[w,y]),U=u.useMemo(()=>w&&y.indexOf("wx-icon-left")!==-1,[w,y]);u.useEffect(()=>{const le=setTimeout(()=>{l&&E.current&&E.current.focus(),c&&E.current&&E.current.select()},1);return()=>clearTimeout(le)},[l,c]);const H=u.useCallback(le=>{const q=le.target.value;k(q),j&&j({value:q,input:!0})},[j]),W=u.useCallback(le=>j&&j({value:le.target.value}),[j]);function _(le){le.stopPropagation(),k(""),j&&j({value:""})}let L=d;return d!=="password"&&d!=="number"&&(L="text"),u.useEffect(()=>{const le=W,q=E.current;return q.addEventListener("change",le),()=>{q&&q.removeEventListener("change",le)}},[W]),s.jsxs("div",{className:`wx-hQ64J4 wx-text ${R} ${g?"wx-error":""} ${p?"wx-disabled":""} ${S?"wx-clear":""}`,"data-tooltip-text":b,children:[s.jsx("input",{className:"wx-hQ64J4 wx-input",ref:E,id:N,readOnly:r,disabled:p,placeholder:m,type:L,title:v,value:M,onInput:H}),S&&!p&&M?s.jsxs(s.Fragment,{children:[s.jsx("i",{className:"wx-hQ64J4 wx-icon wxi-close",onClick:_}),U&&s.jsx("i",{className:`wx-hQ64J4 wx-icon ${w}`})]}):w?s.jsx("i",{className:`wx-hQ64J4 wx-icon ${w}`}):null]})}function lk({date:n,type:a,part:r,onShift:l}){const{calendar:c,formats:d}=u.useContext(Hs).getRaw(),m=n.getFullYear(),p=u.useMemo(()=>{switch(a){case"month":return zo(d.monthYearFormat,c)(n);case"year":return zo(d.yearFormat,c)(n);case"duodecade":{const{start:v,end:b}=Nb(m),y=zo(d.yearFormat,c);return`${y(new Date(v,0,1))} - ${y(new Date(b,11,31))}`}default:return""}},[n,a,m,c,d]);function g(){l&&l({diff:0,type:a})}return s.jsxs("div",{className:"wx-8HQVQV wx-header",children:[r!=="right"?s.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-left",onClick:()=>l&&l({diff:-1,type:a})}):s.jsx("span",{className:"wx-8HQVQV wx-spacer"}),s.jsx("span",{className:"wx-8HQVQV wx-label",onClick:g,children:p}),r!=="left"?s.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-right",onClick:()=>l&&l({diff:1,type:a})}):s.jsx("span",{className:"wx-8HQVQV wx-spacer"})]})}function hp({onClick:n,children:a}){return s.jsx("button",{className:"wx-3s8W4d wx-button",onClick:n,children:a})}function ok({value:n,current:a,part:r="",markers:l=null,css:c="",onCancel:d,onChange:m}){const p=(u.useContext(Hs)||bf()).getRaw().calendar,g=(p.weekStart||7)%7,v=p.dayShort.slice(g).concat(p.dayShort.slice(0,g)),b=(H,W,_)=>new Date(H.getFullYear(),H.getMonth()+(W||0),H.getDate()+(_||0));let y=r!=="normal";function w(H){const W=H.getDay();return W===0||W===6}function S(){const H=b(a,0,1-a.getDate());return H.setDate(H.getDate()-(H.getDay()-(g-7))%7),H}function j(){const H=b(a,1,-a.getDate());return H.setDate(H.getDate()+(6-H.getDay()+g)%7),H}const N=u.useRef(0);function M(H,W){W.timeStamp!==N.current&&(N.current=W.timeStamp,W.stopPropagation(),m&&m(new Date(H)),d&&d())}const k=u.useMemo(()=>r=="normal"?[n?b(n).valueOf():0]:n?[n.start?b(n.start).valueOf():0,n.end?b(n.end).valueOf():0]:[0,0],[r,n]),E=u.useMemo(()=>{const H=S(),W=j(),_=a.getMonth();let L=[];for(let le=H;le<=W;le.setDate(le.getDate()+1)){const q={day:le.getDate(),in:le.getMonth()===_,date:le.valueOf()};let te="";if(te+=q.in?"":" wx-inactive",te+=k.indexOf(q.date)>-1?" wx-selected":"",y){const K=q.date==k[0],ne=q.date==k[1];K&&!ne?te+=" wx-left":ne&&!K&&(te+=" wx-right"),q.date>k[0]&&q.date<k[1]&&(te+=" wx-inrange")}if(te+=w(le)?" wx-weekend":"",l){const K=l(le);K&&(te+=" "+K)}L.push({...q,css:te})}return L},[a,k,y,l]),R=u.useRef(null);let U=u.useRef({});return U.current.click=M,u.useEffect(()=>{Po(R.current,U.current)},[]),s.jsxs("div",{className:`wx-398RBS wx-month ${c}`,children:[s.jsx("div",{className:"wx-398RBS wx-weekdays",children:v.map(H=>s.jsx("div",{className:"wx-398RBS wx-weekday",children:H},H))}),s.jsx("div",{className:"wx-398RBS wx-days",ref:R,children:E.map(H=>s.jsx("div",{className:`wx-398RBS wx-day ${H.css} ${H.in?"":"wx-out"}`,"data-id":H.date,children:H.day},H.date))})]})}function ck({value:n,current:a,part:r,onCancel:l,onChange:c,onShift:d}){const m=u.useRef(new Date),[p,g]=fi(n||m.current),[v,b]=fi(a||m.current),y=u.useContext(Hs).getRaw().calendar,w=y.monthShort||[],S=u.useMemo(()=>v.getMonth(),[v]),j=u.useCallback((k,E)=>{if(k!=null){E.stopPropagation();const R=new Date(v);R.setMonth(k),b(R),d&&d({current:R})}r==="normal"&&g(new Date(v)),l&&l()},[v,r,d,l]),N=u.useCallback(()=>{const k=new Date(Db(p,r)||v);k.setMonth(v.getMonth()),k.setFullYear(v.getFullYear()),c&&c(k)},[p,v,r,c]),M=u.useCallback(k=>{const E=k.target.closest("[data-id]");if(E){const R=parseInt(E.getAttribute("data-id"),10);j(R,k)}},[j]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-34U8T8 wx-months",onClick:M,children:w.map((k,E)=>s.jsx("div",{className:"wx-34U8T8 wx-month"+(S===E?" wx-current":""),"data-id":E,children:k},E))}),s.jsx("div",{className:"wx-34U8T8 wx-buttons",children:s.jsx(hp,{onClick:N,children:y.done})})]})}const rh="wx-1XEF33",uk=({value:n,current:a,onCancel:r,onChange:l,onShift:c,part:d})=>{const m=u.useContext(Hs).getRaw().calendar,[p,g]=fi(a),[v,b]=fi(n),y=u.useMemo(()=>p.getFullYear(),[p]),w=u.useMemo(()=>{const{start:k,end:E}=Nb(y),R=[];for(let U=k;U<=E;++U)R.push(U);return R},[y]),S={click:j};function j(k,E){if(k){E.stopPropagation();const R=new Date(p);R.setFullYear(k),g(R),c&&c({current:R})}d==="normal"&&b(new Date(p)),r&&r()}function N(){const k=new Date(Db(v,d)||p);k.setFullYear(p.getFullYear()),l&&l(k)}const M=u.useRef(null);return u.useEffect(()=>{M.current&&Po(M.current,S)},[]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:rh+" wx-years",ref:M,children:w.map((k,E)=>s.jsx("div",{className:rh+` wx-year ${y==k?"wx-current":""} ${E===0?"wx-prev-decade":""} ${E===11?"wx-next-decade":""}`,"data-id":k,children:k},E))}),s.jsx("div",{className:rh+" wx-buttons",children:s.jsx(hp,{onClick:N,children:m.done})})]})},Yx={month:{component:ok,next:fk,prev:dk},year:{component:ck,next:hk,prev:mk},duodecade:{component:uk,next:gk,prev:pk}};function dk(n){return n=new Date(n),n.setMonth(n.getMonth()-1),n}function fk(n){return n=new Date(n),n.setMonth(n.getMonth()+1),n}function mk(n){return n=new Date(n),n.setFullYear(n.getFullYear()-1),n}function hk(n){return n=new Date(n),n.setFullYear(n.getFullYear()+1),n}function pk(n){return n=new Date(n),n.setFullYear(n.getFullYear()-10),n}function gk(n){return n=new Date(n),n.setFullYear(n.getFullYear()+10),n}function Db(n,a){let r;if(a==="normal")r=n;else{const{start:l,end:c}=n;a==="left"?r=l:a=="right"?r=c:r=l&&c}return r}const vk=["clear","today"];function xk(n){if(n==="done")return-1;if(n==="clear")return null;if(n==="today")return new Date}function yk({value:n,current:a,onCurrentChange:r,part:l="normal",markers:c=null,buttons:d,css:m="",onShift:p,onChange:g}){const v=u.useContext(Hs).getGroup("calendar"),[b,y]=u.useState("month"),w=Array.isArray(d)?d:d?vk:[],S=(E,R)=>{E.preventDefault(),g&&g({value:R})},j=()=>{b==="duodecade"?y("year"):b==="year"&&y("month")},N=E=>{const{diff:R,current:U}=E;if(R===0){b==="month"?y("year"):b==="year"&&y("duodecade");return}if(R){const H=Yx[b];r(R>0?H.next(a):H.prev(a))}else U&&r(U);p&&p()},M=E=>{y("month"),g&&g({select:!0,value:E})},k=u.useMemo(()=>Yx[b].component,[b]);return s.jsx("div",{className:`wx-2Gr4AS wx-calendar ${l!=="normal"&&l!=="both"?"wx-part":""} ${m}`,children:s.jsxs("div",{className:"wx-2Gr4AS wx-wrap",children:[s.jsx(lk,{date:a,part:l,type:b,onShift:N}),s.jsxs("div",{children:[s.jsx(k,{value:n,current:a,onCurrentChange:r,part:l,markers:c,onCancel:j,onChange:M,onShift:N}),b==="month"&&w.length>0&&s.jsx("div",{className:"wx-2Gr4AS wx-buttons",children:w.map(E=>s.jsx("div",{className:"wx-2Gr4AS wx-button-item",children:s.jsx(hp,{onClick:R=>S(R,xk(E)),children:v(E)})},E))})]})]})})}function pp(n){let{words:a=null,optional:r=!1,children:l}=n,c=u.useContext(Hs);const d=u.useMemo(()=>{let m=c;return(!m||!m.extend)&&(m=lu(Mb)),a!==null&&(m=m.extend(a,r)),m},[a,r,c]);return s.jsx(Hs.Provider,{value:d,children:l})}function Kx(n,a,r,l){if(!n||l){const c=a?new Date(a):new Date;c.setDate(1),r(c)}else if(n.getDate()!==1){const c=new Date(n);c.setDate(1),r(c)}}const bk=["clear","today"];function Lb({value:n,current:a,markers:r=null,buttons:l=bk,css:c="",onChange:d}){const[m,p]=fi(n),[g,v]=fi(a);u.useEffect(()=>{Kx(g,m,v,!1)},[m,g]);const b=u.useCallback(w=>{const S=w.value;S?(p(new Date(S)),Kx(g,new Date(S),v,!0)):p(null),d&&d({value:S?new Date(S):null})},[d,g]),y=u.useCallback(w=>{v(w)},[v]);return g?s.jsx(pp,{children:s.jsx(yk,{value:m,current:g,markers:r,buttons:l,css:c,onChange:b,onCurrentChange:y})}):null}function wk(n){return n||(n={}),n.width||(n.width="unset"),n}const Sk=["clear","today"];function Ck({value:n,id:a,disabled:r=!1,error:l=!1,placeholder:c="",format:d="",buttons:m=Sk,css:p="",title:g="",tooltip:v,editable:b=!1,clear:y=!1,onChange:w,dropdown:S={}}){const{calendar:j,formats:N}=(u.useContext(Hs)||bf()).getRaw(),M=d||N?.dateFormat;let k=typeof M=="function"?M:zo(M,j);const[E,R]=u.useState(n),[U,H]=u.useState(!1);u.useEffect(()=>{R(n)},[n]);function W(){H(!1)}function _(q){const te=q===E||q&&E&&q.valueOf()===E.valueOf()||!q&&!E;R(q),te||w&&w({value:q}),setTimeout(W,1)}const L=u.useMemo(()=>E?k(E):"",[E,k]);function le({value:q,input:te}){if(!b&&!y||te)return;let K=typeof b=="function"?b(q):q?new Date(q):null;K=isNaN(K)?E||null:K||null,_(K)}return u.useEffect(()=>{const q=W;return window.addEventListener("scroll",q),()=>window.removeEventListener("scroll",q)},[]),s.jsxs("div",{className:"wx-1lKOFG wx-datepicker",onClick:()=>H(!0),children:[s.jsx(mp,{css:`wx-date-input ${p}`,title:g,tooltip:v,value:L,id:a,readonly:!b,disabled:r,error:l,placeholder:c,onInput:W,onChange:le,icon:"wxi-calendar",clear:y}),U&&!r&&s.jsx(fp,{onCancel:W,...wk(S),children:s.jsx(Lb,{buttons:m,value:E,onChange:q=>_(q.value)})})]})}function jk({value:n="",options:a=[],textOptions:r=null,placeholder:l="",disabled:c=!1,error:d=!1,title:m="",tooltip:p,textField:g="label",clear:v=!1,css:b="",children:y,onChange:w,dropdown:S={}}){const j=u.useRef(null),N=u.useRef(null);let[M,k]=fi(n);function E(_){j.current=_.navigate,N.current=_.keydown}const R=u.useMemo(()=>M||M===0?(r||a).find(_=>_.id===M):null,[M,r,a]),U=u.useCallback(({id:_})=>{(_||_===0)&&(k(_),j.current(null),w&&w({value:_}))},[k,w]),H=u.useCallback(_=>{_.stopPropagation(),k(""),w&&w({value:""})},[k,w]),W=u.useCallback(()=>a.findIndex(_=>_.id===M),[a,M]);return s.jsxs("div",{className:`wx-2YgblL wx-richselect ${b} ${d?"wx-2YgblL wx-error":""} ${c?"wx-2YgblL wx-disabled":""} ${y?"":"wx-2YgblL wx-nowrap"}`,title:m,onClick:()=>j.current(W()),onKeyDown:_=>N.current(_,W()),tabIndex:0,"data-tooltip-text":p,children:[s.jsx("div",{className:"wx-2YgblL wx-label",children:R?y?y(R):R[g]:l?s.jsx("span",{className:"wx-2YgblL wx-placeholder",children:l}):" "}),v&&!c&&M?s.jsx("i",{className:"wx-2YgblL wx-icon wxi-close",onClick:H}):s.jsx("i",{className:"wx-2YgblL wx-icon wxi-angle-down"}),!c&&s.jsx(wf,{items:a,onReady:E,onSelect:U,...S,children:({option:_})=>y?y(_):_[g]})]})}const kk=({options:n=[],value:a="",css:r="",children:l,onChange:c})=>{const[d,m]=u.useState(a),p=g=>{m(g),c&&c({value:g})};return u.useEffect(()=>{m(a)},[a]),s.jsx("div",{className:`wx-0hMO7P wx-segmented ${r}`,children:n.map(g=>s.jsx("button",{className:`wx-0hMO7P wx-segment ${g.css} ${g.id===d?"wx-selected":""}`,title:g.title,onClick:()=>p(g.id),"data-tooltip-text":g.tooltip,children:l?lp(l,{option:g}):s.jsxs(s.Fragment,{children:[g.icon&&s.jsx("i",{className:`wx-0hMO7P wx-icon ${g.icon} ${g.label?"":"wx-only"}`}),g.label&&s.jsx("span",{className:"wx-0hMO7P wx-label",children:g.label})]})},g.id))})};function Ak({notice:n={}}){function a(){n.remove&&n.remove()}return s.jsxs("div",{className:`wx-11sNg5 wx-notice wx-${n.type?n.type:""}`,role:"status","aria-live":"polite",children:[s.jsx("div",{className:"wx-11sNg5 wx-text",children:n.text}),s.jsx("div",{className:"wx-11sNg5 wx-button",children:s.jsx("i",{className:"wx-11sNg5 wxi-close",onClick:a})})]})}function Nk({data:n=[]}){return s.jsx("div",{className:"wx-3nwoO9 wx-notices",children:n.map(a=>s.jsx(Ak,{notice:a},a.id))})}function Hh({title:n="",buttons:a=["cancel","ok"],header:r,children:l,footer:c,css:d="",onConfirm:m,onCancel:p}){const g=(u.useContext(Hs)||bf()).getGroup("core"),v=u.useRef(null);u.useEffect(()=>{v.current?.focus()},[]);function b(w){switch(w.code){case"Enter":{const S=w.target.tagName;if(S==="TEXTAREA"||S==="BUTTON")return;m&&m({event:w});break}case"Escape":p&&p({event:w});break}}function y(w,S){const j={event:w,button:S};S==="cancel"?p&&p(j):m&&m(j)}return s.jsx("div",{className:`wx-1FxkZa wx-modal ${d}`,ref:v,tabIndex:0,onKeyDown:b,children:s.jsxs("div",{className:"wx-1FxkZa wx-window",children:[r||(n?s.jsx("div",{className:"wx-1FxkZa wx-header",children:n}):null),s.jsx("div",{children:l}),c||a&&s.jsx("div",{className:"wx-1FxkZa wx-buttons",children:a.map(w=>s.jsx("div",{className:"wx-1FxkZa wx-button",children:s.jsx(eu,{type:`block ${w==="ok"?"primary":"secondary"}`,onClick:S=>y(S,w),children:g(w)})},w))})]})})}function Mk({children:n},a){const[r,l]=u.useState(null),[c,d]=u.useState([]);return u.useImperativeHandle(a,()=>({showModal:m=>{const p={...m};return l(p),new Promise((g,v)=>{p.resolve=b=>{l(null),g(b)},p.reject=b=>{l(null),v(b)}})},showNotice:m=>{m={...m},m.id=m.id||cp(),m.remove=()=>d(p=>p.filter(g=>g.id!==m.id)),m.expire!=-1&&setTimeout(m.remove,m.expire||5100),d(p=>[...p,m])}}),[]),s.jsxs(s.Fragment,{children:[n,r&&s.jsx(Hh,{title:r.title,buttons:r.buttons,onConfirm:r.resolve,onCancel:r.reject,children:r.message}),s.jsx(Nk,{data:c})]})}const Tk=u.forwardRef(Mk);function Ek(n){let{children:a}=n,r=u.useRef();const l=u.useMemo(()=>({showNotice:c=>r.current.showNotice(c),showModal:c=>r.current.showModal(c)}),[]);return s.jsx(Tb.Provider,{value:l,children:s.jsx(Tk,{ref:r,children:a})})}const Rk=({value:n=!1,type:a="",icon:r="",disabled:l=!1,iconActive:c="",onClick:d,title:m="",tooltip:p,css:g="",text:v="",textActive:b="",children:y,active:w,onChange:S})=>{const[j,N]=fi(n),M=u.useMemo(()=>(j?"pressed":"")+(a?" "+a:""),[j,a]),k=u.useCallback(E=>{let R=!j;d&&d(E),E.defaultPrevented||(N(R),S&&S({value:R}))},[j,d,S]);return j&&w?s.jsx(eu,{title:m,tooltip:p,text:j&&b||v,css:g,type:M,icon:j&&c||r,onClick:k,disabled:l,children:lp(w,{value:j})}):y?s.jsx(eu,{title:m,tooltip:p,text:j&&b||v,css:g,type:M,icon:j&&c||r,onClick:k,disabled:l,children:y}):s.jsx(eu,{title:m,tooltip:p,text:j&&b||v,css:g,type:M,icon:j&&c||r,onClick:k,disabled:l})};function Dk(){return s.jsx(s.Fragment,{})}function Qx(n){const{fonts:a=!0,children:r}=n;return s.jsx(up.Provider,{value:"willow",children:s.jsxs(s.Fragment,{children:[r&&r&&s.jsx("div",{className:"wx-theme wx-willow-theme",children:r}),a&&s.jsxs(s.Fragment,{children:[s.jsx("link",{rel:"preconnect",href:"https://cdn.svar.dev",crossOrigin:"true"}),s.jsx(Dk,{}),s.jsx("link",{rel:"stylesheet",href:"https://cdn.svar.dev/fonts/wxi/wx-icons.css"})]})]})})}op(Ia);const gp={grid:{"Add before":"Add before","Add after":"Add after",Copy:"Copy",Cut:"Cut",Paste:"Paste",Delete:"Delete","New row":"New row","Move up":"Move up","Move down":"Move down",Undo:"Undo",Redo:"Redo",selected:"selected"}};new Date().valueOf();var _b=class{constructor(n){this._nextHandler=null,this._dispatch=n,this.exec=this.exec.bind(this)}async exec(n,a){return this._dispatch(n,a),this._nextHandler&&await this._nextHandler.exec(n,a),a}setNext(n){return this._nextHandler=n}};new Date().valueOf();var Lk=class{constructor(n){const a={id:0,$level:0,data:[],parent:null},r=new Map;r.set(0,a),this._pool=r,n&&n.length&&this.parse(n,0)}parse(n,a){const r=this._pool;for(let c=0;c<n.length;c++){const d=n[c];d.parent=d.parent||a,d.data=null,r.set(d.id,d)}for(let c=0;c<n.length;c++){const d=n[c],m=r.get(d.parent);m&&(m.data||(m.data=[]),m.data.push(d))}const l=r.get(a);this.setLevel(l,l.$level+1,!1)}add(n,a){const r=this._pool.get(n.parent||0);n.$level=r.$level+1,this._pool.set(n.id,n),r.data?a===-1?r.data=[...r.data,n]:Xx(r,a,n):r.data=[n]}addAfter(n,a){if(!a)return this.add(n,-1);const r=this.byId(a),l=this.byId(r.parent),c=Hd(l,r.id)+1;n.parent=l.id,n.$level=l.$level+1,this.add(n,c)}remove(n){const a=this._pool.get(n);this._remove(a);const r=this._pool.get(a.parent);r.data=r.data.filter(l=>l.id!=n),this._clearBranch(r)}_remove(n){n.data&&n.data.forEach(a=>this._remove(a)),this._pool.delete(n.id)}update(n,a){let r=this._pool.get(n);const l=this._pool.get(r.parent),c=Hd(l,r.id);r={...r,...a},l&&c>=0&&(l.data[c]=r,l.data=[...l.data]),this._pool.set(r.id,r)}move(n,a,r){const l=this._pool.get(n),c=a==="child",d=this._pool.get(r),m=d.$level+(c?1:0);if(!l||!d)return;const p=this._pool.get(l.parent),g=c?d:this._pool.get(d.parent);g.data||(g.data=[]);const v=Hd(p,l.id);_k(p,v);const b=c?g.data.length:Hd(g,d.id)+(a==="after"?1:0);if(Xx(g,b,l),p.id===g.id&&v===b)return null;l.parent=g.id,l.$level!==m&&(l.$level=m,this.setLevel(l,m+1,!0)),this.update(l.id,l),this._clearBranch(p)}_clearBranch(n){n.data&&!n.data.length&&(n.open&&delete n.open,this.update(n.id,{data:null}))}toArray(){const n=[],a=this._pool.get(0).data;return a&&zb(a,n),n}byId(n){return this._pool.get(n)}getBranch(n){return this._pool.get(n).data}forEach(n){this._pool.forEach((a,r)=>{r!==0&&n(a)})}eachChild(n,a){const r=this.byId(a);!r||!r.data||r.data.forEach((l,c)=>{n(this.byId(l.id),c),this.eachChild(n,l.id)})}setLevel(n,a,r){n.data&&(n.data=n.data.map(l=>(r&&(l={...l},this._pool.set(l.id,l)),l.$level=a,l.data&&this.setLevel(l,a+1,r),l)))}};function zb(n,a){n.forEach(r=>{a.push(r),r.open===!0&&zb(r.data,a)})}function _k(n,a){const r=[...n.data];r.splice(a,1),n.data=r}function Xx(n,a,r){const l=[...n.data];l.splice(a,0,r),n.data=l}function Hd(n,a){return n?.data.findIndex(r=>r.id===a)}var Ib=2,zk=class{constructor(a){a&&(this._writable=a.writable,this._async=a.async),this._values={},this._state={}}setState(a,r=0){const l={};return this._wrapProperties(a,this._state,this._values,"",l,r),l}getState(){return this._values}getReactive(){return this._state}_wrapProperties(a,r,l,c,d,m){for(const p in a){const g=r[p],v=l[p],b=a[p];if(g&&(v===b&&typeof b!="object"||b instanceof Date&&v instanceof Date&&v.getTime()===b.getTime()))continue;const y=c+(c?".":"")+p;g?(g.__parse(b,y,d,m)&&(l[p]=b),m&Ib?d[y]=g.__trigger:g.__trigger()):(b&&b.__reactive?r[p]=this._wrapNested(b,b,y,d):r[p]=this._wrapWritable(b),l[p]=b),d[y]=d[y]||null}}_wrapNested(a,r,l,c){const d=this._wrapWritable(a);return this._wrapProperties(a,d,r,l,c,0),d.__parse=(m,p,g,v)=>(this._wrapProperties(m,d,r,p,g,v),!1),d}_wrapWritable(a){const r=[],l=function(){for(let c=0;c<r.length;c++)r[c](a)};return{subscribe:c=>(r.push(c),this._async?setTimeout(c,1,a):c(a),()=>{const d=r.indexOf(c);d>=0&&r.splice(d,1)}),__trigger:()=>{r.length&&(this._async?setTimeout(l,1):l())},__parse:function(c){return a=c,!0}}}};function Zx(n,a){return Object.defineProperty(n,"__reactive",{value:!0,enumerable:!1,writable:!1}),n}var Ik=class{constructor(a,r,l,c){typeof a=="function"?this._setter=a:this._setter=a.setState.bind(a),this._routes=r,this._parsers=l,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(d=>{d.in.forEach(m=>{const p=this._triggers.get(m)||[];p.push(d),this._triggers.set(m,p)}),d.out.forEach(m=>{const p=this._sources.get(m)||{};d.in.forEach(g=>p[g]=!0),this._sources.set(m,p)})}),this._routes.forEach(d=>{d.length=Math.max(...d.in.map(m=>Ob(m,this._sources,1)))}),this._bus=c}init(a){const r={};for(const l in a)if(this._prev[l]!==a[l]){const c=this._parsers[l];r[l]=c?c(a[l]):a[l]}this._prev=this._prev?{...this._prev,...a}:{...a},this.setState(r),this._bus&&this._bus.exec("init-state",r)}setStateAsync(a){const r=this._setter(a,Ib);return this._async?Object.assign(this._async.signals,r):this._async={signals:r,timer:setTimeout(this._applyState.bind(this),1)},r}_applyState(){const a=this._async;if(a){this._async=null,this._triggerUpdates(a.signals,[]);for(const r in a.signals){const l=a.signals[r];l&&l()}}}setState(a,r=[]){const l=this._setter(a);return this._triggerUpdates(l,r),l}_triggerUpdates(a,r){const l=Object.keys(a),c=!r.length;r=r||[];for(let d=0;d<l.length;d++){const m=l[d],p=this._triggers.get(m);p&&p.forEach(g=>{r.indexOf(g)==-1&&r.push(g)})}c&&this._execNext(r)}_execNext(a){for(;a.length;){a.sort((l,c)=>l.length<c.length?1:-1);const r=a[a.length-1];a.splice(a.length-1),r.exec(a)}}};function Ob(n,a,r){const l=a.get(n);if(!l)return r;const c=Object.keys(l).map(d=>Ob(d,a,r+1));return Math.max(...c)}var Ok=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(a,r,l){let c=this._handlers[a];c?l&&l.intercept?c.unshift(r):c.push(r):c=this._handlers[a]=[r],l&&l.tag&&this._tag.set(r,l.tag)}intercept(a,r,l){this.on(a,r,{...l,intercept:!0})}detach(a){for(const r in this._handlers){const l=this._handlers[r];for(let c=l.length-1;c>=0;c--)this._tag.get(l[c])===a&&l.splice(c,1)}}async exec(a,r){const l=this._handlers[a];if(l)for(let c=0;c<l.length;c++){const d=l[c](r);if(d===!1||d&&d.then&&await d===!1)return}return this._nextHandler&&await this._nextHandler.exec(a,r),r}setNext(a){return this._nextHandler=a}};const Mo=1024;function ru(n){return n<Mo?`${n} B`:n<Mo**2?`${(n/Mo).toFixed(1)} KB`:n<Mo**3?`${(n/Mo**2).toFixed(1)} MB`:`${(n/Mo**3).toFixed(1)} GB`}function Jx(n,a){a||(a={key:"name",order:"asc"});const r=n.filter(m=>m.type==="folder"),l=n.filter(m=>m.type!=="folder"),c=r.sort(ey(a)),d=l.sort(ey(a));return[...c,...d]}function Hk(n,a){return typeof n=="string"?n.localeCompare(a,void 0,{numeric:!0}):typeof n=="object"?n.getTime()-a.getTime():(n??0)-(a??0)}function Bk(n,a){return typeof n=="string"?-n.localeCompare(a,void 0,{numeric:!0}):typeof a=="object"?a.getTime()-n.getTime():(a??0)-(n??0)}function ey({key:n,order:a}){const r=a==="asc"?Hk:Bk;return(l,c)=>r(l[n],c[n])}function vp(n,a){const r=n==="/"?1:n.split("/").length;return r>=a.length?null:a[r].id}function Fk(n){return n.length>1?n[n.length-2].id:null}let Pk=class extends Lk{constructor(a){const r={id:"/",name:"My files",open:!0,$level:1,parent:0,ext:"",type:"folder"};super([r]),this.parse(a,"/")}parse(a,r,l){!a||!a.length||(a.forEach(c=>this.parseId(c,l?r:void 0)),super.parse(a,r))}parseId(a,r){if(a.parent===0)return;const l=a.id,c=l.lastIndexOf("/");if(a.parent=r??(c===0?"/":l.slice(0,c)),a.name=l.slice(c+1),a.type=a.type||"file",a.type!=="folder"){const d=a.name.lastIndexOf("."),m=d!==-1?a.name.slice(d+1):"";a.ext=m!=="new"?m?.toLocaleLowerCase():""}}getParents(a){const r=[];let l=this.byId(a);if(!l)return r;for(;l.id!==0;)r.push(l),l=this.byId(l.parent);return r.reverse()}findFiles(a,r="/"){const l=[],c=a.toLocaleLowerCase();return this.eachChild(d=>{d.name.toLowerCase().indexOf(c)!==-1&&l.push(d)},r),l}add(a,r){const l=this.byId(a.parent||"/"),c=a.data?[...a.data]:null;a.data=null,super.add(a,r??l.data?l.data.length:0),c&&c.forEach(d=>this.add(d))}renameFiles(a,r,l){const c=this.byId(a),d=this.normalizeFile(c,r),m=[];return d.data?.forEach(p=>m.push(this.renameFiles(p.id,d.id,l))),m.length&&(d.data=m),l[a]=d.id,d}copyFiles(a,r,l){const c={};return a.forEach(d=>{const m=this.renameFiles(d,r,c);this.add(m),l&&this.remove(d),c[d]=m.id}),c}moveFiles(a,r){if(this.byId(a[0]).parent!==r)return this.copyFiles(a,r,!0)}serialize(a="/"){const r=[],l=this.byId(a);return l?(l.data?.forEach(c=>{const{id:d,date:m,type:p,size:g,lazy:v}=c,b={id:d,date:m,type:p??"file"};v&&(b.lazy=v),g&&(b.size=g),r.push(b);const y=this.serialize(d);y.length&&r.push(...y)}),r):null}normalizeFile(a,r){const l=a.name,c=l.lastIndexOf("."),d=c!==-1?l.slice(c+1):"",m=d?`.${d}`:"";let p=c!==-1?l.slice(0,c):l,g=r+(r==="/"?"":"/")+p;for(;this.byId(g+m);){const v=".new";g+=v,p+=v}return{...a,id:g+m,name:p+m,parent:r,ext:d.toLocaleLowerCase()}}},$k=class extends zk{in;_router;constructor(a){super({writable:a,async:!1});const r=[];for(let d=0;d<2;d++)r.push({in:["data",`panels.${d}.path`],out:[`panels.${d}._crumbs`],exec:m=>{const{data:p,panels:g}=this.getState(),v=[];v[d]={_crumbs:p.getParents(g[d].path)},this.setState({panels:v},m)}}),r.push({in:["data",`panels.${d}.path`,`panels.${d}._sorts`,"search"],out:[`panels.${d}._files`],exec:m=>{const{data:p,panels:g,search:v}=this.getState();let b;v?b=p.findFiles(v,g[d].path):b=p.byId(g[d].path)?.data||[];const{path:y,_sorts:w}=g[d];b=Jx(b,w[y]);const S=[];S[d]={_files:b},this.setState({panels:S},m)}}),r.push({in:["data",`panels.${d}.selected`,`panels.${d}._sorts`],out:[`panels.${d}._selected`],exec:m=>{const{data:p,panels:g}=this.getState(),v=[];g[d].selected.forEach(j=>{const N=p.byId(j);N&&v.push(N)});const{path:b,_sorts:y}=g[d],w=Jx(v,y[b]),S=[];S[d]={_selected:w},this.setState({panels:S},m)}});this._router=new Ik(super.setState.bind(this),r,{data:d=>new Pk(d)});const l=this.in=new Ok;l.on("select-file",({id:d,toggle:m,range:p,panel:g,type:v})=>{const{panels:b,activePanel:y}=this.getState();typeof g>"u"&&(g=y),d||(m=p=!1);let w=[...b[g].selected];if(m){const j=w.indexOf(d);j===-1?w.push(d):w.splice(j,1)}else if(p&&b[g]._lastSelected){const j=b[g]._files;let N=j.findIndex(E=>E.id==b[g]._lastSelected),M=j.findIndex(E=>E.id==d);M<N&&([N,M]=[M,N]);const k=j.slice(N,M+1).map(E=>E.id);w=[...new Set([...w,...k])]}else w=d?[d]:[];const S=[];S[g]={selected:w,_lastSelected:d,_selectNavigation:v==="navigation"},this.setState({panels:S})}),l.on("set-path",({id:d,panel:m,selected:p})=>{const{data:g,activePanel:v}=this.getState(),b=g.byId(d);if(b){const y=[];typeof m>"u"&&(m=v),y[m]={path:d},this.setState({panels:y}),l.exec("select-file",{panel:m}),p&&p.forEach(w=>l.exec("select-file",{id:w,panel:m,toggle:!0})),b.lazy&&l.exec("request-data",{id:d})}}),l.on("provide-data",({id:d,data:m})=>{const{mode:p,data:g}=this.getState(),v=g.byId(d);v&&(v.lazy||(v.data=[]),v.lazy=!1,g.parse(m,d,p==="search"),this.setState({data:g}))}),l.on("open-tree-folder",({id:d,mode:m})=>{const{data:p}=this.getState();p.update(d,{open:m}),this.setState({data:p})}),l.on("show-preview",({mode:d})=>{this.setState({preview:d})}),l.on("rename-file",d=>{const{id:m,name:p}=d,{data:g,panels:v}=this.getState(),b=g.byId(m);if(b.name!==p){b.name=p;const y=g.normalizeFile(b,b.parent);d.newId=y.id,y.data=null,g.add(y);let w={[m]:y.id};b.data?.forEach(j=>w={...g.moveFiles([j.id],y.id),...w});const S=v.map(j=>({selected:j.selected,_crumbs:j._crumbs,_lastSelected:j._lastSelected,_sorts:j._sorts}));g.remove(m),this._updatePanels(S,w),this.setState({data:g,panels:S})}}),l.on("create-file",d=>{const{file:m,parent:p}=d,{data:g}=this.getState(),v=g.normalizeFile(m,p);v.type=m.type||"file",d.newId=v.id,g.add(v),this.setState({data:g}),l.exec("select-file",{id:v.id})}),l.on("delete-files",({ids:d})=>{const{data:m,panels:p}=this.getState(),g=p.map(v=>({selected:v.selected,_crumbs:v._crumbs,_lastSelected:v._lastSelected,_sorts:v._sorts}));d.forEach(v=>m.remove(v)),this._updatePanels(g,{}),this.setState({data:m,panels:g})}),l.on("copy-files",d=>{const{ids:m,target:p}=d;if(this._isPlacedIntoSelf(m,p)){console.error("You cannot copy a folder into itself"),d.skipProvider=!0;return}const{data:g,panels:v,activePanel:b}=this.getState(),y=g.copyFiles(m,p);d.newIds=m.map(w=>y[w]),this.setState({data:g}),v[b].path==p&&(l.exec("select-file",{}),m.forEach(w=>{l.exec("select-file",{id:y[w],toggle:!0})}))}),l.on("move-files",d=>{const{ids:m,target:p}=d;if(this._isPlacedIntoSelf(m,p)){console.error("You cannot move a folder into itself"),d.skipProvider=!0;return}const{data:g,panels:v,activePanel:b}=this.getState(),y=g.moveFiles(m,p);if(y){d.newIds=m.map(S=>y[S]);const w=v.map(S=>({selected:S.selected,_crumbs:S._crumbs,_lastSelected:S._lastSelected,_sorts:S._sorts}));this._updatePanels(w,y,!0),this.setState({data:g,panels:w}),v[b].path==p&&(l.exec("select-file",{}),m.forEach(S=>{l.exec("select-file",{id:y[S],toggle:!0})}))}});let c=null;l.on("filter-files",({text:d})=>{if(!d){c&&this.setState({...c});return}l.exec("select-file",{});const{panels:m,mode:p}=this.getState();c||(c={panels:m,mode:p,search:""}),this.setState({mode:"search",search:d})}),l.on("set-mode",({mode:d})=>{const{activePanel:m}=this.getState(),p=[];p[m]={_selectNavigation:!1};const g={mode:d,search:"",panels:p};c=null,this.setState(g)}),l.on("set-active-panel",({panel:d})=>{this.setState({activePanel:d})}),l.on("sort-files",({key:d,order:m,panel:p,path:g})=>{const{activePanel:v,panels:b}=this.getState();p=p??v,g=g??b[p].path;const y=[];y[p]={_sorts:{...b[p]._sorts,[g]:{key:d,order:m}}},this.setState({panels:y})}),this.initOnce()}initOnce(){const a=[];for(let l=0;l<2;l++)a[l]=Zx({_crumbs:[],_files:[],_selected:[],_sorts:{},path:"/",selected:[],...a[l]});const r={panels:Zx(a),data:[],search:""};this._router.init(r)}init(a){const r={...a};this._router.init(r)}setState(a,r){return this._router.setState(a,r)}getFile(a){const{data:r}=this.getState();return r.byId(a)||null}serialize(a){const{data:r}=this.getState();return r.serialize(a)}_updatePanels(a,r,l){const{data:c}=this.getState();a.forEach(d=>{const m=[];d.selected.forEach(v=>{c.byId(v)?m.push(v):!l&&r[v]&&m.push(r[v])}),d.selected=m,c.byId(d._lastSelected)||(d._lastSelected=l?null:r[d._lastSelected]||null);const p={};Object.keys(d._sorts).forEach(v=>{c.byId(v)?p[v]=d._sorts[v]:r[v]&&!l&&(p[r[v]]=d._sorts[v])}),d._sorts=p;const g=d._crumbs[d._crumbs.length-1];g?.id!=="/"&&(r[g.id]?d.path=r[g.id]:c.byId(g.id)||(d.path="/"))})}_isPlacedIntoSelf(a,r){return a.some(l=>l===r||this.getState().data.getParents(r).some(c=>c.id===l))}};function Uk(n){switch(n){case"body":return[{icon:"wxi-content-paste",text:"Paste",hotkey:"Ctrl+V",id:"paste"}];case"add":return[{icon:"mdi mdi-folder-plus-outline",text:"Add new file",id:"add-file"},{icon:"mdi mdi-file-plus-outline",text:"Add new folder",id:"add-folder"},{icon:"mdi mdi-file-upload-outline",text:"Upload file",id:"upload",comp:"upload"}];case"multiselect":return[{icon:"wxi-content-copy",text:"Copy",hotkey:"Ctrl+C",id:"copy"},{icon:"wxi-content-cut",text:"Cut",hotkey:"Ctrl+X",id:"move"},{comp:"separator"},{icon:"wxi-close",text:"Delete",hotkey:"Delete",id:"delete"}];default:return[n==="folder"?null:{icon:"wxi-download",text:"Download",hotkey:"Ctrl+D",id:"download"},{icon:"wxi-content-copy",text:"Copy",hotkey:"Ctrl+C",id:"copy"},{icon:"wxi-content-cut",text:"Cut",hotkey:"Ctrl+X",id:"move"},{icon:"wxi-content-paste",text:"Paste",hotkey:"Ctrl+V",id:"paste"},{comp:"separator"},{icon:"wxi-edit",text:"Rename",hotkey:"Ctrl+R",id:"rename"},{icon:"wxi-close",text:"Delete",hotkey:"Delete",id:"delete"}].filter(a=>a!==null)}}function qk(n,a="data-id"){let r=n;for(!r.tagName&&n.target&&(r=n.target);r;){if(r.getAttribute&&r.getAttribute(a))return r;r=r.parentNode}return null}function Gk(n,a="data-id"){const r=qk(n,a);return r?r.getAttribute(a):null}new Date().valueOf();function Vk(n,a){const{api:r}=a;function l(d,m){const p=a.getPanel(),g=p.selected,v=m.ctrlKey||m.metaKey,b=m.shiftKey;let y;const w=g?.[0]?r.getFile(g[0]):null;g?.length?g.length>1?y=a.menuOptions("multiselect"):y=a.menuOptions(w.type,w):y=a.menuOptions("body");const S=`${v?"ctrl+":""}${b?"shift+":""}${d}`,j=y?y.find(M=>M.hotkey?.toLowerCase()===S):!1,N=a.performAction;if(j)switch(S){case"ctrl+c":N("copy");break;case"ctrl+x":N("move");break;case"ctrl+v":N("paste",w);break;case"delete":N("delete");break;case"ctrl+r":m.preventDefault(),N("rename",w);break;case"ctrl+d":m.preventDefault(),N("download",w);break;default:j.handler?.({context:w})}switch(d){case"enter":{if(v||b)break;const{_crumbs:M,_selectNavigation:k}=p;if(k){const E=Fk(M);if(E){const R=vp(E,M);r.exec("set-path",{id:E,selected:[R]})}}else if(g.length===1){const E=r.getFile(g[0]);E&&r.exec(E.type==="folder"?"set-path":"open-file",{id:E.id})}break}case"arrowup":case"arrowleft":{const{_files:M,_selected:k,path:E,_selectNavigation:R}=p;let U;if(k.length){const H=k.at(0).id,W=M.findIndex(_=>_.id===H);if(W!==-1){const _=W-1;M[_]?U=M[_].id:E!=="/"&&!(v||b)&&r.exec("select-file",{type:"navigation"})}}else{if(R)break;if(E!=="/"){r.exec("select-file",{type:"navigation"});break}U=M.at(0)?.id}U&&r.exec("select-file",{id:U,toggle:v,range:b});break}case"arrowdown":case"arrowright":{const{_files:M,_selected:k,path:E,_selectNavigation:R}=p;let U;if(k.length){const H=k.at(-1).id,W=M.findIndex(_=>_.id===H);if(W!==-1){const _=W+1;M[_]&&(U=M[_].id)}}else{if(E!=="/"&&!R){r.exec("select-file",{type:"navigation"});break}U=M.at(0)?.id}U&&r.exec("select-file",{id:U,toggle:v,range:b});break}}}function c(d){const m=d.code.replace("Key","").toLowerCase();l(m,d),m=="tab"&&setTimeout(()=>{const p=document.activeElement;p.className.indexOf("table")!=-1&&r.exec("set-active-panel",{panel:+Gk(p,"data-panel")})})}return n.addEventListener("keydown",c),{destroy:()=>{n.removeEventListener("keydown",c)}}}function Wk(n,a="data-id"){let r=n;for(!r.tagName&&n.target&&(r=n.target);r;){if(r.getAttribute&&r.getAttribute(a))return r;r=r.parentNode}return null}function Yk(n,a="data-id"){const r=n.getAttribute(a);return r?Kk(r):null}function Kk(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function Qk(){return{detect:()=>!0,addEvent:function(n,a,r){return n.addEventListener(a,r),()=>n.removeEventListener(a,r)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var Xk=Qk();new Date().valueOf();function Hb(n){const[a,r]=u.useState(n),l=u.useRef(n);return u.useEffect(()=>{if(l.current!==n){if(Array.isArray(l.current)&&Array.isArray(n)&&l.current.length===0&&n.length===0)return;l.current=n,r(n)}},[n]),[a,r]}function Zk(n,a,r){const[l,c]=u.useState(()=>a);return n||console.warn(`Writable ${r} is not defined`),u.useEffect(()=>n?n.subscribe(m=>{c(()=>m)}):void 0,[n]),l}function st(n,a){const r=n.getState(),l=n.getReactiveState();return Zk(l[a],r[a],a)}function Jk(n,a){const r=u.useRef(a);r.current=a;const[l,c]=u.useState(1);return u.useEffect(()=>n.subscribe(m=>{r.current=m,c(p=>p+1)}),[n]),[r.current,l]}function ys(n,a){const r=n.getState(),l=n.getReactiveState();return Jk(l[a],r[a])}function Bb(n){const a={};return n.split(";").forEach(r=>{const[l,c]=r.split(":");if(c){let d=l.trim();d.indexOf("-")&&(d=d.replace(/-([a-z])/g,(m,p)=>p.toUpperCase())),a[d]=c.trim()}}),a}function Fb(n){let a=n,r=[];return{subscribe:p=>{r.push(p),p(a)},unsubscribe:p=>{r=r.filter(g=>g!==p)},set:p=>{a=p,r.forEach(g=>g(a))},update:p=>{a=p(a),r.forEach(g=>g(a))}}}function ty(n,a,r){function l(c){const d=Wk(c);if(!d)return;const m=Yk(d);if(typeof a=="function")return a(m,c);let p,g=c.target;for(;g!=d;){if(p=g.dataset?g.dataset.action:null,p&&a[p]){a[p](m,c);return}g=g.parentNode}a[r]&&a[r](m,c)}return Xk.addEvent(n,r,l)}function e1(n,a){const r=[ty(n,a,"click")];return a.dblclick&&r.push(ty(n,a.dblclick,"dblclick")),()=>{r.forEach(l=>l())}}function Pb(n,a){return n.map((r,l)=>{const c=a(r,l);return r.data&&r.data.length&&(c.data=Pb(r.data,a)),c}).filter(Boolean)}function $b(n,a){const r=[];return n.forEach(l=>{if(l.data){const c=$b(l.data,a);c.length&&r.push({...l,data:c})}else a(l)&&r.push(l)}),r}function t1(n){return Pb(n,(a,r)=>{const l={...a,id:a.id||cp()};return l.type&&(l.comp=l.type),l.comp==="separator"&&n[r-1]?.comp==="separator"?null:l})}const Ub={};function n1(n){return Ub[n]||n}function a1(n,a){Ub[n]=a}function s1({onClick:n,onShow:a,option:r}){const l=u.useRef(null),c=u.useCallback(()=>{a(r.data?r.id:!1,l.current)},[a,r]),d=u.useCallback(p=>{if(r.data){p.stopPropagation(),a(r.id,l.current);return}n(p)},[n,a,r]),m=u.useMemo(()=>r&&r.comp?n1(r.comp):null,[r]);return s.jsxs("div",{ref:l,className:`wx-cDCz9rZQ wx-option ${r.css||""} ${r.disabled?"wx-disabled":""}`,"data-id":Bn(r.id),onMouseEnter:c,onClick:d,children:[r.icon?s.jsx("i",{className:`wx-cDCz9rZQ wx-icon ${r.icon}`}):null,r.comp?m?s.jsx(m,{item:r,option:r}):null:s.jsxs("span",{className:"wx-cDCz9rZQ wx-value",children:[" ",r.text," "]}),r.subtext?s.jsx("span",{className:"wx-cDCz9rZQ wx-subtext",children:r.subtext}):null,r.data?s.jsx("i",{className:"wx-cDCz9rZQ wx-sub-icon wxi-angle-right"}):null]})}function xp({options:n,left:a=0,top:r=0,at:l="bottom",parent:c=null,mount:d=null,context:m=null,css:p="",onClick:g,onCancel:v}){const[b,y]=u.useState(-1e4),[w,S]=u.useState(-1e4),[j,N]=u.useState(20),[M,k]=u.useState(),E=u.useRef(null),[R,U]=u.useState(!1),[H,W]=u.useState(null),_=u.useCallback(()=>{const ce=kb(E.current,c,l,a,r);ce&&(y(ce.x),S(ce.y),k(ce.width));let V=ce?.z??20;const O=c?Vj(c):[];let Y=0;for(const X of O){const P=parseInt(getComputedStyle(X).zIndex,10);P>Y&&(Y=P)}Y>=V&&(V=Y+1),N(V)},[c,l,a,r]);u.useEffect(()=>{d&&d(_)},[]);const L=u.useCallback(()=>{U(!1)},[]),le=u.useCallback((ce,V)=>{U(ce),W(V)},[]),q=u.useMemo(()=>t1(n),[n]);u.useEffect(()=>{_()},[c,_]);const te=u.useRef(g),K=u.useRef(v),ne=u.useRef(c);return u.useEffect(()=>{te.current=g},[g]),u.useEffect(()=>{K.current=v},[v]),u.useEffect(()=>{ne.current=c},[c]),u.useEffect(()=>{if(!E.current)return;function ce(V){K.current?K.current(V):te.current&&te.current({action:null,option:null})}return mi(E.current,{callback:ce,modal:!0,parent:()=>ne.current}).destroy},[]),s.jsx("div",{ref:E,"data-wx-menu":"true",className:`wx-XMmAGqVx wx-menu ${p}`,style:{position:"absolute",top:w+"px",left:b+"px",width:M,zIndex:j},onMouseLeave:L,children:q.map(ce=>s.jsxs(u.Fragment,{children:[ce.comp==="separator"?s.jsx("div",{className:"wx-XMmAGqVx wx-separator"}):s.jsx(s1,{option:ce,onShow:le,onClick:V=>{if(!ce.data&&!V.defaultPrevented){const O={context:m,action:ce,option:ce,event:V};ce.handler&&ce.handler(O),g&&g(O),V.stopPropagation()}}}),ce.data&&R===ce.id?s.jsx(xp,{css:p,options:ce.data,at:"right-overlap",parent:H,context:m,onClick:g,onCancel:v}):null]},ce.id))})}const qb=u.forwardRef(function(n,a){const{options:r,at:l="bottom",resolver:c=null,dataKey:d="contextId",filter:m=null,css:p="",children:g,onClick:v}=n,[b,y]=u.useState(null),[w,S]=u.useState(null),[j,N]=u.useState(0),[M,k]=u.useState(0),E=u.useRef(null),R=u.useMemo(()=>`data-${d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,[d]),U=u.useMemo(()=>b!==null&&m?$b(r,L=>m(L,b)):r,[b,m,r]);function H(L){S(null),v&&v(L)}function W(L){if(E.current===L){E.current=null;return}S(null),v&&v({action:null,option:null})}const _=u.useCallback((L,le)=>{if(!L){S(null);return}if(L.defaultPrevented)return;const q=L.target;if(q&&q.dataset&&q.dataset.menuIgnore)return;if(w&&w===q){S(null),L.preventDefault();return}N(L.clientX+1),k(L.clientY+1);let te=typeof le<"u"?le:iu(q,R);c&&(te=c(te,L),!te)||(y(te),S(q),E.current=L.nativeEvent||L,L.preventDefault())},[w,R,c]);return u.useImperativeHandle(a,()=>({show:_}),[_]),s.jsxs(s.Fragment,{children:[g?s.jsx("span",{onClick:_,"data-menu-ignore":"true",children:typeof g=="function"?g():g}):null,w?s.jsx(dp,{children:s.jsx(xp,{css:p,at:l,top:M,left:j,parent:w,context:b,onClick:H,onCancel:W,options:U},w)}):null]})}),i1=u.forwardRef(function(n,a){const{options:r,at:l="bottom",css:c="",children:d,onClick:m}=n,[p,g]=u.useState(null),v=u.useRef(null);function b(j){g(null),m&&m(j)}function y(j){if(v.current===j){v.current=null;return}g(null),m&&m({action:null,option:null})}const w=u.useCallback(j=>{g(j.target),v.current=j.nativeEvent||j,j.preventDefault()},[]);u.useImperativeHandle(a,()=>({show:w}),[w]);function S(j){let N=j.target;for(;!N.dataset.menuIgnore;)g(N),N=N.parentNode}return s.jsxs(s.Fragment,{children:[s.jsx("span",{onClick:S,"data-menu-ignore":"true",children:d}),p?s.jsx(dp,{children:s.jsx(xp,{css:c,at:l,parent:p,options:r,onClick:b,onCancel:y})}):null]})}),r1=u.forwardRef(function(n,a){const{options:r,at:l="bottom",resolver:c=null,dataKey:d="contextId",filter:m=null,css:p="",children:g,onClick:v}=n,b=u.useRef(null),y=u.useCallback((w,S)=>{b.current.show(w,S)},[]);return u.useImperativeHandle(a,()=>({show:y}),[y]),s.jsxs(s.Fragment,{children:[g?s.jsx("span",{onContextMenu:y,"data-menu-ignore":"true",children:g}):null,s.jsx(qb,{css:p,at:l,options:r,resolver:c,dataKey:d,filter:m,ref:b,onClick:v})]})}),l1={uploader:{B:"B",KB:"KB",MB:"MB",GB:"GB",TB:"TB",PB:"PB",EB:"EB","Drop files here or":"Drop files here or","select files":"select files"}};let o1=class{constructor(a,r,l,c,d){this.setFiles=a,this.setReady=r,this.setSignal=l,this.setDrag=c,d&&d.length&&this.setFiles(d)}open(a){this.setSignal(["click",a||{}])}getState(){let a="server";const r=this.files;for(let l=0;l<r.length;l++){if(r[l].status==="client")return"client";r[l].status==="error"&&(a="error")}return a}droparea(a,r){r=r||{};const l=()=>{r.dragEnter&&r.dragEnter(),this.setDrag(!0)},c=()=>{r.dragLeave&&r.dragLeave(),this.setDrag(!1)},d=p=>{p.preventDefault()},m=p=>{p.preventDefault(),this.setDrag(!1),this.setSignal(["drop",r,p]),r.dragLeave&&r.dragLeave(),r.drop&&r.drop()};return a.addEventListener("dragenter",l),a.addEventListener("dragleave",c),a.addEventListener("dragover",d,!0),a.addEventListener("drop",m,!0),()=>{a.removeEventListener("dragenter",l),a.removeEventListener("dragleave",c),a.removeEventListener("dragover",d,!0),a.removeEventListener("drop",m,!0)}}updateFile(a,r){const l=this.files.findIndex(d=>d.id===a);if(l===-1)return;const c=[...this.files];return c[l]={...c[l],...r},this.files=c,this.setFiles(this.files),this.files[l]}deleteFile(a){this.files=this.files.filter(r=>r.id!==a),this.setFiles(this.files)}addFile(a,r){r?this.files=[...this.files,a]:this.files=[a],this.setFiles(this.files)}deleteAll(){this.files=[],this.setFiles(this.files)}};function Gb(n){const[a,r]=u.useState([]),[l,c]=u.useState(Promise.resolve(null)),[d,m]=u.useState(null),[p,g]=u.useState(!1),v=u.useRef();return v.current||(v.current=new o1(r,c,m,g,n)),v.current.files=a,v.current.ready=l,v.current.signal=d,v.current.drag=p,v.current}function c1(n,a){{if(n){const r=n.getGroup(a);if(r)return r}return lu(l1).getGroup(a)}}const u1=()=>Math.random().toString(36).substr(2,9),d1=({data:n,accept:a="",multiple:r=!0,folder:l=!1,uploadURL:c="",apiOnly:d=!1,disabled:m=!1,children:p,onChange:g,onUpload:v})=>{const b=u.useRef(null),y=u.useRef(null),[w,S]=u.useState({}),j=Gb(),N=n||j,M=u.useContext(Pn.i18n),k=c1(M,"uploader");u.useEffect(()=>{b.current&&l&&(b.current.webkitdirectory=!0)},[l]),u.useEffect(()=>{if(!d&&y.current&&!m)return N.droparea(y.current)},[d,m,y]);const E=q=>{const te=new FormData;return te.append("upload",q.file),fetch(c,{method:"POST",body:te}).then(K=>K.json()).then(K=>({id:q.id,...K}),()=>({id:q.id,status:"error"})).catch(K=>(console.log(K),{id:q.id,status:"error"}))},R=(q,te)=>{const K=N.updateFile(q,te),ne={...K,status:N.getState()};K&&K.uploaded&&K.uploaded(ne),v&&v(ne),K.temp&&N.deleteFile(K.id)},U=q=>{if(!q)return;const te=typeof c=="function"?c(q):E(q);N.setReady(te.then(K=>{K.status=K.status||"server",R(q.id,K)}).catch(K=>{R(q.id,{status:"error",error:K})}))},H=(q,te)=>{const K={...te||w,id:u1(),status:"client",name:q.name,file:q};K.selected&&K.selected(K),g&&g(K),N.addFile(K,r),U(K),b.current&&(b.current.value="")},W=(q,te,K)=>{q.isFile?q.file(ne=>{H(ne,K)}):q.isDirectory&&q.createReader().readEntries(ne=>{ne.forEach(ce=>{W(ce,te+ce.name+"/",K)})})},_=q=>{Array.from(q.target.files).forEach(te=>H(te))},L=(q,te)=>{Array.from(q.dataTransfer.items).forEach(K=>{const ne=K.webkitGetAsEntry();ne&&W(ne,"",te)})},le=()=>{b.current&&b.current.click()};return u.useEffect(()=>{if(N.signal){const[q,te,K]=N.signal;S(te),q==="click"?le():q==="drop"&&L(K,te),N.setSignal(null)}},[N.signal]),d?s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:b,onChange:_,accept:a,multiple:r,disabled:m}),p]}):s.jsxs("div",{className:`wx-at1A8tb8 wx-label ${N.drag?"wx-active":""} ${m?"wx-disabled":""}`,ref:y,children:[s.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:b,onChange:_,accept:a,multiple:r,disabled:m}),p||s.jsx("div",{className:"wx-at1A8tb8 wx-dropzone",children:s.jsxs("span",{children:[k("Drop files here or")," ",s.jsx("span",{className:"wx-at1A8tb8 wx-action",onClick:le,children:k("select files")})]})})]})};new Date().valueOf();function f1(n,a){if(Object.keys(n).length!==Object.keys(a).length)return!1;for(const r in a){const l=n[r],c=a[r];if(!Sf(l,c))return!1}return!0}function Sf(n,a){if(typeof n=="number"||typeof n=="string"||typeof n=="boolean"||n===null)return n===a;if(typeof n!=typeof a||(n===null||a===null)&&n!==a||n instanceof Date&&a instanceof Date&&n.getTime()!==a.getTime())return!1;if(typeof n=="object")if(Array.isArray(n)&&Array.isArray(a)){if(n.length!==a.length)return!1;for(let r=n.length-1;r>=0;r--)if(!Sf(n[r],a[r]))return!1;return!0}else return f1(n,a);return n===a}function Bh(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(n instanceof Array)return n.map(Bh);const a={};for(const r in n)a[r]=Bh(n[r]);return a}var Vb=2,m1=class{constructor(n){n&&(this._writable=n.writable,this._async=n.async),this._values={},this._state={}}setState(n,a=0){const r={};return this._wrapProperties(n,this._state,this._values,"",r,a),r}getState(){return this._values}getReactive(){return this._state}_wrapProperties(n,a,r,l,c,d){for(const m in n){const p=a[m],g=r[m],v=n[m];if(p&&(g===v&&typeof v!="object"||v instanceof Date&&g instanceof Date&&g.getTime()===v.getTime()))continue;const b=l+(l?".":"")+m;p?(p.__parse(v,b,c,d)&&(r[m]=v),d&Vb?c[b]=p.__trigger:p.__trigger()):(v&&v.__reactive?a[m]=this._wrapNested(v,v,b,c):a[m]=this._wrapWritable(v),r[m]=v),c[b]=c[b]||null}}_wrapNested(n,a,r,l){const c=this._wrapWritable(n);return this._wrapProperties(n,c,a,r,l,0),c.__parse=(d,m,p,g)=>(this._wrapProperties(d,c,a,m,p,g),!1),c}_wrapWritable(n){const a=[],r=function(){for(let l=0;l<a.length;l++)a[l](n)};return{subscribe:l=>(a.push(l),this._async?setTimeout(l,1,n):l(n),()=>{const c=a.indexOf(l);c>=0&&a.splice(c,1)}),__trigger:()=>{a.length&&(this._async?setTimeout(r,1):r())},__parse:function(l){return n=l,!0}}}},h1=class{constructor(n,a,r,l){typeof n=="function"?this._setter=n:this._setter=n.setState.bind(n),this._routes=a,this._parsers=r,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(c=>{c.in.forEach(d=>{const m=this._triggers.get(d)||[];m.push(c),this._triggers.set(d,m)}),c.out.forEach(d=>{const m=this._sources.get(d)||{};c.in.forEach(p=>m[p]=!0),this._sources.set(d,m)})}),this._routes.forEach(c=>{c.length=Math.max(...c.in.map(d=>Wb(d,this._sources,1)))}),this._bus=l}init(n){const a={};for(const r in n)if(this._prev[r]!==n[r]){const l=this._parsers[r];a[r]=l?l(n[r]):n[r]}this._prev=this._prev?{...this._prev,...n}:{...n},this.setState(a),this._bus&&this._bus.exec("init-state",a)}setStateAsync(n){const a=this._setter(n,Vb);return this._async?Object.assign(this._async.signals,a):this._async={signals:a,timer:setTimeout(this._applyState.bind(this),1)},a}_applyState(){const n=this._async;if(n){this._async=null,this._triggerUpdates(n.signals,[]);for(const a in n.signals){const r=n.signals[a];r&&r()}}}setState(n,a=[]){const r=this._setter(n);return this._triggerUpdates(r,a),r}_triggerUpdates(n,a){const r=Object.keys(n),l=!a.length;a=a||[];for(let c=0;c<r.length;c++){const d=r[c],m=this._triggers.get(d);m&&m.forEach(p=>{a.indexOf(p)==-1&&a.push(p)})}l&&this._execNext(a)}_execNext(n){for(;n.length;){n.sort((r,l)=>r.length<l.length?1:-1);const a=n[n.length-1];n.splice(n.length-1),a.exec(n)}}};function Wb(n,a,r){const l=a.get(n);if(!l)return r;const c=Object.keys(l).map(d=>Wb(d,a,r+1));return Math.max(...c)}var p1=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(n,a,r){let l=this._handlers[n];l?r&&r.intercept?l.unshift(a):l.push(a):l=this._handlers[n]=[a],r&&r.tag&&this._tag.set(a,r.tag)}intercept(n,a,r){this.on(n,a,{...r,intercept:!0})}detach(n){for(const a in this._handlers){const r=this._handlers[a];for(let l=r.length-1;l>=0;l--)this._tag.get(r[l])===n&&r.splice(l,1)}}async exec(n,a){const r=this._handlers[n];if(r)for(let l=0;l<r.length;l++){const c=r[l](a);if(c===!1||c&&c.then&&await c===!1)return}return this._nextHandler&&await this._nextHandler.exec(n,a),a}setNext(n){return this._nextHandler=n}};function g1(n){return a=>a[n]}function v1(n){return(a,r)=>a[n]=r}function Vr(n,a){return(a.getter||g1(a.id))(n)}function lh(n,a,r){return(a.setter||v1(a.id))(n,r)}function x1(n,a){const r=document.createElement("a");r.href=URL.createObjectURL(n),r.download=a,document.body.appendChild(r),r.click(),document.body.removeChild(r)}function Gr(n,a){let r=Vr(n,a)??"";return a.template?r=a.template(r,n,a):a.optionsMap&&(Array.isArray(r)?r=r.map(l=>a.optionsMap.get(l)).join(", "):r=a.optionsMap.get(r)),typeof r>"u"?"":r+""}function y1(n,a){const r=/\n|"|;|,/;let l="";const c=a.rows||`
|
|
13
13
|
`,d=a.cols||" ",m=n._columns,p=n.flatData;a.header!==!1&&m[0].header&&(l=ny("header",m,l,d,c));for(let g=0;g<p.length;g++){const v=[];for(let b=0;b<m.length;b++){let y=Gr(p[g],m[b]);r.test(y)&&(y='"'+y.replace(/"/g,'""')+'"'),v.push(y)}l+=(l?c:"")+v.join(d)}return a.footer!==!1&&m[0].footer&&(l=ny("footer",m,l,d,c)),l}function ny(n,a,r,l,c){const d=/\n|"|;|,/;for(let m=0;m<a[0][n].length;m++){const p=[];for(let g=0;g<a.length;g++){let v=(a[g][n][m].text||"")+"";d.test(v)&&(v='"'+v.replace(/"/g,'""')+'"'),p.push(v)}r+=(r?c:"")+p.join(l)}return r}const b1="portrait",w1=100,S1="a4",C1={a3:{width:11.7,height:16.5},a4:{width:8.27,height:11.7},letter:{width:8.5,height:11}};function j1(n,a){const r=[];let l=[],c=0;const d=n.filter(p=>!p.hidden),m=k1(a);return d.forEach((p,g)=>{c+p.width<=m?(c+=p.width,l.push(p)):(l.length&&r.push(l),l=[p],c=p.width),g===d.length-1&&l.length&&r.push(l)}),r}function ay(n,a,r){const l=[];return n.forEach((c,d)=>{const m=c[a];for(let p=0;p<r.length;p++){l[p]||(l[p]=[]);const g={...m[p]};if(l[p][d]!==null){if(!d&&!g.rowspan&&!g.colspan){let v=1,b=n[d+v][a][p],y=g.width;for(;!b.rowspan&&!b.colspan;)v++,b=n[d+v][a][p],y+=b.width;g.colspan=v,g.width=y,g.height=r[p]}if(l[p].push(g),!g.collapsed&&g.colspan>1){let v=g.colspan-1;if(g.colspan+d>n.length){const b=g.colspan-(g.colspan+d-n.length);g.colspan=b,g.width=n.slice(d,d+v+1).reduce((y,w)=>y+w.width,0),b>1&&(v=b-1)}for(let b=0;b<v;b++)l[p].push(null)}if(g.rowspan>1){const v=g.rowspan;for(let b=1;b<v;b++)l[p+b]||(l[p+b]=[]),l[p+b].push(null)}}}if(c.collapsed)for(let p=0;p<l.length;p++){const g=l[p],v=g[d];if(v&&v.collapsed){if(g[d]=null,!p)break}else{const b=v||g.findLast(y=>y?.colspan>=1);b&&(b.colspan=b.colspan-1,b.width=b.width-c.width)}}}),l.map(c=>c.filter(d=>d&&d.colspan!==0))}function k1(n){const{mode:a,ppi:r,paper:l}=n,{width:c,height:d}=C1[l];return A1(a==="portrait"?c:d,r)}function A1(n,a){return n*a}function N1(n={}){const{mode:a,ppi:r,paper:l}=n;return{mode:a||b1,ppi:r||w1,paper:l||S1}}function Yb(n,a){return n.flexgrow?`min-width:${a}px;width:auto`:`width:${n.width}px; max-width:${n.width}px; height:${n.height}px`}function M1(n,a,r){let l=n[r.id];if(r.filter.type==="richselect"&&l){const c=r.filter.config?.options||a.find(({id:d})=>d==r.id).options;c&&(l=c.find(({id:d})=>d==l).label)}return l??""}const sy=["resize-column","hide-column","update-cell"],T1=["delete-row","update-row","update-cell"],E1=["move-item"],R1=["resize-column","move-item"];class D1{undo=[];redo=[];progress={};in;getState;setState;_previousValues={};constructor(a,r,l){this.in=a,this.getState=r,this.setState=l,this.setHandlers(),this.resetStateHistory()}getHandlers(){return{"add-row":{handler:a=>({action:"delete-row",data:{id:a.id},source:{action:"add-row",data:a}})},"delete-row":{handler:a=>{const{id:r}=a,{data:l}=this.getPrev(),c=l.findIndex(d=>d.id===r);return{action:"add-row",data:{id:r,row:l[c],before:c<l.length-1?l[c+1].id:void 0},source:{action:"delete-row",data:a}}}},"update-cell":{handler:a=>{const{id:r,column:l}=a,c=this.getRow(r),d=this.getColumn(l),m=Vr(c,d);return Sf(m,a.value)?null:{action:"update-cell",data:{id:r,column:l,value:m},source:{action:"update-cell",data:a}}}},"update-row":{handler:a=>{const{id:r,row:l}=a,c=this.getRow(r);for(const d in l)Object.keys(c).includes(d)||(c[d]=void 0);return{action:"update-row",data:{id:r,row:c},source:{action:"update-row",data:a}}}},"copy-row":{handler:a=>{const{id:r}=a,{data:l}=this.getState(),c=l.findIndex(m=>m.id===r),d=l[c];return{action:"delete-row",data:{id:r},source:{action:"add-row",data:{id:r,row:d,before:c<l.length-1?l[c+1].id:void 0}}}}},"resize-column":{handler:a=>{const{id:r,width:l}=a,c=this.getColumn(r),{_sizes:d}=this.getState();return{action:"resize-column",data:{id:r,width:c.width??d.columnWidth},source:{action:"resize-column",data:{id:r,width:l}}}}},"hide-column":{handler:a=>{const{id:r}=a,l=this.getColumn(r);return{action:"hide-column",data:{id:r,mode:l.hidden},source:{action:"hide-column",data:a}}}},"collapse-column":{handler:a=>{const{id:r,row:l,mode:c}=a;return{action:"collapse-column",data:{id:r,row:l,mode:typeof c=="boolean"?!c:c},source:{action:"collapse-column",data:a}}}},"move-item":{handler:a=>{const{id:r,target:l,mode:c}=a,{flatData:d}=this.getPrev(),m=d.findIndex(p=>p.id===r);return{action:"move-item",data:{id:r,target:d[m+(m?-1:1)].id,mode:m?"after":"before"},source:{action:"move-item",data:{id:r,target:l,mode:c}}}}},"open-row":{handler:a=>{const{id:r,nested:l}=a;return{action:"close-row",data:{id:r,nested:l},source:{action:"open-row",data:a}}}},"close-row":{handler:a=>{const{id:r,nested:l}=a;return{action:"open-row",data:{id:r,nested:l},source:{action:"close-row",data:a}}}}}}resetHistory(){this.undo=[],this.redo=[],this.progress={},this.resetStateHistory()}getPrev(){return this._previousValues}setHandlers(){const a=this.getHandlers();for(const r in a)this.in.intercept(r,l=>{if(!(l.eventSource==="undo"||l.eventSource==="redo"||l.skipUndo)){if(R1.includes(r)){(l.inProgress&&!this.progress[r]||typeof l.inProgress!="boolean")&&(E1.includes(r)&&this.setPrev("flatData"),sy.includes(r)&&this.setPrev("columns")),this.progress[r]=l.inProgress;return}T1.includes(r)&&this.setPrev("data"),sy.includes(r)&&this.setPrev("columns")}}),this.in.on(r,l=>{if(l.eventSource==="undo"||l.eventSource==="redo"||l.skipUndo||l.inProgress)return;const c=a[r].handler(l);c&&this.addToHistory(c)})}setPrev(a){this._previousValues[a]=Bh(this.getState()[a])}addToHistory(a){this.undo.push(a),this.redo=[],this.setStateHistory()}handleUndo(){if(!this.undo.length)return;const a=this.undo.pop();this.redo.push({...a.source,source:a}),this.in.exec(a.action,{...a.data,eventSource:"undo"}),this.setStateHistory()}handleRedo(){if(!this.redo.length)return;const a=this.redo.pop();this.undo.push({...a.source,source:a}),this.in.exec(a.action,{...a.data,eventSource:"redo"}),this.setStateHistory()}resetStateHistory(){this.setState({history:{undo:0,redo:0}})}setStateHistory(){this.setState({history:{undo:this.undo.length,redo:this.redo.length}})}getRow(a){const{data:r}=this.getPrev();return this.getState().tree?this.getTreeRow(r,a):r.find(l=>l.id===a)}getTreeRow(a,r){for(let l=0;l<a.length;l++){if(a[l].id===r)return a[l];if(a[l].data){const c=this.getTreeRow(a[l].data,r);if(c)return c}}return null}getColumn(a){const{columns:r}=this.getPrev();return r.find(l=>l.id===a)}}function Kb(n,a){return typeof n>"u"||n===null?-1:typeof a>"u"||a===null?1:n===a?0:n>a?1:-1}function L1(n,a){return-Kb(n,a)}function _1(n,a){if(typeof a.sort=="function")return function(l,c){const d=a.sort(l,c);return n==="asc"?d:-d};const r=n==="asc"?Kb:L1;return function(l,c){return r(Vr(l,a),Vr(c,a))}}function z1(n,a){if(!n||!n.length)return;const r=n.map(l=>{const c=a.find(d=>d.id==l.key);return _1(l.order,c)});return n.length===1?r[0]:function(l,c){for(let d=0;d<r.length;d++){const m=r[d](l,c);if(m!==0)return m}return 0}}const Bd=28,I1=20;function O1(){if(typeof document>"u")return"willow";const n=document.querySelector('[class^="wx"][class$="theme"]');return n?n.className.substring(3,n.className.length-6):"willow"}function mf(n,a,r,l,c){const d=document.createElement("div"),m=document.createElement("div"),p=document.body;c=c?`${c}px`:"auto";let g,v;m.className=a,d.classList.add(`wx-${r}-theme`),d.style.cssText=`height:auto;position:absolute;top:0px;left:100px;overflow:hidden;width=${c};white-space:nowrap;`,d.appendChild(m),p.appendChild(d),typeof n!="object"&&(n=[n]);for(let b=0;b<n.length;b++){m.innerText=n[b]+"";const y=d.getBoundingClientRect(),w=Math.ceil(y.width)+(l&&l.length?l[b]:0),S=Math.ceil(y.height);g=Math.max(g||0,w),v=Math.max(v||0,S)}return d.remove(),{width:g,height:v}}function iy(n,a,r,l,c){const d=[];for(let m=0;m<n.length;m++){const p=n[m][a],g=p.length;for(let v=0;v<g;v++){const{text:b,vertical:y,collapsed:w,rowspan:S,css:j}=p[v];if(!b){d[v]=Math.max(d[v]||0,l);continue}let N=0;if(y&&!w){let M=`wx-measure-cell-${a}`;if(M+=j?` ${j}`:"",N=mf(b,M,c).width,(S>1||!p[v+1])&&r>v+1){const k=S||r-v,E=d.slice(v,v+k).reduce((R,U)=>R+U,0);if(E<N){const R=Math.ceil((N-E)/k);for(let U=v;U<v+k;U++)d[U]=(d[U]||l)+R}continue}}d[v]=Math.max(d[v]||l,N)}}return d}function H1(n,a,r){const l=[],c=[];let d="wx-measure-cell-body";d+=n.css?` ${n.css}`:"";for(let m=0;m<a.length;m++){const p=a[m],g=Gr(p,n);g&&(l.push(g),n.treetoggle?c.push(a[m].$level*Bd+(a[m].$count?Bd:0)+(n.draggable?Bd:0)):n.draggable&&c.push(Bd))}return mf(l,d,r,c).width}function B1(n,a){const r="wx-measure-cell-header",l=n.sort?I1:0;let c=n.header;if(typeof c=="string")return mf(c,r,a).width+l;let d;Array.isArray(c)||(c=[c]);for(let m=0;m<c.length;m++){const p=c[m],g=typeof p=="string"?p:p.text,v=r+(typeof p=="string"?"":` ${p.css}`);let b=mf(g,v,a).width;m===c.length-1&&(b+=l),d=Math.max(d||0,b)}return d}const F1={text:(n,a)=>n?n.toString().toLowerCase().indexOf(a.toLowerCase())!==-1:!a,richselect:(n,a)=>typeof a!="number"&&!a?!0:n==a,datepicker:(n,a)=>a?n&&$1(n,a):!0,multiselect:(n,a)=>!a||a?.length===0?!0:Array.isArray(n)?n?.some(r=>a.includes(r)):n&&a.includes(n)};function Qb(n){return F1[n]}function P1(n,a){const r=[];for(const l in n){const c=a.find(g=>g.id==l),{config:d,type:m}=c.header.find(g=>g.filter).filter,p=n[l];r.push(g=>{const v=Vr(g,c);return d?.handler?d.handler(v,p):Qb(m)(v,p)})}return l=>{for(let c=0;c<r.length;c++)if(!r[c](l))return!1;return!0}}function $1(n,a){return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}let U1=class extends m1{in;_router;_branches;_xlsxWorker;_historyManager;constructor(a){super({writable:a,async:!1});const r={rowHeight:37,columnWidth:160,headerHeight:36,footerHeight:36};this._router=new h1(super.setState.bind(this),[{in:["columns","sizes","_skin"],out:["_columns","_sizes"],exec:c=>{const{columns:d,sizes:m,_skin:p}=this.getState(),g=this.copyColumns(d),v=g.reduce((w,S)=>Math.max(S.header.length,w),0),b=g.reduce((w,S)=>Math.max(S.footer.length,w),0);g.forEach(this.setCollapsibleColumns);const y=this.normalizeSizes(g,m,v,b,p);for(let w=0;w<g.length;w++)this.normalizeColumns(g,w,"header",v,y),this.normalizeColumns(g,w,"footer",b,y);this.setState({_columns:g,_sizes:y},c)}},{in:["data","tree","_filterIds"],out:["flatData","_rowHeightFromData"],exec:c=>{const{data:d,tree:m,dynamic:p,_filterIds:g}=this.getState(),v=g&&new Set(g),b=m?this.flattenRows(d,[],g):v?d.filter(w=>v.has(w.id)):d,y=!p&&b.some(w=>w.rowHeight);this.setState({flatData:b,_rowHeightFromData:y},c)}}],{sizes:c=>({...r,...c})});const l=this.in=new p1;l.on("close-editor",({ignore:c})=>{const{editor:d}=this.getState();d&&(c||l.exec("update-cell",d),this.setState({editor:null}))}),l.on("open-editor",({id:c,column:d})=>{let m=this.getState().editor;m&&l.exec("close-editor",{});const p=this.getRow(c),g=d?this.getColumn(d):this.getNextEditor(p);if(g?.editor){let v=g.editor;if(typeof v=="function"&&(v=v(p,g)),!v)return;m={column:g.id,id:c,value:Vr(p,g)??"",renderedValue:Gr(p,g),type:v.type||v},typeof v=="object"&&v.config&&(m.config=v.config,v.config.options&&(m.options=v.config.options)),g.options&&!m.options&&(m.options=g.options),this.setState({editor:m})}}),l.on("editor",({value:c})=>{let d=this.getState().editor;if(d){d={...d},d.value=c;const m=this.getColumn(d.column),p={...this.getRow(d.id)};lh(p,m,c),d.renderedValue=Gr(p,m),this.setState({editor:d})}}),l.on("add-row",c=>{const d=this.getState();let{data:m}=d;const{select:p,_filterIds:g}=d,{row:v,before:b,after:y,select:w}=c;if(c.id=v.id=c.id||v.id||Fd(),b||y){const j=b||y,N=m.findIndex(M=>M.id===j);m=[...m],m.splice(N+(y?1:0),0,c.row)}else m=[...m,c.row];const S={data:m};g&&(S._filterIds=[...g,c.id]),this.setState(S),!(typeof w=="boolean"&&!w)&&(w||p)&&l.exec("select-row",{id:v.id,show:!0})}),l.on("delete-row",c=>{const{data:d,selectedRows:m,focusCell:p,editor:g}=this.getState(),{id:v}=c,b={data:d.filter(y=>y.id!==v)};this.isSelected(v)&&(b.selectedRows=m.filter(y=>y!==v)),g?.id===v&&(b.editor=null),this.setState(b),p?.row===v&&this.in.exec("focus-cell",{eventSource:"delete-row"})}),l.on("update-cell",c=>{const d=this.getState();let{data:m}=d;m=[...m];const{tree:p}=d,{id:g,column:v,value:b}=c,y=this.getColumn(v);if(p){const w={...this._branches[g]};lh(w,y,b);const S=this.updateTreeRow(w);w.$parent===0&&(m=S)}else{const w=m.findIndex(j=>j.id===g),S={...m[w]};lh(S,y,b),m[w]=S}this.setState({data:m})}),l.on("update-row",c=>{let{data:d}=this.getState();const{id:m,row:p}=c,g=d.findIndex(v=>v.id===m);d=[...d],d[g]={...d[g],...p},this.setState({data:d})}),l.on("select-row",({id:c,toggle:d,range:m,mode:p,show:g,column:v})=>{const b=this.getState(),{focusCell:y}=b;let{selectedRows:w}=b;if(w.length||(m=d=!1),m){const{data:S}=this.getState();let j=S.findIndex(M=>M.id===w[w.length-1]),N=S.findIndex(M=>M.id===c);j>N&&([j,N]=[N,j]),S.slice(j,N+1).forEach(M=>{this.isSelected(M.id)||w.push(M.id)})}else if(d&&this.isSelected(c)){if(p===!0)return;w=w.filter(S=>S!==c)}else if(d){if(p===!1)return;w.push(c)}else w=[c];this.setState({selectedRows:[...w]}),y?.row!==c&&this.in.exec("focus-cell",{eventSource:"select-row"}),g&&this.in.exec("scroll",{row:c,column:v})}),this.in.on("focus-cell",c=>{const{row:d,column:m,eventSource:p}=c,{_columns:g,split:v}=this.getState();d&&m?(this.setState({focusCell:{row:d,column:m}}),p!=="click"&&((!v.left||g.findIndex(b=>b.id===c.column)>=v.left)&&(!v.right||g.findIndex(b=>b.id===c.column)<g.length-v.right)?this.in.exec("scroll",{row:d,column:m}):this.in.exec("scroll",{row:d}))):this.setState({focusCell:null})}),l.on("resize-column",c=>{const{id:d,auto:m,maxRows:p,inProgress:g}=c;if(g===!1)return;let v=c.width||0;const b=[...this.getState().columns],y=this.getColumn(d);if(m){if(m==="data"||m===!0){const{flatData:w,_skin:S}=this.getState();let j=w.length;p&&(j=Math.min(p,j));const N=w.slice(0,j);v=H1(y,N,S)}if(m==="header"||m===!0){const{_skin:w}=this.getState();v=Math.max(B1(y,w),v)}}y.width=Math.max(17,v),delete y.flexgrow,this.setState({columns:b})}),l.on("hide-column",c=>{const{id:d,mode:m}=c,p=[...this.getState().columns],g=this.getColumn(d),v=p.reduce((b,y)=>b+(y.hidden?0:1),0);!m||v>1?(g.hidden=!g.hidden,this.setState({columns:p})):c.skipUndo=!0}),l.on("sort-rows",c=>{const{key:d,add:m,sort:p}=c,g=this.getState(),{columns:v,data:b,tree:y}=g;if(p){const E=[...b];E.sort(p),this.setState({data:E});return}const{order:w="asc"}=c;let S=g.sortMarks;const j=Object.keys(S),N=j.length;!m||!N||N===1&&S[d]?S={[d]:{order:w}}:(N===1&&(S[j[0]]={...S[j[0]],index:0}),S={...S,[d]:{order:w,index:typeof m=="number"?m:S[d]?.index??N}});const M=Object.keys(S).sort((E,R)=>S[E].index-S[R].index).map(E=>({key:E,order:S[E].order}));this.setState({sortMarks:S});const k=z1(M,v);if(k){const E=[...b];y?this.sortTree(E,k):E.sort(k),this.setState({data:E})}}),l.on("filter-rows",c=>{const{value:d,key:m,filter:p}=c;if(!Object.keys(c).length){this.setState({filterValues:{},_filterIds:null});return}const g=this.getState(),{data:v,tree:b,_columns:y}=g;let w=g.filterValues;const S={};m&&(w={...w,[m]:d},S.filterValues=w);const j=p??P1(w,y);let N=[];b?N=this.filterTree(v,j,N):v.forEach(M=>{j(M)&&N.push(M.id)}),S._filterIds=N,this.setState(S)}),l.on("collapse-column",c=>{const{id:d,row:m,mode:p}=c,g=[...this.getState().columns],v=this.getColumn(d).header,b=Array.isArray(v)?v[m]:v;typeof b=="object"&&(b.collapsed=p??!b.collapsed,this.setState({columns:g}))}),l.on("move-item",c=>{const{id:d,inProgress:m}=c;let{target:p,mode:g="after"}=c;const{data:v,flatData:b,tree:y}=this.getState(),w=b.findIndex(N=>N.id===d);let S;if(g==="up"||g==="down"){if(g==="up"){if(w===0)return;S=w-1,g="before"}else if(g==="down"){if(w===b.length-1)return;S=w+1,g="after"}p=b[S]&&b[S].id}else S=b.findIndex(N=>N.id===p);if(w===-1||S===-1||m===!1)return;let j;y||(j=this.moveItem(d,p,v,g)),this.setState({data:y?this.normalizeTreeRows(j):j})}),l.on("copy-row",c=>{const{id:d,target:m,mode:p="after"}=c,g=this.getState(),{flatData:v,_filterIds:b}=g;let{data:y}=g;const w=this.getRow(d);if(!w)return;const S={...w,id:Fd()};c.id=S.id;const j=v.findIndex(M=>M.id===m);if(j===-1)return;y.splice(j+(p==="after"?1:0),0,S),y=[...y];const N={data:y};b&&(N._filterIds=[...b,S.id]),this.setState(N)}),l.on("open-row",c=>{const{id:d,nested:m}=c;this.toggleBranch(d,!0,m)}),l.on("close-row",c=>{const{id:d,nested:m}=c;this.toggleBranch(d,!1,m)}),l.on("export-data",c=>new Promise((d,m)=>{const p=c.format||"csv",g=`${c.fileName||"data"}.${p}`;if(p==="csv"){const v=y1(this.getState(),c.csv||{});c.download!==!1?x1(new Blob(["\uFEFF"+v],{type:"text/csv"}),g):c.result=v,d(!0)}else m()})),l.on("hotkey",({key:c,event:d,isInput:m})=>{switch(c){case"arrowup":{const{flatData:p,focusCell:g,select:v}=this.getState();if(d.preventDefault(),m)return;const b=g?g.column:this._getFirstVisibleColumn()?.id,y=g?this.getPrevRow(g.row)?.id:p[p.length-1]?.id;b&&y&&(this.in.exec("focus-cell",{row:y,column:b,eventSource:"key"}),v&&this.in.exec("select-row",{id:y}));break}case"arrowdown":{const{flatData:p,focusCell:g,select:v}=this.getState();if(d.preventDefault(),m)return;const b=g?g.column:this._getFirstVisibleColumn()?.id,y=g?this.getNextRow(g.row)?.id:p[0]?.id;b&&y&&(this.in.exec("focus-cell",{row:y,column:b,eventSource:"key"}),v&&this.in.exec("select-row",{id:y}));break}case"arrowright":{const{focusCell:p}=this.getState();if(m)return;if(d.preventDefault(),p){const g=this.getNextColumn(p.column,!0)?.id;g&&this.in.exec("focus-cell",{row:p.row,column:g,eventSource:"key"})}break}case"arrowleft":{const{focusCell:p}=this.getState();if(m)return;if(d.preventDefault(),p){const g=this.getPrevColumn(p.column,!0)?.id;g&&this.in.exec("focus-cell",{row:p.row,column:g,eventSource:"key"})}break}case"tab":{const{editor:p,focusCell:g,select:v}=this.getState();if(p){d.preventDefault();const b=p.column;let y=p.id,w=this.getNextEditor(this.getRow(y),this.getColumn(b));if(!w){const S=this.getNextRow(y);S&&(y=S.id,w=this.getNextEditor(S))}w&&(this.in.exec("open-editor",{id:y,column:w.id}),this.in.exec("focus-cell",{row:y,column:w.id,eventSource:"key"}),v&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}else g&&this.in.exec("focus-cell",{eventSource:"key"});break}case"shift+tab":{const{editor:p,focusCell:g,select:v}=this.getState();if(p){d.preventDefault();const b=p.column;let y=p.id,w=this.getPrevEditor(this.getRow(y),this.getColumn(b));if(!w){const S=this.getPrevRow(y);S&&(y=S.id,w=this.getPrevEditor(S))}w&&(this.in.exec("open-editor",{id:y,column:w.id}),this.in.exec("focus-cell",{row:y,column:w.id,eventSource:"key"}),v&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}else g&&this.in.exec("focus-cell",{eventSource:"key"});break}case"escape":{const{editor:p}=this.getState();p&&(this.in.exec("close-editor",{ignore:p.type!="multiselect"}),this.in.exec("focus-cell",{row:p.id,column:p.column,eventSource:"key"}));break}case"f2":{const{editor:p,focusCell:g}=this.getState();!p&&g&&this.in.exec("open-editor",{id:g.row,column:g.column});break}case"enter":{const{focusCell:p,tree:g}=this.getState();if(!m&&g&&p&&this.getColumn(p.column).treetoggle){const v=this.getRow(p.row);if(!v.data)return;this.in.exec(v.open?"close-row":"open-row",{id:p.row,nested:!0})}break}case"home":{const{editor:p,focusCell:g}=this.getState();if(!p&&g){d.preventDefault();const v=this._getFirstVisibleColumn()?.id;this.in.exec("focus-cell",{row:g.row,column:v,eventSource:"key"})}break}case"ctrl+home":{const{editor:p,focusCell:g,flatData:v,select:b}=this.getState();if(!p&&g){d.preventDefault();const y=v[0]?.id,w=this._getFirstVisibleColumn()?.id;y&&w&&(this.in.exec("focus-cell",{row:y,column:w,eventSource:"key"}),b&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}break}case"end":{const{editor:p,focusCell:g}=this.getState();if(!p&&g){d.preventDefault();const v=this._getLastVisibleColumn()?.id,b=g.row;this.in.exec("focus-cell",{row:b,column:v,eventSource:"key"})}break}case"ctrl+end":{const{editor:p,focusCell:g,flatData:v,select:b}=this.getState();if(!p&&g){d.preventDefault();const y=v.at(-1).id,w=this._getLastVisibleColumn()?.id;y&&w&&(this.in.exec("focus-cell",{row:y,column:w,eventSource:"key"}),b&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}break}case"ctrl+z":{this.in.exec("undo",{});break}case"ctrl+y":{this.in.exec("redo",{});break}}}),l.on("scroll",c=>{const{_columns:d,split:m,_sizes:p,flatData:g,dynamic:v,_rowHeightFromData:b}=this.getState();let y=-1,w=-1,S=0,j=0;if(c.column){y=0;const N=d.findIndex(M=>M.id===c.column);S=d[N].width;for(let M=m.left??0;M<N;M++){const k=d[M];k.hidden||(y+=k.width)}}if(c.row&&!v){const N=g.findIndex(M=>M.id===c.row);N>=0&&(b?(w=g.slice(0,N).reduce((M,k)=>M+(k.rowHeight||p.rowHeight),0),j=g[N].rowHeight):w=p.rowHeight*N)}this.setState({scroll:{top:w,left:y,width:S,height:j||p.rowHeight}})}),l.on("scroll-to",c=>{const d={};c.top!==void 0&&(d.scrollTop=c.top),c.left!==void 0&&(d.scrollLeft=c.left),Object.keys(d).length&&this.setState(d)}),l.on("print",c=>{const d=N1(c);this.setState({_print:d}),this.setStateAsync({_print:null})}),l.on("undo",()=>{this._historyManager?.handleUndo()}),l.on("redo",()=>{this._historyManager?.handleRedo()}),this.initOnce()}getXlsxWorker(a){if(!this._xlsxWorker){const r=window.URL.createObjectURL(new Blob([`importScripts('${a}');`],{type:"text/javascript"}));this._xlsxWorker=new Promise(l=>{const c=new Worker(r);c.addEventListener("message",d=>{d.data.type==="init"&&l(c)})})}return this._xlsxWorker}initOnce(){const a={sortMarks:{},_filterIds:null,data:[],filterValues:{},scroll:null,scrollLeft:0,scrollTop:0,editor:null,focusCell:null,_print:null,history:{undo:0,redo:0},search:null};this._router.init(a)}init(a){a.hasOwnProperty("_skin")&&!a._skin&&(a._skin=O1()),a.columns&&a.columns.forEach(r=>{r.options&&(r.optionsMap=new Map(r.options.map(l=>[l.id,l.label])))}),Sf(this.getState().data,a.data)||(a.tree?a.data=this.normalizeTreeRows(a.data):a.data=this.normalizeRows(a.data),this.setState({_filterIds:null,filterValues:{},sortMarks:{},search:null}),this._historyManager&&this._historyManager.resetHistory()),a.tree&&(a.undo=!1,a.reorder=!1),a.split?.right&&(a.split.right=0),a.undo&&!this._historyManager&&(this._historyManager=new D1(this.in,this.getState.bind(this),this.setState.bind(this))),this._router.init({...a})}setState(a,r){return this._router.setState(a,r)}setStateAsync(a){this._router.setStateAsync(a)}getRow(a){const{tree:r}=this.getState();return r?this._branches[a]:this.getState().data.find(l=>l.id===a)}getRowIndex(a,r){return r||(r=this.getState().flatData),r.findIndex(l=>l.id===a)}getNextRow(a){const r=this.getState().flatData,l=this.getRowIndex(a,r);return r[l+1]}getPrevRow(a){const r=this.getState().flatData,l=this.getRowIndex(a,r);return r[l-1]}getColumn(a){return this.getState().columns.find(r=>r.id===a)}getNextColumn(a,r){const l=this.getState()._columns,c=l.findIndex(d=>d.id===a);return r?this._getFirstVisibleColumn(c+1):l[c+1]}getPrevColumn(a,r){const l=this.getState()._columns,c=l.findIndex(d=>d.id===a);return r?this._getLastVisibleColumn(c-1):l[c-1]}_getFirstVisibleColumn(a){const r=this.getState()._columns;let l=a??0;for(;l<r.length&&(r[l]?.hidden||r[l]?.collapsed);)l++;return r[l]}_getLastVisibleColumn(a){const r=this.getState()._columns;let l=a??r.length-1;for(;l<r.length&&(r[l]?.hidden||r[l]?.collapsed);)l--;return r[l]}isCellEditable(a,r){const{editor:l,hidden:c}=r;return!l||c?!1:typeof l=="function"?l(a,r):!0}getNextEditor(a,r){let l=this.getState().columns;if(r){const c=l.findIndex(d=>d.id===r.id);l=l.slice(c+1)}return l.find(c=>this.isCellEditable(a,c))}getPrevEditor(a,r){let l=this.getState().columns;if(r){const c=l.findLastIndex(d=>d.id===r.id);l=l.slice(0,c)}return l.findLast(c=>this.isCellEditable(a,c))}toggleBranch(a,r,l){let c=this._branches[a],{data:d}=this.getState();if(d=[...d],a!==0){c={...c,open:r};const m=this.updateTreeRow(c);c.$parent===0&&(d=m)}l&&c.data?.length&&c.data.forEach(m=>{const p=this.toggleKids(m,r,l);a===0&&(d=p)}),this.setState({data:d})}toggleKids(a,r,l){a={...a,open:r};const c=this.updateTreeRow(a);return l&&a.data?.length&&a.data.forEach(d=>{this.toggleKids(d,r,l)}),c}updateTreeRow(a){const r=a.id;this._branches[r]=a;const l=this._branches[a.$parent],c=l.data.findIndex(d=>d.id===r);return l.data=[...l.data],l.data[c]=a,l.data}isSelected(a){return this.getState().selectedRows.indexOf(a)!==-1}findAndRemove(a,r){for(let l=0;l<a.length;l++){if(a[l].id===r)return a.splice(l,1)[0];if(a[l].data){const c=[...a[l].data],d=this.findAndRemove(c,r);if(d)return a[l]={...a[l],data:c},d}}return null}insertItem(a,r,l,c){for(let d=0;d<a.length;d++){if(a[d].id===r){const m=a[d],p=c==="before"?d:d+1;if(m.data){if(c==="before"){const g=d>0?a[d-1]:null;return g?.data&&g.open?a[d-1]={...g,data:[...g.data,l]}:a.splice(p,0,l),!0}else if(m.open)return a[d]={...m,data:[l,...m.data]},!0}return a.splice(p,0,l),!0}if(a[d].data&&(a[d]={...a[d],data:[...a[d].data]},this.insertItem(a[d].data,r,l,c)))return!0}return!1}moveItem(a,r,l,c){const d=[...l],m=this.findAndRemove(d,a);return this.insertItem(d,r,m,c),d}copyColumns(a){const r=[];for(let l=0;l<a.length;l++){const c={...a[l]};this.copyHeaderFooter(c,"header"),this.copyHeaderFooter(c,"footer"),r[l]=c}return r}copyHeaderFooter(a,r){let l=a[r];l=Array.isArray(l)?[...l]:[l],l.forEach((c,d)=>{l[d]=typeof c=="string"?{text:c}:{...c}}),a[r]=l}setCollapsibleColumns(a,r,l){let c=a.header;for(let d=0;d<c.length;d++){const m=c[d];if(m.collapsible&&m.collapsed){if(m.collapsible!=="first"){a.collapsed=!0,a.width=36,m.vertical=!0;const g=c.length-d;c=c.slice(0,d+1),c[d].rowspan=g}const p=m.colspan;if(p){const g=c[d+1];let v=1;g&&g.colspan&&!g.collapsed&&(v=g.colspan);for(let b=v;b<p;b++){const y=l[r+b];y&&(y.hidden=!0)}}}}}normalizeColumns(a,r,l,c,d){const m=a[r];m.width||(m.width=m.flexgrow?17:d.columnWidth),m._colindex=r+1;const p=m[l],g=d[`${l}RowHeights`];for(let v=0;v<c;v++){const b=p[v];b.id=m.id,v===p.length-1&&(b.rowspan=b.rowspan?Math.min(b.rowspan,c-v):c-v);for(let y=1;y<b.rowspan;y++){p.splice(v+y,0,{_hidden:!0});for(let w=1;w<b.colspan;w++)a[r+w][l].splice(v+y,0,{})}if(b.rowspan){const y=(b.rowspan===c?g:g.slice(v,b.rowspan+v)).reduce((w,S)=>w+S,0);b.height=y,v+b.rowspan!=c&&b.height--}if(b.colspan){let y=m.width,w=m.flexgrow||0;const S=b.colspan;for(let j=1;j<S;j++){const N=a[r+j];N&&(N.hidden?b.colspan-=1:N.flexgrow?w+=N.flexgrow:y+=N.width||d.columnWidth),w?b.flexgrow=w:b.width=y}}else b.width=m.width,b.flexgrow=m.flexgrow;l==="header"&&b.filter&&typeof b.filter=="string"&&(b.filter={type:b.filter})}p.length>c&&(p.length=c),m[l]=p}normalizeRows(a){for(let r=0;r<a.length;r++)a[r].id||(a[r].id=Fd());return a}normalizeTreeRows(a,r,l){return!r&&!l&&(this._branches={0:{data:a}}),a.forEach(c=>{c.id||(c.id=Fd()),c.$level=r||0,c.$parent=l||0,this._branches[c.id]=c,c.data&&(c.data.length?(c.$count=c.data.length,this.normalizeTreeRows(c.data,c.$level+1,c.id)):(delete c.data,delete c.$count,delete c.open))}),a}sortTree(a,r){a.sort(r),a.forEach(l=>{l.data&&this.sortTree(l.data,r)})}filterTree(a,r,l){return a.forEach(c=>{r(c)&&l.push(c.id),c.data&&this.filterTree(c.data,r,l)}),l}flattenRows(a,r,l){const c=r;return a.forEach(d=>{(!l||l.includes(d.id))&&c.push(d),d.data?.length&&d.open!==!1&&this.flattenRows(d.data,c,l)}),c}createFilter(a){const{_columns:r}=this.getState(),l=[];for(const c in a){const d=r.find(v=>v.id==c),{config:m,type:p}=d.header.find(v=>v.filter).filter,g=a[c];l.push(v=>{const b=Vr(v,d);return m?.handler?m.handler(b,g):Qb(p)(b,g)})}return c=>{for(let d=0;d<l.length;d++)if(!l[d](c))return!1;return!0}}searchRows(a,r){a=a.trim().toLowerCase();const l={};if(!a)return l;const{flatData:c,columns:d}=this.getState(),m=r?d.filter(p=>r[p.id]):d;return c.forEach(p=>{const g={};m.forEach(v=>{const b=Gr(p,v);String(b).toLowerCase().includes(a)&&(g[v.id]=!0)}),Object.keys(g).length&&(l[p.id]=g)}),l}normalizeSizes(a,r,l,c,d){const m=iy(a,"header",l,r.headerHeight,d),p=iy(a,"footer",c,r.footerHeight,d),g=m.reduce((b,y)=>b+y,0),v=p.reduce((b,y)=>b+y,0);return{...r,headerRowHeights:m,footerRowHeights:p,headerHeight:g,footerHeight:v}}},q1=new Date().valueOf();function Fd(){return"temp://"+q1++}function G1(n,a="data-id"){let r=n;for(!r.tagName&&n.target&&(r=n.target);r;){if(r.getAttribute&&r.getAttribute(a))return r;r=r.parentNode}return null}new Date().valueOf();var V1=class{constructor(){this.store=new Map}configure(n,a){this.node=a;for(const r in n)if(n[r]){const l=r.toLowerCase().replace(/[ ]/g,""),c=n[r];this.store.set(l,c)}}},Io=[],W1={subscribe:n=>{Y1();const a=new V1;return Io.push(a),n(a),()=>{const r=Io.findIndex(l=>l===a);r>=0&&Io.splice(r,1)}}},ry=!1;function Y1(){ry||(ry=!0,document.addEventListener("keydown",n=>{if(Io.length&&(n.ctrlKey||n.altKey||n.metaKey||n.shiftKey||n.key.length>1||n.key===" ")){const a=[];n.ctrlKey&&a.push("ctrl"),n.altKey&&a.push("alt"),n.metaKey&&a.push("meta"),n.shiftKey&&a.push("shift");let r=n.code.replace("Key","").toLocaleLowerCase();n.key===" "&&(r="space"),a.push(r);const l=a.join("+");for(let c=Io.length-1;c>=0;c--){const d=Io[c],m=d.store.get(l)||d.store.get(r);m&&d.node.contains(n.target)&&m(n,{key:l,evKey:r})}}}))}const K1={tab:!0,"shift+tab":!0,arrowup:!0,arrowdown:!0,arrowright:!0,arrowleft:!0,enter:!0,escape:!0,f2:!0,home:!0,end:!0,"ctrl+home":!0,"ctrl+end":!0,"ctrl+z":!0,"ctrl+y":!0};function Q1(n,{keys:a,exec:r}){if(!a)return;function l(m){const p=m.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||G1(p,"data-header-id")?.classList.contains("wx-filter")||!!p.closest(".wx-cell.wx-editor")}const c={};for(const m in a){const p=a[m];typeof p<"u"&&(typeof p=="function"?c[m]=p:p&&(c[m]=g=>{const v=l(g);r({key:m,event:g,isInput:v})}))}const d=W1.subscribe(m=>{m.configure(c,n)});return{destroy:()=>{d()}}}function X1(n,a){let r=null;a.scroll.subscribe(l=>{if(!l||l===r)return;r=l;const{left:c,top:d,height:m,width:p}=l,g=a.getHeight(),v=a.getWidth(),b=a.getScrollMargin();if(d>=0){const y=n.scrollTop;d<y?n.scrollTop=d:d+m>y+g&&(n.scrollTop=d-g+m)}if(c>=0){const y=n.scrollLeft;c<y?n.scrollLeft=c:c+p>y+v-b&&(n.scrollLeft=c-v+p+b)}}),a.scrollLeft?.subscribe?.(l=>{requestAnimationFrame(()=>{Math.abs(n.scrollLeft-l)>1&&(n.scrollLeft=l)})}),a.scrollTop?.subscribe?.(l=>{requestAnimationFrame(()=>{Math.abs(n.scrollTop-l)>1&&(n.scrollTop=l)})})}const es=u.createContext(null);function Z1(n,a){const r=new ResizeObserver(l=>{requestAnimationFrame(()=>a(l[0].contentRect))});return r.observe(n.parentNode),{destroy(){r.disconnect()}}}const ly=5,J1=700;function Zd(n){const a=n.getBoundingClientRect(),r=document.body,l=a.top+r.scrollTop-r.clientTop||0,c=a.left+r.scrollLeft-r.clientLeft||0;return{y:Math.round(l),x:Math.round(c),width:n.offsetWidth,height:n.offsetHeight}}function Fh(n,a){const r=Zd(a);return{x:n.clientX-r.x,y:n.clientY-r.y}}function eA(n,a){const r=a.current;let l=null,c,d,m=!1,p=!1;const g=document.createElement("DIV");g.className="wx-drag-zone",g.setAttribute("tabindex",-1);function v(){clearTimeout(c),c=null}function b(_){const L=Fo(_);L&&(l={container:g,sourceNode:_.target,from:yf(L),pos:Fh(_,n)},d=l.pos,y(_))}function y(_){if(!l)return;const L=l.pos=Fh(_,n);if(!m){if(!p&&!_?.target?.getAttribute("draggable-data")&&Math.abs(d.x-L.x)<ly&&Math.abs(d.y-L.y)<ly)return;if(H(_)===!1)return W()}if(p){const le=window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft,q=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop;l.targetNode=document.elementFromPoint(_.pageX-le,_.pageY-q)}else l.targetNode=_.target;r.move&&r.move(_,l),g.style.left=-(l.offset?l.offset.x:0)+"px",g.style.top=l.pos.y+(l.offset?l.offset.y:0)+"px"}function w(_){g.parentNode&&g.parentNode.removeChild(g),g.innerHTML="",m&&r.end&&r.end(_,l),l=d=null,W()}function S(_){r.getReorder&&!r.getReorder()||_.button===0&&(U(_),window.addEventListener("mousemove",j),window.addEventListener("mouseup",N),b(_))}function j(_){y(_)}function N(_){w(_)}function M(_){if(r.getReorder&&!r.getReorder())return;c=setTimeout(()=>{p=!0,b(_.touches[0])},J1),U(_);function L(){c&&v(),_.target.removeEventListener("touchmove",k),_.target.removeEventListener("touchend",L),w(_)}_.target.addEventListener("touchmove",k),_.target.addEventListener("touchend",L),n.addEventListener("contextmenu",E)}function k(_){m?(_.preventDefault(),y(_.touches[0])):c&&v()}function E(_){if(m||c)return _.preventDefault(),!1}function R(_){_.preventDefault()}function U(_){if(!r.getDraggableInfo)return;const{hasDraggable:L}=r.getDraggableInfo();(!L||_.target.getAttribute("draggable-data"))&&(document.body.style.userSelect="none",document.body.style.webkitUserSelect="none")}function H(_){if(m=!0,r.start){if(r.start(_,l)===!1)return!1;n.appendChild(g),document.body.style.cursor="move"}}function W(_){m=p=!1,document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",N),_&&(n.removeEventListener("mousedown",S),n.removeEventListener("touchstart",M),n.removeEventListener("dragstart",R))}return n.addEventListener("mousedown",S),n.addEventListener("touchstart",M),n.addEventListener("dragstart",R),{destroy(){W(!0)}}}const tA=.004;function nA(){return{dirX:0,dirY:0,scrollSpeedFactor:1}}function aA(n,a,r,l){const{node:c,left:d,top:m,bottom:p,sense:g,xScroll:v,yScroll:b}=l,y=Fh(n,c);r.scrollState||(r.scrollState=nA());let w=0,S=0;y.x<d+g?w=-1:y.x>a.width-g&&(w=1),y.y<m+Math.round(g/2)?S=-1:y.y>a.height-p-Math.round(g/2)&&(S=1),(r.scrollState.dirX!==w||r.scrollState.dirY!==S)&&(Xb(r),r.scrollState.dirX=w,r.scrollState.dirY=S),(v&&r.scrollState.dirX!==0||b&&r.scrollState.dirY!==0)&&sA(r,l,{x:r.scrollState.dirX,y:r.scrollState.dirY})}function sA(n,a,r){n.autoScrollTimer||(n.autoScrollTimer=setTimeout(()=>{n.activeAutoScroll=setInterval(iA,15,n,a,r)},250))}function Xb(n){n.scrollSpeedFactor=1,n.autoScrollTimer&&(n.autoScrollTimer=clearTimeout(n.autoScrollTimer),n.activeAutoScroll=clearInterval(n.activeAutoScroll))}function iA(n,a,r){const{x:l,y:c}=r;n.scrollSpeedFactor+=tA,l!==0&&lA(n,a,l),c!==0&&rA(n,a,c)}function rA(n,a,r){const l=a.node.scrollTop;Zb(l+Math.round(a.sense/3)*n.scrollSpeedFactor*r,"scrollTop",a)}function lA(n,a,r){const l=a.node.scrollLeft;Zb(l+Math.round(a.sense/3)*n.scrollSpeedFactor*r,"scrollLeft",a)}function Zb(n,a,r){r.node[a]=n}function Cf(n,a,r,l,c,d){const m={};return n&&(m.width=`${n}px`,m.minWidth=`${n}px`),a&&(m.flexGrow=a),d&&(m.height=`${d}px`),r&&(m.position="sticky",r.left&&(m.left=`${l}px`),r.right&&(m.right=`${c}px`)),m}function Jb(n,a,r){let l="";if(n.fixed)for(const c in n.fixed){let d=n.fixed[c]===-1;!d&&n.fixed.leftSize&&a.colspan&&(d=a.colspan+n._colindex-1===n.fixed.leftSize),l+=d?"wx-shadow ":"wx-fixed "}return l+=a.rowspan>1?"wx-rowspan ":"",l+=a.colspan>1?"wx-colspan ":"",l+=a.vertical?"wx-vertical ":"",l+=r?r(n)+" ":"",l}function oA(n){const{row:a,column:r,cellStyle:l=null,columnStyle:c=null,children:d,focusable:m}=n,p=u.useContext(es),g=st(p,"focusCell"),v=st(p,"search"),b=st(p,"reorder"),y=u.useMemo(()=>v?.rows[a.id]&&v.rows[a.id][r.id],[v,a.id,r.id]),w=u.useMemo(()=>Cf(r.width,r.flexgrow,r.fixed,r.left,r.right),[r.width,r.flexgrow,r.fixed,r.left,r.right]);function S(H,W){let _="wx-cell";return _+=r.fixed?" "+(r.fixed===-1?"wx-shadow":"wx-fixed"):"",_+=H?" "+H(r):"",_+=W?" "+W(a,r):"",_+=r.treetoggle?" wx-tree-cell":"",_}const j=u.useMemo(()=>S(c,l),[c,l,r,a]),N=u.useMemo(()=>typeof r.draggable=="function"?r.draggable(a,r)!==!1:r.draggable,[r,a]),M=u.useRef(null);u.useEffect(()=>{M.current&&m&&g?.row===a.id&&g?.column===r.id&&M.current.focus()},[g,m,a.id,r.id]);const k=u.useCallback(()=>{m&&!g&&p.exec("focus-cell",{row:a.id,column:r.id,eventSource:"focus"})},[p,m,g,a.id,r.id]);function E(H){const W=new RegExp(`(${v.value.trim()})`,"gi");return String(H).split(W).map(_=>({text:_,highlight:W.test(_)}))}const R=u.useMemo(()=>{const H=r.fixed&&r.fixed.left===-1||r.fixed.right===-1,W=r.fixed&&r.fixed.right;return[j,H?"wx-shadow":"",W?"wx-fixed-right":""].filter(Boolean).join(" ")},[j,r]),U=r.cell;return s.jsxs("div",{className:"wx-TSCaXsGV "+R,ref:M,onFocus:k,style:w,"data-row-id":Bn(a.id),"data-col-id":Bn(r.id),tabIndex:m?"0":"-1",role:"gridcell","aria-colindex":r._colindex,"aria-readonly":r.editor?void 0:!0,children:[b&&r.draggable?N?s.jsx("i",{"draggable-data":"true",className:"wx-TSCaXsGV wx-draggable wxi-drag"}):s.jsx("i",{className:"wx-TSCaXsGV wx-draggable-stub"}):null,r.treetoggle?s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{marginLeft:`${a.$level*28}px`}}),a.$count?s.jsx("i",{"data-action":"toggle-row",className:`wx-TSCaXsGV wx-table-tree-toggle wxi-menu-${a.open!==!1?"down":"right"}`}):null]}):null,U?s.jsx(U,{api:p,row:a,column:r,onAction:({action:H,data:W})=>p.exec(H,W)}):d?d():y?s.jsx("span",{children:E(Gr(a,r)).map(({highlight:H,text:W},_)=>H?s.jsx("mark",{className:"wx-TSCaXsGV wx-search",children:W},_):s.jsx("span",{children:W},_))}):Gr(a,r)]})}function oy(n,a){let r,l;function c(p){r=p.clientX,n.style.opacity=1,document.body.style.cursor="ew-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",d),window.addEventListener("mouseup",m),a&&a.down&&a.down(n)}function d(p){l=p.clientX-r,a&&a.move&&a.move(l)}function m(){n.style.opacity="",document.body.style.cursor="",document.body.style.userSelect="",a&&a.up&&a.up(l),window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",m)}return n.addEventListener("mousedown",c),{destroy(){n.removeEventListener("mousedown",c)}}}function cA({filter:n,column:a,action:r,filterValue:l}){function c({value:d}){r({value:d,key:a.id})}return s.jsx(mp,{...n.config??{},value:l,onChange:c})}function uA({filter:n,column:a,action:r,filterValue:l}){const c=u.useContext(es),d=st(c,"flatData"),m=u.useMemo(()=>n?.config?.options||a?.options||g(),[n,a,d]),p=u.useMemo(()=>n?.config?.template,[n]);function g(){const y=[];return d.forEach(w=>{const S=Vr(w,a);y.includes(S)||y.push(S)}),y.map(w=>({id:w,label:w}))}function v({value:y}){r({value:y,key:a.id})}function b(y){y.key!=="Tab"&&y.preventDefault()}return s.jsx("div",{style:{width:"100%"},onKeyDown:b,children:s.jsx(jk,{placeholder:"",clear:!0,...n?.config??{},options:m,value:l,onChange:v,children:y=>p?p(y):y.label})})}function dA({filter:n,column:a,action:r,filterValue:l}){function c({value:d}){r({value:d,key:a.id})}return s.jsx("div",{className:"wx-aaaK5VYO",style:{width:"100%"},children:s.jsx(Ck,{placeholder:"",clear:!0,...n?.config??{},value:l,onChange:c})})}function ew(n){const{value:a,options:r=[],placeholder:l="",clear:c=!1,text:d=null,template:m=null,cell:p=null,dropdown:g={},autoOpen:v=!1,onChange:b,onAction:y}=n,[w,S]=Hb(a||[]),j=u.useMemo(()=>(w||[]).map(q=>r.find(te=>te.id===q)).filter(Boolean),[w,r]),N=u.useRef(null),M=u.useRef(null),[k,E]=u.useState(null),R=()=>{const q=w||[];if(!q.length)return 0;const te=r.find(K=>q.includes(K.id));return te?r.indexOf(te):0};function U(q){M.current=q.navigate,E(()=>q.keydown),v&&q.navigate(R())}u.useEffect(()=>{v&&(N.current?.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges())},[]);function H({id:q}){S(q),b&&b({value:q})}function W(q){q.stopPropagation(),S([]),b&&b({value:[]})}function _(){M.current?.(R())}function L(){M.current?.(null)}function le(q){k?.(q,R())}return s.jsxs("div",{ref:N,className:"wx-multiselect wx-aadNNOwy",onClick:_,onKeyDown:le,tabIndex:0,children:[s.jsx("div",{className:"wx-label wx-aadNNOwy",children:m?m(j):p?s.jsx(p,{data:j,onAction:y}):d?s.jsx("span",{className:"wx-text wx-aadNNOwy",children:d}):j.length?s.jsx("span",{className:"wx-text wx-aadNNOwy",children:j.map(q=>q.label).join(", ")}):l?s.jsx("span",{className:"wx-placeholder wx-aadNNOwy",children:l}):" "}),c&&w?.length?s.jsx("i",{className:"wx-icon wxi-close wx-aadNNOwy",onClick:W}):s.jsx("i",{className:"wx-icon wxi-angle-down wx-aadNNOwy"}),s.jsx(wf,{items:r,onReady:U,onSelect:H,multiselect:!0,checkboxes:!0,value:w||[],onCancel:L,...g,children:({option:q})=>s.jsx("div",{className:"wx-option wx-aadNNOwy",children:m?m(q):p?s.jsx(p,{data:q,onAction:y}):q.label})})]})}function fA({filter:n,column:a,action:r,filterValue:l}){const c=u.useContext(Pn.i18n)?.getGroup("grid")||lu(gp).getGroup("grid"),d=u.useMemo(()=>({clear:!0,...n?.config||{}}),[n]),m=u.useMemo(()=>d.options||a.options,[d,a]),p=u.useMemo(()=>{const b=l?.length;return b?b<3?l.map(y=>a.optionsMap.get(y)).join(", "):b+" "+c("selected"):""},[l,a,c]);function g({value:b}){r({value:b,key:a.id})}function v(b){b.key!=="Tab"&&b.preventDefault()}return s.jsx("div",{style:{width:"100%"},onKeyDown:v,children:s.jsx(ew,{placeholder:"",...d,options:m,value:l||[],text:p,onChange:g})})}const mA={text:cA,richselect:uA,datepicker:dA,multiselect:fA};function hA({filter:n,column:a}){const r=u.useContext(es),l=st(r,"filterValues");function c(m){r.exec("filter-rows",m)}const d=u.useMemo(()=>mA[n.type],[n.type]);return s.jsx(d,{filter:n,column:a,action:c,filterValue:l[a.id]})}function pA(n){const{cell:a,column:r,row:l,lastRow:c,sortRow:d,columnStyle:m,bodyHeight:p,hasSplit:g}=n,v=u.useContext(es),b=st(v,"sortMarks"),y=u.useMemo(()=>b?b[r.id]:void 0,[b,r.id]),w=u.useRef(),S=u.useCallback(ce=>{w.current=a.flexgrow?ce.parentNode.clientWidth:a.width},[a.flexgrow,a.width]),j=u.useCallback((ce,V)=>{v.exec("resize-column",{id:a.id,width:Math.max(1,(w.current||0)+ce),inProgress:V})},[v,a.id]),N=u.useCallback(ce=>j(ce,!0),[j]),M=u.useCallback(ce=>j(ce,!1),[j]),k=u.useCallback(ce=>{if(!r.sort||a.filter)return;let V=y?.order;V&&(V=V==="asc"?"desc":"asc"),v.exec("sort-rows",{key:a.id,add:ce.ctrlKey||ce.metaKey,order:V})},[v,a.id,a.filter,r.sort,y?.order]),E=u.useCallback(ce=>{ce&&ce.stopPropagation(),v.exec("collapse-column",{id:a.id,row:l})},[v,a.id,l]),R=u.useCallback(ce=>{ce.key==="Enter"&&E()},[E]),U=u.useCallback(ce=>{ce.key==="Enter"&&!a.filter&&k(ce)},[k,a.filter]),H=u.useMemo(()=>a.collapsed&&r.collapsed,[a.collapsed,r.collapsed]),W=u.useMemo(()=>H&&!g&&a.collapsible!=="header",[H,g,a.collapsible]),_=u.useMemo(()=>W?{top:-p/2,position:"absolute"}:{},[W,p]),L=u.useMemo(()=>Cf(a.width,a.flexgrow,r.fixed,r.left,a.right??r.right,a.height+(H&&W?p:0)),[a.width,a.flexgrow,r.fixed,r.left,a.right,r.right,a.height,H,W,p]),le=u.useMemo(()=>Jb(r,a,m),[r,a,m]),q=u.useCallback(()=>Object.fromEntries(Object.entries(a).filter(([ce])=>ce!=="cell")),[a]),te=`wx-cell ${le} ${a.css||""} wx-collapsed`,K=["wx-cell",le,a.css||"",a.filter?"wx-filter":"",r.fixed&&r.fixed.right?"wx-fixed-right":""].filter(Boolean).join(" "),ne=u.useRef(null);return u.useEffect(()=>{const ce=ne.current;if(!ce)return;const V=oy(ce,{down:S,move:N,up:M});return()=>{typeof V=="function"&&V()}},[S,N,M,oy]),H?s.jsx("div",{className:"wx-RsQD74qC "+te,style:L,role:"button","aria-label":`Expand column ${a.text||""}`,"aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:R,onClick:E,"data-header-id":Bn(r.id),children:s.jsx("div",{className:"wx-RsQD74qC wx-text",style:_,children:a.text||""})}):s.jsxs("div",{className:"wx-RsQD74qC "+K,style:L,onClick:k,"data-header-id":Bn(r.id),tabIndex:!a._hidden&&r.sort&&!a.filter?0:void 0,role:"columnheader","aria-colindex":r._colindex,"aria-colspan":a.colspan>1?a.colspan:void 0,"aria-rowspan":a.rowspan>1?a.rowspan:void 0,"aria-sort":!y?.order||a.filter?"none":y?.order==="asc"?"ascending":"descending",onKeyDown:U,children:[a.collapsible?s.jsx("div",{className:"wx-RsQD74qC wx-collapse",role:"button","aria-label":a.collapsed?"Expand column":"Collapse column","aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:R,onClick:E,children:s.jsx("i",{className:`wx-RsQD74qC wxi-angle-${a.collapsed?"down":"right"}`})}):null,a.cell?(()=>{const ce=a.cell;return s.jsx(ce,{api:v,cell:q(),column:r,row:l,onAction:({action:V,data:O})=>v.exec(V,O)})})():a.filter?s.jsx(hA,{filter:a.filter,column:r}):s.jsx("div",{className:"wx-RsQD74qC wx-text",children:a.text||""}),r.resize&&c&&!a._hidden?s.jsx("div",{className:"wx-RsQD74qC wx-grip",role:"presentation","aria-label":"Resize column",ref:ne,onClick:ce=>ce.stopPropagation(),children:s.jsx("div",{})}):null,d?s.jsx("div",{className:"wx-RsQD74qC wx-sort",children:y?s.jsxs(s.Fragment,{children:[typeof y.index<"u"?s.jsx("div",{className:"wx-RsQD74qC wx-order",children:y.index+1}):null,s.jsx("i",{className:`wx-RsQD74qC wxi-arrow-${y.order==="asc"?"up":"down"}`})]}):null}):null]})}function gA({cell:n,column:a,row:r,columnStyle:l}){const c=u.useContext(es),d=u.useMemo(()=>Cf(n?.width,n?.flexgrow,a?.fixed,a?.left,n?.right??a?.right,n?.height),[n?.width,n?.flexgrow,a?.fixed,a?.left,n?.right,a?.right,n?.height]),m=u.useMemo(()=>Jb(a,n,l),[a,n,l]),p=u.useCallback(()=>Object.fromEntries(Object.entries(n||{}).filter(([v])=>v!=="cell")),[n]),g=`wx-6Sdi3Dfd wx-cell ${m||""} ${n?.css||""}`+(a?.fixed&&a?.fixed.right?" wx-fixed-right":"");return s.jsx("div",{className:g,style:d,children:!a?.collapsed&&!n?.collapsed?n?.cell?Jh.createElement(n.cell,{api:c,cell:p(),column:a,row:r,onAction:({action:v,data:b})=>c.exec(v,b)}):s.jsx("div",{className:"wx-6Sdi3Dfd wx-text",children:n?.text||""}):null})}function cy({deltaLeft:n,contentWidth:a,columns:r,type:l="header",columnStyle:c,bodyHeight:d}){const m=u.useContext(es),p=st(m,"_sizes"),g=st(m,"split"),v=u.useMemo(()=>p?.[`${l}RowHeights`],[p,l]),b=u.useMemo(()=>{let N=[];if(r&&r.length){const M=r[0][l].length;for(let k=0;k<M;k++){let E=0;N.push([]),r.forEach((R,U)=>{const H={...R[l][k]};E||N[k].push(H),H.colspan>1?E=H.colspan-1:E&&E--})}}return N},[r,l]),y=u.useMemo(()=>g?.left||g?.right,[g]);function w(N){return r.find(M=>M.id===N)}function S(N,M){let k=M;return N.rowspan&&(k+=N.rowspan-1),k===b.length-1}function j(N,M,k){if(!k.sort)return!1;for(let E=b.length-1;E>=0;E--){const R=k.header[E];if(!R.filter&&!R._hidden)return M===E}return S(N,M)}return s.jsx("div",{className:`wx-sAsPVaUK wx-${l}`,style:{paddingLeft:`${n}px`,width:`${a}px`},role:"rowgroup",children:b.map((N,M)=>s.jsx("div",{className:l==="header"?"wx-sAsPVaUK wx-h-row":"wx-sAsPVaUK wx-f-row",style:{height:`${v?.[M]}px`,display:"flex"},role:"row",children:N.map(k=>{const E=w(k.id);return l==="header"?s.jsx(pA,{cell:k,columnStyle:c,column:E,row:M,lastRow:S(k,M),bodyHeight:d,sortRow:j(k,M,E),hasSplit:y},k.id):s.jsx(gA,{cell:k,columnStyle:c,column:w(k.id),row:M},k.id)})},M))})}function vA({overlay:n}){const a=u.useContext(es);function r(c){return typeof c=="function"}const l=n;return s.jsx("div",{className:"wx-1ty666CQ wx-overlay",children:r(n)?s.jsx(l,{onAction:({action:c,data:d})=>a.exec(c,d)}):n})}function xA(n){const{editor:a,onSave:r,onApply:l}=n,[c,d]=u.useState(a?.value||""),{type:m="text"}=u.useMemo(()=>a?.config||{},[a]),p=u.useRef(null);u.useEffect(()=>{p.current&&p.current.focus()},[]),u.useEffect(()=>{if(!p.current)return;const b=mi(p.current,()=>r(!0));return()=>b.destroy()},[r]);function g(){p.current&&(d(p.current.value),l(p.current.value))}function v({key:b}){b==="Enter"&&r()}return s.jsx("input",{className:"wx-e7Ao5ejY wx-text",onInput:g,onKeyDown:v,ref:p,type:m,value:c})}function yA({editor:n,onAction:a,onSave:r,onApply:l,onCancel:c}){const[d,m]=u.useState(n?.value),[p,g]=u.useState(n?.renderedValue),[v,b]=u.useState(n?.options||[]),y=u.useMemo(()=>n?.config?.template,[n]),w=u.useMemo(()=>n?.config?.cell,[n]),S=u.useMemo(()=>n?.config?.dropdown||{},[n]),j=u.useMemo(()=>({trackScroll:!0,...S}),[S]),N=u.useMemo(()=>(v||[]).findIndex(_=>_.id===d),[v,d]),M=u.useRef(null),k=u.useRef(null),E=u.useCallback(_=>{M.current=_.navigate,k.current=_.keydown,M.current(N)},[N,M]),R=u.useCallback(_=>{const L=_?.target?.value??"";g(L);const le=L?(n?.options||[]).filter(q=>(q.label||"").toLowerCase().includes(L.toLowerCase())):n?.options||[];b(le),le.length?M.current(-1/0):M.current(null)},[n]),U=u.useRef(null);u.useEffect(()=>{U.current&&U.current.focus()},[]);const H=u.useRef(r);u.useEffect(()=>{H.current=r},[r]),u.useEffect(()=>{if(!U.current)return;const _=mi(U.current,()=>H.current(!0));return()=>_.destroy()},[]),u.useEffect(()=>{m(n?.value),g(n?.renderedValue),b(n?.options||[])},[n]);const W=u.useCallback(({id:_})=>{l(_),r()},[l,r]);return s.jsxs(s.Fragment,{children:[s.jsx("input",{className:"wx-0UYfSd1x wx-input",ref:U,value:p??"",onChange:R,onKeyDown:_=>k.current?k.current(_,N):void 0}),s.jsx(wf,{items:v,onReady:E,onSelect:W,...j,onCancel:c,children:({option:_})=>y?y(_):w?s.jsx(w,{data:_,onAction:a}):_.label})]})}function bA({editor:n,onAction:a,onSave:r,onApply:l,onCancel:c}){const[d]=u.useState(()=>n.value||new Date),{template:m,cell:p,dropdown:g={}}=n?.config||{},v=u.useMemo(()=>({trackScroll:!0,width:"auto",...g}),[g]);function b({value:j}){l(j),r()}const y=u.useRef(null),[w,S]=u.useState(null);return u.useEffect(()=>{y.current&&y.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),u.useEffect(()=>{if(!w)return;const j=mi(w,()=>r(!0));return()=>j.destroy()},[w,r]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-lNWNYUb6 wx-value",ref:y,tabIndex:0,onClick:c,onKeyDown:j=>j.preventDefault(),children:m?m(d):p?s.jsx(p,{data:n.value,onAction:a}):s.jsx("span",{className:"wx-lNWNYUb6 wx-text",children:n.renderedValue})}),s.jsx(fp,{...v,onCancel:c,children:s.jsx("div",{ref:S,className:"wx-lNWNYUb6",children:s.jsx(Lb,{value:d,onChange:b,buttons:n.config?.buttons})})})]})}function wA(n){const{editor:a}=n,r=n.onAction??n.onaction,l=n.onSave??n.onsave,c=n.onApply??n.onapply,d=n.onCancel??n.oncancel,m=a.config||{},{dropdown:p={}}=m,g=u.useMemo(()=>({trackScroll:!0,...p}),[p]),[v]=u.useState(a.options.find(R=>R.id===a.value)),[b]=u.useState(a.value),[y]=u.useState(a.options),w=u.useMemo(()=>y.findIndex(R=>R.id===b),[y,b]);function S({id:R}){c(R),l()}let j;const[N,M]=u.useState();function k(R){j=R.navigate,M(()=>R.keydown),j(w)}const E=u.useRef(null);return u.useEffect(()=>{E.current&&E.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),u.useEffect(()=>{if(!E.current)return;const R=mi(E.current,()=>l(!0));return()=>R.destroy()},[l]),s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:E,className:"wx-ywGRk611 wx-value",tabIndex:0,onClick:d,onKeyDown:R=>{N(R,w),R.preventDefault()},children:m.template?m.template(v):m.cell?(()=>{const R=m.cell;return s.jsx(R,{data:v,onAction:r})})():s.jsx("span",{className:"wx-ywGRk611 wx-text",children:a.renderedValue})}),s.jsx(wf,{items:y,onReady:k,onSelect:S,...g,onCancel:d,children:({option:R})=>m.template?m.template(R):m.cell?(()=>{const U=m.cell;return s.jsx(U,{data:R,onAction:r})})():R.label})]})}function SA(n){const{editor:a,onAction:r,onSave:l,onApply:c}=n,d=a?.config||{},m=a?.options??[],p=a?.value||[],g=a?.renderedValue,v=u.useMemo(()=>({trackScroll:!0,...d.dropdown||{}}),[d]);function b({value:w}){c(w)}const y=u.useRef(null);return u.useEffect(()=>{if(!y.current)return;const w=mi(y.current,()=>l(!0));return()=>w.destroy()},[l]),s.jsx("div",{ref:y,className:"wx-value wx-aacZ4gNU",onClick:()=>l(!0),children:s.jsx(ew,{value:p,options:m,text:g,template:d.template,cell:d.cell,clear:d.clear,dropdown:v,autoOpen:!0,onChange:b,onAction:r})})}const CA={text:xA,combo:yA,datepicker:bA,richselect:wA,multiselect:SA};function jA({column:n,row:a}){const r=u.useContext(es),l=st(r,"editor"),c=u.useCallback((j,N)=>{r.exec("close-editor",{ignore:j}),N&&r.exec("focus-cell",{...N,eventSource:"click"})},[r]),d=u.useCallback(j=>{const N=j?null:{row:l?.id,column:l?.column};c(!1,N)},[l,c]),m=u.useCallback(()=>{c(!0,{row:l?.id,column:l?.column})},[l,c]),p=u.useCallback(j=>{r.exec("editor",{value:j})},[r]),g=u.useCallback(j=>{j.key==="Enter"&&l&&(n.editor.type==="multiselect"?p(l.value):m())},[l,n.editor,m,p]),v=u.useMemo(()=>Cf(n.width,n.flexgrow,n.fixed,n.left,n.right),[n.width,n.flexgrow,n.fixed,n.left,n.right]),b=u.useMemo(()=>{let j=n.editor;if(typeof j=="function"&&(j=j(a,n)),!j)return null;let N=typeof j=="string"?j:j.type;return CA[N]},[n,a]),y=u.useRef(null);u.useEffect(()=>{y.current&&typeof v=="string"&&y.current.setAttribute("style",v)},[v]);const w=typeof a.$parent<"u"?"gridcell":"cell",S=typeof a.$parent<"u"?!n.editor:void 0;return s.jsx("div",{className:"wx-8l724t2g wx-cell wx-editor",ref:y,style:typeof v=="object"&&v!==null?v:void 0,role:w,"aria-readonly":S,tabIndex:-1,onClick:j=>j.stopPropagation(),onDoubleClick:j=>j.stopPropagation(),onKeyDown:g,children:b?s.jsx(b,{editor:l,onSave:d,onApply:p,onCancel:m,onAction:({action:j,data:N})=>r.exec(j,N)}):null})}function uy(n){const{columns:a,type:r,columnStyle:l}=n,c=u.useContext(es),{filterValues:d,_columns:m,_sizes:p}=c.getState();function g(v){return l?" "+l(v):""}return s.jsx(s.Fragment,{children:a.map((v,b)=>s.jsx("tr",{children:v.map(y=>{const w=m.find(N=>N.id===y.id),S=`wx-print-cell-${r}${g(w)}${y.filter?" wx-print-cell-filter":""}${y.vertical?" wx-vertical":""}`,j=y.cell;return s.jsx("th",{style:Bb(Yb(y,p.columnWidth)),className:"wx-Gy81xq2u "+S,rowSpan:y.rowspan,colSpan:y.colspan,children:j?s.jsx(j,{api:c,cell:Object.fromEntries(Object.entries(y).filter(([N])=>N!=="cell")),column:w,row:b}):y.filter?s.jsx("div",{className:"wx-Gy81xq2u wx-print-filter",children:M1(d,m,y)}):s.jsx("div",{className:"wx-Gy81xq2u wx-text",children:y.text??""})},y.id)})},b))})}function kA(n){const{columns:a,rowStyle:r,columnStyle:l,cellStyle:c,header:d,footer:m,reorder:p}=n,g=u.useContext(es),{flatData:v,_sizes:b}=g.getState(),y=d&&ay(a,"header",b.headerRowHeights),w=m&&ay(a,"footer",b.footerRowHeights);function S(N,M){let k="";return k+=l?" "+l(M):"",k+=c?" "+c(N,M):"",k}function j(N,M){return typeof M.draggable=="function"?M.draggable(N,M)!==!1:M.draggable}return s.jsxs("table",{className:`wx-8NTMLH0z wx-print-grid ${a.some(N=>N.flexgrow)?"wx-flex-columns":""}`,children:[d?s.jsx("thead",{children:s.jsx(uy,{columns:y,type:"header",columnStyle:l})}):null,s.jsx("tbody",{children:v.map((N,M)=>s.jsx("tr",{className:"wx-8NTMLH0z wx-row"+(r?" "+r(N):""),style:{height:`${N.rowHeight||b.rowHeight}px`},children:a.map(k=>k.collapsed?null:s.jsxs("td",{className:`wx-8NTMLH0z wx-print-cell wx-cell ${S(N,k)}`,style:Bb(Yb(k,b.columnWidth)),children:[p&&k.draggable?s.jsx("span",{className:"wx-8NTMLH0z wx-print-draggable",children:j(N,k)?s.jsx("i",{className:"wx-8NTMLH0z wxi-drag"}):null}):null,k.treetoggle?s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{marginLeft:N.$level*28+"px"}}),N.$count?s.jsx("i",{className:`wx-8NTMLH0z wx-print-grid-tree-toggle wxi-menu-${N.open!==!1?"down":"right"}`}):null]}):null,k.cell?(()=>{const E=k.cell;return s.jsx(E,{api:g,row:N,column:k})})():s.jsx("span",{children:Gr(N,k)})]},k.id))},M))}),m?s.jsx("tfoot",{children:s.jsx(uy,{columns:w,type:"footer",columnStyle:l})}):null]})}function AA(n){const{config:a,...r}=n,l=u.useContext(es),{_skin:c,_columns:d}=l.getState(),m=u.useMemo(()=>j1(d,a),[]),p=u.useRef(null);return u.useEffect(()=>{const g=document.body;g.classList.add("wx-print");const v=p.current;if(!v)return;const b=v.cloneNode(!0);g.appendChild(b);const y=`@media print { @page { size: ${a.paper} ${a.mode}; }`,w=document.createElement("style");w.setAttribute("type","text/css"),w.setAttribute("media","print"),document.getElementsByTagName("head")[0].appendChild(w),w.appendChild(document.createTextNode(y)),window.print(),w.remove(),g.classList.remove("wx-print"),b.remove()},[]),s.jsx("div",{className:`wx-4zwCKA7C wx-${c}-theme wx-print-container`,ref:p,children:m.map((g,v)=>s.jsx("div",{className:"wx-4zwCKA7C wx-print-grid-wrapper",children:s.jsx(kA,{columns:g,...r})},v))})}function NA(n){const{header:a,footer:r,overlay:l,multiselect:c,onreorder:d,rowStyle:m,columnStyle:p,cellStyle:g,autoRowHeight:v,resize:b,clientWidth:y,clientHeight:w,responsiveLevel:S,hotkeys:j}=n,N=u.useContext(es),M=st(N,"dynamic"),k=st(N,"_columns"),E=st(N,"flatData"),R=st(N,"split"),U=st(N,"_sizes"),[H,W]=ys(N,"selectedRows"),_=st(N,"select"),L=st(N,"editor"),le=st(N,"scrollLeft"),q=st(N,"scrollTop"),te=st(N,"tree"),K=st(N,"focusCell"),ne=st(N,"_print"),ce=st(N,"undo"),V=st(N,"reorder"),O=st(N,"_rowHeightFromData"),[Y,X]=u.useState(0);u.useEffect(()=>{X(ft())},[]);const[P,oe]=u.useState(0),we=u.useMemo(()=>(k||[]).some(ee=>!ee.hidden&&ee.flexgrow),[k]),J=u.useMemo(()=>U?.rowHeight||0,[U]),B=u.useRef(null),[pe,ge]=u.useState(null),[xe,Ae]=u.useState(null),_e=u.useMemo(()=>{let ee=[],Te=0;return R&&R.left&&(ee=(k||[]).slice(0,R.left).filter(qe=>!qe.hidden).map(qe=>({...qe})),ee.forEach(qe=>{qe.fixed={left:1,leftSize:R.left},qe.left=Te,Te+=qe.width}),ee.length&&(ee[ee.length-1].fixed.left=-1)),{columns:ee,width:Te}},[R,k]),ie=u.useMemo(()=>{let ee=[],Te=0;if(R&&R.right){ee=(k||[]).slice(R.right*-1).filter(qe=>!qe.hidden).map(qe=>({...qe}));for(let qe=ee.length-1;qe>=0;qe--){const it=ee[qe];it.fixed={right:1},it.right=Te,Te+=it.width}ee.length&&(ee[0].fixed={right:-1})}return{columns:ee,width:Te}},[R,k]),Q=u.useMemo(()=>{const ee=(k||[]).slice(R?.left||0,(k||[]).length-(R?.right??0)).filter(Te=>!Te.hidden);return ee.forEach(Te=>{Te.fixed=0}),ee},[k,R]),Ie=u.useMemo(()=>(k||[]).reduce((ee,Te)=>(Te.hidden||(ee+=Te.width),ee),0),[k]),Oe=1;function ae(ee,Te,qe){let it=Te,Kt=ee;if(Q.length){let Tt=Q.length;for(let Ze=ee;Ze>=0;Ze--)Q[Ze][qe].forEach(lt=>{lt.colspan>1&&Ze>ee-lt.colspan&&Ze<Tt&&(Tt=Ze)});if(Tt!==Q.length&&Tt<ee){for(let Ze=Tt;Ze<ee;Ze++)it-=Q[Ze].width;Kt=Tt}}return{index:Kt,delta:it}}const ke=u.useMemo(()=>{let ee,Te,qe;const it=le||0,Kt=(le||0)+(y||0);let Tt=0,Ze=0,lt=0,Qt=0;Q.forEach((un,Xt)=>{it>lt&&(Tt=Xt,Qt=lt),lt=lt+un.width,Kt>lt&&(Ze=Xt+Oe)});const $t={header:0,footer:0};for(let un=Ze;un>=Tt;un--)["header","footer"].forEach(Xt=>{Q[un]&&Q[un][Xt].forEach(bs=>{const ws=bs.colspan;if(ws&&ws>1){const pi=ws-(Ze-un+1);pi>0&&($t[Xt]=Math.max($t[Xt],pi))}})});const _t=ae(Tt,Qt,"header"),Ft=ae(Tt,Qt,"footer"),Ut=_t.delta,zt=_t.index,gn=Ft.delta,ss=Ft.index;return we&&Ie>(y||0)?ee=Te=qe=[..._e.columns,...Q,...ie.columns]:(ee=[..._e.columns,...Q.slice(Tt,Ze+1),...ie.columns],Te=[..._e.columns,...Q.slice(zt,Ze+$t.header+1),...ie.columns],qe=[..._e.columns,...Q.slice(ss,Ze+$t.footer+1),...ie.columns]),{data:ee||[],header:Te||[],footer:qe||[],d:Qt,df:gn,dh:Ut}},[Q,_e,ie,le,y,we,Ie]),je=u.useMemo(()=>a&&U?.headerHeight||0,[a,U]),De=u.useMemo(()=>r&&U?.footerHeight||0,[r,U]),Le=u.useMemo(()=>y&&w?Ie>=y:!1,[y,w,Ie]),[$e,he]=u.useState(!1),Me=u.useMemo(()=>(w||0)-je-De-(Le?Y:0),[w,je,De,Le,Y]),de=u.useMemo(()=>Math.ceil((Me||0)/(J||1))+1,[Me,J]),be=u.useRef([]),[We,at]=u.useState(0),[wn,Xe]=u.useState(void 0),ht=u.useMemo(()=>{let ee=0,Te=0;const qe=2,it=q||0;if(v){let Ze=it;for(;Ze>0;)Ze-=be.current[ee]||J,ee++;Te=it-Ze;for(let lt=Math.max(0,ee-qe-1);lt<ee;lt++)Te-=be.current[ee-lt]||J;ee=Math.max(0,ee-qe)}else{if(O){let Ze=0,lt=0;for(let Ft=0;Ft<(E||[]).length;Ft++){const Ut=E[Ft].rowHeight||J;if(lt+Ut>it){Ze=Ft;break}lt+=Ut}ee=Math.max(0,Ze-qe);for(let Ft=0;Ft<ee;Ft++)Te+=E[Ft].rowHeight||J;let Qt=0,$t=0;for(let Ft=Ze+1;Ft<(E||[]).length;Ft++){const Ut=E[Ft].rowHeight||J;if(Qt++,$t+Ut>Me)break;$t+=Ut}const _t=Math.min(M?M.rowCount:(E||[]).length,Ze+Qt+qe);return{d:Te,start:ee,end:_t}}ee=Math.floor(it/(J||1)),ee=Math.max(0,ee-qe),Te=ee*(J||0)}const Kt=M?M.rowCount:(E||[]).length,Tt=Math.min(Kt,ee+(de||0)+qe);return{d:Te,start:ee,end:Tt}},[v,O,q,J,M,E,de,Me]),St=u.useMemo(()=>{const ee=M?M.rowCount:(E||[]).length;if(v)return We+ht.d+(ee-(wn||0))*(J||0);if(!O)return ee*(J||0);let Te=0;for(let qe=0;qe<ee;qe++)Te+=E[qe]?.rowHeight||J;return Te},[M,E,J,v,O,We,ht.d,wn]),Rn=u.useRef({});Rn.current={clientWidth:y,clientHeight:w,fullHeight:St,headerHeight:je,footerHeight:De,fullWidth:Ie,SCROLLSIZE:Y};const He=u.useCallback(()=>{const ee=Rn.current;he(ee.clientWidth&&ee.clientHeight?ee.fullHeight+ee.headerHeight+ee.footerHeight>=ee.clientHeight-(ee.fullWidth>=ee.clientWidth?ee.SCROLLSIZE:0):!1)},[]);u.useEffect(()=>{const ee=requestAnimationFrame(He);return()=>window.cancelAnimationFrame(ee)},[P,He]),u.useEffect(()=>{He()},[w,He]);const Ct=u.useMemo(()=>we&&Ie<=(y||0)?(y||0)-0-($e?Y:0):Ie,[we,Ie,y,$e,Y,Le]),Gt=u.useMemo(()=>we&&Ie<=(y||0)?y||0:Ct<(y||0)?Ie+($e?Y:0):-1,[we,Ie,y,Ct,$e,Y]),pt=u.useRef({});u.useEffect(()=>{if(M&&(pt.current.start!==ht.start||pt.current.end!==ht.end)){const{start:ee,end:Te}=ht;pt.current={start:ee,end:Te},N&&N.exec&&N.exec("request-data",{row:{start:ee,end:Te}})}},[M,ht,N]);const rt=u.useMemo(()=>M?E||[]:(E||[]).slice(ht.start,ht.end),[M,E,ht]),tn=u.useMemo(()=>(H||[]).filter(ee=>(rt||[]).some(Te=>Te.id===ee)),[W,rt]),kt=u.useMemo(()=>ht.start,[ht.start]),ze=u.useRef({top:q,left:le});ze.current={top:q,left:le};const Dn=u.useCallback(ee=>{const Te=ee.target.scrollTop,qe=ee.target.scrollLeft,it=ze.current;(Te!==it.top||qe!==it.left)&&N.exec("scroll-to",{top:Te,left:qe})},[N]),Zi=u.useCallback(ee=>{ee.shiftKey&&ee.preventDefault(),B.current&&B.current.focus&&B.current.focus()},[]),hn=u.useCallback(()=>!!(k||[]).find(ee=>!!ee.draggable),[k]),$n=u.useRef(null),ga=u.useRef(null),ts=u.useRef({dblclick:(ee,Te)=>{const qe={id:ee,column:iu(Te,"data-col-id")};N.exec("open-editor",qe)},click:(ee,Te)=>{if(Te.target.closest("input")||$n.current)return;const qe=iu(Te,"data-col-id");if(K?.id!==ee&&N.exec("focus-cell",{row:ee,column:qe,eventSource:"click"}),_===!1)return;const it=c&&(Te.ctrlKey||Te.metaKey),Kt=c&&Te.shiftKey;(it||H.length>1||!H.includes(ee))&&N.exec("select-row",{id:ee,toggle:it,range:Kt})},"toggle-row":ee=>{const Te=N.getRow(ee);N.exec(Te.open!==!1?"close-row":"open-row",{id:ee})},"ignore-click":()=>!1}),Ln=u.useMemo(()=>({top:je,bottom:De,left:_e.width,xScroll:Le,yScroll:$e,sense:v&&xe?xe.offsetHeight:Math.max(U?.rowHeight||0,40),node:B.current&&B.current.firstElementChild}),[je,De,_e.width,Le,$e,v,xe,U]);function ns(ee,Te){const{container:qe,sourceNode:it,from:Kt}=Te;if(hn()&&!it.getAttribute("draggable-data"))return!1;ge(Kt),te&&N.getRow(Kt).open&&N.exec("close-row",{id:Kt,nested:!0});const Tt=Fo(it),Ze=Tt.cloneNode(!0);Ze.classList.remove("wx-selected"),Ze.querySelectorAll("[tabindex]").forEach(_t=>_t.setAttribute("tabindex","-1")),qe.appendChild(Ze),Ae(Ze);const lt=(le||0)-ke.d,Qt=$e?Y:0;qe.style.width=Math.min((y||0)-Qt,we&&Ie<=(y||0)?Ct:Ct-Qt)+lt+"px";const $t=Zd(Tt);Te.offset={x:lt,y:-Math.round($t.height/2)},ga.current||(ga.current=ee.clientY)}function Be(ee,Te){const{from:qe}=Te,it=Te.pos,Kt=Zd(B.current);it.x=Kt.x;const Tt=Ln.top;if(it.y<Tt)it.y=Tt;else{const Ze=Kt.height-(Le&&Y>0?Y:Math.round(Ln.sense/2))-Ln.bottom;it.y>Ze&&(it.y=Ze)}if(B.current.contains(Te.targetNode)){const Ze=Fo(Te.targetNode),lt=Ze&&yf(Ze);if(lt&<!==qe){Te.to=lt;const Qt=v?xe?.offsetHeight:U?.rowHeight;if(xe&&((q||0)===0||it.y>Tt+Qt-1)){const $t=Ze.getBoundingClientRect(),_t=Zd(xe).y,Ft=$t.y,Ut=_t>Ft?-1:1,zt=Ut===1?"after":"before",gn=N.getState().flatData,ss=Math.abs(gn.findIndex(Xt=>Xt.id===qe)-gn.findIndex(Xt=>Xt.id===lt)),un=ss!==1?zt==="before"?"after":"before":zt;if(ss===1&&(Ut===-1&&ee.clientY>ga.current||Ut===1&&ee.clientY<ga.current))return;ga.current=ee.clientY,N.exec("move-item",{id:qe,target:lt,mode:un,inProgress:!0})}}d&&d({event:ee,context:Te})}aA(ee,Kt,Te,Ln)}function hi(ee,Te){const{from:qe,to:it}=Te;N.exec("move-item",{id:qe,target:it,inProgress:!1}),$n.current=setTimeout(()=>{$n.current=0},1),ge(null),Ae(null),ga.current=null,Xb(Te)}function ft(){const ee=document.createElement("div");ee.style.cssText="position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;min-height:100px;overflow-y:scroll;",document.body.appendChild(ee);const Te=ee.offsetWidth-ee.clientWidth;return document.body.removeChild(ee),Te}const as=u.useMemo(()=>Gt>0?{width:`${Gt}px`}:void 0,[Gt]),Vt=u.useRef(null);function Bs(){Promise.resolve().then(()=>{let ee=0,Te=kt;const qe=Vt.current;qe&&(Array.from(qe.children).forEach((it,Kt)=>{be.current[kt+Kt]=it.offsetHeight,ee+=it.offsetHeight,Te++}),at(ee),Xe(Te))})}u.useEffect(()=>{rt&&v&&Bs()},[rt,v,kt]);let[I,Fe]=u.useState();u.useEffect(()=>{if(K&&(!_||!tn.length||tn.includes(K.row)))Fe({...K});else if(rt.length&&ke.data.length){if(!I||tn.length&&!tn.includes(I.row)||rt.findIndex(ee=>ee.id===I.row)===-1||ke.data.findIndex(ee=>ee.id===I.column&&!ee.collapsed)===-1){const ee=tn[0]||rt[0].id,Te=ke.data.findIndex(qe=>!qe.collapsed);Fe(Te!==-1?{row:ee,column:ke.data[Te].id}:null)}}else Fe(null)},[K]);const mt=u.useRef(null);u.useEffect(()=>{const ee=B.current;if(!ee)return;const Te=Z1(ee,b);return()=>{typeof Te=="function"&&Te()}},[b]);const nn=u.useRef({});Object.assign(nn.current,{start:ns,move:Be,end:hi,getReorder:()=>V,getDraggableInfo:()=>({hasDraggable:hn()})}),u.useEffect(()=>{const ee=B.current;return ee?eA(ee,nn).destroy:void 0},[V,B.current]),u.useEffect(()=>{const ee=B.current;return ee?Q1(ee,{keys:j!==!1&&{...K1,"ctrl+z":ce,"ctrl+y":ce,...j},exec:Te=>N.exec("hotkey",Te)}).destroy:void 0},[N,ce,j]);const pn=u.useRef({scroll:N.getReactiveState().scroll,scrollLeft:N.getReactiveState().scrollLeft,scrollTop:N.getReactiveState().scrollTop});pn.current.getWidth=()=>(y||0)-($e?Y:0),pn.current.getHeight=()=>Me,pn.current.getScrollMargin=()=>_e.width+ie.width,u.useEffect(()=>{X1(mt.current,pn.current)},[]);const Fs=u.useRef(null);u.useEffect(()=>{const ee=Fs.current;if(!ee)return;const Te=[];Te.push(mi(ee,()=>K&&N.exec("focus-cell",{eventSource:"click"})).destroy),Te.push(e1(ee,ts.current)),oe(ee.clientHeight);const qe=new ResizeObserver(()=>{oe(ee.clientHeight)});return qe.observe(ee),Te.push(()=>qe.disconnect()),()=>Te.forEach(it=>it())},[]);const ra=`wx-grid ${S?`wx-responsive-${S}`:""}`;return u.useEffect(()=>{K&&(rt.some(ee=>ee.id===K.row)&&ke.data.some(ee=>ee.id===K.column&&!ee.collapsed)||N.exec("focus-cell",{eventSource:"destroy"}))},[K,rt,ke.data,N]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-4VuBwK2D "+ra,style:{"--header-height":`${je}px`,"--footer-height":`${De}px`,"--split-left-width":`${_e.width}px`,"--split-right-width":`${ie.width}px`},children:s.jsx("div",{ref:B,className:"wx-4VuBwK2D wx-table-box",style:as,role:te?"treegrid":"grid","aria-colcount":ke.data.length,"aria-rowcount":rt.length,"aria-multiselectable":te&&c?!0:void 0,tabIndex:-1,children:s.jsxs("div",{ref:mt,className:"wx-4VuBwK2D wx-scroll",style:{overflowX:Le?"scroll":"hidden",overflowY:$e?"scroll":"hidden"},onScroll:Dn,children:[a?s.jsx("div",{className:"wx-4VuBwK2D wx-header-wrapper",children:s.jsx(cy,{contentWidth:Ct,deltaLeft:ke.dh,columns:ke.header,columnStyle:p,bodyHeight:Me-+r})}):null,s.jsxs("div",{ref:Fs,className:"wx-4VuBwK2D wx-body",style:{width:`${Ct}px`,height:`${St}px`},onMouseDown:ee=>Zi(ee),children:[l?s.jsx(vA,{overlay:l}):null,s.jsx("div",{ref:Vt,className:"wx-4VuBwK2D wx-data",style:{paddingTop:`${ht.d}px`,paddingLeft:`${ke.d}px`},children:rt.map((ee,Te)=>{const qe=H.indexOf(ee.id)!==-1,it=pe===ee.id,Kt="wx-row"+(v?" wx-autoheight":"")+(m?" "+m(ee):"")+(qe?" wx-selected":"")+(it?" wx-inactive":""),Tt=v?{minHeight:`${ee.rowHeight||J}px`}:{height:`${ee.rowHeight||J}px`};return s.jsx("div",{className:"wx-4VuBwK2D "+Kt,"data-id":Bn(ee.id),"data-context-id":Bn(ee.id),style:Tt,role:"row","aria-rowindex":Te,"aria-expanded":ee.open,"aria-level":te?ee.$level+1:void 0,"aria-selected":te?qe:void 0,tabIndex:-1,children:ke.data.map(Ze=>Ze.collapsed?s.jsx("div",{className:"wx-4VuBwK2D wx-cell wx-collapsed"},Ze.id):L?.id===ee.id&&L.column===Ze.id?s.jsx(jA,{row:ee,column:Ze},Ze.id):s.jsx(oA,{row:ee,column:Ze,columnStyle:p,cellStyle:g,reorder:V,focusable:I?.row===ee.id&&I?.column===Ze.id},Ze.id))},ee.id)})})]}),r&&(E||[]).length?s.jsx(cy,{type:"footer",contentWidth:Ct,deltaLeft:ke.df,columns:ke.footer,columnStyle:p}):null]})})}),ne?s.jsx(AA,{config:ne,rowStyle:m,columnStyle:p,cellStyle:g,header:a,footer:r,reorder:V}):null]})}const MA=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join(""),TA=u.forwardRef(function({data:n=[],columns:a=[],rowStyle:r=null,columnStyle:l=null,cellStyle:c=null,selectedRows:d,select:m=!0,multiselect:p=!1,header:g=!0,footer:v=!1,dynamic:b=null,overlay:y=null,reorder:w=!1,onReorder:S=null,autoRowHeight:j=!1,sizes:N,split:M,tree:k=!1,autoConfig:E=!1,init:R=null,responsive:U=null,sortMarks:H,undo:W=!1,hotkeys:_=null,filterValues:L,...le},q){const te=u.useRef();te.current=le;const K=u.useMemo(()=>new U1(Fb),[]),ne=u.useMemo(()=>K.in,[K]),ce=u.useRef(null);ce.current===null&&(ce.current=new _b((ie,Q)=>{const Ie="on"+MA(ie);te.current&&te.current[Ie]&&te.current[Ie](Q)}),ne.setNext(ce.current));const V=u.useMemo(()=>({getState:K.getState.bind(K),getReactiveState:K.getReactive.bind(K),getStores:()=>({data:K}),exec:ne.exec,setNext:ie=>(ce.current=ce.current.setNext(ie),ce.current),intercept:ne.intercept.bind(ne),on:ne.on.bind(ne),detach:ne.detach.bind(ne),getRow:K.getRow.bind(K),getColumn:K.getColumn.bind(K)}),[K,ne]),[O,Y]=u.useState(0),[X,P]=u.useState(0),[oe,we]=u.useState(null),[J,B]=u.useState(null),pe=u.useMemo(()=>{if(E&&!a.length&&n.length){const ie=n[0],Q=[];for(let Ie in ie)if(Ie!=="id"&&Ie[0]!=="$"){let Oe={id:Ie,header:Ie[0].toUpperCase()+Ie.slice(1)};typeof E=="object"&&(Oe={...Oe,...E}),Q.push(Oe)}return Q}return(J&&J.columns)??a},[E,a,n,J]),ge=u.useMemo(()=>(J&&J.sizes)??N,[J,N]),xe=u.useCallback(ie=>{if(Y(ie.width),P(ie.height),U){const Q=Object.keys(U).map(Number).sort((Ie,Oe)=>Ie-Oe).find(Ie=>ie.width<=Ie)??null;Q!==oe&&(B(U[Q]),we(Q))}},[U,oe]),Ae=u.useContext(Pn.theme),_e=u.useRef(0);return u.useEffect(()=>{if(!_e.current)R&&R(V);else{const ie=K.getState();K.init({data:n,columns:pe,split:M||ie.split,sizes:ge||ie.sizes,selectedRows:d||ie.selectedRows,dynamic:b,tree:k,sortMarks:H||ie.sortMarks,filterValues:L||ie.filterValues,undo:W,reorder:w,_skin:Ae,_select:m})}_e.current++},[K,n,pe,M,ge,d,b,k,H,L,W,w,Ae,m,R,V]),_e.current===0&&K.init({data:n,columns:pe,split:M||{left:0},sizes:ge||{},selectedRows:d||[],dynamic:b,tree:k,sortMarks:H||{},filterValues:L||{},undo:W,reorder:w,_skin:Ae,select:m}),u.useImperativeHandle(q,()=>({...V}),[V]),s.jsx(es.Provider,{value:V,children:s.jsx(pp,{words:gp,optional:!0,children:s.jsx(NA,{header:g,footer:v,overlay:y,rowStyle:r,columnStyle:l,cellStyle:c,onReorder:S,multiselect:p,autoRowHeight:j,clientWidth:O,clientHeight:X,responsiveLevel:oe,resize:xe,hotkeys:_})})})});op(Ia);const Fn=u.createContext(null),yp=u.createContext(null),bp=u.createContext(null);function EA({children:n}){const a=u.useContext(Pn.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),l=u.useContext(Fn),[c]=ys(l,"panels"),d=st(l,"activePanel"),m=c[d].path,[p,g]=u.useState(null),[v,b]=u.useState(null),[y,w]=u.useState(""),[S,j]=u.useState(""),[N,M]=u.useState(!1);function k(){const H=y.trim();if(!H){M(!0);return}p.add?l.exec("create-file",{file:{...p.item,name:H},parent:m}):S!==H&&l.exec("rename-file",{id:p.item.id,name:H}),E()}function E(){g(null),M(null),j(""),w("")}function R(){l.exec("delete-files",{ids:v.selected}),b(null)}const U=u.useMemo(()=>({showPrompt(H){const W=H.item.name||(H.item.type==="folder"?r("New folder"):`${r("New file")}.txt`);j(W),w(W),g({...H})},showConfirm(H){b({...H})}}),[r]);return s.jsxs(yp.Provider,{value:U,children:[s.jsx(Ek,{children:n}),p?s.jsx(Hh,{title:r(`Enter ${p.item.type} name`),onConfirm:k,onCancel:E,children:s.jsx(mp,{error:N,select:!0,focus:!0,value:y,onChange:({value:H})=>w(H)})}):null,v?s.jsx(Hh,{title:r("Are you sure you want to delete these items:"),onConfirm:R,onCancel:()=>b(null),children:v.selected?s.jsx("ul",{className:"wx-gq7BMzEP wx-list",children:v.selected.map((H,W)=>s.jsx("li",{children:H},W))}):null}):null]})}let dy={"7z":!0,rar:!0,zip:!0,css:!0,html:!0,js:!0,php:!0,md:!0,xml:!0,sql:!0,aif:!0,mid:!0,mp3:!0,waw:!0,wma:!0,doc:!0,docx:!0,txt:!0,avi:!0,mov:!0,mp4:!0,mpeg:!0,mpg:!0,pdf:!0,xls:!0,xlsx:!0,gif:!0,jpg:!0,jpeg:!0,png:!0,psd:!0,tiff:!0,svg:!0,folder:!0,file:!0,multiple:!0,search:!0,none:!0};function RA(n){const a=n.lastIndexOf("."),r=a>0&&a<n.length-1?Math.min(10,n.length-a):Math.min(5,n.length),l=n.slice(0,-r),c=n.slice(-r);return[l,c]}function DA({item:n}){const a=u.useContext(Fn),r=u.useContext(Pn.i18n).getGroup("filemanager"),l=u.useContext(Fn).templates,[c]=ys(a,"panels"),d=st(a,"activePanel"),m=st(a,"mode"),p=c[d].selected,g=u.useMemo(()=>l.preview(n,214,163),[l,n]),v=u.useMemo(()=>l.icon(n,"big"),[l,n]),[b,y]=u.useMemo(()=>RA(n.name),[n.name]);return s.jsx(s.Fragment,{children:n.id==="/wx-filemanager-parent-link"?m!=="search"?s.jsx("div",{className:"wx-GAOa4kDV wx-back-item",children:s.jsxs("div",{className:`wx-GAOa4kDV wx-back ${n.navigation?"wx-selected":""}`,"data-id":Bn("/wx-filemanager-parent-link"),children:[s.jsx("i",{className:"wx-GAOa4kDV wxi-arrow-left"}),s.jsx("span",{children:r("Back to parent folder")})]})}):null:s.jsxs("div",{className:`wx-GAOa4kDV wx-item ${p?.length&&p.indexOf(n.id)>=0?"wx-selected":""}`,"data-id":Bn(n.id),children:[g?s.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-preview",children:s.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:r("A miniature file preview"),src:g})}):v?s.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-icon",children:s.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:"",src:v})}):s.jsx("div",{className:"wx-GAOa4kDV wx-preview",children:s.jsx("i",{className:`wx-GAOa4kDV wxi-${n.type}`})}),n.type==="folder"?s.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[s.jsxs("div",{className:"wx-GAOa4kDV wx-folder-name",children:[s.jsx("span",{className:"wx-GAOa4kDV wx-type",children:r("Folder")}),s.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[s.jsx("span",{children:b}),s.jsx("span",{children:y})]})]}),s.jsx("div",{"data-action-id":Bn(n.id),className:"wx-GAOa4kDV wx-more",children:s.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]}):s.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[s.jsx("div",{className:"wx-GAOa4kDV wx-file-name",children:s.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[s.jsx("span",{children:b}),s.jsx("span",{children:y})]})}),s.jsx("div",{"data-action-id":Bn(n.id),className:"wx-GAOa4kDV wx-more",children:s.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]})]})})}function tw(){const n=u.useContext(Fn),a=u.useContext(Pn.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),[l]=ys(n,"panels"),c=st(n,"activePanel"),d=st(n,"mode"),m=l[c]._files,p=l[c].selected,g=l[c].path,v=l[c]._crumbs,b=l[c]._selectNavigation,y=u.useCallback((E,R)=>{const U=R&&(R.ctrlKey||R.metaKey),H=R&&R.shiftKey;if(E==="/wx-filemanager-parent-link"){if(p.length&&(U||H))return;n.exec("select-file",{type:"navigation"});return}let W=E==="body"&&R?null:E;const _=R.target.className.indexOf("wx-more")!==-1||R.target.className.indexOf("wxi-dots-v")!==-1;setTimeout(()=>{n.exec("select-file",{id:W,toggle:U&&!_,range:H&&!_,panel:c})},1)},[n,p,c]),w=u.useCallback(()=>{v.length>1&&n.exec("set-path",{id:v[v.length-2].id,panel:c,selected:[v[v.length-1].id]})},[n,v,c]),S=u.useCallback(E=>{if(E==="/wx-filemanager-parent-link")return w();d==="search"&&n.exec("filter-files",{text:""});const R=m.find(U=>U.id===E);R&&(R.type=="folder"?n.exec("set-path",{id:R.id,panel:c}):n.exec("open-file",{id:R.id}))},[n,w,d,m,c]),j=u.useCallback((E,R)=>{(!p?.length||!p.filter(U=>U?.id===E).length>0)&&y(E,R)},[p,y]),N=u.useMemo(()=>g!=="/"?[{id:"/wx-filemanager-parent-link",name:r("Back to parent folder"),navigation:b},...m]:m,[g,r,b,m]),M=u.useRef(null),k=u.useRef();return u.useEffect(()=>{M.current&&(k.current?(k.current.click=y,k.current._dblclick=S,k.current.context=j):(k.current={click:y,dblclick:E=>k.current._dblclick(E),_dblclick:S,context:j},Po(M.current,k.current)))},[y,S,j]),d=="search"&&!N.length?s.jsx("div",{className:"wx-iyjASZCY wx-not-found",children:s.jsx("div",{className:"wx-iyjASZCY wx-not-found-text",children:r("Looks like nothing is here")})}):s.jsx("div",{tabIndex:0,className:"wx-iyjASZCY "+("wx-cards"+(g!=="/"&&d!=="search"?" wx-has-back-link":"")),"data-id":Bn("body"),ref:M,children:N.map(E=>s.jsx(DA,{item:E},E.id))})}function Bl({name:n="",spin:a=!1,onClick:r}){return s.jsx("i",{"data-menu-ignore":"true",className:`wx-uwcvNSAG wx-icon wxi-${n} ${a?"wx-spin":""} ${r?"wx-clickable":""}`,onClick:()=>{r&&r()}})}function LA(){const n=u.useContext(Pn.i18n).getGroup("filemanager"),a=u.useContext(Fn),r=st(a,"activePanel"),[l]=ys(a,"panels"),c=u.useMemo(()=>l[r]._crumbs,[l,r]);function d(){a.exec("filter-files",{text:""})}return s.jsxs("div",{className:"wx-GDJvtROw wx-search",children:[s.jsxs("div",{className:"wx-GDJvtROw wx-toolbar",children:[s.jsx("div",{className:"wx-GDJvtROw wx-back-icon",children:s.jsx(Bl,{name:"angle-left",onClick:d})}),s.jsxs("div",{className:"wx-GDJvtROw wx-text",children:[n("Search results in")," ",Array.isArray(c)&&c.map((m,p)=>s.jsxs(u.Fragment,{children:[p?"/":null,m.id=="/"?n(m.name):m.name]},p))]})]}),s.jsx(tw,{})]})}function oh({narrowMode:n,extraInfo:a}){const r=u.useContext(Fn),{preview:l,icon:c}=r.templates,d=u.useContext(Pn.i18n),m=u.useMemo(()=>d.getGroup("filemanager"),[d]),p=u.useMemo(()=>zo("%D, %d %F %Y, %H:%i",d.getRaw().calendar),[d]),[g,v]=ys(r,"panels"),b=st(r,"activePanel"),y=st(r,"preview"),w=st(r,"search"),S=u.useMemo(()=>{const _=g&&b!=null&&g[b]?._selected?.length||0;return w&&!_},[w,v,b]),j=u.useMemo(()=>{const _=g&&b!=null?g[b]:null;return _?S?_._files:_._selected:[]},[S,v,b]),N=u.useCallback((_,L)=>(_?`${_} ${m(_>1?"folders":"folder")} `:"")+(L?`${L} ${m(L>1?"files":"file")}`:""),[m]),M=u.useCallback(()=>{r.exec("show-preview",{mode:!y})},[r,y]),k=u.useCallback(_=>_.type==="folder"?m("Folder"):_.ext||m("Unknown file"),[m]),E=u.useMemo(()=>{let _,L,le,q,te,K,ne,ce;if(j.length===1&&!S){L=j[0],_=L.name;const V=l(L,400,500);V?(le=V,q=""):(q=c(L,"big"),le=""),te=L.type!=="folder"}else{if(L=te=null,_="",j.length){let V=0,O=0,Y=0,X=[],P;j.forEach(we=>{typeof we.size>"u"&&(P=!0,V=void 0),P||(V+=we.size),X.push(k(we)),we.type==="folder"?O++:Y++});const oe=new Set(X);K=oe.size>1?m("multiple"):[...oe][0],ne=N(O,Y),ce=V,S||(_=m("Multiple files"))}q=c({type:S?"search":j.length?"multiple":"none"},"big"),le=""}return{name:_,item:L,previewSrc:le,iconSrc:q,showDownloadIcon:te,type:K,totalCount:ne,totalSize:ce}},[j,S,l,c,m,k,N]),R=u.useCallback(()=>{r.exec("download-file",{id:j[0].id})},[r,j]),U=u.useCallback(async _=>{if(!a||!_)return null;try{return await a(_)}catch(L){return console.log(L),null}},[a]),[H,W]=u.useState(null);return u.useEffect(()=>{let _=!1;return W(null),Promise.resolve(U(E.item)).then(L=>{_||W(L)}).catch(()=>{_||W(null)}),()=>{_=!0}},[U,E.item]),s.jsx("div",{className:"wx-O0BTtRrH wx-wrapper",children:j&&j.length?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"wx-O0BTtRrH wx-preview",children:[s.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[s.jsx("div",{className:"wx-O0BTtRrH wx-name",children:E.name}),s.jsxs("div",{className:"wx-O0BTtRrH wx-icons",children:[E.showDownloadIcon?s.jsx(Bl,{name:"download",onClick:R}):null,n?s.jsx(Bl,{name:"close",onClick:M}):null]})]}),E.previewSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:s.jsx("img",{src:E.previewSrc,alt:m("A miniature file preview")})}):E.iconSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("img",{src:E.iconSrc,alt:m("A miniature file preview")})}):s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:E.item?s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${E.item.type}`}):s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${S?"search":"file-multiple-outline"}`})})]}),s.jsxs("div",{className:"wx-O0BTtRrH wx-info-panel",children:[s.jsx("div",{className:"wx-O0BTtRrH wx-title",children:m(S?"Found":"Information")}),s.jsxs("div",{className:"wx-O0BTtRrH wx-list",children:[E.item?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Type")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:k(E.item)}),typeof E.item.size<"u"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Size")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:ru(E.item.size)})]}):null,s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Date")}),s.jsxs("span",{className:"wx-O0BTtRrH wx-value",children:[p(E.item.date)," "]})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Count")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:E.totalCount}),s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Type")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:E.type}),typeof E.totalSize<"u"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Size")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:ru(E.totalSize)})]}):null]}),H?Object.entries(H).map(([_,L])=>s.jsxs(Jh.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:_}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:L})]},_)):null]})]})]}):s.jsxs("div",{className:"wx-O0BTtRrH wx-no-info-panel",children:[s.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[s.jsx("div",{className:"wx-O0BTtRrH wx-name",children:E.name}),s.jsx("div",{className:"wx-O0BTtRrH wx-icons",children:n?s.jsx(Bl,{name:"close",onClick:M}):null})]}),s.jsx("div",{className:"wx-O0BTtRrH wx-no-info-wrapper",children:s.jsxs("div",{className:"wx-O0BTtRrH wx-no-info",children:[E.previewSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:s.jsx("img",{src:E.previewSrc,alt:m("A miniature file preview")})}):E.iconSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("img",{src:E.iconSrc,alt:m("A miniature file preview")})}):s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${S?"search":"message-question-outline"}`})}),s.jsx("span",{className:"wx-O0BTtRrH wx-text",children:S?"":m("Select file or folder to view details")})]})})]})})}function nw({panel:n}){const a=u.useContext(Fn),r=u.useContext(Pn.i18n),l=u.useMemo(()=>r.getGroup("filemanager"),[r]),[c,d]=ys(a,"panels"),m=u.useMemo(()=>c[n]._files,[d,n]),p=u.useMemo(()=>c[n]._crumbs||[],[d,n]);function g(j){const N=vp(j,p);a.exec("set-path",{id:j,panel:n,...N&&{selected:[N]}})}const[v,b]=u.useState(null);u.useEffect(()=>{m&&b(null)},[m]);function y(){b(!0),a.exec("request-data",{id:p[p.length-1].id}),setTimeout(()=>{b(null)},5e3)}const w=u.useRef(null),S=u.useRef();return u.useEffect(()=>{S.current?S.current.click=g:(S.current={click:g},Po(w.current,S.current))},[g]),s.jsxs("div",{className:"wx-SNY5LTYx wx-breadcrumbs","data-menu-ignore":"true",ref:w,children:[s.jsx("div",{className:"wx-SNY5LTYx wx-refresh-icon",children:s.jsx(Bl,{name:"refresh",spin:!!v,onClick:y})}),p.map((j,N)=>s.jsxs(Jh.Fragment,{children:[N?s.jsx(Bl,{name:"angle-right"}):null,s.jsx("div",{className:"wx-SNY5LTYx wx-item","data-id":Bn(j.id),"data-menu-ignore":"true",children:j.id=="/"?l(j.name):j.name})]},N))]})}function _A({row:n}){const a=u.useContext(Pn.i18n),[r]=u.useState(()=>a.getGroup("filemanager")),l=u.useContext(Fn).templates,[c]=u.useState(()=>l.icon(n,"small"));return s.jsx("div",{className:"wx-qgAqG6sL wx-name-cell",children:n.id==="/wx-filemanager-parent-link"?s.jsxs(s.Fragment,{children:[s.jsx("i",{className:"wx-qgAqG6sL wxi-arrow-left"}),s.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",r("Back to parent folder")]})]}):s.jsxs(s.Fragment,{children:[c?s.jsx("img",{className:"wx-qgAqG6sL wx-icon",alt:"",src:c,height:"24px",width:"24px"}):s.jsx("i",{className:`wx-qgAqG6sL wxi-${n.type}`}),s.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",n.name," "]})]})})}function aw({children:n}){const a=u.useContext(Fn),r=st(a,"activePanel"),l=u.useContext(bp),c=u.useRef(null);let d=u.useRef({});return d.current.drop=()=>{const m=c.current,p=Oj(m,"data-panel");p&&p!=r&&a.exec("set-active-panel",{panel:p*1})},d.current.dragEnter=()=>{const m=c.current;m&&m.classList.toggle("wx-active")},d.current.dragLeave=()=>{const m=c.current;m&&m.classList.toggle("wx-active")},u.useEffect(()=>{const m=c.current;return l.droparea(m,d.current)},[]),s.jsx("div",{className:"wx-LT9X7tb7 wx-upload-area",ref:c,children:n})}function Ph({panel:n,active:a=!1,onClick:r,onContextMenu:l}){const c=u.useContext(Fn),d=u.useContext(Pn.i18n),m=u.useMemo(()=>d.getGroup("filemanager"),[d]),p=u.useMemo(()=>zo("%d %M %Y",d.getRaw().calendar),[d]),[g]=ys(c,"panels"),v=g[n].selected,b=g[n].path,y=g[n]._crumbs,w=g[n]._sorts,S=g[n]._selectNavigation,j=g[n]._files,N=u.useMemo(()=>[{id:"name",header:m("Name"),flexgrow:3,sort:!0,resize:!0,cell:_A},{id:"size",header:m("Size"),width:100,sort:!0,resize:!0,template:K=>typeof K=="number"?ru(K):""},{id:"date",header:m("Date"),width:120,sort:!0,resize:!0,template:K=>K?p(K):""}],[m,p]),M=u.useRef(null),k=u.useRef(null),E=u.useMemo(()=>S?["/wx-filemanager-parent-link"]:[...v],[S,v]);function R(K,ne){if(ne&&ne.target&&ne.target.className&&ne.target.className.indexOf("wx-grip")!==-1)return;const ce=ne&&(ne.ctrlKey||ne.metaKey),V=ne&&ne.shiftKey;if(K==="/wx-filemanager-parent-link"){if(v.length&&(ce||V))return;c.exec("select-file",{type:"navigation"});return}let O=K==="body"&&ne?null:K;!M.current&&!k.current?c.exec("select-file",{id:O,toggle:ce,range:V,panel:n}):(M.current=null,k.current=null)}function U(){y.length>1&&c.exec("set-path",{id:y[y.length-2].id,panel:n,selected:[y[y.length-1].id]})}function H(K){if(K==="/wx-filemanager-parent-link")return U();const ne=j.find(ce=>ce.id===K);ne&&(ne.type==="folder"?c.exec("set-path",{id:ne.id,panel:n}):c.exec("open-file",{id:ne.id}))}function W(K){const ne=K.key,ce=w[b];let V=ce?"asc":"desc";ce&&ce.key===ne&&(V=ce.order==="asc"?"desc":"asc"),c.exec("sort-files",{key:ne,order:V,panel:n,path:b})}function _(K){K.intercept("sort-rows",ne=>(M.current=!0,W(ne),!1)),K.intercept("select-row",()=>!1),K.on("resize-column",()=>k.current=!0),K.intercept("hotkey",()=>!1)}const L=u.useMemo(()=>b!=="/"?[{id:"/wx-filemanager-parent-link",name:m("Back to parent folder")},...j]:j,[b,j,m]),le=u.useMemo(()=>{if(L&&w&&w[b]){const{key:K,order:ne}=w[b];return{[K]:{order:ne}}}},[L,w,b]),q=u.useRef(null),te=u.useRef();return u.useEffect(()=>{te.current?(te.current.click=R,te.current._dblclick=H):(te.current={click:R,dblclick:K=>te.current._dblclick(K),_dblclick:H},Po(q.current,te.current))},[R,H]),s.jsxs("div",{onClick:r,onContextMenu:l,className:"wx-SSaVhET7 wx-wrapper",children:[s.jsx(nw,{panel:n}),s.jsx("div",{"data-id":Bn("body"),className:`wx-SSaVhET7 wx-list ${a?"wx-active":""}`,ref:q,children:s.jsx(aw,{children:s.jsx(TA,{init:_,data:L,columns:N,selectedRows:E,columnStyle:()=>"wx-SSaVhET7 wx-each-cell",sizes:{rowHeight:42,headerHeight:42},sortMarks:le})})})]})}function zA(){const n=u.useContext(Fn),a=st(n,"activePanel");function r(l){n.exec("set-active-panel",{panel:l})}return s.jsxs("div",{className:"wx-L55BfJa2 wx-panels","data-id":Bn("body"),children:[s.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":0,children:s.jsx(Ph,{panel:0,active:a==0,onClick:()=>r(0),onContextMenu:()=>r(0)})}),s.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":1,children:s.jsx(Ph,{panel:1,active:a==1,onClick:()=>r(1),onContextMenu:()=>r(1)})})]})}function sw({folderIcon:n=!1,folder:a={}}){const r=u.useContext(Fn),[l,c]=ys(r,"panels"),d=st(r,"activePanel"),m=u.useMemo(()=>l[d].path,[c,d]),p=u.useContext(Pn.i18n),g=u.useMemo(()=>p.getGroup("filemanager"),[p]),v=u.useMemo(()=>!!a.data?.find(S=>S.type==="folder"),[a]),b=u.useMemo(()=>a.id=="/"?g(a.name):a.name,[a,g]),y=u.useMemo(()=>a.$level>1?(a.$level-1)*20:0,[a]),w=a.open;return s.jsxs(s.Fragment,{children:[s.jsxs("li",{"data-id":Bn(a.id),className:`wx-NYfhvGIt wx-folder${m===a.id?" wx-selected":""}`,style:{paddingLeft:`${y}px`},children:[v?s.jsx("i",{className:`wx-NYfhvGIt wx-toggle wxi-${w?"angle-down":"angle-right"}`,"data-action":"toggle"}):s.jsx("span",{className:"wx-NYfhvGIt wx-toggle-placeholder"}),s.jsx("i",{className:"wx-NYfhvGIt "+(n||"wxi-folder")}),s.jsxs("span",{className:"wx-NYfhvGIt wx-name",children:[" ",b," "]})]}),w&&a.data&&a.data.length&&v?s.jsx(s.Fragment,{children:a.data.map(S=>S.type==="folder"?s.jsx(sw,{folder:S},S.id):null)}):null]})}function IA(){const n=u.useContext(Fn),[a,r]=ys(n,"data"),[l,c]=ys(n,"panels"),d=st(n,"activePanel"),m=u.useMemo(()=>l[d]._crumbs,[c,d]),p=u.useCallback(S=>{n.exec("open-tree-folder",{id:S,mode:!a.byId(S).open})},[n,r]),g=u.useCallback(S=>{const j=vp(S,m);n.exec("set-path",{id:S,panel:d,...j&&{selected:[j]}})},[n,m,d]),[v,b]=u.useState([]);u.useEffect(()=>{b(a.byId(0).data)},[r]);const y=u.useRef(null),w=u.useRef();return u.useEffect(()=>{w.current?(w.current.click=g,w.current.toggle=p):(w.current={click:g,toggle:p},Po(y.current,w.current))},[g,p]),s.jsx("ul",{ref:y,className:"wx-LyHJ6R6A",children:v.map(S=>S.type==="folder"?s.jsx(sw,{folder:S},S.id):null)})}function OA(){const n=u.useContext(Fn),a=u.useContext(Pn.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),l=st(n,"drive"),c=l?l.used:"",d=l?l.total:"";return c&&d?s.jsxs("div",{className:"wx-DetSyKGG wx-drive",children:[s.jsx("progress",{value:c,max:d,className:"wx-DetSyKGG wx-progress"}),s.jsxs("p",{children:[ru(c)," ",r("of")," ",ru(d)," ",r("used")]})]}):null}function HA({option:n}){const a=u.useContext(Pn.i18n).getGroup("filemanager"),r=u.useContext(bp),l=u.useCallback(()=>{r.open({})},[r]);return s.jsx("div",{className:"wx-9XiKcxq5 wx-upload-button",onClick:l,children:s.jsx("span",{children:a(n.text)})})}function BA({readonly:n,menuOptions:a}){const r=u.useContext(Pn.i18n).getGroup("filemanager"),{showPrompt:l}=u.useContext(yp);u.useEffect(()=>{a1("upload",HA)},[]);function c({action:m}){m&&(m.id==="add-file"?l({item:{type:"file",size:0,date:new Date},add:!0}):m.id==="add-folder"&&l({item:{type:"folder",date:new Date},add:!0}))}const d=u.useMemo(()=>a("add").map(m=>(m.text=r(m.text),m)),[a,r]);return s.jsxs("div",{className:"wx-FlucfALM wx-wrapper",children:[!n&&s.jsx("div",{className:"wx-FlucfALM wx-button",children:s.jsx(i1,{options:d,at:"bottom-fit",onClick:c,children:s.jsx(eu,{type:"primary block",children:r("Add New")})})}),s.jsx("div",{className:"wx-FlucfALM wx-tree",children:s.jsx(IA,{})}),s.jsx(OA,{})]})}function FA({value:n="",onSearch:a}){const[r,l]=Hb(n),c=u.useContext(Pn.i18n).getGroup("filemanager"),d=u.useRef(null),m=u.useMemo(()=>r!==""?"wxi-close":"wxi-search",[r]);function p(v){const b=v.target.value;l(b),a&&a({value:b})}function g(){l(""),d.current&&d.current.focus(),a&&a({value:""})}return s.jsxs("div",{className:"wx-lUZMtgT1 wx-search-input",children:[s.jsx("i",{className:`wx-lUZMtgT1 wx-icon ${m}`,onClick:g}),s.jsx("input",{type:"text",className:"wx-lUZMtgT1 wx-text",ref:d,value:r,onInput:p,placeholder:c("Search")})]})}function PA({narrowMode:n=!1,onShowTree:a}){const r=u.useContext(Fn),l=u.useContext(Pn.i18n).getGroup("filemanager"),c=st(r,"mode"),d=st(r,"preview"),m=st(r,"search"),p=[{icon:"wxi-view-sequential",id:"table"},{icon:"wxi-view-grid",id:"cards"},{icon:"wxi-view-column",id:"panels"}];function g({value:y}){r.exec("set-mode",{mode:y})}function v(y){y.preventDefault(),r.exec("show-preview",{mode:!d})}function b(y){r.exec("filter-files",{text:y.value})}return s.jsxs("div",{className:"wx-5PZQQztG wx-toolbar",children:[s.jsxs("div",{className:"wx-5PZQQztG wx-left "+(n?"wx-left-narrow":""),children:[n?c==="panels"||c==="search"?null:s.jsx("div",{className:"wx-5PZQQztG wx-sidebar-icon","data-id":Bn("toggle-tree"),children:s.jsx(Bl,{onClick:()=>a&&a(),name:"subtask"})}):s.jsx("div",{className:"wx-5PZQQztG wx-name",children:l("Files")}),s.jsx(FA,{onSearch:b,value:m})]}),s.jsxs("div",{className:"wx-5PZQQztG wx-right",children:[n?null:s.jsx("div",{className:"wx-5PZQQztG wx-preview-icon",children:s.jsx(Rk,{onClick:v,value:d,children:s.jsx("i",{className:"wx-5PZQQztG wxi-eye"})})}),s.jsx("div",{className:"wx-5PZQQztG wx-modes",children:s.jsx(kk,{value:c,options:p,onChange:g})})]})]})}function $A(){const n=u.useContext(Fn),a=st(n,"activePanel");return s.jsxs("div",{className:"wx-NwohNJzN wx-wrapper",children:[s.jsx(nw,{panel:a}),s.jsx(aw,{children:s.jsx(tw,{})})]})}function UA({readonly:n=!1,menuOptions:a,extraInfo:r}){const l=u.useRef(null),c=u.useRef(null),[d,m]=u.useState(void 0),[p,g]=u.useState(void 0),[v,b]=u.useState(!1),y=Gb(),w=u.useContext(Fn),{showPrompt:S,showConfirm:j}=u.useContext(yp),N=u.useContext(Pn.i18n),M=u.useMemo(()=>N.getGroup("filemanager"),[N]),k=st(w,"mode"),E=st(w,"preview"),R=st(w,"activePanel"),[U,H]=ys(w,"panels"),W=u.useMemo(()=>(U&&R!=null?U[R]:null)?.selected??[],[H,R]),_=u.useMemo(()=>(U&&R!=null?U[R]:null)?.path,[H,R]),[L,le]=u.useState([]);u.useEffect(()=>{const oe=l.current;if(!oe)return;const we=new ResizeObserver(J=>{const B=J[0]?.borderBoxSize?.[0]?.inlineSize;typeof B=="number"&&g(B<768)});return we.observe(oe),()=>{we.disconnect()}},[]);const q=u.useCallback(()=>{b(oe=>!oe)},[]),te=u.useCallback(oe=>{p&&iu(oe)!=="toggle-tree"&&b(!1)},[p]);u.useEffect(()=>{const oe=c.current;if(oe)return mi(oe,te).destroy},[te]),u.useEffect(()=>{const oe=c.current;if(!oe)return;const we=new ResizeObserver(()=>{oe&&m(oe.clientWidth)});return we.observe(oe),oe&&m(oe.clientWidth),()=>{we.disconnect()}},[]);const K=u.useMemo(()=>({icon:"wxi-eye",text:"Preview",id:"preview"}),[]),ne=u.useCallback(oe=>{let we=p?[K]:[];return oe==="file"&&(we=[...we,...a().filter(J=>J.id==="download")]),we},[p,K,a]),ce=u.useRef(null),V=u.useCallback((oe,we,J)=>{const B=J?[we.id]:W;switch(oe){case"download":w.exec("download-file",{id:we.id});break;case"copy":case"move":ce.current={action:oe,ids:B};break;case"paste":ce.current&&w.exec(ce.current.action==="copy"?"copy-files":"move-files",{ids:ce.current.ids,target:we?.type==="folder"?we.id:_});break;case"rename":S({item:we});break;case"delete":j({selected:B});break;case"preview":w.exec("show-preview",{mode:!E});break}},[w,W,_,S,j,E]),O=u.useCallback(()=>U?.[R],[U,R]);u.useEffect(()=>{const oe=l.current;if(!oe)return;const we=Vk(oe,{api:w,menuOptions:n?ne:a,performAction:V,getPanel:O});return()=>{typeof we=="function"?we():we&&typeof we.destroy=="function"&&we.destroy()}},[w,n,ne,a,V,O]);const Y=u.useCallback((oe,we)=>{const J=oe?w.getFile(oe):null,B=we.target.closest(".tree-item.folder");let pe;if(n)pe=ne(J?.type);else{switch(oe){case"body":pe=a(oe);break;default:if(J)if(!B&&W.length>1)pe=p?[K,...a("multiselect")]:a("multiselect");else if(oe==="/")pe=a("folder",J).filter(ge=>ge.id==="paste");else{const ge=a(J.type,J);ge&&(pe=p?[K,...ge]:ge)}}k==="search"&&(pe=pe?.filter(ge=>ge.id!=="paste"))}if(J?.id&&(!W.length||!W.some(ge=>ge===J.id))&&!B&&w.exec("select-file",{id:J.id}),pe?.length)return pe.forEach(ge=>{B&&(ge.hotkey=""),ge.text&&(ge.text=M(ge.text)),ge.hotkey&&(ge.subtext=ge.hotkey)}),le(pe),J||{}},[w,n,ne,a,W,p,K,k,M]),X=u.useCallback(oe=>{const{action:we,context:J}=oe;we&&V(we.id,J,!we.hotkey)},[V]);async function P(oe){await Promise.resolve();const{name:we,size:J}=oe.file;w.exec("create-file",{file:{name:we,size:J,date:new Date,file:oe.file},parent:_})}return s.jsx("div",{className:"wx-RJbNonjJ wx-filemanager wx-flex",ref:l,"data-menu-ignore":"false",children:p&&E?s.jsx("div",{className:"wx-RJbNonjJ wx-info-narrow",children:s.jsx(oh,{narrowMode:p,extraInfo:r})}):s.jsxs(s.Fragment,{children:[s.jsx(PA,{narrowMode:p,onShowTree:q}),s.jsx(r1,{dataKey:"id",at:"point",options:L,resolver:Y,onClick:X,children:s.jsxs(qb,{dataKey:"actionId",options:L,resolver:Y,onClick:X,children:[s.jsx(d1,{data:y,apiOnly:!0,uploadURL:P}),s.jsx(bp.Provider,{value:y,children:s.jsx("div",{className:"wx-RJbNonjJ wx-content-wrapper wx-flex",children:k!=="panels"&&k!=="search"?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-RJbNonjJ "+["wx-sidebar",p?"wx-sidebar-narrow":"",v?"wx-sidebar-visible":""].filter(Boolean).join(" "),ref:c,children:s.jsx(BA,{readonly:n,menuOptions:a})}),s.jsxs("div",{className:"wx-RJbNonjJ wx-content",style:{width:`calc(100% - ${d||0}px - 10px)`},children:[s.jsx("div",{className:`wx-RJbNonjJ wx-content-item${E?"":"-fit"}`,"data-id":Bn("body"),children:k==="table"?s.jsx(Ph,{panel:R}):s.jsx($A,{})}),E?s.jsx("div",{className:"wx-RJbNonjJ wx-info",children:s.jsx(oh,{extraInfo:r})}):null]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`wx-RJbNonjJ wx-content-item${E?"":"-fit"}`,children:k==="panels"?s.jsx(zA,{}):s.jsx(LA,{})}),E?s.jsx("div",{className:"wx-RJbNonjJ wx-info",children:s.jsx(oh,{extraInfo:r})}):null]})})})]})})]})})}const qA=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join("");function GA(n,a){const{type:r,ext:l}=n;if(r==="folder")return!1;let c;return r&&r!=="file"&&dy[r]?c=r:l?c=dy[l]?l:"file":c="unknown",`https://cdn.svar.dev/icons/filemanager/vivid/${a}/${c}.svg`}const VA=u.forwardRef(function(n,a){const{data:r=[],mode:l="cards",drive:c=null,preview:d=!1,panels:m=null,activePanel:p=0,readonly:g=!1,menuOptions:v=Uk,extraInfo:b=null,init:y=null,icons:w=GA,previews:S=null,...j}=n,N=u.useRef();N.current=j;const M=u.useMemo(()=>new $k(Fb),[]),k=u.useMemo(()=>M.in,[M]),E=u.useRef(null);E.current===null&&(E.current=new _b((H,W)=>{const _="on"+qA(H);N.current&&N.current[_]&&N.current[_](W)}),k.setNext(E.current));const R=u.useMemo(()=>({getState:M.getState.bind(M),getReactiveState:M.getReactive.bind(M),getStores:()=>({data:M}),exec:k.exec,setNext:H=>(E.current=E.current.setNext(H),E.current),intercept:k.intercept.bind(k),on:k.on.bind(k),detach:k.detach.bind(k),getFile:M.getFile.bind(M),serialize:M.serialize.bind(M),templates:{preview:S||(()=>null),icon:w==="simple"?(()=>null):w}}),[M,k]),U=u.useRef(0);return u.useEffect(()=>{if(!U.current)y&&y(R);else{const H=M.getState();M.init({data:r,mode:l,drive:c,preview:d,panels:m||H.panels||[],activePanel:p})}U.current++},[M,r,l,c,d,m,p,y,R]),U.current===0&&M.init({data:r,mode:l,drive:c,preview:d,panels:m||[],activePanel:p}),u.useImperativeHandle(a,()=>({...R}),[R]),s.jsx(Fn.Provider,{value:R,children:s.jsx(pp,{words:gp,optional:!0,children:s.jsx(EA,{children:s.jsx(UA,{readonly:g,menuOptions:v,extraInfo:b})})})})});function WA({fonts:n=!0,children:a}){return a?s.jsx(Qx,{fonts:n,children:a}):s.jsx(Qx,{fonts:n})}op(Ia);function wp(n,a){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Invalid Hub ${a} response.`);return n}function ou(n,a,r){const l=wp(n,r);if(!Array.isArray(l[a]))throw new Error(`Invalid Hub ${r} response: ${a} must be an array.`);return l[a]}function YA(n,a,r){const l=wp(n,r);if(!l[a]||typeof l[a]!="object"||Array.isArray(l[a]))throw new Error(`Invalid Hub ${r} response: ${a} must be an object.`);return l[a]}async function KA(n,a=!1){return ou(await Ge(`/api/remote/filesystem/roots${a?"?refresh=1":""}`,void 0,n),"roots","filesystem roots")}async function ch(n,a){const r=await Ge(`/api/remote/filesystem/entries?id=${encodeURIComponent(n)}`,void 0,a);return{folder:YA(r,"folder","filesystem entries"),entries:ou(r,"entries","filesystem entries")}}async function QA(n,a){return Ge("/api/remote/filesystem/selection/scan",{method:"POST",body:JSON.stringify({itemIds:n})},a)}async function XA(n,a,r,l){return Ge("/api/remote/files/from-hub",{method:"POST",body:JSON.stringify({itemIds:n,deviceIds:a,remoteDirectory:r})},l)}async function ZA(n,a=!1){const r=await Ge(`/api/remote/files/jobs?active=${a?"1":"0"}`,void 0,n);return{jobs:ou(r,"jobs","file transfer jobs")}}async function JA(n,a){return Ge(`/api/remote/files/jobs/${encodeURIComponent(n)}`,void 0,a)}async function eN(n,a){return Ge(`/api/remote/files/jobs/${encodeURIComponent(n)}/cancel`,{method:"POST"},a)}async function fy(n){return ou(await Ge("/api/remote/filesystem/shared-folders",void 0,n),"folders","shared folders")}async function tN(n,a){return Ge("/api/remote/filesystem/shared-folders",{method:"POST",body:JSON.stringify({sourceId:n})},a)}async function nN(n,a,r){return Ge(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)},r)}async function aN(n,a){return Ge(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function sN(n,a,r,l){const c=await Ge(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}/sync`,{method:"POST",body:JSON.stringify({deviceIds:a,remoteDirectory:r})},l),d=wp(c,"shared folder sync");return{ok:d.ok===!0,jobs:ou(c,"jobs","shared folder sync"),files:Number(d.files||0),totalBytes:Number(d.totalBytes||0)}}function iN(n){return{id:String(n.id),parentId:n.parent,name:n.name,type:n.type==="file"?"file":"folder",size:Number(n.size||0),modifiedAt:n.date?.toISOString()||null,displayPath:String(n.displayPath||n.name),hasChildren:n.lazy===!0||!!n.data?.length,locked:n.locked===!0}}function my(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let r=n,l=0;for(;r>=1024&&l<a.length-1;)r/=1024,l+=1;return`${r.toFixed(l===0||r>=100?0:1)} ${a[l]}`}function Jd(n){return n.driveType==="network"?"network":n.driveType==="removable"?"removable":"local"}function rN(n){const a=n.filter(r=>Jd(r)==="local");return a.find(r=>/\bC:/i.test(`${r.name} ${r.displayPath||""}`))||a[0]||n[0]||null}function lN({hubUrl:n,roots:a,loading:r,error:l,onRefreshRoots:c,onImportFiles:d,onImportFolder:m,onSelectionChange:p,onShareItem:g,onAddSyncFolder:v,onNotice:b}){const y=u.useRef(null),w=u.useRef("/"),S=u.useRef(0),j=u.useRef([]),N=u.useRef(new Map),[M,k]=u.useState(null),[E,R]=u.useState([]),[U,H]=u.useState([]),[W,_]=u.useState(0),[L,le]=u.useState(null),[q,te]=u.useState(!1),[K,ne]=u.useState(""),[ce,V]=u.useState(new Set),O=a.find(ae=>ae.id===M)||null,Y=E[E.length-1]||null,X=O?Y?.svarPath||`/${O.name}`:null,P=X;u.useEffect(()=>{j.current=E,w.current=P||"/"},[P,E]);const oe=u.useMemo(()=>(N.current.clear(),!O||!P||E.length===0?[]:(E.forEach(ae=>N.current.set(ae.svarPath,ae.hubId)),[...E.map((ae,ke)=>({id:ae.svarPath,parent:ke===0?"/":E[ke-1].svarPath,type:"folder",name:ae.name,date:ae.modifiedAt?new Date(ae.modifiedAt):void 0,lazy:!1})),...U.map(ae=>{const ke=`${P}/${ae.name}`;return N.current.set(ke,ae.id),{id:ke,parent:P,name:ae.name,type:ae.type==="file"?"file":"folder",...ae.type==="file"?{size:ae.size}:{},date:ae.modifiedAt?new Date(ae.modifiedAt):void 0,lazy:ae.type!=="file"&&ae.hasChildren===!0,displayPath:ae.displayPath,locked:ae.locked,driveType:ae.driveType,totalBytes:ae.totalBytes,freeBytes:ae.freeBytes}})])),[O,U,P,E]),we=ae=>N.current.get(String(ae))||String(ae),J=ae=>iN({...ae,id:we(String(ae.id)),parent:we(String(ae.parent))}),B=async(ae,ke)=>{const je=ae[ae.length-1];if(!je)return;const De=++S.current;te(!0),ne("");try{const Le=await ch(je.hubId,n);if(De!==S.current)return;if(!Array.isArray(Le.entries))throw new Error("Invalid Hub filesystem entries response.");const $e={...je,displayPath:Le.folder.displayPath||je.displayPath,modifiedAt:Le.folder.modifiedAt||je.modifiedAt},he=[...ae.slice(0,-1),$e];j.current=he,R(he),H(Le.entries),_(Me=>Me+1)}catch(Le){if(De!==S.current)return;console.error("[LiveDesk FS] folder navigation failed",{folderId:je.hubId,error:Le}),ne(Le instanceof Error?`${ke}: ${Le.message}`:`${ke}: Unable to read this folder.`)}finally{De===S.current&&te(!1)}},pe=async ae=>{const ke={svarPath:`/${ae.name}`,hubId:ae.id,name:ae.name,displayPath:ae.displayPath,modifiedAt:ae.modifiedAt},je=++S.current;k(ae.id),j.current=[ke],R([ke]),w.current=ke.svarPath,H([]),ne(""),te(!0),le(ae.id),V(De=>{const Le=new Set(De);return Le.delete(ae.id),Le});try{const De=await ch(ae.id,n);if(je!==S.current)return;if(!Array.isArray(De.entries))throw new Error("Invalid Hub filesystem entries response.");const Le={...ke,displayPath:De.folder.displayPath||ke.displayPath,modifiedAt:De.folder.modifiedAt||ke.modifiedAt};j.current=[Le],R([Le]),H(De.entries),_($e=>$e+1)}catch(De){if(je!==S.current)return;console.error("[LiveDesk FS] getEntries failed",{rootId:ae.id,error:De}),V(Le=>new Set(Le).add(ae.id)),ne(De instanceof Error?`${ae.name}: ${De.message}`:`${ae.name}: Unable to read this drive.`),b(De instanceof Error?`${ae.name}: ${De.message}`:`${ae.name}: Unable to read this drive.`)}finally{je===S.current&&(le(null),te(!1))}},ge=ae=>{const ke=j.current;ae<0||ae>=ke.length||ae===ke.length-1||B(ke.slice(0,ae+1),ke[ae].name)},xe=(ae,ke)=>{if(ae.type!=="folder")return;const je=j.current,De=je.findIndex($e=>$e.svarPath===ke);if(De<0)return;const Le={svarPath:`${ke}/${ae.name}`,hubId:ae.id,name:ae.name,displayPath:ae.displayPath,modifiedAt:ae.modifiedAt};B([...je.slice(0,De+1),Le],ae.name)},Ae=()=>ge(j.current.length-2),_e=ae=>{if(ae.key!=="Enter"&&ae.code!=="Enter"&&ae.code!=="NumpadEnter"||ae.target?.closest('button, input, textarea, [contenteditable="true"]'))return;const je=y.current;if(!je)return;const De=je.getState().panels?.flatMap($e=>$e.selected||[])||[];if(De.length!==1)return;const Le=je.getFile(String(De[0]));Le?.type==="folder"&&(ae.preventDefault(),ae.stopPropagation(),xe(J(Le),String(Le.parent||w.current)))};u.useEffect(()=>{const ae=a.find(ke=>ke.id===M)||rN(a);if(V(ke=>new Set([...ke].filter(je=>a.some(De=>De.id===je)))),!ae){k(null),j.current=[],R([]),H([]);return}pe(ae)},[a]);const ie=ae=>{y.current=ae,ae.on("request-data",async({id:ke})=>{const je=String(ke),De=we(je);try{const Le=await ch(De,n);if(!Array.isArray(Le.entries))throw new Error("Invalid Hub filesystem entries response.");const $e=Le.entries.map(he=>{const Me=`${je}/${he.name}`;return N.current.set(Me,he.id),{id:Me,parent:je,name:he.name,type:he.type==="file"?"file":"folder",...he.type==="file"?{size:he.size}:{},date:he.modifiedAt?new Date(he.modifiedAt):void 0,lazy:he.type!=="file"&&he.hasChildren===!0,displayPath:he.displayPath,locked:he.locked,driveType:he.driveType,totalBytes:he.totalBytes,freeBytes:he.freeBytes}});await ae.exec("provide-data",{id:je,data:$e})}catch(Le){console.error("[LiveDesk FS] nested getEntries failed",{id:De,error:Le}),b(Le instanceof Error?Le.message:"Unable to read this folder.")}}),ae.intercept("set-path",({id:ke})=>{const je=String(ke),De=j.current.findIndex($e=>$e.svarPath===je);if(De>=0)return ge(De),!1;const Le=ae.getFile(je);if(Le?.type==="folder")return xe(J(Le),String(Le.parent||w.current)),!1}),ae.intercept("open-file",()=>!1),ae.on("select-file",()=>{window.setTimeout(()=>{const De=(ae.getState().panels?.flatMap(Le=>Le.selected||[])||[]).map(Le=>ae.getFile(Le)).filter(Boolean).map(Le=>J(Le));p(De.map(Le=>Le.id),De)},0)})},Q=(ae,ke)=>{const je=ke?J(ke):null,De=()=>{const Le=je?.type==="file"?String(ke?.parent||w.current):String(ke?.id||w.current);y.current?.exec("request-data",{id:Le})};return ae==="body"?[{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:De},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>b("Select a file or folder to view its properties.")}]:ae==="multiselect"?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>{(y.current?.getState().panels?.flatMap($e=>$e.selected||[])||[]).forEach($e=>{const he=y.current?.getFile($e);he&&g(J(he))})}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:De}]:je?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>g(je)},...je.type==="folder"?[{id:"sync",text:"Add folder to Sync",icon:"mdi mdi-folder-sync-outline",handler:()=>v(je)}]:[],{id:"copy-path",text:"Copy path",icon:"mdi mdi-content-copy",handler:()=>{Rl(je.displayPath||je.name)}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:De},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>b(`${je.name}
|
|
14
14
|
${je.displayPath||""}`)}]:[]},Ie=async()=>{try{await c()}catch(ae){b(ae instanceof Error?ae.message:"Unable to refresh Hub drives.")}},Oe=[{id:"local",label:"Local drives",icon:Ll,roots:a.filter(ae=>Jd(ae)==="local")},{id:"removable",label:"Removable drives",icon:ZS,roots:a.filter(ae=>Jd(ae)==="removable")},{id:"network",label:"Network drives",icon:ep,roots:a.filter(ae=>Jd(ae)==="network")}];return s.jsxs("section",{className:"hub-file-explorer-panel","aria-label":"Hub file explorer",children:[s.jsxs("div",{className:"hub-file-explorer-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Hub file explorer"}),s.jsxs("strong",{children:[s.jsx(Ll,{size:16})," Browse files on this Hub"]})]}),s.jsxs("div",{className:"hub-file-explorer-heading-actions",children:[s.jsx("button",{className:"icon-button",onClick:d,title:"Import files from this browser",type:"button",children:s.jsx(Jy,{size:16})}),s.jsx("button",{className:"icon-button",onClick:m,title:"Import folder from this browser",type:"button",children:s.jsx(JS,{size:16})}),s.jsx("button",{className:"icon-button",onClick:()=>{Ie()},title:"Refresh drives",type:"button",children:s.jsx(Ho,{size:16})})]})]}),r?s.jsxs("div",{className:"hub-file-explorer-state",children:[s.jsx(Ll,{size:24}),s.jsx("strong",{children:"Connecting to LiveDesk Hub file system..."})]}):l?s.jsxs("div",{className:"hub-file-explorer-state error",role:"alert",children:[s.jsx(Is,{size:24}),s.jsx("strong",{children:l})]}):s.jsxs("div",{className:"hub-file-explorer-content",children:[s.jsxs("aside",{className:"hub-file-explorer-drive-sidebar","aria-label":"Hub drives",children:[s.jsxs("div",{className:"hub-drive-sidebar-title",children:[s.jsx(Ll,{size:15}),s.jsx("strong",{children:"This PC"})]}),Oe.map(ae=>ae.roots.length>0&&s.jsxs("section",{className:"hub-drive-group",children:[s.jsxs("h3",{children:[s.jsx(ae.icon,{size:13}),ae.label]}),s.jsx("div",{className:"hub-drive-list",children:ae.roots.map(ke=>{const je=ae.icon,De=ce.has(ke.id)||ke.locked===!0;return s.jsxs("button",{className:`hub-drive-item ${M===ke.id?"active":""} ${De?"unavailable":""}`,onClick:()=>{pe(ke)},"aria-pressed":M===ke.id,type:"button",children:[s.jsx("span",{className:"hub-drive-item-icon",children:s.jsx(je,{size:16})}),s.jsxs("span",{className:"hub-drive-item-copy",children:[s.jsx("strong",{children:ke.name}),s.jsx("small",{children:ke.displayPath||ke.name}),s.jsxs("em",{children:[my(ke.freeBytes||0)," free / ",my(ke.totalBytes||0)]})]}),L===ke.id?s.jsx(qr,{className:"hub-drive-item-status spin",size:15}):De?s.jsx(rx,{className:"hub-drive-item-status",size:15}):null]},ke.id)})})]},ae.id)),a.length===0&&s.jsxs("div",{className:"hub-drive-sidebar-empty",children:[s.jsx(Is,{size:17}),s.jsx("span",{children:"No drives available."})]})]}),s.jsxs("div",{className:"hub-file-explorer-browser",children:[s.jsxs("div",{className:"hub-file-explorer-navigation",children:[s.jsx("nav",{className:"hub-file-explorer-breadcrumbs","aria-label":"Current Hub folder",children:E.map((ae,ke)=>s.jsxs("span",{className:"hub-file-explorer-breadcrumb-item",children:[ke>0&&s.jsx(tp,{size:13,"aria-hidden":"true"}),s.jsx("button",{className:`hub-file-explorer-breadcrumb ${ke===E.length-1?"current":""}`,onClick:()=>ge(ke),"aria-current":ke===E.length-1?"location":void 0,type:"button",children:ae.name})]},ae.svarPath))}),s.jsxs("div",{className:"hub-file-explorer-navigation-actions",children:[q&&s.jsx(qr,{className:"hub-file-explorer-loading-icon spin",size:15,"aria-label":"Loading folder"}),s.jsx("button",{className:"icon-button",onClick:Ae,disabled:E.length<=1||q,title:"Back to parent folder",type:"button",children:s.jsx(Vy,{size:16})})]})]}),K&&s.jsxs("div",{className:"hub-file-explorer-folder-error",role:"alert",children:[s.jsx(rx,{size:15}),s.jsx("span",{children:K})]}),s.jsx("div",{className:"hub-file-explorer-svar",onKeyDownCapture:_e,children:s.jsx(WA,{fonts:!1,children:s.jsx(VA,{data:oe,panels:X?[{path:X,selected:[]}]:void 0,readonly:!0,mode:"table",preview:!1,init:ie,icons:"simple",menuOptions:Q},`${O?.id||"no-root"}:${W}`)})})]})]})]})}class oN extends u.Component{state={error:null};static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,r){console.error("[LiveDesk] Share Files runtime error",a,r.componentStack)}render(){return this.state.error?s.jsxs("section",{className:"file-share-error-boundary",role:"alert",children:[s.jsx(gf,{size:24}),s.jsx("strong",{children:"Share Files could not be opened."}),s.jsx("span",{children:this.state.error.message||"An unexpected file explorer error occurred."}),s.jsxs("button",{className:"text-button",onClick:this.props.onRetry,type:"button",children:[s.jsx(Ho,{size:15})," Retry"]})]}):this.props.children}}function cN(n){return n.deviceName||n.hostname||n.deviceId}function uN({devices:n,mode:a,selectedIds:r,onModeChange:l,onToggle:c}){const d=new Set(r);return s.jsxs("section",{className:"distribution-targets",children:[s.jsxs("div",{className:"file-share-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Target"}),s.jsx("strong",{children:a==="all"?`${n.length} connected`:`${r.length} selected`})]}),s.jsxs("div",{className:"file-share-tabs compact","aria-label":"File transfer targets",children:[s.jsxs("button",{className:a==="all"?"active":"",onClick:()=>l("all"),type:"button",children:[s.jsx(eb,{size:14})," All connected"]}),s.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>l("selected"),type:"button",children:[s.jsx(en,{size:14})," Selected"]})]})]}),s.jsx("div",{className:"file-share-device-list","aria-label":"Connected workstation targets",children:n.length===0?s.jsx("div",{className:"file-share-empty-inline",children:"No connected workstations."}):n.map(m=>{const p=a==="all"||d.has(m.deviceId);return s.jsxs("label",{className:`file-share-device-option ${p?"selected":""}`,children:[s.jsx("input",{type:"checkbox",checked:p,disabled:a==="all",onChange:()=>c(m.deviceId)}),s.jsx(en,{size:20,"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:cN(m)}),s.jsxs("small",{children:["Slot ",m.slotNumber?String(m.slotNumber).padStart(3,"0"):"-"," / ",m.platform||"unknown OS"]})]}),s.jsx(Hn,{size:17,"aria-hidden":"true"})]},m.deviceId)})})]})}function dN(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let r=n,l=0;for(;r>=1024&&l<a.length-1;)r/=1024,l+=1;return`${r.toFixed(l===0||r>=100?0:1)} ${a[l]}`}function fN({folders:n,loading:a,busy:r,canSync:l,onSyncAll:c,onSync:d,onToggleAuto:m,onRemove:p,onAdd:g}){return s.jsxs("section",{className:"file-share-sync-panel",children:[s.jsxs("div",{className:"file-share-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Hub folders"}),s.jsx("strong",{children:"Continuous sync"})]}),s.jsxs("button",{className:"text-button compact",onClick:c,disabled:r||!l||n.length===0,type:"button",children:[s.jsx(Kd,{size:15})," ",r?"Syncing":"Sync all"]})]}),a?s.jsx("div",{className:"file-share-empty-state",children:"Loading Hub sync folders..."}):n.length===0?s.jsxs("button",{className:"file-share-empty-state interactive",onClick:g,type:"button",children:[s.jsx(Kd,{size:28}),s.jsx("strong",{children:"Add a selected Hub folder"}),s.jsx("span",{children:"Hub keeps the manifest and can sync while this browser is closed."})]}):s.jsx("div",{className:"file-share-sync-list",children:n.map(v=>s.jsxs("article",{className:`file-share-sync-row state-${v.status}`,children:[s.jsx("div",{className:"file-share-sync-icon",children:s.jsx(Kd,{size:19})}),s.jsxs("div",{className:"file-share-sync-info",children:[s.jsx("strong",{children:v.name}),s.jsx("span",{children:v.displayPath}),s.jsxs("small",{children:[v.fileCount," files / ",dN(v.totalBytes)," · ",v.lastSyncedAt?`Last sync ${Nh(v.lastSyncedAt)} ago`:v.message||"Not synced yet"]})]}),s.jsxs("label",{className:"file-share-auto-sync",children:[s.jsx("input",{type:"checkbox",checked:v.autoSync,onChange:()=>m(v)}),s.jsx("span",{children:"Auto"})]}),s.jsxs("button",{className:"text-button compact",onClick:()=>d(v),disabled:r||!l||v.status==="syncing",type:"button",children:[s.jsx(Ho,{size:14})," Sync now"]}),s.jsx("button",{className:"icon-button",onClick:()=>p(v),title:"Remove sync folder",type:"button",children:s.jsx(Zh,{size:15})})]},v.id))})]})}function mN(n){const r=(n.targetMode==="all"?n.devices.map(l=>l.deviceId):n.selectedTargetIds).length>0;return s.jsxs("aside",{className:"file-share-distribution-panel",children:[s.jsxs("div",{className:"file-share-distribution-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Distribution"}),s.jsx("strong",{children:"Hub → workstations"})]}),s.jsx(Bo,{size:18})]}),s.jsxs("div",{className:"file-share-tabs",role:"tablist","aria-label":"Distribution mode",children:[s.jsx("button",{className:n.tab==="send"?"active":"",onClick:()=>n.onTabChange("send"),role:"tab","aria-selected":n.tab==="send",type:"button",children:"Send"}),s.jsx("button",{className:n.tab==="sync"?"active":"",onClick:()=>n.onTabChange("sync"),role:"tab","aria-selected":n.tab==="sync",type:"button",children:"Sync"})]}),n.tab==="send"?s.jsxs(s.Fragment,{children:[s.jsx(uN,{devices:n.devices,mode:n.targetMode,selectedIds:n.selectedTargetIds,onModeChange:n.onTargetModeChange,onToggle:n.onTargetToggle}),s.jsxs("label",{className:"file-share-destination",children:[s.jsx("span",{children:"Destination folder"}),s.jsxs("div",{children:[s.jsx(Lo,{size:15}),s.jsx("input",{value:n.remoteDirectory,onChange:l=>n.onRemoteDirectoryChange(l.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),s.jsx("small",{children:"Blank uses Desktop/LiveDeskFiles."})]}),s.jsxs("div",{className:"file-share-selection-summary",children:[s.jsx("span",{children:"Selected"}),s.jsx("strong",{children:n.selectedSummary})]}),s.jsxs("button",{className:"file-share-share-button",onClick:n.onShare,disabled:!n.canShare,type:"button",children:[s.jsx(Bo,{size:17})," Share selected"]}),s.jsxs("button",{className:"file-share-secondary-button",onClick:n.onAddSync,disabled:!n.canAddSync,type:"button",children:[s.jsx(Lo,{size:16})," Add selected folder to Sync"]})]}):s.jsx(fN,{folders:n.folders,loading:n.foldersLoading,busy:n.syncBusy,canSync:r,onSyncAll:n.onSyncAll,onSync:n.onSync,onToggleAuto:n.onToggleAuto,onRemove:n.onRemove,onAdd:n.onAddFolder})]})}function hN(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let r=n,l=0;for(;r>=1024&&l<a.length-1;)r/=1024,l+=1;return`${r.toFixed(l===0||r>=100?0:1)} ${a[l]}`}function hy(n){return n.totalBytes>0?Math.max(0,Math.min(100,Math.round(n.sentBytes/n.totalBytes*100))):n.totalFiles>0?Math.max(0,Math.min(100,Math.round(n.completedFiles/n.totalFiles*100))):n.state==="completed"?100:0}function py(n){return n.state==="scanning"?"Scanning selected Hub items":n.state==="queued"?"Preparing transfer":n.state==="sending"?`${n.completedFiles}/${n.totalFiles} · ${n.currentPath||"sending"}`:n.state==="completed"?`Sent ${n.totalFiles} file${n.totalFiles===1?"":"s"} to ${n.targetCount} workstation${n.targetCount===1?"":"s"}`:n.state==="partially-failed"?`${n.failedTargets.length} workstation${n.failedTargets.length===1?"":"s"} failed`:n.state==="cancelled"?"Transfer cancelled":n.error||"Transfer failed"}function gy(n){return["completed","partially-failed","failed","cancelled"].includes(n)}function pN({hubUrl:n,devices:a,localFeatureAccess:r,upgradeNotice:l,remoteDirectory:c,onRemoteDirectoryChange:d,targetMode:m,selectedTargetIds:p,onTargetModeChange:g,onTargetToggle:v,filePickerRef:b,folderPickerRef:y,onBrowserFileImport:w,onBrowserFolderImport:S,onNotice:j,onTransferChange:N}){const M=Array.isArray(a)?a:[],[k,E]=u.useState([]),[R,U]=u.useState(!0),[H,W]=u.useState(""),[_,L]=u.useState([]),[le,q]=u.useState([]),[te,K]=u.useState(null),[ne,ce]=u.useState(!1),[V,O]=u.useState([]),[Y,X]=u.useState(!0),[P,oe]=u.useState(!1),[we,J]=u.useState("send"),[B,pe]=u.useState([]),ge=u.useRef(new Set),xe=u.useMemo(()=>m==="all"?M.map(de=>de.deviceId):p.filter(de=>M.some(be=>be.deviceId===de)),[M,p,m]),Ae=B.find(de=>!gy(de.state)),_e=le.length===1&&le[0].type==="folder"?le[0]:null,ie=le.length===0?"Select files or folders from the Hub explorer.":ne?"Calculating selection size...":te?`${te.files} files, ${te.folders} folders · ${hN(te.totalBytes)}`:`${le.length} item${le.length===1?"":"s"} selected`,Q=de=>{N({id:de.jobId,state:de.state,progress:hy(de),message:py(de)})},Ie=u.useCallback(async()=>{const de=await KA(n,!0);return E(de),W(""),de},[n]),Oe=async()=>{try{const be=(await ZA(n,!0)).jobs||[],We=await Promise.all([...ge.current].map(async Xe=>{try{return await JA(Xe,n)}catch{return null}})),at=[...be,...We.filter(Boolean)],wn=[...new Map(at.map(Xe=>[Xe.jobId,Xe])).values()];pe(wn),wn.forEach(Q),wn.filter(Xe=>gy(Xe.state)).forEach(Xe=>ge.current.delete(Xe.jobId))}catch{}};u.useEffect(()=>{let de=!0;U(!0),W(""),Promise.all([Ie(),fy(n).then(We=>{de&&O(We)})]).catch(We=>{de&&(W(We instanceof Error?"Hub file system is unavailable. Make sure LiveDesk Hub is running on this computer.":"Hub file system is unavailable."),j(We instanceof Error?We.message:"Hub file system is unavailable."))}).finally(()=>{de&&(U(!1),X(!1))}),Oe();const be=window.setInterval(()=>{Oe()},800);return()=>{de=!1,window.clearInterval(be)}},[n,Ie]),u.useEffect(()=>{if(_.length===0){K(null);return}let de=!1;return ce(!0),QA(_,n).then(be=>{de||K(be)}).catch(be=>{de||j(be instanceof Error?be.message:"Unable to calculate selected size.")}).finally(()=>{de||ce(!1)}),()=>{de=!0}},[n,_.join("|")]);const ae=(de,be)=>{L(de),q(be)},ke=de=>{de.forEach(be=>ge.current.add(be.jobId)),pe(be=>[...new Map([...be,...de].map(We=>[We.jobId,We])).values()]),de.forEach(Q)},je=async()=>{if(!r){j(l);return}if(_.length===0){j("Select files or folders from the Hub explorer.");return}if(xe.length===0){j("Choose at least one connected workstation.");return}if(Ae){j("A Hub transfer is already running.");return}try{const de=await XA(_,xe,c.trim(),n);ge.current.add(de.jobId),j("Hub transfer queued."),await Oe()}catch(de){j(de instanceof Error?de.message:"Unable to start Hub transfer.")}},De=async de=>{const be=de||_e;if(!be||be.type!=="folder"){j("Select one folder to add it to Sync.");return}try{const We=await tN(be.id,n);O(at=>[...at.filter(wn=>wn.id!==We.folder.id),We.folder]),J("sync"),j(`${be.name} is ready for Hub sync.`)}catch(We){j(We instanceof Error?We.message:"Unable to add the Hub folder to Sync.")}},Le=async de=>{if(xe.length===0){j("Choose at least one connected workstation.");return}oe(!0),O(be=>be.map(We=>We.id===de.id?{...We,status:"syncing"}:We));try{const be=await sN(de.id,xe,c.trim(),n);ke(be.jobs||[]),j(be.jobs?.length?"Hub sync queued.":"No changed files to sync.");const We=await fy(n);O(We)}catch(be){j(be instanceof Error?be.message:"Unable to sync the Hub folder."),O(We=>We.map(at=>at.id===de.id?{...at,status:"error",message:"Sync failed"}:at))}finally{oe(!1)}},$e=async()=>{oe(!0);try{for(const de of V)await Le(de)}finally{oe(!1)}},he=async de=>{try{const be=await nN(de.id,{autoSync:!de.autoSync},n);O(We=>We.map(at=>at.id===de.id?be.folder:at))}catch(be){j(be instanceof Error?be.message:"Unable to update auto sync.")}},Me=async de=>{try{await aN(de.id,n),O(be=>be.filter(We=>We.id!==de.id))}catch(be){j(be instanceof Error?be.message:"Unable to remove the sync folder.")}};return s.jsxs("section",{className:"livedesk-file-explorer",children:[s.jsx("input",{ref:b,className:"hidden-file-input",type:"file",multiple:!0,onChange:de=>{de.currentTarget.files&&w(de.currentTarget.files),de.currentTarget.value=""}}),s.jsx("input",{ref:y,className:"hidden-file-input",type:"file",multiple:!0,webkitdirectory:"",directory:"",onChange:de=>{de.currentTarget.files&&S(de.currentTarget.files),de.currentTarget.value=""}}),s.jsx("div",{className:"file-share-workspace",children:s.jsxs(oN,{onRetry:()=>window.location.reload(),children:[s.jsx(lN,{hubUrl:n,roots:k,loading:R,error:H,onRefreshRoots:Ie,onImportFiles:()=>b.current?.click(),onImportFolder:()=>y.current?.click(),onSelectionChange:ae,onShareItem:de=>{L([de.id]),q([de]),J("send")},onAddSyncFolder:de=>{L([de.id]),q([de]),De(de)},onNotice:j}),s.jsx(mN,{devices:M,targetMode:m,selectedTargetIds:p,onTargetModeChange:g,onTargetToggle:v,remoteDirectory:c,onRemoteDirectoryChange:d,selectedEntries:le,selectedSummary:ie,canShare:r&&!Ae&&_.length>0&&xe.length>0&&!ne,onShare:()=>{je()},canAddSync:!!_e,onAddSync:()=>{De()},tab:we,onTabChange:J,folders:V,foldersLoading:Y,syncBusy:P,onSyncAll:()=>{$e()},onSync:de=>{Le(de)},onToggleAuto:de=>{he(de)},onRemove:de=>{Me(de)},onAddFolder:()=>{De()}})]})}),Ae&&s.jsx("footer",{className:"file-share-workspace-footer",children:s.jsxs("span",{children:[py(Ae)," · ",hy(Ae),"% ",s.jsx("button",{className:"icon-button",onClick:()=>{eN(Ae.jobId,n).then(de=>{pe(be=>be.map(We=>We.jobId===de.jobId?de:We)),Q(de)})},title:"Cancel transfer",type:"button",children:s.jsx(Ja,{size:14})})]})})]})}const gN=u.forwardRef(function({value:a,onChange:r,onSubmit:l,onOpenSuggestedTasks:c,suggestedOpen:d=!1,suggestedTaskCount:m,disabled:p=!1},g){return s.jsxs("form",{className:"agents-composer",onSubmit:v=>{v.preventDefault(),l()},children:[s.jsxs("button",{className:`agents-suggested-trigger ${d?"active":""}`,type:"button","aria-label":m===void 0?"Open Suggested tasks":`Open Suggested tasks (${m} available)`,"aria-expanded":d,onClick:c,disabled:p,children:[s.jsx(e0,{size:17}),m!==void 0&&s.jsx("span",{className:"agents-suggested-count","aria-hidden":"true",children:m})]}),s.jsx("textarea",{ref:g,value:a,onChange:v=>r(v.target.value.slice(0,4e3)),placeholder:"Ask LiveDesk to work across your machines...","aria-label":"Ask LiveDesk",rows:2,disabled:p}),s.jsxs("button",{className:"agents-run-button",type:"submit",disabled:p||!a.trim(),children:[p?s.jsx(qr,{className:"spin",size:16}):s.jsx(Bo,{size:16}),p?"Running":"Run"]})]})}),vN=["read","processControl","serviceControl","applicationControl","fileRead","fileWrite","fileDelete","shell","script","softwareInstall","network","systemPower","systemConfiguration","userAccount"];function iw(n){return n.deviceName?.trim()||n.hostname?.trim()||n.deviceId}function $h(n){return n.connected!==!0?!1:n.synthetic===!0?!0:!n.channels||n.channels.control===!0}function xN(n){return n==="running"||n==="completed"||n==="failed"||n==="cancelled"?n:"queued"}function yN(n){switch(n){case"process.list":return"Process list";case"system.health":return"System health";case"gpu.status":return"GPU status";case"disk.status":return"Disk status";case"service.status":return"Service status";case"diagnostics.collect":return"Diagnostics";case"process.control":return"Process control";case"service.control":return"Service control";case"application.launch":return"Launch application";case"application.close":return"Close application";case"file.read":return"Read file";case"file.write":return"Write file";case"file.delete":return"Delete file";case"file.list":return"List directory";case"command.run":return"Run command";case"script.run":return"Run script";case"software.install":return"Install software";case"network.status":return"Network status";case"system.power":return"Power action";case"system.configure":return"System configuration";case"logs.collect":return"Collect logs"}}function bN(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Za(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Pd(n){const a=Za(n);return a===null?"":a<1024**2?`${Math.round(a/1024)}K`:a<1024**3?`${(a/1024**2).toFixed(0)}M`:`${(a/1024**3).toFixed(1)}G`}function wN(n){const a=Za(n);return a===null?"":`${Math.round((a<=1?a:a/100)*100)}%`}function SN(n){return!n||/^(?:[\w .-]+ )?collected(?:\.)?$/i.test(n.trim())?"":n.trim()}function hf(n,a){if(a.error)return a.error;const r=bN(a.data),l=SN(a.result||"");if(!r)return l||a.stage||a.status;if(n==="system.health"){const c=typeof r.machine=="string"?r.machine:"",d=Pd(r.freeMemoryBytes),m=Pd(r.totalMemoryBytes),p=Za(r.totalMemoryBytes)&&Za(r.freeMemoryBytes)!==null?`${Math.round(Za(r.freeMemoryBytes)/Za(r.totalMemoryBytes)*100)}% RAM free`:"";return[c,d&&m?`RAM ${d}/${m}`:"",p,typeof r.platform=="string"?r.platform:""].filter(Boolean).join(" · ")||l||a.status}if(n==="disk.status"){const c=typeof r.root=="string"?r.root:"",d=Pd(r.freeBytes),m=Za(r.totalBytes)&&Za(r.freeBytes)!==null?`${Math.round(Za(r.freeBytes)/Za(r.totalBytes)*100)}% free`:"";return[c,d&&`${d} free`,m].filter(Boolean).join(" · ")||l||a.status}if(n==="gpu.status"){const c=typeof r.name=="string"&&r.name?r.name:"No GPU provider",d=wN(r.usageRatio),m=Za(r.temperatureC)!==null?`${Math.round(Za(r.temperatureC))}°C`:"",p=Pd(r.freeMemoryBytes);return[c,d&&`GPU ${d}`,m,p&&`${p} free`].filter(Boolean).join(" · ")||l||a.status}if(n==="process.list"){const c=Za(r.count);return c!==null?`${c} matching process${c===1?"":"es"}`:l||a.status}if(n==="network.status"){const c=Array.isArray(r.adapters)?r.adapters.length:null;return c!==null?`${c} active adapter${c===1?"":"s"}`:l||a.status}return l||a.stage||a.status}function vy(n,a){const r=hf(n,a);return a.status==="failed"||a.status==="cancelled"||/\b(?:warning|failed|error|offline|not running|low|timeout|timed out)\b/i.test(`${a.result||""} ${r}`)}function CN({state:n,operation:a}){const r=n.status==="completed"?$r:n.status==="failed"||n.status==="cancelled"?Ja:n.status==="running"?qr:tb,l=n.status==="running"?n.stage||"Working":n.status==="completed"?a?hf(a,n):n.result||"Completed":n.status==="failed"?n.error||"Failed":n.status==="cancelled"?"Cancelled":"Queued";return s.jsxs("div",{className:`agent-target-row status-${n.status}`,"data-agent-target-id":n.deviceId,children:[s.jsx("span",{className:"agent-target-status","aria-hidden":"true",children:s.jsx(r,{size:15})}),s.jsx("strong",{children:n.deviceName}),s.jsx("span",{className:"agent-target-state",children:n.status[0].toUpperCase()+n.status.slice(1)}),s.jsx("small",{children:l})]})}function jN({operation:n,states:a,status:r,onCancel:l,onRetry:c,busy:d=!1}){const m=["running","queued"].includes(r),[p,g]=u.useState(!1),[v,b]=u.useState("all"),y=u.useMemo(()=>({total:a.length,completed:a.filter(R=>R.status==="completed").length,failed:a.filter(R=>R.status==="failed").length,running:a.filter(R=>R.status==="running").length,queued:a.filter(R=>R.status==="queued").length,cancelled:a.filter(R=>R.status==="cancelled").length}),[a]),w=a.filter(R=>vy(n,R)),S=w.filter(R=>R.status==="completed").length,j=y.failed>0,N=w.length>0,M=a.filter(R=>v==="issues"?vy(n,R):v==="running"?R.status==="running"||R.status==="queued":v==="completed"?R.status==="completed":v==="failed"?R.status==="failed":!0),k=N&&!m||r==="completed-with-failures"?"Completed with issues":r[0]?.toUpperCase()+r.slice(1),E=a.filter(R=>R.status==="completed").map(R=>hf(n,R)).filter(Boolean).filter((R,U,H)=>H.indexOf(R)===U).slice(0,2);return s.jsxs("section",{className:"agent-task-block","aria-label":"Task execution",children:[s.jsxs("div",{className:"agent-task-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:"LiveDesk Agent"}),s.jsx("strong",{children:yN(n)})]}),s.jsx("span",{className:`agent-task-status status-${N?"completed-with-failures":r}`,children:k})]}),s.jsxs("div",{className:"agent-task-summary","aria-label":"Task summary",children:[s.jsxs("strong",{children:[y.total," targets"]}),s.jsxs("span",{className:"summary-completed",children:[y.completed," completed"]}),y.running>0&&s.jsxs("span",{className:"summary-running",children:[y.running," running"]}),y.queued>0&&s.jsxs("span",{children:[y.queued," queued"]}),j&&s.jsxs("span",{className:"summary-failed",children:[y.failed," failed"]}),S>0&&s.jsxs("span",{className:"summary-cancelled",children:[S," warning"]}),y.cancelled>0&&s.jsxs("span",{className:"summary-cancelled",children:[y.cancelled," cancelled"]})]}),E.length>0&&s.jsxs("div",{className:"agent-task-result-preview",title:E.join(" · "),children:[s.jsx("span",{children:"Result"}),E.join(" · ")]}),s.jsx("div",{className:"agent-target-chips","aria-label":"Target status overview",children:a.map((R,U)=>{const H=R.status==="completed"?"✓":R.status==="failed"?"×":R.status==="cancelled"?"!":R.status==="running"?"…":"·";return s.jsxs("span",{className:`agent-target-chip status-${R.status}`,title:`${R.deviceName}: ${hf(n,R)}`,"aria-label":`${U+1}. ${R.deviceName}: ${R.status}`,children:[s.jsx("b",{children:String(U+1).padStart(2,"0")}),s.jsx("span",{children:H})]},R.deviceId)})}),a.length>0&&s.jsx("div",{className:"agent-task-details-toggle",children:s.jsxs("button",{type:"button",onClick:()=>g(R=>!R),"aria-expanded":p,children:[p?s.jsx(t0,{size:14}):s.jsx(nb,{size:14}),p?"Hide details":"Show details"]})}),p&&s.jsxs("div",{className:"agent-task-details",children:[s.jsx("div",{className:"agent-task-filters",role:"tablist","aria-label":"Task result filter",children:["all","issues","running","completed","failed"].map(R=>s.jsx("button",{className:v===R?"active":"",onClick:()=>b(R),role:"tab","aria-selected":v===R,type:"button",children:R==="all"?"All":R==="issues"?"Issues only":R[0].toUpperCase()+R.slice(1)},R))}),s.jsx("div",{className:"agent-task-rows",children:M.length>0?M.map(R=>s.jsx(CN,{operation:n,state:R},R.deviceId)):s.jsx("small",{className:"agent-task-no-results",children:"No targets match this filter."})})]}),(m||j)&&s.jsxs("div",{className:"agent-task-actions",children:[m&&l&&s.jsxs("button",{onClick:l,disabled:d,type:"button",children:[s.jsx(n0,{size:14})," Cancel"]}),!m&&j&&c&&s.jsxs("button",{onClick:c,disabled:d,type:"button",children:[s.jsx(Qc,{size:14})," Retry failed"]})]})]})}function kN(n){try{return JSON.stringify(n,null,2).slice(0,6e3)}catch{return"{}"}}function AN({approval:n,busy:a=!1,onApprove:r,onReject:l}){return s.jsxs("article",{className:"agent-approval-card","aria-label":"Agent approval required",children:[s.jsxs("div",{className:"agent-approval-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Approval required"}),s.jsx("strong",{children:n.toolName})]}),s.jsx("span",{className:`agent-approval-risk risk-${n.risk}`,children:n.risk})]}),s.jsx("p",{children:n.description}),s.jsx("pre",{children:kN(n.arguments)}),s.jsxs("small",{children:["Permission: ",n.permissionMode," · Scope: selected devices only · Expires in 5 minutes"]}),s.jsxs("div",{className:"agent-approval-actions",children:[s.jsxs("button",{className:"reject",disabled:a,onClick:l,type:"button",children:[s.jsx(Ja,{size:14})," Reject"]}),s.jsxs("button",{disabled:a,onClick:()=>r("once"),type:"button",children:[s.jsx($r,{size:14})," Once"]}),s.jsx("button",{disabled:a,onClick:()=>r("same-action-this-run"),type:"button",children:"Allow same action"}),s.jsx("button",{disabled:a,onClick:()=>r("category-this-run"),type:"button",children:"Allow category"})]}),s.jsxs("div",{className:"agent-approval-scope",children:[s.jsx(gf,{size:13})," Approval is bound to this run, tool, arguments, selected devices, and policy hash."]})]})}function NN(n){return n==="queued"?"Request queued":n==="checking-codex"?"Checking Codex":n==="preparing-tools"?"Preparing tools":n==="thinking"?"Preparing answer":n==="tool-running"?"Working on computers":n==="recovering"?"Retrying safely":n==="waiting-approval"?"Waiting for approval":"Working"}function MN({items:n,onCancel:a,onRetry:r,busyBatchId:l,approvals:c,onApprove:d,onReject:m,busyApprovalId:p,progress:g}){const v=u.useRef(null),b=u.useRef(!0),y=u.useRef(""),w=n[n.length-1];return u.useLayoutEffect(()=>{const S=v.current;S&&(w?.type==="user"&&w.id!==y.current&&(b.current=!0),y.current=w?.id||"",b.current&&(S.scrollTop=S.scrollHeight))},[c,n,w?.id,w?.type,g?.message,g?.stage]),s.jsxs("section",{className:"agents-conversation","aria-live":"polite",ref:v,onScroll:S=>{const j=S.currentTarget;b.current=j.scrollHeight-j.scrollTop-j.clientHeight<72},children:[c.filter(S=>S.status==="pending").map(S=>s.jsx(AN,{approval:S,busy:p===S.approvalId,onApprove:j=>d(S,j),onReject:()=>m(S)},S.approvalId)),n.length===0&&s.jsxs("div",{className:"agents-empty-conversation",children:[s.jsx("strong",{children:"Ask LiveDesk to work across your machines."}),s.jsx("span",{children:"Start with a read-only request such as “모든 PC에서 ComfyUI가 실행 중인지 확인해줘”."})]}),n.map(S=>{if(S.type==="task"){const j=S;return s.jsx(jN,{operation:j.operation,states:j.states,status:j.status,onCancel:()=>a(j.batchId,j.agentRunId),onRetry:()=>r(j.batchId),busy:l===j.batchId},j.id)}return s.jsxs("article",{className:`agents-message ${S.type}`,children:[s.jsx("span",{children:S.type==="user"?"You":"LiveDesk Agent"}),s.jsx("p",{children:S.text})]},S.id)}),g&&s.jsxs("article",{className:"agents-message agent agents-progress-message",role:"status",children:[s.jsxs("span",{children:[s.jsx(qr,{"aria-hidden":"true",size:15}),NN(g.stage)]}),s.jsx("p",{children:g.message})]})]})}const xy=["Recommended","Health & capacity","Processes & services","AI workloads","Files & configuration","Software & automation","Network & connectivity","Power & maintenance","Troubleshooting & recovery"],yn=["windows","macos","linux"],Fr={"system.health":{label:"system health",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:yn},"gpu.status":{label:"GPU status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:yn},"disk.status":{label:"disk status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:yn},"process.list":{label:"process inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:yn},"service.status":{label:"service inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:yn},"diagnostics.collect":{label:"diagnostics collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:yn},"process.control":{label:"process control",permissionCategory:"processControl",readOnly:!1,risk:"high",supportedPlatforms:yn},"service.control":{label:"service control",permissionCategory:"serviceControl",readOnly:!1,risk:"high",supportedPlatforms:["windows","linux"]},"application.launch":{label:"application launch",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:yn},"application.close":{label:"application close",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:yn},"file.read":{label:"file reading",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:yn},"file.write":{label:"file writing",permissionCategory:"fileWrite",readOnly:!1,risk:"high",supportedPlatforms:yn},"file.delete":{label:"file deletion",permissionCategory:"fileDelete",readOnly:!1,risk:"critical",supportedPlatforms:yn},"file.list":{label:"directory listing",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:yn},"command.run":{label:"command execution",permissionCategory:"shell",readOnly:!1,risk:"critical",supportedPlatforms:yn},"script.run":{label:"script execution",permissionCategory:"script",readOnly:!1,risk:"high",supportedPlatforms:yn},"software.install":{label:"software installation",permissionCategory:"softwareInstall",readOnly:!1,risk:"high",supportedPlatforms:yn},"network.status":{label:"network inspection",permissionCategory:"network",readOnly:!0,risk:"low",supportedPlatforms:yn},"system.power":{label:"power control",permissionCategory:"systemPower",readOnly:!1,risk:"critical",supportedPlatforms:yn},"system.configure":{label:"system configuration",permissionCategory:"systemConfiguration",readOnly:!1,risk:"critical",supportedPlatforms:yn},"logs.collect":{label:"log collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:yn}};new Set(Object.keys(Fr));const TN={Recommended:["recommended","overview","fleet","요약","추천"],"Health & capacity":["health","capacity","performance","상태","성능","용량"],"Processes & services":["process","service","application","프로세스","서비스","앱"],"AI workloads":["ai","gpu","comfyui","ollama","인공지능","모델"],"Files & configuration":["file","config","directory","파일","설정","폴더"],"Software & automation":["software","install","automation","프로그램","설치","자동화"],"Network & connectivity":["network","connection","adapter","네트워크","연결","어댑터"],"Power & maintenance":["power","maintenance","restart","전원","유지보수","재시작"],"Troubleshooting & recovery":["troubleshooting","recovery","incident","문제해결","복구","장애"]},yy=["low","medium","high","critical"];function EN(n){return n.reduce((a,r)=>{const l=Fr[r].risk;return yy.indexOf(l)>yy.indexOf(a)?l:a},"low")}function RN(n){return yn.filter(a=>n.every(r=>Fr[r].supportedPlatforms.includes(a)))}function Pe(n,a,r,l,c,d,m={}){const p=m.description||l,g=c.flatMap(b=>b.split(".")),v=[...new Set([...TN[a],...d,...g])];return{id:n,category:a,title:r,prompt:l,description:p,requiredOperations:c,risk:m.risk||EN(c),targetSupport:m.targetSupport||"single-or-multiple",supportedPlatforms:m.supportedPlatforms||RN(c),keywords:v,recommended:m.recommended??!1,enabled:!0}}const rw=[Pe("recommended-fleet-health","Recommended","Summarize current target health","Summarize system health, GPU, and disk capacity for the current target workstations.",["system.health","gpu.status","disk.status"],["summary","overview"],{recommended:!0}),Pe("recommended-attention","Recommended","Find targets needing attention","Identify current targets with high resource use, low disk space, or service warnings.",["system.health","disk.status","service.status"],["attention","warning","monitor"],{recommended:!0}),Pe("recommended-performance-compare","Recommended","Compare selected performance","Compare CPU, memory, disk, and GPU capacity across the current targets.",["system.health","disk.status","gpu.status"],["compare","benchmark"],{recommended:!0}),Pe("recommended-gpu-vram","Recommended","Review GPU and VRAM availability","Show GPU temperature, utilization, and VRAM availability for the current targets.",["gpu.status"],["graphics","temperature","utilization"],{recommended:!0}),Pe("recommended-low-disk","Recommended","Locate low disk capacity","Find current targets with low free disk capacity and report the affected volumes.",["disk.status"],["storage","free space","capacity"],{recommended:!0}),Pe("recommended-ai-workers","Recommended","Verify ComfyUI and Ollama workers","Check whether ComfyUI and Ollama workers and their services are available on the current targets.",["process.list","service.status"],["comfyui","ollama","worker"],{recommended:!0}),Pe("recommended-recover-ai","Recommended","Recover stopped AI workers","Find stopped AI workers and relaunch the registered worker application or service on the target workstation.",["process.list","application.launch","service.control"],["recover","start","ai worker"],{targetSupport:"single",recommended:!0}),Pe("recommended-incident-diagnostics","Recommended","Collect an incident diagnostic bundle","Collect health, service, network, and recent log diagnostics for the current targets.",["diagnostics.collect","logs.collect","system.health","network.status"],["incident","report","evidence"],{recommended:!0}),Pe("health-cpu-memory","Health & capacity","Check high CPU and memory use","Find current targets with unusually high CPU or memory usage.",["system.health"],["cpu","memory","load","높은 사용량"]),Pe("health-uptime","Health & capacity","Review workstation uptime","Show uptime, boot time, and current system health for the target workstations.",["system.health"],["uptime","boot","가동시간"]),Pe("health-gpu-temperature","Health & capacity","Check GPU temperature","Check GPU temperature and thermal warnings on the current targets.",["gpu.status"],["thermal","temperature","발열"]),Pe("health-vram-usage","Health & capacity","Check VRAM usage","Report GPU memory usage and remaining VRAM on the current targets.",["gpu.status"],["vram","gpu memory","video memory"]),Pe("health-low-disk","Health & capacity","Find low disk space","Find volumes below a safe free-space threshold on the current targets.",["disk.status"],["disk","storage","free space","디스크"]),Pe("health-gpu-compare","Health & capacity","Compare GPU capacity","Compare GPU model, memory, temperature, and utilization across the current targets.",["gpu.status"],["compare","graphics","capacity"]),Pe("health-system-warnings","Health & capacity","Collect system warnings","Review health, disk, and network status for warnings that need attention.",["system.health","disk.status","network.status"],["warnings","alerts","경고"]),Pe("health-capacity-report","Health & capacity","Build a capacity report","Create a concise capacity report covering CPU, memory, GPU, disk, and network status.",["system.health","gpu.status","disk.status","network.status"],["report","capacity","inventory"]),Pe("process-find-name","Processes & services","Find a running process by name","Find process named [process name] on the current targets.",["process.list"],["find","running","name","실행 중"]),Pe("process-resource-heavy","Processes & services","Find resource-heavy processes","List the processes using the most CPU or memory on the current targets.",["process.list","system.health"],["top","cpu","memory","resource"]),Pe("process-stop-named","Processes & services","Stop a named process","Stop process named [process name] on the target workstation after checking its current state.",["process.list","process.control"],["stop","terminate","종료"],{targetSupport:"single"}),Pe("process-restart-named","Processes & services","Restart a named process","Check process named [process name] and restart it with its registered launch details when available.",["process.list","process.control"],["restart","relaunch","재시작"],{targetSupport:"single"}),Pe("process-launch-app","Processes & services","Launch a registered application","Launch the registered application [application] on the target workstation with [arguments].",["application.launch"],["launch","open","실행"],{targetSupport:"single"}),Pe("process-close-app","Processes & services","Close an application","Close application [application] on the target workstation and report whether it exited cleanly.",["application.close","process.list"],["close","exit","앱 종료"],{targetSupport:"single"}),Pe("service-status-name","Processes & services","Check a service status","Check service [service name] and report its state on the current targets.",["service.status"],["service","status","서비스 상태"]),Pe("service-restart-name","Processes & services","Restart a service safely","Check service [service name], stop it, wait for it to stop, then start it and verify the result.",["service.status","service.control"],["restart","start","stop","서비스 재시작"],{targetSupport:"single"}),Pe("ai-comfyui-status","AI workloads","Check ComfyUI availability","Check the ComfyUI process, service state, and GPU readiness on the current targets.",["process.list","service.status","gpu.status"],["comfyui","stable diffusion","image generation"]),Pe("ai-start-comfyui","AI workloads","Start ComfyUI","If ComfyUI is stopped, launch its registered application or service and verify it is running.",["process.list","application.launch","service.status"],["comfyui","start","launch"],{targetSupport:"single"}),Pe("ai-restart-ollama","AI workloads","Restart Ollama","Check Ollama, restart its registered application or service, and verify the worker is ready.",["process.list","application.close","application.launch","service.status"],["ollama","restart","llm"],{targetSupport:"single"}),Pe("ai-stable-diffusion","AI workloads","Check Stable Diffusion workers","Check Stable Diffusion or Automatic1111 processes and their GPU usage on the current targets.",["process.list","gpu.status"],["stable diffusion","automatic1111","sd"]),Pe("ai-gpu-readiness","AI workloads","Check GPU readiness for AI","Check GPU temperature, VRAM, utilization, and system health before an AI workload starts.",["gpu.status","system.health"],["readiness","inference","training"]),Pe("ai-worker-logs","AI workloads","Collect AI worker logs","Collect recent logs and relevant log files for the AI worker on the target workstation.",["logs.collect","file.list","file.read"],["logs","diagnostics","worker"],{targetSupport:"single"}),Pe("ai-llama-cpp","AI workloads","Check llama.cpp workers","Find llama.cpp or local model worker processes and inspect their recent logs.",["process.list","logs.collect"],["llama.cpp","local model","inference"]),Pe("ai-recover-orphan-python","AI workloads","Recover an orphaned Python worker","Find an orphaned Python AI worker, stop the stale process, then launch its registered worker again.",["process.list","process.control","application.launch"],["python","orphaned","recovery"],{targetSupport:"single"}),Pe("files-list-directory","Files & configuration","List a directory","List files and folders under [path] on the target workstation.",["file.list"],["directory","folder","list","목록"],{targetSupport:"single"}),Pe("files-read-config","Files & configuration","Read a configuration file","Read the relevant settings from configuration file [path] on the target workstation.",["file.read"],["config","settings","read","구성"]),Pe("files-recent-logs","Files & configuration","Find recent log files","List recent log files under [path] and summarize the latest entries.",["file.list","file.read"],["logs","recent","tail"]),Pe("files-update-config","Files & configuration","Update a configuration value","Read configuration file [path], update [change], and report the exact change made.",["file.read","file.write"],["edit","update","설정 변경"],{targetSupport:"single"}),Pe("files-delete-temp","Files & configuration","Delete temporary files","Find temporary files under [path], delete only the requested matches, and report the freed space.",["file.list","file.delete","disk.status"],["cleanup","temp","delete","정리"],{targetSupport:"single"}),Pe("files-compare-config","Files & configuration","Compare configuration files","Read configuration file [path] on the target workstation and compare it with [reference path].",["file.read"],["compare","diff","configuration"]),Pe("files-set-environment","Files & configuration","Set an environment variable","Set environment variable [name] to [value] for the target workstation and verify the resulting configuration.",["system.configure","file.read"],["environment","variable","env","환경변수"],{targetSupport:"single"}),Pe("files-archive-diagnostics","Files & configuration","Write a diagnostic manifest","Collect selected diagnostics and write a manifest file to [path] on the target workstation.",["diagnostics.collect","file.write"],["manifest","export","diagnostic file"],{targetSupport:"single"}),Pe("software-winget-install","Software & automation","Install software with winget","Install package [package name] with winget on the Windows target workstation, then verify it.",["software.install","process.list"],["winget","windows","install","설치"],{targetSupport:"single",supportedPlatforms:["windows"]}),Pe("software-apt-install","Software & automation","Install software with apt","Install package [package name] with apt on the Linux target workstation, then verify it.",["software.install","process.list"],["apt","linux","package","설치"],{targetSupport:"single",supportedPlatforms:["linux"]}),Pe("software-brew-install","Software & automation","Install software with Homebrew","Install package [package name] with brew on the macOS target workstation, then verify it.",["software.install","process.list"],["brew","homebrew","macos","설치"],{targetSupport:"single",supportedPlatforms:["macos"]}),Pe("software-npm-install","Software & automation","Install an npm package","Install npm package [package name] on the target workstation and verify the installed version.",["software.install","command.run"],["npm","node","package"],{targetSupport:"single"}),Pe("software-run-script","Software & automation","Run a registered script","Run the registered script [script path] on the target workstation and report its result.",["script.run"],["script","automation","registered"],{targetSupport:"single"}),Pe("software-run-command","Software & automation","Run a command on one target","Run command [command] on the target workstation and return its exit status and output.",["command.run"],["command","shell","terminal"],{targetSupport:"single"}),Pe("software-verify-install","Software & automation","Verify an installed tool","Check whether [application] is installed, running, and available on the PATH of the current targets.",["process.list","system.health"],["verify","installed","path"]),Pe("software-toolchain-setup","Software & automation","Set up a toolchain","Install the requested package [package name], configure [change], and verify the toolchain on the target workstation.",["software.install","system.configure","process.list"],["toolchain","setup","developer"],{targetSupport:"single"}),Pe("network-adapter-status","Network & connectivity","Check network adapters","Show adapter state, address, and link information for the current targets.",["network.status"],["adapter","ethernet","wifi","네트워크 상태"]),Pe("network-disconnected","Network & connectivity","Find disconnected targets","Find current targets with disconnected or degraded network adapters.",["network.status"],["disconnected","offline","연결 끊김"]),Pe("network-link-speed","Network & connectivity","Check link speed","Report network link speed and duplex information for the current targets.",["network.status"],["speed","bandwidth","duplex"]),Pe("network-warnings","Network & connectivity","Review network warnings","Review network status and recent logs for connectivity warnings on the current targets.",["network.status","logs.collect"],["warning","latency","packet loss"]),Pe("network-diagnostics","Network & connectivity","Collect network diagnostics","Collect network status, system diagnostics, and relevant logs for the current targets.",["network.status","diagnostics.collect","logs.collect"],["diagnostics","incident","connectivity"]),Pe("network-service-failures","Network & connectivity","Find network service failures","Check network status and relevant service states on the current targets.",["network.status","service.status"],["service","failure","dns"]),Pe("network-compare","Network & connectivity","Compare target connectivity","Compare adapter state, addresses, and link speed across the current targets.",["network.status"],["compare","inventory","connectivity"]),Pe("network-intermittent","Network & connectivity","Investigate intermittent connectivity","Investigate intermittent connectivity using network status, service state, and diagnostics evidence.",["network.status","service.status","diagnostics.collect"],["intermittent","unstable","recovery"]),Pe("power-lock","Power & maintenance","Lock the workstation","Lock the target workstation and report the resulting power action status.",["system.power"],["lock","security","잠금"],{targetSupport:"single",risk:"critical"}),Pe("power-logoff","Power & maintenance","Log off the workstation","Log off the target workstation after warning that interactive sessions will close.",["system.power"],["logoff","session","로그오프"],{targetSupport:"single",risk:"critical"}),Pe("power-sleep","Power & maintenance","Put the workstation to sleep","Put the target workstation to sleep after confirming the requested delay of [delay].",["system.power"],["sleep","suspend","절전"],{targetSupport:"single",risk:"critical"}),Pe("power-restart","Power & maintenance","Restart the workstation","Restart the target workstation after confirming that active work may be interrupted.",["system.power"],["restart","reboot","재부팅"],{targetSupport:"single",risk:"critical"}),Pe("power-shutdown","Power & maintenance","Shut down the workstation","Shut down the target workstation after confirming that active work may be interrupted.",["system.power"],["shutdown","power off","종료"],{targetSupport:"single",risk:"critical"}),Pe("power-maintenance-restart","Power & maintenance","Restart after maintenance","Check the target workstation, restart it after maintenance, and verify that it returns online.",["system.health","system.power","network.status"],["maintenance","reboot","verify"],{targetSupport:"single",risk:"critical"}),Pe("power-timezone","Power & maintenance","Set the workstation timezone","Set the target workstation timezone to [timezone] and verify the resulting system configuration.",["system.configure"],["timezone","clock","시간대"],{targetSupport:"single",risk:"critical"}),Pe("power-persistent-environment","Power & maintenance","Persist an environment variable","Persist environment variable [name] with value [value] for the target workstation and verify it.",["system.configure"],["environment","persistent","환경변수"],{targetSupport:"single",risk:"critical"}),Pe("recovery-app-wont-start","Troubleshooting & recovery","Investigate an app that will not start","Inspect [application], review its logs, launch the registered application, and verify the process.",["process.list","application.launch","logs.collect"],["app failure","start","실행 오류"],{targetSupport:"single"}),Pe("recovery-failed-service","Troubleshooting & recovery","Recover a failed service","Inspect service [service name], collect logs, restart it safely, and verify its running state.",["service.status","logs.collect","service.control"],["service failure","recover","서비스 복구"],{targetSupport:"single"}),Pe("recovery-repeated-process","Troubleshooting & recovery","Investigate a repeatedly stopping process","Inspect process [process name], collect diagnostics, stop stale instances, and relaunch the registered process.",["process.list","diagnostics.collect","process.control","application.launch"],["crash loop","process","반복 종료"],{targetSupport:"single"}),Pe("recovery-low-disk","Troubleshooting & recovery","Recover from low disk space","Inspect disk capacity, find temporary files, remove only the requested files, and verify free space.",["disk.status","file.list","file.delete"],["disk full","cleanup","저장공간 부족"],{targetSupport:"single"}),Pe("recovery-gpu-overheating","Troubleshooting & recovery","Investigate GPU overheating","Inspect GPU temperature and processes, then close the specified workload if it is causing the thermal warning.",["gpu.status","process.list","application.close"],["overheating","thermal","GPU 발열"],{targetSupport:"single"}),Pe("recovery-high-vram","Troubleshooting & recovery","Recover high VRAM usage","Inspect VRAM usage and GPU processes, then stop the specified stale workload if necessary.",["gpu.status","process.list","process.control"],["vram","memory pressure","VRAM 부족"],{targetSupport:"single"}),Pe("recovery-network-instability","Troubleshooting & recovery","Recover network instability","Collect network diagnostics, inspect network services, and report the safest recovery action for the target workstation.",["network.status","service.status","diagnostics.collect"],["network","unstable","네트워크 복구"],{targetSupport:"single"}),Pe("recovery-incident-report","Troubleshooting & recovery","Create a full incident report","Create a full incident report from health, process, service, network, and log evidence for the current targets.",["system.health","process.list","service.status","network.status","logs.collect"],["incident","report","장애 보고서"])],uh={read:"allow",processControl:"allow",serviceControl:"allow",applicationControl:"ask",fileRead:"allow",fileWrite:"allow",fileDelete:"ask",shell:"ask",script:"ask",softwareInstall:"ask",network:"allow",systemPower:"ask",systemConfiguration:"ask",userAccount:"deny"};function DN(n,a){return n==="safe-auto"?uh:n==="full-access"?{...uh,processControl:"allow",serviceControl:"allow",applicationControl:"allow",fileDelete:"allow",shell:"allow",script:"allow",softwareInstall:"allow",systemPower:"allow",systemConfiguration:"allow"}:n==="custom"&&a?a:{...uh,processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileWrite:"ask",network:"ask"}}function LN(n,a,r){const l=DN(a,r),c=n.requiredOperations.map(d=>l[Fr[d].permissionCategory]);if(c.includes("deny")){const d=n.requiredOperations.find(m=>l[Fr[m].permissionCategory]==="deny");return{state:"blocked",label:"Blocked",reason:`This task requires ${Fr[d].label}, which is blocked by the current permission policy.`}}return c.includes("ask")?{state:"approval",label:"Approval required",reason:"This task requires approval before the requested changes can reach a workstation."}:n.requiredOperations.every(d=>Fr[d].readOnly)?{state:"read-only",label:"Read only"}:a==="full-access"?{state:"full-access",label:"Full Access"}:{state:"auto",label:"Auto allowed"}}function _N(n){const a=String(n||"").trim().toLowerCase();return a==="windows"||a==="win32"||a==="win32nt"?"windows":a==="macos"||a==="macosx"||a==="darwin"||a==="osx"?"macos":a==="linux"?"linux":null}function zN(n,a,r){const l=new Set(r);return n.filter(c=>c.connected&&(a==="all"||l.has(c.deviceId)))}function IN(n,a){const r=_N(n.platform);if(!r||!a.supportedPlatforms.includes(r))return!1;const l=n.capabilities?.agentTools;return!Array.isArray(l)||l.length===0?a.requiredOperations.every(c=>Fr[c].readOnly):a.requiredOperations.every(c=>l.includes(c))}function lw(n,a,r,l,c,d){const m=LN(n,c,d),p=zN(a,r,l),g=p.map(S=>S.deviceId),v={...m,available:!1,availableDeviceIds:[],unsupportedDeviceIds:g,risk:n.risk,supportedPlatforms:n.supportedPlatforms};if(p.length===0)return{...v,reason:"Select at least one connected workstation."};if(n.targetSupport==="single"&&p.length!==1)return{...v,reason:"This task supports one workstation at a time."};if(m.state==="blocked")return v;const b=p.filter(S=>IN(S,n)),y=b.map(S=>S.deviceId),w=g.filter(S=>!y.includes(S));return b.length===0?{...v,unsupportedDeviceIds:w,reason:"No current target supports the required platform and client capabilities."}:{...v,available:!0,availableDeviceIds:y,unsupportedDeviceIds:w}}function ON(n,a,r,l,c,d){return n.filter(m=>m.enabled&&lw(m,a,r,l,c,d).available).length}const dh="livedesk.agentPromptRecent",fh="livedesk.agentPromptFavorites",HN={Recommended:Ol,"Health & capacity":cn,"Processes & services":l0,"AI workloads":Qy,"Files & configuration":r0,"Software & automation":sf,"Network & connectivity":ep,"Power & maintenance":Lt,"Troubleshooting & recovery":i0};function by(n){if(typeof window>"u")return[];try{const a=JSON.parse(window.localStorage.getItem(n)||"[]");return Array.isArray(a)?a.filter(r=>typeof r=="string"):[]}catch{return[]}}function $d(n,a){try{window.localStorage.setItem(n,JSON.stringify(a))}catch{}}function mh(n){return n==="all"?"All tasks":n==="recent"?"Recent":n==="favorites"?"Favorites":n==="read-only"?"Read only":n==="auto"?"Auto allowed":n==="approval"?"Approval required":n==="full-access"?"Full Access":n==="available"?"Available":n==="unavailable"?"Unavailable":n}function BN(n){return n==="all"?"All":n==="recent"?"Recent":n==="favorites"?"Favorites":n==="read-only"?"Read only":n==="auto"?"Auto":n==="approval"?"Approval":n==="full-access"?"Full access":n==="available"?"Available":n==="unavailable"?"Unavailable":{Recommended:"Recommended","Health & capacity":"Health","Processes & services":"Processes","AI workloads":"AI","Files & configuration":"Files","Software & automation":"Software","Network & connectivity":"Network","Power & maintenance":"Power","Troubleshooting & recovery":"Recovery"}[n]}function FN(n,a,r){if(!r.trim())return!0;const l=r.trim().toLowerCase();return[n.title,n.prompt,n.description,n.category,n.risk,a.label,...n.keywords,...n.requiredOperations,...n.supportedPlatforms].join(" ").toLowerCase().includes(l)}function PN(n){return`permission-${n}`}function $N(n){return n==="low"?"Low risk":n==="medium"?"Medium risk":n==="high"?"High risk":"Critical risk"}function UN(n){return n==="windows"?"Windows":n==="macos"?"macOS":"Linux"}function qN({devices:n,targetMode:a,selectedIds:r,permissionMode:l,customCategories:c,onSelectPrompt:d,onClose:m}){const[p,g]=u.useState(""),[v,b]=u.useState("all"),[y,w]=u.useState(()=>by(dh)),[S,j]=u.useState(()=>by(fh)),[N,M]=u.useState(0),[k,E]=u.useState(""),R=u.useRef(null),U=u.useRef(null),H=u.useMemo(()=>rw.filter(V=>V.enabled),[]),W=u.useMemo(()=>new Map(H.map(V=>[V.id,lw(V,n,a,r,l,c)])),[c,n,l,r,a,H]),_=u.useMemo(()=>[...W.values()].filter(V=>V.available).length,[W]),L=u.useMemo(()=>n.filter(V=>V.connected&&(a==="all"||r.includes(V.deviceId))).length,[n,r,a]),le=u.useMemo(()=>{const V=H.filter(O=>FN(O,W.get(O.id),p));return v==="recent"?y.map(O=>V.find(Y=>Y.id===O)).filter(O=>!!O):v==="favorites"?S.map(O=>V.find(Y=>Y.id===O)).filter(O=>!!O):v==="all"?V:V.filter(O=>{const Y=W.get(O.id);return v==="read-only"?Y.state==="read-only":v==="auto"?Y.state==="auto":v==="approval"?Y.state==="approval":v==="full-access"?Y.state==="full-access":v==="available"?Y.available:v==="unavailable"?!Y.available:O.category===v})},[W,S,v,y,p,H]),q=u.useMemo(()=>v!=="all"?[{category:mh(v),templates:le}]:xy.map(V=>({category:V,templates:le.filter(O=>O.category===V)})).filter(V=>V.templates.length>0),[v,le]);u.useEffect(()=>{M(V=>Math.min(V,Math.max(0,le.length-1)))},[le.length]),u.useEffect(()=>{$d(dh,y)},[y]),u.useEffect(()=>{$d(fh,S)},[S]),u.useEffect(()=>{U.current?.focus();const V=Y=>{Y.target instanceof Node&&!R.current?.contains(Y.target)&&m()},O=Y=>{Y.key==="Escape"&&(Y.preventDefault(),m())};return document.addEventListener("pointerdown",V),document.addEventListener("keydown",O),()=>{document.removeEventListener("pointerdown",V),document.removeEventListener("keydown",O)}},[m]);const te=V=>{const O=W.get(V.id);if(!O.available){E(O.reason||"This task is not available for the current targets and permission policy.");return}const Y=[V.id,...y.filter(X=>X!==V.id)].slice(0,10);w(Y),$d(dh,Y),d(V.prompt),m()},K=V=>{j(O=>{const Y=O.includes(V)?O.filter(X=>X!==V):[V,...O];return $d(fh,Y),Y})},ne=V=>{V.key==="ArrowDown"?(V.preventDefault(),M(O=>Math.min(O+1,Math.max(0,le.length-1)))):V.key==="ArrowUp"?(V.preventDefault(),M(O=>Math.max(O-1,0))):V.key==="Enter"&&le[N]&&(V.preventDefault(),te(le[N]))};let ce=-1;return s.jsxs("section",{className:"agents-suggested-tasks",ref:R,"aria-label":"Suggested tasks",children:[s.jsxs("header",{className:"agents-suggested-header",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"agents-suggested-title",children:[s.jsx(Ol,{size:15})," Suggested tasks"]}),s.jsxs("small",{children:[_," available · ",H.length," total. Choose a task, edit it, then run it."]})]}),s.jsx("button",{className:"agents-suggested-close",type:"button","aria-label":"Close suggested tasks",onClick:m,children:s.jsx(Ja,{size:16})})]}),s.jsxs("label",{className:"agents-suggested-search",children:[s.jsx(a0,{size:15,"aria-hidden":"true"}),s.jsx("input",{ref:U,value:p,onChange:V=>g(V.target.value),onKeyDown:ne,placeholder:"Search tasks...","aria-label":"Search suggested tasks"})]}),s.jsx("div",{className:"agents-suggested-filters","aria-label":"Task categories and availability filters",children:["all","recent","favorites","read-only","auto","approval","full-access","available","unavailable",...xy].map(V=>{const O=V==="recent"?Ky:V==="favorites"?kh:V==="all"?Ol:V==="available"?Hn:V==="unavailable"?s0:V==="read-only"||V==="auto"||V==="approval"||V==="full-access"?Lt:HN[V];return s.jsxs("button",{className:v===V?"active":"",type:"button",title:mh(V),"aria-label":mh(V),"aria-pressed":v===V,onClick:()=>{b(V),M(0),E("")},children:[s.jsx(O,{size:12})," ",BN(V)]},V)})}),k&&s.jsx("div",{className:"agents-suggested-notice",role:"status",children:k}),s.jsxs("div",{className:"agents-suggested-list",role:"listbox","aria-label":"Suggested tasks",children:[q.map(V=>s.jsxs("div",{className:"agents-suggested-group",children:[s.jsx("strong",{children:V.category}),V.templates.map(O=>{ce+=1;const Y=ce===N,X=S.includes(O.id),P=W.get(O.id),oe=P.availableDeviceIds.length+P.unsupportedDeviceIds.length||L,we=P.available?`Available on ${P.availableDeviceIds.length} of ${oe} target${oe===1?"":"s"}`:`Unavailable: ${P.reason||"not supported by the current targets"}`;return s.jsxs("div",{className:`agents-suggested-item ${Y?"active":""} ${P.available?"":"unavailable"}`,children:[s.jsxs("button",{className:"agents-suggested-prompt",type:"button",role:"option","aria-selected":Y,"aria-disabled":!P.available,onClick:()=>te(O),children:[s.jsx("span",{children:O.title}),s.jsx("small",{className:"agents-suggested-description",children:O.description}),s.jsxs("span",{className:"agents-suggested-meta",children:[s.jsx("em",{children:O.category}),s.jsx("em",{className:PN(P.state),children:P.label}),s.jsx("em",{className:`risk-${O.risk}`,children:$N(O.risk)}),s.jsx("em",{children:O.supportedPlatforms.map(UN).join(" · ")}),s.jsx("em",{className:P.available?"availability-ok":"availability-unavailable",children:we}),P.available&&P.unsupportedDeviceIds.length>0&&s.jsxs("em",{className:"availability-warning",children:["Unsupported on ",P.unsupportedDeviceIds.length]})]})]}),s.jsx("button",{className:`agents-suggested-favorite ${X?"favorite":""}`,type:"button","aria-label":X?`Remove ${O.title} from favorites`:`Add ${O.title} to favorites`,"aria-pressed":X,onClick:()=>K(O.id),children:s.jsx(kh,{size:14,fill:X?"currentColor":"none"})})]},O.id)})]},V.category)),le.length===0&&s.jsx("p",{className:"agents-suggested-empty",children:"No tasks match this search or current filter."})]})]})}function GN({devices:n,mode:a,selectedIds:r,onModeChange:l,onToggle:c,permissionMode:d,onPermissionModeChange:m}){const p=n.filter($h),g=r.filter(v=>p.some(b=>b.deviceId===v)).length;return s.jsxs("section",{className:"agents-target-picker","aria-label":"Agent targets",children:[s.jsxs("div",{className:"agents-target-toolbar",children:[s.jsx("span",{className:"agents-section-label",children:"Targets"}),s.jsxs("div",{className:"agents-target-modes",children:[s.jsxs("button",{className:a==="all"?"active":"",onClick:()=>l("all"),type:"button",children:[s.jsx(eb,{size:14})," All connected ",s.jsx("small",{children:p.length})]}),s.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>l("selected"),type:"button",children:[s.jsx($r,{size:14})," Selected ",g]})]}),s.jsxs("label",{className:`agents-permission-picker permission-${d}`,children:[s.jsx(gf,{size:14}),s.jsx("span",{children:"Permission"}),s.jsxs("select",{value:d,onChange:v=>m(v.target.value),"aria-label":"Agent permission mode",children:[s.jsx("option",{value:"ask",children:"Ask"}),s.jsx("option",{value:"safe-auto",children:"Safe Auto"}),s.jsx("option",{value:"full-access",children:"Full Access"}),s.jsx("option",{value:"custom",children:"Custom"})]}),s.jsx(nb,{size:13,"aria-hidden":"true"})]})]}),s.jsx("div",{className:"agents-target-list",children:n.length===0?s.jsx("span",{className:"agents-target-empty",children:"No workstations discovered."}):n.map(v=>{const b=$h(v),y=a==="all"?b:r.includes(v.deviceId);return s.jsxs("label",{className:`agents-target-option ${y?"selected":""} ${b?"":"offline"}`,children:[s.jsx("input",{type:"checkbox",checked:y,disabled:!b||a==="all",onChange:()=>c(v.deviceId)}),s.jsx("span",{className:"agents-target-icon",children:s.jsx(en,{size:15})}),s.jsxs("span",{children:[s.jsx("strong",{children:iw(v)}),s.jsx("small",{children:b?"Ready":v.connected?"Agent reconnecting":"Offline"})]}),y&&s.jsx($r,{className:"agents-target-check",size:15,"aria-hidden":"true"})]},v.deviceId)})})]})}async function VN(n,a){return Ge("/api/settings/agent/plan",{method:"POST",body:JSON.stringify({instruction:a})},n)}async function WN(n,a){return Ge("/api/settings/agent/run",{method:"POST",body:JSON.stringify(a)},n)}async function YN(n,a){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}`,void 0,n)}async function KN(n,a){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function QN(n){return Ge("/api/settings/agent/runs/cancel-all",{method:"POST",body:JSON.stringify({})},n)}async function XN(n,a,r,l){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(r)}/approve`,{method:"POST",body:JSON.stringify({scope:l})},n)}async function ZN(n,a,r,l="User rejected this action."){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(r)}/reject`,{method:"POST",body:JSON.stringify({reason:l})},n)}async function JN(n,a,r){return Ge(`/api/settings/agent/policies/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({categories:r})},n)}async function eM(n,a){return Ge("/api/settings/agent/summary",{method:"POST",body:JSON.stringify(a)},n)}async function tM(n,a){return Ge("/api/remote/tasks",{method:"POST",body:JSON.stringify({instruction:a.instruction,deviceIds:a.deviceIds,operation:a.operation,targetQuery:a.targetQuery,approvalLevel:"read-only"})},n)}async function nM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}`,void 0,n)}async function aM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function sM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}/retry`,{method:"POST",body:JSON.stringify({failedOnly:!0})},n)}function Nl(n){return`${n}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Ud(n,a){const r=new Map(a.map(l=>[l.deviceId,iw(l)]));return n.results.map(l=>({deviceId:l.deviceId,deviceName:l.deviceName||r.get(l.deviceId)||l.deviceId,status:xN(l.status),stage:l.stage||(l.status==="running"?"Checking processes":void 0),result:l.result,data:l.data,error:l.error,sequence:Number.isSafeInteger(l.sequence)?l.sequence:0}))}function iM(n,a){const r=new Map(a.map(l=>[l.deviceId,l]));return n.map(l=>{const c=r.get(l.deviceId);return!c||c.sequence<=l.sequence?l:c})}function rM(n,a){const r=a.filter(d=>d.status==="completed"),l=a.filter(d=>d.status==="failed");if(n.operation==="process.list"){const m=`${r.filter(p=>{const g=p.result||"";return!/not running|no process/i.test(g)&&/running|online|found/i.test(g)}).length}대에서 요청한 프로세스가 실행 중입니다.`;return l.length>0?`${m}
|