livedesk 0.1.280 → 0.1.281

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.
@@ -0,0 +1,16 @@
1
+ import{r as Hb,a as f,W as lc,S as sy,K as ic,b as Sn,A as nn,L as hc,M as an,c as Ub,C as Gn,d as pc,e as Vi,F as Gr,f as vh,B as Mv,T as $b,g as Pb,h as xh,i as qb,R as rc,m as yh,H as Jo,U as Gb,N as wh,j as ly,k as Vb,l as bc,n as dd,o as Av,p as bh,q as Yb,s as Sd,t as iy,u as nd,v as fd,w as oc,X as Kr,x as Wb,y as gc,z as ry,D as Kb,E as oy,G as Qb,I as Xb,J as Zb,O as Qm,P as Jb,Q as eS,V as tS,Y as nS,Z as aS,_ as sS,$ as cy,a0 as lS,a1 as iS,a2 as Nv,a3 as rS,a4 as oS,a5 as ad,a6 as ec,a7 as sd,a8 as Xm,a9 as tc,aa as cS,ab as vm,ac as uS,ad as dS,ae as fS,af as Tv,ag as Ii,ah as mS,ai as Rv,aj as uy,ak as Ev,al as hS}from"./icons-Dm0ih4lI.js";import{r as dy}from"./react-CgbB2ESH.js";import{c as pS}from"./supabase-C7qjtLN3.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const h of d.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&r(h)}).observe(document,{childList:!0,subtree:!0});function i(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(c){if(c.ep)return;c.ep=!0;const d=i(c);fetch(c.href,d)}})();var xm={exports:{}},Wo={};var Dv;function gS(){if(Dv)return Wo;Dv=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function i(r,c,d){var h=null;if(d!==void 0&&(h=""+d),c.key!==void 0&&(h=""+c.key),"key"in c){d={};for(var p in c)p!=="key"&&(d[p]=c[p])}else d=c;return c=d.ref,{$$typeof:n,type:r,key:h,ref:c!==void 0?c:null,props:d}}return Wo.Fragment=a,Wo.jsx=i,Wo.jsxs=i,Wo}var Lv;function vS(){return Lv||(Lv=1,xm.exports=gS()),xm.exports}var l=vS(),ym={exports:{}},Ko={},wm={exports:{}},bm={};var _v;function xS(){return _v||(_v=1,(function(n){function a(_,Y){var $=_.length;_.push(Y);e:for(;0<$;){var H=$-1>>>1,ie=_[H];if(0<c(ie,Y))_[H]=Y,_[$]=ie,$=H;else break e}}function i(_){return _.length===0?null:_[0]}function r(_){if(_.length===0)return null;var Y=_[0],$=_.pop();if($!==Y){_[0]=$;e:for(var H=0,ie=_.length,xe=ie>>>1;H<xe;){var D=2*(H+1)-1,J=_[D],he=D+1,we=_[he];if(0>c(J,$))he<ie&&0>c(we,J)?(_[H]=we,_[he]=$,H=he):(_[H]=J,_[D]=$,H=D);else if(he<ie&&0>c(we,$))_[H]=we,_[he]=$,H=he;else break e}}return Y}function c(_,Y){var $=_.sortIndex-Y.sortIndex;return $!==0?$:_.id-Y.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var h=Date,p=h.now();n.unstable_now=function(){return h.now()-p}}var v=[],g=[],w=1,y=null,b=3,j=!1,k=!1,M=!1,R=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,E=typeof setImmediate<"u"?setImmediate:null;function U(_){for(var Y=i(g);Y!==null;){if(Y.callback===null)r(g);else if(Y.startTime<=_)r(g),Y.sortIndex=Y.expirationTime,a(v,Y);else break;Y=i(g)}}function F(_){if(M=!1,U(_),!k)if(i(v)!==null)k=!0,P||(P=!0,Z());else{var Y=i(g);Y!==null&&Q(F,Y.startTime-_)}}var P=!1,L=-1,I=5,de=-1;function W(){return R?!0:!(n.unstable_now()-de<I)}function ue(){if(R=!1,P){var _=n.unstable_now();de=_;var Y=!0;try{e:{k=!1,M&&(M=!1,A(L),L=-1),j=!0;var $=b;try{t:{for(U(_),y=i(v);y!==null&&!(y.expirationTime>_&&W());){var H=y.callback;if(typeof H=="function"){y.callback=null,b=y.priorityLevel;var ie=H(y.expirationTime<=_);if(_=n.unstable_now(),typeof ie=="function"){y.callback=ie,U(_),Y=!0;break t}y===i(v)&&r(v),U(_)}else r(v);y=i(v)}if(y!==null)Y=!0;else{var xe=i(g);xe!==null&&Q(F,xe.startTime-_),Y=!1}}break e}finally{y=null,b=$,j=!1}Y=void 0}}finally{Y?Z():P=!1}}}var Z;if(typeof E=="function")Z=function(){E(ue)};else if(typeof MessageChannel<"u"){var le=new MessageChannel,ce=le.port2;le.port1.onmessage=ue,Z=function(){ce.postMessage(null)}}else Z=function(){C(ue,0)};function Q(_,Y){L=C(function(){_(n.unstable_now())},Y)}n.unstable_IdlePriority=5,n.unstable_ImmediatePriority=1,n.unstable_LowPriority=4,n.unstable_NormalPriority=3,n.unstable_Profiling=null,n.unstable_UserBlockingPriority=2,n.unstable_cancelCallback=function(_){_.callback=null},n.unstable_forceFrameRate=function(_){0>_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<_?Math.floor(1e3/_):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function(_){switch(b){case 1:case 2:case 3:var Y=3;break;default:Y=b}var $=b;b=Y;try{return _()}finally{b=$}},n.unstable_requestPaint=function(){R=!0},n.unstable_runWithPriority=function(_,Y){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var $=b;b=_;try{return Y()}finally{b=$}},n.unstable_scheduleCallback=function(_,Y,$){var H=n.unstable_now();switch(typeof $=="object"&&$!==null?($=$.delay,$=typeof $=="number"&&0<$?H+$:H):$=H,_){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=$+ie,_={id:w++,callback:Y,priorityLevel:_,startTime:$,expirationTime:ie,sortIndex:-1},$>H?(_.sortIndex=$,a(g,_),i(v)===null&&_===i(g)&&(M?(A(L),L=-1):M=!0,Q(F,$-H))):(_.sortIndex=ie,a(v,_),k||j||(k=!0,P||(P=!0,Z()))),_},n.unstable_shouldYield=W,n.unstable_wrapCallback=function(_){var Y=b;return function(){var $=b;b=Y;try{return _.apply(this,arguments)}finally{b=$}}}})(bm)),bm}var zv;function yS(){return zv||(zv=1,wm.exports=xS()),wm.exports}var Ov;function wS(){if(Ov)return Ko;Ov=1;var n=yS(),a=Hb(),i=dy();function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function d(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function h(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function v(e){if(d(e)!==e)throw Error(r(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(r(188));return t!==e?null:e}for(var s=e,o=t;;){var u=s.return;if(u===null)break;var m=u.alternate;if(m===null){if(o=u.return,o!==null){s=o;continue}break}if(u.child===m.child){for(m=u.child;m;){if(m===s)return v(u),e;if(m===o)return v(u),t;m=m.sibling}throw Error(r(188))}if(s.return!==o.return)s=u,o=m;else{for(var S=!1,N=u.child;N;){if(N===s){S=!0,s=u,o=m;break}if(N===o){S=!0,o=u,s=m;break}N=N.sibling}if(!S){for(N=m.child;N;){if(N===s){S=!0,s=m,o=u;break}if(N===o){S=!0,o=m,s=u;break}N=N.sibling}if(!S)throw Error(r(189))}}if(s.alternate!==o)throw Error(r(190))}if(s.tag!==3)throw Error(r(188));return s.stateNode.current===s?e:t}function w(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=w(e),t!==null)return t;e=e.sibling}return null}var y=Object.assign,b=Symbol.for("react.element"),j=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),E=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),de=Symbol.for("react.activity"),W=Symbol.for("react.memo_cache_sentinel"),ue=Symbol.iterator;function Z(e){return e===null||typeof e!="object"?null:(e=ue&&e[ue]||e["@@iterator"],typeof e=="function"?e:null)}var le=Symbol.for("react.client.reference");function ce(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===le?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case M:return"Fragment";case C:return"Profiler";case R:return"StrictMode";case F:return"Suspense";case P:return"SuspenseList";case de:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case E:return e.displayName||"Context";case A:return(e._context.displayName||"Context")+".Consumer";case U:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case L:return t=e.displayName||null,t!==null?t:ce(e.type)||"Memo";case I:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var Q=Array.isArray,_=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$={pending:!1,data:null,method:null,action:null},H=[],ie=-1;function xe(e){return{current:e}}function D(e){0>ie||(e.current=H[ie],H[ie]=null,ie--)}function J(e,t){ie++,H[ie]=e.current,e.current=t}var he=xe(null),we=xe(null),je=xe(null),Oe=xe(null);function He(e,t){switch(J(je,t),J(we,e),J(he,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kg(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kg(t),e=Qg(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}D(he),J(he,e)}function oe(){D(he),D(we),D(je)}function Ze(e){e.memoizedState!==null&&J(Oe,e);var t=he.current,s=Qg(t,e.type);t!==s&&(J(we,e),J(he,s))}function De(e){we.current===e&&(D(he),D(we)),Oe.current===e&&(D(Oe),qo._currentValue=$)}var at,ne;function pe(e){if(at===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);at=t&&t[1]||"",ne=-1<s.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+at+e+ne}var Me=!1;function V(e,t){if(!e||Me)return"";Me=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(t){var ye=function(){throw Error()};if(Object.defineProperty(ye.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ye,[])}catch(re){var se=re}Reflect.construct(e,[],ye)}else{try{ye.call()}catch(re){se=re}e.call(ye.prototype)}}else{try{throw Error()}catch(re){se=re}(ye=e())&&typeof ye.catch=="function"&&ye.catch(function(){})}}catch(re){if(re&&se&&typeof re.stack=="string")return[re.stack,se.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var u=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");u&&u.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var m=o.DetermineComponentFrameRoot(),S=m[0],N=m[1];if(S&&N){var B=S.split(`
4
+ `),te=N.split(`
5
+ `);for(u=o=0;o<B.length&&!B[o].includes("DetermineComponentFrameRoot");)o++;for(;u<te.length&&!te[u].includes("DetermineComponentFrameRoot");)u++;if(o===B.length||u===te.length)for(o=B.length-1,u=te.length-1;1<=o&&0<=u&&B[o]!==te[u];)u--;for(;1<=o&&0<=u;o--,u--)if(B[o]!==te[u]){if(o!==1||u!==1)do if(o--,u--,0>u||B[o]!==te[u]){var fe=`
6
+ `+B[o].replace(" at new "," at ");return e.displayName&&fe.includes("<anonymous>")&&(fe=fe.replace("<anonymous>",e.displayName)),fe}while(1<=o&&0<=u);break}}}finally{Me=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?pe(s):""}function ae(e,t){switch(e.tag){case 26:case 27:case 5:return pe(e.type);case 16:return pe("Lazy");case 13:return e.child!==t&&t!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return V(e.type,!1);case 11:return V(e.type.render,!1);case 1:return V(e.type,!0);case 31:return pe("Activity");default:return""}}function ke(e){try{var t="",s=null;do t+=ae(e,s),s=e,e=e.return;while(e);return t}catch(o){return`
7
+ Error generating stack: `+o.message+`
8
+ `+o.stack}}var be=Object.prototype.hasOwnProperty,st=n.unstable_scheduleCallback,It=n.unstable_cancelCallback,Ae=n.unstable_shouldYield,Ne=n.unstable_requestPaint,Ie=n.unstable_now,Pt=n.unstable_getCurrentPriorityLevel,An=n.unstable_ImmediatePriority,Dt=n.unstable_UserBlockingPriority,bl=n.unstable_NormalPriority,as=n.unstable_LowPriority,ws=n.unstable_IdlePriority,Re=n.log,Sl=n.unstable_setDisableYieldValue,Ye=null,wt=null;function ut(e){if(typeof Re=="function"&&Sl(e),wt&&typeof wt.setStrictMode=="function")try{wt.setStrictMode(Ye,e)}catch{}}var Wt=Math.clz32?Math.clz32:fi,Jn=Math.log,Gs=Math.LN2;function fi(e){return e>>>=0,e===0?32:31-(Jn(e)/Gs|0)|0}var La=256,Nt=262144,zn=4194304;function ea(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 _a(e,t,s){var o=e.pendingLanes;if(o===0)return 0;var u=0,m=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var N=o&134217727;return N!==0?(o=N&~m,o!==0?u=ea(o):(S&=N,S!==0?u=ea(S):s||(s=N&~e,s!==0&&(u=ea(s))))):(N=o&~m,N!==0?u=ea(N):S!==0?u=ea(S):s||(s=o&~e,s!==0&&(u=ea(s)))),u===0?0:t!==0&&t!==u&&(t&m)===0&&(m=u&-u,s=t&-t,m>=s||m===32&&(s&4194048)!==0)?t:u}function Vs(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Zr(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 mi(){var e=zn;return zn<<=1,(zn&62914560)===0&&(zn=4194304),e}function Ys(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function hn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function za(e,t,s,o,u,m){var S=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var N=e.entanglements,B=e.expirationTimes,te=e.hiddenUpdates;for(s=S&~s;0<s;){var fe=31-Wt(s),ye=1<<fe;N[fe]=0,B[fe]=-1;var se=te[fe];if(se!==null)for(te[fe]=null,fe=0;fe<se.length;fe++){var re=se[fe];re!==null&&(re.lane&=-536870913)}s&=~ye}o!==0&&Nn(e,o,0),m!==0&&u===0&&e.tag!==0&&(e.suspendedLanes|=m&~(S&~t))}function Nn(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-Wt(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|s&261930}function xa(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var o=31-Wt(s),u=1<<o;u&t|e[o]&t&&(e[o]|=t),s&=~u}}function ya(e,t){var s=t&-t;return s=(s&42)!==0?1:ss(s),(s&(e.suspendedLanes|t))!==0?0:s}function ss(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 Oa(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ta(){var e=Y.p;return e!==0?e:(e=window.event,e===void 0?32:yv(e.type))}function bs(e,t){var s=Y.p;try{return Y.p=e,t()}finally{Y.p=s}}var Tn=Math.random().toString(36).slice(2),X="__reactFiber$"+Tn,Se="__reactProps$"+Tn,_e="__reactContainer$"+Tn,We="__reactEvents$"+Tn,Tt="__reactListeners$"+Tn,jt="__reactHandles$"+Tn,$e="__reactResources$"+Tn,dt="__reactMarker$"+Tn;function pn(e){delete e[X],delete e[Se],delete e[We],delete e[Tt],delete e[jt]}function Kt(e){var t=e[X];if(t)return t;for(var s=e.parentNode;s;){if(t=s[_e]||s[X]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=av(e);e!==null;){if(s=e[X])return s;e=av(e)}return t}e=s,s=e.parentNode}return null}function Rt(e){if(e=e[X]||e[_e]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function kt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function vt(e){var t=e[$e];return t||(t=e[$e]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function mt(e){e[dt]=!0}var Ia=new Set,wa={};function Bt(e,t){qt(e,t),qt(e+"Capture",t)}function qt(e,t){for(wa[e]=t,e=0;e<t.length;e++)Ia.add(t[e])}var Ws=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]*$"),ba={},Ba={};function Jr(e){return be.call(Ba,e)?!0:be.call(ba,e)?!1:Ws.test(e)?Ba[e]=!0:(ba[e]=!0,!1)}function Ss(e,t,s){if(Jr(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){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,""+s)}}function Ks(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function na(e,t,s,o){if(o===null)e.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+o)}}function Rn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Qi(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function jc(e,t,s){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var u=o.get,m=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return u.call(this)},set:function(S){s=""+S,m.call(this,S)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Fa(e){if(!e._valueTracker){var t=Qi(e)?"checked":"value";e._valueTracker=jc(e,t,""+e[t])}}function Cs(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),o="";return e&&(o=Qi(e)?e.checked?"true":"false":e.value),e=o,e!==s?(t.setValue(e),!0):!1}function Sa(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 Ed=/[\n"\\]/g;function On(e){return e.replace(Ed,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function kc(e,t,s,o,u,m,S,N){e.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.type=S:e.removeAttribute("type"),t!=null?S==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Rn(t)):e.value!==""+Rn(t)&&(e.value=""+Rn(t)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),t!=null?js(e,S,Rn(t)):s!=null?js(e,S,Rn(s)):o!=null&&e.removeAttribute("value"),u==null&&m!=null&&(e.defaultChecked=!!m),u!=null&&(e.checked=u&&typeof u!="function"&&typeof u!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?e.name=""+Rn(N):e.removeAttribute("name")}function Mc(e,t,s,o,u,m,S,N){if(m!=null&&typeof m!="function"&&typeof m!="symbol"&&typeof m!="boolean"&&(e.type=m),t!=null||s!=null){if(!(m!=="submit"&&m!=="reset"||t!=null)){Fa(e);return}s=s!=null?""+Rn(s):"",t=t!=null?""+Rn(t):s,N||t===e.value||(e.value=t),e.defaultValue=t}o=o??u,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=N?e.checked:!!o,e.defaultChecked=!!o,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),Fa(e)}function js(e,t,s){t==="number"&&Sa(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function Cl(e,t,s,o){if(e=e.options,t){t={};for(var u=0;u<s.length;u++)t["$"+s[u]]=!0;for(s=0;s<e.length;s++)u=t.hasOwnProperty("$"+e[s].value),e[s].selected!==u&&(e[s].selected=u),u&&o&&(e[s].defaultSelected=!0)}else{for(s=""+Rn(s),t=null,u=0;u<e.length;u++){if(e[u].value===s){e[u].selected=!0,o&&(e[u].defaultSelected=!0);return}t!==null||e[u].disabled||(t=e[u])}t!==null&&(t.selected=!0)}}function Qs(e,t,s){if(t!=null&&(t=""+Rn(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+Rn(s):""}function Xi(e,t,s,o){if(t==null){if(o!=null){if(s!=null)throw Error(r(92));if(Q(o)){if(1<o.length)throw Error(r(93));o=o[0]}s=o}s==null&&(s=""),t=s}s=Rn(t),e.defaultValue=s,o=e.textContent,o===s&&o!==""&&o!==null&&(e.value=o),Fa(e)}function hi(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Uh=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 Dd(e,t,s){var o=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,s):typeof s!="number"||s===0||Uh.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function Ac(e,t,s){if(t!=null&&typeof t!="object")throw Error(r(62));if(e=e.style,s!=null){for(var o in s)!s.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var u in t)o=t[u],t.hasOwnProperty(u)&&s[u]!==o&&Dd(e,u,o)}else for(var m in t)t.hasOwnProperty(m)&&Dd(e,m,t[m])}function Zi(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 Nc=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"]]),Ld=/^[\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 Ji(e){return Ld.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function ls(){}var pi=null;function er(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ha=null,Vn=null;function gi(e){var t=Rt(e);if(t&&(e=t.stateNode)){var s=e[Se]||null;e:switch(e=t.stateNode,t.type){case"input":if(kc(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+On(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var o=s[t];if(o!==e&&o.form===e.form){var u=o[Se]||null;if(!u)throw Error(r(90));kc(o,u.value,u.defaultValue,u.defaultValue,u.checked,u.defaultChecked,u.type,u.name)}}for(t=0;t<s.length;t++)o=s[t],o.form===e.form&&Cs(o)}break e;case"textarea":Qs(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&Cl(e,!!s.multiple,t,!1)}}}var tr=!1;function eo(e,t,s){if(tr)return e(t,s);tr=!0;try{var o=e(t);return o}finally{if(tr=!1,(Ha!==null||Vn!==null)&&(gu(),Ha&&(t=Ha,e=Vn,Vn=Ha=null,gi(t),e)))for(t=0;t<e.length;t++)gi(e[t])}}function is(e,t){var s=e.stateNode;if(s===null)return null;var o=s[Se]||null;if(o===null)return null;s=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(s&&typeof s!="function")throw Error(r(231,t,typeof s));return s}var Ua=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),nr=!1;if(Ua)try{var qe={};Object.defineProperty(qe,"passive",{get:function(){nr=!0}}),window.addEventListener("test",qe,qe),window.removeEventListener("test",qe,qe)}catch{nr=!1}var Qe=null,Yn=null,jl=null;function rs(){if(jl)return jl;var e,t=Yn,s=t.length,o,u="value"in Qe?Qe.value:Qe.textContent,m=u.length;for(e=0;e<s&&t[e]===u[e];e++);var S=s-e;for(o=1;o<=S&&t[s-o]===u[m-o];o++);return jl=u.slice(e,1<o?1-o:void 0)}function Ke(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 vi(){return!0}function Tc(){return!1}function cn(e){function t(s,o,u,m,S){this._reactName=s,this._targetInst=u,this.type=o,this.nativeEvent=m,this.target=S,this.currentTarget=null;for(var N in e)e.hasOwnProperty(N)&&(s=e[N],this[N]=s?s(m):m[N]);return this.isDefaultPrevented=(m.defaultPrevented!=null?m.defaultPrevented:m.returnValue===!1)?vi:Tc,this.isPropagationStopped=Tc,this}return y(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=vi)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=vi)},persist:function(){},isPersistent:vi}),t}var Ca={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},kl=cn(Ca),$a=y({},Ca,{view:0,detail:0}),ja=cn($a),ks,un,Ms,Te=y({},$a,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:sr,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!==Ms&&(Ms&&e.type==="mousemove"?(ks=e.screenX-Ms.screenX,un=e.screenY-Ms.screenY):un=ks=0,Ms=e),ks)},movementY:function(e){return"movementY"in e?e.movementY:un}}),to=cn(Te),_d=y({},Te,{dataTransfer:0}),Pa=cn(_d),zd=y({},$a,{relatedTarget:0}),no=cn(zd),xi=y({},Ca,{animationName:0,elapsedTime:0,pseudoElement:0}),Et=cn(xi),Rc=y({},Ca,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),ar=cn(Rc),Xs=y({},Ca,{data:0}),Ec=cn(Xs),Od={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Qt={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"},Ml={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Id(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Ml[e])?!!t[e]:!1}function sr(){return Id}var os=y({},$a,{key:function(e){if(e.key){var t=Od[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ke(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Qt[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:sr,charCode:function(e){return e.type==="keypress"?Ke(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ke(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Dc=cn(os),lr=y({},Te,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),As=cn(lr),qa=y({},$a,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:sr}),dn=cn(qa),Bd=y({},Ca,{propertyName:0,elapsedTime:0,pseudoElement:0}),Lc=cn(Bd),Al=y({},Te,{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}),Fd=cn(Al),Xt=y({},Ca,{newState:0,oldState:0}),Zs=cn(Xt),ir=[9,13,27,32],Nl=Ua&&"CompositionEvent"in window,Wn=null;Ua&&"documentMode"in document&&(Wn=document.documentMode);var Hd=Ua&&"TextEvent"in window&&!Wn,_c=Ua&&(!Nl||Wn&&8<Wn&&11>=Wn),yi=" ",wi=!1;function ao(e,t){switch(e){case"keyup":return ir.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Js(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var el=!1;function zc(e,t){switch(e){case"compositionend":return Js(t);case"keypress":return t.which!==32?null:(wi=!0,yi);case"textInput":return e=t.data,e===yi&&wi?null:e;default:return null}}function Ud(e,t){if(el)return e==="compositionend"||!Nl&&ao(e,t)?(e=rs(),jl=Yn=Qe=null,el=!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 _c&&t.locale!=="ko"?null:t.data;default:return null}}var Tl={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 Oc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Tl[e.type]:t==="textarea"}function so(e,t,s,o){Ha?Vn?Vn.push(o):Vn=[o]:Ha=o,t=Cu(t,"onChange"),0<t.length&&(s=new kl("onChange","change",null,s,o),e.push({event:s,listeners:t}))}var bi=null,Si=null;function $d(e){Pg(e,0)}function Ci(e){var t=kt(e);if(Cs(t))return e}function Rl(e,t){if(e==="change")return t}var cs=!1;if(Ua){var El;if(Ua){var Ns="oninput"in document;if(!Ns){var Ts=document.createElement("div");Ts.setAttribute("oninput","return;"),Ns=typeof Ts.oninput=="function"}El=Ns}else El=!1;cs=El&&(!document.documentMode||9<document.documentMode)}function rr(){bi&&(bi.detachEvent("onpropertychange",Ic),Si=bi=null)}function Ic(e){if(e.propertyName==="value"&&Ci(Si)){var t=[];so(t,Si,e,er(e)),eo($d,t)}}function Bc(e,t,s){e==="focusin"?(rr(),bi=t,Si=s,bi.attachEvent("onpropertychange",Ic)):e==="focusout"&&rr()}function lo(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ci(Si)}function io(e,t){if(e==="click")return Ci(t)}function Dl(e,t){if(e==="input"||e==="change")return Ci(t)}function Pd(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var gn=typeof Object.is=="function"?Object.is:Pd;function Ll(e,t){if(gn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;for(o=0;o<s.length;o++){var u=s[o];if(!be.call(t,u)||!gn(e[u],t[u]))return!1}return!0}function ji(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function or(e,t){var s=ji(e);e=0;for(var o;s;){if(s.nodeType===3){if(o=e+s.textContent.length,e<=t&&o>=t)return{node:s,offset:t-e};e=o}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=ji(s)}}function cr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?cr(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ki(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Sa(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=Sa(e.document)}return t}function _l(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 ro=Ua&&"documentMode"in document&&11>=document.documentMode,tl=null,Rs=null,Ga=null,zl=!1;function Ol(e,t,s){var o=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;zl||tl==null||tl!==Sa(o)||(o=tl,"selectionStart"in o&&_l(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}),Ga&&Ll(Ga,o)||(Ga=o,o=Cu(Rs,"onSelect"),0<o.length&&(t=new kl("onSelect","select",null,t,s),e.push({event:t,listeners:o}),t.target=tl)))}function vn(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Es={animationend:vn("Animation","AnimationEnd"),animationiteration:vn("Animation","AnimationIteration"),animationstart:vn("Animation","AnimationStart"),transitionrun:vn("Transition","TransitionRun"),transitionstart:vn("Transition","TransitionStart"),transitioncancel:vn("Transition","TransitionCancel"),transitionend:vn("Transition","TransitionEnd")},Mi={},oo={};Ua&&(oo=document.createElement("div").style,"AnimationEvent"in window||(delete Es.animationend.animation,delete Es.animationiteration.animation,delete Es.animationstart.animation),"TransitionEvent"in window||delete Es.transitionend.transition);function Ft(e){if(Mi[e])return Mi[e];if(!Es[e])return e;var t=Es[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in oo)return Mi[e]=t[s];return e}var co=Ft("animationend"),ur=Ft("animationiteration"),Ai=Ft("animationstart"),qd=Ft("transitionrun"),Il=Ft("transitionstart"),Gd=Ft("transitioncancel"),Fc=Ft("transitionend"),Ni=new Map,dr="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(" ");dr.push("scrollEnd");function En(e,t){Ni.set(e,t),Bt(t,[e])}var Ti=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)},In=[],nl=0,uo=0;function Bl(){for(var e=nl,t=uo=nl=0;t<e;){var s=In[t];In[t++]=null;var o=In[t];In[t++]=null;var u=In[t];In[t++]=null;var m=In[t];if(In[t++]=null,o!==null&&u!==null){var S=o.pending;S===null?u.next=u:(u.next=S.next,S.next=u),o.pending=u}m!==0&&fo(s,u,m)}}function fr(e,t,s,o){In[nl++]=e,In[nl++]=t,In[nl++]=s,In[nl++]=o,uo|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function mr(e,t,s,o){return fr(e,t,s,o),hr(e)}function Ds(e,t){return fr(e,null,null,t),hr(e)}function fo(e,t,s){e.lanes|=s;var o=e.alternate;o!==null&&(o.lanes|=s);for(var u=!1,m=e.return;m!==null;)m.childLanes|=s,o=m.alternate,o!==null&&(o.childLanes|=s),m.tag===22&&(e=m.stateNode,e===null||e._visibility&1||(u=!0)),e=m,m=m.return;return e.tag===3?(m=e.stateNode,u&&t!==null&&(u=31-Wt(s),e=m.hiddenUpdates,o=e[u],o===null?e[u]=[t]:o.push(t),t.lane=s|536870912),m):null}function hr(e){if(50<Io)throw Io=0,Uf=null,Error(r(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var us={};function Ls(e,t,s,o){this.tag=e,this.key=s,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 xn(e,t,s,o){return new Ls(e,t,s,o)}function mo(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ka(e,t){var s=e.alternate;return s===null?(s=xn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function pr(e,t){e.flags&=65011714;var s=e.alternate;return s===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=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ce(e,t,s,o,u,m){var S=0;if(o=e,typeof e=="function")mo(e)&&(S=1);else if(typeof e=="string")S=Nb(e,s,he.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case de:return e=xn(31,s,t,u),e.elementType=de,e.lanes=m,e;case M:return Va(s.children,u,m,t);case R:S=8,u|=24;break;case C:return e=xn(12,s,t,u|2),e.elementType=C,e.lanes=m,e;case F:return e=xn(13,s,t,u),e.elementType=F,e.lanes=m,e;case P:return e=xn(19,s,t,u),e.elementType=P,e.lanes=m,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case E:S=10;break e;case A:S=9;break e;case U:S=11;break e;case L:S=14;break e;case I:S=16,o=null;break e}S=29,s=Error(r(130,e===null?"null":typeof e,"")),o=null}return t=xn(S,s,t,u),t.elementType=e,t.type=o,t.lanes=m,t}function Va(e,t,s,o){return e=xn(7,e,o,t),e.lanes=s,e}function gr(e,t,s){return e=xn(6,e,null,t),e.lanes=s,e}function Hc(e){var t=xn(18,null,null,0);return t.stateNode=e,t}function Uc(e,t,s){return t=xn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var vr=new WeakMap;function aa(e,t){if(typeof e=="object"&&e!==null){var s=vr.get(e);return s!==void 0?s:(t={value:e,source:t,stack:ke(t)},vr.set(e,t),t)}return{value:e,source:t,stack:ke(t)}}var ds=[],_t=0,yn=null,tt=0,sa=[],la=0,_s=null,Ya=1,Wa="";function fs(e,t){ds[_t++]=tt,ds[_t++]=yn,yn=e,tt=t}function $c(e,t,s){sa[la++]=Ya,sa[la++]=Wa,sa[la++]=_s,_s=e;var o=Ya;e=Wa;var u=32-Wt(o)-1;o&=~(1<<u),s+=1;var m=32-Wt(t)+u;if(30<m){var S=u-u%5;m=(o&(1<<S)-1).toString(32),o>>=S,u-=S,Ya=1<<32-Wt(t)+u|s<<u|o,Wa=m+e}else Ya=1<<m|s<<u|o,Wa=e}function ho(e){e.return!==null&&(fs(e,1),$c(e,1,0))}function po(e){for(;e===yn;)yn=ds[--_t],ds[_t]=null,tt=ds[--_t],ds[_t]=null;for(;e===_s;)_s=sa[--la],sa[la]=null,Wa=sa[--la],sa[la]=null,Ya=sa[--la],sa[la]=null}function Pc(e,t){sa[la++]=Ya,sa[la++]=Wa,sa[la++]=_s,Ya=t.id,Wa=t.overflow,_s=e}var fn=null,Mt=null,lt=!1,zs=null,ia=!1,go=Error(r(519));function Ka(e){var t=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Ri(aa(t,e)),go}function xr(e){var t=e.stateNode,s=e.type,o=e.memoizedProps;switch(t[X]=e,t[Se]=o,s){case"dialog":rt("cancel",t),rt("close",t);break;case"iframe":case"object":case"embed":rt("load",t);break;case"video":case"audio":for(s=0;s<Fo.length;s++)rt(Fo[s],t);break;case"source":rt("error",t);break;case"img":case"image":case"link":rt("error",t),rt("load",t);break;case"details":rt("toggle",t);break;case"input":rt("invalid",t),Mc(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":rt("invalid",t);break;case"textarea":rt("invalid",t),Xi(t,o.value,o.defaultValue,o.children)}s=o.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||o.suppressHydrationWarning===!0||Yg(t.textContent,s)?(o.popover!=null&&(rt("beforetoggle",t),rt("toggle",t)),o.onScroll!=null&&rt("scroll",t),o.onScrollEnd!=null&&rt("scrollend",t),o.onClick!=null&&(t.onclick=ls),t=!0):t=!1,t||Ka(e,!0)}function qc(e){for(fn=e.return;fn;)switch(fn.tag){case 5:case 31:case 13:ia=!1;return;case 27:case 3:ia=!0;return;default:fn=fn.return}}function Fl(e){if(e!==fn)return!1;if(!lt)return qc(e),lt=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||nm(e.type,e.memoizedProps)),s=!s),s&&Mt&&Ka(e),qc(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));Mt=nv(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));Mt=nv(e)}else t===27?(t=Mt,Jl(e.type)?(e=rm,rm=null,Mt=e):Mt=t):Mt=fn?Ja(e.stateNode.nextSibling):null;return!0}function al(){Mt=fn=null,lt=!1}function vo(){var e=zs;return e!==null&&(da===null?da=e:da.push.apply(da,e),zs=null),e}function Ri(e){zs===null?zs=[e]:zs.push(e)}var xo=xe(null),sl=null,ms=null;function Os(e,t,s){J(xo,t._currentValue),t._currentValue=s}function Bn(e){e._currentValue=xo.current,D(xo)}function yr(e,t,s){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===s)break;e=e.return}}function Ei(e,t,s,o){var u=e.child;for(u!==null&&(u.return=e);u!==null;){var m=u.dependencies;if(m!==null){var S=u.child;m=m.firstContext;e:for(;m!==null;){var N=m;m=u;for(var B=0;B<t.length;B++)if(N.context===t[B]){m.lanes|=s,N=m.alternate,N!==null&&(N.lanes|=s),yr(m.return,s,e),o||(S=null);break e}m=N.next}}else if(u.tag===18){if(S=u.return,S===null)throw Error(r(341));S.lanes|=s,m=S.alternate,m!==null&&(m.lanes|=s),yr(S,s,e),S=null}else S=u.child;if(S!==null)S.return=u;else for(S=u;S!==null;){if(S===e){S=null;break}if(u=S.sibling,u!==null){u.return=S.return,S=u;break}S=S.return}u=S}}function Hl(e,t,s,o){e=null;for(var u=t,m=!1;u!==null;){if(!m){if((u.flags&524288)!==0)m=!0;else if((u.flags&262144)!==0)break}if(u.tag===10){var S=u.alternate;if(S===null)throw Error(r(387));if(S=S.memoizedProps,S!==null){var N=u.type;gn(u.pendingProps.value,S.value)||(e!==null?e.push(N):e=[N])}}else if(u===Oe.current){if(S=u.alternate,S===null)throw Error(r(387));S.memoizedState.memoizedState!==u.memoizedState.memoizedState&&(e!==null?e.push(qo):e=[qo])}u=u.return}e!==null&&Ei(t,e,s,o),t.flags|=262144}function wr(e){for(e=e.firstContext;e!==null;){if(!gn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Is(e){sl=e,ms=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Gt(e){return wn(sl,e)}function br(e,t){return sl===null&&Is(e),wn(e,t)}function wn(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},ms===null){if(e===null)throw Error(r(308));ms=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ms=ms.next=t;return s}var Sr=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},Gc=n.unstable_scheduleCallback,Vd=n.unstable_NormalPriority,Zt={$$typeof:E,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function yo(){return{controller:new Sr,data:new Map,refCount:0}}function Di(e){e.refCount--,e.refCount===0&&Gc(Vd,function(){e.controller.abort()})}var Ul=null,$l=0,Qa=0,ll=null;function Yd(e,t){if(Ul===null){var s=Ul=[];$l=0,Qa=Yf(),ll={status:"pending",value:void 0,then:function(o){s.push(o)}}}return $l++,t.then(Vc,Vc),t}function Vc(){if(--$l===0&&Ul!==null){ll!==null&&(ll.status="fulfilled");var e=Ul;Ul=null,Qa=0,ll=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Wd(e,t){var s=[],o={status:"pending",value:null,reason:null,then:function(u){s.push(u)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var u=0;u<s.length;u++)(0,s[u])(t)},function(u){for(o.status="rejected",o.reason=u,u=0;u<s.length;u++)(0,s[u])(void 0)}),o}var Yc=_.S;_.S=function(e,t){vg=Ie(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Yd(e,t),Yc!==null&&Yc(e,t)};var il=xe(null);function wo(){var e=il.current;return e!==null?e:At.pooledCache}function Cr(e,t){t===null?J(il,il.current):J(il,t.pool)}function Kn(){var e=wo();return e===null?null:{parent:Zt._currentValue,pool:e}}var Pl=Error(r(460)),bo=Error(r(474)),hs=Error(r(542)),jr={then:function(){}};function kr(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Wc(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(ls,ls),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,z(e),e;default:if(typeof t.status=="string")t.then(ls,ls);else{if(e=At,e!==null&&100<e.shellSuspendCounter)throw Error(r(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var u=t;u.status="fulfilled",u.value=o}},function(o){if(t.status==="pending"){var u=t;u.status="rejected",u.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,z(e),e}throw x=t,Pl}}function Bs(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(x=s,Pl):s}}var x=null;function T(){if(x===null)throw Error(r(459));var e=x;return x=null,e}function z(e){if(e===Pl||e===hs)throw Error(r(483))}var q=null,O=0;function me(e){var t=O;return O+=1,q===null&&(q=[]),Wc(q,e,t)}function ge(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ee(e,t){throw t.$$typeof===b?Error(r(525)):(e=Object.prototype.toString.call(t),Error(r(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Pe(e){function t(K,G){if(e){var ee=K.deletions;ee===null?(K.deletions=[G],K.flags|=16):ee.push(G)}}function s(K,G){if(!e)return null;for(;G!==null;)t(K,G),G=G.sibling;return null}function o(K){for(var G=new Map;K!==null;)K.key!==null?G.set(K.key,K):G.set(K.index,K),K=K.sibling;return G}function u(K,G){return K=ka(K,G),K.index=0,K.sibling=null,K}function m(K,G,ee){return K.index=ee,e?(ee=K.alternate,ee!==null?(ee=ee.index,ee<G?(K.flags|=67108866,G):ee):(K.flags|=67108866,G)):(K.flags|=1048576,G)}function S(K){return e&&K.alternate===null&&(K.flags|=67108866),K}function N(K,G,ee,ve){return G===null||G.tag!==6?(G=gr(ee,K.mode,ve),G.return=K,G):(G=u(G,ee),G.return=K,G)}function B(K,G,ee,ve){var Ue=ee.type;return Ue===M?fe(K,G,ee.props.children,ve,ee.key):G!==null&&(G.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===I&&Bs(Ue)===G.type)?(G=u(G,ee.props),ge(G,ee),G.return=K,G):(G=Ce(ee.type,ee.key,ee.props,null,K.mode,ve),ge(G,ee),G.return=K,G)}function te(K,G,ee,ve){return G===null||G.tag!==4||G.stateNode.containerInfo!==ee.containerInfo||G.stateNode.implementation!==ee.implementation?(G=Uc(ee,K.mode,ve),G.return=K,G):(G=u(G,ee.children||[]),G.return=K,G)}function fe(K,G,ee,ve,Ue){return G===null||G.tag!==7?(G=Va(ee,K.mode,ve,Ue),G.return=K,G):(G=u(G,ee),G.return=K,G)}function ye(K,G,ee){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=gr(""+G,K.mode,ee),G.return=K,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case j:return ee=Ce(G.type,G.key,G.props,null,K.mode,ee),ge(ee,G),ee.return=K,ee;case k:return G=Uc(G,K.mode,ee),G.return=K,G;case I:return G=Bs(G),ye(K,G,ee)}if(Q(G)||Z(G))return G=Va(G,K.mode,ee,null),G.return=K,G;if(typeof G.then=="function")return ye(K,me(G),ee);if(G.$$typeof===E)return ye(K,br(K,G),ee);Ee(K,G)}return null}function se(K,G,ee,ve){var Ue=G!==null?G.key:null;if(typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint")return Ue!==null?null:N(K,G,""+ee,ve);if(typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case j:return ee.key===Ue?B(K,G,ee,ve):null;case k:return ee.key===Ue?te(K,G,ee,ve):null;case I:return ee=Bs(ee),se(K,G,ee,ve)}if(Q(ee)||Z(ee))return Ue!==null?null:fe(K,G,ee,ve,null);if(typeof ee.then=="function")return se(K,G,me(ee),ve);if(ee.$$typeof===E)return se(K,G,br(K,ee),ve);Ee(K,ee)}return null}function re(K,G,ee,ve,Ue){if(typeof ve=="string"&&ve!==""||typeof ve=="number"||typeof ve=="bigint")return K=K.get(ee)||null,N(G,K,""+ve,Ue);if(typeof ve=="object"&&ve!==null){switch(ve.$$typeof){case j:return K=K.get(ve.key===null?ee:ve.key)||null,B(G,K,ve,Ue);case k:return K=K.get(ve.key===null?ee:ve.key)||null,te(G,K,ve,Ue);case I:return ve=Bs(ve),re(K,G,ee,ve,Ue)}if(Q(ve)||Z(ve))return K=K.get(ee)||null,fe(G,K,ve,Ue,null);if(typeof ve.then=="function")return re(K,G,ee,me(ve),Ue);if(ve.$$typeof===E)return re(K,G,ee,br(G,ve),Ue);Ee(G,ve)}return null}function ze(K,G,ee,ve){for(var Ue=null,ht=null,Fe=G,nt=G=0,ct=null;Fe!==null&&nt<ee.length;nt++){Fe.index>nt?(ct=Fe,Fe=null):ct=Fe.sibling;var pt=se(K,Fe,ee[nt],ve);if(pt===null){Fe===null&&(Fe=ct);break}e&&Fe&&pt.alternate===null&&t(K,Fe),G=m(pt,G,nt),ht===null?Ue=pt:ht.sibling=pt,ht=pt,Fe=ct}if(nt===ee.length)return s(K,Fe),lt&&fs(K,nt),Ue;if(Fe===null){for(;nt<ee.length;nt++)Fe=ye(K,ee[nt],ve),Fe!==null&&(G=m(Fe,G,nt),ht===null?Ue=Fe:ht.sibling=Fe,ht=Fe);return lt&&fs(K,nt),Ue}for(Fe=o(Fe);nt<ee.length;nt++)ct=re(Fe,K,nt,ee[nt],ve),ct!==null&&(e&&ct.alternate!==null&&Fe.delete(ct.key===null?nt:ct.key),G=m(ct,G,nt),ht===null?Ue=ct:ht.sibling=ct,ht=ct);return e&&Fe.forEach(function(si){return t(K,si)}),lt&&fs(K,nt),Ue}function Ge(K,G,ee,ve){if(ee==null)throw Error(r(151));for(var Ue=null,ht=null,Fe=G,nt=G=0,ct=null,pt=ee.next();Fe!==null&&!pt.done;nt++,pt=ee.next()){Fe.index>nt?(ct=Fe,Fe=null):ct=Fe.sibling;var si=se(K,Fe,pt.value,ve);if(si===null){Fe===null&&(Fe=ct);break}e&&Fe&&si.alternate===null&&t(K,Fe),G=m(si,G,nt),ht===null?Ue=si:ht.sibling=si,ht=si,Fe=ct}if(pt.done)return s(K,Fe),lt&&fs(K,nt),Ue;if(Fe===null){for(;!pt.done;nt++,pt=ee.next())pt=ye(K,pt.value,ve),pt!==null&&(G=m(pt,G,nt),ht===null?Ue=pt:ht.sibling=pt,ht=pt);return lt&&fs(K,nt),Ue}for(Fe=o(Fe);!pt.done;nt++,pt=ee.next())pt=re(Fe,K,nt,pt.value,ve),pt!==null&&(e&&pt.alternate!==null&&Fe.delete(pt.key===null?nt:pt.key),G=m(pt,G,nt),ht===null?Ue=pt:ht.sibling=pt,ht=pt);return e&&Fe.forEach(function(Fb){return t(K,Fb)}),lt&&fs(K,nt),Ue}function Ct(K,G,ee,ve){if(typeof ee=="object"&&ee!==null&&ee.type===M&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case j:e:{for(var Ue=ee.key;G!==null;){if(G.key===Ue){if(Ue=ee.type,Ue===M){if(G.tag===7){s(K,G.sibling),ve=u(G,ee.props.children),ve.return=K,K=ve;break e}}else if(G.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===I&&Bs(Ue)===G.type){s(K,G.sibling),ve=u(G,ee.props),ge(ve,ee),ve.return=K,K=ve;break e}s(K,G);break}else t(K,G);G=G.sibling}ee.type===M?(ve=Va(ee.props.children,K.mode,ve,ee.key),ve.return=K,K=ve):(ve=Ce(ee.type,ee.key,ee.props,null,K.mode,ve),ge(ve,ee),ve.return=K,K=ve)}return S(K);case k:e:{for(Ue=ee.key;G!==null;){if(G.key===Ue)if(G.tag===4&&G.stateNode.containerInfo===ee.containerInfo&&G.stateNode.implementation===ee.implementation){s(K,G.sibling),ve=u(G,ee.children||[]),ve.return=K,K=ve;break e}else{s(K,G);break}else t(K,G);G=G.sibling}ve=Uc(ee,K.mode,ve),ve.return=K,K=ve}return S(K);case I:return ee=Bs(ee),Ct(K,G,ee,ve)}if(Q(ee))return ze(K,G,ee,ve);if(Z(ee)){if(Ue=Z(ee),typeof Ue!="function")throw Error(r(150));return ee=Ue.call(ee),Ge(K,G,ee,ve)}if(typeof ee.then=="function")return Ct(K,G,me(ee),ve);if(ee.$$typeof===E)return Ct(K,G,br(K,ee),ve);Ee(K,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,G!==null&&G.tag===6?(s(K,G.sibling),ve=u(G,ee),ve.return=K,K=ve):(s(K,G),ve=gr(ee,K.mode,ve),ve.return=K,K=ve),S(K)):s(K,G)}return function(K,G,ee,ve){try{O=0;var Ue=Ct(K,G,ee,ve);return q=null,Ue}catch(Fe){if(Fe===Pl||Fe===hs)throw Fe;var ht=xn(29,Fe,null,K.mode);return ht.lanes=ve,ht.return=K,ht}}}var Ve=Pe(!0),zt=Pe(!1),Ht=!1;function Qn(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Xa(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 Fn(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ra(e,t,s){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(gt&2)!==0){var u=o.pending;return u===null?t.next=t:(t.next=u.next,u.next=t),o.pending=t,t=hr(e),fo(e,null,s),t}return fr(e,o,t,s),hr(e)}function Fs(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,s|=o,t.lanes=s,xa(e,s)}}function So(e,t){var s=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,s===o)){var u=null,m=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};m===null?u=m=S:m=m.next=S,s=s.next}while(s!==null);m===null?u=m=t:m=m.next=t}else u=m=t;s={baseState:o.baseState,firstBaseUpdate:u,lastBaseUpdate:m,shared:o.shared,callbacks:o.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var Kd=!1;function Co(){if(Kd){var e=ll;if(e!==null)throw e}}function jo(e,t,s,o){Kd=!1;var u=e.updateQueue;Ht=!1;var m=u.firstBaseUpdate,S=u.lastBaseUpdate,N=u.shared.pending;if(N!==null){u.shared.pending=null;var B=N,te=B.next;B.next=null,S===null?m=te:S.next=te,S=B;var fe=e.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=B))}if(m!==null){var ye=u.baseState;S=0,fe=te=B=null,N=m;do{var se=N.lane&-536870913,re=se!==N.lane;if(re?(ot&se)===se:(o&se)===se){se!==0&&se===Qa&&(Kd=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var ze=e,Ge=N;se=t;var Ct=s;switch(Ge.tag){case 1:if(ze=Ge.payload,typeof ze=="function"){ye=ze.call(Ct,ye,se);break e}ye=ze;break e;case 3:ze.flags=ze.flags&-65537|128;case 0:if(ze=Ge.payload,se=typeof ze=="function"?ze.call(Ct,ye,se):ze,se==null)break e;ye=y({},ye,se);break e;case 2:Ht=!0}}se=N.callback,se!==null&&(e.flags|=64,re&&(e.flags|=8192),re=u.callbacks,re===null?u.callbacks=[se]:re.push(se))}else re={lane:se,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=re,B=ye):fe=fe.next=re,S|=se;if(N=N.next,N===null){if(N=u.shared.pending,N===null)break;re=N,N=re.next,re.next=null,u.lastBaseUpdate=re,u.shared.pending=null}}while(!0);fe===null&&(B=ye),u.baseState=B,u.firstBaseUpdate=te,u.lastBaseUpdate=fe,m===null&&(u.shared.lanes=0),Wl|=S,e.lanes=S,e.memoizedState=ye}}function $h(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function Ph(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)$h(s[e],t)}var Mr=xe(null),Kc=xe(0);function qh(e,t){e=pl,J(Kc,e),J(Mr,t),pl=e|t.baseLanes}function Qd(){J(Kc,pl),J(Mr,Mr.current)}function Xd(){pl=Kc.current,D(Mr),D(Kc)}var Ma=xe(null),Za=null;function ql(e){var t=e.alternate;J(Jt,Jt.current&1),J(Ma,e),Za===null&&(t===null||Mr.current!==null||t.memoizedState!==null)&&(Za=e)}function Zd(e){J(Jt,Jt.current),J(Ma,e),Za===null&&(Za=e)}function Gh(e){e.tag===22?(J(Jt,Jt.current),J(Ma,e),Za===null&&(Za=e)):Gl()}function Gl(){J(Jt,Jt.current),J(Ma,Ma.current)}function Aa(e){D(Ma),Za===e&&(Za=null),D(Jt)}var Jt=xe(0);function Qc(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||lm(s)||im(s)))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 rl=0,Je=null,bt=null,sn=null,Xc=!1,Ar=!1,Li=!1,Zc=0,ko=0,Nr=null,Tw=0;function Vt(){throw Error(r(321))}function Jd(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!gn(e[s],t[s]))return!1;return!0}function ef(e,t,s,o,u,m){return rl=m,Je=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,_.H=e===null||e.memoizedState===null?Np:gf,Li=!1,m=s(o,u),Li=!1,Ar&&(m=Yh(t,s,o,u)),Vh(e),m}function Vh(e){_.H=No;var t=bt!==null&&bt.next!==null;if(rl=0,sn=bt=Je=null,Xc=!1,ko=0,Nr=null,t)throw Error(r(300));e===null||ln||(e=e.dependencies,e!==null&&wr(e)&&(ln=!0))}function Yh(e,t,s,o){Je=e;var u=0;do{if(Ar&&(Nr=null),ko=0,Ar=!1,25<=u)throw Error(r(301));if(u+=1,sn=bt=null,e.updateQueue!=null){var m=e.updateQueue;m.lastEffect=null,m.events=null,m.stores=null,m.memoCache!=null&&(m.memoCache.index=0)}_.H=Tp,m=t(s,o)}while(Ar);return m}function Rw(){var e=_.H,t=e.useState()[0];return t=typeof t.then=="function"?Mo(t):t,e=e.useState()[0],(bt!==null?bt.memoizedState:null)!==e&&(Je.flags|=1024),t}function tf(){var e=Zc!==0;return Zc=0,e}function nf(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function af(e){if(Xc){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Xc=!1}rl=0,sn=bt=Je=null,Ar=!1,ko=Zc=0,Nr=null}function Xn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return sn===null?Je.memoizedState=sn=e:sn=sn.next=e,sn}function en(){if(bt===null){var e=Je.alternate;e=e!==null?e.memoizedState:null}else e=bt.next;var t=sn===null?Je.memoizedState:sn.next;if(t!==null)sn=t,bt=e;else{if(e===null)throw Je.alternate===null?Error(r(467)):Error(r(310));bt=e,e={memoizedState:bt.memoizedState,baseState:bt.baseState,baseQueue:bt.baseQueue,queue:bt.queue,next:null},sn===null?Je.memoizedState=sn=e:sn=sn.next=e}return sn}function Jc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Mo(e){var t=ko;return ko+=1,Nr===null&&(Nr=[]),e=Wc(Nr,e,t),t=Je,(sn===null?t.memoizedState:sn.next)===null&&(t=t.alternate,_.H=t===null||t.memoizedState===null?Np:gf),e}function eu(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Mo(e);if(e.$$typeof===E)return Gt(e)}throw Error(r(438,String(e)))}function sf(e){var t=null,s=Je.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var o=Je.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(u){return u.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=Jc(),Je.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),o=0;o<e;o++)s[o]=W;return t.index++,s}function ol(e,t){return typeof t=="function"?t(e):t}function tu(e){var t=en();return lf(t,bt,e)}function lf(e,t,s){var o=e.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=s;var u=e.baseQueue,m=o.pending;if(m!==null){if(u!==null){var S=u.next;u.next=m.next,m.next=S}t.baseQueue=u=m,o.pending=null}if(m=e.baseState,u===null)e.memoizedState=m;else{t=u.next;var N=S=null,B=null,te=t,fe=!1;do{var ye=te.lane&-536870913;if(ye!==te.lane?(ot&ye)===ye:(rl&ye)===ye){var se=te.revertLane;if(se===0)B!==null&&(B=B.next={lane:0,revertLane:0,gesture:null,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null}),ye===Qa&&(fe=!0);else if((rl&se)===se){te=te.next,se===Qa&&(fe=!0);continue}else ye={lane:0,revertLane:te.revertLane,gesture:null,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null},B===null?(N=B=ye,S=m):B=B.next=ye,Je.lanes|=se,Wl|=se;ye=te.action,Li&&s(m,ye),m=te.hasEagerState?te.eagerState:s(m,ye)}else se={lane:ye,revertLane:te.revertLane,gesture:te.gesture,action:te.action,hasEagerState:te.hasEagerState,eagerState:te.eagerState,next:null},B===null?(N=B=se,S=m):B=B.next=se,Je.lanes|=ye,Wl|=ye;te=te.next}while(te!==null&&te!==t);if(B===null?S=m:B.next=N,!gn(m,e.memoizedState)&&(ln=!0,fe&&(s=ll,s!==null)))throw s;e.memoizedState=m,e.baseState=S,e.baseQueue=B,o.lastRenderedState=m}return u===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function rf(e){var t=en(),s=t.queue;if(s===null)throw Error(r(311));s.lastRenderedReducer=e;var o=s.dispatch,u=s.pending,m=t.memoizedState;if(u!==null){s.pending=null;var S=u=u.next;do m=e(m,S.action),S=S.next;while(S!==u);gn(m,t.memoizedState)||(ln=!0),t.memoizedState=m,t.baseQueue===null&&(t.baseState=m),s.lastRenderedState=m}return[m,o]}function Wh(e,t,s){var o=Je,u=en(),m=lt;if(m){if(s===void 0)throw Error(r(407));s=s()}else s=t();var S=!gn((bt||u).memoizedState,s);if(S&&(u.memoizedState=s,ln=!0),u=u.queue,uf(Xh.bind(null,o,u,e),[e]),u.getSnapshot!==t||S||sn!==null&&sn.memoizedState.tag&1){if(o.flags|=2048,Tr(9,{destroy:void 0},Qh.bind(null,o,u,s,t),null),At===null)throw Error(r(349));m||(rl&127)!==0||Kh(o,t,s)}return s}function Kh(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=Je.updateQueue,t===null?(t=Jc(),Je.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function Qh(e,t,s,o){t.value=s,t.getSnapshot=o,Zh(t)&&Jh(e)}function Xh(e,t,s){return s(function(){Zh(t)&&Jh(e)})}function Zh(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!gn(e,s)}catch{return!0}}function Jh(e){var t=Ds(e,2);t!==null&&fa(t,e,2)}function of(e){var t=Xn();if(typeof e=="function"){var s=e;if(e=s(),Li){ut(!0);try{s()}finally{ut(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ol,lastRenderedState:e},t}function ep(e,t,s,o){return e.baseState=s,lf(e,bt,typeof o=="function"?o:ol)}function Ew(e,t,s,o,u){if(su(e))throw Error(r(485));if(e=t.action,e!==null){var m={payload:u,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){m.listeners.push(S)}};_.T!==null?s(!0):m.isTransition=!1,o(m),s=t.pending,s===null?(m.next=t.pending=m,tp(t,m)):(m.next=s.next,t.pending=s.next=m)}}function tp(e,t){var s=t.action,o=t.payload,u=e.state;if(t.isTransition){var m=_.T,S={};_.T=S;try{var N=s(u,o),B=_.S;B!==null&&B(S,N),np(e,t,N)}catch(te){cf(e,t,te)}finally{m!==null&&S.types!==null&&(m.types=S.types),_.T=m}}else try{m=s(u,o),np(e,t,m)}catch(te){cf(e,t,te)}}function np(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(o){ap(e,t,o)},function(o){return cf(e,t,o)}):ap(e,t,s)}function ap(e,t,s){t.status="fulfilled",t.value=s,sp(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,tp(e,s)))}function cf(e,t,s){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=s,sp(t),t=t.next;while(t!==o)}e.action=null}function sp(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function lp(e,t){return t}function ip(e,t){if(lt){var s=At.formState;if(s!==null){e:{var o=Je;if(lt){if(Mt){t:{for(var u=Mt,m=ia;u.nodeType!==8;){if(!m){u=null;break t}if(u=Ja(u.nextSibling),u===null){u=null;break t}}m=u.data,u=m==="F!"||m==="F"?u:null}if(u){Mt=Ja(u.nextSibling),o=u.data==="F!";break e}}Ka(o)}o=!1}o&&(t=s[0])}}return s=Xn(),s.memoizedState=s.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:lp,lastRenderedState:t},s.queue=o,s=kp.bind(null,Je,o),o.dispatch=s,o=of(!1),m=pf.bind(null,Je,!1,o.queue),o=Xn(),u={state:t,dispatch:null,action:e,pending:null},o.queue=u,s=Ew.bind(null,Je,u,m,s),u.dispatch=s,o.memoizedState=e,[t,s,!1]}function rp(e){var t=en();return op(t,bt,e)}function op(e,t,s){if(t=lf(e,t,lp)[0],e=tu(ol)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=Mo(t)}catch(S){throw S===Pl?hs:S}else o=t;t=en();var u=t.queue,m=u.dispatch;return s!==t.memoizedState&&(Je.flags|=2048,Tr(9,{destroy:void 0},Dw.bind(null,u,s),null)),[o,m,e]}function Dw(e,t){e.action=t}function cp(e){var t=en(),s=bt;if(s!==null)return op(t,s,e);en(),t=t.memoizedState,s=en();var o=s.queue.dispatch;return s.memoizedState=e,[t,o,!1]}function Tr(e,t,s,o){return e={tag:e,create:s,deps:o,inst:t,next:null},t=Je.updateQueue,t===null&&(t=Jc(),Je.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(o=s.next,s.next=e,e.next=o,t.lastEffect=e),e}function up(){return en().memoizedState}function nu(e,t,s,o){var u=Xn();Je.flags|=e,u.memoizedState=Tr(1|t,{destroy:void 0},s,o===void 0?null:o)}function au(e,t,s,o){var u=en();o=o===void 0?null:o;var m=u.memoizedState.inst;bt!==null&&o!==null&&Jd(o,bt.memoizedState.deps)?u.memoizedState=Tr(t,m,s,o):(Je.flags|=e,u.memoizedState=Tr(1|t,m,s,o))}function dp(e,t){nu(8390656,8,e,t)}function uf(e,t){au(2048,8,e,t)}function Lw(e){Je.flags|=4;var t=Je.updateQueue;if(t===null)t=Jc(),Je.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function fp(e){var t=en().memoizedState;return Lw({ref:t,nextImpl:e}),function(){if((gt&2)!==0)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function mp(e,t){return au(4,2,e,t)}function hp(e,t){return au(4,4,e,t)}function pp(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function gp(e,t,s){s=s!=null?s.concat([e]):null,au(4,4,pp.bind(null,t,e),s)}function df(){}function vp(e,t){var s=en();t=t===void 0?null:t;var o=s.memoizedState;return t!==null&&Jd(t,o[1])?o[0]:(s.memoizedState=[e,t],e)}function xp(e,t){var s=en();t=t===void 0?null:t;var o=s.memoizedState;if(t!==null&&Jd(t,o[1]))return o[0];if(o=e(),Li){ut(!0);try{e()}finally{ut(!1)}}return s.memoizedState=[o,t],o}function ff(e,t,s){return s===void 0||(rl&1073741824)!==0&&(ot&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=yg(),Je.lanes|=e,Wl|=e,s)}function yp(e,t,s,o){return gn(s,t)?s:Mr.current!==null?(e=ff(e,s,o),gn(e,t)||(ln=!0),e):(rl&42)===0||(rl&1073741824)!==0&&(ot&261930)===0?(ln=!0,e.memoizedState=s):(e=yg(),Je.lanes|=e,Wl|=e,t)}function wp(e,t,s,o,u){var m=Y.p;Y.p=m!==0&&8>m?m:8;var S=_.T,N={};_.T=N,pf(e,!1,t,s);try{var B=u(),te=_.S;if(te!==null&&te(N,B),B!==null&&typeof B=="object"&&typeof B.then=="function"){var fe=Wd(B,o);Ao(e,t,fe,Ra(e))}else Ao(e,t,o,Ra(e))}catch(ye){Ao(e,t,{then:function(){},status:"rejected",reason:ye},Ra())}finally{Y.p=m,S!==null&&N.types!==null&&(S.types=N.types),_.T=S}}function _w(){}function mf(e,t,s,o){if(e.tag!==5)throw Error(r(476));var u=bp(e).queue;wp(e,u,t,$,s===null?_w:function(){return Sp(e),s(o)})}function bp(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:$,baseState:$,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ol,lastRenderedState:$},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ol,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Sp(e){var t=bp(e);t.next===null&&(t=e.alternate.memoizedState),Ao(e,t.next.queue,{},Ra())}function hf(){return Gt(qo)}function Cp(){return en().memoizedState}function jp(){return en().memoizedState}function zw(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Ra();e=Fn(s);var o=ra(t,e,s);o!==null&&(fa(o,t,s),Fs(o,t,s)),t={cache:yo()},e.payload=t;return}t=t.return}}function Ow(e,t,s){var o=Ra();s={lane:o,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},su(e)?Mp(t,s):(s=mr(e,t,s,o),s!==null&&(fa(s,e,o),Ap(s,t,o)))}function kp(e,t,s){var o=Ra();Ao(e,t,s,o)}function Ao(e,t,s,o){var u={lane:o,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(su(e))Mp(t,u);else{var m=e.alternate;if(e.lanes===0&&(m===null||m.lanes===0)&&(m=t.lastRenderedReducer,m!==null))try{var S=t.lastRenderedState,N=m(S,s);if(u.hasEagerState=!0,u.eagerState=N,gn(N,S))return fr(e,t,u,0),At===null&&Bl(),!1}catch{}if(s=mr(e,t,u,o),s!==null)return fa(s,e,o),Ap(s,t,o),!0}return!1}function pf(e,t,s,o){if(o={lane:2,revertLane:Yf(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},su(e)){if(t)throw Error(r(479))}else t=mr(e,s,o,2),t!==null&&fa(t,e,2)}function su(e){var t=e.alternate;return e===Je||t!==null&&t===Je}function Mp(e,t){Ar=Xc=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function Ap(e,t,s){if((s&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,s|=o,t.lanes=s,xa(e,s)}}var No={readContext:Gt,use:eu,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useLayoutEffect:Vt,useInsertionEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useSyncExternalStore:Vt,useId:Vt,useHostTransitionStatus:Vt,useFormState:Vt,useActionState:Vt,useOptimistic:Vt,useMemoCache:Vt,useCacheRefresh:Vt};No.useEffectEvent=Vt;var Np={readContext:Gt,use:eu,useCallback:function(e,t){return Xn().memoizedState=[e,t===void 0?null:t],e},useContext:Gt,useEffect:dp,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,nu(4194308,4,pp.bind(null,t,e),s)},useLayoutEffect:function(e,t){return nu(4194308,4,e,t)},useInsertionEffect:function(e,t){nu(4,2,e,t)},useMemo:function(e,t){var s=Xn();t=t===void 0?null:t;var o=e();if(Li){ut(!0);try{e()}finally{ut(!1)}}return s.memoizedState=[o,t],o},useReducer:function(e,t,s){var o=Xn();if(s!==void 0){var u=s(t);if(Li){ut(!0);try{s(t)}finally{ut(!1)}}}else u=t;return o.memoizedState=o.baseState=u,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:u},o.queue=e,e=e.dispatch=Ow.bind(null,Je,e),[o.memoizedState,e]},useRef:function(e){var t=Xn();return e={current:e},t.memoizedState=e},useState:function(e){e=of(e);var t=e.queue,s=kp.bind(null,Je,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:df,useDeferredValue:function(e,t){var s=Xn();return ff(s,e,t)},useTransition:function(){var e=of(!1);return e=wp.bind(null,Je,e.queue,!0,!1),Xn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var o=Je,u=Xn();if(lt){if(s===void 0)throw Error(r(407));s=s()}else{if(s=t(),At===null)throw Error(r(349));(ot&127)!==0||Kh(o,t,s)}u.memoizedState=s;var m={value:s,getSnapshot:t};return u.queue=m,dp(Xh.bind(null,o,m,e),[e]),o.flags|=2048,Tr(9,{destroy:void 0},Qh.bind(null,o,m,s,t),null),s},useId:function(){var e=Xn(),t=At.identifierPrefix;if(lt){var s=Wa,o=Ya;s=(o&~(1<<32-Wt(o)-1)).toString(32)+s,t="_"+t+"R_"+s,s=Zc++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=Tw++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:hf,useFormState:ip,useActionState:ip,useOptimistic:function(e){var t=Xn();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=pf.bind(null,Je,!0,s),s.dispatch=t,[e,t]},useMemoCache:sf,useCacheRefresh:function(){return Xn().memoizedState=zw.bind(null,Je)},useEffectEvent:function(e){var t=Xn(),s={impl:e};return t.memoizedState=s,function(){if((gt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}},gf={readContext:Gt,use:eu,useCallback:vp,useContext:Gt,useEffect:uf,useImperativeHandle:gp,useInsertionEffect:mp,useLayoutEffect:hp,useMemo:xp,useReducer:tu,useRef:up,useState:function(){return tu(ol)},useDebugValue:df,useDeferredValue:function(e,t){var s=en();return yp(s,bt.memoizedState,e,t)},useTransition:function(){var e=tu(ol)[0],t=en().memoizedState;return[typeof e=="boolean"?e:Mo(e),t]},useSyncExternalStore:Wh,useId:Cp,useHostTransitionStatus:hf,useFormState:rp,useActionState:rp,useOptimistic:function(e,t){var s=en();return ep(s,bt,e,t)},useMemoCache:sf,useCacheRefresh:jp};gf.useEffectEvent=fp;var Tp={readContext:Gt,use:eu,useCallback:vp,useContext:Gt,useEffect:uf,useImperativeHandle:gp,useInsertionEffect:mp,useLayoutEffect:hp,useMemo:xp,useReducer:rf,useRef:up,useState:function(){return rf(ol)},useDebugValue:df,useDeferredValue:function(e,t){var s=en();return bt===null?ff(s,e,t):yp(s,bt.memoizedState,e,t)},useTransition:function(){var e=rf(ol)[0],t=en().memoizedState;return[typeof e=="boolean"?e:Mo(e),t]},useSyncExternalStore:Wh,useId:Cp,useHostTransitionStatus:hf,useFormState:cp,useActionState:cp,useOptimistic:function(e,t){var s=en();return bt!==null?ep(s,bt,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:sf,useCacheRefresh:jp};Tp.useEffectEvent=fp;function vf(e,t,s,o){t=e.memoizedState,s=s(o,t),s=s==null?t:y({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var xf={enqueueSetState:function(e,t,s){e=e._reactInternals;var o=Ra(),u=Fn(o);u.payload=t,s!=null&&(u.callback=s),t=ra(e,u,o),t!==null&&(fa(t,e,o),Fs(t,e,o))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var o=Ra(),u=Fn(o);u.tag=1,u.payload=t,s!=null&&(u.callback=s),t=ra(e,u,o),t!==null&&(fa(t,e,o),Fs(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Ra(),o=Fn(s);o.tag=2,t!=null&&(o.callback=t),t=ra(e,o,s),t!==null&&(fa(t,e,s),Fs(t,e,s))}};function Rp(e,t,s,o,u,m,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,m,S):t.prototype&&t.prototype.isPureReactComponent?!Ll(s,o)||!Ll(u,m):!0}function Ep(e,t,s,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,o),t.state!==e&&xf.enqueueReplaceState(t,t.state,null)}function _i(e,t){var s=t;if("ref"in t){s={};for(var o in t)o!=="ref"&&(s[o]=t[o])}if(e=e.defaultProps){s===t&&(s=y({},s));for(var u in e)s[u]===void 0&&(s[u]=e[u])}return s}function Dp(e){Ti(e)}function Lp(e){console.error(e)}function _p(e){Ti(e)}function lu(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function zp(e,t,s){try{var o=e.onCaughtError;o(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(u){setTimeout(function(){throw u})}}function yf(e,t,s){return s=Fn(s),s.tag=3,s.payload={element:null},s.callback=function(){lu(e,t)},s}function Op(e){return e=Fn(e),e.tag=3,e}function Ip(e,t,s,o){var u=s.type.getDerivedStateFromError;if(typeof u=="function"){var m=o.value;e.payload=function(){return u(m)},e.callback=function(){zp(t,s,o)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){zp(t,s,o),typeof u!="function"&&(Kl===null?Kl=new Set([this]):Kl.add(this));var N=o.stack;this.componentDidCatch(o.value,{componentStack:N!==null?N:""})})}function Iw(e,t,s,o,u){if(s.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=s.alternate,t!==null&&Hl(t,s,u,!0),s=Ma.current,s!==null){switch(s.tag){case 31:case 13:return Za===null?vu():s.alternate===null&&Yt===0&&(Yt=3),s.flags&=-257,s.flags|=65536,s.lanes=u,o===jr?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([o]):t.add(o),qf(e,o,u)),!1;case 22:return s.flags|=65536,o===jr?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([o]):s.add(o)),qf(e,o,u)),!1}throw Error(r(435,s.tag))}return qf(e,o,u),vu(),!1}if(lt)return t=Ma.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=u,o!==go&&(e=Error(r(422),{cause:o}),Ri(aa(e,s)))):(o!==go&&(t=Error(r(423),{cause:o}),Ri(aa(t,s))),e=e.current.alternate,e.flags|=65536,u&=-u,e.lanes|=u,o=aa(o,s),u=yf(e.stateNode,o,u),So(e,u),Yt!==4&&(Yt=2)),!1;var m=Error(r(520),{cause:o});if(m=aa(m,s),Oo===null?Oo=[m]:Oo.push(m),Yt!==4&&(Yt=2),t===null)return!0;o=aa(o,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=u&-u,s.lanes|=e,e=yf(s.stateNode,o,e),So(s,e),!1;case 1:if(t=s.type,m=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||m!==null&&typeof m.componentDidCatch=="function"&&(Kl===null||!Kl.has(m))))return s.flags|=65536,u&=-u,s.lanes|=u,u=Op(u),Ip(u,e,s,o),So(s,u),!1}s=s.return}while(s!==null);return!1}var wf=Error(r(461)),ln=!1;function Dn(e,t,s,o){t.child=e===null?zt(t,null,s,o):Ve(t,e.child,s,o)}function Bp(e,t,s,o,u){s=s.render;var m=t.ref;if("ref"in o){var S={};for(var N in o)N!=="ref"&&(S[N]=o[N])}else S=o;return Is(t),o=ef(e,t,s,S,m,u),N=tf(),e!==null&&!ln?(nf(e,t,u),cl(e,t,u)):(lt&&N&&ho(t),t.flags|=1,Dn(e,t,o,u),t.child)}function Fp(e,t,s,o,u){if(e===null){var m=s.type;return typeof m=="function"&&!mo(m)&&m.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=m,Hp(e,t,m,o,u)):(e=Ce(s.type,null,o,t,t.mode,u),e.ref=t.ref,e.return=t,t.child=e)}if(m=e.child,!Nf(e,u)){var S=m.memoizedProps;if(s=s.compare,s=s!==null?s:Ll,s(S,o)&&e.ref===t.ref)return cl(e,t,u)}return t.flags|=1,e=ka(m,o),e.ref=t.ref,e.return=t,t.child=e}function Hp(e,t,s,o,u){if(e!==null){var m=e.memoizedProps;if(Ll(m,o)&&e.ref===t.ref)if(ln=!1,t.pendingProps=o=m,Nf(e,u))(e.flags&131072)!==0&&(ln=!0);else return t.lanes=e.lanes,cl(e,t,u)}return bf(e,t,s,o,u)}function Up(e,t,s,o){var u=o.children,m=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(m=m!==null?m.baseLanes|s:s,e!==null){for(o=t.child=e.child,u=0;o!==null;)u=u|o.lanes|o.childLanes,o=o.sibling;o=u&~m}else o=0,t.child=null;return $p(e,t,m,s,o)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Cr(t,m!==null?m.cachePool:null),m!==null?qh(t,m):Qd(),Gh(t);else return o=t.lanes=536870912,$p(e,t,m!==null?m.baseLanes|s:s,s,o)}else m!==null?(Cr(t,m.cachePool),qh(t,m),Gl(),t.memoizedState=null):(e!==null&&Cr(t,null),Qd(),Gl());return Dn(e,t,u,s),t.child}function To(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function $p(e,t,s,o,u){var m=wo();return m=m===null?null:{parent:Zt._currentValue,pool:m},t.memoizedState={baseLanes:s,cachePool:m},e!==null&&Cr(t,null),Qd(),Gh(t),e!==null&&Hl(e,t,o,!0),t.childLanes=u,null}function iu(e,t){return t=ou({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Pp(e,t,s){return Ve(t,e.child,null,s),e=iu(t,t.pendingProps),e.flags|=2,Aa(t),t.memoizedState=null,e}function Bw(e,t,s){var o=t.pendingProps,u=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(lt){if(o.mode==="hidden")return e=iu(t,o),t.lanes=536870912,To(null,e);if(Zd(t),(e=Mt)?(e=tv(e,ia),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:_s!==null?{id:Ya,overflow:Wa}:null,retryLane:536870912,hydrationErrors:null},s=Hc(e),s.return=t,t.child=s,fn=t,Mt=null)):e=null,e===null)throw Ka(t);return t.lanes=536870912,null}return iu(t,o)}var m=e.memoizedState;if(m!==null){var S=m.dehydrated;if(Zd(t),u)if(t.flags&256)t.flags&=-257,t=Pp(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(ln||Hl(e,t,s,!1),u=(s&e.childLanes)!==0,ln||u){if(o=At,o!==null&&(S=ya(o,s),S!==0&&S!==m.retryLane))throw m.retryLane=S,Ds(e,S),fa(o,e,S),wf;vu(),t=Pp(e,t,s)}else e=m.treeContext,Mt=Ja(S.nextSibling),fn=t,lt=!0,zs=null,ia=!1,e!==null&&Pc(t,e),t=iu(t,o),t.flags|=4096;return t}return e=ka(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ru(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(r(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function bf(e,t,s,o,u){return Is(t),s=ef(e,t,s,o,void 0,u),o=tf(),e!==null&&!ln?(nf(e,t,u),cl(e,t,u)):(lt&&o&&ho(t),t.flags|=1,Dn(e,t,s,u),t.child)}function qp(e,t,s,o,u,m){return Is(t),t.updateQueue=null,s=Yh(t,o,s,u),Vh(e),o=tf(),e!==null&&!ln?(nf(e,t,m),cl(e,t,m)):(lt&&o&&ho(t),t.flags|=1,Dn(e,t,s,m),t.child)}function Gp(e,t,s,o,u){if(Is(t),t.stateNode===null){var m=us,S=s.contextType;typeof S=="object"&&S!==null&&(m=Gt(S)),m=new s(o,m),t.memoizedState=m.state!==null&&m.state!==void 0?m.state:null,m.updater=xf,t.stateNode=m,m._reactInternals=t,m=t.stateNode,m.props=o,m.state=t.memoizedState,m.refs={},Qn(t),S=s.contextType,m.context=typeof S=="object"&&S!==null?Gt(S):us,m.state=t.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(vf(t,s,S,o),m.state=t.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof m.getSnapshotBeforeUpdate=="function"||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(S=m.state,typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount(),S!==m.state&&xf.enqueueReplaceState(m,m.state,null),jo(t,o,m,u),Co(),m.state=t.memoizedState),typeof m.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){m=t.stateNode;var N=t.memoizedProps,B=_i(s,N);m.props=B;var te=m.context,fe=s.contextType;S=us,typeof fe=="object"&&fe!==null&&(S=Gt(fe));var ye=s.getDerivedStateFromProps;fe=typeof ye=="function"||typeof m.getSnapshotBeforeUpdate=="function",N=t.pendingProps!==N,fe||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(N||te!==S)&&Ep(t,m,o,S),Ht=!1;var se=t.memoizedState;m.state=se,jo(t,o,m,u),Co(),te=t.memoizedState,N||se!==te||Ht?(typeof ye=="function"&&(vf(t,s,ye,o),te=t.memoizedState),(B=Ht||Rp(t,s,B,o,se,te,S))?(fe||typeof m.UNSAFE_componentWillMount!="function"&&typeof m.componentWillMount!="function"||(typeof m.componentWillMount=="function"&&m.componentWillMount(),typeof m.UNSAFE_componentWillMount=="function"&&m.UNSAFE_componentWillMount()),typeof m.componentDidMount=="function"&&(t.flags|=4194308)):(typeof m.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=te),m.props=o,m.state=te,m.context=S,o=B):(typeof m.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{m=t.stateNode,Xa(e,t),S=t.memoizedProps,fe=_i(s,S),m.props=fe,ye=t.pendingProps,se=m.context,te=s.contextType,B=us,typeof te=="object"&&te!==null&&(B=Gt(te)),N=s.getDerivedStateFromProps,(te=typeof N=="function"||typeof m.getSnapshotBeforeUpdate=="function")||typeof m.UNSAFE_componentWillReceiveProps!="function"&&typeof m.componentWillReceiveProps!="function"||(S!==ye||se!==B)&&Ep(t,m,o,B),Ht=!1,se=t.memoizedState,m.state=se,jo(t,o,m,u),Co();var re=t.memoizedState;S!==ye||se!==re||Ht||e!==null&&e.dependencies!==null&&wr(e.dependencies)?(typeof N=="function"&&(vf(t,s,N,o),re=t.memoizedState),(fe=Ht||Rp(t,s,fe,o,se,re,B)||e!==null&&e.dependencies!==null&&wr(e.dependencies))?(te||typeof m.UNSAFE_componentWillUpdate!="function"&&typeof m.componentWillUpdate!="function"||(typeof m.componentWillUpdate=="function"&&m.componentWillUpdate(o,re,B),typeof m.UNSAFE_componentWillUpdate=="function"&&m.UNSAFE_componentWillUpdate(o,re,B)),typeof m.componentDidUpdate=="function"&&(t.flags|=4),typeof m.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof m.componentDidUpdate!="function"||S===e.memoizedProps&&se===e.memoizedState||(t.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&se===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=re),m.props=o,m.state=re,m.context=B,o=fe):(typeof m.componentDidUpdate!="function"||S===e.memoizedProps&&se===e.memoizedState||(t.flags|=4),typeof m.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&se===e.memoizedState||(t.flags|=1024),o=!1)}return m=o,ru(e,t),o=(t.flags&128)!==0,m||o?(m=t.stateNode,s=o&&typeof s.getDerivedStateFromError!="function"?null:m.render(),t.flags|=1,e!==null&&o?(t.child=Ve(t,e.child,null,u),t.child=Ve(t,null,s,u)):Dn(e,t,s,u),t.memoizedState=m.state,e=t.child):e=cl(e,t,u),e}function Vp(e,t,s,o){return al(),t.flags|=256,Dn(e,t,s,o),t.child}var Sf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Cf(e){return{baseLanes:e,cachePool:Kn()}}function jf(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Ta),e}function Yp(e,t,s){var o=t.pendingProps,u=!1,m=(t.flags&128)!==0,S;if((S=m)||(S=e!==null&&e.memoizedState===null?!1:(Jt.current&2)!==0),S&&(u=!0,t.flags&=-129),S=(t.flags&32)!==0,t.flags&=-33,e===null){if(lt){if(u?ql(t):Gl(),(e=Mt)?(e=tv(e,ia),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:_s!==null?{id:Ya,overflow:Wa}:null,retryLane:536870912,hydrationErrors:null},s=Hc(e),s.return=t,t.child=s,fn=t,Mt=null)):e=null,e===null)throw Ka(t);return im(e)?t.lanes=32:t.lanes=536870912,null}var N=o.children;return o=o.fallback,u?(Gl(),u=t.mode,N=ou({mode:"hidden",children:N},u),o=Va(o,u,s,null),N.return=t,o.return=t,N.sibling=o,t.child=N,o=t.child,o.memoizedState=Cf(s),o.childLanes=jf(e,S,s),t.memoizedState=Sf,To(null,o)):(ql(t),kf(t,N))}var B=e.memoizedState;if(B!==null&&(N=B.dehydrated,N!==null)){if(m)t.flags&256?(ql(t),t.flags&=-257,t=Mf(e,t,s)):t.memoizedState!==null?(Gl(),t.child=e.child,t.flags|=128,t=null):(Gl(),N=o.fallback,u=t.mode,o=ou({mode:"visible",children:o.children},u),N=Va(N,u,s,null),N.flags|=2,o.return=t,N.return=t,o.sibling=N,t.child=o,Ve(t,e.child,null,s),o=t.child,o.memoizedState=Cf(s),o.childLanes=jf(e,S,s),t.memoizedState=Sf,t=To(null,o));else if(ql(t),im(N)){if(S=N.nextSibling&&N.nextSibling.dataset,S)var te=S.dgst;S=te,o=Error(r(419)),o.stack="",o.digest=S,Ri({value:o,source:null,stack:null}),t=Mf(e,t,s)}else if(ln||Hl(e,t,s,!1),S=(s&e.childLanes)!==0,ln||S){if(S=At,S!==null&&(o=ya(S,s),o!==0&&o!==B.retryLane))throw B.retryLane=o,Ds(e,o),fa(S,e,o),wf;lm(N)||vu(),t=Mf(e,t,s)}else lm(N)?(t.flags|=192,t.child=e.child,t=null):(e=B.treeContext,Mt=Ja(N.nextSibling),fn=t,lt=!0,zs=null,ia=!1,e!==null&&Pc(t,e),t=kf(t,o.children),t.flags|=4096);return t}return u?(Gl(),N=o.fallback,u=t.mode,B=e.child,te=B.sibling,o=ka(B,{mode:"hidden",children:o.children}),o.subtreeFlags=B.subtreeFlags&65011712,te!==null?N=ka(te,N):(N=Va(N,u,s,null),N.flags|=2),N.return=t,o.return=t,o.sibling=N,t.child=o,To(null,o),o=t.child,N=e.child.memoizedState,N===null?N=Cf(s):(u=N.cachePool,u!==null?(B=Zt._currentValue,u=u.parent!==B?{parent:B,pool:B}:u):u=Kn(),N={baseLanes:N.baseLanes|s,cachePool:u}),o.memoizedState=N,o.childLanes=jf(e,S,s),t.memoizedState=Sf,To(e.child,o)):(ql(t),s=e.child,e=s.sibling,s=ka(s,{mode:"visible",children:o.children}),s.return=t,s.sibling=null,e!==null&&(S=t.deletions,S===null?(t.deletions=[e],t.flags|=16):S.push(e)),t.child=s,t.memoizedState=null,s)}function kf(e,t){return t=ou({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function ou(e,t){return e=xn(22,e,null,t),e.lanes=0,e}function Mf(e,t,s){return Ve(t,e.child,null,s),e=kf(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Wp(e,t,s){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),yr(e.return,t,s)}function Af(e,t,s,o,u,m){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:s,tailMode:u,treeForkCount:m}:(S.isBackwards=t,S.rendering=null,S.renderingStartTime=0,S.last=o,S.tail=s,S.tailMode=u,S.treeForkCount=m)}function Kp(e,t,s){var o=t.pendingProps,u=o.revealOrder,m=o.tail;o=o.children;var S=Jt.current,N=(S&2)!==0;if(N?(S=S&1|2,t.flags|=128):S&=1,J(Jt,S),Dn(e,t,o,s),o=lt?tt:0,!N&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Wp(e,s,t);else if(e.tag===19)Wp(e,s,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(u){case"forwards":for(s=t.child,u=null;s!==null;)e=s.alternate,e!==null&&Qc(e)===null&&(u=s),s=s.sibling;s=u,s===null?(u=t.child,t.child=null):(u=s.sibling,s.sibling=null),Af(t,!1,u,s,m,o);break;case"backwards":case"unstable_legacy-backwards":for(s=null,u=t.child,t.child=null;u!==null;){if(e=u.alternate,e!==null&&Qc(e)===null){t.child=u;break}e=u.sibling,u.sibling=s,s=u,u=e}Af(t,!0,s,null,m,o);break;case"together":Af(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function cl(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),Wl|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(Hl(e,t,s,!1),(s&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,s=ka(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=ka(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function Nf(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&wr(e)))}function Fw(e,t,s){switch(t.tag){case 3:He(t,t.stateNode.containerInfo),Os(t,Zt,e.memoizedState.cache),al();break;case 27:case 5:Ze(t);break;case 4:He(t,t.stateNode.containerInfo);break;case 10:Os(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Zd(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(ql(t),t.flags|=128,null):(s&t.child.childLanes)!==0?Yp(e,t,s):(ql(t),e=cl(e,t,s),e!==null?e.sibling:null);ql(t);break;case 19:var u=(e.flags&128)!==0;if(o=(s&t.childLanes)!==0,o||(Hl(e,t,s,!1),o=(s&t.childLanes)!==0),u){if(o)return Kp(e,t,s);t.flags|=128}if(u=t.memoizedState,u!==null&&(u.rendering=null,u.tail=null,u.lastEffect=null),J(Jt,Jt.current),o)break;return null;case 22:return t.lanes=0,Up(e,t,s,t.pendingProps);case 24:Os(t,Zt,e.memoizedState.cache)}return cl(e,t,s)}function Qp(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)ln=!0;else{if(!Nf(e,s)&&(t.flags&128)===0)return ln=!1,Fw(e,t,s);ln=(e.flags&131072)!==0}else ln=!1,lt&&(t.flags&1048576)!==0&&$c(t,tt,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Bs(t.elementType),t.type=e,typeof e=="function")mo(e)?(o=_i(e,o),t.tag=1,t=Gp(null,t,e,o,s)):(t.tag=0,t=bf(null,t,e,o,s));else{if(e!=null){var u=e.$$typeof;if(u===U){t.tag=11,t=Bp(null,t,e,o,s);break e}else if(u===L){t.tag=14,t=Fp(null,t,e,o,s);break e}}throw t=ce(e)||e,Error(r(306,t,""))}}return t;case 0:return bf(e,t,t.type,t.pendingProps,s);case 1:return o=t.type,u=_i(o,t.pendingProps),Gp(e,t,o,u,s);case 3:e:{if(He(t,t.stateNode.containerInfo),e===null)throw Error(r(387));o=t.pendingProps;var m=t.memoizedState;u=m.element,Xa(e,t),jo(t,o,null,s);var S=t.memoizedState;if(o=S.cache,Os(t,Zt,o),o!==m.cache&&Ei(t,[Zt],s,!0),Co(),o=S.element,m.isDehydrated)if(m={element:o,isDehydrated:!1,cache:S.cache},t.updateQueue.baseState=m,t.memoizedState=m,t.flags&256){t=Vp(e,t,o,s);break e}else if(o!==u){u=aa(Error(r(424)),t),Ri(u),t=Vp(e,t,o,s);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Mt=Ja(e.firstChild),fn=t,lt=!0,zs=null,ia=!0,s=zt(t,null,o,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(al(),o===u){t=cl(e,t,s);break e}Dn(e,t,o,s)}t=t.child}return t;case 26:return ru(e,t),e===null?(s=rv(t.type,null,t.pendingProps,null))?t.memoizedState=s:lt||(s=t.type,e=t.pendingProps,o=ju(je.current).createElement(s),o[X]=t,o[Se]=e,Ln(o,s,e),mt(o),t.stateNode=o):t.memoizedState=rv(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Ze(t),e===null&&lt&&(o=t.stateNode=sv(t.type,t.pendingProps,je.current),fn=t,ia=!0,u=Mt,Jl(t.type)?(rm=u,Mt=Ja(o.firstChild)):Mt=u),Dn(e,t,t.pendingProps.children,s),ru(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&lt&&((u=o=Mt)&&(o=pb(o,t.type,t.pendingProps,ia),o!==null?(t.stateNode=o,fn=t,Mt=Ja(o.firstChild),ia=!1,u=!0):u=!1),u||Ka(t)),Ze(t),u=t.type,m=t.pendingProps,S=e!==null?e.memoizedProps:null,o=m.children,nm(u,m)?o=null:S!==null&&nm(u,S)&&(t.flags|=32),t.memoizedState!==null&&(u=ef(e,t,Rw,null,null,s),qo._currentValue=u),ru(e,t),Dn(e,t,o,s),t.child;case 6:return e===null&&lt&&((e=s=Mt)&&(s=gb(s,t.pendingProps,ia),s!==null?(t.stateNode=s,fn=t,Mt=null,e=!0):e=!1),e||Ka(t)),null;case 13:return Yp(e,t,s);case 4:return He(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=Ve(t,null,o,s):Dn(e,t,o,s),t.child;case 11:return Bp(e,t,t.type,t.pendingProps,s);case 7:return Dn(e,t,t.pendingProps,s),t.child;case 8:return Dn(e,t,t.pendingProps.children,s),t.child;case 12:return Dn(e,t,t.pendingProps.children,s),t.child;case 10:return o=t.pendingProps,Os(t,t.type,o.value),Dn(e,t,o.children,s),t.child;case 9:return u=t.type._context,o=t.pendingProps.children,Is(t),u=Gt(u),o=o(u),t.flags|=1,Dn(e,t,o,s),t.child;case 14:return Fp(e,t,t.type,t.pendingProps,s);case 15:return Hp(e,t,t.type,t.pendingProps,s);case 19:return Kp(e,t,s);case 31:return Bw(e,t,s);case 22:return Up(e,t,s,t.pendingProps);case 24:return Is(t),o=Gt(Zt),e===null?(u=wo(),u===null&&(u=At,m=yo(),u.pooledCache=m,m.refCount++,m!==null&&(u.pooledCacheLanes|=s),u=m),t.memoizedState={parent:o,cache:u},Qn(t),Os(t,Zt,u)):((e.lanes&s)!==0&&(Xa(e,t),jo(t,null,null,s),Co()),u=e.memoizedState,m=t.memoizedState,u.parent!==o?(u={parent:o,cache:o},t.memoizedState=u,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=u),Os(t,Zt,o)):(o=m.cache,Os(t,Zt,o),o!==u.cache&&Ei(t,[Zt],s,!0))),Dn(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function ul(e){e.flags|=4}function Tf(e,t,s,o,u){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(u&335544128)===u)if(e.stateNode.complete)e.flags|=8192;else if(Cg())e.flags|=8192;else throw x=jr,bo}else e.flags&=-16777217}function Xp(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!fv(t))if(Cg())e.flags|=8192;else throw x=jr,bo}function cu(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?mi():536870912,e.lanes|=t,Lr|=t)}function Ro(e,t){if(!lt)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Lt(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,o=0;if(t)for(var u=e.child;u!==null;)s|=u.lanes|u.childLanes,o|=u.subtreeFlags&65011712,o|=u.flags&65011712,u.return=e,u=u.sibling;else for(u=e.child;u!==null;)s|=u.lanes|u.childLanes,o|=u.subtreeFlags,o|=u.flags,u.return=e,u=u.sibling;return e.subtreeFlags|=o,e.childLanes=s,t}function Hw(e,t,s){var o=t.pendingProps;switch(po(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Lt(t),null;case 1:return Lt(t),null;case 3:return s=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),Bn(Zt),oe(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Fl(t)?ul(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,vo())),Lt(t),null;case 26:var u=t.type,m=t.memoizedState;return e===null?(ul(t),m!==null?(Lt(t),Xp(t,m)):(Lt(t),Tf(t,u,null,o,s))):m?m!==e.memoizedState?(ul(t),Lt(t),Xp(t,m)):(Lt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&ul(t),Lt(t),Tf(t,u,e,o,s)),null;case 27:if(De(t),s=je.current,u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ul(t);else{if(!o){if(t.stateNode===null)throw Error(r(166));return Lt(t),null}e=he.current,Fl(t)?xr(t):(e=sv(u,o,s),t.stateNode=e,ul(t))}return Lt(t),null;case 5:if(De(t),u=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ul(t);else{if(!o){if(t.stateNode===null)throw Error(r(166));return Lt(t),null}if(m=he.current,Fl(t))xr(t);else{var S=ju(je.current);switch(m){case 1:m=S.createElementNS("http://www.w3.org/2000/svg",u);break;case 2:m=S.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;default:switch(u){case"svg":m=S.createElementNS("http://www.w3.org/2000/svg",u);break;case"math":m=S.createElementNS("http://www.w3.org/1998/Math/MathML",u);break;case"script":m=S.createElement("div"),m.innerHTML="<script><\/script>",m=m.removeChild(m.firstChild);break;case"select":m=typeof o.is=="string"?S.createElement("select",{is:o.is}):S.createElement("select"),o.multiple?m.multiple=!0:o.size&&(m.size=o.size);break;default:m=typeof o.is=="string"?S.createElement(u,{is:o.is}):S.createElement(u)}}m[X]=t,m[Se]=o;e:for(S=t.child;S!==null;){if(S.tag===5||S.tag===6)m.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===t)break e;for(;S.sibling===null;){if(S.return===null||S.return===t)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}t.stateNode=m;e:switch(Ln(m,u,o),u){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&ul(t)}}return Lt(t),Tf(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&ul(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(r(166));if(e=je.current,Fl(t)){if(e=t.stateNode,s=t.memoizedProps,o=null,u=fn,u!==null)switch(u.tag){case 27:case 5:o=u.memoizedProps}e[X]=t,e=!!(e.nodeValue===s||o!==null&&o.suppressHydrationWarning===!0||Yg(e.nodeValue,s)),e||Ka(t,!0)}else e=ju(e).createTextNode(o),e[X]=t,t.stateNode=e}return Lt(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(o=Fl(t),s!==null){if(e===null){if(!o)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[X]=t}else al(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Lt(t),e=!1}else s=vo(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(Aa(t),t):(Aa(t),null);if((t.flags&128)!==0)throw Error(r(558))}return Lt(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(u=Fl(t),o!==null&&o.dehydrated!==null){if(e===null){if(!u)throw Error(r(318));if(u=t.memoizedState,u=u!==null?u.dehydrated:null,!u)throw Error(r(317));u[X]=t}else al(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Lt(t),u=!1}else u=vo(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=u),u=!0;if(!u)return t.flags&256?(Aa(t),t):(Aa(t),null)}return Aa(t),(t.flags&128)!==0?(t.lanes=s,t):(s=o!==null,e=e!==null&&e.memoizedState!==null,s&&(o=t.child,u=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(u=o.alternate.memoizedState.cachePool.pool),m=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(m=o.memoizedState.cachePool.pool),m!==u&&(o.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),cu(t,t.updateQueue),Lt(t),null);case 4:return oe(),e===null&&Xf(t.stateNode.containerInfo),Lt(t),null;case 10:return Bn(t.type),Lt(t),null;case 19:if(D(Jt),o=t.memoizedState,o===null)return Lt(t),null;if(u=(t.flags&128)!==0,m=o.rendering,m===null)if(u)Ro(o,!1);else{if(Yt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(m=Qc(e),m!==null){for(t.flags|=128,Ro(o,!1),e=m.updateQueue,t.updateQueue=e,cu(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)pr(s,e),s=s.sibling;return J(Jt,Jt.current&1|2),lt&&fs(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Ie()>hu&&(t.flags|=128,u=!0,Ro(o,!1),t.lanes=4194304)}else{if(!u)if(e=Qc(m),e!==null){if(t.flags|=128,u=!0,e=e.updateQueue,t.updateQueue=e,cu(t,e),Ro(o,!0),o.tail===null&&o.tailMode==="hidden"&&!m.alternate&&!lt)return Lt(t),null}else 2*Ie()-o.renderingStartTime>hu&&s!==536870912&&(t.flags|=128,u=!0,Ro(o,!1),t.lanes=4194304);o.isBackwards?(m.sibling=t.child,t.child=m):(e=o.last,e!==null?e.sibling=m:t.child=m,o.last=m)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Ie(),e.sibling=null,s=Jt.current,J(Jt,u?s&1|2:s&1),lt&&fs(t,o.treeForkCount),e):(Lt(t),null);case 22:case 23:return Aa(t),Xd(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(s&536870912)!==0&&(t.flags&128)===0&&(Lt(t),t.subtreeFlags&6&&(t.flags|=8192)):Lt(t),s=t.updateQueue,s!==null&&cu(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==s&&(t.flags|=2048),e!==null&&D(il),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Bn(Zt),Lt(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Uw(e,t){switch(po(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Bn(Zt),oe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return De(t),null;case 31:if(t.memoizedState!==null){if(Aa(t),t.alternate===null)throw Error(r(340));al()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Aa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));al()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return D(Jt),null;case 4:return oe(),null;case 10:return Bn(t.type),null;case 22:case 23:return Aa(t),Xd(),e!==null&&D(il),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Bn(Zt),null;case 25:return null;default:return null}}function Zp(e,t){switch(po(t),t.tag){case 3:Bn(Zt),oe();break;case 26:case 27:case 5:De(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&Aa(t);break;case 13:Aa(t);break;case 19:D(Jt);break;case 10:Bn(t.type);break;case 22:case 23:Aa(t),Xd(),e!==null&&D(il);break;case 24:Bn(Zt)}}function Eo(e,t){try{var s=t.updateQueue,o=s!==null?s.lastEffect:null;if(o!==null){var u=o.next;s=u;do{if((s.tag&e)===e){o=void 0;var m=s.create,S=s.inst;o=m(),S.destroy=o}s=s.next}while(s!==u)}}catch(N){yt(t,t.return,N)}}function Vl(e,t,s){try{var o=t.updateQueue,u=o!==null?o.lastEffect:null;if(u!==null){var m=u.next;o=m;do{if((o.tag&e)===e){var S=o.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,u=t;var B=s,te=N;try{te()}catch(fe){yt(u,B,fe)}}}o=o.next}while(o!==m)}}catch(fe){yt(t,t.return,fe)}}function Jp(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{Ph(t,s)}catch(o){yt(e,e.return,o)}}}function eg(e,t,s){s.props=_i(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(o){yt(e,t,o)}}function Do(e,t){try{var s=e.ref;if(s!==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 s=="function"?e.refCleanup=s(o):s.current=o}}catch(u){yt(e,t,u)}}function Hs(e,t){var s=e.ref,o=e.refCleanup;if(s!==null)if(typeof o=="function")try{o()}catch(u){yt(e,t,u)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(u){yt(e,t,u)}else s.current=null}function tg(e){var t=e.type,s=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&o.focus();break e;case"img":s.src?o.src=s.src:s.srcSet&&(o.srcset=s.srcSet)}}catch(u){yt(e,e.return,u)}}function Rf(e,t,s){try{var o=e.stateNode;cb(o,e.type,s,t),o[Se]=t}catch(u){yt(e,e.return,u)}}function ng(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Jl(e.type)||e.tag===4}function Ef(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ng(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&&Jl(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 Df(e,t,s){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=ls));else if(o!==4&&(o===27&&Jl(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(Df(e,t,s),e=e.sibling;e!==null;)Df(e,t,s),e=e.sibling}function uu(e,t,s){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(o!==4&&(o===27&&Jl(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(uu(e,t,s),e=e.sibling;e!==null;)uu(e,t,s),e=e.sibling}function ag(e){var t=e.stateNode,s=e.memoizedProps;try{for(var o=e.type,u=t.attributes;u.length;)t.removeAttributeNode(u[0]);Ln(t,o,s),t[X]=e,t[Se]=s}catch(m){yt(e,e.return,m)}}var dl=!1,rn=!1,Lf=!1,sg=typeof WeakSet=="function"?WeakSet:Set,bn=null;function $w(e,t){if(e=e.containerInfo,em=Eu,e=ki(e),_l(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var o=s.getSelection&&s.getSelection();if(o&&o.rangeCount!==0){s=o.anchorNode;var u=o.anchorOffset,m=o.focusNode;o=o.focusOffset;try{s.nodeType,m.nodeType}catch{s=null;break e}var S=0,N=-1,B=-1,te=0,fe=0,ye=e,se=null;t:for(;;){for(var re;ye!==s||u!==0&&ye.nodeType!==3||(N=S+u),ye!==m||o!==0&&ye.nodeType!==3||(B=S+o),ye.nodeType===3&&(S+=ye.nodeValue.length),(re=ye.firstChild)!==null;)se=ye,ye=re;for(;;){if(ye===e)break t;if(se===s&&++te===u&&(N=S),se===m&&++fe===o&&(B=S),(re=ye.nextSibling)!==null)break;ye=se,se=ye.parentNode}ye=re}s=N===-1||B===-1?null:{start:N,end:B}}else s=null}s=s||{start:0,end:0}}else s=null;for(tm={focusedElem:e,selectionRange:s},Eu=!1,bn=t;bn!==null;)if(t=bn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,bn=e;else for(;bn!==null;){switch(t=bn,m=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(s=0;s<e.length;s++)u=e[s],u.ref.impl=u.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&m!==null){e=void 0,s=t,u=m.memoizedProps,m=m.memoizedState,o=s.stateNode;try{var ze=_i(s.type,u);e=o.getSnapshotBeforeUpdate(ze,m),o.__reactInternalSnapshotBeforeUpdate=e}catch(Ge){yt(s,s.return,Ge)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)sm(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":sm(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(r(163))}if(e=t.sibling,e!==null){e.return=t.return,bn=e;break}bn=t.return}}function lg(e,t,s){var o=s.flags;switch(s.tag){case 0:case 11:case 15:ml(e,s),o&4&&Eo(5,s);break;case 1:if(ml(e,s),o&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(S){yt(s,s.return,S)}else{var u=_i(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(u,t,e.__reactInternalSnapshotBeforeUpdate)}catch(S){yt(s,s.return,S)}}o&64&&Jp(s),o&512&&Do(s,s.return);break;case 3:if(ml(e,s),o&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{Ph(e,t)}catch(S){yt(s,s.return,S)}}break;case 27:t===null&&o&4&&ag(s);case 26:case 5:ml(e,s),t===null&&o&4&&tg(s),o&512&&Do(s,s.return);break;case 12:ml(e,s);break;case 31:ml(e,s),o&4&&og(e,s);break;case 13:ml(e,s),o&4&&cg(e,s),o&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=Xw.bind(null,s),vb(e,s))));break;case 22:if(o=s.memoizedState!==null||dl,!o){t=t!==null&&t.memoizedState!==null||rn,u=dl;var m=rn;dl=o,(rn=t)&&!m?hl(e,s,(s.subtreeFlags&8772)!==0):ml(e,s),dl=u,rn=m}break;case 30:break;default:ml(e,s)}}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&&pn(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 Ot=null,oa=!1;function fl(e,t,s){for(s=s.child;s!==null;)rg(e,t,s),s=s.sibling}function rg(e,t,s){if(wt&&typeof wt.onCommitFiberUnmount=="function")try{wt.onCommitFiberUnmount(Ye,s)}catch{}switch(s.tag){case 26:rn||Hs(s,t),fl(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:rn||Hs(s,t);var o=Ot,u=oa;Jl(s.type)&&(Ot=s.stateNode,oa=!1),fl(e,t,s),Uo(s.stateNode),Ot=o,oa=u;break;case 5:rn||Hs(s,t);case 6:if(o=Ot,u=oa,Ot=null,fl(e,t,s),Ot=o,oa=u,Ot!==null)if(oa)try{(Ot.nodeType===9?Ot.body:Ot.nodeName==="HTML"?Ot.ownerDocument.body:Ot).removeChild(s.stateNode)}catch(m){yt(s,t,m)}else try{Ot.removeChild(s.stateNode)}catch(m){yt(s,t,m)}break;case 18:Ot!==null&&(oa?(e=Ot,Jg(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),Ur(e)):Jg(Ot,s.stateNode));break;case 4:o=Ot,u=oa,Ot=s.stateNode.containerInfo,oa=!0,fl(e,t,s),Ot=o,oa=u;break;case 0:case 11:case 14:case 15:Vl(2,s,t),rn||Vl(4,s,t),fl(e,t,s);break;case 1:rn||(Hs(s,t),o=s.stateNode,typeof o.componentWillUnmount=="function"&&eg(s,t,o)),fl(e,t,s);break;case 21:fl(e,t,s);break;case 22:rn=(o=rn)||s.memoizedState!==null,fl(e,t,s),rn=o;break;default:fl(e,t,s)}}function og(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Ur(e)}catch(s){yt(t,t.return,s)}}}function cg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Ur(e)}catch(s){yt(t,t.return,s)}}function Pw(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new sg),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new sg),t;default:throw Error(r(435,e.tag))}}function du(e,t){var s=Pw(e);t.forEach(function(o){if(!s.has(o)){s.add(o);var u=Zw.bind(null,e,o);o.then(u,u)}})}function ca(e,t){var s=t.deletions;if(s!==null)for(var o=0;o<s.length;o++){var u=s[o],m=e,S=t,N=S;e:for(;N!==null;){switch(N.tag){case 27:if(Jl(N.type)){Ot=N.stateNode,oa=!1;break e}break;case 5:Ot=N.stateNode,oa=!1;break e;case 3:case 4:Ot=N.stateNode.containerInfo,oa=!0;break e}N=N.return}if(Ot===null)throw Error(r(160));rg(m,S,u),Ot=null,oa=!1,m=u.alternate,m!==null&&(m.return=null),u.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ug(t,e),t=t.sibling}var ps=null;function ug(e,t){var s=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ca(t,e),ua(e),o&4&&(Vl(3,e,e.return),Eo(3,e),Vl(5,e,e.return));break;case 1:ca(t,e),ua(e),o&512&&(rn||s===null||Hs(s,s.return)),o&64&&dl&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?o:s.concat(o))));break;case 26:var u=ps;if(ca(t,e),ua(e),o&512&&(rn||s===null||Hs(s,s.return)),o&4){var m=s!==null?s.memoizedState:null;if(o=e.memoizedState,s===null)if(o===null)if(e.stateNode===null){e:{o=e.type,s=e.memoizedProps,u=u.ownerDocument||u;t:switch(o){case"title":m=u.getElementsByTagName("title")[0],(!m||m[dt]||m[X]||m.namespaceURI==="http://www.w3.org/2000/svg"||m.hasAttribute("itemprop"))&&(m=u.createElement(o),u.head.insertBefore(m,u.querySelector("head > title"))),Ln(m,o,s),m[X]=e,mt(m),o=m;break e;case"link":var S=uv("link","href",u).get(o+(s.href||""));if(S){for(var N=0;N<S.length;N++)if(m=S[N],m.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&m.getAttribute("rel")===(s.rel==null?null:s.rel)&&m.getAttribute("title")===(s.title==null?null:s.title)&&m.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(N,1);break t}}m=u.createElement(o),Ln(m,o,s),u.head.appendChild(m);break;case"meta":if(S=uv("meta","content",u).get(o+(s.content||""))){for(N=0;N<S.length;N++)if(m=S[N],m.getAttribute("content")===(s.content==null?null:""+s.content)&&m.getAttribute("name")===(s.name==null?null:s.name)&&m.getAttribute("property")===(s.property==null?null:s.property)&&m.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&m.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(N,1);break t}}m=u.createElement(o),Ln(m,o,s),u.head.appendChild(m);break;default:throw Error(r(468,o))}m[X]=e,mt(m),o=m}e.stateNode=o}else dv(u,e.type,e.stateNode);else e.stateNode=cv(u,o,e.memoizedProps);else m!==o?(m===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):m.count--,o===null?dv(u,e.type,e.stateNode):cv(u,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Rf(e,e.memoizedProps,s.memoizedProps)}break;case 27:ca(t,e),ua(e),o&512&&(rn||s===null||Hs(s,s.return)),s!==null&&o&4&&Rf(e,e.memoizedProps,s.memoizedProps);break;case 5:if(ca(t,e),ua(e),o&512&&(rn||s===null||Hs(s,s.return)),e.flags&32){u=e.stateNode;try{hi(u,"")}catch(ze){yt(e,e.return,ze)}}o&4&&e.stateNode!=null&&(u=e.memoizedProps,Rf(e,u,s!==null?s.memoizedProps:u)),o&1024&&(Lf=!0);break;case 6:if(ca(t,e),ua(e),o&4){if(e.stateNode===null)throw Error(r(162));o=e.memoizedProps,s=e.stateNode;try{s.nodeValue=o}catch(ze){yt(e,e.return,ze)}}break;case 3:if(Au=null,u=ps,ps=ku(t.containerInfo),ca(t,e),ps=u,ua(e),o&4&&s!==null&&s.memoizedState.isDehydrated)try{Ur(t.containerInfo)}catch(ze){yt(e,e.return,ze)}Lf&&(Lf=!1,dg(e));break;case 4:o=ps,ps=ku(e.stateNode.containerInfo),ca(t,e),ua(e),ps=o;break;case 12:ca(t,e),ua(e);break;case 31:ca(t,e),ua(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,du(e,o)));break;case 13:ca(t,e),ua(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(mu=Ie()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,du(e,o)));break;case 22:u=e.memoizedState!==null;var B=s!==null&&s.memoizedState!==null,te=dl,fe=rn;if(dl=te||u,rn=fe||B,ca(t,e),rn=fe,dl=te,ua(e),o&8192)e:for(t=e.stateNode,t._visibility=u?t._visibility&-2:t._visibility|1,u&&(s===null||B||dl||rn||zi(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){B=s=t;try{if(m=B.stateNode,u)S=m.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{N=B.stateNode;var ye=B.memoizedProps.style,se=ye!=null&&ye.hasOwnProperty("display")?ye.display:null;N.style.display=se==null||typeof se=="boolean"?"":(""+se).trim()}}catch(ze){yt(B,B.return,ze)}}}else if(t.tag===6){if(s===null){B=t;try{B.stateNode.nodeValue=u?"":B.memoizedProps}catch(ze){yt(B,B.return,ze)}}}else if(t.tag===18){if(s===null){B=t;try{var re=B.stateNode;u?ev(re,!0):ev(B.stateNode,!1)}catch(ze){yt(B,B.return,ze)}}}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;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(s=o.retryQueue,s!==null&&(o.retryQueue=null,du(e,s))));break;case 19:ca(t,e),ua(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,du(e,o)));break;case 30:break;case 21:break;default:ca(t,e),ua(e)}}function ua(e){var t=e.flags;if(t&2){try{for(var s,o=e.return;o!==null;){if(ng(o)){s=o;break}o=o.return}if(s==null)throw Error(r(160));switch(s.tag){case 27:var u=s.stateNode,m=Ef(e);uu(e,m,u);break;case 5:var S=s.stateNode;s.flags&32&&(hi(S,""),s.flags&=-33);var N=Ef(e);uu(e,N,S);break;case 3:case 4:var B=s.stateNode.containerInfo,te=Ef(e);Df(e,te,B);break;default:throw Error(r(161))}}catch(fe){yt(e,e.return,fe)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function dg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;dg(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function ml(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)lg(e,t.alternate,t),t=t.sibling}function zi(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Vl(4,t,t.return),zi(t);break;case 1:Hs(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&eg(t,t.return,s),zi(t);break;case 27:Uo(t.stateNode);case 26:case 5:Hs(t,t.return),zi(t);break;case 22:t.memoizedState===null&&zi(t);break;case 30:zi(t);break;default:zi(t)}e=e.sibling}}function hl(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,u=e,m=t,S=m.flags;switch(m.tag){case 0:case 11:case 15:hl(u,m,s),Eo(4,m);break;case 1:if(hl(u,m,s),o=m,u=o.stateNode,typeof u.componentDidMount=="function")try{u.componentDidMount()}catch(te){yt(o,o.return,te)}if(o=m,u=o.updateQueue,u!==null){var N=o.stateNode;try{var B=u.shared.hiddenCallbacks;if(B!==null)for(u.shared.hiddenCallbacks=null,u=0;u<B.length;u++)$h(B[u],N)}catch(te){yt(o,o.return,te)}}s&&S&64&&Jp(m),Do(m,m.return);break;case 27:ag(m);case 26:case 5:hl(u,m,s),s&&o===null&&S&4&&tg(m),Do(m,m.return);break;case 12:hl(u,m,s);break;case 31:hl(u,m,s),s&&S&4&&og(u,m);break;case 13:hl(u,m,s),s&&S&4&&cg(u,m);break;case 22:m.memoizedState===null&&hl(u,m,s),Do(m,m.return);break;case 30:break;default:hl(u,m,s)}t=t.sibling}}function _f(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&Di(s))}function zf(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Di(e))}function gs(e,t,s,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)fg(e,t,s,o),t=t.sibling}function fg(e,t,s,o){var u=t.flags;switch(t.tag){case 0:case 11:case 15:gs(e,t,s,o),u&2048&&Eo(9,t);break;case 1:gs(e,t,s,o);break;case 3:gs(e,t,s,o),u&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Di(e)));break;case 12:if(u&2048){gs(e,t,s,o),e=t.stateNode;try{var m=t.memoizedProps,S=m.id,N=m.onPostCommit;typeof N=="function"&&N(S,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(B){yt(t,t.return,B)}}else gs(e,t,s,o);break;case 31:gs(e,t,s,o);break;case 13:gs(e,t,s,o);break;case 23:break;case 22:m=t.stateNode,S=t.alternate,t.memoizedState!==null?m._visibility&2?gs(e,t,s,o):Lo(e,t):m._visibility&2?gs(e,t,s,o):(m._visibility|=2,Rr(e,t,s,o,(t.subtreeFlags&10256)!==0||!1)),u&2048&&_f(S,t);break;case 24:gs(e,t,s,o),u&2048&&zf(t.alternate,t);break;default:gs(e,t,s,o)}}function Rr(e,t,s,o,u){for(u=u&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var m=e,S=t,N=s,B=o,te=S.flags;switch(S.tag){case 0:case 11:case 15:Rr(m,S,N,B,u),Eo(8,S);break;case 23:break;case 22:var fe=S.stateNode;S.memoizedState!==null?fe._visibility&2?Rr(m,S,N,B,u):Lo(m,S):(fe._visibility|=2,Rr(m,S,N,B,u)),u&&te&2048&&_f(S.alternate,S);break;case 24:Rr(m,S,N,B,u),u&&te&2048&&zf(S.alternate,S);break;default:Rr(m,S,N,B,u)}t=t.sibling}}function Lo(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,o=t,u=o.flags;switch(o.tag){case 22:Lo(s,o),u&2048&&_f(o.alternate,o);break;case 24:Lo(s,o),u&2048&&zf(o.alternate,o);break;default:Lo(s,o)}t=t.sibling}}var _o=8192;function Er(e,t,s){if(e.subtreeFlags&_o)for(e=e.child;e!==null;)mg(e,t,s),e=e.sibling}function mg(e,t,s){switch(e.tag){case 26:Er(e,t,s),e.flags&_o&&e.memoizedState!==null&&Tb(s,ps,e.memoizedState,e.memoizedProps);break;case 5:Er(e,t,s);break;case 3:case 4:var o=ps;ps=ku(e.stateNode.containerInfo),Er(e,t,s),ps=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=_o,_o=16777216,Er(e,t,s),_o=o):Er(e,t,s));break;default:Er(e,t,s)}}function hg(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 zo(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var o=t[s];bn=o,gg(o,e)}hg(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)pg(e),e=e.sibling}function pg(e){switch(e.tag){case 0:case 11:case 15:zo(e),e.flags&2048&&Vl(9,e,e.return);break;case 3:zo(e);break;case 12:zo(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,fu(e)):zo(e);break;default:zo(e)}}function fu(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var o=t[s];bn=o,gg(o,e)}hg(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Vl(8,t,t.return),fu(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,fu(t));break;default:fu(t)}e=e.sibling}}function gg(e,t){for(;bn!==null;){var s=bn;switch(s.tag){case 0:case 11:case 15:Vl(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var o=s.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:Di(s.memoizedState.cache)}if(o=s.child,o!==null)o.return=s,bn=o;else e:for(s=e;bn!==null;){o=bn;var u=o.sibling,m=o.return;if(ig(o),o===s){bn=null;break e}if(u!==null){u.return=m,bn=u;break e}bn=m}}}var qw={getCacheForType:function(e){var t=Gt(Zt),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return Gt(Zt).controller.signal}},Gw=typeof WeakMap=="function"?WeakMap:Map,gt=0,At=null,it=null,ot=0,xt=0,Na=null,Yl=!1,Dr=!1,Of=!1,pl=0,Yt=0,Wl=0,Oi=0,If=0,Ta=0,Lr=0,Oo=null,da=null,Bf=!1,mu=0,vg=0,hu=1/0,pu=null,Kl=null,mn=0,Ql=null,_r=null,gl=0,Ff=0,Hf=null,xg=null,Io=0,Uf=null;function Ra(){return(gt&2)!==0&&ot!==0?ot&-ot:_.T!==null?Yf():ta()}function yg(){if(Ta===0)if((ot&536870912)===0||lt){var e=Nt;Nt<<=1,(Nt&3932160)===0&&(Nt=262144),Ta=e}else Ta=536870912;return e=Ma.current,e!==null&&(e.flags|=32),Ta}function fa(e,t,s){(e===At&&(xt===2||xt===9)||e.cancelPendingCommit!==null)&&(zr(e,0),Xl(e,ot,Ta,!1)),hn(e,s),((gt&2)===0||e!==At)&&(e===At&&((gt&2)===0&&(Oi|=s),Yt===4&&Xl(e,ot,Ta,!1)),Us(e))}function wg(e,t,s){if((gt&6)!==0)throw Error(r(327));var o=!s&&(t&127)===0&&(t&e.expiredLanes)===0||Vs(e,t),u=o?Ww(e,t):Pf(e,t,!0),m=o;do{if(u===0){Dr&&!o&&Xl(e,t,0,!1);break}else{if(s=e.current.alternate,m&&!Vw(s)){u=Pf(e,t,!1),m=!1;continue}if(u===2){if(m=t,e.errorRecoveryDisabledLanes&m)var S=0;else S=e.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){t=S;e:{var N=e;u=Oo;var B=N.current.memoizedState.isDehydrated;if(B&&(zr(N,S).flags|=256),S=Pf(N,S,!1),S!==2){if(Of&&!B){N.errorRecoveryDisabledLanes|=m,Oi|=m,u=4;break e}m=da,da=u,m!==null&&(da===null?da=m:da.push.apply(da,m))}u=S}if(m=!1,u!==2)continue}}if(u===1){zr(e,0),Xl(e,t,0,!0);break}e:{switch(o=e,m=u,m){case 0:case 1:throw Error(r(345));case 4:if((t&4194048)!==t)break;case 6:Xl(o,t,Ta,!Yl);break e;case 2:da=null;break;case 3:case 5:break;default:throw Error(r(329))}if((t&62914560)===t&&(u=mu+300-Ie(),10<u)){if(Xl(o,t,Ta,!Yl),_a(o,0,!0)!==0)break e;gl=t,o.timeoutHandle=Xg(bg.bind(null,o,s,da,pu,Bf,t,Ta,Oi,Lr,Yl,m,"Throttled",-0,0),u);break e}bg(o,s,da,pu,Bf,t,Ta,Oi,Lr,Yl,m,null,-0,0)}}break}while(!0);Us(e)}function bg(e,t,s,o,u,m,S,N,B,te,fe,ye,se,re){if(e.timeoutHandle=-1,ye=t.subtreeFlags,ye&8192||(ye&16785408)===16785408){ye={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ls},mg(t,m,ye);var ze=(m&62914560)===m?mu-Ie():(m&4194048)===m?vg-Ie():0;if(ze=Rb(ye,ze),ze!==null){gl=m,e.cancelPendingCommit=ze(Tg.bind(null,e,t,m,s,o,u,S,N,B,fe,ye,null,se,re)),Xl(e,m,S,!te);return}}Tg(e,t,m,s,o,u,S,N,B)}function Vw(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var o=0;o<s.length;o++){var u=s[o],m=u.getSnapshot;u=u.value;try{if(!gn(m(),u))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;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 Xl(e,t,s,o){t&=~If,t&=~Oi,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var u=t;0<u;){var m=31-Wt(u),S=1<<m;o[m]=-1,u&=~S}s!==0&&Nn(e,s,t)}function gu(){return(gt&6)===0?(Bo(0),!1):!0}function $f(){if(it!==null){if(xt===0)var e=it.return;else e=it,ms=sl=null,af(e),q=null,O=0,e=it;for(;e!==null;)Zp(e.alternate,e),e=e.return;it=null}}function zr(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,fb(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),gl=0,$f(),At=e,it=s=ka(e.current,null),ot=t,xt=0,Na=null,Yl=!1,Dr=Vs(e,t),Of=!1,Lr=Ta=If=Oi=Wl=Yt=0,da=Oo=null,Bf=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var u=31-Wt(o),m=1<<u;t|=e[u],o&=~m}return pl=t,Bl(),s}function Sg(e,t){Je=null,_.H=No,t===Pl||t===hs?(t=T(),xt=3):t===bo?(t=T(),xt=4):xt=t===wf?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Na=t,it===null&&(Yt=1,lu(e,aa(t,e.current)))}function Cg(){var e=Ma.current;return e===null?!0:(ot&4194048)===ot?Za===null:(ot&62914560)===ot||(ot&536870912)!==0?e===Za:!1}function jg(){var e=_.H;return _.H=No,e===null?No:e}function kg(){var e=_.A;return _.A=qw,e}function vu(){Yt=4,Yl||(ot&4194048)!==ot&&Ma.current!==null||(Dr=!0),(Wl&134217727)===0&&(Oi&134217727)===0||At===null||Xl(At,ot,Ta,!1)}function Pf(e,t,s){var o=gt;gt|=2;var u=jg(),m=kg();(At!==e||ot!==t)&&(pu=null,zr(e,t)),t=!1;var S=Yt;e:do try{if(xt!==0&&it!==null){var N=it,B=Na;switch(xt){case 8:$f(),S=6;break e;case 3:case 2:case 9:case 6:Ma.current===null&&(t=!0);var te=xt;if(xt=0,Na=null,Or(e,N,B,te),s&&Dr){S=0;break e}break;default:te=xt,xt=0,Na=null,Or(e,N,B,te)}}Yw(),S=Yt;break}catch(fe){Sg(e,fe)}while(!0);return t&&e.shellSuspendCounter++,ms=sl=null,gt=o,_.H=u,_.A=m,it===null&&(At=null,ot=0,Bl()),S}function Yw(){for(;it!==null;)Mg(it)}function Ww(e,t){var s=gt;gt|=2;var o=jg(),u=kg();At!==e||ot!==t?(pu=null,hu=Ie()+500,zr(e,t)):Dr=Vs(e,t);e:do try{if(xt!==0&&it!==null){t=it;var m=Na;t:switch(xt){case 1:xt=0,Na=null,Or(e,t,m,1);break;case 2:case 9:if(kr(m)){xt=0,Na=null,Ag(t);break}t=function(){xt!==2&&xt!==9||At!==e||(xt=7),Us(e)},m.then(t,t);break e;case 3:xt=7;break e;case 4:xt=5;break e;case 7:kr(m)?(xt=0,Na=null,Ag(t)):(xt=0,Na=null,Or(e,t,m,7));break;case 5:var S=null;switch(it.tag){case 26:S=it.memoizedState;case 5:case 27:var N=it;if(S?fv(S):N.stateNode.complete){xt=0,Na=null;var B=N.sibling;if(B!==null)it=B;else{var te=N.return;te!==null?(it=te,xu(te)):it=null}break t}}xt=0,Na=null,Or(e,t,m,5);break;case 6:xt=0,Na=null,Or(e,t,m,6);break;case 8:$f(),Yt=6;break e;default:throw Error(r(462))}}Kw();break}catch(fe){Sg(e,fe)}while(!0);return ms=sl=null,_.H=o,_.A=u,gt=s,it!==null?0:(At=null,ot=0,Bl(),Yt)}function Kw(){for(;it!==null&&!Ae();)Mg(it)}function Mg(e){var t=Qp(e.alternate,e,pl);e.memoizedProps=e.pendingProps,t===null?xu(e):it=t}function Ag(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=qp(s,t,t.pendingProps,t.type,void 0,ot);break;case 11:t=qp(s,t,t.pendingProps,t.type.render,t.ref,ot);break;case 5:af(t);default:Zp(s,t),t=it=pr(t,pl),t=Qp(s,t,pl)}e.memoizedProps=e.pendingProps,t===null?xu(e):it=t}function Or(e,t,s,o){ms=sl=null,af(t),q=null,O=0;var u=t.return;try{if(Iw(e,u,t,s,ot)){Yt=1,lu(e,aa(s,e.current)),it=null;return}}catch(m){if(u!==null)throw it=u,m;Yt=1,lu(e,aa(s,e.current)),it=null;return}t.flags&32768?(lt||o===1?e=!0:Dr||(ot&536870912)!==0?e=!1:(Yl=e=!0,(o===2||o===9||o===3||o===6)&&(o=Ma.current,o!==null&&o.tag===13&&(o.flags|=16384))),Ng(t,e)):xu(t)}function xu(e){var t=e;do{if((t.flags&32768)!==0){Ng(t,Yl);return}e=t.return;var s=Hw(t.alternate,t,pl);if(s!==null){it=s;return}if(t=t.sibling,t!==null){it=t;return}it=t=e}while(t!==null);Yt===0&&(Yt=5)}function Ng(e,t){do{var s=Uw(e.alternate,e);if(s!==null){s.flags&=32767,it=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){it=e;return}it=e=s}while(e!==null);Yt=6,it=null}function Tg(e,t,s,o,u,m,S,N,B){e.cancelPendingCommit=null;do yu();while(mn!==0);if((gt&6)!==0)throw Error(r(327));if(t!==null){if(t===e.current)throw Error(r(177));if(m=t.lanes|t.childLanes,m|=uo,za(e,s,m,S,N,B),e===At&&(it=At=null,ot=0),_r=t,Ql=e,gl=s,Ff=m,Hf=u,xg=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Jw(bl,function(){return _g(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=_.T,_.T=null,u=Y.p,Y.p=2,S=gt,gt|=4;try{$w(e,t,s)}finally{gt=S,Y.p=u,_.T=o}}mn=1,Rg(),Eg(),Dg()}}function Rg(){if(mn===1){mn=0;var e=Ql,t=_r,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=_.T,_.T=null;var o=Y.p;Y.p=2;var u=gt;gt|=4;try{ug(t,e);var m=tm,S=ki(e.containerInfo),N=m.focusedElem,B=m.selectionRange;if(S!==N&&N&&N.ownerDocument&&cr(N.ownerDocument.documentElement,N)){if(B!==null&&_l(N)){var te=B.start,fe=B.end;if(fe===void 0&&(fe=te),"selectionStart"in N)N.selectionStart=te,N.selectionEnd=Math.min(fe,N.value.length);else{var ye=N.ownerDocument||document,se=ye&&ye.defaultView||window;if(se.getSelection){var re=se.getSelection(),ze=N.textContent.length,Ge=Math.min(B.start,ze),Ct=B.end===void 0?Ge:Math.min(B.end,ze);!re.extend&&Ge>Ct&&(S=Ct,Ct=Ge,Ge=S);var K=or(N,Ge),G=or(N,Ct);if(K&&G&&(re.rangeCount!==1||re.anchorNode!==K.node||re.anchorOffset!==K.offset||re.focusNode!==G.node||re.focusOffset!==G.offset)){var ee=ye.createRange();ee.setStart(K.node,K.offset),re.removeAllRanges(),Ge>Ct?(re.addRange(ee),re.extend(G.node,G.offset)):(ee.setEnd(G.node,G.offset),re.addRange(ee))}}}}for(ye=[],re=N;re=re.parentNode;)re.nodeType===1&&ye.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<ye.length;N++){var ve=ye[N];ve.element.scrollLeft=ve.left,ve.element.scrollTop=ve.top}}Eu=!!em,tm=em=null}finally{gt=u,Y.p=o,_.T=s}}e.current=t,mn=2}}function Eg(){if(mn===2){mn=0;var e=Ql,t=_r,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=_.T,_.T=null;var o=Y.p;Y.p=2;var u=gt;gt|=4;try{lg(e,t.alternate,t)}finally{gt=u,Y.p=o,_.T=s}}mn=3}}function Dg(){if(mn===4||mn===3){mn=0,Ne();var e=Ql,t=_r,s=gl,o=xg;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?mn=5:(mn=0,_r=Ql=null,Lg(e,e.pendingLanes));var u=e.pendingLanes;if(u===0&&(Kl=null),Oa(s),t=t.stateNode,wt&&typeof wt.onCommitFiberRoot=="function")try{wt.onCommitFiberRoot(Ye,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=_.T,u=Y.p,Y.p=2,_.T=null;try{for(var m=e.onRecoverableError,S=0;S<o.length;S++){var N=o[S];m(N.value,{componentStack:N.stack})}}finally{_.T=t,Y.p=u}}(gl&3)!==0&&yu(),Us(e),u=e.pendingLanes,(s&261930)!==0&&(u&42)!==0?e===Uf?Io++:(Io=0,Uf=e):Io=0,Bo(0)}}function Lg(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Di(t)))}function yu(){return Rg(),Eg(),Dg(),_g()}function _g(){if(mn!==5)return!1;var e=Ql,t=Ff;Ff=0;var s=Oa(gl),o=_.T,u=Y.p;try{Y.p=32>s?32:s,_.T=null,s=Hf,Hf=null;var m=Ql,S=gl;if(mn=0,_r=Ql=null,gl=0,(gt&6)!==0)throw Error(r(331));var N=gt;if(gt|=4,pg(m.current),fg(m,m.current,S,s),gt=N,Bo(0,!1),wt&&typeof wt.onPostCommitFiberRoot=="function")try{wt.onPostCommitFiberRoot(Ye,m)}catch{}return!0}finally{Y.p=u,_.T=o,Lg(e,t)}}function zg(e,t,s){t=aa(s,t),t=yf(e.stateNode,t,2),e=ra(e,t,2),e!==null&&(hn(e,2),Us(e))}function yt(e,t,s){if(e.tag===3)zg(e,e,s);else for(;t!==null;){if(t.tag===3){zg(t,e,s);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Kl===null||!Kl.has(o))){e=aa(s,e),s=Op(2),o=ra(t,s,2),o!==null&&(Ip(s,o,t,e),hn(o,2),Us(o));break}}t=t.return}}function qf(e,t,s){var o=e.pingCache;if(o===null){o=e.pingCache=new Gw;var u=new Set;o.set(t,u)}else u=o.get(t),u===void 0&&(u=new Set,o.set(t,u));u.has(s)||(Of=!0,u.add(s),e=Qw.bind(null,e,t,s),t.then(e,e))}function Qw(e,t,s){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,At===e&&(ot&s)===s&&(Yt===4||Yt===3&&(ot&62914560)===ot&&300>Ie()-mu?(gt&2)===0&&zr(e,0):If|=s,Lr===ot&&(Lr=0)),Us(e)}function Og(e,t){t===0&&(t=mi()),e=Ds(e,t),e!==null&&(hn(e,t),Us(e))}function Xw(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),Og(e,s)}function Zw(e,t){var s=0;switch(e.tag){case 31:case 13:var o=e.stateNode,u=e.memoizedState;u!==null&&(s=u.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(r(314))}o!==null&&o.delete(t),Og(e,s)}function Jw(e,t){return st(e,t)}var wu=null,Ir=null,Gf=!1,bu=!1,Vf=!1,Zl=0;function Us(e){e!==Ir&&e.next===null&&(Ir===null?wu=Ir=e:Ir=Ir.next=e),bu=!0,Gf||(Gf=!0,tb())}function Bo(e,t){if(!Vf&&bu){Vf=!0;do for(var s=!1,o=wu;o!==null;){if(e!==0){var u=o.pendingLanes;if(u===0)var m=0;else{var S=o.suspendedLanes,N=o.pingedLanes;m=(1<<31-Wt(42|e)+1)-1,m&=u&~(S&~N),m=m&201326741?m&201326741|1:m?m|2:0}m!==0&&(s=!0,Hg(o,m))}else m=ot,m=_a(o,o===At?m:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(m&3)===0||Vs(o,m)||(s=!0,Hg(o,m));o=o.next}while(s);Vf=!1}}function eb(){Ig()}function Ig(){bu=Gf=!1;var e=0;Zl!==0&&db()&&(e=Zl);for(var t=Ie(),s=null,o=wu;o!==null;){var u=o.next,m=Bg(o,t);m===0?(o.next=null,s===null?wu=u:s.next=u,u===null&&(Ir=s)):(s=o,(e!==0||(m&3)!==0)&&(bu=!0)),o=u}mn!==0&&mn!==5||Bo(e),Zl!==0&&(Zl=0)}function Bg(e,t){for(var s=e.suspendedLanes,o=e.pingedLanes,u=e.expirationTimes,m=e.pendingLanes&-62914561;0<m;){var S=31-Wt(m),N=1<<S,B=u[S];B===-1?((N&s)===0||(N&o)!==0)&&(u[S]=Zr(N,t)):B<=t&&(e.expiredLanes|=N),m&=~N}if(t=At,s=ot,s=_a(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,s===0||e===t&&(xt===2||xt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&It(o),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||Vs(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(o!==null&&It(o),Oa(s)){case 2:case 8:s=Dt;break;case 32:s=bl;break;case 268435456:s=ws;break;default:s=bl}return o=Fg.bind(null,e),s=st(s,o),e.callbackPriority=t,e.callbackNode=s,t}return o!==null&&o!==null&&It(o),e.callbackPriority=2,e.callbackNode=null,2}function Fg(e,t){if(mn!==0&&mn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(yu()&&e.callbackNode!==s)return null;var o=ot;return o=_a(e,e===At?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(wg(e,o,t),Bg(e,Ie()),e.callbackNode!=null&&e.callbackNode===s?Fg.bind(null,e):null)}function Hg(e,t){if(yu())return null;wg(e,t,!0)}function tb(){mb(function(){(gt&6)!==0?st(An,eb):Ig()})}function Yf(){if(Zl===0){var e=Qa;e===0&&(e=La,La<<=1,(La&261888)===0&&(La=256)),Zl=e}return Zl}function Ug(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ji(""+e)}function $g(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function nb(e,t,s,o,u){if(t==="submit"&&s&&s.stateNode===u){var m=Ug((u[Se]||null).action),S=o.submitter;S&&(t=(t=S[Se]||null)?Ug(t.formAction):S.getAttribute("formAction"),t!==null&&(m=t,S=null));var N=new kl("action","action",null,o,u);e.push({event:N,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Zl!==0){var B=S?$g(u,S):new FormData(u);mf(s,{pending:!0,data:B,method:u.method,action:m},null,B)}}else typeof m=="function"&&(N.preventDefault(),B=S?$g(u,S):new FormData(u),mf(s,{pending:!0,data:B,method:u.method,action:m},m,B))},currentTarget:u}]})}}for(var Wf=0;Wf<dr.length;Wf++){var Kf=dr[Wf],ab=Kf.toLowerCase(),sb=Kf[0].toUpperCase()+Kf.slice(1);En(ab,"on"+sb)}En(co,"onAnimationEnd"),En(ur,"onAnimationIteration"),En(Ai,"onAnimationStart"),En("dblclick","onDoubleClick"),En("focusin","onFocus"),En("focusout","onBlur"),En(qd,"onTransitionRun"),En(Il,"onTransitionStart"),En(Gd,"onTransitionCancel"),En(Fc,"onTransitionEnd"),qt("onMouseEnter",["mouseout","mouseover"]),qt("onMouseLeave",["mouseout","mouseover"]),qt("onPointerEnter",["pointerout","pointerover"]),qt("onPointerLeave",["pointerout","pointerover"]),Bt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Bt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Bt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Bt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Bt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Bt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Fo="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(" "),lb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Fo));function Pg(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var o=e[s],u=o.event;o=o.listeners;e:{var m=void 0;if(t)for(var S=o.length-1;0<=S;S--){var N=o[S],B=N.instance,te=N.currentTarget;if(N=N.listener,B!==m&&u.isPropagationStopped())break e;m=N,u.currentTarget=te;try{m(u)}catch(fe){Ti(fe)}u.currentTarget=null,m=B}else for(S=0;S<o.length;S++){if(N=o[S],B=N.instance,te=N.currentTarget,N=N.listener,B!==m&&u.isPropagationStopped())break e;m=N,u.currentTarget=te;try{m(u)}catch(fe){Ti(fe)}u.currentTarget=null,m=B}}}}function rt(e,t){var s=t[We];s===void 0&&(s=t[We]=new Set);var o=e+"__bubble";s.has(o)||(qg(t,e,2,!1),s.add(o))}function Qf(e,t,s){var o=0;t&&(o|=4),qg(s,e,o,t)}var Su="_reactListening"+Math.random().toString(36).slice(2);function Xf(e){if(!e[Su]){e[Su]=!0,Ia.forEach(function(s){s!=="selectionchange"&&(lb.has(s)||Qf(s,!1,e),Qf(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Su]||(t[Su]=!0,Qf("selectionchange",!1,t))}}function qg(e,t,s,o){switch(yv(t)){case 2:var u=Lb;break;case 8:u=_b;break;default:u=fm}s=u.bind(null,t,s,e),u=void 0,!nr||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(u=!0),o?u!==void 0?e.addEventListener(t,s,{capture:!0,passive:u}):e.addEventListener(t,s,!0):u!==void 0?e.addEventListener(t,s,{passive:u}):e.addEventListener(t,s,!1)}function Zf(e,t,s,o,u){var m=o;if((t&1)===0&&(t&2)===0&&o!==null)e:for(;;){if(o===null)return;var S=o.tag;if(S===3||S===4){var N=o.stateNode.containerInfo;if(N===u)break;if(S===4)for(S=o.return;S!==null;){var B=S.tag;if((B===3||B===4)&&S.stateNode.containerInfo===u)return;S=S.return}for(;N!==null;){if(S=Kt(N),S===null)return;if(B=S.tag,B===5||B===6||B===26||B===27){o=m=S;continue e}N=N.parentNode}}o=o.return}eo(function(){var te=m,fe=er(s),ye=[];e:{var se=Ni.get(e);if(se!==void 0){var re=kl,ze=e;switch(e){case"keypress":if(Ke(s)===0)break e;case"keydown":case"keyup":re=Dc;break;case"focusin":ze="focus",re=no;break;case"focusout":ze="blur",re=no;break;case"beforeblur":case"afterblur":re=no;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=to;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=Pa;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=dn;break;case co:case ur:case Ai:re=Et;break;case Fc:re=Lc;break;case"scroll":case"scrollend":re=ja;break;case"wheel":re=Fd;break;case"copy":case"cut":case"paste":re=ar;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=As;break;case"toggle":case"beforetoggle":re=Zs}var Ge=(t&4)!==0,Ct=!Ge&&(e==="scroll"||e==="scrollend"),K=Ge?se!==null?se+"Capture":null:se;Ge=[];for(var G=te,ee;G!==null;){var ve=G;if(ee=ve.stateNode,ve=ve.tag,ve!==5&&ve!==26&&ve!==27||ee===null||K===null||(ve=is(G,K),ve!=null&&Ge.push(Ho(G,ve,ee))),Ct)break;G=G.return}0<Ge.length&&(se=new re(se,ze,null,s,fe),ye.push({event:se,listeners:Ge}))}}if((t&7)===0){e:{if(se=e==="mouseover"||e==="pointerover",re=e==="mouseout"||e==="pointerout",se&&s!==pi&&(ze=s.relatedTarget||s.fromElement)&&(Kt(ze)||ze[_e]))break e;if((re||se)&&(se=fe.window===fe?fe:(se=fe.ownerDocument)?se.defaultView||se.parentWindow:window,re?(ze=s.relatedTarget||s.toElement,re=te,ze=ze?Kt(ze):null,ze!==null&&(Ct=d(ze),Ge=ze.tag,ze!==Ct||Ge!==5&&Ge!==27&&Ge!==6)&&(ze=null)):(re=null,ze=te),re!==ze)){if(Ge=to,ve="onMouseLeave",K="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Ge=As,ve="onPointerLeave",K="onPointerEnter",G="pointer"),Ct=re==null?se:kt(re),ee=ze==null?se:kt(ze),se=new Ge(ve,G+"leave",re,s,fe),se.target=Ct,se.relatedTarget=ee,ve=null,Kt(fe)===te&&(Ge=new Ge(K,G+"enter",ze,s,fe),Ge.target=ee,Ge.relatedTarget=Ct,ve=Ge),Ct=ve,re&&ze)t:{for(Ge=ib,K=re,G=ze,ee=0,ve=K;ve;ve=Ge(ve))ee++;ve=0;for(var Ue=G;Ue;Ue=Ge(Ue))ve++;for(;0<ee-ve;)K=Ge(K),ee--;for(;0<ve-ee;)G=Ge(G),ve--;for(;ee--;){if(K===G||G!==null&&K===G.alternate){Ge=K;break t}K=Ge(K),G=Ge(G)}Ge=null}else Ge=null;re!==null&&Gg(ye,se,re,Ge,!1),ze!==null&&Ct!==null&&Gg(ye,Ct,ze,Ge,!0)}}e:{if(se=te?kt(te):window,re=se.nodeName&&se.nodeName.toLowerCase(),re==="select"||re==="input"&&se.type==="file")var ht=Rl;else if(Oc(se))if(cs)ht=Dl;else{ht=lo;var Fe=Bc}else re=se.nodeName,!re||re.toLowerCase()!=="input"||se.type!=="checkbox"&&se.type!=="radio"?te&&Zi(te.elementType)&&(ht=Rl):ht=io;if(ht&&(ht=ht(e,te))){so(ye,ht,s,fe);break e}Fe&&Fe(e,se,te),e==="focusout"&&te&&se.type==="number"&&te.memoizedProps.value!=null&&js(se,"number",se.value)}switch(Fe=te?kt(te):window,e){case"focusin":(Oc(Fe)||Fe.contentEditable==="true")&&(tl=Fe,Rs=te,Ga=null);break;case"focusout":Ga=Rs=tl=null;break;case"mousedown":zl=!0;break;case"contextmenu":case"mouseup":case"dragend":zl=!1,Ol(ye,s,fe);break;case"selectionchange":if(ro)break;case"keydown":case"keyup":Ol(ye,s,fe)}var nt;if(Nl)e:{switch(e){case"compositionstart":var ct="onCompositionStart";break e;case"compositionend":ct="onCompositionEnd";break e;case"compositionupdate":ct="onCompositionUpdate";break e}ct=void 0}else el?ao(e,s)&&(ct="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(ct="onCompositionStart");ct&&(_c&&s.locale!=="ko"&&(el||ct!=="onCompositionStart"?ct==="onCompositionEnd"&&el&&(nt=rs()):(Qe=fe,Yn="value"in Qe?Qe.value:Qe.textContent,el=!0)),Fe=Cu(te,ct),0<Fe.length&&(ct=new Ec(ct,e,null,s,fe),ye.push({event:ct,listeners:Fe}),nt?ct.data=nt:(nt=Js(s),nt!==null&&(ct.data=nt)))),(nt=Hd?zc(e,s):Ud(e,s))&&(ct=Cu(te,"onBeforeInput"),0<ct.length&&(Fe=new Ec("onBeforeInput","beforeinput",null,s,fe),ye.push({event:Fe,listeners:ct}),Fe.data=nt)),nb(ye,e,te,s,fe)}Pg(ye,t)})}function Ho(e,t,s){return{instance:e,listener:t,currentTarget:s}}function Cu(e,t){for(var s=t+"Capture",o=[];e!==null;){var u=e,m=u.stateNode;if(u=u.tag,u!==5&&u!==26&&u!==27||m===null||(u=is(e,s),u!=null&&o.unshift(Ho(e,u,m)),u=is(e,t),u!=null&&o.push(Ho(e,u,m))),e.tag===3)return o;e=e.return}return[]}function ib(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Gg(e,t,s,o,u){for(var m=t._reactName,S=[];s!==null&&s!==o;){var N=s,B=N.alternate,te=N.stateNode;if(N=N.tag,B!==null&&B===o)break;N!==5&&N!==26&&N!==27||te===null||(B=te,u?(te=is(s,m),te!=null&&S.unshift(Ho(s,te,B))):u||(te=is(s,m),te!=null&&S.push(Ho(s,te,B)))),s=s.return}S.length!==0&&e.push({event:t,listeners:S})}var rb=/\r\n?/g,ob=/\u0000|\uFFFD/g;function Vg(e){return(typeof e=="string"?e:""+e).replace(rb,`
9
+ `).replace(ob,"")}function Yg(e,t){return t=Vg(t),Vg(e)===t}function St(e,t,s,o,u,m){switch(s){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||hi(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&hi(e,""+o);break;case"className":Ks(e,"class",o);break;case"tabIndex":Ks(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Ks(e,s,o);break;case"style":Ac(e,o,m);break;case"data":if(t!=="object"){Ks(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(s);break}o=Ji(""+o),e.setAttribute(s,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(s,"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 m=="function"&&(s==="formAction"?(t!=="input"&&St(e,t,"name",u.name,u,null),St(e,t,"formEncType",u.formEncType,u,null),St(e,t,"formMethod",u.formMethod,u,null),St(e,t,"formTarget",u.formTarget,u,null)):(St(e,t,"encType",u.encType,u,null),St(e,t,"method",u.method,u,null),St(e,t,"target",u.target,u,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(s);break}o=Ji(""+o),e.setAttribute(s,o);break;case"onClick":o!=null&&(e.onclick=ls);break;case"onScroll":o!=null&&rt("scroll",e);break;case"onScrollEnd":o!=null&&rt("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(r(61));if(s=o.__html,s!=null){if(u.children!=null)throw Error(r(60));e.innerHTML=s}}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}s=Ji(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);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(s,""+o):e.removeAttribute(s);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(s,""):e.removeAttribute(s);break;case"capture":case"download":o===!0?e.setAttribute(s,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,o):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(s,o):e.removeAttribute(s);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(s):e.setAttribute(s,o);break;case"popover":rt("beforetoggle",e),rt("toggle",e),Ss(e,"popover",o);break;case"xlinkActuate":na(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":na(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":na(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":na(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":na(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":na(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":na(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":na(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":na(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Ss(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=Nc.get(s)||s,Ss(e,s,o))}}function Jf(e,t,s,o,u,m){switch(s){case"style":Ac(e,o,m);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(r(61));if(s=o.__html,s!=null){if(u.children!=null)throw Error(r(60));e.innerHTML=s}}break;case"children":typeof o=="string"?hi(e,o):(typeof o=="number"||typeof o=="bigint")&&hi(e,""+o);break;case"onScroll":o!=null&&rt("scroll",e);break;case"onScrollEnd":o!=null&&rt("scrollend",e);break;case"onClick":o!=null&&(e.onclick=ls);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!wa.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(u=s.endsWith("Capture"),t=s.slice(2,u?s.length-7:void 0),m=e[Se]||null,m=m!=null?m[s]:null,typeof m=="function"&&e.removeEventListener(t,m,u),typeof o=="function")){typeof m!="function"&&m!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,o,u);break e}s in e?e[s]=o:o===!0?e.setAttribute(s,""):Ss(e,s,o)}}}function Ln(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":rt("error",e),rt("load",e);var o=!1,u=!1,m;for(m in s)if(s.hasOwnProperty(m)){var S=s[m];if(S!=null)switch(m){case"src":o=!0;break;case"srcSet":u=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:St(e,t,m,S,s,null)}}u&&St(e,t,"srcSet",s.srcSet,s,null),o&&St(e,t,"src",s.src,s,null);return;case"input":rt("invalid",e);var N=m=S=u=null,B=null,te=null;for(o in s)if(s.hasOwnProperty(o)){var fe=s[o];if(fe!=null)switch(o){case"name":u=fe;break;case"type":S=fe;break;case"checked":B=fe;break;case"defaultChecked":te=fe;break;case"value":m=fe;break;case"defaultValue":N=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(r(137,t));break;default:St(e,t,o,fe,s,null)}}Mc(e,m,N,B,te,S,u,!1);return;case"select":rt("invalid",e),o=S=m=null;for(u in s)if(s.hasOwnProperty(u)&&(N=s[u],N!=null))switch(u){case"value":m=N;break;case"defaultValue":S=N;break;case"multiple":o=N;default:St(e,t,u,N,s,null)}t=m,s=S,e.multiple=!!o,t!=null?Cl(e,!!o,t,!1):s!=null&&Cl(e,!!o,s,!0);return;case"textarea":rt("invalid",e),m=u=o=null;for(S in s)if(s.hasOwnProperty(S)&&(N=s[S],N!=null))switch(S){case"value":o=N;break;case"defaultValue":u=N;break;case"children":m=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(r(91));break;default:St(e,t,S,N,s,null)}Xi(e,o,u,m);return;case"option":for(B in s)s.hasOwnProperty(B)&&(o=s[B],o!=null)&&(B==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":St(e,t,B,o,s,null));return;case"dialog":rt("beforetoggle",e),rt("toggle",e),rt("cancel",e),rt("close",e);break;case"iframe":case"object":rt("load",e);break;case"video":case"audio":for(o=0;o<Fo.length;o++)rt(Fo[o],e);break;case"image":rt("error",e),rt("load",e);break;case"details":rt("toggle",e);break;case"embed":case"source":case"link":rt("error",e),rt("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(te in s)if(s.hasOwnProperty(te)&&(o=s[te],o!=null))switch(te){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:St(e,t,te,o,s,null)}return;default:if(Zi(t)){for(fe in s)s.hasOwnProperty(fe)&&(o=s[fe],o!==void 0&&Jf(e,t,fe,o,s,void 0));return}}for(N in s)s.hasOwnProperty(N)&&(o=s[N],o!=null&&St(e,t,N,o,s,null))}function cb(e,t,s,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var u=null,m=null,S=null,N=null,B=null,te=null,fe=null;for(re in s){var ye=s[re];if(s.hasOwnProperty(re)&&ye!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":B=ye;default:o.hasOwnProperty(re)||St(e,t,re,null,o,ye)}}for(var se in o){var re=o[se];if(ye=s[se],o.hasOwnProperty(se)&&(re!=null||ye!=null))switch(se){case"type":m=re;break;case"name":u=re;break;case"checked":te=re;break;case"defaultChecked":fe=re;break;case"value":S=re;break;case"defaultValue":N=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,t));break;default:re!==ye&&St(e,t,se,re,o,ye)}}kc(e,S,N,B,te,fe,m,u);return;case"select":re=S=N=se=null;for(m in s)if(B=s[m],s.hasOwnProperty(m)&&B!=null)switch(m){case"value":break;case"multiple":re=B;default:o.hasOwnProperty(m)||St(e,t,m,null,o,B)}for(u in o)if(m=o[u],B=s[u],o.hasOwnProperty(u)&&(m!=null||B!=null))switch(u){case"value":se=m;break;case"defaultValue":N=m;break;case"multiple":S=m;default:m!==B&&St(e,t,u,m,o,B)}t=N,s=S,o=re,se!=null?Cl(e,!!s,se,!1):!!o!=!!s&&(t!=null?Cl(e,!!s,t,!0):Cl(e,!!s,s?[]:"",!1));return;case"textarea":re=se=null;for(N in s)if(u=s[N],s.hasOwnProperty(N)&&u!=null&&!o.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:St(e,t,N,null,o,u)}for(S in o)if(u=o[S],m=s[S],o.hasOwnProperty(S)&&(u!=null||m!=null))switch(S){case"value":se=u;break;case"defaultValue":re=u;break;case"children":break;case"dangerouslySetInnerHTML":if(u!=null)throw Error(r(91));break;default:u!==m&&St(e,t,S,u,o,m)}Qs(e,se,re);return;case"option":for(var ze in s)se=s[ze],s.hasOwnProperty(ze)&&se!=null&&!o.hasOwnProperty(ze)&&(ze==="selected"?e.selected=!1:St(e,t,ze,null,o,se));for(B in o)se=o[B],re=s[B],o.hasOwnProperty(B)&&se!==re&&(se!=null||re!=null)&&(B==="selected"?e.selected=se&&typeof se!="function"&&typeof se!="symbol":St(e,t,B,se,o,re));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 Ge in s)se=s[Ge],s.hasOwnProperty(Ge)&&se!=null&&!o.hasOwnProperty(Ge)&&St(e,t,Ge,null,o,se);for(te in o)if(se=o[te],re=s[te],o.hasOwnProperty(te)&&se!==re&&(se!=null||re!=null))switch(te){case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(r(137,t));break;default:St(e,t,te,se,o,re)}return;default:if(Zi(t)){for(var Ct in s)se=s[Ct],s.hasOwnProperty(Ct)&&se!==void 0&&!o.hasOwnProperty(Ct)&&Jf(e,t,Ct,void 0,o,se);for(fe in o)se=o[fe],re=s[fe],!o.hasOwnProperty(fe)||se===re||se===void 0&&re===void 0||Jf(e,t,fe,se,o,re);return}}for(var K in s)se=s[K],s.hasOwnProperty(K)&&se!=null&&!o.hasOwnProperty(K)&&St(e,t,K,null,o,se);for(ye in o)se=o[ye],re=s[ye],!o.hasOwnProperty(ye)||se===re||se==null&&re==null||St(e,t,ye,se,o,re)}function Wg(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function ub(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),o=0;o<s.length;o++){var u=s[o],m=u.transferSize,S=u.initiatorType,N=u.duration;if(m&&N&&Wg(S)){for(S=0,N=u.responseEnd,o+=1;o<s.length;o++){var B=s[o],te=B.startTime;if(te>N)break;var fe=B.transferSize,ye=B.initiatorType;fe&&Wg(ye)&&(B=B.responseEnd,S+=fe*(B<N?1:(N-te)/(B-te)))}if(--o,t+=8*(m+S)/(u.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 em=null,tm=null;function ju(e){return e.nodeType===9?e:e.ownerDocument}function Kg(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 Qg(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 am=null;function db(){var e=window.event;return e&&e.type==="popstate"?e===am?!1:(am=e,!0):(am=null,!1)}var Xg=typeof setTimeout=="function"?setTimeout:void 0,fb=typeof clearTimeout=="function"?clearTimeout:void 0,Zg=typeof Promise=="function"?Promise:void 0,mb=typeof queueMicrotask=="function"?queueMicrotask:typeof Zg<"u"?function(e){return Zg.resolve(null).then(e).catch(hb)}:Xg;function hb(e){setTimeout(function(){throw e})}function Jl(e){return e==="head"}function Jg(e,t){var s=t,o=0;do{var u=s.nextSibling;if(e.removeChild(s),u&&u.nodeType===8)if(s=u.data,s==="/$"||s==="/&"){if(o===0){e.removeChild(u),Ur(t);return}o--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")o++;else if(s==="html")Uo(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,Uo(s);for(var m=s.firstChild;m;){var S=m.nextSibling,N=m.nodeName;m[dt]||N==="SCRIPT"||N==="STYLE"||N==="LINK"&&m.rel.toLowerCase()==="stylesheet"||s.removeChild(m),m=S}}else s==="body"&&Uo(e.ownerDocument.body);s=u}while(s);Ur(t)}function ev(e,t){var s=e;e=0;do{var o=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),o&&o.nodeType===8)if(s=o.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=o}while(s)}function sm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":sm(s),pn(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function pb(e,t,s,o){for(;e.nodeType===1;){var u=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[dt])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(m=e.getAttribute("rel"),m==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(m!==u.rel||e.getAttribute("href")!==(u.href==null||u.href===""?null:u.href)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin)||e.getAttribute("title")!==(u.title==null?null:u.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(m=e.getAttribute("src"),(m!==(u.src==null?null:u.src)||e.getAttribute("type")!==(u.type==null?null:u.type)||e.getAttribute("crossorigin")!==(u.crossOrigin==null?null:u.crossOrigin))&&m&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var m=u.name==null?null:""+u.name;if(u.type==="hidden"&&e.getAttribute("name")===m)return e}else return e;if(e=Ja(e.nextSibling),e===null)break}return null}function gb(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=Ja(e.nextSibling),e===null))return null;return e}function tv(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Ja(e.nextSibling),e===null))return null;return e}function lm(e){return e.data==="$?"||e.data==="$~"}function im(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function vb(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var o=function(){t(),s.removeEventListener("DOMContentLoaded",o)};s.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Ja(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 rm=null;function nv(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return Ja(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function av(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function sv(e,t,s){switch(t=ju(s),e){case"html":if(e=t.documentElement,!e)throw Error(r(452));return e;case"head":if(e=t.head,!e)throw Error(r(453));return e;case"body":if(e=t.body,!e)throw Error(r(454));return e;default:throw Error(r(451))}}function Uo(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);pn(e)}var es=new Map,lv=new Set;function ku(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var vl=Y.d;Y.d={f:xb,r:yb,D:wb,C:bb,L:Sb,m:Cb,X:kb,S:jb,M:Mb};function xb(){var e=vl.f(),t=gu();return e||t}function yb(e){var t=Rt(e);t!==null&&t.tag===5&&t.type==="form"?Sp(t):vl.r(e)}var Br=typeof document>"u"?null:document;function iv(e,t,s){var o=Br;if(o&&typeof t=="string"&&t){var u=On(t);u='link[rel="'+e+'"][href="'+u+'"]',typeof s=="string"&&(u+='[crossorigin="'+s+'"]'),lv.has(u)||(lv.add(u),e={rel:e,crossOrigin:s,href:t},o.querySelector(u)===null&&(t=o.createElement("link"),Ln(t,"link",e),mt(t),o.head.appendChild(t)))}}function wb(e){vl.D(e),iv("dns-prefetch",e,null)}function bb(e,t){vl.C(e,t),iv("preconnect",e,t)}function Sb(e,t,s){vl.L(e,t,s);var o=Br;if(o&&e&&t){var u='link[rel="preload"][as="'+On(t)+'"]';t==="image"&&s&&s.imageSrcSet?(u+='[imagesrcset="'+On(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(u+='[imagesizes="'+On(s.imageSizes)+'"]')):u+='[href="'+On(e)+'"]';var m=u;switch(t){case"style":m=Fr(e);break;case"script":m=Hr(e)}es.has(m)||(e=y({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),es.set(m,e),o.querySelector(u)!==null||t==="style"&&o.querySelector($o(m))||t==="script"&&o.querySelector(Po(m))||(t=o.createElement("link"),Ln(t,"link",e),mt(t),o.head.appendChild(t)))}}function Cb(e,t){vl.m(e,t);var s=Br;if(s&&e){var o=t&&typeof t.as=="string"?t.as:"script",u='link[rel="modulepreload"][as="'+On(o)+'"][href="'+On(e)+'"]',m=u;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":m=Hr(e)}if(!es.has(m)&&(e=y({rel:"modulepreload",href:e},t),es.set(m,e),s.querySelector(u)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(Po(m)))return}o=s.createElement("link"),Ln(o,"link",e),mt(o),s.head.appendChild(o)}}}function jb(e,t,s){vl.S(e,t,s);var o=Br;if(o&&e){var u=vt(o).hoistableStyles,m=Fr(e);t=t||"default";var S=u.get(m);if(!S){var N={loading:0,preload:null};if(S=o.querySelector($o(m)))N.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},s),(s=es.get(m))&&om(e,s);var B=S=o.createElement("link");mt(B),Ln(B,"link",e),B._p=new Promise(function(te,fe){B.onload=te,B.onerror=fe}),B.addEventListener("load",function(){N.loading|=1}),B.addEventListener("error",function(){N.loading|=2}),N.loading|=4,Mu(S,t,o)}S={type:"stylesheet",instance:S,count:1,state:N},u.set(m,S)}}}function kb(e,t){vl.X(e,t);var s=Br;if(s&&e){var o=vt(s).hoistableScripts,u=Hr(e),m=o.get(u);m||(m=s.querySelector(Po(u)),m||(e=y({src:e,async:!0},t),(t=es.get(u))&&cm(e,t),m=s.createElement("script"),mt(m),Ln(m,"link",e),s.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},o.set(u,m))}}function Mb(e,t){vl.M(e,t);var s=Br;if(s&&e){var o=vt(s).hoistableScripts,u=Hr(e),m=o.get(u);m||(m=s.querySelector(Po(u)),m||(e=y({src:e,async:!0,type:"module"},t),(t=es.get(u))&&cm(e,t),m=s.createElement("script"),mt(m),Ln(m,"link",e),s.head.appendChild(m)),m={type:"script",instance:m,count:1,state:null},o.set(u,m))}}function rv(e,t,s,o){var u=(u=je.current)?ku(u):null;if(!u)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=Fr(s.href),s=vt(u).hoistableStyles,o=s.get(t),o||(o={type:"style",instance:null,count:0,state:null},s.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=Fr(s.href);var m=vt(u).hoistableStyles,S=m.get(e);if(S||(u=u.ownerDocument||u,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},m.set(e,S),(m=u.querySelector($o(e)))&&!m._p&&(S.instance=m,S.state.loading=5),es.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},es.set(e,s),m||Ab(u,e,s,S.state))),t&&o===null)throw Error(r(528,""));return S}if(t&&o!==null)throw Error(r(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Hr(s),s=vt(u).hoistableScripts,o=s.get(t),o||(o={type:"script",instance:null,count:0,state:null},s.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Fr(e){return'href="'+On(e)+'"'}function $o(e){return'link[rel="stylesheet"]['+e+"]"}function ov(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function Ab(e,t,s,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}),Ln(t,"link",s),mt(t),e.head.appendChild(t))}function Hr(e){return'[src="'+On(e)+'"]'}function Po(e){return"script[async]"+e}function cv(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+On(s.href)+'"]');if(o)return t.instance=o,mt(o),o;var u=y({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),mt(o),Ln(o,"style",u),Mu(o,s.precedence,e),t.instance=o;case"stylesheet":u=Fr(s.href);var m=e.querySelector($o(u));if(m)return t.state.loading|=4,t.instance=m,mt(m),m;o=ov(s),(u=es.get(u))&&om(o,u),m=(e.ownerDocument||e).createElement("link"),mt(m);var S=m;return S._p=new Promise(function(N,B){S.onload=N,S.onerror=B}),Ln(m,"link",o),t.state.loading|=4,Mu(m,s.precedence,e),t.instance=m;case"script":return m=Hr(s.src),(u=e.querySelector(Po(m)))?(t.instance=u,mt(u),u):(o=s,(u=es.get(m))&&(o=y({},s),cm(o,u)),e=e.ownerDocument||e,u=e.createElement("script"),mt(u),Ln(u,"link",o),e.head.appendChild(u),t.instance=u);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,Mu(o,s.precedence,e));return t.instance}function Mu(e,t,s){for(var o=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),u=o.length?o[o.length-1]:null,m=u,S=0;S<o.length;S++){var N=o[S];if(N.dataset.precedence===t)m=N;else if(m!==u)break}m?m.parentNode.insertBefore(e,m.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function om(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function cm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Au=null;function uv(e,t,s){if(Au===null){var o=new Map,u=Au=new Map;u.set(s,o)}else u=Au,o=u.get(s),o||(o=new Map,u.set(s,o));if(o.has(e))return o;for(o.set(e,null),s=s.getElementsByTagName(e),u=0;u<s.length;u++){var m=s[u];if(!(m[dt]||m[X]||e==="link"&&m.getAttribute("rel")==="stylesheet")&&m.namespaceURI!=="http://www.w3.org/2000/svg"){var S=m.getAttribute(t)||"";S=e+S;var N=o.get(S);N?N.push(m):o.set(S,[m])}}return o}function dv(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function Nb(e,t,s){if(s===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 fv(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Tb(e,t,s,o){if(s.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var u=Fr(o.href),m=t.querySelector($o(u));if(m){t=m._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Nu.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=m,mt(m);return}m=t.ownerDocument||t,o=ov(o),(u=es.get(u))&&om(o,u),m=m.createElement("link"),mt(m);var S=m;S._p=new Promise(function(N,B){S.onload=N,S.onerror=B}),Ln(m,"link",o),s.instance=m}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=Nu.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var um=0;function Rb(e,t){return e.stylesheets&&e.count===0&&Ru(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var o=setTimeout(function(){if(e.stylesheets&&Ru(e,e.stylesheets),e.unsuspend){var m=e.unsuspend;e.unsuspend=null,m()}},6e4+t);0<e.imgBytes&&um===0&&(um=62500*ub());var u=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Ru(e,e.stylesheets),e.unsuspend)){var m=e.unsuspend;e.unsuspend=null,m()}},(e.imgBytes>um?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(u)}}:null}function Nu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ru(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Tu=null;function Ru(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Tu=new Map,t.forEach(Eb,e),Tu=null,Nu.call(e))}function Eb(e,t){if(!(t.state.loading&4)){var s=Tu.get(e);if(s)var o=s.get(null);else{s=new Map,Tu.set(e,s);for(var u=e.querySelectorAll("link[data-precedence],style[data-precedence]"),m=0;m<u.length;m++){var S=u[m];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),o=S)}o&&s.set(null,o)}u=t.instance,S=u.getAttribute("data-precedence"),m=s.get(S)||o,m===o&&s.set(null,u),s.set(S,u),this.count++,o=Nu.bind(this),u.addEventListener("load",o),u.addEventListener("error",o),m?m.parentNode.insertBefore(u,m.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(u,e.firstChild)),t.state.loading|=4}}var qo={$$typeof:E,Provider:null,Consumer:null,_currentValue:$,_currentValue2:$,_threadCount:0};function Db(e,t,s,o,u,m,S,N,B){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=Ys(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ys(0),this.hiddenUpdates=Ys(null),this.identifierPrefix=o,this.onUncaughtError=u,this.onCaughtError=m,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=B,this.incompleteTransitions=new Map}function mv(e,t,s,o,u,m,S,N,B,te,fe,ye){return e=new Db(e,t,s,S,B,te,fe,ye,N),t=1,m===!0&&(t|=24),m=xn(3,null,null,t),e.current=m,m.stateNode=e,t=yo(),t.refCount++,e.pooledCache=t,t.refCount++,m.memoizedState={element:o,isDehydrated:s,cache:t},Qn(m),e}function hv(e){return e?(e=us,e):us}function pv(e,t,s,o,u,m){u=hv(u),o.context===null?o.context=u:o.pendingContext=u,o=Fn(t),o.payload={element:s},m=m===void 0?null:m,m!==null&&(o.callback=m),s=ra(e,o,t),s!==null&&(fa(s,e,t),Fs(s,e,t))}function gv(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function dm(e,t){gv(e,t),(e=e.alternate)&&gv(e,t)}function vv(e){if(e.tag===13||e.tag===31){var t=Ds(e,67108864);t!==null&&fa(t,e,67108864),dm(e,67108864)}}function xv(e){if(e.tag===13||e.tag===31){var t=Ra();t=ss(t);var s=Ds(e,t);s!==null&&fa(s,e,t),dm(e,t)}}var Eu=!0;function Lb(e,t,s,o){var u=_.T;_.T=null;var m=Y.p;try{Y.p=2,fm(e,t,s,o)}finally{Y.p=m,_.T=u}}function _b(e,t,s,o){var u=_.T;_.T=null;var m=Y.p;try{Y.p=8,fm(e,t,s,o)}finally{Y.p=m,_.T=u}}function fm(e,t,s,o){if(Eu){var u=mm(o);if(u===null)Zf(e,t,o,Du,s),wv(e,o);else if(Ob(u,e,t,s,o))o.stopPropagation();else if(wv(e,o),t&4&&-1<zb.indexOf(e)){for(;u!==null;){var m=Rt(u);if(m!==null)switch(m.tag){case 3:if(m=m.stateNode,m.current.memoizedState.isDehydrated){var S=ea(m.pendingLanes);if(S!==0){var N=m;for(N.pendingLanes|=2,N.entangledLanes|=2;S;){var B=1<<31-Wt(S);N.entanglements[1]|=B,S&=~B}Us(m),(gt&6)===0&&(hu=Ie()+500,Bo(0))}}break;case 31:case 13:N=Ds(m,2),N!==null&&fa(N,m,2),gu(),dm(m,2)}if(m=mm(o),m===null&&Zf(e,t,o,Du,s),m===u)break;u=m}u!==null&&o.stopPropagation()}else Zf(e,t,o,null,s)}}function mm(e){return e=er(e),hm(e)}var Du=null;function hm(e){if(Du=null,e=Kt(e),e!==null){var t=d(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=h(t),e!==null)return e;e=null}else if(s===31){if(e=p(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Du=e,null}function yv(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(Pt()){case An:return 2;case Dt:return 8;case bl:case as:return 32;case ws:return 268435456;default:return 32}default:return 32}}var pm=!1,ei=null,ti=null,ni=null,Go=new Map,Vo=new Map,ai=[],zb="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 wv(e,t){switch(e){case"focusin":case"focusout":ei=null;break;case"dragenter":case"dragleave":ti=null;break;case"mouseover":case"mouseout":ni=null;break;case"pointerover":case"pointerout":Go.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vo.delete(t.pointerId)}}function Yo(e,t,s,o,u,m){return e===null||e.nativeEvent!==m?(e={blockedOn:t,domEventName:s,eventSystemFlags:o,nativeEvent:m,targetContainers:[u]},t!==null&&(t=Rt(t),t!==null&&vv(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,u!==null&&t.indexOf(u)===-1&&t.push(u),e)}function Ob(e,t,s,o,u){switch(t){case"focusin":return ei=Yo(ei,e,t,s,o,u),!0;case"dragenter":return ti=Yo(ti,e,t,s,o,u),!0;case"mouseover":return ni=Yo(ni,e,t,s,o,u),!0;case"pointerover":var m=u.pointerId;return Go.set(m,Yo(Go.get(m)||null,e,t,s,o,u)),!0;case"gotpointercapture":return m=u.pointerId,Vo.set(m,Yo(Vo.get(m)||null,e,t,s,o,u)),!0}return!1}function bv(e){var t=Kt(e.target);if(t!==null){var s=d(t);if(s!==null){if(t=s.tag,t===13){if(t=h(s),t!==null){e.blockedOn=t,bs(e.priority,function(){xv(s)});return}}else if(t===31){if(t=p(s),t!==null){e.blockedOn=t,bs(e.priority,function(){xv(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Lu(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=mm(e.nativeEvent);if(s===null){s=e.nativeEvent;var o=new s.constructor(s.type,s);pi=o,s.target.dispatchEvent(o),pi=null}else return t=Rt(s),t!==null&&vv(t),e.blockedOn=s,!1;t.shift()}return!0}function Sv(e,t,s){Lu(e)&&s.delete(t)}function Ib(){pm=!1,ei!==null&&Lu(ei)&&(ei=null),ti!==null&&Lu(ti)&&(ti=null),ni!==null&&Lu(ni)&&(ni=null),Go.forEach(Sv),Vo.forEach(Sv)}function _u(e,t){e.blockedOn===t&&(e.blockedOn=null,pm||(pm=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Ib)))}var zu=null;function Cv(e){zu!==e&&(zu=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){zu===e&&(zu=null);for(var t=0;t<e.length;t+=3){var s=e[t],o=e[t+1],u=e[t+2];if(typeof o!="function"){if(hm(o||s)===null)continue;break}var m=Rt(s);m!==null&&(e.splice(t,3),t-=3,mf(m,{pending:!0,data:u,method:s.method,action:o},o,u))}}))}function Ur(e){function t(B){return _u(B,e)}ei!==null&&_u(ei,e),ti!==null&&_u(ti,e),ni!==null&&_u(ni,e),Go.forEach(t),Vo.forEach(t);for(var s=0;s<ai.length;s++){var o=ai[s];o.blockedOn===e&&(o.blockedOn=null)}for(;0<ai.length&&(s=ai[0],s.blockedOn===null);)bv(s),s.blockedOn===null&&ai.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(o=0;o<s.length;o+=3){var u=s[o],m=s[o+1],S=u[Se]||null;if(typeof m=="function")S||Cv(s);else if(S){var N=null;if(m&&m.hasAttribute("formAction")){if(u=m,S=m[Se]||null)N=S.formAction;else if(hm(u)!==null)continue}else N=S.action;typeof N=="function"?s[o+1]=N:(s.splice(o,3),o-=3),Cv(s)}}}function jv(){function e(m){m.canIntercept&&m.info==="react-transition"&&m.intercept({handler:function(){return new Promise(function(S){return u=S})},focusReset:"manual",scroll:"manual"})}function t(){u!==null&&(u(),u=null),o||setTimeout(s,20)}function s(){if(!o&&!navigation.transition){var m=navigation.currentEntry;m&&m.url!=null&&navigation.navigate(m.url,{state:m.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,u=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),u!==null&&(u(),u=null)}}}function gm(e){this._internalRoot=e}Ou.prototype.render=gm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));var s=t.current,o=Ra();pv(s,o,e,t,null,null)},Ou.prototype.unmount=gm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;pv(e.current,2,null,e,null,null),gu(),t[_e]=null}};function Ou(e){this._internalRoot=e}Ou.prototype.unstable_scheduleHydration=function(e){if(e){var t=ta();e={blockedOn:null,target:e,priority:t};for(var s=0;s<ai.length&&t!==0&&t<ai[s].priority;s++);ai.splice(s,0,e),s===0&&bv(e)}};var kv=a.version;if(kv!=="19.2.7")throw Error(r(527,kv,"19.2.7"));Y.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(r(188)):(e=Object.keys(e).join(","),Error(r(268,e)));return e=g(t),e=e!==null?w(e):null,e=e===null?null:e.stateNode,e};var Bb={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:_,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Iu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Iu.isDisabled&&Iu.supportsFiber)try{Ye=Iu.inject(Bb),wt=Iu}catch{}}return Ko.createRoot=function(e,t){if(!c(e))throw Error(r(299));var s=!1,o="",u=Dp,m=Lp,S=_p;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(u=t.onUncaughtError),t.onCaughtError!==void 0&&(m=t.onCaughtError),t.onRecoverableError!==void 0&&(S=t.onRecoverableError)),t=mv(e,1,!1,null,null,s,o,null,u,m,S,jv),e[_e]=t.current,Xf(e),new gm(t)},Ko.hydrateRoot=function(e,t,s){if(!c(e))throw Error(r(299));var o=!1,u="",m=Dp,S=Lp,N=_p,B=null;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(u=s.identifierPrefix),s.onUncaughtError!==void 0&&(m=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(N=s.onRecoverableError),s.formState!==void 0&&(B=s.formState)),t=mv(e,1,!0,t,s??null,o,u,B,m,S,N,jv),t.context=hv(null),s=t.current,o=Ra(),o=ss(o),u=Fn(o),u.callback=null,ra(s,u,o),s=o,t.current.lanes=s,hn(t,s),Us(t),e[_e]=t.current,Xf(e),new Ou(t)},Ko.version="19.2.7",Ko}var Iv;function bS(){if(Iv)return ym.exports;Iv=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(),ym.exports=wS(),ym.exports}var SS=bS();const CS="https://otbyfkjxrkngvjziawki.supabase.co",jS="sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ",$s=pS(CS,jS,{auth:{autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"pkce",storageKey:"livedesk.mindexec.supabase.auth"}});function ii(n,a,i){if(i<0||a<0||a+i>n.length)throw new Error("Invalid LZO1X block: input overrun.")}function Sm(n,a,i){let r=0;for(;ii(n,a.inputIndex,1),n[a.inputIndex]===0;)r+=1,a.inputIndex+=1;const c=r*255+i+n[a.inputIndex];return a.inputIndex+=1,c}function Bu(n,a,i,r){if(ii(n,a.inputIndex,r),a.outputIndex+r>i.length)throw new Error("Invalid LZO1X block: output overrun.");i.set(n.subarray(a.inputIndex,a.inputIndex+r),a.outputIndex),a.inputIndex+=r,a.outputIndex+=r}function kS(n,a,i,r){const c=a-i;if(c<=0||r<=0)throw new Error("Invalid LZO1X block: invalid match distance.");let d=Math.min(c,r);for(n.set(n.subarray(i,i+d),a);d<r;){const h=Math.min(d,r-d);n.copyWithin(a+d,a,a+h),d+=h}return a+r}function fy(n,a){if(!(n instanceof Uint8Array)||n.length<3||a<0)throw new Error("Invalid LZO1X block.");const i=new Uint8Array(a),r={inputIndex:0,outputIndex:0};let c=0,d=0;if(n[r.inputIndex]>=22){const h=n[r.inputIndex]-17;r.inputIndex+=1,Bu(n,r,i,h),c=4}else n[r.inputIndex]>=18&&(c=n[r.inputIndex]-17,r.inputIndex+=1,Bu(n,r,i,c));for(;;){ii(n,r.inputIndex,1);const h=n[r.inputIndex];r.inputIndex+=1;let p,v;if((h&192)!==0)ii(n,r.inputIndex,1),v=r.outputIndex-((n[r.inputIndex]<<3)+(h>>2&7)+1),r.inputIndex+=1,d=(h>>5)+1,p=h&3;else if((h&32)!==0){d=(h&31)+2,d===2&&(d+=Sm(n,r,31)),ii(n,r.inputIndex,2);const g=n[r.inputIndex]|n[r.inputIndex+1]<<8;r.inputIndex+=2,v=r.outputIndex-((g>>2)+1),p=g&3}else if((h&16)!==0){d=(h&7)+2,d===2&&(d+=Sm(n,r,7)),ii(n,r.inputIndex,2);const g=n[r.inputIndex]|n[r.inputIndex+1]<<8;if(r.inputIndex+=2,v=r.outputIndex-(((h&8)<<11)+(g>>2)),p=g&3,v===r.outputIndex)break;v-=16384}else if(c===0){let g=h+3;g===3&&(g+=Sm(n,r,15)),Bu(n,r,i,g),c=4;continue}else c!==4?(ii(n,r.inputIndex,1),p=h&3,v=r.outputIndex-((h>>2)+(n[r.inputIndex]<<2)+1),r.inputIndex+=1,d=2):(ii(n,r.inputIndex,1),p=h&3,v=r.outputIndex-((h>>2)+(n[r.inputIndex]<<2)+2049),r.inputIndex+=1,d=3);if(v<0||r.outputIndex+d+p>i.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");r.outputIndex=kS(i,r.outputIndex,v,d),c=p,Bu(n,r,i,p)}if(d!==3||r.inputIndex!==n.length||r.outputIndex!==i.length)throw new Error("Invalid LZO1X block: incomplete output.");return i}const Bv=16,Fv=8,MS=24*1024*1024,my=new Uint8Array(new Uint32Array([16909060]).buffer)[0]===4,Zm=new Uint32Array(65536);for(let n=0;n<Zm.length;n+=1){const a=Math.round((n>>11&31)*255/31),i=Math.round((n>>5&63)*255/63),r=Math.round((n&31)*255/31);Zm[n]=my?(a|i<<8|r<<16|4278190080)>>>0:(a<<24|i<<16|r<<8|255)>>>0}function li(n,a){return n[a]|n[a+1]<<8}function AS(n,a){const i=Number(a);if(!Number.isSafeInteger(i)||i<Bv||i>MS)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const r=fy(new Uint8Array(n),i);if(r[0]!==76||r[1]!==68||r[2]!==53||r[3]!==68)throw new Error("Invalid Mode 5 packet magic.");if(r[4]!==1)throw new Error(`Unsupported Mode 5 packet version: ${r[4]}.`);const c=(r[5]&1)!==0,d=li(r,6),h=li(r,8),p=li(r,10),v=li(r,12);if(d<=0||h<=0||d>3840||h>2160)throw new Error(`Invalid Mode 5 frame size: ${d}x${h}.`);if(p<=0||p>256||v>8192)throw new Error(`Invalid Mode 5 tile header: ${p}/${v}.`);const g=[];let w=Bv;for(let y=0;y<v;y+=1){if(w+Fv>r.length)throw new Error("Mode 5 tile header is truncated.");const b=li(r,w),j=li(r,w+2),k=li(r,w+4),M=li(r,w+6);w+=Fv;const R=k*M*2;if(k<=0||M<=0||k>p||M>p||b+k>d||j+M>h||w+R>r.length)throw new Error(`Invalid Mode 5 tile ${y}.`);g.push({x:b,y:j,width:k,height:M,pixels:r.subarray(w,w+R)}),w+=R}if(w!==r.length)throw new Error(`Mode 5 packet has ${r.length-w} trailing bytes.`);return{keyFrame:c,width:d,height:h,tileSize:p,tiles:g}}function NS(n,a,i,r){if(!(n instanceof Uint8ClampedArray)||n.length!==a*i*4||r.width!==a||r.height!==i)throw new Error("Mode 5 canvas state does not match the packet dimensions.");let c=a,d=i,h=0,p=0;const v=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const g of r.tiles){const w=my&&(g.pixels.byteOffset&1)===0?new Uint16Array(g.pixels.buffer,g.pixels.byteOffset,g.pixels.byteLength>>>1):null;let y=0;for(let b=0;b<g.height;b+=1){let j=(g.y+b)*a+g.x;for(let k=0;k<g.width;k+=1){const M=y<<1,R=w?w[y]:g.pixels[M]|g.pixels[M+1]<<8;v[j]=Zm[R],y+=1,j+=1}}c=Math.min(c,g.x),d=Math.min(d,g.y),h=Math.max(h,g.x+g.width),p=Math.max(p,g.y+g.height)}return r.tiles.length>0?{x:c,y:d,width:h-c,height:p-d}:null}const ga=new WeakMap,vc=new WeakMap,Jm=new WeakMap,xc=new Set,qi=new Set,md=new WeakMap,eh=new WeakMap,th=new WeakMap,hd=new WeakMap,Sh=32,TS=2,RS=2,ES=2,DS=18,LS=40,_S=0,zS=750,hy=80,Hv=5,OS=150,IS=24,BS=180,FS=1200,HS=18,US=.65,$S=2e3,PS=500,py=250;let pd=!1;function qS(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function GS(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let Yi={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:GS()};function VS(n){n.h264DecodeAcceleration&&(Yi={...Yi,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(Yi.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function gy(n,a=Yi.h264DecodeAcceleration){const i=md.get(n);return i?.requested===a?(i.actual!=="prefer-hardware"&&qi.delete(n),i.actual):(i&&md.delete(n),a!=="prefer-hardware"?(qi.delete(n),a):qi.has(n)?"prefer-hardware":qi.size<Yi.h264HardwareDecoderBudget?(qi.add(n),"prefer-hardware"):"prefer-software")}function Cd(n,a){return a!=="prefer-hardware"?!1:(md.set(n,{requested:a,actual:"prefer-software"}),qi.delete(n),!0)}function YS(n,a,i,r=64){try{let c=eh.get(n);c||(c={canvas:document.createElement("canvas"),lastHash:"",initialized:!1},eh.set(n,c));const d=Math.max(8,Math.min(64,Math.round(r))),h=Math.max(1,Math.round(d*Math.max(1,i)/Math.max(1,a)));(c.canvas.width!==d||c.canvas.height!==h)&&(c.canvas.width=d,c.canvas.height=h);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,i),0,0,d,h);const v=p.getImageData(0,0,d,h).data;let g=2166136261;for(let b=0;b<v.length;b+=4)g^=v[b],g=Math.imul(g,16777619),g^=v[b+1],g=Math.imul(g,16777619),g^=v[b+2],g=Math.imul(g,16777619);const w=(g>>>0).toString(16).padStart(8,"0"),y=!c.initialized||w!==c.lastHash;return c.initialized=!0,c.lastHash=w,{visualHash:w,visualChanged:y}}catch{return{visualHash:"",visualChanged:!0}}}function nh(n,a,i,r=py,c=64){let d=th.get(n);d||(d={lastHash:"",initialized:!1,lastCanvasSampleAt:0},th.set(n,d));const h=performance.now();if(d.initialized&&r>0&&h-d.lastCanvasSampleAt<r)return{visualHash:d.lastHash,visualChanged:!1};const p=YS(n,a,i,c);return d.initialized=!0,d.lastHash=p.visualHash,d.lastCanvasSampleAt=h,p}function WS(n,a){let i=hd.get(n);i||(i={lastHash:"",initialized:!1},hd.set(n,i));const r=String(a.contentHash||""),c=!i.initialized||!r||r!==i.lastHash;return i.initialized=!0,i.lastHash=r,{visualHash:r,visualChanged:c}}function vy(n,a){const i=Jm.get(n);if(i)return i;const r=n.getContext("2d",{alpha:!1,desynchronized:a==="interactive"});if(r){const c=r.getContextAttributes?.(),d={context:r,presentation:c?.desynchronized?"desync":"sync"};return Jm.set(n,d),d}return null}function KS(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),i=String(n.compression||"").toLowerCase(),r=String(n.mimeType||"").toLowerCase();return a==="mode2-lzo"||i==="lzo1x"||r==="application/vnd.livedesk.lzo-rgb565"||a==="mode2-lz4"||String(n.compression||"").toLowerCase()==="lz4"||r==="application/vnd.livedesk.lz4-raw"}function QS(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function XS(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),i=String(n.mimeType||"").toLowerCase();return a==="mode5-lzo-delta"||i==="application/vnd.livedesk.lzo-rgb565-delta"}function Uv(n,a,i){let r=i,c=a;if(r===15){let d=255;for(;d===255;){if(c>=n.length)throw new Error("Invalid LZ4 block: length overrun.");d=n[c],c+=1,r+=d}}return{length:r,cursor:c}}function ZS(n,a){const i=new Uint8Array(a);let r=0,c=0;for(;r<n.length;){const d=n[r];r+=1;const h=Uv(n,r,d>>4);r=h.cursor;const p=h.length;if(r+p>n.length||c+p>i.length)throw new Error("Invalid LZ4 block: literal overrun.");if(i.set(n.subarray(r,r+p),c),r+=p,c+=p,r>=n.length)break;if(r+2>n.length)throw new Error("Invalid LZ4 block: missing offset.");const v=n[r]|n[r+1]<<8;if(r+=2,v<=0||v>c)throw new Error("Invalid LZ4 block: bad match offset.");const g=Uv(n,r,d&15);r=g.cursor;const w=g.length+4;if(c+w>i.length)throw new Error("Invalid LZ4 block: match overrun.");let y=c-v;for(let b=0;b<w;b+=1)i[c]=i[y],c+=1,y+=1}if(c!==i.length)throw new Error("Invalid LZ4 block: incomplete output.");return i}function JS(n){const a=Math.max(1,Math.floor(n.width||0)),i=Math.max(1,Math.floor(n.height||0)),r=String(n.compression||"").toLowerCase(),c=String(n.pixelFormat||n.codec||"").toLowerCase();if(r==="lzo1x"||String(n.frameMode||n.mode||"").toLowerCase()==="mode2-lzo"||String(n.mimeType||"").toLowerCase()==="application/vnd.livedesk.lzo-rgb565"){const w=Math.max(1,Math.floor(n.bytesPerPixel||2)),y=a*i*2,b=Math.floor(n.uncompressedByteLength||y);if(w!==2||b!==y)throw new Error(`Invalid mode2 RGB565 frame size: ${b} for ${a}x${i}.`);if(c&&c!=="rgb565le"&&c!=="rgb565")throw new Error(`Unsupported mode2 pixel format: ${c}`);const j=fy(new Uint8Array(n.payload),y),k=new Uint8ClampedArray(a*i*4);for(let M=0,R=0;M<j.length;M+=2,R+=4){const C=j[M]|j[M+1]<<8,A=C>>11&31,E=C>>5&63,U=C&31;k[R]=A<<3|A>>2,k[R+1]=E<<2|E>>4,k[R+2]=U<<3|U>>2,k[R+3]=255}return new ImageData(k,a,i)}const h=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*i*h,Math.floor(n.uncompressedByteLength||0)),v=ZS(new Uint8Array(n.payload),p);if(h!==4)throw new Error(`Unsupported mode2 pixel size: ${h}`);const g=new Uint8ClampedArray(a*i*4);if(c==="rgba32"||c==="rgba")g.set(v.subarray(0,g.length));else for(let w=0,y=0;y<g.length;w+=4,y+=4)g[y]=v[w+2],g[y+1]=v[w+1],g[y+2]=v[w],g[y+3]=v[w+3];return new ImageData(g,a,i)}function $v(n,a="smooth"){const i=window.VideoDecoder;if(!i||!window.EncodedVideoChunk)throw new Error("WebCodecs H.264 decode is not supported in this browser.");const r=ga.get(n);if(r&&r.decoder.state!=="closed"&&r.latencyMode===a)return r;r&&xs(n);let c;return c={decoder:new i({output:h=>{if(ga.get(n)!==c){h.close();return}const p=Number(h.timestamp||0);c.outputSerial+=1;let v=c.pendingFrames.get(p);if(v)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const k=c.pendingFrames.entries().next().value;k&&(c.pendingFrames.delete(k[0]),v=k[1],c.timestampFallbacks+=1)}const g=h.displayWidth||h.codedWidth||n.width||960,w=h.displayHeight||h.codedHeight||n.height||540,y=Number(v?.frame.durationUs||0),b=Number(h.duration||0),j=Math.max(16,Math.min(250,(y>0?y:b||83333)/1e3));for(c.targetPaintIntervalMs=j,c.decodedFrames.push({videoFrame:h,pending:v,decodedAt:performance.now(),width:g,height:w,durationMs:j}),c.lastOutputAt=performance.now();c.decodedFrames.length>xy(c);)gd(c,c.decodedFrames.shift());yy(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>PS&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=Sh&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),vd(n,c)},error:()=>{ga.get(n)===c&&(Cd(n,c.hardwareAcceleration),Ch(c),xc.delete(n),ga.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:gy(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},ga.set(n,c),xc.add(n),c}function Ch(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 gd(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function xy(n){return n.latencyMode==="interactive"?RS:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?TS:Sh}function yy(n,a=performance.now()){const i=xy(n);for(;n.decodedFrames.length>i;)gd(n,n.decodedFrames.shift());const r=n.latencyMode==="interactive"?hy:zS;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>r;)gd(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function wy(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const i=a.latencyMode==="interactive"?IS:OS,r=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,v]of a.pendingFrames.entries())c-v.queuedAt>$S&&a.pendingFrames.delete(p);if(ga.get(n)!==a||a.decoder.state!=="configured"||a.pendingFrames.size===0||a.inputSerial<=a.lastFlushInputSerial||!r&&a.lastOutputAt>0&&c-a.lastOutputAt<i)return;const d=a.inputSerial,h=performance.now();a.flushInFlight=!0,a.flushCount+=1;try{await a.decoder.flush(),a.lastFlushInputSerial=Math.max(a.lastFlushInputSerial,d)}catch{ga.get(n)===a&&ld(a)}finally{a.flushInFlight=!1;const p=performance.now()-h;if(r&&p>=BS&&a.hardwareAcceleration==="prefer-hardware"){pd=!0,Cd(n,a.hardwareAcceleration),xs(n);return}ga.get(n)===a&&a.inputSerial>d&&a.pendingFrames.size>0&&(r||performance.now()-a.lastOutputAt>=i)&&wy(n,a)}},i)}function Pv(n,a,i){const r=performance.now();try{(n.width!==i.width||n.height!==i.height)&&(n.width=i.width,n.height=i.height);const c=vy(n,a.latencyMode);if(c?.context.drawImage(i.videoFrame,0,0,i.width,i.height),i.pending){const d=performance.now(),p=a.latencyMode==="interactive"?WS(n,i.pending.frame):nh(n,i.width,i.height,py,64);try{a.onPaint?.(i.pending.frame,{deviceId:i.pending.frame.deviceId,frameSeq:i.pending.frame.frameSeq,mode:i.pending.frame.frameMode||i.pending.frame.mode||i.pending.frame.codec||i.pending.frame.mimeType,width:i.width,height:i.height,byteLength:i.pending.frame.byteLength,queuedForMs:Math.max(0,r-i.pending.queuedAt),decodedForMs:Math.max(0,i.decodedAt-i.pending.queuedAt),scheduledForMs:Math.max(0,r-i.decodedAt),drawMs:Math.max(0,d-r),queueSize:i.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{i.videoFrame.close()}}function vd(n,a){if(a.renderTimer!==null||a.decodedFrames.length===0)return;const i=Math.max(16,Math.min(250,a.targetPaintIntervalMs||1e3/12)),r=()=>{if(a.renderTimer=null,a.renderScheduledAt=0,a.decodedFrames.length===0)return;const c=performance.now();if(yy(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const v=a.targetPaintIntervalMs<=LS,g=a.targetPaintIntervalMs<=20;if(g&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const M=a.decodedFrames.length>=ES,R=c-a.interactiveBufferStartedAt>=DS;if(!M&&!R){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else g||(a.interactiveBufferPrimed=!0);const w=a.decodedFrames[0],y=w?.pending?Math.max(0,c-w.pending.queuedAt):0,b=a.lastPaintAt>0?a.lastPaintAt+i:c;if(!(!v||c+Hv>=b||y>=hy)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}const k=a.decodedFrames.shift();if(k)try{Pv(n,a,k)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),vd(n,a);return}const d=a.lastPaintAt>0?a.lastPaintAt+i:c+_S;if(!(c+Hv>=d||a.decodedFrames.length>=Sh-1)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}const p=a.decodedFrames.shift();if(p)try{Pv(n,a,p)}catch{}vd(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r)}function by(n,a){if(ga.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;)gd(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,vd(n,a),!0}function Cm(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of xc){const a=ga.get(n);if(!a||a.decoder.state==="closed"){xc.delete(n);continue}by(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",Cm),window.addEventListener("focus",Cm),window.addEventListener("pageshow",Cm));function xs(n){qi.delete(n),xc.delete(n),hd.delete(n);const a=ga.get(n);if(a){ga.delete(n);try{Ch(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function Qo(n){n&&(md.delete(n),Jm.delete(n),th.delete(n),eh.delete(n),hd.delete(n),vc.delete(n),xs(n))}function ld(n,a=1){try{n.decoder.state!=="closed"&&n.decoder.reset()}catch{}n.configured=!1,n.configKey="",n.keyFrameSeen=!1,n.pendingFrames.clear(),Ch(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 Fu(n,a,i,r){n.decoder.configure(a),n.configured=!0,n.configKey=i,n.codec=a.codec,n.hardwareAcceleration=r,n.keyFrameSeen=!1,n.nextChunkTimestampUs=0,n.lastInputFrameSeq=void 0}function e0(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const i=performance.now();if(i-a.healthSampleStartedAt<FS)return!1;const r=a.inputSerial-a.healthInputSerial,c=a.outputSerial-a.healthOutputSerial;return a.healthSampleStartedAt=i,a.healthInputSerial=a.inputSerial,a.healthOutputSerial=a.outputSerial,r<HS||c/Math.max(1,r)>=US?!1:(pd=!0,Cd(n,a.hardwareAcceleration),xs(n),!0)}function jm(n,a=1){if(!n)return!1;const i=ga.get(n);return i?(i.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),xs(n),!0):!1}function t0(n){if(!n)return!1;const a=ga.get(n);return a?by(n,a):!1}function n0(n,a,i,r="interactive"){xs(n);const c=performance.now(),d=AS(a.payload,a.uncompressedByteLength||0),h=String(a.streamId||"mode5");let p=vc.get(n);if(!p||p.streamId!==h||p.width!==d.width||p.height!==d.height){const M=new Uint8ClampedArray(d.width*d.height*4);for(let R=3;R<M.length;R+=4)M[R]=255;p={streamId:h,width:d.width,height:d.height,rgba:M,imageData:new ImageData(M,d.width,d.height),keyFrameSeen:!1,inputSerial:0,outputSerial:0},vc.set(n,p)}if(!p)throw new Error("Mode 5 canvas state could not be initialized.");p.inputSerial+=1;const g=Number(a.streamFrameSeq||0);if(g>0&&(p.lastStreamFrameSeq=g),!d.keyFrame&&!p.keyFrameSeen)return;d.keyFrame&&(p.keyFrameSeen=!0);const w=NS(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 b=vy(n,r),j=performance.now();w&&b?.context.putImageData(p.imageData,0,0,w.x,w.y,w.width,w.height);const k=performance.now();p.outputSerial+=1,i?.(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,k-c),decodedForMs:Math.max(0,y-c),scheduledForMs:0,drawMs:Math.max(0,k-j),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:b?.presentation||"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:String(a.contentHash||""),visualChanged:Number(a.deltaVisualTileCount||0)>0,paintedAt:k})}const km=[{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 qv(n,a){for(let i=Math.max(0,a);i+3<n.length;i+=1)if(!(n[i]!==0||n[i+1]!==0)){if(n[i+2]===1)return{index:i,length:3};if(n[i+2]===0&&n[i+3]===1)return{index:i,length:4}}return null}function a0(n){const a=new Uint8Array(n);let i=0;for(;i<a.length;){const r=qv(a,i);if(!r)break;const c=r.index+r.length,d=qv(a,c),h=d?.index??a.length;if(c<h&&(a[c]&31)===7){const p=[];let v=0;for(let g=c+1;g<h;g+=1){const w=a[g];if(v>=2&&w===3){v=0;continue}p.push(w),v=w===0?v+1:0}if(p.length>=3)return`avc1.${p.slice(0,3).map(g=>g.toString(16).toUpperCase().padStart(2,"0")).join("")}`}i=d?d.index:a.length}return""}function s0(n,a,i,r,c=""){const d=Math.ceil(n/16)*Math.ceil(a/16),h=i>0?1e6/i:30,p=d*h,v=km.find(g=>d<=g.maxFrameSize&&p<=g.maxMacroblocksPerSecond)||km[km.length-1];return a0(r)||c||`avc1.42E0${v.code.toString(16).toUpperCase().padStart(2,"0")}`}function l0(n,a,i,r,c="smooth"){vc.delete(n);const d=String(a.h264Format||"").toLowerCase()==="avc"?"avc":"annexb",h=Math.max(1,Math.floor(a.width||960)),p=Math.max(1,Math.floor(a.height||540)),v=Math.max(1,Math.floor(a.durationUs||1e6/12));let g=$v(n,c);const w=s0(h,p,v,a.payload,g.codec),y=String(a.frameMode||a.mode||"").toLowerCase(),b=c==="interactive"&&r==="prefer-hardware"&&qS(),k=y==="mode4-h264-atlas"?"prefer-software":gy(n,c==="interactive"&&(pd||b)?"prefer-software":r),M=[a.streamId||"",a.commandId||"",h,p,w,d,k,c].join("|");g.onPaint=i,g.configured&&g.decoder.state!=="configured"&&(g.configured=!1,g.configKey=""),g.configured&&g.configKey!==M&&(xs(n),g=$v(n,c),g.onPaint=i);const R={codec:w,codedWidth:h,codedHeight:p,hardwareAcceleration:k,optimizeForLatency:!0,avc:{format:d}};g.configured||Fu(g,R,M,k);const C=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const A=Number(a.streamFrameSeq||0);if(A>0&&g.lastInputFrameSeq!==void 0){if(A<=g.lastInputFrameSeq){if(!C||A===g.lastInputFrameSeq)return;ld(g,g.lastInputFrameSeq-A+1),Fu(g,R,M,k)}if(A>g.lastInputFrameSeq+1){if(ld(g,A-g.lastInputFrameSeq-1),!C)return;Fu(g,R,M,k)}}if(A>0&&(g.lastInputFrameSeq=A),!C&&!g.keyFrameSeen)return;C&&(g.keyFrameSeen=!0);const E=Number(g.decoder.decodeQueueSize||0);if(E>8){if(g.latencyMode==="interactive"&&g.hardwareAcceleration==="prefer-hardware"){pd=!0,Cd(n,g.hardwareAcceleration),xs(n);return}if(ld(g),!C)return;Fu(g,R,M,k),g.keyFrameSeen=!0}const U=g.nextChunkTimestampUs;g.nextChunkTimestampUs+=v,g.pendingFrames.set(U,{frame:a,queuedAt:performance.now(),queueSize:E}),g.inputSerial+=1,g.lastInputAt=performance.now();const F=new EncodedVideoChunk({type:C?"key":"delta",timestamp:U,duration:v,data:a.payload});try{g.decoder.decode(F)}catch(P){throw xs(n),P}wy(n,g),e0(n,g)}async function Mm(n,a,i,r,c,d="smooth"){if(XS(a)){i()||n0(n,a,r,d);return}if(QS(a)){i()||l0(n,a,r,c,d);return}if(vc.delete(n),KS(a)){xs(n);const y=JS(a);if(i())return;(n.width!==y.width||n.height!==y.height)&&(n.width=y.width,n.height=y.height);const b=n.getContext("2d"),j=performance.now();b?.putImageData(y,0,0);const k=performance.now(),M=nh(n,y.width,y.height);r?.(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,k-j),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Yi.h264DecodeAcceleration,decoderLabel:"lzo-rgb565",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:M.visualHash,visualChanged:M.visualChanged,paintedAt:k});return}xs(n);const h=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(h);if(i()){p.close();return}const v=a.width||p.width||960,g=a.height||p.height||540;(n.width!==v||n.height!==g)&&(n.width=v,n.height=g);const w=n.getContext("2d");if(w){const y=performance.now();w.clearRect(0,0,v,g),w.drawImage(p,0,0,v,g);const b=performance.now(),j=nh(n,v,g);r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:v,height:g,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,b-y),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Yi.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:j.visualHash,visualChanged:j.visualChanged,paintedAt:b})}p.close()}const cc=5179,Cn=di(`http://127.0.0.1:${cc}`);function i0(n){const a=n.split(".").map(i=>Number(i));return a.length===4&&a.every(i=>Number.isInteger(i)&&i>=0&&i<=255)?a:[]}function r0(n){const a=n.trim().toLowerCase();return a==="localhost"||a==="127.0.0.1"||a==="::1"||a==="[::1]"}function o0(n){const a=n.trim().toLowerCase();return!a||a==="0.0.0.0"||a==="::"||a==="[::]"}function c0(n){const a=i0(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 u0(n){return n.includes(":")&&!n.startsWith("[")?`[${n}]`:n}function d0(n){const a=String(n||"").trim();if(!a)return null;const i=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`tcp://${a}`;try{const r=new URL(i),c=r.hostname.replace(/^\[|\]$/g,""),d=Number(r.port);return!c||!Number.isInteger(d)||d<1||d>65535||o0(c)?null:{host:c,port:d}}catch{return null}}function di(n){const a=String(n||"").trim()||`http://127.0.0.1:${cc}`,i=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`http://${a}`;try{const r=new URL(i);return r.port||(r.port=String(cc)),r.hash="",r.search="",r.toString().replace(/\/+$/,"")}catch{return`http://127.0.0.1:${cc}`}}function f0(n){const a=d0(n);return a?di(`http://${u0(a.host)}:${cc}`):""}function Gv(n){const i=[n?.endpoint,...Array.isArray(n?.endpoint_candidates)?n.endpoint_candidates:[]].map(r=>f0(String(r||""))).filter(Boolean);return[...new Set(i)]}function uc(n=Cn){if(!(typeof window>"u"||window.location.protocol!=="https:"))try{const a=new URL(n);if(a.protocol!=="http:")return;if(r0(a.hostname))return"loopback";if(c0(a.hostname))return"local"}catch{return}}function jd(n,a=Cn){const i=new URL(n,di(a));return i.protocol=i.protocol==="https:"?"wss:":"ws:",i.toString()}async function Be(n,a,i=Cn){const r=di(i),c={...a,headers:{"Content-Type":"application/json",...a?.headers||{}},cache:"no-store"},d=uc(r);d&&(c.targetAddressSpace=d);let h;try{h=await fetch(`${r}${n}`,c)}catch(v){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."):v}let p=null;try{p=await h.json()}catch{p=null}if(!h.ok){const v=p&&typeof p=="object"&&"error"in p?String(p.error||""):"";throw new Error(`${h.status} ${v||h.statusText}`)}return p}function ah(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 Pi(n){await navigator.clipboard.writeText(n)}const Vv="livedesk_remote_host_targets",m0="livedesk_entitlements";function h0(n){const i=(Array.isArray(n)?n:[n||Cn]).map(r=>di(r||Cn));return[...new Set(i.filter(Boolean))]}function p0(){const[n,a]=f.useState(null),[i,r]=f.useState(!0);return f.useEffect(()=>{let c=!0;$s.auth.getSession().then(({data:h})=>{c&&(a(h.session??null),r(!1))});const{data:{subscription:d}}=$s.auth.onAuthStateChange((h,p)=>{a(p),r(!1)});return()=>{c=!1,d.unsubscribe()}},[]),{session:n,loading:i}}function g0(n,a=!0){const[i,r]=f.useState(null),[c,d]=f.useState([]),[h,p]=f.useState(""),[v,g]=f.useState(""),[w,y]=f.useState(0),b=f.useRef(new Map),j=Array.isArray(n)?n.join(`
10
+ `):String(n||""),k=f.useMemo(()=>h0(n),[j]),M=f.useMemo(()=>k.find(A=>uc(A)==="loopback")||k[0]||Cn,[k]),R=f.useCallback(async()=>{if(!a){r(null),d([]),g(""),p("");return}let A=null;const E=Date.now(),U=k.filter(F=>(b.current.get(F)||0)<=E);if(U.length===0)throw new Error("No LiveDesk Hub endpoint is reachable. Retrying shortly.");for(const F of U)try{const[P,L]=await Promise.all([Be("/api/remote/status",void 0,F),Be("/api/remote/devices",void 0,F)]);if(!Array.isArray(L.devices))throw new Error("Invalid Hub devices response.");b.current.delete(F),r(P),d(L.devices),g(F),p("");return}catch(P){A=P,b.current.set(F,Date.now()+1e4)}throw g(""),A||new Error("No LiveDesk Hub endpoint is reachable.")},[a,k]),C=f.useCallback(()=>{b.current.clear(),R().catch(A=>{p(A instanceof Error?A.message:String(A))}),y(A=>A+1)},[R]);return f.useEffect(()=>{if(!a){r(null),d([]),g(""),p("");return}let A=!0;const E=async()=>{try{await R()}catch(F){A&&p(F instanceof Error?F.message:String(F))}};E();const U=window.setInterval(E,2500);return()=>{A=!1,window.clearInterval(U)}},[a,R,w]),{status:i,devices:c,error:h,refresh:C,hubBaseUrl:v||M,hubCandidates:k}}function v0(n){const[a,i]=f.useState(null),[r,c]=f.useState(""),d=n?.user?.id||"",h=f.useCallback(async()=>{if(!d){i(null);return}const{data:p,error:v}=await $s.from(Vv).select("*").eq("user_id",d).maybeSingle();if(v){c(v.message);return}i(p),c("")},[d]);return f.useEffect(()=>{h()},[h]),f.useEffect(()=>{if(!d)return;const p=$s.channel(`livedesk-remote-host-targets-${d.replace(/[^a-zA-Z0-9]/g,"")}`).on("postgres_changes",{event:"*",schema:"public",table:Vv,filter:`user_id=eq.${d}`},v=>i(v.new)).subscribe();return()=>{$s.removeChannel(p)}},[d]),{target:a,error:r,refresh:h}}function x0(n){const[a,i]=f.useState(null),[r,c]=f.useState(!1),[d,h]=f.useState(""),p=n?.user?.id||"",v=f.useCallback(async()=>{if(!p){i(null),h(""),c(!1);return}c(!0);const{data:w,error:y}=await $s.from(m0).select("*").eq("user_id",p).eq("product_key","livedesk").maybeSingle();if(y){h(y.message),c(!1);return}i(w),h(""),c(!1)},[p]);f.useEffect(()=>{v()},[v]);const g=f.useMemo(()=>!a||a.status!=="active"?!1:a.expires_at?new Date(a.expires_at).getTime()>Date.now():!0,[a]);return{entitlement:a,licensed:g,loading:r,error:d,refresh:v}}const dc={totalFrames:0,totalBytes:0,framesPerSecond:0,bytesPerSecond:0,sampleMs:0,lastUpdatedAt:0},y0=2500,w0=3e4,b0=64*1024,S0=6,C0=S0,Sy=new Map;function j0(n){return Sy.get(n)}const Yv={totalSent:0,totalDropped:0,sentPerSecond:0,droppedPerSecond:0,bufferedAmount:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0,lastUpdatedAt:0};function Wv(n){const a=Date.parse(String(n||""));if(!Number.isFinite(a))return 0;const i=Date.now()-a;return i>0&&i<=w0?i:0}function Kv(n,a,i=Cn,r={}){const[c,d]=f.useState(new Map),[h,p]=f.useState("idle"),[v,g]=f.useState(""),[w,y]=f.useState(dc),b=f.useRef(new Map),j=f.useRef(new Map),k=f.useRef(0),M=f.useRef(new Map),R=f.useRef({enabled:!1,token:"",reason:""}),C=f.useRef(new Set),[A,E]=f.useState(0),U=f.useRef(r.onFrame),F=f.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),P=f.useMemo(()=>[...n].sort().join(","),[n]),L=Number.isFinite(r.fps)?Number(r.fps):2,I=Number.isFinite(r.maxWidth)?Number(r.maxWidth):640,de=Number.isFinite(r.maxHeight)?Number(r.maxHeight):360,W=Number.isFinite(r.quality)?Number(r.quality):45,ue=String(r.frameMode||r.mode||"mode3-h264-hw").trim()||"mode3-h264-hw",Z=r.streamPurpose==="control"?"control":"wall",le=r.forceRestart===!0,ce=String(r.forceRestartToken||"").trim(),Q=String(r.restartReason||"").trim();R.current={enabled:le,token:ce,reason:Q};const _=f.useMemo(()=>{const J=Object.entries(r.monitorSelections||{}).filter(([he])=>!!he).sort(([he],[we])=>he.localeCompare(we));return JSON.stringify(Object.fromEntries(J))},[r.monitorSelections]);f.useEffect(()=>{U.current=r.onFrame},[r.onFrame]);const Y=f.useCallback((J,he="livedesk-frame-socket-release")=>{J.disposed=!0;try{J.socket.readyState===WebSocket.CONNECTING||J.socket.readyState===WebSocket.OPEN?J.socket.close(1e3,he):J.socket.close()}catch{}},[]),$=f.useCallback(()=>{const J=[...j.current.values()].map(he=>he.socket);if(J.length===0){p("idle");return}if(J.some(he=>he.readyState===WebSocket.OPEN)){p("open");return}if(J.some(he=>he.readyState===WebSocket.CONNECTING)){p("connecting");return}p("closed")},[]),H=f.useCallback((J,he,we,je)=>{if(he.disposed||he.socket.readyState!==WebSocket.OPEN)return!1;try{return he.socket.send(JSON.stringify({...he.payload,type:"restart-live",deviceIds:[J],forceRestart:!0,restartReason:we,restartToken:je})),!0}catch{return!1}},[]),ie=f.useCallback((J,he)=>{if(!J||J.byteLength<5)return;const we=Date.now(),Oe=new DataView(J).getUint32(0,!1);if(Oe<=0||Oe+4>J.byteLength)return;const He=new Uint8Array(J.slice(4,4+Oe)),oe=JSON.parse(new TextDecoder().decode(He));if(Math.max(Wv(oe.receivedAt),Wv(oe.capturedAt))>y0)return;const De=J.slice(4+Oe),at={deviceId:String(oe.deviceId||""),kind:oe.kind==="thumbnail"?"thumbnail":"live",frameSeq:Number(oe.frameSeq||0),streamFrameSeq:Number(oe.streamFrameSeq||0)||void 0,streamId:String(oe.streamId||""),commandId:oe.commandId?String(oe.commandId):void 0,width:Number(oe.width||0),height:Number(oe.height||0),sourceWidth:Number(oe.sourceWidth||0)||void 0,sourceHeight:Number(oe.sourceHeight||0)||void 0,mimeType:String(oe.mimeType||"image/jpeg"),mode:oe.mode?String(oe.mode):void 0,frameMode:oe.frameMode?String(oe.frameMode):void 0,frameProfile:oe.frameProfile?String(oe.frameProfile):void 0,encoding:oe.encoding?String(oe.encoding):void 0,codec:oe.codec?String(oe.codec):void 0,compression:oe.compression?String(oe.compression):void 0,pixelFormat:oe.pixelFormat?String(oe.pixelFormat):void 0,bytesPerPixel:Number(oe.bytesPerPixel||0)||0,uncompressedByteLength:Number(oe.uncompressedByteLength||0)||0,h264Format:oe.h264Format?String(oe.h264Format):void 0,isKeyFrame:oe.isKeyFrame===!0,chunkType:oe.chunkType?String(oe.chunkType):void 0,timestampUs:Number(oe.timestampUs||0)||0,durationUs:Number(oe.durationUs||0)||0,sourceGapMs:Number(oe.sourceGapMs||0)||0,agentSendGapMs:Number(oe.agentSendGapMs||0)||0,agentSendDurationMs:Number(oe.agentSendDurationMs||0)||0,agentSendDurationFrameSeq:Number(oe.agentSendDurationFrameSeq||0)||0,agentPaceMs:Number(oe.agentPaceMs||0)||0,agentQueueBeforePaceMs:Number(oe.agentQueueBeforePaceMs||0)||0,agentFrameAgeMs:Number(oe.agentFrameAgeMs||0)||0,droppedByAgent:Number(oe.droppedByAgent||0)||0,hubIngressDropped:Number(oe.hubIngressDropped||0)||0,hubClientDropped:Number(oe.hubClientDropped||0)||0,hardwareEncoder:oe.hardwareEncoder?String(oe.hardwareEncoder):void 0,platformProfile:oe.platformProfile?String(oe.platformProfile):void 0,monitorIndex:Number.isFinite(Number(oe.monitorIndex))?Number(oe.monitorIndex):void 0,monitorCount:Number.isFinite(Number(oe.monitorCount))?Number(oe.monitorCount):void 0,requestedFps:Number(oe.requestedFps||0)||0,effectiveFps:Number(oe.effectiveFps||0)||0,captureAverageMs:Number(oe.captureAverageMs||0)||0,captureP95Ms:Number(oe.captureP95Ms||0)||0,slowFrameCount:Number(oe.slowFrameCount||0)||0,captureHelperRestarts:Number(oe.captureHelperRestarts||0)||0,capturedAt:String(oe.capturedAt||""),receivedAt:String(oe.receivedAt||""),hubPacketAt:oe.hubPacketAt?String(oe.hubPacketAt):void 0,hubPacketEpochMs:Number.isFinite(Number(oe.hubPacketEpochMs))?Number(oe.hubPacketEpochMs):void 0,browserReceivedEpochMs:we,byteLength:Number(oe.byteLength||De.byteLength),contentHash:oe.contentHash?String(oe.contentHash):void 0,captureMs:Number(oe.captureMs||0)||0,captureStageMs:Number(oe.captureStageMs||0)||0,convertMs:Number(oe.convertMs||0)||0,compressMs:Number(oe.compressMs||0)||0,captureSourceSerial:Number(oe.captureSourceSerial||0)||0,captureSourceSkipped:Number(oe.captureSourceSkipped||0)||0,deltaTileSize:Number(oe.deltaTileSize||0)||0,deltaTileCount:Number(oe.deltaTileCount||0)||0,deltaVisualTileCount:Number(oe.deltaVisualTileCount||0)||0,deltaRefreshTileCount:Number(oe.deltaRefreshTileCount||0)||0,deltaTotalTiles:Number(oe.deltaTotalTiles||0)||0,payload:De};if(!at.deviceId)return;const ne={streamId:he.lastFrameStreamId,commandId:he.lastFrameCommandId,order:he.lastFrameOrder},pe=Number(at.streamFrameSeq||at.frameSeq||0),Me=!!ne.commandId&&!!at.commandId,V=ne.streamId===at.streamId&&(!Me||ne.commandId===at.commandId),ae=ne.order;if(V&&ae>=pe&&(ae===pe||Me))return;he.lastFrameStreamId=at.streamId,he.lastFrameCommandId=at.commandId||"",he.lastFrameOrder=pe;const ke=F.current;ke.totalFrames+=1,ke.totalBytes+=De.byteLength,ke.sampleFrames+=1,ke.sampleBytes+=De.byteLength;const be=!b.current.has(at.deviceId);b.current.set(at.deviceId,at),be&&d(new Map(b.current)),U.current?.(at)},[]);f.useEffect(()=>{const J=window.setInterval(()=>{const he=performance.now(),we=F.current,je=Math.max(1,he-we.sampleStartedAt);y({totalFrames:we.totalFrames,totalBytes:we.totalBytes,framesPerSecond:we.sampleFrames*1e3/je,bytesPerSecond:we.sampleBytes*1e3/je,sampleMs:je,lastUpdatedAt:Date.now()}),d(new Map(b.current)),we.sampleFrames=0,we.sampleBytes=0,we.sampleStartedAt=he},2e3);return()=>{window.clearInterval(J)}},[]),f.useEffect(()=>{const J=P?P.split(",").filter(Boolean):[],he=new Set(J),we=performance.now();for(const[je,Oe]of j.current.entries())he.has(je)||(Y(Oe,"livedesk-device-unsubscribed"),j.current.delete(je),M.current.delete(je),b.current.delete(je));if(J.length===0){for(const je of j.current.values())Y(je,"livedesk-no-devices");j.current.clear(),M.current.clear(),b.current=new Map,d(new Map),g(""),F.current={totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0},y(dc),$();return}F.current.sampleStartedAt<=0&&(F.current.sampleStartedAt=we,y({...dc,lastUpdatedAt:Date.now()}));for(const je of J){const Oe=r.monitorSelections?.[je],He=Number.isFinite(Number(Oe))?{[je]:Number(Oe)}:{},oe={type:"subscribe",deviceIds:[je],autoStartLive:a,fps:L,maxWidth:I,maxHeight:de,quality:W,mode:ue,frameMode:ue,streamPurpose:Z,monitorSelections:He},Ze=JSON.stringify(oe),De=j.current.get(je);if(De){const Me=De.socket.readyState===WebSocket.CONNECTING||De.socket.readyState===WebSocket.OPEN;if(De.payloadKey===Ze&&Me&&!De.disposed)continue}const at=De&&(De.socket.readyState===WebSocket.CONNECTING||De.socket.readyState===WebSocket.OPEN)&&!De.disposed?De.handoffFrom&&!De.handoffCompleted?De.handoffFrom:De:void 0;De&&De!==at&&Y(De,"livedesk-subscription-superseded");const ne=new WebSocket(jd(`/api/remote/frames/ws?devices=${encodeURIComponent(je)}`,i));ne.binaryType="arraybuffer";const pe={socket:ne,payload:oe,payloadKey:Ze,generation:k.current+1,disposed:!1,handoffFrom:at,handoffCompleted:!1,lastFrameStreamId:"",lastFrameCommandId:"",lastFrameOrder:-1};k.current=pe.generation,j.current.set(je,pe),ne.addEventListener("open",()=>{if(pe.disposed||j.current.get(je)!==pe){Y(pe,"livedesk-stale-frame-socket");return}g("");const Me=R.current,V=Me.enabled&&(!Me.token||M.current.get(je)!==Me.token);ne.send(JSON.stringify({...pe.payload,forceRestart:V,restartReason:V?Me.reason:"",restartToken:V?Me.token:""})),V&&Me.token&&M.current.set(je,Me.token);const ae=pe.handoffFrom;pe.handoffFrom=void 0,pe.handoffCompleted=!0,ae&&!ae.disposed&&Y(ae,"livedesk-subscription-replaced"),$()}),ne.addEventListener("message",Me=>{if(pe.disposed||j.current.get(je)!==pe)return;if(typeof Me.data=="string"){try{const ae=JSON.parse(Me.data);if(ae?.type==="RemoteFrameSubscriptionError")g(String(ae.error||"control-stream-start-failed"));else if(ae?.type==="RemoteFrameLiveAutoStart"){const be=(Array.isArray(ae.skipped)?ae.skipped:[]).find(st=>st?.deviceId===je);be?g(String(be.reason||"control-stream-start-failed")):Array.isArray(ae.started)&&ae.started.some(st=>st?.deviceId===je)&&g("")}}catch{}return}const V=Me.data instanceof ArrayBuffer?Me.data:null;V&&(g(""),ie(V,pe))}),ne.addEventListener("error",()=>{pe.disposed||j.current.get(je)!==pe||(g("frame-socket-error"),p("error"))}),ne.addEventListener("close",()=>{const Me=!pe.disposed;pe.disposed=!0;const V=j.current.get(je);let ae=!1;if(V===pe){const ke=pe.handoffFrom;pe.handoffFrom=void 0,ke&&!ke.disposed&&(ke.socket.readyState===WebSocket.CONNECTING||ke.socket.readyState===WebSocket.OPEN)?(j.current.set(je,ke),ae=!0):j.current.delete(je)}if($(),Me&&V===pe&&!ae){const ke=window.setTimeout(()=>{C.current.delete(ke),E(be=>be+1)},750);C.current.add(ke)}})}$()},[a,Y,P,L,ue,ie,i,de,I,_,r.monitorSelections,W,A,Z,$]),f.useEffect(()=>{if(!le||!ce)return;const J=P?P.split(",").filter(Boolean):[];for(const he of J){if(M.current.get(he)===ce)continue;const we=j.current.get(he);!we||!H(he,we,Q,ce)||M.current.set(he,ce)}},[P,le,ce,Q,H]),f.useEffect(()=>()=>{for(const J of j.current.values())Y(J,"livedesk-hook-unmount");j.current.clear();for(const J of C.current)window.clearTimeout(J);C.current.clear()},[Y]);const xe=f.useCallback((J,he="browser-stale")=>{const we=Array.isArray(J)&&J.length>0?J:P.split(",").filter(Boolean);if(we.length===0)return!1;let je=!1;for(const Oe of we){const He=j.current.get(Oe);!He||He.socket.readyState!==WebSocket.OPEN||(je=H(Oe,He,he,`${Date.now()}-${Math.random().toString(36).slice(2)}`)||je)}return je},[P,H]),D=f.useCallback((J,he="browser-reconnect")=>{const we=Array.isArray(J)&&J.length>0?J:P.split(",").filter(Boolean);if(we.length===0)return!1;let je=!1;for(const Oe of we){const He=j.current.get(Oe);He&&(Y(He,`livedesk-${he}`),j.current.delete(Oe),M.current.delete(Oe),b.current.delete(Oe),je=!0)}return je&&d(new Map(b.current)),E(Oe=>Oe+1),$(),!0},[Y,P,$]);return{frames:c,state:h,error:v,stats:w,restartLive:xe,reconnectLive:D}}function k0(n,a,i=Cn,r={}){const[c,d]=f.useState(null),[h,p]=f.useState(null),[v,g]=f.useState("idle"),[w,y]=f.useState(dc),b=f.useRef(null),j=f.useRef(r.onFrame),k=f.useRef(null),M=f.useRef(0),R=f.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),C=f.useMemo(()=>[...new Set(n.filter(Boolean))].join(","),[n]),A=f.useMemo(()=>[...new Set((r.captureDeviceIds||n).filter(Boolean))].join(","),[n,r.captureDeviceIds]),E=f.useMemo(()=>JSON.stringify(r.monitorSelections||{}),[r.monitorSelections]),U=f.useMemo(()=>({deviceIds:C.split(",").filter(Boolean),captureDeviceIds:A.split(",").filter(Boolean),fps:Number(r.fps||20),width:Number(r.width||1920),height:Number(r.height||1080),tileWidth:Number(r.tileWidth||320),tileHeight:Number(r.tileHeight||180),monitorSelections:r.monitorSelections||{}}),[A,C,E,r.fps,r.height,r.monitorSelections,r.tileHeight,r.tileWidth,r.width]),F=f.useMemo(()=>JSON.stringify(U),[U]),P=f.useRef(U);P.current=U;const L=a&&U.deviceIds.length>0,I=f.useCallback(W=>W.readyState!==WebSocket.OPEN?!1:(W.send(JSON.stringify({type:"configure",...P.current})),!0),[]);f.useEffect(()=>{j.current=r.onFrame},[r.onFrame]),f.useEffect(()=>{const W=window.setInterval(()=>{const ue=R.current,Z=performance.now(),le=Math.max(1,Z-ue.sampleStartedAt);y({totalFrames:ue.totalFrames,totalBytes:ue.totalBytes,framesPerSecond:ue.sampleFrames*1e3/le,bytesPerSecond:ue.sampleBytes*1e3/le,sampleMs:le,lastUpdatedAt:Date.now()});const ce=k.current;ce&&ce.frameSeq!==M.current&&(M.current=ce.frameSeq,d(ce)),ue.sampleFrames=0,ue.sampleBytes=0,ue.sampleStartedAt=Z},1e3);return()=>window.clearInterval(W)},[]),f.useEffect(()=>{if(!L){b.current?.close(),b.current=null,d(null),k.current=null,M.current=0,p(null),g("idle"),y(dc);return}let W=!1,ue=0;const Z=()=>{if(W)return;const le=new WebSocket(jd("/api/remote/atlas/ws",i));le.binaryType="arraybuffer",b.current=le,g("connecting"),le.addEventListener("open",()=>{R.current.sampleStartedAt=performance.now(),g("open"),I(le)}),le.addEventListener("message",ce=>{if(typeof ce.data=="string"){try{const _=JSON.parse(ce.data);_?.type==="Mode4AtlasLayout"&&p({layoutVersion:Number(_.layoutVersion||0),width:Number(_.width||1920),height:Number(_.height||1080),columns:Number(_.columns||1),rows:Number(_.rows||1),tiles:Array.isArray(_.tiles)?_.tiles:[]})}catch{}return}const Q=ce.data instanceof ArrayBuffer?ce.data:null;if(!(!Q||Q.byteLength<5))try{const _=Date.now(),$=new DataView(Q).getUint32(0,!1);if($<=0||$+4>Q.byteLength)return;const H=JSON.parse(new TextDecoder().decode(new Uint8Array(Q,4,$))),ie=Q.slice(4+$),xe={deviceId:String(H.deviceId||"__livedesk_mode4_atlas__"),kind:"live",frameSeq:Number(H.frameSeq||0),streamFrameSeq:Number(H.streamFrameSeq||0)||void 0,streamId:String(H.streamId||"mode4-atlas"),commandId:H.commandId?String(H.commandId):void 0,width:Number(H.width||1920),height:Number(H.height||1080),sourceWidth:Number(H.sourceWidth||H.width||1920),sourceHeight:Number(H.sourceHeight||H.height||1080),mimeType:String(H.mimeType||"video/h264"),mode:String(H.mode||"mode4-h264-atlas"),frameMode:String(H.frameMode||"mode4-h264-atlas"),frameProfile:String(H.frameProfile||"mode4-h264-atlas-v1"),encoding:String(H.encoding||"video-atlas"),codec:String(H.codec||"h264"),compression:String(H.compression||"video/h264"),h264Format:String(H.h264Format||"annexb"),isKeyFrame:H.isKeyFrame===!0,chunkType:String(H.chunkType||""),timestampUs:Number(H.timestampUs||0),durationUs:Number(H.durationUs||0),hardwareEncoder:H.hardwareEncoder?String(H.hardwareEncoder):void 0,platformProfile:H.platformProfile?String(H.platformProfile):void 0,capturedAt:String(H.capturedAt||""),receivedAt:String(H.receivedAt||""),hubPacketAt:H.hubPacketAt?String(H.hubPacketAt):void 0,hubPacketEpochMs:Number(H.hubPacketEpochMs||0)||void 0,browserReceivedEpochMs:_,byteLength:ie.byteLength,layoutVersion:Number(H.layoutVersion||0),atlasComposeMs:Number(H.atlasComposeMs||0),atlasPoolStarved:Number(H.atlasPoolStarved||0),atlasReadyTiles:Number(H.atlasReadyTiles||0),atlasTileCount:Number(H.atlasTileCount||0),payload:ie},D=R.current;D.totalFrames+=1,D.totalBytes+=ie.byteLength,D.sampleFrames+=1,D.sampleBytes+=ie.byteLength,k.current=xe,M.current===0&&(M.current=xe.frameSeq,d(xe)),j.current?.(xe)}catch{}}),le.addEventListener("error",()=>g("error")),le.addEventListener("close",()=>{b.current===le&&(b.current=null),!W&&(g("closed"),ue=window.setTimeout(Z,1200))})};return Z(),()=>{W=!0,window.clearTimeout(ue),b.current?.close(),b.current=null}},[L,i,I]),f.useEffect(()=>{if(!L)return;const W=b.current;W&&I(W)},[F,L,I]);const de=f.useCallback(()=>{const W=b.current;return W?I(W):!1},[I]);return{frame:c,layout:h,state:v,stats:w,refreshInputs:de}}function M0(n,a=Cn){const i=f.useRef(null),r=f.useRef(0),c=f.useRef(0),d=f.useRef(new Map),[h,p]=f.useState("idle"),[v,g]=f.useState(""),[w,y]=f.useState(Yv),b=f.useRef({totalSent:0,totalDropped:0,sampleSent:0,sampleDropped:0,sampleStartedAt:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0});f.useEffect(()=>{if(!n){i.current?.close(),i.current=null,c.current=0,p("idle"),g(""),y(Yv);return}const k=new WebSocket(jd("/api/remote/input/ws",a));return i.current=k,b.current.sampleStartedAt=performance.now(),p("connecting"),g(""),k.addEventListener("open",()=>{g(""),p("open")}),k.addEventListener("message",M=>{if(typeof M.data=="string")try{const R=JSON.parse(M.data);if(R?.type==="RemoteInputError"){g(String(R.error||R.result?.error||"Remote input failed.")),p("error");return}if(R?.type!=="RemoteInputApplied")return;const C=Number(R.inputSeq||0),A=d.current.get(C);A!==void 0&&(b.current.lastRoundTripMs=Math.max(0,performance.now()-A),d.current.delete(C)),b.current.lastInputSeq=C,b.current.lastAgentApplyMs=Math.max(0,Number(R.agentApplyMs||0))}catch{}}),k.addEventListener("close",()=>p("closed")),k.addEventListener("error",()=>p("error")),()=>{k.close(),d.current.clear(),i.current===k&&(i.current=null)}},[n,a]),f.useEffect(()=>{if(!n)return;const k=window.setInterval(()=>{const M=performance.now(),R=b.current,C=Math.max(1,M-R.sampleStartedAt);y({totalSent:R.totalSent,totalDropped:R.totalDropped,sentPerSecond:R.sampleSent*1e3/C,droppedPerSecond:R.sampleDropped*1e3/C,bufferedAmount:i.current?.bufferedAmount||0,lastInputType:R.lastInputType,lastInputSeq:R.lastInputSeq,lastRoundTripMs:R.lastRoundTripMs,lastAgentApplyMs:R.lastAgentApplyMs,lastUpdatedAt:Date.now()}),R.sampleSent=0,R.sampleDropped=0,R.sampleStartedAt=M},1e3);return()=>window.clearInterval(k)},[n]);const j=f.useCallback((k,M)=>{const R=i.current;if(!R||R.readyState!==WebSocket.OPEN||!k)return!1;const C=String(M.type||"").toLowerCase(),A=C==="pointermove",U=A||C==="wheel",F=b.current;if(A&&R.bufferedAmount>b0)return F.totalDropped+=1,F.sampleDropped+=1,F.lastInputType="pointermove-drop",!1;const P=r.current+1;r.current=P;const L=Date.now(),I=!U||P-c.current>=C0;for(I&&(d.current.set(P,performance.now()),U&&(c.current=P)),A||Sy.set(k,{inputSeq:P,inputType:C||"input",sentAt:performance.now()});d.current.size>256;){const de=d.current.keys().next().value;if(de===void 0)break;d.current.delete(de)}return R.send(JSON.stringify({type:"input",requestId:U?"":crypto.randomUUID(),fireAndForget:U,deviceId:k,input:{...M,inputSeq:P,requestAck:I,issuedAtEpochMs:L,issuedAt:new Date(L).toISOString()}})),F.totalSent+=1,F.sampleSent+=1,F.lastInputType=C||"input",!0},[]);return{state:h,sendInput:j,stats:w,error:v}}function A0(n){const a=String(n||"").toLowerCase();return a.includes("audio/pcm")||a.includes("audio/l16")||a.includes("f32le")||a.includes("s16le")}const Hu={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},N0=.08,T0=.25,R0=.02,Qv=300,E0=4,Uu=1500,Am=5e3,D0=2e3,L0=1e4,$u=[0,1e3,3e3];function Xv(n){const a=Date.parse(String(n||""));return Number.isFinite(a)?Math.max(0,Date.now()-a):0}function _0(n,a,i){const r=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(),h=d.includes("s16le")||d.includes("audio/l16"),p=h?2:4,v=Math.floor(i.byteLength/p),g=Math.floor(v/r),w=n.createBuffer(r,g,c),y=new DataView(i);for(let b=0;b<r;b+=1){const j=w.getChannelData(b);for(let k=0;k<g;k+=1){const R=(k*r+b)*p;j[k]=h?Math.max(-1,Math.min(1,y.getInt16(R,!0)/32768)):Math.max(-1,Math.min(1,y.getFloat32(R,!0)))}}return w}function z0(n,a,i=Cn){const r=f.useRef(null),c=f.useRef(0),[d,h]=f.useState("idle"),[p,v]=f.useState(null),[g,w]=f.useState(Hu),[y,b]=f.useState("");return f.useEffect(()=>{if(!a||!n){h("idle"),v(null),w(Hu),b("");return}h("connecting"),v(null),w(Hu),b("");const j=window.AudioContext||window.webkitAudioContext;if(!j){h("unsupported"),w(Hu),b("Audio playback is not supported in this browser.");return}const k=new j;r.current=k,c.current=k.currentTime;const M=new WebSocket(jd("/api/remote/audio/ws?devices="+encodeURIComponent(n),i));M.binaryType="arraybuffer";const R=new Set,C={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(k.state),stalledCount:0,automaticRestarts:0,activeStreamId:"",lastCaptureStatusAt:0,lastPcmAtEpochMs:0};let A=!1,E=0,U=!1,F=0,P=0;const L=(_=!0)=>{for(const Y of R)try{Y.stop()}catch{}R.clear(),_&&(c.current=k.currentTime+N0)},I=()=>{C.audioContextState=String(k.state),!A&&(C.audioContextState==="suspended"||C.audioContextState==="interrupted"?h("suspended"):C.audioContextState==="closed"&&(h("error"),b("The browser audio context is closed. Toggle Remote Audio off and on to recover.")))},de=async()=>{if(A||String(k.state)==="closed")return!1;try{if(String(k.state)!=="running"&&await k.resume(),C.audioContextState=String(k.state),!A&&!U&&C.audioContextState==="running"){const _=C.lastAcceptedAt>0&&performance.now()-C.lastAcceptedAt<=Uu,Y=C.lastCaptureStatusAt>0&&performance.now()-C.lastCaptureStatusAt<=Am&&C.captureAlive&&C.helperAlive;h(_?"playing":Y?"silent":"open")}return C.audioContextState==="running"}catch(_){return A||(h("suspended"),b(_ instanceof Error?"Audio playback is suspended: "+_.message:"Audio playback is suspended.")),!1}},W=async()=>{if(A||U||M.readyState!==WebSocket.OPEN)return;if(F>=$u.length){h("error"),b("Remote audio stopped sending frames. Toggle Audio off and on to retry.");return}const _=F;F+=1,U=!0,C.stalledCount+=1,C.automaticRestarts+=1,h("reconnecting");try{const Y=await Be("/api/remote/devices/"+encodeURIComponent(n)+"/audio/stop",{method:"POST",body:JSON.stringify({})},i);if(Y.ok===!1)throw new Error(Y.error||"Remote audio stop failed.");if(A)return;const $=await Be("/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})},i);if($.ok===!1)throw new Error($.error||"Remote audio start failed.");const H=performance.now();E=H,C.lastPacketAt=H,C.lastAcceptedAt=0,C.lastCaptureStatusAt=0,C.lastPcmAtEpochMs=0,C.captureAlive=!1,C.helperAlive=!1,C.silentForMs=0,P=H+($u[_+1]??3e3),b(""),A||h("open")}catch(Y){A||(P=performance.now()+($u[_+1]??3e3),h("error"),b(Y instanceof Error?"Remote audio restart failed: "+Y.message:"Remote audio restart failed."))}finally{U=!1}},ue=()=>{C.drops+=1},Z=window.setInterval(()=>{if(A)return;const _=performance.now(),Y=C.lastPacketAt>0?Math.max(0,_-C.lastPacketAt):E>0?Math.max(0,_-E):0,$=C.lastAcceptedAt>0?Math.max(0,_-C.lastAcceptedAt):0,H=C.lastCaptureStatusAt>0?Math.max(0,_-C.lastCaptureStatusAt):0,ie=M.readyState===WebSocket.OPEN,xe=C.lastCaptureStatusAt>0,D=xe&&H<=Am,J=xe&&(!C.captureAlive||!C.helperAlive)&&H>D0,he=xe&&H>Am,we=!xe&&E>0&&_-E>L0,je=E>0&&(C.lastAcceptedAt<=0?_-E>Uu:$>Uu);ie&&E>0&&(J||he||we)?F>=$u.length&&!U?(h("error"),b("Remote audio capture heartbeat stopped. Toggle Audio off and on to retry.")):!U&&_>=P?W():U||h("stalled"):ie&&je&&!U&&C.audioContextState!=="suspended"&&C.audioContextState!=="interrupted"&&h(D?"silent":"open"),w({queuedMs:Math.max(0,(c.current-k.currentTime)*1e3),browserAgeMs:C.browserAgeMs,captureAgeMs:C.captureAgeMs,captureStatusAgeMs:H,silentForMs:C.silentForMs,captureAlive:C.captureAlive,helperAlive:C.helperAlive,captureRestartCount:C.captureRestartCount,localProcessingAgeMs:C.localProcessingAgeMs,lastPacketAgeMs:Y,lastAcceptedAgeMs:$,framesReceived:C.framesReceived,drops:C.drops,resyncs:C.resyncs,pendingDecodes:C.pendingDecodes,lastFrameSeq:C.lastFrameSeq,audioContextState:C.audioContextState,stalledCount:C.stalledCount,automaticRestarts:C.automaticRestarts,lastUpdatedAt:Date.now()})},250),le=()=>{I(),(String(k.state)==="suspended"||String(k.state)==="interrupted")&&de()},ce=()=>{document.visibilityState==="visible"&&de()},Q=()=>{de()};return k.addEventListener("statechange",le),document.addEventListener("visibilitychange",ce),window.addEventListener("pageshow",Q),window.addEventListener("pointerdown",Q),window.addEventListener("keydown",Q),h("connecting"),b(""),I(),M.addEventListener("open",()=>{A||(E=performance.now(),C.lastPacketAt=E,C.lastAcceptedAt=0,C.lastCaptureStatusAt=0,C.lastPcmAtEpochMs=0,C.captureAlive=!1,C.helperAlive=!1,C.silentForMs=0,h("open"),M.send(JSON.stringify({type:"subscribe",deviceIds:[n]})),de())}),M.addEventListener("message",_=>{if(typeof _.data=="string")return;const Y=_.data instanceof ArrayBuffer?_.data:null;if(!Y||Y.byteLength<5)return;const $=performance.now();C.lastPacketAt=$,(async()=>{try{const ie=new DataView(Y).getUint32(0,!1);if(ie<=0||ie+4>Y.byteLength){ue();return}const xe=new Uint8Array(Y.slice(4,4+ie)),D=JSON.parse(new TextDecoder().decode(xe)),J=Y.slice(4+ie),he=String(D.frameKind||D.kind||"").toLowerCase();if(D.type==="remote.audio.status"||he==="audio-status"){if(C.lastCaptureStatusAt=$,C.captureAlive=D.captureAlive===!0,C.helperAlive=D.helperAlive===!0,C.captureRestartCount=Math.max(0,Number(D.restartCount||0)||0),C.lastPcmAtEpochMs=Math.max(0,Number(D.lastPcmAtEpochMs||0)||0),C.silentForMs=Math.max(0,Number(D.silentForMs||0)||0),C.captureAgeMs=C.lastPcmAtEpochMs>0?Math.max(0,Date.now()-C.lastPcmAtEpochMs):C.silentForMs,C.captureAlive&&C.helperAlive){if(F=0,P=0,!U){b("");const je=String(k.state)==="running",Oe=C.lastAcceptedAt>0&&performance.now()-C.lastAcceptedAt<=Uu;h(je?Oe?"playing":"silent":"suspended")}}else U||h("stalled");return}const we={deviceId:String(D.deviceId||""),frameSeq:Number(D.frameSeq||0),streamId:String(D.streamId||""),mimeType:String(D.mimeType||"audio/webm;codecs=opus"),sampleRate:Number(D.sampleRate||48e3),channels:Number(D.channels||2),capturedAt:String(D.capturedAt||""),receivedAt:String(D.receivedAt||""),byteLength:Number(D.byteLength||J.byteLength),payload:J};if(!we.deviceId||A)return;if(performance.now()-$>Qv){ue();return}if(C.pendingDecodes>=E0){ue();return}C.pendingDecodes+=1;try{const je=A0(we.mimeType)?_0(k,we,J):await k.decodeAudioData(J.slice(0));if(C.localProcessingAgeMs=Math.max(0,performance.now()-$),A)return;if(C.localProcessingAgeMs>Qv){ue();return}if(we.frameSeq>0&&we.frameSeq<=C.lastFrameSeq){ue();return}if(C.activeStreamId&&we.streamId!==C.activeStreamId&&we.frameSeq<=C.lastFrameSeq){ue();return}we.streamId&&we.streamId!==C.activeStreamId&&(C.activeStreamId=we.streamId,C.lastFrameSeq=0,L());const Oe=k.currentTime;Math.max(0,c.current-Oe)>T0&&(L(),C.resyncs+=1);const oe=k.createBufferSource();oe.buffer=je,oe.connect(k.destination),R.add(oe),oe.onended=()=>{R.delete(oe),oe.onended=null};const Ze=Math.max(k.currentTime+R0,c.current);oe.start(Ze),c.current=Ze+je.duration,C.browserAgeMs=Xv(we.receivedAt),C.captureAgeMs=Xv(we.capturedAt),C.lastAcceptedAt=performance.now(),C.framesReceived+=1,C.lastFrameSeq=we.frameSeq,F=0,P=0,v(we),de();const De=String(k.state)==="running";De&&b(""),h(De?"playing":"suspended")}finally{C.pendingDecodes=Math.max(0,C.pendingDecodes-1)}}catch(H){A||(h("error"),b(H instanceof Error?H.message:String(H)))}})()}),M.addEventListener("error",()=>{A||(h("error"),b("Remote audio WebSocket error."))}),M.addEventListener("close",()=>{A||h("closed")}),()=>{A=!0,window.clearInterval(Z),k.removeEventListener("statechange",le),document.removeEventListener("visibilitychange",ce),window.removeEventListener("pageshow",Q),window.removeEventListener("pointerdown",Q),window.removeEventListener("keydown",Q),L(!1),M.close(),k.close().catch(()=>{}),r.current===k&&(r.current=null)}},[n,a,i]),{state:d,lastFrame:p,stats:g,error:y}}const sh={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}}},O0=[{id:"connection",label:"Connection",icon:lc},{id:"security",label:"Security",icon:Sn},{id:"control",label:"Control",icon:an},{id:"wall",label:"Wall",icon:pc},{id:"files-audio",label:"Files & Audio",icon:Gr},{id:"agent",label:"Agent",icon:Vi},{id:"advanced",label:"Advanced",icon:vh}];function Bi(n,a){return n?.settings?.[a]||sh.settings[a]}function et({icon:n,title:a,description:i,children:r,disabled:c=!1,recommended:d=!1}){return l.jsxs("div",{className:`product-setting-row ${c?"disabled":""}`,children:[l.jsx("div",{className:"product-setting-control",children:r}),n&&l.jsx("span",{className:"product-setting-icon",children:l.jsx(n,{size:17})}),l.jsxs("div",{className:"product-setting-copy",children:[l.jsx("strong",{children:a}),d&&l.jsx("em",{children:"Recommended"}),l.jsx("small",{children:i})]})]})}function ft({checked:n,onChange:a,disabled:i=!1,label:r}){return l.jsxs("label",{className:"product-switch",children:[l.jsx("input",{"aria-label":r,type:"checkbox",checked:n,disabled:i,onChange:c=>a(c.target.checked)}),l.jsx("span",{})]})}function xl({value:n,onChange:a,options:i,disabled:r=!1,label:c}){return l.jsx("select",{"aria-label":c,value:String(n),disabled:r,onChange:d=>a(d.target.value),children:i.map(([d,h])=>l.jsx("option",{value:d,children:h},d))})}function I0({hubUrl:n="",initialTab:a="connection",pin:i,wall:r,control:c,agent:d,advancedExtras:h,captureGallery:p}){const[v,g]=f.useState(a),[w,y]=f.useState(null),[b,j]=f.useState("loading"),[k,M]=f.useState("");f.useEffect(()=>{let $=!0;return j("loading"),Be("/api/settings",void 0,n).then(H=>{$&&(y({revision:Number(H.revision||0),updatedAt:H.updatedAt,settings:H.settings}),j("saved"))}).catch(H=>{$&&(M(H instanceof Error?H.message:String(H)),y(sh),j("failed"))}),()=>{$=!1}},[n]);const R=async($,H,ie)=>{const xe=w||sh,D=xe,J={...xe,settings:{...xe.settings,[$]:{...Bi(xe,$),[H]:ie}}};y(J),j("saving"),M("");try{const he=await Be("/api/settings",{method:"PATCH",body:JSON.stringify({revision:xe.revision,[$]:{[H]:ie}})},n);y({revision:he.revision,updatedAt:he.updatedAt,settings:he.settings}),j("saved")}catch(he){y(D),j("failed"),M(he instanceof Error?he.message:String(he))}},C=($,H)=>ie=>{R($,H,ie)},A=Bi(w,"security"),E=Bi(w,"connection"),U=Bi(w,"control"),F=Bi(w,"wall"),P=Bi(w,"filesAudio"),L=Bi(w,"agent"),I=f.useMemo(()=>A.allowInternetConnections===!1?{label:"Local only",tone:"local",detail:"Internet connections are disabled."}:A.requireEncryptedConnections&&A.requireNewDeviceApproval&&A.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."},[A]),de=`settings-panel-${v}`,W=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"product-settings-hero",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"settings-eyebrow",children:[l.jsx(lc,{size:14})," Connection"]}),l.jsx("h2",{children:"Connect a device"}),l.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."})]}),l.jsxs("div",{className:"product-save-state",role:"status",children:[l.jsx(sy,{size:14})," ",b==="saving"?"Saving":b==="failed"?"Failed":b==="loading"?"Loading":"Saved"]})]}),i,l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Connection behavior"}),l.jsx("h3",{children:"New device access"})]}),l.jsx(ic,{size:20})]}),l.jsx(et,{icon:ic,title:"Use PIN to add new devices",description:"Allow temporary PIN pairing from the client.",recommended:!0,children:l.jsx(ft,{checked:!!E.usePinToAddDevices,onChange:C("connection","usePinToAddDevices"),label:"Use PIN to add new devices"})}),l.jsx(et,{icon:Sn,title:"Approve new devices on this Hub",description:"Ask for approval before an unfamiliar computer becomes trusted.",children:l.jsx(ft,{checked:!!E.approveNewDevices,onChange:C("connection","approveNewDevices"),label:"Approve new devices"})}),l.jsx(et,{icon:nn,title:"Show connection notifications",description:"Show a short notice when a computer connects or leaves.",children:l.jsx(ft,{checked:!!E.showConnectionNotifications,onChange:C("connection","showConnectionNotifications"),label:"Show connection notifications"})})]})]}),ue=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:`security-status-card ${I.tone}`,children:[l.jsxs("div",{children:[l.jsx("span",{children:"Security status"}),l.jsx("strong",{children:I.label}),l.jsx("small",{children:I.detail})]}),l.jsx(Sn,{size:28})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Access mode"}),l.jsx("h3",{children:"Who may use this Hub?"})]}),l.jsx(hc,{size:20})]}),l.jsx(et,{icon:Sn,title:"Access mode",description:"Choose the default boundary for remote sessions.",recommended:!0,children:l.jsx(xl,{value:String(A.accessMode),onChange:C("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"]]})}),l.jsx(et,{icon:lc,title:"Require encrypted connections",description:"External connections cannot disable this protection.",recommended:!0,children:l.jsx(ft,{checked:!!A.requireEncryptedConnections,onChange:C("security","requireEncryptedConnections"),label:"Require encrypted connections"})}),l.jsx(et,{icon:lc,title:"Allow internet connections",description:"Keep off unless you intentionally expose this Hub beyond the LAN.",children:l.jsx(ft,{checked:!!A.allowInternetConnections,onChange:C("security","allowInternetConnections"),label:"Allow internet connections"})}),l.jsx(et,{icon:an,title:"Allow LAN connections",description:"Permit connections from the local network.",children:l.jsx(ft,{checked:!!A.allowLanConnections,onChange:C("security","allowLanConnections"),label:"Allow LAN connections"})}),l.jsx(et,{icon:Sn,title:"Require approval for new devices",description:"New computers must be approved before remote access is granted.",children:l.jsx(ft,{checked:!!A.requireNewDeviceApproval,onChange:C("security","requireNewDeviceApproval"),label:"Require approval for new devices"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Session protection"}),l.jsx("h3",{children:"End sessions safely"})]}),l.jsx(nn,{size:20})]}),l.jsx(et,{icon:an,title:"Show an indicator while Control is active",description:"Make active remote control visible on the local computer.",children:l.jsx(ft,{checked:!!A.visibleControlIndicator,onChange:C("security","visibleControlIndicator"),label:"Show Control indicator"})}),l.jsx(et,{icon:hc,title:"Lock the remote computer when Control ends",description:"Protect the local screen after a Control session.",children:l.jsx(ft,{checked:!!A.lockOnControlEnd,onChange:C("security","lockOnControlEnd"),label:"Lock after Control ends"})}),l.jsx(et,{icon:nn,title:"Disconnect idle Control sessions",description:"Automatically close inactive Control sessions.",children:l.jsx(ft,{checked:!!A.disconnectIdleControlSessions,onChange:C("security","disconnectIdleControlSessions"),label:"Disconnect idle sessions"})}),l.jsx(et,{icon:nn,title:"Idle timeout",description:"Time before an inactive Control session closes.",disabled:!A.disconnectIdleControlSessions,children:l.jsx(xl,{value:Number(A.idleControlMinutes),onChange:$=>C("security","idleControlMinutes")(Number($)),disabled:!A.disconnectIdleControlSessions,label:"Idle timeout",options:[["5","5 minutes"],["15","15 minutes"],["30","30 minutes"],["60","1 hour"],["1440","Never"]]})})]})]}),Z=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Remote use"}),l.jsx("h3",{children:"What can a connected user do?"})]}),l.jsx(an,{size:20})]}),l.jsx(et,{icon:an,title:"Keyboard and mouse control",description:"Allow the Hub to send keyboard and pointer input.",recommended:!0,children:l.jsx(ft,{checked:!!U.allowKeyboardMouse,onChange:C("control","allowKeyboardMouse"),label:"Keyboard and mouse control"})}),l.jsx(et,{icon:Ub,title:"System shortcuts",description:"Allow shortcut keys such as Alt-Tab and the system key.",children:l.jsx(ft,{checked:!!U.allowSystemShortcuts,onChange:C("control","allowSystemShortcuts"),label:"System shortcuts"})}),l.jsx(et,{icon:ic,title:"Clipboard text sharing",description:"Share plain text through the remote session.",children:l.jsx(ft,{checked:!!U.allowClipboardText,onChange:C("control","allowClipboardText"),label:"Clipboard text sharing"})}),l.jsx(et,{icon:nn,title:"Remote restart",description:"Allow restart requests from Control.",disabled:!U.allowKeyboardMouse,children:l.jsx(ft,{checked:!!U.allowRemoteRestart,onChange:C("control","allowRemoteRestart"),disabled:!U.allowKeyboardMouse,label:"Remote restart"})}),l.jsx(et,{icon:an,title:"Switching monitors",description:"Allow the viewer to select another connected display.",children:l.jsx(ft,{checked:!!U.allowSwitchingMonitors,onChange:C("control","allowSwitchingMonitors"),label:"Switching monitors"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Session behavior"}),l.jsx("h3",{children:"Make Control predictable"})]}),l.jsx(Gn,{size:20})]}),l.jsx(et,{icon:an,title:"Open Control on double-click",description:"Double-clicking a Wall tile opens its Control view.",children:l.jsx(ft,{checked:!!U.openControlOnDoubleClick,onChange:C("control","openControlOnDoubleClick"),label:"Open Control on double-click"})}),l.jsx(et,{icon:nn,title:"Start audio with Control",description:"Keep audio muted by default for new sessions.",children:l.jsx(ft,{checked:!!U.startRemoteAudioWithControl,onChange:C("control","startRemoteAudioWithControl"),label:"Start audio with Control"})}),l.jsx(et,{icon:an,title:"Fit remote screen to window",description:"Scale the remote display to the available Control area.",children:l.jsx(ft,{checked:!!U.fitRemoteScreen,onChange:C("control","fitRemoteScreen"),label:"Fit remote screen"})}),l.jsx(et,{icon:nn,title:"Keep Control ready between pages",description:"Faster reconnection for 1 minute.",recommended:!0,children:l.jsx(ft,{checked:!!U.keepControlReadyBetweenPages,onChange:C("control","keepControlReadyBetweenPages"),label:"Keep Control ready between pages"})})]})]}),le=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Performance mode"}),l.jsx("h3",{children:"Let LiveDesk choose the best path"})]}),l.jsx(pc,{size:20})]}),l.jsx(et,{icon:Vi,title:"Performance mode",description:"Automatic mode balances responsiveness and image quality.",recommended:!0,children:l.jsx(xl,{value:String(F.performanceMode),onChange:C("wall","performanceMode"),label:"Performance mode",options:[["auto","Auto"],["responsive","Prioritize responsiveness"],["quality","Prioritize image quality"],["custom","Custom"]]})}),l.jsx("p",{className:"settings-help",children:"Streaming details are available under Advanced for diagnostics and development."})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall behavior"}),l.jsx("h3",{children:"What should the Wall show?"})]}),l.jsx(nn,{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(([$,H,ie])=>l.jsx(et,{icon:an,title:H,description:ie,children:l.jsx(ft,{checked:!!F[$],onChange:C("wall",$),label:H})},$))]})]}),ce=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"File permissions"}),l.jsx("h3",{children:"Move files deliberately"})]}),l.jsx(Gr,{size:20})]}),l.jsx(et,{icon:Gr,title:"Allow file transfer",description:"Permit Hub-to-device file delivery.",recommended:!0,children:l.jsx(ft,{checked:!!P.allowFileTransfer,onChange:C("filesAudio","allowFileTransfer"),label:"Allow file transfer"})}),l.jsx(et,{icon:pc,title:"Allow folder sync",description:"Enable recurring folder synchronization.",disabled:!P.allowFileTransfer,children:l.jsx(ft,{checked:!!P.allowFolderSync,onChange:C("filesAudio","allowFolderSync"),disabled:!P.allowFileTransfer,label:"Allow folder sync"})}),l.jsx(et,{icon:Sn,title:"Ask before receiving files",description:"Require local confirmation before a transfer is written.",children:l.jsx(ft,{checked:!!P.askBeforeReceivingFiles,onChange:C("filesAudio","askBeforeReceivingFiles"),label:"Ask before receiving files"})}),l.jsx(et,{icon:Gr,title:"Allow overwrite",description:"Permit replacing an existing destination file.",children:l.jsx(ft,{checked:!!P.allowOverwrite,onChange:C("filesAudio","allowOverwrite"),label:"Allow overwrite"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Audio permissions"}),l.jsx("h3",{children:"Remote sound"})]}),l.jsx(nn,{size:20})]}),l.jsx(et,{icon:nn,title:"Allow remote audio",description:"Permit audio capture from connected computers.",recommended:!0,children:l.jsx(ft,{checked:!!P.allowRemoteAudio,onChange:C("filesAudio","allowRemoteAudio"),label:"Allow remote audio"})}),l.jsx(et,{icon:nn,title:"Start audio muted",description:"New audio sessions begin silent.",children:l.jsx(ft,{checked:!!P.startAudioMuted,onChange:C("filesAudio","startAudioMuted"),label:"Start audio muted"})}),l.jsx(et,{icon:nn,title:"Automatically recover audio",description:"Recover from temporary capture or transport stalls.",children:l.jsx(ft,{checked:!!P.automaticallyRecoverAudio,onChange:C("filesAudio","automaticallyRecoverAudio"),label:"Automatically recover audio"})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Capture defaults"}),l.jsx("h3",{children:"Screen recording"})]}),l.jsx(an,{size:20})]}),l.jsx(et,{icon:nn,title:"Keep a Last 30s buffer",description:"Keep recent video in memory only until you explicitly save it.",children:l.jsx(ft,{checked:!!P.rollingBufferEnabled,onChange:C("filesAudio","rollingBufferEnabled"),label:"Keep a Last 30s buffer"})}),l.jsx(et,{icon:nn,title:"Recording quality",description:"Choose the WebM bitrate profile.",children:l.jsx(xl,{value:String(P.recordingQuality),onChange:C("filesAudio","recordingQuality"),label:"Recording quality",options:[["standard","Standard"],["high","High"]]})}),l.jsx(et,{icon:nn,title:"Timelapse interval",description:"Capture one frame at the selected interval.",children:l.jsx(xl,{value:Number(P.timelapseIntervalSeconds),onChange:$=>C("filesAudio","timelapseIntervalSeconds")(Number($)),label:"Timelapse interval",options:[["5","5 seconds"],["10","10 seconds"],["30","30 seconds"],["60","60 seconds"]]})}),l.jsx(et,{icon:an,title:"Include remote cursor",description:"Include the cursor indicator when the source provides it.",children:l.jsx(ft,{checked:!!P.includeRemoteCursor,onChange:C("filesAudio","includeRemoteCursor"),label:"Include remote cursor"})}),l.jsx(et,{icon:Gr,title:"Capture save location",description:"Captures are stored inside the Hub capture library.",children:l.jsx(xl,{value:String(P.captureSaveLocation),onChange:C("filesAudio","captureSaveLocation"),label:"Capture save location",options:[[String(P.captureSaveLocation||"LiveDesk Captures"),"LiveDesk Captures"]]})}),l.jsx(et,{icon:Gr,title:"Automatic deletion",description:"Keep saved captures until you delete them.",children:l.jsx(xl,{value:String(P.captureAutoDelete),onChange:C("filesAudio","captureAutoDelete"),label:"Automatic deletion",options:[["never","Never"],["7-days","After 7 days"],["30-days","After 30 days"]]})})]}),p]}),Q=l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Agent safety"}),l.jsx("h3",{children:"AI workstation operations"})]}),l.jsx(Vi,{size:20})]}),l.jsx(et,{icon:Vi,title:"Enable AI Agent on devices",description:"Allow Agent runs to reach connected workstations.",recommended:!0,children:l.jsx(ft,{checked:!!L.enabled,onChange:C("agent","enabled"),label:"Enable AI Agent"})}),l.jsx(et,{icon:Sn,title:"Default permission mode",description:"Safe Auto keeps destructive operations behind approval.",children:l.jsx(xl,{value:String(L.defaultPermissionMode),onChange:C("agent","defaultPermissionMode"),label:"Default Agent permission mode",options:[["ask","Ask"],["safe-auto","Safe Auto"],["full-access","Full Access"],["custom","Custom"]]})}),l.jsx(et,{icon:Sn,title:"Ask before destructive operations",description:"Locked on for Safe Auto and destructive actions.",disabled:!L.enabled,children:l.jsx(ft,{checked:!!L.askBeforeDestructive,onChange:C("agent","askBeforeDestructive"),disabled:!L.enabled,label:"Ask before destructive operations"})}),l.jsx(et,{icon:nn,title:"Keep Agent audit history",description:"Retain an inspectable record of Agent runs.",children:l.jsx(ft,{checked:!!L.keepAuditHistory,onChange:C("agent","keepAuditHistory"),label:"Keep Agent audit history"})}),l.jsx(et,{icon:nn,title:"Stop Agent tasks after timeout",description:"Maximum runtime for one task.",children:l.jsx(xl,{value:Number(L.timeoutMinutes),onChange:$=>C("agent","timeoutMinutes")(Number($)),label:"Agent task timeout",options:[["1","1 minute"],["5","5 minutes"],["10","10 minutes"],["30","30 minutes"],["60","1 hour"]]})})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Detailed permissions"}),l.jsx("h3",{children:"Capabilities"})]}),l.jsx(Sn,{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(([$,H])=>l.jsx(et,{icon:Sn,title:H,description:$.includes("allowCommand")||$.includes("Installation")||$.includes("Power")?"Disabled by default for safety.":"Applied by the Hub and checked again by the Client.",children:l.jsx(ft,{checked:!!L[$],onChange:C("agent",$),label:H})},$))]}),l.jsx("p",{className:"settings-help",children:"The existing Codex runtime and audit controls remain available below in Advanced and the Agent diagnostics panel."})]}),Y=v==="connection"?W:v==="security"?ue:v==="control"?Z:v==="wall"?le:v==="files-audio"?ce:v==="agent"?l.jsxs(l.Fragment,{children:[Q,d]}):l.jsxs("div",{className:"settings-tab-content product-settings-content",children:[h,l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Developer controls"}),l.jsx("h3",{children:"Streaming and diagnostics"})]}),l.jsx(vh,{size:20})]}),l.jsx("p",{className:"settings-help",children:"Codec, frame rate, resolution, quality, Atlas layout, and decoder preferences are intentionally kept here."}),r,c]})]});return l.jsxs("section",{className:"settings-page",children:[l.jsx("div",{className:"settings-page-tabs",role:"tablist","aria-label":"LiveDesk settings",children:O0.map(({id:$,label:H,icon:ie})=>l.jsxs("button",{className:v===$?"active":"",id:`settings-tab-${$}`,role:"tab","aria-selected":v===$,"aria-controls":`settings-panel-${$}`,tabIndex:v===$?0:-1,onClick:()=>g($),type:"button",children:[l.jsx(ie,{size:16}),H]},$))}),k&&l.jsx("div",{className:"agent-settings-alert error",role:"alert",children:k}),l.jsx("section",{className:"settings-page-panel",id:de,role:"tabpanel","aria-labelledby":`settings-tab-${v}`,tabIndex:0,children:Y})]})}function B0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}function F0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}function H0({children:n}){return l.jsx("div",{className:"settings-tab-content",children:n})}const Cy={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 Zv(n){return{...Cy,...n||{}}}function U0({hubUrl:n}){const[a,i]=f.useState(Cy),[r,c]=f.useState(null),[d,h]=f.useState(""),[p,v]=f.useState(""),[g,w]=f.useState(""),[y,b]=f.useState("");f.useEffect(()=>{let I=!0;return Be("/api/settings/agent",void 0,n).then(de=>{I&&(c(de.settings),i(Zv(de.settings)))}).catch(de=>{I&&b(de instanceof Error?de.message:String(de))}),()=>{I=!1}},[n]);const j=(I,de)=>i(W=>({...W,[I]:de})),k=I=>{c(I),i(Zv(I))},M=async()=>{v("save"),b(""),w("");try{const I={...a};d.trim()&&(I.apiKey=d.trim());const de=await Be("/api/settings/agent",{method:"PUT",body:JSON.stringify(I)},n);k(de.settings),h(""),w("Agent settings saved.")}catch(I){b(I instanceof Error?I.message:String(I))}finally{v("")}},R=async()=>{v("reset"),b("");try{const I=await Be("/api/settings/agent/reset",{method:"POST",body:JSON.stringify({})},n);k(I.settings),w("Codex defaults restored.")}catch(I){b(I instanceof Error?I.message:String(I))}finally{v("")}},C=async()=>{v("test"),b(""),w("");try{const I=await Be("/api/settings/agent/test",{method:"POST",body:JSON.stringify({})},n),de=await Be("/api/settings/agent",void 0,n);k(de.settings),w(`Codex connection verified with ${I.connection?.modelName||"the configured model"}${I.connection?.latencyMs?` in ${I.connection.latencyMs} ms.`:"."}`)}catch(I){b(I instanceof Error?I.message:String(I))}finally{v("")}},A=async()=>{v("clear-key"),b("");try{const I=await Be("/api/settings/agent/api-key",{method:"DELETE"},n);k(I.settings),h(""),w("The optional OpenCode Go key was removed.")}catch(I){b(I instanceof Error?I.message:String(I))}finally{v("")}},E=r?.codexInstallation==="installed"&&r.codexAuth==="signed-in",U=r?.securityStatus,F=U?.state||"unavailable",P=F==="verified"?"Verified":F==="configured"?"Configured":"Unavailable",L=[["Codex home",U?.isolatedCodexHome],["Environment variables",U?.restrictedEnvironment],["LiveDesk MCP only",U?.livedeskMcpOnly],["Selected-device scope",U?.selectedDeviceScopeEnforced],["Fail-closed execution",U?.failClosed]];return l.jsxs("div",{className:"settings-tab-content agent-settings-content",children:[l.jsxs("header",{className:"agent-settings-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"settings-eyebrow",children:[l.jsx(Mv,{size:14})," Agent AI"]}),l.jsx("h2",{children:"Codex SDK"}),l.jsx("p",{children:"Codex owns the agent reasoning loop. LiveDesk keeps the existing task manager and exposes only safe, read-only workstation tools."})]}),l.jsxs("label",{className:"settings-toggle agent-enable-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.enabled,onChange:I=>j("enabled",I.target.checked)}),l.jsx("span",{children:"Enable Agent AI"})]})]}),y&&l.jsx("div",{className:"agent-settings-alert error",role:"alert",children:y}),g&&l.jsx("div",{className:"agent-settings-alert success",role:"status",children:g}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Provider"}),l.jsx("h3",{children:"Codex is the default"})]}),l.jsx(ic,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Agent provider"}),l.jsxs("select",{value:a.provider,onChange:I=>j("provider",I.target.value),children:[l.jsx("option",{value:"codex",children:"Codex SDK"}),l.jsx("option",{value:"opencode-go",children:"OpenCode Go (optional legacy)"})]})]}),l.jsxs("div",{className:"agent-connection-row",children:[l.jsx("span",{className:`agent-connection-dot ${E?"connected":r?.codexAuth==="not-signed-in"?"unavailable":""}`}),l.jsx("span",{children:r?.codexInstallation==="not-installed"?"Codex SDK not installed":r?.codexAuth==="signed-in"?"Codex CLI signed in":r?.codexAuth==="not-signed-in"?"Codex CLI sign-in required":"Codex status not tested"}),l.jsxs("button",{className:"settings-reset",onClick:()=>{C()},disabled:p!==""||a.provider!=="codex",type:"button",children:[l.jsx($b,{size:15})," ",p==="test"?"Testing":"Test connection"]})]}),l.jsxs("p",{className:"settings-help",children:[l.jsx(Pb,{size:12})," Authentication is owned by the installed Codex CLI. LiveDesk never asks for or stores a ChatGPT token."]}),r?.codexPath&&l.jsxs("p",{className:"settings-help",children:["CLI: ",r.codexPath]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Codex runtime"}),l.jsx("h3",{children:"Model and reasoning"})]}),l.jsx(Mv,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Model"}),l.jsx("input",{value:a.codexModelId,onChange:I=>j("codexModelId",I.target.value),placeholder:"Codex default",disabled:a.provider!=="codex"})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Reasoning effort"}),l.jsxs("select",{value:a.codexReasoningEffort,onChange:I=>j("codexReasoningEffort",I.target.value),disabled:a.provider!=="codex",children:[l.jsx("option",{value:"minimal",children:"Minimal"}),l.jsx("option",{value:"low",children:"Low"}),l.jsx("option",{value:"medium",children:"Medium"}),l.jsx("option",{value:"high",children:"High"}),l.jsx("option",{value:"xhigh",children:"Extra high"})]})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Task timeout (ms)"}),l.jsx("input",{type:"number",min:"30000",max:"1800000",step:"10000",value:a.codexTaskTimeoutMs,onChange:I=>j("codexTaskTimeoutMs",Number(I.target.value)),disabled:a.provider!=="codex"})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Max tool calls"}),l.jsx("input",{type:"number",min:"1",max:"100",value:a.codexMaxToolCalls,onChange:I=>j("codexMaxToolCalls",Number(I.target.value)),disabled:a.provider!=="codex"})]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Workspace"}),l.jsx("h3",{children:"Restricted execution context"})]}),l.jsx(Sn,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Working directory"}),l.jsx("input",{value:r?.agentWorkspacePath||a.codexWorkingDirectory,readOnly:!0})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.codexResumeSessions,onChange:I=>j("codexResumeSessions",I.target.checked),disabled:a.provider!=="codex"}),l.jsx("span",{children:"Allow session resume"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.codexShowDetailedEvents,onChange:I=>j("codexShowDetailedEvents",I.target.checked),disabled:a.provider!=="codex"}),l.jsx("span",{children:"Show detailed Codex events"})]}),l.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"&&l.jsxs("section",{className:"settings-section-card agent-legacy-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Developer fallback"}),l.jsx("h3",{children:"OpenCode Go"})]}),l.jsx(ic,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Base URL"}),l.jsx("input",{value:a.baseUrl,onChange:I=>j("baseUrl",I.target.value)})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"API key"}),l.jsx("input",{type:"password",value:d,onChange:I=>h(I.target.value),placeholder:r?.hasApiKey?r.apiKeyPreview:"Stored only in the Hub",autoComplete:"new-password"})]}),l.jsxs("div",{className:"settings-action-row",children:[l.jsxs("button",{className:"settings-reset",onClick:()=>{A()},disabled:p!==""||!r?.hasApiKey,type:"button",children:[l.jsx(xh,{size:15})," Clear key"]}),l.jsx("span",{className:"settings-help",children:"This provider does not run the Codex MCP tool loop."})]})]}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Agent behavior"}),l.jsx("h3",{children:"Predictable operation"})]}),l.jsx(Gn,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.deterministicParserFirst,onChange:I=>j("deterministicParserFirst",I.target.checked)}),l.jsx("span",{children:"Use deterministic parser before Codex"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.generateSummary,onChange:I=>j("generateSummary",I.target.checked)}),l.jsx("span",{children:"Generate task summaries"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.fallbackSummary,onChange:I=>j("fallbackSummary",I.target.checked)}),l.jsx("span",{children:"Fallback to deterministic summaries"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:a.includeRawDeviceDetails,onChange:I=>j("includeRawDeviceDetails",I.target.checked)}),l.jsx("span",{children:"Include raw device details in summaries"})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Safety"}),l.jsx("h3",{children:"Locked execution boundary"})]}),l.jsx(Sn,{size:20})]}),["Arbitrary shell commands","PowerShell and Bash","Filesystem writes, deletes, and installs","Reboot, shutdown, and process termination","Network access and web search"].map(I=>l.jsxs("div",{className:"agent-safety-row",children:[l.jsx(qb,{size:15}),l.jsx("span",{children:I}),l.jsx("strong",{children:"Blocked"})]},I)),L.map(([I])=>l.jsxs("div",{className:"agent-safety-row",children:[l.jsx(Sn,{size:15}),l.jsx("span",{children:I}),l.jsx("strong",{className:F==="unavailable"?"agent-safety-failed":F==="configured"?"agent-safety-configured":"agent-safety-verified",children:P})]},I)),l.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."})]})]}),l.jsxs("div",{className:"settings-action-row agent-settings-actions",children:[l.jsxs("button",{className:"settings-reset",onClick:()=>{R()},disabled:p!=="",type:"button",children:[l.jsx(rc,{size:15})," Reset defaults"]}),l.jsxs("button",{className:"text-button primary",onClick:()=>{M()},disabled:p!=="",type:"button",children:[l.jsx(sy,{size:15})," ",p==="save"?"Saving":"Save Agent settings"]})]})]})}new Date().valueOf();function Ps(n){const[a,i]=f.useState(n),r=f.useRef(n);return f.useEffect(()=>{if(r.current!==n){if(Array.isArray(r.current)&&Array.isArray(n)&&r.current.length===0&&n.length===0)return;r.current=n,i(n)}},[n]),[a,i]}function jh(n,a){return typeof n=="function"?typeof a=="object"?n(a):n():n}function Qr(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function $0(n,a="data-id"){const i=Qr(n,a);return i?i.getAttribute(a):null}function yc(n,a="data-id"){const i=Qr(n,a);return i?kd(i,a):null}function kd(n,a="data-id"){const i=n.getAttribute(a);return i?P0(i):null}function jn(n){return typeof n=="string"?":"+n:n}function P0(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function q0(){return{detect:()=>!0,addEvent:function(n,a,i){return n.addEventListener(a,i),()=>n.removeEventListener(a,i)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var va=q0();function kh(n){Object.assign(va,n)}function Jv(n,a,i){function r(c){const d=Qr(c);if(!d)return;const h=kd(d);if(typeof a=="function")return a(h,c);let p,v=c.target;for(;v!=d;){if(p=v.dataset?v.dataset.action:null,p&&a[p]){a[p](h,c);return}v=v.parentNode}a[i]&&a[i](h,c)}va.addEvent(n,i,r)}function Xr(n,a){Jv(n,a,"click"),a.dblclick&&Jv(n,a.dblclick,"dblclick")}function G0(n,a){for(let i=n.length-1;i>=0;i--)if(n[i]===a){n.splice(i,1);break}}function V0(n,a,i){for(let r=0;r<wl.length;r++){if(r===i)continue;const c=wl[r],d=c.props.parent?.();if(d&&n.contains(d)&&c.node.contains(a))return!0}return!1}var jy=new Date,xd=!1,Pu=[],wl=[],ex=n=>{const a=n.target;if(xd||!a.isConnected){xd=!1;return}for(let i=wl.length-1;i>=0;i--){const{node:r,date:c,props:d}=wl[i];if(!(c>jy)&&!r.contains(a)&&r!==a&&(V0(r,a,i)||(d.callback&&d.callback(n),d.modal||n.defaultPrevented)))break}},Y0=n=>{jy=new Date,xd=!0;for(let a=wl.length-1;a>=0;a--){const{node:i}=wl[a];if(!i.contains(n.target)&&i!==n.target){xd=!1;break}}};function qs(n,a){Pu.length||(Pu=[va.addGlobalEvent("click",ex,n),va.addGlobalEvent("contextmenu",ex,n),va.addGlobalEvent("mousedown",Y0,n)]),typeof a!="object"&&(a={callback:a});const i={node:n,date:new Date,props:a};return wl.push(i),{destroy(){G0(wl,i),wl.length||(Pu.forEach(r=>r()),Pu=[])}}}var qu=n=>n.indexOf("bottom")!==-1,Gu=n=>n.indexOf("left")!==-1,Vu=n=>n.indexOf("right")!==-1,Nm=n=>n.indexOf("top")!==-1,tx=n=>n.indexOf("fit")!==-1,Xo=n=>n.indexOf("overlap")!==-1,W0=n=>n.split("-").every(a=>["center","fit"].indexOf(a)>-1),K0=n=>{const a=n.match(/(start|center|end)/);return a?a[0]:null};function Q0(n,a){let i=0;const r=va.getTopNode(n);for(;n&&n!==r;){const c=getComputedStyle(n).position;if((c==="absolute"||c==="relative"||c==="fixed")&&(i=parseInt(getComputedStyle(n).zIndex)||0),n=n.parentNode,n===a)break}return i}var on,Hn,Zo,_n;function ky(n,a,i="bottom",r=0,c=0){if(!n)return null;on=r,Hn=c,Zo="auto";let d=0,h=0,p=i;const v=My(n),g=Xo(i)?va.getTopNode(n):v;if(!v)return null;const w=v.getBoundingClientRect(),y=n.getBoundingClientRect(),b=g.getBoundingClientRect(),j=window.getComputedStyle(g),k={left:0,top:0,bottom:0,right:0};for(const U in k){const F=`border-${U}-width`;k[U]=parseFloat(j.getPropertyValue(F))}if(a){const U=Q0(a,v);d=Math.max(U+1,20)}if(a){if(_n=a.getBoundingClientRect(),tx(i)&&(Zo=_n.width+"px"),i!=="point")if(W0(i))tx(i)?on=0:(on=b.width/2,h=1),Hn=(b.height-y.height)/2;else{const U=Xo(i)?0:1;on=Vu(i)?_n.right+U:_n.left-U,Hn=qu(i)?_n.bottom+1:_n.top;const F=K0(i);F&&(Vu(i)||Gu(i)?F==="center"?Hn-=(y.height-_n.height)/2:F==="end"&&(Hn-=y.height-_n.height):(qu(i)||Nm(i))&&(F==="center"?on-=(y.width-_n.width)/2:F==="end"&&(on-=y.width-_n.width),Xo(i)||(on+=1)))}}else _n={left:r,right:r,top:c,bottom:c};const M=(Gu(i)||Vu(i))&&(qu(i)||Nm(i));Gu(i)&&(h=2);const R=on-y.width-b.left;a&&Gu(i)&&!M&&R<0&&(on=_n.right,h=0,p=p.replace("left","right"));const C=on+y.width*(1-h/2)-b.right;if(C>0)if(!Vu(i))on=b.right-k.right-y.width;else{const U=_n.left-b.x-y.width;a&&!M&&U>=0?(on=_n.left-y.width,p=p.replace("right","left")):on-=C+k.right}h&&(on=Math.round(on-y.width*h/2));const A=R<0||C>0||!M;Nm(i)&&(Hn=_n.top-y.height,a&&Hn<b.y&&A&&(Hn=_n.bottom,p=p.replace("top","bottom")));const E=Hn+y.height-b.bottom;return E>0&&(a&&qu(i)&&A?(Hn-=y.height+_n.height+1,p=p.replace("bottom","top")):Hn-=E+k.bottom),on-=w.left+k.left,Hn-=w.top+k.top,on=(Xo(i)?on:Math.max(on,0))+g.scrollLeft,Hn=(Xo(i)?Hn:Math.max(Hn,0))+g.scrollTop,Zo=Zo||"auto",{at:p,x:on,y:Hn,z:d,width:Zo}}function My(n){const a=va.getTopNode(n);for(n&&(n=n.parentElement);n;){const i=getComputedStyle(n).position;if(n===a||i==="relative"||i==="absolute"||i==="fixed")return n;n=n.parentNode}return null}function X0(n){const a=[];let i=n;const r=va.getTopNode(n);for(;i&&i!==r&&!i.getAttribute("data-wx-portal-root");)getComputedStyle(i).position==="absolute"&&a.push(i),i=i.parentNode;return a}var nx=new Date().valueOf();function Mh(){return nx+=1,nx}function $n(n){return n<10?"0"+n:n.toString()}function Z0(n){const a=$n(n);return a.length==2?"0"+a:a}function Ay(n){const a=Math.floor(n/11)*11;return{start:a,end:a+11}}function Tm(n){const a=(n.getDay()+6)%7,i=new Date(n.valueOf());i.setDate(n.getDate()+(3-a)),i.setHours(0,0,0,0);const r=new Date(i.getFullYear(),0,1),c=Math.round((i.getTime()-r.getTime())/864e5);return 1+Math.floor(c/7)}var ax=["",""];function J0(n,a,i){switch(n){case"%d":return $n(a.getDate());case"%m":return $n(a.getMonth()+1);case"%j":return a.getDate();case"%n":return a.getMonth()+1;case"%y":return $n(a.getFullYear()%100);case"%Y":return a.getFullYear();case"%D":return i.dayShort[a.getDay()];case"%l":return i.dayFull[a.getDay()];case"%M":return i.monthShort[a.getMonth()];case"%F":return i.monthFull[a.getMonth()];case"%h":return $n((a.getHours()+11)%12+1);case"%g":return(a.getHours()+11)%12+1;case"%G":return a.getHours();case"%H":return $n(a.getHours());case"%i":return $n(a.getMinutes());case"%a":return((a.getHours()>11?i.pm:i.am)||ax)[0];case"%A":return((a.getHours()>11?i.pm:i.am)||ax)[1];case"%s":return $n(a.getSeconds());case"%S":return Z0(a.getMilliseconds());case"%W":return $n(Tm(a));case"%w":{const r=i.weekStart??1;if(r===1)return $n(Tm(a));const c=(a.getDay()-r+7)%7,d=(1-r+7)%7,h=new Date(a.valueOf());return h.setDate(a.getDate()+(d-c)),$n(Tm(h))}case"%c":{let r=a.getFullYear()+"";return r+="-"+$n(a.getMonth()+1),r+="-"+$n(a.getDate()),r+="T",r+=$n(a.getHours()),r+=":"+$n(a.getMinutes()),r+=":"+$n(a.getSeconds()),r}case"%Q":return Math.floor(a.getMonth()/3)+1;default:return n}}var e1=/%[a-zA-Z]/g;function Vr(n,a){return typeof n=="function"?n:function(i){return i?(i.getMonth||(i=new Date(i)),n.replace(e1,r=>J0(r,i,a))):""}}function sx(n){return n&&typeof n=="object"&&!Array.isArray(n)}function lh(n,a){for(const i in a){const r=a[i];sx(n[i])&&sx(r)?n[i]=lh({...n[i]},a[i]):n[i]=a[i]}return n}function Sc(n){return{getGroup(a){const i=n[a];return r=>i&&i[r]||r},getRaw(){return n},extend(a,i){if(!a)return this;let r;return i?r=lh({...a},n):r=lh({...n},a),Sc(r)}}}var t1=dy();const n1="en-US",a1={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},s1={ok:"OK",cancel:"Cancel",select:"Select","No data":"No data","Rows per page":"Rows per page","Total pages":"Total pages"},l1={timeFormat:"%H:%i",dateFormat:"%m/%d/%Y",monthYearFormat:"%F %Y",yearFormat:"%Y"},Ny={core:s1,calendar:a1,formats:l1,lang:n1},Ah=f.createContext(""),Ty=f.createContext({}),ys=f.createContext(null),Ry=f.createContext(null),Mn=Object.freeze(Object.defineProperty({__proto__:null,fieldId:Ry,helpers:Ty,i18n:ys,theme:Ah},Symbol.toStringTag,{value:"Module"}));function Ey(n){const a=f.useContext(Ry),[i]=f.useState(()=>n||a||Mh());return i}function fc({type:n="",css:a="",icon:i="",disabled:r=!1,title:c="",tooltip:d,text:h="",children:p,onClick:v}){const g=f.useMemo(()=>{let y=n?n.split(" ").filter(b=>b!=="").map(b=>"wx-"+b).join(" "):"";return a+(a?" ":"")+y},[n,a]),w=y=>{v&&v(y)};return l.jsxs("button",{title:c,className:`wx-2ZWgb4 wx-button ${g} ${i&&!p?"wx-icon":""}`,disabled:r,onClick:w,"data-tooltip-text":d,children:[i&&l.jsx("i",{className:"wx-2ZWgb4 "+i}),p||h||" "]})}function i1({id:n,label:a="",inputValue:i="",value:r=!1,onChange:c,disabled:d=!1,css:h=""}){const p=Ey(n),[v,g]=Ps(r),w=({target:y})=>{const b=y.checked;g(b),c&&c({value:b,inputValue:i})};return l.jsxs("div",{className:`wx-2IvefP wx-checkbox ${h}`,children:[l.jsx("input",{type:"checkbox",id:p,disabled:d,className:"wx-2IvefP wx-check",checked:v,value:i,onChange:w}),l.jsxs("label",{htmlFor:p,className:"wx-2IvefP wx-label",children:[l.jsx("span",{className:"wx-2IvefP wx-before"}),a&&l.jsx("span",{className:"wx-2IvefP wx-after",children:a})]})]})}function Nh({theme:n="",target:a,children:i}){const r=f.useRef(null),c=f.useRef(null),[d,h]=f.useState(null);r.current||(r.current=document.createElement("div"));const p=f.useContext(Ah);return f.useEffect(()=>{h(a||r1(c.current)||va.getTopNode(c.current))},[c.current]),l.jsxs(l.Fragment,{children:[l.jsx("span",{ref:c,style:{display:"none"}}),c.current&&d?t1.createPortal(l.jsx("div",{className:`wx-3ZWsT0 wx-${n||p}-theme`,children:i}),d):null]})}function r1(n){const a=va.getTopNode(n);for(;n&&n!==a&&!n.getAttribute("data-wx-portal-root");)n=n.parentNode;return n}function o1({left:n=0,top:a=0,at:i="bottom",parent:r=null,width:c="auto",css:d="",onCancel:h,children:p,trackScroll:v=!1}){const[g,w]=f.useState(0),[y,b]=f.useState(0),[j,k]=f.useState("auto"),[M,R]=f.useState(!1),C=f.useRef(null),A=f.useRef(null),E=f.useRef(h);f.useEffect(()=>{E.current=h},[h]);function U(P){return r&&(c+"").indexOf("%")>-1?c.replace(/(\d+)%/,(L,I)=>(I=I*r.offsetWidth/100+"px",c.replace(L,I))):c&&c!=="auto"?c:P}const F=f.useCallback(()=>{if(!C.current)return;const P=ky(C.current,r,i,n,a);P&&(w(P.x),b(P.y),k(U(P.width)))},[C,r,i,n,a,c]);return f.useLayoutEffect(()=>{const P=I=>{E.current&&I.target!==A.current&&C.current&&!C.current.contains(I.target)&&E.current(I)};let L;return requestAnimationFrame(()=>{F(),R(!0),v&&C.current&&(A.current=My(C.current),A.current&&A.current.addEventListener("scroll",P,!0)),r&&(L=new ResizeObserver(F),L.observe(r))}),()=>{v&&A.current&&A.current.removeEventListener("scroll",P,!0),L?.disconnect()}},[]),f.useLayoutEffect(()=>{F()},[r,i,n,a]),f.useEffect(()=>{const P=L=>{E.current&&E.current(L)};if(C.current)return qs(C.current,{callback:P,parent:()=>r}).destroy},[r]),l.jsx("div",{ref:C,className:["wx-37M6Fj","wx-popup",d].filter(Boolean).join(" "),style:{position:"absolute",visibility:M?"visible":"hidden",top:y+"px",left:g+"px",width:j},children:p})}function c1({position:n="bottom",align:a="start",autoFit:i=!0,onCancel:r=null,width:c="100%",css:d="",children:h}){const p=f.useRef(null),[v,g]=f.useState(n),[w,y]=f.useState(a),b=f.useRef(r);return f.useEffect(()=>{b.current=r},[r]),f.useEffect(()=>{if(i){const j=p.current;if(j){const k=j.getBoundingClientRect(),M=document.body.getBoundingClientRect();k.right>=M.right&&y("end"),k.bottom>=M.bottom&&g("top")}}},[]),f.useEffect(()=>{if(p.current){const j=k=>{b.current&&b.current(k)};return qs(p.current,j).destroy}},[]),l.jsx("div",{ref:p,className:["wx-dropdown",`wx-${v}-${w}`,d||"","wx-aaaVytZW"].filter(Boolean).join(" "),style:{width:c},children:h})}function Th({position:n="bottom",align:a="start",autoFit:i=!0,inline:r=!1,onCancel:c,width:d="100%",children:h,...p}){const[v,g]=f.useState(void 0),w=f.useRef(null),y=f.useMemo(()=>`${n}-${a}`,[n,a]);return f.useLayoutEffect(()=>{w.current&&g(w.current.parentNode)},[]),l.jsxs(l.Fragment,{children:[v&&(r?l.jsx(c1,{onCancel:c,position:n,align:a,autoFit:i,width:d,...p,children:h}):l.jsx(Nh,{children:l.jsx(o1,{parent:v,at:y,onCancel:c,width:d,...p,children:h})})),l.jsx("span",{ref:w,className:"wx-portal-node wx-32GZ52"})]})}function Md(){return Sc(Ny)}function u1(){let n=null,a=!1,i=!1,r,c,d,h;const p=(y,b,j,k,M)=>{r=y,c=b,d=j,h=k,i=M},v=y=>{n=y,a=n!==null,d(n)},g=(y,b)=>{if(!i&&y!==null&&r){const j=r.querySelectorAll(".wx-list > .wx-item")[y];j&&(j.scrollIntoView({block:"nearest"}),b&&b.preventDefault())}},w=(y,b)=>{const j=y===null?null:Math.max(0,Math.min(n+y,c.length-1));j!==n&&(v(j),r?g(j,b):requestAnimationFrame(()=>g(j,b)))};return{move:y=>{const b=yc(y),j=c.findIndex(k=>k.id===b);j!==n&&v(j)},keydown:(y,b)=>{switch(y.code){case"Enter":a?h():v(0);break;case"Space":a||v(0);break;case"Escape":d(n=null);break;case"Tab":d(n=null);break;case"ArrowDown":w(a?1:b||0,y);break;case"ArrowUp":w(a?-1:b||0,y);break}},init:p,navigate:w}}const lx=10,d1=f.memo(function({data:n,checkboxes:a,itemTemplate:i,value:r}){return l.jsxs(l.Fragment,{children:[a&&l.jsx(i1,{id:n.id,css:"wx-list-checkbox",value:r&&r.includes(n.id)}),i?jh(i,{option:n}):n.label]})});function ix({visibleItems:n,visibleRange:a,navIndex:i,checkboxes:r,itemTemplate:c,value:d,measureRefCallback:h}){return n.map((p,v)=>{const g=a.start+v;return l.jsx("div",{ref:v===0?h:void 0,className:`wx-233fr7 wx-item ${g===i?"wx-focus":""}`,"data-id":p.id,children:l.jsx(d1,{data:p,checkboxes:r,itemTemplate:c,value:d})},p.id)})}function Ad({items:n=[],children:a,onSelect:i,onReady:r,virtualized:c=!1,checkboxes:d,multiselect:h,value:p,...v}){const g=f.useRef(),w=f.useRef(!1),y=f.useRef(u1()),[b,j]=f.useState(null),k=f.useRef(b),[M,R]=f.useState(0),[C,A]=f.useState(24),E=f.useRef(!1),U=(f.useContext(ys)||Md()).getGroup("core"),F=f.useRef(n);f.useEffect(()=>{F.current=n},[n]);const P=f.useRef(p);f.useEffect(()=>{P.current=p},[p]);const L=f.useRef(0);f.useEffect(()=>{L.current=C},[C]);const I=f.useCallback(D=>{D&&D.stopPropagation();const J=F.current,he=P.current,we=k.current;let je;const Oe=J[we]?.id;h?he&&he.includes(Oe)?je=he.filter(He=>He!==Oe):je=[...he||[],Oe]:je=Oe,i&&i({id:je})},[h,i]),de=f.useRef(I);f.useEffect(()=>{de.current=I},[I]);const W=f.useCallback(D=>{if(g.current){let J=D*L.current-g.current.clientHeight+L.current;R(J),g.current.scrollTop=J}},[L.current]),ue=f.useCallback(D=>{g.current=D,c&&(D&&!w.current&&k.current!==null&&requestAnimationFrame(()=>{g.current&&(W(k.current),w.current=!0)}),D||(w.current=!1))},[W]),Z=f.useCallback(D=>{if(!D||E.current)return;const J=D.getBoundingClientRect().height;J&&(A(J),L.current=J,E.current=!0)},[]);f.useEffect(()=>{y.current.init(g.current,n,D=>{j(D),k.current=D},D=>de.current(D),c)},[n,g.current,c]),f.useEffect(()=>{const D=(he,we)=>{y.current.navigate(he,we),W(k.current)},J=(he,we)=>{const je=k.current,Oe=F.current;if(je!==0&&je!==Oe.length-1&&(he.key==="ArrowDown"||he.key==="ArrowUp")&&he.preventDefault(),y.current.keydown(he,we),g.current){const He=g.current.scrollTop<=k.current*L.current,oe=g.current.scrollTop+g.current.clientHeight>=k.current*L.current+L.current;He?oe||W(k.current):(g.current.scrollTop=k.current*L.current,R(g.current.scrollTop))}};r&&r({navigate:c?D:y.current.navigate,keydown:c?J:y.current.keydown,move:y.current.move})},[]);const le=f.useRef(0),ce=f.useRef(n);ce.current!==n&&(ce.current=n,le.current+=1);const Q=f.useCallback(()=>{y.current.navigate(null)},[y]),_=f.useCallback(D=>{c&&R(D.target.scrollTop)},[c]),Y=f.useMemo(()=>Math.ceil((g.current?.clientHeight||0)/C),[C,M]),$=f.useMemo(()=>{if(!c)return{start:0,end:n.length};if(!n.length)return{start:0,end:0};const D=Math.floor(M/C),J=D+Y;return{start:Math.max(0,D-lx),end:Math.min(n.length,J+lx)}},[c,n,M,C,Y]),H=f.useMemo(()=>{if(!c)return n;const{start:D,end:J}=$;return n.slice(D,J).map(he=>({...he}))},[c,n,$]),ie=$.start*C,xe=n.length*C;return f.useEffect(()=>{c&&R(0)},[n,c]),f.useEffect(()=>{b===null&&(w.current=!1)},[b]),b===null?null:l.jsx(Th,{onCancel:Q,...v,children:l.jsx("div",{className:"wx-233fr7 wx-list",ref:ue,onClick:I,onMouseMove:y.current.move,onScroll:_,children:n.length?c?l.jsx("div",{className:"wx-233fr7 wx-list-wrapper",style:{height:`${xe}px`},children:l.jsx("div",{className:"wx-233fr7 wx-list-content",style:{transform:`translateY(${ie}px)`},children:l.jsx(ix,{visibleRange:$,visibleItems:H,navIndex:b,measureRefCallback:Z,checkboxes:d,itemTemplate:a,value:p})})}):l.jsx(ix,{visibleRange:$,visibleItems:H,navIndex:b,measureRefCallback:Z,checkboxes:d,itemTemplate:a,value:p}):l.jsx("div",{className:"wx-233fr7 wx-no-data",children:U("No data")})})},le.current)}function Rh({value:n="",id:a,readonly:i=!1,focus:r=!1,select:c=!1,type:d="text",placeholder:h="",disabled:p=!1,error:v=!1,title:g="",tooltip:w,css:y="",icon:b="",clear:j=!1,onChange:k}){const M=Ey(a),[R,C]=Ps(n),A=f.useRef(null),E=f.useMemo(()=>b&&y.indexOf("wx-icon-left")===-1?"wx-icon-right "+y:y,[b,y]),U=f.useMemo(()=>b&&y.indexOf("wx-icon-left")!==-1,[b,y]);f.useEffect(()=>{const de=setTimeout(()=>{r&&A.current&&A.current.focus(),c&&A.current&&A.current.select()},1);return()=>clearTimeout(de)},[r,c]);const F=f.useCallback(de=>{const W=de.target.value;C(W),k&&k({value:W,input:!0})},[k]),P=f.useCallback(de=>k&&k({value:de.target.value}),[k]);function L(de){de.stopPropagation(),C(""),k&&k({value:""})}let I=d;return d!=="password"&&d!=="number"&&(I="text"),f.useEffect(()=>{const de=P,W=A.current;return W.addEventListener("change",de),()=>{W&&W.removeEventListener("change",de)}},[P]),l.jsxs("div",{className:`wx-hQ64J4 wx-text ${E} ${v?"wx-error":""} ${p?"wx-disabled":""} ${j?"wx-clear":""}`,"data-tooltip-text":w,children:[l.jsx("input",{className:"wx-hQ64J4 wx-input",ref:A,id:M,readOnly:i,disabled:p,placeholder:h,type:I,title:g,value:R,onInput:F}),j&&!p&&R?l.jsxs(l.Fragment,{children:[l.jsx("i",{className:"wx-hQ64J4 wx-icon wxi-close",onClick:L}),U&&l.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`})]}):b?l.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`}):null]})}function f1({date:n,type:a,part:i,onShift:r}){const{calendar:c,formats:d}=f.useContext(ys).getRaw(),h=n.getFullYear(),p=f.useMemo(()=>{switch(a){case"month":return Vr(d.monthYearFormat,c)(n);case"year":return Vr(d.yearFormat,c)(n);case"duodecade":{const{start:g,end:w}=Ay(h),y=Vr(d.yearFormat,c);return`${y(new Date(g,0,1))} - ${y(new Date(w,11,31))}`}default:return""}},[n,a,h,c,d]);function v(){r&&r({diff:0,type:a})}return l.jsxs("div",{className:"wx-8HQVQV wx-header",children:[i!=="right"?l.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-left",onClick:()=>r&&r({diff:-1,type:a})}):l.jsx("span",{className:"wx-8HQVQV wx-spacer"}),l.jsx("span",{className:"wx-8HQVQV wx-label",onClick:v,children:p}),i!=="left"?l.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-right",onClick:()=>r&&r({diff:1,type:a})}):l.jsx("span",{className:"wx-8HQVQV wx-spacer"})]})}function Eh({onClick:n,children:a}){return l.jsx("button",{className:"wx-3s8W4d wx-button",onClick:n,children:a})}function m1({value:n,current:a,part:i="",markers:r=null,css:c="",onCancel:d,onChange:h}){const p=(f.useContext(ys)||Md()).getRaw().calendar,v=(p.weekStart||7)%7,g=p.dayShort.slice(v).concat(p.dayShort.slice(0,v)),w=(F,P,L)=>new Date(F.getFullYear(),F.getMonth()+(P||0),F.getDate()+(L||0));let y=i!=="normal";function b(F){const P=F.getDay();return P===0||P===6}function j(){const F=w(a,0,1-a.getDate());return F.setDate(F.getDate()-(F.getDay()-(v-7))%7),F}function k(){const F=w(a,1,-a.getDate());return F.setDate(F.getDate()+(6-F.getDay()+v)%7),F}const M=f.useRef(0);function R(F,P){P.timeStamp!==M.current&&(M.current=P.timeStamp,P.stopPropagation(),h&&h(new Date(F)),d&&d())}const C=f.useMemo(()=>i=="normal"?[n?w(n).valueOf():0]:n?[n.start?w(n.start).valueOf():0,n.end?w(n.end).valueOf():0]:[0,0],[i,n]),A=f.useMemo(()=>{const F=j(),P=k(),L=a.getMonth();let I=[];for(let de=F;de<=P;de.setDate(de.getDate()+1)){const W={day:de.getDate(),in:de.getMonth()===L,date:de.valueOf()};let ue="";if(ue+=W.in?"":" wx-inactive",ue+=C.indexOf(W.date)>-1?" wx-selected":"",y){const Z=W.date==C[0],le=W.date==C[1];Z&&!le?ue+=" wx-left":le&&!Z&&(ue+=" wx-right"),W.date>C[0]&&W.date<C[1]&&(ue+=" wx-inrange")}if(ue+=b(de)?" wx-weekend":"",r){const Z=r(de);Z&&(ue+=" "+Z)}I.push({...W,css:ue})}return I},[a,C,y,r]),E=f.useRef(null);let U=f.useRef({});return U.current.click=R,f.useEffect(()=>{Xr(E.current,U.current)},[]),l.jsxs("div",{className:`wx-398RBS wx-month ${c}`,children:[l.jsx("div",{className:"wx-398RBS wx-weekdays",children:g.map(F=>l.jsx("div",{className:"wx-398RBS wx-weekday",children:F},F))}),l.jsx("div",{className:"wx-398RBS wx-days",ref:E,children:A.map(F=>l.jsx("div",{className:`wx-398RBS wx-day ${F.css} ${F.in?"":"wx-out"}`,"data-id":F.date,children:F.day},F.date))})]})}function h1({value:n,current:a,part:i,onCancel:r,onChange:c,onShift:d}){const h=f.useRef(new Date),[p,v]=Ps(n||h.current),[g,w]=Ps(a||h.current),y=f.useContext(ys).getRaw().calendar,b=y.monthShort||[],j=f.useMemo(()=>g.getMonth(),[g]),k=f.useCallback((C,A)=>{if(C!=null){A.stopPropagation();const E=new Date(g);E.setMonth(C),w(E),d&&d({current:E})}i==="normal"&&v(new Date(g)),r&&r()},[g,i,d,r]),M=f.useCallback(()=>{const C=new Date(Dy(p,i)||g);C.setMonth(g.getMonth()),C.setFullYear(g.getFullYear()),c&&c(C)},[p,g,i,c]),R=f.useCallback(C=>{const A=C.target.closest("[data-id]");if(A){const E=parseInt(A.getAttribute("data-id"),10);k(E,C)}},[k]);return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-34U8T8 wx-months",onClick:R,children:b.map((C,A)=>l.jsx("div",{className:"wx-34U8T8 wx-month"+(j===A?" wx-current":""),"data-id":A,children:C},A))}),l.jsx("div",{className:"wx-34U8T8 wx-buttons",children:l.jsx(Eh,{onClick:M,children:y.done})})]})}const Rm="wx-1XEF33",p1=({value:n,current:a,onCancel:i,onChange:r,onShift:c,part:d})=>{const h=f.useContext(ys).getRaw().calendar,[p,v]=Ps(a),[g,w]=Ps(n),y=f.useMemo(()=>p.getFullYear(),[p]),b=f.useMemo(()=>{const{start:C,end:A}=Ay(y),E=[];for(let U=C;U<=A;++U)E.push(U);return E},[y]),j={click:k};function k(C,A){if(C){A.stopPropagation();const E=new Date(p);E.setFullYear(C),v(E),c&&c({current:E})}d==="normal"&&w(new Date(p)),i&&i()}function M(){const C=new Date(Dy(g,d)||p);C.setFullYear(p.getFullYear()),r&&r(C)}const R=f.useRef(null);return f.useEffect(()=>{R.current&&Xr(R.current,j)},[]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:Rm+" wx-years",ref:R,children:b.map((C,A)=>l.jsx("div",{className:Rm+` wx-year ${y==C?"wx-current":""} ${A===0?"wx-prev-decade":""} ${A===11?"wx-next-decade":""}`,"data-id":C,children:C},A))}),l.jsx("div",{className:Rm+" wx-buttons",children:l.jsx(Eh,{onClick:M,children:h.done})})]})},rx={month:{component:m1,next:v1,prev:g1},year:{component:h1,next:y1,prev:x1},duodecade:{component:p1,next:b1,prev:w1}};function g1(n){return n=new Date(n),n.setMonth(n.getMonth()-1),n}function v1(n){return n=new Date(n),n.setMonth(n.getMonth()+1),n}function x1(n){return n=new Date(n),n.setFullYear(n.getFullYear()-1),n}function y1(n){return n=new Date(n),n.setFullYear(n.getFullYear()+1),n}function w1(n){return n=new Date(n),n.setFullYear(n.getFullYear()-10),n}function b1(n){return n=new Date(n),n.setFullYear(n.getFullYear()+10),n}function Dy(n,a){let i;if(a==="normal")i=n;else{const{start:r,end:c}=n;a==="left"?i=r:a=="right"?i=c:i=r&&c}return i}const S1=["clear","today"];function C1(n){if(n==="done")return-1;if(n==="clear")return null;if(n==="today")return new Date}function j1({value:n,current:a,onCurrentChange:i,part:r="normal",markers:c=null,buttons:d,css:h="",onShift:p,onChange:v}){const g=f.useContext(ys).getGroup("calendar"),[w,y]=f.useState("month"),b=Array.isArray(d)?d:d?S1:[],j=(A,E)=>{A.preventDefault(),v&&v({value:E})},k=()=>{w==="duodecade"?y("year"):w==="year"&&y("month")},M=A=>{const{diff:E,current:U}=A;if(E===0){w==="month"?y("year"):w==="year"&&y("duodecade");return}if(E){const F=rx[w];i(E>0?F.next(a):F.prev(a))}else U&&i(U);p&&p()},R=A=>{y("month"),v&&v({select:!0,value:A})},C=f.useMemo(()=>rx[w].component,[w]);return l.jsx("div",{className:`wx-2Gr4AS wx-calendar ${r!=="normal"&&r!=="both"?"wx-part":""} ${h}`,children:l.jsxs("div",{className:"wx-2Gr4AS wx-wrap",children:[l.jsx(f1,{date:a,part:r,type:w,onShift:M}),l.jsxs("div",{children:[l.jsx(C,{value:n,current:a,onCurrentChange:i,part:r,markers:c,onCancel:k,onChange:R,onShift:M}),w==="month"&&b.length>0&&l.jsx("div",{className:"wx-2Gr4AS wx-buttons",children:b.map(A=>l.jsx("div",{className:"wx-2Gr4AS wx-button-item",children:l.jsx(Eh,{onClick:E=>j(E,C1(A)),children:g(A)})},A))})]})]})})}function Dh(n){let{words:a=null,optional:i=!1,children:r}=n,c=f.useContext(ys);const d=f.useMemo(()=>{let h=c;return(!h||!h.extend)&&(h=Sc(Ny)),a!==null&&(h=h.extend(a,i)),h},[a,i,c]);return l.jsx(ys.Provider,{value:d,children:r})}function ox(n,a,i,r){if(!n||r){const c=a?new Date(a):new Date;c.setDate(1),i(c)}else if(n.getDate()!==1){const c=new Date(n);c.setDate(1),i(c)}}const k1=["clear","today"];function Ly({value:n,current:a,markers:i=null,buttons:r=k1,css:c="",onChange:d}){const[h,p]=Ps(n),[v,g]=Ps(a);f.useEffect(()=>{ox(v,h,g,!1)},[h,v]);const w=f.useCallback(b=>{const j=b.value;j?(p(new Date(j)),ox(v,new Date(j),g,!0)):p(null),d&&d({value:j?new Date(j):null})},[d,v]),y=f.useCallback(b=>{g(b)},[g]);return v?l.jsx(Dh,{children:l.jsx(j1,{value:h,current:v,markers:i,buttons:r,css:c,onChange:w,onCurrentChange:y})}):null}function M1(n){return n||(n={}),n.width||(n.width="unset"),n}const A1=["clear","today"];function N1({value:n,id:a,disabled:i=!1,error:r=!1,placeholder:c="",format:d="",buttons:h=A1,css:p="",title:v="",tooltip:g,editable:w=!1,clear:y=!1,onChange:b,dropdown:j={}}){const{calendar:k,formats:M}=(f.useContext(ys)||Md()).getRaw(),R=d||M?.dateFormat;let C=typeof R=="function"?R:Vr(R,k);const[A,E]=f.useState(n),[U,F]=f.useState(!1);f.useEffect(()=>{E(n)},[n]);function P(){F(!1)}function L(W){const ue=W===A||W&&A&&W.valueOf()===A.valueOf()||!W&&!A;E(W),ue||b&&b({value:W}),setTimeout(P,1)}const I=f.useMemo(()=>A?C(A):"",[A,C]);function de({value:W,input:ue}){if(!w&&!y||ue)return;let Z=typeof w=="function"?w(W):W?new Date(W):null;Z=isNaN(Z)?A||null:Z||null,L(Z)}return f.useEffect(()=>{const W=P;return window.addEventListener("scroll",W),()=>window.removeEventListener("scroll",W)},[]),l.jsxs("div",{className:"wx-1lKOFG wx-datepicker",onClick:()=>F(!0),children:[l.jsx(Rh,{css:`wx-date-input ${p}`,title:v,tooltip:g,value:I,id:a,readonly:!w,disabled:i,error:r,placeholder:c,onInput:P,onChange:de,icon:"wxi-calendar",clear:y}),U&&!i&&l.jsx(Th,{onCancel:P,...M1(j),children:l.jsx(Ly,{buttons:h,value:A,onChange:W=>L(W.value)})})]})}function T1({value:n="",options:a=[],textOptions:i=null,placeholder:r="",disabled:c=!1,error:d=!1,title:h="",tooltip:p,textField:v="label",clear:g=!1,css:w="",children:y,onChange:b,dropdown:j={}}){const k=f.useRef(null),M=f.useRef(null);let[R,C]=Ps(n);function A(L){k.current=L.navigate,M.current=L.keydown}const E=f.useMemo(()=>R||R===0?(i||a).find(L=>L.id===R):null,[R,i,a]),U=f.useCallback(({id:L})=>{(L||L===0)&&(C(L),k.current(null),b&&b({value:L}))},[C,b]),F=f.useCallback(L=>{L.stopPropagation(),C(""),b&&b({value:""})},[C,b]),P=f.useCallback(()=>a.findIndex(L=>L.id===R),[a,R]);return l.jsxs("div",{className:`wx-2YgblL wx-richselect ${w} ${d?"wx-2YgblL wx-error":""} ${c?"wx-2YgblL wx-disabled":""} ${y?"":"wx-2YgblL wx-nowrap"}`,title:h,onClick:()=>k.current(P()),onKeyDown:L=>M.current(L,P()),tabIndex:0,"data-tooltip-text":p,children:[l.jsx("div",{className:"wx-2YgblL wx-label",children:E?y?y(E):E[v]:r?l.jsx("span",{className:"wx-2YgblL wx-placeholder",children:r}):" "}),g&&!c&&R?l.jsx("i",{className:"wx-2YgblL wx-icon wxi-close",onClick:F}):l.jsx("i",{className:"wx-2YgblL wx-icon wxi-angle-down"}),!c&&l.jsx(Ad,{items:a,onReady:A,onSelect:U,...j,children:({option:L})=>y?y(L):L[v]})]})}const R1=({options:n=[],value:a="",css:i="",children:r,onChange:c})=>{const[d,h]=f.useState(a),p=v=>{h(v),c&&c({value:v})};return f.useEffect(()=>{h(a)},[a]),l.jsx("div",{className:`wx-0hMO7P wx-segmented ${i}`,children:n.map(v=>l.jsx("button",{className:`wx-0hMO7P wx-segment ${v.css} ${v.id===d?"wx-selected":""}`,title:v.title,onClick:()=>p(v.id),"data-tooltip-text":v.tooltip,children:r?jh(r,{option:v}):l.jsxs(l.Fragment,{children:[v.icon&&l.jsx("i",{className:`wx-0hMO7P wx-icon ${v.icon} ${v.label?"":"wx-only"}`}),v.label&&l.jsx("span",{className:"wx-0hMO7P wx-label",children:v.label})]})},v.id))})};function E1({notice:n={}}){function a(){n.remove&&n.remove()}return l.jsxs("div",{className:`wx-11sNg5 wx-notice wx-${n.type?n.type:""}`,role:"status","aria-live":"polite",children:[l.jsx("div",{className:"wx-11sNg5 wx-text",children:n.text}),l.jsx("div",{className:"wx-11sNg5 wx-button",children:l.jsx("i",{className:"wx-11sNg5 wxi-close",onClick:a})})]})}function D1({data:n=[]}){return l.jsx("div",{className:"wx-3nwoO9 wx-notices",children:n.map(a=>l.jsx(E1,{notice:a},a.id))})}function ih({title:n="",buttons:a=["cancel","ok"],header:i,children:r,footer:c,css:d="",onConfirm:h,onCancel:p}){const v=(f.useContext(ys)||Md()).getGroup("core"),g=f.useRef(null);f.useEffect(()=>{g.current?.focus()},[]);function w(b){switch(b.code){case"Enter":{const j=b.target.tagName;if(j==="TEXTAREA"||j==="BUTTON")return;h&&h({event:b});break}case"Escape":p&&p({event:b});break}}function y(b,j){const k={event:b,button:j};j==="cancel"?p&&p(k):h&&h(k)}return l.jsx("div",{className:`wx-1FxkZa wx-modal ${d}`,ref:g,tabIndex:0,onKeyDown:w,children:l.jsxs("div",{className:"wx-1FxkZa wx-window",children:[i||(n?l.jsx("div",{className:"wx-1FxkZa wx-header",children:n}):null),l.jsx("div",{children:r}),c||a&&l.jsx("div",{className:"wx-1FxkZa wx-buttons",children:a.map(b=>l.jsx("div",{className:"wx-1FxkZa wx-button",children:l.jsx(fc,{type:`block ${b==="ok"?"primary":"secondary"}`,onClick:j=>y(j,b),children:v(b)})},b))})]})})}function L1({children:n},a){const[i,r]=f.useState(null),[c,d]=f.useState([]);return f.useImperativeHandle(a,()=>({showModal:h=>{const p={...h};return r(p),new Promise((v,g)=>{p.resolve=w=>{r(null),v(w)},p.reject=w=>{r(null),g(w)}})},showNotice:h=>{h={...h},h.id=h.id||Mh(),h.remove=()=>d(p=>p.filter(v=>v.id!==h.id)),h.expire!=-1&&setTimeout(h.remove,h.expire||5100),d(p=>[...p,h])}}),[]),l.jsxs(l.Fragment,{children:[n,i&&l.jsx(ih,{title:i.title,buttons:i.buttons,onConfirm:i.resolve,onCancel:i.reject,children:i.message}),l.jsx(D1,{data:c})]})}const _1=f.forwardRef(L1);function z1(n){let{children:a}=n,i=f.useRef();const r=f.useMemo(()=>({showNotice:c=>i.current.showNotice(c),showModal:c=>i.current.showModal(c)}),[]);return l.jsx(Ty.Provider,{value:r,children:l.jsx(_1,{ref:i,children:a})})}const O1=({value:n=!1,type:a="",icon:i="",disabled:r=!1,iconActive:c="",onClick:d,title:h="",tooltip:p,css:v="",text:g="",textActive:w="",children:y,active:b,onChange:j})=>{const[k,M]=Ps(n),R=f.useMemo(()=>(k?"pressed":"")+(a?" "+a:""),[k,a]),C=f.useCallback(A=>{let E=!k;d&&d(A),A.defaultPrevented||(M(E),j&&j({value:E}))},[k,d,j]);return k&&b?l.jsx(fc,{title:h,tooltip:p,text:k&&w||g,css:v,type:R,icon:k&&c||i,onClick:C,disabled:r,children:jh(b,{value:k})}):y?l.jsx(fc,{title:h,tooltip:p,text:k&&w||g,css:v,type:R,icon:k&&c||i,onClick:C,disabled:r,children:y}):l.jsx(fc,{title:h,tooltip:p,text:k&&w||g,css:v,type:R,icon:k&&c||i,onClick:C,disabled:r})};function I1(){return l.jsx(l.Fragment,{})}function cx(n){const{fonts:a=!0,children:i}=n;return l.jsx(Ah.Provider,{value:"willow",children:l.jsxs(l.Fragment,{children:[i&&i&&l.jsx("div",{className:"wx-theme wx-willow-theme",children:i}),a&&l.jsxs(l.Fragment,{children:[l.jsx("link",{rel:"preconnect",href:"https://cdn.svar.dev",crossOrigin:"true"}),l.jsx(I1,{}),l.jsx("link",{rel:"stylesheet",href:"https://cdn.svar.dev/fonts/wxi/wx-icons.css"})]})]})})}kh(va);const Lh={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 _y=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 B1=class{constructor(n){const a={id:0,$level:0,data:[],parent:null},i=new Map;i.set(0,a),this._pool=i,n&&n.length&&this.parse(n,0)}parse(n,a){const i=this._pool;for(let c=0;c<n.length;c++){const d=n[c];d.parent=d.parent||a,d.data=null,i.set(d.id,d)}for(let c=0;c<n.length;c++){const d=n[c],h=i.get(d.parent);h&&(h.data||(h.data=[]),h.data.push(d))}const r=i.get(a);this.setLevel(r,r.$level+1,!1)}add(n,a){const i=this._pool.get(n.parent||0);n.$level=i.$level+1,this._pool.set(n.id,n),i.data?a===-1?i.data=[...i.data,n]:ux(i,a,n):i.data=[n]}addAfter(n,a){if(!a)return this.add(n,-1);const i=this.byId(a),r=this.byId(i.parent),c=Yu(r,i.id)+1;n.parent=r.id,n.$level=r.$level+1,this.add(n,c)}remove(n){const a=this._pool.get(n);this._remove(a);const i=this._pool.get(a.parent);i.data=i.data.filter(r=>r.id!=n),this._clearBranch(i)}_remove(n){n.data&&n.data.forEach(a=>this._remove(a)),this._pool.delete(n.id)}update(n,a){let i=this._pool.get(n);const r=this._pool.get(i.parent),c=Yu(r,i.id);i={...i,...a},r&&c>=0&&(r.data[c]=i,r.data=[...r.data]),this._pool.set(i.id,i)}move(n,a,i){const r=this._pool.get(n),c=a==="child",d=this._pool.get(i),h=d.$level+(c?1:0);if(!r||!d)return;const p=this._pool.get(r.parent),v=c?d:this._pool.get(d.parent);v.data||(v.data=[]);const g=Yu(p,r.id);F1(p,g);const w=c?v.data.length:Yu(v,d.id)+(a==="after"?1:0);if(ux(v,w,r),p.id===v.id&&g===w)return null;r.parent=v.id,r.$level!==h&&(r.$level=h,this.setLevel(r,h+1,!0)),this.update(r.id,r),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&&zy(a,n),n}byId(n){return this._pool.get(n)}getBranch(n){return this._pool.get(n).data}forEach(n){this._pool.forEach((a,i)=>{i!==0&&n(a)})}eachChild(n,a){const i=this.byId(a);!i||!i.data||i.data.forEach((r,c)=>{n(this.byId(r.id),c),this.eachChild(n,r.id)})}setLevel(n,a,i){n.data&&(n.data=n.data.map(r=>(i&&(r={...r},this._pool.set(r.id,r)),r.$level=a,r.data&&this.setLevel(r,a+1,i),r)))}};function zy(n,a){n.forEach(i=>{a.push(i),i.open===!0&&zy(i.data,a)})}function F1(n,a){const i=[...n.data];i.splice(a,1),n.data=i}function ux(n,a,i){const r=[...n.data];r.splice(a,0,i),n.data=r}function Yu(n,a){return n?.data.findIndex(i=>i.id===a)}var Oy=2,H1=class{constructor(a){a&&(this._writable=a.writable,this._async=a.async),this._values={},this._state={}}setState(a,i=0){const r={};return this._wrapProperties(a,this._state,this._values,"",r,i),r}getState(){return this._values}getReactive(){return this._state}_wrapProperties(a,i,r,c,d,h){for(const p in a){const v=i[p],g=r[p],w=a[p];if(v&&(g===w&&typeof w!="object"||w instanceof Date&&g instanceof Date&&g.getTime()===w.getTime()))continue;const y=c+(c?".":"")+p;v?(v.__parse(w,y,d,h)&&(r[p]=w),h&Oy?d[y]=v.__trigger:v.__trigger()):(w&&w.__reactive?i[p]=this._wrapNested(w,w,y,d):i[p]=this._wrapWritable(w),r[p]=w),d[y]=d[y]||null}}_wrapNested(a,i,r,c){const d=this._wrapWritable(a);return this._wrapProperties(a,d,i,r,c,0),d.__parse=(h,p,v,g)=>(this._wrapProperties(h,d,i,p,v,g),!1),d}_wrapWritable(a){const i=[],r=function(){for(let c=0;c<i.length;c++)i[c](a)};return{subscribe:c=>(i.push(c),this._async?setTimeout(c,1,a):c(a),()=>{const d=i.indexOf(c);d>=0&&i.splice(d,1)}),__trigger:()=>{i.length&&(this._async?setTimeout(r,1):r())},__parse:function(c){return a=c,!0}}}};function dx(n,a){return Object.defineProperty(n,"__reactive",{value:!0,enumerable:!1,writable:!1}),n}var U1=class{constructor(a,i,r,c){typeof a=="function"?this._setter=a:this._setter=a.setState.bind(a),this._routes=i,this._parsers=r,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(d=>{d.in.forEach(h=>{const p=this._triggers.get(h)||[];p.push(d),this._triggers.set(h,p)}),d.out.forEach(h=>{const p=this._sources.get(h)||{};d.in.forEach(v=>p[v]=!0),this._sources.set(h,p)})}),this._routes.forEach(d=>{d.length=Math.max(...d.in.map(h=>Iy(h,this._sources,1)))}),this._bus=c}init(a){const i={};for(const r in a)if(this._prev[r]!==a[r]){const c=this._parsers[r];i[r]=c?c(a[r]):a[r]}this._prev=this._prev?{...this._prev,...a}:{...a},this.setState(i),this._bus&&this._bus.exec("init-state",i)}setStateAsync(a){const i=this._setter(a,Oy);return this._async?Object.assign(this._async.signals,i):this._async={signals:i,timer:setTimeout(this._applyState.bind(this),1)},i}_applyState(){const a=this._async;if(a){this._async=null,this._triggerUpdates(a.signals,[]);for(const i in a.signals){const r=a.signals[i];r&&r()}}}setState(a,i=[]){const r=this._setter(a);return this._triggerUpdates(r,i),r}_triggerUpdates(a,i){const r=Object.keys(a),c=!i.length;i=i||[];for(let d=0;d<r.length;d++){const h=r[d],p=this._triggers.get(h);p&&p.forEach(v=>{i.indexOf(v)==-1&&i.push(v)})}c&&this._execNext(i)}_execNext(a){for(;a.length;){a.sort((r,c)=>r.length<c.length?1:-1);const i=a[a.length-1];a.splice(a.length-1),i.exec(a)}}};function Iy(n,a,i){const r=a.get(n);if(!r)return i;const c=Object.keys(r).map(d=>Iy(d,a,i+1));return Math.max(...c)}var $1=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(a,i,r){let c=this._handlers[a];c?r&&r.intercept?c.unshift(i):c.push(i):c=this._handlers[a]=[i],r&&r.tag&&this._tag.set(i,r.tag)}intercept(a,i,r){this.on(a,i,{...r,intercept:!0})}detach(a){for(const i in this._handlers){const r=this._handlers[i];for(let c=r.length-1;c>=0;c--)this._tag.get(r[c])===a&&r.splice(c,1)}}async exec(a,i){const r=this._handlers[a];if(r)for(let c=0;c<r.length;c++){const d=r[c](i);if(d===!1||d&&d.then&&await d===!1)return}return this._nextHandler&&await this._nextHandler.exec(a,i),i}setNext(a){return this._nextHandler=a}};const $r=1024;function wc(n){return n<$r?`${n} B`:n<$r**2?`${(n/$r).toFixed(1)} KB`:n<$r**3?`${(n/$r**2).toFixed(1)} MB`:`${(n/$r**3).toFixed(1)} GB`}function fx(n,a){a||(a={key:"name",order:"asc"});const i=n.filter(h=>h.type==="folder"),r=n.filter(h=>h.type!=="folder"),c=i.sort(mx(a)),d=r.sort(mx(a));return[...c,...d]}function P1(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 q1(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 mx({key:n,order:a}){const i=a==="asc"?P1:q1;return(r,c)=>i(r[n],c[n])}function _h(n,a){const i=n==="/"?1:n.split("/").length;return i>=a.length?null:a[i].id}function G1(n){return n.length>1?n[n.length-2].id:null}let V1=class extends B1{constructor(a){const i={id:"/",name:"My files",open:!0,$level:1,parent:0,ext:"",type:"folder"};super([i]),this.parse(a,"/")}parse(a,i,r){!a||!a.length||(a.forEach(c=>this.parseId(c,r?i:void 0)),super.parse(a,i))}parseId(a,i){if(a.parent===0)return;const r=a.id,c=r.lastIndexOf("/");if(a.parent=i??(c===0?"/":r.slice(0,c)),a.name=r.slice(c+1),a.type=a.type||"file",a.type!=="folder"){const d=a.name.lastIndexOf("."),h=d!==-1?a.name.slice(d+1):"";a.ext=h!=="new"?h?.toLocaleLowerCase():""}}getParents(a){const i=[];let r=this.byId(a);if(!r)return i;for(;r.id!==0;)i.push(r),r=this.byId(r.parent);return i.reverse()}findFiles(a,i="/"){const r=[],c=a.toLocaleLowerCase();return this.eachChild(d=>{d.name.toLowerCase().indexOf(c)!==-1&&r.push(d)},i),r}add(a,i){const r=this.byId(a.parent||"/"),c=a.data?[...a.data]:null;a.data=null,super.add(a,i??r.data?r.data.length:0),c&&c.forEach(d=>this.add(d))}renameFiles(a,i,r){const c=this.byId(a),d=this.normalizeFile(c,i),h=[];return d.data?.forEach(p=>h.push(this.renameFiles(p.id,d.id,r))),h.length&&(d.data=h),r[a]=d.id,d}copyFiles(a,i,r){const c={};return a.forEach(d=>{const h=this.renameFiles(d,i,c);this.add(h),r&&this.remove(d),c[d]=h.id}),c}moveFiles(a,i){if(this.byId(a[0]).parent!==i)return this.copyFiles(a,i,!0)}serialize(a="/"){const i=[],r=this.byId(a);return r?(r.data?.forEach(c=>{const{id:d,date:h,type:p,size:v,lazy:g}=c,w={id:d,date:h,type:p??"file"};g&&(w.lazy=g),v&&(w.size=v),i.push(w);const y=this.serialize(d);y.length&&i.push(...y)}),i):null}normalizeFile(a,i){const r=a.name,c=r.lastIndexOf("."),d=c!==-1?r.slice(c+1):"",h=d?`.${d}`:"";let p=c!==-1?r.slice(0,c):r,v=i+(i==="/"?"":"/")+p;for(;this.byId(v+h);){const g=".new";v+=g,p+=g}return{...a,id:v+h,name:p+h,parent:i,ext:d.toLocaleLowerCase()}}},Y1=class extends H1{in;_router;constructor(a){super({writable:a,async:!1});const i=[];for(let d=0;d<2;d++)i.push({in:["data",`panels.${d}.path`],out:[`panels.${d}._crumbs`],exec:h=>{const{data:p,panels:v}=this.getState(),g=[];g[d]={_crumbs:p.getParents(v[d].path)},this.setState({panels:g},h)}}),i.push({in:["data",`panels.${d}.path`,`panels.${d}._sorts`,"search"],out:[`panels.${d}._files`],exec:h=>{const{data:p,panels:v,search:g}=this.getState();let w;g?w=p.findFiles(g,v[d].path):w=p.byId(v[d].path)?.data||[];const{path:y,_sorts:b}=v[d];w=fx(w,b[y]);const j=[];j[d]={_files:w},this.setState({panels:j},h)}}),i.push({in:["data",`panels.${d}.selected`,`panels.${d}._sorts`],out:[`panels.${d}._selected`],exec:h=>{const{data:p,panels:v}=this.getState(),g=[];v[d].selected.forEach(k=>{const M=p.byId(k);M&&g.push(M)});const{path:w,_sorts:y}=v[d],b=fx(g,y[w]),j=[];j[d]={_selected:b},this.setState({panels:j},h)}});this._router=new U1(super.setState.bind(this),i,{data:d=>new V1(d)});const r=this.in=new $1;r.on("select-file",({id:d,toggle:h,range:p,panel:v,type:g})=>{const{panels:w,activePanel:y}=this.getState();typeof v>"u"&&(v=y),d||(h=p=!1);let b=[...w[v].selected];if(h){const k=b.indexOf(d);k===-1?b.push(d):b.splice(k,1)}else if(p&&w[v]._lastSelected){const k=w[v]._files;let M=k.findIndex(A=>A.id==w[v]._lastSelected),R=k.findIndex(A=>A.id==d);R<M&&([M,R]=[R,M]);const C=k.slice(M,R+1).map(A=>A.id);b=[...new Set([...b,...C])]}else b=d?[d]:[];const j=[];j[v]={selected:b,_lastSelected:d,_selectNavigation:g==="navigation"},this.setState({panels:j})}),r.on("set-path",({id:d,panel:h,selected:p})=>{const{data:v,activePanel:g}=this.getState(),w=v.byId(d);if(w){const y=[];typeof h>"u"&&(h=g),y[h]={path:d},this.setState({panels:y}),r.exec("select-file",{panel:h}),p&&p.forEach(b=>r.exec("select-file",{id:b,panel:h,toggle:!0})),w.lazy&&r.exec("request-data",{id:d})}}),r.on("provide-data",({id:d,data:h})=>{const{mode:p,data:v}=this.getState(),g=v.byId(d);g&&(g.lazy||(g.data=[]),g.lazy=!1,v.parse(h,d,p==="search"),this.setState({data:v}))}),r.on("open-tree-folder",({id:d,mode:h})=>{const{data:p}=this.getState();p.update(d,{open:h}),this.setState({data:p})}),r.on("show-preview",({mode:d})=>{this.setState({preview:d})}),r.on("rename-file",d=>{const{id:h,name:p}=d,{data:v,panels:g}=this.getState(),w=v.byId(h);if(w.name!==p){w.name=p;const y=v.normalizeFile(w,w.parent);d.newId=y.id,y.data=null,v.add(y);let b={[h]:y.id};w.data?.forEach(k=>b={...v.moveFiles([k.id],y.id),...b});const j=g.map(k=>({selected:k.selected,_crumbs:k._crumbs,_lastSelected:k._lastSelected,_sorts:k._sorts}));v.remove(h),this._updatePanels(j,b),this.setState({data:v,panels:j})}}),r.on("create-file",d=>{const{file:h,parent:p}=d,{data:v}=this.getState(),g=v.normalizeFile(h,p);g.type=h.type||"file",d.newId=g.id,v.add(g),this.setState({data:v}),r.exec("select-file",{id:g.id})}),r.on("delete-files",({ids:d})=>{const{data:h,panels:p}=this.getState(),v=p.map(g=>({selected:g.selected,_crumbs:g._crumbs,_lastSelected:g._lastSelected,_sorts:g._sorts}));d.forEach(g=>h.remove(g)),this._updatePanels(v,{}),this.setState({data:h,panels:v})}),r.on("copy-files",d=>{const{ids:h,target:p}=d;if(this._isPlacedIntoSelf(h,p)){console.error("You cannot copy a folder into itself"),d.skipProvider=!0;return}const{data:v,panels:g,activePanel:w}=this.getState(),y=v.copyFiles(h,p);d.newIds=h.map(b=>y[b]),this.setState({data:v}),g[w].path==p&&(r.exec("select-file",{}),h.forEach(b=>{r.exec("select-file",{id:y[b],toggle:!0})}))}),r.on("move-files",d=>{const{ids:h,target:p}=d;if(this._isPlacedIntoSelf(h,p)){console.error("You cannot move a folder into itself"),d.skipProvider=!0;return}const{data:v,panels:g,activePanel:w}=this.getState(),y=v.moveFiles(h,p);if(y){d.newIds=h.map(j=>y[j]);const b=g.map(j=>({selected:j.selected,_crumbs:j._crumbs,_lastSelected:j._lastSelected,_sorts:j._sorts}));this._updatePanels(b,y,!0),this.setState({data:v,panels:b}),g[w].path==p&&(r.exec("select-file",{}),h.forEach(j=>{r.exec("select-file",{id:y[j],toggle:!0})}))}});let c=null;r.on("filter-files",({text:d})=>{if(!d){c&&this.setState({...c});return}r.exec("select-file",{});const{panels:h,mode:p}=this.getState();c||(c={panels:h,mode:p,search:""}),this.setState({mode:"search",search:d})}),r.on("set-mode",({mode:d})=>{const{activePanel:h}=this.getState(),p=[];p[h]={_selectNavigation:!1};const v={mode:d,search:"",panels:p};c=null,this.setState(v)}),r.on("set-active-panel",({panel:d})=>{this.setState({activePanel:d})}),r.on("sort-files",({key:d,order:h,panel:p,path:v})=>{const{activePanel:g,panels:w}=this.getState();p=p??g,v=v??w[p].path;const y=[];y[p]={_sorts:{...w[p]._sorts,[v]:{key:d,order:h}}},this.setState({panels:y})}),this.initOnce()}initOnce(){const a=[];for(let r=0;r<2;r++)a[r]=dx({_crumbs:[],_files:[],_selected:[],_sorts:{},path:"/",selected:[],...a[r]});const i={panels:dx(a),data:[],search:""};this._router.init(i)}init(a){const i={...a};this._router.init(i)}setState(a,i){return this._router.setState(a,i)}getFile(a){const{data:i}=this.getState();return i.byId(a)||null}serialize(a){const{data:i}=this.getState();return i.serialize(a)}_updatePanels(a,i,r){const{data:c}=this.getState();a.forEach(d=>{const h=[];d.selected.forEach(g=>{c.byId(g)?h.push(g):!r&&i[g]&&h.push(i[g])}),d.selected=h,c.byId(d._lastSelected)||(d._lastSelected=r?null:i[d._lastSelected]||null);const p={};Object.keys(d._sorts).forEach(g=>{c.byId(g)?p[g]=d._sorts[g]:i[g]&&!r&&(p[i[g]]=d._sorts[g])}),d._sorts=p;const v=d._crumbs[d._crumbs.length-1];v?.id!=="/"&&(i[v.id]?d.path=i[v.id]:c.byId(v.id)||(d.path="/"))})}_isPlacedIntoSelf(a,i){return a.some(r=>r===i||this.getState().data.getParents(i).some(c=>c.id===r))}};function W1(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 K1(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function Q1(n,a="data-id"){const i=K1(n,a);return i?i.getAttribute(a):null}new Date().valueOf();function X1(n,a){const{api:i}=a;function r(d,h){const p=a.getPanel(),v=p.selected,g=h.ctrlKey||h.metaKey,w=h.shiftKey;let y;const b=v?.[0]?i.getFile(v[0]):null;v?.length?v.length>1?y=a.menuOptions("multiselect"):y=a.menuOptions(b.type,b):y=a.menuOptions("body");const j=`${g?"ctrl+":""}${w?"shift+":""}${d}`,k=y?y.find(R=>R.hotkey?.toLowerCase()===j):!1,M=a.performAction;if(k)switch(j){case"ctrl+c":M("copy");break;case"ctrl+x":M("move");break;case"ctrl+v":M("paste",b);break;case"delete":M("delete");break;case"ctrl+r":h.preventDefault(),M("rename",b);break;case"ctrl+d":h.preventDefault(),M("download",b);break;default:k.handler?.({context:b})}switch(d){case"enter":{if(g||w)break;const{_crumbs:R,_selectNavigation:C}=p;if(C){const A=G1(R);if(A){const E=_h(A,R);i.exec("set-path",{id:A,selected:[E]})}}else if(v.length===1){const A=i.getFile(v[0]);A&&i.exec(A.type==="folder"?"set-path":"open-file",{id:A.id})}break}case"arrowup":case"arrowleft":{const{_files:R,_selected:C,path:A,_selectNavigation:E}=p;let U;if(C.length){const F=C.at(0).id,P=R.findIndex(L=>L.id===F);if(P!==-1){const L=P-1;R[L]?U=R[L].id:A!=="/"&&!(g||w)&&i.exec("select-file",{type:"navigation"})}}else{if(E)break;if(A!=="/"){i.exec("select-file",{type:"navigation"});break}U=R.at(0)?.id}U&&i.exec("select-file",{id:U,toggle:g,range:w});break}case"arrowdown":case"arrowright":{const{_files:R,_selected:C,path:A,_selectNavigation:E}=p;let U;if(C.length){const F=C.at(-1).id,P=R.findIndex(L=>L.id===F);if(P!==-1){const L=P+1;R[L]&&(U=R[L].id)}}else{if(A!=="/"&&!E){i.exec("select-file",{type:"navigation"});break}U=R.at(0)?.id}U&&i.exec("select-file",{id:U,toggle:g,range:w});break}}}function c(d){const h=d.code.replace("Key","").toLowerCase();r(h,d),h=="tab"&&setTimeout(()=>{const p=document.activeElement;p.className.indexOf("table")!=-1&&i.exec("set-active-panel",{panel:+Q1(p,"data-panel")})})}return n.addEventListener("keydown",c),{destroy:()=>{n.removeEventListener("keydown",c)}}}function Z1(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}function J1(n,a="data-id"){const i=n.getAttribute(a);return i?eC(i):null}function eC(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function tC(){return{detect:()=>!0,addEvent:function(n,a,i){return n.addEventListener(a,i),()=>n.removeEventListener(a,i)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var nC=tC();new Date().valueOf();function By(n){const[a,i]=f.useState(n),r=f.useRef(n);return f.useEffect(()=>{if(r.current!==n){if(Array.isArray(r.current)&&Array.isArray(n)&&r.current.length===0&&n.length===0)return;r.current=n,i(n)}},[n]),[a,i]}function aC(n,a,i){const[r,c]=f.useState(()=>a);return n||console.warn(`Writable ${i} is not defined`),f.useEffect(()=>n?n.subscribe(h=>{c(()=>h)}):void 0,[n]),r}function Xe(n,a){const i=n.getState(),r=n.getReactiveState();return aC(r[a],i[a],a)}function sC(n,a){const i=f.useRef(a);i.current=a;const[r,c]=f.useState(1);return f.useEffect(()=>n.subscribe(h=>{i.current=h,c(p=>p+1)}),[n]),[i.current,r]}function ns(n,a){const i=n.getState(),r=n.getReactiveState();return sC(r[a],i[a])}function Fy(n){const a={};return n.split(";").forEach(i=>{const[r,c]=i.split(":");if(c){let d=r.trim();d.indexOf("-")&&(d=d.replace(/-([a-z])/g,(h,p)=>p.toUpperCase())),a[d]=c.trim()}}),a}function Hy(n){let a=n,i=[];return{subscribe:p=>{i.push(p),p(a)},unsubscribe:p=>{i=i.filter(v=>v!==p)},set:p=>{a=p,i.forEach(v=>v(a))},update:p=>{a=p(a),i.forEach(v=>v(a))}}}function hx(n,a,i){function r(c){const d=Z1(c);if(!d)return;const h=J1(d);if(typeof a=="function")return a(h,c);let p,v=c.target;for(;v!=d;){if(p=v.dataset?v.dataset.action:null,p&&a[p]){a[p](h,c);return}v=v.parentNode}a[i]&&a[i](h,c)}return nC.addEvent(n,i,r)}function lC(n,a){const i=[hx(n,a,"click")];return a.dblclick&&i.push(hx(n,a.dblclick,"dblclick")),()=>{i.forEach(r=>r())}}function Uy(n,a){return n.map((i,r)=>{const c=a(i,r);return i.data&&i.data.length&&(c.data=Uy(i.data,a)),c}).filter(Boolean)}function $y(n,a){const i=[];return n.forEach(r=>{if(r.data){const c=$y(r.data,a);c.length&&i.push({...r,data:c})}else a(r)&&i.push(r)}),i}function iC(n){return Uy(n,(a,i)=>{const r={...a,id:a.id||Mh()};return r.type&&(r.comp=r.type),r.comp==="separator"&&n[i-1]?.comp==="separator"?null:r})}const Py={};function rC(n){return Py[n]||n}function oC(n,a){Py[n]=a}function cC({onClick:n,onShow:a,option:i}){const r=f.useRef(null),c=f.useCallback(()=>{a(i.data?i.id:!1,r.current)},[a,i]),d=f.useCallback(p=>{if(i.data){p.stopPropagation(),a(i.id,r.current);return}n(p)},[n,a,i]),h=f.useMemo(()=>i&&i.comp?rC(i.comp):null,[i]);return l.jsxs("div",{ref:r,className:`wx-cDCz9rZQ wx-option ${i.css||""} ${i.disabled?"wx-disabled":""}`,"data-id":jn(i.id),onMouseEnter:c,onClick:d,children:[i.icon?l.jsx("i",{className:`wx-cDCz9rZQ wx-icon ${i.icon}`}):null,i.comp?h?l.jsx(h,{item:i,option:i}):null:l.jsxs("span",{className:"wx-cDCz9rZQ wx-value",children:[" ",i.text," "]}),i.subtext?l.jsx("span",{className:"wx-cDCz9rZQ wx-subtext",children:i.subtext}):null,i.data?l.jsx("i",{className:"wx-cDCz9rZQ wx-sub-icon wxi-angle-right"}):null]})}function zh({options:n,left:a=0,top:i=0,at:r="bottom",parent:c=null,mount:d=null,context:h=null,css:p="",onClick:v,onCancel:g}){const[w,y]=f.useState(-1e4),[b,j]=f.useState(-1e4),[k,M]=f.useState(20),[R,C]=f.useState(),A=f.useRef(null),[E,U]=f.useState(!1),[F,P]=f.useState(null),L=f.useCallback(()=>{const ce=ky(A.current,c,r,a,i);ce&&(y(ce.x),j(ce.y),C(ce.width));let Q=ce?.z??20;const _=c?X0(c):[];let Y=0;for(const $ of _){const H=parseInt(getComputedStyle($).zIndex,10);H>Y&&(Y=H)}Y>=Q&&(Q=Y+1),M(Q)},[c,r,a,i]);f.useEffect(()=>{d&&d(L)},[]);const I=f.useCallback(()=>{U(!1)},[]),de=f.useCallback((ce,Q)=>{U(ce),P(Q)},[]),W=f.useMemo(()=>iC(n),[n]);f.useEffect(()=>{L()},[c,L]);const ue=f.useRef(v),Z=f.useRef(g),le=f.useRef(c);return f.useEffect(()=>{ue.current=v},[v]),f.useEffect(()=>{Z.current=g},[g]),f.useEffect(()=>{le.current=c},[c]),f.useEffect(()=>{if(!A.current)return;function ce(Q){Z.current?Z.current(Q):ue.current&&ue.current({action:null,option:null})}return qs(A.current,{callback:ce,modal:!0,parent:()=>le.current}).destroy},[]),l.jsx("div",{ref:A,"data-wx-menu":"true",className:`wx-XMmAGqVx wx-menu ${p}`,style:{position:"absolute",top:b+"px",left:w+"px",width:R,zIndex:k},onMouseLeave:I,children:W.map(ce=>l.jsxs(f.Fragment,{children:[ce.comp==="separator"?l.jsx("div",{className:"wx-XMmAGqVx wx-separator"}):l.jsx(cC,{option:ce,onShow:de,onClick:Q=>{if(!ce.data&&!Q.defaultPrevented){const _={context:h,action:ce,option:ce,event:Q};ce.handler&&ce.handler(_),v&&v(_),Q.stopPropagation()}}}),ce.data&&E===ce.id?l.jsx(zh,{css:p,options:ce.data,at:"right-overlap",parent:F,context:h,onClick:v,onCancel:g}):null]},ce.id))})}const qy=f.forwardRef(function(n,a){const{options:i,at:r="bottom",resolver:c=null,dataKey:d="contextId",filter:h=null,css:p="",children:v,onClick:g}=n,[w,y]=f.useState(null),[b,j]=f.useState(null),[k,M]=f.useState(0),[R,C]=f.useState(0),A=f.useRef(null),E=f.useMemo(()=>`data-${d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,[d]),U=f.useMemo(()=>w!==null&&h?$y(i,I=>h(I,w)):i,[w,h,i]);function F(I){j(null),g&&g(I)}function P(I){if(A.current===I){A.current=null;return}j(null),g&&g({action:null,option:null})}const L=f.useCallback((I,de)=>{if(!I){j(null);return}if(I.defaultPrevented)return;const W=I.target;if(W&&W.dataset&&W.dataset.menuIgnore)return;if(b&&b===W){j(null),I.preventDefault();return}M(I.clientX+1),C(I.clientY+1);let ue=typeof de<"u"?de:yc(W,E);c&&(ue=c(ue,I),!ue)||(y(ue),j(W),A.current=I.nativeEvent||I,I.preventDefault())},[b,E,c]);return f.useImperativeHandle(a,()=>({show:L}),[L]),l.jsxs(l.Fragment,{children:[v?l.jsx("span",{onClick:L,"data-menu-ignore":"true",children:typeof v=="function"?v():v}):null,b?l.jsx(Nh,{children:l.jsx(zh,{css:p,at:r,top:R,left:k,parent:b,context:w,onClick:F,onCancel:P,options:U},b)}):null]})}),uC=f.forwardRef(function(n,a){const{options:i,at:r="bottom",css:c="",children:d,onClick:h}=n,[p,v]=f.useState(null),g=f.useRef(null);function w(k){v(null),h&&h(k)}function y(k){if(g.current===k){g.current=null;return}v(null),h&&h({action:null,option:null})}const b=f.useCallback(k=>{v(k.target),g.current=k.nativeEvent||k,k.preventDefault()},[]);f.useImperativeHandle(a,()=>({show:b}),[b]);function j(k){let M=k.target;for(;!M.dataset.menuIgnore;)v(M),M=M.parentNode}return l.jsxs(l.Fragment,{children:[l.jsx("span",{onClick:j,"data-menu-ignore":"true",children:d}),p?l.jsx(Nh,{children:l.jsx(zh,{css:c,at:r,parent:p,options:i,onClick:w,onCancel:y})}):null]})}),dC=f.forwardRef(function(n,a){const{options:i,at:r="bottom",resolver:c=null,dataKey:d="contextId",filter:h=null,css:p="",children:v,onClick:g}=n,w=f.useRef(null),y=f.useCallback((b,j)=>{w.current.show(b,j)},[]);return f.useImperativeHandle(a,()=>({show:y}),[y]),l.jsxs(l.Fragment,{children:[v?l.jsx("span",{onContextMenu:y,"data-menu-ignore":"true",children:v}):null,l.jsx(qy,{css:p,at:r,options:i,resolver:c,dataKey:d,filter:h,ref:w,onClick:g})]})}),fC={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 mC=class{constructor(a,i,r,c,d){this.setFiles=a,this.setReady=i,this.setSignal=r,this.setDrag=c,d&&d.length&&this.setFiles(d)}open(a){this.setSignal(["click",a||{}])}getState(){let a="server";const i=this.files;for(let r=0;r<i.length;r++){if(i[r].status==="client")return"client";i[r].status==="error"&&(a="error")}return a}droparea(a,i){i=i||{};const r=()=>{i.dragEnter&&i.dragEnter(),this.setDrag(!0)},c=()=>{i.dragLeave&&i.dragLeave(),this.setDrag(!1)},d=p=>{p.preventDefault()},h=p=>{p.preventDefault(),this.setDrag(!1),this.setSignal(["drop",i,p]),i.dragLeave&&i.dragLeave(),i.drop&&i.drop()};return a.addEventListener("dragenter",r),a.addEventListener("dragleave",c),a.addEventListener("dragover",d,!0),a.addEventListener("drop",h,!0),()=>{a.removeEventListener("dragenter",r),a.removeEventListener("dragleave",c),a.removeEventListener("dragover",d,!0),a.removeEventListener("drop",h,!0)}}updateFile(a,i){const r=this.files.findIndex(d=>d.id===a);if(r===-1)return;const c=[...this.files];return c[r]={...c[r],...i},this.files=c,this.setFiles(this.files),this.files[r]}deleteFile(a){this.files=this.files.filter(i=>i.id!==a),this.setFiles(this.files)}addFile(a,i){i?this.files=[...this.files,a]:this.files=[a],this.setFiles(this.files)}deleteAll(){this.files=[],this.setFiles(this.files)}};function Gy(n){const[a,i]=f.useState([]),[r,c]=f.useState(Promise.resolve(null)),[d,h]=f.useState(null),[p,v]=f.useState(!1),g=f.useRef();return g.current||(g.current=new mC(i,c,h,v,n)),g.current.files=a,g.current.ready=r,g.current.signal=d,g.current.drag=p,g.current}function hC(n,a){{if(n){const i=n.getGroup(a);if(i)return i}return Sc(fC).getGroup(a)}}const pC=()=>Math.random().toString(36).substr(2,9),gC=({data:n,accept:a="",multiple:i=!0,folder:r=!1,uploadURL:c="",apiOnly:d=!1,disabled:h=!1,children:p,onChange:v,onUpload:g})=>{const w=f.useRef(null),y=f.useRef(null),[b,j]=f.useState({}),k=Gy(),M=n||k,R=f.useContext(Mn.i18n),C=hC(R,"uploader");f.useEffect(()=>{w.current&&r&&(w.current.webkitdirectory=!0)},[r]),f.useEffect(()=>{if(!d&&y.current&&!h)return M.droparea(y.current)},[d,h,y]);const A=W=>{const ue=new FormData;return ue.append("upload",W.file),fetch(c,{method:"POST",body:ue}).then(Z=>Z.json()).then(Z=>({id:W.id,...Z}),()=>({id:W.id,status:"error"})).catch(Z=>(console.log(Z),{id:W.id,status:"error"}))},E=(W,ue)=>{const Z=M.updateFile(W,ue),le={...Z,status:M.getState()};Z&&Z.uploaded&&Z.uploaded(le),g&&g(le),Z.temp&&M.deleteFile(Z.id)},U=W=>{if(!W)return;const ue=typeof c=="function"?c(W):A(W);M.setReady(ue.then(Z=>{Z.status=Z.status||"server",E(W.id,Z)}).catch(Z=>{E(W.id,{status:"error",error:Z})}))},F=(W,ue)=>{const Z={...ue||b,id:pC(),status:"client",name:W.name,file:W};Z.selected&&Z.selected(Z),v&&v(Z),M.addFile(Z,i),U(Z),w.current&&(w.current.value="")},P=(W,ue,Z)=>{W.isFile?W.file(le=>{F(le,Z)}):W.isDirectory&&W.createReader().readEntries(le=>{le.forEach(ce=>{P(ce,ue+ce.name+"/",Z)})})},L=W=>{Array.from(W.target.files).forEach(ue=>F(ue))},I=(W,ue)=>{Array.from(W.dataTransfer.items).forEach(Z=>{const le=Z.webkitGetAsEntry();le&&P(le,"",ue)})},de=()=>{w.current&&w.current.click()};return f.useEffect(()=>{if(M.signal){const[W,ue,Z]=M.signal;j(ue),W==="click"?de():W==="drop"&&I(Z,ue),M.setSignal(null)}},[M.signal]),d?l.jsxs(l.Fragment,{children:[l.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:L,accept:a,multiple:i,disabled:h}),p]}):l.jsxs("div",{className:`wx-at1A8tb8 wx-label ${M.drag?"wx-active":""} ${h?"wx-disabled":""}`,ref:y,children:[l.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:L,accept:a,multiple:i,disabled:h}),p||l.jsx("div",{className:"wx-at1A8tb8 wx-dropzone",children:l.jsxs("span",{children:[C("Drop files here or")," ",l.jsx("span",{className:"wx-at1A8tb8 wx-action",onClick:de,children:C("select files")})]})})]})};new Date().valueOf();function vC(n,a){if(Object.keys(n).length!==Object.keys(a).length)return!1;for(const i in a){const r=n[i],c=a[i];if(!Nd(r,c))return!1}return!0}function Nd(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 i=n.length-1;i>=0;i--)if(!Nd(n[i],a[i]))return!1;return!0}else return vC(n,a);return n===a}function rh(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(n instanceof Array)return n.map(rh);const a={};for(const i in n)a[i]=rh(n[i]);return a}var Vy=2,xC=class{constructor(n){n&&(this._writable=n.writable,this._async=n.async),this._values={},this._state={}}setState(n,a=0){const i={};return this._wrapProperties(n,this._state,this._values,"",i,a),i}getState(){return this._values}getReactive(){return this._state}_wrapProperties(n,a,i,r,c,d){for(const h in n){const p=a[h],v=i[h],g=n[h];if(p&&(v===g&&typeof g!="object"||g instanceof Date&&v instanceof Date&&v.getTime()===g.getTime()))continue;const w=r+(r?".":"")+h;p?(p.__parse(g,w,c,d)&&(i[h]=g),d&Vy?c[w]=p.__trigger:p.__trigger()):(g&&g.__reactive?a[h]=this._wrapNested(g,g,w,c):a[h]=this._wrapWritable(g),i[h]=g),c[w]=c[w]||null}}_wrapNested(n,a,i,r){const c=this._wrapWritable(n);return this._wrapProperties(n,c,a,i,r,0),c.__parse=(d,h,p,v)=>(this._wrapProperties(d,c,a,h,p,v),!1),c}_wrapWritable(n){const a=[],i=function(){for(let r=0;r<a.length;r++)a[r](n)};return{subscribe:r=>(a.push(r),this._async?setTimeout(r,1,n):r(n),()=>{const c=a.indexOf(r);c>=0&&a.splice(c,1)}),__trigger:()=>{a.length&&(this._async?setTimeout(i,1):i())},__parse:function(r){return n=r,!0}}}},yC=class{constructor(n,a,i,r){typeof n=="function"?this._setter=n:this._setter=n.setState.bind(n),this._routes=a,this._parsers=i,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(c=>{c.in.forEach(d=>{const h=this._triggers.get(d)||[];h.push(c),this._triggers.set(d,h)}),c.out.forEach(d=>{const h=this._sources.get(d)||{};c.in.forEach(p=>h[p]=!0),this._sources.set(d,h)})}),this._routes.forEach(c=>{c.length=Math.max(...c.in.map(d=>Yy(d,this._sources,1)))}),this._bus=r}init(n){const a={};for(const i in n)if(this._prev[i]!==n[i]){const r=this._parsers[i];a[i]=r?r(n[i]):n[i]}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,Vy);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 i=n.signals[a];i&&i()}}}setState(n,a=[]){const i=this._setter(n);return this._triggerUpdates(i,a),i}_triggerUpdates(n,a){const i=Object.keys(n),r=!a.length;a=a||[];for(let c=0;c<i.length;c++){const d=i[c],h=this._triggers.get(d);h&&h.forEach(p=>{a.indexOf(p)==-1&&a.push(p)})}r&&this._execNext(a)}_execNext(n){for(;n.length;){n.sort((i,r)=>i.length<r.length?1:-1);const a=n[n.length-1];n.splice(n.length-1),a.exec(n)}}};function Yy(n,a,i){const r=a.get(n);if(!r)return i;const c=Object.keys(r).map(d=>Yy(d,a,i+1));return Math.max(...c)}var wC=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(n,a,i){let r=this._handlers[n];r?i&&i.intercept?r.unshift(a):r.push(a):r=this._handlers[n]=[a],i&&i.tag&&this._tag.set(a,i.tag)}intercept(n,a,i){this.on(n,a,{...i,intercept:!0})}detach(n){for(const a in this._handlers){const i=this._handlers[a];for(let r=i.length-1;r>=0;r--)this._tag.get(i[r])===n&&i.splice(r,1)}}async exec(n,a){const i=this._handlers[n];if(i)for(let r=0;r<i.length;r++){const c=i[r](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 bC(n){return a=>a[n]}function SC(n){return(a,i)=>a[n]=i}function ui(n,a){return(a.getter||bC(a.id))(n)}function Em(n,a,i){return(a.setter||SC(a.id))(n,i)}function CC(n,a){const i=document.createElement("a");i.href=URL.createObjectURL(n),i.download=a,document.body.appendChild(i),i.click(),document.body.removeChild(i)}function ci(n,a){let i=ui(n,a)??"";return a.template?i=a.template(i,n,a):a.optionsMap&&(Array.isArray(i)?i=i.map(r=>a.optionsMap.get(r)).join(", "):i=a.optionsMap.get(i)),typeof i>"u"?"":i+""}function jC(n,a){const i=/\n|"|;|,/;let r="";const c=a.rows||`
11
+ `,d=a.cols||" ",h=n._columns,p=n.flatData;a.header!==!1&&h[0].header&&(r=px("header",h,r,d,c));for(let v=0;v<p.length;v++){const g=[];for(let w=0;w<h.length;w++){let y=ci(p[v],h[w]);i.test(y)&&(y='"'+y.replace(/"/g,'""')+'"'),g.push(y)}r+=(r?c:"")+g.join(d)}return a.footer!==!1&&h[0].footer&&(r=px("footer",h,r,d,c)),r}function px(n,a,i,r,c){const d=/\n|"|;|,/;for(let h=0;h<a[0][n].length;h++){const p=[];for(let v=0;v<a.length;v++){let g=(a[v][n][h].text||"")+"";d.test(g)&&(g='"'+g.replace(/"/g,'""')+'"'),p.push(g)}i+=(i?c:"")+p.join(r)}return i}const kC="portrait",MC=100,AC="a4",NC={a3:{width:11.7,height:16.5},a4:{width:8.27,height:11.7},letter:{width:8.5,height:11}};function TC(n,a){const i=[];let r=[],c=0;const d=n.filter(p=>!p.hidden),h=RC(a);return d.forEach((p,v)=>{c+p.width<=h?(c+=p.width,r.push(p)):(r.length&&i.push(r),r=[p],c=p.width),v===d.length-1&&r.length&&i.push(r)}),i}function gx(n,a,i){const r=[];return n.forEach((c,d)=>{const h=c[a];for(let p=0;p<i.length;p++){r[p]||(r[p]=[]);const v={...h[p]};if(r[p][d]!==null){if(!d&&!v.rowspan&&!v.colspan){let g=1,w=n[d+g][a][p],y=v.width;for(;!w.rowspan&&!w.colspan;)g++,w=n[d+g][a][p],y+=w.width;v.colspan=g,v.width=y,v.height=i[p]}if(r[p].push(v),!v.collapsed&&v.colspan>1){let g=v.colspan-1;if(v.colspan+d>n.length){const w=v.colspan-(v.colspan+d-n.length);v.colspan=w,v.width=n.slice(d,d+g+1).reduce((y,b)=>y+b.width,0),w>1&&(g=w-1)}for(let w=0;w<g;w++)r[p].push(null)}if(v.rowspan>1){const g=v.rowspan;for(let w=1;w<g;w++)r[p+w]||(r[p+w]=[]),r[p+w].push(null)}}}if(c.collapsed)for(let p=0;p<r.length;p++){const v=r[p],g=v[d];if(g&&g.collapsed){if(v[d]=null,!p)break}else{const w=g||v.findLast(y=>y?.colspan>=1);w&&(w.colspan=w.colspan-1,w.width=w.width-c.width)}}}),r.map(c=>c.filter(d=>d&&d.colspan!==0))}function RC(n){const{mode:a,ppi:i,paper:r}=n,{width:c,height:d}=NC[r];return EC(a==="portrait"?c:d,i)}function EC(n,a){return n*a}function DC(n={}){const{mode:a,ppi:i,paper:r}=n;return{mode:a||kC,ppi:i||MC,paper:r||AC}}function Wy(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 LC(n,a,i){let r=n[i.id];if(i.filter.type==="richselect"&&r){const c=i.filter.config?.options||a.find(({id:d})=>d==i.id).options;c&&(r=c.find(({id:d})=>d==r).label)}return r??""}const vx=["resize-column","hide-column","update-cell"],_C=["delete-row","update-row","update-cell"],zC=["move-item"],OC=["resize-column","move-item"];class IC{undo=[];redo=[];progress={};in;getState;setState;_previousValues={};constructor(a,i,r){this.in=a,this.getState=i,this.setState=r,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:i}=a,{data:r}=this.getPrev(),c=r.findIndex(d=>d.id===i);return{action:"add-row",data:{id:i,row:r[c],before:c<r.length-1?r[c+1].id:void 0},source:{action:"delete-row",data:a}}}},"update-cell":{handler:a=>{const{id:i,column:r}=a,c=this.getRow(i),d=this.getColumn(r),h=ui(c,d);return Nd(h,a.value)?null:{action:"update-cell",data:{id:i,column:r,value:h},source:{action:"update-cell",data:a}}}},"update-row":{handler:a=>{const{id:i,row:r}=a,c=this.getRow(i);for(const d in r)Object.keys(c).includes(d)||(c[d]=void 0);return{action:"update-row",data:{id:i,row:c},source:{action:"update-row",data:a}}}},"copy-row":{handler:a=>{const{id:i}=a,{data:r}=this.getState(),c=r.findIndex(h=>h.id===i),d=r[c];return{action:"delete-row",data:{id:i},source:{action:"add-row",data:{id:i,row:d,before:c<r.length-1?r[c+1].id:void 0}}}}},"resize-column":{handler:a=>{const{id:i,width:r}=a,c=this.getColumn(i),{_sizes:d}=this.getState();return{action:"resize-column",data:{id:i,width:c.width??d.columnWidth},source:{action:"resize-column",data:{id:i,width:r}}}}},"hide-column":{handler:a=>{const{id:i}=a,r=this.getColumn(i);return{action:"hide-column",data:{id:i,mode:r.hidden},source:{action:"hide-column",data:a}}}},"collapse-column":{handler:a=>{const{id:i,row:r,mode:c}=a;return{action:"collapse-column",data:{id:i,row:r,mode:typeof c=="boolean"?!c:c},source:{action:"collapse-column",data:a}}}},"move-item":{handler:a=>{const{id:i,target:r,mode:c}=a,{flatData:d}=this.getPrev(),h=d.findIndex(p=>p.id===i);return{action:"move-item",data:{id:i,target:d[h+(h?-1:1)].id,mode:h?"after":"before"},source:{action:"move-item",data:{id:i,target:r,mode:c}}}}},"open-row":{handler:a=>{const{id:i,nested:r}=a;return{action:"close-row",data:{id:i,nested:r},source:{action:"open-row",data:a}}}},"close-row":{handler:a=>{const{id:i,nested:r}=a;return{action:"open-row",data:{id:i,nested:r},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 i in a)this.in.intercept(i,r=>{if(!(r.eventSource==="undo"||r.eventSource==="redo"||r.skipUndo)){if(OC.includes(i)){(r.inProgress&&!this.progress[i]||typeof r.inProgress!="boolean")&&(zC.includes(i)&&this.setPrev("flatData"),vx.includes(i)&&this.setPrev("columns")),this.progress[i]=r.inProgress;return}_C.includes(i)&&this.setPrev("data"),vx.includes(i)&&this.setPrev("columns")}}),this.in.on(i,r=>{if(r.eventSource==="undo"||r.eventSource==="redo"||r.skipUndo||r.inProgress)return;const c=a[i].handler(r);c&&this.addToHistory(c)})}setPrev(a){this._previousValues[a]=rh(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:i}=this.getPrev();return this.getState().tree?this.getTreeRow(i,a):i.find(r=>r.id===a)}getTreeRow(a,i){for(let r=0;r<a.length;r++){if(a[r].id===i)return a[r];if(a[r].data){const c=this.getTreeRow(a[r].data,i);if(c)return c}}return null}getColumn(a){const{columns:i}=this.getPrev();return i.find(r=>r.id===a)}}function Ky(n,a){return typeof n>"u"||n===null?-1:typeof a>"u"||a===null?1:n===a?0:n>a?1:-1}function BC(n,a){return-Ky(n,a)}function FC(n,a){if(typeof a.sort=="function")return function(r,c){const d=a.sort(r,c);return n==="asc"?d:-d};const i=n==="asc"?Ky:BC;return function(r,c){return i(ui(r,a),ui(c,a))}}function HC(n,a){if(!n||!n.length)return;const i=n.map(r=>{const c=a.find(d=>d.id==r.key);return FC(r.order,c)});return n.length===1?i[0]:function(r,c){for(let d=0;d<i.length;d++){const h=i[d](r,c);if(h!==0)return h}return 0}}const Wu=28,UC=20;function $C(){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 yd(n,a,i,r,c){const d=document.createElement("div"),h=document.createElement("div"),p=document.body;c=c?`${c}px`:"auto";let v,g;h.className=a,d.classList.add(`wx-${i}-theme`),d.style.cssText=`height:auto;position:absolute;top:0px;left:100px;overflow:hidden;width=${c};white-space:nowrap;`,d.appendChild(h),p.appendChild(d),typeof n!="object"&&(n=[n]);for(let w=0;w<n.length;w++){h.innerText=n[w]+"";const y=d.getBoundingClientRect(),b=Math.ceil(y.width)+(r&&r.length?r[w]:0),j=Math.ceil(y.height);v=Math.max(v||0,b),g=Math.max(g||0,j)}return d.remove(),{width:v,height:g}}function xx(n,a,i,r,c){const d=[];for(let h=0;h<n.length;h++){const p=n[h][a],v=p.length;for(let g=0;g<v;g++){const{text:w,vertical:y,collapsed:b,rowspan:j,css:k}=p[g];if(!w){d[g]=Math.max(d[g]||0,r);continue}let M=0;if(y&&!b){let R=`wx-measure-cell-${a}`;if(R+=k?` ${k}`:"",M=yd(w,R,c).width,(j>1||!p[g+1])&&i>g+1){const C=j||i-g,A=d.slice(g,g+C).reduce((E,U)=>E+U,0);if(A<M){const E=Math.ceil((M-A)/C);for(let U=g;U<g+C;U++)d[U]=(d[U]||r)+E}continue}}d[g]=Math.max(d[g]||r,M)}}return d}function PC(n,a,i){const r=[],c=[];let d="wx-measure-cell-body";d+=n.css?` ${n.css}`:"";for(let h=0;h<a.length;h++){const p=a[h],v=ci(p,n);v&&(r.push(v),n.treetoggle?c.push(a[h].$level*Wu+(a[h].$count?Wu:0)+(n.draggable?Wu:0)):n.draggable&&c.push(Wu))}return yd(r,d,i,c).width}function qC(n,a){const i="wx-measure-cell-header",r=n.sort?UC:0;let c=n.header;if(typeof c=="string")return yd(c,i,a).width+r;let d;Array.isArray(c)||(c=[c]);for(let h=0;h<c.length;h++){const p=c[h],v=typeof p=="string"?p:p.text,g=i+(typeof p=="string"?"":` ${p.css}`);let w=yd(v,g,a).width;h===c.length-1&&(w+=r),d=Math.max(d||0,w)}return d}const GC={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&&YC(n,a):!0,multiselect:(n,a)=>!a||a?.length===0?!0:Array.isArray(n)?n?.some(i=>a.includes(i)):n&&a.includes(n)};function Qy(n){return GC[n]}function VC(n,a){const i=[];for(const r in n){const c=a.find(v=>v.id==r),{config:d,type:h}=c.header.find(v=>v.filter).filter,p=n[r];i.push(v=>{const g=ui(v,c);return d?.handler?d.handler(g,p):Qy(h)(g,p)})}return r=>{for(let c=0;c<i.length;c++)if(!i[c](r))return!1;return!0}}function YC(n,a){return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}let WC=class extends xC{in;_router;_branches;_xlsxWorker;_historyManager;constructor(a){super({writable:a,async:!1});const i={rowHeight:37,columnWidth:160,headerHeight:36,footerHeight:36};this._router=new yC(super.setState.bind(this),[{in:["columns","sizes","_skin"],out:["_columns","_sizes"],exec:c=>{const{columns:d,sizes:h,_skin:p}=this.getState(),v=this.copyColumns(d),g=v.reduce((b,j)=>Math.max(j.header.length,b),0),w=v.reduce((b,j)=>Math.max(j.footer.length,b),0);v.forEach(this.setCollapsibleColumns);const y=this.normalizeSizes(v,h,g,w,p);for(let b=0;b<v.length;b++)this.normalizeColumns(v,b,"header",g,y),this.normalizeColumns(v,b,"footer",w,y);this.setState({_columns:v,_sizes:y},c)}},{in:["data","tree","_filterIds"],out:["flatData","_rowHeightFromData"],exec:c=>{const{data:d,tree:h,dynamic:p,_filterIds:v}=this.getState(),g=v&&new Set(v),w=h?this.flattenRows(d,[],v):g?d.filter(b=>g.has(b.id)):d,y=!p&&w.some(b=>b.rowHeight);this.setState({flatData:w,_rowHeightFromData:y},c)}}],{sizes:c=>({...i,...c})});const r=this.in=new wC;r.on("close-editor",({ignore:c})=>{const{editor:d}=this.getState();d&&(c||r.exec("update-cell",d),this.setState({editor:null}))}),r.on("open-editor",({id:c,column:d})=>{let h=this.getState().editor;h&&r.exec("close-editor",{});const p=this.getRow(c),v=d?this.getColumn(d):this.getNextEditor(p);if(v?.editor){let g=v.editor;if(typeof g=="function"&&(g=g(p,v)),!g)return;h={column:v.id,id:c,value:ui(p,v)??"",renderedValue:ci(p,v),type:g.type||g},typeof g=="object"&&g.config&&(h.config=g.config,g.config.options&&(h.options=g.config.options)),v.options&&!h.options&&(h.options=v.options),this.setState({editor:h})}}),r.on("editor",({value:c})=>{let d=this.getState().editor;if(d){d={...d},d.value=c;const h=this.getColumn(d.column),p={...this.getRow(d.id)};Em(p,h,c),d.renderedValue=ci(p,h),this.setState({editor:d})}}),r.on("add-row",c=>{const d=this.getState();let{data:h}=d;const{select:p,_filterIds:v}=d,{row:g,before:w,after:y,select:b}=c;if(c.id=g.id=c.id||g.id||Ku(),w||y){const k=w||y,M=h.findIndex(R=>R.id===k);h=[...h],h.splice(M+(y?1:0),0,c.row)}else h=[...h,c.row];const j={data:h};v&&(j._filterIds=[...v,c.id]),this.setState(j),!(typeof b=="boolean"&&!b)&&(b||p)&&r.exec("select-row",{id:g.id,show:!0})}),r.on("delete-row",c=>{const{data:d,selectedRows:h,focusCell:p,editor:v}=this.getState(),{id:g}=c,w={data:d.filter(y=>y.id!==g)};this.isSelected(g)&&(w.selectedRows=h.filter(y=>y!==g)),v?.id===g&&(w.editor=null),this.setState(w),p?.row===g&&this.in.exec("focus-cell",{eventSource:"delete-row"})}),r.on("update-cell",c=>{const d=this.getState();let{data:h}=d;h=[...h];const{tree:p}=d,{id:v,column:g,value:w}=c,y=this.getColumn(g);if(p){const b={...this._branches[v]};Em(b,y,w);const j=this.updateTreeRow(b);b.$parent===0&&(h=j)}else{const b=h.findIndex(k=>k.id===v),j={...h[b]};Em(j,y,w),h[b]=j}this.setState({data:h})}),r.on("update-row",c=>{let{data:d}=this.getState();const{id:h,row:p}=c,v=d.findIndex(g=>g.id===h);d=[...d],d[v]={...d[v],...p},this.setState({data:d})}),r.on("select-row",({id:c,toggle:d,range:h,mode:p,show:v,column:g})=>{const w=this.getState(),{focusCell:y}=w;let{selectedRows:b}=w;if(b.length||(h=d=!1),h){const{data:j}=this.getState();let k=j.findIndex(R=>R.id===b[b.length-1]),M=j.findIndex(R=>R.id===c);k>M&&([k,M]=[M,k]),j.slice(k,M+1).forEach(R=>{this.isSelected(R.id)||b.push(R.id)})}else if(d&&this.isSelected(c)){if(p===!0)return;b=b.filter(j=>j!==c)}else if(d){if(p===!1)return;b.push(c)}else b=[c];this.setState({selectedRows:[...b]}),y?.row!==c&&this.in.exec("focus-cell",{eventSource:"select-row"}),v&&this.in.exec("scroll",{row:c,column:g})}),this.in.on("focus-cell",c=>{const{row:d,column:h,eventSource:p}=c,{_columns:v,split:g}=this.getState();d&&h?(this.setState({focusCell:{row:d,column:h}}),p!=="click"&&((!g.left||v.findIndex(w=>w.id===c.column)>=g.left)&&(!g.right||v.findIndex(w=>w.id===c.column)<v.length-g.right)?this.in.exec("scroll",{row:d,column:h}):this.in.exec("scroll",{row:d}))):this.setState({focusCell:null})}),r.on("resize-column",c=>{const{id:d,auto:h,maxRows:p,inProgress:v}=c;if(v===!1)return;let g=c.width||0;const w=[...this.getState().columns],y=this.getColumn(d);if(h){if(h==="data"||h===!0){const{flatData:b,_skin:j}=this.getState();let k=b.length;p&&(k=Math.min(p,k));const M=b.slice(0,k);g=PC(y,M,j)}if(h==="header"||h===!0){const{_skin:b}=this.getState();g=Math.max(qC(y,b),g)}}y.width=Math.max(17,g),delete y.flexgrow,this.setState({columns:w})}),r.on("hide-column",c=>{const{id:d,mode:h}=c,p=[...this.getState().columns],v=this.getColumn(d),g=p.reduce((w,y)=>w+(y.hidden?0:1),0);!h||g>1?(v.hidden=!v.hidden,this.setState({columns:p})):c.skipUndo=!0}),r.on("sort-rows",c=>{const{key:d,add:h,sort:p}=c,v=this.getState(),{columns:g,data:w,tree:y}=v;if(p){const A=[...w];A.sort(p),this.setState({data:A});return}const{order:b="asc"}=c;let j=v.sortMarks;const k=Object.keys(j),M=k.length;!h||!M||M===1&&j[d]?j={[d]:{order:b}}:(M===1&&(j[k[0]]={...j[k[0]],index:0}),j={...j,[d]:{order:b,index:typeof h=="number"?h:j[d]?.index??M}});const R=Object.keys(j).sort((A,E)=>j[A].index-j[E].index).map(A=>({key:A,order:j[A].order}));this.setState({sortMarks:j});const C=HC(R,g);if(C){const A=[...w];y?this.sortTree(A,C):A.sort(C),this.setState({data:A})}}),r.on("filter-rows",c=>{const{value:d,key:h,filter:p}=c;if(!Object.keys(c).length){this.setState({filterValues:{},_filterIds:null});return}const v=this.getState(),{data:g,tree:w,_columns:y}=v;let b=v.filterValues;const j={};h&&(b={...b,[h]:d},j.filterValues=b);const k=p??VC(b,y);let M=[];w?M=this.filterTree(g,k,M):g.forEach(R=>{k(R)&&M.push(R.id)}),j._filterIds=M,this.setState(j)}),r.on("collapse-column",c=>{const{id:d,row:h,mode:p}=c,v=[...this.getState().columns],g=this.getColumn(d).header,w=Array.isArray(g)?g[h]:g;typeof w=="object"&&(w.collapsed=p??!w.collapsed,this.setState({columns:v}))}),r.on("move-item",c=>{const{id:d,inProgress:h}=c;let{target:p,mode:v="after"}=c;const{data:g,flatData:w,tree:y}=this.getState(),b=w.findIndex(M=>M.id===d);let j;if(v==="up"||v==="down"){if(v==="up"){if(b===0)return;j=b-1,v="before"}else if(v==="down"){if(b===w.length-1)return;j=b+1,v="after"}p=w[j]&&w[j].id}else j=w.findIndex(M=>M.id===p);if(b===-1||j===-1||h===!1)return;let k;y||(k=this.moveItem(d,p,g,v)),this.setState({data:y?this.normalizeTreeRows(k):k})}),r.on("copy-row",c=>{const{id:d,target:h,mode:p="after"}=c,v=this.getState(),{flatData:g,_filterIds:w}=v;let{data:y}=v;const b=this.getRow(d);if(!b)return;const j={...b,id:Ku()};c.id=j.id;const k=g.findIndex(R=>R.id===h);if(k===-1)return;y.splice(k+(p==="after"?1:0),0,j),y=[...y];const M={data:y};w&&(M._filterIds=[...w,j.id]),this.setState(M)}),r.on("open-row",c=>{const{id:d,nested:h}=c;this.toggleBranch(d,!0,h)}),r.on("close-row",c=>{const{id:d,nested:h}=c;this.toggleBranch(d,!1,h)}),r.on("export-data",c=>new Promise((d,h)=>{const p=c.format||"csv",v=`${c.fileName||"data"}.${p}`;if(p==="csv"){const g=jC(this.getState(),c.csv||{});c.download!==!1?CC(new Blob(["\uFEFF"+g],{type:"text/csv"}),v):c.result=g,d(!0)}else h()})),r.on("hotkey",({key:c,event:d,isInput:h})=>{switch(c){case"arrowup":{const{flatData:p,focusCell:v,select:g}=this.getState();if(d.preventDefault(),h)return;const w=v?v.column:this._getFirstVisibleColumn()?.id,y=v?this.getPrevRow(v.row)?.id:p[p.length-1]?.id;w&&y&&(this.in.exec("focus-cell",{row:y,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:y}));break}case"arrowdown":{const{flatData:p,focusCell:v,select:g}=this.getState();if(d.preventDefault(),h)return;const w=v?v.column:this._getFirstVisibleColumn()?.id,y=v?this.getNextRow(v.row)?.id:p[0]?.id;w&&y&&(this.in.exec("focus-cell",{row:y,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:y}));break}case"arrowright":{const{focusCell:p}=this.getState();if(h)return;if(d.preventDefault(),p){const v=this.getNextColumn(p.column,!0)?.id;v&&this.in.exec("focus-cell",{row:p.row,column:v,eventSource:"key"})}break}case"arrowleft":{const{focusCell:p}=this.getState();if(h)return;if(d.preventDefault(),p){const v=this.getPrevColumn(p.column,!0)?.id;v&&this.in.exec("focus-cell",{row:p.row,column:v,eventSource:"key"})}break}case"tab":{const{editor:p,focusCell:v,select:g}=this.getState();if(p){d.preventDefault();const w=p.column;let y=p.id,b=this.getNextEditor(this.getRow(y),this.getColumn(w));if(!b){const j=this.getNextRow(y);j&&(y=j.id,b=this.getNextEditor(j))}b&&(this.in.exec("open-editor",{id:y,column:b.id}),this.in.exec("focus-cell",{row:y,column:b.id,eventSource:"key"}),g&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}else v&&this.in.exec("focus-cell",{eventSource:"key"});break}case"shift+tab":{const{editor:p,focusCell:v,select:g}=this.getState();if(p){d.preventDefault();const w=p.column;let y=p.id,b=this.getPrevEditor(this.getRow(y),this.getColumn(w));if(!b){const j=this.getPrevRow(y);j&&(y=j.id,b=this.getPrevEditor(j))}b&&(this.in.exec("open-editor",{id:y,column:b.id}),this.in.exec("focus-cell",{row:y,column:b.id,eventSource:"key"}),g&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}else v&&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:v}=this.getState();!p&&v&&this.in.exec("open-editor",{id:v.row,column:v.column});break}case"enter":{const{focusCell:p,tree:v}=this.getState();if(!h&&v&&p&&this.getColumn(p.column).treetoggle){const g=this.getRow(p.row);if(!g.data)return;this.in.exec(g.open?"close-row":"open-row",{id:p.row,nested:!0})}break}case"home":{const{editor:p,focusCell:v}=this.getState();if(!p&&v){d.preventDefault();const g=this._getFirstVisibleColumn()?.id;this.in.exec("focus-cell",{row:v.row,column:g,eventSource:"key"})}break}case"ctrl+home":{const{editor:p,focusCell:v,flatData:g,select:w}=this.getState();if(!p&&v){d.preventDefault();const y=g[0]?.id,b=this._getFirstVisibleColumn()?.id;y&&b&&(this.in.exec("focus-cell",{row:y,column:b,eventSource:"key"}),w&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}break}case"end":{const{editor:p,focusCell:v}=this.getState();if(!p&&v){d.preventDefault();const g=this._getLastVisibleColumn()?.id,w=v.row;this.in.exec("focus-cell",{row:w,column:g,eventSource:"key"})}break}case"ctrl+end":{const{editor:p,focusCell:v,flatData:g,select:w}=this.getState();if(!p&&v){d.preventDefault();const y=g.at(-1).id,b=this._getLastVisibleColumn()?.id;y&&b&&(this.in.exec("focus-cell",{row:y,column:b,eventSource:"key"}),w&&!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}}}),r.on("scroll",c=>{const{_columns:d,split:h,_sizes:p,flatData:v,dynamic:g,_rowHeightFromData:w}=this.getState();let y=-1,b=-1,j=0,k=0;if(c.column){y=0;const M=d.findIndex(R=>R.id===c.column);j=d[M].width;for(let R=h.left??0;R<M;R++){const C=d[R];C.hidden||(y+=C.width)}}if(c.row&&!g){const M=v.findIndex(R=>R.id===c.row);M>=0&&(w?(b=v.slice(0,M).reduce((R,C)=>R+(C.rowHeight||p.rowHeight),0),k=v[M].rowHeight):b=p.rowHeight*M)}this.setState({scroll:{top:b,left:y,width:j,height:k||p.rowHeight}})}),r.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)}),r.on("print",c=>{const d=DC(c);this.setState({_print:d}),this.setStateAsync({_print:null})}),r.on("undo",()=>{this._historyManager?.handleUndo()}),r.on("redo",()=>{this._historyManager?.handleRedo()}),this.initOnce()}getXlsxWorker(a){if(!this._xlsxWorker){const i=window.URL.createObjectURL(new Blob([`importScripts('${a}');`],{type:"text/javascript"}));this._xlsxWorker=new Promise(r=>{const c=new Worker(i);c.addEventListener("message",d=>{d.data.type==="init"&&r(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=$C()),a.columns&&a.columns.forEach(i=>{i.options&&(i.optionsMap=new Map(i.options.map(r=>[r.id,r.label])))}),Nd(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 IC(this.in,this.getState.bind(this),this.setState.bind(this))),this._router.init({...a})}setState(a,i){return this._router.setState(a,i)}setStateAsync(a){this._router.setStateAsync(a)}getRow(a){const{tree:i}=this.getState();return i?this._branches[a]:this.getState().data.find(r=>r.id===a)}getRowIndex(a,i){return i||(i=this.getState().flatData),i.findIndex(r=>r.id===a)}getNextRow(a){const i=this.getState().flatData,r=this.getRowIndex(a,i);return i[r+1]}getPrevRow(a){const i=this.getState().flatData,r=this.getRowIndex(a,i);return i[r-1]}getColumn(a){return this.getState().columns.find(i=>i.id===a)}getNextColumn(a,i){const r=this.getState()._columns,c=r.findIndex(d=>d.id===a);return i?this._getFirstVisibleColumn(c+1):r[c+1]}getPrevColumn(a,i){const r=this.getState()._columns,c=r.findIndex(d=>d.id===a);return i?this._getLastVisibleColumn(c-1):r[c-1]}_getFirstVisibleColumn(a){const i=this.getState()._columns;let r=a??0;for(;r<i.length&&(i[r]?.hidden||i[r]?.collapsed);)r++;return i[r]}_getLastVisibleColumn(a){const i=this.getState()._columns;let r=a??i.length-1;for(;r<i.length&&(i[r]?.hidden||i[r]?.collapsed);)r--;return i[r]}isCellEditable(a,i){const{editor:r,hidden:c}=i;return!r||c?!1:typeof r=="function"?r(a,i):!0}getNextEditor(a,i){let r=this.getState().columns;if(i){const c=r.findIndex(d=>d.id===i.id);r=r.slice(c+1)}return r.find(c=>this.isCellEditable(a,c))}getPrevEditor(a,i){let r=this.getState().columns;if(i){const c=r.findLastIndex(d=>d.id===i.id);r=r.slice(0,c)}return r.findLast(c=>this.isCellEditable(a,c))}toggleBranch(a,i,r){let c=this._branches[a],{data:d}=this.getState();if(d=[...d],a!==0){c={...c,open:i};const h=this.updateTreeRow(c);c.$parent===0&&(d=h)}r&&c.data?.length&&c.data.forEach(h=>{const p=this.toggleKids(h,i,r);a===0&&(d=p)}),this.setState({data:d})}toggleKids(a,i,r){a={...a,open:i};const c=this.updateTreeRow(a);return r&&a.data?.length&&a.data.forEach(d=>{this.toggleKids(d,i,r)}),c}updateTreeRow(a){const i=a.id;this._branches[i]=a;const r=this._branches[a.$parent],c=r.data.findIndex(d=>d.id===i);return r.data=[...r.data],r.data[c]=a,r.data}isSelected(a){return this.getState().selectedRows.indexOf(a)!==-1}findAndRemove(a,i){for(let r=0;r<a.length;r++){if(a[r].id===i)return a.splice(r,1)[0];if(a[r].data){const c=[...a[r].data],d=this.findAndRemove(c,i);if(d)return a[r]={...a[r],data:c},d}}return null}insertItem(a,i,r,c){for(let d=0;d<a.length;d++){if(a[d].id===i){const h=a[d],p=c==="before"?d:d+1;if(h.data){if(c==="before"){const v=d>0?a[d-1]:null;return v?.data&&v.open?a[d-1]={...v,data:[...v.data,r]}:a.splice(p,0,r),!0}else if(h.open)return a[d]={...h,data:[r,...h.data]},!0}return a.splice(p,0,r),!0}if(a[d].data&&(a[d]={...a[d],data:[...a[d].data]},this.insertItem(a[d].data,i,r,c)))return!0}return!1}moveItem(a,i,r,c){const d=[...r],h=this.findAndRemove(d,a);return this.insertItem(d,i,h,c),d}copyColumns(a){const i=[];for(let r=0;r<a.length;r++){const c={...a[r]};this.copyHeaderFooter(c,"header"),this.copyHeaderFooter(c,"footer"),i[r]=c}return i}copyHeaderFooter(a,i){let r=a[i];r=Array.isArray(r)?[...r]:[r],r.forEach((c,d)=>{r[d]=typeof c=="string"?{text:c}:{...c}}),a[i]=r}setCollapsibleColumns(a,i,r){let c=a.header;for(let d=0;d<c.length;d++){const h=c[d];if(h.collapsible&&h.collapsed){if(h.collapsible!=="first"){a.collapsed=!0,a.width=36,h.vertical=!0;const v=c.length-d;c=c.slice(0,d+1),c[d].rowspan=v}const p=h.colspan;if(p){const v=c[d+1];let g=1;v&&v.colspan&&!v.collapsed&&(g=v.colspan);for(let w=g;w<p;w++){const y=r[i+w];y&&(y.hidden=!0)}}}}}normalizeColumns(a,i,r,c,d){const h=a[i];h.width||(h.width=h.flexgrow?17:d.columnWidth),h._colindex=i+1;const p=h[r],v=d[`${r}RowHeights`];for(let g=0;g<c;g++){const w=p[g];w.id=h.id,g===p.length-1&&(w.rowspan=w.rowspan?Math.min(w.rowspan,c-g):c-g);for(let y=1;y<w.rowspan;y++){p.splice(g+y,0,{_hidden:!0});for(let b=1;b<w.colspan;b++)a[i+b][r].splice(g+y,0,{})}if(w.rowspan){const y=(w.rowspan===c?v:v.slice(g,w.rowspan+g)).reduce((b,j)=>b+j,0);w.height=y,g+w.rowspan!=c&&w.height--}if(w.colspan){let y=h.width,b=h.flexgrow||0;const j=w.colspan;for(let k=1;k<j;k++){const M=a[i+k];M&&(M.hidden?w.colspan-=1:M.flexgrow?b+=M.flexgrow:y+=M.width||d.columnWidth),b?w.flexgrow=b:w.width=y}}else w.width=h.width,w.flexgrow=h.flexgrow;r==="header"&&w.filter&&typeof w.filter=="string"&&(w.filter={type:w.filter})}p.length>c&&(p.length=c),h[r]=p}normalizeRows(a){for(let i=0;i<a.length;i++)a[i].id||(a[i].id=Ku());return a}normalizeTreeRows(a,i,r){return!i&&!r&&(this._branches={0:{data:a}}),a.forEach(c=>{c.id||(c.id=Ku()),c.$level=i||0,c.$parent=r||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,i){a.sort(i),a.forEach(r=>{r.data&&this.sortTree(r.data,i)})}filterTree(a,i,r){return a.forEach(c=>{i(c)&&r.push(c.id),c.data&&this.filterTree(c.data,i,r)}),r}flattenRows(a,i,r){const c=i;return a.forEach(d=>{(!r||r.includes(d.id))&&c.push(d),d.data?.length&&d.open!==!1&&this.flattenRows(d.data,c,r)}),c}createFilter(a){const{_columns:i}=this.getState(),r=[];for(const c in a){const d=i.find(g=>g.id==c),{config:h,type:p}=d.header.find(g=>g.filter).filter,v=a[c];r.push(g=>{const w=ui(g,d);return h?.handler?h.handler(w,v):Qy(p)(w,v)})}return c=>{for(let d=0;d<r.length;d++)if(!r[d](c))return!1;return!0}}searchRows(a,i){a=a.trim().toLowerCase();const r={};if(!a)return r;const{flatData:c,columns:d}=this.getState(),h=i?d.filter(p=>i[p.id]):d;return c.forEach(p=>{const v={};h.forEach(g=>{const w=ci(p,g);String(w).toLowerCase().includes(a)&&(v[g.id]=!0)}),Object.keys(v).length&&(r[p.id]=v)}),r}normalizeSizes(a,i,r,c,d){const h=xx(a,"header",r,i.headerHeight,d),p=xx(a,"footer",c,i.footerHeight,d),v=h.reduce((w,y)=>w+y,0),g=p.reduce((w,y)=>w+y,0);return{...i,headerRowHeights:h,footerRowHeights:p,headerHeight:v,footerHeight:g}}},KC=new Date().valueOf();function Ku(){return"temp://"+KC++}function QC(n,a="data-id"){let i=n;for(!i.tagName&&n.target&&(i=n.target);i;){if(i.getAttribute&&i.getAttribute(a))return i;i=i.parentNode}return null}new Date().valueOf();var XC=class{constructor(){this.store=new Map}configure(n,a){this.node=a;for(const i in n)if(n[i]){const r=i.toLowerCase().replace(/[ ]/g,""),c=n[i];this.store.set(r,c)}}},Yr=[],ZC={subscribe:n=>{JC();const a=new XC;return Yr.push(a),n(a),()=>{const i=Yr.findIndex(r=>r===a);i>=0&&Yr.splice(i,1)}}},yx=!1;function JC(){yx||(yx=!0,document.addEventListener("keydown",n=>{if(Yr.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 i=n.code.replace("Key","").toLocaleLowerCase();n.key===" "&&(i="space"),a.push(i);const r=a.join("+");for(let c=Yr.length-1;c>=0;c--){const d=Yr[c],h=d.store.get(r)||d.store.get(i);h&&d.node.contains(n.target)&&h(n,{key:r,evKey:i})}}}))}const ej={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 tj(n,{keys:a,exec:i}){if(!a)return;function r(h){const p=h.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||QC(p,"data-header-id")?.classList.contains("wx-filter")||!!p.closest(".wx-cell.wx-editor")}const c={};for(const h in a){const p=a[h];typeof p<"u"&&(typeof p=="function"?c[h]=p:p&&(c[h]=v=>{const g=r(v);i({key:h,event:v,isInput:g})}))}const d=ZC.subscribe(h=>{h.configure(c,n)});return{destroy:()=>{d()}}}function nj(n,a){let i=null;a.scroll.subscribe(r=>{if(!r||r===i)return;i=r;const{left:c,top:d,height:h,width:p}=r,v=a.getHeight(),g=a.getWidth(),w=a.getScrollMargin();if(d>=0){const y=n.scrollTop;d<y?n.scrollTop=d:d+h>y+v&&(n.scrollTop=d-v+h)}if(c>=0){const y=n.scrollLeft;c<y?n.scrollLeft=c:c+p>y+g-w&&(n.scrollLeft=c-g+p+w)}}),a.scrollLeft?.subscribe?.(r=>{requestAnimationFrame(()=>{Math.abs(n.scrollLeft-r)>1&&(n.scrollLeft=r)})}),a.scrollTop?.subscribe?.(r=>{requestAnimationFrame(()=>{Math.abs(n.scrollTop-r)>1&&(n.scrollTop=r)})})}const Da=f.createContext(null);function aj(n,a){const i=new ResizeObserver(r=>{requestAnimationFrame(()=>a(r[0].contentRect))});return i.observe(n.parentNode),{destroy(){i.disconnect()}}}const wx=5,sj=700;function id(n){const a=n.getBoundingClientRect(),i=document.body,r=a.top+i.scrollTop-i.clientTop||0,c=a.left+i.scrollLeft-i.clientLeft||0;return{y:Math.round(r),x:Math.round(c),width:n.offsetWidth,height:n.offsetHeight}}function oh(n,a){const i=id(a);return{x:n.clientX-i.x,y:n.clientY-i.y}}function lj(n,a){const i=a.current;let r=null,c,d,h=!1,p=!1;const v=document.createElement("DIV");v.className="wx-drag-zone",v.setAttribute("tabindex",-1);function g(){clearTimeout(c),c=null}function w(L){const I=Qr(L);I&&(r={container:v,sourceNode:L.target,from:kd(I),pos:oh(L,n)},d=r.pos,y(L))}function y(L){if(!r)return;const I=r.pos=oh(L,n);if(!h){if(!p&&!L?.target?.getAttribute("draggable-data")&&Math.abs(d.x-I.x)<wx&&Math.abs(d.y-I.y)<wx)return;if(F(L)===!1)return P()}if(p){const de=window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft,W=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop;r.targetNode=document.elementFromPoint(L.pageX-de,L.pageY-W)}else r.targetNode=L.target;i.move&&i.move(L,r),v.style.left=-(r.offset?r.offset.x:0)+"px",v.style.top=r.pos.y+(r.offset?r.offset.y:0)+"px"}function b(L){v.parentNode&&v.parentNode.removeChild(v),v.innerHTML="",h&&i.end&&i.end(L,r),r=d=null,P()}function j(L){i.getReorder&&!i.getReorder()||L.button===0&&(U(L),window.addEventListener("mousemove",k),window.addEventListener("mouseup",M),w(L))}function k(L){y(L)}function M(L){b(L)}function R(L){if(i.getReorder&&!i.getReorder())return;c=setTimeout(()=>{p=!0,w(L.touches[0])},sj),U(L);function I(){c&&g(),L.target.removeEventListener("touchmove",C),L.target.removeEventListener("touchend",I),b(L)}L.target.addEventListener("touchmove",C),L.target.addEventListener("touchend",I),n.addEventListener("contextmenu",A)}function C(L){h?(L.preventDefault(),y(L.touches[0])):c&&g()}function A(L){if(h||c)return L.preventDefault(),!1}function E(L){L.preventDefault()}function U(L){if(!i.getDraggableInfo)return;const{hasDraggable:I}=i.getDraggableInfo();(!I||L.target.getAttribute("draggable-data"))&&(document.body.style.userSelect="none",document.body.style.webkitUserSelect="none")}function F(L){if(h=!0,i.start){if(i.start(L,r)===!1)return!1;n.appendChild(v),document.body.style.cursor="move"}}function P(L){h=p=!1,document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",M),L&&(n.removeEventListener("mousedown",j),n.removeEventListener("touchstart",R),n.removeEventListener("dragstart",E))}return n.addEventListener("mousedown",j),n.addEventListener("touchstart",R),n.addEventListener("dragstart",E),{destroy(){P(!0)}}}const ij=.004;function rj(){return{dirX:0,dirY:0,scrollSpeedFactor:1}}function oj(n,a,i,r){const{node:c,left:d,top:h,bottom:p,sense:v,xScroll:g,yScroll:w}=r,y=oh(n,c);i.scrollState||(i.scrollState=rj());let b=0,j=0;y.x<d+v?b=-1:y.x>a.width-v&&(b=1),y.y<h+Math.round(v/2)?j=-1:y.y>a.height-p-Math.round(v/2)&&(j=1),(i.scrollState.dirX!==b||i.scrollState.dirY!==j)&&(Xy(i),i.scrollState.dirX=b,i.scrollState.dirY=j),(g&&i.scrollState.dirX!==0||w&&i.scrollState.dirY!==0)&&cj(i,r,{x:i.scrollState.dirX,y:i.scrollState.dirY})}function cj(n,a,i){n.autoScrollTimer||(n.autoScrollTimer=setTimeout(()=>{n.activeAutoScroll=setInterval(uj,15,n,a,i)},250))}function Xy(n){n.scrollSpeedFactor=1,n.autoScrollTimer&&(n.autoScrollTimer=clearTimeout(n.autoScrollTimer),n.activeAutoScroll=clearInterval(n.activeAutoScroll))}function uj(n,a,i){const{x:r,y:c}=i;n.scrollSpeedFactor+=ij,r!==0&&fj(n,a,r),c!==0&&dj(n,a,c)}function dj(n,a,i){const r=a.node.scrollTop;Zy(r+Math.round(a.sense/3)*n.scrollSpeedFactor*i,"scrollTop",a)}function fj(n,a,i){const r=a.node.scrollLeft;Zy(r+Math.round(a.sense/3)*n.scrollSpeedFactor*i,"scrollLeft",a)}function Zy(n,a,i){i.node[a]=n}function Td(n,a,i,r,c,d){const h={};return n&&(h.width=`${n}px`,h.minWidth=`${n}px`),a&&(h.flexGrow=a),d&&(h.height=`${d}px`),i&&(h.position="sticky",i.left&&(h.left=`${r}px`),i.right&&(h.right=`${c}px`)),h}function Jy(n,a,i){let r="";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),r+=d?"wx-shadow ":"wx-fixed "}return r+=a.rowspan>1?"wx-rowspan ":"",r+=a.colspan>1?"wx-colspan ":"",r+=a.vertical?"wx-vertical ":"",r+=i?i(n)+" ":"",r}function mj(n){const{row:a,column:i,cellStyle:r=null,columnStyle:c=null,children:d,focusable:h}=n,p=f.useContext(Da),v=Xe(p,"focusCell"),g=Xe(p,"search"),w=Xe(p,"reorder"),y=f.useMemo(()=>g?.rows[a.id]&&g.rows[a.id][i.id],[g,a.id,i.id]),b=f.useMemo(()=>Td(i.width,i.flexgrow,i.fixed,i.left,i.right),[i.width,i.flexgrow,i.fixed,i.left,i.right]);function j(F,P){let L="wx-cell";return L+=i.fixed?" "+(i.fixed===-1?"wx-shadow":"wx-fixed"):"",L+=F?" "+F(i):"",L+=P?" "+P(a,i):"",L+=i.treetoggle?" wx-tree-cell":"",L}const k=f.useMemo(()=>j(c,r),[c,r,i,a]),M=f.useMemo(()=>typeof i.draggable=="function"?i.draggable(a,i)!==!1:i.draggable,[i,a]),R=f.useRef(null);f.useEffect(()=>{R.current&&h&&v?.row===a.id&&v?.column===i.id&&R.current.focus()},[v,h,a.id,i.id]);const C=f.useCallback(()=>{h&&!v&&p.exec("focus-cell",{row:a.id,column:i.id,eventSource:"focus"})},[p,h,v,a.id,i.id]);function A(F){const P=new RegExp(`(${g.value.trim()})`,"gi");return String(F).split(P).map(L=>({text:L,highlight:P.test(L)}))}const E=f.useMemo(()=>{const F=i.fixed&&i.fixed.left===-1||i.fixed.right===-1,P=i.fixed&&i.fixed.right;return[k,F?"wx-shadow":"",P?"wx-fixed-right":""].filter(Boolean).join(" ")},[k,i]),U=i.cell;return l.jsxs("div",{className:"wx-TSCaXsGV "+E,ref:R,onFocus:C,style:b,"data-row-id":jn(a.id),"data-col-id":jn(i.id),tabIndex:h?"0":"-1",role:"gridcell","aria-colindex":i._colindex,"aria-readonly":i.editor?void 0:!0,children:[w&&i.draggable?M?l.jsx("i",{"draggable-data":"true",className:"wx-TSCaXsGV wx-draggable wxi-drag"}):l.jsx("i",{className:"wx-TSCaXsGV wx-draggable-stub"}):null,i.treetoggle?l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{marginLeft:`${a.$level*28}px`}}),a.$count?l.jsx("i",{"data-action":"toggle-row",className:`wx-TSCaXsGV wx-table-tree-toggle wxi-menu-${a.open!==!1?"down":"right"}`}):null]}):null,U?l.jsx(U,{api:p,row:a,column:i,onAction:({action:F,data:P})=>p.exec(F,P)}):d?d():y?l.jsx("span",{children:A(ci(a,i)).map(({highlight:F,text:P},L)=>F?l.jsx("mark",{className:"wx-TSCaXsGV wx-search",children:P},L):l.jsx("span",{children:P},L))}):ci(a,i)]})}function bx(n,a){let i,r;function c(p){i=p.clientX,n.style.opacity=1,document.body.style.cursor="ew-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",d),window.addEventListener("mouseup",h),a&&a.down&&a.down(n)}function d(p){r=p.clientX-i,a&&a.move&&a.move(r)}function h(){n.style.opacity="",document.body.style.cursor="",document.body.style.userSelect="",a&&a.up&&a.up(r),window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",h)}return n.addEventListener("mousedown",c),{destroy(){n.removeEventListener("mousedown",c)}}}function hj({filter:n,column:a,action:i,filterValue:r}){function c({value:d}){i({value:d,key:a.id})}return l.jsx(Rh,{...n.config??{},value:r,onChange:c})}function pj({filter:n,column:a,action:i,filterValue:r}){const c=f.useContext(Da),d=Xe(c,"flatData"),h=f.useMemo(()=>n?.config?.options||a?.options||v(),[n,a,d]),p=f.useMemo(()=>n?.config?.template,[n]);function v(){const y=[];return d.forEach(b=>{const j=ui(b,a);y.includes(j)||y.push(j)}),y.map(b=>({id:b,label:b}))}function g({value:y}){i({value:y,key:a.id})}function w(y){y.key!=="Tab"&&y.preventDefault()}return l.jsx("div",{style:{width:"100%"},onKeyDown:w,children:l.jsx(T1,{placeholder:"",clear:!0,...n?.config??{},options:h,value:r,onChange:g,children:y=>p?p(y):y.label})})}function gj({filter:n,column:a,action:i,filterValue:r}){function c({value:d}){i({value:d,key:a.id})}return l.jsx("div",{className:"wx-aaaK5VYO",style:{width:"100%"},children:l.jsx(N1,{placeholder:"",clear:!0,...n?.config??{},value:r,onChange:c})})}function ew(n){const{value:a,options:i=[],placeholder:r="",clear:c=!1,text:d=null,template:h=null,cell:p=null,dropdown:v={},autoOpen:g=!1,onChange:w,onAction:y}=n,[b,j]=By(a||[]),k=f.useMemo(()=>(b||[]).map(W=>i.find(ue=>ue.id===W)).filter(Boolean),[b,i]),M=f.useRef(null),R=f.useRef(null),[C,A]=f.useState(null),E=()=>{const W=b||[];if(!W.length)return 0;const ue=i.find(Z=>W.includes(Z.id));return ue?i.indexOf(ue):0};function U(W){R.current=W.navigate,A(()=>W.keydown),g&&W.navigate(E())}f.useEffect(()=>{g&&(M.current?.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges())},[]);function F({id:W}){j(W),w&&w({value:W})}function P(W){W.stopPropagation(),j([]),w&&w({value:[]})}function L(){R.current?.(E())}function I(){R.current?.(null)}function de(W){C?.(W,E())}return l.jsxs("div",{ref:M,className:"wx-multiselect wx-aadNNOwy",onClick:L,onKeyDown:de,tabIndex:0,children:[l.jsx("div",{className:"wx-label wx-aadNNOwy",children:h?h(k):p?l.jsx(p,{data:k,onAction:y}):d?l.jsx("span",{className:"wx-text wx-aadNNOwy",children:d}):k.length?l.jsx("span",{className:"wx-text wx-aadNNOwy",children:k.map(W=>W.label).join(", ")}):r?l.jsx("span",{className:"wx-placeholder wx-aadNNOwy",children:r}):" "}),c&&b?.length?l.jsx("i",{className:"wx-icon wxi-close wx-aadNNOwy",onClick:P}):l.jsx("i",{className:"wx-icon wxi-angle-down wx-aadNNOwy"}),l.jsx(Ad,{items:i,onReady:U,onSelect:F,multiselect:!0,checkboxes:!0,value:b||[],onCancel:I,...v,children:({option:W})=>l.jsx("div",{className:"wx-option wx-aadNNOwy",children:h?h(W):p?l.jsx(p,{data:W,onAction:y}):W.label})})]})}function vj({filter:n,column:a,action:i,filterValue:r}){const c=f.useContext(Mn.i18n)?.getGroup("grid")||Sc(Lh).getGroup("grid"),d=f.useMemo(()=>({clear:!0,...n?.config||{}}),[n]),h=f.useMemo(()=>d.options||a.options,[d,a]),p=f.useMemo(()=>{const w=r?.length;return w?w<3?r.map(y=>a.optionsMap.get(y)).join(", "):w+" "+c("selected"):""},[r,a,c]);function v({value:w}){i({value:w,key:a.id})}function g(w){w.key!=="Tab"&&w.preventDefault()}return l.jsx("div",{style:{width:"100%"},onKeyDown:g,children:l.jsx(ew,{placeholder:"",...d,options:h,value:r||[],text:p,onChange:v})})}const xj={text:hj,richselect:pj,datepicker:gj,multiselect:vj};function yj({filter:n,column:a}){const i=f.useContext(Da),r=Xe(i,"filterValues");function c(h){i.exec("filter-rows",h)}const d=f.useMemo(()=>xj[n.type],[n.type]);return l.jsx(d,{filter:n,column:a,action:c,filterValue:r[a.id]})}function wj(n){const{cell:a,column:i,row:r,lastRow:c,sortRow:d,columnStyle:h,bodyHeight:p,hasSplit:v}=n,g=f.useContext(Da),w=Xe(g,"sortMarks"),y=f.useMemo(()=>w?w[i.id]:void 0,[w,i.id]),b=f.useRef(),j=f.useCallback(ce=>{b.current=a.flexgrow?ce.parentNode.clientWidth:a.width},[a.flexgrow,a.width]),k=f.useCallback((ce,Q)=>{g.exec("resize-column",{id:a.id,width:Math.max(1,(b.current||0)+ce),inProgress:Q})},[g,a.id]),M=f.useCallback(ce=>k(ce,!0),[k]),R=f.useCallback(ce=>k(ce,!1),[k]),C=f.useCallback(ce=>{if(!i.sort||a.filter)return;let Q=y?.order;Q&&(Q=Q==="asc"?"desc":"asc"),g.exec("sort-rows",{key:a.id,add:ce.ctrlKey||ce.metaKey,order:Q})},[g,a.id,a.filter,i.sort,y?.order]),A=f.useCallback(ce=>{ce&&ce.stopPropagation(),g.exec("collapse-column",{id:a.id,row:r})},[g,a.id,r]),E=f.useCallback(ce=>{ce.key==="Enter"&&A()},[A]),U=f.useCallback(ce=>{ce.key==="Enter"&&!a.filter&&C(ce)},[C,a.filter]),F=f.useMemo(()=>a.collapsed&&i.collapsed,[a.collapsed,i.collapsed]),P=f.useMemo(()=>F&&!v&&a.collapsible!=="header",[F,v,a.collapsible]),L=f.useMemo(()=>P?{top:-p/2,position:"absolute"}:{},[P,p]),I=f.useMemo(()=>Td(a.width,a.flexgrow,i.fixed,i.left,a.right??i.right,a.height+(F&&P?p:0)),[a.width,a.flexgrow,i.fixed,i.left,a.right,i.right,a.height,F,P,p]),de=f.useMemo(()=>Jy(i,a,h),[i,a,h]),W=f.useCallback(()=>Object.fromEntries(Object.entries(a).filter(([ce])=>ce!=="cell")),[a]),ue=`wx-cell ${de} ${a.css||""} wx-collapsed`,Z=["wx-cell",de,a.css||"",a.filter?"wx-filter":"",i.fixed&&i.fixed.right?"wx-fixed-right":""].filter(Boolean).join(" "),le=f.useRef(null);return f.useEffect(()=>{const ce=le.current;if(!ce)return;const Q=bx(ce,{down:j,move:M,up:R});return()=>{typeof Q=="function"&&Q()}},[j,M,R,bx]),F?l.jsx("div",{className:"wx-RsQD74qC "+ue,style:I,role:"button","aria-label":`Expand column ${a.text||""}`,"aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:E,onClick:A,"data-header-id":jn(i.id),children:l.jsx("div",{className:"wx-RsQD74qC wx-text",style:L,children:a.text||""})}):l.jsxs("div",{className:"wx-RsQD74qC "+Z,style:I,onClick:C,"data-header-id":jn(i.id),tabIndex:!a._hidden&&i.sort&&!a.filter?0:void 0,role:"columnheader","aria-colindex":i._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?l.jsx("div",{className:"wx-RsQD74qC wx-collapse",role:"button","aria-label":a.collapsed?"Expand column":"Collapse column","aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:E,onClick:A,children:l.jsx("i",{className:`wx-RsQD74qC wxi-angle-${a.collapsed?"down":"right"}`})}):null,a.cell?(()=>{const ce=a.cell;return l.jsx(ce,{api:g,cell:W(),column:i,row:r,onAction:({action:Q,data:_})=>g.exec(Q,_)})})():a.filter?l.jsx(yj,{filter:a.filter,column:i}):l.jsx("div",{className:"wx-RsQD74qC wx-text",children:a.text||""}),i.resize&&c&&!a._hidden?l.jsx("div",{className:"wx-RsQD74qC wx-grip",role:"presentation","aria-label":"Resize column",ref:le,onClick:ce=>ce.stopPropagation(),children:l.jsx("div",{})}):null,d?l.jsx("div",{className:"wx-RsQD74qC wx-sort",children:y?l.jsxs(l.Fragment,{children:[typeof y.index<"u"?l.jsx("div",{className:"wx-RsQD74qC wx-order",children:y.index+1}):null,l.jsx("i",{className:`wx-RsQD74qC wxi-arrow-${y.order==="asc"?"up":"down"}`})]}):null}):null]})}function bj({cell:n,column:a,row:i,columnStyle:r}){const c=f.useContext(Da),d=f.useMemo(()=>Td(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]),h=f.useMemo(()=>Jy(a,n,r),[a,n,r]),p=f.useCallback(()=>Object.fromEntries(Object.entries(n||{}).filter(([g])=>g!=="cell")),[n]),v=`wx-6Sdi3Dfd wx-cell ${h||""} ${n?.css||""}`+(a?.fixed&&a?.fixed.right?" wx-fixed-right":"");return l.jsx("div",{className:v,style:d,children:!a?.collapsed&&!n?.collapsed?n?.cell?yh.createElement(n.cell,{api:c,cell:p(),column:a,row:i,onAction:({action:g,data:w})=>c.exec(g,w)}):l.jsx("div",{className:"wx-6Sdi3Dfd wx-text",children:n?.text||""}):null})}function Sx({deltaLeft:n,contentWidth:a,columns:i,type:r="header",columnStyle:c,bodyHeight:d}){const h=f.useContext(Da),p=Xe(h,"_sizes"),v=Xe(h,"split"),g=f.useMemo(()=>p?.[`${r}RowHeights`],[p,r]),w=f.useMemo(()=>{let M=[];if(i&&i.length){const R=i[0][r].length;for(let C=0;C<R;C++){let A=0;M.push([]),i.forEach((E,U)=>{const F={...E[r][C]};A||M[C].push(F),F.colspan>1?A=F.colspan-1:A&&A--})}}return M},[i,r]),y=f.useMemo(()=>v?.left||v?.right,[v]);function b(M){return i.find(R=>R.id===M)}function j(M,R){let C=R;return M.rowspan&&(C+=M.rowspan-1),C===w.length-1}function k(M,R,C){if(!C.sort)return!1;for(let A=w.length-1;A>=0;A--){const E=C.header[A];if(!E.filter&&!E._hidden)return R===A}return j(M,R)}return l.jsx("div",{className:`wx-sAsPVaUK wx-${r}`,style:{paddingLeft:`${n}px`,width:`${a}px`},role:"rowgroup",children:w.map((M,R)=>l.jsx("div",{className:r==="header"?"wx-sAsPVaUK wx-h-row":"wx-sAsPVaUK wx-f-row",style:{height:`${g?.[R]}px`,display:"flex"},role:"row",children:M.map(C=>{const A=b(C.id);return r==="header"?l.jsx(wj,{cell:C,columnStyle:c,column:A,row:R,lastRow:j(C,R),bodyHeight:d,sortRow:k(C,R,A),hasSplit:y},C.id):l.jsx(bj,{cell:C,columnStyle:c,column:b(C.id),row:R},C.id)})},R))})}function Sj({overlay:n}){const a=f.useContext(Da);function i(c){return typeof c=="function"}const r=n;return l.jsx("div",{className:"wx-1ty666CQ wx-overlay",children:i(n)?l.jsx(r,{onAction:({action:c,data:d})=>a.exec(c,d)}):n})}function Cj(n){const{editor:a,onSave:i,onApply:r}=n,[c,d]=f.useState(a?.value||""),{type:h="text"}=f.useMemo(()=>a?.config||{},[a]),p=f.useRef(null);f.useEffect(()=>{p.current&&p.current.focus()},[]),f.useEffect(()=>{if(!p.current)return;const w=qs(p.current,()=>i(!0));return()=>w.destroy()},[i]);function v(){p.current&&(d(p.current.value),r(p.current.value))}function g({key:w}){w==="Enter"&&i()}return l.jsx("input",{className:"wx-e7Ao5ejY wx-text",onInput:v,onKeyDown:g,ref:p,type:h,value:c})}function jj({editor:n,onAction:a,onSave:i,onApply:r,onCancel:c}){const[d,h]=f.useState(n?.value),[p,v]=f.useState(n?.renderedValue),[g,w]=f.useState(n?.options||[]),y=f.useMemo(()=>n?.config?.template,[n]),b=f.useMemo(()=>n?.config?.cell,[n]),j=f.useMemo(()=>n?.config?.dropdown||{},[n]),k=f.useMemo(()=>({trackScroll:!0,...j}),[j]),M=f.useMemo(()=>(g||[]).findIndex(L=>L.id===d),[g,d]),R=f.useRef(null),C=f.useRef(null),A=f.useCallback(L=>{R.current=L.navigate,C.current=L.keydown,R.current(M)},[M,R]),E=f.useCallback(L=>{const I=L?.target?.value??"";v(I);const de=I?(n?.options||[]).filter(W=>(W.label||"").toLowerCase().includes(I.toLowerCase())):n?.options||[];w(de),de.length?R.current(-1/0):R.current(null)},[n]),U=f.useRef(null);f.useEffect(()=>{U.current&&U.current.focus()},[]);const F=f.useRef(i);f.useEffect(()=>{F.current=i},[i]),f.useEffect(()=>{if(!U.current)return;const L=qs(U.current,()=>F.current(!0));return()=>L.destroy()},[]),f.useEffect(()=>{h(n?.value),v(n?.renderedValue),w(n?.options||[])},[n]);const P=f.useCallback(({id:L})=>{r(L),i()},[r,i]);return l.jsxs(l.Fragment,{children:[l.jsx("input",{className:"wx-0UYfSd1x wx-input",ref:U,value:p??"",onChange:E,onKeyDown:L=>C.current?C.current(L,M):void 0}),l.jsx(Ad,{items:g,onReady:A,onSelect:P,...k,onCancel:c,children:({option:L})=>y?y(L):b?l.jsx(b,{data:L,onAction:a}):L.label})]})}function kj({editor:n,onAction:a,onSave:i,onApply:r,onCancel:c}){const[d]=f.useState(()=>n.value||new Date),{template:h,cell:p,dropdown:v={}}=n?.config||{},g=f.useMemo(()=>({trackScroll:!0,width:"auto",...v}),[v]);function w({value:k}){r(k),i()}const y=f.useRef(null),[b,j]=f.useState(null);return f.useEffect(()=>{y.current&&y.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),f.useEffect(()=>{if(!b)return;const k=qs(b,()=>i(!0));return()=>k.destroy()},[b,i]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-lNWNYUb6 wx-value",ref:y,tabIndex:0,onClick:c,onKeyDown:k=>k.preventDefault(),children:h?h(d):p?l.jsx(p,{data:n.value,onAction:a}):l.jsx("span",{className:"wx-lNWNYUb6 wx-text",children:n.renderedValue})}),l.jsx(Th,{...g,onCancel:c,children:l.jsx("div",{ref:j,className:"wx-lNWNYUb6",children:l.jsx(Ly,{value:d,onChange:w,buttons:n.config?.buttons})})})]})}function Mj(n){const{editor:a}=n,i=n.onAction??n.onaction,r=n.onSave??n.onsave,c=n.onApply??n.onapply,d=n.onCancel??n.oncancel,h=a.config||{},{dropdown:p={}}=h,v=f.useMemo(()=>({trackScroll:!0,...p}),[p]),[g]=f.useState(a.options.find(E=>E.id===a.value)),[w]=f.useState(a.value),[y]=f.useState(a.options),b=f.useMemo(()=>y.findIndex(E=>E.id===w),[y,w]);function j({id:E}){c(E),r()}let k;const[M,R]=f.useState();function C(E){k=E.navigate,R(()=>E.keydown),k(b)}const A=f.useRef(null);return f.useEffect(()=>{A.current&&A.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),f.useEffect(()=>{if(!A.current)return;const E=qs(A.current,()=>r(!0));return()=>E.destroy()},[r]),l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:A,className:"wx-ywGRk611 wx-value",tabIndex:0,onClick:d,onKeyDown:E=>{M(E,b),E.preventDefault()},children:h.template?h.template(g):h.cell?(()=>{const E=h.cell;return l.jsx(E,{data:g,onAction:i})})():l.jsx("span",{className:"wx-ywGRk611 wx-text",children:a.renderedValue})}),l.jsx(Ad,{items:y,onReady:C,onSelect:j,...v,onCancel:d,children:({option:E})=>h.template?h.template(E):h.cell?(()=>{const U=h.cell;return l.jsx(U,{data:E,onAction:i})})():E.label})]})}function Aj(n){const{editor:a,onAction:i,onSave:r,onApply:c}=n,d=a?.config||{},h=a?.options??[],p=a?.value||[],v=a?.renderedValue,g=f.useMemo(()=>({trackScroll:!0,...d.dropdown||{}}),[d]);function w({value:b}){c(b)}const y=f.useRef(null);return f.useEffect(()=>{if(!y.current)return;const b=qs(y.current,()=>r(!0));return()=>b.destroy()},[r]),l.jsx("div",{ref:y,className:"wx-value wx-aacZ4gNU",onClick:()=>r(!0),children:l.jsx(ew,{value:p,options:h,text:v,template:d.template,cell:d.cell,clear:d.clear,dropdown:g,autoOpen:!0,onChange:w,onAction:i})})}const Nj={text:Cj,combo:jj,datepicker:kj,richselect:Mj,multiselect:Aj};function Tj({column:n,row:a}){const i=f.useContext(Da),r=Xe(i,"editor"),c=f.useCallback((k,M)=>{i.exec("close-editor",{ignore:k}),M&&i.exec("focus-cell",{...M,eventSource:"click"})},[i]),d=f.useCallback(k=>{const M=k?null:{row:r?.id,column:r?.column};c(!1,M)},[r,c]),h=f.useCallback(()=>{c(!0,{row:r?.id,column:r?.column})},[r,c]),p=f.useCallback(k=>{i.exec("editor",{value:k})},[i]),v=f.useCallback(k=>{k.key==="Enter"&&r&&(n.editor.type==="multiselect"?p(r.value):h())},[r,n.editor,h,p]),g=f.useMemo(()=>Td(n.width,n.flexgrow,n.fixed,n.left,n.right),[n.width,n.flexgrow,n.fixed,n.left,n.right]),w=f.useMemo(()=>{let k=n.editor;if(typeof k=="function"&&(k=k(a,n)),!k)return null;let M=typeof k=="string"?k:k.type;return Nj[M]},[n,a]),y=f.useRef(null);f.useEffect(()=>{y.current&&typeof g=="string"&&y.current.setAttribute("style",g)},[g]);const b=typeof a.$parent<"u"?"gridcell":"cell",j=typeof a.$parent<"u"?!n.editor:void 0;return l.jsx("div",{className:"wx-8l724t2g wx-cell wx-editor",ref:y,style:typeof g=="object"&&g!==null?g:void 0,role:b,"aria-readonly":j,tabIndex:-1,onClick:k=>k.stopPropagation(),onDoubleClick:k=>k.stopPropagation(),onKeyDown:v,children:w?l.jsx(w,{editor:r,onSave:d,onApply:p,onCancel:h,onAction:({action:k,data:M})=>i.exec(k,M)}):null})}function Cx(n){const{columns:a,type:i,columnStyle:r}=n,c=f.useContext(Da),{filterValues:d,_columns:h,_sizes:p}=c.getState();function v(g){return r?" "+r(g):""}return l.jsx(l.Fragment,{children:a.map((g,w)=>l.jsx("tr",{children:g.map(y=>{const b=h.find(M=>M.id===y.id),j=`wx-print-cell-${i}${v(b)}${y.filter?" wx-print-cell-filter":""}${y.vertical?" wx-vertical":""}`,k=y.cell;return l.jsx("th",{style:Fy(Wy(y,p.columnWidth)),className:"wx-Gy81xq2u "+j,rowSpan:y.rowspan,colSpan:y.colspan,children:k?l.jsx(k,{api:c,cell:Object.fromEntries(Object.entries(y).filter(([M])=>M!=="cell")),column:b,row:w}):y.filter?l.jsx("div",{className:"wx-Gy81xq2u wx-print-filter",children:LC(d,h,y)}):l.jsx("div",{className:"wx-Gy81xq2u wx-text",children:y.text??""})},y.id)})},w))})}function Rj(n){const{columns:a,rowStyle:i,columnStyle:r,cellStyle:c,header:d,footer:h,reorder:p}=n,v=f.useContext(Da),{flatData:g,_sizes:w}=v.getState(),y=d&&gx(a,"header",w.headerRowHeights),b=h&&gx(a,"footer",w.footerRowHeights);function j(M,R){let C="";return C+=r?" "+r(R):"",C+=c?" "+c(M,R):"",C}function k(M,R){return typeof R.draggable=="function"?R.draggable(M,R)!==!1:R.draggable}return l.jsxs("table",{className:`wx-8NTMLH0z wx-print-grid ${a.some(M=>M.flexgrow)?"wx-flex-columns":""}`,children:[d?l.jsx("thead",{children:l.jsx(Cx,{columns:y,type:"header",columnStyle:r})}):null,l.jsx("tbody",{children:g.map((M,R)=>l.jsx("tr",{className:"wx-8NTMLH0z wx-row"+(i?" "+i(M):""),style:{height:`${M.rowHeight||w.rowHeight}px`},children:a.map(C=>C.collapsed?null:l.jsxs("td",{className:`wx-8NTMLH0z wx-print-cell wx-cell ${j(M,C)}`,style:Fy(Wy(C,w.columnWidth)),children:[p&&C.draggable?l.jsx("span",{className:"wx-8NTMLH0z wx-print-draggable",children:k(M,C)?l.jsx("i",{className:"wx-8NTMLH0z wxi-drag"}):null}):null,C.treetoggle?l.jsxs(l.Fragment,{children:[l.jsx("span",{style:{marginLeft:M.$level*28+"px"}}),M.$count?l.jsx("i",{className:`wx-8NTMLH0z wx-print-grid-tree-toggle wxi-menu-${M.open!==!1?"down":"right"}`}):null]}):null,C.cell?(()=>{const A=C.cell;return l.jsx(A,{api:v,row:M,column:C})})():l.jsx("span",{children:ci(M,C)})]},C.id))},R))}),h?l.jsx("tfoot",{children:l.jsx(Cx,{columns:b,type:"footer",columnStyle:r})}):null]})}function Ej(n){const{config:a,...i}=n,r=f.useContext(Da),{_skin:c,_columns:d}=r.getState(),h=f.useMemo(()=>TC(d,a),[]),p=f.useRef(null);return f.useEffect(()=>{const v=document.body;v.classList.add("wx-print");const g=p.current;if(!g)return;const w=g.cloneNode(!0);v.appendChild(w);const y=`@media print { @page { size: ${a.paper} ${a.mode}; }`,b=document.createElement("style");b.setAttribute("type","text/css"),b.setAttribute("media","print"),document.getElementsByTagName("head")[0].appendChild(b),b.appendChild(document.createTextNode(y)),window.print(),b.remove(),v.classList.remove("wx-print"),w.remove()},[]),l.jsx("div",{className:`wx-4zwCKA7C wx-${c}-theme wx-print-container`,ref:p,children:h.map((v,g)=>l.jsx("div",{className:"wx-4zwCKA7C wx-print-grid-wrapper",children:l.jsx(Rj,{columns:v,...i})},g))})}function Dj(n){const{header:a,footer:i,overlay:r,multiselect:c,onreorder:d,rowStyle:h,columnStyle:p,cellStyle:v,autoRowHeight:g,resize:w,clientWidth:y,clientHeight:b,responsiveLevel:j,hotkeys:k}=n,M=f.useContext(Da),R=Xe(M,"dynamic"),C=Xe(M,"_columns"),A=Xe(M,"flatData"),E=Xe(M,"split"),U=Xe(M,"_sizes"),[F,P]=ns(M,"selectedRows"),L=Xe(M,"select"),I=Xe(M,"editor"),de=Xe(M,"scrollLeft"),W=Xe(M,"scrollTop"),ue=Xe(M,"tree"),Z=Xe(M,"focusCell"),le=Xe(M,"_print"),ce=Xe(M,"undo"),Q=Xe(M,"reorder"),_=Xe(M,"_rowHeightFromData"),[Y,$]=f.useState(0);f.useEffect(()=>{$(Ys())},[]);const[H,ie]=f.useState(0),xe=f.useMemo(()=>(C||[]).some(X=>!X.hidden&&X.flexgrow),[C]),D=f.useMemo(()=>U?.rowHeight||0,[U]),J=f.useRef(null),[he,we]=f.useState(null),[je,Oe]=f.useState(null),He=f.useMemo(()=>{let X=[],Se=0;return E&&E.left&&(X=(C||[]).slice(0,E.left).filter(_e=>!_e.hidden).map(_e=>({..._e})),X.forEach(_e=>{_e.fixed={left:1,leftSize:E.left},_e.left=Se,Se+=_e.width}),X.length&&(X[X.length-1].fixed.left=-1)),{columns:X,width:Se}},[E,C]),oe=f.useMemo(()=>{let X=[],Se=0;if(E&&E.right){X=(C||[]).slice(E.right*-1).filter(_e=>!_e.hidden).map(_e=>({..._e}));for(let _e=X.length-1;_e>=0;_e--){const We=X[_e];We.fixed={right:1},We.right=Se,Se+=We.width}X.length&&(X[0].fixed={right:-1})}return{columns:X,width:Se}},[E,C]),Ze=f.useMemo(()=>{const X=(C||[]).slice(E?.left||0,(C||[]).length-(E?.right??0)).filter(Se=>!Se.hidden);return X.forEach(Se=>{Se.fixed=0}),X},[C,E]),De=f.useMemo(()=>(C||[]).reduce((X,Se)=>(Se.hidden||(X+=Se.width),X),0),[C]),at=1;function ne(X,Se,_e){let We=Se,Tt=X;if(Ze.length){let jt=Ze.length;for(let $e=X;$e>=0;$e--)Ze[$e][_e].forEach(dt=>{dt.colspan>1&&$e>X-dt.colspan&&$e<jt&&(jt=$e)});if(jt!==Ze.length&&jt<X){for(let $e=jt;$e<X;$e++)We-=Ze[$e].width;Tt=jt}}return{index:Tt,delta:We}}const pe=f.useMemo(()=>{let X,Se,_e;const We=de||0,Tt=(de||0)+(y||0);let jt=0,$e=0,dt=0,pn=0;Ze.forEach((Bt,qt)=>{We>dt&&(jt=qt,pn=dt),dt=dt+Bt.width,Tt>dt&&($e=qt+at)});const Kt={header:0,footer:0};for(let Bt=$e;Bt>=jt;Bt--)["header","footer"].forEach(qt=>{Ze[Bt]&&Ze[Bt][qt].forEach(Ws=>{const ba=Ws.colspan;if(ba&&ba>1){const Ba=ba-($e-Bt+1);Ba>0&&(Kt[qt]=Math.max(Kt[qt],Ba))}})});const Rt=ne(jt,pn,"header"),kt=ne(jt,pn,"footer"),vt=Rt.delta,mt=Rt.index,Ia=kt.delta,wa=kt.index;return xe&&De>(y||0)?X=Se=_e=[...He.columns,...Ze,...oe.columns]:(X=[...He.columns,...Ze.slice(jt,$e+1),...oe.columns],Se=[...He.columns,...Ze.slice(mt,$e+Kt.header+1),...oe.columns],_e=[...He.columns,...Ze.slice(wa,$e+Kt.footer+1),...oe.columns]),{data:X||[],header:Se||[],footer:_e||[],d:pn,df:Ia,dh:vt}},[Ze,He,oe,de,y,xe,De]),Me=f.useMemo(()=>a&&U?.headerHeight||0,[a,U]),V=f.useMemo(()=>i&&U?.footerHeight||0,[i,U]),ae=f.useMemo(()=>y&&b?De>=y:!1,[y,b,De]),[ke,be]=f.useState(!1),st=f.useMemo(()=>(b||0)-Me-V-(ae?Y:0),[b,Me,V,ae,Y]),It=f.useMemo(()=>Math.ceil((st||0)/(D||1))+1,[st,D]),Ae=f.useRef([]),[Ne,Ie]=f.useState(0),[Pt,An]=f.useState(void 0),Dt=f.useMemo(()=>{let X=0,Se=0;const _e=2,We=W||0;if(g){let $e=We;for(;$e>0;)$e-=Ae.current[X]||D,X++;Se=We-$e;for(let dt=Math.max(0,X-_e-1);dt<X;dt++)Se-=Ae.current[X-dt]||D;X=Math.max(0,X-_e)}else{if(_){let $e=0,dt=0;for(let kt=0;kt<(A||[]).length;kt++){const vt=A[kt].rowHeight||D;if(dt+vt>We){$e=kt;break}dt+=vt}X=Math.max(0,$e-_e);for(let kt=0;kt<X;kt++)Se+=A[kt].rowHeight||D;let pn=0,Kt=0;for(let kt=$e+1;kt<(A||[]).length;kt++){const vt=A[kt].rowHeight||D;if(pn++,Kt+vt>st)break;Kt+=vt}const Rt=Math.min(R?R.rowCount:(A||[]).length,$e+pn+_e);return{d:Se,start:X,end:Rt}}X=Math.floor(We/(D||1)),X=Math.max(0,X-_e),Se=X*(D||0)}const Tt=R?R.rowCount:(A||[]).length,jt=Math.min(Tt,X+(It||0)+_e);return{d:Se,start:X,end:jt}},[g,_,W,D,R,A,It,st]),bl=f.useMemo(()=>{const X=R?R.rowCount:(A||[]).length;if(g)return Ne+Dt.d+(X-(Pt||0))*(D||0);if(!_)return X*(D||0);let Se=0;for(let _e=0;_e<X;_e++)Se+=A[_e]?.rowHeight||D;return Se},[R,A,D,g,_,Ne,Dt.d,Pt]),as=f.useRef({});as.current={clientWidth:y,clientHeight:b,fullHeight:bl,headerHeight:Me,footerHeight:V,fullWidth:De,SCROLLSIZE:Y};const ws=f.useCallback(()=>{const X=as.current;be(X.clientWidth&&X.clientHeight?X.fullHeight+X.headerHeight+X.footerHeight>=X.clientHeight-(X.fullWidth>=X.clientWidth?X.SCROLLSIZE:0):!1)},[]);f.useEffect(()=>{const X=requestAnimationFrame(ws);return()=>window.cancelAnimationFrame(X)},[H,ws]),f.useEffect(()=>{ws()},[b,ws]);const Re=f.useMemo(()=>xe&&De<=(y||0)?(y||0)-0-(ke?Y:0):De,[xe,De,y,ke,Y,ae]),Sl=f.useMemo(()=>xe&&De<=(y||0)?y||0:Re<(y||0)?De+(ke?Y:0):-1,[xe,De,y,Re,ke,Y]),Ye=f.useRef({});f.useEffect(()=>{if(R&&(Ye.current.start!==Dt.start||Ye.current.end!==Dt.end)){const{start:X,end:Se}=Dt;Ye.current={start:X,end:Se},M&&M.exec&&M.exec("request-data",{row:{start:X,end:Se}})}},[R,Dt,M]);const wt=f.useMemo(()=>R?A||[]:(A||[]).slice(Dt.start,Dt.end),[R,A,Dt]),ut=f.useMemo(()=>(F||[]).filter(X=>(wt||[]).some(Se=>Se.id===X)),[P,wt]),Wt=f.useMemo(()=>Dt.start,[Dt.start]),Jn=f.useRef({top:W,left:de});Jn.current={top:W,left:de};const Gs=f.useCallback(X=>{const Se=X.target.scrollTop,_e=X.target.scrollLeft,We=Jn.current;(Se!==We.top||_e!==We.left)&&M.exec("scroll-to",{top:Se,left:_e})},[M]),fi=f.useCallback(X=>{X.shiftKey&&X.preventDefault(),J.current&&J.current.focus&&J.current.focus()},[]),La=f.useCallback(()=>!!(C||[]).find(X=>!!X.draggable),[C]),Nt=f.useRef(null),zn=f.useRef(null),ea=f.useRef({dblclick:(X,Se)=>{const _e={id:X,column:yc(Se,"data-col-id")};M.exec("open-editor",_e)},click:(X,Se)=>{if(Se.target.closest("input")||Nt.current)return;const _e=yc(Se,"data-col-id");if(Z?.id!==X&&M.exec("focus-cell",{row:X,column:_e,eventSource:"click"}),L===!1)return;const We=c&&(Se.ctrlKey||Se.metaKey),Tt=c&&Se.shiftKey;(We||F.length>1||!F.includes(X))&&M.exec("select-row",{id:X,toggle:We,range:Tt})},"toggle-row":X=>{const Se=M.getRow(X);M.exec(Se.open!==!1?"close-row":"open-row",{id:X})},"ignore-click":()=>!1}),_a=f.useMemo(()=>({top:Me,bottom:V,left:He.width,xScroll:ae,yScroll:ke,sense:g&&je?je.offsetHeight:Math.max(U?.rowHeight||0,40),node:J.current&&J.current.firstElementChild}),[Me,V,He.width,ae,ke,g,je,U]);function Vs(X,Se){const{container:_e,sourceNode:We,from:Tt}=Se;if(La()&&!We.getAttribute("draggable-data"))return!1;we(Tt),ue&&M.getRow(Tt).open&&M.exec("close-row",{id:Tt,nested:!0});const jt=Qr(We),$e=jt.cloneNode(!0);$e.classList.remove("wx-selected"),$e.querySelectorAll("[tabindex]").forEach(Rt=>Rt.setAttribute("tabindex","-1")),_e.appendChild($e),Oe($e);const dt=(de||0)-pe.d,pn=ke?Y:0;_e.style.width=Math.min((y||0)-pn,xe&&De<=(y||0)?Re:Re-pn)+dt+"px";const Kt=id(jt);Se.offset={x:dt,y:-Math.round(Kt.height/2)},zn.current||(zn.current=X.clientY)}function Zr(X,Se){const{from:_e}=Se,We=Se.pos,Tt=id(J.current);We.x=Tt.x;const jt=_a.top;if(We.y<jt)We.y=jt;else{const $e=Tt.height-(ae&&Y>0?Y:Math.round(_a.sense/2))-_a.bottom;We.y>$e&&(We.y=$e)}if(J.current.contains(Se.targetNode)){const $e=Qr(Se.targetNode),dt=$e&&kd($e);if(dt&&dt!==_e){Se.to=dt;const pn=g?je?.offsetHeight:U?.rowHeight;if(je&&((W||0)===0||We.y>jt+pn-1)){const Kt=$e.getBoundingClientRect(),Rt=id(je).y,kt=Kt.y,vt=Rt>kt?-1:1,mt=vt===1?"after":"before",Ia=M.getState().flatData,wa=Math.abs(Ia.findIndex(qt=>qt.id===_e)-Ia.findIndex(qt=>qt.id===dt)),Bt=wa!==1?mt==="before"?"after":"before":mt;if(wa===1&&(vt===-1&&X.clientY>zn.current||vt===1&&X.clientY<zn.current))return;zn.current=X.clientY,M.exec("move-item",{id:_e,target:dt,mode:Bt,inProgress:!0})}}d&&d({event:X,context:Se})}oj(X,Tt,Se,_a)}function mi(X,Se){const{from:_e,to:We}=Se;M.exec("move-item",{id:_e,target:We,inProgress:!1}),Nt.current=setTimeout(()=>{Nt.current=0},1),we(null),Oe(null),zn.current=null,Xy(Se)}function Ys(){const X=document.createElement("div");X.style.cssText="position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;min-height:100px;overflow-y:scroll;",document.body.appendChild(X);const Se=X.offsetWidth-X.clientWidth;return document.body.removeChild(X),Se}const hn=f.useMemo(()=>Sl>0?{width:`${Sl}px`}:void 0,[Sl]),za=f.useRef(null);function Nn(){Promise.resolve().then(()=>{let X=0,Se=Wt;const _e=za.current;_e&&(Array.from(_e.children).forEach((We,Tt)=>{Ae.current[Wt+Tt]=We.offsetHeight,X+=We.offsetHeight,Se++}),Ie(X),An(Se))})}f.useEffect(()=>{wt&&g&&Nn()},[wt,g,Wt]);let[xa,ya]=f.useState();f.useEffect(()=>{if(Z&&(!L||!ut.length||ut.includes(Z.row)))ya({...Z});else if(wt.length&&pe.data.length){if(!xa||ut.length&&!ut.includes(xa.row)||wt.findIndex(X=>X.id===xa.row)===-1||pe.data.findIndex(X=>X.id===xa.column&&!X.collapsed)===-1){const X=ut[0]||wt[0].id,Se=pe.data.findIndex(_e=>!_e.collapsed);ya(Se!==-1?{row:X,column:pe.data[Se].id}:null)}}else ya(null)},[Z]);const ss=f.useRef(null);f.useEffect(()=>{const X=J.current;if(!X)return;const Se=aj(X,w);return()=>{typeof Se=="function"&&Se()}},[w]);const Oa=f.useRef({});Object.assign(Oa.current,{start:Vs,move:Zr,end:mi,getReorder:()=>Q,getDraggableInfo:()=>({hasDraggable:La()})}),f.useEffect(()=>{const X=J.current;return X?lj(X,Oa).destroy:void 0},[Q,J.current]),f.useEffect(()=>{const X=J.current;return X?tj(X,{keys:k!==!1&&{...ej,"ctrl+z":ce,"ctrl+y":ce,...k},exec:Se=>M.exec("hotkey",Se)}).destroy:void 0},[M,ce,k]);const ta=f.useRef({scroll:M.getReactiveState().scroll,scrollLeft:M.getReactiveState().scrollLeft,scrollTop:M.getReactiveState().scrollTop});ta.current.getWidth=()=>(y||0)-(ke?Y:0),ta.current.getHeight=()=>st,ta.current.getScrollMargin=()=>He.width+oe.width,f.useEffect(()=>{nj(ss.current,ta.current)},[]);const bs=f.useRef(null);f.useEffect(()=>{const X=bs.current;if(!X)return;const Se=[];Se.push(qs(X,()=>Z&&M.exec("focus-cell",{eventSource:"click"})).destroy),Se.push(lC(X,ea.current)),ie(X.clientHeight);const _e=new ResizeObserver(()=>{ie(X.clientHeight)});return _e.observe(X),Se.push(()=>_e.disconnect()),()=>Se.forEach(We=>We())},[]);const Tn=`wx-grid ${j?`wx-responsive-${j}`:""}`;return f.useEffect(()=>{Z&&(wt.some(X=>X.id===Z.row)&&pe.data.some(X=>X.id===Z.column&&!X.collapsed)||M.exec("focus-cell",{eventSource:"destroy"}))},[Z,wt,pe.data,M]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-4VuBwK2D "+Tn,style:{"--header-height":`${Me}px`,"--footer-height":`${V}px`,"--split-left-width":`${He.width}px`,"--split-right-width":`${oe.width}px`},children:l.jsx("div",{ref:J,className:"wx-4VuBwK2D wx-table-box",style:hn,role:ue?"treegrid":"grid","aria-colcount":pe.data.length,"aria-rowcount":wt.length,"aria-multiselectable":ue&&c?!0:void 0,tabIndex:-1,children:l.jsxs("div",{ref:ss,className:"wx-4VuBwK2D wx-scroll",style:{overflowX:ae?"scroll":"hidden",overflowY:ke?"scroll":"hidden"},onScroll:Gs,children:[a?l.jsx("div",{className:"wx-4VuBwK2D wx-header-wrapper",children:l.jsx(Sx,{contentWidth:Re,deltaLeft:pe.dh,columns:pe.header,columnStyle:p,bodyHeight:st-+i})}):null,l.jsxs("div",{ref:bs,className:"wx-4VuBwK2D wx-body",style:{width:`${Re}px`,height:`${bl}px`},onMouseDown:X=>fi(X),children:[r?l.jsx(Sj,{overlay:r}):null,l.jsx("div",{ref:za,className:"wx-4VuBwK2D wx-data",style:{paddingTop:`${Dt.d}px`,paddingLeft:`${pe.d}px`},children:wt.map((X,Se)=>{const _e=F.indexOf(X.id)!==-1,We=he===X.id,Tt="wx-row"+(g?" wx-autoheight":"")+(h?" "+h(X):"")+(_e?" wx-selected":"")+(We?" wx-inactive":""),jt=g?{minHeight:`${X.rowHeight||D}px`}:{height:`${X.rowHeight||D}px`};return l.jsx("div",{className:"wx-4VuBwK2D "+Tt,"data-id":jn(X.id),"data-context-id":jn(X.id),style:jt,role:"row","aria-rowindex":Se,"aria-expanded":X.open,"aria-level":ue?X.$level+1:void 0,"aria-selected":ue?_e:void 0,tabIndex:-1,children:pe.data.map($e=>$e.collapsed?l.jsx("div",{className:"wx-4VuBwK2D wx-cell wx-collapsed"},$e.id):I?.id===X.id&&I.column===$e.id?l.jsx(Tj,{row:X,column:$e},$e.id):l.jsx(mj,{row:X,column:$e,columnStyle:p,cellStyle:v,reorder:Q,focusable:xa?.row===X.id&&xa?.column===$e.id},$e.id))},X.id)})})]}),i&&(A||[]).length?l.jsx(Sx,{type:"footer",contentWidth:Re,deltaLeft:pe.df,columns:pe.footer,columnStyle:p}):null]})})}),le?l.jsx(Ej,{config:le,rowStyle:h,columnStyle:p,cellStyle:v,header:a,footer:i,reorder:Q}):null]})}const Lj=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join(""),_j=f.forwardRef(function({data:n=[],columns:a=[],rowStyle:i=null,columnStyle:r=null,cellStyle:c=null,selectedRows:d,select:h=!0,multiselect:p=!1,header:v=!0,footer:g=!1,dynamic:w=null,overlay:y=null,reorder:b=!1,onReorder:j=null,autoRowHeight:k=!1,sizes:M,split:R,tree:C=!1,autoConfig:A=!1,init:E=null,responsive:U=null,sortMarks:F,undo:P=!1,hotkeys:L=null,filterValues:I,...de},W){const ue=f.useRef();ue.current=de;const Z=f.useMemo(()=>new WC(Hy),[]),le=f.useMemo(()=>Z.in,[Z]),ce=f.useRef(null);ce.current===null&&(ce.current=new _y((oe,Ze)=>{const De="on"+Lj(oe);ue.current&&ue.current[De]&&ue.current[De](Ze)}),le.setNext(ce.current));const Q=f.useMemo(()=>({getState:Z.getState.bind(Z),getReactiveState:Z.getReactive.bind(Z),getStores:()=>({data:Z}),exec:le.exec,setNext:oe=>(ce.current=ce.current.setNext(oe),ce.current),intercept:le.intercept.bind(le),on:le.on.bind(le),detach:le.detach.bind(le),getRow:Z.getRow.bind(Z),getColumn:Z.getColumn.bind(Z)}),[Z,le]),[_,Y]=f.useState(0),[$,H]=f.useState(0),[ie,xe]=f.useState(null),[D,J]=f.useState(null),he=f.useMemo(()=>{if(A&&!a.length&&n.length){const oe=n[0],Ze=[];for(let De in oe)if(De!=="id"&&De[0]!=="$"){let at={id:De,header:De[0].toUpperCase()+De.slice(1)};typeof A=="object"&&(at={...at,...A}),Ze.push(at)}return Ze}return(D&&D.columns)??a},[A,a,n,D]),we=f.useMemo(()=>(D&&D.sizes)??M,[D,M]),je=f.useCallback(oe=>{if(Y(oe.width),H(oe.height),U){const Ze=Object.keys(U).map(Number).sort((De,at)=>De-at).find(De=>oe.width<=De)??null;Ze!==ie&&(J(U[Ze]),xe(Ze))}},[U,ie]),Oe=f.useContext(Mn.theme),He=f.useRef(0);return f.useEffect(()=>{if(!He.current)E&&E(Q);else{const oe=Z.getState();Z.init({data:n,columns:he,split:R||oe.split,sizes:we||oe.sizes,selectedRows:d||oe.selectedRows,dynamic:w,tree:C,sortMarks:F||oe.sortMarks,filterValues:I||oe.filterValues,undo:P,reorder:b,_skin:Oe,_select:h})}He.current++},[Z,n,he,R,we,d,w,C,F,I,P,b,Oe,h,E,Q]),He.current===0&&Z.init({data:n,columns:he,split:R||{left:0},sizes:we||{},selectedRows:d||[],dynamic:w,tree:C,sortMarks:F||{},filterValues:I||{},undo:P,reorder:b,_skin:Oe,select:h}),f.useImperativeHandle(W,()=>({...Q}),[Q]),l.jsx(Da.Provider,{value:Q,children:l.jsx(Dh,{words:Lh,optional:!0,children:l.jsx(Dj,{header:v,footer:g,overlay:y,rowStyle:i,columnStyle:r,cellStyle:c,onReorder:j,multiselect:p,autoRowHeight:k,clientWidth:_,clientHeight:$,responsiveLevel:ie,resize:je,hotkeys:L})})})});kh(va);const kn=f.createContext(null),Oh=f.createContext(null),Ih=f.createContext(null);function zj({children:n}){const a=f.useContext(Mn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),r=f.useContext(kn),[c]=ns(r,"panels"),d=Xe(r,"activePanel"),h=c[d].path,[p,v]=f.useState(null),[g,w]=f.useState(null),[y,b]=f.useState(""),[j,k]=f.useState(""),[M,R]=f.useState(!1);function C(){const F=y.trim();if(!F){R(!0);return}p.add?r.exec("create-file",{file:{...p.item,name:F},parent:h}):j!==F&&r.exec("rename-file",{id:p.item.id,name:F}),A()}function A(){v(null),R(null),k(""),b("")}function E(){r.exec("delete-files",{ids:g.selected}),w(null)}const U=f.useMemo(()=>({showPrompt(F){const P=F.item.name||(F.item.type==="folder"?i("New folder"):`${i("New file")}.txt`);k(P),b(P),v({...F})},showConfirm(F){w({...F})}}),[i]);return l.jsxs(Oh.Provider,{value:U,children:[l.jsx(z1,{children:n}),p?l.jsx(ih,{title:i(`Enter ${p.item.type} name`),onConfirm:C,onCancel:A,children:l.jsx(Rh,{error:M,select:!0,focus:!0,value:y,onChange:({value:F})=>b(F)})}):null,g?l.jsx(ih,{title:i("Are you sure you want to delete these items:"),onConfirm:E,onCancel:()=>w(null),children:g.selected?l.jsx("ul",{className:"wx-gq7BMzEP wx-list",children:g.selected.map((F,P)=>l.jsx("li",{children:F},P))}):null}):null]})}let jx={"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 Oj(n){const a=n.lastIndexOf("."),i=a>0&&a<n.length-1?Math.min(10,n.length-a):Math.min(5,n.length),r=n.slice(0,-i),c=n.slice(-i);return[r,c]}function Ij({item:n}){const a=f.useContext(kn),i=f.useContext(Mn.i18n).getGroup("filemanager"),r=f.useContext(kn).templates,[c]=ns(a,"panels"),d=Xe(a,"activePanel"),h=Xe(a,"mode"),p=c[d].selected,v=f.useMemo(()=>r.preview(n,214,163),[r,n]),g=f.useMemo(()=>r.icon(n,"big"),[r,n]),[w,y]=f.useMemo(()=>Oj(n.name),[n.name]);return l.jsx(l.Fragment,{children:n.id==="/wx-filemanager-parent-link"?h!=="search"?l.jsx("div",{className:"wx-GAOa4kDV wx-back-item",children:l.jsxs("div",{className:`wx-GAOa4kDV wx-back ${n.navigation?"wx-selected":""}`,"data-id":jn("/wx-filemanager-parent-link"),children:[l.jsx("i",{className:"wx-GAOa4kDV wxi-arrow-left"}),l.jsx("span",{children:i("Back to parent folder")})]})}):null:l.jsxs("div",{className:`wx-GAOa4kDV wx-item ${p?.length&&p.indexOf(n.id)>=0?"wx-selected":""}`,"data-id":jn(n.id),children:[v?l.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-preview",children:l.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:i("A miniature file preview"),src:v})}):g?l.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-icon",children:l.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:"",src:g})}):l.jsx("div",{className:"wx-GAOa4kDV wx-preview",children:l.jsx("i",{className:`wx-GAOa4kDV wxi-${n.type}`})}),n.type==="folder"?l.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[l.jsxs("div",{className:"wx-GAOa4kDV wx-folder-name",children:[l.jsx("span",{className:"wx-GAOa4kDV wx-type",children:i("Folder")}),l.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[l.jsx("span",{children:w}),l.jsx("span",{children:y})]})]}),l.jsx("div",{"data-action-id":jn(n.id),className:"wx-GAOa4kDV wx-more",children:l.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]}):l.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[l.jsx("div",{className:"wx-GAOa4kDV wx-file-name",children:l.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[l.jsx("span",{children:w}),l.jsx("span",{children:y})]})}),l.jsx("div",{"data-action-id":jn(n.id),className:"wx-GAOa4kDV wx-more",children:l.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]})]})})}function tw(){const n=f.useContext(kn),a=f.useContext(Mn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),[r]=ns(n,"panels"),c=Xe(n,"activePanel"),d=Xe(n,"mode"),h=r[c]._files,p=r[c].selected,v=r[c].path,g=r[c]._crumbs,w=r[c]._selectNavigation,y=f.useCallback((A,E)=>{const U=E&&(E.ctrlKey||E.metaKey),F=E&&E.shiftKey;if(A==="/wx-filemanager-parent-link"){if(p.length&&(U||F))return;n.exec("select-file",{type:"navigation"});return}let P=A==="body"&&E?null:A;const L=E.target.className.indexOf("wx-more")!==-1||E.target.className.indexOf("wxi-dots-v")!==-1;setTimeout(()=>{n.exec("select-file",{id:P,toggle:U&&!L,range:F&&!L,panel:c})},1)},[n,p,c]),b=f.useCallback(()=>{g.length>1&&n.exec("set-path",{id:g[g.length-2].id,panel:c,selected:[g[g.length-1].id]})},[n,g,c]),j=f.useCallback(A=>{if(A==="/wx-filemanager-parent-link")return b();d==="search"&&n.exec("filter-files",{text:""});const E=h.find(U=>U.id===A);E&&(E.type=="folder"?n.exec("set-path",{id:E.id,panel:c}):n.exec("open-file",{id:E.id}))},[n,b,d,h,c]),k=f.useCallback((A,E)=>{(!p?.length||!p.filter(U=>U?.id===A).length>0)&&y(A,E)},[p,y]),M=f.useMemo(()=>v!=="/"?[{id:"/wx-filemanager-parent-link",name:i("Back to parent folder"),navigation:w},...h]:h,[v,i,w,h]),R=f.useRef(null),C=f.useRef();return f.useEffect(()=>{R.current&&(C.current?(C.current.click=y,C.current._dblclick=j,C.current.context=k):(C.current={click:y,dblclick:A=>C.current._dblclick(A),_dblclick:j,context:k},Xr(R.current,C.current)))},[y,j,k]),d=="search"&&!M.length?l.jsx("div",{className:"wx-iyjASZCY wx-not-found",children:l.jsx("div",{className:"wx-iyjASZCY wx-not-found-text",children:i("Looks like nothing is here")})}):l.jsx("div",{tabIndex:0,className:"wx-iyjASZCY "+("wx-cards"+(v!=="/"&&d!=="search"?" wx-has-back-link":"")),"data-id":jn("body"),ref:R,children:M.map(A=>l.jsx(Ij,{item:A},A.id))})}function Wi({name:n="",spin:a=!1,onClick:i}){return l.jsx("i",{"data-menu-ignore":"true",className:`wx-uwcvNSAG wx-icon wxi-${n} ${a?"wx-spin":""} ${i?"wx-clickable":""}`,onClick:()=>{i&&i()}})}function Bj(){const n=f.useContext(Mn.i18n).getGroup("filemanager"),a=f.useContext(kn),i=Xe(a,"activePanel"),[r]=ns(a,"panels"),c=f.useMemo(()=>r[i]._crumbs,[r,i]);function d(){a.exec("filter-files",{text:""})}return l.jsxs("div",{className:"wx-GDJvtROw wx-search",children:[l.jsxs("div",{className:"wx-GDJvtROw wx-toolbar",children:[l.jsx("div",{className:"wx-GDJvtROw wx-back-icon",children:l.jsx(Wi,{name:"angle-left",onClick:d})}),l.jsxs("div",{className:"wx-GDJvtROw wx-text",children:[n("Search results in")," ",Array.isArray(c)&&c.map((h,p)=>l.jsxs(f.Fragment,{children:[p?"/":null,h.id=="/"?n(h.name):h.name]},p))]})]}),l.jsx(tw,{})]})}function Dm({narrowMode:n,extraInfo:a}){const i=f.useContext(kn),{preview:r,icon:c}=i.templates,d=f.useContext(Mn.i18n),h=f.useMemo(()=>d.getGroup("filemanager"),[d]),p=f.useMemo(()=>Vr("%D, %d %F %Y, %H:%i",d.getRaw().calendar),[d]),[v,g]=ns(i,"panels"),w=Xe(i,"activePanel"),y=Xe(i,"preview"),b=Xe(i,"search"),j=f.useMemo(()=>{const L=v&&w!=null&&v[w]?._selected?.length||0;return b&&!L},[b,g,w]),k=f.useMemo(()=>{const L=v&&w!=null?v[w]:null;return L?j?L._files:L._selected:[]},[j,g,w]),M=f.useCallback((L,I)=>(L?`${L} ${h(L>1?"folders":"folder")} `:"")+(I?`${I} ${h(I>1?"files":"file")}`:""),[h]),R=f.useCallback(()=>{i.exec("show-preview",{mode:!y})},[i,y]),C=f.useCallback(L=>L.type==="folder"?h("Folder"):L.ext||h("Unknown file"),[h]),A=f.useMemo(()=>{let L,I,de,W,ue,Z,le,ce;if(k.length===1&&!j){I=k[0],L=I.name;const Q=r(I,400,500);Q?(de=Q,W=""):(W=c(I,"big"),de=""),ue=I.type!=="folder"}else{if(I=ue=null,L="",k.length){let Q=0,_=0,Y=0,$=[],H;k.forEach(xe=>{typeof xe.size>"u"&&(H=!0,Q=void 0),H||(Q+=xe.size),$.push(C(xe)),xe.type==="folder"?_++:Y++});const ie=new Set($);Z=ie.size>1?h("multiple"):[...ie][0],le=M(_,Y),ce=Q,j||(L=h("Multiple files"))}W=c({type:j?"search":k.length?"multiple":"none"},"big"),de=""}return{name:L,item:I,previewSrc:de,iconSrc:W,showDownloadIcon:ue,type:Z,totalCount:le,totalSize:ce}},[k,j,r,c,h,C,M]),E=f.useCallback(()=>{i.exec("download-file",{id:k[0].id})},[i,k]),U=f.useCallback(async L=>{if(!a||!L)return null;try{return await a(L)}catch(I){return console.log(I),null}},[a]),[F,P]=f.useState(null);return f.useEffect(()=>{let L=!1;return P(null),Promise.resolve(U(A.item)).then(I=>{L||P(I)}).catch(()=>{L||P(null)}),()=>{L=!0}},[U,A.item]),l.jsx("div",{className:"wx-O0BTtRrH wx-wrapper",children:k&&k.length?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-preview",children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-name",children:A.name}),l.jsxs("div",{className:"wx-O0BTtRrH wx-icons",children:[A.showDownloadIcon?l.jsx(Wi,{name:"download",onClick:E}):null,n?l.jsx(Wi,{name:"close",onClick:R}):null]})]}),A.previewSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:l.jsx("img",{src:A.previewSrc,alt:h("A miniature file preview")})}):A.iconSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("img",{src:A.iconSrc,alt:h("A miniature file preview")})}):l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:A.item?l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${A.item.type}`}):l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${j?"search":"file-multiple-outline"}`})})]}),l.jsxs("div",{className:"wx-O0BTtRrH wx-info-panel",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-title",children:h(j?"Found":"Information")}),l.jsxs("div",{className:"wx-O0BTtRrH wx-list",children:[A.item?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Type")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:C(A.item)}),typeof A.item.size<"u"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Size")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:wc(A.item.size)})]}):null,l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Date")}),l.jsxs("span",{className:"wx-O0BTtRrH wx-value",children:[p(A.item.date)," "]})]}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Count")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:A.totalCount}),l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Type")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:A.type}),typeof A.totalSize<"u"?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:h("Size")}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:wc(A.totalSize)})]}):null]}),F?Object.entries(F).map(([L,I])=>l.jsxs(yh.Fragment,{children:[l.jsx("span",{className:"wx-O0BTtRrH wx-name",children:L}),l.jsx("span",{className:"wx-O0BTtRrH wx-value",children:I})]},L)):null]})]})]}):l.jsxs("div",{className:"wx-O0BTtRrH wx-no-info-panel",children:[l.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[l.jsx("div",{className:"wx-O0BTtRrH wx-name",children:A.name}),l.jsx("div",{className:"wx-O0BTtRrH wx-icons",children:n?l.jsx(Wi,{name:"close",onClick:R}):null})]}),l.jsx("div",{className:"wx-O0BTtRrH wx-no-info-wrapper",children:l.jsxs("div",{className:"wx-O0BTtRrH wx-no-info",children:[A.previewSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:l.jsx("img",{src:A.previewSrc,alt:h("A miniature file preview")})}):A.iconSrc?l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("img",{src:A.iconSrc,alt:h("A miniature file preview")})}):l.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:l.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${j?"search":"message-question-outline"}`})}),l.jsx("span",{className:"wx-O0BTtRrH wx-text",children:j?"":h("Select file or folder to view details")})]})})]})})}function nw({panel:n}){const a=f.useContext(kn),i=f.useContext(Mn.i18n),r=f.useMemo(()=>i.getGroup("filemanager"),[i]),[c,d]=ns(a,"panels"),h=f.useMemo(()=>c[n]._files,[d,n]),p=f.useMemo(()=>c[n]._crumbs||[],[d,n]);function v(k){const M=_h(k,p);a.exec("set-path",{id:k,panel:n,...M&&{selected:[M]}})}const[g,w]=f.useState(null);f.useEffect(()=>{h&&w(null)},[h]);function y(){w(!0),a.exec("request-data",{id:p[p.length-1].id}),setTimeout(()=>{w(null)},5e3)}const b=f.useRef(null),j=f.useRef();return f.useEffect(()=>{j.current?j.current.click=v:(j.current={click:v},Xr(b.current,j.current))},[v]),l.jsxs("div",{className:"wx-SNY5LTYx wx-breadcrumbs","data-menu-ignore":"true",ref:b,children:[l.jsx("div",{className:"wx-SNY5LTYx wx-refresh-icon",children:l.jsx(Wi,{name:"refresh",spin:!!g,onClick:y})}),p.map((k,M)=>l.jsxs(yh.Fragment,{children:[M?l.jsx(Wi,{name:"angle-right"}):null,l.jsx("div",{className:"wx-SNY5LTYx wx-item","data-id":jn(k.id),"data-menu-ignore":"true",children:k.id=="/"?r(k.name):k.name})]},M))]})}function Fj({row:n}){const a=f.useContext(Mn.i18n),[i]=f.useState(()=>a.getGroup("filemanager")),r=f.useContext(kn).templates,[c]=f.useState(()=>r.icon(n,"small"));return l.jsx("div",{className:"wx-qgAqG6sL wx-name-cell",children:n.id==="/wx-filemanager-parent-link"?l.jsxs(l.Fragment,{children:[l.jsx("i",{className:"wx-qgAqG6sL wxi-arrow-left"}),l.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",i("Back to parent folder")]})]}):l.jsxs(l.Fragment,{children:[c?l.jsx("img",{className:"wx-qgAqG6sL wx-icon",alt:"",src:c,height:"24px",width:"24px"}):l.jsx("i",{className:`wx-qgAqG6sL wxi-${n.type}`}),l.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",n.name," "]})]})})}function aw({children:n}){const a=f.useContext(kn),i=Xe(a,"activePanel"),r=f.useContext(Ih),c=f.useRef(null);let d=f.useRef({});return d.current.drop=()=>{const h=c.current,p=$0(h,"data-panel");p&&p!=i&&a.exec("set-active-panel",{panel:p*1})},d.current.dragEnter=()=>{const h=c.current;h&&h.classList.toggle("wx-active")},d.current.dragLeave=()=>{const h=c.current;h&&h.classList.toggle("wx-active")},f.useEffect(()=>{const h=c.current;return r.droparea(h,d.current)},[]),l.jsx("div",{className:"wx-LT9X7tb7 wx-upload-area",ref:c,children:n})}function ch({panel:n,active:a=!1,onClick:i,onContextMenu:r}){const c=f.useContext(kn),d=f.useContext(Mn.i18n),h=f.useMemo(()=>d.getGroup("filemanager"),[d]),p=f.useMemo(()=>Vr("%d %M %Y",d.getRaw().calendar),[d]),[v]=ns(c,"panels"),g=v[n].selected,w=v[n].path,y=v[n]._crumbs,b=v[n]._sorts,j=v[n]._selectNavigation,k=v[n]._files,M=f.useMemo(()=>[{id:"name",header:h("Name"),flexgrow:3,sort:!0,resize:!0,cell:Fj},{id:"size",header:h("Size"),width:100,sort:!0,resize:!0,template:Z=>typeof Z=="number"?wc(Z):""},{id:"date",header:h("Date"),width:120,sort:!0,resize:!0,template:Z=>Z?p(Z):""}],[h,p]),R=f.useRef(null),C=f.useRef(null),A=f.useMemo(()=>j?["/wx-filemanager-parent-link"]:[...g],[j,g]);function E(Z,le){if(le&&le.target&&le.target.className&&le.target.className.indexOf("wx-grip")!==-1)return;const ce=le&&(le.ctrlKey||le.metaKey),Q=le&&le.shiftKey;if(Z==="/wx-filemanager-parent-link"){if(g.length&&(ce||Q))return;c.exec("select-file",{type:"navigation"});return}let _=Z==="body"&&le?null:Z;!R.current&&!C.current?c.exec("select-file",{id:_,toggle:ce,range:Q,panel:n}):(R.current=null,C.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 F(Z){if(Z==="/wx-filemanager-parent-link")return U();const le=k.find(ce=>ce.id===Z);le&&(le.type==="folder"?c.exec("set-path",{id:le.id,panel:n}):c.exec("open-file",{id:le.id}))}function P(Z){const le=Z.key,ce=b[w];let Q=ce?"asc":"desc";ce&&ce.key===le&&(Q=ce.order==="asc"?"desc":"asc"),c.exec("sort-files",{key:le,order:Q,panel:n,path:w})}function L(Z){Z.intercept("sort-rows",le=>(R.current=!0,P(le),!1)),Z.intercept("select-row",()=>!1),Z.on("resize-column",()=>C.current=!0),Z.intercept("hotkey",()=>!1)}const I=f.useMemo(()=>w!=="/"?[{id:"/wx-filemanager-parent-link",name:h("Back to parent folder")},...k]:k,[w,k,h]),de=f.useMemo(()=>{if(I&&b&&b[w]){const{key:Z,order:le}=b[w];return{[Z]:{order:le}}}},[I,b,w]),W=f.useRef(null),ue=f.useRef();return f.useEffect(()=>{ue.current?(ue.current.click=E,ue.current._dblclick=F):(ue.current={click:E,dblclick:Z=>ue.current._dblclick(Z),_dblclick:F},Xr(W.current,ue.current))},[E,F]),l.jsxs("div",{onClick:i,onContextMenu:r,className:"wx-SSaVhET7 wx-wrapper",children:[l.jsx(nw,{panel:n}),l.jsx("div",{"data-id":jn("body"),className:`wx-SSaVhET7 wx-list ${a?"wx-active":""}`,ref:W,children:l.jsx(aw,{children:l.jsx(_j,{init:L,data:I,columns:M,selectedRows:A,columnStyle:()=>"wx-SSaVhET7 wx-each-cell",sizes:{rowHeight:42,headerHeight:42},sortMarks:de})})})]})}function Hj(){const n=f.useContext(kn),a=Xe(n,"activePanel");function i(r){n.exec("set-active-panel",{panel:r})}return l.jsxs("div",{className:"wx-L55BfJa2 wx-panels","data-id":jn("body"),children:[l.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":0,children:l.jsx(ch,{panel:0,active:a==0,onClick:()=>i(0),onContextMenu:()=>i(0)})}),l.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":1,children:l.jsx(ch,{panel:1,active:a==1,onClick:()=>i(1),onContextMenu:()=>i(1)})})]})}function sw({folderIcon:n=!1,folder:a={}}){const i=f.useContext(kn),[r,c]=ns(i,"panels"),d=Xe(i,"activePanel"),h=f.useMemo(()=>r[d].path,[c,d]),p=f.useContext(Mn.i18n),v=f.useMemo(()=>p.getGroup("filemanager"),[p]),g=f.useMemo(()=>!!a.data?.find(j=>j.type==="folder"),[a]),w=f.useMemo(()=>a.id=="/"?v(a.name):a.name,[a,v]),y=f.useMemo(()=>a.$level>1?(a.$level-1)*20:0,[a]),b=a.open;return l.jsxs(l.Fragment,{children:[l.jsxs("li",{"data-id":jn(a.id),className:`wx-NYfhvGIt wx-folder${h===a.id?" wx-selected":""}`,style:{paddingLeft:`${y}px`},children:[g?l.jsx("i",{className:`wx-NYfhvGIt wx-toggle wxi-${b?"angle-down":"angle-right"}`,"data-action":"toggle"}):l.jsx("span",{className:"wx-NYfhvGIt wx-toggle-placeholder"}),l.jsx("i",{className:"wx-NYfhvGIt "+(n||"wxi-folder")}),l.jsxs("span",{className:"wx-NYfhvGIt wx-name",children:[" ",w," "]})]}),b&&a.data&&a.data.length&&g?l.jsx(l.Fragment,{children:a.data.map(j=>j.type==="folder"?l.jsx(sw,{folder:j},j.id):null)}):null]})}function Uj(){const n=f.useContext(kn),[a,i]=ns(n,"data"),[r,c]=ns(n,"panels"),d=Xe(n,"activePanel"),h=f.useMemo(()=>r[d]._crumbs,[c,d]),p=f.useCallback(j=>{n.exec("open-tree-folder",{id:j,mode:!a.byId(j).open})},[n,i]),v=f.useCallback(j=>{const k=_h(j,h);n.exec("set-path",{id:j,panel:d,...k&&{selected:[k]}})},[n,h,d]),[g,w]=f.useState([]);f.useEffect(()=>{w(a.byId(0).data)},[i]);const y=f.useRef(null),b=f.useRef();return f.useEffect(()=>{b.current?(b.current.click=v,b.current.toggle=p):(b.current={click:v,toggle:p},Xr(y.current,b.current))},[v,p]),l.jsx("ul",{ref:y,className:"wx-LyHJ6R6A",children:g.map(j=>j.type==="folder"?l.jsx(sw,{folder:j},j.id):null)})}function $j(){const n=f.useContext(kn),a=f.useContext(Mn.i18n),i=f.useMemo(()=>a.getGroup("filemanager"),[a]),r=Xe(n,"drive"),c=r?r.used:"",d=r?r.total:"";return c&&d?l.jsxs("div",{className:"wx-DetSyKGG wx-drive",children:[l.jsx("progress",{value:c,max:d,className:"wx-DetSyKGG wx-progress"}),l.jsxs("p",{children:[wc(c)," ",i("of")," ",wc(d)," ",i("used")]})]}):null}function Pj({option:n}){const a=f.useContext(Mn.i18n).getGroup("filemanager"),i=f.useContext(Ih),r=f.useCallback(()=>{i.open({})},[i]);return l.jsx("div",{className:"wx-9XiKcxq5 wx-upload-button",onClick:r,children:l.jsx("span",{children:a(n.text)})})}function qj({readonly:n,menuOptions:a}){const i=f.useContext(Mn.i18n).getGroup("filemanager"),{showPrompt:r}=f.useContext(Oh);f.useEffect(()=>{oC("upload",Pj)},[]);function c({action:h}){h&&(h.id==="add-file"?r({item:{type:"file",size:0,date:new Date},add:!0}):h.id==="add-folder"&&r({item:{type:"folder",date:new Date},add:!0}))}const d=f.useMemo(()=>a("add").map(h=>(h.text=i(h.text),h)),[a,i]);return l.jsxs("div",{className:"wx-FlucfALM wx-wrapper",children:[!n&&l.jsx("div",{className:"wx-FlucfALM wx-button",children:l.jsx(uC,{options:d,at:"bottom-fit",onClick:c,children:l.jsx(fc,{type:"primary block",children:i("Add New")})})}),l.jsx("div",{className:"wx-FlucfALM wx-tree",children:l.jsx(Uj,{})}),l.jsx($j,{})]})}function Gj({value:n="",onSearch:a}){const[i,r]=By(n),c=f.useContext(Mn.i18n).getGroup("filemanager"),d=f.useRef(null),h=f.useMemo(()=>i!==""?"wxi-close":"wxi-search",[i]);function p(g){const w=g.target.value;r(w),a&&a({value:w})}function v(){r(""),d.current&&d.current.focus(),a&&a({value:""})}return l.jsxs("div",{className:"wx-lUZMtgT1 wx-search-input",children:[l.jsx("i",{className:`wx-lUZMtgT1 wx-icon ${h}`,onClick:v}),l.jsx("input",{type:"text",className:"wx-lUZMtgT1 wx-text",ref:d,value:i,onInput:p,placeholder:c("Search")})]})}function Vj({narrowMode:n=!1,onShowTree:a}){const i=f.useContext(kn),r=f.useContext(Mn.i18n).getGroup("filemanager"),c=Xe(i,"mode"),d=Xe(i,"preview"),h=Xe(i,"search"),p=[{icon:"wxi-view-sequential",id:"table"},{icon:"wxi-view-grid",id:"cards"},{icon:"wxi-view-column",id:"panels"}];function v({value:y}){i.exec("set-mode",{mode:y})}function g(y){y.preventDefault(),i.exec("show-preview",{mode:!d})}function w(y){i.exec("filter-files",{text:y.value})}return l.jsxs("div",{className:"wx-5PZQQztG wx-toolbar",children:[l.jsxs("div",{className:"wx-5PZQQztG wx-left "+(n?"wx-left-narrow":""),children:[n?c==="panels"||c==="search"?null:l.jsx("div",{className:"wx-5PZQQztG wx-sidebar-icon","data-id":jn("toggle-tree"),children:l.jsx(Wi,{onClick:()=>a&&a(),name:"subtask"})}):l.jsx("div",{className:"wx-5PZQQztG wx-name",children:r("Files")}),l.jsx(Gj,{onSearch:w,value:h})]}),l.jsxs("div",{className:"wx-5PZQQztG wx-right",children:[n?null:l.jsx("div",{className:"wx-5PZQQztG wx-preview-icon",children:l.jsx(O1,{onClick:g,value:d,children:l.jsx("i",{className:"wx-5PZQQztG wxi-eye"})})}),l.jsx("div",{className:"wx-5PZQQztG wx-modes",children:l.jsx(R1,{value:c,options:p,onChange:v})})]})]})}function Yj(){const n=f.useContext(kn),a=Xe(n,"activePanel");return l.jsxs("div",{className:"wx-NwohNJzN wx-wrapper",children:[l.jsx(nw,{panel:a}),l.jsx(aw,{children:l.jsx(tw,{})})]})}function Wj({readonly:n=!1,menuOptions:a,extraInfo:i}){const r=f.useRef(null),c=f.useRef(null),[d,h]=f.useState(void 0),[p,v]=f.useState(void 0),[g,w]=f.useState(!1),y=Gy(),b=f.useContext(kn),{showPrompt:j,showConfirm:k}=f.useContext(Oh),M=f.useContext(Mn.i18n),R=f.useMemo(()=>M.getGroup("filemanager"),[M]),C=Xe(b,"mode"),A=Xe(b,"preview"),E=Xe(b,"activePanel"),[U,F]=ns(b,"panels"),P=f.useMemo(()=>(U&&E!=null?U[E]:null)?.selected??[],[F,E]),L=f.useMemo(()=>(U&&E!=null?U[E]:null)?.path,[F,E]),[I,de]=f.useState([]);f.useEffect(()=>{const ie=r.current;if(!ie)return;const xe=new ResizeObserver(D=>{const J=D[0]?.borderBoxSize?.[0]?.inlineSize;typeof J=="number"&&v(J<768)});return xe.observe(ie),()=>{xe.disconnect()}},[]);const W=f.useCallback(()=>{w(ie=>!ie)},[]),ue=f.useCallback(ie=>{p&&yc(ie)!=="toggle-tree"&&w(!1)},[p]);f.useEffect(()=>{const ie=c.current;if(ie)return qs(ie,ue).destroy},[ue]),f.useEffect(()=>{const ie=c.current;if(!ie)return;const xe=new ResizeObserver(()=>{ie&&h(ie.clientWidth)});return xe.observe(ie),ie&&h(ie.clientWidth),()=>{xe.disconnect()}},[]);const Z=f.useMemo(()=>({icon:"wxi-eye",text:"Preview",id:"preview"}),[]),le=f.useCallback(ie=>{let xe=p?[Z]:[];return ie==="file"&&(xe=[...xe,...a().filter(D=>D.id==="download")]),xe},[p,Z,a]),ce=f.useRef(null),Q=f.useCallback((ie,xe,D)=>{const J=D?[xe.id]:P;switch(ie){case"download":b.exec("download-file",{id:xe.id});break;case"copy":case"move":ce.current={action:ie,ids:J};break;case"paste":ce.current&&b.exec(ce.current.action==="copy"?"copy-files":"move-files",{ids:ce.current.ids,target:xe?.type==="folder"?xe.id:L});break;case"rename":j({item:xe});break;case"delete":k({selected:J});break;case"preview":b.exec("show-preview",{mode:!A});break}},[b,P,L,j,k,A]),_=f.useCallback(()=>U?.[E],[U,E]);f.useEffect(()=>{const ie=r.current;if(!ie)return;const xe=X1(ie,{api:b,menuOptions:n?le:a,performAction:Q,getPanel:_});return()=>{typeof xe=="function"?xe():xe&&typeof xe.destroy=="function"&&xe.destroy()}},[b,n,le,a,Q,_]);const Y=f.useCallback((ie,xe)=>{const D=ie?b.getFile(ie):null,J=xe.target.closest(".tree-item.folder");let he;if(n)he=le(D?.type);else{switch(ie){case"body":he=a(ie);break;default:if(D)if(!J&&P.length>1)he=p?[Z,...a("multiselect")]:a("multiselect");else if(ie==="/")he=a("folder",D).filter(we=>we.id==="paste");else{const we=a(D.type,D);we&&(he=p?[Z,...we]:we)}}C==="search"&&(he=he?.filter(we=>we.id!=="paste"))}if(D?.id&&(!P.length||!P.some(we=>we===D.id))&&!J&&b.exec("select-file",{id:D.id}),he?.length)return he.forEach(we=>{J&&(we.hotkey=""),we.text&&(we.text=R(we.text)),we.hotkey&&(we.subtext=we.hotkey)}),de(he),D||{}},[b,n,le,a,P,p,Z,C,R]),$=f.useCallback(ie=>{const{action:xe,context:D}=ie;xe&&Q(xe.id,D,!xe.hotkey)},[Q]);async function H(ie){await Promise.resolve();const{name:xe,size:D}=ie.file;b.exec("create-file",{file:{name:xe,size:D,date:new Date,file:ie.file},parent:L})}return l.jsx("div",{className:"wx-RJbNonjJ wx-filemanager wx-flex",ref:r,"data-menu-ignore":"false",children:p&&A?l.jsx("div",{className:"wx-RJbNonjJ wx-info-narrow",children:l.jsx(Dm,{narrowMode:p,extraInfo:i})}):l.jsxs(l.Fragment,{children:[l.jsx(Vj,{narrowMode:p,onShowTree:W}),l.jsx(dC,{dataKey:"id",at:"point",options:I,resolver:Y,onClick:$,children:l.jsxs(qy,{dataKey:"actionId",options:I,resolver:Y,onClick:$,children:[l.jsx(gC,{data:y,apiOnly:!0,uploadURL:H}),l.jsx(Ih.Provider,{value:y,children:l.jsx("div",{className:"wx-RJbNonjJ wx-content-wrapper wx-flex",children:C!=="panels"&&C!=="search"?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"wx-RJbNonjJ "+["wx-sidebar",p?"wx-sidebar-narrow":"",g?"wx-sidebar-visible":""].filter(Boolean).join(" "),ref:c,children:l.jsx(qj,{readonly:n,menuOptions:a})}),l.jsxs("div",{className:"wx-RJbNonjJ wx-content",style:{width:`calc(100% - ${d||0}px - 10px)`},children:[l.jsx("div",{className:`wx-RJbNonjJ wx-content-item${A?"":"-fit"}`,"data-id":jn("body"),children:C==="table"?l.jsx(ch,{panel:E}):l.jsx(Yj,{})}),A?l.jsx("div",{className:"wx-RJbNonjJ wx-info",children:l.jsx(Dm,{extraInfo:i})}):null]})]}):l.jsxs(l.Fragment,{children:[l.jsx("div",{className:`wx-RJbNonjJ wx-content-item${A?"":"-fit"}`,children:C==="panels"?l.jsx(Hj,{}):l.jsx(Bj,{})}),A?l.jsx("div",{className:"wx-RJbNonjJ wx-info",children:l.jsx(Dm,{extraInfo:i})}):null]})})})]})})]})})}const Kj=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join("");function Qj(n,a){const{type:i,ext:r}=n;if(i==="folder")return!1;let c;return i&&i!=="file"&&jx[i]?c=i:r?c=jx[r]?r:"file":c="unknown",`https://cdn.svar.dev/icons/filemanager/vivid/${a}/${c}.svg`}const Xj=f.forwardRef(function(n,a){const{data:i=[],mode:r="cards",drive:c=null,preview:d=!1,panels:h=null,activePanel:p=0,readonly:v=!1,menuOptions:g=W1,extraInfo:w=null,init:y=null,icons:b=Qj,previews:j=null,...k}=n,M=f.useRef();M.current=k;const R=f.useMemo(()=>new Y1(Hy),[]),C=f.useMemo(()=>R.in,[R]),A=f.useRef(null);A.current===null&&(A.current=new _y((F,P)=>{const L="on"+Kj(F);M.current&&M.current[L]&&M.current[L](P)}),C.setNext(A.current));const E=f.useMemo(()=>({getState:R.getState.bind(R),getReactiveState:R.getReactive.bind(R),getStores:()=>({data:R}),exec:C.exec,setNext:F=>(A.current=A.current.setNext(F),A.current),intercept:C.intercept.bind(C),on:C.on.bind(C),detach:C.detach.bind(C),getFile:R.getFile.bind(R),serialize:R.serialize.bind(R),templates:{preview:j||(()=>null),icon:b==="simple"?(()=>null):b}}),[R,C]),U=f.useRef(0);return f.useEffect(()=>{if(!U.current)y&&y(E);else{const F=R.getState();R.init({data:i,mode:r,drive:c,preview:d,panels:h||F.panels||[],activePanel:p})}U.current++},[R,i,r,c,d,h,p,y,E]),U.current===0&&R.init({data:i,mode:r,drive:c,preview:d,panels:h||[],activePanel:p}),f.useImperativeHandle(a,()=>({...E}),[E]),l.jsx(kn.Provider,{value:E,children:l.jsx(Dh,{words:Lh,optional:!0,children:l.jsx(zj,{children:l.jsx(Wj,{readonly:v,menuOptions:g,extraInfo:w})})})})});function Zj({fonts:n=!0,children:a}){return a?l.jsx(cx,{fonts:n,children:a}):l.jsx(cx,{fonts:n})}kh(va);function Bh(n,a){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Invalid Hub ${a} response.`);return n}function Cc(n,a,i){const r=Bh(n,i);if(!Array.isArray(r[a]))throw new Error(`Invalid Hub ${i} response: ${a} must be an array.`);return r[a]}function Jj(n,a,i){const r=Bh(n,i);if(!r[a]||typeof r[a]!="object"||Array.isArray(r[a]))throw new Error(`Invalid Hub ${i} response: ${a} must be an object.`);return r[a]}async function kx(n,a=!1){return Cc(await Be(`/api/remote/filesystem/roots${a?"?refresh=1":""}`,void 0,n),"roots","filesystem roots")}async function Lm(n,a){const i=await Be(`/api/remote/filesystem/entries?id=${encodeURIComponent(n)}`,void 0,a);return{folder:Jj(i,"folder","filesystem entries"),entries:Cc(i,"entries","filesystem entries")}}async function ek(n,a){return Be("/api/remote/filesystem/selection/scan",{method:"POST",body:JSON.stringify({itemIds:n})},a)}async function tk(n,a,i,r){return Be("/api/remote/files/from-hub",{method:"POST",body:JSON.stringify({itemIds:n,deviceIds:a,remoteDirectory:i})},r)}async function nk(n,a=!1){const i=await Be(`/api/remote/files/jobs?active=${a?"1":"0"}`,void 0,n);return{jobs:Cc(i,"jobs","file transfer jobs")}}async function ak(n,a){return Be(`/api/remote/files/jobs/${encodeURIComponent(n)}`,void 0,a)}async function sk(n,a){return Be(`/api/remote/files/jobs/${encodeURIComponent(n)}/cancel`,{method:"POST"},a)}async function Mx(n){return Cc(await Be("/api/remote/filesystem/shared-folders",void 0,n),"folders","shared folders")}async function lk(n,a){return Be("/api/remote/filesystem/shared-folders",{method:"POST",body:JSON.stringify({sourceId:n})},a)}async function ik(n,a,i){return Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)},i)}async function rk(n,a){return Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function ok(n,a,i,r){const c=await Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}/sync`,{method:"POST",body:JSON.stringify({deviceIds:a,remoteDirectory:i})},r),d=Bh(c,"shared folder sync");return{ok:d.ok===!0,jobs:Cc(c,"jobs","shared folder sync"),files:Number(d.files||0),totalBytes:Number(d.totalBytes||0)}}function ck(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 Ax(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function rd(n){return n.driveType==="network"?"network":n.driveType==="removable"?"removable":"local"}function uk(n){const a=n.filter(i=>rd(i)==="local");return a.find(i=>/\bC:/i.test(`${i.name} ${i.displayPath||""}`))||a[0]||n[0]||null}function dk({hubUrl:n,roots:a,loading:i,error:r,onRefreshRoots:c,onImportFiles:d,onImportFolder:h,onSelectionChange:p,onShareItem:v,onAddSyncFolder:g,onNotice:w}){const y=f.useRef(null),b=f.useRef("/"),j=f.useRef(0),k=f.useRef([]),M=f.useRef(new Map),[R,C]=f.useState(null),[A,E]=f.useState([]),[U,F]=f.useState([]),[P,L]=f.useState(0),[I,de]=f.useState(null),[W,ue]=f.useState(!1),[Z,le]=f.useState(""),[ce,Q]=f.useState(new Set),_=a.find(ne=>ne.id===R)||null,Y=A[A.length-1]||null,$=_?Y?.svarPath||`/${_.name}`:null,H=$;f.useEffect(()=>{k.current=A,b.current=H||"/"},[H,A]);const ie=f.useMemo(()=>(M.current.clear(),!_||!H||A.length===0?[]:(A.forEach(ne=>M.current.set(ne.svarPath,ne.hubId)),[...A.map((ne,pe)=>({id:ne.svarPath,parent:pe===0?"/":A[pe-1].svarPath,type:"folder",name:ne.name,date:ne.modifiedAt?new Date(ne.modifiedAt):void 0,lazy:!1})),...U.map(ne=>{const pe=`${H}/${ne.name}`;return M.current.set(pe,ne.id),{id:pe,parent:H,name:ne.name,type:ne.type==="file"?"file":"folder",...ne.type==="file"?{size:ne.size}:{},date:ne.modifiedAt?new Date(ne.modifiedAt):void 0,lazy:ne.type!=="file"&&ne.hasChildren===!0,displayPath:ne.displayPath,locked:ne.locked,driveType:ne.driveType,totalBytes:ne.totalBytes,freeBytes:ne.freeBytes}})])),[_,U,H,A]),xe=ne=>M.current.get(String(ne))||String(ne),D=ne=>ck({...ne,id:xe(String(ne.id)),parent:xe(String(ne.parent))}),J=async(ne,pe)=>{const Me=ne[ne.length-1];if(!Me)return;const V=++j.current;ue(!0),le("");try{const ae=await Lm(Me.hubId,n);if(V!==j.current)return;if(!Array.isArray(ae.entries))throw new Error("Invalid Hub filesystem entries response.");const ke={...Me,displayPath:ae.folder.displayPath||Me.displayPath,modifiedAt:ae.folder.modifiedAt||Me.modifiedAt},be=[...ne.slice(0,-1),ke];k.current=be,E(be),F(ae.entries),L(st=>st+1)}catch(ae){if(V!==j.current)return;console.error("[LiveDesk FS] folder navigation failed",{folderId:Me.hubId,error:ae}),le(ae instanceof Error?`${pe}: ${ae.message}`:`${pe}: Unable to read this folder.`)}finally{V===j.current&&ue(!1)}},he=async ne=>{const pe={svarPath:`/${ne.name}`,hubId:ne.id,name:ne.name,displayPath:ne.displayPath,modifiedAt:ne.modifiedAt},Me=++j.current;C(ne.id),k.current=[pe],E([pe]),b.current=pe.svarPath,F([]),le(""),ue(!0),de(ne.id),Q(V=>{const ae=new Set(V);return ae.delete(ne.id),ae});try{const V=await Lm(ne.id,n);if(Me!==j.current)return;if(!Array.isArray(V.entries))throw new Error("Invalid Hub filesystem entries response.");const ae={...pe,displayPath:V.folder.displayPath||pe.displayPath,modifiedAt:V.folder.modifiedAt||pe.modifiedAt};k.current=[ae],E([ae]),F(V.entries),L(ke=>ke+1)}catch(V){if(Me!==j.current)return;console.error("[LiveDesk FS] getEntries failed",{rootId:ne.id,error:V}),Q(ae=>new Set(ae).add(ne.id)),le(V instanceof Error?`${ne.name}: ${V.message}`:`${ne.name}: Unable to read this drive.`),w(V instanceof Error?`${ne.name}: ${V.message}`:`${ne.name}: Unable to read this drive.`)}finally{Me===j.current&&(de(null),ue(!1))}},we=ne=>{const pe=k.current;ne<0||ne>=pe.length||ne===pe.length-1||J(pe.slice(0,ne+1),pe[ne].name)},je=(ne,pe)=>{if(ne.type!=="folder")return;const Me=k.current,V=Me.findIndex(ke=>ke.svarPath===pe);if(V<0)return;const ae={svarPath:`${pe}/${ne.name}`,hubId:ne.id,name:ne.name,displayPath:ne.displayPath,modifiedAt:ne.modifiedAt};J([...Me.slice(0,V+1),ae],ne.name)},Oe=()=>we(k.current.length-2),He=ne=>{if(ne.key!=="Enter"&&ne.code!=="Enter"&&ne.code!=="NumpadEnter"||ne.target?.closest('button, input, textarea, [contenteditable="true"]'))return;const Me=y.current;if(!Me)return;const V=Me.getState().panels?.flatMap(ke=>ke.selected||[])||[];if(V.length!==1)return;const ae=Me.getFile(String(V[0]));ae?.type==="folder"&&(ne.preventDefault(),ne.stopPropagation(),je(D(ae),String(ae.parent||b.current)))};f.useEffect(()=>{const ne=a.find(pe=>pe.id===R)||uk(a);if(Q(pe=>new Set([...pe].filter(Me=>a.some(V=>V.id===Me)))),!ne){C(null),k.current=[],E([]),F([]);return}he(ne)},[a]);const oe=ne=>{y.current=ne,ne.on("request-data",async({id:pe})=>{const Me=String(pe),V=xe(Me);try{const ae=await Lm(V,n);if(!Array.isArray(ae.entries))throw new Error("Invalid Hub filesystem entries response.");const ke=ae.entries.map(be=>{const st=`${Me}/${be.name}`;return M.current.set(st,be.id),{id:st,parent:Me,name:be.name,type:be.type==="file"?"file":"folder",...be.type==="file"?{size:be.size}:{},date:be.modifiedAt?new Date(be.modifiedAt):void 0,lazy:be.type!=="file"&&be.hasChildren===!0,displayPath:be.displayPath,locked:be.locked,driveType:be.driveType,totalBytes:be.totalBytes,freeBytes:be.freeBytes}});await ne.exec("provide-data",{id:Me,data:ke})}catch(ae){console.error("[LiveDesk FS] nested getEntries failed",{id:V,error:ae}),w(ae instanceof Error?ae.message:"Unable to read this folder.")}}),ne.intercept("set-path",({id:pe})=>{const Me=String(pe),V=k.current.findIndex(ke=>ke.svarPath===Me);if(V>=0)return we(V),!1;const ae=ne.getFile(Me);if(ae?.type==="folder")return je(D(ae),String(ae.parent||b.current)),!1}),ne.intercept("open-file",()=>!1),ne.on("select-file",()=>{window.setTimeout(()=>{const V=(ne.getState().panels?.flatMap(ae=>ae.selected||[])||[]).map(ae=>ne.getFile(ae)).filter(Boolean).map(ae=>D(ae));p(V.map(ae=>ae.id),V)},0)})},Ze=(ne,pe)=>{const Me=pe?D(pe):null,V=()=>{const ae=Me?.type==="file"?String(pe?.parent||b.current):String(pe?.id||b.current);y.current?.exec("request-data",{id:ae})};return ne==="body"?[{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:V},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w("Select a file or folder to view its properties.")}]:ne==="multiselect"?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>{(y.current?.getState().panels?.flatMap(ke=>ke.selected||[])||[]).forEach(ke=>{const be=y.current?.getFile(ke);be&&v(D(be))})}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:V}]:Me?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>v(Me)},...Me.type==="folder"?[{id:"sync",text:"Add folder to Sync",icon:"mdi mdi-folder-sync-outline",handler:()=>g(Me)}]:[],{id:"copy-path",text:"Copy path",icon:"mdi mdi-content-copy",handler:()=>{Pi(Me.displayPath||Me.name)}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:V},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w(`${Me.name}
12
+ ${Me.displayPath||""}`)}]:[]},De=async()=>{try{await c()}catch(ne){w(ne instanceof Error?ne.message:"Unable to refresh Hub drives.")}},at=[{id:"local",label:"Local drives",icon:Jo,roots:a.filter(ne=>rd(ne)==="local")},{id:"removable",label:"Removable drives",icon:Gb,roots:a.filter(ne=>rd(ne)==="removable")},{id:"network",label:"Network drives",icon:wh,roots:a.filter(ne=>rd(ne)==="network")}];return l.jsxs("section",{className:"hub-file-explorer-panel","aria-label":"Hub file explorer",children:[l.jsxs("div",{className:"hub-file-explorer-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub file explorer"}),l.jsxs("strong",{children:[l.jsx(Jo,{size:16})," Browse files on this Hub"]})]}),l.jsxs("div",{className:"hub-file-explorer-heading-actions",children:[l.jsx("button",{className:"icon-button",onClick:d,title:"Import files from this browser",type:"button",children:l.jsx(ly,{size:16})}),l.jsx("button",{className:"icon-button",onClick:h,title:"Import folder from this browser",type:"button",children:l.jsx(Vb,{size:16})}),l.jsx("button",{className:"icon-button",onClick:()=>{De()},title:"Refresh drives",type:"button",children:l.jsx(bc,{size:16})})]})]}),i?l.jsxs("div",{className:"hub-file-explorer-state",children:[l.jsx(Jo,{size:24}),l.jsx("strong",{children:"Connecting to LiveDesk Hub file system..."})]}):r?l.jsxs("div",{className:"hub-file-explorer-state error",role:"alert",children:[l.jsx(hc,{size:24}),l.jsx("strong",{children:r})]}):l.jsxs("div",{className:"hub-file-explorer-content",children:[l.jsxs("aside",{className:"hub-file-explorer-drive-sidebar","aria-label":"Hub drives",children:[l.jsxs("div",{className:"hub-drive-sidebar-title",children:[l.jsx(Jo,{size:15}),l.jsx("strong",{children:"This PC"})]}),at.map(ne=>ne.roots.length>0&&l.jsxs("section",{className:"hub-drive-group",children:[l.jsxs("h3",{children:[l.jsx(ne.icon,{size:13}),ne.label]}),l.jsx("div",{className:"hub-drive-list",children:ne.roots.map(pe=>{const Me=ne.icon,V=ce.has(pe.id)||pe.locked===!0;return l.jsxs("button",{className:`hub-drive-item ${R===pe.id?"active":""} ${V?"unavailable":""}`,onClick:()=>{he(pe)},"aria-pressed":R===pe.id,type:"button",children:[l.jsx("span",{className:"hub-drive-item-icon",children:l.jsx(Me,{size:16})}),l.jsxs("span",{className:"hub-drive-item-copy",children:[l.jsx("strong",{children:pe.name}),l.jsx("small",{children:pe.displayPath||pe.name}),l.jsxs("em",{children:[Ax(pe.freeBytes||0)," free / ",Ax(pe.totalBytes||0)]})]}),I===pe.id?l.jsx(dd,{className:"hub-drive-item-status spin",size:15}):V?l.jsx(Av,{className:"hub-drive-item-status",size:15}):null]},pe.id)})})]},ne.id)),a.length===0&&l.jsxs("div",{className:"hub-drive-sidebar-empty",children:[l.jsx(hc,{size:17}),l.jsx("span",{children:"No drives available."})]})]}),l.jsxs("div",{className:"hub-file-explorer-browser",children:[l.jsxs("div",{className:"hub-file-explorer-navigation",children:[l.jsx("nav",{className:"hub-file-explorer-breadcrumbs","aria-label":"Current Hub folder",children:A.map((ne,pe)=>l.jsxs("span",{className:"hub-file-explorer-breadcrumb-item",children:[pe>0&&l.jsx(bh,{size:13,"aria-hidden":"true"}),l.jsx("button",{className:`hub-file-explorer-breadcrumb ${pe===A.length-1?"current":""}`,onClick:()=>we(pe),"aria-current":pe===A.length-1?"location":void 0,type:"button",children:ne.name})]},ne.svarPath))}),l.jsxs("div",{className:"hub-file-explorer-navigation-actions",children:[W&&l.jsx(dd,{className:"hub-file-explorer-loading-icon spin",size:15,"aria-label":"Loading folder"}),l.jsx("button",{className:"icon-button",onClick:Oe,disabled:A.length<=1||W,title:"Back to parent folder",type:"button",children:l.jsx(Yb,{size:16})})]})]}),Z&&l.jsxs("div",{className:"hub-file-explorer-folder-error",role:"alert",children:[l.jsx(Av,{size:15}),l.jsx("span",{children:Z})]}),l.jsx("div",{className:"hub-file-explorer-svar",onKeyDownCapture:He,children:l.jsx(Zj,{fonts:!1,children:l.jsx(Xj,{data:ie,panels:$?[{path:$,selected:[]}]:void 0,readonly:!0,mode:"table",preview:!1,init:oe,icons:"simple",menuOptions:Ze},`${_?.id||"no-root"}:${P}`)})})]})]})]})}class fk extends f.Component{state={error:null};static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,i){console.error("[LiveDesk] Share Files runtime error",a,i.componentStack)}render(){return this.state.error?l.jsxs("section",{className:"file-share-error-boundary",role:"alert",children:[l.jsx(Sd,{size:24}),l.jsx("strong",{children:"Share Files could not be opened."}),l.jsx("span",{children:this.state.error.message||"An unexpected file explorer error occurred."}),l.jsxs("button",{className:"text-button",onClick:this.props.onRetry,type:"button",children:[l.jsx(bc,{size:15})," Retry"]})]}):this.props.children}}function mk(n){return n.deviceName||n.hostname||n.deviceId}function hk({devices:n,mode:a,selectedIds:i,onModeChange:r,onToggle:c}){const d=new Set(i);return l.jsxs("section",{className:"distribution-targets",children:[l.jsxs("div",{className:"file-share-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Target"}),l.jsx("strong",{children:a==="all"?`${n.length} connected`:`${i.length} selected`})]}),l.jsxs("div",{className:"file-share-tabs compact","aria-label":"File transfer targets",children:[l.jsxs("button",{className:a==="all"?"active":"",onClick:()=>r("all"),type:"button",children:[l.jsx(iy,{size:14})," All connected"]}),l.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>r("selected"),type:"button",children:[l.jsx(an,{size:14})," Selected"]})]})]}),l.jsx("div",{className:"file-share-device-list","aria-label":"Connected workstation targets",children:n.length===0?l.jsx("div",{className:"file-share-empty-inline",children:"No connected workstations."}):n.map(h=>{const p=a==="all"||d.has(h.deviceId);return l.jsxs("label",{className:`file-share-device-option ${p?"selected":""}`,children:[l.jsx("input",{type:"checkbox",checked:p,disabled:a==="all",onChange:()=>c(h.deviceId)}),l.jsx(an,{size:20,"aria-hidden":"true"}),l.jsxs("span",{children:[l.jsx("strong",{children:mk(h)}),l.jsxs("small",{children:["Slot ",h.slotNumber?String(h.slotNumber).padStart(3,"0"):"-"," / ",h.platform||"unknown OS"]})]}),l.jsx(Gn,{size:17,"aria-hidden":"true"})]},h.deviceId)})})]})}function pk(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function gk({folders:n,loading:a,busy:i,canSync:r,onSyncAll:c,onSync:d,onToggleAuto:h,onRemove:p,onAdd:v}){return l.jsxs("section",{className:"file-share-sync-panel",children:[l.jsxs("div",{className:"file-share-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub folders"}),l.jsx("strong",{children:"Continuous sync"})]}),l.jsxs("button",{className:"text-button compact",onClick:c,disabled:i||!r||n.length===0,type:"button",children:[l.jsx(nd,{size:15})," ",i?"Syncing":"Sync all"]})]}),a?l.jsx("div",{className:"file-share-empty-state",children:"Loading Hub sync folders..."}):n.length===0?l.jsxs("button",{className:"file-share-empty-state interactive",onClick:v,type:"button",children:[l.jsx(nd,{size:28}),l.jsx("strong",{children:"Add a selected Hub folder"}),l.jsx("span",{children:"Hub keeps the manifest and can sync while this browser is closed."})]}):l.jsx("div",{className:"file-share-sync-list",children:n.map(g=>l.jsxs("article",{className:`file-share-sync-row state-${g.status}`,children:[l.jsx("div",{className:"file-share-sync-icon",children:l.jsx(nd,{size:19})}),l.jsxs("div",{className:"file-share-sync-info",children:[l.jsx("strong",{children:g.name}),l.jsx("span",{children:g.displayPath}),l.jsxs("small",{children:[g.fileCount," files / ",pk(g.totalBytes)," · ",g.lastSyncedAt?`Last sync ${ah(g.lastSyncedAt)} ago`:g.message||"Not synced yet"]})]}),l.jsxs("label",{className:"file-share-auto-sync",children:[l.jsx("input",{type:"checkbox",checked:g.autoSync,onChange:()=>h(g)}),l.jsx("span",{children:"Auto"})]}),l.jsxs("button",{className:"text-button compact",onClick:()=>d(g),disabled:i||!r||g.status==="syncing",type:"button",children:[l.jsx(bc,{size:14})," Sync now"]}),l.jsx("button",{className:"icon-button",onClick:()=>p(g),title:"Remove sync folder",type:"button",children:l.jsx(xh,{size:15})})]},g.id))})]})}function vk(n){const i=(n.targetMode==="all"?n.devices.map(r=>r.deviceId):n.selectedTargetIds).length>0;return l.jsxs("aside",{className:"file-share-distribution-panel",children:[l.jsxs("div",{className:"file-share-distribution-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Distribution"}),l.jsx("strong",{children:"Hub → workstations"})]}),l.jsx(fd,{size:18})]}),l.jsxs("div",{className:"file-share-tabs",role:"tablist","aria-label":"Distribution mode",children:[l.jsx("button",{className:n.tab==="send"?"active":"",onClick:()=>n.onTabChange("send"),role:"tab","aria-selected":n.tab==="send",type:"button",children:"Send"}),l.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"?l.jsxs(l.Fragment,{children:[l.jsx(hk,{devices:n.devices,mode:n.targetMode,selectedIds:n.selectedTargetIds,onModeChange:n.onTargetModeChange,onToggle:n.onTargetToggle}),l.jsxs("label",{className:"file-share-destination",children:[l.jsx("span",{children:"Destination folder"}),l.jsxs("div",{children:[l.jsx(oc,{size:15}),l.jsx("input",{value:n.remoteDirectory,onChange:r=>n.onRemoteDirectoryChange(r.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),l.jsx("small",{children:"Blank uses Desktop/LiveDeskFiles."})]}),l.jsxs("div",{className:"file-share-selection-summary",children:[l.jsx("span",{children:"Selected"}),l.jsx("strong",{children:n.selectedSummary})]}),l.jsxs("button",{className:"file-share-share-button",onClick:n.onShare,disabled:!n.canShare,type:"button",children:[l.jsx(fd,{size:17})," Share selected"]}),l.jsxs("button",{className:"file-share-secondary-button",onClick:n.onAddSync,disabled:!n.canAddSync,type:"button",children:[l.jsx(oc,{size:16})," Add selected folder to Sync"]})]}):l.jsx(gk,{folders:n.folders,loading:n.foldersLoading,busy:n.syncBusy,canSync:i,onSyncAll:n.onSyncAll,onSync:n.onSync,onToggleAuto:n.onToggleAuto,onRemove:n.onRemove,onAdd:n.onAddFolder})]})}function xk(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;return`${i.toFixed(r===0||i>=100?0:1)} ${a[r]}`}function Nx(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 Tx(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 Rx(n){return["completed","partially-failed","failed","cancelled"].includes(n)}function yk({hubUrl:n,devices:a,localFeatureAccess:i,upgradeNotice:r,notice:c,remoteDirectory:d,onRemoteDirectoryChange:h,targetMode:p,selectedTargetIds:v,onTargetModeChange:g,onTargetToggle:w,filePickerRef:y,folderPickerRef:b,onBrowserFileImport:j,onBrowserFolderImport:k,onNotice:M,onTransferChange:R}){const C=Array.isArray(a)?a:[],[A,E]=f.useState([]),[U,F]=f.useState(!0),[P,L]=f.useState(""),[I,de]=f.useState([]),[W,ue]=f.useState([]),[Z,le]=f.useState(null),[ce,Q]=f.useState(!1),[_,Y]=f.useState([]),[$,H]=f.useState(!0),[ie,xe]=f.useState(!1),[D,J]=f.useState("send"),[he,we]=f.useState([]),je=f.useRef(new Set),Oe=f.useMemo(()=>p==="all"?C.map(Ae=>Ae.deviceId):v.filter(Ae=>C.some(Ne=>Ne.deviceId===Ae)),[C,v,p]),He=he.find(Ae=>!Rx(Ae.state)),oe=W.length===1&&W[0].type==="folder"?W[0]:null,Ze=W.length===0?"Select files or folders from the Hub explorer.":ce?"Calculating selection size...":Z?`${Z.files} files, ${Z.folders} folders · ${xk(Z.totalBytes)}`:`${W.length} item${W.length===1?"":"s"} selected`,De=Ae=>{R({id:Ae.jobId,state:Ae.state,progress:Nx(Ae),message:Tx(Ae)})},at=f.useCallback(async()=>{const Ae=await kx(n,!0);return E(Ae),L(""),Ae},[n]),ne=async()=>{try{const Ne=(await nk(n,!0)).jobs||[],Ie=await Promise.all([...je.current].map(async Dt=>{try{return await ak(Dt,n)}catch{return null}})),Pt=[...Ne,...Ie.filter(Boolean)],An=[...new Map(Pt.map(Dt=>[Dt.jobId,Dt])).values()];we(An),An.forEach(De),An.filter(Dt=>Rx(Dt.state)).forEach(Dt=>je.current.delete(Dt.jobId))}catch{}};f.useEffect(()=>{let Ae=!0;F(!0),L(""),Promise.all([at(),Mx(n).then(Ie=>{Ae&&Y(Ie)})]).catch(Ie=>{Ae&&(L(Ie instanceof Error?"Hub file system is unavailable. Make sure LiveDesk Hub is running on this computer.":"Hub file system is unavailable."),M(Ie instanceof Error?Ie.message:"Hub file system is unavailable."))}).finally(()=>{Ae&&(F(!1),H(!1))}),ne();const Ne=window.setInterval(()=>{ne()},800);return()=>{Ae=!1,window.clearInterval(Ne)}},[n,at]),f.useEffect(()=>{if(I.length===0){le(null);return}let Ae=!1;return Q(!0),ek(I,n).then(Ne=>{Ae||le(Ne)}).catch(Ne=>{Ae||M(Ne instanceof Error?Ne.message:"Unable to calculate selected size.")}).finally(()=>{Ae||Q(!1)}),()=>{Ae=!0}},[n,I.join("|")]);const pe=(Ae,Ne)=>{de(Ae),ue(Ne)},Me=Ae=>{Ae.forEach(Ne=>je.current.add(Ne.jobId)),we(Ne=>[...new Map([...Ne,...Ae].map(Ie=>[Ie.jobId,Ie])).values()]),Ae.forEach(De)},V=async()=>{if(!i){M(r);return}if(I.length===0){M("Select files or folders from the Hub explorer.");return}if(Oe.length===0){M("Choose at least one connected workstation.");return}if(He){M("A Hub transfer is already running.");return}try{const Ae=await tk(I,Oe,d.trim(),n);je.current.add(Ae.jobId),M("Hub transfer queued."),await ne()}catch(Ae){M(Ae instanceof Error?Ae.message:"Unable to start Hub transfer.")}},ae=async Ae=>{const Ne=Ae||oe;if(!Ne||Ne.type!=="folder"){M("Select one folder to add it to Sync.");return}try{const Ie=await lk(Ne.id,n);Y(Pt=>[...Pt.filter(An=>An.id!==Ie.folder.id),Ie.folder]),J("sync"),M(`${Ne.name} is ready for Hub sync.`)}catch(Ie){M(Ie instanceof Error?Ie.message:"Unable to add the Hub folder to Sync.")}},ke=async Ae=>{if(Oe.length===0){M("Choose at least one connected workstation.");return}xe(!0),Y(Ne=>Ne.map(Ie=>Ie.id===Ae.id?{...Ie,status:"syncing"}:Ie));try{const Ne=await ok(Ae.id,Oe,d.trim(),n);Me(Ne.jobs||[]),M(Ne.jobs?.length?"Hub sync queued.":"No changed files to sync.");const Ie=await Mx(n);Y(Ie)}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to sync the Hub folder."),Y(Ie=>Ie.map(Pt=>Pt.id===Ae.id?{...Pt,status:"error",message:"Sync failed"}:Pt))}finally{xe(!1)}},be=async()=>{xe(!0);try{for(const Ae of _)await ke(Ae)}finally{xe(!1)}},st=async Ae=>{try{const Ne=await ik(Ae.id,{autoSync:!Ae.autoSync},n);Y(Ie=>Ie.map(Pt=>Pt.id===Ae.id?Ne.folder:Pt))}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to update auto sync.")}},It=async Ae=>{try{await rk(Ae.id,n),Y(Ne=>Ne.filter(Ie=>Ie.id!==Ae.id))}catch(Ne){M(Ne instanceof Error?Ne.message:"Unable to remove the sync folder.")}};return l.jsxs("section",{className:"livedesk-file-explorer",children:[l.jsx("input",{ref:y,className:"hidden-file-input",type:"file",multiple:!0,onChange:Ae=>{Ae.currentTarget.files&&j(Ae.currentTarget.files),Ae.currentTarget.value=""}}),l.jsx("input",{ref:b,className:"hidden-file-input",type:"file",multiple:!0,webkitdirectory:"",directory:"",onChange:Ae=>{Ae.currentTarget.files&&k(Ae.currentTarget.files),Ae.currentTarget.value=""}}),(c||P)&&l.jsxs("section",{className:"file-share-notice",role:P?"alert":void 0,children:[P||c,l.jsx("button",{className:"icon-button",onClick:()=>{L(""),F(!0),kx(n).then(Ae=>E(Ae)).catch(()=>L("Hub file system is unavailable.")).finally(()=>F(!1))},title:"Retry",type:"button",children:l.jsx(bc,{size:15})})]}),l.jsx("div",{className:"file-share-workspace",children:l.jsxs(fk,{onRetry:()=>window.location.reload(),children:[l.jsx(dk,{hubUrl:n,roots:A,loading:U,error:P,onRefreshRoots:at,onImportFiles:()=>y.current?.click(),onImportFolder:()=>b.current?.click(),onSelectionChange:pe,onShareItem:Ae=>{de([Ae.id]),ue([Ae]),J("send")},onAddSyncFolder:Ae=>{de([Ae.id]),ue([Ae]),ae(Ae)},onNotice:M}),l.jsx(vk,{devices:C,targetMode:p,selectedTargetIds:v,onTargetModeChange:g,onTargetToggle:w,remoteDirectory:d,onRemoteDirectoryChange:h,selectedEntries:W,selectedSummary:Ze,canShare:i&&!He&&I.length>0&&Oe.length>0&&!ce,onShare:()=>{V()},canAddSync:!!oe,onAddSync:()=>{ae()},tab:D,onTabChange:J,folders:_,foldersLoading:$,syncBusy:ie,onSyncAll:()=>{be()},onSync:Ae=>{ke(Ae)},onToggleAuto:Ae=>{st(Ae)},onRemove:Ae=>{It(Ae)},onAddFolder:()=>{ae()}})]})}),He&&l.jsx("footer",{className:"file-share-workspace-footer",children:l.jsxs("span",{children:[Tx(He)," · ",Nx(He),"% ",l.jsx("button",{className:"icon-button",onClick:()=>{sk(He.jobId,n).then(Ae=>{we(Ne=>Ne.map(Ie=>Ie.jobId===Ae.jobId?Ae:Ie)),De(Ae)})},title:"Cancel transfer",type:"button",children:l.jsx(Kr,{size:14})})]})})]})}const wk=f.forwardRef(function({value:a,onChange:i,onSubmit:r,onOpenSuggestedTasks:c,suggestedOpen:d=!1,suggestedTaskCount:h,disabled:p=!1},v){return l.jsxs("form",{className:"agents-composer",onSubmit:g=>{g.preventDefault(),r()},children:[l.jsxs("button",{className:`agents-suggested-trigger ${d?"active":""}`,type:"button","aria-label":h===void 0?"Open Suggested tasks":`Open Suggested tasks (${h} available)`,"aria-expanded":d,onClick:c,disabled:p,children:[l.jsx(Wb,{size:17}),h!==void 0&&l.jsx("span",{className:"agents-suggested-count","aria-hidden":"true",children:h})]}),l.jsx("textarea",{ref:v,value:a,onChange:g=>i(g.target.value.slice(0,4e3)),placeholder:"Ask LiveDesk to work across your machines...","aria-label":"Ask LiveDesk",rows:2,disabled:p}),l.jsxs("button",{className:"agents-run-button",type:"submit",disabled:p||!a.trim(),children:[p?l.jsx(dd,{className:"spin",size:16}):l.jsx(fd,{size:16}),p?"Running":"Run"]})]})}),bk=["read","processControl","serviceControl","applicationControl","fileRead","fileWrite","fileDelete","shell","script","softwareInstall","network","systemPower","systemConfiguration","userAccount"];function lw(n){return n.deviceName?.trim()||n.hostname?.trim()||n.deviceId}function Sk(n){return n==="running"||n==="completed"||n==="failed"||n==="cancelled"?n:"queued"}function Ck(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 jk(n){const a=n.match(/\[([^\]]+)\]/)?.[1]?.trim();if(a)return a;if(n.includes("comfyui"))return"comfyui";if(n.includes("ollama"))return"ollama";const i=n.match(/process(?:\s+(?:named|called))?\s+([a-z0-9._-]+)/i)?.[1];return i&&!["is","running","process"].includes(i)?i:void 0}function kk(n){const a=n.trim().toLowerCase();return!a||/(stop|restart|kill|terminate|start|launch|close|delete|write|edit|run command|execute|install|shutdown|reboot|sleep|power|file|folder|script|application)/i.test(a)?null:/(process|프로세스|실행 중|실행중|comfyui|running|processes)/i.test(a)?{operation:"process.list",query:jk(a)}:/(gpu|그래픽|vram|gpu 상태)/i.test(a)?{operation:"gpu.status"}:/(disk|디스크|storage|저장 공간)/i.test(a)?{operation:"disk.status"}:/(service|서비스)/i.test(a)?{operation:"service.status"}:/(diagnostic|진단|로그)/i.test(a)?{operation:"diagnostics.collect"}:/(health|system|시스템|상태)/i.test(a)?{operation:"system.health"}:null}const Mk=["이 작업은 아직 지원되지 않습니다.","","현재 지원:","• 시스템 상태 확인","• GPU 상태 확인","• 디스크 상태 확인","• 프로세스 조회","• 서비스 상태 조회","• 진단 로그 수집"].join(`
13
+ `);function Ak(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Ea(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Qu(n){const a=Ea(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 Nk(n){const a=Ea(n);return a===null?"":`${Math.round((a<=1?a:a/100)*100)}%`}function Tk(n){return!n||/^(?:[\w .-]+ )?collected(?:\.)?$/i.test(n.trim())?"":n.trim()}function wd(n,a){if(a.error)return a.error;const i=Ak(a.data),r=Tk(a.result||"");if(!i)return r||a.stage||a.status;if(n==="system.health"){const c=typeof i.machine=="string"?i.machine:"",d=Qu(i.freeMemoryBytes),h=Qu(i.totalMemoryBytes),p=Ea(i.totalMemoryBytes)&&Ea(i.freeMemoryBytes)!==null?`${Math.round(Ea(i.freeMemoryBytes)/Ea(i.totalMemoryBytes)*100)}% RAM free`:"";return[c,d&&h?`RAM ${d}/${h}`:"",p,typeof i.platform=="string"?i.platform:""].filter(Boolean).join(" · ")||r||a.status}if(n==="disk.status"){const c=typeof i.root=="string"?i.root:"",d=Qu(i.freeBytes),h=Ea(i.totalBytes)&&Ea(i.freeBytes)!==null?`${Math.round(Ea(i.freeBytes)/Ea(i.totalBytes)*100)}% free`:"";return[c,d&&`${d} free`,h].filter(Boolean).join(" · ")||r||a.status}if(n==="gpu.status"){const c=typeof i.name=="string"&&i.name?i.name:"No GPU provider",d=Nk(i.usageRatio),h=Ea(i.temperatureC)!==null?`${Math.round(Ea(i.temperatureC))}°C`:"",p=Qu(i.freeMemoryBytes);return[c,d&&`GPU ${d}`,h,p&&`${p} free`].filter(Boolean).join(" · ")||r||a.status}if(n==="process.list"){const c=Ea(i.count);return c!==null?`${c} matching process${c===1?"":"es"}`:r||a.status}if(n==="network.status"){const c=Array.isArray(i.adapters)?i.adapters.length:null;return c!==null?`${c} active adapter${c===1?"":"s"}`:r||a.status}return r||a.stage||a.status}function Ex(n,a){const i=wd(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||""} ${i}`)}function Rk({state:n,operation:a}){const i=n.status==="completed"?gc:n.status==="failed"||n.status==="cancelled"?Kr:n.status==="running"?dd:ry,r=n.status==="running"?n.stage||"Working":n.status==="completed"?a?wd(a,n):n.result||"Completed":n.status==="failed"?n.error||"Failed":n.status==="cancelled"?"Cancelled":"Queued";return l.jsxs("div",{className:`agent-target-row status-${n.status}`,"data-agent-target-id":n.deviceId,children:[l.jsx("span",{className:"agent-target-status","aria-hidden":"true",children:l.jsx(i,{size:15})}),l.jsx("strong",{children:n.deviceName}),l.jsx("span",{className:"agent-target-state",children:n.status[0].toUpperCase()+n.status.slice(1)}),l.jsx("small",{children:r})]})}function Ek({operation:n,states:a,status:i,onCancel:r,onRetry:c,busy:d=!1}){const h=["running","queued"].includes(i),[p,v]=f.useState(!1),[g,w]=f.useState("all"),y=f.useMemo(()=>({total:a.length,completed:a.filter(E=>E.status==="completed").length,failed:a.filter(E=>E.status==="failed").length,running:a.filter(E=>E.status==="running").length,queued:a.filter(E=>E.status==="queued").length,cancelled:a.filter(E=>E.status==="cancelled").length}),[a]),b=a.filter(E=>Ex(n,E)),j=b.filter(E=>E.status==="completed").length,k=y.failed>0,M=b.length>0,R=a.filter(E=>g==="issues"?Ex(n,E):g==="running"?E.status==="running"||E.status==="queued":g==="completed"?E.status==="completed":g==="failed"?E.status==="failed":!0),C=M&&!h||i==="completed-with-failures"?"Completed with issues":i[0]?.toUpperCase()+i.slice(1),A=a.filter(E=>E.status==="completed").map(E=>wd(n,E)).filter(Boolean).filter((E,U,F)=>F.indexOf(E)===U).slice(0,2);return l.jsxs("section",{className:"agent-task-block","aria-label":"Task execution",children:[l.jsxs("div",{className:"agent-task-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"LiveDesk Agent"}),l.jsx("strong",{children:Ck(n)})]}),l.jsx("span",{className:`agent-task-status status-${M?"completed-with-failures":i}`,children:C})]}),l.jsxs("div",{className:"agent-task-summary","aria-label":"Task summary",children:[l.jsxs("strong",{children:[y.total," targets"]}),l.jsxs("span",{className:"summary-completed",children:[y.completed," completed"]}),y.running>0&&l.jsxs("span",{className:"summary-running",children:[y.running," running"]}),y.queued>0&&l.jsxs("span",{children:[y.queued," queued"]}),k&&l.jsxs("span",{className:"summary-failed",children:[y.failed," failed"]}),j>0&&l.jsxs("span",{className:"summary-cancelled",children:[j," warning"]}),y.cancelled>0&&l.jsxs("span",{className:"summary-cancelled",children:[y.cancelled," cancelled"]})]}),A.length>0&&l.jsxs("div",{className:"agent-task-result-preview",title:A.join(" · "),children:[l.jsx("span",{children:"Result"}),A.join(" · ")]}),l.jsx("div",{className:"agent-target-chips","aria-label":"Target status overview",children:a.map((E,U)=>{const F=E.status==="completed"?"✓":E.status==="failed"?"×":E.status==="cancelled"?"!":E.status==="running"?"…":"·";return l.jsxs("span",{className:`agent-target-chip status-${E.status}`,title:`${E.deviceName}: ${wd(n,E)}`,"aria-label":`${U+1}. ${E.deviceName}: ${E.status}`,children:[l.jsx("b",{children:String(U+1).padStart(2,"0")}),l.jsx("span",{children:F})]},E.deviceId)})}),a.length>0&&l.jsx("div",{className:"agent-task-details-toggle",children:l.jsxs("button",{type:"button",onClick:()=>v(E=>!E),"aria-expanded":p,children:[p?l.jsx(Kb,{size:14}):l.jsx(oy,{size:14}),p?"Hide details":"Show details"]})}),p&&l.jsxs("div",{className:"agent-task-details",children:[l.jsx("div",{className:"agent-task-filters",role:"tablist","aria-label":"Task result filter",children:["all","issues","running","completed","failed"].map(E=>l.jsx("button",{className:g===E?"active":"",onClick:()=>w(E),role:"tab","aria-selected":g===E,type:"button",children:E==="all"?"All":E==="issues"?"Issues only":E[0].toUpperCase()+E.slice(1)},E))}),l.jsx("div",{className:"agent-task-rows",children:R.length>0?R.map(E=>l.jsx(Rk,{operation:n,state:E},E.deviceId)):l.jsx("small",{className:"agent-task-no-results",children:"No targets match this filter."})})]}),(h||k)&&l.jsxs("div",{className:"agent-task-actions",children:[h&&r&&l.jsxs("button",{onClick:r,disabled:d,type:"button",children:[l.jsx(Qb,{size:14})," Cancel"]}),!h&&k&&c&&l.jsxs("button",{onClick:c,disabled:d,type:"button",children:[l.jsx(rc,{size:14})," Retry failed"]})]})]})}function Dk(n){try{return JSON.stringify(n,null,2).slice(0,6e3)}catch{return"{}"}}function Lk({approval:n,busy:a=!1,onApprove:i,onReject:r}){return l.jsxs("article",{className:"agent-approval-card","aria-label":"Agent approval required",children:[l.jsxs("div",{className:"agent-approval-head",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Approval required"}),l.jsx("strong",{children:n.toolName})]}),l.jsx("span",{className:`agent-approval-risk risk-${n.risk}`,children:n.risk})]}),l.jsx("p",{children:n.description}),l.jsx("pre",{children:Dk(n.arguments)}),l.jsxs("small",{children:["Permission: ",n.permissionMode," · Scope: selected devices only · Expires in 5 minutes"]}),l.jsxs("div",{className:"agent-approval-actions",children:[l.jsxs("button",{className:"reject",disabled:a,onClick:r,type:"button",children:[l.jsx(Kr,{size:14})," Reject"]}),l.jsxs("button",{disabled:a,onClick:()=>i("once"),type:"button",children:[l.jsx(gc,{size:14})," Once"]}),l.jsx("button",{disabled:a,onClick:()=>i("same-action-this-run"),type:"button",children:"Allow same action"}),l.jsx("button",{disabled:a,onClick:()=>i("category-this-run"),type:"button",children:"Allow category"})]}),l.jsxs("div",{className:"agent-approval-scope",children:[l.jsx(Sd,{size:13})," Approval is bound to this run, tool, arguments, selected devices, and policy hash."]})]})}function _k({items:n,onCancel:a,onRetry:i,busyBatchId:r,approvals:c,onApprove:d,onReject:h,busyApprovalId:p}){return l.jsxs("section",{className:"agents-conversation","aria-live":"polite",children:[c.filter(v=>v.status==="pending").map(v=>l.jsx(Lk,{approval:v,busy:p===v.approvalId,onApprove:g=>d(v,g),onReject:()=>h(v)},v.approvalId)),n.length===0&&l.jsxs("div",{className:"agents-empty-conversation",children:[l.jsx("strong",{children:"Ask LiveDesk to work across your machines."}),l.jsx("span",{children:"Start with a read-only request such as “모든 PC에서 ComfyUI가 실행 중인지 확인해줘”."})]}),n.map(v=>{if(v.type==="task"){const g=v;return l.jsx(Ek,{operation:g.operation,states:g.states,status:g.status,onCancel:()=>a(g.batchId,g.agentRunId),onRetry:()=>i(g.batchId),busy:r===g.batchId},g.id)}return l.jsxs("article",{className:`agents-message ${v.type}`,children:[l.jsx("span",{children:v.type==="user"?"You":"LiveDesk Agent"}),l.jsx("p",{children:v.text})]},v.id)})]})}const Dx=["Recommended","Health & capacity","Processes & services","AI workloads","Files & configuration","Software & automation","Network & connectivity","Power & maintenance","Troubleshooting & recovery"],tn=["windows","macos","linux"],ri={"system.health":{label:"system health",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"gpu.status":{label:"GPU status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"disk.status":{label:"disk status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"process.list":{label:"process inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"service.status":{label:"service inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"diagnostics.collect":{label:"diagnostics collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn},"process.control":{label:"process control",permissionCategory:"processControl",readOnly:!1,risk:"high",supportedPlatforms:tn},"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:tn},"application.close":{label:"application close",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:tn},"file.read":{label:"file reading",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:tn},"file.write":{label:"file writing",permissionCategory:"fileWrite",readOnly:!1,risk:"high",supportedPlatforms:tn},"file.delete":{label:"file deletion",permissionCategory:"fileDelete",readOnly:!1,risk:"critical",supportedPlatforms:tn},"file.list":{label:"directory listing",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:tn},"command.run":{label:"command execution",permissionCategory:"shell",readOnly:!1,risk:"critical",supportedPlatforms:tn},"script.run":{label:"script execution",permissionCategory:"script",readOnly:!1,risk:"high",supportedPlatforms:tn},"software.install":{label:"software installation",permissionCategory:"softwareInstall",readOnly:!1,risk:"high",supportedPlatforms:tn},"network.status":{label:"network inspection",permissionCategory:"network",readOnly:!0,risk:"low",supportedPlatforms:tn},"system.power":{label:"power control",permissionCategory:"systemPower",readOnly:!1,risk:"critical",supportedPlatforms:tn},"system.configure":{label:"system configuration",permissionCategory:"systemConfiguration",readOnly:!1,risk:"critical",supportedPlatforms:tn},"logs.collect":{label:"log collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:tn}};new Set(Object.keys(ri));const zk={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","문제해결","복구","장애"]},Lx=["low","medium","high","critical"];function Ok(n){return n.reduce((a,i)=>{const r=ri[i].risk;return Lx.indexOf(r)>Lx.indexOf(a)?r:a},"low")}function Ik(n){return tn.filter(a=>n.every(i=>ri[i].supportedPlatforms.includes(a)))}function Le(n,a,i,r,c,d,h={}){const p=h.description||r,v=c.flatMap(w=>w.split(".")),g=[...new Set([...zk[a],...d,...v])];return{id:n,category:a,title:i,prompt:r,description:p,requiredOperations:c,risk:h.risk||Ok(c),targetSupport:h.targetSupport||"single-or-multiple",supportedPlatforms:h.supportedPlatforms||Ik(c),keywords:g,recommended:h.recommended??!1,enabled:!0}}const iw=[Le("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}),Le("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}),Le("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}),Le("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}),Le("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}),Le("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}),Le("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}),Le("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}),Le("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","높은 사용량"]),Le("health-uptime","Health & capacity","Review workstation uptime","Show uptime, boot time, and current system health for the target workstations.",["system.health"],["uptime","boot","가동시간"]),Le("health-gpu-temperature","Health & capacity","Check GPU temperature","Check GPU temperature and thermal warnings on the current targets.",["gpu.status"],["thermal","temperature","발열"]),Le("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"]),Le("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","디스크"]),Le("health-gpu-compare","Health & capacity","Compare GPU capacity","Compare GPU model, memory, temperature, and utilization across the current targets.",["gpu.status"],["compare","graphics","capacity"]),Le("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","경고"]),Le("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"]),Le("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","실행 중"]),Le("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"]),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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","서비스 상태"]),Le("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"}),Le("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"]),Le("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"}),Le("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"}),Le("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"]),Le("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"]),Le("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"}),Le("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"]),Le("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"}),Le("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"}),Le("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","구성"]),Le("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"]),Le("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"}),Le("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"}),Le("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"]),Le("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"}),Le("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"}),Le("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"]}),Le("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"]}),Le("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"]}),Le("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"}),Le("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"}),Le("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"}),Le("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"]),Le("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"}),Le("network-adapter-status","Network & connectivity","Check network adapters","Show adapter state, address, and link information for the current targets.",["network.status"],["adapter","ethernet","wifi","네트워크 상태"]),Le("network-disconnected","Network & connectivity","Find disconnected targets","Find current targets with disconnected or degraded network adapters.",["network.status"],["disconnected","offline","연결 끊김"]),Le("network-link-speed","Network & connectivity","Check link speed","Report network link speed and duplex information for the current targets.",["network.status"],["speed","bandwidth","duplex"]),Le("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"]),Le("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"]),Le("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"]),Le("network-compare","Network & connectivity","Compare target connectivity","Compare adapter state, addresses, and link speed across the current targets.",["network.status"],["compare","inventory","connectivity"]),Le("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"]),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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"}),Le("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","장애 보고서"])],_m={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 Bk(n,a){return n==="safe-auto"?_m:n==="full-access"?{..._m,processControl:"allow",serviceControl:"allow",applicationControl:"allow",fileDelete:"allow",shell:"allow",script:"allow",softwareInstall:"allow",systemPower:"allow",systemConfiguration:"allow"}:n==="custom"&&a?a:{..._m,processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileWrite:"ask",network:"ask"}}function Fk(n,a,i){const r=Bk(a,i),c=n.requiredOperations.map(d=>r[ri[d].permissionCategory]);if(c.includes("deny")){const d=n.requiredOperations.find(h=>r[ri[h].permissionCategory]==="deny");return{state:"blocked",label:"Blocked",reason:`This task requires ${ri[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=>ri[d].readOnly)?{state:"read-only",label:"Read only"}:a==="full-access"?{state:"full-access",label:"Full Access"}:{state:"auto",label:"Auto allowed"}}function Hk(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 Uk(n,a,i){const r=new Set(i);return n.filter(c=>c.connected&&(a==="all"||r.has(c.deviceId)))}function $k(n,a){const i=Hk(n.platform);if(!i||!a.supportedPlatforms.includes(i))return!1;const r=n.capabilities?.agentTools;return!Array.isArray(r)||r.length===0?a.requiredOperations.every(c=>ri[c].readOnly):a.requiredOperations.every(c=>r.includes(c))}function rw(n,a,i,r,c,d){const h=Fk(n,c,d),p=Uk(a,i,r),v=p.map(j=>j.deviceId),g={...h,available:!1,availableDeviceIds:[],unsupportedDeviceIds:v,risk:n.risk,supportedPlatforms:n.supportedPlatforms};if(p.length===0)return{...g,reason:"Select at least one connected workstation."};if(n.targetSupport==="single"&&p.length!==1)return{...g,reason:"This task supports one workstation at a time."};if(h.state==="blocked")return g;const w=p.filter(j=>$k(j,n)),y=w.map(j=>j.deviceId),b=v.filter(j=>!y.includes(j));return w.length===0?{...g,unsupportedDeviceIds:b,reason:"No current target supports the required platform and client capabilities."}:{...g,available:!0,availableDeviceIds:y,unsupportedDeviceIds:b}}function Pk(n,a,i,r,c,d){return n.filter(h=>h.enabled&&rw(h,a,i,r,c,d).available).length}const zm="livedesk.agentPromptRecent",Om="livedesk.agentPromptFavorites",qk={Recommended:Vi,"Health & capacity":nn,"Processes & services":aS,"AI workloads":nS,"Files & configuration":tS,"Software & automation":vh,"Network & connectivity":wh,"Power & maintenance":Sn,"Troubleshooting & recovery":eS};function _x(n){if(typeof window>"u")return[];try{const a=JSON.parse(window.localStorage.getItem(n)||"[]");return Array.isArray(a)?a.filter(i=>typeof i=="string"):[]}catch{return[]}}function Xu(n,a){try{window.localStorage.setItem(n,JSON.stringify(a))}catch{}}function Im(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 Gk(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 Vk(n,a,i){if(!i.trim())return!0;const r=i.trim().toLowerCase();return[n.title,n.prompt,n.description,n.category,n.risk,a.label,...n.keywords,...n.requiredOperations,...n.supportedPlatforms].join(" ").toLowerCase().includes(r)}function Yk(n){return`permission-${n}`}function Wk(n){return n==="low"?"Low risk":n==="medium"?"Medium risk":n==="high"?"High risk":"Critical risk"}function Kk(n){return n==="windows"?"Windows":n==="macos"?"macOS":"Linux"}function Qk({devices:n,targetMode:a,selectedIds:i,permissionMode:r,customCategories:c,onSelectPrompt:d,onClose:h}){const[p,v]=f.useState(""),[g,w]=f.useState("all"),[y,b]=f.useState(()=>_x(zm)),[j,k]=f.useState(()=>_x(Om)),[M,R]=f.useState(0),[C,A]=f.useState(""),E=f.useRef(null),U=f.useRef(null),F=f.useMemo(()=>iw.filter(Q=>Q.enabled),[]),P=f.useMemo(()=>new Map(F.map(Q=>[Q.id,rw(Q,n,a,i,r,c)])),[c,n,r,i,a,F]),L=f.useMemo(()=>[...P.values()].filter(Q=>Q.available).length,[P]),I=f.useMemo(()=>n.filter(Q=>Q.connected&&(a==="all"||i.includes(Q.deviceId))).length,[n,i,a]),de=f.useMemo(()=>{const Q=F.filter(_=>Vk(_,P.get(_.id),p));return g==="recent"?y.map(_=>Q.find(Y=>Y.id===_)).filter(_=>!!_):g==="favorites"?j.map(_=>Q.find(Y=>Y.id===_)).filter(_=>!!_):g==="all"?Q:Q.filter(_=>{const Y=P.get(_.id);return g==="read-only"?Y.state==="read-only":g==="auto"?Y.state==="auto":g==="approval"?Y.state==="approval":g==="full-access"?Y.state==="full-access":g==="available"?Y.available:g==="unavailable"?!Y.available:_.category===g})},[P,j,g,y,p,F]),W=f.useMemo(()=>g!=="all"?[{category:Im(g),templates:de}]:Dx.map(Q=>({category:Q,templates:de.filter(_=>_.category===Q)})).filter(Q=>Q.templates.length>0),[g,de]);f.useEffect(()=>{R(Q=>Math.min(Q,Math.max(0,de.length-1)))},[de.length]),f.useEffect(()=>{Xu(zm,y)},[y]),f.useEffect(()=>{Xu(Om,j)},[j]),f.useEffect(()=>{U.current?.focus();const Q=Y=>{Y.target instanceof Node&&!E.current?.contains(Y.target)&&h()},_=Y=>{Y.key==="Escape"&&(Y.preventDefault(),h())};return document.addEventListener("pointerdown",Q),document.addEventListener("keydown",_),()=>{document.removeEventListener("pointerdown",Q),document.removeEventListener("keydown",_)}},[h]);const ue=Q=>{const _=P.get(Q.id);if(!_.available){A(_.reason||"This task is not available for the current targets and permission policy.");return}const Y=[Q.id,...y.filter($=>$!==Q.id)].slice(0,10);b(Y),Xu(zm,Y),d(Q.prompt),h()},Z=Q=>{k(_=>{const Y=_.includes(Q)?_.filter($=>$!==Q):[Q,..._];return Xu(Om,Y),Y})},le=Q=>{Q.key==="ArrowDown"?(Q.preventDefault(),R(_=>Math.min(_+1,Math.max(0,de.length-1)))):Q.key==="ArrowUp"?(Q.preventDefault(),R(_=>Math.max(_-1,0))):Q.key==="Enter"&&de[M]&&(Q.preventDefault(),ue(de[M]))};let ce=-1;return l.jsxs("section",{className:"agents-suggested-tasks",ref:E,"aria-label":"Suggested tasks",children:[l.jsxs("header",{className:"agents-suggested-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"agents-suggested-title",children:[l.jsx(Vi,{size:15})," Suggested tasks"]}),l.jsxs("small",{children:[L," available · ",F.length," total. Choose a task, edit it, then run it."]})]}),l.jsx("button",{className:"agents-suggested-close",type:"button","aria-label":"Close suggested tasks",onClick:h,children:l.jsx(Kr,{size:16})})]}),l.jsxs("label",{className:"agents-suggested-search",children:[l.jsx(Xb,{size:15,"aria-hidden":"true"}),l.jsx("input",{ref:U,value:p,onChange:Q=>v(Q.target.value),onKeyDown:le,placeholder:"Search tasks...","aria-label":"Search suggested tasks"})]}),l.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",...Dx].map(Q=>{const _=Q==="recent"?Zb:Q==="favorites"?Qm:Q==="all"?Vi:Q==="available"?Gn:Q==="unavailable"?Jb:Q==="read-only"||Q==="auto"||Q==="approval"||Q==="full-access"?Sn:qk[Q];return l.jsxs("button",{className:g===Q?"active":"",type:"button",title:Im(Q),"aria-label":Im(Q),"aria-pressed":g===Q,onClick:()=>{w(Q),R(0),A("")},children:[l.jsx(_,{size:12})," ",Gk(Q)]},Q)})}),C&&l.jsx("div",{className:"agents-suggested-notice",role:"status",children:C}),l.jsxs("div",{className:"agents-suggested-list",role:"listbox","aria-label":"Suggested tasks",children:[W.map(Q=>l.jsxs("div",{className:"agents-suggested-group",children:[l.jsx("strong",{children:Q.category}),Q.templates.map(_=>{ce+=1;const Y=ce===M,$=j.includes(_.id),H=P.get(_.id),ie=H.availableDeviceIds.length+H.unsupportedDeviceIds.length||I,xe=H.available?`Available on ${H.availableDeviceIds.length} of ${ie} target${ie===1?"":"s"}`:`Unavailable: ${H.reason||"not supported by the current targets"}`;return l.jsxs("div",{className:`agents-suggested-item ${Y?"active":""} ${H.available?"":"unavailable"}`,children:[l.jsxs("button",{className:"agents-suggested-prompt",type:"button",role:"option","aria-selected":Y,"aria-disabled":!H.available,onClick:()=>ue(_),children:[l.jsx("span",{children:_.title}),l.jsx("small",{className:"agents-suggested-description",children:_.description}),l.jsxs("span",{className:"agents-suggested-meta",children:[l.jsx("em",{children:_.category}),l.jsx("em",{className:Yk(H.state),children:H.label}),l.jsx("em",{className:`risk-${_.risk}`,children:Wk(_.risk)}),l.jsx("em",{children:_.supportedPlatforms.map(Kk).join(" · ")}),l.jsx("em",{className:H.available?"availability-ok":"availability-unavailable",children:xe}),H.available&&H.unsupportedDeviceIds.length>0&&l.jsxs("em",{className:"availability-warning",children:["Unsupported on ",H.unsupportedDeviceIds.length]})]})]}),l.jsx("button",{className:`agents-suggested-favorite ${$?"favorite":""}`,type:"button","aria-label":$?`Remove ${_.title} from favorites`:`Add ${_.title} to favorites`,"aria-pressed":$,onClick:()=>Z(_.id),children:l.jsx(Qm,{size:14,fill:$?"currentColor":"none"})})]},_.id)})]},Q.category)),de.length===0&&l.jsx("p",{className:"agents-suggested-empty",children:"No tasks match this search or current filter."})]})]})}function Xk({devices:n,mode:a,selectedIds:i,onModeChange:r,onToggle:c,permissionMode:d,onPermissionModeChange:h}){const p=n.filter(g=>g.connected),v=i.filter(g=>p.some(w=>w.deviceId===g)).length;return l.jsxs("section",{className:"agents-target-picker","aria-label":"Agent targets",children:[l.jsxs("div",{className:"agents-target-toolbar",children:[l.jsx("span",{className:"agents-section-label",children:"Targets"}),l.jsxs("div",{className:"agents-target-modes",children:[l.jsxs("button",{className:a==="all"?"active":"",onClick:()=>r("all"),type:"button",children:[l.jsx(iy,{size:14})," All connected ",l.jsx("small",{children:p.length})]}),l.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>r("selected"),type:"button",children:[l.jsx(gc,{size:14})," Selected ",v]})]}),l.jsxs("label",{className:`agents-permission-picker permission-${d}`,children:[l.jsx(Sd,{size:14}),l.jsx("span",{children:"Permission"}),l.jsxs("select",{value:d,onChange:g=>h(g.target.value),"aria-label":"Agent permission mode",children:[l.jsx("option",{value:"ask",children:"Ask"}),l.jsx("option",{value:"safe-auto",children:"Safe Auto"}),l.jsx("option",{value:"full-access",children:"Full Access"}),l.jsx("option",{value:"custom",children:"Custom"})]}),l.jsx(oy,{size:13,"aria-hidden":"true"})]})]}),l.jsx("div",{className:"agents-target-list",children:n.length===0?l.jsx("span",{className:"agents-target-empty",children:"No workstations discovered."}):n.map(g=>{const w=a==="all"?g.connected:i.includes(g.deviceId);return l.jsxs("label",{className:`agents-target-option ${w?"selected":""} ${g.connected?"":"offline"}`,children:[l.jsx("input",{type:"checkbox",checked:w,disabled:!g.connected||a==="all",onChange:()=>c(g.deviceId)}),l.jsx("span",{className:"agents-target-icon",children:l.jsx(an,{size:15})}),l.jsxs("span",{children:[l.jsx("strong",{children:lw(g)}),l.jsx("small",{children:g.connected?"Connected":"Offline"})]}),w&&l.jsx(gc,{className:"agents-target-check",size:15,"aria-hidden":"true"})]},g.deviceId)})})]})}async function Zk(n,a){return Be("/api/settings/agent/plan",{method:"POST",body:JSON.stringify({instruction:a})},n)}async function Jk(n,a){return Be("/api/settings/agent/run",{method:"POST",body:JSON.stringify(a)},n)}async function eM(n,a){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}`,void 0,n)}async function tM(n,a){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function nM(n){return Be("/api/settings/agent/runs/cancel-all",{method:"POST",body:JSON.stringify({})},n)}async function aM(n,a,i,r){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(i)}/approve`,{method:"POST",body:JSON.stringify({scope:r})},n)}async function sM(n,a,i,r="User rejected this action."){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(i)}/reject`,{method:"POST",body:JSON.stringify({reason:r})},n)}async function lM(n,a,i){return Be(`/api/settings/agent/policies/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({categories:i})},n)}async function iM(n,a){return Be("/api/settings/agent/summary",{method:"POST",body:JSON.stringify(a)},n)}async function rM(n,a){return Be("/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 oM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}`,void 0,n)}async function cM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function uM(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}/retry`,{method:"POST",body:JSON.stringify({failedOnly:!0})},n)}function Fi(n){return`${n}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Zu(n,a){const i=new Map(a.map(r=>[r.deviceId,lw(r)]));return n.results.map(r=>({deviceId:r.deviceId,deviceName:r.deviceName||i.get(r.deviceId)||r.deviceId,status:Sk(r.status),stage:r.stage||(r.status==="running"?"Checking processes":void 0),result:r.result,data:r.data,error:r.error,sequence:Number.isSafeInteger(r.sequence)?r.sequence:0}))}function dM(n,a){const i=new Map(a.map(r=>[r.deviceId,r]));return n.map(r=>{const c=i.get(r.deviceId);return!c||c.sequence<=r.sequence?r:c})}function fM(n,a){const i=a.filter(d=>d.status==="completed"),r=a.filter(d=>d.status==="failed");if(n.operation==="process.list"){const h=`${i.filter(p=>{const v=p.result||"";return!/not running|no process/i.test(v)&&/running|online|found/i.test(v)}).length}대에서 요청한 프로세스가 실행 중입니다.`;return r.length>0?`${h}
14
+ ${r.map(p=>`${p.deviceName}는 ${p.error||"응답하지 않았습니다."}`).join(`
15
+ `)}`:h}return r.length>0?`${i.length}대 완료, ${r.length}대 실패했습니다.`:`${i.length}대 작업이 완료되었습니다.`}const mM={read:"allow",processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileRead:"ask",fileWrite:"ask",fileDelete:"ask",shell:"ask",script:"ask",softwareInstall:"ask",network:"ask",systemPower:"ask",systemConfiguration:"ask",userAccount:"deny"};function hM(n){return n==="safe-auto"?"Safe Auto":n==="full-access"?"Full Access":n==="custom"?"Custom":"Ask"}function pM(n){return n.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase())}function gM({hubUrl:n,devices:a}){const[i,r]=f.useState("all"),[c,d]=f.useState([]),[h,p]=f.useState(""),[v,g]=f.useState([]),[w,y]=f.useState(""),[b,j]=f.useState(""),[k,M]=f.useState(""),[R,C]=f.useState("safe-auto"),[A]=f.useState("custom-default"),[E,U]=f.useState(mM),[F,P]=f.useState([]),[L,I]=f.useState(""),[de,W]=f.useState(!1),[ue,Z]=f.useState(null),[le,ce]=f.useState(!1),[Q,_]=f.useState(""),[Y,$]=f.useState(!1),H=f.useRef(null),ie=f.useRef(new Set),xe=f.useRef(new Set),D=f.useRef(new Set),J=f.useMemo(()=>a.filter(V=>V.connected).map(V=>V.deviceId),[a]),he=f.useMemo(()=>Pk(iw,a,i,c,R,E),[E,a,R,c,i]),we=f.useCallback(V=>{const ae=Zu(V,a);if(g(ke=>ke.map(be=>be.type==="task"&&be.batchId===V.batchId?{...be,states:dM(be.states,ae),status:V.status}:be)),!["running","queued"].includes(V.status)&&!ie.current.has(V.batchId)){ie.current.add(V.batchId);const ke=Fi("agent-summary");g(be=>[...be,{type:"agent",id:ke,text:fM(V,ae)}]),V.operation&&iM(n,{instruction:V.instructionPreview,operation:V.operation,total:ae.length,completed:ae.filter(be=>be.status==="completed").length,failed:ae.filter(be=>be.status==="failed").length,results:ae.map(be=>({deviceName:be.deviceName,status:be.status,result:be.result,error:be.error}))}).then(be=>{!be.ok||!be.summary||g(st=>st.map(It=>It.type==="agent"&&It.id===ke?{...It,text:be.summary}:It))}).catch(()=>{}),y(be=>be===V.batchId?"":be)}},[a,n]),je=f.useCallback(async V=>{const ae=await oM(n,V);return we(ae),ae},[n,we]),Oe=f.useCallback((V,ae)=>{D.current.has(V.batchId)||(D.current.add(V.batchId),g(ke=>[...ke,{type:"task",id:Fi("task"),batchId:V.batchId,agentRunId:ae,operation:V.operation||"diagnostics.collect",instruction:V.instructionPreview,states:Zu(V,a),status:V.status}])),we(V)},[a,we]),He=f.useCallback(async V=>{const ae=await eM(n,V);for(const ke of ae.taskBatches||[])Oe(ke,V);if(P(ae.approvals||[]),!["running","queued","waiting-approval"].includes(ae.status)&&!xe.current.has(V)){xe.current.add(V);const ke=ae.finalResponse?.trim()||(ae.status==="cancelled"?"Codex 작업을 취소했습니다.":ae.error?`Codex 작업이 완료되지 않았습니다: ${ae.error}`:"Codex 작업이 완료되었습니다.");g(be=>[...be,{type:ae.status==="failed"?"error":"agent",id:Fi("agent-run-result"),text:ke}])}return ae},[Oe,n]);f.useEffect(()=>{if(!w)return;let V=!0;const ae=async()=>{try{const be=await je(w);V&&!["running","queued"].includes(be.status)&&y("")}catch(be){V&&_(be instanceof Error?be.message:String(be))}};ae();const ke=window.setInterval(()=>{ae()},800);return()=>{V=!1,window.clearInterval(ke)}},[w,je]),f.useEffect(()=>{if(!b)return;let V=!0;const ae=async()=>{try{const be=await He(b);V&&!["running","queued","waiting-approval"].includes(be.status)&&(j(""),ce(!1))}catch(be){V&&_(be instanceof Error?be.message:String(be))}};ae();const ke=window.setInterval(()=>{ae()},800);return()=>{V=!1,window.clearInterval(ke)}},[b,He]);const oe=async(V="",ae,ke=!1)=>{const be=(V||h).trim();if(!be||w||b)return;let st=kk(be);const It=ae||(i==="all"?J:c.filter(Ne=>J.includes(Ne)));if(It.length===0){_("Select at least one connected workstation.");return}if(R==="full-access"&&!le&&!ke){Z({instruction:be,targetIds:It});return}if(g(Ne=>[...Ne,{type:"user",id:Fi("user"),text:be}]),p(""),$(!1),_(""),(i==="all"?J:c.filter(Ne=>J.includes(Ne))).length===0){g(Ne=>[...Ne,{type:"error",id:Fi("no-targets"),text:"연결된 대상 장비를 하나 이상 선택해 주세요."}]);return}if(!st){try{if(R==="custom"){const Ie=await lM(n,A,E);if(!Ie.ok)throw new Error(Ie.error||"Custom Agent policy could not be saved.")}const Ne=await Jk(n,{instruction:be,deviceIds:It,permissionMode:R,customPolicyId:A});if(!Ne.ok||!Ne.runId)throw new Error(Ne.error||"Codex Agent run could not be started.");P(Ne.approvals||[]),j(Ne.runId);return}catch(Ne){try{const Ie=await Zk(n,be);Ie.ok&&Ie.plan&&(st={operation:Ie.plan.operation,query:Ie.plan.targetQuery})}catch{g(Ie=>[...Ie,{type:"error",id:Fi("unsupported"),text:Ne instanceof Error?Ne.message:Mk}])}}if(!st)return}try{const Ne=await rM(n,{instruction:be,deviceIds:It,operation:st.operation,targetQuery:st.query});if(!Ne.ok||!Ne.batch||!Ne.batchId)throw new Error(Ne.error||"작업을 만들지 못했습니다.");const Ie={type:"task",id:Fi("task"),batchId:Ne.batchId,operation:st.operation,instruction:be,states:Zu(Ne.batch,a),status:Ne.batch.status};D.current.add(Ne.batchId),g(Pt=>[...Pt,Ie]),y(Ne.batchId)}catch(Ne){_(Ne instanceof Error?Ne.message:String(Ne))}},Ze=async(V,ae)=>{I(V.approvalId);try{const ke=await aM(n,V.runId,V.approvalId,ae);if(!ke.ok)throw new Error(ke.error||"Agent approval could not be applied.");await He(V.runId)}catch(ke){_(ke instanceof Error?ke.message:String(ke))}finally{I("")}},De=async V=>{I(V.approvalId);try{const ae=await sM(n,V.runId,V.approvalId);if(!ae.ok)throw new Error(ae.error||"Agent approval could not be rejected.");await He(V.runId)}catch(ae){_(ae instanceof Error?ae.message:String(ae))}finally{I("")}},at=async(V,ae)=>{M(V);try{if(ae){const be=await tM(n,ae);for(const st of be.taskBatches||[])we(st);j(st=>st===ae?"":st);return}const ke=await cM(n,V);we(ke),y(be=>be===V?"":be)}catch(ke){_(ke instanceof Error?ke.message:String(ke))}finally{M("")}},ne=async()=>{if(!(de||!w&&!b)){W(!0);try{const V=await nM(n);if(!V.ok)throw new Error(V.error||"모든 Agent 작업을 취소하지 못했습니다.");y(""),j(""),P([]),g(ae=>ae.map(ke=>ke.type==="task"&&["queued","running"].includes(ke.status)?{...ke,status:"cancelled",states:ke.states.map(be=>["queued","running"].includes(be.status)?{...be,status:"cancelled",stage:"Cancelled",error:"Cancelled by user."}:be)}:ke))}catch(V){_(V instanceof Error?V.message:String(V))}finally{W(!1)}}},pe=async V=>{M(V);try{const ae=await uM(n,V);if(!ae.ok||!ae.batch||!ae.batchId)throw new Error(ae.error||"재시도하지 못했습니다.");ie.current.delete(ae.batchId),g(ke=>ke.map(be=>be.type==="task"&&be.batchId===V?{...be,batchId:ae.batchId,states:Zu(ae.batch,a),status:ae.batch.status}:be)),y(ae.batchId)}catch(ae){_(ae instanceof Error?ae.message:String(ae))}finally{M("")}},Me=V=>{p(V),$(!1),window.requestAnimationFrame(()=>H.current?.focus())};return l.jsxs("section",{className:"agents-page",children:[l.jsxs("div",{className:"agents-workspace",children:[(w||b)&&l.jsxs("div",{className:"agents-page-status",children:[l.jsxs("span",{children:[J.length," workstations · ",hM(R)]}),l.jsx("button",{type:"button",className:"agents-stop-all",onClick:()=>{ne()},disabled:de,children:de?"Stopping…":"Stop all"})]}),ue&&l.jsx("div",{className:"agents-permission-modal-backdrop",role:"presentation",children:l.jsxs("section",{className:"agents-permission-modal",role:"dialog","aria-modal":"true","aria-labelledby":"full-access-title",children:[l.jsx("span",{className:"agents-permission-modal-icon",children:l.jsx(Sd,{size:20})}),l.jsx("h3",{id:"full-access-title",children:"Confirm Full Access"}),l.jsx("p",{children:"Codex may change files, run commands, manage applications, and modify system state on the selected workstations. This run is still limited to the selected devices, the fixed policy, and the tool budget."}),l.jsxs("div",{className:"agents-permission-modal-actions",children:[l.jsx("button",{type:"button",onClick:()=>Z(null),children:"Cancel"}),l.jsx("button",{type:"button",className:"danger",onClick:()=>{const V=ue;Z(null),ce(!0),oe(V.instruction,V.targetIds,!0)},children:"Run with Full Access"})]})]})}),Q&&l.jsx("div",{className:"agents-error",role:"alert",children:Q}),l.jsx(_k,{items:v,onCancel:at,onRetry:pe,busyBatchId:k,approvals:F,onApprove:Ze,onReject:De,busyApprovalId:L}),l.jsxs("div",{className:"agents-composer-shell",children:[Y&&l.jsx(Qk,{devices:a,targetMode:i,selectedIds:c,permissionMode:R,customCategories:E,onSelectPrompt:Me,onClose:()=>$(!1)}),l.jsx(wk,{ref:H,value:h,onChange:p,onSubmit:()=>{oe()},onOpenSuggestedTasks:()=>$(V=>!V),suggestedOpen:Y,suggestedTaskCount:he,disabled:!!w||!!b})]})]}),l.jsxs("aside",{className:"agents-target-sidebar","aria-label":"Agent targets and permissions",children:[l.jsx(Xk,{devices:a,mode:i,selectedIds:c,onModeChange:r,onToggle:V=>d(ae=>ae.includes(V)?ae.filter(ke=>ke!==V):[...ae,V]),permissionMode:R,onPermissionModeChange:V=>{C(V),V!=="full-access"&&ce(!1)}}),R==="custom"&&l.jsxs("section",{className:"agents-custom-policy","aria-label":"Custom Agent permissions",children:[l.jsxs("div",{className:"agents-custom-policy-head",children:[l.jsxs("div",{children:[l.jsx("span",{className:"agents-section-label",children:"Custom policy"}),l.jsx("strong",{children:"Choose what Codex may do automatically."})]}),l.jsx("span",{children:"Denied actions never reach a device."})]}),l.jsx("div",{className:"agents-custom-policy-grid",children:bk.map(V=>l.jsxs("label",{children:[l.jsx("span",{children:pM(V)}),l.jsxs("select",{value:E[V],onChange:ae=>U(ke=>({...ke,[V]:ae.target.value})),children:[l.jsx("option",{value:"allow",children:"Allow automatically"}),l.jsx("option",{value:"ask",children:"Ask every time"}),l.jsx("option",{value:"deny",children:"Deny"})]})]},V))})]})]})]})}function ow(n){return{type:n.type,deviceIds:n.deviceIds,monitorIndex:n.monitorIndex,label:n.label}}async function cw(n){try{return(await n.json()).error||`${n.status} ${n.statusText}`}catch{return`${n.status} ${n.statusText}`}}async function uw(n,a,i){const r=encodeURIComponent(JSON.stringify({kind:a.kind,fileName:a.fileName,mimeType:n.type||"application/octet-stream",durationMs:a.durationMs,target:ow(a.target)})),c=await fetch(`${di(i)}/api/captures?metadata=${r}`,{method:"POST",headers:{"Content-Type":n.type||"application/octet-stream"},body:n,cache:"no-store"});if(!c.ok)throw new Error(await cw(c));return await c.json()}async function vM(n,a){return await Be("/api/capture-sessions",{method:"POST",body:JSON.stringify({...n,target:ow(n.target)})},a)}async function xM(n,a,i,r){const c=await fetch(`${di(r)}/api/capture-sessions/${encodeURIComponent(n)}/chunks/${a}`,{method:"PUT",headers:{"Content-Type":i.type||"application/octet-stream"},body:i,cache:"no-store"});if(!c.ok)throw new Error(await cw(c));return await c.json()}async function yM(n,a,i){return await Be(`/api/capture-sessions/${encodeURIComponent(n)}/finalize`,{method:"POST",body:JSON.stringify({durationMs:a})},i)}async function zx(n,a){await Be(`/api/capture-sessions/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function wM(n){return await Be("/api/captures",void 0,n)}function Ox(n,a){return`${di(a)}/api/captures/${encodeURIComponent(n)}/content`}async function bM(n,a){return await Be(`/api/captures/${encodeURIComponent(n)}`,{method:"DELETE"},a)}function SM({hubUrl:n,onToast:a}){const[i,r]=f.useState([]),[c,d]=f.useState(!0),h=f.useCallback(async()=>{d(!0);try{r((await wM(n)).captures||[])}catch(v){a(v instanceof Error?v.message:String(v))}finally{d(!1)}},[n,a]);f.useEffect(()=>{h()},[h]);const p=async v=>{const g=Ox(v.id,n);if(navigator.share)try{await navigator.share({title:v.fileName,url:g});return}catch{}window.open(g,"_blank","noopener,noreferrer")};return l.jsxs("section",{className:"capture-gallery",children:[l.jsxs("header",{children:[l.jsxs("div",{children:[l.jsx("span",{className:"settings-eyebrow",children:"Capture Gallery"}),l.jsx("h2",{children:"Saved captures"})]}),l.jsxs("button",{className:"text-button",onClick:()=>{h()},type:"button",children:[l.jsx(bc,{size:15})," Refresh"]})]}),c?l.jsx("p",{className:"settings-help",children:"Loading captures..."}):i.length===0?l.jsx("p",{className:"settings-help",children:"No captures saved yet."}):l.jsx("div",{className:"capture-gallery-grid",children:i.map(v=>{const g=Ox(v.id,n);return l.jsxs("article",{className:"capture-gallery-card",children:[v.mimeType.startsWith("image/")?l.jsx("img",{src:g,alt:v.target.label}):l.jsx("video",{src:g,controls:!0,preload:"metadata"}),l.jsxs("div",{className:"capture-gallery-card-body",children:[l.jsx("strong",{children:v.fileName}),l.jsxs("small",{children:[v.target.label," · ",new Date(v.createdAt).toLocaleString()," · ",Math.ceil(v.sizeBytes/1024)," KB"]}),l.jsxs("div",{children:[l.jsx("button",{className:"icon-button",title:"Open","aria-label":"Open",onClick:()=>window.open(g,"_blank","noopener,noreferrer"),type:"button",children:l.jsx(sS,{size:15})}),l.jsx("a",{className:"icon-button",title:"Download","aria-label":"Download",href:`${g}?download=1`,download:v.fileName,children:l.jsx(cy,{size:15})}),l.jsx("button",{className:"icon-button",title:"Share","aria-label":"Share",onClick:()=>{p(v)},type:"button",children:l.jsx(lS,{size:15})}),l.jsx("button",{className:"icon-button danger",title:"Delete","aria-label":"Delete",onClick:()=>{window.confirm(`Delete ${v.fileName}?`)&&bM(v.id,n).then(()=>h()).catch(w=>a(w instanceof Error?w.message:String(w)))},type:"button",children:l.jsx(xh,{size:15})})]})]})]},v.id)})})]})}function Ju(n){if(!n)return"";const a=Math.max(0,Math.floor((Date.now()-n)/1e3)),i=Math.floor(a/3600),r=Math.floor(a%3600/60),c=a%60;return i>0?`${String(i).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`}function Ix({controller:n,compact:a=!1,onFirstRollingUse:i,onError:r}){const{state:c,settings:d,videoSupported:h}=n,p=async y=>{try{await y()}catch(b){r?.(b instanceof Error?b.message:String(b))}},v=async()=>{if(d.rollingEnabled){n.setRollingEnabled(!1);return}(i?await i():window.confirm(`Keep the most recent 30 seconds in memory temporarily?
16
+ Nothing is saved until you press Save Last 30s.`))&&n.setRollingEnabled(!0)},g=c.recording?`Stop recording · ${Ju(c.recordingStartedAt)}`:`Start recording · ${c.targetLabel}`,w=c.timelapse?`Stop timelapse · ${Ju(c.timelapseStartedAt)}`:`Start timelapse · ${d.timelapseIntervalSeconds}s interval`;return l.jsxs("div",{className:`capture-toolbar ${a?"compact":""} ${c.recording?"recording-active":""}`,"aria-label":"Capture actions",children:[l.jsx("button",{className:"capture-action","aria-label":`Take screenshot · ${c.targetLabel}`,title:`Take screenshot · ${c.targetLabel}`,disabled:c.busy,onClick:()=>{p(n.takeScreenshot)},type:"button",children:l.jsx(iS,{size:17})}),l.jsx("button",{className:`capture-action ${c.recording?"active":""}`,"aria-label":g,title:g,disabled:!h||c.busy||c.timelapse,onClick:()=>{p(c.recording?n.stopRecording:n.startRecording)},type:"button",children:c.recording?l.jsxs(l.Fragment,{children:[l.jsx(Nv,{size:14,fill:"currentColor"}),l.jsx("span",{children:Ju(c.recordingStartedAt)})]}):l.jsx(ry,{size:18})}),l.jsxs("button",{className:"capture-action","aria-label":c.bufferEnabled?`Save last 30 seconds · ${c.bufferSeconds}s ready`:"Enable Last 30s memory buffer",title:c.bufferEnabled?`Save last 30 seconds · ${c.bufferSeconds}s ready`:"Enable Last 30s memory buffer",disabled:!h||c.recording||c.timelapse||c.busy||c.bufferEnabled&&c.bufferSeconds<1,onClick:()=>c.bufferEnabled?void p(n.saveLast30Seconds):void v(),type:"button",children:[l.jsx(rS,{size:17}),l.jsx("small",{children:"30s"})]}),l.jsx("button",{className:`capture-action ${c.timelapse?"timelapse-active":""}`,"aria-label":w,title:w,disabled:!h||c.busy||c.recording,onClick:()=>{p(c.timelapse?n.stopTimelapse:n.startTimelapse)},type:"button",children:c.timelapse?l.jsxs(l.Fragment,{children:[l.jsx(Nv,{size:14,fill:"currentColor"}),l.jsx("span",{children:Ju(c.timelapseStartedAt)})]}):l.jsx(oS,{size:17})})]})}async function CM(n,a={}){const i=n.filter(y=>y.canvas&&y.canvas.width>0&&y.canvas.height>0),r=Math.max(320,a.maxWidth||1920),c=Math.max(180,a.maxHeight||1080),d=i.length<=1?1:i.length<=4?2:i.length<=9?3:4,h=Math.max(1,Math.ceil(Math.max(1,i.length)/d)),p=Math.floor(r/d),v=Math.floor(c/h),g=document.createElement("canvas");g.width=Math.max(320,p*d),g.height=Math.max(180,v*h);const w=g.getContext("2d",{alpha:!1});if(!w)return g;w.fillStyle="#0b1220",w.fillRect(0,0,g.width,g.height),w.font="600 14px system-ui, sans-serif",w.textBaseline="bottom";for(let y=0;y<i.length;y+=1){const b=i[y],j=y%d,k=Math.floor(y/d),M=j*p,R=k*v,C=b.canvas,A=Math.min(p/C.width,v/C.height),E=Math.max(1,Math.floor(C.width*A)),U=Math.max(1,Math.floor(C.height*A)),F=M+Math.floor((p-E)/2),P=R+Math.floor((v-U)/2);w.drawImage(C,F,P,E,U),a.includeLabels!==!1&&(w.fillStyle="rgba(4, 10, 20, .74)",w.fillRect(M,R+v-28,p,28),w.fillStyle="#f8fafc",w.fillText(b.label,M+9,R+v-9))}return g}function jM(n){return n?.signature||"none"}function kM(n){return n?.label||"No capture target"}function Bx(n){return{...n,deviceIds:[...n.deviceIds],sourceCanvas:n.sourceCanvas||null}}function MM(){const n=new Date,a=i=>String(i).padStart(2,"0");return`${n.getFullYear()}${a(n.getMonth()+1)}${a(n.getDate())}_${a(n.getHours())}${a(n.getMinutes())}${a(n.getSeconds())}`}function AM(n){return n.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"Wall"}function NM(n){return`LiveDesk_${n.type==="wall"||n.type==="selection"?"Wall":`${AM(n.label)}_Monitor-${Number(n.monitorIndex||0)+1}`}_${MM()}.png`}async function TM(n,a,i){const r=await new Promise((d,h)=>n.toBlob(p=>p?d(p):h(new Error("Screenshot could not be encoded.")),"image/png")),c=await uw(r,{kind:"screenshot",fileName:NM(a),target:a},i);try{await navigator.clipboard.write([new ClipboardItem({"image/png":r})])}catch{}return c.capture}function dw(){return["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"].find(a=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(a))||""}function RM(n,a){const i=new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"").replace("T","_"),r=a.label.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,70)||"Wall";return n==="timelapse"?`LiveDesk_Timelapse_${r}_${i}.webm`:`LiveDesk_Recording_${r}_${i}.webm`}async function fw(n){if(typeof MediaRecorder>"u"||typeof n.canvas.captureStream!="function")throw new Error("This browser does not support video recording.");const a=dw();if(!a)throw new Error("This browser does not support WebM recording.");const i=n.kind||"recording",r=await vM({kind:i,fileName:RM(i,n.target),mimeType:a,target:n.target},n.hubUrl),c=n.canvas.captureStream(n.frameRequests?0:n.fps),d=new MediaRecorder(c,{mimeType:a,videoBitsPerSecond:i==="timelapse"?2e6:4e6}),h=performance.now();let p=0,v=!1,g=null,w=Promise.resolve();return d.ondataavailable=y=>{if(!y.data||y.data.size===0)return;const b=p++;w=w.then(()=>xM(r.sessionId,b,y.data,n.hubUrl).then(()=>{})).catch(j=>{g=g||(j instanceof Error?j:new Error(String(j))),n.onError?.(g)})},d.onerror=()=>{g=new Error("Video recording stopped unexpectedly."),n.onError?.(g)},d.start(1e3),{requestFrame:()=>{c.getVideoTracks()[0]?.requestFrame?.()},stop:async()=>{if(!v){if(v=!0,await new Promise(y=>{d.addEventListener("stop",()=>y(),{once:!0}),d.stop()}),c.getTracks().forEach(y=>y.stop()),await w,g)throw await zx(r.sessionId,n.hubUrl).catch(()=>{}),g;await yM(r.sessionId,Math.max(0,performance.now()-h),n.hubUrl)}},cancel:async()=>{v||(v=!0,d.stop(),c.getTracks().forEach(y=>y.stop()),await zx(r.sessionId,n.hubUrl).catch(()=>{}))}}}class EM{recorder=null;stream=null;segments=[];totalBytes=0;targetSignature="";startedAt=0;maxDurationMs=3e4;maxBytes=128*1024*1024;get seconds(){return!this.startedAt||this.segments.length===0?0:Math.min(30,Math.max(0,(performance.now()-this.segments[0].at)/1e3))}get active(){return this.recorder!==null}async start(a,i){if(this.recorder&&this.targetSignature===i.signature)return;if(this.stop(),typeof MediaRecorder>"u"||typeof a.captureStream!="function")throw new Error("This browser does not support Last 30s.");const r=dw();if(!r)throw new Error("This browser does not support WebM recording.");this.targetSignature=i.signature,this.stream=a.captureStream(20),this.recorder=new MediaRecorder(this.stream,{mimeType:r,videoBitsPerSecond:3e6}),this.startedAt=performance.now(),this.recorder.ondataavailable=c=>{if(!c.data.size)return;const d=performance.now();for(this.segments.push({blob:c.data,at:d}),this.totalBytes+=c.data.size;this.segments.length>1&&(d-this.segments[0].at>this.maxDurationMs||this.totalBytes>this.maxBytes);){const h=this.segments.shift();this.totalBytes-=h.blob.size}},this.recorder.start(1e3)}stop(){const a=this.recorder;this.recorder=null,a&&a.state!=="inactive"&&(a.ondataavailable=null,a.stop()),this.stream?.getTracks().forEach(i=>i.stop()),this.stream=null,this.segments=[],this.totalBytes=0,this.startedAt=0}async save(a,i){if(this.segments.length===0)throw new Error("The Last 30s buffer is not ready yet.");const r=new Blob(this.segments.map(h=>h.blob),{type:this.segments[0].blob.type||"video/webm"}),d=`LiveDesk_Last30s_${a.label.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,70)||"Wall"}_${new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"").replace("T","_")}.webm`;return await uw(r,{kind:"last-30s",fileName:d,target:a,durationMs:Math.min(3e4,this.segments.length*1e3)},i)}}async function DM(n,a,i,r,c){const d=await fw({canvas:n,target:a,kind:"timelapse",fps:30,frameRequests:!0,hubUrl:r,onError:c});d.requestFrame?.();const h=window.setInterval(()=>d.requestFrame?.(),Math.max(5,i)*1e3);return{stop:async()=>{window.clearInterval(h),await d.stop()},cancel:async()=>{window.clearInterval(h),await d.cancel()}}}const mw="livedesk.captureSettings";function LM(){const n={rollingEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0};try{const a=JSON.parse(localStorage.getItem(mw)||"null");return{...n,...a&&typeof a=="object"?a:{}}}catch{return n}}function _M(n){const[a,i]=f.useState(LM),[r,c]=f.useState(0),[d,h]=f.useState(0),[p,v]=f.useState(0),[g,w]=f.useState(!1),y=f.useRef(void 0),b=f.useRef(!1),j=f.useRef(""),k=f.useRef(null),M=f.useRef(null),R=f.useRef(null),C=f.useRef(null),A=f.useRef(new EM),E=n.sourceRegistry.resolveCurrentTarget(),U=jM(E),F=kM(E),P=typeof MediaRecorder<"u"&&typeof HTMLCanvasElement<"u"&&"captureStream"in HTMLCanvasElement.prototype;f.useEffect(()=>{if(localStorage.setItem(mw,JSON.stringify(a)),!b.current)return;const $=JSON.stringify(a);$!==j.current&&(j.current=$,Be("/api/settings",{method:"PATCH",body:JSON.stringify({revision:y.current,filesAudio:{rollingBufferEnabled:a.rollingEnabled,recordingQuality:a.recordingQuality,timelapseIntervalSeconds:a.timelapseIntervalSeconds,includeRemoteCursor:a.includeRemoteCursor}})},n.hubUrl).then(H=>{y.current=Number(H.revision||y.current||0)}).catch(()=>{}))},[n.hubUrl,a]),f.useEffect(()=>{let $=!0;return Be("/api/settings",void 0,n.hubUrl).then(H=>{if(!$)return;const ie=H.settings?.filesAudio||{},xe=typeof ie.rollingBufferEnabled=="boolean"?ie.rollingBufferEnabled:a.rollingEnabled,D=ie.recordingQuality==="high"?"high":"standard",J=[5,10,30,60].includes(Number(ie.timelapseIntervalSeconds))?Number(ie.timelapseIntervalSeconds):a.timelapseIntervalSeconds,he=typeof ie.includeRemoteCursor=="boolean"?ie.includeRemoteCursor:a.includeRemoteCursor,we={rollingEnabled:xe,recordingQuality:D,timelapseIntervalSeconds:J,includeRemoteCursor:he};y.current=Number(H.revision||0),j.current=JSON.stringify(we),b.current=!0,i(we)}).catch(()=>{b.current=!0}),()=>{$=!1}},[n.hubUrl]);const L=f.useCallback(async $=>{if($.sourceCanvas&&$.sourceCanvas.width>0&&$.sourceCanvas.height>0)return{target:Bx($),canvas:$.sourceCanvas,cleanup:()=>{}};const H=await n.sourceRegistry.composeWall($.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0});let ie=!1;const xe=window.setInterval(async()=>{if(ie)return;const D=await n.sourceRegistry.composeWall($.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0}).catch(()=>null);!D||ie||((H.width!==D.width||H.height!==D.height)&&(H.width=D.width,H.height=D.height),H.getContext("2d")?.drawImage(D,0,0))},100);return{target:Bx($),canvas:H,cleanup:()=>{ie=!0,window.clearInterval(xe)}}},[n.sourceRegistry]);f.useEffect(()=>{const $=A.current;if(!a.rollingEnabled||!E||!P){$.stop(),v(0);return}let H=!1,ie=null;return(async()=>{try{if(ie=await L(E),H)return;await $.start(ie.canvas,ie.target);const D=window.setInterval(()=>v(Math.round($.seconds)),500),J=()=>{window.clearInterval(D),ie?.cleanup()};$.__cleanup=J}catch(D){H||n.onToast(D instanceof Error?D.message:String(D))}})(),()=>{H=!0,$.stop(),$.__cleanup?.(),$.__cleanup=void 0,v(0)}},[L,n.onToast,a.rollingEnabled,U,P]);const I=f.useCallback($=>i(H=>({...H,rollingEnabled:$})),[]),de=f.useCallback($=>i(H=>({...H,recordingQuality:$})),[]),W=f.useCallback($=>i(H=>({...H,timelapseIntervalSeconds:$})),[]),ue=f.useCallback(async()=>{const $=n.sourceRegistry.resolveCurrentTarget();if(!$)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);let H=null;try{H=await L($),await TM(H.canvas,H.target,n.hubUrl),n.onToast("Screenshot saved")}finally{H?.cleanup(),w(!1)}},[L,n.hubUrl,n.onToast,n.sourceRegistry]),Z=f.useCallback(async()=>{if(R.current)throw new Error("Stop the timelapse before recording.");const $=n.sourceRegistry.resolveCurrentTarget();if(!$)throw new Error("화면이 준비된 후 다시 시도하세요.");const H=await L($),ie=await fw({canvas:H.canvas,target:H.target,fps:$.type==="control"?30:15,hubUrl:n.hubUrl,onError:xe=>n.onToast(xe.message)});M.current=H.cleanup,k.current=ie,c(Date.now()),n.onToast("Recording started")},[L,n.hubUrl,n.onToast,n.sourceRegistry]),le=f.useCallback(async()=>{const $=k.current;if($){w(!0);try{await $.stop(),n.onToast("Recording saved")}finally{k.current=null,M.current?.(),M.current=null,c(0),w(!1)}}},[n.onToast]),ce=f.useCallback(async()=>{if(k.current||R.current)throw new Error("Last 30s is unavailable during a recording.");const $=n.sourceRegistry.resolveCurrentTarget();if(!$)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);try{await A.current.save($,n.hubUrl),n.onToast("Last 30 seconds saved")}finally{w(!1)}},[n.hubUrl,n.onToast,n.sourceRegistry]),Q=f.useCallback(async()=>{if(k.current)throw new Error("Stop the recording before starting a timelapse.");const $=n.sourceRegistry.resolveCurrentTarget();if(!$)throw new Error("화면이 준비된 후 다시 시도하세요.");const H=await L($),ie=await DM(H.canvas,H.target,a.timelapseIntervalSeconds,n.hubUrl,xe=>n.onToast(xe.message));C.current=H.cleanup,R.current=ie,h(Date.now()),n.onToast("Timelapse started")},[L,n.hubUrl,n.onToast,n.sourceRegistry,a.timelapseIntervalSeconds]),_=f.useCallback(async()=>{const $=R.current;if($){w(!0);try{await $.stop(),n.onToast("Timelapse saved")}finally{R.current=null,C.current?.(),C.current=null,h(0),w(!1)}}},[n.onToast]);return f.useEffect(()=>{const $=H=>{!k.current&&!R.current||(H.preventDefault(),H.returnValue="")};return window.addEventListener("beforeunload",$),()=>window.removeEventListener("beforeunload",$)},[]),f.useEffect(()=>()=>{A.current.stop(),k.current?.cancel(),R.current?.cancel(),M.current?.(),C.current?.()},[]),{state:f.useMemo(()=>({recording:!!k.current,recordingStartedAt:r,timelapse:!!R.current,timelapseStartedAt:d,bufferSeconds:p,bufferEnabled:a.rollingEnabled,busy:g,targetLabel:F}),[p,g,r,a.rollingEnabled,F,d]),settings:a,videoSupported:P,targetKey:U,setRollingEnabled:I,setRecordingQuality:de,setTimelapseInterval:W,takeScreenshot:ue,startRecording:Z,stopRecording:le,saveLast30Seconds:ce,startTimelapse:Q,stopTimelapse:_}}const zM=120,OM=999,nc=5,ac=30,IM=Number.POSITIVE_INFINITY,hw="livedesk.remoteDirectory",uh="livedesk.localHubAccessEnabled",pw="livedesk.streamSettings",gw=15,vw="livedesk.controlStreamSettings",dh=6,xw="livedesk.wallMonitorSelections",yw=1,Bm=512*1024,fh="".trim(),ww="".trim(),Fx="livedesk-adsense-script",Fm=!!fh&&!!ww,BM=1e3/60,Hm=1500,FM=650,HM=1800,UM=650,$M=2500,Hx=1500,Ux=15e3,PM=6e4,$x=240,qM=1024,GM=480,VM=270,Px="LiveDesk clients are updating. Hub will restart after every client reconnects.",Um="LiveDesk is restarting with the latest Hub.";function YM(n,a){if(a.deviceId!==n.deviceId)return!1;const i=Number(a.browserReceivedEpochMs);if(!Number.isFinite(i)||i<n.startedAtEpochMs)return!1;const r=Number(a.monitorIndex);if(Number.isFinite(r)&&Math.floor(r)!==n.monitorIndex)return!1;const c=String(a.frameMode||a.mode||"").trim().toLowerCase();return!c||c===n.frameMode?!0:(n.frameMode==="mode3-h264-hw"||n.frameMode==="mode5-lzo-delta")&&(c==="mode2-lzo"||c==="mode3-h264-hw")}const Hi={free:{name:"Free",price:"$0",limit:nc,audience:"Personal trial",note:"5 devices with a standard ad banner."},ltd:{name:"Plus",price:"$79 LTD",ltd:"$79 LTD",limit:ac,audience:"Creators and homelabs",note:"30 devices, no ads, personal use."},pro:{name:"Pro",price:"$199 LTD",ltd:"$199 LTD",limit:IM,audience:"Business and studios",note:"Commercial use and larger workstation walls."}},bw={"mode1-jpeg":5,"mode2-lzo":8,"mode3-h264-hw":20,"mode4-h264-atlas":20};function vs(n,a){return`${n}:${a}`}const ma={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-hardware",fps:bw["mode3-h264-hw"],maxWidth:1920,maxHeight:1080,atlasTileWidth:320,atlasTileHeight:180,atlasTileSizeMode:"auto",quality:75,autoStartLive:!0,showScreenStatus:!0,visibleOnlyLive:!0,adaptiveLoadShedding:!0,adaptiveSizeByWall:!0},ha={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-software",fps:30,maxWidth:1920,maxHeight:1080,quality:75,showScreenStatus:!1};function od(n,a){if(n.length===0)return 0;const i=[...n].sort((c,d)=>c-d),r=Math.max(0,Math.min(i.length-1,Math.ceil(i.length*a)-1));return i[r]}function Fh(n,a){n.push(a),n.length>$x&&n.splice(0,n.length-$x)}function qx(n,a){n.sampleFrames=0,n.sampleStartedAt=a,n.intervalCount=0,n.intervalSumMs=0,n.minIntervalMs=Number.POSITIVE_INFINITY,n.maxIntervalMs=0,n.intervalSamplesMs.length=0,n.seqGapCount=0,n.maxSeqGap=0}function Gx(n,a,i){if(n.lastAt!==void 0){const r=Math.max(0,a-n.lastAt);n.intervalCount+=1,n.intervalSumMs+=r,n.minIntervalMs=Math.min(n.minIntervalMs,r),n.maxIntervalMs=Math.max(n.maxIntervalMs,r),Fh(n.intervalSamplesMs,r)}if(n.lastFrameSeq!==void 0){const r=i-n.lastFrameSeq;r!==1&&(n.seqGapCount+=1,n.maxSeqGap=Math.max(n.maxSeqGap,Math.abs(r)))}n.lastAt=a,n.lastFrameSeq=i}function Vx(n){return!n||n.intervalCount<=0?"waiting":`${Math.round(n.averageIntervalMs)}ms avg / p95 ${Math.round(n.p95IntervalMs)}ms / max ${Math.round(n.maxIntervalMs)}ms`}function WM(){const[n,a]=f.useState({framesPerSecond:0,averageIntervalMs:0,p95IntervalMs:0,maxIntervalMs:0,longTaskCount:0,longTaskMs:0});return f.useEffect(()=>{let i=0,r=performance.now(),c=0,d=0,h=[],p=0,v=0,g=null;const w=b=>{document.visibilityState==="visible"?(c+=1,d>0&&Fh(h,Math.max(0,b-d)),d=b):d=0,i=window.requestAnimationFrame(w)};try{g=new PerformanceObserver(b=>{for(const j of b.getEntries())p+=1,v+=j.duration}),g.observe({entryTypes:["longtask"]})}catch{g=null}i=window.requestAnimationFrame(w);const y=window.setInterval(()=>{const b=performance.now(),j=Math.max(1,b-r),k=h.reduce((M,R)=>M+R,0);a({framesPerSecond:c*1e3/j,averageIntervalMs:h.length>0?k/h.length:0,p95IntervalMs:od(h,.95),maxIntervalMs:h.length>0?Math.max(...h):0,longTaskCount:p,longTaskMs:v}),r=b,c=0,h=[],p=0,v=0},1e3);return()=>{window.cancelAnimationFrame(i),window.clearInterval(y),g?.disconnect()}},[]),n}function Yx(n){return!n||n.seqGapCount<=0?"none":`${n.seqGapCount} gaps / max ${n.maxSeqGap}`}function KM(n){return Number.isFinite(n)?String(n):"30+"}const cd=[{id:"mode4-h264-atlas",label:"Mode 4",detail:"Hub H.264 Atlas"},{id:"mode3-h264-hw",label:"Mode 3",detail:"H.264 hardware"},{id:"mode2-lzo",label:"Mode 2",detail:"RGB565 LZO wall"},{id:"mode1-jpeg",label:"Mode 1",detail:"JPEG test"}],mh=[{id:"prefer-software",label:"Software low latency"},{id:"prefer-hardware",label:"Hardware decode"},{id:"no-preference",label:"Browser auto"}],QM=[{id:"mode3-h264-hw",label:"Mode 3 - H.264 hardware"},{id:"mode2-lzo",label:"Mode 2 - RGB565 compatibility"},{id:"mode5-lzo-delta",label:"Mode 5 - LZO tile delta"}],ud=[{id:"640x360",label:"Compact",width:640,height:360},{id:"960x540",label:"Standard",width:960,height:540},{id:"1280x720",label:"HD",width:1280,height:720},{id:"1920x1080",label:"Full HD",width:1920,height:1080},{id:"2560x1440",label:"QHD",width:2560,height:1440},{id:"3840x2160",label:"4K",width:3840,height:2160}],$m=ud.filter(n=>n.width>=1280),Pm=[{id:"auto",label:"Auto by wall size"},{id:"320x180",label:"Standard 320x180",width:320,height:180},{id:"480x270",label:"Sharp 480x270",width:480,height:270}],Hh=[1,2,5,8,12,20,30],XM=[20,30,60],Wx=[45,60,75,90],Kx={large:{maxWidth:1280,maxHeight:720},medium:{maxWidth:960,maxHeight:540},small:{maxWidth:640,maxHeight:360}},qn={preserveConfiguredFpsDeviceCount:12,visibleRootMargin:"520px 0px 760px 0px",fallbackVisibleCounts:{large:12,medium:18,small:32},maxWallFramesPerSecond:96,maxWallBytesPerSecond:80*1024*1024,maxFrameGapMs:280,lowLoadFrameRatio:.58,lowLoadByteRatio:.52,downshiftCooldownMs:1800,recoveryCooldownMs:14e3,minFps:5},Qx=2200,ZM=8e3,JM=3500,eA=7e3,tA=2,nA=2600,aA=4200,sA=750,lA=2,Xx=4200;function Zx(n,a){return Math.min(3e4,n*2**Math.min(3,Math.max(0,a)))}function mc(n,a){const i=n.capabilities?.[a];return typeof i=="boolean"?i:/^(1|true|yes|on)$/i.test(String(i||"").trim())}function Gi(n){return n.deviceName||n.hostname||n.deviceId}function iA(){return"npx -y --prefer-online livedesk@latest client"}function rA(){return"npx -y --prefer-online livedesk@latest"}function oA(){try{return localStorage.getItem(hw)||""}catch{return""}}function cA(){try{return localStorage.getItem(uh)==="1"}catch{return!1}}function Pr(n){try{n?localStorage.setItem(uh,"1"):localStorage.removeItem(uh)}catch{}}function ts(n,a,i,r){const c=Number(n);return Number.isFinite(c)?Math.max(a,Math.min(i,Math.round(c))):r}function hh(n){const a=String(n||"").trim();return a==="mode2-lz4"||a==="lz4"?"mode2-lzo":cd.some(i=>i.id===a)?a:ma.frameMode}function bd(n){const a=String(n||"").trim();return mh.some(i=>i.id===a)?a:ma.h264DecodeAcceleration}function ph(n){return n==="mode2-lzo"||n==="mode3-h264-hw"||n==="mode5-lzo-delta"?n:ha.frameMode}function Sw(n){return bw[n]||12}function Cw(n){return n==="mode3-h264-hw"||n==="mode4-h264-atlas"?20:30}function gh(n,a){return ts(n,1,Cw(a),Sw(a))}function Ki(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}function Pn(n){const a=Ki(n.status),i=Ki(a.screens),r=Ki(n.capabilities),c=[a.monitorCount,a.screenCount,i.count,r.monitorCount,r.screenCount];for(const d of c){const h=Number(d);if(Number.isFinite(h)&&h>0)return Math.max(1,Math.min(64,Math.floor(h)))}return 1}function oi(n){const a=Number(n);return Number.isFinite(a)&&a>0?Math.floor(a):0}function uA(n){const a=Ki(n.status),r=[Ki(a.screens).displays,a.displays,a.monitors];for(const c of r)if(!(!Array.isArray(c)||c.length===0))return c.map(d=>Ki(d));return[]}function jw(n,a){const i=uA(n),r=i.find(v=>Number(v.index)===a)||i[a]||i[0]||{},c=oi(r.width),d=oi(r.height),h=[r.name,r.displayName,r.deviceName,r.id].find(v=>typeof v=="string"&&v.trim()),p=typeof h=="string"?h.trim():`Display ${a+1}`;return{index:a,name:p,width:c,height:d,primary:r.primary===!0||r.isPrimary===!0}}function dA(n){const a=Pn(n);return Array.from({length:a},(i,r)=>jw(n,r))}function fA(n){const a=[n.name||`Display ${n.index+1}`];return n.width>0&&n.height>0&&a.push(`${n.width}x${n.height}`),n.primary&&a.push("Primary"),a.join(" - ")}function kw(n,a){const i=jw(n,a);if(i.width>0&&i.height>0)return{width:i.width,height:i.height};const r=Ki(n.status),c=oi(r.screenWidth||r.width),d=oi(r.screenHeight||r.height);return c>0&&d>0?{width:c,height:d}:null}function Mw(n){if(!n)return null;const a=oi(n.sourceWidth)||oi(n.width),i=oi(n.sourceHeight)||oi(n.height);return a>0&&i>0?{width:a,height:i}:null}function mA(n,a,i){const d=((typeof a?.monitorIndex=="number"?Zn(a.monitorIndex,Math.max(1,a.monitorCount||1)):i)===i?Mw(a):null)||kw(n,i);return d?Math.max(.25,Math.min(4,d.width/d.height)):16/9}const ed=16/9;function Zn(n,a){const i=Math.max(1,Math.min(64,Math.floor(Number(a)||1))),r=Math.floor(Number(n));return Number.isFinite(r)?Math.max(0,Math.min(i-1,r)):0}function hA(){try{const n=localStorage.getItem(xw);if(!n)return{};const a=JSON.parse(n),i=a&&typeof a=="object"&&!Array.isArray(a)?a.selections:void 0;if(Number(a?.version)!==yw||!i||typeof i!="object"||Array.isArray(i))return{};const r={};for(const[c,d]of Object.entries(i)){const h=c.trim(),p=Math.floor(Number(d));!h||!Number.isFinite(p)||(r[h]=Math.max(0,Math.min(63,p)))}return r}catch{return{}}}function pA(n){try{localStorage.setItem(xw,JSON.stringify({version:yw,selections:n}))}catch{}}function gA(){try{const n=JSON.parse(localStorage.getItem(pw)||"{}");if(![gw,14,13,12,11].includes(Number(n.version)))return ma;const a=hh(n.frameMode),i=ts(n.maxWidth,320,3840,ma.maxWidth),r=ts(n.maxHeight,180,2160,ma.maxHeight);return{frameMode:a,h264DecodeAcceleration:bd(n.h264DecodeAcceleration),fps:gh(n.fps,a),maxWidth:i,maxHeight:r,atlasTileWidth:Number(n.atlasTileWidth)>=480?480:320,atlasTileHeight:Number(n.atlasTileHeight)>=270?270:180,atlasTileSizeMode:n.atlasTileSizeMode==="fixed"?"fixed":"auto",quality:ts(n.quality,20,95,ma.quality),autoStartLive:typeof n.autoStartLive=="boolean"?n.autoStartLive:ma.autoStartLive,showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:ma.showScreenStatus,visibleOnlyLive:typeof n.visibleOnlyLive=="boolean"?n.visibleOnlyLive:ma.visibleOnlyLive,adaptiveLoadShedding:typeof n.adaptiveLoadShedding=="boolean"?n.adaptiveLoadShedding:ma.adaptiveLoadShedding,adaptiveSizeByWall:typeof n.adaptiveSizeByWall=="boolean"?n.adaptiveSizeByWall:ma.adaptiveSizeByWall}}catch{return ma}}function vA(n){try{localStorage.setItem(pw,JSON.stringify({...n,version:gw}))}catch{}}function xA(){try{const n=JSON.parse(localStorage.getItem(vw)||"{}"),a=Number(n.version);if(![dh,5,4,3,2,1].includes(a))return ha;const i=ts(n.fps,20,60,ha.fps),r=a<dh;return{frameMode:r?ha.frameMode:ph(n.frameMode),h264DecodeAcceleration:r?ha.h264DecodeAcceleration:bd(n.h264DecodeAcceleration),fps:r?ha.fps:i,maxWidth:ts(n.maxWidth,1280,3840,ha.maxWidth),maxHeight:ts(n.maxHeight,720,2160,ha.maxHeight),quality:ts(n.quality,20,95,ha.quality),showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:ha.showScreenStatus}}catch{return ha}}function yA(n){try{localStorage.setItem(vw,JSON.stringify({...n,version:dh}))}catch{}}function qm(n,a){return n.length!==a.length?!1:n.every((i,r)=>i===a[r])}function Gm(n){return[...new Set(n.filter(Boolean))].sort()}function wA(n){return qn.fallbackVisibleCounts[n]||qn.fallbackVisibleCounts.large}function bA(n,a,i){if(n.frameMode==="mode2-lzo")return{maxWidth:320,maxHeight:180};if(n.frameMode==="mode4-h264-atlas")return n.atlasTileSizeMode==="auto"?a==="large"?{maxWidth:480,maxHeight:270}:{maxWidth:320,maxHeight:180}:{maxWidth:n.atlasTileWidth,maxHeight:n.atlasTileHeight};if(!n.adaptiveSizeByWall)return{maxWidth:n.maxWidth,maxHeight:n.maxHeight};const r=Kx[a]||Kx.large;return{maxWidth:Math.min(n.maxWidth,r.maxWidth),maxHeight:Math.min(n.maxHeight,r.maxHeight)}}function SA(n,a=qn.minFps){const i=[...Hh].sort((c,d)=>c-d),r=Math.max(a,Math.floor(n/2));return[...i].reverse().find(c=>c<n&&c>=a)||r}function CA(n,a){return[...Hh].sort((r,c)=>r-c).find(r=>r>n&&r<=a)||a}function sc(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let i=n,r=0;for(;i>=1024&&r<a.length-1;)i/=1024,r+=1;const c=r===0||i>=100?0:1;return`${i.toFixed(c)} ${a[r]}`}function Jx(n){if(!Number.isFinite(n)||!n||n<=0)return"0GB";const a=1024**4,i=1024**3;return n>=a?`${Math.max(1,Math.round(n/a))}TB`:`${Math.max(1,Math.round(n/i))}GB`}function Vm(n,a){if(!Number.isFinite(n)||!n||n<=0)return"not reported";const i=Math.max(0,n-Math.max(0,Number(a||0)));return`${Jx(i)} / ${Jx(n)}`}function jA(n){const a=new Uint8Array(n),i=32768;let r="";for(let c=0;c<a.length;c+=i){const d=a.subarray(c,c+i);r+=String.fromCharCode(...d)}return btoa(r)}function ey(n){return Array.from(n).filter(a=>a.size>=0).map(a=>{const i=a.webkitRelativePath||a.name;return{file:a,relativePath:i,fingerprint:`${a.size}:${a.lastModified}`}})}function kA(n){return n===1?"middle":n===2?"right":"left"}function ty(n,...a){for(const i of a){const r=n?.[i];if(typeof r=="string"&&r.trim())return r.trim()}return""}function ny(n){const a=Number(n);return Number.isInteger(a)&&a>=1&&a<=OM?a:0}const MA={cpu:"CPU",memory:"MEM",disk:"Disk",gpu:"GPU",vram:"VRAM",npu:"NPU",temp:"Temp",network:"Net"};function AA(n,a,i){if(n==="online")return"Online";if(n==="busy")return"Busy";if(n==="stale")return"Stale";if(n==="offline")return"Offline";if(i==="failed")return"Task failed";const r=n==="critical"?"critical":"warn",c=a.find(h=>h.state===r)||a.find(h=>h.state==="critical"||h.state==="warn");if(!c)return n==="critical"?"Issue":"Check";const d=MA[c.id]||c.label;return c.value&&c.value!=="-"?`${d} ${c.value}`:d}function Rd(n,a){const i=a.split(".");let r=n;for(const c of i){if(r==null)return;if(Array.isArray(r)){const d=Number(c);r=Number.isInteger(d)?r[d]:void 0;continue}if(typeof r=="object"){r=r[c];continue}return}return r}function Ut(n,...a){for(const i of a){const r=Rd(n,i),c=Number(r);if(Number.isFinite(c))return c}}function pa(n,...a){for(const i of a){const r=Rd(n,i);if(typeof r=="string"&&r.trim())return r.trim();if(typeof r=="number"&&Number.isFinite(r))return String(r)}return""}function NA(n,...a){for(const i of a){const r=Rd(n,i);if(typeof r=="boolean")return r;if(/^(1|true|yes|on|online|running|ready)$/i.test(String(r||"").trim()))return!0;if(/^(0|false|no|off|offline|stopped|missing)$/i.test(String(r||"").trim()))return!1}}function yl(n){const a=Number(n);if(Number.isFinite(a))return Math.max(0,Math.min(1,a>1?a/100:a))}function Ym(n,a){if(!(typeof n!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(a)||n<=0))return yl((n-Math.max(0,a))/n)}function qr(n){return n===void 0?"-":`${Math.round(n*100)}%`}function Wm(n){return n===void 0||!Number.isFinite(n)?"":n>=1e3?`${(n/1e3).toFixed(n>=1e4?0:1)}Gb/s`:`${Math.round(n)}Mb/s`}function Ui(n,a=.92,i=.78){return n===void 0?"unknown":n>=a?"critical":n>=i?"warn":"good"}function Aw(n){return!Number.isFinite(n)||!n||n<=0?"-":n<3600?`${Math.round(n/60)}m`:n<86400?`${Math.round(n/3600)}h`:`${Math.round(n/86400)}d`}function td(n,a,i){const r=Rd(n,`tools.${a}`),c=pa(n,`tools.${a}.status`,`tooling.${a}.status`,`${a}.status`).toLowerCase(),d=NA(n,`tools.${a}.running`,`tooling.${a}.running`,`${a}.running`),h=pa(n,`tools.${a}.version`,`tooling.${a}.version`,`${a}.version`),p=pa(n,`tools.${a}.port`,`tooling.${a}.port`,`${a}.port`);let v="unknown";return c==="busy"?v="busy":["online","running","ready","active"].includes(c)||d===!0?v="online":(["offline","stopped","missing","not-found"].includes(c)||d===!1||r===!1)&&(v="offline"),{id:a,label:i,status:v,detail:v==="offline"?"offline":h||(p?`:${p}`:v==="unknown"?"not reported":v)}}function Nw(n){const a=n.status||{},i=Ut(a,"cpu.cores","cpuCores","processorCount"),r=Ut(a,"loadavg.0","cpu.load1"),c=yl(Ut(a,"cpu.usedRatio","cpu.usageRatio","cpu.ratio","cpu.usedPct","cpu.usagePct","cpu.percent")??(i&&r!==void 0?r/Math.max(1,i):void 0)),d=Ut(a,"memory.totalBytes","totalMem"),h=Ut(a,"memory.freeBytes","freeMem"),p=yl(Ut(a,"memory.usedRatio","memory.usedPct","usedMemRatio"))??Ym(d,h),v=Ut(a,"disk.totalBytes","rootDisk.totalBytes","storage.totalBytes"),g=Ut(a,"disk.freeBytes","rootDisk.freeBytes","storage.freeBytes"),w=yl(Ut(a,"disk.usedRatio","disk.usedPct","rootDisk.usedRatio","storage.usedRatio"))??Ym(v,g),y=Ut(a,"thermal.cpuC","temperatureC","cpu.temperatureC","gpu.temperatureC"),b=yl(Ut(a,"gpu.usedRatio","gpu.usageRatio","gpu.usedPct","gpu.usagePct","gpu.percent","accelerators.gpu.usageRatio")),j=pa(a,"gpu.name","gpu.model","accelerators.gpu.name"),k=Ut(a,"gpu.memory.totalBytes","gpu.totalMemoryBytes","gpu.vramTotalBytes"),M=Ut(a,"gpu.memory.freeBytes","gpu.freeMemoryBytes","gpu.vramFreeBytes"),R=yl(Ut(a,"gpu.memory.usedRatio","gpu.vramUsedRatio"))??Ym(k,M),C=Ut(a,"gpu.temperatureC","thermal.gpuC"),A=yl(Ut(a,"npu.usedRatio","npu.usageRatio","npu.usedPct","npu.usagePct","npu.percent","accelerators.npu.usageRatio")),E=pa(a,"npu.name","npu.model","accelerators.npu.name"),U=Ut(a,"npu.tops","npu.topsInt8","accelerators.npu.tops"),F=Ut(a,"network.rxMbps","network.receiveMbps","network.downMbps"),P=Ut(a,"network.txMbps","network.transmitMbps","network.upMbps"),L=Ut(a,"network.latencyMs","network.rttMs"),I=yl(Ut(a,"network.usedRatio","network.usageRatio","network.saturationRatio")),de=pa(a,"network.link","network.interface","network.name"),W=y===void 0?void 0:yl((y-35)/60),ue=pa(a,"workload.role","role","lane")||(mc(n,"aiAssist")?"Agent worker":mc(n,"taskDispatch")?"Task worker":"Local machine"),Z=pa(n.latestTask,"status")||pa(a,"workload.status")||"idle",le=pa(n.latestTask,"title","instructionPreview")||pa(a,"workload.title"),ce=pa(n.latestTask,"resultSummary","error","instructionPreview")||pa(a,"workload.summary"),Q=[td(a,"ollama","Ollama"),td(a,"lmStudio","LM Studio"),td(a,"comfyui","ComfyUI"),td(a,"stableDiffusion","Stable Diffusion")],_=Q.some(D=>D.status!=="unknown"),Y=Date.parse(n.lastSeenAt||n.connectedAt||""),$=Number.isFinite(Y)?Date.now()-Y:0;let H="online";n.connected?$>5*6e4?H="stale":(y??0)>=86||(C??0)>=88||(c??0)>=.94||(b??0)>=.96||(R??0)>=.96||(A??0)>=.96||(p??0)>=.94||(w??0)>=.94||(L??0)>=200||Z==="failed"?H="critical":(y??0)>=78||(C??0)>=80||(c??0)>=.82||(b??0)>=.86||(R??0)>=.88||(A??0)>=.86||(p??0)>=.82||(w??0)>=.86||(L??0)>=80?H="warn":(["queued","running","targeted"].includes(Z)||Q.some(D=>D.status==="busy"))&&(H="busy"):H="offline";const ie=Q.filter(D=>D.status==="online"||D.status==="busy").length,xe=[{id:"cpu",label:"CPU",value:qr(c),detail:i?`${i} cores`:r!==void 0?`load ${r.toFixed(1)}`:"not reported",ratio:c,state:Ui(c,.92,.78)},{id:"memory",label:"RAM",value:qr(p),detail:Vm(d,h),ratio:p,state:Ui(p,.92,.78)},{id:"disk",label:"DISK",value:qr(w),detail:Vm(v,g),ratio:w,state:Ui(w,.92,.82)},{id:"gpu",label:"GPU",value:qr(b),detail:j||(k&&M!==void 0?`${sc(M)} VRAM free`:C!==void 0?`${Math.round(C)}C`:"not reported"),ratio:b,state:C!==void 0&&C>=88?"critical":C!==void 0&&C>=80?"warn":Ui(b,.96,.86)},{id:"vram",label:"VRAM",value:qr(R),detail:Vm(k,M),ratio:R,state:Ui(R,.96,.88)},{id:"npu",label:"NPU",value:A!==void 0?qr(A):U!==void 0?`${Math.round(U)} TOPS`:"-",detail:E||(U!==void 0?"neural engine":"not reported"),ratio:A,state:Ui(A,.96,.86)},{id:"temp",label:"TEMP",value:y===void 0?"-":`${Math.round(y)}C`,detail:ie>0?`${ie} local tools`:`uptime ${Aw(Ut(a,"uptimeSec"))}`,ratio:W,state:y===void 0?"unknown":y>=86?"critical":y>=78?"warn":"good"},{id:"network",label:"NET",value:Wm(F)||(L!==void 0?`${Math.round(L)}ms`:de||"-"),detail:Wm(P)?`${Wm(P)} up`:de||"not reported",ratio:I,state:L!==void 0&&L>=200?"critical":L!==void 0&&L>=80?"warn":Ui(I,.9,.75)}];return{state:H,label:AA(H,xe,Z),role:ue,taskLabel:le||(Z==="idle"?"idle":Z),taskStatus:Z,taskSummary:ce,tools:_?Q:Q.map(D=>({...D,detail:"not reported"})),metrics:xe}}function TA({size:n=22}){return l.jsxs("svg",{width:n,height:n,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[l.jsx("rect",{x:"2.5",y:"4",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.42"}),l.jsx("path",{d:"M7 16v1.5h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.42"}),l.jsx("rect",{x:"10.5",y:"2.5",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.62"}),l.jsx("path",{d:"M15 14.5V16h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.62"}),l.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"}),l.jsx("path",{d:"M12 21v1.5H9.5M16 21v1.5h2.5M9.5 22.5h9",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round"})]})}const RA=[{id:"small",label:"Small"},{id:"medium",label:"Medium"},{id:"large",label:"Large"}],EA=[{id:"wall",label:"Wall",icon:pc,accent:"blue"},{id:"control",label:"Control",icon:ad,accent:"red"},{id:"share-files",label:"Share Files",icon:nd,accent:"green"},{id:"agents",label:"Agents",icon:ec,accent:"violet"},{id:"sync-server",label:"Sync Server",icon:sd,accent:"blue"}],DA=[{id:"doc",label:"Doc",icon:Xm,accent:"amber"},{id:"pricing",label:"Pricing",icon:tc,accent:"green"}];function LA(n){return n.replaceAll("npx -y @livedesk/client","npx -y --prefer-online livedesk@latest client").replaceAll("npx @livedesk/client","npx -y --prefer-online livedesk@latest client").replaceAll("npx -y livedesk client","npx -y --prefer-online livedesk@latest client").replaceAll("npx livedesk client","npx -y --prefer-online livedesk@latest client").replaceAll("npx -y livedesk","npx -y --prefer-online livedesk@latest").replaceAll("npx livedesk","npx -y --prefer-online livedesk@latest")}function $t(n){return LA(n).replace(/\bRemoteHub\b/g,"Hub client endpoint").replace(/\bManagers\b/g,"Hubs").replace(/\bManager\b/g,"Hub").replace(/\bmanager\b/g,"Hub").replace(/\bMANAGER\b/g,"HUB").replace(/매니저/g,"Hub")}function $i(n){return n.map(a=>$t(a))}function Un(n){return{languageName:n.languageName,languageLabel:n.languageLabel,eyebrow:n.eyebrow,title:$t(n.title),intro:$t(n.intro),sections:[{title:$t(n.managerTitle),body:$t(n.managerBody),points:$i(n.managerPoints)},{title:$t(n.clientTitle),body:$t(n.clientBody),points:$i(n.clientPoints)},{title:$t(n.syncTitle),body:$t(n.syncBody),points:$i(n.syncPoints)},...n.agentTitle&&n.agentBody&&n.agentPoints?[{title:$t(n.agentTitle),body:$t(n.agentBody),points:$i(n.agentPoints)}]:[],{title:$t(n.platformTitle),body:$t(n.platformBody),points:$i(n.platformPoints)}],sync:{title:$t(n.syncTitle),body:$t(n.syncBody),points:$i(n.syncPoints)},firewall:{title:$t(n.firewallTitle),body:$t(n.firewallBody),points:$i(n.firewallPoints)},commands:{title:$t(n.commandsTitle),body:$t(n.commandsBody),manager:$t(n.managerCommandLabel),primary:$t(n.clientCommandLabel),slot:$t(n.slotCommandLabel),manual:$t(n.manualCommandLabel)}}}const Wr={ko:Un({languageName:"한국어",languageLabel:"문서 언어",eyebrow:"LiveDesk Manual",title:"한 줄로 여는 로컬 Screen Wall",intro:"LiveDesk는 매니저 PC 한 대에서 여러 작업 PC, AI 박스, 맥미니, 개발 장비를 한 화면에 모니터링하고 필요한 제어를 실행하는 npm-first 원격 작업 데크입니다.",managerTitle:"1. 매니저 실행",managerBody:"화면을 모아 볼 컴퓨터에서 LiveDesk 매니저를 실행합니다. 매니저는 UI와 로컬 서버를 같이 열고 브라우저를 http://127.0.0.1:5179 로 띄웁니다.",managerPoints:["명령은 npx -y livedesk 입니다.","매니저는 Screen Wall/API 포트 5179와 클라이언트 접속 포트 5197을 사용합니다.","기존 LiveDesk 포트가 남아 있으면 기본적으로 정리하고 새로 시작합니다. 필요하면 --no-clean 을 붙입니다."],clientTitle:"2. 워크스테이션 연결",clientBody:"모니터링할 PC에서는 Google 로그인 또는 Hub 화면의 6자리 PIN으로 연결합니다. Hub가 켜져 있지 않아도 클라이언트는 종료하지 않고 5초마다 계속 찾습니다.",clientPoints:["빈 자리에 자동 배치하려면 npx -y livedesk client 를 실행합니다.","자리 번호를 고정하려면 npx -y livedesk client 3 처럼 번호를 붙입니다.","브라우저 연결 페이지에서 Google 버튼 또는 6자리 PIN 입력 중 하나를 선택합니다."],syncTitle:"3. Sync Server와 자동 발견",syncBody:"Sync Server는 이 매니저를 현재 계정의 활성 Screen Wall로 Supabase에 등록합니다. 클라이언트는 같은 Google 계정으로 로그인한 뒤 그 기록을 읽고 접속 후보들을 순서대로 시도합니다.",syncPoints:["등록 정보에는 host instance, LAN/private 주소, public 후보 주소, pair token, 짧은 lease가 포함됩니다.","같은 LAN 후보를 먼저 쓰고, 필요하면 외부 주소 후보를 시도합니다.","매니저 위치, VPN, 방화벽, 공유기 설정이 바뀌었거나 개발 중 활성 매니저를 바꿀 때 Sync Server를 누릅니다.","이제 livedesk.pages.dev의 Chrome Local Network Access 허용은 기본 실행 경로가 아닙니다. npm 매니저 앱이 실제 서버입니다."],agentTitle:"4. Agent로 여러 장비 작업하기",agentBody:"Agents 화면은 Hub에서 실행되는 Codex 기반 Agent가 연결된 장비를 확인하고, 선택한 권한 범위 안에서 작업을 실행하는 공간입니다. 클라이언트 PC에 Codex 앱이나 Codex SDK를 설치할 필요는 없습니다.",agentPoints:["Suggested tasks에는 현재 72개의 읽기·운영 작업 템플릿이 있으며, 검색과 권한·플랫폼·capability 조건으로 실행 가능 항목을 안내합니다.","Ask, Safe Auto, Full Access, Custom 권한 모드를 선택할 수 있습니다. 위험한 변경 작업은 승인 카드와 장비 capability 검사를 거칩니다.","All connected 또는 Selected로 대상 장비를 제한하고, 결과는 장비별 상태 칩과 실제 RAM·디스크·GPU·프로세스 요약으로 확인합니다.","Agent 실행은 Hub의 격리된 runtime과 LiveDesk MCP 도구를 통해서만 장비에 전달되며, 모든 작업은 timeout·취소·tool limit·감사 로그 경계를 가집니다."],platformTitle:"5. 현재 플랫폼과 스트림 상태",platformBody:"Windows의 Wall, Control, 파일 전송, 원격 오디오와 RemoteFast 경로를 현재 기준으로 확인했습니다. macOS와 Linux는 같은 npm 명령 경로를 유지하면서 권한과 캡처 백엔드를 확장하고 있습니다.",platformPoints:["Wall은 Mode 4 H.264 Atlas와 Mode 2 LZO 경로를 제공하고, Control은 Mode 3 H.264 또는 Mode 5 LZO tile delta를 사용합니다.","원격 오디오는 선택한 장비가 capability를 광고할 때 사용할 수 있으며, 브라우저는 queue·drop·resync·automatic restart 상태를 진단합니다.","macOS: 화면 캡처와 제어에는 Screen Recording/Accessibility 권한이 필요합니다. RemoteFast 로그는 필요한 상태 중심으로 제한됩니다.","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot 캡처, xdotool 입력 백엔드가 추가되었습니다. 오디오는 아직 비활성입니다."],firewallTitle:"방화벽과 외부 장소 연결",firewallBody:"같은 LAN 안에서는 보통 공유기 포트포워딩이 필요 없습니다. 다른 장소의 PC를 붙이려면 클라이언트가 매니저의 클라이언트 접속 포트에 도달할 수 있어야 합니다.",firewallPoints:["클라이언트 접속 포트는 TCP 5197입니다.","클라이언트 쪽은 나가는 연결이므로 보통 인바운드 포트 개방이 필요 없습니다.","다른 네트워크에서 붙일 때는 매니저 PC 방화벽에서 TCP 5197 인바운드를 허용하고, 공유기에서는 TCP 5197을 매니저 PC로 전달합니다.","Screen Wall/API 포트 5179는 매니저 UI용입니다. 외부 브라우저에서 Wall을 직접 열 필요가 있을 때만 별도로 노출을 검토합니다.","공개 인터넷에 바로 열기보다 VPN, Tailscale, ZeroTier, 고정 IP allowlist를 우선합니다."],commandsTitle:"현재 사용 명령",commandsBody:"웹사이트를 찾아가 설치 파일을 받는 방식보다 터미널 한 줄로 모든 운영체제에서 거의 같은 흐름을 쓰는 것이 LiveDesk의 기본 방향입니다.",managerCommandLabel:"매니저 시작",clientCommandLabel:"워크스테이션 연결",slotCommandLabel:"3번 슬롯에 고정",manualCommandLabel:"고급 수동 연결"}),en:Un({languageName:"English",languageLabel:"Document language",eyebrow:"LiveDesk Manual",title:"Open a local Screen Wall with one command",intro:"LiveDesk is an npm-first remote work deck for monitoring many workstations, AI boxes, Mac minis, and dev machines from one manager PC.",managerTitle:"1. Run the manager",managerBody:"Run LiveDesk on the computer that will watch the screens. The manager starts the UI and local server together, then opens http://127.0.0.1:5179.",managerPoints:["The command is npx -y livedesk.","The manager uses port 5179 for the Screen Wall/API and port 5197 for client connections.","If an old LiveDesk process still owns those ports, startup cleans it by default. Add --no-clean when you want to keep it."],clientTitle:"2. Connect a workstation",clientBody:"On each monitored computer, connect with Google sign-in or the 6-digit PIN shown on the Hub screen. If no manager is online yet, the client keeps running and retries every 5 seconds.",clientPoints:["Run npx -y livedesk client for first available placement.","Run npx -y livedesk client 3 to pin the machine to slot 3.","The browser connection page lets you choose Google or a 6-digit PIN."],syncTitle:"3. Sync Server and discovery",syncBody:"Sync Server publishes this manager as the active Screen Wall for the signed-in account. Clients read that Supabase record after Google sign-in and try the endpoint candidates in order.",syncPoints:["The record includes host instance, LAN/private addresses, public endpoint candidates, pair token, and a short lease.","LAN candidates are preferred first, then public candidates if needed.","Press Sync Server after manager moves, VPN/firewall/router changes, or when this development machine should take over as active manager.","Chrome Local Network Access on livedesk.pages.dev is no longer the default runtime path. The npm manager app is the real server."],agentTitle:"4. Run multi-workstation tasks with Agent",agentBody:"The Agents page runs a Codex-based Agent in the Hub to inspect connected workstations and perform actions within the selected permission scope. Client PCs do not need the Codex app or Codex SDK installed.",agentPoints:["Suggested tasks currently contains 72 read-only and operational templates with search plus permission, platform, and capability availability checks.","Choose Ask, Safe Auto, Full Access, or Custom. Risky changes go through approval cards and explicit client capability checks.","Limit targets with All connected or Selected. Results use compact per-device status chips and show real RAM, disk, GPU, and process summaries.","Runs stay inside the Hub-isolated runtime and LiveDesk MCP tools, with timeout, cancellation, tool-call limits, and audit-log boundaries."],platformTitle:"5. Current platform and stream state",platformBody:"Windows Wall, Control, file transfer, remote audio, and the RemoteFast path are verified against the current implementation. macOS and Linux keep the same npm command path while capture and permission backends expand.",platformPoints:["Wall provides Mode 4 H.264 Atlas and Mode 2 LZO paths. Control provides Mode 3 H.264 or Mode 5 LZO tile delta.","Remote audio is available when the selected workstation advertises the capability, with queue, drop, resync, and automatic-restart diagnostics in the browser.","macOS requires Screen Recording and Accessibility permissions for capture and control. RemoteFast logs focus on actionable state.","Linux includes the linux-x64 runtime, grim/gnome-screenshot/import/scrot capture, and xdotool input backend. Audio is still disabled."],firewallTitle:"Firewall and remote locations",firewallBody:"On the same LAN, router forwarding is usually unnecessary. For another office, building, or country, clients must be able to reach the manager client port.",firewallPoints:["Client connection port: TCP 5197.","Client machines normally only need outbound access.","For remote networks, allow inbound TCP 5197 on the manager firewall and forward TCP 5197 from the router to the manager PC.","Screen Wall/API port 5179 is for the manager UI. Expose it only if a remote browser must open the Wall directly.","Prefer VPN, Tailscale, ZeroTier, or fixed-IP allowlists over public internet exposure."],commandsTitle:"Current commands",commandsBody:"The product direction is one terminal command across operating systems instead of finding a website, downloading, and installing manually.",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),ja:Un({languageName:"日本語",languageLabel:"ドキュメント言語",eyebrow:"LiveDesk Manual",title:"1行でローカル Screen Wall を開く",intro:"LiveDesk は、複数の作業 PC、AI マシン、Mac mini、開発機を1台の manager PC から監視する npm-first のリモート作業デッキです。",managerTitle:"1. manager を実行",managerBody:"画面を集めて見るコンピューターで LiveDesk manager を実行します。UI とローカルサーバーが同時に起動し、http://127.0.0.1:5179 が開きます。",managerPoints:["コマンドは npx -y livedesk です。","Screen Wall/API は 5179、client 接続は 5197 を使います。","古い LiveDesk プロセスがポートを使っている場合は、基本的に自動で整理して起動します。"],clientTitle:"2. workstation を接続",clientBody:"監視される PC で同じ Google アカウントにログインします。manager がまだ無くても client は終了せず、5秒ごとに再試行します。",clientPoints:["空きスロットに入れるには npx -y livedesk client を実行します。","スロットを固定するには npx -y livedesk client 3 のように番号を付けます。","大量の PC でも再ログインなしで待ち続けます。"],syncTitle:"3. Sync Server と自動検出",syncBody:"Sync Server はこの manager を現在の Google アカウントの active Screen Wall として Supabase に登録します。",syncPoints:["host instance、LAN/private アドレス、public 候補、pair token、短い lease を登録します。","client は LAN 候補を優先し、必要なら public 候補も試します。","VPN、firewall、router、manager の場所が変わったら Sync Server を押します。","livedesk.pages.dev の Chrome Local Network Access は標準実行経路ではありません。npm manager アプリが実際のサーバーです。"],platformTitle:"4. 現在のプラットフォーム状態",platformBody:"Windows は live screen transfer まで確認済みです。macOS と Linux も同じ npm コマンド経路を目標に対応を広げています。",platformPoints:["Windows: 動作確認済み。","macOS: 画面取得と制御には Screen Recording/Accessibility 権限が必要です。","Linux: linux-x64 runtime、grim/gnome-screenshot/import/scrot capture、xdotool input backend を追加済み。audio は未対応です。"],firewallTitle:"Firewall と外部拠点",firewallBody:"同じ LAN なら通常 router forwarding は不要です。外部拠点では client が manager の接続ポートへ到達できる必要があります。",firewallPoints:["client 接続ポートは TCP 5197 です。","client 側は通常 outbound だけで足ります。","外部 network では manager PC の firewall で TCP 5197 inbound を許可し、router から manager PC へ forward します。","5179 は manager UI 用なので、外部ブラウザで Wall を開く必要がある時だけ公開を検討します。","公開 internet より VPN、Tailscale、ZeroTier、IP allowlist を優先してください。"],commandsTitle:"現在のコマンド",commandsBody:"Web サイトから installer を探すより、OS をまたいで terminal 1行で動かす方向です。",managerCommandLabel:"manager 起動",clientCommandLabel:"workstation 接続",slotCommandLabel:"slot 3 に固定",manualCommandLabel:"高度な手動接続"}),"zh-CN":Un({languageName:"简体中文",languageLabel:"文档语言",eyebrow:"LiveDesk Manual",title:"用一条命令打开本地 Screen Wall",intro:"LiveDesk 是 npm-first 的远程工作台,用一台 manager PC 监控多台工作站、AI 主机、Mac mini 和开发机器。",managerTitle:"1. 运行 manager",managerBody:"在负责查看屏幕的电脑上运行 LiveDesk manager。它会同时启动 UI 和本地服务器,并打开 http://127.0.0.1:5179。",managerPoints:["命令是 npx -y livedesk。","Screen Wall/API 使用 5179,client 连接使用 5197。","如果旧的 LiveDesk 进程占用端口,默认会清理后重新启动。"],clientTitle:"2. 连接 workstation",clientBody:"在被监控的电脑上使用同一个 Google 账号登录。即使 manager 还没在线,client 也会继续运行并每 5 秒重试。",clientPoints:["自动放入空位: npx -y livedesk client。","固定到 3 号位置: npx -y livedesk client 3。","大量电脑也可以持续等待,不需要反复登录。"],syncTitle:"3. Sync Server 和自动发现",syncBody:"Sync Server 会把当前 manager 作为该账号的 active Screen Wall 写入 Supabase。client 登录后读取记录并依次尝试连接候选地址。",syncPoints:["记录包括 host instance、LAN/private 地址、public 候选、pair token 和短 lease。","优先尝试同一 LAN 地址,需要时再尝试外部地址。","manager 位置、VPN、防火墙或路由变化后请点击 Sync Server。","livedesk.pages.dev 的 Chrome Local Network Access 不再是默认运行方式。npm manager app 才是真正服务器。"],platformTitle:"4. 当前平台状态",platformBody:"Windows 已确认可传输实时画面。macOS 和 Linux 正按同一 npm 命令路径扩展支持。",platformPoints:["Windows: 已确认可用。","macOS: 画面捕获和控制需要 Screen Recording/Accessibility 权限。","Linux: 已加入 linux-x64 runtime、grim/gnome-screenshot/import/scrot 捕获、xdotool 输入后端。音频尚未启用。"],firewallTitle:"防火墙和外部地点",firewallBody:"同一 LAN 通常不需要路由端口转发。不同地点连接时,client 必须能访问 manager 的 client 连接端口。",firewallPoints:["client 连接端口是 TCP 5197。","client 机器通常只需要出站访问。","跨网络时,在 manager 防火墙放行 TCP 5197 入站,并在路由器转发到 manager PC。","5179 是 manager UI 端口,仅在需要远程浏览器直接打开 Wall 时考虑暴露。","优先使用 VPN、Tailscale、ZeroTier 或固定 IP allowlist。"],commandsTitle:"当前命令",commandsBody:"产品方向是跨操作系统使用一条终端命令,而不是先找网站、下载、安装。",managerCommandLabel:"启动 manager",clientCommandLabel:"连接 workstation",slotCommandLabel:"固定到 slot 3",manualCommandLabel:"高级手动连接"}),"zh-TW":Un({languageName:"繁體中文",languageLabel:"文件語言",eyebrow:"LiveDesk Manual",title:"用一行指令開啟本機 Screen Wall",intro:"LiveDesk 是 npm-first 的遠端工作台,用一台 manager PC 監看多台工作站、AI 主機、Mac mini 與開發機。",managerTitle:"1. 執行 manager",managerBody:"在負責看畫面的電腦上執行 LiveDesk manager。它會同時啟動 UI 與本機伺服器,並開啟 http://127.0.0.1:5179。",managerPoints:["指令是 npx -y livedesk。","Screen Wall/API 使用 5179,client 連線使用 5197。","若舊的 LiveDesk 程序占用連接埠,預設會清理後重新啟動。"],clientTitle:"2. 連接 workstation",clientBody:"在被監看的電腦上使用同一個 Google 帳號登入。即使 manager 尚未上線,client 也會持續執行並每 5 秒重試。",clientPoints:["自動放入空位: npx -y livedesk client。","固定到 3 號位置: npx -y livedesk client 3。","大量電腦也能持續等待,不需要反覆登入。"],syncTitle:"3. Sync Server 與自動探索",syncBody:"Sync Server 會把目前 manager 登錄為此帳號的 active Screen Wall。client 登入後讀取 Supabase 記錄並依序嘗試連線候選地址。",syncPoints:["記錄包含 host instance、LAN/private 位址、public 候選、pair token 與短 lease。","優先嘗試 LAN 位址,需要時再嘗試外部位址。","manager 位置、VPN、防火牆或路由設定改變後請按 Sync Server。","livedesk.pages.dev 的 Chrome Local Network Access 不再是預設執行路徑。npm manager app 才是真正伺服器。"],platformTitle:"4. 目前平台狀態",platformBody:"Windows 已確認可傳輸即時畫面。macOS 與 Linux 也沿用相同 npm 指令路徑擴充支援。",platformPoints:["Windows: 已確認可用。","macOS: 畫面擷取與控制需要 Screen Recording/Accessibility 權限。","Linux: 已加入 linux-x64 runtime、grim/gnome-screenshot/import/scrot capture、xdotool input backend。音訊尚未啟用。"],firewallTitle:"防火牆與外部地點",firewallBody:"同一 LAN 通常不需要路由器轉發。不同地點連線時,client 必須能到達 manager 的 client 連線埠。",firewallPoints:["client 連線埠是 TCP 5197。","client 電腦通常只需要對外連線。","跨網路時,請在 manager 防火牆允許 TCP 5197 inbound,並從路由器轉發到 manager PC。","5179 是 manager UI 連接埠,只在需要遠端瀏覽器直接打開 Wall 時才考慮公開。","優先使用 VPN、Tailscale、ZeroTier 或固定 IP allowlist。"],commandsTitle:"目前指令",commandsBody:"產品方向是跨作業系統用一行 terminal 指令,而不是先找網站、下載、安裝。",managerCommandLabel:"啟動 manager",clientCommandLabel:"連接 workstation",slotCommandLabel:"固定到 slot 3",manualCommandLabel:"進階手動連線"}),es:Un({languageName:"Español",languageLabel:"Idioma del documento",eyebrow:"LiveDesk Manual",title:"Abre un Screen Wall local con un comando",intro:"LiveDesk es una consola npm-first para vigilar muchas estaciones, cajas de IA, Mac mini y equipos de desarrollo desde un PC manager.",managerTitle:"1. Ejecuta el manager",managerBody:"Ejecuta LiveDesk en el equipo que verá las pantallas. El manager inicia la UI y el servidor local juntos y abre http://127.0.0.1:5179.",managerPoints:["El comando es npx -y livedesk.","El manager usa 5179 para Screen Wall/API y 5197 para conexiones client.","Si un proceso antiguo ocupa los puertos, el arranque lo limpia por defecto."],clientTitle:"2. Conecta una workstation",clientBody:"En cada equipo monitoreado, inicia sesión con la misma cuenta Google. Si el manager aún no está activo, el client sigue intentando cada 5 segundos.",clientPoints:["Usa npx -y livedesk client para el primer slot libre.","Usa npx -y livedesk client 3 para fijar el equipo al slot 3.","Los clients siguen esperando para no repetir login en muchas máquinas."],syncTitle:"3. Sync Server y descubrimiento",syncBody:"Sync Server publica este manager como Screen Wall activo para la cuenta. Los clients leen el registro en Supabase y prueban los endpoints.",syncPoints:["Incluye host instance, direcciones LAN/private, candidatos public, pair token y lease corto.","Primero se prueban candidatos LAN, luego públicos si hace falta.","Pulsa Sync Server después de cambios de manager, VPN, firewall o router.","Chrome Local Network Access en livedesk.pages.dev ya no es el flujo principal. La app npm manager es el servidor real."],platformTitle:"4. Estado de plataformas",platformBody:"Windows ya fue verificado con transferencia de pantalla. macOS y Linux siguen el mismo camino npm.",platformPoints:["Windows: verificado.","macOS: captura y control requieren permisos Screen Recording/Accessibility.","Linux: agregado linux-x64 runtime, captura grim/gnome-screenshot/import/scrot y entrada xdotool. Audio aún desactivado."],firewallTitle:"Firewall y sedes remotas",firewallBody:"En la misma LAN normalmente no hace falta port forwarding. Para otra red, los clients deben llegar al puerto client del manager.",firewallPoints:["Puerto de conexión client: TCP 5197.","Los equipos client normalmente solo necesitan salida.","Para redes remotas, permite TCP 5197 inbound en el manager y reenvía TCP 5197 al PC manager.","El puerto 5179 es para la UI del manager; expónlo solo si un navegador remoto debe abrir el Wall.","Prefiere VPN, Tailscale, ZeroTier o allowlist de IP fijas."],commandsTitle:"Comandos actuales",commandsBody:"La dirección del producto es un comando de terminal común entre sistemas, no descargar e instalar desde una web.",managerCommandLabel:"Iniciar manager",clientCommandLabel:"Conectar workstation",slotCommandLabel:"Fijar al slot 3",manualCommandLabel:"Conexión manual avanzada"}),fr:Un({languageName:"Français",languageLabel:"Langue du document",eyebrow:"LiveDesk Manual",title:"Ouvrir un Screen Wall local en une commande",intro:"LiveDesk est un deck npm-first pour surveiller plusieurs postes, machines IA, Mac mini et machines dev depuis un PC manager.",managerTitle:"1. Lancer le manager",managerBody:"Lancez LiveDesk sur l’ordinateur qui observe les écrans. Le manager démarre l’UI et le serveur local, puis ouvre http://127.0.0.1:5179.",managerPoints:["La commande est npx -y livedesk.","Le manager utilise 5179 pour Screen Wall/API et 5197 pour les connexions client.","Si un ancien processus utilise les ports, le démarrage le nettoie par défaut."],clientTitle:"2. Connecter une workstation",clientBody:"Sur chaque ordinateur surveillé, connectez-vous avec le même compte Google. Si le manager n’est pas encore actif, le client réessaie toutes les 5 secondes.",clientPoints:["Utilisez npx -y livedesk client pour le premier slot libre.","Utilisez npx -y livedesk client 3 pour fixer la machine au slot 3.","Les clients continuent d’attendre pour éviter les reconnexions répétées."],syncTitle:"3. Sync Server et découverte",syncBody:"Sync Server publie ce manager comme Screen Wall actif du compte. Les clients lisent l’enregistrement Supabase et testent les endpoints.",syncPoints:["Il contient host instance, adresses LAN/private, candidats public, pair token et lease court.","Les candidats LAN sont essayés en premier, puis les candidats publics si besoin.","Cliquez Sync Server après un changement de manager, VPN, firewall ou routeur.","Chrome Local Network Access sur livedesk.pages.dev n’est plus le chemin par défaut. L’app npm manager est le vrai serveur."],platformTitle:"4. État des plateformes",platformBody:"Windows est vérifié avec transfert d’écran live. macOS et Linux suivent le même chemin npm.",platformPoints:["Windows: vérifié.","macOS: capture et contrôle nécessitent Screen Recording/Accessibility.","Linux: runtime linux-x64, capture grim/gnome-screenshot/import/scrot et entrée xdotool ajoutés. Audio désactivé."],firewallTitle:"Firewall et sites distants",firewallBody:"Sur le même LAN, le port forwarding est rarement nécessaire. Depuis un autre réseau, les clients doivent atteindre le port client du manager.",firewallPoints:["Port de connexion client: TCP 5197.","Les machines client ont normalement seulement besoin de sortie réseau.","Pour un réseau distant, autorisez TCP 5197 entrant sur le manager et redirigez TCP 5197 vers le PC manager.","Le port 5179 sert à l’UI manager; exposez-le seulement si un navigateur distant doit ouvrir le Wall.","Préférez VPN, Tailscale, ZeroTier ou allowlist IP fixes."],commandsTitle:"Commandes actuelles",commandsBody:"La direction produit est une commande terminal commune aux OS, plutôt qu’un téléchargement manuel depuis un site.",managerCommandLabel:"Démarrer manager",clientCommandLabel:"Connecter workstation",slotCommandLabel:"Fixer au slot 3",manualCommandLabel:"Connexion manuelle avancée"}),de:Un({languageName:"Deutsch",languageLabel:"Dokumentsprache",eyebrow:"LiveDesk Manual",title:"Lokale Screen Wall mit einem Befehl öffnen",intro:"LiveDesk ist ein npm-first Arbeitsdeck, um viele Workstations, AI-Boxen, Mac minis und Dev-Rechner von einem Manager-PC zu überwachen.",managerTitle:"1. Manager starten",managerBody:"Starte LiveDesk auf dem Computer, der die Screens sieht. Der Manager startet UI und lokalen Server zusammen und öffnet http://127.0.0.1:5179.",managerPoints:["Der Befehl ist npx -y livedesk.","Der Manager nutzt 5179 für Screen Wall/API und 5197 für Client-Verbindungen.","Wenn alte LiveDesk-Prozesse Ports belegen, werden sie beim Start standardmäßig bereinigt."],clientTitle:"2. Workstation verbinden",clientBody:"Melde dich auf jedem überwachten Computer mit demselben Google-Konto an. Wenn kein Manager online ist, versucht der Client alle 5 Sekunden weiter.",clientPoints:["npx -y livedesk client nutzt den ersten freien Slot.","npx -y livedesk client 3 fixiert den Rechner auf Slot 3.","Clients warten weiter, damit große Setups kein wiederholtes Login brauchen."],syncTitle:"3. Sync Server und Discovery",syncBody:"Sync Server veröffentlicht diesen Manager als aktive Screen Wall des Kontos. Clients lesen den Supabase-Eintrag und testen Endpoints der Reihe nach.",syncPoints:["Enthält host instance, LAN/private Adressen, public Kandidaten, pair token und kurze lease.","LAN-Kandidaten werden zuerst versucht, danach public Kandidaten.","Nach Änderungen an Manager, VPN, Firewall oder Router Sync Server drücken.","Chrome Local Network Access auf livedesk.pages.dev ist nicht mehr der Standardpfad. Die npm Manager App ist der echte Server."],platformTitle:"4. Plattformstatus",platformBody:"Windows wurde mit Live-Screen-Transfer geprüft. macOS und Linux folgen demselben npm-Pfad.",platformPoints:["Windows: verifiziert.","macOS: Capture und Control brauchen Screen Recording/Accessibility Rechte.","Linux: linux-x64 Runtime, grim/gnome-screenshot/import/scrot Capture und xdotool Input Backend sind ergänzt. Audio ist deaktiviert."],firewallTitle:"Firewall und entfernte Standorte",firewallBody:"Im gleichen LAN ist Router-Forwarding meist unnötig. Aus anderen Netzwerken müssen Clients den Client-Port des Managers erreichen.",firewallPoints:["Client-Verbindungsport: TCP 5197.","Client-Rechner brauchen normalerweise nur ausgehenden Zugriff.","Für entfernte Netzwerke TCP 5197 inbound am Manager erlauben und vom Router zum Manager-PC forwarden.","Port 5179 ist für die Manager-UI; nur öffnen, wenn ein Remote-Browser die Wall direkt öffnen muss.","VPN, Tailscale, ZeroTier oder feste IP-Allowlists bevorzugen."],commandsTitle:"Aktuelle Befehle",commandsBody:"Die Produktlinie ist ein Terminalbefehl über Betriebssysteme hinweg, statt Website suchen, herunterladen und installieren.",managerCommandLabel:"Manager starten",clientCommandLabel:"Workstation verbinden",slotCommandLabel:"An Slot 3 fixieren",manualCommandLabel:"Erweiterte manuelle Verbindung"}),"pt-BR":Un({languageName:"Português",languageLabel:"Idioma do documento",eyebrow:"LiveDesk Manual",title:"Abra um Screen Wall local com um comando",intro:"LiveDesk é um deck npm-first para monitorar várias estações, caixas de IA, Mac minis e máquinas dev a partir de um PC manager.",managerTitle:"1. Execute o manager",managerBody:"Rode LiveDesk no computador que verá as telas. O manager inicia a UI e o servidor local juntos e abre http://127.0.0.1:5179.",managerPoints:["O comando é npx -y livedesk.","O manager usa 5179 para Screen Wall/API e 5197 para conexões client.","Se um processo antigo ocupa as portas, a inicialização limpa por padrão."],clientTitle:"2. Conecte uma workstation",clientBody:"Em cada computador monitorado, entre com a mesma conta Google. Se o manager ainda não estiver online, o client tenta a cada 5 segundos.",clientPoints:["Use npx -y livedesk client para o primeiro slot livre.","Use npx -y livedesk client 3 para fixar no slot 3.","Clients continuam tentando para evitar login repetido em muitos PCs."],syncTitle:"3. Sync Server e descoberta",syncBody:"Sync Server publica este manager como Screen Wall ativo da conta. Clients leem o registro no Supabase e testam endpoints.",syncPoints:["Inclui host instance, endereços LAN/private, candidatos public, pair token e lease curto.","Candidatos LAN vêm primeiro; public depois se necessário.","Clique Sync Server após mudanças de manager, VPN, firewall ou roteador.","Chrome Local Network Access em livedesk.pages.dev não é mais o caminho padrão. O app npm manager é o servidor real."],platformTitle:"4. Estado das plataformas",platformBody:"Windows foi verificado com transferência de tela. macOS e Linux seguem o mesmo caminho npm.",platformPoints:["Windows: verificado.","macOS: captura e controle precisam de permissões Screen Recording/Accessibility.","Linux: runtime linux-x64, captura grim/gnome-screenshot/import/scrot e entrada xdotool adicionados. Áudio ainda desativado."],firewallTitle:"Firewall e locais remotos",firewallBody:"Na mesma LAN normalmente não é preciso port forwarding. Em outra rede, clients precisam alcançar a porta client do manager.",firewallPoints:["Porta client: TCP 5197.","Máquinas client normalmente só precisam de saída.","Para redes remotas, permita TCP 5197 inbound no manager e encaminhe TCP 5197 para o PC manager.","A porta 5179 é para a UI do manager; exponha apenas se um navegador remoto precisar abrir o Wall.","Prefira VPN, Tailscale, ZeroTier ou allowlist de IP fixo."],commandsTitle:"Comandos atuais",commandsBody:"A direção do produto é um comando de terminal comum entre sistemas, não baixar e instalar manualmente.",managerCommandLabel:"Iniciar manager",clientCommandLabel:"Conectar workstation",slotCommandLabel:"Fixar no slot 3",manualCommandLabel:"Conexão manual avançada"}),it:Un({languageName:"Italiano",languageLabel:"Lingua documento",eyebrow:"LiveDesk Manual",title:"Apri uno Screen Wall locale con un comando",intro:"LiveDesk è un deck npm-first per monitorare workstation, box AI, Mac mini e macchine dev da un solo PC manager.",managerTitle:"1. Avvia il manager",managerBody:"Esegui LiveDesk sul computer che guarderà gli schermi. Il manager avvia UI e server locale e apre http://127.0.0.1:5179.",managerPoints:["Il comando è npx -y livedesk.","Il manager usa 5179 per Screen Wall/API e 5197 per connessioni client.","Se vecchi processi occupano le porte, l’avvio le pulisce di default."],clientTitle:"2. Connetti una workstation",clientBody:"Su ogni computer monitorato, accedi con lo stesso account Google. Se il manager non è online, il client riprova ogni 5 secondi.",clientPoints:["npx -y livedesk client usa il primo slot libero.","npx -y livedesk client 3 fissa la macchina allo slot 3.","I client continuano a provare per evitare login ripetuti."],syncTitle:"3. Sync Server e discovery",syncBody:"Sync Server pubblica questo manager come Screen Wall attivo dell’account. I client leggono Supabase e provano gli endpoint.",syncPoints:["Include host instance, indirizzi LAN/private, candidati public, pair token e lease breve.","Prima LAN, poi public se necessario.","Premi Sync Server dopo cambi di manager, VPN, firewall o router.","Chrome Local Network Access su livedesk.pages.dev non è più il percorso principale. L’app npm manager è il server reale."],platformTitle:"4. Stato piattaforme",platformBody:"Windows è verificato con trasferimento schermo live. macOS e Linux seguono lo stesso percorso npm.",platformPoints:["Windows: verificato.","macOS: capture e control richiedono permessi Screen Recording/Accessibility.","Linux: aggiunti runtime linux-x64, capture grim/gnome-screenshot/import/scrot e input xdotool. Audio disattivato."],firewallTitle:"Firewall e sedi remote",firewallBody:"Nella stessa LAN di solito non serve port forwarding. Da altre reti, i client devono raggiungere la porta client del manager.",firewallPoints:["Porta client: TCP 5197.","I client normalmente richiedono solo uscita.","Per reti remote, abilita TCP 5197 inbound sul manager e inoltra TCP 5197 al PC manager.","La porta 5179 è per la UI manager; esponila solo se un browser remoto deve aprire il Wall.","Preferisci VPN, Tailscale, ZeroTier o IP allowlist."],commandsTitle:"Comandi attuali",commandsBody:"La direzione è un comando terminale comune tra sistemi operativi, invece di download e install manuale.",managerCommandLabel:"Avvia manager",clientCommandLabel:"Connetti workstation",slotCommandLabel:"Fissa allo slot 3",manualCommandLabel:"Connessione manuale avanzata"}),id:Un({languageName:"Bahasa Indonesia",languageLabel:"Bahasa dokumen",eyebrow:"LiveDesk Manual",title:"Buka Screen Wall lokal dengan satu perintah",intro:"LiveDesk adalah deck npm-first untuk memantau banyak workstation, AI box, Mac mini, dan mesin dev dari satu PC manager.",managerTitle:"1. Jalankan manager",managerBody:"Jalankan LiveDesk di komputer yang melihat layar. Manager membuka UI dan server lokal bersama, lalu membuka http://127.0.0.1:5179.",managerPoints:["Perintahnya npx -y livedesk.","Manager memakai 5179 untuk Screen Wall/API dan 5197 untuk koneksi client.","Jika proses lama memakai port itu, startup membersihkannya secara default."],clientTitle:"2. Hubungkan workstation",clientBody:"Di komputer yang dipantau, masuk dengan akun Google yang sama. Jika manager belum online, client tetap mencoba tiap 5 detik.",clientPoints:["npx -y livedesk client memakai slot kosong pertama.","npx -y livedesk client 3 mengunci mesin ke slot 3.","Client terus mencoba agar banyak PC tidak perlu login berulang."],syncTitle:"3. Sync Server dan discovery",syncBody:"Sync Server menerbitkan manager ini sebagai Screen Wall aktif untuk akun. Client membaca Supabase dan mencoba endpoint.",syncPoints:["Berisi host instance, alamat LAN/private, kandidat public, pair token, dan lease pendek.","Kandidat LAN dicoba lebih dulu, lalu public jika perlu.","Tekan Sync Server setelah perubahan manager, VPN, firewall, atau router.","Chrome Local Network Access di livedesk.pages.dev bukan jalur utama lagi. App npm manager adalah server sebenarnya."],platformTitle:"4. Status platform",platformBody:"Windows sudah diverifikasi dengan live screen transfer. macOS dan Linux mengikuti jalur npm yang sama.",platformPoints:["Windows: terverifikasi.","macOS: capture dan control perlu izin Screen Recording/Accessibility.","Linux: runtime linux-x64, capture grim/gnome-screenshot/import/scrot, dan input xdotool sudah ditambahkan. Audio belum aktif."],firewallTitle:"Firewall dan lokasi luar",firewallBody:"Di LAN yang sama biasanya tidak perlu port forwarding. Dari jaringan lain, client harus mencapai port client manager.",firewallPoints:["Port client: TCP 5197.","Mesin client biasanya hanya perlu akses keluar.","Untuk jaringan luar, izinkan TCP 5197 inbound di manager dan forward TCP 5197 ke PC manager.","Port 5179 untuk UI manager; buka hanya jika browser luar harus membuka Wall.","Utamakan VPN, Tailscale, ZeroTier, atau IP allowlist."],commandsTitle:"Perintah saat ini",commandsBody:"Arah produk adalah satu perintah terminal lintas OS, bukan download dan instal manual.",managerCommandLabel:"Mulai manager",clientCommandLabel:"Hubungkan workstation",slotCommandLabel:"Kunci ke slot 3",manualCommandLabel:"Koneksi manual lanjutan"}),vi:Un({languageName:"Tiếng Việt",languageLabel:"Ngôn ngữ tài liệu",eyebrow:"LiveDesk Manual",title:"Mở Screen Wall cục bộ bằng một lệnh",intro:"LiveDesk là deck npm-first để giám sát nhiều workstation, máy AI, Mac mini và máy dev từ một PC manager.",managerTitle:"1. Chạy manager",managerBody:"Chạy LiveDesk trên máy dùng để xem màn hình. Manager khởi động UI và server cục bộ cùng lúc, rồi mở http://127.0.0.1:5179.",managerPoints:["Lệnh là npx -y livedesk.","Manager dùng 5179 cho Screen Wall/API và 5197 cho kết nối client.","Nếu tiến trình cũ giữ port, startup mặc định sẽ dọn và khởi động lại."],clientTitle:"2. Kết nối workstation",clientBody:"Trên mỗi máy được giám sát, đăng nhập cùng tài khoản Google. Nếu manager chưa online, client tiếp tục thử mỗi 5 giây.",clientPoints:["npx -y livedesk client dùng slot trống đầu tiên.","npx -y livedesk client 3 ghim máy vào slot 3.","Client tiếp tục chờ để nhiều máy không cần đăng nhập lại."],syncTitle:"3. Sync Server và tự phát hiện",syncBody:"Sync Server đăng manager này là Screen Wall đang hoạt động của tài khoản. Client đọc Supabase và thử các endpoint.",syncPoints:["Bao gồm host instance, địa chỉ LAN/private, public candidate, pair token và lease ngắn.","Ưu tiên LAN trước, sau đó thử public nếu cần.","Bấm Sync Server sau thay đổi manager, VPN, firewall hoặc router.","Chrome Local Network Access trên livedesk.pages.dev không còn là đường chạy chính. App npm manager mới là server thật."],platformTitle:"4. Trạng thái nền tảng",platformBody:"Windows đã được kiểm chứng với truyền màn hình live. macOS và Linux đi theo cùng đường npm.",platformPoints:["Windows: đã kiểm chứng.","macOS: capture và control cần quyền Screen Recording/Accessibility.","Linux: đã thêm runtime linux-x64, capture grim/gnome-screenshot/import/scrot và input xdotool. Audio chưa bật."],firewallTitle:"Firewall và địa điểm ngoài",firewallBody:"Trong cùng LAN thường không cần port forwarding. Từ mạng khác, client phải truy cập được port client của manager.",firewallPoints:["Port client: TCP 5197.","Máy client thường chỉ cần kết nối outbound.","Với mạng ngoài, cho phép TCP 5197 inbound trên manager và forward TCP 5197 tới PC manager.","Port 5179 dành cho UI manager; chỉ mở nếu trình duyệt từ xa cần mở Wall trực tiếp.","Ưu tiên VPN, Tailscale, ZeroTier hoặc allowlist IP cố định."],commandsTitle:"Lệnh hiện tại",commandsBody:"Hướng sản phẩm là một lệnh terminal dùng chung giữa các OS, thay vì tải và cài thủ công.",managerCommandLabel:"Khởi động manager",clientCommandLabel:"Kết nối workstation",slotCommandLabel:"Ghim vào slot 3",manualCommandLabel:"Kết nối thủ công nâng cao"}),th:Un({languageName:"ไทย",languageLabel:"ภาษาของเอกสาร",eyebrow:"LiveDesk Manual",title:"เปิด Screen Wall ภายในด้วยคำสั่งเดียว",intro:"LiveDesk คือ deck แบบ npm-first สำหรับดู workstation, กล่อง AI, Mac mini และเครื่อง dev หลายเครื่องจาก manager PC เครื่องเดียว",managerTitle:"1. รัน manager",managerBody:"รัน LiveDesk บนเครื่องที่ใช้ดูหน้าจอ Manager จะเปิด UI และ local server พร้อมกัน แล้วเปิด http://127.0.0.1:5179",managerPoints:["คำสั่งคือ npx -y livedesk","Manager ใช้ 5179 สำหรับ Screen Wall/API และ 5197 สำหรับ client connection","ถ้า process เก่ายังใช้ port อยู่ startup จะล้างให้โดย default"],clientTitle:"2. เชื่อม workstation",clientBody:"บนเครื่องที่ต้อง monitor ให้ login ด้วย Google account เดียวกัน ถ้า manager ยังไม่ออนไลน์ client จะลองใหม่ทุก 5 วินาที",clientPoints:["npx -y livedesk client จะใช้ slot ว่างแรก","npx -y livedesk client 3 จะตรึงเครื่องไว้ที่ slot 3","Client จะรอต่อเนื่องเพื่อไม่ต้อง login ซ้ำเมื่อมีหลายเครื่อง"],syncTitle:"3. Sync Server และ discovery",syncBody:"Sync Server จะ publish manager นี้เป็น active Screen Wall ของ account แล้ว client อ่านข้อมูลจาก Supabase และลอง endpoint ต่างๆ",syncPoints:["มี host instance, LAN/private address, public candidate, pair token และ short lease","ลอง LAN ก่อน แล้วค่อยลอง public ถ้าจำเป็น","กด Sync Server หลังเปลี่ยน manager, VPN, firewall หรือ router","Chrome Local Network Access บน livedesk.pages.dev ไม่ใช่ runtime หลักแล้ว app npm manager คือ server จริง"],platformTitle:"4. สถานะ platform",platformBody:"Windows ตรวจสอบแล้วว่าส่งภาพ live ได้ macOS และ Linux ใช้เส้นทาง npm เดียวกัน",platformPoints:["Windows: verified","macOS: capture/control ต้องใช้สิทธิ์ Screen Recording/Accessibility","Linux: เพิ่ม linux-x64 runtime, grim/gnome-screenshot/import/scrot capture และ xdotool input แล้ว audio ยังปิดอยู่"],firewallTitle:"Firewall และเครื่องต่างสถานที่",firewallBody:"ใน LAN เดียวกันปกติไม่ต้อง port forwarding ถ้าอยู่คนละ network client ต้องเข้าถึง client port ของ manager ได้",firewallPoints:["Client port คือ TCP 5197","เครื่อง client ปกติต้องการ outbound เท่านั้น","ถ้าอยู่นอก network ให้เปิด TCP 5197 inbound ที่ manager และ forward TCP 5197 ไปยัง manager PC","Port 5179 เป็น UI ของ manager เปิดเฉพาะเมื่อ browser ระยะไกลต้องเปิด Wall โดยตรง","ควรใช้ VPN, Tailscale, ZeroTier หรือ IP allowlist ก่อนเปิดสู่ public internet"],commandsTitle:"คำสั่งปัจจุบัน",commandsBody:"ทิศทาง product คือคำสั่ง terminal เดียวข้าม OS ไม่ใช่ download/install จากเว็บไซต์",managerCommandLabel:"เริ่ม manager",clientCommandLabel:"เชื่อม workstation",slotCommandLabel:"ตรึง slot 3",manualCommandLabel:"manual connection ขั้นสูง"}),hi:Un({languageName:"हिन्दी",languageLabel:"दस्तावेज़ भाषा",eyebrow:"LiveDesk Manual",title:"एक कमांड से local Screen Wall खोलें",intro:"LiveDesk एक npm-first remote work deck है जिससे एक manager PC से कई workstation, AI box, Mac mini और dev machines देखे जा सकते हैं।",managerTitle:"1. manager चलाएं",managerBody:"जिस computer से screens देखनी हैं उस पर LiveDesk manager चलाएं। यह UI और local server साथ में शुरू करता है और http://127.0.0.1:5179 खोलता है।",managerPoints:["कमांड है npx -y livedesk।","Manager Screen Wall/API के लिए 5179 और client connections के लिए 5197 इस्तेमाल करता है।","अगर पुराने LiveDesk ports बचे हों तो startup default रूप से साफ करता है।"],clientTitle:"2. workstation जोड़ें",clientBody:"हर monitored computer पर उसी Google account से sign in करें। Manager online न हो तब भी client बंद नहीं होता और हर 5 सेकंड retry करता है।",clientPoints:["npx -y livedesk client पहला खाली slot लेता है।","npx -y livedesk client 3 machine को slot 3 पर pin करता है।","बहुत सी machines हों तब भी बार-बार login की जरूरत नहीं रहती।"],syncTitle:"3. Sync Server और discovery",syncBody:"Sync Server इस manager को account का active Screen Wall बनाकर Supabase में publish करता है। Clients record पढ़कर endpoints try करते हैं।",syncPoints:["इसमें host instance, LAN/private addresses, public candidates, pair token और short lease होता है।","LAN candidates पहले try होते हैं, जरूरत हो तो public candidates।","Manager, VPN, firewall या router बदलने के बाद Sync Server दबाएं।","livedesk.pages.dev का Chrome Local Network Access अब default runtime नहीं है। npm manager app ही real server है।"],platformTitle:"4. Platform status",platformBody:"Windows live screen transfer के साथ verified है। macOS और Linux भी इसी npm path पर आगे बढ़ रहे हैं।",platformPoints:["Windows: verified.","macOS: capture/control के लिए Screen Recording/Accessibility permissions चाहिए।","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot capture और xdotool input backend जोड़े गए हैं। Audio अभी disabled है।"],firewallTitle:"Firewall और remote locations",firewallBody:"Same LAN में आम तौर पर router forwarding जरूरी नहीं। दूसरे network से clients को manager client port तक पहुंचना होगा।",firewallPoints:["Client connection port: TCP 5197.","Client machines को आम तौर पर सिर्फ outbound access चाहिए।","Remote network के लिए manager firewall में TCP 5197 inbound allow करें और router से TCP 5197 manager PC पर forward करें।","5179 manager UI port है; इसे तभी expose करें जब remote browser को Wall खोलना हो।","Public internet से पहले VPN, Tailscale, ZeroTier या fixed IP allowlist बेहतर है।"],commandsTitle:"Current commands",commandsBody:"Product direction है OS के बीच एक terminal command, website से download/install नहीं।",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),ar:Un({languageName:"العربية",languageLabel:"لغة المستند",eyebrow:"LiveDesk Manual",title:"افتح Screen Wall محلي بأمر واحد",intro:"LiveDesk هو deck بنمط npm-first لمراقبة عدة workstations وأجهزة AI وMac mini وأجهزة تطوير من كمبيوتر manager واحد.",managerTitle:"1. شغل manager",managerBody:"شغل LiveDesk على الكمبيوتر الذي سيعرض الشاشات. يبدأ manager الواجهة والخادم المحلي معا ويفتح http://127.0.0.1:5179.",managerPoints:["الأمر هو npx -y livedesk.","يستخدم manager المنفذ 5179 للواجهة/API والمنفذ 5197 لاتصالات client.","إذا بقيت عملية LiveDesk قديمة على المنافذ، يتم تنظيفها افتراضيا عند التشغيل."],clientTitle:"2. وصل workstation",clientBody:"على كل كمبيوتر تتم مراقبته، سجل الدخول بنفس حساب Google. إذا لم يكن manager متاحا، يبقى client يعمل ويحاول كل 5 ثوان.",clientPoints:["npx -y livedesk client يختار أول slot فارغ.","npx -y livedesk client 3 يثبت الجهاز في slot 3.","clients تستمر بالمحاولة لتجنب تكرار تسجيل الدخول عند كثرة الأجهزة."],syncTitle:"3. Sync Server والاكتشاف",syncBody:"Sync Server ينشر هذا manager كـ active Screen Wall للحساب. يقرأ clients سجل Supabase ويجربون endpoints بالترتيب.",syncPoints:["السجل يتضمن host instance وعناوين LAN/private وpublic candidates وpair token وlease قصير.","يتم تفضيل LAN أولا، ثم public عند الحاجة.","اضغط Sync Server بعد تغيير manager أو VPN أو firewall أو router.","Chrome Local Network Access على livedesk.pages.dev لم يعد مسار التشغيل الافتراضي. تطبيق npm manager هو الخادم الحقيقي."],platformTitle:"4. حالة المنصات",platformBody:"Windows تم التحقق منه مع نقل شاشة live. macOS وLinux يتبعان نفس مسار npm.",platformPoints:["Windows: تم التحقق.","macOS: capture/control يحتاجان أذونات Screen Recording/Accessibility.","Linux: تمت إضافة linux-x64 runtime وgrim/gnome-screenshot/import/scrot capture وxdotool input. الصوت ما زال معطلا."],firewallTitle:"Firewall والمواقع البعيدة",firewallBody:"داخل نفس LAN غالبا لا تحتاج port forwarding. من شبكة أخرى يجب أن يصل client إلى منفذ manager client.",firewallPoints:["منفذ client: TCP 5197.","أجهزة client تحتاج عادة اتصال outbound فقط.","للشبكات البعيدة، اسمح TCP 5197 inbound على manager ووجه TCP 5197 من router إلى manager PC.","المنفذ 5179 مخصص لواجهة manager؛ اكشفه فقط إذا كان متصفح بعيد يحتاج فتح Wall مباشرة.","يفضل VPN أو Tailscale أو ZeroTier أو fixed IP allowlist بدل التعريض العام."],commandsTitle:"الأوامر الحالية",commandsBody:"اتجاه المنتج هو أمر terminal واحد عبر الأنظمة، وليس تحميل وتثبيت يدوي من موقع.",managerCommandLabel:"Start manager",clientCommandLabel:"Connect workstation",slotCommandLabel:"Pin to slot 3",manualCommandLabel:"Advanced manual connection"}),tr:Un({languageName:"Türkçe",languageLabel:"Belge dili",eyebrow:"LiveDesk Manual",title:"Yerel Screen Wall tek komutla açılsın",intro:"LiveDesk, tek bir manager PC üzerinden birçok workstation, AI box, Mac mini ve dev machine izlemek için npm-first bir çalışma deckidir.",managerTitle:"1. Manager çalıştır",managerBody:"Ekranları izleyecek bilgisayarda LiveDesk manager çalıştır. Manager UI ve local server birlikte başlar ve http://127.0.0.1:5179 açılır.",managerPoints:["Komut: npx -y livedesk.","Manager Screen Wall/API için 5179, client bağlantıları için 5197 kullanır.","Eski LiveDesk process portları tutuyorsa başlangıç varsayılan olarak temizler."],clientTitle:"2. Workstation bağla",clientBody:"İzlenecek bilgisayarda aynı Google hesabıyla giriş yap. Manager henüz online değilse client kapanmaz ve her 5 saniyede tekrar dener.",clientPoints:["npx -y livedesk client ilk boş slota yerleşir.","npx -y livedesk client 3 makineyi slot 3’e sabitler.","Çok makinede tekrar tekrar login gerekmesin diye client beklemeye devam eder."],syncTitle:"3. Sync Server ve discovery",syncBody:"Sync Server bu managerı hesabın active Screen Wall kaydı olarak Supabase’e yazar. Clients bu kaydı okuyup endpoint adaylarını dener.",syncPoints:["Host instance, LAN/private adresler, public adaylar, pair token ve kısa lease içerir.","Önce LAN adayları, gerekirse public adaylar denenir.","Manager, VPN, firewall veya router değişince Sync Server’a bas.","livedesk.pages.dev üzerindeki Chrome Local Network Access artık default runtime yolu değil. Gerçek server npm manager app."],platformTitle:"4. Platform durumu",platformBody:"Windows live screen transfer ile doğrulandı. macOS ve Linux aynı npm yolunu takip ediyor.",platformPoints:["Windows: doğrulandı.","macOS: capture/control için Screen Recording/Accessibility izinleri gerekir.","Linux: linux-x64 runtime, grim/gnome-screenshot/import/scrot capture ve xdotool input backend eklendi. Audio kapalı."],firewallTitle:"Firewall ve uzak konumlar",firewallBody:"Aynı LAN içinde genelde router forwarding gerekmez. Başka ağdan clients manager client portuna ulaşabilmelidir.",firewallPoints:["Client port: TCP 5197.","Client makineler normalde sadece outbound erişim ister.","Uzak ağ için manager firewall üzerinde TCP 5197 inbound aç ve routerdan TCP 5197yi manager PCye forward et.","5179 manager UI portudur; sadece uzak browser Wall açacaksa expose et.","Public internet yerine VPN, Tailscale, ZeroTier veya sabit IP allowlist tercih et."],commandsTitle:"Güncel komutlar",commandsBody:"Ürün yönü, webden indirip kurmak yerine işletim sistemleri arasında ortak tek terminal komutu.",managerCommandLabel:"Manager başlat",clientCommandLabel:"Workstation bağla",slotCommandLabel:"Slot 3’e sabitle",manualCommandLabel:"Gelişmiş manuel bağlantı"})},_A=Object.entries(Wr).map(([n,a])=>({id:n,label:a.languageName}));function zA(){if(typeof navigator>"u")return"en";const n=navigator.languages?.length?navigator.languages:[navigator.language];for(const a of n){const i=a.toLowerCase();if(Wr[a])return a;if(i.startsWith("zh-tw")||i.startsWith("zh-hk"))return"zh-TW";if(i.startsWith("pt"))return"pt-BR";const r=i.split("-")[0];if(Wr[r])return r}return"en"}function ay({index:n}){const a=n+1;return l.jsx("article",{className:"device-tile placeholder-tile","aria-label":`Empty slot ${a}`,children:l.jsxs("div",{className:"tile-screen","aria-hidden":"true",children:[l.jsx("span",{className:"slot-grid","aria-hidden":"true"}),l.jsxs("span",{className:"empty-screen",children:[l.jsx(an,{size:24}),l.jsxs("strong",{children:["Slot ",String(a).padStart(3,"0")]})]})]})})}function Km({device:n,frame:a,selected:i,controlEnabled:r,showStatus:c,monitorIndex:d,monitorCount:h,onSelect:p,onFocusDevice:v,onOpenControl:g,onCycleMonitor:w,onCanvasReady:y,sendInput:b,updateIndicator:j,presentationReady:k,showPresentationSpinner:M=!1}){const R=f.useRef(null),C=f.useRef(null),A=f.useRef(0),E=f.useRef(null),U=Nw(n),F=["cpu","gpu","memory","vram"].map(D=>U.metrics.find(J=>J.id===D)).filter(D=>!!D),P=Zn(d,h),L=h>1,I=k??!!a,de=M&&n.connected&&!I,W=mA(n,a,P),ue=W>=ed?100:W/ed*100,Z=W>=ed?ed/W*100:100,le={"--screen-aspect":W.toFixed(5),"--screen-content-width":`${Math.max(1,Math.min(100,ue)).toFixed(3)}%`,"--screen-content-height":`${Math.max(1,Math.min(100,Z)).toFixed(3)}%`},ce=f.useCallback(D=>{R.current=D,y(n.deviceId,D)},[n.deviceId,y]),Q=D=>{const J=D.currentTarget.getBoundingClientRect();return{normalizedX:Math.max(0,Math.min(1,(D.clientX-J.left)/Math.max(1,J.width))),normalizedY:Math.max(0,Math.min(1,(D.clientY-J.top)/Math.max(1,J.height)))}},_=D=>({shiftKey:D.shiftKey,ctrlKey:D.ctrlKey,altKey:D.altKey,metaKey:D.metaKey}),Y=f.useCallback(()=>{E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null)},[]),$=f.useCallback(()=>{const D=C.current;if(!D)return;C.current=null;const J=Number(D.input.normalizedX),he=Number(D.input.normalizedY);if(!Number.isFinite(J)||!Number.isFinite(he))return;b(n.deviceId,{...D.input,normalizedX:J,normalizedY:he})&&(A.current=performance.now())},[n.deviceId,b]),H=f.useCallback(()=>{E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null,$()}))},[$]);f.useEffect(()=>()=>{Y(),C.current=null},[Y]);const ie=(D,J)=>{if(!r)return;const he={type:J,monitorIndex:P,...Q(D),button:kA(D.button),..._(D)};if(J==="pointermove"){const we=performance.now();C.current={input:he},we-A.current>=BM&&(Y(),$()),H();return}C.current&&(Y(),$()),b(n.deviceId,he)},xe=f.useCallback(D=>{const J=document.activeElement;J instanceof HTMLElement&&D.contains(J)&&J.classList.contains("monitor-cycle-button")&&J.blur()},[]);return l.jsx("article",{className:`device-tile ${i?"selected":""} ${n.connected?"online":"offline"}`,"data-live-device-id":n.deviceId,style:le,children:l.jsxs("div",{className:`tile-screen ${I?"has-frame":"is-empty"}`,role:"button",tabIndex:r?-1:0,"aria-pressed":i,onClick:D=>{D.target instanceof Element&&D.target.closest(".monitor-cycle")||r||p()},onKeyDown:D=>{D.target instanceof Element&&D.target.closest(".monitor-cycle")||r||(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),p())},onDoubleClick:D=>{D.target instanceof Element&&D.target.closest(".monitor-cycle")||(D.preventDefault(),g())},onPointerLeave:D=>xe(D.currentTarget),children:[l.jsx("span",{className:`screen-content ${I?"has-frame":"is-empty"}`,children:l.jsx("canvas",{ref:ce,className:`remote-canvas ${I?"has-frame":"is-empty"}`,tabIndex:r?0:-1,onPointerDown:D=>{r&&(D.preventDefault(),D.stopPropagation(),v(),D.currentTarget.focus(),D.currentTarget.setPointerCapture(D.pointerId),ie(D,"pointerdown"))},onPointerMove:D=>{r&&D.preventDefault(),ie(D,"pointermove")},onPointerUp:D=>{r&&(D.preventDefault(),D.stopPropagation(),ie(D,"pointerup"),D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId))},onPointerCancel:D=>{D.currentTarget.hasPointerCapture(D.pointerId)&&D.currentTarget.releasePointerCapture(D.pointerId)},onWheel:D=>{r&&(D.preventDefault(),b(n.deviceId,{type:"wheel",monitorIndex:P,...Q(D),deltaX:D.deltaX,deltaY:D.deltaY,..._(D)}))},onKeyDown:D=>{r&&(D.preventDefault(),D.stopPropagation(),b(n.deviceId,{type:"keydown",monitorIndex:P,key:D.key,code:D.code,keyCode:D.keyCode||D.which||0,location:D.location,text:D.key.length===1?D.key:"",repeat:D.repeat,..._(D)}))},onKeyUp:D=>{r&&(D.preventDefault(),D.stopPropagation(),b(n.deviceId,{type:"keyup",monitorIndex:P,key:D.key,code:D.code,keyCode:D.keyCode||D.which||0,location:D.location,text:D.key.length===1?D.key:"",repeat:!1,..._(D)}))},onContextMenu:D=>r&&D.preventDefault()})}),!I&&l.jsx("span",{className:"empty-screen",children:l.jsx(an,{size:26})}),de&&l.jsxs("span",{className:"wall-presentation-loading",role:"status","aria-live":"polite",children:[l.jsx("span",{className:"wall-presentation-spinner","aria-hidden":"true"}),l.jsx("strong",{children:"Preparing video"})]}),j&&l.jsxs("span",{className:`wall-update-status ${j==="updated"?"updated":""}`,role:"status","aria-live":"polite",children:[j==="updating"?l.jsx("span",{className:"wall-update-spinner","aria-hidden":"true"}):l.jsx(Gn,{size:20,"aria-hidden":"true"}),l.jsx("strong",{children:j==="updating"?"Updating...":"Updated"})]}),c&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:`tile-health-pill state-${U.state}`,children:U.label}),l.jsx("span",{className:"tile-metrics","aria-label":`${Gi(n)} status`,children:F.map(D=>l.jsxs("span",{className:`tile-metric state-${D.state}`,children:[l.jsx("b",{children:D.label}),l.jsx("em",{children:D.value}),D.ratio!==void 0&&l.jsx("i",{style:{width:`${Math.round(D.ratio*100)}%`}})]},D.id))})]}),L&&l.jsxs("span",{className:"monitor-cycle","aria-label":`${Gi(n)} display ${P+1} of ${h}`,onPointerDown:D=>D.stopPropagation(),onClick:D=>D.stopPropagation(),onDoubleClick:D=>D.stopPropagation(),children:[l.jsx("button",{className:"monitor-cycle-button previous",onClick:D=>{D.preventDefault(),D.stopPropagation(),w(-1),D.currentTarget.blur()},title:"Previous display",type:"button",children:l.jsx(uy,{size:18})}),l.jsxs("span",{className:"monitor-cycle-count",children:["Screen ",P+1,"/",h]}),l.jsx("button",{className:"monitor-cycle-button next",onClick:D=>{D.preventDefault(),D.stopPropagation(),w(1),D.currentTarget.blur()},title:"Next display",type:"button",children:l.jsx(bh,{size:18})})]}),i&&l.jsx("span",{className:"device-selection-check","aria-hidden":"true",children:l.jsx(gc,{size:23,strokeWidth:3.5})})]})})}function OA({visible:n}){return f.useEffect(()=>{if(!n||!Fm)return;if(!document.getElementById(Fx)){const i=document.createElement("script");i.id=Fx,i.async=!0,i.crossOrigin="anonymous",i.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${encodeURIComponent(fh)}`,document.head.appendChild(i)}const a=window.setTimeout(()=>{try{window.adsbygoogle=window.adsbygoogle||[],window.adsbygoogle.push({})}catch{}},120);return()=>window.clearTimeout(a)},[n]),n?l.jsxs("aside",{className:`free-ad-banner ${Fm?"adsense-ready":"house-ad"}`,"aria-label":"Advertisement",children:[l.jsx("span",{className:"ad-label",children:"Advertisement"}),Fm?l.jsx("ins",{className:"adsbygoogle livedesk-ad-unit",style:{display:"block"},"data-ad-client":fh,"data-ad-slot":ww,"data-ad-format":"auto","data-full-width-responsive":"true"}):l.jsxs("div",{className:"house-ad-copy",children:[l.jsx("strong",{children:"Sponsored placement"}),l.jsx("span",{children:"Local AI gear, mini PCs, GPUs, NAS, and developer tools."})]})]}):null}function IA(){const n=WM(),{session:a,loading:i}=p0(),{target:r,error:c,refresh:d}=v0(a),h=f.useMemo(()=>{if(!r?.active)return null;const x=r.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY;return Number.isFinite(x)&&x<=Date.now()?null:r},[r]),p=f.useMemo(()=>Gv(h),[h]),v=f.useMemo(()=>p.length>0?[...new Set([...p,Cn])]:[Cn],[p]),[g,w]=f.useState(cA),y=f.useMemo(()=>v.some(x=>!!uc(x)),[v]),b=!y||g,{status:j,devices:k,error:M,refresh:R,hubBaseUrl:C}=g0(v,b),{entitlement:A,licensed:E,loading:U,error:F,refresh:P}=x0(a),[L,I]=f.useState([]),[de,W]=f.useState(""),[ue,Z]=f.useState(""),[le,ce]=f.useState(""),[Q,_]=f.useState(""),[Y,$]=f.useState(""),[H,ie]=f.useState("idle"),[xe,D]=f.useState(!1),[J,he]=f.useState(""),we=f.useRef("");we.current=Q;const[je,Oe]=f.useState(!1),[He,oe]=f.useState(!1),Ze=f.useRef(""),De=f.useRef(new Map),at=f.useRef(0),[ne,pe]=f.useState(""),[Me,V]=f.useState(""),[ae,ke]=f.useState("wall"),[be,st]=f.useState("large"),[It,Ae]=f.useState(zA),[Ne,Ie]=f.useState(!1),[Pt,An]=f.useState(!1),[Dt,bl]=f.useState(!1),[as,ws]=f.useState(oA),[Re,Sl]=f.useState(gA),[Ye,wt]=f.useState(xA),[ut,Wt]=f.useState(hA),[Jn,Gs]=f.useState(null),[fi,La]=f.useState([]),[Nt,zn]=f.useState(Re.fps),[ea,_a]=f.useState(""),[Vs,Zr]=f.useState(0),[mi,Ys]=f.useState(()=>new Set),hn=f.useRef(new Map),za=f.useRef(new Map),Nn=f.useRef(new Map),xa=f.useRef(new Map),ya=f.useRef(new Set),ss=f.useRef(new Map),Oa=f.useRef(0),ta=f.useRef(""),bs=f.useRef(""),Tn=f.useRef(null),X=f.useRef(new Map),Se=f.useRef(null),_e=f.useRef(0),We=f.useRef(new Map),[Tt,jt]=f.useState({}),$e=f.useRef(new Map),[dt,pn]=f.useState({}),[Kt,Rt]=f.useState(!1),kt=f.useRef(null),vt=f.useRef(null),mt=f.useRef(0),Ia=f.useRef(""),wa=f.useRef(new Map),Bt=f.useRef(new Map),qt=f.useRef(performance.now()),Ws=f.useRef(new Map),ba=f.useRef(new Map),Ba=f.useRef(new Map),Jr=f.useRef(new Map),Ss=f.useRef(0),Ks=f.useRef(0),na=f.useRef(0),Rn=f.useRef(0),Qi=f.useRef(0),jc=f.useRef(new Map),Fa=f.useRef(new Map),[Cs,Sa]=f.useState(null),[Ed,On]=f.useState(!1),[kc,Mc]=f.useState([]),[js,Cl]=f.useState("all"),[Qs,Xi]=f.useState([]),[hi,Uh]=f.useState(!1),[Dd,Ac]=f.useState(!0),Zi=f.useRef(null),Nc=f.useRef(null),Ld=f.useRef(null),Ji=f.useRef(null),ls=f.useRef(!1),pi=f.useRef(!1),er=f.useRef(0),Ha=f.useRef(0),Vn=f.useRef(0),gi=ae==="settings",tr=ae==="pricing",eo=ae==="doc",is=ae==="share-files",Ua=ae==="agents",nr=!gi&&!tr&&!eo&&!is&&!Ua,qe=ae==="control",Qe=Re.frameMode==="mode4-h264-atlas",Yn=Y||Ye.frameMode,jl=Yn!=="mode3-h264-hw"?Math.min(30,Ye.fps):Ye.fps,rs=Yn!=="mode3-h264-hw"?{maxWidth:Math.min(1920,Ye.maxWidth),maxHeight:Math.min(1080,Ye.maxHeight)}:{maxWidth:Ye.maxWidth,maxHeight:Ye.maxHeight};f.useEffect(()=>{if(j?.started){if(!a?.access_token){Be("/api/remote/license",{method:"DELETE"},C).catch(()=>{});return}Be("/api/remote/license/sync",{method:"POST",headers:{Authorization:`Bearer ${a.access_token}`}},C).catch(x=>{console.warn("[LiveDesk] Hub license sync failed",x)})}},[A?.updated_at,C,a?.access_token,j?.started]);const Ke=f.useMemo(()=>k.filter(x=>x.connected),[k]),vi=js==="all"?Ke.length:Qs.filter(x=>Ke.some(T=>T.deviceId===x)).length,Tc=f.useMemo(()=>Ke.reduce((x,T)=>Math.max(x,ny(T.slotNumber)),0),[Ke]),cn=Math.max(zM,Ke.length,Tc),Ca=f.useMemo(()=>{const x=Array(cn).fill(null),T=[];for(const z of Ke){const q=ny(z.slotNumber);q>0&&q<=cn&&!x[q-1]?x[q-1]=z:T.push(z)}for(const z of T){const q=x.findIndex(O=>!O);q<0?x.push(z):x[q]=z}return x},[Ke]),kl=f.useMemo(()=>Ke.map(x=>x.deviceId),[Ke]),$a=f.useMemo(()=>new Set(L),[L]),ja=f.useMemo(()=>Ke.filter(x=>$a.has(x.deviceId)),[Ke,$a]),ks=f.useMemo(()=>k.find(x=>x.deviceId===de)||ja[0]||null,[k,de,ja]),un=f.useMemo(()=>k.find(x=>x.deviceId===ue)||null,[ue,k]),Ms=un?Zn(ut[un.deviceId],Pn(un)):0,Te=qe?un:ks,to=f.useMemo(()=>new Set(Qs),[Qs]),_d=f.useMemo(()=>js==="all"?Ke.map(x=>x.deviceId):Ke.filter(x=>to.has(x.deviceId)).map(x=>x.deviceId),[Ke,to,js]),Pa=f.useMemo(()=>Te?Nw(Te):null,[Te]),zd=Te?mc(Te,"control"):!1,no=Te?.platform==="macos"&&Te.capabilities?.controlPermission===!1,xi=Te?mc(Te,"audio")||mc(Te,"remoteAudio"):!1,Et=E?A?.plan==="pro"?"pro":"ltd":"free",Rc=Hi[Et],ar=Rc.limit,Xs=f.useMemo(()=>{if(!Number.isFinite(ar))return new Set(Ke.map(T=>T.deviceId));const x=Te?[Te,...Ke.filter(T=>T.deviceId!==Te.deviceId)]:Ke;return new Set(x.slice(0,ar).map(T=>T.deviceId))},[ar,Ke,Te]),Ec=!Te||Xs.has(Te.deviceId),Od=Et==="free",Qt=Ec,Ml=Et==="ltd"?`Plus includes up to ${ac} workstations. Upgrade to Pro for commercial use and larger walls.`:`Free includes up to ${nc} workstations. Upgrade to Plus for ${ac} devices and no ads.`,Id=Et==="free",sr=Qt&&!!Te,os=Qt&&!!Te&&zd,Dc=Qt&&!!Te&&xi,lr=f.useMemo(()=>Ca.filter(x=>!!x?.connected).slice(0,wA(be)).map(x=>x.deviceId),[Ca,be]),As=f.useMemo(()=>Qe?kl:Re.visibleOnlyLive?fi.length>0?fi:lr:kl,[lr,Qe,fi,Re.visibleOnlyLive,kl]),qa=f.useMemo(()=>Gm(As.filter(x=>Xs.has(x))),[Xs,As]),dn=f.useMemo(()=>qa.filter(x=>x!==ea),[qa,ea]);f.useEffect(()=>{const x=new Set(qa);Ys(T=>{let z=!1;const q=new Set;for(const O of T)x.has(O)?q.add(O):z=!0;return z?q:T})},[qa]);const Bd=f.useMemo(()=>{const x=O=>Ke.find(me=>me.deviceId===O)||null,T=O=>Zn(ut[O],x(O)?Pn(x(O)):0),z=(O,me=T(O))=>O===le&&(H==="connecting"||H==="active"||H==="warm")?Nn.current.get(O)||za.current.get(O)||null:Qe?X.current.get(O)||hn.current.get(O)||null:hn.current.get(O)||null,q=(O,me=T(O))=>{const ge=x(O);return`${ge?Gi(ge):O} · Monitor ${me+1}`};return{resolveCurrentTarget(){if(qe&&un){const Pe=Ms;return{type:"control",deviceIds:[un.deviceId],monitorIndex:Pe,label:`${Gi(un)} · Monitor ${Pe+1}`,sourceCanvas:z(un.deviceId,Pe),signature:`control:${un.deviceId}:${Pe}:${Ye.frameMode}`}}const O=ja.map(Pe=>Pe.deviceId).filter(Pe=>dn.includes(Pe)),me=ks&&dn.includes(ks.deviceId)?ks.deviceId:"",ge=O.length>0?O:me?[me]:dn,Ee=O.length===0&&!me;if(ge.length===0)return null;if(ge.length===1){const Pe=ge[0],Ve=T(Pe);return{type:Ee?"wall":O.length>1?"selection":"device",deviceIds:ge,monitorIndex:Ve,label:Ee?"Wall":q(Pe,Ve),sourceCanvas:Ee?null:z(Pe,Ve),signature:`${Ee?"wall":"device"}:${Pe}:${Ve}:${Qe?"atlas":"direct"}`}}return{type:O.length>1?"selection":"wall",deviceIds:ge,label:O.length>1?`${ge.length} selected workstations`:"Wall",sourceCanvas:null,signature:`${O.length>1?"selection":"wall"}:${ge.join(",")}:${be}`}},getDeviceCanvas:z,composeWall(O,me={}){return CM(O.map(ge=>{const Ee=T(ge);return{deviceId:ge,label:q(ge,Ee),canvas:z(ge,Ee)}}),me)}}},[Ke,un,le,H,Ye.frameMode,hn,Qe,ut,Ms,ja,qe,dn,ks,be]),Lc=_M({hubUrl:C,sourceRegistry:Bd,onToast:V}),Al=f.useMemo(()=>Qt&&le&&Xs.has(le)&&(H==="connecting"||H==="active"||H==="warm")?[le]:[],[le,H,Qt,Xs]),Fd=f.useMemo(()=>Gm([...qa,...Al]),[Al,qa]),Xt=f.useMemo(()=>bA(Re,be),[Re,be]),Zs=f.useCallback((x,T)=>{if(x.width<=0||x.height<=0)return!1;(T.width!==x.width||T.height!==x.height)&&(T.width=x.width,T.height=x.height);const z=T.getContext("2d",{alpha:!1});return z?(z.imageSmoothingEnabled=!0,z.imageSmoothingQuality="high",z.drawImage(x,0,0,x.width,x.height,0,0,T.width,T.height),!0):!1},[]),ir=f.useCallback(x=>{x&&Ys(T=>{if(T.has(x))return T;const z=new Set(T);return z.add(x),z})},[]),Nl=f.useCallback(x=>{x&&Ys(T=>{if(!T.has(x))return T;const z=new Set(T);return z.delete(x),z})},[]),Wn=f.useCallback((x,T=!1)=>{if(!ya.current.has(x))return!1;const z=performance.now(),q=ss.current.get(x)||0;if(!T&&z-q<150)return!1;const O=Nn.current.get(x)||za.current.get(x),me=Qe?X.current.get(x):hn.current.get(x);return!O||!me||!Zs(O,me)?!1:(ss.current.set(x,z),ir(x),!0)},[ir,Qe,Zs]);f.useEffect(()=>{ta.current=ea},[ea]);const Hd=f.useCallback((x,T)=>{const z=hn.current.get(x);if(z&&z!==T&&Qo(z),T){hn.current.set(x,T),Wn(x,!0);return}hn.current.delete(x),Nl(x)},[Nl,Wn]),_c=f.useCallback((x,T)=>{const z=za.current.get(x);if(z&&z!==T&&Qo(z),T){za.current.set(x,T);const q=Nn.current.get(x);q&&Zs(q,T);return}za.current.delete(x)},[Zs]),yi=f.useCallback((x,T,z)=>{const q=performance.now(),O=vs(x,z.deviceId);let me=z;if(x==="control"&&z.visualChanged){const Ee=j0(z.deviceId),Pe=jc.current.get(z.deviceId)||0,Ve=Ee?q-Ee.sentAt:Number.POSITIVE_INFINITY;Ee&&Ee.inputSeq>Pe&&Ve<=Hx&&(me={...z,inputFeedbackSeq:Ee.inputSeq,inputFeedbackMs:Math.max(0,Ve),inputFeedbackAt:q},jc.current.set(z.deviceId,Ee.inputSeq))}Bt.current.set(O,q);const ge=We.current.get(O)||{totalFrames:0,totalChangedFrames:0,sampleFrames:0,sampleChangedFrames:0,sampleStartedAt:q,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleDecoderInputBase:0,sampleDecoderOutputBase:0};x==="control"&&me.inputFeedbackMs===void 0&&ge.lastInfo?.inputFeedbackMs!==void 0&&ge.lastInfo.inputFeedbackAt!==void 0&&q-ge.lastInfo.inputFeedbackAt<=Hx&&(me={...me,inputFeedbackSeq:ge.lastInfo.inputFeedbackSeq,inputFeedbackMs:ge.lastInfo.inputFeedbackMs,inputFeedbackAt:ge.lastInfo.inputFeedbackAt}),ge.totalFrames+=1,ge.sampleFrames+=1,Gx(ge,q,me.frameSeq),me.visualChanged&&(ge.totalChangedFrames+=1,ge.sampleChangedFrames+=1),ge.lastInfo=me,We.current.set(O,ge)},[]),wi=f.useCallback((x,T)=>{yi("wall",x,T),x.kind==="live"&&ir(x.deviceId);const z=xe&&le===x.deviceId;ta.current!==x.deviceId&&!z&&(ya.current.delete(x.deviceId),ss.current.delete(x.deviceId))},[le,xe,ir,yi]),ao=f.useCallback((x,T)=>{yi("control",x,T),he(me=>me&&"");const z=Nn.current.get(x.deviceId),q=za.current.get(x.deviceId);z&&z.width>0&&z.height>0&&(q&&Zs(z,q),xa.current.set(x.deviceId,{...x,payload:new ArrayBuffer(0),byteLength:0}),ya.current.add(x.deviceId),x.deviceId===le&&(D(!0),ie(me=>me==="connecting"?"active":me)),Wn(x.deviceId));const O=kt.current;!O||!YM(O,x)||Rt(!0)},[le,Zs,Wn,yi]);f.useEffect(()=>{const x=window.setInterval(()=>{const T=performance.now(),z={};for(const[q,O]of We.current.entries()){const me=Math.max(1,T-O.sampleStartedAt);z[q]={totalFrames:O.totalFrames,totalChangedFrames:O.totalChangedFrames,framesPerSecond:O.sampleFrames*1e3/me,changedFramesPerSecond:O.sampleChangedFrames*1e3/me,averageIntervalMs:O.intervalCount>0?O.intervalSumMs/O.intervalCount:0,minIntervalMs:Number.isFinite(O.minIntervalMs)?O.minIntervalMs:0,maxIntervalMs:O.maxIntervalMs,p95IntervalMs:od(O.intervalSamplesMs,.95),intervalCount:O.intervalCount,seqGapCount:O.seqGapCount,maxSeqGap:O.maxSeqGap,decoderInputFps:Math.max(0,(Number(O.lastInfo?.decoderInputCount||0)-O.sampleDecoderInputBase)*1e3/me),decoderOutputFps:Math.max(0,(Number(O.lastInfo?.decoderOutputCount||0)-O.sampleDecoderOutputBase)*1e3/me),sampleMs:me,lastInfo:O.lastInfo},O.sampleDecoderInputBase=Number(O.lastInfo?.decoderInputCount||0),O.sampleDecoderOutputBase=Number(O.lastInfo?.decoderOutputCount||0),O.sampleChangedFrames=0,qx(O,T)}jt(z)},1e3);return()=>window.clearInterval(x)},[]);const Js=f.useCallback((x,T)=>{const z=performance.now(),q=vs(x,T.deviceId);wa.current.set(q,z),Fa.current.delete(q),x==="control"&&ba.current.delete(q);const O=$e.current.get(q)||{totalFrames:0,sampleFrames:0,sampleStartedAt:z,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleBytes:0,sampleH264Frames:0,sampleTinyFrames:0,sampleRepeatedFrames:0,sourceSendIntervalsMs:[]};if(O.totalFrames+=1,O.sampleFrames+=1,O.sampleBytes+=Math.max(0,Number(T.byteLength||0)),String(T.frameMode||T.mode||T.codec||T.mimeType||"").toLowerCase().includes("h264")){O.sampleH264Frames+=1,Number(T.byteLength||0)<=qM&&(O.sampleTinyFrames+=1);const Pe=String(T.contentHash||"");Pe&&O.lastContentHash===Pe&&(O.sampleRepeatedFrames+=1),O.lastContentHash=Pe}const Ee=Number(T.agentSendGapMs||0);Ee>0&&Ee<1e3&&Fh(O.sourceSendIntervalsMs,Ee),O.lastFrame=T,Gx(O,z,T.frameSeq),$e.current.set(q,O)},[]);f.useEffect(()=>{const x=window.setInterval(()=>{const T=performance.now(),z={};for(const[q,O]of $e.current.entries()){const me=Math.max(1,T-O.sampleStartedAt);z[q]={totalFrames:O.totalFrames,framesPerSecond:O.sampleFrames*1e3/me,averageIntervalMs:O.intervalCount>0?O.intervalSumMs/O.intervalCount:0,minIntervalMs:Number.isFinite(O.minIntervalMs)?O.minIntervalMs:0,maxIntervalMs:O.maxIntervalMs,p95IntervalMs:od(O.intervalSamplesMs,.95),intervalCount:O.intervalCount,seqGapCount:O.seqGapCount,maxSeqGap:O.maxSeqGap,averageFrameBytes:O.sampleFrames>0?O.sampleBytes/O.sampleFrames:0,tinyFrameRatio:O.sampleH264Frames>0?O.sampleTinyFrames/O.sampleH264Frames:0,repeatedFrameRatio:O.sampleH264Frames>0?O.sampleRepeatedFrames/O.sampleH264Frames:0,sourceSendAverageMs:O.sourceSendIntervalsMs.length>0?O.sourceSendIntervalsMs.reduce((ge,Ee)=>ge+Ee,0)/O.sourceSendIntervalsMs.length:0,sourceSendP95Ms:od(O.sourceSendIntervalsMs,.95),sourceSendSampleCount:O.sourceSendIntervalsMs.length,sampleMs:me,lastFrame:O.lastFrame},O.sampleBytes=0,O.sampleH264Frames=0,O.sampleTinyFrames=0,O.sampleRepeatedFrames=0,O.sourceSendIntervalsMs.length=0,qx(O,T)}pn(z)},1e3);return()=>window.clearInterval(x)},[]);const el=f.useCallback(x=>{Js("wall",x);const T=hn.current.get(x.deviceId);T&&Mm(T,x,()=>hn.current.get(x.deviceId)!==T,wi,Re.h264DecodeAcceleration).catch(()=>{})},[wi,Js,Re.h264DecodeAcceleration]),zc=f.useCallback(x=>{Js("control",x);let T=Nn.current.get(x.deviceId);T||(T=document.createElement("canvas"),T.setAttribute("aria-hidden","true"),Nn.current.set(x.deviceId,T));const z=T,q=we.current;Mm(z,x,()=>Nn.current.get(x.deviceId)!==z,ao,Ye.h264DecodeAcceleration,"interactive").catch(O=>{we.current!==q||Nn.current.get(x.deviceId)!==z||le!==x.deviceId||he(O instanceof Error?O.message:String(O||"Control H.264 decode failed"))})},[le,Ye.h264DecodeAcceleration,ao,Js]),Ud=f.useCallback(x=>{const T=Tn.current;T&&T!==x&&Qo(T),Tn.current=x,Ss.current=0,Ks.current=0,na.current=0,Rn.current=0,Qi.current=0,_e.current=0},[]),Tl=f.useCallback(()=>{const x=Tn.current,T=Se.current;if(!(!x||!T||x.width<=0||x.height<=0||_e.current!==T.layoutVersion))for(const z of T.tiles){const q=X.current.get(z.deviceId);if(!q||z.width<=0||z.height<=0)continue;const O=Math.max(1,Math.round(z.width)),me=Math.max(1,Math.round(z.height)),ge=GM,Ee=VM;(q.width!==ge||q.height!==Ee)&&(q.width=ge,q.height=Ee);const Pe=q.getContext("2d",{alpha:!1});if(Pe){Pe.imageSmoothingEnabled=!0,Pe.imageSmoothingQuality="high";try{Pe.drawImage(x,Math.round(z.x),Math.round(z.y),O,me,0,0,ge,Ee)}catch{}}}},[]),Oc=f.useCallback((x,T)=>{if(T){X.current.set(x,T),window.requestAnimationFrame(Tl),window.requestAnimationFrame(()=>Wn(x,!0));return}X.current.delete(x),Nl(x)},[Nl,Tl,Wn]),so=f.useCallback((x,T)=>{na.current=performance.now(),_e.current=Number(x.layoutVersion||0),Tl();const z=Se.current?.tiles||[],q=z.length>0?Math.round(x.byteLength/z.length):x.byteLength;for(const O of z){const me={...x,deviceId:O.deviceId,width:O.width,height:O.height,sourceWidth:O.width,sourceHeight:O.height,byteLength:q};wi(me,{...T,deviceId:O.deviceId,width:O.width,height:O.height,byteLength:q}),ta.current===O.deviceId&&Wn(O.deviceId,!0)}},[wi,Tl,Wn]),bi=f.useCallback(x=>{const T=performance.now();Ss.current<=0&&(Ss.current=T),Ks.current=T;const z=Tn.current;if(!z)return;const q=Se.current?.tiles||[],O=q.length>0?Math.round(x.byteLength/q.length):x.byteLength;for(const me of q)Js("wall",{...x,deviceId:me.deviceId,width:me.width,height:me.height,sourceWidth:me.width,sourceHeight:me.height,byteLength:O});Mm(z,x,()=>Tn.current!==z,so).catch(()=>{})},[so,Js]),Si=f.useMemo(()=>({fps:Nt,maxWidth:Xt.maxWidth,maxHeight:Xt.maxHeight,quality:Re.quality,mode:Re.frameMode,frameMode:Re.frameMode,streamPurpose:"wall",monitorSelections:ut,onFrame:el}),[Nt,el,Xt,ut,Re]),$d=f.useMemo(()=>({fps:jl,maxWidth:rs.maxWidth,maxHeight:rs.maxHeight,quality:Ye.quality,mode:Yn,frameMode:Yn,streamPurpose:"control",forceRestart:Q!=="",forceRestartToken:Q,restartReason:Q?"control-session-start":"",monitorSelections:ut,onFrame:zc}),[Q,Ye.quality,zc,jl,Yn,rs.maxHeight,rs.maxWidth,ut]),{frames:Ci,state:Rl,stats:cs,restartLive:El}=Kv(Qe?[]:dn,!Qe&&Re.autoStartLive&&dn.length>0,C,Si),{frame:Ns,layout:Ts,state:rr,stats:Ic,refreshInputs:Bc}=k0(As,Qe&&Re.autoStartLive&&As.length>0,C,{fps:20,width:1920,height:1080,tileWidth:Xt.maxWidth,tileHeight:Xt.maxHeight,captureDeviceIds:dn,monitorSelections:ut,onFrame:bi});f.useEffect(()=>{Se.current=Ts,Ts&&window.requestAnimationFrame(Tl)},[Ts,Tl]),f.useEffect(()=>{if(!Qe||rr!=="open"){Ss.current=0,Ks.current=0,na.current=0;return}const x=window.setInterval(()=>{const T=Tn.current,z=performance.now();if(!T||document.visibilityState!=="visible"||z-qt.current<Hm)return;const q=Ks.current,O=Ss.current;if(q<=0||O<=0||z-q>500)return;const me=na.current||O,ge=z-me;if(ge>=HM&&z-Qi.current>=$M){jm(T)&&(Qi.current=z,Rn.current=z);return}ge>=FM&&z-Rn.current>=UM&&t0(T)&&(Rn.current=z)},250);return()=>window.clearInterval(x)},[rr,Qe]);const{frames:lo,state:io,error:Dl,stats:Pd,restartLive:gn,reconnectLive:Ll}=Kv(Al,Al.length>0,C,$d),ji=f.useMemo(()=>{const x=new Map(Ci);if(Qe&&Ns){const T=new Map((Ts?.tiles||[]).map(q=>[q.deviceId,q])),z=Math.max(1,T.size);for(const q of As){const O=T.get(q);x.set(q,{...Ns,deviceId:q,width:O?.width||Xt.maxWidth,height:O?.height||Xt.maxHeight,sourceWidth:O?.width||Xt.maxWidth,sourceHeight:O?.height||Xt.maxHeight,byteLength:Math.round(Ns.byteLength/z)})}}for(const[T,z]of lo.entries())x.set(T,z);for(const T of As){if(!ya.current.has(T)||x.has(T))continue;const z=xa.current.get(T);z&&x.set(T,z)}return x},[Ns,Ts,lo,Xt,Qe,Ci,As,Vs]),or=qe&&Al.length>0?io:Qe?rr:Rl,cr=qe&&Al.length>0?Pd:Qe?Ic:cs;f.useCallback((x,T="browser-stale")=>{const z=El(x,T),q=gn(x,T);return z||q},[gn,El]),f.useEffect(()=>{Qe&&!qe&&Bc()},[Qe,Bc,qe]);const ki=f.useCallback((x,T,z)=>{const q=T==="control"?Nn.current.get(x)||null:hn.current.get(x)||null;if(!q||!jm(q))return!1;const O=performance.now();return Jr.current.set(vs(T,x),O),!0},[]),_l=f.useCallback(x=>{if(Yn!=="mode3-h264-hw"||!le||Y)return!1;const T=Ke.find(Pe=>Pe.deviceId===le)||un,z=String(T?.platform||"").toLowerCase(),q=["win32","windows","win32nt"].includes(z)?"mode5-lzo-delta":"mode2-lzo",O=vs("control",le),me=performance.now();Ba.current.set(O,me),wa.current.delete(O),Bt.current.delete(O),Ws.current.delete(O),ba.current.delete(O),Fa.current.delete(O),jm(Nn.current.get(le)||null),Ll([le],"control-decode-fallback"),$(q),_(`control-${q}-fallback-${le}-${Date.now()}`),D(!1),Rt(!1);const ge=x==="no first frame"||x==="control-first-frame-timeout",Ee=q==="mode5-lzo-delta"?"Mode 5":"Mode 2";return he(Pe=>Pe||(ge?`Control frame transport timeout; retrying Control with ${Ee} (${x})`:`H.264 decode failed; retrying Control with ${Ee} (${x})`)),ie("connecting"),!0},[Ke,un,le,Y,Yn,Ll]);f.useEffect(()=>{const x=qe?un:null;if(x){kt.current={deviceId:x.deviceId,monitorIndex:Ms,frameMode:Yn,startedAtEpochMs:Date.now()},Rt(le===x.deviceId&&xe);return}kt.current=null,Rt(!1)},[un?.sessionId,ue,le,xe,Yn,Ms,qe]);const ro=f.useCallback(async x=>{const T=Qe,z=k.find(ge=>ge.deviceId===x),q=Zn(ut[x],z?Pn(z):1),O=T?{fps:8,maxWidth:Xt.maxWidth,maxHeight:Xt.maxHeight,quality:60,mode:"mode2-lzo",frameMode:"mode2-lzo",streamPurpose:"atlas",monitorIndex:q}:{fps:Nt,maxWidth:Xt.maxWidth,maxHeight:Xt.maxHeight,quality:Re.quality,mode:Re.frameMode,frameMode:Re.frameMode,streamPurpose:"wall",monitorIndex:q},me=await Be(`/api/remote/devices/${encodeURIComponent(x)}/live/start`,{method:"POST",body:JSON.stringify(O)},C);if(me?.ok===!1)throw new Error(me.error||"wall-stream-start-failed");return me},[Nt,k,Xt.maxHeight,Xt.maxWidth,C,Qe,ut,Re.frameMode,Re.quality]),tl=f.useCallback(async x=>{const T=await Be(`/api/remote/devices/${encodeURIComponent(x)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:Qe?"atlas":"wall",reason:"control-active"})},C);if(T?.ok===!1)throw new Error(T.error||"wall-stream-stop-failed");return T},[C,Qe]),Rs=f.useCallback(async(x,T="control-session-stop")=>{const z=await Be(`/api/remote/devices/${encodeURIComponent(x)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:"control",reason:T})},C);if(z?.ok===!1)throw new Error(z.error||"control-stream-stop-failed");return z},[C]),Ga=f.useCallback(x=>{const T=Nn.current.get(x);T&&(Qo(T),Nn.current.delete(x));const z=za.current.get(x);z&&Qo(z),xa.current.delete(x),ya.current.delete(x),ss.current.delete(x)},[]);f.useEffect(()=>{if(!qe)return;const x=ue&&Ke.find(O=>O.deviceId===ue)||null;if(!Qt||!x)return;if(le===x.deviceId&&(H==="active"||H==="warm"||H==="connecting")){ie(O=>O==="warm"?"active":O);return}if(Ia.current===x.deviceId)return;const T=++mt.current,z=le;Ia.current=x.deviceId,(async()=>{if(z){if(ie("stopping"),await Rs(z,"control-session-switch").catch(()=>{}),T!==mt.current)return;Ga(z)}if(T!==mt.current)return;const O=vs("control",x.deviceId),me=`control-session-${T}-${x.deviceId}`;Ba.current.set(O,performance.now()),wa.current.delete(O),Bt.current.delete(O),Fa.current.delete(O),ba.current.delete(O),$(""),he(""),_(me),ce(x.deviceId),D(!1),ie("connecting"),mt.current===T&&Ia.current===x.deviceId&&(Ia.current="")})()},[Ke,ue,le,H,Qt,Ga,qe,Rs]),f.useEffect(()=>{if(!le||Ke.some(z=>z.deviceId===le))return;const x=le,T=++mt.current;ie("stopping"),Rs(x,"control-device-disconnected").catch(()=>{}).finally(()=>{T===mt.current&&(Ga(x),D(!1),_(""),$(""),he(""),ce(z=>z===x?"":z),ie("idle"))})},[Ke,le,Ga,Rs]),f.useEffect(()=>{if(vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null),!le||H==="idle"||H==="stopping"||H==="error"||qe||ae==="wall"){le&&!qe&&ae==="wall"&&ie(z=>z==="warm"||z==="active"?"active":z);return}ie(z=>z==="idle"||z==="stopping"?z:"warm");const x=le,T=++mt.current;return vt.current=window.setTimeout(()=>{vt.current=null,ie("stopping"),Rs(x,"control-session-warm-timeout").catch(()=>{}).finally(()=>{T===mt.current&&(Ga(x),D(!1),_(""),$(""),he(""),ce(z=>z===x?"":z),ie("idle"))})},PM),()=>{vt.current!==null&&(window.clearTimeout(vt.current),vt.current=null)}},[ae,le,H,Ga,qe,Rs]),f.useEffect(()=>()=>{vt.current!==null&&window.clearTimeout(vt.current)},[]),f.useEffect(()=>{const x=++Oa.current,T=xe&&(H==="active"||H==="warm")&&le?le:"",z=ta.current;if(bs.current||!T&&!z||T&&T===z)return;(async()=>{bs.current=T||z;try{if(z&&z!==T){if(await ro(z),x!==Oa.current)return;ta.current="",_a("")}if(!T||x!==Oa.current)return;if(await tl(T),x!==Oa.current){await ro(T).catch(()=>{});return}ta.current=T,_a(T),ya.current.add(T),V(z&&z!==T?`Wall paused for Control: ${T}`:"")}catch(O){x===Oa.current&&V(O instanceof Error?O.message:String(O))}finally{bs.current===(T||z)&&(bs.current="")}})()},[le,xe,H,Qe,ro,tl]);const{state:zl,sendInput:Ol,stats:vn,error:Es}=M0(os&&je,C);f.useEffect(()=>{Es&&qe&&je&&V(Es)},[je,Es,qe]);const{state:Mi,lastFrame:oo,stats:Ft,error:co}=z0(Te?.deviceId||"",Dc&&He,C);f.useEffect(()=>{if(!qe||!je||!os||!Te)return;const x=(q,O)=>{const me=q.target,ge=me?.tagName?.toLowerCase();me?.isContentEditable||ge==="input"||ge==="textarea"||ge==="select"||(q.preventDefault(),q.stopPropagation(),Ol(Te.deviceId,{type:O,monitorIndex:Zn(ut[Te.deviceId],Pn(Te)),key:q.key,code:q.code,keyCode:q.keyCode||q.which||0,location:q.location,text:q.key.length===1?q.key:"",repeat:O==="keydown"?q.repeat:!1,shiftKey:q.shiftKey,ctrlKey:q.ctrlKey,altKey:q.altKey,metaKey:q.metaKey}))},T=q=>x(q,"keydown"),z=q=>x(q,"keyup");return window.addEventListener("keydown",T),window.addEventListener("keyup",z),()=>{window.removeEventListener("keydown",T),window.removeEventListener("keyup",z)}},[os,je,ut,Te,Ol,qe]),f.useEffect(()=>{const x=()=>{document.visibilityState==="visible"&&(qt.current=performance.now())};return document.addEventListener("visibilitychange",x),window.addEventListener("pageshow",x),()=>{document.removeEventListener("visibilitychange",x),window.removeEventListener("pageshow",x)}},[]),f.useEffect(()=>{if(!le||H!=="connecting"&&H!=="active"&&H!=="warm"||io!=="open")return;const x=le,T=vs("control",x),z=window.setInterval(()=>{const q=performance.now();if(document.visibilityState!=="visible"||q-qt.current<Hm)return;const O=wa.current.get(T)||0,me=Bt.current.get(T)||0,ge=Ws.current.get(T)||0,Ee=Ba.current.get(T)||q;Ba.current.has(T)||Ba.current.set(T,Ee);const Pe=O<=0,Ve=Pe?q-Ee>ZM:q-O>Qx,zt=O>0&&(me<=0||q-me>Qx);if(!Ve&&zt){const Fn=Jr.current.get(T)||0;q-Fn>=Xx&&ki(x,"control","decoder-paint-stale");return}if(!Ve)return;const Ht=ba.current.get(T)||0;if(Ht>0){if(q-Ht<eA)return;ba.current.delete(T)}const Qn=Fa.current.get(T)||0;if(Qn>=tA){if(_l(Pe?"no first frame":"stale stream"))return;D(!1),Rt(!1),ie("error");return}if(q-ge<Zx(JM,Qn))return;gn([x],Pe?"control-first-frame-timeout":"control-receive-stale")&&(Ws.current.set(T,q),ba.current.set(T,q),Ba.current.set(T,q),Fa.current.set(T,Qn+1))},650);return()=>window.clearInterval(z)},[io,le,H,_l,ki,gn]),f.useEffect(()=>{!J||Yn!=="mode3-h264-hw"||_l(J)},[J,Yn,_l]),f.useEffect(()=>{!qe||!le||!Dl||ie(x=>x==="error"?x:"error")},[Dl,le,qe]),f.useEffect(()=>{if(Qe||Rl!=="open"||!Re.autoStartLive||dn.length===0)return;const x=window.setInterval(()=>{const T=performance.now();if(document.visibilityState!=="visible"||T-qt.current<Hm)return;const z=1e3/Math.max(1,Nt||Re.fps||1),q=Math.max(nA,Math.ceil(z*4)),O=[];for(const me of dn){if(O.length>=lA)break;const ge=vs("wall",me),Ee=wa.current.get(ge)||0;if(Ee<=0)continue;const Pe=Ws.current.get(ge)||0,Ve=Bt.current.get(ge)||0,zt=T-Ee>q,Ht=Ve<=0||T-Ve>q;if(!zt&&Ht){const Xa=Jr.current.get(ge)||0;T-Xa>=Xx&&ki(me,"wall","decoder-paint-stale");continue}if(!zt)continue;const Qn=Fa.current.get(ge)||0;T-Pe>=Zx(aA,Qn)&&O.push(me)}if(O.length>0&&El(O,"wall-frame-stale"))for(const me of O){const ge=vs("wall",me);Ws.current.set(ge,T),Fa.current.set(ge,(Fa.current.get(ge)||0)+1)}},sA);return()=>window.clearInterval(x)},[Nt,Qe,ki,El,Re.autoStartLive,Re.fps,dn,Rl]),f.useEffect(()=>{zn(Re.fps),Ha.current=Date.now(),Vn.current=0},[Re.fps,Re.frameMode,Re.adaptiveLoadShedding]),f.useEffect(()=>{VS({h264DecodeAcceleration:Re.h264DecodeAcceleration})},[Re.h264DecodeAcceleration]),f.useEffect(()=>{if(!Qt||qe||!Re.visibleOnlyLive){La([]);return}const x=Zi.current;if(!x||typeof IntersectionObserver>"u"){La(lr);return}const T=Array.from(x.querySelectorAll("[data-live-device-id]"));if(T.length===0){La([]);return}const z=new Map,q=()=>{const me=Gm(T.map(ge=>String(ge.dataset.liveDeviceId||"")).filter(ge=>(z.get(ge)||0)>0));La(ge=>qm(ge,me)?ge:me)},O=new IntersectionObserver(me=>{for(const ge of me){const Ee=String(ge.target.dataset.liveDeviceId||"");Ee&&z.set(Ee,ge.isIntersecting?ge.intersectionRatio||.01:0)}q()},{root:null,rootMargin:qn.visibleRootMargin,threshold:[0,.01,.2,.6,1]});return T.forEach(me=>O.observe(me)),q(),()=>O.disconnect()},[lr,Qt,qe,Ca,Re.visibleOnlyLive,be]),f.useEffect(()=>{if(Qe||!Re.adaptiveLoadShedding||!Re.autoStartLive||dn.length===0)return;const x=Re.fps;if(dn.length<=qn.preserveConfiguredFpsDeviceCount){Nt!==x&&(zn(x),Ha.current=Date.now(),Vn.current=0);return}if(Rl!=="open"||cs.sampleMs<500)return;const T=Date.now(),z=dn.length*Nt,q=cs.framesPerSecond,O=cs.bytesPerSecond,me=Math.max(0,...dn.map(zt=>dt[vs("wall",zt)]?.maxIntervalMs||0)),ge=Math.max(0,...dn.map(zt=>Tt[vs("wall",zt)]?.maxIntervalMs||0)),Ee=z>8&&q>0&&q<z*.72;if(q>qn.maxWallFramesPerSecond||O>qn.maxWallBytesPerSecond||me>qn.maxFrameGapMs||ge>qn.maxFrameGapMs||Ee){Vn.current=0;const zt=qn.minFps;if(T-Ha.current>=qn.downshiftCooldownMs&&Nt>zt){const Ht=Math.max(zt,SA(Nt,zt));Ht<Nt&&(zn(Ht),Ha.current=T)}return}const Ve=q<qn.maxWallFramesPerSecond*qn.lowLoadFrameRatio&&O<qn.maxWallBytesPerSecond*qn.lowLoadByteRatio;if(!Ve||Nt>=x){Ve||(Vn.current=0);return}if(!Vn.current){Vn.current=T;return}if(T-Vn.current>=qn.recoveryCooldownMs){const zt=Math.min(x,CA(Nt,x));zt>Nt&&(zn(zt),Ha.current=T,Vn.current=0)}},[Nt,Qe,Tt,dt,dn.length,dn,Rl,cs.bytesPerSecond,cs.framesPerSecond,cs.lastUpdatedAt,cs.sampleMs,Re.adaptiveLoadShedding,Re.autoStartLive,Re.frameMode,Re.fps]),f.useEffect(()=>{const x=new URLSearchParams(window.location.search).get("checkout");if(x==="success"){V("Checkout returned. Waiting for Dodo confirmation."),P();const T=window.setInterval(()=>{P()},4e3),z=window.setTimeout(()=>{window.clearInterval(T)},45e3);return()=>{window.clearInterval(T),window.clearTimeout(z)}}x==="cancelled"&&V("Checkout cancelled.")},[P]),f.useEffect(()=>{!Qt&&je&&Oe(!1),!Qt&&He&&oe(!1)},[He,je,Qt]),f.useEffect(()=>{const x=Te?.deviceId||"",T=Ze.current;if(Ze.current=x,!T||T===x)return;const z=++at.current,q=x?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:"";x&&He&&De.current.set(x,q);let O=!0;return(async()=>{try{const ge=De.current.get(T);if(De.current.delete(T),await Be(`/api/remote/devices/${encodeURIComponent(T)}/audio/stop`,{method:"POST",body:JSON.stringify(ge?{streamId:ge}:{})},C),!O||z!==at.current||!He||!x||!Qt||!xi)return;const Ee=await Be(`/api/remote/devices/${encodeURIComponent(x)}/audio/start`,{method:"POST",body:JSON.stringify({streamId:q,mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},C);if(Ee.ok===!1)throw new Error(Ee.error||"Remote audio start failed.")}catch(ge){O&&(De.current.delete(x),oe(!1),V(ge instanceof Error?ge.message:String(ge)))}})(),()=>{O=!1}},[He,Qt,C,xi,Te?.deviceId]),f.useEffect(()=>{const x=Ke.map(q=>q.deviceId),T=new Set(x),z=new Map(Ke.map(q=>[q.deviceId,q]));I(q=>{const O=q.filter(me=>T.has(me));return qm(q,O)?q:O}),W(q=>q&&T.has(q)?q:""),Z(q=>q&&T.has(q)?q:""),Wt(q=>{let O=!1;const me={};for(const[ge,Ee]of Object.entries(q)){const Pe=z.get(ge);if(!Pe){me[ge]=Ee;continue}const Ve=Zn(Ee,Pe?Pn(Pe):1);me[ge]=Ve,Ve!==Ee&&(O=!0)}return O?me:q}),Xi(q=>{const O=q.filter(me=>T.has(me));return qm(q,O)?q:O})},[Ke,cn]),f.useEffect(()=>{Mc([]),Ac(!1)},[Wn]),f.useEffect(()=>{!is||js!=="selected"||Qs.length>0||ja.length===0||Xi(ja.map(x=>x.deviceId))},[ja,Qs.length,js,is]),f.useEffect(()=>{try{localStorage.setItem(hw,as)}catch{}},[as]),f.useEffect(()=>{vA(Re)},[Re]),f.useEffect(()=>{yA(Ye)},[Ye]),f.useEffect(()=>{pA(ut)},[ut]);const ur=f.useCallback(async()=>{const x=new Set(v);x.add(Cn);try{const me=await Be("/api/remote/status",void 0,Cn);Gv({endpoint:me.agentEndpoint,endpoint_candidates:[...me.agentEndpointCandidates||[],...me.hostTargetEndpointCandidates||[]]}).forEach(ge=>x.add(ge))}catch{}const T=[...x].sort((me,ge)=>{const Ee=Pe=>{const Ve=uc(Pe);return Ve==="local"?0:Ve==="loopback"?1:2};return Ee(me)-Ee(ge)||me.localeCompare(ge)});let z=!1,q="",O=!1;try{for(const me of T){const ge=uc(me);try{if(await Be("/api/health",void 0,me),ge==="local")return w(!0),Pr(!0),me;ge==="loopback"&&(z=!0,q=me)}catch{ge==="local"&&(O=!0)}}return z?(O&&V("LiveDesk Hub is reachable on this PC, but not through the LAN address yet. Restart LiveDesk Hub to bind 5179 on the network."),w(!0),Pr(!0),q||Cn):(w(!1),Pr(!1),"")}catch{return w(!1),Pr(!1),""}},[v]),Ai=async()=>{pe("auth"),An(!1),await ur();const{error:x}=await $s.auth.signInWithOAuth({provider:"google",options:{redirectTo:window.location.origin}});x&&(V(x.message),pe(""))},qd=async()=>{pe("auth"),An(!1),await $s.auth.signOut(),pe("")};f.useEffect(()=>{if(!Pt)return;const x=z=>{z.target instanceof Element&&(z.target.closest(".account-popover, .rail-account")||An(!1))},T=z=>{z.key==="Escape"&&An(!1)};return window.addEventListener("pointerdown",x),window.addEventListener("keydown",T),()=>{window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",T)}},[Pt]);const Il=f.useCallback(async(x={})=>{const T=x.silent===!0,z=x.takeover===!0,q=x.requestLocalAccess===!0,O=q?await ur():"";if(!a?.user){T||V("Sign in before publishing this host.");return}if(!pi.current){pi.current=!0,T||pe("host");try{const me=O||C||Cn,ge=j||await Be("/api/remote/status",void 0,me);if(!ge.started)throw new Error("Start LiveDesk on this computer before syncing the server.");const Ee=`livedesk-${a.user.id}`,Pe=await Be("/api/remote/host-target",{method:"POST",body:JSON.stringify({nodeId:Ee,leaseMs:6e4,takeover:z})},me);if(!Pe.ok)throw new Error(Pe.error||"host-target-failed");const Ve=await Be("/api/remote/status",void 0,me),zt=await Be("/api/remote/registry-credentials",void 0,me),Ht=Pe.hostTarget||{},Qn=Ve.hostTargetEndpointCandidates||Ve.agentEndpointCandidates||ge.agentEndpointCandidates||[Ve.agentEndpoint||ge.agentEndpoint].filter(Boolean),{data:Xa,error:Fn}=await $s.rpc("set_livedesk_remote_host_target",{p_node_id:Ee,p_lease_id:String(Ht.leaseId||Ve.hostTargetLeaseId||crypto.randomUUID()),p_host_instance_id:Ve.hostInstanceId||Ee,p_endpoint:Ve.hostTargetEndpoint||Ve.agentEndpoint||ge.agentEndpoint,p_pair_token:zt.pairToken||"",p_manager_package:"@livedesk/hub",p_manager_version:Ve.managerVersion||"0.1.0",p_agent_package:"@livedesk/client",p_activated_at:new Date().toISOString(),p_expires_at:new Date(Date.now()+6e4).toISOString(),p_takeover:z,p_endpoint_candidates:Qn,p_pairing_pin:zt.pairingPin||Ve.pairingPin||""});if(Fn)throw Fn;const ra=Array.isArray(Xa)?Xa[0]:Xa;if(ra&&ra.ok===!1)throw new Error(ra.reason||"registry-rejected");T||(V("Host published."),(q||y)&&(w(!0),Pr(!0)),R()),d()}catch(me){if(!T){const ge=me instanceof Error?me.message:String(me);ge.includes("local network access")&&(w(!1),Pr(!1)),V(ge)}}finally{pi.current=!1,T||pe("")}}},[C,y,R,d,ur,a,j]),Gd=f.useCallback(async()=>{if(!(!j?.update?.canApply||ne==="update")){pe("update");try{const x=await Be("/api/update/apply",{method:"POST",body:JSON.stringify({})},C||Cn);if(!x.ok)throw new Error(x.error||"LiveDesk update could not be started.");const T=[...new Set((x.targets||[]).map(z=>String(z.deviceId||"").trim()).filter(Boolean))];T.length>0&&Gs({operationId:String(x.operationId||`wall-update-${Date.now()}`),targetIds:T,stage:x.state==="clients-updated"?"updated":"updating",requiresHubRestart:!!(x.managerUpdateAvailable||x.clientPackageUpdateAvailable),initialHostInstanceId:String(j.hostInstanceId||"")}),V(x.state==="hub-restart-requested"?Um:Px),R()}catch(x){V(x instanceof Error?x.message:String(x))}finally{pe("")}}},[ne,C,R,j]);f.useEffect(()=>{const x=Jn,T=j?.update;if(!x||x.stage==="updated"||!T)return;if(T.state==="failed"){Gs(O=>O?.operationId===x.operationId?null:O);return}if(T.operationId===x.operationId){!x.requiresHubRestart&&T.state==="clients-updated"&&Gs(O=>O?.operationId===x.operationId?{...O,stage:"updated"}:O);return}if(!x.requiresHubRestart)return;const z=j.started===!0&&(!x.initialHostInstanceId||j.hostInstanceId&&j.hostInstanceId!==x.initialHostInstanceId),q=T.state==="idle"&&T.updateAvailable===!1;z&&q&&Gs(O=>O?.operationId===x.operationId?{...O,stage:"updated"}:O)},[j,Jn]),f.useEffect(()=>{if(!Jn||Jn.stage!=="updated")return;const x=Jn.operationId,T=window.setTimeout(()=>{Gs(z=>z?.operationId===x?null:z)},8e3);return()=>window.clearTimeout(T)},[Jn]),f.useEffect(()=>{if(Me!==Px&&Me!==Um)return;const x=j?.update,T=String(x?.state||"");if(T==="failed"){V(x?.error||"LiveDesk update failed.");return}(T==="clients-updated"||T==="idle"&&x?.updateAvailable===!1||!j&&M&&Me===Um)&&V("")},[M,Me,j,j?.update?.error,j?.update?.state,j?.update?.updateAvailable]);const Fc=f.useCallback(async()=>{if(!ne){pe("pin");try{const T=await Be("/api/remote/pairing-pin",{method:"POST"},C||Cn);if(!T.ok)throw new Error(T.error||"pin-rotation-failed");await R(),a?.user&&await Il({silent:!0,takeover:!0}),V("New PIN published.")}catch(x){V(x instanceof Error?x.message:String(x))}finally{pe("")}}},[ne,C,Il,R,a]);f.useEffect(()=>{if(!a?.user||!j?.started||M)return;const x=r?.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY,T=r?.active===!0&&(!r.expires_at||!Number.isFinite(x)||x>Date.now()),z=!!r?.host_instance_id&&!!j.hostInstanceId&&r.host_instance_id===j.hostInstanceId;if(T&&!z)return;let q=!1;const O=()=>{if(q)return;const ge=Date.now();ge-er.current<25e3||(er.current=ge,Il({silent:!0}))};O();const me=window.setInterval(O,3e4);return()=>{q=!0,window.clearInterval(me)}},[M,Il,a?.user?.id,j?.agentEndpoint,j?.hostInstanceId,j?.started,r?.active,r?.expires_at,r?.host_instance_id]);const Ni=f.useCallback(x=>{x&&(W(x),I(T=>T.includes(x)?T:[...T,x]))},[]),dr=f.useCallback(x=>{if(!x)return;const T=$a.has(x);W(z=>T&&z===x?"":x),I(z=>T?z.filter(q=>q!==x):z.includes(x)?z:[...z,x])},[$a]),En=f.useCallback(()=>{I([]),W("")},[Zs]),Ti=f.useCallback(()=>{I(Ke.map(x=>x.deviceId)),W("")},[Ke]),In=f.useCallback((x,T)=>{const z=Ke.find(O=>O.deviceId===x);if(!z)return;const q=Pn(z);q<=1||(Wt(O=>{const ge=(Zn(O[x],q)+T+q)%q;return{...O,[x]:ge}}),qe&&(Rt(!1),Z(x)))},[Ke,qe]);f.useEffect(()=>{const x=T=>{if(qe&&je&&os)return;const z=T.target,q=z?.tagName?.toLowerCase();z?.isContentEditable||q==="input"||q==="textarea"||q==="select"||((T.ctrlKey||T.metaKey)&&T.key.toLowerCase()==="a"&&(T.preventDefault(),Ti()),T.key==="Escape"&&En())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[os,En,je,Ti,qe]);const nl=async(x,T={})=>{if(!Xs.has(x)){V(Ml);return}const z=T.focused||qe;z?(Rt(!1),Z(x)):Ni(x);try{const q=Ke.find(ge=>ge.deviceId===x),O=z?{maxWidth:Ye.maxWidth,maxHeight:Ye.maxHeight}:Xt,me=Zn(T.monitorIndex??ut[x],q?Pn(q):1);await Be(`/api/remote/devices/${encodeURIComponent(x)}/live/start`,{method:"POST",body:JSON.stringify({fps:z?Ye.fps:Nt,maxWidth:O.maxWidth,maxHeight:O.maxHeight,quality:z?Ye.quality:Re.quality,mode:z?Ye.frameMode:Re.frameMode,frameMode:z?Ye.frameMode:Re.frameMode,streamPurpose:z?"control":"wall",monitorIndex:me})},C),R()}catch(q){V(q instanceof Error?q.message:String(q))}},uo=(x,T)=>{const z=Ke.find(O=>O.deviceId===x),q=Zn(T,z?Pn(z):1);Wt(O=>({...O,[x]:q})),qe?(Rt(!1),Z(x)):Ni(x)},Bl=async x=>{if(Rt(!1),Z(x),ke("control"),!Xs.has(x)){Oe(!1),V(Ml);return}Oe(!0)},fr=async()=>{if(!Te){V("Select a workstation before playing audio.");return}if(!Qt){V(Ml);return}if(!xi){V("Selected workstation does not report remote audio support yet.");return}const x=!He,T=x?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:De.current.get(Te.deviceId);x&&T?De.current.set(Te.deviceId,T):x||De.current.delete(Te.deviceId),oe(x);try{await Be(`/api/remote/devices/${encodeURIComponent(Te.deviceId)}/audio/${x?"start":"stop"}`,{method:"POST",body:JSON.stringify({...T?{streamId:T}:{},mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},C)}catch(z){x&&De.current.delete(Te.deviceId),oe(!1),V(z instanceof Error?z.message:String(z))}},mr=async(x,T,z="files")=>{const q=x.filter(Ee=>Ee.file.size>=0);if(q.length===0)return{files:0,bytes:0};if(!Qt)throw new Error(Ml);if(T.length===0)throw new Error("Select at least one connected workstation.");const O=crypto.randomUUID(),me=q.reduce((Ee,Pe)=>Ee+Pe.file.size,0);let ge=0;Sa({id:O,status:"reading",progress:1,message:`Preparing ${q.length} ${z}`});try{for(let Ee=0;Ee<q.length;Ee+=1){const Pe=q[Ee],Ve=Pe.file,zt=Math.max(1,Math.ceil(Ve.size/Bm));for(let Ht=0;Ht<zt;Ht+=1){const Qn=Ht*Bm,Xa=Math.min(Ve.size,Qn+Bm),Fn=Ve.size===0?new ArrayBuffer(0):await Ve.slice(Qn,Xa).arrayBuffer(),ra=Ht===zt-1;Sa({id:O,status:"sending",progress:Math.max(2,Math.min(98,Math.round(ge/Math.max(1,me)*96))),message:`${Ee+1}/${q.length} ${Pe.relativePath}`});const Fs=await Be("/api/remote/files/chunk",{method:"POST",body:JSON.stringify({transferId:O,deviceIds:T,remoteDirectory:as.trim(),name:Ve.name,relativePath:Pe.relativePath,size:Ve.size,type:Ve.type,lastModified:Ve.lastModified,offset:Qn,totalBytes:Ve.size,final:ra,dataBase64:jA(Fn)})},C);if(!Fs.ok||Fs.queued!==T.length)throw new Error(Fs.error||`file-chunk-not-queued-${Fs.queued}/${T.length}`);ge+=Fn.byteLength,await new Promise(So=>window.setTimeout(So,0))}}return Sa({id:O,status:"queued",progress:100,message:`Sent ${q.length} file${q.length===1?"":"s"} to ${T.length} workstation${T.length===1?"":"s"}`}),window.setTimeout(()=>{Sa(Ee=>Ee?.id===O&&Ee.status==="queued"?null:Ee)},4500),{files:q.length,bytes:me}}catch(Ee){throw Sa({id:O,status:"failed",progress:100,message:Ee instanceof Error?Ee.message:String(Ee)}),Ee}},Ds=async x=>{const T=ja.length>0?ja.map(z=>z.deviceId):Te?[Te.deviceId]:[];try{await mr(ey(x),T)}catch(z){V(z instanceof Error?z.message:String(z))}},fo=async x=>{try{await mr(ey(x),_d)}catch(T){V(T instanceof Error?T.message:String(T))}};f.useEffect(()=>{ls.current=!1},[]);const hr=x=>{x.preventDefault(),x.stopPropagation(),On(!1),Ds(x.dataTransfer.files)},us=async(x="ltd")=>{if(!a){V("Sign in with Google before checkout.");return}if(E&&x===Et){V("LiveDesk license is already active.");return}if(E&&Et==="pro"){V("LiveDesk Pro is already active.");return}pe("checkout");try{const{data:T,error:z}=await $s.functions.invoke("dodo-checkout",{body:{plan:x}});if(z)throw z;if(!T?.checkout_url)throw new Error("Checkout function did not return a checkout URL.");window.location.assign(T.checkout_url)}catch(T){V(T instanceof Error?T.message:String(T)),pe("")}},Ls=iA(),xn=rA(),mo=Ke.length,ka=Fd.filter(x=>ji.has(x)).length,pr=or==="open"&&cr.sampleMs>0?`${cr.framesPerSecond.toFixed(1)} fps`:or,Ce=Te?qe?lo.get(Te.deviceId):ji.get(Te.deviceId):void 0,Va=Te?Zn(ut[Te.deviceId],Pn(Te)):0,gr=Te?dA(Te):[],Hc=typeof Ce?.monitorIndex=="number"?Zn(Ce.monitorIndex,Math.max(1,Ce.monitorCount||1)):Va,vr=(Ce&&Hc===Va?Mw(Ce):null)||(Te?kw(Te,Va):null),aa=vr?`${vr.width}x${vr.height}`:"-",ds=Te?vs(qe?"control":"wall",Te.deviceId):"",_t=ds?dt[ds]:void 0,yn=ds?Tt[ds]:void 0,tt=yn?.lastInfo,sa=_t&&_t.sampleMs>0?`${_t.framesPerSecond.toFixed(1)} fps`:"waiting",la=_t?`#${_t.totalFrames} / ${sa}`:"waiting",_s=yn&&yn.sampleMs>0?`${yn.framesPerSecond.toFixed(1)} fps`:"waiting",Ya=yn&&yn.sampleMs>0?`${yn.changedFramesPerSecond.toFixed(1)} fps`:"waiting",Wa=tt?`#${tt.frameSeq} ${tt.decoderLabel} q${tt.queueSize} r${tt.renderQueueSize} d${tt.droppedForLatency} f${tt.decoderFlushCount} t${tt.decoderTimestampFallbacks} io${tt.decoderInputCount}/${tt.decoderOutputCount} ${tt.visualChanged?"changed":"same"}`:"waiting",fs=tt?`${Math.round(tt.queuedForMs)}ms total / ${Math.round(tt.decodedForMs)}ms decode / ${Math.round(tt.scheduledForMs)}ms pace / ${tt.drawMs.toFixed(1)}ms draw`:"-",$c=tt?.targetPaintIntervalMs?`${tt.targetPaintIntervalMs.toFixed(1)}ms / ${(1e3/tt.targetPaintIntervalMs).toFixed(1)} fps`:"-",ho=yn?`${yn.decoderInputFps.toFixed(1)} in / ${yn.decoderOutputFps.toFixed(1)} out fps`:"waiting",po=tt?.canvasPresentation||"-",Pc=tt?`${tt.interactiveBufferWaitCount} waits / ${Math.round(tt.interactiveBufferWaitMs)}ms / ${tt.interactiveQueueDrainCount} drains`:"waiting",fn=n.framesPerSecond>0?`${n.framesPerSecond.toFixed(1)} fps / p95 ${n.p95IntervalMs.toFixed(1)}ms / max ${n.maxIntervalMs.toFixed(1)}ms / long ${n.longTaskCount} (${Math.round(n.longTaskMs)}ms)`:"waiting",Mt=_t?Ce?.frameMode==="mode5-lzo-delta"?`${sc(_t.averageFrameBytes)} avg / visual ${Ce.deltaVisualTileCount||0} + refresh ${Ce.deltaRefreshTileCount||0} / ${Ce.deltaTotalTiles||0}`:`${sc(_t.averageFrameBytes)} avg / tiny ${Math.round(_t.tinyFrameRatio*100)}% / repeat ${Math.round(_t.repeatedFrameRatio*100)}%`:"waiting",lt=_t&&_t.sourceSendSampleCount>0?`${_t.sourceSendAverageMs.toFixed(1)}ms avg / p95 ${_t.sourceSendP95Ms.toFixed(1)}ms`:"waiting",zs=Vx(_t),ia=Vx(yn),go=_t&&yn?`rx ${Yx(_t)} / paint ${Yx(yn)}`:"waiting",Ka=Ce?Ce.frameMode||Ce.mode||Ce.codec||Ce.mimeType:qe?Ye.frameMode:Re.frameMode,xr=qe?Ye.frameMode:Re.frameMode,qc=Ka!==xr?`${xr} -> ${Ka}`:xr,Fl=Ce?`${Ce.width}x${Ce.height} ${sc(Ce.byteLength)}`:qe?`${rs.maxWidth}x${rs.maxHeight}`:`${Re.maxWidth}x${Re.maxHeight}`,al=Ce?Ce.frameMode==="mode2-lzo"?"independent":`${Ce.isKeyFrame?"key":String(Ce.chunkType||"delta")}`:"-",vo=Ce&&Ce.monitorCount?`${(Ce.monitorIndex??0)+1}/${Ce.monitorCount}`:"-",Ri=Ce?[`src ${Math.round(Ce.sourceGapMs||0)}ms`,`gap ${Math.round(Ce.agentSendGapMs||0)}ms`,`tx ${Math.round(Ce.agentSendDurationMs||0)}ms`,`pace ${Math.round(Ce.agentPaceMs||0)}ms`,`queue ${Math.round(Ce.agentQueueBeforePaceMs||0)}ms`,`age ${Math.round(Ce.agentFrameAgeMs||0)}ms`,Ce.browserReceivedEpochMs&&Ce.receivedAt?`hub ${Math.max(0,Math.round(Ce.browserReceivedEpochMs-Date.parse(Ce.receivedAt)))}ms`:"",Ce.browserReceivedEpochMs&&Ce.hubPacketEpochMs?`sock ${Math.max(0,Math.round(Ce.browserReceivedEpochMs-Ce.hubPacketEpochMs))}ms`:"",Ce.droppedByAgent?`drop ${Ce.droppedByAgent}`:"",Ce.hubIngressDropped?`ingress-drop ${Ce.hubIngressDropped}`:"",Ce.hubClientDropped?`ws-drop ${Ce.hubClientDropped}`:"",Ce.captureStageMs?`capture ${Math.round(Ce.captureStageMs)}ms`:"",Ce.requestedFps?`req ${Math.round(Ce.requestedFps)}fps`:"",Ce.effectiveFps?`eff ${Math.round(Ce.effectiveFps)}fps`:"",Ce.captureAverageMs?`avg ${Math.round(Ce.captureAverageMs)}ms`:"",Ce.captureP95Ms?`p95 ${Math.round(Ce.captureP95Ms)}ms`:"",Ce.slowFrameCount?`slow ${Math.round(Ce.slowFrameCount)}`:"",Ce.captureHelperRestarts?`helper ${Math.round(Ce.captureHelperRestarts)}`:"",Ce.convertMs?`rgb565 ${Math.round(Ce.convertMs)}ms`:"",Ce.compressMs?`lzo ${Math.round(Ce.compressMs)}ms`:"",Ce.captureSourceSerial?`cap #${Ce.captureSourceSerial}`:"",Ce.captureSourceSkipped?`cap skip ${Ce.captureSourceSkipped}`:"",Ce.frameMode==="mode5-lzo-delta"?`tiles ${Ce.deltaVisualTileCount||0}+${Ce.deltaRefreshTileCount||0}/${Ce.deltaTotalTiles||0}@${Ce.deltaTileSize||0}`:"",Ce.platformProfile||Ce.hardwareEncoder||"-",Ce.atlasComposeMs?`atlas ${Ce.atlasComposeMs.toFixed(1)}ms`:"",Ce.atlasPoolStarved?`pool ${Ce.atlasPoolStarved}`:"",Ce.atlasTileCount?`tiles ${Ce.atlasReadyTiles||0}/${Ce.atlasTileCount}`:"",tt?.inputFeedbackMs!==void 0&&tt.inputFeedbackAt!==void 0&&performance.now()-tt.inputFeedbackAt<=Ux?`feedback ${Math.round(tt.inputFeedbackMs)}ms`:"",Ce.contentHash?`enc ${Ce.contentHash.slice(0,6)}`:"",tt?.visualHash?`pix ${tt.visualHash.slice(0,6)}`:""].filter(Boolean).join(" / "):"-",xo=zl==="open"?[`${vn.sentPerSecond.toFixed(1)} hz`,vn.lastInputSeq>0?`rtt ${Math.round(vn.lastRoundTripMs)}ms`:"",vn.lastInputSeq>0?`apply ${vn.lastAgentApplyMs.toFixed(1)}ms`:"",vn.droppedPerSecond>0?`drop ${vn.droppedPerSecond.toFixed(1)}/s`:"",vn.bufferedAmount>0?`buf ${sc(vn.bufferedAmount)}`:"",vn.lastInputType||"ready"].filter(Boolean).join(" / "):zl,sl=tt?.inputFeedbackMs!==void 0&&tt.inputFeedbackAt!==void 0&&performance.now()-tt.inputFeedbackAt<=Ux?`${Math.round(tt.inputFeedbackMs)}ms / input #${tt.inputFeedbackSeq||0}`:"waiting for changed frame",ms=He?[Mi,`context ${Ft.audioContextState}`,`queue ${Math.round(Ft.queuedMs)}ms`,`last ${Math.round(Ft.lastPacketAgeMs)}ms`,`accepted ${Math.round(Ft.lastAcceptedAgeMs)}ms`,`process ${Math.round(Ft.localProcessingAgeMs)}ms`,`remote ${Math.round(Ft.browserAgeMs)}/${Math.round(Ft.captureAgeMs)}ms`,`heartbeat ${Math.round(Ft.captureStatusAgeMs)}ms`,`capture ${Ft.captureAlive&&Ft.helperAlive?"alive":"down"}`,`drop ${Ft.drops}`,`resync ${Ft.resyncs}`,`restart ${Ft.automaticRestarts}`,Ft.pendingDecodes>0?`decode ${Ft.pendingDecodes}`:"",oo?`#${oo.frameSeq}`:"waiting"].filter(Boolean).join(" / "):"off",Os=Ce?`#${Ce.frameSeq} ${ah(Ce.receivedAt||Ce.capturedAt)}`:"waiting",Bn=Math.max(0,cr.bytesPerSecond*8/1e6),yr=Ns?.atlasReadyTiles??ka,Ei=Ns?.atlasTileCount??ka,Hl=yr===Ei?`${Ei} tiles`:`${yr}/${Ei} tiles`,wr=qe?`1 stream / ${pr} / ${Bn.toFixed(Bn>=10?0:1)}Mbps`:Qe?`1 stream / ${Hl} / ${pr} / ${Bn.toFixed(Bn>=10?0:1)}Mbps`:`${ka} screens / ${pr} / ${Bn.toFixed(Bn>=10?0:1)}Mbps`,Is=M?"offline":j?.started?"online":"starting",Gt=ja.length,br=qe?Te?Gi(Te):"No workstation":Gt===0?"No workstation":Gt>1?`${Gt} selected`:Te?Gi(Te):"No workstation",wn=Wr[It]||Wr.en,Sr=wn.sync||Wr.en.sync,Gc=i||U?"checking":E?Et==="pro"?"Pro LTD active":`Plus LTD ${Ke.length}/${ac}`:Od?`Free ${Ke.length}/${nc}`:`Upgrade ${Ke.length}/${nc}`,Vd=Et==="pro"?"Pro active":ne==="checkout"?"Opening":Et==="ltd"?"Pro $199":"Plus $79",yo=E?Et==="pro"?"Pro active":"Upgrade to Pro LTD":a?ne==="checkout"?"Opening checkout":Et==="ltd"?"Buy Pro LTD":"Buy Plus LTD":ne==="auth"?"Opening Google":"Sign in to buy",Di=Et==="pro"||ne==="checkout"||ne==="auth"||i||U,Ul=a?.user.user_metadata,$l=ty(Ul,"avatar_url","picture"),Qa=ty(Ul,"full_name","name")||a?.user.email||"Google",ll=Qa.slice(0,1).toUpperCase(),Yd=j?.started?"Local app ready":"Start LiveDesk",Vc=r?.active?"Published":a?"Not published":"Sign in required",Wd=/^\d{6}$/.test(j?.pairingPin||"")?j?.pairingPin:"------",Yc=ud.find(x=>x.width===Re.maxWidth&&x.height===Re.maxHeight)?.id||`${Re.maxWidth}x${Re.maxHeight}`,il=Re.atlasTileSizeMode==="auto"?"auto":Pm.find(x=>x.width===Re.atlasTileWidth&&x.height===Re.atlasTileHeight)?.id||"320x180",wo=$m.find(x=>x.width===Ye.maxWidth&&x.height===Ye.maxHeight)?.id||`${Ye.maxWidth}x${Ye.maxHeight}`,Cr=cd.find(x=>x.id===Re.frameMode)||cd[0],Kn=x=>{Sl(T=>{const z=x.frameMode?hh(x.frameMode):T.frameMode,q=x.frameMode!==void 0&&z!==T.frameMode;return{...T,...x,frameMode:z,fps:gh(x.fps??(q?Sw(z):T.fps),z)}})},Pl=x=>{const T=ud.find(z=>z.id===x);T&&Kn({maxWidth:T.width,maxHeight:T.height})},bo=x=>{if(x==="auto"){Kn({atlasTileSizeMode:"auto"});return}const T=Pm.find(z=>z.id===x);!T?.width||!T?.height||Kn({atlasTileSizeMode:"fixed",atlasTileWidth:T.width,atlasTileHeight:T.height})},hs=x=>{x.frameMode!==void 0&&($(""),he("")),wt(T=>{const z=x.frameMode?ph(x.frameMode):T.frameMode,q=x.frameMode!==void 0&&z!==T.frameMode,O=x.fps??(q?30:T.fps),me=x.maxWidth??T.maxWidth,ge=x.maxHeight??T.maxHeight;return{...T,...x,frameMode:z,fps:ts(O,20,z==="mode3-h264-hw"?60:30,z==="mode3-h264-hw"?60:30),maxWidth:z==="mode3-h264-hw"?me:Math.min(1920,me),maxHeight:z==="mode3-h264-hw"?ge:Math.min(1080,ge)}})},jr=x=>{const T=$m.find(z=>z.id===x);T&&hs({maxWidth:T.width,maxHeight:T.height})},kr=x=>{if(x==="control"){const T=un||ks;if(T&&(Rt(!1),Z(T.deviceId)),ke(x),!Qt){Oe(!1),V(Ml);return}Oe(!0);return}x==="wall"&&Zr(T=>T+1),ke(x),Oe(!1)},Wc=ne==="update"||["dispatching","waiting-for-clients","hub-restart-requested"].includes(j?.update?.state||""),Bs=f.useCallback(x=>{if(Jn?.targetIds.includes(x))return Jn.stage},[Jn]);return l.jsxs("main",{className:"app-shell",children:[l.jsxs("aside",{className:"tool-rail","aria-label":"LiveDesk tools",children:[l.jsx("div",{className:"rail-brand",title:"LiveDesk",children:l.jsx(TA,{size:25})}),l.jsx("nav",{className:"rail-tools",children:EA.map(x=>{const T=x.icon;return l.jsxs(f.Fragment,{children:[l.jsxs("button",{className:`rail-tool ${x.id==="sync-server"?"sync-server":""} ${ae===x.id?"active":""} accent-${x.accent}`,onClick:()=>x.id==="sync-server"?void Il({takeover:!0,requestLocalAccess:!0}):kr(x.id),title:x.label,type:"button",children:[l.jsx(T,{size:19}),l.jsx("span",{children:x.label})]}),x.id==="sync-server"&&j?.update?.updateAvailable&&j.update.canApply&&!Wc?l.jsxs("button",{className:"rail-update-button",onClick:()=>{Gd()},title:`Update LiveDesk to ${j.update.latestVersion||"latest"}`,type:"button",children:[l.jsx(cy,{size:16}),l.jsx("span",{children:"Update"})]}):null]},x.id)})}),l.jsxs("div",{className:"rail-footer",children:[DA.map(x=>{const T=x.icon;return l.jsxs("button",{className:`rail-tool compact ${ae===x.id?"active":""} accent-${x.accent}`,onClick:()=>kr(x.id),title:x.label,type:"button",children:[l.jsx(T,{size:18}),l.jsx("span",{children:x.label})]},x.id)}),l.jsxs("button",{className:`rail-tool compact local-settings ${gi?"active":""}`,onClick:()=>{ke("settings"),An(!1),Oe(!1),Ie(!1)},title:"Settings",type:"button",children:[l.jsx(cS,{size:18}),l.jsx("span",{children:"Settings"})]}),l.jsxs("button",{className:`rail-account ${a?"signed-in":""}`,onClick:()=>{An(x=>!x)},disabled:i||ne==="auth","aria-expanded":Pt,title:a?`Account: ${a.user.email||Qa}`:"Sign in with Google",type:"button",children:[a?$l?l.jsx("img",{src:$l,alt:Qa,referrerPolicy:"no-referrer"}):l.jsx("span",{className:"avatar-fallback",children:ll}):l.jsx(vm,{size:18}),l.jsx("span",{children:a?"Account":"Google"})]}),Pt&&l.jsxs("section",{className:"account-popover",role:"dialog","aria-label":"LiveDesk account",children:[l.jsxs("div",{className:"account-popover-head",children:[l.jsx("div",{className:"account-popover-avatar",children:a&&$l?l.jsx("img",{src:$l,alt:Qa,referrerPolicy:"no-referrer"}):a?l.jsx("span",{children:ll}):l.jsx(vm,{size:18})}),l.jsxs("div",{children:[l.jsx("strong",{children:a?Qa:"Account"}),l.jsx("p",{children:a?.user.email||"Not signed in"})]})]}),l.jsxs("dl",{className:"account-popover-facts",children:[l.jsx("dt",{children:"User"}),l.jsx("dd",{children:a?.user.email||"Not signed in"}),l.jsx("dt",{children:"Network"}),l.jsx("dd",{children:Yd}),l.jsx("dt",{children:"Access"}),l.jsx("dd",{children:Vc}),l.jsx("dt",{children:"Plan"}),l.jsx("dd",{children:Gc}),l.jsx("dt",{children:"Ads"}),l.jsx("dd",{children:Et==="free"?"Standard banner":"Removed"})]}),a?l.jsxs("button",{className:"account-popover-action",onClick:qd,disabled:ne==="auth",type:"button",children:[l.jsx(uS,{size:16}),"Logout"]}):l.jsxs("button",{className:"account-popover-action primary",onClick:Ai,disabled:ne==="auth",type:"button",children:[l.jsx(vm,{size:16}),"Sign in with Google"]})]})]})]}),l.jsxs("section",{className:`desk-stage ${nr&&!Ne?"dock-open":""} ${qe?"control-stage":""}`,children:[l.jsxs("header",{className:"topbar",children:[l.jsxs("div",{className:"brand",children:[l.jsx("span",{className:"brand-mark",children:l.jsx(nn,{size:18})}),l.jsxs("div",{children:[l.jsx("h1",{children:"LiveDesk"}),l.jsx("p",{children:"Control wall for local machines"})]})]}),is&&!qe&&l.jsxs("div",{className:"file-share-top-route","aria-label":"File distribution route",children:[l.jsxs("div",{children:[l.jsx(Jo,{size:17}),l.jsxs("span",{children:[l.jsx("small",{children:"Source"}),l.jsx("strong",{children:"LiveDesk Hub"})]})]}),l.jsx(wh,{size:15}),l.jsx(dS,{size:16}),l.jsxs("div",{children:[l.jsx("span",{className:"file-share-top-route-laptops",children:"▣ ▣ ▣"}),l.jsxs("span",{children:[l.jsx("small",{children:"Destination"}),l.jsxs("strong",{children:[vi," workstation",vi===1?"":"s"]}),l.jsx("em",{children:as.trim()||"Desktop/LiveDeskFiles"})]})]})]}),nr&&!qe&&l.jsxs("div",{className:"top-actions",children:[l.jsx(Ix,{controller:Lc,onError:V}),l.jsx("span",{className:"top-actions-divider","aria-hidden":"true"}),l.jsx("div",{className:"segmented-control","aria-label":"Screen size",children:RA.map(x=>l.jsx("button",{className:be===x.id?"active":"",onClick:()=>st(x.id),type:"button",children:x.label},x.id))})]}),qe&&l.jsx("div",{className:"top-actions",children:l.jsx(Ix,{controller:Lc,onError:V})})]}),eo?l.jsxs("section",{className:"doc-page",lang:It,dir:It==="ar"?"rtl":"ltr",children:[l.jsxs("section",{className:"doc-hero",children:[l.jsxs("div",{className:"doc-hero-copy",children:[l.jsxs("span",{className:"pricing-eyebrow",children:[l.jsx(Xm,{size:16}),wn.eyebrow]}),l.jsx("h2",{children:wn.title}),l.jsx("p",{children:wn.intro})]}),l.jsxs("label",{className:"doc-language-picker",children:[l.jsxs("span",{children:[l.jsx(fS,{size:17}),wn.languageLabel]}),l.jsx("select",{value:It,onChange:x=>Ae(x.target.value),children:_A.map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),l.jsx("section",{className:"doc-grid",children:wn.sections.map((x,T)=>{const q=[Tv,ec,sd,Sn,lc][T]||Xm;return l.jsxs("article",{className:"doc-card",children:[l.jsx("div",{className:"doc-card-icon",children:l.jsx(q,{size:19})}),l.jsxs("div",{children:[l.jsx("h3",{children:x.title}),l.jsx("p",{children:x.body}),l.jsx("ul",{children:x.points.map(O=>l.jsx("li",{children:O},O))})]})]},x.title)})}),Sr&&l.jsxs("section",{className:"doc-sync",children:[l.jsxs("div",{className:"doc-sync-head",children:[l.jsx(sd,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:Sr.title}),l.jsx("p",{children:Sr.body})]})]}),l.jsx("ul",{children:Sr.points.map(x=>l.jsx("li",{children:x},x))})]}),l.jsxs("section",{className:"doc-firewall",children:[l.jsxs("div",{className:"doc-firewall-head",children:[l.jsx(Sn,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:wn.firewall.title}),l.jsx("p",{children:wn.firewall.body})]})]}),l.jsx("ul",{children:wn.firewall.points.map(x=>l.jsx("li",{children:x},x))})]}),l.jsxs("section",{className:"doc-command-panel",children:[l.jsxs("div",{className:"doc-command-head",children:[l.jsx(ec,{size:20}),l.jsxs("div",{children:[l.jsx("h3",{children:wn.commands.title}),l.jsx("p",{children:wn.commands.body})]})]}),l.jsxs("div",{className:"doc-command-list",children:[wn.commands.manager&&l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:wn.commands.manager}),l.jsx("code",{children:xn}),l.jsx("button",{className:"icon-button",onClick:()=>Pi(xn),title:"Copy command",type:"button",children:l.jsx(Ii,{size:16})})]}),l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:wn.commands.primary}),l.jsx("code",{children:Ls}),l.jsx("button",{className:"icon-button",onClick:()=>Pi(Ls),title:"Copy command",type:"button",children:l.jsx(Ii,{size:16})})]}),l.jsxs("div",{className:"doc-command-row",children:[l.jsx("span",{children:wn.commands.slot}),l.jsx("code",{children:`${Ls} 3`}),l.jsx("button",{className:"icon-button",onClick:()=>Pi(`${Ls} 3`),title:"Copy command",type:"button",children:l.jsx(Ii,{size:16})})]})]})]})]}):Ua?l.jsx(gM,{hubUrl:C,devices:k}):is?l.jsx(yk,{hubUrl:C,devices:Ke,localFeatureAccess:Qt,upgradeNotice:Ml,notice:Me,remoteDirectory:as,onRemoteDirectoryChange:ws,targetMode:js,selectedTargetIds:Qs,onTargetModeChange:Cl,onTargetToggle:x=>Xi(T=>T.includes(x)?T.filter(z=>z!==x):[...T,x]),filePickerRef:Ld,folderPickerRef:Ji,onBrowserFileImport:x=>{fo(x)},onBrowserFolderImport:x=>{fo(x)},onNotice:V,onTransferChange:x=>{if(!x){Sa(null);return}const T=x.state==="failed"||x.state==="partially-failed"||x.state==="cancelled"?"failed":x.state==="completed"?"queued":x.state==="sending"?"sending":"reading";Sa({id:x.id,status:T,progress:x.progress,message:x.message}),["completed","partially-failed","failed","cancelled"].includes(x.state)&&window.setTimeout(()=>Sa(z=>z?.id===x.id?null:z),4500)}}):gi?l.jsx(I0,{hubUrl:C,pin:l.jsxs(B0,{children:[(M||c||F||Me)&&l.jsx("section",{className:"notice-band",children:M||c||F||Me}),l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card settings-pairing-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Pair a workstation"}),l.jsx("h3",{children:"Connect another local PC"})]}),l.jsx(an,{size:20})]}),l.jsxs("div",{className:"settings-pin-display",children:[l.jsx("span",{children:"Hub PIN"}),l.jsx("strong",{children:Wd}),l.jsxs("button",{className:"text-button ghost compact",onClick:Fc,disabled:!j?.started||ne==="pin",type:"button",children:[l.jsx(hc,{size:15}),ne==="pin"?"Creating":"New PIN"]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Hub status"}),l.jsx("h3",{children:Is})]}),l.jsx("span",{className:`settings-status-dot state-${Is}`})]}),l.jsxs("dl",{className:"settings-facts",children:[l.jsx("dt",{children:"Address"}),l.jsx("dd",{children:C||"-"}),l.jsx("dt",{children:"Connected workstations"}),l.jsxs("dd",{children:[mo,"/",cn]}),l.jsx("dt",{children:"Sync access"}),l.jsx("dd",{children:j?.started?"Local app ready":"Start Hub first"}),l.jsx("dt",{children:"Plan"}),l.jsx("dd",{children:Gc})]}),l.jsxs("div",{className:"settings-action-row",children:[l.jsxs("button",{className:"text-button primary",onClick:()=>Il({takeover:!0,requestLocalAccess:!0}),disabled:!a||ne==="host",type:"button",children:[l.jsx(sd,{size:16}),"Sync access"]}),l.jsxs("button",{className:"text-button buy",onClick:()=>us(Et==="ltd"?"pro":"ltd"),disabled:ne==="checkout"||Et==="pro",type:"button",children:[l.jsx(tc,{size:16}),Vd]})]})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"File transfer"}),l.jsx("h3",{children:"Client destination folder"})]}),l.jsx(oc,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Remote folder"}),l.jsx("input",{value:as,onChange:x=>ws(x.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),l.jsx("p",{className:"settings-help",children:"Blank uses Desktop/LiveDeskFiles on each workstation."})]})]}),wall:l.jsx(F0,{children:l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall stream"}),l.jsx("h3",{children:"Frame delivery"})]}),l.jsx(pc,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Frame mode"}),l.jsx("select",{value:Re.frameMode,onChange:x=>Kn({frameMode:hh(x.target.value)}),children:cd.map(x=>l.jsxs("option",{value:x.id,children:[x.label," - ",x.detail]},x.id))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"H.264 decode"}),l.jsx("select",{value:Re.h264DecodeAcceleration,onChange:x=>Kn({h264DecodeAcceleration:bd(x.target.value)}),children:mh.map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"FPS"}),l.jsx("select",{value:Re.fps,onChange:x=>Kn({fps:gh(x.target.value,Re.frameMode)}),children:Hh.filter(x=>x<=Cw(Re.frameMode)).map(x=>l.jsx("option",{value:x,children:x},x))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:Qe?"Atlas tile":"Resolution"}),l.jsx("select",{value:Qe?il:Yc,onChange:x=>Qe?bo(x.target.value):Pl(x.target.value),children:(Qe?Pm:ud).map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Quality"}),l.jsx("select",{value:Re.quality,onChange:x=>Kn({quality:ts(x.target.value,20,95,ma.quality)}),children:Wx.map(x=>l.jsx("option",{value:x,children:x},x))})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Wall behavior"}),l.jsx("h3",{children:"Visibility and load"})]}),l.jsx(nn,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Re.autoStartLive,onChange:x=>Kn({autoStartLive:x.target.checked})}),l.jsx("span",{children:"Auto live on connected screens"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Re.visibleOnlyLive,onChange:x=>Kn({visibleOnlyLive:x.target.checked})}),l.jsx("span",{children:"Stream visible tiles first"})]}),!Qe&&l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Re.adaptiveSizeByWall,onChange:x=>Kn({adaptiveSizeByWall:x.target.checked})}),l.jsx("span",{children:"Fit stream size to Wall"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Re.adaptiveLoadShedding,onChange:x=>Kn({adaptiveLoadShedding:x.target.checked})}),l.jsx("span",{children:"Reduce FPS under load"})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Re.showScreenStatus,onChange:x=>Kn({showScreenStatus:x.target.checked})}),l.jsx("span",{children:"Screen status overlay"})]}),l.jsxs("div",{className:"settings-summary",children:[l.jsx("span",{children:Cr.label}),l.jsxs("strong",{children:[Xt.maxWidth,"x",Xt.maxHeight," / ",Nt,"fps"]})]}),l.jsxs("button",{className:"settings-reset",onClick:()=>Sl(ma),type:"button",children:[l.jsx(rc,{size:15})," Reset Wall settings"]})]})]})}),control:l.jsx(H0,{children:l.jsxs("div",{className:"settings-section-grid",children:[l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Control stream"}),l.jsx("h3",{children:"Low-latency delivery"})]}),l.jsx(ad,{size:20})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Frame mode"}),l.jsx("select",{value:Ye.frameMode,onChange:x=>hs({frameMode:ph(x.target.value)}),children:QM.map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))})]}),Ye.frameMode==="mode3-h264-hw"&&l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"H.264 decode"}),l.jsx("select",{value:Ye.h264DecodeAcceleration,onChange:x=>hs({h264DecodeAcceleration:bd(x.target.value)}),children:mh.map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))})]}),l.jsxs("div",{className:"settings-field-grid",children:[l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"FPS"}),l.jsx("select",{value:Ye.fps,onChange:x=>hs({fps:ts(x.target.value,20,60,ha.fps)}),children:XM.filter(x=>Ye.frameMode==="mode3-h264-hw"||x<=30).map(x=>l.jsx("option",{value:x,children:x},x))})]}),l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Resolution"}),l.jsx("select",{value:wo,onChange:x=>jr(x.target.value),children:$m.filter(x=>Ye.frameMode==="mode3-h264-hw"||x.width<=1920).map(x=>l.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),Ye.frameMode==="mode3-h264-hw"&&l.jsxs("label",{className:"settings-field",children:[l.jsx("span",{children:"Quality"}),l.jsx("select",{value:Ye.quality,onChange:x=>hs({quality:ts(x.target.value,20,95,ha.quality)}),children:Wx.map(x=>l.jsx("option",{value:x,children:x},x))})]})]}),l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Control behavior"}),l.jsx("h3",{children:"Session display"})]}),l.jsx(an,{size:20})]}),l.jsxs("label",{className:"settings-toggle",children:[l.jsx("input",{type:"checkbox",checked:Ye.showScreenStatus,onChange:x=>hs({showScreenStatus:x.target.checked})}),l.jsx("span",{children:"Screen status overlay"})]}),l.jsxs("div",{className:"settings-summary control",children:[l.jsx("span",{children:Ye.frameMode==="mode5-lzo-delta"?"Mode 5 tile delta":Ye.frameMode==="mode2-lzo"?"Mode 2 RGB565":"Mode 3 H.264"}),l.jsxs("strong",{children:[rs.maxWidth,"x",rs.maxHeight," / ",jl,"fps"]})]}),l.jsxs("button",{className:"settings-reset",onClick:()=>wt(ha),type:"button",children:[l.jsx(rc,{size:15})," Reset Control settings"]})]})]})}),agent:l.jsx(U0,{hubUrl:C}),captureGallery:l.jsx(SM,{hubUrl:C,onToast:V}),advancedExtras:l.jsxs("section",{className:"settings-section-card",children:[l.jsxs("div",{className:"settings-section-heading",children:[l.jsxs("div",{children:[l.jsx("span",{children:"Connection commands"}),l.jsx("h3",{children:"Developer setup"})]}),l.jsx(Ii,{size:20})]}),l.jsxs("div",{className:"settings-command-list",children:[l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Client"}),l.jsx("code",{children:Ls}),l.jsx("button",{className:"icon-button",onClick:()=>Pi(Ls),title:"Copy client command",type:"button",children:l.jsx(Ii,{size:16})})]}),l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Slot example"}),l.jsx("code",{children:`${Ls} 3`}),l.jsx("button",{className:"icon-button",onClick:()=>Pi(`${Ls} 3`),title:"Copy slot command",type:"button",children:l.jsx(Ii,{size:16})})]}),l.jsxs("div",{className:"settings-command-row",children:[l.jsx("span",{children:"Hub"}),l.jsx("code",{children:xn}),l.jsx("button",{className:"icon-button",onClick:()=>Pi(xn),title:"Copy Hub command",type:"button",children:l.jsx(Ii,{size:16})})]})]})]})}):tr?l.jsxs("section",{className:"pricing-page",children:[l.jsxs("header",{className:"pricing-header",children:[l.jsxs("div",{children:[l.jsxs("span",{className:"pricing-eyebrow",children:[l.jsx(Qm,{size:15})," LiveDesk plans"]}),l.jsx("h2",{children:"Choose the plan that fits your wall"}),l.jsx("p",{children:"Start free with a local screen wall. Upgrade when you need ad-free monitoring, more workstations, or commercial controls."})]}),l.jsx("button",{className:"pricing-close",onClick:()=>kr("wall"),title:"Close pricing",type:"button",children:l.jsx(Kr,{size:18})})]}),(F||Me)&&l.jsx("section",{className:"notice-band",children:F||Me}),l.jsxs("div",{className:"pricing-status","aria-live":"polite",children:[l.jsx("span",{children:"Current plan"}),l.jsx("strong",{children:Rc.name}),l.jsxs("small",{children:[Ke.length,"/",KM(ar)," connected devices"]})]}),l.jsxs("div",{className:"pricing-cards","aria-label":"LiveDesk plans",children:[l.jsxs("article",{className:`pricing-plan-card ${Et==="free"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsx("span",{className:"pricing-plan-badge free",children:"Free"}),l.jsx("strong",{children:"$0"})]}),l.jsx("p",{className:"pricing-plan-audience",children:Hi.free.audience}),l.jsx("h3",{children:"Monitor your local wall"}),l.jsx("p",{children:Hi.free.note}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(Gn,{size:16})," Up to ",nc," devices"]}),l.jsxs("li",{children:[l.jsx(Gn,{size:16})," Live view and local control"]}),l.jsxs("li",{children:[l.jsx(Gn,{size:16})," Standard ad-supported banner"]})]}),l.jsx("span",{className:"pricing-current-label",children:Et==="free"?"Current plan":"Included for everyone"})]}),l.jsxs("article",{className:`pricing-plan-card featured ${Et==="ltd"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsxs("span",{className:"pricing-plan-badge plus",children:[l.jsx(mS,{size:14})," Plus"]}),l.jsx("strong",{children:"$5"})]}),l.jsx("p",{className:"pricing-plan-audience",children:Hi.ltd.audience}),l.jsx("h3",{children:"Ad-free monitoring"}),l.jsx("p",{children:"More room for personal AI workstations without the standard banner."}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(Gn,{size:16})," Up to ",ac," devices"]}),l.jsxs("li",{children:[l.jsx(Gn,{size:16})," No standard ad banner"]}),l.jsxs("li",{children:[l.jsx(Gn,{size:16})," ",Hi.ltd.ltd]})]}),l.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>us("ltd"):Ai,disabled:Et!=="free"||ne==="checkout"||ne==="auth"||i||U,type:"button",children:[l.jsx(tc,{size:16}),Et==="free"?a?"Choose Plus":"Sign in for Plus":"Plus active"]})]}),l.jsxs("article",{className:`pricing-plan-card pro ${Et==="pro"?"current":""}`,children:[l.jsxs("div",{className:"pricing-plan-topline",children:[l.jsxs("span",{className:"pricing-plan-badge pro",children:[l.jsx(Sn,{size:14})," Pro"]}),l.jsx("strong",{children:"$15"})]}),l.jsx("p",{className:"pricing-plan-audience",children:Hi.pro.audience}),l.jsx("h3",{children:"For serious operations"}),l.jsx("p",{children:"Commercial-ready monitoring for larger AI labs, studios, and teams."}),l.jsxs("ul",{children:[l.jsxs("li",{children:[l.jsx(Gn,{size:16})," 30+ workstation walls"]}),l.jsxs("li",{children:[l.jsx(Gn,{size:16})," Commercial use included"]}),l.jsxs("li",{children:[l.jsx(Gn,{size:16})," ",Hi.pro.ltd]})]}),l.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>us("pro"):Ai,disabled:Et==="pro"||ne==="checkout"||ne==="auth"||i||U,type:"button",children:[l.jsx(tc,{size:16}),Et==="pro"?"Pro active":a?"Choose Pro":"Sign in for Pro"]})]})]}),l.jsxs("section",{className:"pricing-includes",children:[l.jsxs("div",{children:[l.jsx(an,{size:17}),l.jsx("span",{children:"Screen wall"}),l.jsx("strong",{children:"120+ slots"})]}),l.jsxs("div",{children:[l.jsx(ad,{size:17}),l.jsx("span",{children:"Focused control"}),l.jsx("strong",{children:"Local-first"})]}),l.jsxs("div",{children:[l.jsx(Rv,{size:17}),l.jsx("span",{children:"Remote audio"}),l.jsx("strong",{children:"Available"})]}),l.jsxs("div",{children:[l.jsx(oc,{size:17}),l.jsx("span",{children:"File transfer"}),l.jsx("strong",{children:"Included"})]})]}),l.jsxs("p",{className:"pricing-note",children:[l.jsx(Gn,{size:15})," Commercial use requires Pro. Plus LTD is for personal, creator, and homelab use."]}),l.jsxs("button",{className:"pricing-primary-cta",onClick:a?()=>us(Et==="ltd"?"pro":"ltd"):Ai,disabled:Di,type:"button",children:[l.jsx(tc,{size:18}),yo]})]}):l.jsx(l.Fragment,{children:l.jsxs("section",{className:`monitor-layout ${Ne?"dock-collapsed":""}`,children:[l.jsxs("section",{ref:Zi,className:`screen-wall-panel ${Ed?"drop-active":""}`,onClick:x=>{x.currentTarget===x.target&&En()},onDragEnter:x=>{x.preventDefault(),On(!0)},onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy"},onDragLeave:x=>{x.currentTarget===x.target&&On(!1)},onDrop:hr,children:[Qe&&l.jsx("canvas",{ref:Ud,className:"atlas-source-canvas",width:Ts?.width||1920,height:Ts?.height||1080,"aria-hidden":"true"}),qe?l.jsx("section",{className:"control-focus",children:l.jsxs("div",{className:"control-wall",children:[Te&&gr.length>1&&l.jsx("div",{className:"control-monitor-tabs","aria-label":"Select monitor",children:gr.map(x=>l.jsxs("button",{className:x.index===Va?"active":"",onClick:()=>uo(Te.deviceId,x.index),title:fA(x),type:"button",children:[l.jsx("span",{children:x.name||`Display ${x.index+1}`}),x.width>0&&x.height>0&&l.jsxs("small",{children:[x.width,"x",x.height]})]},x.index))}),Te?l.jsx(Km,{device:Te,frame:Ce,selected:!1,controlEnabled:os&&je,showStatus:Ye.showScreenStatus,monitorIndex:Zn(ut[Te.deviceId],Pn(Te)),monitorCount:Pn(Te),onSelect:()=>{},onFocusDevice:()=>Z(Te.deviceId),onOpenControl:()=>Bl(Te.deviceId),onCycleMonitor:x=>In(Te.deviceId,x),onCanvasReady:_c,sendInput:Ol,presentationReady:Kt},Te.deviceId):l.jsxs("div",{className:"control-empty",children:[l.jsx(an,{size:30}),l.jsx("strong",{children:"No workstation"}),l.jsx("span",{children:"Open a workstation from the Wall."})]}),Te&&!Kt&&l.jsxs("div",{className:"control-connection-overlay",role:"status","aria-live":"polite",children:[H!=="error"&&l.jsx("span",{className:"control-connection-spinner","aria-hidden":"true"}),l.jsx("strong",{children:H==="error"?"Connection failed":"Connecting"}),l.jsx("small",{children:H==="error"?Dl||J?`Control stream: ${Dl||J}`:"No control frame was received. Reopen Control to retry.":Dl||J?`Control stream: ${Dl||J}`:or==="open"?"Preparing the first control frame":"Opening the Control stream"})]})]})}):Qe?l.jsx("div",{className:`screen-wall atlas-slot-wall size-${be}`,onClick:x=>{x.currentTarget===x.target&&En()},children:Ca.map((x,T)=>x?l.jsx(Km,{device:x,frame:ji.get(x.deviceId),selected:$a.has(x.deviceId),controlEnabled:!1,showStatus:Re.showScreenStatus,monitorIndex:Zn(ut[x.deviceId],Pn(x)),monitorCount:Pn(x),onSelect:()=>dr(x.deviceId),onFocusDevice:()=>Ni(x.deviceId),onOpenControl:()=>Bl(x.deviceId),onCycleMonitor:z=>In(x.deviceId,z),onCanvasReady:Oc,sendInput:Ol,updateIndicator:Bs(x.deviceId),presentationReady:Re.autoStartLive&&qa.includes(x.deviceId)?mi.has(x.deviceId):void 0,showPresentationSpinner:Re.autoStartLive&&qa.includes(x.deviceId)},x.deviceId):l.jsx(ay,{index:T},`slot-${T}`))}):l.jsx("div",{className:`screen-wall size-${be}`,onClick:x=>{x.currentTarget===x.target&&En()},children:Ca.map((x,T)=>x?l.jsx(Km,{device:x,frame:ji.get(x.deviceId),selected:$a.has(x.deviceId),controlEnabled:os&&je&&Te?.deviceId===x.deviceId,showStatus:Re.showScreenStatus,monitorIndex:Zn(ut[x.deviceId],Pn(x)),monitorCount:Pn(x),onSelect:()=>dr(x.deviceId),onFocusDevice:()=>Ni(x.deviceId),onOpenControl:()=>Bl(x.deviceId),onCycleMonitor:z=>In(x.deviceId,z),onCanvasReady:Hd,sendInput:Ol,updateIndicator:Bs(x.deviceId),presentationReady:Re.autoStartLive&&qa.includes(x.deviceId)?mi.has(x.deviceId):void 0,showPresentationSpinner:Re.autoStartLive&&qa.includes(x.deviceId)},x.deviceId):l.jsx(ay,{index:T},`slot-${T}`))}),l.jsx(OA,{visible:Id&&!qe})]}),!gi&&l.jsxs("aside",{className:`right-dock actions-mode ${Ne?"collapsed":""}`,"aria-label":"LiveDesk tools",children:[l.jsx("button",{className:"dock-toggle",onClick:()=>Ie(x=>!x),"aria-label":Ne?"Show control panel":"Hide control panel",title:Ne?"Show control panel":"Hide control panel",type:"button",children:Ne?l.jsx(uy,{size:18}):l.jsx(bh,{size:18})}),!Ne&&l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"action-dock",children:[l.jsxs("div",{className:"action-context",children:[l.jsx("span",{children:qe?"Control target":Gt>0?"Selection":"No selection"}),l.jsx("strong",{children:br})]}),l.jsx("input",{ref:Nc,className:"hidden-file-input",type:"file",multiple:!0,onChange:x=>{x.currentTarget.files&&Ds(x.currentTarget.files),x.currentTarget.value=""}}),(M||Me)&&l.jsx("div",{className:"notice-band compact",children:l.jsx("span",{children:M||Me})}),l.jsxs("div",{className:"action-grid",children:[l.jsxs("button",{className:"action-tile primary",onClick:()=>Te&&nl(Te.deviceId),disabled:!sr,type:"button",children:[l.jsx(Ev,{size:21}),l.jsx("span",{children:"Live"})]}),l.jsxs("button",{className:`action-tile ${je?"active":""}`,onClick:()=>Oe(x=>!x),disabled:!os,title:no?"Allow Accessibility for the terminal app that starts LiveDesk, then restart the Mac client.":os?"Remote keyboard and mouse control":"Remote control is not available on this workstation",type:"button",children:[l.jsx(ad,{size:21}),l.jsx("span",{children:zl!=="idle"?zl:"Control"})]}),l.jsxs("button",{className:`action-tile ${He?"active":""}`,onClick:fr,disabled:!Dc,type:"button",title:xi?"Remote PC audio":"Remote audio is not supported by this workstation yet",children:[l.jsx(Rv,{size:21}),l.jsx("span",{children:He&&Mi!=="idle"?Mi:"Audio"})]}),l.jsxs("button",{className:"action-tile",onClick:()=>Nc.current?.click(),disabled:!Qt||(qe?!Te:ja.length===0),type:"button",title:"File transfer",children:[l.jsx(oc,{size:21}),l.jsx("span",{children:"Files"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Reboot",children:[l.jsx(rc,{size:21}),l.jsx("span",{children:"Reboot"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Power",children:[l.jsx(hS,{size:21}),l.jsx("span",{children:"Power"})]}),l.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Terminal",children:[l.jsx(ec,{size:21}),l.jsx("span",{children:"Shell"})]})]})]}),Te&&Pa&&l.jsxs("section",{className:"side-panel selected-panel",children:[l.jsxs("div",{className:"machine-detail-head",children:[l.jsxs("div",{className:"panel-title",children:[l.jsx(an,{size:17}),l.jsx("h2",{children:"Machine detail"})]}),l.jsx("span",{className:`machine-health state-${Pa.state}`,children:Pa.label})]}),l.jsxs("div",{className:"machine-title",children:[l.jsx("strong",{children:Gi(Te)}),l.jsx("span",{children:Pa.role})]}),l.jsx("div",{className:"machine-metric-grid",children:Pa.metrics.map(x=>l.jsxs("article",{className:`machine-metric state-${x.state}`,children:[l.jsx("span",{children:x.label}),l.jsx("strong",{children:x.value}),l.jsx("small",{children:x.detail}),x.ratio!==void 0&&l.jsx("i",{children:l.jsx("b",{style:{width:`${Math.round(x.ratio*100)}%`}})})]},x.id))}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(nn,{size:15}),l.jsx("span",{children:"Stream"})]}),l.jsxs("dl",{className:"facts compact",children:[l.jsx("dt",{children:"Frames"}),l.jsx("dd",{children:la}),l.jsx("dt",{children:qe?"Control RX":Qe?"Atlas RX":"Wall RX"}),l.jsx("dd",{children:wr}),l.jsx("dt",{children:"Painted"}),l.jsx("dd",{children:_s}),l.jsx("dt",{children:qe?"Encoded changes":"Visual samples"}),l.jsx("dd",{children:Ya}),l.jsx("dt",{children:"Decoder"}),l.jsx("dd",{children:Wa}),l.jsx("dt",{children:"Decoder IO"}),l.jsx("dd",{children:ho}),l.jsx("dt",{children:"Canvas"}),l.jsx("dd",{children:po}),l.jsx("dt",{children:"Control buffer"}),l.jsx("dd",{children:Pc}),l.jsx("dt",{children:"Browser RAF"}),l.jsx("dd",{children:fn}),l.jsx("dt",{children:"Latency"}),l.jsx("dd",{children:fs}),l.jsx("dt",{children:"Cadence"}),l.jsx("dd",{children:$c}),l.jsx("dt",{children:"Source send"}),l.jsx("dd",{children:lt}),l.jsx("dt",{children:"Packet mix"}),l.jsx("dd",{children:Mt}),l.jsx("dt",{children:"Receive gap"}),l.jsx("dd",{children:zs}),l.jsx("dt",{children:"Paint gap"}),l.jsx("dd",{children:ia}),l.jsx("dt",{children:"Seq gap"}),l.jsx("dd",{children:go}),l.jsx("dt",{children:"Selected"}),l.jsx("dd",{children:Os}),l.jsx("dt",{children:"Requested"}),l.jsx("dd",{children:qc}),l.jsx("dt",{children:"Mode"}),l.jsx("dd",{children:Ka}),l.jsx("dt",{children:"Chunk"}),l.jsx("dd",{children:al}),l.jsx("dt",{children:"Size"}),l.jsx("dd",{children:Fl}),l.jsx("dt",{children:"Native"}),l.jsx("dd",{children:aa}),l.jsx("dt",{children:"Monitor"}),l.jsx("dd",{children:vo}),l.jsx("dt",{children:"Source"}),l.jsx("dd",{children:Ri}),l.jsx("dt",{children:"Input"}),l.jsx("dd",{children:xo}),l.jsx("dt",{children:"Audio"}),l.jsx("dd",{children:ms}),qe&&l.jsxs(l.Fragment,{children:[l.jsx("dt",{children:"Visual feedback"}),l.jsx("dd",{children:sl})]})]})]}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(ec,{size:15}),l.jsx("span",{children:"Local services"})]}),l.jsx("div",{className:"tool-probe-list",children:Pa.tools.map(x=>l.jsxs("span",{className:`tool-probe state-${x.status}`,children:[l.jsx("b",{children:x.label}),l.jsx("em",{children:x.detail})]},x.id))})]}),l.jsxs("section",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(fd,{size:15}),l.jsx("span",{children:"Workload"})]}),l.jsxs("div",{className:"workload-card",children:[l.jsx("strong",{children:Pa.taskLabel}),l.jsx("span",{children:Pa.taskStatus}),Pa.taskSummary&&l.jsx("p",{children:Pa.taskSummary})]})]}),l.jsxs("div",{className:"machine-section",children:[l.jsxs("div",{className:"machine-section-title",children:[l.jsx(Tv,{size:15}),l.jsx("span",{children:"System"})]}),l.jsxs("dl",{className:"facts compact",children:[l.jsx("dt",{children:"Platform"}),l.jsxs("dd",{children:[Te.platform||"-"," ",Te.arch||""]}),l.jsx("dt",{children:"Release"}),l.jsx("dd",{children:pa(Te.status,"release")||"-"}),l.jsx("dt",{children:"Uptime"}),l.jsx("dd",{children:Aw(Ut(Te.status,"uptimeSec"))}),l.jsx("dt",{children:"Last seen"}),l.jsx("dd",{children:ah(Te.lastSeenAt||Te.connectedAt)}),l.jsx("dt",{children:"Agent"}),l.jsx("dd",{children:Te.agentVersion||"-"}),l.jsx("dt",{children:"Address"}),l.jsx("dd",{children:Te.remoteAddress||"-"})]})]}),co&&l.jsx("p",{className:"panel-warning",children:co}),l.jsxs("button",{className:"text-button full",onClick:()=>Te&&nl(Te.deviceId),disabled:!sr,type:"button",children:[l.jsx(Ev,{size:16}),"Start live"]})]})]})]})]})})]}),Cs&&l.jsxs("aside",{className:`transfer-bar state-${Cs.status}`,"aria-live":"polite",children:[l.jsx("span",{className:"transfer-bar-icon","aria-hidden":"true",children:Cs.status==="queued"?l.jsx(Gn,{size:18}):Cs.status==="failed"?l.jsx(Kr,{size:18}):l.jsx(ly,{size:18})}),l.jsxs("div",{className:"transfer-bar-copy",children:[l.jsx("p",{children:Cs.message}),l.jsx("div",{className:"transfer-bar-track",children:l.jsx("span",{style:{width:`${Math.max(0,Math.min(100,Cs.progress))}%`}})})]}),l.jsxs("strong",{children:[Math.max(0,Math.min(100,Cs.progress)),"%"]})]})]})}SS.createRoot(document.getElementById("root")).render(l.jsx(f.StrictMode,{children:l.jsx(IA,{})}));